Skip to content

HQC implementation out of date/vulnerable #482

@ambiso

Description

@ambiso

The current HQC implementation still contains the timing side-channel vulnerable rejection sampling, whose running time is dependent on the seed that is derived from the secret message.

while (i < weight) {
do {
if (j == random_bytes_size) {
seedexpander(ctx, rand_bytes, random_bytes_size);
j = 0;
}

See here for details.

There's a new round 4 submission that uses Sendrier's countermeasure (see vector.c).

Unfortunately with gcc the modulo reductions in the loop compile to divide instructions, which might not be constant-time.

image

clang successfully compiles the modulo reductions down to (I believe) Barrett reductions (which don't use div instructions).

I don't know how practical it is however to exploit any leakage from this on x86, however the clean version which might be used to target microprocessors where division might be very leaky.

One could manually inline the assembly to ensure that the timing behavior of the implementation doesn't depend on whether the compiler is having a good day or not 🙂

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions