Commit Graph

34882 Commits

Author SHA1 Message Date
Gilles Peskine f9a7620e5b Create a new directory for non-user-facing scripts
Create a directory for scripts that are useful to maintainers, and may be
invoked as part of the CI, but are not part of the normal build.

These scripts may require a recent Python version and may require additional
third-party modules, unlike user-facing scripts where we try to minimize
requirements.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-02-19 18:24:08 +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
Valerio Setti 4a57bd209d Merge pull request #265 from gilles-peskine-arm/crypto_knowledge-psa_spec_1.4-no_pake
Crypto knowledge: up to PSA Crypto 1.4, XOF test driver
2026-02-16 16:05: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 4857228971 psasim: add XOF operation support
XOF operations are not available on every branch, so their serialization
code needs to be compiled conditionally on the availability of the type.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-02-10 12:21:28 +01:00
Gilles Peskine 2ffd883d80 Driver entry point test code: add XOF support
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-02-09 21:16:28 +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
Gilles Peskine 1e8f77d47c Add elliptic curve FRP256v1
Sample key from
https://www.ietf.org/archive/id/draft-lspm-cose-c509-test-vectors-00.html#name-weierstrass-ec-public-key-with-f

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-02-09 18:04:13 +01:00
Gilles Peskine 000b04968f Indicate the provenance of keys
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-02-09 18:04:13 +01:00
Gilles Peskine c0a8a9cbed Merge pull request #276 from gilles-peskine-arm/psasim-generate-wrappers-dynamically
psasim: generate wrappers dynamically
2026-02-09 17:58:27 +01:00
Gilles Peskine a9bb80e699 Document the psasim build
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-02-09 15:34:29 +01:00
Gilles Peskine 2bc58125fe Add missing dependencies on generated headers
Without those dependencies, the headers don't get generated.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-02-05 22:23:52 +01:00
Gilles Peskine 3a69598ade Clean up psasim/.gitignore
Add generated files that are no longer checked in.

Remove obsolete things (including things now covered at the framework root).

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-02-05 14:03:57 +01:00
Gilles Peskine b6c23e6e01 Remove psasim generated files
The files are now generated during the build. Stop having them in version
control.

As formerly in Mbed TLS, `make clean` doesn't remove
configuration-independent target-independent generated files, but the new
target `make neat` does.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-02-05 13:58:22 +01:00
Gilles Peskine 9dca598383 Add rules to generate wrappers during the psasim build
We don't need to check those generated files into version control.

