33194 Commits

Author SHA1 Message Date
Valerio Setti
c6f5f2547d changelog: add note for PKCS7 rejecting weak hash algorithms
Signed-off-by: Valerio Setti <vsetti@baylibre.com>
2026-06-22 11:49:45 +02:00
Valerio Setti
42471969d1 tests: pkcs7: adjust return code in SHA-1 based PKCS7 test
Signed-off-by: Valerio Setti <vsetti@baylibre.com>
2026-06-22 11:49:45 +02:00
Valerio Setti
a38ea44d97 pkcs7: fail verification if MD alg or sig_alg are not secure
Add a check on mbedtls_pkcs7_data_or_hash_verify() so that the verification
fails if the MD alg specified in PKCS7 structure or the signature
algorithm specified in the X.509 certificate are not in the list of
secure algorithms (i.e. mbedtls_x509_crt_profile_default).

Signed-off-by: Valerio Setti <vsetti@baylibre.com>
2026-06-22 11:49:45 +02:00
Valerio Setti
3215f53789 x509: make profile checking functions internally available
Following functions

- x509_profile_check_md_alg
- x509_profile_check_pk_alg

are made non-static and moved to x509_internal.h so that other library
files can used them.

Signed-off-by: Valerio Setti <vsetti@baylibre.com>
2026-06-22 11:49:45 +02:00
Valerio Setti
9da2709411 x509_crt: add SHA3 algs to mbedtls_x509_crt_profile_default
Signed-off-by: Valerio Setti <vsetti@baylibre.com>
2026-06-22 11:49:45 +02:00
Valerio Setti
cfd6fb4a58 x509_crt: remove old invalid comment
ssl_preset_default_hashes was removed in
f0cda410a4bca0f45f66bdbf0714cd0eb2ea4718 but the comment in 'x509_crt.c'
wasn't updated.

Signed-off-by: Valerio Setti <vsetti@baylibre.com>
2026-06-22 11:49:45 +02:00
Ronald Cron
f6f6492228
Merge pull request #1641 from gilles-peskine-arm/badmac_seen_or_in_hsfraglen-fix
3.6 only: Fix and test badmac_seen_or_in_hsfraglen confusion
2026-06-22 10:30:00 +02:00
Gilles Peskine
609b299e1c
Merge pull request #10762 from Nadav0077/harden-serialized-load-3.6
Backport to 3.6: harden serialized data deserialization
2026-06-19 20:18:13 +00:00
Gilles Peskine
d3b43bcbc1
Merge pull request #1596 from gilles-peskine-arm/basic-constaints-sequence-check-3.6
Backport 3.6: Fix CA bit forgery through invalid basicConstraints
2026-06-18 15:36:50 +02:00
Ben Taylor
12717ec8f4 Add in the two additional checks that were dropped.
Co-authored-by: Ronald Cron <ronald.cron@arm.com>
Signed-off-by: Ben Taylor <32939606+bjwtaylor@users.noreply.github.com>
(cherry picked from commit 377aa4eff16cd0aa5e7440a41de59847e3a789a0)
2026-06-18 13:15:58 +01:00
Ben Taylor
7457580790 Remove pkcs7_parse_free_resets_context as it duplicates pkcs7_parse_reuse
Signed-off-by: Ben Taylor <ben.taylor@linaro.org>
(cherry picked from commit 10afc1ed5c8e9c47caf1ad8ee6241fd99e43f945)

