Update LMS and LMOTS to use TEST_EQUAL
Signed-off-by: Raef Coles <raef.coles@arm.com>
This commit is contained in:
parent
90e13fc3c6
commit
810612e14e
2 changed files with 31 additions and 31 deletions
|
@ -38,12 +38,12 @@ void lmots_sign_verify_test ( data_t *msg, data_t *key_id, int leaf_id,
|
|||
mbedtls_lmots_public_init( &pub_ctx );
|
||||
mbedtls_lmots_private_init( &priv_ctx );
|
||||
|
||||
TEST_ASSERT( mbedtls_lmots_generate_private_key(&priv_ctx, MBEDTLS_LMOTS_SHA256_N32_W8,
|
||||
key_id->x, leaf_id, seed->x, seed->len ) == 0 );
|
||||
TEST_ASSERT( mbedtls_lmots_calculate_public_key(&pub_ctx, &priv_ctx) == 0 );
|
||||
TEST_ASSERT( mbedtls_lmots_sign(&priv_ctx, &mbedtls_test_rnd_std_rand, NULL,
|
||||
msg->x, msg->len, sig, sizeof(sig), NULL ) == 0 );
|
||||
TEST_ASSERT( mbedtls_lmots_verify(&pub_ctx, msg->x, msg->len, sig, sizeof(sig)) == 0 );
|
||||
TEST_EQUAL( mbedtls_lmots_generate_private_key(&priv_ctx, MBEDTLS_LMOTS_SHA256_N32_W8,
|
||||
key_id->x, leaf_id, seed->x, seed->len ), 0 );
|
||||
TEST_EQUAL( mbedtls_lmots_calculate_public_key(&pub_ctx, &priv_ctx), 0 );
|
||||
TEST_EQUAL( mbedtls_lmots_sign(&priv_ctx, &mbedtls_test_rnd_std_rand, NULL,
|
||||
msg->x, msg->len, sig, sizeof(sig), NULL ), 0 );
|
||||
TEST_EQUAL( mbedtls_lmots_verify(&pub_ctx, msg->x, msg->len, sig, sizeof(sig)), 0 );
|
||||
|
||||
exit:
|
||||
mbedtls_lmots_public_free( &pub_ctx );
|
||||
|
@ -61,12 +61,12 @@ void lmots_sign_verify_null_msg_test ( data_t *key_id, int leaf_id, data_t *seed
|
|||
mbedtls_lmots_public_init( &pub_ctx );
|
||||
mbedtls_lmots_private_init( &priv_ctx );
|
||||
|
||||
TEST_ASSERT( mbedtls_lmots_generate_private_key(&priv_ctx, MBEDTLS_LMOTS_SHA256_N32_W8,
|
||||
key_id->x, leaf_id, seed->x, seed->len ) == 0 );
|
||||
TEST_ASSERT( mbedtls_lmots_calculate_public_key(&pub_ctx, &priv_ctx) == 0 );
|
||||
TEST_ASSERT( mbedtls_lmots_sign(&priv_ctx, &mbedtls_test_rnd_std_rand, NULL,
|
||||
NULL, 0, sig, sizeof(sig), NULL ) == 0 );
|
||||
TEST_ASSERT( mbedtls_lmots_verify(&pub_ctx, NULL, 0, sig, sizeof(sig)) == 0 );
|
||||
TEST_EQUAL( mbedtls_lmots_generate_private_key(&priv_ctx, MBEDTLS_LMOTS_SHA256_N32_W8,
|
||||
key_id->x, leaf_id, seed->x, seed->len ), 0 );
|
||||
TEST_EQUAL( mbedtls_lmots_calculate_public_key(&pub_ctx, &priv_ctx), 0 );
|
||||
TEST_EQUAL( mbedtls_lmots_sign(&priv_ctx, &mbedtls_test_rnd_std_rand, NULL,
|
||||
NULL, 0, sig, sizeof(sig), NULL ), 0 );
|
||||
TEST_EQUAL( mbedtls_lmots_verify(&pub_ctx, NULL, 0, sig, sizeof(sig)), 0 );
|
||||
|
||||
exit:
|
||||
mbedtls_lmots_public_free( &pub_ctx );
|
||||
|
@ -150,10 +150,10 @@ void lmots_import_export_test ( data_t * pub_key )
|
|||
size_t exported_pub_key_len;
|
||||
|
||||
mbedtls_lmots_public_init( &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,
|
||||
TEST_EQUAL( mbedtls_lmots_import_public_key( &ctx, pub_key->x, pub_key->len ), 0 );
|
||||
TEST_EQUAL( mbedtls_lmots_export_public_key( &ctx, exported_pub_key,
|
||||
sizeof( exported_pub_key ),
|
||||
&exported_pub_key_len ) == 0 );
|
||||
&exported_pub_key_len ), 0 );
|
||||
|
||||
ASSERT_COMPARE( pub_key->x, pub_key->len,
|
||||
exported_pub_key, exported_pub_key_len );
|
||||
|
@ -170,17 +170,17 @@ void lmots_reuse_test ( data_t *msg, data_t *key_id, int leaf_id, data_t *seed )
|
|||
unsigned char sig[MBEDTLS_LMOTS_SIG_LEN(MBEDTLS_LMOTS_SHA256_N32_W8)];
|
||||
|
||||
mbedtls_lmots_private_init( &ctx );
|
||||
TEST_ASSERT( mbedtls_lmots_generate_private_key(&ctx, MBEDTLS_LMOTS_SHA256_N32_W8,
|
||||
TEST_EQUAL( mbedtls_lmots_generate_private_key(&ctx, MBEDTLS_LMOTS_SHA256_N32_W8,
|
||||
key_id->x, leaf_id, seed->x,
|
||||
seed->len ) == 0 );
|
||||
TEST_ASSERT( mbedtls_lmots_sign(&ctx, mbedtls_test_rnd_std_rand, NULL,
|
||||
msg->x, msg->len, sig, sizeof( sig ), NULL ) == 0 );
|
||||
seed->len ), 0 );
|
||||
TEST_EQUAL( mbedtls_lmots_sign(&ctx, mbedtls_test_rnd_std_rand, NULL,
|
||||
msg->x, msg->len, sig, sizeof( sig ), NULL ), 0 );
|
||||
|
||||
/* Running another sign operation should fail, since the key should now have
|
||||
* been erased.
|
||||
*/
|
||||
TEST_ASSERT( mbedtls_lmots_sign(&ctx, mbedtls_test_rnd_std_rand, NULL,
|
||||
msg->x, msg->len, sig, sizeof( sig ), NULL ) != 0 );
|
||||
TEST_EQUAL( mbedtls_lmots_sign(&ctx, mbedtls_test_rnd_std_rand, NULL,
|
||||
msg->x, msg->len, sig, sizeof( sig ), NULL ), MBEDTLS_ERR_LMS_BAD_INPUT_DATA );
|
||||
|
||||
exit:
|
||||
mbedtls_lmots_private_free( &ctx );
|
||||
|
@ -200,11 +200,11 @@ void lmots_signature_leak_test ( data_t *msg, data_t *key_id, int leaf_id,
|
|||
memset( sig, 0x7E, sizeof( sig ) );
|
||||
|
||||
mbedtls_lmots_private_init( &ctx );
|
||||
TEST_ASSERT( mbedtls_lmots_generate_private_key(&ctx, MBEDTLS_LMOTS_SHA256_N32_W8,
|
||||
TEST_EQUAL( mbedtls_lmots_generate_private_key(&ctx, MBEDTLS_LMOTS_SHA256_N32_W8,
|
||||
key_id->x, leaf_id, seed->x,
|
||||
seed->len ) == 0 );
|
||||
TEST_ASSERT( mbedtls_lmots_sign(&ctx, mbedtls_test_rnd_std_rand, NULL,
|
||||
msg->x, msg->len, sig, sizeof( sig ), NULL ) == 0 );
|
||||
seed->len ), 0 );
|
||||
TEST_EQUAL( mbedtls_lmots_sign(&ctx, mbedtls_test_rnd_std_rand, NULL,
|
||||
msg->x, msg->len, sig, sizeof( sig ), NULL ), 0 );
|
||||
|
||||
exit:
|
||||
mbedtls_lmots_private_free( &ctx );
|
||||
|
|
|
@ -155,9 +155,9 @@ void lms_import_export_test ( data_t * pub_key )
|
|||
uint8_t exported_pub_key[MBEDTLS_LMS_PUBLIC_KEY_LEN(MBEDTLS_LMS_SHA256_M32_H10)];
|
||||
|
||||
mbedtls_lms_public_init(&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 );
|
||||
TEST_EQUAL( mbedtls_lms_import_public_key( &ctx, pub_key->x, pub_key->len ), 0 );
|
||||
TEST_EQUAL( 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(MBEDTLS_LMS_SHA256_M32_H10),
|
||||
exported_pub_key, MBEDTLS_LMS_PUBLIC_KEY_LEN(MBEDTLS_LMS_SHA256_M32_H10) );
|
||||
|
|
Loading…
Reference in a new issue