aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2013-01-15 14:47:05 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2013-01-15 14:47:05 +0100
commit07a54e21dd08bcd752a23095fdedc904eb7127fb (patch)
treefda649b9f6f1071827a8ccd4fcfdd95491459ef5
parent6830ade6aa91dad5afe6abf9d1e4f696f5641bf1 (diff)
downloadbusybox-w32-07a54e21dd08bcd752a23095fdedc904eb7127fb.tar.gz
busybox-w32-07a54e21dd08bcd752a23095fdedc904eb7127fb.tar.bz2
busybox-w32-07a54e21dd08bcd752a23095fdedc904eb7127fb.zip
sha3: another speedup for SHA3_SMALL=0 case
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--libbb/hash_md5_sha.c35
1 files changed, 25 insertions, 10 deletions
diff --git a/libbb/hash_md5_sha.c b/libbb/hash_md5_sha.c
index 643cf205f..3b1366762 100644
--- a/libbb/hash_md5_sha.c
+++ b/libbb/hash_md5_sha.c
@@ -1041,16 +1041,31 @@ static void KeccakF(uint64_t *state)
1041 1041
1042 /* Chi */ 1042 /* Chi */
1043 for (y = 0; y <= 20; y += 5) { 1043 for (y = 0; y <= 20; y += 5) {
1044 uint64_t BC[5]; 1044 if (SHA3_SMALL) {
1045 BC[0] = state[y + 0]; 1045 uint64_t BC[5];
1046 BC[1] = state[y + 1]; 1046 BC[0] = state[y + 0];
1047 BC[2] = state[y + 2]; 1047 BC[1] = state[y + 1];
1048 BC[3] = state[y + 3]; 1048 BC[2] = state[y + 2];
1049 BC[4] = state[y + 4]; 1049 BC[3] = state[y + 3];
1050 for (x = 0; x < 5; ++x) { 1050 BC[4] = state[y + 4];
1051 state[y + x] = 1051 for (x = 0; x < 5; ++x) {
1052 BC[x] ^ ((~BC[KeccakF_Mod5[x + 1]]) & 1052 state[y + x] =
1053 BC[KeccakF_Mod5[x + 2]]); 1053 BC[x] ^ ((~BC[KeccakF_Mod5[x + 1]]) &
1054 BC[KeccakF_Mod5[x + 2]]);
1055 }
1056 } else {
1057 /* 32-bit x86: +50 bytes code, 10% faster */
1058 uint64_t BC0, BC1, BC2, BC3, BC4;
1059 BC0 = state[y + 0];
1060 BC1 = state[y + 1];
1061 BC2 = state[y + 2];
1062 state[y + 0] = BC0 ^ ((~BC1) & BC2);
1063 BC3 = state[y + 3];
1064 state[y + 1] = BC1 ^ ((~BC2) & BC3);
1065 BC4 = state[y + 4];
1066 state[y + 2] = BC2 ^ ((~BC3) & BC4);
1067 state[y + 3] = BC3 ^ ((~BC4) & BC0);
1068 state[y + 4] = BC4 ^ ((~BC0) & BC1);
1054 } 1069 }
1055 } 1070 }
1056 1071