diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2008-11-13 12:55:11 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2008-11-13 12:55:11 +0000 |
commit | 6bd54d48f44b65464dd637add13292ca8189e1ef (patch) | |
tree | 60f554b0a7ec2c53a58d4a43118d9686a244cc7c /libbb/pw_encrypt_sha.c | |
parent | 6b1e3d7e734f85a08c2e4414764f03a7f880b3e6 (diff) | |
download | busybox-w32-6bd54d48f44b65464dd637add13292ca8189e1ef.tar.gz busybox-w32-6bd54d48f44b65464dd637add13292ca8189e1ef.tar.bz2 busybox-w32-6bd54d48f44b65464dd637add13292ca8189e1ef.zip |
libbb/pw_encrypt_sha: -28 bytes
Diffstat (limited to 'libbb/pw_encrypt_sha.c')
-rw-r--r-- | libbb/pw_encrypt_sha.c | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/libbb/pw_encrypt_sha.c b/libbb/pw_encrypt_sha.c index 08b064750..3dbaeabc9 100644 --- a/libbb/pw_encrypt_sha.c +++ b/libbb/pw_encrypt_sha.c | |||
@@ -196,25 +196,23 @@ do { \ | |||
196 | resptr = to64(resptr, w, N); \ | 196 | resptr = to64(resptr, w, N); \ |
197 | } while (0) | 197 | } while (0) |
198 | if (is_sha512 == '5') { | 198 | if (is_sha512 == '5') { |
199 | unsigned i = 0; | 199 | int i = 0; |
200 | unsigned j = 10; | 200 | int j = 10; |
201 | unsigned k = 20; | 201 | int k = 20; |
202 | /* strange swap of one byte (see below why) */ | ||
203 | unsigned char alt_result_31 = alt_result[31]; | ||
204 | alt_result[31] = alt_result[1]; | ||
205 | while (1) { | 202 | while (1) { |
206 | b64_from_24bit(alt_result[i], alt_result[j], alt_result[k], 4); | 203 | b64_from_24bit(alt_result[i], alt_result[j], alt_result[k], 4); |
207 | if (i == 9) | 204 | if (i == 9) |
208 | break; | 205 | break; |
209 | i += 21; i = (((i >> 4) & 2) + i) & 0x1f; | 206 | /* if x - 9 produces < 0, subtract 2 more: |
210 | j += 21; j = (((j >> 4) & 2) + j) & 0x1f; | 207 | * ((i >> 8) << 1) is either 0 or binary 111111...1110 */ |
211 | k += 21; k = (((k >> 4) & 2) + k) & 0x1f; | 208 | i -= 9; i = (i & 0x1f) + ((i >> 8) << 1); |
209 | j -= 9; j = (j & 0x1f) + ((j >> 8) << 1); | ||
210 | k -= 9; k = (k & 0x1f) + ((k >> 8) << 1); | ||
212 | } | 211 | } |
213 | b64_from_24bit(0, alt_result_31, alt_result[30], 3); | 212 | b64_from_24bit(0, alt_result[31], alt_result[30], 3); |
214 | /* was: | 213 | /* was: |
215 | b64_from_24bit(alt_result[0], alt_result[10], alt_result[20], 4); | 214 | b64_from_24bit(alt_result[0], alt_result[10], alt_result[20], 4); |
216 | b64_from_24bit(alt_result[21], alt_result[1], alt_result[11], 4); | 215 | b64_from_24bit(alt_result[21], alt_result[1], alt_result[11], 4); |
217 | ...............................^^^^^^^^^^^^^ why [1] and not [31]? | ||
218 | b64_from_24bit(alt_result[12], alt_result[22], alt_result[2], 4); | 216 | b64_from_24bit(alt_result[12], alt_result[22], alt_result[2], 4); |
219 | b64_from_24bit(alt_result[3], alt_result[13], alt_result[23], 4); | 217 | b64_from_24bit(alt_result[3], alt_result[13], alt_result[23], 4); |
220 | b64_from_24bit(alt_result[24], alt_result[4], alt_result[14], 4); | 218 | b64_from_24bit(alt_result[24], alt_result[4], alt_result[14], 4); |