Skip to content
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

ML-KEM FIPS 203 destruction of intermediate values #1883

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

dkostic
Copy link
Contributor

@dkostic dkostic commented Sep 26, 2024

Issues:

CryptoAlg-2616

Description of changes:

FIPS 203 Section 3.3 requires destruction of intermediate values.
AWS-LC ML-KEM implementation allocates intermediate values
only on stack, so this destruction seems a bit silly, but we do it
anyway for compliance.

Call-outs:

Point out areas that need special attention or support during the review process. Discuss architecture or design changes.

Testing:

How is this change tested (unit tests, fuzz tests, etc.)? Are there any testing steps to be verified by the reviewer?

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.

@dkostic dkostic requested a review from a team as a code owner September 26, 2024 22:37
@codecov-commenter
Copy link

codecov-commenter commented Sep 26, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 78.49%. Comparing base (36e0307) to head (db0a771).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1883      +/-   ##
==========================================
- Coverage   78.50%   78.49%   -0.02%     
==========================================
  Files         585      585              
  Lines       99516    99543      +27     
  Branches    14244    14242       -2     
==========================================
+ Hits        78122    78133      +11     
- Misses      20759    20777      +18     
+ Partials      635      633       -2     

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

@@ -190,6 +190,9 @@ void gen_matrix(ml_kem_params *params, polyvec *a, const uint8_t seed[KYBER_SYMB
}
}
}

// FIPS 203. Section 3.3 Destruction of intermidiate values.
OPENSSL_memset(buf, 0, sizeof(buf));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should these all be OPENSSL_cleanse to make sure the compiler doesn't optimize out the unused 0 value?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, fixed!

@dkostic dkostic marked this pull request as draft September 27, 2024 18:40
@dkostic dkostic force-pushed the ml-kem-destruct-intermidiate-values branch from 4cd79ef to 4ebc30d Compare September 30, 2024 18:15
@dkostic dkostic marked this pull request as ready for review September 30, 2024 18:15
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.

4 participants