1
0
mirror of https://github.com/Mbed-TLS/mbedtls.git synced 2025-07-02 20:42:25 +03:00
Commit Graph

7603 Commits

Author SHA1 Message Date
f446b8917d Conditionally include exit label
...on functions where the label was only added
due to the modifications required by this PR.

Signed-off-by: Thomas Daubney <thomas.daubney@arm.com>
2024-01-30 13:36:01 +00:00
290aac472a Implement safe buffer copying in asymmetric signature API
Use local copy buffer macros to implement safe
copy mechanism in asymmetric signature API.

Signed-off-by: Thomas Daubney <thomas.daubney@arm.com>
2024-01-30 12:45:26 +00:00
9d52c713b2 Merge remote-tracking branch 'restricted/mbedtls-2.28' into mbedtls-2.28-restricted 2024-01-26 10:27:26 +00:00
3b0c371c04 Add allocate and copy style output buffer handling
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>
2024-01-24 17:28:33 +01:00
6baf6e9a06 Add buffer copying to psa_aead_decrypt()
Signed-off-by: David Horstmann <david.horstmann@arm.com>
2024-01-24 14:58:05 +00:00
21c1a94813 Copy buffers in psa_aead_encrypt()
Signed-off-by: David Horstmann <david.horstmann@arm.com>
2024-01-24 14:58:05 +00:00
2866a6bb20 Merge remote-tracking branch 'restricted/mbedtls-2.28' into mbedtls-2.28.7rc 2024-01-22 16:48:18 +00:00
f154831067 bump version
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2024-01-22 16:47:12 +00:00
e90cbc3d12 Fix Issue #8687
Signed-off-by: Jonathan Winzig <jwinzig@hilscher.com>
2024-01-22 16:00:07 +00:00
1a9a69778e Fix 'missing prototype' warnings
Signed-off-by: Janos Follath <janos.follath@arm.com>
2024-01-22 15:58:57 +00:00
8cdb6064de Align Montgomery init with development
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>
2024-01-22 15:58:57 +00:00
601bffc4ce Extend blinding to RSA result check
Signed-off-by: Janos Follath <janos.follath@arm.com>
2024-01-22 15:58:57 +00:00
aa6760d7b5 Make RSA unblinding constant flow
Signed-off-by: Janos Follath <janos.follath@arm.com>
2024-01-22 15:58:57 +00:00
4fe396f1e1 Move some bignum functions to internal header
We will need a couple of low level functions to implement safe
unblinding in RSA.

Signed-off-by: Janos Follath <janos.follath@arm.com>
2024-01-22 15:58:57 +00:00
42175031ca Move calculating RR into a separate function
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>
2024-01-22 15:58:57 +00:00
c7e208d2fa Merge pull request #8662 from LocutusOfBorg/mbedtls-2.28
timing.c fix build failure with -O3 optimization level
2024-01-18 13:52:02 +00:00
d7768235da Update library/timing.c
Co-authored-by: Gilles Peskine <gilles.peskine@arm.com>
Signed-off-by: Gianfranco Costamagna <costamagnagianfranco@yahoo.it>
2024-01-18 12:25:18 +01:00
a836a8499e Fix Issue #8687
Signed-off-by: Jonathan Winzig <jwinzig@hilscher.com>
2024-01-10 13:26:36 +01:00
8b736290ad Fix 'missing prototype' warnings
Signed-off-by: Janos Follath <janos.follath@arm.com>
2024-01-09 09:37:06 +00:00
6f499b7ed4 Align Montgomery init with development
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>
2024-01-09 09:28:48 +00:00
24bb226232 Extend blinding to RSA result check
Signed-off-by: Janos Follath <janos.follath@arm.com>
2024-01-08 15:19:11 +00:00
8b246b3d16 Make RSA unblinding constant flow
Signed-off-by: Janos Follath <janos.follath@arm.com>
2024-01-08 15:12:38 +00:00
f9cc4763f1 Move some bignum functions to internal header
We will need a couple of low level functions to implement safe
unblinding in RSA.

