diff options
author | Todd C. Miller <millert@cvs.openbsd.org> | 1996-09-29 14:55:27 +0000 |
---|---|---|
committer | Todd C. Miller <millert@cvs.openbsd.org> | 1996-09-29 14:55:27 +0000 |
commit | c9262bcc75ddb6b8a2532f7b0c361af53b175a0f (patch) | |
tree | 78c211ddae2aa02e7fc1ba874e5a49ee221a940f /lib/libc/md/md5c.c | |
parent | 0626d2a3680b7e66f0c987b5ad5ddf816b859b6a (diff) |
Now use bittypes wo we work on 64-bit machines
Diffstat (limited to 'lib/libc/md/md5c.c')
-rw-r--r-- | lib/libc/md/md5c.c | 42 |
1 files changed, 20 insertions, 22 deletions
diff --git a/lib/libc/md/md5c.c b/lib/libc/md/md5c.c index 9abf08b2aca..dedb39d8ed0 100644 --- a/lib/libc/md/md5c.c +++ b/lib/libc/md/md5c.c @@ -23,17 +23,15 @@ documentation and/or software. */ #if defined(LIBC_SCCS) && !defined(lint) -static char rcsid[] = "$OpenBSD: md5c.c,v 1.2 1996/08/19 08:28:29 tholo Exp $"; +static char rcsid[] = "$OpenBSD: md5c.c,v 1.3 1996/09/29 14:55:25 millert Exp $"; #endif /* LIBC_SCCS and not lint */ -#include <md5.h> #include <string.h> +#include <sys/types.h> +#include <md5.h> +/* POINTER defines a generic pointer type */ typedef unsigned char *POINTER; -typedef unsigned short int UINT2; -typedef unsigned long int UINT4; - -#define PROTO_LIST(list) list /* Constants for MD5Transform routine. */ @@ -54,18 +52,18 @@ typedef unsigned long int UINT4; #define S43 15 #define S44 21 -static void MD5Transform PROTO_LIST ((UINT4 [4], const unsigned char [64])); +static void MD5Transform __P ((u_int32_t [4], const unsigned char [64])); #ifdef i386 #define Encode memcpy #define Decode memcpy #else /* i386 */ -/* Encodes input (UINT4) into output (unsigned char). Assumes len is +/* Encodes input (u_int32_t) into output (unsigned char). Assumes len is a multiple of 4. */ static void Encode (output, input, len) unsigned char *output; -UINT4 *input; +u_int32_t *input; unsigned int len; { unsigned int i, j; @@ -78,19 +76,19 @@ unsigned int len; } } -/* Decodes input (unsigned char) into output (UINT4). Assumes len is +/* Decodes input (unsigned char) into output (u_int32_t). Assumes len is a multiple of 4. */ static void Decode (output, input, len) -UINT4 *output; +u_int32_t *output; const unsigned char *input; unsigned int len; { unsigned int i, j; for (i = 0, j = 0; j < len; i++, j += 4) - output[i] = ((UINT4)input[j]) | (((UINT4)input[j+1]) << 8) | - (((UINT4)input[j+2]) << 16) | (((UINT4)input[j+3]) << 24); + output[i] = ((u_int32_t)input[j]) | (((u_int32_t)input[j+1]) << 8) | + (((u_int32_t)input[j+2]) << 16) | (((u_int32_t)input[j+3]) << 24); } #endif /* i386 */ @@ -115,22 +113,22 @@ static unsigned char PADDING[64] = { Rotation is separate from addition to prevent recomputation. */ #define FF(a, b, c, d, x, s, ac) { \ - (a) += F ((b), (c), (d)) + (x) + (UINT4)(ac); \ + (a) += F ((b), (c), (d)) + (x) + (u_int32_t)(ac); \ (a) = ROTATE_LEFT ((a), (s)); \ (a) += (b); \ } #define GG(a, b, c, d, x, s, ac) { \ - (a) += G ((b), (c), (d)) + (x) + (UINT4)(ac); \ + (a) += G ((b), (c), (d)) + (x) + (u_int32_t)(ac); \ (a) = ROTATE_LEFT ((a), (s)); \ (a) += (b); \ } #define HH(a, b, c, d, x, s, ac) { \ - (a) += H ((b), (c), (d)) + (x) + (UINT4)(ac); \ + (a) += H ((b), (c), (d)) + (x) + (u_int32_t)(ac); \ (a) = ROTATE_LEFT ((a), (s)); \ (a) += (b); \ } #define II(a, b, c, d, x, s, ac) { \ - (a) += I ((b), (c), (d)) + (x) + (UINT4)(ac); \ + (a) += I ((b), (c), (d)) + (x) + (u_int32_t)(ac); \ (a) = ROTATE_LEFT ((a), (s)); \ (a) += (b); \ } @@ -164,10 +162,10 @@ unsigned int inputLen; /* length of input block */ index = (unsigned int)((context->count[0] >> 3) & 0x3F); /* Update number of bits */ - if ((context->count[0] += ((UINT4)inputLen << 3)) - < ((UINT4)inputLen << 3)) + if ((context->count[0] += ((u_int32_t)inputLen << 3)) + < ((u_int32_t)inputLen << 3)) context->count[1]++; - context->count[1] += ((UINT4)inputLen >> 29); + context->count[1] += ((u_int32_t)inputLen >> 29); partLen = 64 - index; @@ -224,10 +222,10 @@ MD5_CTX *context; /* context */ /* MD5 basic transformation. Transforms state based on block. */ static void MD5Transform (state, block) -UINT4 state[4]; +u_int32_t state[4]; const unsigned char block[64]; { - UINT4 a = state[0], b = state[1], c = state[2], d = state[3], x[16]; + u_int32_t a = state[0], b = state[1], c = state[2], d = state[3], x[16]; Decode (x, block, 64); |