mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-04-15 23:42:41 +00:00
Add output round-trip testcase
Signed-off-by: David Horstmann <david.horstmann@arm.com>
This commit is contained in:
parent
35dd103688
commit
0a57ed25c4
@ -57,3 +57,6 @@ output_copy_free:0:0:PSA_SUCCESS
|
||||
|
||||
PSA crypto output copy free, NULL original buffer
|
||||
output_copy_free:200:1:PSA_ERROR_CORRUPTION_DETECTED
|
||||
|
||||
PSA crypto output copy round-trip
|
||||
output_copy_round_trip
|
||||
|
@ -229,3 +229,34 @@ exit:
|
||||
output_copy.len = 0;
|
||||
}
|
||||
/* END_CASE */
|
||||
|
||||
/* BEGIN_CASE */
|
||||
void output_copy_round_trip()
|
||||
{
|
||||
psa_crypto_output_copy_t output_copy;
|
||||
uint8_t output[200];
|
||||
uint8_t *buffer_copy_for_comparison = NULL;
|
||||
psa_status_t status;
|
||||
|
||||
status = psa_crypto_output_copy_alloc(output, sizeof(output), &output_copy);
|
||||
TEST_EQUAL(status, PSA_SUCCESS);
|
||||
TEST_ASSERT(output_copy.buffer != output);
|
||||
|
||||
/* Simulate the function generating output */
|
||||
fill_buffer_pattern(output_copy.buffer, output_copy.len);
|
||||
|
||||
TEST_CALLOC(buffer_copy_for_comparison, output_copy.len);
|
||||
memcpy(buffer_copy_for_comparison, output_copy.buffer, output_copy.len);
|
||||
|
||||
psa_crypto_output_copy_free(&output_copy);
|
||||
TEST_ASSERT(output_copy.buffer == NULL);
|
||||
TEST_EQUAL(output_copy.len, 0);
|
||||
|
||||
/* Check that the buffer was correctly copied back */
|
||||
TEST_MEMORY_COMPARE(output, sizeof(output),
|
||||
buffer_copy_for_comparison, sizeof(output));
|
||||
|
||||
exit:
|
||||
mbedtls_free(buffer_copy_for_comparison);
|
||||
}
|
||||
/* END_CASE */
|
||||
|
Loading…
x
Reference in New Issue
Block a user