Commit Graph

32508 Commits

Author SHA1 Message Date
Manuel Pégourié-Gonnard
01b04ab723 Merge pull request #1489 from davidhorstmann-arm/fix-psa-ffdh-buffer-overflow-3.6
[Backport 3.6] Fix buffer overflow in FFDH public key export
2026-03-13 09:56:43 +01:00
David Horstmann
97c4e3f69b Add missing full stop in ChangeLog entry
Signed-off-by: David Horstmann <david.horstmann@arm.com>
2026-03-10 09:09:56 +00:00
David Horstmann
89f132d3fa Add buffer-too-small case for FFDH-8192
Signed-off-by: David Horstmann <david.horstmann@arm.com>
2026-03-10 09:07:20 +00:00
David Horstmann
14b37ec1c4 Add small buffer case for P521 import/export
Specifically for the simple import/export case and also the
import/export-public case.

Signed-off-by: David Horstmann <david.horstmann@arm.com>
2026-03-10 09:05:37 +00:00
David Horstmann
cc4e191d4f Add missing buffer-too-small tests
Add tests for key import-export and key import followed by public-key
export when the output buffer is too small. Add these tests for the
following curves:
* p256 as an example of a Weierstrass curve
* Curve25519
* Curve448

Signed-off-by: David Horstmann <david.horstmann@arm.com>
2026-03-10 09:05:37 +00:00
David Horstmann
23e688b3ab Add credit to the ChangeLog entry
Signed-off-by: David Horstmann <david.horstmann@arm.com>
2026-03-10 09:05:37 +00:00
David Horstmann
1ecd0c1ea6 Simplify ChangeLog entry
Improve readability of the ChangeLog by including only the strictly
necessary information.

Signed-off-by: David Horstmann <david.horstmann@arm.com>
2026-03-10 09:05:37 +00:00
David Horstmann
a749c3a5f8 Add ChangeLog entry for FFDH buffer overflow fix
Signed-off-by: David Horstmann <david.horstmann@arm.com>
2026-03-10 09:05:37 +00:00
David Horstmann
01bcc1f754 Add missing FFDH public key buffer length check
When exporting an FFDH public key we were not properly checking the
length of the output buffer and would write the full length of the key
in all cases. Fix this by checking the size of the output buffer before
we write to it.

Signed-off-by: David Horstmann <david.horstmann@arm.com>
2026-03-10 09:05:37 +00:00
David Horstmann
443300e700 Add testcase for FFDH buffer overflow
This testcase calls psa_export_public_key() on an FFDH key with an
output buffer that is too small. Since the size is calculated based on
the required key size but not checked against the available buffer size,
we overflow the buffer.

Signed-off-by: David Horstmann <david.horstmann@arm.com>
2026-03-10 09:05:37 +00:00
Manuel Pégourié-Gonnard
4704b6b4bd Merge pull request #1488 from davidhorstmann-arm/fix-null-pointer-dereference-3.6
[Backport 3.6] Fix null pointer dereference in `mbedtls_x509_string_to_names()`
2026-03-09 12:42:56 +01:00
Manuel Pégourié-Gonnard
6a5d54b73d Merge pull request #1503 from gilles-peskine-arm/merge-3.6-restricted-20260309
Merge 3.6 public into restricted (ready for fork fix)
2026-03-09 10:11:32 +01:00
Gilles Peskine
02b2b50fb0 Update framework with unix detection improvements
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-03-08 20:31:59 +01:00
Gilles Peskine
8f8b70aff1 Merge remote-tracking branch 'mbedtls-3.6' into merge-3.6-restricted-20260309 2026-03-08 20:26:08 +01:00
Gilles Peskine
4b571add25 Merge pull request #10621 from gilles-peskine-arm/unix-detection-202601-3.6
Backport 3.6: Simplify platform requirements
2026-03-06 18:06:04 +00:00
David Horstmann
f858b47709 Merge pull request #1500 from gilles-peskine-arm/inet_pton-changelog-attribution-3.6
Update attribution to conform to contributor's request
2026-03-05 15:00:22 +00:00
Gilles Peskine
7147da8783 Update attribution to conform to contributor's request
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-03-05 12:11:08 +01:00
Gilles Peskine
a1d7a81d39 Merge pull request #1496 from gilles-peskine-arm/merge-3.6-restricted-20260304
Merge public 3.6 into restricted
2026-03-04 16:00:20 +01:00
Gilles Peskine
685a1ce6f4 Merge remote-tracking branch 'mbedtls-3.6' into merge-3.6-restricted-20260304 2026-03-04 14:39:06 +01:00
Gilles Peskine
31934f47c5 Note platforms with known improvements
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-03-03 15:19:58 +01:00
Gilles Peskine
2393fddd60 clock_gettime: don't assume more than 1 second since the origin of time
With e.g. `CLOCK_BOOTTIME`, it's plausible that less than 1 second has
passed since the boot reference time.

