diff --git a/tests/suites/test_suite_psa_crypto.data b/tests/suites/test_suite_psa_crypto.data index ca13b51e84..be32882513 100644 --- a/tests/suites/test_suite_psa_crypto.data +++ b/tests/suites/test_suite_psa_crypto.data @@ -7416,6 +7416,12 @@ psa_crypto_copy_input:10:20:PSA_SUCCESS PSA input buffer copy: copy buffer too small psa_crypto_copy_input:20:10:PSA_ERROR_BUFFER_TOO_SMALL +PSA input buffer copy: zero-length source buffer +psa_crypto_copy_input:0:10:PSA_SUCCESS + +PSA input buffer copy: zero-length both buffers +psa_crypto_copy_input:0:0:PSA_SUCCESS + PSA output buffer copy: straightforward copy psa_crypto_copy_output:20:20:PSA_SUCCESS @@ -7425,6 +7431,12 @@ psa_crypto_copy_output:10:20:PSA_SUCCESS PSA output buffer copy: output buffer too small psa_crypto_copy_output:20:10:PSA_ERROR_BUFFER_TOO_SMALL +PSA output buffer copy: zero-length source buffer +psa_crypto_copy_output:0:10:PSA_SUCCESS + +PSA output buffer copy: zero-length both buffers +psa_crypto_copy_output:0:0:PSA_SUCCESS + PSA buffers alloc and copy psa_crypto_alloc_and_copy:0:20:0:20:PSA_SUCCESS diff --git a/tests/suites/test_suite_psa_crypto.function b/tests/suites/test_suite_psa_crypto.function index cd46fef13b..1e9e8d9565 100644 --- a/tests/suites/test_suite_psa_crypto.function +++ b/tests/suites/test_suite_psa_crypto.function @@ -10314,8 +10314,12 @@ void psa_crypto_copy_input(int src_len, int dst_len, int exp_ret) uint8_t *dst_buffer = NULL; psa_status_t ret; - TEST_CALLOC(src_buffer, src_len); - TEST_CALLOC(dst_buffer, dst_len); + /* Special case, when src_len or dst_len is 0, we want to test on a real + * buffer. Calling TEST_CALLOC with 0 will return NULL. */ + size_t src_calloc_len = (src_len == 0 ? 1 : src_len); + size_t dst_calloc_len = (dst_len == 0 ? 1 : dst_len); + TEST_CALLOC(src_buffer, src_calloc_len); + TEST_CALLOC(dst_buffer, dst_calloc_len); for (int i = 0; i < src_len; i++) { src_buffer[i] = data[i % sizeof(data)]; @@ -10343,8 +10347,12 @@ void psa_crypto_copy_output(int src_len, int dst_len, int exp_ret) uint8_t *dst_buffer = NULL; psa_status_t ret; - TEST_CALLOC(src_buffer, src_len); - TEST_CALLOC(dst_buffer, dst_len); + /* Special case, when src_len or dst_len is 0, we want to test on a real + * buffer. Calling TEST_CALLOC with 0 will return NULL. */ + size_t src_calloc_len = (src_len == 0 ? 1 : src_len); + size_t dst_calloc_len = (dst_len == 0 ? 1 : dst_len); + TEST_CALLOC(src_buffer, src_calloc_len); + TEST_CALLOC(dst_buffer, dst_calloc_len); for (int i = 0; i < src_len; i++) { src_buffer[i] = data[i % sizeof(data)];