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

fix(kyber): Close potential side-channel vulnerability #534

Merged
merged 3 commits into from
Jan 25, 2024

Conversation

thomwiggers
Copy link
Member

Address the Kyber side-channel vulnerabilities that are potentially
introduced by the division in certain poly operations.

Closes #533

Address the Kyber side-channel vulnerabilities that are potentially
introduced by the division in certain poly operations.

Closes #533
@thomwiggers thomwiggers merged commit 3b43bc6 into master Jan 25, 2024
36 checks passed
@thomwiggers thomwiggers deleted the fix-kyber-div-sidechannel branch January 25, 2024 10:58
smuellerDD added a commit to smuellerDD/leancrypto that referenced this pull request Jan 25, 2024
This is a port of issue PQClean/PQClean#534

Description from mupq/pqm4#320:

The function poly_tomsg from the reference implementation of Kyber
(which was copied into the M4-optimized implementations) would result
in a variable-time udiv instruction operating on secret data when
compiled with gcc using -Os. I tried a couple of versions from gcc 11
to gcc 13, but did not see any difference.

Description from mupq/pqm4#319

This bit of code or similar is used in your various implementations of
Kyber to compress a polynomial ring element into a (secret) message:

```
 t = (((a->coeffs[8 * i + j] << 1) + KYBER_Q / 2) / KYBER_Q) & 1;
```

To do so, it performs a division by Q that might not necessarily compile
to a multiplication instruction: looking at the output of some C
compilers using https://godbolt.org/z/sKn3TKKGq and
https://godbolt.org/z/8GqKoTfYh for example, a division instruction is
emitted even when -O3 is specified. Should a division instruction be
emitted, its execution time would likely be variable and leak
information about its secret input.

Signed-off-by: Stephan Mueller <smueller@chronox.de>
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.

Update Kyber implementations for security improvements
2 participants