Fix byteorder bug in Random.c

This commit is contained in:
Stuart D. Gathman 2016-12-05 00:14:43 -05:00
parent 5cba6bd565
commit 4ed812affe

View File

@ -1,6 +1,30 @@
diff -up ./crypto/random/Random.c.ppc64 ./crypto/random/Random.c
--- ./crypto/random/Random.c.ppc64 2016-12-05 00:06:42.586930523 -0500
+++ ./crypto/random/Random.c 2016-12-05 00:07:36.524592652 -0500
@@ -20,6 +20,7 @@
#include "util/Assert.h"
#include "util/Base32.h"
#include "util/Identity.h"
+#include "util/Endian.h"
#include <crypto_hash_sha256.h>
#include <crypto_stream_salsa20.h>
@@ -163,10 +164,11 @@ void Random_addRandom(struct Random* ran
static void stir(struct Random* rand)
{
+ uint64_t nonce = Endian_hostToLittleEndian64(rand->nonce);
crypto_stream_salsa20_xor((uint8_t*)rand->buff,
(uint8_t*)rand->buff,
BUFFSIZE,
- (uint8_t*)&rand->nonce,
+ (uint8_t*)&nonce,
(uint8_t*)rand->tempSeed);
rand->nonce++;
rand->nextByte = 0;
diff -up ./util/ArchInfo.c.ppc64 ./util/ArchInfo.c
--- ./util/ArchInfo.c.ppc64 2016-10-11 17:39:44.000000000 -0400
+++ ./util/ArchInfo.c 2016-12-02 17:35:50.896575546 -0500
+++ ./util/ArchInfo.c 2016-12-05 00:05:56.482360588 -0500
@@ -98,8 +98,15 @@ gcc arch.c
#error unknown endian
#endif