aboutsummaryrefslogtreecommitdiffstats
path: root/src/seed.cpp
diff options
context:
space:
mode:
authorlloyd <[email protected]>2007-10-19 14:01:29 +0000
committerlloyd <[email protected]>2007-10-19 14:01:29 +0000
commit1bd6dba28be1db70227ddb5bac4284ac18f6a46b (patch)
treee427986229991d22b8c4f1a2857455e6eb9b5895 /src/seed.cpp
parent0c89766c853fd766b4dac7cc4ac22a5db8e10fe4 (diff)
Fold an XOR operation that was happening during SEED encryption/decryption to
occur inside the key schedule instead. This should lead to (slightly) better scheduling in the compiled code by reducing the length of a critical path.
Diffstat (limited to 'src/seed.cpp')
-rw-r--r--src/seed.cpp12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/seed.cpp b/src/seed.cpp
index 9ed05b28f..765466ab6 100644
--- a/src/seed.cpp
+++ b/src/seed.cpp
@@ -34,14 +34,14 @@ void SEED::enc(const byte in[], byte out[]) const
u32bit T0, T1;
T0 = B2 ^ K[2*j];
- T1 = G(T0 ^ B3 ^ K[2*j+1]);
+ T1 = G(B2 ^ B3 ^ K[2*j+1]);
T0 = G(T1 + T0);
T1 = G(T1 + T0);
B1 ^= T1;
B0 ^= T0 + T1;
T0 = B0 ^ K[2*j+2];
- T1 = G(T0 ^ B1 ^ K[2*j+3]);
+ T1 = G(B0 ^ B1 ^ K[2*j+3]);
T0 = G(T1 + T0);
T1 = G(T1 + T0);
B3 ^= T1;
@@ -68,14 +68,14 @@ void SEED::dec(const byte in[], byte out[]) const
u32bit T0, T1;
T0 = B2 ^ K[30-2*j];
- T1 = G(T0 ^ B3 ^ K[31-2*j]);
+ T1 = G(B2 ^ B3 ^ K[31-2*j]);
T0 = G(T1 + T0);
T1 = G(T1 + T0);
B1 ^= T1;
B0 ^= T0 + T1;
T0 = B0 ^ K[28-2*j];
- T1 = G(T0 ^ B1 ^ K[29-2*j]);
+ T1 = G(B0 ^ B1 ^ K[29-2*j]);
T0 = G(T1 + T0);
T1 = G(T1 + T0);
B3 ^= T1;
@@ -107,14 +107,14 @@ void SEED::key(const byte key[], u32bit)
for(u32bit j = 0; j != 16; j += 2)
{
K[2*j ] = G(WK[0] + WK[2] - RC[j]);
- K[2*j+1] = G(WK[1] - WK[3] + RC[j]);
+ K[2*j+1] = G(WK[1] - WK[3] + RC[j]) ^ K[2*j];
byte T = get_byte(3, WK[0]);
WK[0] = (WK[0] >> 8) | (get_byte(3, WK[1]) << 24);
WK[1] = (WK[1] >> 8) | (T << 24);
K[2*j+2] = G(WK[0] + WK[2] - RC[j+1]);
- K[2*j+3] = G(WK[1] - WK[3] + RC[j+1]);
+ K[2*j+3] = G(WK[1] - WK[3] + RC[j+1]) ^ K[2*j+2];
T = get_byte(0, WK[3]);
WK[3] = (WK[3] << 8) | get_byte(0, WK[2]);