Use PSA_ASSERT(a) in preference to TEST_ASSERT(a==PSA_SUCCESS)
This commit is the result of the following command, followed by
reindenting (but not wrapping lines):
perl -00 -i -pe 's/^( *)TEST_ASSERT\(([^;=]*)(?: |\n *)==\s*PSA_SUCCESS\s*\);$/${1}PSA_ASSERT($2 );/gm' tests/suites/test_suite_psa_*.function
diff --git a/tests/suites/test_suite_psa_crypto.function b/tests/suites/test_suite_psa_crypto.function
index d6b5e51..f665fb7 100644
--- a/tests/suites/test_suite_psa_crypto.function
+++ b/tests/suites/test_suite_psa_crypto.function
@@ -139,13 +139,13 @@
if( usage & PSA_KEY_USAGE_SIGN )
{
- TEST_ASSERT( psa_mac_sign_setup( &operation,
- handle, alg ) == PSA_SUCCESS );
- TEST_ASSERT( psa_mac_update( &operation,
- input, sizeof( input ) ) == PSA_SUCCESS );
- TEST_ASSERT( psa_mac_sign_finish( &operation,
- mac, sizeof( mac ),
- &mac_length ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_mac_sign_setup( &operation,
+ handle, alg ) );
+ PSA_ASSERT( psa_mac_update( &operation,
+ input, sizeof( input ) ) );
+ PSA_ASSERT( psa_mac_sign_finish( &operation,
+ mac, sizeof( mac ),
+ &mac_length ) );
}
if( usage & PSA_KEY_USAGE_VERIFY )
@@ -154,10 +154,10 @@
( usage & PSA_KEY_USAGE_SIGN ?
PSA_SUCCESS :
PSA_ERROR_INVALID_SIGNATURE );
- TEST_ASSERT( psa_mac_verify_setup( &operation,
- handle, alg ) == PSA_SUCCESS );
- TEST_ASSERT( psa_mac_update( &operation,
- input, sizeof( input ) ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_mac_verify_setup( &operation,
+ handle, alg ) );
+ PSA_ASSERT( psa_mac_update( &operation,
+ input, sizeof( input ) ) );
TEST_ASSERT( psa_mac_verify_finish( &operation,
mac,
mac_length ) == verify_status );
@@ -185,19 +185,19 @@
if( usage & PSA_KEY_USAGE_ENCRYPT )
{
- TEST_ASSERT( psa_cipher_encrypt_setup( &operation,
- handle, alg ) == PSA_SUCCESS );
- TEST_ASSERT( psa_cipher_generate_iv( &operation,
- iv, sizeof( iv ),
- &iv_length ) == PSA_SUCCESS );
- TEST_ASSERT( psa_cipher_update( &operation,
- plaintext, sizeof( plaintext ),
- ciphertext, sizeof( ciphertext ),
- &ciphertext_length ) == PSA_SUCCESS );
- TEST_ASSERT( psa_cipher_finish( &operation,
- ciphertext + ciphertext_length,
- sizeof( ciphertext ) - ciphertext_length,
- &part_length ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_cipher_encrypt_setup( &operation,
+ handle, alg ) );
+ PSA_ASSERT( psa_cipher_generate_iv( &operation,
+ iv, sizeof( iv ),
+ &iv_length ) );
+ PSA_ASSERT( psa_cipher_update( &operation,
+ plaintext, sizeof( plaintext ),
+ ciphertext, sizeof( ciphertext ),
+ &ciphertext_length ) );
+ PSA_ASSERT( psa_cipher_finish( &operation,
+ ciphertext + ciphertext_length,
+ sizeof( ciphertext ) - ciphertext_length,
+ &part_length ) );
ciphertext_length += part_length;
}
@@ -211,14 +211,14 @@
TEST_ASSERT( psa_get_key_information( handle, &type, &bits ) );
iv_length = PSA_BLOCK_CIPHER_BLOCK_SIZE( type );
}
- TEST_ASSERT( psa_cipher_decrypt_setup( &operation,
- handle, alg ) == PSA_SUCCESS );
- TEST_ASSERT( psa_cipher_set_iv( &operation,
- iv, iv_length ) == PSA_SUCCESS );
- TEST_ASSERT( psa_cipher_update( &operation,
- ciphertext, ciphertext_length,
- decrypted, sizeof( decrypted ),
- &part_length ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_cipher_decrypt_setup( &operation,
+ handle, alg ) );
+ PSA_ASSERT( psa_cipher_set_iv( &operation,
+ iv, iv_length ) );
+ PSA_ASSERT( psa_cipher_update( &operation,
+ ciphertext, ciphertext_length,
+ decrypted, sizeof( decrypted ),
+ &part_length ) );
status = psa_cipher_finish( &operation,
decrypted + part_length,
sizeof( decrypted ) - part_length,
@@ -228,7 +228,7 @@
ciphertext, a padding error is likely. */
if( ( usage & PSA_KEY_USAGE_ENCRYPT ) ||
PSA_BLOCK_CIPHER_BLOCK_SIZE( type ) == 1 )
- TEST_ASSERT( status == PSA_SUCCESS );
+ PSA_ASSERT( status );
else
TEST_ASSERT( status == PSA_SUCCESS ||
status == PSA_ERROR_INVALID_PADDING );
@@ -254,12 +254,12 @@
if( usage & PSA_KEY_USAGE_ENCRYPT )
{
- TEST_ASSERT( psa_aead_encrypt( handle, alg,
- nonce, nonce_length,
- NULL, 0,
- plaintext, sizeof( plaintext ),
- ciphertext, sizeof( ciphertext ),
- &ciphertext_length ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_aead_encrypt( handle, alg,
+ nonce, nonce_length,
+ NULL, 0,
+ plaintext, sizeof( plaintext ),
+ ciphertext, sizeof( ciphertext ),
+ &ciphertext_length ) );
}
if( usage & PSA_KEY_USAGE_DECRYPT )
@@ -299,10 +299,10 @@
psa_algorithm_t hash_alg = PSA_ALG_SIGN_GET_HASH( alg );
if( hash_alg != 0 )
payload_length = PSA_HASH_SIZE( hash_alg );
- TEST_ASSERT( psa_asymmetric_sign( handle, alg,
- payload, payload_length,
- signature, sizeof( signature ),
- &signature_length ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_asymmetric_sign( handle, alg,
+ payload, payload_length,
+ signature, sizeof( signature ),
+ &signature_length ) );
}
if( usage & PSA_KEY_USAGE_VERIFY )
@@ -334,12 +334,12 @@
if( usage & PSA_KEY_USAGE_ENCRYPT )
{
- TEST_ASSERT(
+ PSA_ASSERT(
psa_asymmetric_encrypt( handle, alg,
plaintext, plaintext_length,
NULL, 0,
ciphertext, sizeof( ciphertext ),
- &ciphertext_length ) == PSA_SUCCESS );
+ &ciphertext_length ) );
}
if( usage & PSA_KEY_USAGE_DECRYPT )
@@ -375,15 +375,15 @@
if( usage & PSA_KEY_USAGE_DERIVE )
{
- TEST_ASSERT( psa_key_derivation( &generator,
- handle, alg,
- label, label_length,
- seed, seed_length,
- sizeof( output ) ) == PSA_SUCCESS );
- TEST_ASSERT( psa_generator_read( &generator,
- output,
- sizeof( output ) ) == PSA_SUCCESS );
- TEST_ASSERT( psa_generator_abort( &generator ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_key_derivation( &generator,
+ handle, alg,
+ label, label_length,
+ seed, seed_length,
+ sizeof( output ) ) );
+ PSA_ASSERT( psa_generator_read( &generator,
+ output,
+ sizeof( output ) ) );
+ PSA_ASSERT( psa_generator_abort( &generator ) );
}
return( 1 );
@@ -408,16 +408,16 @@
* good enough: callers will report it as a failed test anyway. */
psa_status_t status = PSA_ERROR_UNKNOWN_ERROR;
- TEST_ASSERT( psa_get_key_information( handle,
- &private_key_type,
- &key_bits ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_get_key_information( handle,
+ &private_key_type,
+ &key_bits ) );
public_key_type = PSA_KEY_TYPE_PUBLIC_KEY_OF_KEYPAIR( private_key_type );
public_key_length = PSA_KEY_EXPORT_MAX_SIZE( public_key_type, key_bits );
ASSERT_ALLOC( public_key, public_key_length );
TEST_ASSERT( public_key != NULL );
- TEST_ASSERT( psa_export_public_key( handle,
- public_key, public_key_length,
- &public_key_length ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_export_public_key( handle,
+ public_key, public_key_length,
+ &public_key_length ) );
status = psa_key_agreement( generator, handle,
public_key, public_key_length,
@@ -439,12 +439,11 @@
{
/* We need two keys to exercise key agreement. Exercise the
* private key against its own public key. */
- TEST_ASSERT( key_agreement_with_self( &generator, handle, alg ) ==
- PSA_SUCCESS );
- TEST_ASSERT( psa_generator_read( &generator,
- output,
- sizeof( output ) ) == PSA_SUCCESS );
- TEST_ASSERT( psa_generator_abort( &generator ) == PSA_SUCCESS );
+ PSA_ASSERT( key_agreement_with_self( &generator, handle, alg ) );
+ PSA_ASSERT( psa_generator_read( &generator,
+ output,
+ sizeof( output ) ) );
+ PSA_ASSERT( psa_generator_abort( &generator ) );
}
ok = 1;
@@ -721,7 +720,7 @@
size_t exported_length = 0;
int ok = 0;
- TEST_ASSERT( psa_get_key_information( handle, &type, &bits ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_get_key_information( handle, &type, &bits ) );
if( ( usage & PSA_KEY_USAGE_EXPORT ) == 0 &&
! PSA_KEY_TYPE_IS_PUBLIC_KEY( type ) )
@@ -734,9 +733,9 @@
exported_size = PSA_KEY_EXPORT_MAX_SIZE( type, bits );
ASSERT_ALLOC( exported, exported_size );
- TEST_ASSERT( psa_export_key( handle,
- exported, exported_size,
- &exported_length ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_export_key( handle,
+ exported, exported_size,
+ &exported_length ) );
ok = exported_key_sanity_check( type, bits, exported, exported_length );
exit:
@@ -754,7 +753,7 @@
size_t exported_length = 0;
int ok = 0;
- TEST_ASSERT( psa_get_key_information( handle, &type, &bits ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_get_key_information( handle, &type, &bits ) );
if( ! PSA_KEY_TYPE_IS_ASYMMETRIC( type ) )
{
TEST_ASSERT( psa_export_public_key( handle,
@@ -767,9 +766,9 @@
exported_size = PSA_KEY_EXPORT_MAX_SIZE( public_type, bits );
ASSERT_ALLOC( exported, exported_size );
- TEST_ASSERT( psa_export_public_key( handle,
- exported, exported_size,
- &exported_length ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_export_public_key( handle,
+ exported, exported_size,
+ &exported_length ) );
ok = exported_key_sanity_check( public_type, bits,
exported, exported_length );
@@ -885,14 +884,14 @@
TEST_ASSERT( data != NULL );
TEST_ASSERT( PSA_CRYPTO_TEST_SIZE_T_RANGE( data->len ) );
- TEST_ASSERT( psa_crypto_init( ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_crypto_init( ) );
- TEST_ASSERT( psa_allocate_key( type, KEY_BITS_FROM_DATA( type, data ),
- &handle ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_allocate_key( type, KEY_BITS_FROM_DATA( type, data ),
+ &handle ) );
status = psa_import_key( handle, type, data->x, data->len );
TEST_ASSERT( status == expected_status );
if( status == PSA_SUCCESS )
- TEST_ASSERT( psa_destroy_key( handle ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_destroy_key( handle ) );
exit:
mbedtls_psa_crypto_free( );
@@ -916,15 +915,15 @@
psa_key_policy_t policy;
psa_status_t status;
- TEST_ASSERT( psa_crypto_init( ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_crypto_init( ) );
- TEST_ASSERT( psa_allocate_key( type1,
- MAX( KEY_BITS_FROM_DATA( type1, data1 ),
- KEY_BITS_FROM_DATA( type2, data2 ) ),
- &handle ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_allocate_key( type1,
+ MAX( KEY_BITS_FROM_DATA( type1, data1 ),
+ KEY_BITS_FROM_DATA( type2, data2 ) ),
+ &handle ) );
psa_key_policy_init( &policy );
psa_key_policy_set_usage( &policy, usage, alg );
- TEST_ASSERT( psa_set_key_policy( handle, &policy ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_set_key_policy( handle, &policy ) );
status = psa_import_key( handle, type1, data1->x, data1->len );
TEST_ASSERT( status == expected_import1_status );
@@ -958,7 +957,7 @@
int ret;
size_t length;
- TEST_ASSERT( psa_crypto_init( ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_crypto_init( ) );
ASSERT_ALLOC( buffer, buffer_size );
TEST_ASSERT( ( ret = construct_fake_rsa_key( buffer, buffer_size, &p,
@@ -966,11 +965,11 @@
length = ret;
/* Try importing the key */
- TEST_ASSERT( psa_allocate_key( type, bits, &handle ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_allocate_key( type, bits, &handle ) );
status = psa_import_key( handle, type, p, length );
TEST_ASSERT( status == expected_status );
if( status == PSA_SUCCESS )
- TEST_ASSERT( psa_destroy_key( handle ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_destroy_key( handle ) );
exit:
mbedtls_free( buffer );
@@ -1008,25 +1007,24 @@
ASSERT_ALLOC( exported, export_size );
if( ! canonical_input )
ASSERT_ALLOC( reexported, export_size );
- TEST_ASSERT( psa_crypto_init( ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_crypto_init( ) );
- TEST_ASSERT( psa_allocate_key( type, expected_bits, &handle ) ==
- PSA_SUCCESS );
+ PSA_ASSERT( psa_allocate_key( type, expected_bits, &handle ) );
psa_key_policy_init( &policy );
psa_key_policy_set_usage( &policy, usage_arg, alg );
- TEST_ASSERT( psa_set_key_policy( handle, &policy ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_set_key_policy( handle, &policy ) );
TEST_ASSERT( psa_get_key_information(
handle, NULL, NULL ) == PSA_ERROR_EMPTY_SLOT );
/* Import the key */
- TEST_ASSERT( psa_import_key( handle, type,
- data->x, data->len ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_import_key( handle, type,
+ data->x, data->len ) );
/* Test the key information */
- TEST_ASSERT( psa_get_key_information( handle,
- &got_type,
- &got_bits ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_get_key_information( handle,
+ &got_type,
+ &got_bits ) );
TEST_ASSERT( got_type == type );
TEST_ASSERT( got_bits == (size_t) expected_bits );
@@ -1058,26 +1056,25 @@
else
{
psa_key_handle_t handle2;
- TEST_ASSERT( psa_allocate_key( type, expected_bits, &handle2 ) ==
- PSA_SUCCESS );
- TEST_ASSERT( psa_set_key_policy( handle2, &policy ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_allocate_key( type, expected_bits, &handle2 ) );
+ PSA_ASSERT( psa_set_key_policy( handle2, &policy ) );
- TEST_ASSERT( psa_import_key( handle2, type,
- exported,
- exported_length ) == PSA_SUCCESS );
- TEST_ASSERT( psa_export_key( handle2,
- reexported,
- export_size,
- &reexported_length ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_import_key( handle2, type,
+ exported,
+ exported_length ) );
+ PSA_ASSERT( psa_export_key( handle2,
+ reexported,
+ export_size,
+ &reexported_length ) );
ASSERT_COMPARE( exported, exported_length,
reexported, reexported_length );
- TEST_ASSERT( psa_close_key( handle2 ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_close_key( handle2 ) );
}
TEST_ASSERT( exported_length <= PSA_KEY_EXPORT_MAX_SIZE( type, got_bits ) );
destroy:
/* Destroy the key */
- TEST_ASSERT( psa_destroy_key( handle ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_destroy_key( handle ) );
TEST_ASSERT( psa_get_key_information(
handle, NULL, NULL ) == PSA_ERROR_INVALID_HANDLE );
@@ -1095,14 +1092,14 @@
psa_key_type_t type = PSA_KEY_TYPE_RAW_DATA;
psa_status_t status;
const uint8_t data[] = { 0x1, 0x2, 0x3, 0x4, 0x5 };
- TEST_ASSERT( psa_crypto_init( ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_crypto_init( ) );
- TEST_ASSERT( psa_allocate_key( type, PSA_BYTES_TO_BITS( sizeof( data ) ),
- &handle ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_allocate_key( type, PSA_BYTES_TO_BITS( sizeof( data ) ),
+ &handle ) );
/* Import the key */
- TEST_ASSERT( psa_import_key( handle, type,
- data, sizeof( data ) ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_import_key( handle, type,
+ data, sizeof( data ) ) );
/* Import the key again */
status = psa_import_key( handle, type, data, sizeof( data ) );
@@ -1122,7 +1119,7 @@
size_t exported_length = INVALID_EXPORT_LENGTH;
psa_status_t expected_export_status = expected_export_status_arg;
- TEST_ASSERT( psa_crypto_init( ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_crypto_init( ) );
/* Export the key */
status = psa_export_key( (psa_key_handle_t) handle,
@@ -1146,13 +1143,13 @@
size_t export_size = 0;
size_t exported_length = INVALID_EXPORT_LENGTH;
- TEST_ASSERT( psa_crypto_init( ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_crypto_init( ) );
- TEST_ASSERT( psa_allocate_key( PSA_KEY_TYPE_RAW_DATA, 0,
- &handle ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_allocate_key( PSA_KEY_TYPE_RAW_DATA, 0,
+ &handle ) );
psa_key_policy_init( &policy );
psa_key_policy_set_usage( &policy, PSA_KEY_USAGE_EXPORT, alg );
- TEST_ASSERT( psa_set_key_policy( handle, &policy ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_set_key_policy( handle, &policy ) );
/* Export the key */
status = psa_export_key( handle,
@@ -1174,13 +1171,13 @@
psa_cipher_operation_t operation;
int exercise_alg = PSA_ALG_CTR;
- TEST_ASSERT( psa_crypto_init( ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_crypto_init( ) );
- TEST_ASSERT( psa_allocate_key( PSA_KEY_TYPE_RAW_DATA, 0,
- &handle ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_allocate_key( PSA_KEY_TYPE_RAW_DATA, 0,
+ &handle ) );
psa_key_policy_init( &policy );
psa_key_policy_set_usage( &policy, PSA_KEY_USAGE_ENCRYPT, exercise_alg );
- TEST_ASSERT( psa_set_key_policy( handle, &policy ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_set_key_policy( handle, &policy ) );
status = psa_cipher_encrypt_setup( &operation, handle, exercise_alg );
TEST_ASSERT( status == PSA_ERROR_EMPTY_SLOT );
@@ -1203,10 +1200,10 @@
psa_status_t expected_import_status = expected_import_status_arg;
size_t exported_length = INVALID_EXPORT_LENGTH;
- TEST_ASSERT( psa_crypto_init( ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_crypto_init( ) );
- TEST_ASSERT( psa_allocate_key( type, KEY_BITS_FROM_DATA( type, data ),
- &handle ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_allocate_key( type, KEY_BITS_FROM_DATA( type, data ),
+ &handle ) );
/* Import the key - expect failure */
status = psa_import_key( handle, type,
@@ -1235,10 +1232,10 @@
psa_status_t expected_import_status = expected_import_status_arg;
int exercise_alg = PSA_ALG_CTR;
- TEST_ASSERT( psa_crypto_init( ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_crypto_init( ) );
- TEST_ASSERT( psa_allocate_key( type, KEY_BITS_FROM_DATA( type, data ),
- &handle ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_allocate_key( type, KEY_BITS_FROM_DATA( type, data ),
+ &handle ) );
/* Import the key - expect failure */
status = psa_import_key( handle, type,
@@ -1266,25 +1263,25 @@
size_t export_size = 0;
size_t exported_length = INVALID_EXPORT_LENGTH;
- TEST_ASSERT( psa_crypto_init( ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_crypto_init( ) );
- TEST_ASSERT( psa_allocate_key( type, KEY_BITS_FROM_DATA( type, data ),
- &handle ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_allocate_key( type, KEY_BITS_FROM_DATA( type, data ),
+ &handle ) );
psa_key_policy_init( &policy );
psa_key_policy_set_usage( &policy, PSA_KEY_USAGE_EXPORT, alg );
- TEST_ASSERT( psa_set_key_policy( handle, &policy ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_set_key_policy( handle, &policy ) );
export_size = (ptrdiff_t) data->len;
ASSERT_ALLOC( exported, export_size );
/* Import the key */
- TEST_ASSERT( psa_import_key( handle, type,
- data->x, data->len ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_import_key( handle, type,
+ data->x, data->len ) );
- TEST_ASSERT( psa_export_key( handle, exported, export_size,
- &exported_length ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_export_key( handle, exported, export_size,
+ &exported_length ) );
/* Destroy the key */
- TEST_ASSERT( psa_destroy_key( handle ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_destroy_key( handle ) );
/* Export the key */
status = psa_export_key( handle, exported, export_size,
@@ -1315,17 +1312,17 @@
size_t exported_length = INVALID_EXPORT_LENGTH;
psa_key_policy_t policy;
- TEST_ASSERT( psa_crypto_init( ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_crypto_init( ) );
- TEST_ASSERT( psa_allocate_key( type, KEY_BITS_FROM_DATA( type, data ),
- &handle ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_allocate_key( type, KEY_BITS_FROM_DATA( type, data ),
+ &handle ) );
psa_key_policy_init( &policy );
psa_key_policy_set_usage( &policy, PSA_KEY_USAGE_EXPORT, alg );
- TEST_ASSERT( psa_set_key_policy( handle, &policy ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_set_key_policy( handle, &policy ) );
/* Import the key */
- TEST_ASSERT( psa_import_key( handle, type,
- data->x, data->len ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_import_key( handle, type,
+ data->x, data->len ) );
/* Export the public key */
ASSERT_ALLOC( exported, export_size );
@@ -1337,8 +1334,7 @@
{
psa_key_type_t public_type = PSA_KEY_TYPE_PUBLIC_KEY_OF_KEYPAIR( type );
size_t bits;
- TEST_ASSERT( psa_get_key_information( handle, NULL, &bits ) ==
- PSA_SUCCESS );
+ PSA_ASSERT( psa_get_key_information( handle, NULL, &bits ) );
TEST_ASSERT( expected_public_key->len <=
PSA_KEY_EXPORT_MAX_SIZE( public_type, bits ) );
ASSERT_COMPARE( expected_public_key->x, expected_public_key->len,
@@ -1368,22 +1364,22 @@
size_t got_bits;
psa_status_t status;
- TEST_ASSERT( psa_crypto_init( ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_crypto_init( ) );
- TEST_ASSERT( psa_allocate_key( type, KEY_BITS_FROM_DATA( type, data ),
- &handle ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_allocate_key( type, KEY_BITS_FROM_DATA( type, data ),
+ &handle ) );
psa_key_policy_init( &policy );
psa_key_policy_set_usage( &policy, usage, alg );
- TEST_ASSERT( psa_set_key_policy( handle, &policy ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_set_key_policy( handle, &policy ) );
/* Import the key */
status = psa_import_key( handle, type, data->x, data->len );
- TEST_ASSERT( status == PSA_SUCCESS );
+ PSA_ASSERT( status );
/* Test the key information */
- TEST_ASSERT( psa_get_key_information( handle,
- &got_type,
- &got_bits ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_get_key_information( handle,
+ &got_type,
+ &got_bits ) );
TEST_ASSERT( got_type == type );
TEST_ASSERT( got_bits == bits );
@@ -1410,22 +1406,22 @@
memset( key, 0x2a, sizeof( key ) );
- TEST_ASSERT( psa_crypto_init( ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_crypto_init( ) );
- TEST_ASSERT( psa_allocate_key( key_type, PSA_BYTES_TO_BITS( sizeof( key ) ),
- &handle ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_allocate_key( key_type, PSA_BYTES_TO_BITS( sizeof( key ) ),
+ &handle ) );
psa_key_policy_init( &policy_set );
psa_key_policy_init( &policy_get );
psa_key_policy_set_usage( &policy_set, usage, alg );
TEST_ASSERT( psa_key_policy_get_usage( &policy_set ) == usage );
TEST_ASSERT( psa_key_policy_get_algorithm( &policy_set ) == alg );
- TEST_ASSERT( psa_set_key_policy( handle, &policy_set ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_set_key_policy( handle, &policy_set ) );
- TEST_ASSERT( psa_import_key( handle, key_type,
- key, sizeof( key ) ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_import_key( handle, key_type,
+ key, sizeof( key ) ) );
- TEST_ASSERT( psa_get_key_policy( handle, &policy_get ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_get_key_policy( handle, &policy_get ) );
TEST_ASSERT( policy_get.usage == policy_set.usage );
TEST_ASSERT( policy_get.alg == policy_set.alg );
@@ -1449,22 +1445,22 @@
psa_status_t status;
unsigned char mac[PSA_MAC_MAX_SIZE];
- TEST_ASSERT( psa_crypto_init( ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_crypto_init( ) );
- TEST_ASSERT( psa_allocate_key( key_type,
- KEY_BITS_FROM_DATA( key_type, key_data ),
- &handle ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_allocate_key( key_type,
+ KEY_BITS_FROM_DATA( key_type, key_data ),
+ &handle ) );
psa_key_policy_init( &policy );
psa_key_policy_set_usage( &policy, policy_usage, policy_alg );
- TEST_ASSERT( psa_set_key_policy( handle, &policy ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_set_key_policy( handle, &policy ) );
- TEST_ASSERT( psa_import_key( handle, key_type,
- key_data->x, key_data->len ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_import_key( handle, key_type,
+ key_data->x, key_data->len ) );
status = psa_mac_sign_setup( &operation, handle, exercise_alg );
if( policy_alg == exercise_alg &&
( policy_usage & PSA_KEY_USAGE_SIGN ) != 0 )
- TEST_ASSERT( status == PSA_SUCCESS );
+ PSA_ASSERT( status );
else
TEST_ASSERT( status == PSA_ERROR_NOT_PERMITTED );
psa_mac_abort( &operation );
@@ -1473,7 +1469,7 @@
status = psa_mac_verify_setup( &operation, handle, exercise_alg );
if( policy_alg == exercise_alg &&
( policy_usage & PSA_KEY_USAGE_VERIFY ) != 0 )
- TEST_ASSERT( status == PSA_SUCCESS );
+ PSA_ASSERT( status );
else
TEST_ASSERT( status == PSA_ERROR_NOT_PERMITTED );
@@ -1496,22 +1492,22 @@
psa_cipher_operation_t operation;
psa_status_t status;
- TEST_ASSERT( psa_crypto_init( ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_crypto_init( ) );
- TEST_ASSERT( psa_allocate_key( key_type,
- KEY_BITS_FROM_DATA( key_type, key_data ),
- &handle ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_allocate_key( key_type,
+ KEY_BITS_FROM_DATA( key_type, key_data ),
+ &handle ) );
psa_key_policy_init( &policy );
psa_key_policy_set_usage( &policy, policy_usage, policy_alg );
- TEST_ASSERT( psa_set_key_policy( handle, &policy ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_set_key_policy( handle, &policy ) );
- TEST_ASSERT( psa_import_key( handle, key_type,
- key_data->x, key_data->len ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_import_key( handle, key_type,
+ key_data->x, key_data->len ) );
status = psa_cipher_encrypt_setup( &operation, handle, exercise_alg );
if( policy_alg == exercise_alg &&
( policy_usage & PSA_KEY_USAGE_ENCRYPT ) != 0 )
- TEST_ASSERT( status == PSA_SUCCESS );
+ PSA_ASSERT( status );
else
TEST_ASSERT( status == PSA_ERROR_NOT_PERMITTED );
psa_cipher_abort( &operation );
@@ -1519,7 +1515,7 @@
status = psa_cipher_decrypt_setup( &operation, handle, exercise_alg );
if( policy_alg == exercise_alg &&
( policy_usage & PSA_KEY_USAGE_DECRYPT ) != 0 )
- TEST_ASSERT( status == PSA_SUCCESS );
+ PSA_ASSERT( status );
else
TEST_ASSERT( status == PSA_ERROR_NOT_PERMITTED );
@@ -1551,17 +1547,17 @@
TEST_ASSERT( nonce_length <= sizeof( nonce ) );
TEST_ASSERT( tag_length <= sizeof( tag ) );
- TEST_ASSERT( psa_crypto_init( ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_crypto_init( ) );
- TEST_ASSERT( psa_allocate_key( key_type,
- KEY_BITS_FROM_DATA( key_type, key_data ),
- &handle ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_allocate_key( key_type,
+ KEY_BITS_FROM_DATA( key_type, key_data ),
+ &handle ) );
psa_key_policy_init( &policy );
psa_key_policy_set_usage( &policy, policy_usage, policy_alg );
- TEST_ASSERT( psa_set_key_policy( handle, &policy ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_set_key_policy( handle, &policy ) );
- TEST_ASSERT( psa_import_key( handle, key_type,
- key_data->x, key_data->len ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_import_key( handle, key_type,
+ key_data->x, key_data->len ) );
status = psa_aead_encrypt( handle, exercise_alg,
nonce, nonce_length,
@@ -1571,7 +1567,7 @@
&output_length );
if( policy_alg == exercise_alg &&
( policy_usage & PSA_KEY_USAGE_ENCRYPT ) != 0 )
- TEST_ASSERT( status == PSA_SUCCESS );
+ PSA_ASSERT( status );
else
TEST_ASSERT( status == PSA_ERROR_NOT_PERMITTED );
@@ -1609,21 +1605,21 @@
unsigned char *buffer = NULL;
size_t output_length;
- TEST_ASSERT( psa_crypto_init( ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_crypto_init( ) );
- TEST_ASSERT( psa_allocate_key( key_type,
- KEY_BITS_FROM_DATA( key_type, key_data ),
- &handle ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_allocate_key( key_type,
+ KEY_BITS_FROM_DATA( key_type, key_data ),
+ &handle ) );
psa_key_policy_init( &policy );
psa_key_policy_set_usage( &policy, policy_usage, policy_alg );
- TEST_ASSERT( psa_set_key_policy( handle, &policy ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_set_key_policy( handle, &policy ) );
- TEST_ASSERT( psa_import_key( handle, key_type,
- key_data->x, key_data->len ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_import_key( handle, key_type,
+ key_data->x, key_data->len ) );
- TEST_ASSERT( psa_get_key_information( handle,
- NULL,
- &key_bits ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_get_key_information( handle,
+ NULL,
+ &key_bits ) );
buffer_length = PSA_ASYMMETRIC_ENCRYPT_OUTPUT_SIZE( key_type, key_bits,
exercise_alg );
ASSERT_ALLOC( buffer, buffer_length );
@@ -1635,7 +1631,7 @@
&output_length );
if( policy_alg == exercise_alg &&
( policy_usage & PSA_KEY_USAGE_ENCRYPT ) != 0 )
- TEST_ASSERT( status == PSA_SUCCESS );
+ PSA_ASSERT( status );
else
TEST_ASSERT( status == PSA_ERROR_NOT_PERMITTED );
@@ -1674,17 +1670,17 @@
unsigned char signature[PSA_ASYMMETRIC_SIGNATURE_MAX_SIZE] = {0};
size_t signature_length;
- TEST_ASSERT( psa_crypto_init( ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_crypto_init( ) );
- TEST_ASSERT( psa_allocate_key( key_type,
- KEY_BITS_FROM_DATA( key_type, key_data ),
- &handle ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_allocate_key( key_type,
+ KEY_BITS_FROM_DATA( key_type, key_data ),
+ &handle ) );
psa_key_policy_init( &policy );
psa_key_policy_set_usage( &policy, policy_usage, policy_alg );
- TEST_ASSERT( psa_set_key_policy( handle, &policy ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_set_key_policy( handle, &policy ) );
- TEST_ASSERT( psa_import_key( handle, key_type,
- key_data->x, key_data->len ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_import_key( handle, key_type,
+ key_data->x, key_data->len ) );
status = psa_asymmetric_sign( handle, exercise_alg,
payload, payload_length,
@@ -1692,7 +1688,7 @@
&signature_length );
if( policy_alg == exercise_alg &&
( policy_usage & PSA_KEY_USAGE_SIGN ) != 0 )
- TEST_ASSERT( status == PSA_SUCCESS );
+ PSA_ASSERT( status );
else
TEST_ASSERT( status == PSA_ERROR_NOT_PERMITTED );
@@ -1724,17 +1720,17 @@
psa_crypto_generator_t generator = PSA_CRYPTO_GENERATOR_INIT;
psa_status_t status;
- TEST_ASSERT( psa_crypto_init( ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_crypto_init( ) );
- TEST_ASSERT( psa_allocate_key( key_type,
- KEY_BITS_FROM_DATA( key_type, key_data ),
- &handle ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_allocate_key( key_type,
+ KEY_BITS_FROM_DATA( key_type, key_data ),
+ &handle ) );
psa_key_policy_init( &policy );
psa_key_policy_set_usage( &policy, policy_usage, policy_alg );
- TEST_ASSERT( psa_set_key_policy( handle, &policy ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_set_key_policy( handle, &policy ) );
- TEST_ASSERT( psa_import_key( handle, key_type,
- key_data->x, key_data->len ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_import_key( handle, key_type,
+ key_data->x, key_data->len ) );
status = psa_key_derivation( &generator, handle,
exercise_alg,
@@ -1743,7 +1739,7 @@
1 );
if( policy_alg == exercise_alg &&
( policy_usage & PSA_KEY_USAGE_DERIVE ) != 0 )
- TEST_ASSERT( status == PSA_SUCCESS );
+ PSA_ASSERT( status );
else
TEST_ASSERT( status == PSA_ERROR_NOT_PERMITTED );
@@ -1767,23 +1763,23 @@
psa_crypto_generator_t generator = PSA_CRYPTO_GENERATOR_INIT;
psa_status_t status;
- TEST_ASSERT( psa_crypto_init( ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_crypto_init( ) );
- TEST_ASSERT( psa_allocate_key( key_type,
- KEY_BITS_FROM_DATA( key_type, key_data ),
- &handle ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_allocate_key( key_type,
+ KEY_BITS_FROM_DATA( key_type, key_data ),
+ &handle ) );
psa_key_policy_init( &policy );
psa_key_policy_set_usage( &policy, policy_usage, policy_alg );
- TEST_ASSERT( psa_set_key_policy( handle, &policy ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_set_key_policy( handle, &policy ) );
- TEST_ASSERT( psa_import_key( handle, key_type,
- key_data->x, key_data->len ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_import_key( handle, key_type,
+ key_data->x, key_data->len ) );
status = key_agreement_with_self( &generator, handle, exercise_alg );
if( policy_alg == exercise_alg &&
( policy_usage & PSA_KEY_USAGE_DERIVE ) != 0 )
- TEST_ASSERT( status == PSA_SUCCESS );
+ PSA_ASSERT( status );
else
TEST_ASSERT( status == PSA_ERROR_NOT_PERMITTED );
@@ -1803,7 +1799,7 @@
psa_hash_operation_t operation;
psa_status_t status;
- TEST_ASSERT( psa_crypto_init( ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_crypto_init( ) );
status = psa_hash_setup( &operation, alg );
psa_hash_abort( &operation );
@@ -1826,7 +1822,7 @@
size_t hash_len;
psa_hash_operation_t operation;
- TEST_ASSERT( psa_crypto_init( ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_crypto_init( ) );
/* psa_hash_update without calling psa_hash_setup beforehand */
memset( &operation, 0, sizeof( operation ) );
@@ -1864,22 +1860,22 @@
size_t expected_size = PSA_HASH_SIZE( alg );
psa_hash_operation_t operation;
- TEST_ASSERT( psa_crypto_init( ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_crypto_init( ) );
/* psa_hash_verify with a smaller hash than expected */
- TEST_ASSERT( psa_hash_setup( &operation, alg ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_hash_setup( &operation, alg ) );
TEST_ASSERT( psa_hash_verify( &operation,
hash, expected_size - 1 ) ==
PSA_ERROR_INVALID_SIGNATURE );
/* psa_hash_verify with a non-matching hash */
- TEST_ASSERT( psa_hash_setup( &operation, alg ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_hash_setup( &operation, alg ) );
TEST_ASSERT( psa_hash_verify( &operation,
hash + 1, expected_size ) ==
PSA_ERROR_INVALID_SIGNATURE );
/* psa_hash_verify with a hash longer than expected */
- TEST_ASSERT( psa_hash_setup( &operation, alg ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_hash_setup( &operation, alg ) );
TEST_ASSERT( psa_hash_verify( &operation,
hash, sizeof( hash ) ) ==
PSA_ERROR_INVALID_SIGNATURE );
@@ -1898,10 +1894,10 @@
psa_hash_operation_t operation;
size_t hash_len;
- TEST_ASSERT( psa_crypto_init( ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_crypto_init( ) );
/* psa_hash_finish with a smaller hash buffer than expected */
- TEST_ASSERT( psa_hash_setup( &operation, alg ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_hash_setup( &operation, alg ) );
TEST_ASSERT( psa_hash_finish( &operation,
hash, expected_size - 1,
&hash_len ) == PSA_ERROR_BUFFER_TOO_SMALL );
@@ -1925,18 +1921,18 @@
psa_key_policy_t policy;
psa_status_t status;
- TEST_ASSERT( psa_crypto_init( ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_crypto_init( ) );
- TEST_ASSERT( psa_allocate_key( key_type, PSA_BYTES_TO_BITS( key->len ),
- &handle ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_allocate_key( key_type, PSA_BYTES_TO_BITS( key->len ),
+ &handle ) );
psa_key_policy_init( &policy );
psa_key_policy_set_usage( &policy,
PSA_KEY_USAGE_SIGN | PSA_KEY_USAGE_VERIFY,
alg );
- TEST_ASSERT( psa_set_key_policy( handle, &policy ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_set_key_policy( handle, &policy ) );
- TEST_ASSERT( psa_import_key( handle, key_type,
- key->x, key->len ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_import_key( handle, key_type,
+ key->x, key->len ) );
status = psa_mac_sign_setup( &operation, handle, alg );
psa_mac_abort( &operation );
@@ -1972,25 +1968,25 @@
TEST_ASSERT( mac_buffer_size <= PSA_MAC_MAX_SIZE );
TEST_ASSERT( expected_mac->len <= mac_buffer_size );
- TEST_ASSERT( psa_crypto_init( ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_crypto_init( ) );
- TEST_ASSERT( psa_allocate_key( key_type, PSA_BYTES_TO_BITS( key->len ),
- &handle ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_allocate_key( key_type, PSA_BYTES_TO_BITS( key->len ),
+ &handle ) );
psa_key_policy_init( &policy );
psa_key_policy_set_usage( &policy, PSA_KEY_USAGE_SIGN, alg );
- TEST_ASSERT( psa_set_key_policy( handle, &policy ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_set_key_policy( handle, &policy ) );
- TEST_ASSERT( psa_import_key( handle, key_type,
- key->x, key->len ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_import_key( handle, key_type,
+ key->x, key->len ) );
/* Calculate the MAC. */
- TEST_ASSERT( psa_mac_sign_setup( &operation,
- handle, alg ) == PSA_SUCCESS );
- TEST_ASSERT( psa_mac_update( &operation,
- input->x, input->len ) == PSA_SUCCESS );
- TEST_ASSERT( psa_mac_sign_finish( &operation,
- actual_mac, mac_buffer_size,
- &mac_length ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_mac_sign_setup( &operation,
+ handle, alg ) );
+ PSA_ASSERT( psa_mac_update( &operation,
+ input->x, input->len ) );
+ PSA_ASSERT( psa_mac_sign_finish( &operation,
+ actual_mac, mac_buffer_size,
+ &mac_length ) );
/* Compare with the expected value. */
TEST_ASSERT( mac_length == expected_mac->len );
@@ -2028,25 +2024,25 @@
TEST_ASSERT( PSA_CRYPTO_TEST_SIZE_T_RANGE( input->len ) );
TEST_ASSERT( PSA_CRYPTO_TEST_SIZE_T_RANGE( expected_mac->len ) );
- TEST_ASSERT( psa_crypto_init( ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_crypto_init( ) );
- TEST_ASSERT( psa_allocate_key( key_type, PSA_BYTES_TO_BITS( key->len ),
- &handle ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_allocate_key( key_type, PSA_BYTES_TO_BITS( key->len ),
+ &handle ) );
psa_key_policy_init( &policy );
psa_key_policy_set_usage( &policy, PSA_KEY_USAGE_VERIFY, alg );
- TEST_ASSERT( psa_set_key_policy( handle, &policy ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_set_key_policy( handle, &policy ) );
- TEST_ASSERT( psa_import_key( handle, key_type,
- key->x, key->len ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_import_key( handle, key_type,
+ key->x, key->len ) );
- TEST_ASSERT( psa_mac_verify_setup( &operation,
- handle, alg ) == PSA_SUCCESS );
- TEST_ASSERT( psa_destroy_key( handle ) == PSA_SUCCESS );
- TEST_ASSERT( psa_mac_update( &operation,
- input->x, input->len ) == PSA_SUCCESS );
- TEST_ASSERT( psa_mac_verify_finish( &operation,
- expected_mac->x,
- expected_mac->len ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_mac_verify_setup( &operation,
+ handle, alg ) );
+ PSA_ASSERT( psa_destroy_key( handle ) );
+ PSA_ASSERT( psa_mac_update( &operation,
+ input->x, input->len ) );
+ PSA_ASSERT( psa_mac_verify_finish( &operation,
+ expected_mac->x,
+ expected_mac->len ) );
exit:
psa_destroy_key( handle );
@@ -2068,16 +2064,16 @@
psa_key_policy_t policy;
psa_status_t status;
- TEST_ASSERT( psa_crypto_init( ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_crypto_init( ) );
- TEST_ASSERT( psa_allocate_key( key_type, PSA_BYTES_TO_BITS( key->len ),
- &handle ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_allocate_key( key_type, PSA_BYTES_TO_BITS( key->len ),
+ &handle ) );
psa_key_policy_init( &policy );
psa_key_policy_set_usage( &policy, PSA_KEY_USAGE_ENCRYPT, alg );
- TEST_ASSERT( psa_set_key_policy( handle, &policy ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_set_key_policy( handle, &policy ) );
- TEST_ASSERT( psa_import_key( handle, key_type,
- key->x, key->len ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_import_key( handle, key_type,
+ key->x, key->len ) );
status = psa_cipher_encrypt_setup( &operation, handle, alg );
psa_cipher_abort( &operation );
@@ -2119,30 +2115,30 @@
iv_size = PSA_BLOCK_CIPHER_BLOCK_SIZE( key_type );
memset( iv, 0x2a, iv_size );
- TEST_ASSERT( psa_crypto_init( ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_crypto_init( ) );
- TEST_ASSERT( psa_allocate_key( key_type, PSA_BYTES_TO_BITS( key->len ),
- &handle ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_allocate_key( key_type, PSA_BYTES_TO_BITS( key->len ),
+ &handle ) );
psa_key_policy_init( &policy );
psa_key_policy_set_usage( &policy, PSA_KEY_USAGE_ENCRYPT, alg );
- TEST_ASSERT( psa_set_key_policy( handle, &policy ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_set_key_policy( handle, &policy ) );
- TEST_ASSERT( psa_import_key( handle, key_type,
- key->x, key->len ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_import_key( handle, key_type,
+ key->x, key->len ) );
- TEST_ASSERT( psa_cipher_encrypt_setup( &operation,
- handle, alg ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_cipher_encrypt_setup( &operation,
+ handle, alg ) );
- TEST_ASSERT( psa_cipher_set_iv( &operation,
- iv, iv_size ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_cipher_set_iv( &operation,
+ iv, iv_size ) );
output_buffer_size = ( (size_t) input->len +
PSA_BLOCK_CIPHER_BLOCK_SIZE( key_type ) );
ASSERT_ALLOC( output, output_buffer_size );
- TEST_ASSERT( psa_cipher_update( &operation,
- input->x, input->len,
- output, output_buffer_size,
- &function_output_length ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_cipher_update( &operation,
+ input->x, input->len,
+ output, output_buffer_size,
+ &function_output_length ) );
total_output_length += function_output_length;
status = psa_cipher_finish( &operation,
output + function_output_length,
@@ -2153,7 +2149,7 @@
TEST_ASSERT( status == expected_status );
if( expected_status == PSA_SUCCESS )
{
- TEST_ASSERT( psa_cipher_abort( &operation ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_cipher_abort( &operation ) );
ASSERT_COMPARE( expected_output->x, expected_output->len,
output, total_output_length );
}
@@ -2194,43 +2190,43 @@
iv_size = PSA_BLOCK_CIPHER_BLOCK_SIZE( key_type );
memset( iv, 0x2a, iv_size );
- TEST_ASSERT( psa_crypto_init( ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_crypto_init( ) );
- TEST_ASSERT( psa_allocate_key( key_type, PSA_BYTES_TO_BITS( key->len ),
- &handle ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_allocate_key( key_type, PSA_BYTES_TO_BITS( key->len ),
+ &handle ) );
psa_key_policy_init( &policy );
psa_key_policy_set_usage( &policy, PSA_KEY_USAGE_ENCRYPT, alg );
- TEST_ASSERT( psa_set_key_policy( handle, &policy ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_set_key_policy( handle, &policy ) );
- TEST_ASSERT( psa_import_key( handle, key_type,
- key->x, key->len ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_import_key( handle, key_type,
+ key->x, key->len ) );
- TEST_ASSERT( psa_cipher_encrypt_setup( &operation,
- handle, alg ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_cipher_encrypt_setup( &operation,
+ handle, alg ) );
- TEST_ASSERT( psa_cipher_set_iv( &operation,
- iv, sizeof( iv ) ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_cipher_set_iv( &operation,
+ iv, sizeof( iv ) ) );
output_buffer_size = ( (size_t) input->len +
PSA_BLOCK_CIPHER_BLOCK_SIZE( key_type ) );
ASSERT_ALLOC( output, output_buffer_size );
TEST_ASSERT( (unsigned int) first_part_size < input->len );
- TEST_ASSERT( psa_cipher_update( &operation, input->x, first_part_size,
- output, output_buffer_size,
- &function_output_length ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_cipher_update( &operation, input->x, first_part_size,
+ output, output_buffer_size,
+ &function_output_length ) );
total_output_length += function_output_length;
- TEST_ASSERT( psa_cipher_update( &operation,
- input->x + first_part_size,
- input->len - first_part_size,
- output, output_buffer_size,
- &function_output_length ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_cipher_update( &operation,
+ input->x + first_part_size,
+ input->len - first_part_size,
+ output, output_buffer_size,
+ &function_output_length ) );
total_output_length += function_output_length;
- TEST_ASSERT( psa_cipher_finish( &operation,
- output + function_output_length,
- output_buffer_size,
- &function_output_length ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_cipher_finish( &operation,
+ output + function_output_length,
+ output_buffer_size,
+ &function_output_length ) );
total_output_length += function_output_length;
- TEST_ASSERT( psa_cipher_abort( &operation ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_cipher_abort( &operation ) );
ASSERT_COMPARE( expected_output->x, expected_output->len,
output, total_output_length );
@@ -2272,45 +2268,45 @@
iv_size = PSA_BLOCK_CIPHER_BLOCK_SIZE( key_type );
memset( iv, 0x2a, iv_size );
- TEST_ASSERT( psa_crypto_init( ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_crypto_init( ) );
- TEST_ASSERT( psa_allocate_key( key_type, PSA_BYTES_TO_BITS( key->len ),
- &handle ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_allocate_key( key_type, PSA_BYTES_TO_BITS( key->len ),
+ &handle ) );
psa_key_policy_init( &policy );
psa_key_policy_set_usage( &policy, PSA_KEY_USAGE_DECRYPT, alg );
- TEST_ASSERT( psa_set_key_policy( handle, &policy ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_set_key_policy( handle, &policy ) );
- TEST_ASSERT( psa_import_key( handle, key_type,
- key->x, key->len ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_import_key( handle, key_type,
+ key->x, key->len ) );
- TEST_ASSERT( psa_cipher_decrypt_setup( &operation,
- handle, alg ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_cipher_decrypt_setup( &operation,
+ handle, alg ) );
- TEST_ASSERT( psa_cipher_set_iv( &operation,
- iv, sizeof( iv ) ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_cipher_set_iv( &operation,
+ iv, sizeof( iv ) ) );
output_buffer_size = ( (size_t) input->len +
PSA_BLOCK_CIPHER_BLOCK_SIZE( key_type ) );
ASSERT_ALLOC( output, output_buffer_size );
TEST_ASSERT( (unsigned int) first_part_size < input->len );
- TEST_ASSERT( psa_cipher_update( &operation,
- input->x, first_part_size,
- output, output_buffer_size,
- &function_output_length ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_cipher_update( &operation,
+ input->x, first_part_size,
+ output, output_buffer_size,
+ &function_output_length ) );
total_output_length += function_output_length;
- TEST_ASSERT( psa_cipher_update( &operation,
- input->x + first_part_size,
- input->len - first_part_size,
- output, output_buffer_size,
- &function_output_length ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_cipher_update( &operation,
+ input->x + first_part_size,
+ input->len - first_part_size,
+ output, output_buffer_size,
+ &function_output_length ) );
total_output_length += function_output_length;
- TEST_ASSERT( psa_cipher_finish( &operation,
- output + function_output_length,
- output_buffer_size,
- &function_output_length ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_cipher_finish( &operation,
+ output + function_output_length,
+ output_buffer_size,
+ &function_output_length ) );
total_output_length += function_output_length;
- TEST_ASSERT( psa_cipher_abort( &operation ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_cipher_abort( &operation ) );
ASSERT_COMPARE( expected_output->x, expected_output->len,
output, total_output_length );
@@ -2352,31 +2348,31 @@
iv_size = PSA_BLOCK_CIPHER_BLOCK_SIZE( key_type );
memset( iv, 0x2a, iv_size );
- TEST_ASSERT( psa_crypto_init( ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_crypto_init( ) );
- TEST_ASSERT( psa_allocate_key( key_type, PSA_BYTES_TO_BITS( key->len ),
- &handle ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_allocate_key( key_type, PSA_BYTES_TO_BITS( key->len ),
+ &handle ) );
psa_key_policy_init( &policy );
psa_key_policy_set_usage( &policy, PSA_KEY_USAGE_DECRYPT, alg );
- TEST_ASSERT( psa_set_key_policy( handle, &policy ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_set_key_policy( handle, &policy ) );
- TEST_ASSERT( psa_import_key( handle, key_type,
- key->x, key->len ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_import_key( handle, key_type,
+ key->x, key->len ) );
- TEST_ASSERT( psa_cipher_decrypt_setup( &operation,
- handle, alg ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_cipher_decrypt_setup( &operation,
+ handle, alg ) );
- TEST_ASSERT( psa_cipher_set_iv( &operation,
- iv, iv_size ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_cipher_set_iv( &operation,
+ iv, iv_size ) );
output_buffer_size = ( (size_t) input->len +
PSA_BLOCK_CIPHER_BLOCK_SIZE( key_type ) );
ASSERT_ALLOC( output, output_buffer_size );
- TEST_ASSERT( psa_cipher_update( &operation,
- input->x, input->len,
- output, output_buffer_size,
- &function_output_length ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_cipher_update( &operation,
+ input->x, input->len,
+ output, output_buffer_size,
+ &function_output_length ) );
total_output_length += function_output_length;
status = psa_cipher_finish( &operation,
output + function_output_length,
@@ -2387,7 +2383,7 @@
if( expected_status == PSA_SUCCESS )
{
- TEST_ASSERT( psa_cipher_abort( &operation ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_cipher_abort( &operation ) );
ASSERT_COMPARE( expected_output->x, expected_output->len,
output, total_output_length );
}
@@ -2426,57 +2422,57 @@
TEST_ASSERT( PSA_CRYPTO_TEST_SIZE_T_RANGE( key->len ) );
TEST_ASSERT( PSA_CRYPTO_TEST_SIZE_T_RANGE( input->len ) );
- TEST_ASSERT( psa_crypto_init( ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_crypto_init( ) );
- TEST_ASSERT( psa_allocate_key( key_type, PSA_BYTES_TO_BITS( key->len ),
- &handle ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_allocate_key( key_type, PSA_BYTES_TO_BITS( key->len ),
+ &handle ) );
psa_key_policy_init( &policy );
psa_key_policy_set_usage( &policy, PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_DECRYPT, alg );
- TEST_ASSERT( psa_set_key_policy( handle, &policy ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_set_key_policy( handle, &policy ) );
- TEST_ASSERT( psa_import_key( handle, key_type,
- key->x, key->len ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_import_key( handle, key_type,
+ key->x, key->len ) );
- TEST_ASSERT( psa_cipher_encrypt_setup( &operation1,
- handle, alg ) == PSA_SUCCESS );
- TEST_ASSERT( psa_cipher_decrypt_setup( &operation2,
- handle, alg ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_cipher_encrypt_setup( &operation1,
+ handle, alg ) );
+ PSA_ASSERT( psa_cipher_decrypt_setup( &operation2,
+ handle, alg ) );
- TEST_ASSERT( psa_cipher_generate_iv( &operation1,
- iv, iv_size,
- &iv_length ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_cipher_generate_iv( &operation1,
+ iv, iv_size,
+ &iv_length ) );
output1_size = ( (size_t) input->len +
PSA_BLOCK_CIPHER_BLOCK_SIZE( key_type ) );
ASSERT_ALLOC( output1, output1_size );
- TEST_ASSERT( psa_cipher_update( &operation1, input->x, input->len,
- output1, output1_size,
- &output1_length ) == PSA_SUCCESS );
- TEST_ASSERT( psa_cipher_finish( &operation1,
- output1 + output1_length, output1_size,
- &function_output_length ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_cipher_update( &operation1, input->x, input->len,
+ output1, output1_size,
+ &output1_length ) );
+ PSA_ASSERT( psa_cipher_finish( &operation1,
+ output1 + output1_length, output1_size,
+ &function_output_length ) );
output1_length += function_output_length;
- TEST_ASSERT( psa_cipher_abort( &operation1 ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_cipher_abort( &operation1 ) );
output2_size = output1_length;
ASSERT_ALLOC( output2, output2_size );
- TEST_ASSERT( psa_cipher_set_iv( &operation2,
- iv, iv_length ) == PSA_SUCCESS );
- TEST_ASSERT( psa_cipher_update( &operation2, output1, output1_length,
- output2, output2_size,
- &output2_length ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_cipher_set_iv( &operation2,
+ iv, iv_length ) );
+ PSA_ASSERT( psa_cipher_update( &operation2, output1, output1_length,
+ output2, output2_size,
+ &output2_length ) );
function_output_length = 0;
- TEST_ASSERT( psa_cipher_finish( &operation2,
- output2 + output2_length,
- output2_size,
- &function_output_length ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_cipher_finish( &operation2,
+ output2 + output2_length,
+ output2_size,
+ &function_output_length ) );
output2_length += function_output_length;
- TEST_ASSERT( psa_cipher_abort( &operation2 ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_cipher_abort( &operation2 ) );
ASSERT_COMPARE( input->x, input->len, output2, output2_length );
@@ -2517,76 +2513,76 @@
TEST_ASSERT( PSA_CRYPTO_TEST_SIZE_T_RANGE( key->len ) );
TEST_ASSERT( PSA_CRYPTO_TEST_SIZE_T_RANGE( input->len ) );
- TEST_ASSERT( psa_crypto_init( ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_crypto_init( ) );
- TEST_ASSERT( psa_allocate_key( key_type, PSA_BYTES_TO_BITS( key->len ),
- &handle ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_allocate_key( key_type, PSA_BYTES_TO_BITS( key->len ),
+ &handle ) );
psa_key_policy_init( &policy );
psa_key_policy_set_usage( &policy, PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_DECRYPT, alg );
- TEST_ASSERT( psa_set_key_policy( handle, &policy ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_set_key_policy( handle, &policy ) );
- TEST_ASSERT( psa_import_key( handle, key_type,
- key->x, key->len ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_import_key( handle, key_type,
+ key->x, key->len ) );
- TEST_ASSERT( psa_cipher_encrypt_setup( &operation1,
- handle, alg ) == PSA_SUCCESS );
- TEST_ASSERT( psa_cipher_decrypt_setup( &operation2,
- handle, alg ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_cipher_encrypt_setup( &operation1,
+ handle, alg ) );
+ PSA_ASSERT( psa_cipher_decrypt_setup( &operation2,
+ handle, alg ) );
- TEST_ASSERT( psa_cipher_generate_iv( &operation1,
- iv, iv_size,
- &iv_length ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_cipher_generate_iv( &operation1,
+ iv, iv_size,
+ &iv_length ) );
output1_buffer_size = ( (size_t) input->len +
PSA_BLOCK_CIPHER_BLOCK_SIZE( key_type ) );
ASSERT_ALLOC( output1, output1_buffer_size );
TEST_ASSERT( (unsigned int) first_part_size < input->len );
- TEST_ASSERT( psa_cipher_update( &operation1, input->x, first_part_size,
- output1, output1_buffer_size,
- &function_output_length ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_cipher_update( &operation1, input->x, first_part_size,
+ output1, output1_buffer_size,
+ &function_output_length ) );
output1_length += function_output_length;
- TEST_ASSERT( psa_cipher_update( &operation1,
- input->x + first_part_size,
- input->len - first_part_size,
- output1, output1_buffer_size,
- &function_output_length ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_cipher_update( &operation1,
+ input->x + first_part_size,
+ input->len - first_part_size,
+ output1, output1_buffer_size,
+ &function_output_length ) );
output1_length += function_output_length;
- TEST_ASSERT( psa_cipher_finish( &operation1,
- output1 + output1_length,
- output1_buffer_size - output1_length,
- &function_output_length ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_cipher_finish( &operation1,
+ output1 + output1_length,
+ output1_buffer_size - output1_length,
+ &function_output_length ) );
output1_length += function_output_length;
- TEST_ASSERT( psa_cipher_abort( &operation1 ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_cipher_abort( &operation1 ) );
output2_buffer_size = output1_length;
ASSERT_ALLOC( output2, output2_buffer_size );
- TEST_ASSERT( psa_cipher_set_iv( &operation2,
- iv, iv_length ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_cipher_set_iv( &operation2,
+ iv, iv_length ) );
- TEST_ASSERT( psa_cipher_update( &operation2, output1, first_part_size,
- output2, output2_buffer_size,
- &function_output_length ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_cipher_update( &operation2, output1, first_part_size,
+ output2, output2_buffer_size,
+ &function_output_length ) );
output2_length += function_output_length;
- TEST_ASSERT( psa_cipher_update( &operation2,
- output1 + first_part_size,
- output1_length - first_part_size,
- output2, output2_buffer_size,
- &function_output_length ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_cipher_update( &operation2,
+ output1 + first_part_size,
+ output1_length - first_part_size,
+ output2, output2_buffer_size,
+ &function_output_length ) );
output2_length += function_output_length;
- TEST_ASSERT( psa_cipher_finish( &operation2,
- output2 + output2_length,
- output2_buffer_size - output2_length,
- &function_output_length ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_cipher_finish( &operation2,
+ output2 + output2_length,
+ output2_buffer_size - output2_length,
+ &function_output_length ) );
output2_length += function_output_length;
- TEST_ASSERT( psa_cipher_abort( &operation2 ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_cipher_abort( &operation2 ) );
ASSERT_COMPARE( input->x, input->len, output2, output2_length );
@@ -2630,18 +2626,18 @@
output_size = input_data->len + tag_length;
ASSERT_ALLOC( output_data, output_size );
- TEST_ASSERT( psa_crypto_init( ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_crypto_init( ) );
- TEST_ASSERT( psa_allocate_key( key_type, PSA_BYTES_TO_BITS( key_data->len ),
- &handle ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_allocate_key( key_type, PSA_BYTES_TO_BITS( key_data->len ),
+ &handle ) );
psa_key_policy_init( &policy );
psa_key_policy_set_usage( &policy,
PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_DECRYPT,
alg );
- TEST_ASSERT( psa_set_key_policy( handle, &policy ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_set_key_policy( handle, &policy ) );
- TEST_ASSERT( psa_import_key( handle, key_type,
- key_data->x, key_data->len ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_import_key( handle, key_type,
+ key_data->x, key_data->len ) );
TEST_ASSERT( psa_aead_encrypt( handle, alg,
nonce->x, nonce->len,
@@ -2706,24 +2702,24 @@
output_size = input_data->len + tag_length;
ASSERT_ALLOC( output_data, output_size );
- TEST_ASSERT( psa_crypto_init( ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_crypto_init( ) );
- TEST_ASSERT( psa_allocate_key( key_type, PSA_BYTES_TO_BITS( key_data->len ),
- &handle ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_allocate_key( key_type, PSA_BYTES_TO_BITS( key_data->len ),
+ &handle ) );
psa_key_policy_init( &policy );
psa_key_policy_set_usage( &policy, PSA_KEY_USAGE_ENCRYPT , alg );
- TEST_ASSERT( psa_set_key_policy( handle, &policy ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_set_key_policy( handle, &policy ) );
- TEST_ASSERT( psa_import_key( handle, key_type,
- key_data->x,
- key_data->len ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_import_key( handle, key_type,
+ key_data->x,
+ key_data->len ) );
- TEST_ASSERT( psa_aead_encrypt( handle, alg,
- nonce->x, nonce->len,
- additional_data->x, additional_data->len,
- input_data->x, input_data->len,
- output_data, output_size,
- &output_length ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_aead_encrypt( handle, alg,
+ nonce->x, nonce->len,
+ additional_data->x, additional_data->len,
+ input_data->x, input_data->len,
+ output_data, output_size,
+ &output_length ) );
ASSERT_COMPARE( expected_result->x, expected_result->len,
output_data, output_length );
@@ -2768,17 +2764,17 @@
output_size = input_data->len + tag_length;
ASSERT_ALLOC( output_data, output_size );
- TEST_ASSERT( psa_crypto_init( ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_crypto_init( ) );
- TEST_ASSERT( psa_allocate_key( key_type, PSA_BYTES_TO_BITS( key_data->len ),
- &handle ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_allocate_key( key_type, PSA_BYTES_TO_BITS( key_data->len ),
+ &handle ) );
psa_key_policy_init( &policy );
psa_key_policy_set_usage( &policy, PSA_KEY_USAGE_DECRYPT , alg );
- TEST_ASSERT( psa_set_key_policy( handle, &policy ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_set_key_policy( handle, &policy ) );
- TEST_ASSERT( psa_import_key( handle, key_type,
- key_data->x,
- key_data->len ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_import_key( handle, key_type,
+ key_data->x,
+ key_data->len ) );
TEST_ASSERT( psa_aead_decrypt( handle, alg,
nonce->x, nonce->len,
@@ -2835,21 +2831,21 @@
TEST_ASSERT( PSA_CRYPTO_TEST_SIZE_T_RANGE( input_data->len ) );
TEST_ASSERT( PSA_CRYPTO_TEST_SIZE_T_RANGE( output_data->len ) );
- TEST_ASSERT( psa_crypto_init( ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_crypto_init( ) );
- TEST_ASSERT( psa_allocate_key( key_type,
- KEY_BITS_FROM_DATA( key_type, key_data ),
- &handle ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_allocate_key( key_type,
+ KEY_BITS_FROM_DATA( key_type, key_data ),
+ &handle ) );
psa_key_policy_init( &policy );
psa_key_policy_set_usage( &policy, PSA_KEY_USAGE_SIGN, alg );
- TEST_ASSERT( psa_set_key_policy( handle, &policy ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_set_key_policy( handle, &policy ) );
- TEST_ASSERT( psa_import_key( handle, key_type,
- key_data->x,
- key_data->len ) == PSA_SUCCESS );
- TEST_ASSERT( psa_get_key_information( handle,
- NULL,
- &key_bits ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_import_key( handle, key_type,
+ key_data->x,
+ key_data->len ) );
+ PSA_ASSERT( psa_get_key_information( handle,
+ NULL,
+ &key_bits ) );
/* Allocate a buffer which has the size advertized by the
* library. */
@@ -2860,10 +2856,10 @@
ASSERT_ALLOC( signature, signature_size );
/* Perform the signature. */
- TEST_ASSERT( psa_asymmetric_sign( handle, alg,
- input_data->x, input_data->len,
- signature, signature_size,
- &signature_length ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_asymmetric_sign( handle, alg,
+ input_data->x, input_data->len,
+ signature, signature_size,
+ &signature_length ) );
/* Verify that the signature is what is expected. */
ASSERT_COMPARE( output_data->x, output_data->len,
signature, signature_length );
@@ -2897,18 +2893,18 @@
ASSERT_ALLOC( signature, signature_size );
- TEST_ASSERT( psa_crypto_init( ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_crypto_init( ) );
- TEST_ASSERT( psa_allocate_key( key_type,
- KEY_BITS_FROM_DATA( key_type, key_data ),
- &handle ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_allocate_key( key_type,
+ KEY_BITS_FROM_DATA( key_type, key_data ),
+ &handle ) );
psa_key_policy_init( &policy );
psa_key_policy_set_usage( &policy, PSA_KEY_USAGE_SIGN, alg );
- TEST_ASSERT( psa_set_key_policy( handle, &policy ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_set_key_policy( handle, &policy ) );
- TEST_ASSERT( psa_import_key( handle, key_type,
- key_data->x,
- key_data->len ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_import_key( handle, key_type,
+ key_data->x,
+ key_data->len ) );
actual_status = psa_asymmetric_sign( handle, alg,
input_data->x, input_data->len,
@@ -2941,23 +2937,23 @@
size_t signature_length = 0xdeadbeef;
psa_key_policy_t policy;
- TEST_ASSERT( psa_crypto_init( ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_crypto_init( ) );
- TEST_ASSERT( psa_allocate_key( key_type,
- KEY_BITS_FROM_DATA( key_type, key_data ),
- &handle ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_allocate_key( key_type,
+ KEY_BITS_FROM_DATA( key_type, key_data ),
+ &handle ) );
psa_key_policy_init( &policy );
psa_key_policy_set_usage( &policy,
PSA_KEY_USAGE_SIGN | PSA_KEY_USAGE_VERIFY,
alg );
- TEST_ASSERT( psa_set_key_policy( handle, &policy ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_set_key_policy( handle, &policy ) );
- TEST_ASSERT( psa_import_key( handle, key_type,
- key_data->x,
- key_data->len ) == PSA_SUCCESS );
- TEST_ASSERT( psa_get_key_information( handle,
- NULL,
- &key_bits ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_import_key( handle, key_type,
+ key_data->x,
+ key_data->len ) );
+ PSA_ASSERT( psa_get_key_information( handle,
+ NULL,
+ &key_bits ) );
/* Allocate a buffer which has the size advertized by the
* library. */
@@ -2968,19 +2964,19 @@
ASSERT_ALLOC( signature, signature_size );
/* Perform the signature. */
- TEST_ASSERT( psa_asymmetric_sign( handle, alg,
- input_data->x, input_data->len,
- signature, signature_size,
- &signature_length ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_asymmetric_sign( handle, alg,
+ input_data->x, input_data->len,
+ signature, signature_size,
+ &signature_length ) );
/* Check that the signature length looks sensible. */
TEST_ASSERT( signature_length <= signature_size );
TEST_ASSERT( signature_length > 0 );
/* Use the library to verify that the signature is correct. */
- TEST_ASSERT( psa_asymmetric_verify(
- handle, alg,
- input_data->x, input_data->len,
- signature, signature_length ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_asymmetric_verify(
+ handle, alg,
+ input_data->x, input_data->len,
+ signature, signature_length ) );
if( input_data->len != 0 )
{
@@ -3021,23 +3017,23 @@
TEST_ASSERT( PSA_CRYPTO_TEST_SIZE_T_RANGE( hash_data->len ) );
TEST_ASSERT( PSA_CRYPTO_TEST_SIZE_T_RANGE( signature_data->len ) );
- TEST_ASSERT( psa_crypto_init( ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_crypto_init( ) );
- TEST_ASSERT( psa_allocate_key( key_type,
- KEY_BITS_FROM_DATA( key_type, key_data ),
- &handle ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_allocate_key( key_type,
+ KEY_BITS_FROM_DATA( key_type, key_data ),
+ &handle ) );
psa_key_policy_init( &policy );
psa_key_policy_set_usage( &policy, PSA_KEY_USAGE_VERIFY, alg );
- TEST_ASSERT( psa_set_key_policy( handle, &policy ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_set_key_policy( handle, &policy ) );
- TEST_ASSERT( psa_import_key( handle, key_type,
- key_data->x,
- key_data->len ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_import_key( handle, key_type,
+ key_data->x,
+ key_data->len ) );
- TEST_ASSERT( psa_asymmetric_verify( handle, alg,
- hash_data->x, hash_data->len,
- signature_data->x,
- signature_data->len ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_asymmetric_verify( handle, alg,
+ hash_data->x, hash_data->len,
+ signature_data->x,
+ signature_data->len ) );
exit:
psa_destroy_key( handle );
mbedtls_psa_crypto_free( );
@@ -3064,18 +3060,18 @@
TEST_ASSERT( PSA_CRYPTO_TEST_SIZE_T_RANGE( hash_data->len ) );
TEST_ASSERT( PSA_CRYPTO_TEST_SIZE_T_RANGE( signature_data->len ) );
- TEST_ASSERT( psa_crypto_init( ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_crypto_init( ) );
- TEST_ASSERT( psa_allocate_key( key_type,
- KEY_BITS_FROM_DATA( key_type, key_data ),
- &handle ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_allocate_key( key_type,
+ KEY_BITS_FROM_DATA( key_type, key_data ),
+ &handle ) );
psa_key_policy_init( &policy );
psa_key_policy_set_usage( &policy, PSA_KEY_USAGE_VERIFY, alg );
- TEST_ASSERT( psa_set_key_policy( handle, &policy ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_set_key_policy( handle, &policy ) );
- TEST_ASSERT( psa_import_key( handle, key_type,
- key_data->x,
- key_data->len ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_import_key( handle, key_type,
+ key_data->x,
+ key_data->len ) );
actual_status = psa_asymmetric_verify( handle, alg,
hash_data->x, hash_data->len,
@@ -3111,24 +3107,23 @@
psa_status_t expected_status = expected_status_arg;
psa_key_policy_t policy;
- TEST_ASSERT( psa_crypto_init( ) == PSA_SUCCESS );
-
+ PSA_ASSERT( psa_crypto_init( ) );
/* Import the key */
- TEST_ASSERT( psa_allocate_key( key_type,
- KEY_BITS_FROM_DATA( key_type, key_data ),
- &handle ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_allocate_key( key_type,
+ KEY_BITS_FROM_DATA( key_type, key_data ),
+ &handle ) );
psa_key_policy_init( &policy );
psa_key_policy_set_usage( &policy, PSA_KEY_USAGE_ENCRYPT, alg );
- TEST_ASSERT( psa_set_key_policy( handle, &policy ) == PSA_SUCCESS );
- TEST_ASSERT( psa_import_key( handle, key_type,
- key_data->x,
- key_data->len ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_set_key_policy( handle, &policy ) );
+ PSA_ASSERT( psa_import_key( handle, key_type,
+ key_data->x,
+ key_data->len ) );
/* Determine the maximum output length */
- TEST_ASSERT( psa_get_key_information( handle,
- NULL,
- &key_bits ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_get_key_information( handle,
+ NULL,
+ &key_bits ) );
output_size = PSA_ASYMMETRIC_ENCRYPT_OUTPUT_SIZE( key_type, key_bits, alg );
ASSERT_ALLOC( output, output_size );
@@ -3188,26 +3183,25 @@
TEST_ASSERT( PSA_CRYPTO_TEST_SIZE_T_RANGE( key_data->len ) );
TEST_ASSERT( PSA_CRYPTO_TEST_SIZE_T_RANGE( input_data->len ) );
- TEST_ASSERT( psa_crypto_init( ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_crypto_init( ) );
- TEST_ASSERT( psa_allocate_key( key_type,
- KEY_BITS_FROM_DATA( key_type, key_data ),
- &handle ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_allocate_key( key_type,
+ KEY_BITS_FROM_DATA( key_type, key_data ),
+ &handle ) );
psa_key_policy_init( &policy );
psa_key_policy_set_usage( &policy,
PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_DECRYPT,
alg );
- TEST_ASSERT( psa_set_key_policy( handle, &policy ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_set_key_policy( handle, &policy ) );
- TEST_ASSERT( psa_import_key( handle, key_type,
- key_data->x,
- key_data->len ) == PSA_SUCCESS );
-
+ PSA_ASSERT( psa_import_key( handle, key_type,
+ key_data->x,
+ key_data->len ) );
/* Determine the maximum ciphertext length */
- TEST_ASSERT( psa_get_key_information( handle,
- NULL,
- &key_bits ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_get_key_information( handle,
+ NULL,
+ &key_bits ) );
output_size = PSA_ASYMMETRIC_ENCRYPT_OUTPUT_SIZE( key_type, key_bits, alg );
ASSERT_ALLOC( output, output_size );
output2_size = input_data->len;
@@ -3216,20 +3210,20 @@
/* We test encryption by checking that encrypt-then-decrypt gives back
* the original plaintext because of the non-optional random
* part of encryption process which prevents using fixed vectors. */
- TEST_ASSERT( psa_asymmetric_encrypt( handle, alg,
- input_data->x, input_data->len,
- label->x, label->len,
- output, output_size,
- &output_length ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_asymmetric_encrypt( handle, alg,
+ input_data->x, input_data->len,
+ label->x, label->len,
+ output, output_size,
+ &output_length ) );
/* We don't know what ciphertext length to expect, but check that
* it looks sensible. */
TEST_ASSERT( output_length <= output_size );
- TEST_ASSERT( psa_asymmetric_decrypt( handle, alg,
- output, output_length,
- label->x, label->len,
- output2, output2_size,
- &output2_length ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_asymmetric_decrypt( handle, alg,
+ output, output_length,
+ label->x, label->len,
+ output2, output2_size,
+ &output2_length ) );
ASSERT_COMPARE( input_data->x, input_data->len,
output2, output2_length );
@@ -3267,25 +3261,25 @@
output_size = key_data->len;
ASSERT_ALLOC( output, output_size );
- TEST_ASSERT( psa_crypto_init( ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_crypto_init( ) );
- TEST_ASSERT( psa_allocate_key( key_type,
- KEY_BITS_FROM_DATA( key_type, key_data ),
- &handle ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_allocate_key( key_type,
+ KEY_BITS_FROM_DATA( key_type, key_data ),
+ &handle ) );
psa_key_policy_init( &policy );
psa_key_policy_set_usage( &policy, PSA_KEY_USAGE_DECRYPT, alg );
- TEST_ASSERT( psa_set_key_policy( handle, &policy ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_set_key_policy( handle, &policy ) );
- TEST_ASSERT( psa_import_key( handle, key_type,
- key_data->x,
- key_data->len ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_import_key( handle, key_type,
+ key_data->x,
+ key_data->len ) );
- TEST_ASSERT( psa_asymmetric_decrypt( handle, alg,
- input_data->x, input_data->len,
- label->x, label->len,
- output,
- output_size,
- &output_length ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_asymmetric_decrypt( handle, alg,
+ input_data->x, input_data->len,
+ label->x, label->len,
+ output,
+ output_size,
+ &output_length ) );
ASSERT_COMPARE( expected_data->x, expected_data->len,
output, output_length );
@@ -3296,12 +3290,12 @@
output_length = ~0;
if( output_size != 0 )
memset( output, 0, output_size );
- TEST_ASSERT( psa_asymmetric_decrypt( handle, alg,
- input_data->x, input_data->len,
- NULL, label->len,
- output,
- output_size,
- &output_length ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_asymmetric_decrypt( handle, alg,
+ input_data->x, input_data->len,
+ NULL, label->len,
+ output,
+ output_size,
+ &output_length ) );
ASSERT_COMPARE( expected_data->x, expected_data->len,
output, output_length );
}
@@ -3339,18 +3333,18 @@
output_size = key_data->len;
ASSERT_ALLOC( output, output_size );
- TEST_ASSERT( psa_crypto_init( ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_crypto_init( ) );
- TEST_ASSERT( psa_allocate_key( key_type,
- KEY_BITS_FROM_DATA( key_type, key_data ),
- &handle ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_allocate_key( key_type,
+ KEY_BITS_FROM_DATA( key_type, key_data ),
+ &handle ) );
psa_key_policy_init( &policy );
psa_key_policy_set_usage( &policy, PSA_KEY_USAGE_DECRYPT, alg );
- TEST_ASSERT( psa_set_key_policy( handle, &policy ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_set_key_policy( handle, &policy ) );
- TEST_ASSERT( psa_import_key( handle, key_type,
- key_data->x,
- key_data->len ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_import_key( handle, key_type,
+ key_data->x,
+ key_data->len ) );
actual_status = psa_asymmetric_decrypt( handle, alg,
input_data->x, input_data->len,
@@ -3400,17 +3394,17 @@
psa_crypto_generator_t generator = PSA_CRYPTO_GENERATOR_INIT;
psa_key_policy_t policy;
- TEST_ASSERT( psa_crypto_init( ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_crypto_init( ) );
- TEST_ASSERT( psa_allocate_key( key_type, PSA_BYTES_TO_BITS( key_data->len ),
- &handle ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_allocate_key( key_type, PSA_BYTES_TO_BITS( key_data->len ),
+ &handle ) );
psa_key_policy_init( &policy );
psa_key_policy_set_usage( &policy, PSA_KEY_USAGE_DERIVE, alg );
- TEST_ASSERT( psa_set_key_policy( handle, &policy ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_set_key_policy( handle, &policy ) );
- TEST_ASSERT( psa_import_key( handle, key_type,
- key_data->x,
- key_data->len ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_import_key( handle, key_type,
+ key_data->x,
+ key_data->len ) );
TEST_ASSERT( psa_key_derivation( &generator, handle, alg,
salt->x, salt->len,
@@ -3438,24 +3432,24 @@
0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b};
psa_key_policy_t policy;
- TEST_ASSERT( psa_crypto_init( ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_crypto_init( ) );
- TEST_ASSERT( psa_allocate_key( key_type,
- PSA_BYTES_TO_BITS( sizeof( key_data ) ),
- &handle ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_allocate_key( key_type,
+ PSA_BYTES_TO_BITS( sizeof( key_data ) ),
+ &handle ) );
psa_key_policy_init( &policy );
psa_key_policy_set_usage( &policy, PSA_KEY_USAGE_DERIVE, alg );
- TEST_ASSERT( psa_set_key_policy( handle, &policy ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_set_key_policy( handle, &policy ) );
- TEST_ASSERT( psa_import_key( handle, key_type,
- key_data,
- sizeof( key_data ) ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_import_key( handle, key_type,
+ key_data,
+ sizeof( key_data ) ) );
/* valid key derivation */
- TEST_ASSERT( psa_key_derivation( &generator, handle, alg,
- NULL, 0,
- NULL, 0,
- capacity ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_key_derivation( &generator, handle, alg,
+ NULL, 0,
+ NULL, 0,
+ capacity ) );
/* state of generator shouldn't allow additional generation */
TEST_ASSERT( psa_key_derivation( &generator, handle, alg,
@@ -3463,13 +3457,12 @@
NULL, 0,
capacity ) == PSA_ERROR_BAD_STATE );
- TEST_ASSERT( psa_generator_read( &generator, buffer, capacity )
- == PSA_SUCCESS );
+ PSA_ASSERT( psa_generator_read( &generator, buffer, capacity )
+ );
TEST_ASSERT( psa_generator_read( &generator, buffer, capacity )
== PSA_ERROR_INSUFFICIENT_CAPACITY );
-
exit:
psa_generator_abort( &generator );
psa_destroy_key( handle );
@@ -3477,7 +3470,6 @@
}
/* END_CASE */
-
/* BEGIN_CASE */
void test_derive_invalid_generator_tests( )
{
@@ -3492,7 +3484,7 @@
TEST_ASSERT( psa_get_generator_capacity( &generator, &capacity )
== PSA_SUCCESS ); // should be PSA_ERROR_BAD_STATE:#183
- TEST_ASSERT( psa_generator_abort( &generator ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_generator_abort( &generator ) );
TEST_ASSERT( psa_generator_read( &generator, output_buffer, buffer_size )
== PSA_ERROR_INSUFFICIENT_CAPACITY ); // should be PSA_ERROR_BAD_STATE:#183
@@ -3538,27 +3530,26 @@
expected_outputs[i] = NULL;
}
ASSERT_ALLOC( output_buffer, output_buffer_size );
- TEST_ASSERT( psa_crypto_init( ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_crypto_init( ) );
- TEST_ASSERT( psa_allocate_key( PSA_KEY_TYPE_DERIVE,
- PSA_BYTES_TO_BITS( key_data->len ),
- &handle ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_allocate_key( PSA_KEY_TYPE_DERIVE,
+ PSA_BYTES_TO_BITS( key_data->len ),
+ &handle ) );
psa_key_policy_init( &policy );
psa_key_policy_set_usage( &policy, PSA_KEY_USAGE_DERIVE, alg );
- TEST_ASSERT( psa_set_key_policy( handle, &policy ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_set_key_policy( handle, &policy ) );
- TEST_ASSERT( psa_import_key( handle, PSA_KEY_TYPE_DERIVE,
- key_data->x,
- key_data->len ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_import_key( handle, PSA_KEY_TYPE_DERIVE,
+ key_data->x,
+ key_data->len ) );
/* Extraction phase. */
- TEST_ASSERT( psa_key_derivation( &generator, handle, alg,
- salt->x, salt->len,
- label->x, label->len,
- requested_capacity ) == PSA_SUCCESS );
- TEST_ASSERT( psa_get_generator_capacity( &generator,
- ¤t_capacity ) ==
- PSA_SUCCESS );
+ PSA_ASSERT( psa_key_derivation( &generator, handle, alg,
+ salt->x, salt->len,
+ label->x, label->len,
+ requested_capacity ) );
+ PSA_ASSERT( psa_get_generator_capacity( &generator,
+ ¤t_capacity ) );
TEST_ASSERT( current_capacity == requested_capacity );
expected_capacity = requested_capacity;
@@ -3584,18 +3575,17 @@
continue;
}
/* Success. Check the read data. */
- TEST_ASSERT( status == PSA_SUCCESS );
+ PSA_ASSERT( status );
if( output_sizes[i] != 0 )
TEST_ASSERT( memcmp( output_buffer, expected_outputs[i],
output_sizes[i] ) == 0 );
/* Check the generator status. */
expected_capacity -= output_sizes[i];
- TEST_ASSERT( psa_get_generator_capacity( &generator,
- ¤t_capacity ) ==
- PSA_SUCCESS );
+ PSA_ASSERT( psa_get_generator_capacity( &generator,
+ ¤t_capacity ) );
TEST_ASSERT( expected_capacity == current_capacity );
}
- TEST_ASSERT( psa_generator_abort( &generator ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_generator_abort( &generator ) );
exit:
mbedtls_free( output_buffer );
@@ -3621,27 +3611,26 @@
size_t current_capacity;
psa_key_policy_t policy;
- TEST_ASSERT( psa_crypto_init( ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_crypto_init( ) );
- TEST_ASSERT( psa_allocate_key( PSA_KEY_TYPE_DERIVE,
- PSA_BYTES_TO_BITS( key_data->len ),
- &handle ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_allocate_key( PSA_KEY_TYPE_DERIVE,
+ PSA_BYTES_TO_BITS( key_data->len ),
+ &handle ) );
psa_key_policy_init( &policy );
psa_key_policy_set_usage( &policy, PSA_KEY_USAGE_DERIVE, alg );
- TEST_ASSERT( psa_set_key_policy( handle, &policy ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_set_key_policy( handle, &policy ) );
- TEST_ASSERT( psa_import_key( handle, PSA_KEY_TYPE_DERIVE,
- key_data->x,
- key_data->len ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_import_key( handle, PSA_KEY_TYPE_DERIVE,
+ key_data->x,
+ key_data->len ) );
/* Extraction phase. */
- TEST_ASSERT( psa_key_derivation( &generator, handle, alg,
- salt->x, salt->len,
- label->x, label->len,
- requested_capacity ) == PSA_SUCCESS );
- TEST_ASSERT( psa_get_generator_capacity( &generator,
- ¤t_capacity ) ==
- PSA_SUCCESS );
+ PSA_ASSERT( psa_key_derivation( &generator, handle, alg,
+ salt->x, salt->len,
+ label->x, label->len,
+ requested_capacity ) );
+ PSA_ASSERT( psa_get_generator_capacity( &generator,
+ ¤t_capacity ) );
TEST_ASSERT( current_capacity == expected_capacity );
/* Expansion phase. */
@@ -3650,13 +3639,12 @@
size_t read_size = sizeof( output_buffer );
if( read_size > current_capacity )
read_size = current_capacity;
- TEST_ASSERT( psa_generator_read( &generator,
- output_buffer,
- read_size ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_generator_read( &generator,
+ output_buffer,
+ read_size ) );
expected_capacity -= read_size;
- TEST_ASSERT( psa_get_generator_capacity( &generator,
- ¤t_capacity ) ==
- PSA_SUCCESS );
+ PSA_ASSERT( psa_get_generator_capacity( &generator,
+ ¤t_capacity ) );
TEST_ASSERT( current_capacity == expected_capacity );
}
@@ -3665,7 +3653,7 @@
output_buffer,
1 ) == PSA_ERROR_INSUFFICIENT_CAPACITY );
- TEST_ASSERT( psa_generator_abort( &generator ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_generator_abort( &generator ) );
exit:
psa_generator_abort( &generator );
@@ -3697,36 +3685,36 @@
psa_key_type_t got_type;
size_t got_bits;
- TEST_ASSERT( psa_crypto_init( ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_crypto_init( ) );
- TEST_ASSERT( psa_allocate_key( PSA_KEY_TYPE_DERIVE,
- PSA_BYTES_TO_BITS( key_data->len ),
- &base_handle ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_allocate_key( PSA_KEY_TYPE_DERIVE,
+ PSA_BYTES_TO_BITS( key_data->len ),
+ &base_handle ) );
psa_key_policy_init( &policy );
psa_key_policy_set_usage( &policy, PSA_KEY_USAGE_DERIVE, alg );
- TEST_ASSERT( psa_set_key_policy( base_handle, &policy ) == PSA_SUCCESS );
- TEST_ASSERT( psa_import_key( base_handle, PSA_KEY_TYPE_DERIVE,
- key_data->x,
- key_data->len ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_set_key_policy( base_handle, &policy ) );
+ PSA_ASSERT( psa_import_key( base_handle, PSA_KEY_TYPE_DERIVE,
+ key_data->x,
+ key_data->len ) );
/* Derive a key. */
- TEST_ASSERT( psa_key_derivation( &generator, base_handle, alg,
- salt->x, salt->len,
- label->x, label->len,
- capacity ) == PSA_SUCCESS );
- TEST_ASSERT( psa_allocate_key( derived_type, derived_bits,
- &derived_handle ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_key_derivation( &generator, base_handle, alg,
+ salt->x, salt->len,
+ label->x, label->len,
+ capacity ) );
+ PSA_ASSERT( psa_allocate_key( derived_type, derived_bits,
+ &derived_handle ) );
psa_key_policy_set_usage( &policy, derived_usage, derived_alg );
- TEST_ASSERT( psa_set_key_policy( derived_handle, &policy ) == PSA_SUCCESS );
- TEST_ASSERT( psa_generator_import_key( derived_handle,
- derived_type,
- derived_bits,
- &generator ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_set_key_policy( derived_handle, &policy ) );
+ PSA_ASSERT( psa_generator_import_key( derived_handle,
+ derived_type,
+ derived_bits,
+ &generator ) );
/* Test the key information */
- TEST_ASSERT( psa_get_key_information( derived_handle,
- &got_type,
- &got_bits ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_get_key_information( derived_handle,
+ &got_type,
+ &got_bits ) );
TEST_ASSERT( got_type == derived_type );
TEST_ASSERT( got_bits == derived_bits );
@@ -3765,57 +3753,57 @@
ASSERT_ALLOC( output_buffer, capacity );
ASSERT_ALLOC( export_buffer, capacity );
- TEST_ASSERT( psa_crypto_init( ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_crypto_init( ) );
- TEST_ASSERT( psa_allocate_key( PSA_KEY_TYPE_DERIVE,
- PSA_BYTES_TO_BITS( key_data->len ),
- &base_handle ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_allocate_key( PSA_KEY_TYPE_DERIVE,
+ PSA_BYTES_TO_BITS( key_data->len ),
+ &base_handle ) );
psa_key_policy_init( &policy );
psa_key_policy_set_usage( &policy, PSA_KEY_USAGE_DERIVE, alg );
- TEST_ASSERT( psa_set_key_policy( base_handle, &policy ) == PSA_SUCCESS );
- TEST_ASSERT( psa_import_key( base_handle, PSA_KEY_TYPE_DERIVE,
- key_data->x,
- key_data->len ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_set_key_policy( base_handle, &policy ) );
+ PSA_ASSERT( psa_import_key( base_handle, PSA_KEY_TYPE_DERIVE,
+ key_data->x,
+ key_data->len ) );
/* Derive some material and output it. */
- TEST_ASSERT( psa_key_derivation( &generator, base_handle, alg,
- salt->x, salt->len,
- label->x, label->len,
- capacity ) == PSA_SUCCESS );
- TEST_ASSERT( psa_generator_read( &generator,
- output_buffer,
- capacity ) == PSA_SUCCESS );
- TEST_ASSERT( psa_generator_abort( &generator ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_key_derivation( &generator, base_handle, alg,
+ salt->x, salt->len,
+ label->x, label->len,
+ capacity ) );
+ PSA_ASSERT( psa_generator_read( &generator,
+ output_buffer,
+ capacity ) );
+ PSA_ASSERT( psa_generator_abort( &generator ) );
/* Derive the same output again, but this time store it in key objects. */
- TEST_ASSERT( psa_key_derivation( &generator, base_handle, alg,
- salt->x, salt->len,
- label->x, label->len,
- capacity ) == PSA_SUCCESS );
- TEST_ASSERT( psa_allocate_key( PSA_KEY_TYPE_RAW_DATA, derived_bits,
- &derived_handle ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_key_derivation( &generator, base_handle, alg,
+ salt->x, salt->len,
+ label->x, label->len,
+ capacity ) );
+ PSA_ASSERT( psa_allocate_key( PSA_KEY_TYPE_RAW_DATA, derived_bits,
+ &derived_handle ) );
psa_key_policy_set_usage( &policy, PSA_KEY_USAGE_EXPORT, 0 );
- TEST_ASSERT( psa_set_key_policy( derived_handle, &policy ) == PSA_SUCCESS );
- TEST_ASSERT( psa_generator_import_key( derived_handle,
- PSA_KEY_TYPE_RAW_DATA,
- derived_bits,
- &generator ) == PSA_SUCCESS );
- TEST_ASSERT( psa_export_key( derived_handle,
- export_buffer, bytes1,
- &length ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_set_key_policy( derived_handle, &policy ) );
+ PSA_ASSERT( psa_generator_import_key( derived_handle,
+ PSA_KEY_TYPE_RAW_DATA,
+ derived_bits,
+ &generator ) );
+ PSA_ASSERT( psa_export_key( derived_handle,
+ export_buffer, bytes1,
+ &length ) );
TEST_ASSERT( length == bytes1 );
- TEST_ASSERT( psa_destroy_key( derived_handle ) == PSA_SUCCESS );
- TEST_ASSERT( psa_allocate_key( PSA_KEY_TYPE_RAW_DATA,
- PSA_BYTES_TO_BITS( bytes2 ),
- &derived_handle ) == PSA_SUCCESS );
- TEST_ASSERT( psa_set_key_policy( derived_handle, &policy ) == PSA_SUCCESS );
- TEST_ASSERT( psa_generator_import_key( derived_handle,
- PSA_KEY_TYPE_RAW_DATA,
- PSA_BYTES_TO_BITS( bytes2 ),
- &generator ) == PSA_SUCCESS );
- TEST_ASSERT( psa_export_key( derived_handle,
- export_buffer + bytes1, bytes2,
- &length ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_destroy_key( derived_handle ) );
+ PSA_ASSERT( psa_allocate_key( PSA_KEY_TYPE_RAW_DATA,
+ PSA_BYTES_TO_BITS( bytes2 ),
+ &derived_handle ) );
+ PSA_ASSERT( psa_set_key_policy( derived_handle, &policy ) );
+ PSA_ASSERT( psa_generator_import_key( derived_handle,
+ PSA_KEY_TYPE_RAW_DATA,
+ PSA_BYTES_TO_BITS( bytes2 ),
+ &generator ) );
+ PSA_ASSERT( psa_export_key( derived_handle,
+ export_buffer + bytes1, bytes2,
+ &length ) );
TEST_ASSERT( length == bytes2 );
/* Compare the outputs from the two runs. */
@@ -3843,18 +3831,18 @@
psa_crypto_generator_t generator = PSA_CRYPTO_GENERATOR_INIT;
psa_key_policy_t policy;
- TEST_ASSERT( psa_crypto_init( ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_crypto_init( ) );
- TEST_ASSERT( psa_allocate_key( our_key_type,
- KEY_BITS_FROM_DATA( our_key_type,
- our_key_data ),
- &our_key ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_allocate_key( our_key_type,
+ KEY_BITS_FROM_DATA( our_key_type,
+ our_key_data ),
+ &our_key ) );
psa_key_policy_init( &policy );
psa_key_policy_set_usage( &policy, PSA_KEY_USAGE_DERIVE, alg );
- TEST_ASSERT( psa_set_key_policy( our_key, &policy ) == PSA_SUCCESS );
- TEST_ASSERT( psa_import_key( our_key, our_key_type,
- our_key_data->x,
- our_key_data->len ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_set_key_policy( our_key, &policy ) );
+ PSA_ASSERT( psa_import_key( our_key, our_key_type,
+ our_key_data->x,
+ our_key_data->len ) );
TEST_ASSERT( psa_key_agreement( &generator,
our_key,
@@ -3882,40 +3870,38 @@
size_t actual_capacity;
unsigned char output[16];
- TEST_ASSERT( psa_crypto_init( ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_crypto_init( ) );
- TEST_ASSERT( psa_allocate_key( our_key_type,
- KEY_BITS_FROM_DATA( our_key_type,
- our_key_data ),
- &our_key ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_allocate_key( our_key_type,
+ KEY_BITS_FROM_DATA( our_key_type,
+ our_key_data ),
+ &our_key ) );
psa_key_policy_init( &policy );
psa_key_policy_set_usage( &policy, PSA_KEY_USAGE_DERIVE, alg );
- TEST_ASSERT( psa_set_key_policy( our_key, &policy ) == PSA_SUCCESS );
- TEST_ASSERT( psa_import_key( our_key, our_key_type,
- our_key_data->x,
- our_key_data->len ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_set_key_policy( our_key, &policy ) );
+ PSA_ASSERT( psa_import_key( our_key, our_key_type,
+ our_key_data->x,
+ our_key_data->len ) );
- TEST_ASSERT( psa_key_agreement( &generator,
- our_key,
- peer_key_data->x, peer_key_data->len,
- alg ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_key_agreement( &generator,
+ our_key,
+ peer_key_data->x, peer_key_data->len,
+ alg ) );
/* Test the advertized capacity. */
- TEST_ASSERT( psa_get_generator_capacity(
- &generator, &actual_capacity ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_get_generator_capacity(
+ &generator, &actual_capacity ) );
TEST_ASSERT( actual_capacity == (size_t) expected_capacity_arg );
/* Test the actual capacity by reading the output. */
while( actual_capacity > sizeof( output ) )
{
- TEST_ASSERT( psa_generator_read( &generator,
- output, sizeof( output ) ) ==
- PSA_SUCCESS );
+ PSA_ASSERT( psa_generator_read( &generator,
+ output, sizeof( output ) ) );
actual_capacity -= sizeof( output );
}
- TEST_ASSERT( psa_generator_read( &generator,
- output, actual_capacity ) ==
- PSA_SUCCESS );
+ PSA_ASSERT( psa_generator_read( &generator,
+ output, actual_capacity ) );
TEST_ASSERT( psa_generator_read( &generator, output, 1 ) ==
PSA_ERROR_INSUFFICIENT_CAPACITY );
@@ -3942,36 +3928,36 @@
ASSERT_ALLOC( actual_output, MAX( expected_output1->len,
expected_output2->len ) );
- TEST_ASSERT( psa_crypto_init( ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_crypto_init( ) );
- TEST_ASSERT( psa_allocate_key( our_key_type,
- KEY_BITS_FROM_DATA( our_key_type,
- our_key_data ),
- &our_key ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_allocate_key( our_key_type,
+ KEY_BITS_FROM_DATA( our_key_type,
+ our_key_data ),
+ &our_key ) );
psa_key_policy_init( &policy );
psa_key_policy_set_usage( &policy, PSA_KEY_USAGE_DERIVE, alg );
- TEST_ASSERT( psa_set_key_policy( our_key, &policy ) == PSA_SUCCESS );
- TEST_ASSERT( psa_import_key( our_key, our_key_type,
- our_key_data->x,
- our_key_data->len ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_set_key_policy( our_key, &policy ) );
+ PSA_ASSERT( psa_import_key( our_key, our_key_type,
+ our_key_data->x,
+ our_key_data->len ) );
- TEST_ASSERT( psa_key_agreement( &generator,
- our_key,
- peer_key_data->x, peer_key_data->len,
- alg ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_key_agreement( &generator,
+ our_key,
+ peer_key_data->x, peer_key_data->len,
+ alg ) );
- TEST_ASSERT(
+ PSA_ASSERT(
psa_generator_read( &generator,
actual_output,
- expected_output1->len ) == PSA_SUCCESS );
+ expected_output1->len ) );
TEST_ASSERT( memcmp( actual_output, expected_output1->x,
expected_output1->len ) == 0 );
if( expected_output2->len != 0 )
{
- TEST_ASSERT(
+ PSA_ASSERT(
psa_generator_read( &generator,
actual_output,
- expected_output2->len ) == PSA_SUCCESS );
+ expected_output2->len ) );
TEST_ASSERT( memcmp( actual_output, expected_output2->x,
expected_output2->len ) == 0 );
}
@@ -3998,7 +3984,7 @@
ASSERT_ALLOC( changed, bytes );
memcpy( output + bytes, trail, sizeof( trail ) );
- TEST_ASSERT( psa_crypto_init( ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_crypto_init( ) );
/* Run several times, to ensure that every output byte will be
* nonzero at least once with overwhelming probability
@@ -4007,7 +3993,7 @@
{
if( bytes != 0 )
memset( output, 0, bytes );
- TEST_ASSERT( psa_generate_random( output, bytes ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_generate_random( output, bytes ) );
/* Check that no more than bytes have been overwritten */
TEST_ASSERT( memcmp( output + bytes, trail, sizeof( trail ) ) == 0 );
@@ -4053,12 +4039,12 @@
expected_status == PSA_SUCCESS ? PSA_SUCCESS : PSA_ERROR_EMPTY_SLOT;
psa_key_policy_t policy;
- TEST_ASSERT( psa_crypto_init( ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_crypto_init( ) );
- TEST_ASSERT( psa_allocate_key( type, bits, &handle ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_allocate_key( type, bits, &handle ) );
psa_key_policy_init( &policy );
psa_key_policy_set_usage( &policy, usage, alg );
- TEST_ASSERT( psa_set_key_policy( handle, &policy ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_set_key_policy( handle, &policy ) );
/* Generate a key */
TEST_ASSERT( psa_generate_key( handle, type, bits,
@@ -4110,50 +4096,50 @@
ASSERT_ALLOC( first_export, export_size );
ASSERT_ALLOC( second_export, export_size );
- TEST_ASSERT( psa_crypto_init() == PSA_SUCCESS );
+ PSA_ASSERT( psa_crypto_init() );
- TEST_ASSERT( psa_create_key( PSA_KEY_LIFETIME_PERSISTENT, 1,
- type, bits,
- &handle ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_create_key( PSA_KEY_LIFETIME_PERSISTENT, 1,
+ type, bits,
+ &handle ) );
psa_key_policy_init( &policy_set );
psa_key_policy_set_usage( &policy_set, policy_usage,
policy_alg );
- TEST_ASSERT( psa_set_key_policy( handle, &policy_set ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_set_key_policy( handle, &policy_set ) );
switch( generation_method )
{
case IMPORT_KEY:
/* Import the key */
- TEST_ASSERT( psa_import_key( handle, type,
- data->x, data->len ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_import_key( handle, type,
+ data->x, data->len ) );
break;
case GENERATE_KEY:
/* Generate a key */
- TEST_ASSERT( psa_generate_key( handle, type, bits,
- NULL, 0 ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_generate_key( handle, type, bits,
+ NULL, 0 ) );
break;
case DERIVE_KEY:
/* Create base key */
- TEST_ASSERT( psa_allocate_key( PSA_KEY_TYPE_DERIVE,
- PSA_BYTES_TO_BITS( data->len ),
- &base_key ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_allocate_key( PSA_KEY_TYPE_DERIVE,
+ PSA_BYTES_TO_BITS( data->len ),
+ &base_key ) );
psa_key_policy_init( &base_policy_set );
psa_key_policy_set_usage( &base_policy_set, PSA_KEY_USAGE_DERIVE,
base_policy_alg );
- TEST_ASSERT( psa_set_key_policy(
- base_key, &base_policy_set ) == PSA_SUCCESS );
- TEST_ASSERT( psa_import_key( base_key, PSA_KEY_TYPE_DERIVE,
- data->x, data->len ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_set_key_policy(
+ base_key, &base_policy_set ) );
+ PSA_ASSERT( psa_import_key( base_key, PSA_KEY_TYPE_DERIVE,
+ data->x, data->len ) );
/* Derive a key. */
- TEST_ASSERT( psa_key_derivation( &generator, base_key,
- base_policy_alg,
- NULL, 0, NULL, 0,
- export_size ) == PSA_SUCCESS );
- TEST_ASSERT( psa_generator_import_key(
- handle, PSA_KEY_TYPE_RAW_DATA,
- bits, &generator ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_key_derivation( &generator, base_key,
+ base_policy_alg,
+ NULL, 0, NULL, 0,
+ export_size ) );
+ PSA_ASSERT( psa_generator_import_key(
+ handle, PSA_KEY_TYPE_RAW_DATA,
+ bits, &generator ) );
break;
}
@@ -4163,17 +4149,17 @@
/* Shutdown and restart */
mbedtls_psa_crypto_free();
- TEST_ASSERT( psa_crypto_init() == PSA_SUCCESS );
+ PSA_ASSERT( psa_crypto_init() );
/* Check key slot still contains key data */
- TEST_ASSERT( psa_open_key( PSA_KEY_LIFETIME_PERSISTENT, 1,
- &handle ) == PSA_SUCCESS );
- TEST_ASSERT( psa_get_key_information(
- handle, &type_get, &bits_get ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_open_key( PSA_KEY_LIFETIME_PERSISTENT, 1,
+ &handle ) );
+ PSA_ASSERT( psa_get_key_information(
+ handle, &type_get, &bits_get ) );
TEST_ASSERT( type_get == type );
TEST_ASSERT( bits_get == (size_t) bits );
- TEST_ASSERT( psa_get_key_policy( handle, &policy_get ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_get_key_policy( handle, &policy_get ) );
TEST_ASSERT( psa_key_policy_get_usage(
&policy_get ) == policy_usage );
TEST_ASSERT( psa_key_policy_get_algorithm(
diff --git a/tests/suites/test_suite_psa_crypto_entropy.function b/tests/suites/test_suite_psa_crypto_entropy.function
index 46c77e9..117184d 100644
--- a/tests/suites/test_suite_psa_crypto_entropy.function
+++ b/tests/suites/test_suite_psa_crypto_entropy.function
@@ -55,9 +55,9 @@
TEST_ASSERT( status == expected_status_a );
status = mbedtls_psa_inject_entropy( seed, seed_length_b );
TEST_ASSERT( status == expected_status_b );
- TEST_ASSERT( psa_crypto_init( ) == PSA_SUCCESS );
- TEST_ASSERT( psa_generate_random( output,
- sizeof( output ) ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_crypto_init( ) );
+ PSA_ASSERT( psa_generate_random( output,
+ sizeof( output ) ) );
TEST_ASSERT( memcmp( output, zeros, sizeof( output ) ) != 0 );
exit:
mbedtls_free( seed );
@@ -82,15 +82,15 @@
TEST_ASSERT( ( its_status == PSA_ITS_SUCCESS ) ||
( its_status == PSA_ITS_ERROR_KEY_NOT_FOUND ) );
status = mbedtls_psa_inject_entropy( seed, sizeof( seed ) );
- TEST_ASSERT( status == PSA_SUCCESS );
+ PSA_ASSERT( status );
its_status = psa_its_remove( PSA_CRYPTO_ITS_RANDOM_SEED_UID );
TEST_ASSERT( its_status == PSA_ITS_SUCCESS );
status = psa_crypto_init( );
TEST_ASSERT( status == PSA_ERROR_INSUFFICIENT_ENTROPY );
status = mbedtls_psa_inject_entropy( seed, sizeof( seed ) );
- TEST_ASSERT( status == PSA_SUCCESS );
+ PSA_ASSERT( status );
status = psa_crypto_init( );
- TEST_ASSERT( status == PSA_SUCCESS );
+ PSA_ASSERT( status );
mbedtls_psa_crypto_free( );
/* The seed is written by nv_seed callback functions therefore the injection will fail */
status = mbedtls_psa_inject_entropy( seed, sizeof( seed ) );
diff --git a/tests/suites/test_suite_psa_crypto_hash.function b/tests/suites/test_suite_psa_crypto_hash.function
index bed80e2..5931a23 100644
--- a/tests/suites/test_suite_psa_crypto_hash.function
+++ b/tests/suites/test_suite_psa_crypto_hash.function
@@ -23,14 +23,14 @@
size_t actual_hash_length;
psa_hash_operation_t operation;
- TEST_ASSERT( psa_crypto_init( ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_crypto_init( ) );
- TEST_ASSERT( psa_hash_setup( &operation, alg ) == PSA_SUCCESS );
- TEST_ASSERT( psa_hash_update( &operation,
- input->x, input->len ) == PSA_SUCCESS );
- TEST_ASSERT( psa_hash_finish( &operation,
- actual_hash, sizeof( actual_hash ),
- &actual_hash_length ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_hash_setup( &operation, alg ) );
+ PSA_ASSERT( psa_hash_update( &operation,
+ input->x, input->len ) );
+ PSA_ASSERT( psa_hash_finish( &operation,
+ actual_hash, sizeof( actual_hash ),
+ &actual_hash_length ) );
ASSERT_COMPARE( expected_hash->x, expected_hash->len,
actual_hash, actual_hash_length );
@@ -45,15 +45,15 @@
psa_algorithm_t alg = alg_arg;
psa_hash_operation_t operation;
- TEST_ASSERT( psa_crypto_init( ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_crypto_init( ) );
- TEST_ASSERT( psa_hash_setup( &operation, alg ) == PSA_SUCCESS );
- TEST_ASSERT( psa_hash_update( &operation,
- input->x,
- input->len ) == PSA_SUCCESS );
- TEST_ASSERT( psa_hash_verify( &operation,
- expected_hash->x,
- expected_hash->len ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_hash_setup( &operation, alg ) );
+ PSA_ASSERT( psa_hash_update( &operation,
+ input->x,
+ input->len ) );
+ PSA_ASSERT( psa_hash_verify( &operation,
+ expected_hash->x,
+ expected_hash->len ) );
exit:
mbedtls_psa_crypto_free( );
@@ -69,22 +69,21 @@
psa_hash_operation_t operation;
uint32_t len = 0;
- TEST_ASSERT( psa_crypto_init( ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_crypto_init( ) );
do
{
memset( actual_hash, 0, sizeof( actual_hash ) );
- TEST_ASSERT( psa_hash_setup( &operation, alg ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_hash_setup( &operation, alg ) );
- TEST_ASSERT( psa_hash_update( &operation,
- input->x, len ) == PSA_SUCCESS );
- TEST_ASSERT( psa_hash_update( &operation,
- input->x + len, input->len - len ) ==
- PSA_SUCCESS );
+ PSA_ASSERT( psa_hash_update( &operation,
+ input->x, len ) );
+ PSA_ASSERT( psa_hash_update( &operation,
+ input->x + len, input->len - len ) );
- TEST_ASSERT( psa_hash_finish( &operation,
- actual_hash, sizeof( actual_hash ),
- &actual_hash_length ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_hash_finish( &operation,
+ actual_hash, sizeof( actual_hash ),
+ &actual_hash_length ) );
ASSERT_COMPARE( expected_hash->x, expected_hash->len,
actual_hash, actual_hash_length );
diff --git a/tests/suites/test_suite_psa_crypto_init.function b/tests/suites/test_suite_psa_crypto_init.function
index 132fe82..f4da989 100644
--- a/tests/suites/test_suite_psa_crypto_init.function
+++ b/tests/suites/test_suite_psa_crypto_init.function
@@ -142,9 +142,9 @@
for( i = 0; i < count; i++ )
{
status = psa_crypto_init( );
- TEST_ASSERT( status == PSA_SUCCESS );
+ PSA_ASSERT( status );
status = psa_crypto_init( );
- TEST_ASSERT( status == PSA_SUCCESS );
+ PSA_ASSERT( status );
mbedtls_psa_crypto_free( );
}
}
@@ -156,7 +156,7 @@
int i;
for( i = 0; i < count; i++ )
{
- TEST_ASSERT( psa_crypto_init( ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_crypto_init( ) );
mbedtls_psa_crypto_free( );
}
mbedtls_psa_crypto_free( );
@@ -172,7 +172,7 @@
for( i = 0; i < count; i++ )
{
status = psa_crypto_init( );
- TEST_ASSERT( status == PSA_SUCCESS );
+ PSA_ASSERT( status );
mbedtls_psa_crypto_free( );
}
status = psa_generate_random( random, sizeof( random ) );
@@ -189,7 +189,7 @@
for( i = 0; i < count; i++ )
{
status = psa_crypto_init( );
- TEST_ASSERT( status == PSA_SUCCESS );
+ PSA_ASSERT( status );
mbedtls_psa_crypto_free( );
}
status = psa_import_key( 1, PSA_KEY_TYPE_RAW_DATA, data, sizeof( data ) );
@@ -204,16 +204,14 @@
uint8_t random[10] = { 0 };
custom_entropy_sources_mask = sources_arg;
- TEST_ASSERT( mbedtls_psa_crypto_configure_entropy_sources(
- custom_entropy_init, mbedtls_entropy_free ) ==
- PSA_SUCCESS );
+ PSA_ASSERT( mbedtls_psa_crypto_configure_entropy_sources(
+ custom_entropy_init, mbedtls_entropy_free ) );
TEST_ASSERT( psa_crypto_init( ) == expected_init_status );
if( expected_init_status != PSA_SUCCESS )
goto exit;
- TEST_ASSERT( psa_generate_random( random, sizeof( random ) ) ==
- PSA_SUCCESS );
+ PSA_ASSERT( psa_generate_random( random, sizeof( random ) ) );
exit:
mbedtls_psa_crypto_free( );
@@ -246,16 +244,14 @@
fake_entropy_state.length_sequence = lengths;
custom_entropy_sources_mask = ENTROPY_SOURCE_FAKE;
- TEST_ASSERT( mbedtls_psa_crypto_configure_entropy_sources(
- custom_entropy_init, mbedtls_entropy_free ) ==
- PSA_SUCCESS );
+ PSA_ASSERT( mbedtls_psa_crypto_configure_entropy_sources(
+ custom_entropy_init, mbedtls_entropy_free ) );
TEST_ASSERT( psa_crypto_init( ) == expected_init_status );
if( expected_init_status != PSA_SUCCESS )
goto exit;
- TEST_ASSERT( psa_generate_random( random, sizeof( random ) ) ==
- PSA_SUCCESS );
+ PSA_ASSERT( psa_generate_random( random, sizeof( random ) ) );
exit:
mbedtls_psa_crypto_free( );
@@ -275,16 +271,14 @@
TEST_ASSERT( mbedtls_nv_seed_write( seed, seed_size ) >= 0 );
custom_entropy_sources_mask = ENTROPY_SOURCE_NV_SEED;
- TEST_ASSERT( mbedtls_psa_crypto_configure_entropy_sources(
- custom_entropy_init, mbedtls_entropy_free ) ==
- PSA_SUCCESS );
+ PSA_ASSERT( mbedtls_psa_crypto_configure_entropy_sources(
+ custom_entropy_init, mbedtls_entropy_free ) );
TEST_ASSERT( psa_crypto_init( ) == expected_init_status );
if( expected_init_status != PSA_SUCCESS )
goto exit;
- TEST_ASSERT( psa_generate_random( random, sizeof( random ) ) ==
- PSA_SUCCESS );
+ PSA_ASSERT( psa_generate_random( random, sizeof( random ) ) );
exit:
mbedtls_free( seed );
diff --git a/tests/suites/test_suite_psa_crypto_persistent_key.function b/tests/suites/test_suite_psa_crypto_persistent_key.function
index aa8fddd..bf75376 100644
--- a/tests/suites/test_suite_psa_crypto_persistent_key.function
+++ b/tests/suites/test_suite_psa_crypto_persistent_key.function
@@ -81,7 +81,6 @@
}
/* END_CASE */
-
/* BEGIN_CASE */
void save_large_persistent_key( int data_too_large, int expected_status )
{
@@ -95,12 +94,12 @@
ASSERT_ALLOC( data, data_length );
- TEST_ASSERT( psa_crypto_init() == PSA_SUCCESS );
+ PSA_ASSERT( psa_crypto_init() );
- TEST_ASSERT( psa_create_key( PSA_KEY_LIFETIME_PERSISTENT, key_id,
- PSA_KEY_TYPE_RAW_DATA,
- PSA_BYTES_TO_BITS( data_length ),
- &handle ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_create_key( PSA_KEY_LIFETIME_PERSISTENT, key_id,
+ PSA_KEY_TYPE_RAW_DATA,
+ PSA_BYTES_TO_BITS( data_length ),
+ &handle ) );
TEST_ASSERT( psa_import_key( handle, PSA_KEY_TYPE_RAW_DATA,
data, data_length ) == expected_status );
@@ -123,24 +122,24 @@
psa_key_type_t first_type = (psa_key_type_t) first_type_arg;
psa_key_type_t second_type = (psa_key_type_t) second_type_arg;
- TEST_ASSERT( psa_crypto_init() == PSA_SUCCESS );
+ PSA_ASSERT( psa_crypto_init() );
psa_key_policy_init( &policy );
- TEST_ASSERT( psa_create_key( PSA_KEY_LIFETIME_PERSISTENT, key_id,
- first_type,
- PSA_BYTES_TO_BITS( first_data->len ),
- &handle ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_create_key( PSA_KEY_LIFETIME_PERSISTENT, key_id,
+ first_type,
+ PSA_BYTES_TO_BITS( first_data->len ),
+ &handle ) );
if( should_store == 1 )
{
- TEST_ASSERT( psa_import_key(
- handle, first_type,
- first_data->x, first_data->len ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_import_key(
+ handle, first_type,
+ first_data->x, first_data->len ) );
}
/* Destroy the key */
- TEST_ASSERT( psa_destroy_key( handle ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_destroy_key( handle ) );
/* Check key slot storage is removed */
TEST_ASSERT( psa_is_key_present_in_storage( key_id ) == 0 );
@@ -150,16 +149,16 @@
/* Shutdown and restart */
mbedtls_psa_crypto_free();
- TEST_ASSERT( psa_crypto_init() == PSA_SUCCESS );
+ PSA_ASSERT( psa_crypto_init() );
/* Create another key in the same slot */
- TEST_ASSERT( psa_create_key( PSA_KEY_LIFETIME_PERSISTENT, key_id,
- second_type,
- PSA_BYTES_TO_BITS( second_data->len ),
- &handle ) == PSA_SUCCESS );
- TEST_ASSERT( psa_import_key(
- handle, second_type,
- second_data->x, second_data->len ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_create_key( PSA_KEY_LIFETIME_PERSISTENT, key_id,
+ second_type,
+ PSA_BYTES_TO_BITS( second_data->len ),
+ &handle ) );
+ PSA_ASSERT( psa_import_key(
+ handle, second_type,
+ second_data->x, second_data->len ) );
exit:
mbedtls_psa_crypto_free();
@@ -177,12 +176,12 @@
psa_key_type_t type = (psa_key_type_t) type_arg;
psa_key_handle_t handle = 0;
- TEST_ASSERT( psa_crypto_init() == PSA_SUCCESS );
+ PSA_ASSERT( psa_crypto_init() );
- TEST_ASSERT( psa_create_key( PSA_KEY_LIFETIME_PERSISTENT, key_id,
- type,
- PSA_BYTES_TO_BITS( data->len ),
- &handle ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_create_key( PSA_KEY_LIFETIME_PERSISTENT, key_id,
+ type,
+ PSA_BYTES_TO_BITS( data->len ),
+ &handle ) );
psa_key_policy_init( &policy );
TEST_ASSERT( psa_import_key( handle, type,
data->x, data->len ) == expected_status );
@@ -193,7 +192,7 @@
goto exit;
}
- TEST_ASSERT( psa_get_key_lifetime( handle, &lifetime ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_get_key_lifetime( handle, &lifetime ) );
TEST_ASSERT( lifetime == PSA_KEY_LIFETIME_PERSISTENT );
exit:
@@ -219,28 +218,28 @@
ASSERT_ALLOC( exported, export_size );
- TEST_ASSERT( psa_crypto_init( ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_crypto_init( ) );
- TEST_ASSERT( psa_create_key( PSA_KEY_LIFETIME_PERSISTENT, key_id,
- type,
- PSA_BYTES_TO_BITS( data->len ),
- &handle ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_create_key( PSA_KEY_LIFETIME_PERSISTENT, key_id,
+ type,
+ PSA_BYTES_TO_BITS( data->len ),
+ &handle ) );
psa_key_policy_init( &policy );
psa_key_policy_set_usage( &policy, PSA_KEY_USAGE_EXPORT,
PSA_ALG_VENDOR_FLAG );
- TEST_ASSERT( psa_set_key_policy( handle, &policy ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_set_key_policy( handle, &policy ) );
/* Import the key */
- TEST_ASSERT( psa_import_key( handle, type,
- data->x, data->len ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_import_key( handle, type,
+ data->x, data->len ) );
- TEST_ASSERT( psa_get_key_lifetime( handle, &lifetime_get ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_get_key_lifetime( handle, &lifetime_get ) );
TEST_ASSERT( lifetime_get == PSA_KEY_LIFETIME_PERSISTENT );
/* Test the key information */
- TEST_ASSERT( psa_get_key_information(
- handle, &got_type, &got_bits ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_get_key_information(
+ handle, &got_type, &got_bits ) );
TEST_ASSERT( got_type == type );
TEST_ASSERT( got_bits == (size_t) expected_bits );
@@ -251,13 +250,13 @@
psa_destroy_persistent_key( key_id );
}
/* Export the key */
- TEST_ASSERT( psa_export_key( handle, exported, export_size,
- &exported_length ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_export_key( handle, exported, export_size,
+ &exported_length ) );
ASSERT_COMPARE( data->x, data->len, exported, exported_length );
/* Destroy the key */
- TEST_ASSERT( psa_destroy_key( handle ) == PSA_SUCCESS );
+ PSA_ASSERT( psa_destroy_key( handle ) );
TEST_ASSERT( psa_is_key_present_in_storage( key_id ) == 0 );
exit:
diff --git a/tests/suites/test_suite_psa_crypto_slot_management.function b/tests/suites/test_suite_psa_crypto_slot_management.function
index 407d24b..4584ceb 100644
--- a/tests/suites/test_suite_psa_crypto_slot_management.function
+++ b/tests/suites/test_suite_psa_crypto_slot_management.function
@@ -367,7 +367,7 @@
&handles[i] );
if( status == PSA_ERROR_INSUFFICIENT_MEMORY )
break;
- TEST_ASSERT( status == PSA_SUCCESS );
+ PSA_ASSERT( status );
TEST_ASSERT( handles[i] != 0 );
for( j = 0; j < i; j++ )
TEST_ASSERT( handles[i] != handles[j] );
diff --git a/tests/suites/test_suite_psa_crypto_storage_file.function b/tests/suites/test_suite_psa_crypto_storage_file.function
index e753d78..dabba20 100644
--- a/tests/suites/test_suite_psa_crypto_storage_file.function
+++ b/tests/suites/test_suite_psa_crypto_storage_file.function
@@ -97,7 +97,6 @@
}
/* END_CASE */
-
/* BEGIN_CASE */
void get_file_size( data_t *data, int expected_data_length,
int expected_status, int should_make_file )