aboutsummaryrefslogtreecommitdiffstats
path: root/src/block/aes/aes.cpp
diff options
context:
space:
mode:
authorlloyd <[email protected]>2010-10-14 18:09:31 +0000
committerlloyd <[email protected]>2010-10-14 18:09:31 +0000
commitf8d3d95b84c55b48d61b50f9d0e6aabbfe007e12 (patch)
tree98ea61c7a01daf8b8ed0ea9290a01b61a627d82b /src/block/aes/aes.cpp
parent0cb6bcfedef6ffa797801acd7cb945feb2d05d50 (diff)
Remove standalone S function
Diffstat (limited to 'src/block/aes/aes.cpp')
-rw-r--r--src/block/aes/aes.cpp25
1 files changed, 13 insertions, 12 deletions
diff --git a/src/block/aes/aes.cpp b/src/block/aes/aes.cpp
index 7f6c5ea9c..0c45c38a0 100644
--- a/src/block/aes/aes.cpp
+++ b/src/block/aes/aes.cpp
@@ -606,15 +606,6 @@ void aes_decrypt_n(const byte in[], byte out[], size_t blocks,
}
}
-/*
-* AES Byte Substitution
-*/
-u32bit aes_S(u32bit input)
- {
- return make_u32bit(SE[get_byte(0, input)], SE[get_byte(1, input)],
- SE[get_byte(2, input)], SE[get_byte(3, input)]);
- }
-
void aes_key_schedule(const byte key[], size_t length,
MemoryRegion<u32bit>& EK,
MemoryRegion<u32bit>& DK,
@@ -635,13 +626,23 @@ void aes_key_schedule(const byte key[], size_t length,
for(size_t i = X; i < 4*(rounds+1); i += X)
{
- XEK[i] = XEK[i-X] ^ aes_S(rotate_left(XEK[i-1], 8)) ^ RC[(i-X)/X];
+ XEK[i] = XEK[i-X] ^ RC[(i-X)/X] ^
+ make_u32bit(SE[get_byte(1, XEK[i-1])],
+ SE[get_byte(2, XEK[i-1])],
+ SE[get_byte(3, XEK[i-1])],
+ SE[get_byte(0, XEK[i-1])]);
+
for(size_t j = 1; j != X; ++j)
{
+ XEK[i+j] = XEK[i+j-X];
+
if(X == 8 && j == 4)
- XEK[i+j] = XEK[i+j-X] ^ aes_S(XEK[i+j-1]);
+ XEK[i+j] ^= make_u32bit(SE[get_byte(0, XEK[i+j-1])],
+ SE[get_byte(1, XEK[i+j-1])],
+ SE[get_byte(2, XEK[i+j-1])],
+ SE[get_byte(3, XEK[i+j-1])]);
else
- XEK[i+j] = XEK[i+j-X] ^ XEK[i+j-1];
+ XEK[i+j] ^= XEK[i+j-1];
}
}