1
0
mirror of https://github.com/Mbed-TLS/mbedtls.git synced 2025-07-30 22:43:08 +03:00

Create memory poisoning wrapper for cipher encrypt

Use the preprocessor to wrap psa_cipher_encrypt in a wrapper that
poisons the input and output buffers.

Signed-off-by: David Horstmann <david.horstmann@arm.com>
This commit is contained in:
David Horstmann
2023-11-27 17:32:47 +00:00
parent 38e4e9c499
commit 8f35a4f003
2 changed files with 31 additions and 0 deletions

View File

@ -0,0 +1,27 @@
#include "psa/crypto.h"
#include "test/memory.h"
psa_status_t wrap_psa_cipher_encrypt(mbedtls_svc_key_id_t key,
psa_algorithm_t alg,
const uint8_t *input,
size_t input_length,
uint8_t *output,
size_t output_size,
size_t *output_length)
{
MBEDTLS_TEST_MEMORY_POISON(input, input_length);
MBEDTLS_TEST_MEMORY_POISON(output, output_size);
psa_status_t status = psa_cipher_encrypt(key,
alg,
input,
input_length,
output,
output_size,
output_length);
MBEDTLS_TEST_MEMORY_UNPOISON(input, input_length);
MBEDTLS_TEST_MEMORY_UNPOISON(output, output_size);
return status;
}
#define psa_cipher_encrypt(...) wrap_psa_cipher_encrypt(__VA_ARGS__)