32727 Commits

Author SHA1 Message Date
Ronald Cron
365a16dc38 tls13: Do not negotiate TLS 1.2 after an HRR
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2026-02-27 16:03:30 +01:00
Ronald Cron
3b244905bc Add unit test with TLS 1.2 nego after HRR
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2026-02-27 16:00:11 +01:00
Manuel Pégourié-Gonnard
1fee3da79a PK: require more option combinations in tests
Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2026-02-27 10:48:48 +01:00
Manuel Pégourié-Gonnard
023c51b282 PK: adjust size macro in case PSA is disabled
Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2026-02-27 10:37:34 +01:00
Manuel Pégourié-Gonnard
127b0352b3 PK: move another large buffer to the heap
Was previously missed as it only exists when USE_PSA_CRYPTO is enabled.

Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2026-02-27 10:32:19 +01:00
Manuel Pégourié-Gonnard
571d78361a PK: zeroize dummy signature just to be sure
The signature of a dummy hash for which no pre-image is know is probably
not sensitive, but zeroize it anyway.

Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2026-02-27 10:32:04 +01:00
Manuel Pégourié-Gonnard
81ecc37372 PK: clarify comment about key export
Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2026-02-27 10:32:04 +01:00
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
David Horstmann
0d48251122 Add ChangeLog entry for NULL dereference fix
Signed-off-by: David Horstmann <david.horstmann@arm.com>
2026-02-26 14:05:13 +00:00
Bence Szépkúti
1937efdd94
Merge pull request #10615 from gilles-peskine-arm/generate-psa_test_wrappers-3.6
Backport 3.6: generate psa test wrappers
2026-02-26 13:44:15 +00:00
David Horstmann
bfaf4a47fd Fix null pointer dereference in string to names
In mbedtls_x509_string_to_names() we were not checking for allocation
failures. An allocation failure would lead to a memcpy() to a null
pointer address.

Fix this by checking the result of the call to mbedtls_calloc() and
returning MBEDTLS_ERR_X509_ALLOC_FAILED in the error case.

Signed-off-by: David Horstmann <david.horstmann@arm.com>
2026-02-26 13:22:35 +00:00
Gilles Peskine
409baa7b7b Document /dev/random vs /dev/urandom on Linux
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-02-25 22:43:19 +01:00
Gilles Peskine
8f962c1b22 Add MBEDTLS_PLATFORM_DEV_RANDOM as a compile-time option
Document when this is not used. This was the case in TF-PSA-Crypto 1.0.0,
but not yet in Mbed TLS 3.6.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-02-25 22:43:19 +01:00
Gilles Peskine
2ccda0f48c Make the random device configurable
Instead of unconditionally using `/dev/urandom`, make the device path
configurable at compile time through `MBEDTLS_PLATFORM_DEV_RANDOM` or
at run time through `mbedtls_platform_dev_random`.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-02-25 22:10:17 +01:00
Ronald Cron
7d022d3275 ssl-opt.sh: DTLS fragmenting: Do not check for ServerKeyExchange fragmentation
In DTLS fragmenting tests, do not check for
ServerKeyExchange message fragmentation as
depending on the configuration and consequently
the chosen ciphersuite the server may not
send the message.

Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2026-02-25 20:18:19 +01:00
Ronald Cron
6b529ff50d component_test_tls1_2_ccm_psk_dtls_psa: Enable MBEDTLS_HAVE_TIME
As done in component_test_tls1_2_ccm_psk_dtls_legacy
enable MBEDTLS_HAVE_TIME in
component_test_tls1_2_ccm_psk_dtls_psa.

Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2026-02-25 17:49:53 +01:00
Ronald Cron
97a25e4c68 ssl_tls12_server.c: Update hs status after some validations of the ClientHello
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2026-02-24 15:37:33 +01:00
Ronald Cron
38213a7856 Add change log
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2026-02-24 15:37:30 +01:00
Ronald Cron
1bdb0901c9 Update mbedtls_ssl_handshake() documentation
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2026-02-24 15:37:28 +01:00
Ronald Cron
82d549a297 ssl-opt.sh: Use more diverse MTUs
Do not use only power of 2 MTUs.
Use diverse MTUs in DTLS reassembly/
fragmenting/proxy tests.

Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2026-02-24 15:30:00 +01:00
Ronald Cron
404daf5f6d ssl-opt.sh: DTLS reassembly: Improve max_content_len requirements
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2026-02-24 15:30:00 +01:00
Ronald Cron
50d1a74ad8 ssl-opt.sh: Fix/improve comments
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2026-02-24 15:30:00 +01:00
Ronald Cron
f44b6545fe ssl-opt.sh: Add tests with CH fragmented with DTLS in default config
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2026-02-24 15:30:00 +01:00
Ronald Cron
f20d48f719 ssl-opt.sh: Add interop test of DTLS defragmentation on server side
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2026-02-24 15:30:00 +01:00
Ronald Cron
09546ee120 ssl_msg.c: Remove some now unnecessary code
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2026-02-24 15:30:00 +01:00
Ronald Cron
2086b20f28 ssl_tls12_server.c: parse_client_hello: Remove remaining record level code
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2026-02-24 15:30:00 +01:00
Ronald Cron
6a9fc0ce77 ssl_tls12_server.c: Move ClientHello record sequence_number init
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2026-02-24 15:30:00 +01:00
Ronald Cron
5a744e8d34 ssl_tls12_server.c: Move ClientHello message_seq adjustment
Move ClientHello message_seq adjustment to the record layer.

Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2026-02-24 15:30:00 +01:00
Ronald Cron
06abef2307 ssl_tls12_server.c: Use mbedtls_ssl_read_record() only to read the ClientHello
In ssl_tls12_server.c:ssl_parse_client_hello(), remove
the code that directly reads the received data to read
the record expected to contain the ClientHello message.

The function already supported handling a ClientHello
read via mbedtls_ssl_read_record() in the following
cases:
- when the ClientHello was read as a post-handshake
  message (renegotiation).
- when the ClientHello was read by
  ssl_tls13_process_client_hello() during TLS 1.3 or
  TLS 1.2 version negotiation.

Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2026-02-24 15:30:00 +01:00
Ronald Cron
17acd871c1 ssl_tls12_server.c: Document replay check and update in ssl_parse_client_hello()
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2026-02-24 15:30:00 +01:00
Ronald Cron
0a8c35d273 ssl_server2.c: DTLS: Attempt to read the response to the close notification
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2026-02-24 15:30:00 +01:00
Ronald Cron
faa9d95638 ssl-opt.sh: Relax deps of handshake defrag tests
Relax the dependencies of the tests about handshake
message defragmentation/reassembly on server side.

TLS 1.3 does not need to be enable anymore for this
to work for TLS 1.2 handshake messages.

Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2026-02-24 15:30:00 +01:00
Ronald Cron
4a8d476568 ssl_tls.c: Allow client hello fragmentation
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2026-02-24 15:30:00 +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