diff options
Diffstat (limited to 'src/lib/pubkey/newhope')
-rw-r--r-- | src/lib/pubkey/newhope/newhope.cpp | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/src/lib/pubkey/newhope/newhope.cpp b/src/lib/pubkey/newhope/newhope.cpp index b5d841144..1c6a841d5 100644 --- a/src/lib/pubkey/newhope/newhope.cpp +++ b/src/lib/pubkey/newhope/newhope.cpp @@ -63,7 +63,7 @@ inline void ntt(uint16_t* a, const uint16_t* omega) for(size_t i = 0; i < 10; i+=2) { // Even level - size_t distance = (1<<i); + size_t distance = (1ULL << i); for(size_t start = 0; start < distance; start++) { size_t jTwiddle = 0; @@ -138,12 +138,12 @@ inline void poly_tobytes(uint8_t* r, const poly* p) t3 = m ^ ((t3^m)&c); // <Make sure that coefficients are in [0,q] r[7*i+0] = t0 & 0xff; - r[7*i+1] = (t0 >> 8) | (t1 << 6); - r[7*i+2] = (t1 >> 2); - r[7*i+3] = (t1 >> 10) | (t2 << 4); - r[7*i+4] = (t2 >> 4); - r[7*i+5] = (t2 >> 12) | (t3 << 2); - r[7*i+6] = (t3 >> 6); + r[7*i+1] = static_cast<uint8_t>((t0 >> 8) | (t1 << 6)); + r[7*i+2] = static_cast<uint8_t>((t1 >> 2)); + r[7*i+3] = static_cast<uint8_t>((t1 >> 10) | (t2 << 4)); + r[7*i+4] = static_cast<uint8_t>((t2 >> 4)); + r[7*i+5] = static_cast<uint8_t>((t2 >> 12) | (t3 << 2)); + r[7*i+6] = static_cast<uint8_t>((t3 >> 6)); } } @@ -163,7 +163,7 @@ inline void poly_getnoise(Botan::RandomNumberGenerator& rng, poly* r) } const uint32_t a = ((d >> 8) & 0xff) + (d & 0xff); const uint32_t b = (d >> 24) + ((d >> 16) & 0xff); - r->coeffs[i] = a + PARAM_Q - b; + r->coeffs[i] = static_cast<uint16_t>(a + PARAM_Q - b); } } |