summaryrefslogtreecommitdiff
path: root/libbb
diff options
context:
space:
mode:
authorDenys Vlasenko2014-07-30 16:26:09 +0200
committerDenys Vlasenko2014-07-30 16:26:09 +0200
commit09a0e2223f68a266749043bf33c84faeb5cee8a0 (patch)
treee55c9b8c8c8f0ede551284e28fe0ffe4a8812f2e /libbb
parent4ff933c0e7895bd1ac1fe9793117f4d69de35514 (diff)
downloadbusybox-09a0e2223f68a266749043bf33c84faeb5cee8a0.zip
busybox-09a0e2223f68a266749043bf33c84faeb5cee8a0.tar.gz
sha3: tweak comments and indentation
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'libbb')
-rw-r--r--libbb/hash_md5_sha.c27
1 files changed, 14 insertions, 13 deletions
diff --git a/libbb/hash_md5_sha.c b/libbb/hash_md5_sha.c
index 4cef2ab..1f63ccd 100644
--- a/libbb/hash_md5_sha.c
+++ b/libbb/hash_md5_sha.c
@@ -1174,12 +1174,13 @@ static void sha3_process_block72(uint64_t *state)
combine_halves(state);
#else
- /* Elements should be 64-bit, but top half is always zero or 0x80000000.
- * We encode 63rd bits in a separate word below.
- * Same is true for 31th bits, which lets us use 16-bit table instead of 64-bit.
- * The speed penalty is lost in the noise.
- */
+ /* Native 64-bit algorithm */
static const uint16_t IOTA_CONST[NROUNDS] = {
+ /* Elements should be 64-bit, but top half is always zero
+ * or 0x80000000. We encode 63rd bits in a separate word below.
+ * Same is true for 31th bits, which lets us use 16-bit table
+ * instead of 64-bit. The speed penalty is lost in the noise.
+ */
0x0001,
0x8082,
0x808a,
@@ -1283,7 +1284,7 @@ static void sha3_process_block72(uint64_t *state)
#undef RhoPi_twice
}
/* Chi */
-#if LONG_MAX > 0x7fffffff
+# if LONG_MAX > 0x7fffffff
for (x = 0; x <= 20; x += 5) {
uint64_t BC0, BC1, BC2, BC3, BC4;
BC0 = state[x + 0];
@@ -1297,7 +1298,7 @@ static void sha3_process_block72(uint64_t *state)
state[x + 3] = BC3 ^ ((~BC4) & BC0);
state[x + 4] = BC4 ^ ((~BC0) & BC1);
}
-#else
+# else
/* Reduced register pressure version
* for register-starved 32-bit arches
* (i386: -95 bytes, and it is _faster_)
@@ -1305,9 +1306,9 @@ static void sha3_process_block72(uint64_t *state)
for (x = 0; x <= 40;) {
uint32_t BC0, BC1, BC2, BC3, BC4;
uint32_t *const s32 = (uint32_t*)state;
-# if SHA3_SMALL
+# if SHA3_SMALL
do_half:
-#endif
+# endif
BC0 = s32[x + 0*2];
BC1 = s32[x + 1*2];
BC2 = s32[x + 2*2];
@@ -1319,11 +1320,11 @@ static void sha3_process_block72(uint64_t *state)
s32[x + 3*2] = BC3 ^ ((~BC4) & BC0);
s32[x + 4*2] = BC4 ^ ((~BC0) & BC1);
x++;
-# if SHA3_SMALL
+# if SHA3_SMALL
if (x & 1)
goto do_half;
x += 8;
-# else
+# else
BC0 = s32[x + 0*2];
BC1 = s32[x + 1*2];
BC2 = s32[x + 2*2];
@@ -1335,9 +1336,9 @@ static void sha3_process_block72(uint64_t *state)
s32[x + 3*2] = BC3 ^ ((~BC4) & BC0);
s32[x + 4*2] = BC4 ^ ((~BC0) & BC1);
x += 9;
-# endif
+# endif
}
-#endif
+# endif /* long is 32-bit */
/* Iota */
state[0] ^= IOTA_CONST[round]
| (uint32_t)((IOTA_CONST_bit31 << round) & 0x80000000)