34791 Commits

Author SHA1 Message Date
Julius Bairaktaris
cbcee99db1 tests: build the SHA-256 crypto extensions with GCC and a fortified libc
Build sha256.c with -mcpu=cortex-a53 and _FORTIFY_SOURCE for both
MBEDTLS_SHA256_USE_ARMV8_A_CRYPTO_ONLY and _IF_PRESENT. Without
Mbed-TLS/TF-PSA-Crypto#937 this fails to inline the fortified memset().

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Julius Bairaktaris <julius@bairaktaris.de>
2026-10-24 11:40:37 +02:00
Valerio Setti
0d13af54a8
Merge pull request #10799 from bjwtaylor/no-program-failure-4.1
Backport 4.1: Add fix for -DENABLE_PROGRAMS=OFF build error
2026-10-21 15:41:24 +00:00
Gilles Peskine
5e889b385f
Merge pull request #10985 from MechatronikMonkey/fix-empty-authority-key-id-4.1
Backport 4.1: x509_crt: accept empty AuthorityKeyIdentifier sequence
2026-10-21 15:12:21 +00:00
Gilles Peskine
9ce9b40d84
Merge pull request #10929 from nvxbug/tls12-handshake-len-bounds-4.1
Backport 4.1: Fix off-by-one over-read in TLS 1.2 ClientHello and CertificateRequest
2026-10-21 15:08:41 +00:00
Gilles Peskine
79b4563370
Merge pull request #11010 from v1rtu3x/fix-x509-basic-constraints-integer-first-4.1
fix-x509-basic-constraints-integer-first-4.1
2026-10-21 15:07:32 +00:00
v1rtu3x
6323be8b1f tests: Clarify pathLenConstraint values in test descriptions
Signed-off-by: v1rtu3x <149050962+v1rtu3x@users.noreply.github.com>
(cherry picked from commit 1b3bbfd4a24b3d3c17cf5ac94c4576bba81f6ce5)
2026-10-21 13:23:06 +03:00
v1rtu3x
f429097cdd x509: Accept basicConstraints with omitted cA
RFC 5280 defines cA as BOOLEAN DEFAULT FALSE, so a basicConstraints
extension containing only pathLenConstraint (SEQUENCE { INTEGER n })
is syntactically valid and must be interpreted as cA=FALSE. The fix
for CVE-2026-49300 rejected this encoding outright, breaking
compatibility with certificates emitted by devices such as
Eaton/CODESYS PLCs.

Tolerate MBEDTLS_ERR_ASN1_UNEXPECTED_TAG from the cA BOOLEAN parse,
keeping cA FALSE and letting the existing INTEGER parser validate
pathLenConstraint. The INTEGER value is never used to determine cA,
so the CVE fix is preserved.

Fixes #11006

Signed-off-by: v1rtu3x <149050962+v1rtu3x@users.noreply.github.com>
(cherry picked from commit 62dd8a556c01cc289d4fb3f19352a78ede90dac2)
2026-10-21 12:55:10 +03:00
Manuel Pégourié-Gonnard
7e75131af9
Merge pull request #10997 from subotac/fix/numeric-oid-overflow-4.1
Backport 4.1: Reject overflowing numeric OID components
2026-10-13 09:24:32 +00:00
subotac
7b0eb04af9 Reject overflowing numeric OID components
Backport of f79eac885dec294d6e441bada15be1605dcb75b0.

Refs Mbed-TLS/mbedtls#10911.

Signed-off-by: subotac <73706465+subotac@users.noreply.github.com>
2026-10-06 23:18:15 +03:00
Manuel Pégourié-Gonnard
14501f4503
Merge pull request #10993 from saadgodikat/backport-10973-4.1
[4.1] Fix DER certificate output on Windows
2026-10-06 10:13:44 +00:00
Ronald Cron
4d4fdd21d9
Merge pull request #10991 from nvxbug/ssl-context-load-alpn-bounds-4.1
Backport 4.1: Reject out-of-bounds ALPN length in ssl_context_load
2026-10-05 11:39:53 +00:00
saadgodikat
b6d441ed52 Add changelog for DER certificate output fix
Signed-off-by: saadgodikat <saadgodikat601@gmail.com>
2026-10-05 16:15:16 +05:30
saadgodikat
f99e60c339 Fix DER certificate output on Windows
Fixes #10152

Signed-off-by: saadgodikat <saadgodikat601@gmail.com>
2026-10-05 15:20:35 +05:30
Naveed
ff9388a77d Add an out_cid case to the ssl_context_load OOB length test
Cover the serialized out_cid length with the same construction as the
in_cid one, and rename the existing case to IN_CID accordingly. Give
the client and server sentinel CIDs different lengths so the two
fields can be told apart in the serialized data. Skip the CID cases
under configurations of MBEDTLS_SSL_CID_IN_LEN_MAX and
MBEDTLS_SSL_CID_OUT_LEN_MAX that the test does not support.

Signed-off-by: Naveed <naveed@bugqore.com>
2026-10-04 22:44:50 +05:30
Naveed
aed8d01bf2 Guard the in_cid size check in the CID case
The previous approach documented the in_cid_len > sizeof(in_cid) cap
as untestable, since the overflowing memcpy() lands inside the
transform structure where sanitizers cannot see it. It can be guarded
without a sanitizer: grow the in_cid field in the loaded data (keep
its bytes, pad to MBEDTLS_SSL_CID_IN_LEN_MAX + 1) and append the rest
of the serialized data untouched, so the in-buffer bounds check passes
and the cap is what must reject the length. Without the cap the
remaining data parses correctly aligned and the load succeeds, so the
test catches a regression by the return value alone.

Signed-off-by: Naveed <naveed@bugqore.com>
2026-10-04 22:44:50 +05:30
Naveed
bccab06703 Keep the out_cid length byte in the CID case's truncated data
With the loaded data cut right after the in_cid bytes, even the
pristine in_cid length tripped the (end - p) < in_cid_len + 1u bounds
check, since the out_cid length byte it accounts for was missing: the
truncation, not the corruption, was what got rejected. Keep the
out_cid length byte in the loaded data, so the pristine length passes
the check and only the corrupted length trips it. Also document why
this pre-existing check is the only one in the in_cid path that a
regression test can guard: the in_cid_len > sizeof(in_cid) cap
protects the memcpy() destination, and without it the overflow lands
in the out_cid field inside the transform structure, where sanitizers
cannot see it.

Signed-off-by: Naveed <naveed@bugqore.com>
2026-10-04 22:44:50 +05:30
Naveed
a3c9450cd2 Fix the CID case of the OOB length regression test
The corrupted in_cid length exercised the pre-existing size-cap check,
not the bounds check: the in_cid field is not the last one serialized,
and the MBEDTLS_SSL_CID_IN_LEN_MAX cap is smaller than the size of the
fields that follow it, so no corrupted length could reach past the end
of the full buffer, and reverting the bounds check did not change the
test's outcome. Truncate the loaded data right after the in_cid bytes,
load from a tightly allocated copy, and corrupt the length to one byte
past that end, so that reverting the bounds check now trips ASan with
an out-of-bounds read in the memcpy(), like the ALPN case.

Signed-off-by: Naveed <naveed@bugqore.com>
2026-10-04 22:44:50 +05:30
Naveed
e0177ae7e9 Address review: verify pristine load, corrupt ALPN length by exactly one
Load the serialized context once before corrupting it, to check the
data is well-formed to begin with. Shorten the second ALPN protocol so
the corrupted length overruns the serialized data by exactly one byte,
and assert that property at runtime. Document that the corrupted load
usually fails even without the bounds check, so the regression is only
caught when the suite runs under ASan or Valgrind.

Signed-off-by: Naveed <naveed@bugqore.com>
2026-10-04 22:44:50 +05:30
Naveed
63f1c42b7c Merge the two ssl_context_load OOB length tests
Fold ssl_context_load_rejects_oob_cid_length and
ssl_context_load_rejects_oob_alpn_length into a single parameterized
test function, since they shared most of their code.

Signed-off-by: Naveed <naveed@bugqore.com>
2026-10-04 22:44:50 +05:30
Naveed
5ece3de4d2 Reject out-of-bounds ALPN length in ssl_context_load
The serialized ALPN length was passed to memcmp() against each configured protocol without checking it against the remaining serialized data, so a malformed context could read past the end of the buffer. Bound it before the comparison, like the adjacent CID fields.

Signed-off-by: Naveed <naveed@bugqore.com>
2026-10-04 22:44:49 +05:30
Christopher Müller
04e572bcda Add ChangeLog entry for empty AuthorityKeyIdentifier
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Christopher Müller <chris@mechatronikmonkey.de>
2026-10-03 14:28:34 +02:00
Christopher Müller
23091dbf2a tests: x509parse: add empty and truncated AuthorityKeyIdentifier tests
An empty AuthorityKeyIdentifier SEQUENCE must parse. A [0] tag without
a length must still be rejected; that case already passed before the
fix and guards against loosening the check too much.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Christopher Müller <chris@mechatronikmonkey.de>
2026-10-03 14:28:34 +02:00
Christopher Müller
a8fda00a13 x509_crt: accept empty AuthorityKeyIdentifier sequence
All fields of AuthorityKeyIdentifier are OPTIONAL, so an empty SEQUENCE
(30 00) is syntactically valid. It was rejected with
MBEDTLS_ERR_X509_INVALID_EXTENSIONS + MBEDTLS_ERR_ASN1_OUT_OF_DATA,
because mbedtls_asn1_get_tag() reports OUT_OF_DATA rather than
UNEXPECTED_TAG when there is nothing left to parse.

Check for the empty sequence explicitly instead of treating OUT_OF_DATA
as an absent keyIdentifier: OUT_OF_DATA is also returned for a [0] tag
with a missing or truncated length, which must still be rejected.

Fixes #10253.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Christopher Müller <chris@mechatronikmonkey.de>
2026-10-03 14:28:34 +02:00
Valerio Setti
77eacf4c93
Merge pull request #10971 from valeriosetti/replace-legacy-rsa-symbols-followup-4.1
[4.1] Replace legacy rsa symbols followup
2026-09-25 14:53:18 +00:00
Valerio Setti
1b40f0d573 tests: ssl: refine RSA dependencies of test functions
- mbedtls_endpoint_sanity() is only used for TLS 1.2 tests, where RSA
  signatures are limited to PKCS#1 v1.5. Moreover the test does not
  perform a full handshake, so only being able to hold an RSA public key
  is required here: PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY.
- move_handshake_to_state() is used for both TLS 1.2 and TLS 1.3 tests
  and the RSA capabilities it needs depend on the handshake state being
  reached, so the RSA dependency is set on test data instead.

Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2026-09-25 09:18:41 +02:00
Valerio Setti
88a3ee59eb tests: ssl: refine RSA dependencies in test data
- Mbed TLS only implements TLS 1.2 and DTLS 1.2 (not 1.0/1.1) and there
  RSA signatures are limited to PKCS#1 v1.5, so replace
  PSA_HAVE_ALG_SOME_RSA_SIGN with PSA_HAVE_ALG_RSA_PKCS1V15_SIGN.
- move_handshake_to_state() sets options.pk_alg = MBEDTLS_PK_RSA, so some
  minimal support for RSA keys is always needed: at least an RSA public
  key. Stricter requirements only apply depending on the protocol version
  (TLS 1.2 vs 1.3) and on the handshake state reached by the test (ex:
  initial phase vs ending phase), so they are set per test case.
- Test cases already requiring MBEDTLS_X509_RSASSA_PSS_SUPPORT don't need
  PSA_WANT_ALG_RSA_PSS too, since the former depends on the latter.
- Add a comment to the handshake_psk_cipher test cases to explain why a
  test which is ideally about PSK has requirements on RSA and EC keys.

Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2026-09-25 09:18:41 +02:00
Valerio Setti
f207f1949b tests: pkcs7: remove RSA dependency from pkcs7_verify()
PKCS7 supports ECC as well so the test function should not be guarded or
limited to RSA build symbols. Those guards are now set on the test data
as required by each test itself. This allows for test extension to also
include ECC testing (not present now).

Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2026-09-25 09:18:41 +02:00
Valerio Setti
dceeba6ca5 tests: pkcs7: set proper RSA dependencies on pkcs7_verify() test data
pkcs7_verify() is about to lose its blanket RSA guard, so each test case
must declare what it actually needs:
- cases that really validate an RSA signature require
  PSA_HAVE_ALG_RSA_PKCS1V15_VERIFY. This includes the cases which used
  to pass accidentally because the certificate is invalid and the code
  never gets to verify the signature: using the same dependency as the
  valid cases is more uniform;
- cases which are expected to fail before reaching signature
  verification only require PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY.

Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2026-09-25 09:18:41 +02:00
Valerio Setti
5086860839 tests: x509parse: ease RSA requirements in test data
- Tests that only parse a certificate/CRL/CSR without verifying any
  signature only need to be able to hold an RSA public key, so replace
  PSA_HAVE_ALG_SOME_RSA_VERIFY with PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY.
  PSA_HAVE_ALG_SOME_RSA_VERIFY is kept in x509_verify tests, which do
  verify signatures.