Backport note: resolved the redundant-test removal conflict by deleting the temporary reset test while keeping the 3.6 pkcs7_verify dependency expression.
2026-06-18 13:15:58 +01:00
Ben Taylor
2ce44c5b1d Add CVE ID to ChangeLog
Co-authored-by: Gilles Peskine <gilles.peskine@arm.com>
Signed-off-by: Ben Taylor <32939606+bjwtaylor@users.noreply.github.com>
(cherry picked from commit a798b5804ef8571bcfd6609019758014325162c4)
2026-06-18 13:13:59 +01:00
Ben Taylor
25513f33f0 Remove whitespace in ChangeLog
Signed-off-by: Ben Taylor <ben.taylor@linaro.org>
(cherry picked from commit 74555884cc72bf8aa6b74a0a09bb2a3a68741806)
2026-06-18 13:13:59 +01:00
Ben Taylor
ad814cabe2 Correct changelog style
Signed-off-by: Ben Taylor <ben.taylor@linaro.org>
(cherry picked from commit 351419f1ff82f148e142bd9bdbfc2a3fa3b7f5ee)
2026-06-18 13:13:59 +01:00
Ben Taylor
439e194752 Add further testing
Signed-off-by: Ben Taylor <ben.taylor@linaro.org>
(cherry picked from commit 84966c1bda07dd01e38786b2caa9b7453a5adb95)

Backport note: resolved PKCS7 test conflicts by retaining the 3.6 dependency names (MBEDTLS_MD_CAN_SHA256:MBEDTLS_RSA_C) for the added regression cases.
2026-06-18 13:13:59 +01:00
Ben Taylor
544f1ccc1d Update ChangeLog
Signed-off-by: Ben Taylor <ben.taylor@linaro.org>
(cherry picked from commit 64435904480332b9dd7249b73385853720b6a5da)
2026-06-18 13:12:25 +01:00
Ben Taylor
dfa25b3577 Update ChangeLog
Signed-off-by: Ben Taylor <ben.taylor@linaro.org>
(cherry picked from commit 4e797c14e0ae62c31f7ae5996dd27888642d11a3)
2026-06-18 13:12:25 +01:00
Ben Taylor
b6793c584d Fix style issues
Signed-off-by: Ben Taylor <ben.taylor@linaro.org>
(cherry picked from commit 62162e6e4d08ddcc6805975cc39e59f69e0c9775)
2026-06-18 13:12:25 +01:00
Ben Taylor
934bee94c1 Remove redundant function from pkcs7_parse_reuse
Signed-off-by: Ben Taylor <ben.taylor@linaro.org>
(cherry picked from commit f60f5ba85cda59545442af29b59fdee9ed6af83d)
2026-06-18 13:12:25 +01:00
Ben Taylor
34f0016cbc Add ChangeLog
Signed-off-by: Ben Taylor <ben.taylor@linaro.org>
(cherry picked from commit e9ec4ce3caf7e21f877d4dd6d733b858bc56df75)
2026-06-18 13:12:25 +01:00
Ben Taylor
699d4030c2 Add fix for stale pointer after mbedtls_pkcs7_free
Signed-off-by: Ben Taylor <ben.taylor@linaro.org>
(cherry picked from commit 67e696b430716f95ed714f2c1404681697251438)

Backport note: resolved the PKCS7 test-suite conflict by keeping the 3.6 pkcs7_verify dependency expression while adding the reuse regression test.
2026-06-18 13:12:14 +01:00
Ronald Cron
cc1181a65e
Merge pull request #1662 from minosgalanakis/public-sync/mbedtls-3.6-14062026
[Sync] Merge mbedtls-3.6 into Merge mbedtls-3.6-restricted
2026-06-16 23:07:37 +02:00
Gilles Peskine
abb6bcd354 Credit independent report
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-06-16 19:36:40 +02:00
Gilles Peskine
794e1a89db Add documentation for the new getters and setters
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-06-16 15:04:35 +02:00
Gilles Peskine
7c28ccf8ab Use functions instead of macros for badmac_seen_or_in_hsfraglen setters
Let the caller handle returning on error. This is less surprising, and it's
more flexible in case the caller needs to perform some cleanup (which is
currently not the case).

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-06-16 14:56:59 +02:00
Gilles Peskine
364f07a926
Merge pull request #1654 from bjwtaylor/ECDHE-PSK-integer-overflow-restricted-3.6
Backport for Ecdhe psk integer overflow fix to 3.6
2026-06-16 11:50:01 +02:00
Ronald Cron
1d44a35519
Merge pull request #1647 from bjwtaylor/oob-key-exchange-restricted-3.6
Add fix for OOB key exchange error 3.6
2026-06-15 22:42:22 +02:00
Gilles Peskine
93460dafc7 Reject MBEDTLS_SSL_SET_BADMAC_SEEN at compile time if DTLS is disabled
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-06-15 18:39:19 +02:00
Gilles Peskine
1453fda32c Remove some test cases that are not really meaningful
Remove the "srv" variant of "DTLS proxy: server: get invalid AD record then
accept renego", where the server initiates the renegotiation process by
sending a HelloRequest. The HelloRequest message is not relevant to this
test. The first message of the actual renegotiation is the ClientHello
message from the client, and the interesting part of the test happens when
the client receives the server's response.

