aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGlenn L McGrath <bug1@ihug.co.nz>2003-11-20 06:27:33 +0000
committerGlenn L McGrath <bug1@ihug.co.nz>2003-11-20 06:27:33 +0000
commit0413af0e275ec0f899b2bd4f06af2c43017f8296 (patch)
tree9eb02f2f111730b1ac74ed2d956ecd1f5a836657
parent5c069aaf2f3a6848cb9c30c1e9e47069d48cd2f3 (diff)
downloadbusybox-w32-0413af0e275ec0f899b2bd4f06af2c43017f8296.tar.gz
busybox-w32-0413af0e275ec0f899b2bd4f06af2c43017f8296.tar.bz2
busybox-w32-0413af0e275ec0f899b2bd4f06af2c43017f8296.zip
Superficial changes
-rw-r--r--libbb/hash_fd.c36
1 files changed, 17 insertions, 19 deletions
diff --git a/libbb/hash_fd.c b/libbb/hash_fd.c
index b95c1369b..ad0e4f446 100644
--- a/libbb/hash_fd.c
+++ b/libbb/hash_fd.c
@@ -106,13 +106,13 @@
106 e = d; d = c; c = rotl32(b, 30); b = t 106 e = d; d = c; c = rotl32(b, 30); b = t
107 107
108/* type to hold the SHA1 context */ 108/* type to hold the SHA1 context */
109typedef struct { 109typedef struct sha1_ctx_s {
110 uint32_t count[2]; 110 uint32_t count[2];
111 uint32_t hash[5]; 111 uint32_t hash[5];
112 uint32_t wbuf[16]; 112 uint32_t wbuf[16];
113} sha1_ctx; 113} sha1_ctx_t;
114 114
115static void sha1_compile(sha1_ctx ctx[1]) 115static void sha1_compile(sha1_ctx_t *ctx)
116{ 116{
117 uint32_t w[80], i, a, b, c, d, e, t; 117 uint32_t w[80], i, a, b, c, d, e, t;
118 118
@@ -154,7 +154,7 @@ static void sha1_compile(sha1_ctx ctx[1])
154 ctx->hash[4] += e; 154 ctx->hash[4] += e;
155} 155}
156 156
157static void sha1_begin(sha1_ctx ctx[1]) 157static void sha1_begin(sha1_ctx_t *ctx)
158{ 158{
159 ctx->count[0] = ctx->count[1] = 0; 159 ctx->count[0] = ctx->count[1] = 0;
160 ctx->hash[0] = 0x67452301; 160 ctx->hash[0] = 0x67452301;
@@ -166,7 +166,7 @@ static void sha1_begin(sha1_ctx ctx[1])
166 166
167/* SHA1 hash data in an array of bytes into hash buffer and call the */ 167/* SHA1 hash data in an array of bytes into hash buffer and call the */
168/* hash_compile function as required. */ 168/* hash_compile function as required. */
169static void sha1_hash(const unsigned char data[], unsigned int len, sha1_ctx ctx[1]) 169static void sha1_hash(const unsigned char data[], unsigned int len, sha1_ctx_t *ctx)
170{ 170{
171 uint32_t pos = (uint32_t) (ctx->count[0] & SHA1_MASK), 171 uint32_t pos = (uint32_t) (ctx->count[0] & SHA1_MASK),
172 freeb = SHA1_BLOCK_SIZE - pos; 172 freeb = SHA1_BLOCK_SIZE - pos;
@@ -196,7 +196,7 @@ static uint32_t mask[4] = { 0x00000000, 0xff000000, 0xffff0000, 0xffffff00 };
196static uint32_t bits[4] = { 0x80000000, 0x00800000, 0x00008000, 0x00000080 }; 196static uint32_t bits[4] = { 0x80000000, 0x00800000, 0x00008000, 0x00000080 };
197# endif /* __BYTE_ORDER */ 197# endif /* __BYTE_ORDER */
198 198
199void sha1_end(unsigned char hval[], sha1_ctx ctx[1]) 199void sha1_end(unsigned char hval[], sha1_ctx_t *ctx)
200{ 200{
201 uint32_t i, cnt = (uint32_t) (ctx->count[0] & SHA1_MASK); 201 uint32_t i, cnt = (uint32_t) (ctx->count[0] & SHA1_MASK);
202 202
@@ -288,7 +288,7 @@ static const unsigned char fillbuf[64] = { 0x80, 0 /* , 0, 0, ... */ };
288typedef u_int32_t md5_uint32; 288typedef u_int32_t md5_uint32;
289 289
290/* Structure to save state of computation between the single steps. */ 290/* Structure to save state of computation between the single steps. */
291struct md5_ctx { 291typedef struct md5_ctx_s {
292 md5_uint32 A; 292 md5_uint32 A;
293 md5_uint32 B; 293 md5_uint32 B;
294 md5_uint32 C; 294 md5_uint32 C;
@@ -297,12 +297,12 @@ struct md5_ctx {
297 md5_uint32 total[2]; 297 md5_uint32 total[2];
298 md5_uint32 buflen; 298 md5_uint32 buflen;
299 char buffer[128]; 299 char buffer[128];
300}; 300} md5_ctx_t;
301 301
302/* Initialize structure containing state of computation. 302/* Initialize structure containing state of computation.
303 * (RFC 1321, 3.3: Step 3) 303 * (RFC 1321, 3.3: Step 3)
304 */ 304 */
305static void md5_begin(struct md5_ctx *ctx) 305static void md5_begin(md5_ctx_t *ctx)
306{ 306{
307 ctx->A = 0x67452301; 307 ctx->A = 0x67452301;
308 ctx->B = 0xefcdab89; 308 ctx->B = 0xefcdab89;
@@ -328,8 +328,7 @@ static void md5_begin(struct md5_ctx *ctx)
328 * starting at BUFFER. 328 * starting at BUFFER.
329 * It is necessary that LEN is a multiple of 64!!! 329 * It is necessary that LEN is a multiple of 64!!!
330 */ 330 */
331static void md5_hash_block(const void *buffer, size_t len, 331static void md5_hash_block(const void *buffer, size_t len, md5_ctx_t *ctx)
332 struct md5_ctx *ctx)
333{ 332{
334 md5_uint32 correct_words[16]; 333 md5_uint32 correct_words[16];
335 const md5_uint32 *words = buffer; 334 const md5_uint32 *words = buffer;
@@ -670,8 +669,7 @@ static void md5_hash_block(const void *buffer, size_t len,
670 * It is NOT required that LEN is a multiple of 64. 669 * It is NOT required that LEN is a multiple of 64.
671 */ 670 */
672 671
673static void md5_hash_bytes(const void *buffer, size_t len, 672static void md5_hash_bytes(const void *buffer, size_t len, md5_ctx_t *ctx)
674 struct md5_ctx *ctx)
675{ 673{
676 /* When we already have some bits in our internal buffer concatenate 674 /* When we already have some bits in our internal buffer concatenate
677 both inputs first. */ 675 both inputs first. */
@@ -716,7 +714,7 @@ static void md5_hash_bytes(const void *buffer, size_t len,
716 * IMPORTANT: On some systems it is required that RESBUF is correctly 714 * IMPORTANT: On some systems it is required that RESBUF is correctly
717 * aligned for a 32 bits value. 715 * aligned for a 32 bits value.
718 */ 716 */
719static void *md5_end(void *resbuf, struct md5_ctx *ctx) 717static void *md5_end(void *resbuf, md5_ctx_t *ctx)
720{ 718{
721 /* Take yet unprocessed bytes into account. */ 719 /* Take yet unprocessed bytes into account. */
722 md5_uint32 bytes = ctx->buflen; 720 md5_uint32 bytes = ctx->buflen;
@@ -770,10 +768,10 @@ extern int hash_fd(int src_fd, const off_t size, const uint8_t hash_algo,
770 unsigned int blocksize = 0; 768 unsigned int blocksize = 0;
771 unsigned char *buffer = NULL; 769 unsigned char *buffer = NULL;
772#ifdef CONFIG_SHA1SUM 770#ifdef CONFIG_SHA1SUM
773 sha1_ctx sha1_cx[1]; 771 sha1_ctx_t sha1_cx;
774#endif 772#endif
775#ifdef CONFIG_MD5SUM 773#ifdef CONFIG_MD5SUM
776 struct md5_ctx md5_cx; 774 md5_ctx_t md5_cx;
777#endif 775#endif
778 776
779 777
@@ -794,7 +792,7 @@ extern int hash_fd(int src_fd, const off_t size, const uint8_t hash_algo,
794 /* Initialize the computation context. */ 792 /* Initialize the computation context. */
795#ifdef CONFIG_SHA1SUM 793#ifdef CONFIG_SHA1SUM
796 if (hash_algo == HASH_SHA1) { 794 if (hash_algo == HASH_SHA1) {
797 sha1_begin(sha1_cx); 795 sha1_begin(&sha1_cx);
798 } 796 }
799#endif 797#endif
800#ifdef CONFIG_MD5SUM 798#ifdef CONFIG_MD5SUM
@@ -817,7 +815,7 @@ extern int hash_fd(int src_fd, const off_t size, const uint8_t hash_algo,
817 /* Process buffer */ 815 /* Process buffer */
818#ifdef CONFIG_SHA1SUM 816#ifdef CONFIG_SHA1SUM
819 if (hash_algo == HASH_SHA1) { 817 if (hash_algo == HASH_SHA1) {
820 sha1_hash(buffer, count, sha1_cx); 818 sha1_hash(buffer, count, &sha1_cx);
821 } 819 }
822#endif 820#endif
823#ifdef CONFIG_MD5SUM 821#ifdef CONFIG_MD5SUM
@@ -834,7 +832,7 @@ extern int hash_fd(int src_fd, const off_t size, const uint8_t hash_algo,
834 /* Finalize and write the hash into our buffer. */ 832 /* Finalize and write the hash into our buffer. */
835#ifdef CONFIG_SHA1SUM 833#ifdef CONFIG_SHA1SUM
836 if (hash_algo == HASH_SHA1) { 834 if (hash_algo == HASH_SHA1) {
837 sha1_end(hashval, sha1_cx); 835 sha1_end(hashval, &sha1_cx);
838 } 836 }
839#endif 837#endif
840#ifdef CONFIG_MD5SUM 838#ifdef CONFIG_MD5SUM