-
Notifications
You must be signed in to change notification settings - Fork 120
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Prevent non-constant-time code in Kyber-R3 and ML-KEM implementation (#…
…1619) ### Issues: Resolves V1399146249 ### Description of changes: A branch can be introduced by the compiler from the `poly_frommsg` code. This has been reported for Clang versions 15-18, x86_64, for the following compiler flags: - `-Os` - `-O1` - `-O2 -fno-vectorize` - `-O3 -fno-vectorize` An upstream fix has been published [here](pq-crystals/kyber@9b8d306) which we are deciding not to take directly. Due to the way AWS-LC compiles the Kyber reference code, it may not have the desired effect. We instead opt to use our own constant-time implementations for performing conditional bit-masks which have much stronger guarantees around portability. ### Call-outs: Point out areas that need special attention or support during the review process. Discuss architecture or design changes. - An interesting observation is that the old code would *always* produce SIMD instructions despite passing in `-fno-vectorize` and technically never produced the non-constant-time branching described. - This new code for performing the conditional bit-masks seems to completely avoid SIMD now. The fact that this is more controlled/predicted is an improvement in my book.
- Loading branch information
Showing
4 changed files
with
28 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters