Mercurial > dovecot > original-hg > dovecot-1.2
diff src/lib/sha1.c @ 2385:161a9e818ad6 HEAD
Changed to use standard uint* types rather than u_int*. Also removed
K&R-isms.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Fri, 30 Jul 2004 05:58:22 +0300 |
parents | eda658b1557e |
children | 59059ea978b2 |
line wrap: on
line diff
--- a/src/lib/sha1.c Fri Jul 30 05:07:47 2004 +0300 +++ b/src/lib/sha1.c Fri Jul 30 05:58:22 2004 +0300 @@ -34,10 +34,7 @@ * implemented by Jun-ichiro itojun Itoh <itojun@itojun.org> */ -#include <sys/types.h> -#include <sys/time.h> -#include <string.h> - +#include "lib.h" #include "sha1.h" #include "safe-memset.h" @@ -51,7 +48,7 @@ #ifndef unsupported /* constant table */ -static u_int32_t _K[] = { 0x5a827999, 0x6ed9eba1, 0x8f1bbcdc, 0xca62c1d6 }; +static uint32_t _K[] = { 0x5a827999, 0x6ed9eba1, 0x8f1bbcdc, 0xca62c1d6 }; #define K(t) _K[(t) / 20] #define F0(b, c, d) (((b) & (c)) | ((~(b)) & (d))) @@ -86,12 +83,11 @@ static void sha1_step(struct sha1_ctxt *); static void -sha1_step(ctxt) - struct sha1_ctxt *ctxt; +sha1_step(struct sha1_ctxt *ctxt) { - u_int32_t a, b, c, d, e; + uint32_t a, b, c, d, e; size_t t, s; - u_int32_t tmp; + uint32_t tmp; #if BYTE_ORDER == LITTLE_ENDIAN struct sha1_ctxt tctxt; @@ -171,8 +167,7 @@ /*------------------------------------------------------------*/ void -sha1_init(ctxt) - struct sha1_ctxt *ctxt; +sha1_init(struct sha1_ctxt *ctxt) { memset(ctxt, 0, sizeof(struct sha1_ctxt)); H(0) = 0x67452301; @@ -183,8 +178,7 @@ } void -sha1_pad(ctxt) - struct sha1_ctxt *ctxt; +sha1_pad(struct sha1_ctxt *ctxt) { size_t padlen; /*pad length in bytes*/ size_t padstart; @@ -218,10 +212,7 @@ } void -sha1_loop(ctxt, input, len) - struct sha1_ctxt *ctxt; - const u_int8_t *input; - size_t len; +sha1_loop(struct sha1_ctxt *ctxt, const uint8_t *input, size_t len) { size_t gaplen; size_t gapstart; @@ -246,13 +237,11 @@ } void -sha1_result(ctxt, digest0) - struct sha1_ctxt *ctxt; - void *digest0; +sha1_result(struct sha1_ctxt *ctxt, void *digest0) { - u_int8_t *digest; + uint8_t *digest; - digest = (u_int8_t *)digest0; + digest = (uint8_t *)digest0; sha1_pad(ctxt); #if BYTE_ORDER == BIG_ENDIAN memmove(digest, &ctxt->h.b8[0], 20); @@ -271,10 +260,8 @@ safe_memset(ctxt, 0, sizeof(struct sha1_ctxt)); } -void sha1_get_digest(data, size, result) - const void *data; - size_t size; - unsigned char result[SHA1_RESULTLEN]; +void sha1_get_digest(const void *data, size_t size, + unsigned char result[SHA1_RESULTLEN]) { struct sha1_ctxt ctx;