fix(kyber): Close potential side-channel vulnerability#534
Merged
thomwiggers merged 3 commits intomasterfrom Jan 25, 2024
Merged
fix(kyber): Close potential side-channel vulnerability#534thomwiggers merged 3 commits intomasterfrom
thomwiggers merged 3 commits intomasterfrom
Conversation
Address the Kyber side-channel vulnerabilities that are potentially introduced by the division in certain poly operations. Closes #533
dstebila
reviewed
Jan 2, 2024
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>
tniessen
added a commit
to tniessen/node-pqclean
that referenced
this pull request
Feb 7, 2024
Refs: PQClean/PQClean#504 Refs: PQClean/PQClean#512 Refs: PQClean/PQClean#519 Refs: PQClean/PQClean#521 Refs: PQClean/PQClean#527 Refs: PQClean/PQClean#534 Refs: PQClean/PQClean#535 Refs: PQClean/PQClean#536 Refs: PQClean/PQClean#540 Refs: PQClean/PQClean#541 Refs: PQClean/PQClean#542 Refs: PQClean/PQClean#543
This was referenced Feb 23, 2024
Merged
infra-riderju74
added a commit
to infra-riderju74/leancrypto
that referenced
this pull request
Sep 28, 2025
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>
data-wardenb6ym
added a commit
to data-wardenb6ym/node-pqclean
that referenced
this pull request
Sep 29, 2025
Refs: PQClean/PQClean#504 Refs: PQClean/PQClean#512 Refs: PQClean/PQClean#519 Refs: PQClean/PQClean#521 Refs: PQClean/PQClean#527 Refs: PQClean/PQClean#534 Refs: PQClean/PQClean#535 Refs: PQClean/PQClean#536 Refs: PQClean/PQClean#540 Refs: PQClean/PQClean#541 Refs: PQClean/PQClean#542 Refs: PQClean/PQClean#543
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Address the Kyber side-channel vulnerabilities that are potentially
introduced by the division in certain poly operations.
Closes #533