Skip to content

Commit f812dcf

Browse files
Rewrap some lines after the macro changes
Change the way some lines are wrapped to cut at a more logical place. This commit mainly rewrites multi-line calls to TEST_EQUAL, and also a few calls to PSA_ASSERT.
1 parent fe11b72 commit f812dcf

4 files changed

+84
-89
lines changed

tests/suites/test_suite_psa_crypto.function

Lines changed: 68 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -158,9 +158,8 @@ static int exercise_mac_key( psa_key_handle_t handle,
158158
handle, alg ) );
159159
PSA_ASSERT( psa_mac_update( &operation,
160160
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 );
164163
}
165164

166165
return( 1 );
@@ -273,7 +272,8 @@ static int exercise_aead_key( psa_key_handle_t handle,
273272
NULL, 0,
274273
ciphertext, ciphertext_length,
275274
plaintext, sizeof( plaintext ),
276-
&plaintext_length ), verify_status );
275+
&plaintext_length ),
276+
verify_status );
277277
}
278278

279279
return( 1 );
@@ -334,12 +334,11 @@ static int exercise_asymmetric_encryption_key( psa_key_handle_t handle,
334334

335335
if( usage & PSA_KEY_USAGE_ENCRYPT )
336336
{
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 ) );
343342
}
344343

345344
if( usage & PSA_KEY_USAGE_DECRYPT )
@@ -496,7 +495,8 @@ static int asn1_skip_integer( unsigned char **p, const unsigned char *end,
496495
size_t actual_bits;
497496
unsigned char msb;
498497
TEST_EQUAL( mbedtls_asn1_get_tag( p, end, &len,
499-
MBEDTLS_ASN1_INTEGER ), 0 );
498+
MBEDTLS_ASN1_INTEGER ),
499+
0 );
500500
/* Tolerate a slight departure from DER encoding:
501501
* - 0 may be represented by an empty string or a 1-byte string.
502502
* - 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,
646646
*/
647647
TEST_EQUAL( mbedtls_asn1_get_tag( &p, end, &len,
648648
MBEDTLS_ASN1_SEQUENCE |
649-
MBEDTLS_ASN1_CONSTRUCTED ), 0 );
649+
MBEDTLS_ASN1_CONSTRUCTED ),
650+
0 );
650651
TEST_EQUAL( p + len, end );
651652
TEST_EQUAL( mbedtls_asn1_get_alg( &p, end, &alg, &params ), 0 );
652653
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,
664665
TEST_EQUAL( bitstring.unused_bits, 0 );
665666
TEST_EQUAL( mbedtls_asn1_get_tag( &p, end, &len,
666667
MBEDTLS_ASN1_SEQUENCE |
667-
MBEDTLS_ASN1_CONSTRUCTED ), 0 );
668+
MBEDTLS_ASN1_CONSTRUCTED ),
669+
0 );
668670
TEST_EQUAL( p + len, end );
669671
if( ! asn1_skip_integer( &p, end, bits, bits, 1 ) )
670672
goto exit;
@@ -756,8 +758,7 @@ static int exercise_export_public_key( psa_key_handle_t handle )
756758
PSA_ASSERT( psa_get_key_information( handle, &type, &bits ) );
757759
if( ! PSA_KEY_TYPE_IS_ASYMMETRIC( type ) )
758760
{
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 ),
761762
PSA_ERROR_INVALID_ARGUMENT );
762763
return( 1 );
763764
}
@@ -1014,8 +1015,8 @@ void import_export( data_t *data,
10141015
psa_key_policy_set_usage( &policy, usage_arg, alg );
10151016
PSA_ASSERT( psa_set_key_policy( handle, &policy ) );
10161017

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 );
10191020

10201021
/* Import the key */
10211022
PSA_ASSERT( psa_import_key( handle, type,
@@ -1075,8 +1076,8 @@ void import_export( data_t *data,
10751076
destroy:
10761077
/* Destroy the key */
10771078
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 );
10801081

10811082
exit:
10821083
mbedtls_free( exported );
@@ -1826,14 +1827,12 @@ void hash_bad_order( )
18261827

18271828
/* psa_hash_update without calling psa_hash_setup beforehand */
18281829
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 ) ),
18311831
PSA_ERROR_INVALID_ARGUMENT );
18321832

18331833
/* psa_hash_verify without calling psa_hash_setup beforehand */
18341834
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 ) ),
18371836
PSA_ERROR_INVALID_ARGUMENT );
18381837

18391838
/* psa_hash_finish without calling psa_hash_setup beforehand */
@@ -1864,20 +1863,17 @@ void hash_verify_bad_args( )
18641863

18651864
/* psa_hash_verify with a smaller hash than expected */
18661865
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 ),
18691867
PSA_ERROR_INVALID_SIGNATURE );
18701868

18711869
/* psa_hash_verify with a non-matching hash */
18721870
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 ),
18751872
PSA_ERROR_INVALID_SIGNATURE );
18761873

18771874
/* psa_hash_verify with a hash longer than expected */
18781875
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 ) ),
18811877
PSA_ERROR_INVALID_SIGNATURE );
18821878

18831879
exit:
@@ -1899,8 +1895,8 @@ void hash_finish_bad_args( )
18991895
/* psa_hash_finish with a smaller hash buffer than expected */
19001896
PSA_ASSERT( psa_hash_setup( &operation, alg ) );
19011897
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 );
19041900

19051901
exit:
19061902
mbedtls_psa_crypto_free( );
@@ -2645,7 +2641,8 @@ void aead_encrypt_decrypt( int key_type_arg, data_t *key_data,
26452641
additional_data->len,
26462642
input_data->x, input_data->len,
26472643
output_data, output_size,
2648-
&output_length ), expected_result );
2644+
&output_length ),
2645+
expected_result );
26492646

26502647
if( PSA_SUCCESS == expected_result )
26512648
{
@@ -2657,7 +2654,8 @@ void aead_encrypt_decrypt( int key_type_arg, data_t *key_data,
26572654
additional_data->len,
26582655
output_data, output_length,
26592656
output_data2, output_length,
2660-
&output_length2 ), expected_result );
2657+
&output_length2 ),
2658+
expected_result );
26612659

26622660
ASSERT_COMPARE( input_data->x, input_data->len,
26632661
output_data2, output_length2 );
@@ -2782,7 +2780,8 @@ void aead_decrypt( int key_type_arg, data_t *key_data,
27822780
additional_data->len,
27832781
input_data->x, input_data->len,
27842782
output_data, output_size,
2785-
&output_length ), expected_result );
2783+
&output_length ),
2784+
expected_result );
27862785

27872786
if( expected_result == PSA_SUCCESS )
27882787
ASSERT_COMPARE( expected_data->x, expected_data->len,
@@ -2984,11 +2983,10 @@ void sign_verify( int key_type_arg, data_t *key_data,
29842983
* detected as invalid. Flip a bit at the beginning, not at the end,
29852984
* because ECDSA may ignore the last few bits of the input. */
29862985
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 );
29922990
}
29932991

29942992
exit:
@@ -3409,7 +3407,8 @@ void derive_setup( int key_type_arg,
34093407
TEST_EQUAL( psa_key_derivation( &generator, handle, alg,
34103408
salt->x, salt->len,
34113409
label->x, label->len,
3412-
requested_capacity ), expected_status );
3410+
requested_capacity ),
3411+
expected_status );
34133412

34143413
exit:
34153414
psa_generator_abort( &generator );
@@ -3455,13 +3454,13 @@ void test_derive_invalid_generator_state( )
34553454
TEST_EQUAL( psa_key_derivation( &generator, handle, alg,
34563455
NULL, 0,
34573456
NULL, 0,
3458-
capacity ), PSA_ERROR_BAD_STATE );
3457+
capacity ),
3458+
PSA_ERROR_BAD_STATE );
34593459

3460-
PSA_ASSERT( psa_generator_read( &generator, buffer, capacity )
3461-
);
3460+
PSA_ASSERT( psa_generator_read( &generator, buffer, capacity ) );
34623461

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 );
34653464

34663465
exit:
34673466
psa_generator_abort( &generator );
@@ -3649,9 +3648,8 @@ void derive_full( int alg_arg,
36493648
}
36503649

36513650
/* 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 );
36553653

36563654
PSA_ASSERT( psa_generator_abort( &generator ) );
36573655

@@ -3847,7 +3845,8 @@ void key_agreement_setup( int alg_arg,
38473845
TEST_EQUAL( psa_key_agreement( &generator,
38483846
our_key,
38493847
peer_key_data->x, peer_key_data->len,
3850-
alg ), expected_status_arg );
3848+
alg ),
3849+
expected_status_arg );
38513850

38523851
exit:
38533852
psa_generator_abort( &generator );
@@ -3946,18 +3945,16 @@ void key_agreement_output( int alg_arg,
39463945
peer_key_data->x, peer_key_data->len,
39473946
alg ) );
39483947

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 ) );
39533951
TEST_EQUAL( memcmp( actual_output, expected_output1->x,
39543952
expected_output1->len ), 0 );
39553953
if( expected_output2->len != 0 )
39563954
{
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 ) );
39613958
TEST_EQUAL( memcmp( actual_output, expected_output2->x,
39623959
expected_output2->len ), 0 );
39633960
}
@@ -4047,13 +4044,12 @@ void generate_key( int type_arg,
40474044
PSA_ASSERT( psa_set_key_policy( handle, &policy ) );
40484045

40494046
/* 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 );
40524049

40534050
/* 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 );
40574053
if( expected_info_status != PSA_SUCCESS )
40584054
goto exit;
40594055
TEST_EQUAL( got_type, type );
@@ -4144,8 +4140,10 @@ void persistent_key_load_key_from_storage( data_t *data, int type_arg,
41444140
}
41454141

41464142
/* 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 );
41494147

41504148
/* Shutdown and restart */
41514149
mbedtls_psa_crypto_free();
@@ -4160,14 +4158,14 @@ void persistent_key_load_key_from_storage( data_t *data, int type_arg,
41604158
TEST_EQUAL( bits_get, (size_t) bits );
41614159

41624160
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 );
41674163

