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
diff --git a/tests/suites/test_suite_psa_crypto.function b/tests/suites/test_suite_psa_crypto.function
index 1017e88..9eac29b 100644
--- a/tests/suites/test_suite_psa_crypto.function
+++ b/tests/suites/test_suite_psa_crypto.function
@@ -1057,7 +1057,8 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 );