Rename LMS and LMOTS init/free functions
To match convention Signed-off-by: Raef Coles <raef.coles@arm.com>
This commit is contained in:
parent
29117d2e4e
commit
be3bdd8240
@ -242,7 +242,7 @@ typedef struct {
|
||||
* \param ctx The uninitialized LMS context that will then be
|
||||
* initialized.
|
||||
*/
|
||||
void mbedtls_lms_init_public( mbedtls_lms_public_t *ctx );
|
||||
void mbedtls_lms_public_init( mbedtls_lms_public_t *ctx );
|
||||
|
||||
/**
|
||||
* \brief This function uninitializes an LMS public context
|
||||
@ -250,7 +250,7 @@ void mbedtls_lms_init_public( mbedtls_lms_public_t *ctx );
|
||||
* \param ctx The initialized LMS context that will then be
|
||||
* uninitialized.
|
||||
*/
|
||||
void mbedtls_lms_free_public( mbedtls_lms_public_t *ctx );
|
||||
void mbedtls_lms_public_free( mbedtls_lms_public_t *ctx );
|
||||
|
||||
/**
|
||||
* \brief This function imports an LMS public key into a
|
||||
@ -304,7 +304,7 @@ int mbedtls_lms_verify( const mbedtls_lms_public_t *ctx,
|
||||
*
|
||||
* \param ctx The uninitialized LMS private context that will
|
||||
* then be initialized. */
|
||||
void mbedtls_lms_init_private( mbedtls_lms_private_t *ctx );
|
||||
void mbedtls_lms_private_init( mbedtls_lms_private_t *ctx );
|
||||
|
||||
/**
|
||||
* \brief This function uninitializes an LMS private context
|
||||
@ -312,7 +312,7 @@ void mbedtls_lms_init_private( mbedtls_lms_private_t *ctx );
|
||||
* \param ctx The initialized LMS private context that will then
|
||||
* be uninitialized.
|
||||
*/
|
||||
void mbedtls_lms_free_private( mbedtls_lms_private_t *ctx );
|
||||
void mbedtls_lms_private_free( mbedtls_lms_private_t *ctx );
|
||||
|
||||
/**
|
||||
* \brief This function generates an LMS private key, and
|
||||
|
@ -396,14 +396,14 @@ int mbedtls_lms_error_from_psa( psa_status_t status )
|
||||
}
|
||||
}
|
||||
|
||||
void mbedtls_lmots_init_public( mbedtls_lmots_public_t *ctx )
|
||||
void mbedtls_lmots_public_init( mbedtls_lmots_public_t *ctx )
|
||||
{
|
||||
mbedtls_platform_zeroize( ctx, sizeof( mbedtls_lmots_public_t ) ) ;
|
||||
mbedtls_platform_zeroize( ctx, sizeof( *ctx ) ) ;
|
||||
}
|
||||
|
||||
void mbedtls_lmots_free_public( mbedtls_lmots_public_t *ctx )
|
||||
void mbedtls_lmots_public_free( mbedtls_lmots_public_t *ctx )
|
||||
{
|
||||
mbedtls_platform_zeroize( ctx, sizeof( mbedtls_lmots_public_t ) ) ;
|
||||
mbedtls_platform_zeroize( ctx, sizeof( *ctx ) ) ;
|
||||
}
|
||||
|
||||
int mbedtls_lmots_import_public_key( mbedtls_lmots_public_t *ctx,
|
||||
@ -540,14 +540,14 @@ int mbedtls_lmots_verify( const mbedtls_lmots_public_t *ctx,
|
||||
|
||||
#if defined(MBEDTLS_LMS_PRIVATE)
|
||||
|
||||
void mbedtls_lmots_init_private( mbedtls_lmots_private_t *ctx )
|
||||
void mbedtls_lmots_private_init( mbedtls_lmots_private_t *ctx )
|
||||
{
|
||||
mbedtls_platform_zeroize( ctx, sizeof( mbedtls_lmots_private_t ) ) ;
|
||||
mbedtls_platform_zeroize( ctx, sizeof( *ctx ) ) ;
|
||||
}
|
||||
|
||||
void mbedtls_lmots_free_private( mbedtls_lmots_private_t *ctx )
|
||||
void mbedtls_lmots_private_free( mbedtls_lmots_private_t *ctx )
|
||||
{
|
||||
mbedtls_platform_zeroize( ctx, sizeof( mbedtls_lmots_private_t ) ) ;
|
||||
mbedtls_platform_zeroize( ctx, sizeof( *ctx ) ) ;
|
||||
}
|
||||
|
||||
int mbedtls_lmots_generate_private_key( mbedtls_lmots_private_t *ctx,
|
||||
|
@ -96,7 +96,7 @@ int mbedtls_lms_error_from_psa( psa_status_t status );
|
||||
* \param ctx The uninitialized LMOTS context that will then be
|
||||
* initialized.
|
||||
*/
|
||||
void mbedtls_lmots_init_public( mbedtls_lmots_public_t *ctx );
|
||||
void mbedtls_lmots_public_init( mbedtls_lmots_public_t *ctx );
|
||||
|
||||
/**
|
||||
* \brief This function uninitializes a public LMOTS context
|
||||
@ -104,7 +104,7 @@ void mbedtls_lmots_init_public( mbedtls_lmots_public_t *ctx );
|
||||
* \param ctx The initialized LMOTS context that will then be
|
||||
* uninitialized.
|
||||
*/
|
||||
void mbedtls_lmots_free_public( mbedtls_lmots_public_t *ctx );
|
||||
void mbedtls_lmots_public_free( mbedtls_lmots_public_t *ctx );
|
||||
|
||||
/**
|
||||
* \brief This function imports an LMOTS public key into a
|
||||
@ -198,7 +198,7 @@ int mbedtls_lmots_verify( const mbedtls_lmots_public_t *ctx,
|
||||
* \param ctx The uninitialized LMOTS context that will then be
|
||||
* initialized.
|
||||
*/
|
||||
void mbedtls_lmots_init_private( mbedtls_lmots_private_t *ctx );
|
||||
void mbedtls_lmots_private_init( mbedtls_lmots_private_t *ctx );
|
||||
|
||||
/**
|
||||
* \brief This function uninitializes a private LMOTS context
|
||||
@ -206,7 +206,7 @@ void mbedtls_lmots_init_private( mbedtls_lmots_private_t *ctx );
|
||||
* \param ctx The initialized LMOTS context that will then be
|
||||
* uninitialized.
|
||||
*/
|
||||
void mbedtls_lmots_free_private( mbedtls_lmots_private_t *ctx );
|
||||
void mbedtls_lmots_private_free( mbedtls_lmots_private_t *ctx );
|
||||
|
||||
/**
|
||||
* \brief This function calculates an LMOTS private key, and
|
||||
|
@ -219,14 +219,14 @@ exit:
|
||||
return( mbedtls_lms_error_from_psa( status ) );
|
||||
}
|
||||
|
||||
void mbedtls_lms_init_public( mbedtls_lms_public_t *ctx )
|
||||
void mbedtls_lms_public_init( mbedtls_lms_public_t *ctx )
|
||||
{
|
||||
mbedtls_platform_zeroize( ctx, sizeof( mbedtls_lms_public_t ) ) ;
|
||||
mbedtls_platform_zeroize( ctx, sizeof( *ctx ) ) ;
|
||||
}
|
||||
|
||||
void mbedtls_lms_free_public( mbedtls_lms_public_t *ctx )
|
||||
void mbedtls_lms_public_free( mbedtls_lms_public_t *ctx )
|
||||
{
|
||||
mbedtls_platform_zeroize( ctx, sizeof( mbedtls_lms_public_t ) );
|
||||
mbedtls_platform_zeroize( ctx, sizeof( *ctx ) );
|
||||
}
|
||||
|
||||
int mbedtls_lms_import_public_key( mbedtls_lms_public_t *ctx,
|
||||
@ -489,12 +489,12 @@ static int get_merkle_path( mbedtls_lms_private_t *ctx,
|
||||
return( 0 );
|
||||
}
|
||||
|
||||
void mbedtls_lms_init_private( mbedtls_lms_private_t *ctx )
|
||||
void mbedtls_lms_private_init( mbedtls_lms_private_t *ctx )
|
||||
{
|
||||
mbedtls_platform_zeroize( ctx, sizeof( mbedtls_lms_private_t ) ) ;
|
||||
mbedtls_platform_zeroize( ctx, sizeof( *ctx ) ) ;
|
||||
}
|
||||
|
||||
void mbedtls_lms_free_private( mbedtls_lms_private_t *ctx )
|
||||
void mbedtls_lms_private_free( mbedtls_lms_private_t *ctx )
|
||||
{
|
||||
unsigned int idx;
|
||||
|
||||
@ -502,15 +502,15 @@ void mbedtls_lms_free_private( mbedtls_lms_private_t *ctx )
|
||||
{
|
||||
for( idx = 0; idx < MERKLE_TREE_LEAF_NODE_AM(ctx->params.type); idx++ )
|
||||
{
|
||||
mbedtls_lmots_free_private( &ctx->ots_private_keys[idx] );
|
||||
mbedtls_lmots_free_public( &ctx->ots_public_keys[idx] );
|
||||
mbedtls_lmots_private_free( &ctx->ots_private_keys[idx] );
|
||||
mbedtls_lmots_public_free( &ctx->ots_public_keys[idx] );
|
||||
}
|
||||
|
||||
mbedtls_free( ctx->ots_private_keys );
|
||||
mbedtls_free( ctx->ots_public_keys );
|
||||
}
|
||||
|
||||
mbedtls_platform_zeroize( ctx, sizeof( mbedtls_lms_private_t ) );
|
||||
mbedtls_platform_zeroize( ctx, sizeof( *ctx ) );
|
||||
}
|
||||
|
||||
|
||||
@ -565,8 +565,8 @@ int mbedtls_lms_generate_private_key( mbedtls_lms_private_t *ctx,
|
||||
|
||||
for( idx = 0; idx < MERKLE_TREE_LEAF_NODE_AM(ctx->params.type); idx++ )
|
||||
{
|
||||
mbedtls_lmots_init_private( &ctx->ots_private_keys[idx] );
|
||||
mbedtls_lmots_init_public( &ctx->ots_public_keys[idx] );
|
||||
mbedtls_lmots_private_init( &ctx->ots_private_keys[idx] );
|
||||
mbedtls_lmots_public_init( &ctx->ots_public_keys[idx] );
|
||||
}
|
||||
|
||||
|
||||
@ -593,8 +593,8 @@ exit:
|
||||
{
|
||||
for ( free_idx = 0; free_idx < idx; free_idx++ )
|
||||
{
|
||||
mbedtls_lmots_free_private( &ctx->ots_private_keys[free_idx] );
|
||||
mbedtls_lmots_free_public( &ctx->ots_public_keys[free_idx] );
|
||||
mbedtls_lmots_private_free( &ctx->ots_private_keys[free_idx] );
|
||||
mbedtls_lmots_public_free( &ctx->ots_public_keys[free_idx] );
|
||||
}
|
||||
|
||||
mbedtls_free( ctx->ots_private_keys );
|
||||
|
@ -36,8 +36,8 @@ void lmots_sign_verify_test ( data_t *msg, data_t *key_id, int leaf_id,
|
||||
mbedtls_lmots_private_t priv_ctx;
|
||||
unsigned char sig[MBEDTLS_LMOTS_SIG_LEN(MBEDTLS_LMOTS_SHA256_N32_W8)];
|
||||
|
||||
mbedtls_lmots_init_public( &pub_ctx );
|
||||
mbedtls_lmots_init_private( &priv_ctx );
|
||||
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 );
|
||||
@ -47,8 +47,8 @@ void lmots_sign_verify_test ( data_t *msg, data_t *key_id, int leaf_id,
|
||||
TEST_ASSERT( mbedtls_lmots_verify(&pub_ctx, msg->x, msg->len, sig, sizeof(sig)) == 0 );
|
||||
|
||||
exit:
|
||||
mbedtls_lmots_free_public( &pub_ctx );
|
||||
mbedtls_lmots_free_private( &priv_ctx );
|
||||
mbedtls_lmots_public_free( &pub_ctx );
|
||||
mbedtls_lmots_private_free( &priv_ctx );
|
||||
}
|
||||
/* END_CASE */
|
||||
|
||||
@ -59,8 +59,8 @@ void lmots_sign_verify_null_msg_test ( data_t *key_id, int leaf_id, data_t *seed
|
||||
mbedtls_lmots_private_t priv_ctx;
|
||||
unsigned char sig[MBEDTLS_LMOTS_SIG_LEN(MBEDTLS_LMOTS_SHA256_N32_W8)];
|
||||
|
||||
mbedtls_lmots_init_public( &pub_ctx );
|
||||
mbedtls_lmots_init_private( &priv_ctx );
|
||||
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 );
|
||||
@ -70,8 +70,8 @@ void lmots_sign_verify_null_msg_test ( data_t *key_id, int leaf_id, data_t *seed
|
||||
TEST_ASSERT( mbedtls_lmots_verify(&pub_ctx, NULL, 0, sig, sizeof(sig)) == 0 );
|
||||
|
||||
exit:
|
||||
mbedtls_lmots_free_public( &pub_ctx );
|
||||
mbedtls_lmots_free_private( &priv_ctx );
|
||||
mbedtls_lmots_public_free( &pub_ctx );
|
||||
mbedtls_lmots_private_free( &priv_ctx );
|
||||
}
|
||||
/* END_CASE */
|
||||
|
||||
@ -81,14 +81,14 @@ void lmots_verify_test ( data_t *msg, data_t *sig, data_t *pub_key,
|
||||
{
|
||||
mbedtls_lmots_public_t ctx;
|
||||
|
||||
mbedtls_lmots_init_public( &ctx );
|
||||
mbedtls_lmots_public_init( &ctx );
|
||||
|
||||
mbedtls_lmots_import_public_key( &ctx, pub_key->x, pub_key->len );
|
||||
|
||||
TEST_ASSERT(mbedtls_lmots_verify( &ctx, msg->x, msg->len, sig->x, sig->len ) == expected_rc );
|
||||
|
||||
exit:
|
||||
mbedtls_lmots_free_public( &ctx );
|
||||
mbedtls_lmots_public_free( &ctx );
|
||||
}
|
||||
/* END_CASE */
|
||||
|
||||
@ -99,7 +99,7 @@ void lmots_import_export_test ( data_t * pub_key )
|
||||
uint8_t exported_pub_key[MBEDTLS_LMOTS_PUBLIC_KEY_LEN(MBEDTLS_LMOTS_SHA256_N32_W8)];
|
||||
size_t exported_pub_key_len;
|
||||
|
||||
mbedtls_lmots_init_public( &ctx );
|
||||
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,
|
||||
sizeof( exported_pub_key ),
|
||||
@ -109,7 +109,7 @@ void lmots_import_export_test ( data_t * pub_key )
|
||||
exported_pub_key, exported_pub_key_len );
|
||||
|
||||
exit:
|
||||
mbedtls_lmots_free_public( &ctx );
|
||||
mbedtls_lmots_public_free( &ctx );
|
||||
}
|
||||
/* END_CASE */
|
||||
|
||||
@ -119,7 +119,7 @@ void lmots_reuse_test ( data_t *msg, data_t *key_id, int leaf_id, data_t *seed )
|
||||
mbedtls_lmots_private_t ctx;
|
||||
unsigned char sig[MBEDTLS_LMOTS_SIG_LEN(MBEDTLS_LMOTS_SHA256_N32_W8)];
|
||||
|
||||
mbedtls_lmots_init_private( &ctx );
|
||||
mbedtls_lmots_private_init( &ctx );
|
||||
TEST_ASSERT( mbedtls_lmots_generate_private_key(&ctx, MBEDTLS_LMOTS_SHA256_N32_W8,
|
||||
key_id->x, leaf_id, seed->x,
|
||||
seed->len ) == 0 );
|
||||
@ -133,7 +133,7 @@ void lmots_reuse_test ( data_t *msg, data_t *key_id, int leaf_id, data_t *seed )
|
||||
msg->x, msg->len, sig, sizeof( sig ), NULL ) != 0 );
|
||||
|
||||
exit:
|
||||
mbedtls_lmots_free_private( &ctx );
|
||||
mbedtls_lmots_private_free( &ctx );
|
||||
}
|
||||
/* END_CASE */
|
||||
|
||||
@ -149,7 +149,7 @@ void lmots_signature_leak_test ( data_t *msg, data_t *key_id, int leaf_id,
|
||||
/* Fill with recognisable pattern */
|
||||
memset( sig, 0x7E, sizeof( sig ) );
|
||||
|
||||
mbedtls_lmots_init_private( &ctx );
|
||||
mbedtls_lmots_private_init( &ctx );
|
||||
TEST_ASSERT( mbedtls_lmots_generate_private_key(&ctx, MBEDTLS_LMOTS_SHA256_N32_W8,
|
||||
key_id->x, leaf_id, seed->x,
|
||||
seed->len ) == 0 );
|
||||
@ -157,7 +157,7 @@ void lmots_signature_leak_test ( data_t *msg, data_t *key_id, int leaf_id,
|
||||
msg->x, msg->len, sig, sizeof( sig ), NULL ) == 0 );
|
||||
|
||||
exit:
|
||||
mbedtls_lmots_free_private( &ctx );
|
||||
mbedtls_lmots_private_free( &ctx );
|
||||
mbedtls_lmots_sign_private_key_invalidated_hook = NULL;
|
||||
}
|
||||
/* END_CASE */
|
||||
|
@ -16,8 +16,8 @@ void lms_sign_verify_test ( data_t *msg, data_t *seed )
|
||||
unsigned char sig[MBEDTLS_LMS_SIG_LEN(MBEDTLS_LMS_SHA256_M32_H10, MBEDTLS_LMOTS_SHA256_N32_W8)];
|
||||
int rc;
|
||||
|
||||
mbedtls_lms_init_public( &pub_ctx );
|
||||
mbedtls_lms_init_private( &priv_ctx );
|
||||
mbedtls_lms_public_init( &pub_ctx );
|
||||
mbedtls_lms_private_init( &priv_ctx );
|
||||
|
||||
/* Allocation failure isn't a test failure, since it likely just means
|
||||
* there's not enough memory to run the test.
|
||||
@ -39,8 +39,8 @@ void lms_sign_verify_test ( data_t *msg, data_t *seed )
|
||||
sizeof( sig ) ) == 0 );
|
||||
|
||||
exit:
|
||||
mbedtls_lms_free_public( &pub_ctx );
|
||||
mbedtls_lms_free_private( &priv_ctx );
|
||||
mbedtls_lms_public_free( &pub_ctx );
|
||||
mbedtls_lms_private_free( &priv_ctx );
|
||||
}
|
||||
/* END_CASE */
|
||||
|
||||
@ -52,8 +52,8 @@ void lms_sign_verify_null_msg_test( data_t *seed )
|
||||
unsigned char sig[MBEDTLS_LMS_SIG_LEN(MBEDTLS_LMS_SHA256_M32_H10, MBEDTLS_LMOTS_SHA256_N32_W8)];
|
||||
int rc;
|
||||
|
||||
mbedtls_lms_init_public( &pub_ctx );
|
||||
mbedtls_lms_init_private( &priv_ctx );
|
||||
mbedtls_lms_public_init( &pub_ctx );
|
||||
mbedtls_lms_private_init( &priv_ctx );
|
||||
|
||||
/* Allocation failure isn't a test failure, since it likely just means
|
||||
* there's not enough memory to run the test.
|
||||
@ -75,8 +75,8 @@ void lms_sign_verify_null_msg_test( data_t *seed )
|
||||
sizeof( sig ) ) == 0 );
|
||||
|
||||
exit:
|
||||
mbedtls_lms_free_public( &pub_ctx );
|
||||
mbedtls_lms_free_private( &priv_ctx );
|
||||
mbedtls_lms_public_free( &pub_ctx );
|
||||
mbedtls_lms_private_free( &priv_ctx );
|
||||
}
|
||||
/* END_CASE */
|
||||
|
||||
@ -86,14 +86,14 @@ void lms_verify_test ( data_t * msg, data_t * sig, data_t * pub_key,
|
||||
{
|
||||
mbedtls_lms_public_t ctx;
|
||||
|
||||
mbedtls_lms_init_public( &ctx);
|
||||
mbedtls_lms_public_init( &ctx);
|
||||
|
||||
mbedtls_lms_import_public_key( &ctx, pub_key->x, pub_key->len );
|
||||
|
||||
TEST_ASSERT( mbedtls_lms_verify( &ctx, msg->x, msg->len, sig->x, sig->len ) == expected_rc );
|
||||
|
||||
exit:
|
||||
mbedtls_lms_free_public( &ctx );
|
||||
mbedtls_lms_public_free( &ctx );
|
||||
}
|
||||
/* END_CASE */
|
||||
|
||||
@ -103,7 +103,7 @@ void lms_import_export_test ( data_t * pub_key )
|
||||
mbedtls_lms_public_t ctx;
|
||||
uint8_t exported_pub_key[MBEDTLS_LMS_PUBLIC_KEY_LEN(MBEDTLS_LMS_SHA256_M32_H10)];
|
||||
|
||||
mbedtls_lms_init_public(&ctx);
|
||||
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 );
|
||||
@ -112,7 +112,7 @@ void lms_import_export_test ( data_t * pub_key )
|
||||
exported_pub_key, MBEDTLS_LMS_PUBLIC_KEY_LEN(MBEDTLS_LMS_SHA256_M32_H10) );
|
||||
|
||||
exit:
|
||||
mbedtls_lms_free_public( &ctx );
|
||||
mbedtls_lms_public_free( &ctx );
|
||||
}
|
||||
/* END_CASE */
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user