Commit Graph

12020 Commits

Author SHA1 Message Date
Manuel Pégourié-Gonnard
5cce3c8a75 Add comment in raw key agreement test function
Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2026-03-05 12:56:35 +01:00
Manuel Pégourié-Gonnard
fb70b7f849 FFDH: test with key derivation and bad peer key
Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2026-03-05 12:53:19 +01:00
Manuel Pégourié-Gonnard
118dc8c347 DH: clean up test function key_agreement_setup()
See the comment that was there. I chose not to split the test function
in two, but just have two arguments for each expected status.

Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2026-03-05 12:53:03 +01:00
Manuel Pégourié-Gonnard
7644b0d9e5 FFDH: Add tests for invalid peer key
Failing right now, will fix the library in the next commit.

For 8192-bit, we don't have any positive test, because we have a stupid
line length limitation [1] and we can't fit both our key, the peer's
key, and the output. But for negative tests we don't need the output and
the rest fits, so let's have those.

[1] https://github.com/Mbed-TLS/mbedtls/issues/1866

Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2026-03-05 12:32:18 +01:00
Manuel Pégourié-Gonnard
0c5accb716 DH: Update title in test data
The function is testing both psa_raw_key_agreement() and
psa_key_agreement().

Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2026-03-05 12:32:06 +01:00
Manuel Pégourié-Gonnard
0b91bdea2e DH: update name of test function
Aligning on the name in development, which is also acceptable for 3.6,
and should reduce conflicts when backporting.

Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2026-03-05 12:31:09 +01:00
Manuel Pégourié-Gonnard
51bae4b813 DH: add expected_status to key_agreement test func
Also, while at it, add a test for input buffer too small. This had been
added previously in development but not backported.

Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2026-03-05 12:16:04 +01:00
Gilles Peskine
685a1ce6f4 Merge remote-tracking branch 'mbedtls-3.6' into merge-3.6-restricted-20260304 2026-03-04 14:39:06 +01:00
Bence Szépkúti
1937efdd94 Merge pull request #10615 from gilles-peskine-arm/generate-psa_test_wrappers-3.6
Backport 3.6: generate psa test wrappers
2026-02-26 13:44:15 +00:00
Gilles Peskine
d841a6a782 Generate psa_test_wrappers.{h,c} automatically
This is not only convenient, but now necessary, because if the content of
the generated files changes due to changes in Python files in the framework,
`all.sh check_generated_files` will fail in the framework CI.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-02-22 20:33:27 +01:00
Ronald Cron
d8b97c6a28 ssl-opt.sh: Revert leftover debug level increase
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2026-02-18 14:41:57 +01:00
Ronald Cron
3b6bd65334 ssl_msg.c: Improve handshake message fragmenting message
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2026-02-18 14:41:57 +01:00
Ronald Cron
8e68a06bdf ssl-opt.sh: Improve DTLS proxy 3d tests
Improve DTLS proxy 3d tests with OpenSSL and
GnuTLS servers. Have a better control of which
message is fragmented and verify it is the
case.

Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2026-02-18 14:41:57 +01:00
Ronald Cron
98b3ef2e43 ssl-opt.sh: Improve DTLS reassembly tests
Improve DTLS reassembly tests with OpenSSL
and GnuTLS server. Check that some messages
have been reassembled.

Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2026-02-18 14:41:56 +01:00
Ronald Cron
87871ddf30 ssl-opt.sh: Remove DTLS reassembly redundant test
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2026-02-18 14:41:56 +01:00
Ronald Cron
0b4cb31fb6 ssl-opt.sh: Remove CH reassembly unsupported test
We are about to have full support for TLS 1.2
CH reassembly on server side. The equivalent
positive test would be a duplicate of one of
the tests generated by generate_tls_handshake_tests.py.
Thus just removing the negative test.

Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2026-02-18 14:41:56 +01:00
Ronald Cron
a02505a7be ssl_msg.c: Improve HS message reassembly completed message
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2026-02-18 14:41:56 +01:00
Ronald Cron
373e08939f Add branch specific generate_tls_handshake_tests.py file
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2026-02-17 10:10:34 +01:00
David Horstmann
7c2f728178 Merge pull request #1429 from yanesca/1427_buffer_underflow-backport-3.6
Fix buffer underflow in `x509_inet_pton_ipv6()` [3.6 backport]
2026-02-16 11:58:38 +00:00
Manuel Pégourié-Gonnard
6617ab467f pkwrite: tests: make helper more robust
Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2026-02-10 11:34:00 +01:00
Manuel Pégourié-Gonnard
56503ba340 pkwrite: tests: test that DER writes at the end
Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2026-02-10 11:24:05 +01:00
Manuel Pégourié-Gonnard
533a806405 pkwrite: test: factor common part into helper func
Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2026-02-10 11:18:24 +01:00
Valerio Setti
2b2f430fcd tests: scripts: adapt test_tf_psa_crypto_optimized_alignment to 3.6
Move from CMake to Make

Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2026-01-28 00:18:09 +01:00
Valerio Setti
10193b37e3 tests: scripts: add new component to test alignment with GCC O3 optizations
This is meant to test a bug found on:
- Little endian platforms other than x86 or ARM (these have specific
  optimizations available);
