[dovecot-cvs] dovecot/src/lib sha1.c,1.1,1.2 sha1.h,1.1,1.2

cras at dovecot.org cras at dovecot.org
Fri Jul 30 05:58:25 EEST 2004


Update of /home/cvs/dovecot/src/lib
In directory talvi:/tmp/cvs-serv25821

Modified Files:
	sha1.c sha1.h 
Log Message:
Changed to use standard uint* types rather than u_int*. Also removed
K&R-isms.



Index: sha1.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib/sha1.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- sha1.c	26 Jul 2004 17:07:28 -0000	1.1
+++ sha1.c	30 Jul 2004 02:58:22 -0000	1.2
@@ -34,10 +34,7 @@
  * implemented by Jun-ichiro itojun Itoh <itojun at 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;
 

Index: sha1.h
===================================================================
RCS file: /home/cvs/dovecot/src/lib/sha1.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- sha1.h	26 Jul 2004 17:07:28 -0000	1.1
+++ sha1.h	30 Jul 2004 02:58:22 -0000	1.2
@@ -40,23 +40,23 @@
 
 struct sha1_ctxt {
 	union {
-		u_int8_t	b8[20];
-		u_int32_t	b32[5];
+		uint8_t	b8[20];
+		uint32_t b32[5];
 	} h;
 	union {
-		u_int8_t	b8[8];
-		u_int64_t	b64[1];
+		uint8_t	b8[8];
+		uint64_t b64[1];
 	} c;
 	union {
-		u_int8_t	b8[64];
-		u_int32_t	b32[16];
+		uint8_t	b8[64];
+		uint32_t b32[16];
 	} m;
 	u_int8_t	count;
 };
 
 extern void sha1_init(struct sha1_ctxt *);
 extern void sha1_pad(struct sha1_ctxt *);
-extern void sha1_loop(struct sha1_ctxt *, const u_int8_t *, size_t);
+extern void sha1_loop(struct sha1_ctxt *, const uint8_t *, size_t);
 extern void sha1_result(struct sha1_ctxt *, void *);
 
 



More information about the dovecot-cvs mailing list