Skip to content

Conversation

@sgmenda
Copy link
Contributor

@sgmenda sgmenda commented Dec 8, 2025

Description of changes:

Integrates 9 Wycheproof ML-KEM test vector files:

  • 3 ML-KEM encapsulation test files (mlkem_512_encaps_test, mlkem_768_encaps_test, mlkem_1024_encaps_test)
  • 3 ML-KEM test files (mlkem_512_test, mlkem_768_test, mlkem_1024_test)
  • 3 ML-KEM decapsulation test files (mlkem_512_decaps_test, mlkem_768_decaps_test, mlkem_1024_decaps_test)

Each integration adds upstream JSON vectors and converted txt files to third_party/vectors/, and adds test code with duvet annotations for traceability.

Call-outs:

  • Generated new test vectors: the ML-KEM decapsulation test vectors (mlkem_*_decaps_test) are new, and I opened a PR to upstream Wycheproof: Add ML-KEM decapsulation validation test vectors C2SP/wycheproof#202
  • Missing encaps key import checks: we successfully import ML-KEM encapsulation keys with modulus overflow. This is allowed by FIPS 203, but is not ideal, so the tests print a warning. We will resolve this in an upcoming PR.
  • Missing decaps key import checks: we successfully import ML-KEM decapsulation keys with an inconsistent hash of the embedded encaps key. This is also allowed by FIPS 203, so the tests print a warning, and we will resolve this in an upcoming PR.

Testing:

All new tests pass and duvet verification succeeds:

cd build && ./crypto/crypto_test --gtest_filter="*Wycheproof*"
cd third_party/vectors && python3 sync.py

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license and the ISC license.

### Issues:

Integrating Wycheproof ML-KEM test vectors.

### Description of changes:

Integrates all 6 Wycheproof ML-KEM test vector files:
- 3 ML-KEM encapsulation test files (mlkem_512_encaps_test, mlkem_768_encaps_test, mlkem_1024_encaps_test)
- 3 ML-KEM decapsulation test files (mlkem_512_test, mlkem_768_test, mlkem_1024_test)

Each integration adds upstream JSON vectors and converted txt files to `third_party/vectors/`, and adds test code with duvet annotations for traceability.

### Call-outs:

- We successfully import ML-KEM encapsulation keys with modulus overflow. This is allowed by FIPS 203, but is not ideal, so the tests print a warning.
- Decapsulation tests have only one test case per parameter set. We will add more vectors in follow-up PR.

### Testing:

All new tests pass and duvet verification succeeds:
```bash
cd build && ./crypto/crypto_test --gtest_filter="*Wycheproof*"
cd third_party/vectors && python3 sync.py
```

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license and the ISC license.
@sgmenda sgmenda requested a review from dkostic December 8, 2025 22:43
@sgmenda sgmenda requested a review from a team as a code owner December 8, 2025 22:43
@sgmenda sgmenda self-assigned this Dec 8, 2025
@codecov-commenter
Copy link

codecov-commenter commented Dec 8, 2025

Codecov Report

❌ Patch coverage is 80.48780% with 16 lines in your changes missing coverage. Please review.
✅ Project coverage is 78.27%. Comparing base (3f7f005) to head (e07efea).
⚠️ Report is 4 commits behind head on main.

Files with missing lines Patch % Lines
crypto/evp_extra/p_kem_test.cc 87.67% 9 Missing ⚠️
crypto/test/wycheproof_util.cc 22.22% 7 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2891      +/-   ##
==========================================
- Coverage   78.42%   78.27%   -0.16%     
==========================================
  Files         683      683              
  Lines      117492   117685     +193     
  Branches    16514    16520       +6     
==========================================
- Hits        92142    92113      -29     
- Misses      24460    24684     +224     
+ Partials      890      888       -2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@sgmenda
Copy link
Contributor Author

sgmenda commented Dec 9, 2025

I added some noseed decaps test vectors to see how we handle invalid decaps keys, and similarly to encaps, we successfully import invalid decaps keys, but do not successfully decaps with them. This also seems not-ideal.

justsmth
justsmth previously approved these changes Dec 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants