2349 Commits

Author SHA1 Message Date
Ben Taylor 40e07ca2d8 Remove unused import
Signed-off-by: Ben Taylor <ben.taylor@linaro.org>
2026-05-06 11:52:28 +01:00
Gilles Peskine c6610dde67 Merge pull request #282 from gilles-peskine-arm/mldsa-pqcp-driver-framework
Generate MLDSA test cases for the driver and dispatch layers
2026-04-08 15:50:19 +02:00
Gilles Peskine 8e06778bc8 Minor clarification
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-04-07 16:19:20 +02:00
Gilles Peskine 541289c9cb Copyediting
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-04-07 16:19:09 +02:00
Gilles Peskine 80a0ea93f0 Support extending a TestCaseSet
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-04-07 10:49:35 +02:00
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
Gilles Peskine ab001120d6 Exclude maintainer scripts from Python checks
Maintainer scripts may require a more recent Python than the version we
currently use for Python checks (3.6).

https://github.com/Mbed-TLS/mbedtls-framework/issues/293

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-03-31 16:01:03 +02:00
Gilles Peskine 7f537471bd Clean up overly complicated typing in read_file_lines
The `read_file_lines` context manager supported either text or binary
streams, based on a parameter passed to the constructor. But the type
annotation on the iterator claimed that all lines were text. The version of
mypy that we use on the CI was happy with that, but modern versions are not.

The advantage of `read_file_lines` over built-in functions is better
tracking of line numbers. We never took advantage of this in our code with
binary streams. Change the one place where `read_file_lines` was used with a
binary stream to use built-in functions instead, and specialize
`read_file_lines` to text streams.

This fixes a legitimate complaint of modern mypy on `macro_collectory.py`.

There was no runtime bug: the behavior was correct, only the type
annotations were wrong.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-03-31 15:19:41 +02: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 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
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
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
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 4f3a21f40d Stop using MBEDTLS_PRINTF_SIZET
Since Mbed TLS 3.6.0, all officially supported versions of Visual Studio
a printf function family that is sufficiently compliant to C99 for our
purposes, in particular supporting `%zu` for `size_t`. The only platform
without `%zu` that we semi-officially support is older versions of MinGW,
still used in our CI. MinGW provides either a Windows legacy printf or a
standards-compliant printf depending on the value of
`__USE_MINGW_ANSI_STDIO` when compiling each C file. Force the use of the
compliant version. Don't rely on `MBEDTLS_PRINTF_SIZET`, which is defined in
`<mbedtls/debug.h>` and no longer considers the Windows legacy version in
Mbed TLS >= 4.1.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-02-20 20:31:56 +01:00
Gilles Peskine d85217d8f5 Support test data generators in generate_files_helper.py
Support check and always-update mode. Update-if-needed mode falls back to
always-update mode because test_data_generation.py doesn't support
update-if-needed.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-02-19 18:24:08 +01:00
Gilles Peskine 2fe235d289 Test data generators: add --list-outdated option
As part of a long-term unification effort of generation scripts, add an
option for test generators to list oudated targets without writing to files.
This corresponds to functionality that the new generate_files_helper module
offers.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-02-19 18:24:08 +01:00
Gilles Peskine 151585f1a1 New utility Python module: generate_files_helper
A new utility to give a common interface to committed generated files.

