Add testcase for psa_crypto_input_copy_alloc()

Signed-off-by: David Horstmann <david.horstmann@arm.com>
This commit is contained in:
David Horstmann 2023-11-06 18:18:59 +00:00
parent 6fd4c7cff2
commit 1ac7e24fb7
2 changed files with 37 additions and 0 deletions

View File

@ -27,3 +27,9 @@ copy_output:0:10:PSA_SUCCESS
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

View File

@ -78,3 +78,34 @@ exit:
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 */