Add explicit UNPOISON calls to memory tests

These are needed to allow them to operate on buffer copies without
triggering ASan use-after-poison detection.

Signed-off-by: David Horstmann <david.horstmann@arm.com>
diff --git a/tests/suites/test_suite_psa_crypto_memory.function b/tests/suites/test_suite_psa_crypto_memory.function
index 2bb0f0d..55c0092 100644
--- a/tests/suites/test_suite_psa_crypto_memory.function
+++ b/tests/suites/test_suite_psa_crypto_memory.function
@@ -9,6 +9,7 @@
 #include "psa_crypto_invasive.h"
 
 #include "test/psa_crypto_helpers.h"
+#include "test/memory.h"
 
 /* Helper to fill a buffer with a data pattern. The pattern is not
  * important, it just allows a basic check that the correct thing has
@@ -42,6 +43,7 @@
     TEST_EQUAL(status, exp_status);
 
     if (exp_status == PSA_SUCCESS) {
+        MBEDTLS_TEST_MEMORY_UNPOISON(src_buffer, src_len);
         /* Note: We compare the first src_len bytes of each buffer, as this is what was copied. */
         TEST_MEMORY_COMPARE(src_buffer, src_len, dst_buffer, src_len);
     }
@@ -68,6 +70,7 @@
     TEST_EQUAL(status, exp_status);
 
     if (exp_status == PSA_SUCCESS) {
+        MBEDTLS_TEST_MEMORY_UNPOISON(dst_buffer, dst_len);
         /* Note: We compare the first src_len bytes of each buffer, as this is what was copied. */
         TEST_MEMORY_COMPARE(src_buffer, src_len, dst_buffer, src_len);
     }
@@ -94,6 +97,7 @@
     TEST_EQUAL(status, exp_status);
 
     if (exp_status == PSA_SUCCESS) {
+        MBEDTLS_TEST_MEMORY_UNPOISON(input, input_len);
         if (input_len != 0) {
             TEST_ASSERT(local_input.buffer != input);
         }
@@ -139,6 +143,8 @@
 
     status = psa_crypto_local_input_alloc(input, sizeof(input), &local_input);
     TEST_EQUAL(status, PSA_SUCCESS);
+
+    MBEDTLS_TEST_MEMORY_UNPOISON(input, sizeof(input));
     TEST_MEMORY_COMPARE(local_input.buffer, local_input.length,
                         input, sizeof(input));
     TEST_ASSERT(local_input.buffer != input);
@@ -204,6 +210,7 @@
     TEST_EQUAL(status, exp_status);
 
     if (exp_status == PSA_SUCCESS) {
+        MBEDTLS_TEST_MEMORY_UNPOISON(output, output_len);
         TEST_ASSERT(local_output.buffer == NULL);
         TEST_EQUAL(local_output.length, 0);
         TEST_MEMORY_COMPARE(buffer_copy_for_comparison, output_len,
@@ -240,6 +247,7 @@
     TEST_ASSERT(local_output.buffer == NULL);
     TEST_EQUAL(local_output.length, 0);
 
+    MBEDTLS_TEST_MEMORY_UNPOISON(output, sizeof(output));
     /* Check that the buffer was correctly copied back */
     TEST_MEMORY_COMPARE(output, sizeof(output),
                         buffer_copy_for_comparison, sizeof(output));