12988 Commits

Author SHA1 Message Date
Valerio Setti
cac9589a97
Merge pull request #10654 from bjwtaylor/no-program-failure
Add fix for -DENABLE_PROGRAMS=OFF build error
2026-10-21 15:41:31 +00:00
Gilles Peskine
159d6120cf
Merge pull request #10974 from MechatronikMonkey/fix-empty-authority-key-id
x509_crt: accept empty AuthorityKeyIdentifier sequence
2026-10-21 15:12:30 +00:00
Gilles Peskine
cb6f98ee6f
Merge pull request #10833 from nvxbug/tls12-handshake-len-bounds
Fix off-by-one over-read in TLS 1.2 ClientHello and CertificateRequest
2026-10-21 15:08:28 +00:00
Gilles Peskine
270eea420e
Merge pull request #11008 from v1rtu3x/fix-x509-basic-constraints-integer-first
x509: Accept basic Constraints with omitted CA
2026-10-21 15:07:39 +00:00
v1rtu3x
1b3bbfd4a2 tests: Clarify pathLenConstraint values in test descriptions
Signed-off-by: v1rtu3x <149050962+v1rtu3x@users.noreply.github.com>
2026-10-20 11:50:52 +03:00
Rohan Luchmun
4972da7059 Removed explicit include path from consistency check
Signed-off-by: Rohan Luchmun <Rohan.Luchmun@arm.com>
2026-10-19 14:12:30 +01:00
Rohan Luchmun
7f9525b141 Removed static key slot component test
Signed-off-by: Rohan Luchmun <Rohan.Luchmun@arm.com>
2026-10-19 14:12:27 +01:00
Rohan Luchmun
d23fcce12c Removed debugging print
Signed-off-by: Rohan Luchmun <Rohan.Luchmun@arm.com>
2026-10-19 14:11:16 +01:00
Rohan Luchmun
662ffe3141 Added pqcp to include path
Signed-off-by: Rohan Luchmun <Rohan.Luchmun@arm.com>
2026-10-19 14:11:16 +01:00
v1rtu3x
62dd8a556c 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>
2026-10-16 13:53:40 +03:00
Manuel Pégourié-Gonnard
38c5d91611
Merge pull request #10911 from subotac/fix/numeric-oid-overflow
Reject overflowing numeric OID components
2026-10-13 09:24:29 +00:00
Ronald Cron
6bdf4e15e2
Merge pull request #10792 from nvxbug/ssl-context-load-alpn-bounds
Reject out-of-bounds ALPN length in ssl_context_load
2026-10-05 11:39:44 +00:00
Christopher Müller
10e40b70ad 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-09-26 10:27:11 +02:00
Valerio Setti
c0748befd5
Merge pull request #10642 from valeriosetti/replace-legacy-rsa-symbols-followup
[dev] Replace legacy rsa symbols followup
2026-09-25 14:53:25 +00:00
Valerio Setti
c648c33515 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:10:48 +02:00
Valerio Setti
ad51f9af04 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:10:43 +02:00
Valerio Setti
cac46b68d0 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:10:40 +02:00
Valerio Setti
b08bfee580 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:10:37 +02:00
Valerio Setti
d88eb68385 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:10:33 +02:00
Valerio Setti
0282e0f0e9 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:10:29 +02:00
Naveed
fbc06d7909 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-09-22 17:27:35 +05:30
Naveed
a39d101718 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-09-22 17:23:31 +05:30
Naveed
13bbd7ec0b 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-09-22 17:23:31 +05:30
Naveed
05f02b1e40 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-09-22 17:23:31 +05:30
Naveed
467e053210 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-09-22 17:23:31 +05:30
Naveed
8b670951eb 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-09-22 17:23:31 +05:30
Naveed
c2c8d1e142 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-09-22 17:23:31 +05:30
Valerio Setti
dd30cc683f scripts: depends-py: fix pylint complains
Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2026-09-17 17:29:58 +02:00
Valerio Setti
00aff9cbb4 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-17 11:24:40 +02:00
Valerio Setti
9b0370e949 configuration-crypto: add ALG_SM3 to the components accelerating hash algs
Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2026-09-09 15:52:59 +02:00
Valerio Setti
2f4b6f3bb9 tests: configuration-crypto: accelerate Blake2 on tests accelerating EC
Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2026-09-09 15:52:59 +02:00
Valerio Setti
2b0003a134 scripts: libtestdriver1_rewrite.pl: fix tf-psa-crypto private headers path
Generated tf-psa-crypto private includes path in
'crypto_builtin_primitives.h' were wrong. For example the output for
'blake2.h' was:

"libtestdriver1/tf-psa-crypto/include/tf-psa-crypto/private/blake2.h"

