34496 Commits

Author SHA1 Message Date
Gilles Peskine
f624adff2e Switch to MBEDTLS_ERROR_ADD for combining X509 and ASN1 error codes
Since Mbed TLS 4.0, this is just the low-level error code. But keep the
combination for uniformity with the rest of the file, and to reduce the
differences with the 3.6 branch.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-06-05 11:35:46 +02:00
Gilles Peskine
045cede1b8 basicConstraints with leading INTEGER field: document the behavior change
Announce the security fix together with the overflow fix, since the two bugs
are pretty much indistinguishable from a black-box perspective, despite
being due to independent problems in the code.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-06-05 11:35:46 +02:00
Gilles Peskine
0d6060d644 Stop accepting basicConstraints with only pathLenConstraint
In an X.509 certificate, a basicConstraints extension where the cA
field (BOOLEAN) is omitted but the pathLenConstraint field (INTEGER )is
present is syntactically valid, but RFC 5280 states that CAs MUST NOT emit
such a certificate.

Historically, since XySSL 0.9 in 2008, if a basicConstraints extension
started with an INTEGER field, we interpreted that field as a cA value. This
was a deliberate change:

> Fixed x509_get_ext() to accept some rare certificates (like
> www.openssl.org:443) which have an INTEGER instead of a BOOLEAN for
> Extension::BasicConstraints::cA.

However, 18 years later, this does not seem to be relevant, and the details
seem to have been lost. Furthermore, major implementations follow RFC 5280
and interpret `SEQUENCE { INTEGER n }` with cA being set to its default
value (FALSE) and pathLenConstraint set to `n`. This means that such a
certificate with n != 0 would be interpreted as a CA certificate in Mbed TLS
but as a leaf certificate elsewhere, which is dangerous.

Since CAs are not supposed to emit such certificates, stop accepting them
altogether.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-06-05 11:35:46 +02:00
Gilles Peskine
5cc6fb22c6 basicConstraints pathLenConstraint tests: use standard cA type
In test cases for pathLenConstraint parsing in a basicConstraints extension
of an X.509 certificate, use the standard type for the leading cA field,
namely BOOLEAN. The test data was encoding that field as INTEGER, which was
accepted as a deviation from the standard since XySSL 0.9.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-06-05 11:35:46 +02:00
Gilles Peskine
eb051b501a Remove unreachable CSR extensionRequest check
It is now unreachable because:

- end_set == end_attr_data is enforced at library/x509_csr.c:236.
- end_exts == end_set is enforced at library/x509_csr.c:248.
- x509_csr_parse_extensions() only returns success if *p == end_exts, enforced
  at library/x509_csr.c:188.

So after a successful x509_csr_parse_extensions() call, *p == end_exts ==
end_set == end_attr_data. The condition at line 257 cannot be true.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-06-05 11:35:41 +02:00
Gilles Peskine
cc794d8501 Tighten CSR extensionRequest bounds
Don't allow parts of a compound (SEQUENCE or SET) to go beyond the
containing compound.

The inline CSR regression test is derived from the existing "X509 CSR
ASN.1 (OK)" DER test vector. In the extensionRequest attribute, the original
well-formed fragment is:

    a029 3027 06092a864886f70d01090e 311a 3018 ...

where 31 1a is the SET containing the Extensions sequence and 30 18 is the
contained Extensions sequence. The malformed test changes only the SET
length byte, from 1a to 19:

    a029 3027 06092a864886f70d01090e 3119 3018 ...

The attribute SEQUENCE length and the inner Extensions sequence length are
left unchanged. This makes the SET one byte too short for its containing
attribute, so the parser must reject it with
MBEDTLS_ERR_ASN1_LENGTH_MISMATCH instead of parsing the trailing byte as
data outside the SET.

There is no known security impact, just some risk reduction.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-06-05 11:35:38 +02:00
Gilles Peskine
6c8ae1ea48 Fix lax basicConstraints parsing
When parsing the basicConstraints extension, reject junk after the SEQUENCE
inside the extension (which is probably benign), and reject a SEQUENCE that
extends beyond the extension (could be very dangerous).

Add a non-regression test where a certificate that is technically malformed,
but accepted as a leaf certificate by OpenSSL and other X.509
implementations, to be accepted as a CA certificate by Mbed TLS.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-05-26 21:07:09 +02:00
Gilles Peskine
22dccc1d83 Update framework with test certificate with basicConstraints overflow
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-05-26 21:07:09 +02:00
Manuel Pégourié-Gonnard
4a1d150cdf
Merge pull request #1600 from mpg/development-restricted
Merge public development into -restricted
2026-05-12 08:59:49 +02:00
Manuel Pégourié-Gonnard
00dfa64627 Merge branch 'development' into development-restricted
* development: (46 commits)
  Update tf-psa-crypto pointer to bring in fix for python imports
  Update framework pointer to bring in fix for python imports
  check_config: fix error message for missing TLS 1.2 key exchanges
  check_config: add check for TLS 1.3 key exchanges
  update ChangeLog
  Pacify uncrustify
  ChangeLog: Fixed a reference to TF-PSA-Crypto
  ssl: add TLS 1.2 RSA-PSS debug trace
  add ChangeLog
  Fix build warning/error using llvm-mingw
  ssl: narrow TLS 1.2 RSA-PSS handling and add interop coverage
  test: improve symlink checks
  test: versioned symlink order fix
  test: reorder if-else structure
  test: add debug output and fix for win config
  ChangeLog fix
  Unify TF-PSA-Crypto and mbedtls templates
  tests: fix DESTDIR install checks and add macOS compatibility
  ChangeLog fixes
  Update crypto submodule with analyze_outcomes.py
  ...
2026-05-11 12:04:15 +02:00
Manuel Pégourié-Gonnard
902b012537
Merge pull request #10749 from bjwtaylor/broken-build
Update framework pointer to bring in fix for python imports
2026-05-07 19:13:19 +00:00
Ben Taylor
954e236500 Update tf-psa-crypto pointer to bring in fix for python imports
Signed-off-by: Ben Taylor <ben.taylor@linaro.org>
2026-05-07 14:17:54 +01:00
Ben Taylor
02fb4c75cb Update framework pointer to bring in fix for python imports
Signed-off-by: Ben Taylor <ben.taylor@linaro.org>
2026-05-07 08:14:43 +01:00
minosgalanakis
d12fbb991c
Merge pull request #10695 from valord577/patch-1
Fix build warning/error using llvm-mingw
2026-04-29 14:52:00 +00:00
Gilles Peskine
a314ada082
Merge pull request #10631 from yiwu0b11/destdir_install_env_support
Support DESTDIR for install and add build-system test
2026-04-29 14:37:29 +00:00
Valerio Setti
ae8579f2a2
Merge pull request #10650 from valeriosetti/fix-tls13-guard
check_config: add missing check for TLS 1.3 key exchanges
2026-04-24 14:32:36 +00:00
Valerio Setti
51b62060de
Merge pull request #10639 from valeriosetti/ecdhe-rsa-fix-check
library: check_config: remove RSA encryption requirement from ECDHE-RSA
2026-04-24 07:30:47 +00:00
Valerio Setti
c3d52b905b check_config: fix error message for missing TLS 1.2 key exchanges
Align the error message to the one used for the same check in TLS 1.3.

Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2026-04-22 15:00:55 +02:00
Valerio Setti
5ea77200d9 check_config: add check for TLS 1.3 key exchanges
When MBEDTLS_SSL_PROTO_TLS1_3 is enabled ensure that at least one of the
related key exchanges is also enabled.

Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2026-04-22 15:00:54 +02:00
valord577
68319cbc80 update ChangeLog
Signed-off-by: valord577 <valord577@gmail.com>
2026-04-22 11:05:04 +08:00
valord577
e022733f9f
Merge branch 'Mbed-TLS:development' into patch-1 2026-04-22 10:41:51 +08:00
Ronald Cron
391af7c976
Merge pull request #10701 from minosgalanakis/docs/4.1.0_changelog_fixes
ChangeLog: Fixed a reference to TF-PSA-Crypto
2026-04-20 09:38:38 +00:00
Ronald Cron
518ed0337d
Merge pull request #10672 from Maokaman1/fix/tls12-rsa-pss-sigalgs
ssl: accept TLS 1.2 rsa_pss_rsae signature algorithms
2026-04-20 08:03:39 +00:00
Viktor Sokolovskiy
f90e81c7f8 Pacify uncrustify
Signed-off-by: Viktor Sokolovskiy <maokaman@gmail.com>
2026-04-18 01:51:17 +03:00
Maokaman1
78336bb5bd
Merge branch 'Mbed-TLS:development' into fix/tls12-rsa-pss-sigalgs 2026-04-17 19:13:43 +03:00
Minos Galanakis
935eb1a53b ChangeLog: Fixed a reference to TF-PSA-Crypto
Signed-off-by: Minos Galanakis <minos.galanakis@arm.com>
2026-04-17 16:59:05 +01:00
Viktor Sokolovskiy
3d61c38ea0 ssl: add TLS 1.2 RSA-PSS debug trace
Signed-off-by: Viktor Sokolovskiy <maokaman@gmail.com>
2026-04-17 17:36:31 +03:00
valord577
37b81f13c7 add ChangeLog
Signed-off-by: valord577 <valord577@gmail.com>
2026-04-16 15:17:32 +08:00
valord577
a3d3ede9d6
Fix build warning/error using llvm-mingw
error logs refs: https://github.com/valord577/nativepkgs/actions/runs/24490614774/job/71574726128

Signed-off-by: valord577 <valord577@gmail.com>
2026-04-16 14:31:55 +08:00
Viktor Sokolovskiy
2168fe9cda ssl: narrow TLS 1.2 RSA-PSS handling and add interop coverage
Signed-off-by: Viktor Sokolovskiy <maokaman@gmail.com>
2026-04-16 04:36:48 +03:00
Yi Wu
970df30a8f test: improve symlink checks
Signed-off-by: Yi Wu <yi.wu2@arm.com>
2026-04-15 12:13:09 +01:00
Gilles Peskine
8426c9bc51
Merge pull request #10684 from gilles-peskine-arm/maintainer-scripts-create-directory-dev
development: Create a directory for maintainer-only Python scripts
2026-04-15 08:19:36 +00:00
Gilles Peskine
8bf89416cf
Merge pull request #10647 from gilles-peskine-arm/github-pr-template-add-4.1-mbedtls
Add 1.1 line to the PR template
2026-04-15 08:17:24 +00:00
Yi Wu
0c02d74a48 test: versioned symlink order fix
Signed-off-by: Yi Wu <yi.wu2@arm.com>
2026-04-14 11:06:16 +01:00
Yi Wu
f38b17e7a0 test: reorder if-else structure
Signed-off-by: Yi Wu <yi.wu2@arm.com>
2026-04-14 10:12:44 +01:00
Yi Wu
331ad77fe2 test: add debug output and fix for win config
Signed-off-by: Yi Wu <yi.wu2@arm.com>
2026-04-13 15:13:52 +01:00
Yi Wu
6fb557c31a ChangeLog fix
Signed-off-by: Yi Wu <yi.wu2@arm.com>
2026-04-13 15:00:44 +01:00
Gilles Peskine
6b31bc6885 Unify TF-PSA-Crypto and mbedtls templates
Following the team discussion, don't suggest "prerequisite" or "consuming"
in the template. Suggest linking all the pull requests in a group
everywhere.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-04-13 14:57:07 +02:00
Yi Wu
e9e0409b11 tests: fix DESTDIR install checks and add macOS compatibility
Signed-off-by: Yi Wu <yi.wu2@arm.com>
2026-04-13 12:48:01 +01:00
Yi Wu
15be9e9048 ChangeLog fixes
Signed-off-by: Yi Wu <yi.wu2@arm.com>
2026-04-13 12:12:24 +01:00
Gilles Peskine
2a7d1ece77
Merge pull request #10676 from gilles-peskine-arm/analyze_outcomes-read_crypto
Let TF-PSA-Crypto define test cases that Mbed TLS does not need to cover
2026-04-13 09:24:21 +00:00
Gilles Peskine
cc134b0b94 Update crypto submodule with analyze_outcomes.py
Update framework to match.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-04-10 14:49:14 +02:00
Yi Wu
f14f28ce75 ChangeLog padding space fix
Signed-off-by: Yi Wu <yi.wu2@arm.com>
2026-04-10 10:27:09 +01:00
Gilles Peskine
9248af96b1 Create a directory for maintainer-only Python scripts
This directory is currently excluded from `check-python-files.sh`, because
we run it on the CI in an old Python version that doesn't support some of
our new maintainer scripts.

There are no such scripts in mbedtls for now (only in TF-PSA-Crypto), but be
ready if we want to add some.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-04-09 19:39:42 +02:00
Gilles Peskine
806e1d365b Documentation improvements
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-04-08 17:22:10 +02:00
Gilles Peskine
d25f03919a INTERNAL_TEST_CASES moved to a separate data-only module
This way, when Mbed TLS's `analyze_outcomes.py` loads the python module from
TF-PSA-Crypto (because it needs to know the value of `INTERNAL_TEST_CASES`),
there's no risk that the subproject and the superproject will have different
requirements on auxiliary modules such as `mbedtls_framework.outcome_analysis`.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-04-08 15:47:49 +02:00
Gilles Peskine
16a90a556e Add copyright line
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-04-08 15:31:52 +02:00
Viktor Sokolovskiy
f75c033ead ssl: add TLS 1.2 RSA-PSS regression coverage
Signed-off-by: Viktor Sokolovskiy <maokaman@gmail.com>
2026-04-07 20:20:09 +03:00
Gilles Peskine
667a3f6442 Move test currently covered by crypto from uncovered list to ignored list
If we can't read `INTERNAL_TEST_CASES` from
`tf-psa-crypto/tests/scripts/analyze_outcomes.py` because the script doesn't
exist, hard-code the legacy value of that information.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-04-07 11:47:24 +02:00
Gilles Peskine
1978e1bd6b Ignore test cases that TF-PSA-Crypto tells us to ignore
If the `tf-psa-crypto` submodule has `tests/scripts/analyze_outcomes.py`,
require it to define a global variable `INTERNAL_TEST_CASES`. Those test
cases will be ignored in Mbed TLS's coverage analysis.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-04-07 11:47:13 +02:00