diff options
author | lloyd <[email protected]> | 2007-03-07 01:53:45 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2007-03-07 01:53:45 +0000 |
commit | bbd20f37f6bb4fde0b36fe3ceddaedb531c2562f (patch) | |
tree | d321fa487d390a5fff5637109ffa0193d678fc3f /src/tiger.cpp | |
parent | 0392cd772513865b2e98dc5c666f5598d8134c6b (diff) |
Inline the definition of Tiger::round into Tiger::pass, which was its only
caller. The resulting code is longer and somewhat harder to read, but it's
giving 25-30% performance increases on my Core2, and something a bit
lower but still measurable on the P4.
Diffstat (limited to 'src/tiger.cpp')
-rw-r--r-- | src/tiger.cpp | 76 |
1 files changed, 55 insertions, 21 deletions
diff --git a/src/tiger.cpp b/src/tiger.cpp index d51fa4cc4..3df507853 100644 --- a/src/tiger.cpp +++ b/src/tiger.cpp @@ -48,14 +48,61 @@ void Tiger::copy_out(byte output[]) *************************************************/ void Tiger::pass(u64bit& A, u64bit& B, u64bit& C, u64bit X[8], byte mul) { - round(A, B, C, X[0], mul); - round(B, C, A, X[1], mul); - round(C, A, B, X[2], mul); - round(A, B, C, X[3], mul); - round(B, C, A, X[4], mul); - round(C, A, B, X[5], mul); - round(A, B, C, X[6], mul); - round(B, C, A, X[7], mul); + C ^= X[0]; + A -= SBOX1[get_byte(7, C)] ^ SBOX2[get_byte(5, C)] ^ + SBOX3[get_byte(3, C)] ^ SBOX4[get_byte(1, C)]; + B += SBOX1[get_byte(0, C)] ^ SBOX2[get_byte(2, C)] ^ + SBOX3[get_byte(4, C)] ^ SBOX4[get_byte(6, C)]; + B *= mul; + + A ^= X[1]; + B -= SBOX1[get_byte(7, A)] ^ SBOX2[get_byte(5, A)] ^ + SBOX3[get_byte(3, A)] ^ SBOX4[get_byte(1, A)]; + C += SBOX1[get_byte(0, A)] ^ SBOX2[get_byte(2, A)] ^ + SBOX3[get_byte(4, A)] ^ SBOX4[get_byte(6, A)]; + C *= mul; + + B ^= X[2]; + C -= SBOX1[get_byte(7, B)] ^ SBOX2[get_byte(5, B)] ^ + SBOX3[get_byte(3, B)] ^ SBOX4[get_byte(1, B)]; + A += SBOX1[get_byte(0, B)] ^ SBOX2[get_byte(2, B)] ^ + SBOX3[get_byte(4, B)] ^ SBOX4[get_byte(6, B)]; + A *= mul; + + C ^= X[3]; + A -= SBOX1[get_byte(7, C)] ^ SBOX2[get_byte(5, C)] ^ + SBOX3[get_byte(3, C)] ^ SBOX4[get_byte(1, C)]; + B += SBOX1[get_byte(0, C)] ^ SBOX2[get_byte(2, C)] ^ + SBOX3[get_byte(4, C)] ^ SBOX4[get_byte(6, C)]; + B *= mul; + + A ^= X[4]; + B -= SBOX1[get_byte(7, A)] ^ SBOX2[get_byte(5, A)] ^ + SBOX3[get_byte(3, A)] ^ SBOX4[get_byte(1, A)]; + C += SBOX1[get_byte(0, A)] ^ SBOX2[get_byte(2, A)] ^ + SBOX3[get_byte(4, A)] ^ SBOX4[get_byte(6, A)]; + C *= mul; + + B ^= X[5]; + C -= SBOX1[get_byte(7, B)] ^ SBOX2[get_byte(5, B)] ^ + SBOX3[get_byte(3, B)] ^ SBOX4[get_byte(1, B)]; + A += SBOX1[get_byte(0, B)] ^ SBOX2[get_byte(2, B)] ^ + SBOX3[get_byte(4, B)] ^ SBOX4[get_byte(6, B)]; + A *= mul; + + C ^= X[6]; + A -= SBOX1[get_byte(7, C)] ^ SBOX2[get_byte(5, C)] ^ + SBOX3[get_byte(3, C)] ^ SBOX4[get_byte(1, C)]; + B += SBOX1[get_byte(0, C)] ^ SBOX2[get_byte(2, C)] ^ + SBOX3[get_byte(4, C)] ^ SBOX4[get_byte(6, C)]; + B *= mul; + + A ^= X[7]; + B -= SBOX1[get_byte(7, A)] ^ SBOX2[get_byte(5, A)] ^ + SBOX3[get_byte(3, A)] ^ SBOX4[get_byte(1, A)]; + C += SBOX1[get_byte(0, A)] ^ SBOX2[get_byte(2, A)] ^ + SBOX3[get_byte(4, A)] ^ SBOX4[get_byte(6, A)]; + C *= mul; } /************************************************* @@ -72,19 +119,6 @@ void Tiger::mix(u64bit X[8]) } /************************************************* -* Tiger Round * -*************************************************/ -void Tiger::round(u64bit& A, u64bit& B, u64bit& C, u64bit msg, byte mul) - { - C ^= msg; - A -= SBOX1[get_byte(7, C)] ^ SBOX2[get_byte(5, C)] ^ - SBOX3[get_byte(3, C)] ^ SBOX4[get_byte(1, C)]; - B += SBOX1[get_byte(0, C)] ^ SBOX2[get_byte(2, C)] ^ - SBOX3[get_byte(4, C)] ^ SBOX4[get_byte(6, C)]; - B *= mul; - } - -/************************************************* * Clear memory of sensitive data * *************************************************/ void Tiger::clear() throw() |