From 3d91abefac0e6be0a6cc1aa094392181c549acb0 Mon Sep 17 00:00:00 2001 From: mohammad1603 Date: Tue, 3 Jul 2018 13:15:54 +0300 Subject: [PATCH] Use PSA_BLOCK_CIPHER_BLOCK_SIZE() macro to get the cipher block size Use PSA_BLOCK_CIPHER_BLOCK_SIZE() macro to get the cipher block size instead of accessing the operation struct additionally, for SPM case, the 'block_size' member is not a member in the operation struct --- tests/suites/test_suite_psa_crypto.function | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/tests/suites/test_suite_psa_crypto.function b/tests/suites/test_suite_psa_crypto.function index 1017e88c8..9eac29b43 100644 --- a/tests/suites/test_suite_psa_crypto.function +++ b/tests/suites/test_suite_psa_crypto.function @@ -1057,7 +1057,8 @@ void cipher_encrypt( int alg_arg, int key_type_arg, TEST_ASSERT( psa_encrypt_set_iv( &operation, iv, iv_size ) == PSA_SUCCESS ); - output_buffer_size = input->len + operation.block_size; + output_buffer_size = (size_t) input->len + + PSA_BLOCK_CIPHER_BLOCK_SIZE( key_type ); output = mbedtls_calloc( 1, output_buffer_size ); TEST_ASSERT( output != NULL ); @@ -1126,7 +1127,8 @@ void cipher_encrypt_multipart( int alg_arg, int key_type_arg, TEST_ASSERT( psa_encrypt_set_iv( &operation, iv, sizeof( iv ) ) == PSA_SUCCESS ); - output_buffer_size = input->len + operation.block_size; + output_buffer_size = (size_t) input->len + + PSA_BLOCK_CIPHER_BLOCK_SIZE( key_type ); output = mbedtls_calloc( 1, output_buffer_size ); TEST_ASSERT( output != NULL ); @@ -1199,7 +1201,8 @@ void cipher_decrypt_multipart( int alg_arg, int key_type_arg, TEST_ASSERT( psa_encrypt_set_iv( &operation, iv, sizeof( iv ) ) == PSA_SUCCESS ); - output_buffer_size = input->len + operation.block_size; + output_buffer_size = (size_t) input->len + + PSA_BLOCK_CIPHER_BLOCK_SIZE( key_type ); output = mbedtls_calloc( 1, output_buffer_size ); TEST_ASSERT( output != NULL ); @@ -1273,7 +1276,8 @@ void cipher_decrypt( int alg_arg, int key_type_arg, TEST_ASSERT( psa_encrypt_set_iv( &operation, iv, iv_size ) == PSA_SUCCESS ); - output_buffer_size = input->len + operation.block_size; + output_buffer_size = (size_t) input->len + + PSA_BLOCK_CIPHER_BLOCK_SIZE( key_type ); output = mbedtls_calloc( 1, output_buffer_size ); TEST_ASSERT( output != NULL ); @@ -1343,7 +1347,8 @@ void cipher_verify_output( int alg_arg, int key_type_arg, TEST_ASSERT( psa_encrypt_generate_iv( &operation1, iv, iv_size, &iv_length ) == PSA_SUCCESS ); - output1_size = input->len + operation1.block_size; + output1_size = (size_t) input->len + + PSA_BLOCK_CIPHER_BLOCK_SIZE( key_type ); output1 = mbedtls_calloc( 1, output1_size ); TEST_ASSERT( output1 != NULL ); @@ -1429,7 +1434,8 @@ void cipher_verify_output_multipart( int alg_arg, TEST_ASSERT( psa_encrypt_generate_iv( &operation1, iv, iv_size, &iv_length ) == PSA_SUCCESS ); - output1_buffer_size = input->len + operation1.block_size; + output1_buffer_size = (size_t) input->len + + PSA_BLOCK_CIPHER_BLOCK_SIZE( key_type ); output1 = mbedtls_calloc( 1, output1_buffer_size ); TEST_ASSERT( output1 != NULL );