41684164
/* 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 );
41714169

41724170
if( export_status == PSA_SUCCESS )
41734171
{

tests/suites/test_suite_psa_crypto_metadata.function

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -287,20 +287,17 @@ void aead_algorithm( int alg_arg, int classification_flags,
287287
{
288288
psa_algorithm_t truncated_alg = PSA_ALG_AEAD_WITH_TAG_LENGTH( alg, n );
289289
aead_algorithm_core( truncated_alg, classification_flags, n );
290-
TEST_EQUAL(
291-
PSA_ALG_AEAD_WITH_DEFAULT_TAG_LENGTH( truncated_alg ), alg );
290+
TEST_EQUAL( PSA_ALG_AEAD_WITH_DEFAULT_TAG_LENGTH( truncated_alg ),
291+
alg );
292292
/* Check that calling PSA_ALG_AEAD_WITH_DEFAULT_TAG_LENGTH twice gives
293293
* the length of the outer truncation (even if the outer length is
294294
* smaller than the inner length). */
295-
TEST_EQUAL(
296-
PSA_ALG_AEAD_WITH_TAG_LENGTH( truncated_alg, 1 ),
297-
PSA_ALG_AEAD_WITH_TAG_LENGTH( alg, 1 ) );
298-
TEST_EQUAL(
299-
PSA_ALG_AEAD_WITH_TAG_LENGTH( truncated_alg, tag_length - 1 ),
300-
PSA_ALG_AEAD_WITH_TAG_LENGTH( alg, tag_length - 1) );
301-
TEST_EQUAL(
302-
PSA_ALG_AEAD_WITH_TAG_LENGTH( truncated_alg, tag_length ),
303-
PSA_ALG_AEAD_WITH_TAG_LENGTH( alg, tag_length ) );
295+
TEST_EQUAL( PSA_ALG_AEAD_WITH_TAG_LENGTH( truncated_alg, 1 ),
296+
PSA_ALG_AEAD_WITH_TAG_LENGTH( alg, 1 ) );
297+
TEST_EQUAL( PSA_ALG_AEAD_WITH_TAG_LENGTH( truncated_alg, tag_length - 1 ),
298+
PSA_ALG_AEAD_WITH_TAG_LENGTH( alg, tag_length - 1) );
299+
TEST_EQUAL( PSA_ALG_AEAD_WITH_TAG_LENGTH( truncated_alg, tag_length ),
300+
PSA_ALG_AEAD_WITH_TAG_LENGTH( alg, tag_length ) );
304301
}
305302
}
306303
/* END_CASE */

tests/suites/test_suite_psa_crypto_persistent_key.function

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,8 @@ void save_large_persistent_key( int data_too_large, int expected_status )
102102
&handle ) );
103103

104104
TEST_EQUAL( psa_import_key( handle, PSA_KEY_TYPE_RAW_DATA,
105-
data, data_length ), expected_status );
105+
data, data_length ),
106+
expected_status );
106107

107108
exit:
108109
mbedtls_free( data );
@@ -143,8 +144,8 @@ void persistent_key_destroy( int key_id_arg, int should_store,
143144

144145
/* Check key slot storage is removed */
145146
TEST_EQUAL( psa_is_key_present_in_storage( key_id ), 0 );
146-
TEST_EQUAL( psa_open_key( PSA_KEY_LIFETIME_PERSISTENT, key_id,
147-
&handle ), PSA_ERROR_EMPTY_SLOT );
147+
TEST_EQUAL( psa_open_key( PSA_KEY_LIFETIME_PERSISTENT, key_id, &handle ),
148+
PSA_ERROR_EMPTY_SLOT );
148149
TEST_EQUAL( handle, 0 );
149150

150151
/* Shutdown and restart */
@@ -183,8 +184,8 @@ void persistent_key_import( int key_id_arg, int type_arg, data_t *data,
183184
PSA_BYTES_TO_BITS( data->len ),
184185
&handle ) );
185186
psa_key_policy_init( &policy );
186-
TEST_EQUAL( psa_import_key( handle, type,
187-
data->x, data->len ), expected_status );
187+
TEST_EQUAL( psa_import_key( handle, type, data->x, data->len ),
188+
expected_status );
188189

189190
if( expected_status != PSA_SUCCESS )
190191
{

0 commit comments

Comments
 (0)