-
Notifications
You must be signed in to change notification settings - Fork 155
ML-DSA: Missing Private Key Validation Checks #2874
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
CI seems to not love that I am referencing internal functions: https://github.com/aws/aws-lc/actions/runs/19872727434/job/56952394758?pr=2874 So lemme think on it, maybe I should hardcode the vectors instead of generating them inside the test. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2874 +/- ##
==========================================
- Coverage 78.24% 78.22% -0.02%
==========================================
Files 683 684 +1
Lines 117388 117428 +40
Branches 16497 16501 +4
==========================================
+ Hits 91853 91862 +9
- Misses 24649 24680 +31
Partials 886 886 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
jakemas
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR will need to made in https://github.com/pq-code-package/mldsa-native not here in aws-lc. The process for working on ml-dsa code is to develop in mldsa-native and use the importer. This can be added upstream now, and once #2849 is merged, we can run the "importer" to update the code -- as with ml-kem.
|
@jakemas oops, good catch, I forgot about that. I'll make an upstream PR for the mldsa changes, and hold off on adding the test till it we merge those changes into LC. |
|
the mldsa-native code is not imported to aws-lc yet afaik, so we do need to make this change in aws-lc. |
|
@dkostic the argument is that since the mldsa-native import PR is in-flight as #2849, we can land this on top of that, instead of creating unnecessary merge conflicts and test failures for that PR. Since the severity is low and fix upstream is not going to be too bad (see pq-code-package/mldsa-native#714 which describes the function that we are going to add the bounds check to), I agree with @jakemas. Re proofs: these are the |
I cherrypicked the new tests onto @jakemas's #2849 and the tests all pass locally without any changes. 🎉 Likely because of the above So, I will continue to hold this PR till that lands. Then, we can add these tests on top of it and run it on CI to see if we need to make any changes to upstream. |
These tests are expected to fail till aws#2874 is resolved
Issue:
EVP_PKEY_pqdsa_new_raw_private_key()accepts malformed keys with secret vectorss1ands2containing coefficients outside the valid range[-η, η]. These keys lead to undefined behavior, like producing signatures that fail verification.Description of changes:
Adds the missing validation checks to
ml_dsa_pack_pk_from_sk()incrypto/fipsmodule/ml_dsa/ml_dsa_ref/packing.c. It now rejects keys ifs1ors2have coefficients exceeding[-η, η].Call-outs:
Testing:
crypto/fipsmodule/ml_dsa/make_corrupted_key_tests.cccrypto/evp_extra/mldsa_corrupted_key_tests.txtcrypto/evp_extra/mldsa_test.ccthat uses these test vectorsTo run the test:
To (re-)generate the test vectors:
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.