Only assert that the returned time is nonzero (because all-bits-zero is
highly implausible as an actual clock value, but likely indicates that the
intended value was not copied out correctly).

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-03-03 15:19:58 +01:00
Gilles Peskine
b17d0f3028 Let test suites see strtoull() on FreeBSD if building with -std=c99
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-03-03 15:19:58 +01:00
Gilles Peskine
fa62af0a47 Let test suites see gettimeofday() on FreeBSD
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-03-03 15:19:58 +01:00
Gilles Peskine
08614e1e96 Skip printf("%zu") tests with MinGW
MinGW uses a legacy printf by default which doesn't support the `z` modifier
for `size_t`. Skip these test cases on MinGW.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-03-03 15:19:58 +01:00
Gilles Peskine
5c6ec6bcc0 Add smoke test for gettimeofday()
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-03-03 15:19:58 +01:00
Gilles Peskine
60cfb78882 Fix the build on non-Unix-like platforms that define CLOCK_REALTIME as a macro
Needed for MinGW builds in our CI.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-03-03 15:19:58 +01:00
Gilles Peskine
9cd92b207f Support testing baremetal builds without the UNIXLIKE code
When `MBEDTLS_TEST_PLATFORM_IS_NOT_UNIXLIKE` is defined, do not enable
`MBEDTLS_PLATFORM_IS_UNIXLIKE`. This lets us test baremetal builds as such
even if we happen to be building for Linux or other Unix-like platform.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-03-03 15:19:58 +01:00
Gilles Peskine
dec0d500a8 Test printf integer format modifiers more
In particular, test `"%zu"` for `size_t` and `"%lld"` for `long long`, which
older Windows runtimes do not support, but which Mbed TLS uses.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-03-03 15:19:58 +01:00
Gilles Peskine
f994fe05cd Fix the build on non-UNIXLIKE platforms
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-03-03 15:19:58 +01:00
Gilles Peskine
5ca8894b59 Fix the build with dietlibc
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-03-03 15:19:58 +01:00
Gilles Peskine
df9fdae4c4 Add smoke test for availability of some Unix functions
The goal isn't to do any functional testing, but to have a simple diagnostic
if some Unix platform function isn't available, and to have a record of
success in the outcome file.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-03-03 15:19:58 +01:00
Gilles Peskine
168461a3a9 Unify the detection of Unix-like platforms
We were using slightly different guards to decide whether to include
`<unistd.h>` in different places. Unify those.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-03-03 15:19:58 +01:00
Gilles Peskine
15c041c465 Fix wrong pointer type passed to printf
It works in practice, but clang on FreeBSD rightfully complains about it.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-03-03 15:19:58 +01:00
Gilles Peskine
f2c25e0133 test_suite_debug: test the printf used by debug.c
In `test_suite_debug`, test `mbedtls_debug_snprintf()`, which uses
`mbedtls_vsnprintf()` like `mbedtls_debug_print_msg()`. Do this instead of
testing `mbedtls_snprintf()`, which might be subtly different (older
Windows runtimes had slightly different behavior for vsnprintf() vs
snprintf(); TF-PSA-Crypto might pick up a different function if the
platform configuration is different in TF-PSA-Crypto and Mbed TLS).

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-03-03 15:19:58 +01:00
Gilles Peskine
a7de32a719 Disable Unix-like integration code in baremetal builds in all.sh
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-03-03 15:19:58 +01:00
Gilles Peskine
59c6afcd46 Update framework with TEST_ASSERT_ERRNO
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-03-03 15:19:58 +01:00
Gilles Peskine
95be019fb2 Merge pull request #10599 from valeriosetti/backport-fix-ans1write
[backport] include: fix guard in asn1write.h
2026-03-03 09:59:24 +00: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
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
Gilles Peskine
d841a6a782 Generate psa_test_wrappers.{h,c} automatically
This is not only convenient, but now necessary, because if the content of
the generated files changes due to changes in Python files in the framework,
`all.sh check_generated_files` will fail in the framework CI.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-02-22 20:33:27 +01: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