@@ -158,9 +158,8 @@ static int exercise_mac_key( psa_key_handle_t handle,
158
158
handle, alg ) );
159
159
PSA_ASSERT( psa_mac_update( &operation,
160
160
input, sizeof( input ) ) );
161
- TEST_EQUAL( psa_mac_verify_finish( &operation,
162
- mac,
163
- mac_length ), verify_status );
161
+ TEST_EQUAL( psa_mac_verify_finish( &operation, mac, mac_length ),
162
+ verify_status );
164
163
}
165
164
166
165
return( 1 );
@@ -273,7 +272,8 @@ static int exercise_aead_key( psa_key_handle_t handle,
273
272
NULL, 0,
274
273
ciphertext, ciphertext_length,
275
274
plaintext, sizeof( plaintext ),
276
- &plaintext_length ), verify_status );
275
+ &plaintext_length ),
276
+ verify_status );
277
277
}
278
278
279
279
return( 1 );
@@ -334,12 +334,11 @@ static int exercise_asymmetric_encryption_key( psa_key_handle_t handle,
334
334
335
335
if( usage & PSA_KEY_USAGE_ENCRYPT )
336
336
{
337
- PSA_ASSERT(
338
- psa_asymmetric_encrypt( handle, alg,
339
- plaintext, plaintext_length,
340
- NULL, 0,
341
- ciphertext, sizeof( ciphertext ),
342
- &ciphertext_length ) );
337
+ PSA_ASSERT( psa_asymmetric_encrypt( handle, alg,
338
+ plaintext, plaintext_length,
339
+ NULL, 0,
340
+ ciphertext, sizeof( ciphertext ),
341
+ &ciphertext_length ) );
343
342
}
344
343
345
344
if( usage & PSA_KEY_USAGE_DECRYPT )
@@ -496,7 +495,8 @@ static int asn1_skip_integer( unsigned char **p, const unsigned char *end,
496
495
size_t actual_bits;
497
496
unsigned char msb;
498
497
TEST_EQUAL( mbedtls_asn1_get_tag( p, end, &len,
499
- MBEDTLS_ASN1_INTEGER ), 0 );
498
+ MBEDTLS_ASN1_INTEGER ),
499
+ 0 );
500
500
/* Tolerate a slight departure from DER encoding:
501
501
* - 0 may be represented by an empty string or a 1-byte string.
502
502
* - The sign bit may be used as a value bit. */
@@ -646,7 +646,8 @@ static int exported_key_sanity_check( psa_key_type_t type, size_t bits,
646
646
*/
647
647
TEST_EQUAL( mbedtls_asn1_get_tag( &p, end, &len,
648
648
MBEDTLS_ASN1_SEQUENCE |
649
- MBEDTLS_ASN1_CONSTRUCTED ), 0 );
649
+ MBEDTLS_ASN1_CONSTRUCTED ),
650
+ 0 );
650
651
TEST_EQUAL( p + len, end );
651
652
TEST_EQUAL( mbedtls_asn1_get_alg( &p, end, &alg, ¶ms ), 0 );
652
653
if( ! is_oid_of_key_type( type, alg.p, alg.len ) )
@@ -664,7 +665,8 @@ static int exported_key_sanity_check( psa_key_type_t type, size_t bits,
664
665
TEST_EQUAL( bitstring.unused_bits, 0 );
665
666
TEST_EQUAL( mbedtls_asn1_get_tag( &p, end, &len,
666
667
MBEDTLS_ASN1_SEQUENCE |
667
- MBEDTLS_ASN1_CONSTRUCTED ), 0 );
668
+ MBEDTLS_ASN1_CONSTRUCTED ),
669
+ 0 );
668
670
TEST_EQUAL( p + len, end );
669
671
if( ! asn1_skip_integer( &p, end, bits, bits, 1 ) )
670
672
goto exit;
@@ -756,8 +758,7 @@ static int exercise_export_public_key( psa_key_handle_t handle )
756
758
PSA_ASSERT( psa_get_key_information( handle, &type, &bits ) );
757
759
if( ! PSA_KEY_TYPE_IS_ASYMMETRIC( type ) )
758
760
{
759
- TEST_EQUAL( psa_export_public_key( handle,
760
- NULL, 0, &exported_length ),
761
+ TEST_EQUAL( psa_export_public_key( handle, NULL, 0, &exported_length ),
761
762
PSA_ERROR_INVALID_ARGUMENT );
762
763
return( 1 );
763
764
}
@@ -1014,8 +1015,8 @@ void import_export( data_t *data,
1014
1015
psa_key_policy_set_usage( &policy, usage_arg, alg );
1015
1016
PSA_ASSERT( psa_set_key_policy( handle, &policy ) );
1016
1017
1017
- TEST_EQUAL( psa_get_key_information(
1018
- handle, NULL, NULL ), PSA_ERROR_EMPTY_SLOT );
1018
+ TEST_EQUAL( psa_get_key_information( handle, NULL, NULL ),
1019
+ PSA_ERROR_EMPTY_SLOT );
1019
1020
1020
1021
/* Import the key */
1021
1022
PSA_ASSERT( psa_import_key( handle, type,
@@ -1075,8 +1076,8 @@ void import_export( data_t *data,
1075
1076
destroy:
1076
1077
/* Destroy the key */
1077
1078
PSA_ASSERT( psa_destroy_key( handle ) );
1078
- TEST_EQUAL( psa_get_key_information(
1079
- handle, NULL, NULL ), PSA_ERROR_INVALID_HANDLE );
1079
+ TEST_EQUAL( psa_get_key_information( handle, NULL, NULL ),
1080
+ PSA_ERROR_INVALID_HANDLE );
1080
1081
1081
1082
exit:
1082
1083
mbedtls_free( exported );
@@ -1826,14 +1827,12 @@ void hash_bad_order( )
1826
1827
1827
1828
/* psa_hash_update without calling psa_hash_setup beforehand */
1828
1829
memset( &operation, 0, sizeof( operation ) );
1829
- TEST_EQUAL( psa_hash_update( &operation,
1830
- input, sizeof( input ) ),
1830
+ TEST_EQUAL( psa_hash_update( &operation, input, sizeof( input ) ),
1831
1831
PSA_ERROR_INVALID_ARGUMENT );
1832
1832
1833
1833
/* psa_hash_verify without calling psa_hash_setup beforehand */
1834
1834
memset( &operation, 0, sizeof( operation ) );
1835
- TEST_EQUAL( psa_hash_verify( &operation,
1836
- hash, sizeof( hash ) ),
1835
+ TEST_EQUAL( psa_hash_verify( &operation, hash, sizeof( hash ) ),
1837
1836
PSA_ERROR_INVALID_ARGUMENT );
1838
1837
1839
1838
/* psa_hash_finish without calling psa_hash_setup beforehand */
@@ -1864,20 +1863,17 @@ void hash_verify_bad_args( )
1864
1863
1865
1864
/* psa_hash_verify with a smaller hash than expected */
1866
1865
PSA_ASSERT( psa_hash_setup( &operation, alg ) );
1867
- TEST_EQUAL( psa_hash_verify( &operation,
1868
- hash, expected_size - 1 ),
1866
+ TEST_EQUAL( psa_hash_verify( &operation, hash, expected_size - 1 ),
1869
1867
PSA_ERROR_INVALID_SIGNATURE );
1870
1868
1871
1869
/* psa_hash_verify with a non-matching hash */
1872
1870
PSA_ASSERT( psa_hash_setup( &operation, alg ) );
1873
- TEST_EQUAL( psa_hash_verify( &operation,
1874
- hash + 1, expected_size ),
1871
+ TEST_EQUAL( psa_hash_verify( &operation, hash + 1, expected_size ),
1875
1872
PSA_ERROR_INVALID_SIGNATURE );
1876
1873
1877
1874
/* psa_hash_verify with a hash longer than expected */
1878
1875
PSA_ASSERT( psa_hash_setup( &operation, alg ) );
1879
- TEST_EQUAL( psa_hash_verify( &operation,
1880
- hash, sizeof( hash ) ),
1876
+ TEST_EQUAL( psa_hash_verify( &operation, hash, sizeof( hash ) ),
1881
1877
PSA_ERROR_INVALID_SIGNATURE );
1882
1878
1883
1879
exit:
@@ -1899,8 +1895,8 @@ void hash_finish_bad_args( )
1899
1895
/* psa_hash_finish with a smaller hash buffer than expected */
1900
1896
PSA_ASSERT( psa_hash_setup( &operation, alg ) );
1901
1897
TEST_EQUAL( psa_hash_finish( &operation,
1902
- hash, expected_size - 1,
1903
- &hash_len ), PSA_ERROR_BUFFER_TOO_SMALL );
1898
+ hash, expected_size - 1, &hash_len ),
1899
+ PSA_ERROR_BUFFER_TOO_SMALL );
1904
1900
1905
1901
exit:
1906
1902
mbedtls_psa_crypto_free( );
@@ -2645,7 +2641,8 @@ void aead_encrypt_decrypt( int key_type_arg, data_t *key_data,
2645
2641
additional_data->len,
2646
2642
input_data->x, input_data->len,
2647
2643
output_data, output_size,
2648
- &output_length ), expected_result );
2644
+ &output_length ),
2645
+ expected_result );
2649
2646
2650
2647
if( PSA_SUCCESS == expected_result )
2651
2648
{
@@ -2657,7 +2654,8 @@ void aead_encrypt_decrypt( int key_type_arg, data_t *key_data,
2657
2654
additional_data->len,
2658
2655
output_data, output_length,
2659
2656
output_data2, output_length,
2660
- &output_length2 ), expected_result );
2657
+ &output_length2 ),
2658
+ expected_result );
2661
2659
2662
2660
ASSERT_COMPARE( input_data->x, input_data->len,
2663
2661
output_data2, output_length2 );
@@ -2782,7 +2780,8 @@ void aead_decrypt( int key_type_arg, data_t *key_data,
2782
2780
additional_data->len,
2783
2781
input_data->x, input_data->len,
2784
2782
output_data, output_size,
2785
- &output_length ), expected_result );
2783
+ &output_length ),
2784
+ expected_result );
2786
2785
2787
2786
if( expected_result == PSA_SUCCESS )
2788
2787
ASSERT_COMPARE( expected_data->x, expected_data->len,
@@ -2984,11 +2983,10 @@ void sign_verify( int key_type_arg, data_t *key_data,
2984
2983
* detected as invalid. Flip a bit at the beginning, not at the end,
2985
2984
* because ECDSA may ignore the last few bits of the input. */
2986
2985
input_data->x[0] ^= 1;
2987
- TEST_EQUAL( psa_asymmetric_verify(
2988
- handle, alg,
2989
- input_data->x, input_data->len,
2990
- signature,
2991
- signature_length ), PSA_ERROR_INVALID_SIGNATURE );
2986
+ TEST_EQUAL( psa_asymmetric_verify( handle, alg,
2987
+ input_data->x, input_data->len,
2988
+ signature, signature_length ),
2989
+ PSA_ERROR_INVALID_SIGNATURE );
2992
2990
}
2993
2991
2994
2992
exit:
@@ -3409,7 +3407,8 @@ void derive_setup( int key_type_arg,
3409
3407
TEST_EQUAL( psa_key_derivation( &generator, handle, alg,
3410
3408
salt->x, salt->len,
3411
3409
label->x, label->len,
3412
- requested_capacity ), expected_status );
3410
+ requested_capacity ),
3411
+ expected_status );
3413
3412
3414
3413
exit:
3415
3414
psa_generator_abort( &generator );
@@ -3455,13 +3454,13 @@ void test_derive_invalid_generator_state( )
3455
3454
TEST_EQUAL( psa_key_derivation( &generator, handle, alg,
3456
3455
NULL, 0,
3457
3456
NULL, 0,
3458
- capacity ), PSA_ERROR_BAD_STATE );
3457
+ capacity ),
3458
+ PSA_ERROR_BAD_STATE );
3459
3459
3460
- PSA_ASSERT( psa_generator_read( &generator, buffer, capacity )
3461
- );
3460
+ PSA_ASSERT( psa_generator_read( &generator, buffer, capacity ) );
3462
3461
3463
- TEST_EQUAL( psa_generator_read( &generator, buffer, capacity )
3464
- , PSA_ERROR_INSUFFICIENT_CAPACITY );
3462
+ TEST_EQUAL( psa_generator_read( &generator, buffer, capacity ),
3463
+ PSA_ERROR_INSUFFICIENT_CAPACITY );
3465
3464
3466
3465
exit:
3467
3466
psa_generator_abort( &generator );
@@ -3649,9 +3648,8 @@ void derive_full( int alg_arg,
3649
3648
}
3650
3649
3651
3650
/* Check that the generator refuses to go over capacity. */
3652
- TEST_EQUAL( psa_generator_read( &generator,
3653
- output_buffer,
3654
- 1 ), PSA_ERROR_INSUFFICIENT_CAPACITY );
3651
+ TEST_EQUAL( psa_generator_read( &generator, output_buffer, 1 ),
3652
+ PSA_ERROR_INSUFFICIENT_CAPACITY );
3655
3653
3656
3654
PSA_ASSERT( psa_generator_abort( &generator ) );
3657
3655
@@ -3847,7 +3845,8 @@ void key_agreement_setup( int alg_arg,
3847
3845
TEST_EQUAL( psa_key_agreement( &generator,
3848
3846
our_key,
3849
3847
peer_key_data->x, peer_key_data->len,
3850
- alg ), expected_status_arg );
3848
+ alg ),
3849
+ expected_status_arg );
3851
3850
3852
3851
exit:
3853
3852
psa_generator_abort( &generator );
@@ -3946,18 +3945,16 @@ void key_agreement_output( int alg_arg,
3946
3945
peer_key_data->x, peer_key_data->len,
3947
3946
alg ) );
3948
3947
3949
- PSA_ASSERT(
3950
- psa_generator_read( &generator,
3951
- actual_output,
3952
- expected_output1->len ) );
3948
+ PSA_ASSERT( psa_generator_read( &generator,
3949
+ actual_output,
3950
+ expected_output1->len ) );
3953
3951
TEST_EQUAL( memcmp( actual_output, expected_output1->x,
3954
3952
expected_output1->len ), 0 );
3955
3953
if( expected_output2->len != 0 )
3956
3954
{
3957
- PSA_ASSERT(
3958
- psa_generator_read( &generator,
3959
- actual_output,
3960
- expected_output2->len ) );
3955
+ PSA_ASSERT( psa_generator_read( &generator,
3956
+ actual_output,
3957
+ expected_output2->len ) );
3961
3958
TEST_EQUAL( memcmp( actual_output, expected_output2->x,
3962
3959
expected_output2->len ), 0 );
3963
3960
}
@@ -4047,13 +4044,12 @@ void generate_key( int type_arg,
4047
4044
PSA_ASSERT( psa_set_key_policy( handle, &policy ) );
4048
4045
4049
4046
/* Generate a key */
4050
- TEST_EQUAL( psa_generate_key( handle, type, bits,
4051
- NULL, 0 ), expected_status );
4047
+ TEST_EQUAL( psa_generate_key( handle, type, bits, NULL, 0 ),
4048
+ expected_status );
4052
4049
4053
4050
/* Test the key information */
4054
- TEST_EQUAL( psa_get_key_information( handle,
4055
- &got_type,
4056
- &got_bits ), expected_info_status );
4051
+ TEST_EQUAL( psa_get_key_information( handle, &got_type, &got_bits ),
4052
+ expected_info_status );
4057
4053
if( expected_info_status != PSA_SUCCESS )
4058
4054
goto exit;
4059
4055
TEST_EQUAL( got_type, type );
@@ -4144,8 +4140,10 @@ void persistent_key_load_key_from_storage( data_t *data, int type_arg,
4144
4140
}
4145
4141
4146
4142
/* Export the key */
4147
- TEST_EQUAL( psa_export_key( handle, first_export, export_size,
4148
- &first_exported_length ), export_status );
4143
+ TEST_EQUAL( psa_export_key( handle,
4144
+ first_export, export_size,
4145
+ &first_exported_length ),
4146
+ export_status );
4149
4147
4150
4148
/* Shutdown and restart */
4151
4149
mbedtls_psa_crypto_free();
@@ -4160,14 +4158,14 @@ void persistent_key_load_key_from_storage( data_t *data, int type_arg,
4160
4158
TEST_EQUAL( bits_get, (size_t) bits );
4161
4159
4162
4160
PSA_ASSERT( psa_get_key_policy( handle, &policy_get ) );
4163
- TEST_EQUAL( psa_key_policy_get_usage(
4164
- &policy_get ), policy_usage );
4165
- TEST_EQUAL( psa_key_policy_get_algorithm(
4166
- &policy_get ), policy_alg );
4161
+ TEST_EQUAL( psa_key_policy_get_usage( &policy_get ), policy_usage );
4162
+ TEST_EQUAL( psa_key_policy_get_algorithm( &policy_get ), policy_alg );
4167
4163
4168
4164
/* Export the key again */
4169
- TEST_EQUAL( psa_export_key( handle, second_export, export_size,
4170
- &second_exported_length ), export_status );
4165
+ TEST_EQUAL( psa_export_key( handle,
4166
+ second_export, export_size,
4167
+ &second_exported_length ),
4168
+ export_status );
4171
4169
4172
4170
if( export_status == PSA_SUCCESS )
4173
4171
{
0 commit comments