Commit Graph

34873 Commits

Author SHA1 Message Date
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
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
Valerio Setti 4eebe42a11 tests: pk_helpers: optimize failure reporting in mbedtls_pk_helpers_populate_context
Keep TEST_EQUAL() on the function that might fail so that if a failure
happen the message will report the actual function that failed.

Documentation of the helper function is also updated.

Signed-off-by: Valerio Setti <vsetti@baylibre.com>
2026-01-14 23:09:35 +01:00
Valerio Setti 2d7c5cb574 tests: pk_helpers: fix outer guard in functions implementation
Signed-off-by: Valerio Setti <vsetti@baylibre.com>
2026-01-14 12:54:37 +01:00
Valerio Setti 43e4dc061d tests: pk_helpers: update documentation
Signed-off-by: Valerio Setti <vsetti@baylibre.com>
2026-01-14 12:54:10 +01:00
Valerio Setti 2b3cc12c01 tests: pk_helpers: let all helper function return an error code
Signed-off-by: Valerio Setti <vsetti@baylibre.com>
2026-01-14 12:53:25 +01:00
Gilles Peskine fceee93024 Add drivers/pqcp/include to C include paths
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-01-12 13:26:25 +01:00
Ronald Cron ebad5b9817 Merge pull request #270 from gilles-peskine-arm/make_generated_files-use_same_python
Use the same Python executable instead of `python`
2026-01-12 12:04:30 +01:00
Gilles Peskine a56534ba79 Use the same Python executable instead of python
`python` might be the wrong version, for example it might be Python 2 on
some systems, or it might be a different version of Python 3. Use
`sys.executable`, so that the same version gets used consistently.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-01-09 20:44:58 +01:00
Gilles Peskine ee399cc257 Merge pull request #245 from gilles-peskine-arm/make_generated_files-fix-check
Fix make_generated_files --check
2026-01-09 10:46:49 +01:00
Minos Galanakis f51cf54fd4 all-core.sh: Allow overriding of the psa-sim location
Signed-off-by: Minos Galanakis <minos.galanakis@arm.com>
2026-01-08 17:46:11 +00:00