- x509_parse_rsassa_pss_params tests don't need any explicit RSA
  dependency: the test function already depends on
  MBEDTLS_X509_RSASSA_PSS_SUPPORT which itself depends on
  PSA_WANT_KEY_TYPE_RSA_KEY_PAIR_BASIC, i.e. something "stronger" than
  PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY.

Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2026-09-25 09:18:39 +02:00
Valerio Setti
2682ef0bd7 depends.py: add PSA_WANT_ALG_RSA_PSS to pkalgs domain
MBEDTLS_X509_RSASSA_PSS_SUPPORT depends on PSA_WANT_ALG_RSA_PSS, so add
the corresponding reverse dependency and include PSA_WANT_ALG_RSA_PSS in
the 'pkalgs' ComplementaryDomain in order to also test builds where
RSA-PSS is disabled.

Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2026-09-25 09:14:09 +02:00
Gilles Peskine
0970a715f1
Merge pull request #10963 from davidhorstmann-arm/fix-check-config-rsa-pss-4.1
[Backport 4.1] Fix incorrect check in `check_config.h`
2026-09-22 12:43:25 +00:00
David Horstmann
480a9bfb09 Fix incorrect check in check_config.h
OAEP is for RSA encryption and therefore is not the correct check when
we want to test for signatures with PSS.

Additionally, we can use RSA PSS when we only have public key support
(not key pairs) so check for PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY (which is
auto-enabled when we have key pairs enabled anyway).

Signed-off-by: David Horstmann <david.horstmann@arm.com>
2026-09-22 11:20:07 +01:00
Valerio Setti
67e43044c1
Merge pull request #10960 from valeriosetti/improve-depends-py-4.1
[4.1] scripts: depends-py: add the possibility to provide a fully custom build-and-test command
2026-09-21 15:04:35 +00:00
Valerio Setti
3c1b87e387 scripts: depends-py: fix pylint complains
Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2026-09-21 11:37:10 +02:00
Valerio Setti
dff951822a scripts: depends-py: add the possibility to provide a fully custom build-and-test command
This is useful for debugging purposes because, for example, the user
only want to build a specific suite and/or only run it instead of
building and testing everything for all the jobs.
For this scope the custom command can be a bash script that's executed
instead of 'make' + 'make test'.

Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2026-09-21 11:37:10 +02:00
David Horstmann
5471f382e5
Merge pull request #10812 from davidhorstmann-arm/2026-07-update-python-dependencies-4.1
[Backport 4.1] Update Python docs dependencies
2026-09-09 17:18:43 +00:00
David Horstmann
0b46f15a07 Update Python packages for docs
Signed-off-by: David Horstmann <david.horstmann@arm.com>
2026-09-09 14:48:28 +01:00
Gilles Peskine
3f1ce37679
Merge pull request #10948 from gilles-peskine-arm/update-submodule-20261008-4.1
Backport 4.1: Update framework with check-python-files fix
2026-09-09 14:40:57 +02:00
Gilles Peskine
c2f44402f8 Update framework with check-python-files fix
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-09-09 11:27:10 +02:00
David Horstmann
56e1c4058e
Merge pull request #10944 from ronald-cron-arm/cve_id_issue_1618-4.1
4.1: Add CVE-2026-73096 ID in ChangeLog
2026-09-03 11:02:32 +00:00
David Horstmann
b4e7dd432c
Merge pull request #10940 from HelloOO7/mbedtls-4.1
Backport 4.1: Restore __cplusplus guard absent from oid.h
2026-09-03 10:30:17 +00:00
minosgalanakis
150d1ea6f0
Merge pull request #10935 from gilles-peskine-arm/cmake-config-4.1
Backport 4.1: Cmake custom compile-time config support
2026-09-02 15:16:25 +00:00
HelloOO7
3416cba59b Add missing __cplusplus guard to oid.h
Signed-off-by: HelloOO7 <cendarehor@gmail.com>
2026-09-02 13:59:12 +02:00
Ronald Cron
cbc8c55b0c Add CVE ID
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2026-09-02 09:36:33 +02:00
Gilles Peskine
7ce654d532
Merge pull request #10938 from gilles-peskine-arm/threading-1.0-alt-build-mbedtls
Backport 4.1: Remove unused test headers
2026-09-01 11:00:13 +02:00
Valerio Setti
87e8d096b1
Merge pull request #10681 from gilles-peskine-arm/all.sh-silence-support-failures-4.0
Backport 4.1: Silence support failures in all.sh
2026-08-31 16:07:19 +00:00
Yi Wu
9671dd208c Update tf-psa-crypto with CMake config improvements
Signed-off-by: Yi Wu <yi.wu2@arm.com>
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-08-27 21:19:14 +02:00
Yi Wu
af4e77afd4 improve test coverage
Signed-off-by: Yi Wu <yi.wu2@arm.com>
2026-08-27 21:19:14 +02:00
Yi Wu
79e39ed09e CMake: restore FILEPATH from STING for base
Signed-off-by: Yi Wu <yi.wu2@arm.com>
2026-08-27 12:34:42 +02:00
Yi Wu
d110a4c5ad CMake: combine Mbed TLS and PSA transformations
Signed-off-by: Yi Wu <yi.wu2@arm.com>
2026-08-27 12:34:42 +02:00