- GCC versions from 10 to 14.2 (below and above are fine);
- Optimization level "-O3" (lower levels are fine).

Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2026-01-28 00:07:44 +01:00
Gilles Peskine
ccf280d158 Add a few more test cases for printf formats
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-01-26 17:49:05 +01:00
Janos Follath
763a0cfd15 inet_pton: help ASan find the underflow
The generated unit tests have the input parameters in large stack
buffers and therefore ASan doesn't notice under or overflows in them.
Copy the input parameter into a locally allocated buffer to trigger ASan
if something goes wrong.

Signed-off-by: Janos Follath <janos.follath@arm.com>
2026-01-20 18:19:33 +00:00
Valerio Setti
8102fe3b0f tests: suite_psa_crypto_persistent_key: fix load_primed_storage
Do not remove keys that belong to the reserved range.

Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2025-11-03 11:07:04 +01:00
Valerio Setti
cbc6bc56b1 tests: suite_psa_crypto_persistent_key: fix test data for 3.6 branch
Previous tests were backported from tf-psa-crypto and they work fine there.
However the library implementation is not the same between 3.6 and
tf-psa-crypto: in 3.6 we only prevent loading of persistent keys if their
ID is within the volatile range, but the built-in one is still allowed.
Therefore this commit fix expected return values for the 3.6 branch
when built-in keys are accessed.

Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2025-10-31 12:37:09 +01:00
Gilles Peskine
0e59579358 Test with bad data in storage: support existing built-in or volatile key
When testing what happens with when accessing a key ID in the built-in or
volatile range and a file exists in storage, we were skipping the test case
when the key existed. When the volatile or built-in key exists, the
expectations on the test case are wrong, but the test case is still useful:
we should ensure that the existence of the file doesn't somehow prevent
access to the built-in or volatile key. So, instead of skipping, change the
test assertions on the fly to ensure that we are accessing the existing key.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-10-29 23:10:00 +01:00
Valerio Setti
e2b0e94592 tests: suite_psa_crypto_persistent: fix formatting
Signed-off-by: Valerio Setti <vsetti@baylibre.com>
2025-10-29 23:10:00 +01:00
Gilles Peskine
32dbf968c8 Test with bad data in storage: key IDs
Test what happens when the application tries to access a key and the storage
contains something invalid: either a corrupted file, or a key ID that's
outside the standard range for persistent keys.

Coverage of APIs in this commit:

* `psa_get_key_attributes()` (generally as a proxy for any key access);
* `psa_export_key()` (minor, but does provide some coverage of what happens
  if only the key material is corrupted);
* `psa_destroy_key()`, which hopefully should work even for a corrupted file.

Coverage of key IDs in this commit:

* Key IDs in various ranges: user (i.e. the normal range for persistent
  keys), builtin, volatile, reserved file ID, none of the above.
* Includes coverage for nonzero owner ID.

No coverage of corrupted files in this commit.

Assert the behavior that I think is the right thing. Subsequent commits will
reconcile the library behavior with the code as needed.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-10-29 23:09:59 +01:00
Gilles Peskine
3e5d0c1202 Test key identifier ranges
Add some assertions on the various ranges of key identifiers to ensure that
they're disjoint and they comply with documented guarantees.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-10-29 23:07:11 +01:00
Minos Galanakis
ddffba970b Revert "Added generated files"
This reverts commit 335197e60c.