Signed-off-by: Janos Follath <janos.follath@arm.com>
2024-01-08 14:15:08 +00:00
404160a533 Move calculating RR into a separate function
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>
2024-01-08 13:53:33 +00:00
ffb18d2012 Merge pull request #8670 from daverodgman/default-compiler-all-2.28
Backport CI perf: Use clang by default in all.sh
2024-01-04 12:58:50 +00:00
52c294acb4 backport MBEDTLS_MAYBE_UNUSED
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2024-01-04 11:37:17 +00:00
f88dd840a2 timing.c: use memset to initialize the structure, from Gilles Peskine
Signed-off-by: Gianfranco Costamagna <locutusofborg@debian.org>
Signed-off-by: Gianfranco Costamagna <costamagnagianfranco@yahoo.it>
2024-01-03 12:13:24 +01:00
ca902dbd9c timing.c
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>
2023-12-27 16:41:08 +01:00
575938e806 Fix a comment in ecp
Fixes: 5521b4ce37
Signed-off-by: Chien Wong <m@xv97.com>
2023-12-27 21:26:39 +08:00
0071830a4f Merge pull request #8386 from paul-elliott-arm/remove_ssl_null_tls12_2_28
[Backport 2.28] Remove NULLing of ssl context in TLS1.2 transform population
2023-12-21 13:28:28 +00:00
3ce3e7a193 Add new config option to generated files
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>
2023-12-20 15:23:04 +00:00
b80e35a54a Tweak the behaviour of copy handling macros
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>
2023-12-20 14:49:41 +00:00
926193a93d Redesign local copy handling macros
* 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>
2023-12-20 14:49:41 +00:00
2b70a66118 Put local output status in scope
This means that a unique name is no longer needed.

Signed-off-by: David Horstmann <david.horstmann@arm.com>
2023-12-20 14:49:41 +00:00
f96ae67a76 Remove spaces around token-pasting macro operator
Signed-off-by: David Horstmann <david.horstmann@arm.com>
2023-12-20 14:49:41 +00:00
e800aa8d34 Make return statuses unique in FREE_LOCAL_OUTPUT()
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>
2023-12-20 14:49:41 +00:00
1f53213830 Improve FREE_LOCAL_INPUT() and FREE_LOCAL_OUTPUT()
* 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>
2023-12-20 14:49:41 +00:00
114d82407c Add more information to comment on test hooks
Signed-off-by: David Horstmann <david.horstmann@arm.com>
2023-12-20 14:49:41 +00:00
2b10b3713d Remove unnecessary include directory from CMake
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>
2023-12-20 14:49:41 +00:00
c0a2c30252 Add MBEDTLS_PSA_COPY_CALLER_BUFFERS config option
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>
2023-12-20 14:49:41 +00:00
34980bd832 Use macros to manage buffer copies
Signed-off-by: David Horstmann <david.horstmann@arm.com>
2023-12-20 14:49:41 +00:00
63f82f7c0c Change to use test-hook-based approach
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>
2023-12-20 14:49:41 +00:00
d2ad886258 Copy input and output in psa_cipher_encrypt()
Signed-off-by: David Horstmann <david.horstmann@arm.com>
2023-12-20 14:49:41 +00:00
0760b15d45 Add memory poisoning hooks
Signed-off-by: David Horstmann <david.horstmann@arm.com>
2023-12-20 14:49:41 +00:00
e1f6d3bebd Backport 2.28: Avoid use of ip_len as it clashes with a macro in AIX system headers
Fixes #8624

Signed-off-by: Tom Cosgrove <tom.cosgrove@arm.com>
2023-12-08 21:53:18 +00:00
806c27c5f4 Merge pull request #1126 from davidhorstmann-arm/psa-buffer-copy-fn-2.28
[Backport 2.28] Implement buffer copying functions for PSA crypto
2023-11-24 10:46:31 +00:00
8e1f0d0d31 Improve description of psa_crypto_input_copy_alloc
Signed-off-by: David Horstmann <david.horstmann@arm.com>
2023-11-23 16:04:11 +00:00
0d52c71ccd Use initializers in alloc functions
Signed-off-by: David Horstmann <david.horstmann@arm.com>
2023-11-23 16:04:11 +00:00
45221ffdc4 Add casts to local input / output initializers
Signed-off-by: David Horstmann <david.horstmann@arm.com>
2023-11-23 16:04:11 +00:00
1a76ab1c34 Rename "output_copy" -> "local_output"
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>
2023-11-22 15:09:04 +00:00