Commit Graph

13702 Commits

Author SHA1 Message Date
Minos Galanakis
a35f5326f5 drivers sha256|512: Adjusted tf_psa_crypto_common.h inclusion
This patch adjusts the include order so that some ACLE
intrinsics macros are configured before
the inclusion of `neon.h`. This fixes issues with older
clang compilers but has no effect in modern versions.

Signed-off-by: Minos Galanakis <minos.galanakis@arm.com>
2026-01-21 14:16:18 +00:00
Gilles Peskine
ad6ceaa4e7 Indicate which Clang version stops requiring the workaround
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-12-11 16:10:41 +01:00
Gilles Peskine
85e28b266e AESCE: fix the build with Clang <<16
As indicated in a comment, with older Clang, we need to define
`__ARM_FEATURE_CRYPTO` before we include `arm_neon.h`, which is done via
`common.h`. 4c44990d65
accidentally broke this. Fix it, while taking care not to include another
header before `common.h`.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-12-11 16:09:53 +01:00
David Horstmann
419f302dcd Merge pull request #10526 from gilles-peskine-arm/include-common-first-202510-3.6
Backport 3.6: Include common header first
2025-12-09 16:50:12 +00:00
Manuel Pégourié-Gonnard
f6f837aec5 rsa: clarify drawing at random with the CRT
Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2025-12-09 09:39:07 +01:00
Manuel Pégourié-Gonnard
d251d73d06 rsa: clarify CRT computation
Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2025-12-09 09:26:20 +01:00
Manuel Pégourié-Gonnard
ec5bc19996 Fix some typos in comments
Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2025-12-09 09:16:25 +01:00
Manuel Pégourié-Gonnard
83e3b37e9d rsa: rm unused variable + fix typos
Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2025-12-03 13:27:19 +01:00
Manuel Pégourié-Gonnard
f90c04d646 RSA: remove undocumented check
This only made the function harder to use.

Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2025-12-03 11:35:28 +01:00
Manuel Pégourié-Gonnard
fbd7388482 RSA: handle low-probability events in a uniform way
Previously we were looping in one case but not even checking the other.
Let's check both cases and error out immediately. The error path should
never be taken in pratice anyway.

Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2025-12-03 11:26:09 +01:00
Gilles Peskine
4c44990d65 Include common.h before system headers
In library source files, the order of things should be:

1. Define macros that affect the behavior of system headers, such as
   `_POSIX_C_SOURCE` and `_GNU_SOURCE`.
2. Include the library's common header: `common.h`.
   It takes care of many things, including defining the library
   configuration, granting access to private fields in structures, and
   activating platform-specific hacks.
3. Possibly a few header inclusions and macro definitions.
4. Guard everything else by `#if defined(MBEDTLS_XXX_C)` or some such.

Enforce this order in files that previously did things they shouldn't have
before including `common.h`. To locate the potentially
problematic files:

```
grep -m1 '^#' library/*.c | grep -v -F common.h
```

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-12-02 22:35:16 +01:00
Manuel Pégourié-Gonnard
8b0ee342fa rsa: use the CRT to generate blinding values
Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2025-11-18 12:02:33 +01:00
Manuel Pégourié-Gonnard
b13033dd3e rsa: extract helper function for CRT
Was only used in one place so far, but will be used in
rsa_gen_rand_with_inverse()'s upcoming CRT-based implementation.

Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2025-11-18 11:39:40 +01:00
Manuel Pégourié-Gonnard
3be31bf21b rsa: extract helper function
Will gain a new implementation using the CRT, so we want to hide the
upcoming complexity in a dedicated function.

Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2025-11-18 11:38:47 +01:00
Valerio Setti
14ada7f73c Merge pull request #10473 from valeriosetti/issue488-3.6
[3.6] psa_load_builtin_key_into_slot: prevent accessing the PSA storage if key ID is in volatile range
2025-11-11 12:31:15 +00:00
Juha-Pekka Kesonen
b11d969e2c ssl_msg.c: change log level for record checking
Signed-off-by: Juha-Pekka <juha-pekka.kesonen@nordicsemi.no>
2025-11-05 15:06:02 +02:00
Juha-Pekka Kesonen
a535836d14 ssl_tls12: change log level for ECDH computation
Signed-off-by: Juha-Pekka <juha-pekka.kesonen@nordicsemi.no>
2025-11-05 15:05:23 +02:00
Valerio Setti
cc0385852d Merge pull request #10471 from yanesca/fix_dead_code_231025
Fix dead code - 3.6 Backport
2025-10-31 12:49:57 +00:00
Valerio Setti
667e56a0a7 Merge pull request #10478 from Cube707/backport/iar-compiler-warning
[backport] add cast to fix IAR compiler errors
2025-10-31 12:33:11 +00:00
Jan Wille
8d59423fe5 format: apply suggestions (add spaces)
Signed-off-by: Jan Wille <jan.wille@siemens.com>
2025-10-29 15:50:57 +01:00
Jan Spannberger
73d5398f02 add cast to fix IAR compiler errors
IAR throws a warning "mixed ENUM with other type"