Signed-off-by: Minos Galanakis <minos.galanakis@arm.com>
2025-10-22 10:51:01 +01:00
Janos Follath
be0cef43ea Add ASan to test_sw_inet_pton
Signed-off-by: Janos Follath <janos.follath@arm.com>
2025-10-13 14:11:26 +01:00
Minos Galanakis
335197e60c Added generated files
Signed-off-by: Minos Galanakis <minos.galanakis@arm.com>
2025-10-10 18:04:55 +01:00
Minos Galanakis
ad63800090 Version bump for mbedtls-3.5.6
./scripts/bump_version.sh --version 3.6.5

Signed-off-by: Minos Galanakis <minos.galanakis@arm.com>
2025-10-10 18:04:55 +01:00
Gilles Peskine
7e81fe32d0 Add storage format test case for JPAKE
The storage test generator doesn't support JPAKE at this time. So write a
test case manually.

The key is not exercised, since `psa_exercise_key()` doesn't support PAKE at
this time. But at least we can use this test case to ensure that we know how
the key is represented in storage.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
(cherry picked from commit 98a4029d51)
Signed-off-by: Minos Galanakis <minos.galanakis@arm.com>
2025-10-10 18:04:55 +01:00
Janos Follath
db3e6ebebe Add malicious ip test for inet_pton
Signed-off-by: Janos Follath <janos.follath@arm.com>
2025-10-02 16:11:10 +01:00
Gilles Peskine
334dfa8799 Merge remote-tracking branch '3.6' into restricted-3.6-merge-public-20250916
Conflicts:

* `framework`: update submodule to the merge of `main` and `main-restricted`.
2025-09-16 16:16:53 +02:00
Janos Follath
753036edb3 Merge pull request #10336 from gilles-peskine-arm/generated-files-lib-build-3.6
Backport 3.6: fix `make lib GEN_FILES=` sometimes requiring python
2025-09-12 13:27:26 +00:00
Manuel Pégourié-Gonnard
3e59e0ae08 Merge pull request #1411 from mpg/bypass-wrappers
[3.6] Bypass GCD/modinv wrappers when possible
2025-09-11 12:25:23 +02:00
Gilles Peskine
d3e182e7da Add BUFFER_TOO_SMALL testing
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-09-08 12:22:39 +02:00
Gilles Peskine
b6b1a8299b Factor API calls into auxiliary functions
Factor some common code for one-shot or multipart encryption/decryption into
auxiliary functions. No behavior change.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-09-08 12:22:39 +02:00
Gilles Peskine
bba5d7c439 Add constant-time AES-CBC encrypt and decrypt tests through PSA
The main goal is to validate that unpadding is constant-time, including
error reporting.

Use a separate test function, not annotations in the existing function, so
that the functional tests can run on any platform, and we know from test
outcomes where we have run the constant-time tests.

The tests can only be actually constant-time if AES is constant time, since
AES computations are part of what is checked. Thus this requires
hardware-accelerated AES. We can't run our AESNI (or AESCE?) code under
Msan (it doesn't detect when memory is written from assembly code), so these
tests can only be run with Valgrind.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-09-08 12:22:39 +02:00
Gilles Peskine
9d7d0e63ae Merge pull request #1407 from gilles-peskine-arm/mbedtls_cipher_finish_padded-3.6
Backport 3.6: Introduce mbedtls_cipher_finish_padded
2025-09-08 12:18:50 +02:00
Gilles Peskine
56c4dc12b8 Single-threaded test of nominal mutex usage
No negative tests since all forbidden usage has undefined behavior.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-09-01 00:28:15 +02:00
Gilles Peskine
c2e9dac28f Expand on why and how we bypass the quiet wrapper
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-08-29 13:23:33 +02:00
Gilles Peskine
44765c4b9b Test invalid_padding against all-bits-one
`SIZE_MAX` and `~(size_t) 0` are the same, but since the documentation says
"all-bits-one", write it that way in the test code.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-08-26 13:14:22 +02:00
Gilles Peskine
94e4e15748 Explain the near-duplication of test function for constant-flow tests
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-08-25 16:56:44 +02:00
Manuel Pégourié-Gonnard
f35d30799c ECP: use CT modinv
A function that was previously called in multiple places is now called
only once, hence more susceptible to being inlined, hence the test fix.

Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2025-08-14 09:18:52 +02:00