From c93ef4369c44a24fd21b91215a67af4d99c55781 Mon Sep 17 00:00:00 2001 From: SChernykh Date: Thu, 7 Feb 2019 10:32:06 +0100 Subject: [PATCH] Fixes for big-endian machines --- src/crypto/variant4_random_math.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/crypto/variant4_random_math.h b/src/crypto/variant4_random_math.h index fc16ef4d8..2024cf80e 100644 --- a/src/crypto/variant4_random_math.h +++ b/src/crypto/variant4_random_math.h @@ -195,7 +195,7 @@ static inline int v4_random_math_init(struct V4_Instruction* code, const uint64_ char data[32]; memset(data, 0, sizeof(data)); - *((uint64_t*)data) = height; + *((uint64_t*)data) = SWAP64LE(height); size_t data_index = sizeof(data); @@ -209,7 +209,7 @@ static inline int v4_random_math_init(struct V4_Instruction* code, const uint64_ // byte 1: instruction opcode // byte 2: current value of the source register // - // Registers R4-R7 are constant and are threatened as having the same value because when we do + // Registers R4-R7 are constant and are treated as having the same value because when we do // the same operation twice with two constant source registers, it can be optimized into a single operation int inst_data[8] = { 0, 1, 2, 3, -1, -1, -1, -1 }; @@ -355,7 +355,7 @@ static inline int v4_random_math_init(struct V4_Instruction* code, const uint64_ // ADD instruction requires 4 more random bytes for 32-bit constant "C" in "a = a + b + C" check_data(&data_index, sizeof(uint32_t), data, sizeof(data)); - code[code_size].C = *((uint32_t*)&data[data_index]); + code[code_size].C = SWAP32LE(*((uint32_t*)&data[data_index])); data_index += sizeof(uint32_t); }