From 1bd6dba28be1db70227ddb5bac4284ac18f6a46b Mon Sep 17 00:00:00 2001 From: lloyd Date: Fri, 19 Oct 2007 14:01:29 +0000 Subject: 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. --- src/seed.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/seed.cpp') 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]); -- cgit v1.2.3