summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>1996-09-29 14:55:27 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>1996-09-29 14:55:27 +0000
commitc9262bcc75ddb6b8a2532f7b0c361af53b175a0f (patch)
tree78c211ddae2aa02e7fc1ba874e5a49ee221a940f /lib
parent0626d2a3680b7e66f0c987b5ad5ddf816b859b6a (diff)
Now use bittypes wo we work on 64-bit machines
Diffstat (limited to 'lib')
-rw-r--r--lib/libc/md/md4c.c46
-rw-r--r--lib/libc/md/md5c.c42
-rw-r--r--lib/libc/md/mdXhl.c17
3 files changed, 54 insertions, 51 deletions
diff --git a/lib/libc/md/md4c.c b/lib/libc/md/md4c.c
index d604bd388ab..35f3b1ae27e 100644
--- a/lib/libc/md/md4c.c
+++ b/lib/libc/md/md4c.c
@@ -22,17 +22,15 @@
*/
#if defined(LIBC_SCCS) && !defined(lint)
-static char rcsid[] = "$OpenBSD: md4c.c,v 1.2 1996/08/19 08:28:26 tholo Exp $";
+static char rcsid[] = "$OpenBSD: md4c.c,v 1.3 1996/09/29 14:55:25 millert Exp $";
#endif /* LIBC_SCCS and not lint */
-#include <md4.h>
#include <string.h>
+#include <sys/types.h>
+#include <md4.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 MD4Transform routine.
*/
@@ -49,11 +47,11 @@ typedef unsigned long int UINT4;
#define S33 11
#define S34 15
-static void MD4Transform PROTO_LIST ((UINT4 [4], const unsigned char [64]));
-static void Encode PROTO_LIST
- ((unsigned char *, UINT4 *, unsigned int));
-static void Decode PROTO_LIST
- ((UINT4 *, const unsigned char *, unsigned int));
+static void MD4Transform __P ((u_int32_t [4], const unsigned char [64]));
+static void Encode __P
+ ((unsigned char *, u_int32_t *, unsigned int));
+static void Decode __P
+ ((u_int32_t *, const unsigned char *, unsigned int));
static unsigned char PADDING[64] = {
0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
@@ -78,11 +76,11 @@ static unsigned char PADDING[64] = {
(a) = ROTATE_LEFT ((a), (s)); \
}
#define GG(a, b, c, d, x, s) { \
- (a) += G ((b), (c), (d)) + (x) + (UINT4)0x5a827999; \
+ (a) += G ((b), (c), (d)) + (x) + (u_int32_t)0x5a827999; \
(a) = ROTATE_LEFT ((a), (s)); \
}
#define HH(a, b, c, d, x, s) { \
- (a) += H ((b), (c), (d)) + (x) + (UINT4)0x6ed9eba1; \
+ (a) += H ((b), (c), (d)) + (x) + (u_int32_t)0x6ed9eba1; \
(a) = ROTATE_LEFT ((a), (s)); \
}
@@ -115,10 +113,10 @@ unsigned int inputLen; /* length of input block */
/* Compute number of bytes mod 64 */
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;
/* Transform as many times as possible.
@@ -174,10 +172,10 @@ MD4_CTX *context; /* context */
/* MD4 basic transformation. Transforms state based on block.
*/
static void MD4Transform (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);
@@ -245,12 +243,12 @@ const unsigned char block[64];
memset ((POINTER)x, 0, sizeof (x));
}
-/* 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;
@@ -263,18 +261,18 @@ 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);
}
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);
diff --git a/lib/libc/md/mdXhl.c b/lib/libc/md/mdXhl.c
index c8724b0fa32..cda72b02fcf 100644
--- a/lib/libc/md/mdXhl.c
+++ b/lib/libc/md/mdXhl.c
@@ -8,21 +8,23 @@
*/
#if defined(LIBC_SCCS) && !defined(lint)
-static char rcsid[] = "$OpenBSD: mdXhl.c,v 1.3 1996/09/15 09:31:16 tholo Exp $";
+static char rcsid[] = "$OpenBSD: mdXhl.c,v 1.4 1996/09/29 14:55:26 millert Exp $";
#endif /* LIBC_SCCS and not lint */
#include <stdlib.h>
#include <stdio.h>
#include <errno.h>
-#include "mdX.h"
#include <sys/file.h>
#include <sys/types.h>
#include <sys/uio.h>
#include <unistd.h>
+#include "mdX.h"
/* ARGSUSED */
char *
-MDXEnd(MDX_CTX *ctx, char *buf)
+MDXEnd(ctx, buf)
+ MDX_CTX *ctx;
+ char *buf;
{
int i;
char *p = malloc(33);
@@ -43,7 +45,9 @@ MDXEnd(MDX_CTX *ctx, char *buf)
}
char *
-MDXFile (char *filename, char *buf)
+MDXFile (filename, buf)
+ char *filename;
+ char *buf;
{
unsigned char buffer[BUFSIZ];
MDX_CTX ctx;
@@ -63,7 +67,10 @@ MDXFile (char *filename, char *buf)
}
char *
-MDXData (const unsigned char *data, unsigned int len, char *buf)
+MDXData (data, len, buf)
+ const unsigned char *data;
+ unsigned int len;
+ char *buf;
{
MDX_CTX ctx;