Commit Graph

32554 Commits

Author SHA1 Message Date
David Horstmann
6ca2d7da8b Add ChangeLog entry for verify_result hardening
Signed-off-by: David Horstmann <david.horstmann@arm.com>
2026-02-17 14:39:53 +00:00
David Horstmann
b413935518 Add non-regression test for verify_result init
Write a testcase to get verify_result before we have performed a
handshake and make sure that it is initialised to a failure value.

Signed-off-by: David Horstmann <david.horstmann@arm.com>
2026-02-17 14:39:50 +00:00
David Horstmann
710aaa7ae7 Set verify_result to failure by default
At initialization, set the verify_result field of the ssl session to
MBEDTLS_X509_VERIFY_NOT_STARTED, rather than 0 as it is by default
currently. This prevents mbedtls_ssl_get_verify_result() from indicating
that certificate verification has passed if it is called prior to the
handshake happening.

Signed-off-by: David Horstmann <david.horstmann@arm.com>
2026-02-17 14:38:28 +00:00
David Horstmann
6966659a31 Add new X509 verification result for 'not started'
Add a new verification result bitflag MBEDTLS_X509_VERIFY_NOT_STARTED
to use as a safe initial value for verify_result. This is better than
the current initial value which is 0 (indicating success).

Signed-off-by: David Horstmann <david.horstmann@arm.com>
2026-02-17 14:38:28 +00:00
Ronald Cron
9d96a23fa2 ssl_server2.c: Flush stdout to improve logs timeliness
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2026-02-17 10:10:34 +01:00
Ronald Cron
373e08939f Add branch specific generate_tls_handshake_tests.py file
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2026-02-17 10:10:34 +01:00
Ronald Cron
381b296956 Update framework pointer
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2026-02-17 10:07:42 +01:00
David Horstmann
85426311e3 Fix missing type conversion in the TLS-Exporter
In the TLS-Exporter for TLS 1.3 we mistakenly call PSA_HASH_LENGTH() on
an mbedtls_md_type_t when it should be called on a psa_algorithm_t.

Fortunately, these two types have almost the same values, since we have
previously aligned them to make conversion more efficient. As a result,
PSA_HASH_LENGTH() produces exactly the same value when called on an
mbedtls_md_type_t as with the equivalent psa_algorithm_t.

Thanks to this happy coincidence, fix a largely cosmetic issue (rather
than a major functional bug).

Signed-off-by: David Horstmann <david.horstmann@arm.com>
2026-02-16 17:07:30 +00:00
David Horstmann
b847040a1a Merge pull request #10594 from gilles-peskine-arm/bump-version-202602-3.6
Backport 3.6: Minor improvements to bump_version.sh
2026-02-16 16:50:12 +00:00
Valerio Setti
32649e1e33 include: fix guard in asn1write.h
Fix the location of the ending braket of "extern C" block in order to
have it balanced between C guards.

Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2026-02-16 14:03:48 +01:00
Valerio Setti
a372f1a5cb library: check_crypto_config: remove redundant check on hash algorithms for TLS 1.2
TLS-PRF uses either SHA-256 and SHA-384, so the removed paragraph was not
correct. The correct version is already available in "check_config.h".

Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2026-02-12 22:09:06 +01:00
David Horstmann
48c3b179c5 Merge pull request #10589 from daverodgman/backport_gcc_bswap
[Backport 3.6] fix error in GCC bswap
2026-02-11 14:04:47 +00:00
David Horstmann
610f4997c2 Merge pull request #10565 from minosgalanakis/bugfix/fix-intrisic-aesce-clang-36
[3.6 Backport] Fixed clang arm intrinsics for older compiler versions
2026-02-11 11:58:55 +00:00
Valerio Setti
5334c1dd14 Merge pull request #10592 from mpg/pkwrite-large-stack-buffer
[3.6] PK write: avoid large stack buffer
2026-02-11 05:02:04 +00:00
Gilles Peskine
f41929496e Don't treat --help as an error
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-02-10 14:52:50 +01:00
Gilles Peskine
b47774c9a9 Remove unused variable
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-02-10 14:52:46 +01:00
Manuel Pégourié-Gonnard
6617ab467f pkwrite: tests: make helper more robust
Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2026-02-10 11:34:00 +01:00
Manuel Pégourié-Gonnard
20118b65bd pkwrite: RSA: avoid large stack buffer
In the default build, it was 2363 bytes which is a lot to put on the
stack for constrained devices. Fortunately we already have a large
enough buffer at hand: the user-provided output buffer. Use it.

Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2026-02-10 11:34:00 +01:00
Manuel Pégourié-Gonnard
56503ba340 pkwrite: tests: test that DER writes at the end
Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2026-02-10 11:24:05 +01:00
Manuel Pégourié-Gonnard
533a806405 pkwrite: test: factor common part into helper func
Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2026-02-10 11:18:24 +01:00
Dave Rodgman
4f6c8ef2ac fix error in GCC bswap
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2026-02-06 10:10:42 +00:00
Valerio Setti
25b5fcdcd3 Merge pull request #10581 from valeriosetti/issue665-backport
[backport] Software GCM table calculation buggy with gcc -O3
2026-01-29 15:17:00 +00:00
David Horstmann
337218d667 Merge pull request #10165 from davidhorstmann-arm/fix-mingw-ansi-stdio-3.6
[3.6] Fix format specifiers for MinGW ANSI stdio
2026-01-28 16:42:07 +00:00
Valerio Setti
2b2f430fcd tests: scripts: adapt test_tf_psa_crypto_optimized_alignment to 3.6
Move from CMake to Make

Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2026-01-28 00:18:09 +01:00
Valerio Setti
f79c548ad0 changelog: add changelog about fixing issue #665 in tf-psa-crypto
Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2026-01-28 00:07:44 +01:00
Valerio Setti
32ef705024 library: alignment: add "may_alias" attribute to mbedtls_uintXX_unaligned_t structs
Tell the GCC compiler that pointers to types "mbedtls_uintXX_unaligned_t"
(where XX is 16, 32 or 64) might alias with other types. This helps at
high optimizations level (i.e. "-O3") so that the compiler does not mess
up with instruction reordering and memory accesses.

Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2026-01-28 00:07:44 +01:00
Valerio Setti
be0c788105 library: alignment.h: add internal symbol to disable optimizations on x86
MBEDTLS_ALIGNMENT_DISABLE_EFFICENT_UNALIGNED_ACCESS is used to forcedly
prevent MBEDTLS_EFFICIENT_UNALIGNED_ACCESS from being set. This prevents
optimizations from being used on x86 which is useful for testing
purposes.

Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2026-01-28 00:07:44 +01:00
Valerio Setti
10193b37e3 tests: scripts: add new component to test alignment with GCC O3 optizations
This is meant to test a bug found on:
- Little endian platforms other than x86 or ARM (these have specific
  optimizations available);
