-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
std.crypto.kem.kyber: mitigate KyberSlash #18316
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
Conversation
/cc @bwesterb |
Note that, while unlikely, this still permits the compiler to detect that the code is equivalent to a division, and lower to a division. Proper solution will be #1776. Although we don't have a fully specified proposal, I have marked that issue as "accepted" meaning that implementing such a feature blocks the release of Zig 1.0. |
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.
I think you should also introduce a comment explaining why it is doing this instead of the more straightforward division operation, lest someone come in and simplify the logic, blissfully unaware of the mitigation that is in place.
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.
Thanks!
lgtm, thanks. |
On some architectures, including AMD Zen CPUs, dividing a secret by a constant denominator may not be a constant-time operation. And most Kyber implementations, including ours, could leak the hamming weight of the shared secret because of this. See: https://kyberslash.cr.yp.to Multiplications aren't guaranteed to be constant-time either, but at least on the CPUs we currently support, it is.
On some architectures, including AMD Zen CPUs, dividing a secret by a constant denominator may not be a constant-time operation. And most Kyber implementations, including ours, could leak the hamming weight of the shared secret because of this. See: https://kyberslash.cr.yp.to Multiplications aren't guaranteed to be constant-time either, but at least on the CPUs we currently support, it is.
On some architectures, including AMD Zen CPUs, dividing a secret by a constant denominator may not be a constant-time operation.
And most Kyber implementations, including ours, could leak the hamming weight of the shared secret because of this. See:
https://kyberslash.cr.yp.to
Multiplications aren't guaranteed to be constant-time either, but at least on the CPUs we support, they are.