derive_output() test: fix code style

Signed-off-by: Przemek Stekiel <przemyslaw.stekiel@mobica.com>
This commit is contained in:
Przemek Stekiel 2022-04-19 13:27:47 +02:00
parent 2503f7e4cb
commit 38647defa8

View File

@ -6956,7 +6956,7 @@ void derive_output( int alg_arg,
case 0:
break;
case PSA_KEY_DERIVATION_INPUT_SECRET:
switch ( key_input_type )
switch( key_input_type )
{
case 0: // input bytes
PSA_ASSERT( psa_key_derivation_input_bytes(
@ -6972,15 +6972,16 @@ void derive_output( int alg_arg,
inputs[i]->x, inputs[i]->len,
&keys[i] ) );
if ( PSA_ALG_IS_TLS12_PSK_TO_MS( alg ) )
if( PSA_ALG_IS_TLS12_PSK_TO_MS( alg ) )
{
PSA_ASSERT( psa_get_key_attributes( keys[i], &attributes1 ) );
TEST_ASSERT( PSA_BITS_TO_BYTES( psa_get_key_bits( &attributes1 ) ) <=
PSA_TLS12_PSK_TO_MS_PSK_MAX_SIZE );
}
PSA_ASSERT( psa_key_derivation_input_key(
&operation, steps[i], keys[i] ) );
PSA_ASSERT( psa_key_derivation_input_key( &operation,
steps[i],
keys[i] ) );
break;
default:
TEST_ASSERT( ! "default case not supported" );
@ -6988,12 +6989,14 @@ void derive_output( int alg_arg,
}
break;
case PSA_KEY_DERIVATION_INPUT_OTHER_SECRET:
switch ( other_key_input_type )
switch( other_key_input_type )
{
case 0: // input bytes
TEST_EQUAL( psa_key_derivation_input_bytes(
&operation, steps[i],
inputs[i]->x, inputs[i]->len ), statuses[i] );
TEST_EQUAL( psa_key_derivation_input_bytes( &operation,
steps[i],
inputs[i]->x,
inputs[i]->len ),
statuses[i] );
break;
case 1: // input key
psa_set_key_usage_flags( &attributes2, PSA_KEY_USAGE_DERIVE );
@ -7001,15 +7004,17 @@ void derive_output( int alg_arg,
psa_set_key_type( &attributes2, PSA_KEY_TYPE_DERIVE );
// other secret of type RAW_DATA passed with input_key
if ( statuses[i] == PSA_ERROR_INVALID_ARGUMENT )
if( statuses[i] == PSA_ERROR_INVALID_ARGUMENT )
psa_set_key_type( &attributes2, PSA_KEY_TYPE_RAW_DATA );
PSA_ASSERT( psa_import_key( &attributes2,
inputs[i]->x, inputs[i]->len,
&keys[i] ) );
inputs[i]->x, inputs[i]->len,
&keys[i] ) );
TEST_EQUAL( psa_key_derivation_input_key(
&operation, steps[i], keys[i] ), statuses[i] );
TEST_EQUAL( psa_key_derivation_input_key( &operation,
steps[i],
keys[i] ),
statuses[i] );
break;
case 2: // key agreement
psa_set_key_usage_flags( &attributes3, PSA_KEY_USAGE_DERIVE );
@ -7017,8 +7022,8 @@ void derive_output( int alg_arg,
psa_set_key_type( &attributes3, PSA_KEY_TYPE_ECC_KEY_PAIR(PSA_ECC_FAMILY_SECP_R1) );
PSA_ASSERT( psa_import_key( &attributes3,
inputs[i]->x, inputs[i]->len,
&keys[i] ) );
inputs[i]->x, inputs[i]->len,
&keys[i] ) );
TEST_EQUAL( psa_key_derivation_key_agreement(
&operation,
@ -7035,8 +7040,8 @@ void derive_output( int alg_arg,
size_t key_agreement_output_length;
PSA_ASSERT( psa_import_key( &attributes3,
inputs[i]->x, inputs[i]->len,
&keys[i] ) );
inputs[i]->x, inputs[i]->len,
&keys[i] ) );
PSA_ASSERT( psa_raw_key_agreement(
PSA_ALG_ECDH,
@ -7055,7 +7060,7 @@ void derive_output( int alg_arg,
break;
}
if ( statuses[i] != PSA_SUCCESS )
if( statuses[i] != PSA_SUCCESS )
goto exit;
break;
default: