-
Notifications
You must be signed in to change notification settings - Fork 92
Description
This bit of code or similar is used in your various implementations of Kyber to compress a polynomial ring element into a (secret) message:
pqm4/crypto_kem/kyber768/m4fspeed/poly.c
Line 550 in dc26f54
| 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.
We reported a similar issue in the CRYSTALS-Kyber reference implementation; you may want to use their fix: pq-crystals/kyber@dda29cc