mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-03-31 01:20:35 +00:00
Fix LMS and LMOTS coding style violations
Signed-off-by: Raef Coles <raef.coles@arm.com>
This commit is contained in:
parent
366d67d9af
commit
9b88ee5d5d
@ -79,7 +79,8 @@ void unsigned_int_to_network_bytes(unsigned int val, size_t len,
|
||||
{
|
||||
size_t idx;
|
||||
|
||||
for (idx = 0; idx < len; idx++) {
|
||||
for ( idx = 0; idx < len; idx++ )
|
||||
{
|
||||
bytes[idx] = ( val >> ( ( len - 1 - idx ) * 8 ) ) & 0xFF;
|
||||
}
|
||||
}
|
||||
@ -90,7 +91,8 @@ unsigned int network_bytes_to_unsigned_int(size_t len,
|
||||
size_t idx;
|
||||
unsigned int val = 0;
|
||||
|
||||
for (idx = 0; idx < len; idx++) {
|
||||
for ( idx = 0; idx < len; idx++ )
|
||||
{
|
||||
val |= ( ( unsigned int )bytes[idx] ) << (8 * ( len - 1 - idx ) );
|
||||
}
|
||||
|
||||
@ -331,7 +333,8 @@ exit:
|
||||
|
||||
int mbedtls_lms_error_from_psa( psa_status_t status )
|
||||
{
|
||||
switch( status ) {
|
||||
switch( status )
|
||||
{
|
||||
case PSA_SUCCESS:
|
||||
return( 0 );
|
||||
case PSA_ERROR_HARDWARE_FAILURE:
|
||||
@ -459,8 +462,7 @@ int mbedtls_lmots_verify( mbedtls_lmots_public_t *ctx, const unsigned char *msg,
|
||||
return( MBEDTLS_ERR_LMS_BAD_INPUT_DATA );
|
||||
}
|
||||
|
||||
if( ctx->params.MBEDTLS_PRIVATE( type )
|
||||
!= MBEDTLS_LMOTS_SHA256_N32_W8 )
|
||||
if( ctx->params.type != MBEDTLS_LMOTS_SHA256_N32_W8 )
|
||||
{
|
||||
return( MBEDTLS_ERR_LMS_BAD_INPUT_DATA );
|
||||
}
|
||||
@ -522,7 +524,8 @@ int mbedtls_lmots_generate_private_key( mbedtls_lmots_private_t *ctx,
|
||||
return( MBEDTLS_ERR_LMS_BAD_INPUT_DATA );
|
||||
}
|
||||
|
||||
if ( type != MBEDTLS_LMOTS_SHA256_N32_W8 ) {
|
||||
if ( type != MBEDTLS_LMOTS_SHA256_N32_W8 )
|
||||
{
|
||||
return( MBEDTLS_ERR_LMS_BAD_INPUT_DATA );
|
||||
}
|
||||
|
||||
@ -634,7 +637,7 @@ int mbedtls_lmots_calculate_public_key( mbedtls_lmots_public_t *ctx,
|
||||
memcpy( &ctx->params, &priv_ctx->params,
|
||||
sizeof( ctx->params ) );
|
||||
|
||||
ctx->MBEDTLS_PRIVATE(have_public_key = 1);
|
||||
ctx->have_public_key = 1;
|
||||
|
||||
return( ret );
|
||||
}
|
||||
|
@ -539,7 +539,8 @@ int mbedtls_lms_generate_private_key( mbedtls_lms_private_t *ctx,
|
||||
exit:
|
||||
if( ret )
|
||||
{
|
||||
for ( free_idx = 0; free_idx < idx; free_idx++ ) {
|
||||
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] );
|
||||
}
|
||||
@ -558,7 +559,7 @@ int mbedtls_lms_calculate_public_key( mbedtls_lms_public_t *ctx,
|
||||
unsigned char tree[MERKLE_TREE_NODE_AM_MAX][MBEDTLS_LMS_M_NODE_BYTES_MAX];
|
||||
int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;
|
||||
|
||||
if( ! priv_ctx->MBEDTLS_PRIVATE( have_private_key ) )
|
||||
if( ! priv_ctx->have_private_key )
|
||||
{
|
||||
return( MBEDTLS_ERR_LMS_BAD_INPUT_DATA );
|
||||
}
|
||||
@ -598,7 +599,8 @@ int mbedtls_lms_export_public_key( mbedtls_lms_public_t *ctx,
|
||||
unsigned char *key,
|
||||
size_t key_size, size_t *key_len )
|
||||
{
|
||||
if( key_size < MBEDTLS_LMS_PUBLIC_KEY_LEN(ctx->params.type) ) {
|
||||
if( key_size < MBEDTLS_LMS_PUBLIC_KEY_LEN(ctx->params.type) )
|
||||
{
|
||||
return( MBEDTLS_ERR_LMS_BUFFER_TOO_SMALL );
|
||||
}
|
||||
|
||||
@ -619,7 +621,8 @@ int mbedtls_lms_export_public_key( mbedtls_lms_public_t *ctx,
|
||||
ctx->T_1_pub_key,
|
||||
MBEDTLS_LMS_M_NODE_BYTES(ctx->params.type) );
|
||||
|
||||
if( key_len != NULL ) {
|
||||
if( key_len != NULL )
|
||||
{
|
||||
*key_len = MBEDTLS_LMS_PUBLIC_KEY_LEN(ctx->params.type);
|
||||
}
|
||||
|
||||
@ -691,7 +694,8 @@ int mbedtls_lms_sign( mbedtls_lms_private_t *ctx,
|
||||
return( ret );
|
||||
}
|
||||
|
||||
if( sig_len != NULL ) {
|
||||
if( sig_len != NULL )
|
||||
{
|
||||
*sig_len = MBEDTLS_LMS_SIG_LEN(ctx->params.type, ctx->params.otstype);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user