Skip to content

Commit 154edc9

Browse files
authored
Type fix in mldsa (#2308)
Change types `uint32_t t0, t1;` to` int32_t t0, t1;` due to potential overflow in `if (t0 < 9){a[ctr++] = 4 - t0;}` causing cbmc proofs to fail. ### Issues: From pq-code-package/mldsa-native#86. ### Description of changes: The output array is of type `int32_t* a`, thus, `uint32_t` aux values `t0, t1` cause cbmc proofs to fail due to potential overflow. ### Testing: `./crypto/crypto_test ` By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license and the ISC license.
1 parent 83f6eb3 commit 154edc9

File tree

1 file changed

+4
-4
lines changed
  • crypto/fipsmodule/ml_dsa/ml_dsa_ref

1 file changed

+4
-4
lines changed

crypto/fipsmodule/ml_dsa/ml_dsa_ref/poly.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -372,19 +372,19 @@ static unsigned int rej_eta(ml_dsa_params *params,
372372
if (params->eta == 2) {
373373
if(t0 < 15) {
374374
t0 = t0 - (205*t0 >> 10)*5;
375-
a[ctr++] = 2 - t0;
375+
a[ctr++] = 2 - (int32_t)t0;
376376
}
377377
if(t1 < 15 && ctr < len) {
378378
t1 = t1 - (205*t1 >> 10)*5;
379-
a[ctr++] = 2 - t1;
379+
a[ctr++] = 2 - (int32_t)t1;
380380
}
381381
}
382382

383383
else if (params->eta == 4) {
384384
if(t0 < 9)
385-
a[ctr++] = 4 - t0;
385+
a[ctr++] = 4 - (int32_t)t0;
386386
if(t1 < 9 && ctr < len)
387-
a[ctr++] = 4 - t1;
387+
a[ctr++] = 4 - (int32_t)t1;
388388
}
389389
}
390390
return ctr;

0 commit comments

Comments
 (0)