Commit Graph

32558 Commits

Author SHA1 Message Date
Janos Follath
b353e92c2b Improve ssl_parse_signature_algorithm
Simplify and improve error reporting and remove unnecessary
initialisation (the caller is responsible for initialising those
values).

Signed-off-by: Janos Follath <janos.follath@arm.com>
2026-03-16 12:39:01 +00:00
Janos Follath
c07cc0e36b Fix a typo and an oversight
DEBUG_C supposed to have been removed from the test dependencies, still
being there is an oversight. Removing it was the sole purpose of
3e58109fbd.

Signed-off-by: Janos Follath <janos.follath@arm.com>
2026-03-16 12:39:01 +00:00
Janos Follath
1f938bc20f Fix code style
Signed-off-by: Janos Follath <janos.follath@arm.com>
2026-03-16 12:39:01 +00:00
Janos Follath
28886c543e ssl_parse_signature_algorithm: match error codes
The caller is returning MBEDTLS_ERR_SSL_ILLEGAL_PARAMETER if
ssl_parse_signature_algorithm() fails, but
ssl_parse_signature_algorithm() returns
MBEDTLS_ERR_SSL_HANDSHAKE_FAILURE upon failure. There is no good reason
for this mismatch and better to be aligned.

Signed-off-by: Janos Follath <janos.follath@arm.com>
2026-03-16 12:39:01 +00:00
Janos Follath
d91902c9d6 send_invalid_sig_alg: reduce debug dependency
Run as much of the test as we can even in the abscence of
MBEDTLS_DEBUG_C.

Signed-off-by: Janos Follath <janos.follath@arm.com>
2026-03-16 12:39:01 +00:00
Janos Follath
4d70ce2f13 ssl_parse_signature_algorithm: caller to get bytes
After the recent refactoring ssl_parse_signature_algorithm() sends an
alert on failure, but the caller also sends an alert on failure. Sending
two alerts is at least a protocol violation, and might not leave the SSL
context in a good state.

It is simpler to have the caller read the two bytes, and pass them to
this function.

Signed-off-by: Janos Follath <janos.follath@arm.com>
2026-03-16 12:39:01 +00:00
Janos Follath
51ea7aca6f Fix dependencies
The unit test framework always loads the client key as well, which
requires a different curve and a hash than the server key.

Signed-off-by: Janos Follath <janos.follath@arm.com>
2026-03-16 12:39:01 +00:00
Janos Follath
e50420a2dd Fix code style
Signed-off-by: Janos Follath <janos.follath@arm.com>
2026-03-16 12:39:01 +00:00
Janos Follath
03a9c87895 send_invalid_sig_alg: add baseline test
Add a test case with a successful handshake for each test case that
causes the desired handshake failure, with minimal differences between
the two.

The reason is to have more assurance that the handshake is failing for
the desired reason (as opposed to not having done something correctly in
the test code).

Signed-off-by: Janos Follath <janos.follath@arm.com>
2026-03-16 12:38:59 +00:00
Janos Follath
4d2027b271 Fix test case dependency
Signed-off-by: Janos Follath <janos.follath@arm.com>
2026-03-16 12:38:21 +00:00
Janos Follath
0ab0d7c170 Fix typos
Signed-off-by: Janos Follath <janos.follath@arm.com>
2026-03-16 12:38:21 +00:00
Janos Follath
2b696cd84f Fix some compile time guards
Signed-off-by: Janos Follath <janos.follath@arm.com>
2026-03-16 12:38:21 +00:00
Janos Follath
cd0b3f34b6 send_invalid_sig_alg: check logs
There are other issues that can fail with the same error code. Make sure
that the handshake fails exactly the way we want it to fail by analysing
the client logs.

Signed-off-by: Janos Follath <janos.follath@arm.com>
2026-03-16 12:38:21 +00:00
Janos Follath
b34279950d Use API function to set sig_alg config in test
Signed-off-by: Janos Follath <janos.follath@arm.com>
2026-03-16 12:38:21 +00:00
Janos Follath
3549b6f4a8 Fix the MBEDTLS_TEST_HAS_ADDITIONAL_HASH macro
It should require a hash that is configured in TLS 1.2 SSL contexts by
default.

