summaryrefslogtreecommitdiff
path: root/lib/libc/hash
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>2002-12-23 04:33:32 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>2002-12-23 04:33:32 +0000
commit240d00ccd27633050d6be0531a777f845b5b5440 (patch)
tree29cb992a046c08dd2cfb239776fcbb1a8c6be710 /lib/libc/hash
parent29b88a9674bfc30b4c7a4401f9169584b56e571a (diff)
o Ansi function headers
o Add __BEGIN_DECLS/__END_DECLS to include files o Safe macros o Remove useless variable assignment in the End function of *hl.c o Some minor KNF, needs more From Dan Weeks
Diffstat (limited to 'lib/libc/hash')
-rw-r--r--lib/libc/hash/rmd160.c34
-rw-r--r--lib/libc/hash/rmd160hl.c30
-rw-r--r--lib/libc/hash/sha1.c26
-rw-r--r--lib/libc/hash/sha1hl.c28
4 files changed, 51 insertions, 67 deletions
diff --git a/lib/libc/hash/rmd160.c b/lib/libc/hash/rmd160.c
index 2826a62727c..a8c6a409611 100644
--- a/lib/libc/hash/rmd160.c
+++ b/lib/libc/hash/rmd160.c
@@ -32,23 +32,23 @@
#include <rmd160.h>
#if defined(LIBC_SCCS) && !defined(lint)
-static char rcsid[] = "$OpenBSD: rmd160.c,v 1.11 2001/10/01 20:36:17 markus Exp $";
+static char rcsid[] = "$OpenBSD: rmd160.c,v 1.12 2002/12/23 04:33:31 millert Exp $";
#endif /* LIBC_SCCS and not lint */
-#define PUT_64BIT_LE(cp, value) do { \
- (cp)[7] = (value) >> 56; \
- (cp)[6] = (value) >> 48; \
- (cp)[5] = (value) >> 40; \
- (cp)[4] = (value) >> 32; \
- (cp)[3] = (value) >> 24; \
- (cp)[2] = (value) >> 16; \
- (cp)[1] = (value) >> 8; \
+#define PUT_64BIT_LE(cp, value) do { \
+ (cp)[7] = (value) >> 56; \
+ (cp)[6] = (value) >> 48; \
+ (cp)[5] = (value) >> 40; \
+ (cp)[4] = (value) >> 32; \
+ (cp)[3] = (value) >> 24; \
+ (cp)[2] = (value) >> 16; \
+ (cp)[1] = (value) >> 8; \
(cp)[0] = (value); } while (0)
-#define PUT_32BIT_LE(cp, value) do { \
- (cp)[3] = (value) >> 24; \
- (cp)[2] = (value) >> 16; \
- (cp)[1] = (value) >> 8; \
+#define PUT_32BIT_LE(cp, value) do { \
+ (cp)[3] = (value) >> 24; \
+ (cp)[2] = (value) >> 16; \
+ (cp)[1] = (value) >> 8; \
(cp)[0] = (value); } while (0)
#define H0 0x67452301U
@@ -78,10 +78,10 @@ static char rcsid[] = "$OpenBSD: rmd160.c,v 1.11 2001/10/01 20:36:17 markus Exp
#define F3(x, y, z) (((x) & (z)) | ((y) & (~z)))
#define F4(x, y, z) ((x) ^ ((y) | (~z)))
-#define R(a, b, c, d, e, Fj, Kj, sj, rj) \
- do { \
- a = ROL(sj, a + Fj(b,c,d) + X(rj) + Kj) + e; \
- c = ROL(10, c); \
+#define R(a, b, c, d, e, Fj, Kj, sj, rj) \
+ do { \
+ a = ROL(sj, a + Fj(b,c,d) + X(rj) + Kj) + e; \
+ c = ROL(10, c); \
} while(0)
#define X(i) x[i]
diff --git a/lib/libc/hash/rmd160hl.c b/lib/libc/hash/rmd160hl.c
index 06511336938..bf0060029be 100644
--- a/lib/libc/hash/rmd160hl.c
+++ b/lib/libc/hash/rmd160hl.c
@@ -8,7 +8,7 @@
*/
#if defined(LIBC_SCCS) && !defined(lint)
-static char rcsid[] = "$OpenBSD: rmd160hl.c,v 1.2 1999/08/17 09:13:12 millert Exp $";
+static char rcsid[] = "$OpenBSD: rmd160hl.c,v 1.3 2002/12/23 04:33:31 millert Exp $";
#endif /* LIBC_SCCS and not lint */
#include <stdlib.h>
@@ -22,31 +22,26 @@ static char rcsid[] = "$OpenBSD: rmd160hl.c,v 1.2 1999/08/17 09:13:12 millert Ex
/* ARGSUSED */
char *
-RMD160End(ctx, buf)
- RMD160_CTX *ctx;
- char *buf;
+RMD160End(RMD160_CTX *ctx, char *buf)
{
int i;
- char *p = buf;
u_char digest[20];
static const char hex[]="0123456789abcdef";
- if (p == NULL && (p = malloc(41)) == NULL)
- return 0;
+ if (buf == NULL && (buf = malloc(41)) == NULL)
+ return(NULL);
- RMD160Final(digest,ctx);
+ RMD160Final(digest, ctx);
for (i = 0; i < 20; i++) {
- p[i + i] = hex[digest[i] >> 4];
- p[i + i + 1] = hex[digest[i] & 0x0f];
+ buf[i + i] = hex[digest[i] >> 4];
+ buf[i + i + 1] = hex[digest[i] & 0x0f];
}
- p[i + i] = '\0';
- return(p);
+ buf[i + i] = '\0';
+ return(buf);
}
char *
-RMD160File (filename, buf)
- char *filename;
- char *buf;
+RMD160File (char *filename, char *buf)
{
u_char buffer[BUFSIZ];
RMD160_CTX ctx;
@@ -67,10 +62,7 @@ RMD160File (filename, buf)
}
char *
-RMD160Data (data, len, buf)
- const u_char *data;
- size_t len;
- char *buf;
+RMD160Data (const u_char *data, size_t len, char *buf)
{
RMD160_CTX ctx;
diff --git a/lib/libc/hash/sha1.c b/lib/libc/hash/sha1.c
index 7b11732e925..def87a5b6d9 100644
--- a/lib/libc/hash/sha1.c
+++ b/lib/libc/hash/sha1.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sha1.c,v 1.9 1997/07/23 21:12:32 kstailey Exp $ */
+/* $OpenBSD: sha1.c,v 1.10 2002/12/23 04:33:31 millert Exp $ */
/*
* SHA-1 in C
@@ -14,6 +14,10 @@
* 34AA973C D4C4DAA4 F61EEB2B DBAD2731 6534016F
*/
+#if defined(LIBC_SCCS) && !defined(lint)
+static char rcsid[] = "$OpenBSD: sha1.c,v 1.10 2002/12/23 04:33:31 millert Exp $";
+#endif /* LIBC_SCCS and not lint */
+
#define SHA1HANDSOFF /* Copies data before messing with it. */
#include <sys/param.h>
@@ -48,9 +52,8 @@
/*
* Hash a single 512-bit block. This is the core of the algorithm.
*/
-void SHA1Transform(state, buffer)
- u_int32_t state[5];
- const u_char buffer[64];
+void
+SHA1Transform(u_int32_t state[5], const u_char buffer[64])
{
u_int32_t a, b, c, d, e;
typedef union {
@@ -111,8 +114,8 @@ void SHA1Transform(state, buffer)
/*
* SHA1Init - Initialize new context
*/
-void SHA1Init(context)
- SHA1_CTX *context;
+void
+SHA1Init(SHA1_CTX *context)
{
/* SHA1 initialization constants */
@@ -128,10 +131,8 @@ void SHA1Init(context)
/*
* Run your data through this.
*/
-void SHA1Update(context, data, len)
- SHA1_CTX *context;
- const u_char *data;
- u_int len;
+void
+SHA1Update(SHA1_CTX *context, const u_char *data, u_int len)
{
u_int i, j;
@@ -155,9 +156,8 @@ void SHA1Update(context, data, len)
/*
* Add padding and return the message digest.
*/
-void SHA1Final(digest, context)
- u_char digest[20];
- SHA1_CTX* context;
+void
+SHA1Final(u_char digest[20], SHA1_CTX *context)
{
u_int i;
u_char finalcount[8];
diff --git a/lib/libc/hash/sha1hl.c b/lib/libc/hash/sha1hl.c
index 75d65c1a522..a8f3a732ca1 100644
--- a/lib/libc/hash/sha1hl.c
+++ b/lib/libc/hash/sha1hl.c
@@ -8,7 +8,7 @@
*/
#if defined(LIBC_SCCS) && !defined(lint)
-static char rcsid[] = "$OpenBSD: sha1hl.c,v 1.2 1999/08/17 09:13:12 millert Exp $";
+static char rcsid[] = "$OpenBSD: sha1hl.c,v 1.3 2002/12/23 04:33:31 millert Exp $";
#endif /* LIBC_SCCS and not lint */
#include <stdlib.h>
@@ -22,31 +22,26 @@ static char rcsid[] = "$OpenBSD: sha1hl.c,v 1.2 1999/08/17 09:13:12 millert Exp
/* ARGSUSED */
char *
-SHA1End(ctx, buf)
- SHA1_CTX *ctx;
- char *buf;
+SHA1End(SHA1_CTX *ctx, char *buf)
{
int i;
- char *p = buf;
u_char digest[20];
static const char hex[]="0123456789abcdef";
- if (p == NULL && (p = malloc(41)) == NULL)
- return 0;
+ if (buf == NULL && (buf = malloc(41)) == NULL)
+ return(NULL);
SHA1Final(digest,ctx);
for (i = 0; i < 20; i++) {
- p[i + i] = hex[digest[i] >> 4];
- p[i + i + 1] = hex[digest[i] & 0x0f];
+ buf[i + i] = hex[digest[i] >> 4];
+ buf[i + i + 1] = hex[digest[i] & 0x0f];
}
- p[i + i] = '\0';
- return(p);
+ buf[i + i] = '\0';
+ return(buf);
}
char *
-SHA1File (filename, buf)
- char *filename;
- char *buf;
+SHA1File (char *filename, char *buf)
{
u_char buffer[BUFSIZ];
SHA1_CTX ctx;
@@ -67,10 +62,7 @@ SHA1File (filename, buf)
}
char *
-SHA1Data (data, len, buf)
- const u_char *data;
- size_t len;
- char *buf;
+SHA1Data (const u_char *data, size_t len, char *buf)
{
SHA1_CTX ctx;