aboutsummaryrefslogtreecommitdiffstats
path: root/src/block/aes/aes.cpp
diff options
context:
space:
mode:
authorlloyd <[email protected]>2010-08-19 05:50:31 +0000
committerlloyd <[email protected]>2010-08-19 05:50:31 +0000
commitdf4b36149bbec56a74cb824494fe5eb7ccf335c8 (patch)
tree97320391141ce4c270d9a2c511fc242177bc82b9 /src/block/aes/aes.cpp
parent02620c3c59e0773ba9a89035dd6ebe33127aba16 (diff)
Also use a smaller table in the first round of AES in the decrypt direction
Diffstat (limited to 'src/block/aes/aes.cpp')
-rw-r--r--src/block/aes/aes.cpp28
1 files changed, 19 insertions, 9 deletions
diff --git a/src/block/aes/aes.cpp b/src/block/aes/aes.cpp
index 1177a1461..54a663045 100644
--- a/src/block/aes/aes.cpp
+++ b/src/block/aes/aes.cpp
@@ -539,15 +539,25 @@ void AES::decrypt_n(const byte in[], byte out[], u32bit blocks) const
u32bit T2 = load_be<u32bit>(in, 2) ^ DK[2];
u32bit T3 = load_be<u32bit>(in, 3) ^ DK[3];
- u32bit B0, B1, B2, B3;
- B0 = TD0[get_byte(0, T0)] ^ TD1[get_byte(1, T3)] ^
- TD2[get_byte(2, T2)] ^ TD3[get_byte(3, T1)] ^ DK[4];
- B1 = TD0[get_byte(0, T1)] ^ TD1[get_byte(1, T0)] ^
- TD2[get_byte(2, T3)] ^ TD3[get_byte(3, T2)] ^ DK[5];
- B2 = TD0[get_byte(0, T2)] ^ TD1[get_byte(1, T1)] ^
- TD2[get_byte(2, T0)] ^ TD3[get_byte(3, T3)] ^ DK[6];
- B3 = TD0[get_byte(0, T3)] ^ TD1[get_byte(1, T2)] ^
- TD2[get_byte(2, T1)] ^ TD3[get_byte(3, T0)] ^ DK[7];
+ u32bit B0 = TD[get_byte(0, T0)] ^
+ rotate_right(TD[get_byte(1, T3)], 8) ^
+ rotate_right(TD[get_byte(2, T2)], 16) ^
+ rotate_right(TD[get_byte(3, T1)], 24) ^ DK[4];
+
+ u32bit B1 = TD[get_byte(0, T1)] ^
+ rotate_right(TD[get_byte(1, T0)], 8) ^
+ rotate_right(TD[get_byte(2, T3)], 16) ^
+ rotate_right(TD[get_byte(3, T2)], 24) ^ DK[5];
+
+ u32bit B2 = TD[get_byte(0, T2)] ^
+ rotate_right(TD[get_byte(1, T1)], 8) ^
+ rotate_right(TD[get_byte(2, T0)], 16) ^
+ rotate_right(TD[get_byte(3, T3)], 24) ^ DK[6];
+
+ u32bit B3 = TD[get_byte(0, T3)] ^
+ rotate_right(TD[get_byte(1, T2)], 8) ^
+ rotate_right(TD[get_byte(2, T1)], 16) ^
+ rotate_right(TD[get_byte(3, T0)], 24) ^ DK[7];
for(u32bit j = 2; j != ROUNDS; j += 2)
{