From adb9b2372b9edd355e4d1a87cf8c742033264dd0 Mon Sep 17 00:00:00 2001 From: Mohammad AboMokh Date: Thu, 28 Jun 2018 01:52:54 -0700 Subject: [PATCH 1/2] fix PSA_BLOCK_CIPHER_BLOCK_SIZE() argument in test code --- tests/suites/test_suite_psa_crypto.function | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/suites/test_suite_psa_crypto.function b/tests/suites/test_suite_psa_crypto.function index 0d056db2a..51e541902 100644 --- a/tests/suites/test_suite_psa_crypto.function +++ b/tests/suites/test_suite_psa_crypto.function @@ -108,9 +108,9 @@ static int exercise_cipher_key( psa_key_slot_t key, if( usage & PSA_KEY_USAGE_DECRYPT ) { psa_status_t status; + psa_key_type_t type = PSA_KEY_TYPE_NONE; if( ! ( usage & PSA_KEY_USAGE_ENCRYPT ) ) { - psa_key_type_t type; size_t bits; TEST_ASSERT( psa_get_key_information( key, &type, &bits ) ); iv_length = PSA_BLOCK_CIPHER_BLOCK_SIZE( type ); @@ -130,7 +130,7 @@ static int exercise_cipher_key( psa_key_slot_t key, * if the input is some aribtrary data rather than an actual ciphertext, a padding error is likely. */ if( ( usage & PSA_KEY_USAGE_DECRYPT ) || - PSA_BLOCK_CIPHER_BLOCK_SIZE( alg ) == 1 ) + PSA_BLOCK_CIPHER_BLOCK_SIZE( type ) == 1 ) TEST_ASSERT( status == PSA_SUCCESS ); else TEST_ASSERT( status == PSA_SUCCESS || From 65fa0b84339ac07ec93db350a11437b46752c188 Mon Sep 17 00:00:00 2001 From: Mohammad AboMokh Date: Thu, 28 Jun 2018 02:14:00 -0700 Subject: [PATCH 2/2] fix if condition to validate encrypt key usage --- tests/suites/test_suite_psa_crypto.function | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/suites/test_suite_psa_crypto.function b/tests/suites/test_suite_psa_crypto.function index 51e541902..6bcc65f31 100644 --- a/tests/suites/test_suite_psa_crypto.function +++ b/tests/suites/test_suite_psa_crypto.function @@ -129,7 +129,7 @@ static int exercise_cipher_key( psa_key_slot_t key, /* For a stream cipher, all inputs are valid. For a block cipher, * if the input is some aribtrary data rather than an actual ciphertext, a padding error is likely. */ - if( ( usage & PSA_KEY_USAGE_DECRYPT ) || + if( ( usage & PSA_KEY_USAGE_ENCRYPT ) || PSA_BLOCK_CIPHER_BLOCK_SIZE( type ) == 1 ) TEST_ASSERT( status == PSA_SUCCESS ); else