Zero-length test for psa_crypto_alloc_and_copy()

Signed-off-by: David Horstmann <david.horstmann@arm.com>
This commit is contained in:
David Horstmann 2023-11-01 12:30:24 +00:00
parent f06ac88284
commit 03b0472413
2 changed files with 35 additions and 0 deletions

View File

@ -7448,3 +7448,12 @@ psa_crypto_alloc_and_copy:0:20:1:0:PSA_SUCCESS
PSA buffers alloc and copy: null input and output
psa_crypto_alloc_and_copy:1:0:1:0:PSA_SUCCESS
PSA buffers alloc and copy zero-length input
psa_crypto_alloc_and_copy_zero_length:1:0
PSA buffers alloc and copy zero-length output
psa_crypto_alloc_and_copy_zero_length:0:1
PSA buffers alloc and copy both zero length
psa_crypto_alloc_and_copy_zero_length:1:1

View File

@ -10412,3 +10412,29 @@ exit:
mbedtls_free(buffer_copies.output);
}
/* END_CASE */
/* BEGIN_CASE */
void psa_crypto_alloc_and_copy_zero_length(int input_zero_length,
int output_zero_length)
{
uint8_t input_buffer[] = { 0x12 };
uint8_t output_buffer[] = { 0x34 };
psa_crypto_buffer_copy_t buffer_copies;
size_t input_len = input_zero_length ? 0 : 1;
size_t output_len = output_zero_length ? 0 : 1;
psa_status_t ret = psa_crypto_alloc_and_copy(input_buffer, input_len,
output_buffer, output_len,
&buffer_copies);
TEST_EQUAL(ret, PSA_SUCCESS);
TEST_MEMORY_COMPARE(input_buffer, input_len, buffer_copies.input, buffer_copies.input_len);
TEST_EQUAL(output_len, buffer_copies.output_len);
exit:
mbedtls_free(buffer_copies.input);
mbedtls_free(buffer_copies.output);
}
/* END_CASE */