diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2013-01-15 16:27:39 +0100 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2013-01-15 16:27:39 +0100 |
commit | ac4100e103ca2b4e6e782c5814b1f43cef58c00b (patch) | |
tree | e247d858cc0684f41f953d8eb87d6fcd4e9a610d | |
parent | a55df2793660941f42589182537d02ce54eaed66 (diff) | |
download | busybox-w32-ac4100e103ca2b4e6e782c5814b1f43cef58c00b.tar.gz busybox-w32-ac4100e103ca2b4e6e782c5814b1f43cef58c00b.tar.bz2 busybox-w32-ac4100e103ca2b4e6e782c5814b1f43cef58c00b.zip |
sha3: code shrink
function old new delta
KeccakF 1053 1078 +25
KeccakF_RoundConstants 192 48 -144
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | libbb/hash_md5_sha.c | 62 |
1 files changed, 36 insertions, 26 deletions
diff --git a/libbb/hash_md5_sha.c b/libbb/hash_md5_sha.c index a0eec7789..4cd2244a1 100644 --- a/libbb/hash_md5_sha.c +++ b/libbb/hash_md5_sha.c | |||
@@ -933,32 +933,40 @@ enum { | |||
933 | cKeccakNumberOfRounds = 24, | 933 | cKeccakNumberOfRounds = 24, |
934 | }; | 934 | }; |
935 | 935 | ||
936 | static const uint64_t KeccakF_RoundConstants[cKeccakNumberOfRounds] = { | 936 | /* Elements should be 64-bit, but top half is always zero or 0x80000000. |
937 | 0x0000000000000001ULL, | 937 | * It is encoded as a separate word below. |
938 | 0x0000000000008082ULL, | 938 | * Same is true for 31th bits. |
939 | 0x800000000000808aULL, | 939 | */ |
940 | 0x8000000080008000ULL, | 940 | static const uint16_t KeccakF_RoundConstants[cKeccakNumberOfRounds] = { |
941 | 0x000000000000808bULL, | 941 | 0x0001UL, |
942 | 0x0000000080000001ULL, | 942 | 0x8082UL, |
943 | 0x8000000080008081ULL, | 943 | 0x808aUL, |
944 | 0x8000000000008009ULL, | 944 | 0x8000UL, |
945 | 0x000000000000008aULL, | 945 | 0x808bUL, |
946 | 0x0000000000000088ULL, | 946 | 0x0001UL, |
947 | 0x0000000080008009ULL, | 947 | 0x8081UL, |
948 | 0x000000008000000aULL, | 948 | 0x8009UL, |
949 | 0x000000008000808bULL, | 949 | 0x008aUL, |
950 | 0x800000000000008bULL, | 950 | 0x0088UL, |
951 | 0x8000000000008089ULL, | 951 | 0x8009UL, |
952 | 0x8000000000008003ULL, | 952 | 0x000aUL, |
953 | 0x8000000000008002ULL, | 953 | 0x808bUL, |
954 | 0x8000000000000080ULL, | 954 | 0x008bUL, |
955 | 0x000000000000800aULL, | 955 | 0x8089UL, |
956 | 0x800000008000000aULL, | 956 | 0x8003UL, |
957 | 0x8000000080008081ULL, | 957 | 0x8002UL, |
958 | 0x8000000000008080ULL, | 958 | 0x0080UL, |
959 | 0x0000000080000001ULL, | 959 | 0x800aUL, |
960 | 0x8000000080008008ULL | 960 | 0x000aUL, |
961 | 0x8081UL, | ||
962 | 0x8080UL, | ||
963 | 0x0001UL, | ||
964 | 0x8008UL | ||
961 | }; | 965 | }; |
966 | /* 0th first - 0011 0011 0000 0111 1101 1101: */ | ||
967 | #define KeccakF_RoundConstantBit63 ((uint32_t)(0x3307dd00)) | ||
968 | /* 0th first - 0001 0110 0011 1000 0001 1011: */ | ||
969 | #define KeccakF_RoundConstantBit31 ((uint32_t)(0x16381b00)) | ||
962 | 970 | ||
963 | static const uint8_t KeccakF_RotationConstants[25] = { | 971 | static const uint8_t KeccakF_RotationConstants[25] = { |
964 | 1, 3, 6, 10, 15, 21, 28, 36, 45, 55, 2, 14, 27, 41, 56, 8, 25, 43, 62, | 972 | 1, 3, 6, 10, 15, 21, 28, 36, 45, 55, 2, 14, 27, 41, 56, 8, 25, 43, 62, |
@@ -1075,7 +1083,9 @@ static void KeccakF(uint64_t *state) | |||
1075 | } | 1083 | } |
1076 | 1084 | ||
1077 | /* Iota */ | 1085 | /* Iota */ |
1078 | state[0] ^= KeccakF_RoundConstants[round]; | 1086 | state[0] ^= KeccakF_RoundConstants[round] |
1087 | | (uint32_t)((KeccakF_RoundConstantBit31 << round) & 0x80000000) | ||
1088 | | (uint64_t)((KeccakF_RoundConstantBit63 << round) & 0x80000000) << 32; | ||
1079 | } | 1089 | } |
1080 | 1090 | ||
1081 | if (BB_BIG_ENDIAN) { | 1091 | if (BB_BIG_ENDIAN) { |