Commit Graph

32475 Commits

Author SHA1 Message Date
Manuel Pégourié-Gonnard
bc69abd2cb PK: use existing macros and functions
Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2026-02-27 10:32:04 +01:00
Manuel Pégourié-Gonnard
c5121ed11e PK: only use PSA macros when the header has been included...
Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2026-02-23 11:04:23 +01:00
Manuel Pégourié-Gonnard
3e7657c81f PK: use smarter size for stack buffer
The original macro was accounting for the size of public FFDH keys,
which are not a concern for PK. Use sizes for key types supported by PK,
this brings the size of the buffer from 1kB to 528 bytes in the default
config.

Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2026-02-23 10:14:21 +01:00
Manuel Pégourié-Gonnard
06830d69df PK: avoid 1kB stack buffer in rsa_alt_check_pair()
Again, guarded by RSA_C, so use of heap is clearly OK.

Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2026-02-23 10:01:29 +01:00
Manuel Pégourié-Gonnard
a76d2129ba PK: avoid using a > 2kB stack buffer in RSA -> PSA
Here the code path is guarded by RSA_C so using the heap is clearly OK.

Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2026-02-23 09:54:12 +01:00
Manuel Pégourié-Gonnard
ee2c3e819f Adjust guard for 3.6
In all.sh component test_psa_crypto_config_accel_rsa_crypto, where RSA
is provided only by a drivers, we were using a stack buffer. However
that was not correct, as "opaque" (PSA-held) RSA keys are still
possible. This was pointed by failing test cases in test_suite_pk, such
as "PSA import into PSA: opaque RSA, EXPORT (ok)".

As usual with 3.6, we need more complicated pre-processor conditions.

Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2026-02-23 09:42:06 +01:00
Manuel Pégourié-Gonnard
3a16bd5306 Add ChangeLog entry for PK large stack buffers
Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2026-02-23 09:42:06 +01:00
Manuel Pégourié-Gonnard
4bebabb687 PSA: improve PSA_EXPORT_KEY_OUTPUT_SIZE; PK: use it
Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2026-02-23 09:42:06 +01:00
Manuel Pégourié-Gonnard
6b90afb2bb PK: ensure we test with keys on the stack or heap
Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2026-02-23 09:42:06 +01:00
Manuel Pégourié-Gonnard
56771d12b8 PK: improve naming & doc of internal macro
Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2026-02-23 09:42:06 +01:00
Manuel Pégourié-Gonnard
925341971d PK: validate type upfront when copying from PSA
The type was validated near the end of the function when importing, but
if makes more sense to validate upfront before we possibly allocate a
buffer, export the key to it etc.

This also guarantees a sensible error value without requiring a special
case when exporting on the stack.

Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2026-02-23 09:42:06 +01:00
Manuel Pégourié-Gonnard
70454dc75b PK: rework failure case of internal size function
Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2026-02-23 09:42:06 +01:00
Manuel Pégourié-Gonnard
1cc0e98f68 PSA: add and use PSA_EXPORT_ASYMMETRIC_KEY_MAX_SIZE
Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2026-02-23 09:42:06 +01:00
Manuel Pégourié-Gonnard
00fd34ef18 PK: return helpful error on API misuse
This makes test_suite_pk pass again, but beyond that I think it's the
right thing to do.

Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2026-02-23 09:42:06 +01:00
Manuel Pégourié-Gonnard
210c613361 PK: fix stack buffer size for ECC keys
This fixes 2 out of the 3 tests cases that were failing in
test_suite_pk. The last failure will be adressed in the next commit.

Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2026-02-23 09:42:06 +01:00
Manuel Pégourié-Gonnard
eb8289d072 PK: adjust heap buffer size for key type+bits
Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2026-02-23 09:42:06 +01:00
Manuel Pégourié-Gonnard
4d14271515 PK: avoid large stack buffer in to/from PSA functions
But still retain the ability to function without a heap when only ECC is
enabled.

Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2026-02-23 09:42:06 +01:00
Bence Szépkúti
34fcd9ae4f Merge pull request #10603 from ronald-cron-arm/dtls-client-hello-defragmentation-prep-3.6
Backport 3.6: Some preparatory work for DTLS client hello defragmentation
2026-02-22 23:30:44 +00:00
Ronald Cron
d8b97c6a28 ssl-opt.sh: Revert leftover debug level increase
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2026-02-18 14:41:57 +01:00
Ronald Cron
3b6bd65334 ssl_msg.c: Improve handshake message fragmenting message
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2026-02-18 14:41:57 +01:00
Ronald Cron
8e68a06bdf ssl-opt.sh: Improve DTLS proxy 3d tests
Improve DTLS proxy 3d tests with OpenSSL and
GnuTLS servers. Have a better control of which
message is fragmented and verify it is the
case.

Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2026-02-18 14:41:57 +01:00
Ronald Cron
98b3ef2e43 ssl-opt.sh: Improve DTLS reassembly tests
Improve DTLS reassembly tests with OpenSSL
and GnuTLS server. Check that some messages
have been reassembled.

Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2026-02-18 14:41:56 +01:00
Ronald Cron
87871ddf30 ssl-opt.sh: Remove DTLS reassembly redundant test
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2026-02-18 14:41:56 +01:00
Ronald Cron
0b4cb31fb6 ssl-opt.sh: Remove CH reassembly unsupported test
We are about to have full support for TLS 1.2
CH reassembly on server side. The equivalent
positive test would be a duplicate of one of
the tests generated by generate_tls_handshake_tests.py.
Thus just removing the negative test.

Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2026-02-18 14:41:56 +01:00
Ronald Cron
a02505a7be ssl_msg.c: Improve HS message reassembly completed message
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2026-02-18 14:41:56 +01:00
Ronald Cron
c065fdd4d4 ssl_tls.c: Rename and expand ssl_tls13_get_hs_msg_name
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2026-02-18 14:41:56 +01:00
Manuel Pégourié-Gonnard
fbfd13e22b Merge pull request #10597 from valeriosetti/fix-tls12-sha-guards-backport
[backport] library: check_config: fix required hash algorithms for TLS 1.2
2026-02-18 08:23:38 +00:00
David Horstmann
94594b96bd Merge pull request #10602 from davidhorstmann-arm/fix-missing-type-conversion-tls-exporter-3.6
[Backport 3.6] Fix missing type conversion in the TLS-Exporter
2026-02-17 18:31:05 +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
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