Remove "DTLS proxy: server: get invalid AD record then accept early
renego (cli)" and the corresponding "reject" control. This test case doesn't
really do what it is advertised to do, and in particular does not lead to a
call to `ssl_consume_current_message()` in the server. What happens is that
the client sends a ClientHello message to start the renegotiation, then it
blocks until the server has replied. So there is nothing to delay that
ClientHello after:(unlike what happens in the corresponding client-side
test, where the first flight of the renegotiation protocol contains multiple
messages, so we can delay the first of these messages after the second one).
What happens in practice is that the client times out, then resends its
ClientHello, and the proxy sends the delayed ClientHello immediately after
the resent one, which does not cause any interesting behavior in the server.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-06-15 18:22:11 +02:00
Gilles Peskine
1db3c1c9a0 Explain the "get invalid AD record .*renego" tests better
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-06-15 16:14:31 +02:00
Gilles Peskine
a145116bff Don't pass badmac_limit when it would have no effect
Only set `badmac_limit` on the side that actually receives a message with a
bad MAC/tag (injected by the proxy).

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-06-15 13:37:54 +02:00
Gilles Peskine
a939d850c7 Add DTLS handshake test with badmac_seen=1
Add a test entry point for a handshake with a specially crafted context.
This can be used for defense in depths for scenarios that we think can't
happen, but might actually happen due to a bug, or due to a new feature that
is insufficiently tested. This can also be a proxy for testing aspects of
renegotiation or session resumption in circumstances that are hard to
arrange.

In this commit, use it to test a DTLS handshake with `ssl->badmac_seen`
:(actually `ssl->badmac_seen_or_in_hsfraglen` in the 3.6 branch) set to a
nonzero value. This can't happen, as far as I know (`badmac_seen` can only
be nonzero during renegotiation, not during a nominal handshake or in
session resumption). But it could happen, for example, if
`mbedtls_ssl_session_reset()` failed to reset `badmac_seen`, as was the case
in Mbed TLS 4.0.0 to 4.1.0.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-06-15 13:08:43 +02:00
Amy Chan
1aed7869ff library/alignment.h: Fix 'MBEDTLS_GCC_VERSION' is not defined error
Only check 'MBEDTLS_GCC_VERSION' when 'MBEDTLS_COMPILER_IS_GCC' is defined

