diff options
author | xiphon <xiphon@protonmail.com> | 2018-10-31 03:13:55 +0000 |
---|---|---|
committer | xiphon <xiphon@protonmail.com> | 2018-10-31 03:13:55 +0000 |
commit | 42d8d5085e96732e96fcb39f4b851bc85f4e4a8b (patch) | |
tree | 8ebde5d5390744b4a64432753995d68a5286d295 | |
parent | Merge pull request #4721 (diff) | |
download | monero-42d8d5085e96732e96fcb39f4b851bc85f4e4a8b.tar.xz |
crypto: fix AES encryption on big endian
-rw-r--r-- | src/crypto/aesb.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/crypto/aesb.c b/src/crypto/aesb.c index 5d57b8af4..8a22a4b93 100644 --- a/src/crypto/aesb.c +++ b/src/crypto/aesb.c @@ -19,6 +19,7 @@ Issue Date: 20/12/2007 */ #include <stdint.h> +#include "common/int-util.h" #if defined(__cplusplus) extern "C" @@ -50,7 +51,7 @@ extern "C" #define state_out(y,x) so(y,x,0); so(y,x,1); so(y,x,2); so(y,x,3) #define round(rm,y,x,k) rm(y,x,k,0); rm(y,x,k,1); rm(y,x,k,2); rm(y,x,k,3) #define to_byte(x) ((x) & 0xff) -#define bval(x,n) to_byte((x) >> (8 * (n))) +#define bval(x,n) to_byte(SWAP32LE(x) >> (8 * (n))) #define fwd_var(x,r,c)\ ( r == 0 ? ( c == 0 ? s(x,0) : c == 1 ? s(x,1) : c == 2 ? s(x,2) : s(x,3))\ @@ -58,7 +59,7 @@ extern "C" : r == 2 ? ( c == 0 ? s(x,2) : c == 1 ? s(x,3) : c == 2 ? s(x,0) : s(x,1))\ : ( c == 0 ? s(x,3) : c == 1 ? s(x,0) : c == 2 ? s(x,1) : s(x,2))) -#define fwd_rnd(y,x,k,c) (s(y,c) = (k)[c] ^ four_tables(x,t_use(f,n),fwd_var,rf1,c)) +#define fwd_rnd(y,x,k,c) (s(y,c) = (k)[c] ^ SWAP32LE(four_tables(x,t_use(f,n),fwd_var,rf1,c))) #define sb_data(w) {\ w(0x63), w(0x7c), w(0x77), w(0x7b), w(0xf2), w(0x6b), w(0x6f), w(0xc5),\ |