This fixes the problem that the generated files have precise knowledge of
the functions that exist on whatever branch of TF-PSA-Crypto is consuming
the framework.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-02-05 13:58:22 +01:00
Gilles Peskine 4b0febffa1 psasim: Update generation script instructions for the TF-PSA-Crypto split
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-02-05 13:39:25 +01:00
Gilles Peskine 499dd4322e Update psasim generated files
TF-PSA-Crypto no longer has `psa_can_do_hash()` (except as a temporary stub
to avoid breaking the build of psasim).

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-02-05 13:38:12 +01:00
Gilles Peskine 8ebca51516 Merge pull request #275 from gilles-peskine-arm/mldsa-pqcp-add-driver-framework-return-of-the-psasim
psasim: Read include paths from the TF-PSA-Crypto makefile
2026-01-29 12:39:49 +01:00
Gilles Peskine c5c6dda693 Read include paths from the TF-PSA-Crypto makefile
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-01-27 18:25:25 +01:00
Ronald Cron 042e954d7d make_generated_files.py: Split data from code
Initial work to eventually have the list of
scripts that generate files in the branches
that consume the framework.

Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2026-01-26 15:54:59 +01:00
Ronald Cron c678de61dc tls_handshake_tests.py: Fix expected server log
The TLS 1.2 ClientHello function does not return
at the end in case of parsing error. Thus adapt
the server expected log in case of too small
fragments.

Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2026-01-26 15:53:19 +01:00
Ronald Cron 650159869a tls_handshake_tests.py: Add no-tls12-client-hello-defragmentation-support arg
Add a no-tls12-client-hello-defragmentation-support
argument to specify if TLS 1.2 Client Hello
defragmentation is fully supported or not.
This is temporary while the support is being added
in Mbed TLS development and 3.6 branches.

Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2026-01-23 21:02:16 +01:00
Ronald Cron 5639bf9a69 Make generate_tls_handshake_tests.py a module
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2026-01-23 20:17:13 +01:00
David Horstmann 421f7a29f7 Merge pull request #238 from minosgalanakis/rework/move-psasim
Move psasim into framework
2026-01-23 15:23:09 +00:00
Gilles Peskine b4d205efc4 Merge pull request #273 from gilles-peskine-arm/mldsa-pqcp-add-driver-framework-the-split-strikes-back
Framework support for the pqcp driver, again
2026-01-21 13:49:24 +01:00
Gilles Peskine 84a637899a Add pqcp path when building in mbedtls as well
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-01-20 11:32:01 +01:00
Gilles Peskine 93d94f4b42 c_build_helper: don't hide the compiler output
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-01-20 11:31:45 +01:00
Valerio Setti ece660e1cf Merge pull request #271 from gilles-peskine-arm/mldsa-pqcp-add-driver-framework
Framework support for the pqcp driver
2026-01-19 16:40:28 +01:00
Gilles Peskine 390abf3b39 Fix compatibility with old CMake
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-01-19 12:36:38 +01:00
Gilles Peskine ab1a43e781 check_names: Use the same Python executable instead of python3
Fix build failure in environments where `python3` doesn't exist or is too
old.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-01-19 12:34:34 +01:00
Gilles Peskine 18525876aa check_names: allow pqcp driver to configure mldsa-native
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-01-15 19:31:32 +01:00
Gilles Peskine 0c94e7d164 check_names: Allow mldsa-native symbols to be undeclared
The mldsa-native and mlkem-native headers use preprocessor tricks to
construct identifiers. We can't recognize those. So f a symbol found in the
binary is in the expected sub-namespace for those parts of the library,
allow it to be undeclared.

Make the exception general enough for mldsa-native (needed now) and
mlkem-native (needed soon).

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-01-15 19:31:27 +01:00
Gilles Peskine dd06b4989f check_names: tighten the pattern for internal macros
The pattern for internal macros was weird, in part, because of the unusual
short names we use in bignum code. Make the pattern stricter, but add an
exception mechanism. Declare an exception for those bignum names, but
allow them only in bignum code.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-01-15 19:23:27 +01:00
Gilles Peskine 21007fc2bc check_names: use set, not list, when only testing membership
It's both clearer and faster.

No semantic change.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-01-15 18:09:14 +01:00
Gilles Peskine 2f01eca203 check_names: add type annotations
I needed that to understand how the data is represented (str vs Match, list
vs set vs tuple, ...).

No semantic change.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-01-15 18:09:08 +01:00
Gilles Peskine 8caa0e42ab check_names: Use dedicated class for parse results
Use a typed namespace instead of a dictionary with heterogenously typed values.

No semantic change.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-01-15 18:08:56 +01:00
Gilles Peskine 8b6217bba8 check_names: don't build what we don't need
We only look at symbols in the library, so don't bother building tests.

No semantic change.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-01-15 18:08:46 +01:00
Valerio Setti b392da5c46 Merge pull request #257 from valeriosetti/issue598-framework
[framework] tests: pk: add a common function to create a PSA key out of predefined keys
2026-01-15 16:55:35 +01:00
Valerio Setti c32c5064c0 tests: pk_helpers: fix code style
Signed-off-by: Valerio Setti <vsetti@baylibre.com>
2026-01-15 10:11:37 +01:00
Valerio Setti 73c4f2e5d6 tests: pk_helpers: improve documentation of pk_context_populate_method_t
Signed-off-by: Valerio Setti <vsetti@baylibre.com>
2026-01-14 23:33:50 +01:00