diff options
author | Jack Lloyd <[email protected]> | 2018-12-04 09:35:41 -0500 |
---|---|---|
committer | Jack Lloyd <[email protected]> | 2018-12-04 09:35:41 -0500 |
commit | 4e16f683d7fd3a2ab0553c9423fc725798cd899f (patch) | |
tree | 208f30df5b1922442e2804c5c9299659bc99c77a /src/lib/pubkey/newhope/newhope.cpp | |
parent | 50de06c585609d969da5b9ab5812e62328bacaee (diff) |
Silence MSVC warnings
static_casts for the compiler god
Diffstat (limited to 'src/lib/pubkey/newhope/newhope.cpp')
-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); } } |