Add a new macro `LOCAL_OUTPUT_ALLOC_WITH_COPY` to support the output buffer
handling of the multipart operations like `psa_cipher_update`. This will
allocate a local buffer and copy the content of the original buffer.
Signed-off-by: Gabor Mezei <gabor.mezei@arm.com>
The signature and naming of the Montgomrey initialisation function in
development and in the LTS was different. Align them for easier
readability and maintenance.
Signed-off-by: Janos Follath <janos.follath@arm.com>
So far we needed it only locally here, but we will need calculating RR
for safe unblinding in RSA as well.
Signed-off-by: Janos Follath <janos.follath@arm.com>
The signature and naming of the Montgomrey initialisation function in
development and in the LTS was different. Align them for easier
readability and maintenance.
Signed-off-by: Janos Follath <janos.follath@arm.com>
So far we needed it only locally here, but we will need calculating RR
for safe unblinding in RSA as well.
Signed-off-by: Janos Follath <janos.follath@arm.com>
Make sure the ctx variable in function mbedtls_timing_self_test is initialized properly, to avoid build
failures with -O3 e.g. on ppc64el
cd /<<PKGBUILDDIR>>/obj-powerpc64le-linux-gnu/library && /usr/bin/cc -I/<<PKGBUILDDIR>>/include -I/<<PKGBUILDDIR>>/library -g -O3 -Werror=implicit-function-declaration -Werror=array-bounds -Werror=clobbered -Werror=volatile-register-var -D__DEB_CANARY_CFLAGS_428fca9bc1921c25c5121f9da7815cde__ -fno-omit-frame-pointer -ffile-prefix-map=/<<PKGBUILDDIR>>=. -fstack-protector-strong -Wformat -Werror=format-security -fdebug-prefix-map=/<<PKGBUILDDIR>>=/usr/src/mbedtls-2.28.6-1 -D__DEB_CANARY_CPPFLAGS_428fca9bc1921c25c5121f9da7815cde__ -Wdate-time -D_FORTIFY_SOURCE=3 -Wall -Wextra -Wwrite-strings -Wformat=2 -Wno-format-nonliteral -Wvla -Wlogical-op -Wshadow -Wformat-signedness -Wformat-overflow=2 -Wformat-truncation -Werror -Wmissing-declarations -Wmissing-prototypes -MD -MT library/CMakeFiles/mbedcrypto_static.dir/xtea.c.o -MF CMakeFiles/mbedcrypto_static.dir/xtea.c.o.d -o CMakeFiles/mbedcrypto_static.dir/xtea.c.o -c /<<PKGBUILDDIR>>/library/xtea.c
In function ‘mbedtls_timing_get_delay’,
inlined from ‘mbedtls_timing_self_test’ at /<<PKGBUILDDIR>>/library/timing.c:427:13:
/<<PKGBUILDDIR>>/library/timing.c:334:12: error: ‘ctx.fin_ms’ may be used uninitialized [-Werror=maybe-uninitialized]
334 | if (ctx->fin_ms == 0) {
| ~~~^~~~~~~~
/<<PKGBUILDDIR>>/library/timing.c: In function ‘mbedtls_timing_self_test’:
/<<PKGBUILDDIR>>/library/timing.c:402:34: note: ‘ctx’ declared here
402 | mbedtls_timing_delay_context ctx;
| ^~~
In function ‘mbedtls_timing_get_delay’,
inlined from ‘mbedtls_timing_self_test’ at /<<PKGBUILDDIR>>/library/timing.c:427:13:
/<<PKGBUILDDIR>>/library/timing.c:344:26: error: ‘ctx.int_ms’ may be used uninitialized [-Werror=maybe-uninitialized]
344 | if (elapsed_ms >= ctx->int_ms) {
| ~~~^~~~~~~~
/<<PKGBUILDDIR>>/library/timing.c: In function ‘mbedtls_timing_self_test’:
/<<PKGBUILDDIR>>/library/timing.c:402:34: note: ‘ctx’ declared here
402 | mbedtls_timing_delay_context ctx;
| ^~~
Signed-off-by: Gianfranco Costamagna <locutusofborg@debian.org>
Signed-off-by: Gianfranco Costamagna <costamagnagianfranco@yahoo.it>
Add MBEDTLS_PSA_COPY_CALLER_BUFFERS to query_config.c,
version_features.c and mbedTLS.vcxproj via their respective scripts.
Signed-off-by: David Horstmann <david.horstmann@arm.com>
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>
* 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>
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>
This helps to prevent confusion as it avoids overloading the word
"copy" as both an action and an object.
Signed-off-by: David Horstmann <david.horstmann@arm.com>