Add configs to disable unused APIs [full CI]#1000
Conversation
CBMC Results (ML-DSA-65)Full Results (186 proofs)
|
CBMC Results (ML-DSA-44)Full Results (186 proofs)
|
CBMC Results (ML-DSA-87)Full Results (186 proofs)
|
0e7f1ba to
6b89fae
Compare
6b89fae to
69d203c
Compare
54b3c74 to
ec9c236
Compare
d868b27 to
70be886
Compare
9ac9432 to
dff98f0
Compare
|
@hanno-becker : Any chance this can be approved soon? It's been almost 2 months since the first version of these changes and due to the size I need to do a lot of updates when rebasing onto other changes on main. |
hanno-becker
left a comment
There was a problem hiding this comment.
Apologies for the long silence, and thank you very much for all the work on this, @flynd @mkannwischer!
I support the change in principle, but the build + test story needs more work:
- A plain
make testshould work with any valid config -- right now, it doesn't. The existing tests and examples need adjusting to only exercise the API that is enabled in the config. - Testing the reduced configurations through examples introduces test gaps; e.g., we don't exercise them in monobuilds.
ISTM that we should test this through config variations rather than new examples; this would force/solve both issues above.
3be30c0 to
7449c47
Compare
7449c47 to
aff3b9f
Compare
I had a look at the tests and this looks like a big change since the pattern of creating key, signing, and then verifying the signature will no longer work. As I'm not at all familiar with these tests, I don't know how to contribute such a change. Do either of you have the time to help out with this? If not, could you give some clear hints on how the tests should be modified and maybe I can try to figure it out. I did notice though that there were two commits in the stack that could be merged separately so they are now moved to PRs #1029 and #1032. |
bb5eafc to
6109d2d
Compare
42e289b to
1a28863
Compare
|
@flynd @mkannwischer I had a stab at adjusting the tests. Please have a look if you agree with the approach. |
1a28863 to
ef6577f
Compare
Thank you. |
ef6577f to
7acfdb3
Compare
7acfdb3 to
e1492c5
Compare
mkannwischer
left a comment
There was a problem hiding this comment.
Thanks @hanno-becker for adjusting the tests. Looks great to me! Here are a couple of nits. WDYT?
Make it possible to exclude key generation when not needed, together with all internal functions not needed for signature creation or verification. Signed-off-by: Anders Sonmark <Anders.Sonmark@axis.com>
Make it possible to exclude signature creation when not needed, together with all internal functions not needed for key generation or signature verification. Signed-off-by: Anders Sonmark <Anders.Sonmark@axis.com>
Make it possible to exclude signature verification when not needed, together with all internal functions not needed for key generation or signature creation. Signed-off-by: Anders Sonmark <Anders.Sonmark@axis.com>
Make it possible to exclude code only used for signature creation or verification. Signed-off-by: Anders Sonmark <Anders.Sonmark@axis.com>
Make it possible to exclude code only used for key generation or verification. Signed-off-by: Anders Sonmark <Anders.Sonmark@axis.com>
Make it possible to exclude code only used for key generation or signature creation. Signed-off-by: Anders Sonmark <Anders.Sonmark@axis.com>
Make it possible to exclude the wrapper APIs if not needed and build only the internal API functions. Signed-off-by: Anders Sonmark <Anders.Sonmark@axis.com>
… APIs The PCT implementation internally calls crypto_sign_signature() and crypto_sign_verify(), so it is incompatible with MLD_CONFIG_NO_SIGN_API and MLD_CONFIG_NO_VERIFY_API. Signed-off-by: Matthias J. Kannwischer <matthias@zerorisc.com>
The previous tests and examples assumed all APIs (keygen, sign, verify)
were always available: sign tests generated a keypair as setup, verify
tests generated a keypair and signature as setup, and the alloc test
required keygen for every test function. This made them incompatible
with reduced-API configurations where some APIs are disabled via
MLD_CONFIG_NO_KEYPAIR_API, MLD_CONFIG_NO_SIGN_API, or
MLD_CONFIG_NO_VERIFY_API. Additionally, signature test vector
comparisons depended on PRNG state flowing sequentially from keygen
into signing, which broke when PCT (Pairwise Consistency Test) consumed
extra PRNG bytes during keygen.
This commit introduces auto-generated test vectors and refactors all
tests and examples so that each operation (keygen, sign, verify) can
be tested independently using pre-computed test vectors.
scripts/notrandombytes:
- Add Python implementation of the SURF-based deterministic test PRNG,
matching the C version in test/notrandombytes/
- Used by autogen --test-vectors to generate reproducible randomness
for test vector generation
Test vector generation (scripts/autogen --test-vectors):
- Add --test-vectors flag to scripts/autogen that invokes the ACVP
binaries with randomness from scripts/notrandombytes to generate
test/test_vectors/expected_test_vectors.h and the multilevel variant
- Generate pk, sk, sig, sig_extmu, and sig_pre_hash_shake256 vectors
for all three parameter sets (44, 65, 87)
- Include message, context, rnd, and mu in the header so consumers
don't need to hardcode them
- Array dimensions are explicit in the generated header
- Rename all test vector arrays from expected_xxx to test_vector_xxx
- Add --test-vectors-msg and --test-vectors-ctx flags for custom
message/context
Test changes (test_mldsa.c):
- The existing tests (test_sign, test_wrong_pk, etc.) require all
three APIs and are left unchanged, guarded by
!MLD_CONFIG_NO_KEYPAIR_API && !MLD_CONFIG_NO_SIGN_API &&
!MLD_CONFIG_NO_VERIFY_API
- Add test_sign_expected() as a new minimal test that works in
reduced-API configurations: each block (keygen, sign, verify) is
independently guarded and uses test vectors directly, so e.g. the
sign block can run without keygen by using test_vector_sk
- Reset PRNG before each independent test operation so signature
vectors are deterministic regardless of PCT
test_alloc.c and test_rng_fail.c:
- Both files exercise the same 10 API entry points (keygen,
pk_from_sk, sign, sign_combined, signature_extmu,
signature_pre_hash_shake256, verify, verify_extmu,
verify_pre_hash_shake256, open), each independently guarded by
the minimal required API
- Sign tests use test_vector_sk directly (no keygen dependency)
- Verify tests use test_vector_sig/pk/sig_extmu/sig_pre_hash_shake256
directly (no sign or keygen dependency)
- main() uses r |= pattern for error accumulation
Example refactoring:
- Hoist test logic into static example_xxx() functions with
#if/#else/#endif guards and SKIPPED stubs for disabled APIs
- main() is a flat sequence of r |= example_xxx() calls
- Verify moved to independent block (not nested inside sign block)
- example_sign_message requires only sign+verify, not keygen
- Remove redundant duplicate signature verification
- Remove verbose printfs around bare memcmp checks
- Multilevel examples group functions by API guard to reduce
#if/#endif repetition
- basic_deterministic uses test_vector_rnd from the header instead
of hardcoded byte arrays
CI (config-variations):
- Add keygen-sign and keygen-verify test configurations, covering
all 6 combinations of 1 or 2 enabled APIs from {keygen, sign,
verify}
Signed-off-by: Hanno Becker <beckphan@amazon.co.uk>
e1492c5 to
2334ea7
Compare
|
@mkannwischer @flynd Ready to go from my perspective. |
Continuation of #960 by @flynd to run full CI.