diff options
author | Jack Lloyd <[email protected]> | 2016-02-06 11:27:47 -0500 |
---|---|---|
committer | Jack Lloyd <[email protected]> | 2016-02-06 11:27:47 -0500 |
commit | 4a1f9b821796fa586ab7872ab342fd05e68bc059 (patch) | |
tree | b7b495bad9f1f9e04f86f1402574bfe2f061bcfc /src/lib/hash/keccak | |
parent | 8a84d370550508349d1f872195dedd09236e37b1 (diff) |
Order the accesses to A[] in the Keccak permutation.
Consistent speed up of about ~5% on my machine.
Also tried moving all the A[] values to local registers, was slower.
Diffstat (limited to 'src/lib/hash/keccak')
-rw-r--r-- | src/lib/hash/keccak/keccak.cpp | 34 |
1 files changed, 17 insertions, 17 deletions
diff --git a/src/lib/hash/keccak/keccak.cpp b/src/lib/hash/keccak/keccak.cpp index c0b430a8f..44297dcef 100644 --- a/src/lib/hash/keccak/keccak.cpp +++ b/src/lib/hash/keccak/keccak.cpp @@ -41,30 +41,30 @@ void keccak_f_1600(u64bit A[25]) const u64bit D4 = rotate_left(C4, 1) ^ C2; const u64bit B00 = A[ 0] ^ D1; - const u64bit B01 = rotate_left(A[ 6] ^ D2, 44); - const u64bit B02 = rotate_left(A[12] ^ D3, 43); - const u64bit B03 = rotate_left(A[18] ^ D4, 21); - const u64bit B04 = rotate_left(A[24] ^ D0, 14); - const u64bit B05 = rotate_left(A[ 3] ^ D4, 28); - const u64bit B06 = rotate_left(A[ 9] ^ D0, 20); - const u64bit B07 = rotate_left(A[10] ^ D1, 3); - const u64bit B08 = rotate_left(A[16] ^ D2, 45); - const u64bit B09 = rotate_left(A[22] ^ D3, 61); const u64bit B10 = rotate_left(A[ 1] ^ D2, 1); - const u64bit B11 = rotate_left(A[ 7] ^ D3, 6); - const u64bit B12 = rotate_left(A[13] ^ D4, 25); - const u64bit B13 = rotate_left(A[19] ^ D0, 8); - const u64bit B14 = rotate_left(A[20] ^ D1, 18); + const u64bit B20 = rotate_left(A[ 2] ^ D3, 62); + const u64bit B05 = rotate_left(A[ 3] ^ D4, 28); const u64bit B15 = rotate_left(A[ 4] ^ D0, 27); const u64bit B16 = rotate_left(A[ 5] ^ D1, 36); - const u64bit B17 = rotate_left(A[11] ^ D2, 10); - const u64bit B18 = rotate_left(A[17] ^ D3, 15); - const u64bit B19 = rotate_left(A[23] ^ D4, 56); - const u64bit B20 = rotate_left(A[ 2] ^ D3, 62); + const u64bit B01 = rotate_left(A[ 6] ^ D2, 44); + const u64bit B11 = rotate_left(A[ 7] ^ D3, 6); const u64bit B21 = rotate_left(A[ 8] ^ D4, 55); + const u64bit B06 = rotate_left(A[ 9] ^ D0, 20); + const u64bit B07 = rotate_left(A[10] ^ D1, 3); + const u64bit B17 = rotate_left(A[11] ^ D2, 10); + const u64bit B02 = rotate_left(A[12] ^ D3, 43); + const u64bit B12 = rotate_left(A[13] ^ D4, 25); const u64bit B22 = rotate_left(A[14] ^ D0, 39); const u64bit B23 = rotate_left(A[15] ^ D1, 41); + const u64bit B08 = rotate_left(A[16] ^ D2, 45); + const u64bit B18 = rotate_left(A[17] ^ D3, 15); + const u64bit B03 = rotate_left(A[18] ^ D4, 21); + const u64bit B13 = rotate_left(A[19] ^ D0, 8); + const u64bit B14 = rotate_left(A[20] ^ D1, 18); const u64bit B24 = rotate_left(A[21] ^ D2, 2); + const u64bit B09 = rotate_left(A[22] ^ D3, 61); + const u64bit B19 = rotate_left(A[23] ^ D4, 56); + const u64bit B04 = rotate_left(A[24] ^ D0, 14); A[ 0] = B00 ^ (~B01 & B02); A[ 1] = B01 ^ (~B02 & B03); |