Commit Graph

35082 Commits

Author SHA1 Message Date
Gilles Peskine 30d14d340e Separate ignored from uncovered tests in coverage analysis
For historical reasons, the "ignored" tests in outcome analysis are not
actually ignored: they must not be covered, otherwise the script complains
about an unnecessary exception. In coverage analysis, rename this behavior
to "uncovered", and have "ignored" tests be actually ignored. In driver test
parity analysis, which is now only done in the 3.6 LTS branch, keep the
historical behavior

Consuming branches are currently defining `IGNORED_TESTS` with the
expectation that the test cases must be uncovered. They will need to rename
their definition to `UNCOVERED_TESTS`.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-04-07 10:49:35 +02:00
Gilles Peskine 1404bcbb8e Generalize ignore mechanism to TestCaseSet
Outcome analysis tasks can have "ignored" tests. Both coverage and driver
tasks actually don't ignore "ignored" tests: an "ignored" test must fail the
verification if it wasn't ignored.

In preparation for distinguishing between truly ignored tests and tests that
must be uncovered, generalize the test case lookup mechanism.

No intended behavior change for `CoverageTask` and `DriverVSReference`.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-04-07 10:49:35 +02:00
Gilles Peskine 812aada0a2 Move _has_word_re from Mbed TLS's analyze_outcomes.py
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-03-31 16:35:08 +02:00
Bence Szépkúti dff9da0443 Merge pull request #13 from gilles-peskine-arm/fork-test-helper-valgrind
Fix fork test helper under Valgrind
mbedtls-4.1.0_tf-psa-crypto-1.1.0
2026-03-24 15:12:38 +01:00
Gilles Peskine be3764a69f Work around Valgrind hooking into _exit()
When running tests that use mbedtls_test_fork_run_child() under Valgrind,
bad things happen. Specifically:

* Valgrind reports leaks in the child. Those leaks do exist, but they're
  deliberate since we avoid cleaning up in the child (because we want to
  do as little as possible in the child, and because cleanups such as
  destroying PSA persistent keys would have undesirable effects outside
  the child process).
* Valgrind's overridden `_exit()` doesn't just perform checks, but also for
  some reason it causes the file description on the .datax file to seek
  backwards, causing tests to run again in a loop.

Avoid this by calling `execve()` (via `execlp()`) rather than `_exit()` if
it looks like the test is run under Valgrind. This is safe as long as
Valgrind isn't run with `--trace-children=yes`.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-03-23 19:24:18 +01:00
Gilles Peskine a5b6f6f778 Explain why the child calls _exit() and not exit()
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-03-23 19:24:18 +01:00
Gilles Peskine 3d57272bbc Merge pull request #11 from gilles-peskine-arm/fork-test-helper
Add fork test helper
2026-03-17 21:17:35 +01:00
Gilles Peskine 1a5bf10ca0 Declare platform requirements for test helpers before including any system header
If we rely on `tf_psa_crypto_common.h`, it's too late. And `common.h in 3.6
doesn't have platform requirements.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-03-16 23:45:49 +01:00
Gilles Peskine a2083218c7 Keep exposing the library common.h in test/macros.h
Partially revert "Give test code access to internal macros of the library".
I think that it would be better not to require every user of `test/macros.h`
to have access to the library source, but it's out of scope here.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-03-16 17:47:22 +01:00
Gilles Peskine a55f15580f Avoid a buffer overread if the child reports a wrong length
The child code isn't supposed to cause memory corruption, but if it does,
try to report a problem rather than mess up further.

Adapt the code to report the failure to the parent accordingly. In
particular, we need to make sure that the first byte written to the
reporting pipe is the result code in all cases, so don't jump over the
writing of the result code.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-03-16 15:55:52 +01:00
Gilles Peskine f4677c89d6 Fix null pointer dereference in the child if fdopen fails
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-03-16 15:53:57 +01:00
Gilles Peskine f7df78d3ab Fix reading of child output when it's fragmented
In the success case, we were only reporting the correct data written by the
child if the data was read in a single `read` call.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-03-16 15:53:57 +01:00
Gilles Peskine 96c9dca216 Fix exact-size check on failure in the child
When reading data from the child, if the child reports a failure, the parent
expects the child to write an `mbedtls_test_info_t` structure, no less, no
more. To achieve this, we try reading at least one byte more, and check that
we couldn't read more than the expected size. This commit fixes two bugs:

