mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-07-29 11:41:15 +03:00
Update LMS API to support multiple parameter sets
Parameterise macros to allow variation of sizes Signed-off-by: Raef Coles <raef.coles@arm.com>
This commit is contained in:
@ -17,7 +17,7 @@ void lmots_sign_verify_test ( data_t * msg )
|
||||
{
|
||||
mbedtls_lmots_public_t pub_ctx;
|
||||
mbedtls_lmots_private_t priv_ctx;
|
||||
unsigned char sig[MBEDTLS_LMOTS_SIG_LEN];
|
||||
unsigned char sig[MBEDTLS_LMOTS_SIG_LEN(MBEDTLS_LMOTS_SHA256_N32_W8)];
|
||||
mbedtls_entropy_context entropy_ctx;
|
||||
mbedtls_ctr_drbg_context drbg_ctx;
|
||||
uint8_t seed[16];
|
||||
@ -67,13 +67,14 @@ exit:
|
||||
void lmots_import_export_test ( data_t * pub_key )
|
||||
{
|
||||
mbedtls_lmots_public_t ctx;
|
||||
uint8_t exported_pub_key[MBEDTLS_LMOTS_PUBLIC_KEY_LEN];
|
||||
uint8_t exported_pub_key[MBEDTLS_LMOTS_PUBLIC_KEY_LEN(MBEDTLS_LMOTS_SHA256_N32_W8)];
|
||||
|
||||
mbedtls_lmots_init_public( &ctx );
|
||||
TEST_ASSERT( mbedtls_lmots_import_public_key( &ctx, pub_key->x, pub_key->len ) == 0 );
|
||||
TEST_ASSERT( mbedtls_lmots_export_public_key( &ctx, exported_pub_key, sizeof( exported_pub_key ), NULL ) == 0 );
|
||||
|
||||
TEST_ASSERT( memcmp( pub_key->x, exported_pub_key, MBEDTLS_LMOTS_PUBLIC_KEY_LEN ) == 0 );
|
||||
TEST_ASSERT( memcmp( pub_key->x, exported_pub_key,
|
||||
MBEDTLS_LMOTS_PUBLIC_KEY_LEN(MBEDTLS_LMOTS_SHA256_N32_W8) ) == 0 );
|
||||
|
||||
exit:
|
||||
mbedtls_lmots_free_public( &ctx );
|
||||
@ -84,7 +85,7 @@ exit:
|
||||
void lmots_reuse_test ( data_t * msg )
|
||||
{
|
||||
mbedtls_lmots_private_t ctx;
|
||||
unsigned char sig[MBEDTLS_LMOTS_SIG_LEN];
|
||||
unsigned char sig[MBEDTLS_LMOTS_SIG_LEN(MBEDTLS_LMOTS_SHA256_N32_W8)];
|
||||
mbedtls_entropy_context entropy_ctx;
|
||||
mbedtls_ctr_drbg_context drbg_ctx;
|
||||
uint8_t seed[16];
|
||||
|
@ -15,7 +15,7 @@ void lms_sign_verify_test ( data_t * msg )
|
||||
{
|
||||
mbedtls_lms_public_t pub_ctx;
|
||||
mbedtls_lms_private_t priv_ctx;
|
||||
unsigned char sig[MBEDTLS_LMS_SIG_LEN];
|
||||
unsigned char sig[MBEDTLS_LMS_SIG_LEN(MBEDTLS_LMS_SHA256_M32_H10, MBEDTLS_LMOTS_SHA256_N32_W8)];
|
||||
mbedtls_entropy_context entropy_ctx;
|
||||
mbedtls_ctr_drbg_context drbg_ctx;
|
||||
uint8_t seed[16];
|
||||
@ -76,15 +76,15 @@ exit:
|
||||
void lms_import_export_test ( data_t * pub_key )
|
||||
{
|
||||
mbedtls_lms_public_t ctx;
|
||||
uint8_t exported_pub_key[MBEDTLS_LMS_PUBLIC_KEY_LEN];
|
||||
uint8_t exported_pub_key[MBEDTLS_LMS_PUBLIC_KEY_LEN(MBEDTLS_LMS_SHA256_M32_H10)];
|
||||
|
||||
mbedtls_lms_init_public(&ctx);
|
||||
TEST_ASSERT( mbedtls_lms_import_public_key( &ctx, pub_key->x, pub_key->len ) == 0 );
|
||||
TEST_ASSERT( mbedtls_lms_export_public_key( &ctx, exported_pub_key,
|
||||
sizeof(exported_pub_key), NULL ) == 0 );
|
||||
|
||||
ASSERT_COMPARE( pub_key->x, MBEDTLS_LMS_PUBLIC_KEY_LEN,
|
||||
exported_pub_key, MBEDTLS_LMS_PUBLIC_KEY_LEN );
|
||||
ASSERT_COMPARE( pub_key->x, MBEDTLS_LMS_PUBLIC_KEY_LEN(MBEDTLS_LMS_SHA256_M32_H10),
|
||||
exported_pub_key, MBEDTLS_LMS_PUBLIC_KEY_LEN(MBEDTLS_LMS_SHA256_M32_H10) );
|
||||
|
||||
exit:
|
||||
mbedtls_lms_free_public( &ctx );
|
||||
|
Reference in New Issue
Block a user