Commit Graph

16 Commits

Author SHA1 Message Date
Gilles Peskine 88cfd0cf47 Improve the construction of inputs to multipart APIs
Fix a bug whereby the chunks did not actually have the desired lengths.

Make the message content depend only on its length, and not how it is split
into chunks. This way, it'll be easier to notice and analyze bugs that cause
different outputs for different ways to split the input.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-04-23 15:43:05 +02:00
Gilles Peskine ffc707d4f6 Support generating multipart tests for driver and dispatch
Not done by default for smooth transition in the consuming TF-PSA-Crypto
branch. It's up to the calling script `generate_mldsa_tests.py` to
enable the new test cases.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-04-20 15:18:41 +02:00
Gilles Peskine f8d36c84ac Speed up generation by caching signatures
We tend to generate the signature of the same message under the same keys
multiple times for different APIs (sign/verify, driver/dispatch, ...).
Caching results makes the script noticeably faster.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-04-20 10:13:21 +02:00
Gilles Peskine dcf227c5b9 Generate MLDSA test cases for the driver dispatch layer
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-03-31 16:01:03 +02:00
Gilles Peskine 4a58f90329 Generate MLDSA test cases for the driver entry points
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-03-31 16:01:03 +02:00
Gilles Peskine 6466dc62c3 Make mbedtls_maintainer a Python package
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-03-31 15:19:41 +02:00
Gilles Peskine 85a47fc277 mldsa_test_generator refactor: new methods gen_key_management, gen_all
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-03-31 15:19:41 +02:00
Gilles Peskine a53c51425d mldsa_test_generator refactor: change function calls to method calls
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-03-31 15:19:41 +02:00
Gilles Peskine 38d9d83ae7 mldsa_test_generator refactor: extend API class to Generator
Turn functions that generate test cases into methods of the generator class.
Functions that used to take an API argument are now implemented in the
generic class, and API-specific functions are now methods of the
corresponding API-specific concrete class.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-03-31 15:19:41 +02:00
Gilles Peskine 31bae441f6 mldsa_test_generator refactor: preliminary rearrangement
Move code around, to make subsequent diffs easier to review.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-03-31 15:19:41 +02:00
Gilles Peskine 72f178bdbd Move most of generate_mldsa_tests.py into a module
We are moving the command line entry point to the consuming branch.

The move will be completed when the consuming branch no longer needs the
script to exist in the framework.
https://github.com/Mbed-TLS/mbedtls-framework/issues/294

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-03-31 15:19:41 +02: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
Gilles Peskine c88127f488 ML-DSA test case generator
Generate some basic test cases for the mldsa-native functions.

Uses `dilithium_py` from https://github.com/GiacomoPope/dilithium-py
(`pip install dilithium-py`), which requires Python >=3.9.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-02-19 18:24:08 +01:00
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