Signed-off-by: Amy Chan <amy.chan@intel.com>
2026-06-15 17:05:38 +08:00
Manuel Pégourié-Gonnard
591982e047 Clarify a commend in tests
Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2026-06-15 10:24:09 +02:00
Ben Taylor
b961ac2cf2
Update ChangeLog to include CVE number
Co-authored-by: Gilles Peskine <gilles.peskine@arm.com>
Signed-off-by: Ben Taylor <32939606+bjwtaylor@users.noreply.github.com>
2026-06-15 09:21:28 +01:00
Ben Taylor
e1351f7881 Fix style issue
Signed-off-by: Ben Taylor <ben.taylor@linaro.org>
2026-06-15 09:14:29 +01:00
Ben Taylor
0421e88ce1 Correct ChangeLog style
Signed-off-by: Ben Taylor <ben.taylor@linaro.org>
2026-06-15 09:14:29 +01:00
Ben Taylor
9befdba49e Add CVE to ChangeLog
Co-authored-by: Ronald Cron <ronald.cron@arm.com>
Signed-off-by: Ben Taylor <32939606+bjwtaylor@users.noreply.github.com>
2026-06-15 09:14:29 +01:00
Ben Taylor
b461821223 Improve the wording of the ChangeLog
Co-authored-by: Ronald Cron <ronald.cron@arm.com>
Signed-off-by: Ben Taylor <32939606+bjwtaylor@users.noreply.github.com>
2026-06-15 09:14:29 +01:00
Minos Galanakis
154516a789 Merge remote-tracking branch 'public/mbedtls-3.6' into public-sync/mbedtls-3.6-14062026
Signed-off-by: Minos Galanakis <minos.galanakis@arm.com>
2026-06-14 19:35:34 +01:00
Manuel Pégourié-Gonnard
255fd41e1e pk: tests: avoid corner case
Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2026-06-11 16:50:29 +02:00
Ben Taylor
e8908dfa54 Correct maximum lengths in length tests
Signed-off-by: Ben Taylor <ben.taylor@linaro.org>
(cherry picked from commit 89620b3cd4649dc3af967af8cf901dcaa1986ec0)
2026-06-11 14:11:36 +01:00
Ben Taylor
757e75732d Add note clarifying that output integrity for the chachpoly update is currently provided, though not gauranteed in the future
Signed-off-by: Ben Taylor <ben.taylor@linaro.org>
(cherry picked from commit b70d73e6a7591f99a05e8b1c03f0b3915ae7cdff)
2026-06-11 14:11:30 +01:00
Ben Taylor
4ee90fe0e6 Correct logic for keystream_bytes_used
Co-authored-by: minosgalanakis <30719586+minosgalanakis@users.noreply.github.com>
Signed-off-by: Ben Taylor <32939606+bjwtaylor@users.noreply.github.com>
(cherry picked from commit 8de9f6aa776d5e92d77b10dfca6666f83f542ab2)
2026-06-11 14:11:24 +01:00
Ben Taylor
bac83ee5de Add additional verification that output hasn't been modified
Signed-off-by: Ben Taylor <ben.taylor@linaro.org>
(cherry picked from commit 720ee2392a6ced5ee0220a87c20d6c3d43a10650)
2026-06-11 14:11:16 +01:00
Ben Taylor
29090200c2 Update tests to reflect change to lenght checking
Signed-off-by: Ben Taylor <ben.taylor@linaro.org>
(cherry picked from commit f650b3f761ff5d88c94800d168b1889567106eec)
2026-06-11 14:11:10 +01:00
Ben Taylor
89005658bc Remove issue number and add CVE to ChangeLog
Signed-off-by: Ben Taylor <ben.taylor@linaro.org>
(cherry picked from commit 84bb99ca557ddfe4864d3b9ae84299ba4fb0c358)
2026-06-11 14:11:05 +01:00
Ben Taylor
77a2831999 Remove length checking from chacha20
Signed-off-by: Ben Taylor <ben.taylor@linaro.org>
(cherry picked from commit 21594d5f6daeb8b6f633d481d3335bd7399f8237)
2026-06-11 14:10:53 +01:00
Ben Taylor
176bea08b7 Correct maximum size for chacha20
Signed-off-by: Ben Taylor <ben.taylor@linaro.org>
(cherry picked from commit 540c75e5a0fa787b6e4ffdaec33648f83b850b6a)
2026-06-11 14:10:47 +01:00
Ben Taylor
e1641d00e2 Remove assertion that ctx.ciphertext_len is 0
Signed-off-by: Ben Taylor <ben.taylor@linaro.org>
(cherry picked from commit 3f3d3da789e05f078a4df9995278d3d53e273513)
2026-06-11 14:10:42 +01:00