* On success, don't require the child to fill the output buffer. This check
  was only intended for the failure case, but was accidentally put in the
  wrong place.
* On failure, we weren't checking that the child had written at least the
  expected size, which could have been worse (we'd end up with a
  child_test_info structure that's only partially initialized).

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-03-16 15:53:57 +01:00
Gilles Peskine 0384a5929a Give test code access to internal macros of the library
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-03-16 15:53:57 +01:00
Gilles Peskine dbfd1a6fa9 New test helper mbedtls_test_fork_run_child()
Run some code in a child process. Propagate output from the child if the
test succeeds, and propagate the test result information otherwise.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-03-16 15:53:57 +01:00
Gilles Peskine d1a8b5b596 Merge pull request #289 from gilles-peskine-arm/iar-1.1.0-framework
IAR build fixes before 1.1.0/4.1.0/3.6.6: framework support
2026-03-16 14:48:45 +01:00
Gilles Peskine c3d6599465 Merge pull request #283 from gilles-peskine-arm/audit_validity_dates-move-from-mbedtls
Move some scripts from mbedtls
2026-03-12 09:57:39 +01:00
Gilles Peskine 96b9d674eb Switch off overeager IAR warning
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-03-11 20:11:47 +01:00
Gilles Peskine 4ad123d54f IAR: let test code use stdio FILE functions
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-03-11 20:11:47 +01:00
Gilles Peskine 25c1750beb Sort out inclusions of <test/build_info.h> vs "test_common.h"
Include `"test_common.h"` as the first thing in C files, and
`<test/build_info.h>` as the first thing in header files.

This requires moving `<test/test_common.h>` to its intended location
`"test_common.h"`.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-03-11 20:11:47 +01:00
Gilles Peskine 30d9a6210b Split <test/build_info.h> out of test_common.h
The header `test_common.h` contains two kinds of things:

* Things to do at the beginning of individual C files. Specifically,
  defining macros that notify system headers about what we want from them.
  Keep those in `test_common.h`, which will subsequently be moved out of
  the include directory.
* Things to do at the beginning of every header. In particular, read the
  library configuration. Move them to a new header `build_info.h`,
  which is the only one intended to be included from headers.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-03-11 20:11:47 +01:00
Gilles Peskine c5135a0c47 Add pylint duplicate-code exceptions for newly moved files
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-03-09 10:50:57 +01:00
Gilles Peskine 345b13a2b4 Run pylint and mypy on all files in mbedtls_framework
We were missing `mbedtls_framework/code_wrapper/*.py` because we were not
traversing the directory recursively.

Also improve the comment explaining the duplicate-code workaround for code
that's being moved between files in different repositories.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-03-09 10:50:57 +01:00
Gilles Peskine 95367dbdf1 Remove temporary code from the tf-psa-crypto split
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-03-09 10:50:57 +01:00
Gilles Peskine c77ecf059c Fix or silence minor issues reported by pylint
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-03-09 10:50:57 +01:00
Gilles Peskine d393ebd792 Fix cosmetic issues reported by pylint
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-03-09 10:50:57 +01:00
Gilles Peskine 7bc3cdfd12 Update paths after moving some scripts to the framework
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-03-09 10:50:57 +01:00
Gilles Peskine 72215295d8 Add requirements in the framework for scripts in the framework
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-03-09 10:50:57 +01:00
Gilles Peskine 731ff38bf9 Merge remote-tracking branch 'main' into audit_validity_dates-move-from-mbedtls 2026-03-09 10:50:00 +01:00
Valerio Setti 9b92164c47 Merge pull request #280 from ronald-cron-arm/tf-psa-crypto-reorg-prep
Prepare for TF-PSA-Crypto repository reorganization
2026-03-07 14:07:50 +01:00
Gilles Peskine 08e8a79146 Merge pull request #286 from gilles-peskine-arm/psasim-serialize-unsigned-int
psasim serialize: Support a few more standard C types
2026-03-05 22:11:12 +01:00
Gilles Peskine 0058f4c4cb psasim serialize: Support a few more standard C types
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-03-05 10:59:26 +01:00
Gilles Peskine 7dffa3505a Merge branch 'tmp-branch-move-files-to-framework' into audit_validity_dates-move-from-mbedtls 2026-03-03 13:37:11 +01:00
Gilles Peskine 7e011cca07 Move some scripts from mbedtls into the framework
Move a bunch of files from `scripts` and `mbedtls/scripts` to the framework.

The following files will be added (moved from Mbed TLS `development`):

* `scripts/ecp_comb_table.py`
* `scripts/massif_max.pl`
* `tests/scripts/audit-validity-dates.py` (moved to `scripts/`)
* `tests/scripts/gen_ctr_drbg.pl` (moved to `scripts/`)
* `tests/scripts/gen_gcm_decrypt.pl` (moved to `scripts/`)
* `tests/scripts/gen_gcm_encrypt.pl` (moved to `scripts/`)
* `tests/scripts/gen_pkcs1_v21_sign_verify.pl` (moved to `scripts/`)
* `tests/scripts/generate-afl-tests.sh` (moved to `scripts/`)
* `tests/scripts/generate_server9_bad_saltlen.py` (moved to `scripts/`)
* `tests/scripts/run-metatests.sh` (moved to `scripts/`)
* `tests/scripts/run_demos.py` (moved to `scripts/`)
* `tests/scripts/test_config_script.py` (moved to `scripts/`)

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-03-03 13:36:26 +01:00
Valerio Setti e07b6643e8 Merge pull request #278 from gilles-peskine-arm/generate_mldsa_tests-create
Support committed generated test data and generate PQCP test data
2026-02-27 11:12:44 +01:00
Gilles Peskine 0879d0c806 Merge pull request #279 from gilles-peskine-arm/unix-detection-202601-framework
Simplify platform requirements before 1.1/4.1: framework support
2026-02-26 19:10:22 +01:00
Bence Szépkúti c2cb8565a5 Merge pull request #10607 from gilles-peskine-arm/timing-use-mstime
Simplify MBEDTLS_TIMING_C to use mbedtls_ms_time()
2026-02-26 14:38:50 +00:00
Gilles Peskine d1bb3a61a5 dilithium_py reproducible output requires pycryptodome
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-02-25 21:12:46 +01:00
Gilles Peskine d6dce9b3f8 Make the output deterministic
Tests using randomized signatures were currently randomized. We need the
output of the script to be reproducible, so this won't do.

Force randomized signatures to use a specific RNG which is reset before
constructing each test case. This way, the script's output is reproducible.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-02-25 19:02:22 +01:00
Gilles Peskine 3ddf7bc717 Fix verify test cases not having a randomized signature
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-02-24 16:06:11 +01:00
Janos Follath 9394d25048 Merge pull request #10584 from davidhorstmann-arm/add-link-to-crypto-security-md
Add link to TF-PSA-Crypto `SECURITY.md`
2026-02-24 08:36:39 +00:00
Ronald Cron 25db08b18b check-doxy-blocks.pl: Add dispatch, extras, platform and utilities directories
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2026-02-23 10:23:01 +01:00
Valerio Setti b41c8f6e04 Merge pull request #10608 from bjwtaylor/DriverVsReference_removal
Remove DriverVsReference tasks from analyze_outcomes.py
2026-02-23 09:01:25 +00:00
Ronald Cron 055618425f check_names.py: Add dispatch, extras, platform and utilities directories
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2026-02-23 08:17:50 +01:00
Bence Szépkúti bbf8bbbdb6 Merge pull request #10575 from ronald-cron-arm/dtls-client-hello-defragmentation-prep
Some preparatory work for DTLS client hello defragmentation
2026-02-22 23:30:39 +00:00
Gilles Peskine bd6dfd6d8a Fix check_names complaints about *_platform_requirements.h
Platform requirement headers are expected to define macro names
outside of our namespace.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-02-21 21:45:27 +01:00
Gilles Peskine b2eb76d575 Revert "Fix check_names complaints about *_platform_requirements.h"
This reverts commit 5452c7747b.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-02-21 21:45:20 +01:00
Gilles Peskine 99c4159681 Disable Unix-like integration code in baremetal builds in all.sh
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-02-21 21:20:36 +01:00
Gilles Peskine f004998303 Add issue number
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-02-21 21:20:34 +01:00
Gilles Peskine 6d5987a954 Include <test/test_common.h> first in test code
This lets us define things that we want to have everywhere in test code. In
particular, this lets us define platform-specific symbols that influence
what system headers declare. This also takes care of including the library
configuration.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-02-20 21:46:11 +01:00