Add testcase for psa_crypto_input_copy_alloc()
Signed-off-by: David Horstmann <david.horstmann@arm.com>
diff --git a/tests/suites/test_suite_psa_crypto_memory.data b/tests/suites/test_suite_psa_crypto_memory.data
index 0d44fb3..85fed8f 100644
--- a/tests/suites/test_suite_psa_crypto_memory.data
+++ b/tests/suites/test_suite_psa_crypto_memory.data
@@ -27,3 +27,9 @@
PSA output buffer copy: zero-length both buffers
copy_output:0:0:PSA_SUCCESS
+
+PSA crypto input copy alloc
+input_copy_alloc:200:PSA_SUCCESS
+
+PSA crypto input copy alloc, NULL buffer
+input_copy_alloc:0:PSA_SUCCESS
diff --git a/tests/suites/test_suite_psa_crypto_memory.function b/tests/suites/test_suite_psa_crypto_memory.function
index 7e59bb9..837ff06 100644
--- a/tests/suites/test_suite_psa_crypto_memory.function
+++ b/tests/suites/test_suite_psa_crypto_memory.function
@@ -78,3 +78,34 @@
mbedtls_free(dst_buffer);
}
/* END_CASE */
+
+/* BEGIN_CASE */
+void input_copy_alloc(int input_len, psa_status_t exp_status)
+{
+ uint8_t *input = NULL;
+ psa_crypto_input_copy_t input_copy;
+ psa_status_t status;
+
+ input_copy.buffer = NULL;
+
+ TEST_CALLOC(input, input_len);
+ fill_buffer_pattern(input, input_len);
+
+ status = psa_crypto_input_copy_alloc(input, input_len, &input_copy);
+ TEST_EQUAL(status, exp_status);
+
+ if (exp_status == PSA_SUCCESS) {
+ if (input == NULL) {
+ TEST_ASSERT(input_copy.buffer == NULL);
+ } else {
+ TEST_ASSERT(input_copy.buffer != input);
+ TEST_MEMORY_COMPARE(input, input_len,
+ input_copy.buffer, input_copy.len);
+ }
+ }
+
+exit:
+ mbedtls_free(input_copy.buffer);
+ mbedtls_free(input);
+}
+/* END_CASE */