For the time being, this module is only intended for committed generated
files, and `make_generated_files_common.py` is only intended for non-committed
generated files. The two may be unified at some point in the future.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-02-19 18:24:08 +01:00
Gilles Peskine 5452c7747b 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-19 17:18:03 +01:00
Gilles Peskine 67538f61bc Remove an unused method
`TextChangelogFormat.version_title_text` never worked: it's missing a
parameter in the call to `re.sub`. Fortunately it's unused, so just remove it.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-02-19 12:34:35 +01:00
Gilles Peskine 316ec76508 Modernize usage of re.sub deprecated in Python 3.13
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-02-18 20:10:40 +01:00
Ronald Cron 1b5a0b1877 Add branch specific generate_tls_handshake_tests.py file
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2026-02-18 13:02:26 +01:00
Ronald Cron 57b29c2fe5 Introduce branch specific make_generated_files.py
Introduce branch specific make_generated_files.py
and use it in the development branch.

Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2026-02-18 13:02:26 +01:00
Ronald Cron 8ed11c99fe Merge pull request #274 from ronald-cron-arm/dtls-client-hello-defragmentation-prep
Some preparatory work for DTLS client hello defragmentation
2026-02-16 17:48:56 +01:00
Gilles Peskine c99fb5762d Fix SM3 hash length (bits/bytes confusion)
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-02-16 11:07:24 +01:00
Gilles Peskine 05d8c71202 Don't treat --help as an error
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-02-10 14:52:21 +01:00
Gilles Peskine 4cce03530a Remove unused variable
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-02-10 14:52:16 +01:00
Gilles Peskine 4484c52f9a Support test_suite_psa_crypto_metadata functions for new algorithm categories
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-02-09 18:04:13 +01:00
Gilles Peskine 567f89ade9 Remain compatible with generate_psa_constants.py which is outside the framework
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-02-09 18:04:13 +01:00
Gilles Peskine 43a6e55ece Match field names to algorithm category names
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-02-09 18:04:13 +01:00
Gilles Peskine d60e412a2d generate_test_keys.py: Support ML-DSA, ML-KEM and SLH-DSA keys
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-02-09 18:04:13 +01:00
Gilles Peskine dec6c51f7d Add sample keys for ML-DSA, ML-KEM and SLH-DSA
Use NIST test vectors. I copied the first test case for each parameter set.
For ML-KEM and ML-DSA, I did it manually. For SLH-DSA, I used the following
Python script:

```
<gen-val/json-files/SLH-DSA-keyGen-FIPS205/internalProjection.json python -c '
import json, re, sys
data = json.load(sys.stdin)
types = {family: {} for family in ["SHA2_F", "SHA2_S", "SHAKE_F", "SHAKE_S"]}
for group in data["testGroups"]:
  t = group["tests"][0]
  m = re.match(r"SLH-DSA-(\w+)-([0-9]+)(\w+)", group["parameterSet"])
  type = m.group(1) + "_" + m.group(3).upper()
  size = m.group(2)
  prv = t["skSeed"] + t["skPrf"] + t["pkSeed"] + t["pk"]
  pub = t["pkSeed"] + t["pk"]
  types[type][size] = (prv, pub)
for type in sorted(types.keys()):
  print("")
  print(f"    # https://github.com/usnistgov/ACVP-Server/blob/v1.1.0.41/gen-val/json-files/SLH-DSA-keyGen-FIPS205/internalProjection.json")
  print(f"    \x27SLH_DSA(PSA_SLH_FAMILY_{type})\x27: {{")
  for size in sorted(types[type].keys()):
    entry = types[type][size]
    print(f"        {size}: (\"{entry[0]}\",")
    print(f"              \"{entry[1]}\"),")
  print(f"    }},")
'
```

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-02-09 18:04:13 +01:00
Gilles Peskine 87e3988537 Add all algorithms from PSA Crypto 1.4 PQC extension
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-02-09 18:04:13 +01:00
Gilles Peskine 4c54ebd97d OpFail: only consider categories in which at least one algorithm is supported
Addresses https://github.com/Mbed-TLS/mbedtls-framework/issues/264
but perhaps not in the best way.

Keep an exception for PAKE, for which we already have algorithm
support (`PSA_ALG_JPAKE`) but no `pake_fail` function.
https://github.com/Mbed-TLS/mbedtls-framework/issues/263

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-02-09 18:04:13 +01:00
Gilles Peskine 987737675a OpFail generator: pre-compute the lists of categories and algorithms
No behavior change.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-02-09 18:04:13 +01:00
Gilles Peskine 29697c90ff Support new destructor in PSA Crypto API 1.4
Recognize `PSA_ALG_SIGN_SUPPORTS_CONTEXT` as a destructor.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-02-09 18:04:13 +01:00
Gilles Peskine 1ef0e676bf Add all mechanisms up to PSA Crypto API 1.4
Define the necessary new categories (key wrap, key encapsulation, XOF).

This completes the list of mechanisms in the PSA Crypto API version 1.4,
except for PAKE that are more challenging (family parametrization, need to
find sample keys in `asymmetric_key_data.py`), and except for the PQC
extension.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-02-09 18:04:13 +01:00
Gilles Peskine e9f66f7ec2 Add DH family RFC3526
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-02-09 18:04:13 +01:00