- GCC versions from 10 to 14.2 (below and above are fine);
- Optimization level "-O3" (lower levels are fine).

Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2026-01-28 00:07:44 +01:00
Gilles Peskine
ccf280d158 Add a few more test cases for printf formats
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-01-26 17:49:05 +01:00
Minos Galanakis
2f384c82a5 built-in drivers(aesce): Fixed clang arm intrinsics for verions < 7
Signed-off-by: Minos Galanakis <minos.galanakis@arm.com>
2026-01-26 11:06:58 +00:00
Gilles Peskine
0bc29f6441 Merge pull request #10542 from minosgalanakis/bugfix/fix-intrisic-header-armf-3.6
[Backport 3.6] Bugfix/fix intrisic header armf 3.6
2026-01-22 14:51:13 +00:00
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
David Horstmann
366e469c2b Merge pull request #10568 from yanesca/add_clarifications_3.6.x
[Backport 3.6] Add miscellaneous clarifications
2026-01-20 16:38:58 +00:00
Janos Follath
6c0a661b68 programs/README.md clarify security remark
Signed-off-by: Janos Follath <janos.follath@arm.com>
2026-01-20 13:47:05 +00:00
Janos Follath
92dbfb34f0 SECURITY.md: make x509 data section more readable
Signed-off-by: Janos Follath <janos.follath@arm.com>
2026-01-20 13:47:03 +00:00
Janos Follath
7b2ad1c518 Clarify purpose and suitability of sample programs
Signed-off-by: Janos Follath <janos.follath@arm.com>
2026-01-19 15:00:22 +00:00
Janos Follath
baea194a04 Clarify CRL security guarantees
Signed-off-by: Janos Follath <janos.follath@arm.com>
2026-01-19 14:58:39 +00:00
David Horstmann
bdc6ce751b Merge pull request #10538 from gilles-peskine-arm/include-common-first-fix-aesce-3.6
Backport 3.6: Fix AESCE regression with Clang due to inclusion order changes
2025-12-18 14:32:55 +00:00
Manuel Pégourié-Gonnard
12b3c46d6a Merge pull request #10347 from aphroteus/mbedtls-3.6
[3.6] Fix a build failure that occurs in environments using Code Page 950
2025-12-16 08:14:04 +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
Gilles Peskine
c05500c7f9 Merge pull request #10513 from mpg/rsa-blinding-crt
[3.6] Rsa: use the CRT to generate base blinding values
2025-12-09 11:18:21 +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
Valerio Setti
d5161daa48 Merge pull request #10531 from gilles-peskine-arm/race-condition-in-makefile-3.6
Backport 3.6: fix race condition in makefile affecting test_sha3_variations
2025-12-04 21:42:20 +00:00
Pengyu Lv
0502ba15b1 Fix dependencies in programs/Makefile
Make fuzz depend on MBEDLIBS to avoid multiple instances for
generation the library files.

Signed-off-by: Pengyu Lv <pengyu.lv@arm.com>
2025-12-04 16:56:21 +01:00
Pengyu Lv
b902851840 Fix the commands to build library
In `scripts/common.make`, used by `tests/Makefile` and `programs/Makefile`,
we have the following rules to build the library:

  ```
  $(MBEDLIBS):
      $(MAKE) -C ../library
  ```

$(MBEDLIBS) contains three library files but the command is for all
the 3 files instead of single target generation. This would cause a
race when doing parallel build. This commit fixes command so that
the recipe could generate a single library file.

Fix https://github.com/Mbed-TLS/mbedtls/issues/8229

Signed-off-by: Pengyu Lv <pengyu.lv@arm.com>
Signed-off-by: Gilles Peskine <gilles.peskine@arm.com>
2025-12-04 16:53:37 +01:00
Gilles Peskine
e45e036b91 Fix Mbed-TLS/TF-PSA-Crypto#548
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-12-03 20:09:47 +01:00