diff options
| author | Denys Vlasenko <vda.linux@googlemail.com> | 2014-07-30 16:26:09 +0200 |
|---|---|---|
| committer | Denys Vlasenko <vda.linux@googlemail.com> | 2014-07-30 16:26:09 +0200 |
| commit | 09a0e2223f68a266749043bf33c84faeb5cee8a0 (patch) | |
| tree | e55c9b8c8c8f0ede551284e28fe0ffe4a8812f2e /libbb | |
| parent | 4ff933c0e7895bd1ac1fe9793117f4d69de35514 (diff) | |
| download | busybox-w32-09a0e2223f68a266749043bf33c84faeb5cee8a0.tar.gz busybox-w32-09a0e2223f68a266749043bf33c84faeb5cee8a0.tar.bz2 busybox-w32-09a0e2223f68a266749043bf33c84faeb5cee8a0.zip | |
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.c | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/libbb/hash_md5_sha.c b/libbb/hash_md5_sha.c index 4cef2aba1..1f63ccdee 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) | |||
| 1174 | 1174 | ||
| 1175 | combine_halves(state); | 1175 | combine_halves(state); |
| 1176 | #else | 1176 | #else |
| 1177 | /* Elements should be 64-bit, but top half is always zero or 0x80000000. | 1177 | /* Native 64-bit algorithm */ |
| 1178 | * We encode 63rd bits in a separate word below. | ||
| 1179 | * Same is true for 31th bits, which lets us use 16-bit table instead of 64-bit. | ||
| 1180 | * The speed penalty is lost in the noise. | ||
| 1181 | */ | ||
| 1182 | static const uint16_t IOTA_CONST[NROUNDS] = { | 1178 | static const uint16_t IOTA_CONST[NROUNDS] = { |
| 1179 | /* Elements should be 64-bit, but top half is always zero | ||
| 1180 | * or 0x80000000. We encode 63rd bits in a separate word below. | ||
| 1181 | * Same is true for 31th bits, which lets us use 16-bit table | ||
| 1182 | * instead of 64-bit. The speed penalty is lost in the noise. | ||
| 1183 | */ | ||
| 1183 | 0x0001, | 1184 | 0x0001, |
| 1184 | 0x8082, | 1185 | 0x8082, |
| 1185 | 0x808a, | 1186 | 0x808a, |
| @@ -1283,7 +1284,7 @@ static void sha3_process_block72(uint64_t *state) | |||
| 1283 | #undef RhoPi_twice | 1284 | #undef RhoPi_twice |
| 1284 | } | 1285 | } |
| 1285 | /* Chi */ | 1286 | /* Chi */ |
| 1286 | #if LONG_MAX > 0x7fffffff | 1287 | # if LONG_MAX > 0x7fffffff |
| 1287 | for (x = 0; x <= 20; x += 5) { | 1288 | for (x = 0; x <= 20; x += 5) { |
| 1288 | uint64_t BC0, BC1, BC2, BC3, BC4; | 1289 | uint64_t BC0, BC1, BC2, BC3, BC4; |
| 1289 | BC0 = state[x + 0]; | 1290 | BC0 = state[x + 0]; |
| @@ -1297,7 +1298,7 @@ static void sha3_process_block72(uint64_t *state) | |||
| 1297 | state[x + 3] = BC3 ^ ((~BC4) & BC0); | 1298 | state[x + 3] = BC3 ^ ((~BC4) & BC0); |
| 1298 | state[x + 4] = BC4 ^ ((~BC0) & BC1); | 1299 | state[x + 4] = BC4 ^ ((~BC0) & BC1); |
| 1299 | } | 1300 | } |
| 1300 | #else | 1301 | # else |
| 1301 | /* Reduced register pressure version | 1302 | /* Reduced register pressure version |
| 1302 | * for register-starved 32-bit arches | 1303 | * for register-starved 32-bit arches |
| 1303 | * (i386: -95 bytes, and it is _faster_) | 1304 | * (i386: -95 bytes, and it is _faster_) |
| @@ -1305,9 +1306,9 @@ static void sha3_process_block72(uint64_t *state) | |||
| 1305 | for (x = 0; x <= 40;) { | 1306 | for (x = 0; x <= 40;) { |
| 1306 | uint32_t BC0, BC1, BC2, BC3, BC4; | 1307 | uint32_t BC0, BC1, BC2, BC3, BC4; |
| 1307 | uint32_t *const s32 = (uint32_t*)state; | 1308 | uint32_t *const s32 = (uint32_t*)state; |
| 1308 | # if SHA3_SMALL | 1309 | # if SHA3_SMALL |
| 1309 | do_half: | 1310 | do_half: |
| 1310 | #endif | 1311 | # endif |
| 1311 | BC0 = s32[x + 0*2]; | 1312 | BC0 = s32[x + 0*2]; |
| 1312 | BC1 = s32[x + 1*2]; | 1313 | BC1 = s32[x + 1*2]; |
| 1313 | BC2 = s32[x + 2*2]; | 1314 | BC2 = s32[x + 2*2]; |
| @@ -1319,11 +1320,11 @@ static void sha3_process_block72(uint64_t *state) | |||
| 1319 | s32[x + 3*2] = BC3 ^ ((~BC4) & BC0); | 1320 | s32[x + 3*2] = BC3 ^ ((~BC4) & BC0); |
| 1320 | s32[x + 4*2] = BC4 ^ ((~BC0) & BC1); | 1321 | s32[x + 4*2] = BC4 ^ ((~BC0) & BC1); |
| 1321 | x++; | 1322 | x++; |
| 1322 | # if SHA3_SMALL | 1323 | # if SHA3_SMALL |
| 1323 | if (x & 1) | 1324 | if (x & 1) |
| 1324 | goto do_half; | 1325 | goto do_half; |
| 1325 | x += 8; | 1326 | x += 8; |
| 1326 | # else | 1327 | # else |
| 1327 | BC0 = s32[x + 0*2]; | 1328 | BC0 = s32[x + 0*2]; |
| 1328 | BC1 = s32[x + 1*2]; | 1329 | BC1 = s32[x + 1*2]; |
| 1329 | BC2 = s32[x + 2*2]; | 1330 | BC2 = s32[x + 2*2]; |
| @@ -1335,9 +1336,9 @@ static void sha3_process_block72(uint64_t *state) | |||
| 1335 | s32[x + 3*2] = BC3 ^ ((~BC4) & BC0); | 1336 | s32[x + 3*2] = BC3 ^ ((~BC4) & BC0); |
| 1336 | s32[x + 4*2] = BC4 ^ ((~BC0) & BC1); | 1337 | s32[x + 4*2] = BC4 ^ ((~BC0) & BC1); |
| 1337 | x += 9; | 1338 | x += 9; |
| 1338 | # endif | 1339 | # endif |
| 1339 | } | 1340 | } |
| 1340 | #endif | 1341 | # endif /* long is 32-bit */ |
| 1341 | /* Iota */ | 1342 | /* Iota */ |
| 1342 | state[0] ^= IOTA_CONST[round] | 1343 | state[0] ^= IOTA_CONST[round] |
| 1343 | | (uint32_t)((IOTA_CONST_bit31 << round) & 0x80000000) | 1344 | | (uint32_t)((IOTA_CONST_bit31 << round) & 0x80000000) |
