From 35dd103688acdb4e01da7c2dff8c3dde319add51 Mon Sep 17 00:00:00 2001 From: David Horstmann Date: Wed, 8 Nov 2023 18:01:40 +0000 Subject: [PATCH] Add input round-trip testcase Signed-off-by: David Horstmann --- .../suites/test_suite_psa_crypto_memory.data | 3 +++ .../test_suite_psa_crypto_memory.function | 21 +++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/tests/suites/test_suite_psa_crypto_memory.data b/tests/suites/test_suite_psa_crypto_memory.data index 2ca7e15abf..3d14ba35dc 100644 --- a/tests/suites/test_suite_psa_crypto_memory.data +++ b/tests/suites/test_suite_psa_crypto_memory.data @@ -40,6 +40,9 @@ input_copy_free:200 PSA crypto input copy free, NULL buffer input_copy_free:0 +PSA crypto input copy round-trip +input_copy_round_trip + PSA crypto output copy alloc output_copy_alloc:200:PSA_SUCCESS diff --git a/tests/suites/test_suite_psa_crypto_memory.function b/tests/suites/test_suite_psa_crypto_memory.function index 57a10ae791..3c7b8425eb 100644 --- a/tests/suites/test_suite_psa_crypto_memory.function +++ b/tests/suites/test_suite_psa_crypto_memory.function @@ -131,6 +131,27 @@ exit: } /* END_CASE */ +/* BEGIN_CASE */ +void input_copy_round_trip() +{ + psa_crypto_input_copy_t input_copy; + uint8_t input[200]; + psa_status_t status; + + fill_buffer_pattern(input, sizeof(input)); + + status = psa_crypto_input_copy_alloc(input, sizeof(input), &input_copy); + TEST_EQUAL(status, PSA_SUCCESS); + TEST_MEMORY_COMPARE(input_copy.buffer, input_copy.len, + input, sizeof(input)); + TEST_ASSERT(input_copy.buffer != input); + + psa_crypto_input_copy_free(&input_copy); + TEST_ASSERT(input_copy.buffer == NULL); + TEST_EQUAL(input_copy.len, 0); +} +/* END_CASE */ + /* BEGIN_CASE */ void output_copy_alloc(int output_len, psa_status_t exp_status) {