mirror of
https://github.com/ARMmbed/mbedtls.git
synced 2025-05-10 08:59:05 +08:00
Add extra zeroization to LMS and LMOTS
Signed-off-by: Raef Coles <raef.coles@arm.com>
This commit is contained in:
parent
9fc303a99a
commit
142e577c34
@ -700,7 +700,7 @@ int mbedtls_lmots_calculate_public_key( mbedtls_lmots_public_t *ctx,
|
|||||||
NULL, ( unsigned char * )y_hashed_digits );
|
NULL, ( unsigned char * )y_hashed_digits );
|
||||||
if( ret )
|
if( ret )
|
||||||
{
|
{
|
||||||
return( ret );
|
goto exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = public_key_from_hashed_digit_array( &priv_ctx->params,
|
ret = public_key_from_hashed_digit_array( &priv_ctx->params,
|
||||||
@ -708,7 +708,7 @@ int mbedtls_lmots_calculate_public_key( mbedtls_lmots_public_t *ctx,
|
|||||||
ctx->public_key );
|
ctx->public_key );
|
||||||
if( ret )
|
if( ret )
|
||||||
{
|
{
|
||||||
return( ret );
|
goto exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
memcpy( &ctx->params, &priv_ctx->params,
|
memcpy( &ctx->params, &priv_ctx->params,
|
||||||
@ -716,6 +716,9 @@ int mbedtls_lmots_calculate_public_key( mbedtls_lmots_public_t *ctx,
|
|||||||
|
|
||||||
ctx->have_public_key = 1;
|
ctx->have_public_key = 1;
|
||||||
|
|
||||||
|
exit:
|
||||||
|
mbedtls_platform_zeroize( y_hashed_digits, sizeof( y_hashed_digits ) );
|
||||||
|
|
||||||
return( ret );
|
return( ret );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -765,14 +768,14 @@ int mbedtls_lmots_sign( mbedtls_lmots_private_t *ctx,
|
|||||||
tmp_digit_array );
|
tmp_digit_array );
|
||||||
if( ret )
|
if( ret )
|
||||||
{
|
{
|
||||||
return( ret );
|
goto exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = hash_digit_array( &ctx->params, ( unsigned char * )ctx->private_key,
|
ret = hash_digit_array( &ctx->params, ( unsigned char * )ctx->private_key,
|
||||||
NULL, tmp_digit_array, ( unsigned char * )tmp_sig );
|
NULL, tmp_digit_array, ( unsigned char * )tmp_sig );
|
||||||
if( ret )
|
if( ret )
|
||||||
{
|
{
|
||||||
return( ret );
|
goto exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
mbedtls_lms_unsigned_int_to_network_bytes( ctx->params.type,
|
mbedtls_lms_unsigned_int_to_network_bytes( ctx->params.type,
|
||||||
@ -810,7 +813,13 @@ int mbedtls_lmots_sign( mbedtls_lmots_private_t *ctx,
|
|||||||
*sig_len = MBEDTLS_LMOTS_SIG_LEN(ctx->params.type);
|
*sig_len = MBEDTLS_LMOTS_SIG_LEN(ctx->params.type);
|
||||||
}
|
}
|
||||||
|
|
||||||
return( 0 );
|
ret = 0;
|
||||||
|
|
||||||
|
exit:
|
||||||
|
mbedtls_platform_zeroize( tmp_digit_array, sizeof( tmp_digit_array ) );
|
||||||
|
mbedtls_platform_zeroize( tmp_sig, sizeof( tmp_sig ) );
|
||||||
|
|
||||||
|
return ( ret );
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* defined(MBEDTLS_LMS_PRIVATE) */
|
#endif /* defined(MBEDTLS_LMS_PRIVATE) */
|
||||||
|
@ -516,7 +516,7 @@ static int get_merkle_path( mbedtls_lms_private_t *ctx,
|
|||||||
ret = calculate_merkle_tree( ctx, ( unsigned char * )tree );
|
ret = calculate_merkle_tree( ctx, ( unsigned char * )tree );
|
||||||
if( ret != 0 )
|
if( ret != 0 )
|
||||||
{
|
{
|
||||||
return( ret );
|
goto exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
for( height = 0; height < MBEDTLS_LMS_H_TREE_HEIGHT(ctx->params.type);
|
for( height = 0; height < MBEDTLS_LMS_H_TREE_HEIGHT(ctx->params.type);
|
||||||
@ -531,7 +531,12 @@ static int get_merkle_path( mbedtls_lms_private_t *ctx,
|
|||||||
curr_node_id >>=1;
|
curr_node_id >>=1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return( 0 );
|
ret = 0;
|
||||||
|
|
||||||
|
exit:
|
||||||
|
mbedtls_platform_zeroize( tree, sizeof( tree ) );
|
||||||
|
|
||||||
|
return( ret );
|
||||||
}
|
}
|
||||||
|
|
||||||
void mbedtls_lms_private_init( mbedtls_lms_private_t *ctx )
|
void mbedtls_lms_private_init( mbedtls_lms_private_t *ctx )
|
||||||
@ -688,7 +693,7 @@ int mbedtls_lms_calculate_public_key( mbedtls_lms_public_t *ctx,
|
|||||||
ret = calculate_merkle_tree( priv_ctx, ( unsigned char * )tree );
|
ret = calculate_merkle_tree( priv_ctx, ( unsigned char * )tree );
|
||||||
if( ret != 0 )
|
if( ret != 0 )
|
||||||
{
|
{
|
||||||
return( ret );
|
goto exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Root node is always at position 1, due to 1-based indexing */
|
/* Root node is always at position 1, due to 1-based indexing */
|
||||||
@ -697,7 +702,12 @@ int mbedtls_lms_calculate_public_key( mbedtls_lms_public_t *ctx,
|
|||||||
|
|
||||||
ctx->have_public_key = 1;
|
ctx->have_public_key = 1;
|
||||||
|
|
||||||
return( 0 );
|
ret = 0;
|
||||||
|
|
||||||
|
exit:
|
||||||
|
mbedtls_platform_zeroize( tree, sizeof( tree ) );
|
||||||
|
|
||||||
|
return( ret );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user