feat(ml-kem): add zeroize support and tests#1332
feat(ml-kem): add zeroize support and tests#1332rainmitch wants to merge 1 commit intocryspen:mainfrom
Conversation
d2bb7f8 to
b99428c
Compare
|
Just a heads-up. I've also successfully applied this same hardening pattern to the ML-DSA module locally. I'll open a separate PR for that one if these changes are wanted and once I have feedback on this PR and on your preferences. |
|
Thank you for the effort on this! |
|
Sorry, I did not get to it last week. Will update here soon. |
|
This PR has been marked as stale due to a lack of activity for 60 days. If you believe this pull request is still relevant, please provide an update or comment to keep it open. Otherwise, it will be closed in 7 days. |
|
This PR has been closed due to a lack of activity since being marked as stale. If you believe this pull request is still relevant, please reopen it with an update or comment. |
|
Re-opening for consideration in light of #1390. |
Description:
This PR introduces memory hardening for ML-KEM secret keys by implementing the Zeroize and ZeroizeOnDrop traits. The goal is to ensure sensitive key material is securely wiped from memory when it goes out of scope. This facilitates FIPS 140-3 compliance (AS05.10) regarding the zeroization of plaintext secret keys.
Scope:
This implementation focuses on the secret-holding structs and their underlying vector types. It does not modify the underlying core logic or seed inputs (which very likely needs more work to fully implement zeroize). I believe this covers all primary secret-holding structs in a non-intrusive way required for memory hardening.
This is implemented as an optional feature that requires being enabled.
Changes:
I have implemented Zeroize for the following types:
I have implemented ZeroizeOnDrop for the following types:
Technical Verification:
To ensure the security features are not optimized away by the compiler, I performed the following checks:
Assembly Audit:
Performance:
Benchmarks show a negligible performance impact (performed on a Ryzen 5 7430u):
Closing Notes:
Note: I am not a security programmer or researcher. I have tried to implement this to the best of my abilities, verifying the assembly output to ensure the compiler respects the zeroing instructions. I really like libcrux and wanted to use it for a project, but also need zeroize functionality, so I worked to try to implement it. I have tried to do my due diligence in checking and design. I would very much appreciate someone double checking my work, especially as this is my first contribution to a project. But I believe that this works.
I would greatly appreciate feedback and comments on anything that needs to be changed.