From ded14a2c0214d30744f719ed4a1892e2aff3cba6 Mon Sep 17 00:00:00 2001 From: David Horstmann Date: Mon, 23 Oct 2023 18:58:41 +0100 Subject: [PATCH] Add example wrapper function implementation Give an example wrapper foir psa_aead_update for the transparent testing option. Signed-off-by: David Horstmann --- docs/architecture/psa-shared-memory.md | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/docs/architecture/psa-shared-memory.md b/docs/architecture/psa-shared-memory.md index 0d48324262..b10953824e 100644 --- a/docs/architecture/psa-shared-memory.md +++ b/docs/architecture/psa-shared-memory.md @@ -509,7 +509,27 @@ We will specify the particularities of each approach's implementation below. In order to implement transparent memory poisoning we require a wrapper around all PSA function calls that poisons any input and output buffers. -The easiest way to do this is to create a header that `#define`s PSA function names to be wrapped versions of themselves. +The easiest way to do this is to create wrapper functions that poison the memory and then `#define` PSA function names to be wrapped versions of themselves. For example, to replace `psa_aead_update()`: +```c +psa_status_t mem_poison_psa_aead_update(psa_aead_operation_t *operation, + const uint8_t *input, + size_t input_length, + uint8_t *output, + size_t output_size, + size_t *output_length) +{ + mbedtls_psa_core_poison_memory(input, input_length, 1); + mbedtls_psa_core_poison_memory(output, output_size, 1); + psa_status_t status = psa_aead_update(operation, input, input_length, + output, output_size, output_length); + mbedtls_psa_core_poison_memory(input, input_length, 0); + mbedtls_psa_core_poison_memory(output, output_size, 0); + + return status; +} + +#define psa_aead_update(...) mem_poison_psa_aead_update(__VA_ARGS__) +``` #### Memory poisoning functions and a new testsuite