1
0
mirror of https://github.com/ARMmbed/mbedtls.git synced 2025-05-16 03:37:49 +08:00

Add testcase for psa_crypto_output_copy_alloc()

Signed-off-by: David Horstmann <david.horstmann@arm.com>
This commit is contained in:
David Horstmann 2023-11-08 15:10:41 +00:00
parent dfa14cbbcd
commit 70b82256b5
2 changed files with 39 additions and 0 deletions

View File

@ -39,3 +39,9 @@ input_copy_free:200
PSA crypto input copy free, NULL buffer
input_copy_free:0
PSA crypto output copy alloc
output_copy_alloc:200:PSA_SUCCESS
PSA crypto output copy alloc, NULL buffer
output_copy_alloc:0:PSA_SUCCESS

View File

@ -130,3 +130,36 @@ exit:
input_copy.len = 0;
}
/* END_CASE */
/* BEGIN_CASE */
void output_copy_alloc(int output_len, psa_status_t exp_status)
{
uint8_t *output = NULL;
psa_crypto_output_copy_t output_copy;
psa_status_t status;
output_copy.buffer = NULL;
TEST_CALLOC(output, output_len);
status = psa_crypto_output_copy_alloc(output, output_len, &output_copy);
TEST_EQUAL(status, exp_status);
if (exp_status == PSA_SUCCESS) {
TEST_ASSERT(output_copy.original == output);
if (output == NULL) {
TEST_ASSERT(output_copy.buffer == NULL);
} else {
TEST_EQUAL(output_copy.len, output_len);
}
}
exit:
mbedtls_free(output_copy.buffer);
output_copy.original = NULL;
output_copy.buffer = NULL;
output_copy.len = 0;
mbedtls_free(output);
output = NULL;
}
/* END_CASE */