Specifically:
* Move the creation of the pointer to the copied buffer into the
DECLARE() macro, to solve warnings about potentially skipping
initialization.
* Reorder the arguments of the FREE() macro - having a different order
made it confusing, so keep the order the same throughout.
Signed-off-by: David Horstmann <david.horstmann@arm.com>
Note that enabling MBEDTLS_PSA_COPY_CALLER_BUFFERS allows full buffer
overlap support, whereas without it, overlap support is reduced to that
documented in the function descriptions.
Signed-off-by: David Horstmann <david.horstmann@arm.com>
* Separate initialization from allocation.
* Rewrite description of macros to fit the new interface.
* Use a longer name to store the local copy objects, to reduce the risk
of shadowing.
* Use different names for the original and the copy. Append the suffix
'_external' to the original argument and use the previous name
for the copy.
Signed-off-by: David Horstmann <david.horstmann@arm.com>
Previously the return from psa_crypto_local_output_free() had a fixed
name, which meant that multiple outputs would cause redefinitions of the
same variable.
Signed-off-by: David Horstmann <david.horstmann@arm.com>
* Set swapped pointers to NULL when the buffers are freed.
* Change example name <buffer> to <input> and <output> to reduce
confusion.
* Document assumptions of FREE_LOCAL_ macros.
* Add comment on error case in FREE_LOCAL_OUTPUT(), explaining why it's
okay to mask the existing status code.
Signed-off-by: David Horstmann <david.horstmann@arm.com>
Since psa_crypto.c does not include tests/include/test/memory.h, we do
not need the tests/include include path.
Signed-off-by: David Horstmann <david.horstmann@arm.com>
This allows us to entirely remove copying code, where the convenience
macros are used for copying.
Signed-off-by: David Horstmann <david.horstmann@arm.com>
This check is intended to ensure that we do not write intermediate
results to the shared output buffer. This check will be made obselete
by generic memory-poisoning-based testing for all functions.
Signed-off-by: David Horstmann <david.horstmann@arm.com>
Since we are applying hooks transparently to all tests, we cannot setup
and teardown test hooks in the tests. Instead we must do this in the
test wrappers which are used to pre-poison and unpoison memory.
Signed-off-by: David Horstmann <david.horstmann@arm.com>
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>
These are needed to allow them to operate on buffer copies without
triggering ASan use-after-poison detection.
Signed-off-by: David Horstmann <david.horstmann@arm.com>
Now that library is in the include path when compiling metatest.c, don't
duplicate the definition of __func__ from library/common.h.
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
Asan poisons memory with an 8-byte granularity. We want to make sure that
the whole specified region is poisoned (our typical use case is a
heap-allocated object, and we want to poison the whole object, and we don't
care about the bytes after the end of the object and up to the beginning of
the next object). So align the start and end of the region to (un)poison to
an 8-byte boundary.
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
While an area of memory is poisoned, reading or writing from it triggers a
sanitizer violation.
Implemented for ASan.
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>