From 6b2e3aa24fa29bf7e449372f61a709ab94c0ced5 Mon Sep 17 00:00:00 2001 From: Jack Lloyd Date: Tue, 30 Aug 2016 13:15:40 -0400 Subject: Fix tests on things that are not little endian --- src/lib/pubkey/newhope/newhope.cpp | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) (limited to 'src/lib') diff --git a/src/lib/pubkey/newhope/newhope.cpp b/src/lib/pubkey/newhope/newhope.cpp index 178cf340e..8436457b4 100644 --- a/src/lib/pubkey/newhope/newhope.cpp +++ b/src/lib/pubkey/newhope/newhope.cpp @@ -160,23 +160,17 @@ inline void poly_tobytes(uint8_t *r, const poly *p) inline void poly_getnoise(Botan::RandomNumberGenerator& rng, poly *r) { uint8_t buf[4*PARAM_N]; - uint32_t *tp, t,d, a, b; - int i,j; - - // Not an endian problem because this is just used for RNG output - // Is an endian problem for tests - tp = (uint32_t *) buf; rng.randomize(buf, 4*PARAM_N); - for(i=0;i(buf, i); + uint32_t d = 0; + for(int j=0;j<8;j++) d += (t >> j) & 0x01010101; - a = ((d >> 8) & 0xff) + (d & 0xff); - b = (d >> 24) + ((d >> 16) & 0xff); + uint32_t a = ((d >> 8) & 0xff) + (d & 0xff); + uint32_t b = (d >> 24) + ((d >> 16) & 0xff); r->coeffs[i] = a + PARAM_Q - b; } } -- cgit v1.2.3