diff options
author | vda <vda@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2006-09-28 00:29:00 +0000 |
---|---|---|
committer | vda <vda@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2006-09-28 00:29:00 +0000 |
commit | fc9975761320f38189e69a6e63666fa86019c550 (patch) | |
tree | ade67c96b46c3cbbd869c4ca4b77b462b4db0d81 /libbb | |
parent | ede88e7a5065cac3e03d4d34c83d0dfa414453b4 (diff) | |
download | busybox-w32-fc9975761320f38189e69a6e63666fa86019c550.tar.gz busybox-w32-fc9975761320f38189e69a6e63666fa86019c550.tar.bz2 busybox-w32-fc9975761320f38189e69a6e63666fa86019c550.zip |
Tried to find sha1_crypt - nope... ok, save few bytes in md5_sha1_sum.c
(time to sleep, 02:28 in the morning)...
git-svn-id: svn://busybox.net/trunk/busybox@16244 69ca8d6d-28ef-0310-b511-8ec308f3f277
Diffstat (limited to 'libbb')
-rw-r--r-- | libbb/sha1.c | 33 |
1 files changed, 16 insertions, 17 deletions
diff --git a/libbb/sha1.c b/libbb/sha1.c index a86218b25..34813e24a 100644 --- a/libbb/sha1.c +++ b/libbb/sha1.c | |||
@@ -26,27 +26,28 @@ | |||
26 | 26 | ||
27 | #include "libbb.h" | 27 | #include "libbb.h" |
28 | 28 | ||
29 | # define SHA1_BLOCK_SIZE 64 | 29 | #define SHA1_BLOCK_SIZE 64 |
30 | # define SHA1_DIGEST_SIZE 20 | 30 | #define SHA1_DIGEST_SIZE 20 |
31 | # define SHA1_HASH_SIZE SHA1_DIGEST_SIZE | 31 | #define SHA1_HASH_SIZE SHA1_DIGEST_SIZE |
32 | # define SHA2_GOOD 0 | 32 | #define SHA2_GOOD 0 |
33 | # define SHA2_BAD 1 | 33 | #define SHA2_BAD 1 |
34 | 34 | ||
35 | # define rotl32(x,n) (((x) << n) | ((x) >> (32 - n))) | 35 | #define rotl32(x,n) (((x) << n) | ((x) >> (32 - n))) |
36 | 36 | ||
37 | # define SHA1_MASK (SHA1_BLOCK_SIZE - 1) | 37 | #define SHA1_MASK (SHA1_BLOCK_SIZE - 1) |
38 | 38 | ||
39 | /* reverse byte order in 32-bit words */ | 39 | /* reverse byte order in 32-bit words */ |
40 | #define ch(x,y,z) ((z) ^ ((x) & ((y) ^ (z)))) | 40 | #define ch(x,y,z) ((z) ^ ((x) & ((y) ^ (z)))) |
41 | #define parity(x,y,z) ((x) ^ (y) ^ (z)) | 41 | #define parity(x,y,z) ((x) ^ (y) ^ (z)) |
42 | #define maj(x,y,z) (((x) & (y)) | ((z) & ((x) | (y)))) | 42 | #define maj(x,y,z) (((x) & (y)) | ((z) & ((x) | (y)))) |
43 | 43 | ||
44 | /* A normal version as set out in the FIPS. This version uses */ | 44 | /* A normal version as set out in the FIPS. This version uses */ |
45 | /* partial loop unrolling and is optimised for the Pentium 4 */ | 45 | /* partial loop unrolling and is optimised for the Pentium 4 */ |
46 | # define rnd(f,k) \ | 46 | #define rnd(f,k) \ |
47 | t = a; a = rotl32(a,5) + f(b,c,d) + e + k + w[i]; \ | 47 | do { \ |
48 | e = d; d = c; c = rotl32(b, 30); b = t | 48 | t = a; a = rotl32(a,5) + f(b,c,d) + e + k + w[i]; \ |
49 | 49 | e = d; d = c; c = rotl32(b, 30); b = t; \ | |
50 | } while(0) | ||
50 | 51 | ||
51 | static void sha1_compile(sha1_ctx_t *ctx) | 52 | static void sha1_compile(sha1_ctx_t *ctx) |
52 | { | 53 | { |
@@ -160,7 +161,7 @@ void *sha1_end(void *resbuf, sha1_ctx_t *ctx) | |||
160 | ctx->wbuf[cnt++] = 0; | 161 | ctx->wbuf[cnt++] = 0; |
161 | 162 | ||
162 | /* assemble the eight byte counter in the buffer in big-endian */ | 163 | /* assemble the eight byte counter in the buffer in big-endian */ |
163 | /* format */ | 164 | /* format */ |
164 | 165 | ||
165 | ctx->wbuf[14] = htonl((ctx->count[1] << 3) | (ctx->count[0] >> 29)); | 166 | ctx->wbuf[14] = htonl((ctx->count[1] << 3) | (ctx->count[0] >> 29)); |
166 | ctx->wbuf[15] = htonl(ctx->count[0] << 3); | 167 | ctx->wbuf[15] = htonl(ctx->count[0] << 3); |
@@ -175,5 +176,3 @@ void *sha1_end(void *resbuf, sha1_ctx_t *ctx) | |||
175 | 176 | ||
176 | return resbuf; | 177 | return resbuf; |
177 | } | 178 | } |
178 | |||
179 | |||