Signed-off-by: Janos Follath <janos.follath@arm.com>
2026-03-16 12:38:20 +00:00
Janos Follath
fcb70427f8 Reintroduce ssl_parse_signature_algorithm
The logic was easier to follow before 693a47a, which removed the
ssl_parse_signature_algorithm function and introduced the bug being
fixed in this PR.

When validating multiple conditions, it's easier to read, easier to
debug and, as we can see, easier to get right if you validate them
separately.

Signed-off-by: Janos Follath <janos.follath@arm.com>
2026-03-16 12:38:20 +00:00
Janos Follath
238976c73a sig_algs: add ChangeLog
Signed-off-by: Janos Follath <janos.follath@arm.com>
2026-03-16 12:38:20 +00:00
Janos Follath
27c0aa0b3e sig_algs: Add non-regression test
Signed-off-by: Janos Follath <janos.follath@arm.com>
2026-03-16 12:38:17 +00:00
Janos Follath
94116eddb8 Fix mbedtls_test_free_handshake_options
We usually follow the pattern that a zero-initialised struct is safe to
free. This wasn't the case here.

Signed-off-by: Janos Follath <janos.follath@arm.com>
2026-03-16 12:37:49 +00:00
Janos Follath
a51506b3f0 Fix root cert prerequisites
This root certificate uses SECP-384 and if we don't have it in the
build, the parsing already fails even if we don't try to use it, there
is no reason to have it in the build without the SECP-384.

Signed-off-by: Janos Follath <janos.follath@arm.com>
2026-03-16 12:37:49 +00:00
Janos Follath
0165a8d763 sig_algs: fix typo in client's sig_algs check
This bug caused the client accepting sig_algs used by the server that
it explicitly wanted to disallow.

Signed-off-by: Janos Follath <janos.follath@arm.com>
2026-03-16 12:37:49 +00:00
Manuel Pégourié-Gonnard
0d48c34169 Merge pull request #1490 from ronald-cron-arm/tls12-2nd-client-hello-3.6
Backport 3.6: Fix TLS 1.2 client hello after HRR
2026-03-16 10:58:44 +01:00
Manuel Pégourié-Gonnard
2d0aa97f81 Merge pull request #1501 from mpg/restricted-ffdh-peerkey-checks
[Backport 3.6] FFDH peer key checks
2026-03-13 12:44:30 +01:00
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
Ronald Cron
0be90b44e2 Add change log
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2026-03-10 19:26:14 +01:00
Ronald Cron
668e677faf tls13_hrr_then_tls12_second_client_hello: Improve client and server state checks
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2026-03-10 19:26:14 +01:00
Ronald Cron
7b3af46c40 tls13_hrr_then_tls12_second_client_hello: Improve some comments
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2026-03-10 19:26:08 +01:00
Ronald Cron
a76e7c65bc tls13_hrr_then_tls12_second_client_hello: Various improvements
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2026-03-10 17:08:22 +01:00
Manuel Pégourié-Gonnard
199d4d9380 FFDH: fix wrong word in comment
Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2026-03-10 11:40:14 +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
Manuel Pégourié-Gonnard
174c323479 FFDH: fix some typos in test case titles
Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2026-03-05 14:26:06 +01:00
Manuel Pégourié-Gonnard
e1d64c5ce2 Fix misplaced blank line in test data file
Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2026-03-05 13:10:35 +01:00
Manuel Pégourié-Gonnard
35aec41600 Add Changelog entry for FFDH missing peerkey check
Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2026-03-05 13:07:23 +01:00
Manuel Pégourié-Gonnard
f22ed632b4 FFDH: also test peer key 1 byte too long
Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2026-03-05 13:04:50 +01:00
Manuel Pégourié-Gonnard
20a84bd287 FFDH: also test peer key = p, p+1, ff...ff
Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2026-03-05 12:57:20 +01:00
Manuel Pégourié-Gonnard
7453b664af tests: use derive_setup when applicable
There was a single case for key_agreement_setup that was failing when
setting up the derivation operation. Move this test case to use
derive_setup() instead. Add a corresponding positive test with
derive_setup() to make it more obvious that KEY_AGREEEMENT(ECDH, KDF)
works and the problem really is that the KDF is unknown.

Not the expected_status_setup argument of key_agreement_setup is no
longer needed and can be removed.

Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2026-03-05 12:57:05 +01:00