diff options
Diffstat (limited to 'src/block')
-rw-r--r-- | src/block/square/square.cpp | 9 | ||||
-rw-r--r-- | src/block/xtea_simd/xtea_simd.cpp | 8 |
2 files changed, 11 insertions, 6 deletions
diff --git a/src/block/square/square.cpp b/src/block/square/square.cpp index f96162c37..2d798c3e8 100644 --- a/src/block/square/square.cpp +++ b/src/block/square/square.cpp @@ -152,9 +152,10 @@ void Square::key_schedule(const byte key[], u32bit) XEK[4*i+6] = XEK[4*i+2] ^ XEK[4*i+5]; XEK[4*i+7] = XEK[4*i+3] ^ XEK[4*i+6]; - XDK.copy(28 - 4*i, XEK + 4*(i+1), 4); + for(u32bit j = 0; j != 4; ++j) + XDK[28 - 4*i + j] = XEK[4*(i+1)+j]; - transform(XEK + 4*i); + transform(&XEK[4*i]); } for(u32bit i = 0; i != 4; ++i) @@ -166,8 +167,8 @@ void Square::key_schedule(const byte key[], u32bit) MD[4*i+j+16] = get_byte(j, XEK[i ]); } - EK.copy(XEK + 4, 28); - DK.copy(XDK + 4, 28); + EK.copy(&XEK[4], 28); + DK.copy(&XDK[4], 28); } /* diff --git a/src/block/xtea_simd/xtea_simd.cpp b/src/block/xtea_simd/xtea_simd.cpp index 794533d5e..b1c19aca3 100644 --- a/src/block/xtea_simd/xtea_simd.cpp +++ b/src/block/xtea_simd/xtea_simd.cpp @@ -94,9 +94,11 @@ void xtea_decrypt_8(const byte in[64], byte out[64], const u32bit EK[64]) */ void XTEA_SIMD::encrypt_n(const byte in[], byte out[], u32bit blocks) const { + const u32bit* KS = &(this->get_EK()[0]); + while(blocks >= 8) { - xtea_encrypt_8(in, out, this->get_EK()); + xtea_encrypt_8(in, out, KS); in += 8 * BLOCK_SIZE; out += 8 * BLOCK_SIZE; blocks -= 8; @@ -111,9 +113,11 @@ void XTEA_SIMD::encrypt_n(const byte in[], byte out[], u32bit blocks) const */ void XTEA_SIMD::decrypt_n(const byte in[], byte out[], u32bit blocks) const { + const u32bit* KS = &(this->get_EK()[0]); + while(blocks >= 8) { - xtea_decrypt_8(in, out, this->get_EK()); + xtea_decrypt_8(in, out, KS); in += 8 * BLOCK_SIZE; out += 8 * BLOCK_SIZE; blocks -= 8; |