whereas it should have been

"libtestdriver1/tf-psa-crypto/drivers/builtin/include/tf-psa-crypto/private/blake2.h"

Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2026-09-09 15:52:59 +02:00
minosgalanakis
023aca8620
Merge pull request #10860 from yiwu0b11/cmake-config
Cmake custom compile-time config support
2026-09-02 15:16:33 +00:00
Gilles Peskine
a5a368690e
Merge pull request #10394 from gilles-peskine-arm/threading-1.0-alt-build-mbedtls
Remove unused test headers
2026-09-01 11:00:04 +02:00
Valerio Setti
33f79f8ab0
Merge pull request #10493 from gilles-peskine-arm/all.sh-silence-support-failures-4.0
Silence support failures in all.sh
2026-08-31 14:36:46 +00:00
Yi Wu
8a7fdf2600 improve test coverage
Signed-off-by: Yi Wu <yi.wu2@arm.com>
2026-08-21 15:17:07 +01:00
Yi Wu
ebbe61a192 CMake: restore FILEPATH from STING for base
Signed-off-by: Yi Wu <yi.wu2@arm.com>
2026-08-21 12:13:28 +01:00
Yi Wu
d18007682d CMake: combine Mbed TLS and PSA transformations
Signed-off-by: Yi Wu <yi.wu2@arm.com>
2026-08-20 17:03:11 +01:00
Yi Wu
5c906f7fa0 compatible with PSA configs and test improvements
Signed-off-by: Yi Wu <yi.wu2@arm.com>
2026-08-19 15:57:00 +01:00
Gilles Peskine
50c40957c3 Make installable pqcp headers available to the libtestdriver1 build
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-08-18 16:07:13 +02:00
Yi Wu
c734d57590 test fixes: CMake 3.10 not support cmake -S -B
Signed-off-by: Yi Wu <yi.wu2@arm.com>
2026-08-14 17:23:24 +01:00
Yi Wu
166c69a921 CMake: make generated configs relocatable
Signed-off-by: Yi Wu <yi.wu2@arm.com>
2026-08-14 16:20:27 +01:00
Yi Wu
030f872a9b tests: cmake coverage improve
Signed-off-by: Yi Wu <yi.wu2@arm.com>
2026-08-14 15:28:29 +01:00
Valerio Setti
a6b469a5f5
Merge pull request #10848 from valeriosetti/issue10694
tests: scripts: remove _reference test components
2026-08-13 14:53:27 +00:00
Valerio Setti
88ae2c66c8
Merge pull request #10620 from mpg/ref-for-drivers
Check test dependencies against crypto internal macros
2026-08-13 09:56:09 +00:00
Valerio Setti
67050ecbf1 tests: remove duplicate component_test_psa_crypto_config_accel_hash
Following recent removal for '_reference' and '_use_psa' functions we
ended up having 2 very similar test components named
'component_test_psa_crypto_config_accel_hash', one using 'default'
configuration and the other one using the 'full' one.

Let's keep the 'full' configuration version and get rid of the 'default'
case.

Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2026-08-11 16:59:39 +02:00
subotac
f79eac885d Reject overflowing numeric OID components
Signed-off-by: subotac <73706465+subotac@users.noreply.github.com>
2026-08-10 02:38:16 +03:00
Naveed
77343dc0e5 rework handshake length checks per review
ClientHello: narrow the session-id check to the session id itself, check
the cookie length byte before reading it, and let the ciphersuite-list
length check cover both transports.

CertificateRequest: make the signature-algorithms check also reserve the
two certificate-authorities length bytes instead of adding a separate
check, use the available < needed pattern throughout, and reject an
odd-length signature-algorithms list.

Add injected truncated-ClientHello test cases (TLS 1.2-only builds).

Signed-off-by: Naveed <naveed@bugqore.com>
2026-08-07 15:48:03 +05:30
Yi Wu
346ece94cc CMake: support custom base configurations
Signed-off-by: Yi Wu <yi.wu2@arm.com>
2026-08-06 16:21:07 +01:00
Valerio Setti
8a97676cb7 tests: configuration-crypto: remove ssl-opt.sh and compat.sh testing from accel components
'ssl-opt.sh' and 'compat.sh' in accel components were mostly useful back
when the accelerated components were to be compared against the reference
ones to ensure proper test coverage. Now that the reference components
have been removed it doesn't make sense to keep 'ssl-opt.sh' and
'compat.sh' around because they take a lot of simulation time for almost
no benefit. From TLS point of view we can rely on normal 'test_suite_'
testing to be sure that the crypto mechanism works as expected.

Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2026-08-06 14:36:08 +02:00