mirror of
https://github.com/henrydcase/pqc.git
synced 2024-11-22 23:48:58 +00:00
Fix reduce.c's overflowing multiplication
This commit is contained in:
parent
ea5ede6e80
commit
3ef983c459
@ -18,7 +18,7 @@ int16_t PQCLEAN_KYBER102490S_CLEAN_montgomery_reduce(int32_t a) {
|
|||||||
int32_t t;
|
int32_t t;
|
||||||
int16_t u;
|
int16_t u;
|
||||||
|
|
||||||
u = (int16_t)(a * QINV);
|
u = (int16_t)(a * (int64_t)QINV);
|
||||||
t = (int32_t)u * KYBER_Q;
|
t = (int32_t)u * KYBER_Q;
|
||||||
t = a - t;
|
t = a - t;
|
||||||
t >>= 16;
|
t >>= 16;
|
||||||
|
@ -18,7 +18,7 @@ int16_t PQCLEAN_KYBER1024_CLEAN_montgomery_reduce(int32_t a) {
|
|||||||
int32_t t;
|
int32_t t;
|
||||||
int16_t u;
|
int16_t u;
|
||||||
|
|
||||||
u = (int16_t)(a * QINV);
|
u = (int16_t)(a * (int64_t)QINV);
|
||||||
t = (int32_t)u * KYBER_Q;
|
t = (int32_t)u * KYBER_Q;
|
||||||
t = a - t;
|
t = a - t;
|
||||||
t >>= 16;
|
t >>= 16;
|
||||||
|
@ -18,7 +18,7 @@ int16_t PQCLEAN_KYBER51290S_CLEAN_montgomery_reduce(int32_t a) {
|
|||||||
int32_t t;
|
int32_t t;
|
||||||
int16_t u;
|
int16_t u;
|
||||||
|
|
||||||
u = (int16_t)(a * QINV);
|
u = (int16_t)(a * (int64_t)QINV);
|
||||||
t = (int32_t)u * KYBER_Q;
|
t = (int32_t)u * KYBER_Q;
|
||||||
t = a - t;
|
t = a - t;
|
||||||
t >>= 16;
|
t >>= 16;
|
||||||
|
@ -18,7 +18,7 @@ int16_t PQCLEAN_KYBER512_CLEAN_montgomery_reduce(int32_t a) {
|
|||||||
int32_t t;
|
int32_t t;
|
||||||
int16_t u;
|
int16_t u;
|
||||||
|
|
||||||
u = (int16_t)(a * QINV);
|
u = (int16_t)(a * (int64_t)QINV);
|
||||||
t = (int32_t)u * KYBER_Q;
|
t = (int32_t)u * KYBER_Q;
|
||||||
t = a - t;
|
t = a - t;
|
||||||
t >>= 16;
|
t >>= 16;
|
||||||
|
@ -18,7 +18,7 @@ int16_t PQCLEAN_KYBER76890S_CLEAN_montgomery_reduce(int32_t a) {
|
|||||||
int32_t t;
|
int32_t t;
|
||||||
int16_t u;
|
int16_t u;
|
||||||
|
|
||||||
u = (int16_t)(a * QINV);
|
u = (int16_t)(a * (int64_t)QINV);
|
||||||
t = (int32_t)u * KYBER_Q;
|
t = (int32_t)u * KYBER_Q;
|
||||||
t = a - t;
|
t = a - t;
|
||||||
t >>= 16;
|
t >>= 16;
|
||||||
|
@ -18,7 +18,7 @@ int16_t PQCLEAN_KYBER768_CLEAN_montgomery_reduce(int32_t a) {
|
|||||||
int32_t t;
|
int32_t t;
|
||||||
int16_t u;
|
int16_t u;
|
||||||
|
|
||||||
u = (int16_t)(a * QINV);
|
u = (int16_t)(a * (int64_t)QINV);
|
||||||
t = (int32_t)u * KYBER_Q;
|
t = (int32_t)u * KYBER_Q;
|
||||||
t = a - t;
|
t = a - t;
|
||||||
t >>= 16;
|
t >>= 16;
|
||||||
|
Loading…
Reference in New Issue
Block a user