backport of a5384bdf09

Signed-off-by: Jan Spannberger <jan.spannberger@siemens.com>
2025-10-28 15:14:30 +01:00
Valerio Setti
1b93588d93 psa_crypto_slot_management: check key ID range when loading a persistent key
Do not try to load a persistent key whose key ID is in the volatile range.

Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2025-10-27 11:12:07 +01:00
Luc Schrijvers
7a399a6ed6 Add library/CMakeList.txt to the changes
Signed-off-by: Luc Schrijvers <begasus@gmail.com>
2025-10-24 13:00:40 +02:00
Janos Follath
94700198fb Remove dead code
Signed-off-by: Janos Follath <janos.follath@arm.com>
2025-10-23 14:43:52 +01:00
Minos Galanakis
ddffba970b Revert "Added generated files"
This reverts commit 335197e60c.

Signed-off-by: Minos Galanakis <minos.galanakis@arm.com>
2025-10-22 10:51:01 +01:00
Minos Galanakis
5a3d0214b3 Merge tag 'mbedtls-3.6.5' into mbedtls-3.6.5_mergeback
Mbed TLS 3.6.5

Signed-off-by: Minos Galanakis <minos.galanakis@arm.com>
2025-10-15 18:41:13 +01:00
Minos Galanakis
335197e60c Added generated files
Signed-off-by: Minos Galanakis <minos.galanakis@arm.com>
2025-10-10 18:04:55 +01:00
Minos Galanakis
ad63800090 Version bump for mbedtls-3.5.6
./scripts/bump_version.sh --version 3.6.5

Signed-off-by: Minos Galanakis <minos.galanakis@arm.com>
2025-10-10 18:04:55 +01:00
Gilles Peskine
42ae2ac6ec Merge pull request #10318 from keith-packard/gcc-14-3-array-bounds
Avoid invalid gcc 14.3 warning about array bounds in mbedtls_xor
2025-10-08 19:00:48 +00:00
Keith Packard
292b96c0a6 Avoid invalid gcc 14.3 warning about array bounds in mbedtls_xor
The combination of the multi-byte loop with the single byte loop
confuses GCC 14.3's array bounds checker. When the loop size is
constant, check to see if it is a multiple of the multi-byte size and
bail early. As this will be evaluated at compile time, there should be
no run-time cost.

This change uses the __builtin_constant_p compile-time operation. To
check if that is supported, the change uses the existing
MBEDTLS_HAS_BUILTIN macro. That macro was defined later in
library/common.h than is needed for this change, so it was moved up to
join some other macros that looked similar.

Signed-off-by: Keith Packard <keithp@keithp.com>
2025-10-02 11:09:29 -07:00
Minos Galanakis
bafcf5bddf Merge remote-tracking branch 'restricted/mbedtls-3.6-restricted' into mbedtls-3.6.5rc0-pr
Signed-off-by: Minos Galanakis <minos.galanakis@arm.com>
2025-10-02 15:37:04 +01:00
Ben Taylor
6e73b2f2fd Backport time_t type conversions
Signed-off-by: Ben Taylor <ben.taylor@linaro.org>
2025-09-29 15:35:28 +01:00
Gilles Peskine
b6bf893c70 Qualify "reference implementation" wording
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-09-17 14:04:10 +02:00
Gilles Peskine
334dfa8799 Merge remote-tracking branch '3.6' into restricted-3.6-merge-public-20250916
Conflicts:

* `framework`: update submodule to the merge of `main` and `main-restricted`.
2025-09-16 16:16:53 +02:00
Gilles Peskine
c2b94d45d4 Merge pull request #10401 from gilles-peskine-arm/psa_can_do-declare-publicly-3.6
Backport 3.6: Declare psa_can_do_cipher() publicly
2025-09-15 12:02:50 +00:00
Janos Follath
753036edb3 Merge pull request #10336 from gilles-peskine-arm/generated-files-lib-build-3.6
Backport 3.6: fix `make lib GEN_FILES=` sometimes requiring python
2025-09-12 13:27:26 +00:00
Gilles Peskine
3aee15b8e5 Declare psa_can_do_cipher() in a public header
Integrators in a client-server architecture need to provide this function on
the client side.

Fixes mbedtls/issues#10341.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-09-12 11:27:07 +02:00
Manuel Pégourié-Gonnard
3e59e0ae08 Merge pull request #1411 from mpg/bypass-wrappers
[3.6] Bypass GCD/modinv wrappers when possible
2025-09-11 12:25:23 +02:00
Manuel Pégourié-Gonnard
c6b28b31ef Be explicit about modinv output range
Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2025-09-11 09:58:45 +02:00
Gilles Peskine
cc908ad04c Remove redundant memset on freshly initialized buffer
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-09-08 12:22:39 +02:00
Gilles Peskine
04dfd70432 psa_cipher_decrypt: treat status and output length as sensitive
In `psa_cipher_decrypt()` and in the corresponding function in our built-in
implementation `mbedtls_psa_cipher_decrypt()`, treat `status` and
`*output_length` as sensitive variables whose value must not leak through a
timing side channel. This is important when doing decryption with unpadding,
where leaking the validity or amount of padding can enable a padding oracle
attack.

With this change, `psa_cipher_decrypt()` should be constant-time if the
underlying legacy function (including the cipher implementation) is.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-09-08 12:22:39 +02:00
Gilles Peskine
3b380daedb psa_cipher_finish: treat status and output length as sensitive
In `psa_cipher_finish()` and in the corresponding function in our built-in
implementation `mbedtls_psa_cipher_finish()`, treat `status` and
`*output_length` as sensitive variables whose value must not leak through a
timing side channel. This is important when doing decryption with unpadding,
where leaking the validity or amount of padding can enable a padding oracle
attack.

With this change, `psa_cipher_finish()` should be constant-time if the
underlying legacy function (including the cipher implementation) is.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-09-08 12:22:39 +02:00
Gilles Peskine
e74b42832e Return PSA_ERROR_INVALID_PADDING in constant time
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-09-08 12:22:39 +02:00
Gilles Peskine
d179dc80a5 Use mbedtls_psa_cipher_finish() in PSA
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-09-08 12:22:39 +02:00
Gilles Peskine
9d7d0e63ae Merge pull request #1407 from gilles-peskine-arm/mbedtls_cipher_finish_padded-3.6
Backport 3.6: Introduce mbedtls_cipher_finish_padded
2025-09-08 12:18:50 +02:00
Gilles Peskine
9f7ac0371f Fix code style
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-08-29 10:46:52 +02:00
Gilles Peskine
7e43145bac Typo
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-08-29 09:35:29 +02:00
Gilles Peskine
2324a02602 Create threading_internal.h
This is meant to hold threading-related definitions that are not public, but
are used in the test framework.

To be populated later.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-08-29 08:59:27 +02:00
Manuel Pégourié-Gonnard
c18eea6d43 Minor grammar fix in comment
Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2025-08-26 11:34:45 +02:00
Manuel Pégourié-Gonnard
b46432930e ecdsa: rm unused variable
Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2025-08-26 11:33:12 +02:00