summaryrefslogtreecommitdiff
path: root/lib/libc/md/md4c.c
diff options
context:
space:
mode:
authorNiklas Hallqvist <niklas@cvs.openbsd.org>1996-11-24 02:26:01 +0000
committerNiklas Hallqvist <niklas@cvs.openbsd.org>1996-11-24 02:26:01 +0000
commit6388d3d9cf07f4ef99b2149951cb5533a69f8912 (patch)
treeebc1a9ef18f305b2559289da5f10ca04db7bddb6 /lib/libc/md/md4c.c
parent2cc34713ef2a7401726ee17cc4419cee9b170cab (diff)
64-bit cleanup + pedantic -W flags
Diffstat (limited to 'lib/libc/md/md4c.c')
-rw-r--r--lib/libc/md/md4c.c33
1 files changed, 15 insertions, 18 deletions
diff --git a/lib/libc/md/md4c.c b/lib/libc/md/md4c.c
index a65c0e8f15f..4f3f9a7a815 100644
--- a/lib/libc/md/md4c.c
+++ b/lib/libc/md/md4c.c
@@ -22,7 +22,7 @@
*/
#if defined(LIBC_SCCS) && !defined(lint)
-static char rcsid[] = "$OpenBSD: md4c.c,v 1.4 1996/10/02 03:50:25 millert Exp $";
+static char rcsid[] = "$OpenBSD: md4c.c,v 1.5 1996/11/24 02:25:58 niklas Exp $";
#endif /* LIBC_SCCS and not lint */
#include <string.h>
@@ -54,9 +54,9 @@ static void MD4Transform __P ((u_int32_t [4], const unsigned char [64]));
#define Decode memcpy
#else /* BIG_ENDIAN */
static void Encode __P
- ((unsigned char *, u_int32_t *, unsigned int));
+ ((unsigned char *, u_int32_t *, size_t));
static void Decode __P
- ((u_int32_t *, const unsigned char *, unsigned int));
+ ((u_int32_t *, const unsigned char *, size_t));
#endif /* LITTLE_ENDIAN */
static unsigned char PADDING[64] = {
@@ -97,9 +97,9 @@ static unsigned char PADDING[64] = {
static void Encode (output, input, len)
unsigned char *output;
u_int32_t *input;
-unsigned int len;
+size_t len;
{
- unsigned int i, j;
+ size_t i, j;
for (i = 0, j = 0; j < len; i++, j += 4) {
output[j] = (unsigned char)(input[i] & 0xff);
@@ -115,9 +115,9 @@ unsigned int len;
static void Decode (output, input, len)
u_int32_t *output;
const unsigned char *input;
-unsigned int len;
+size_t len;
{
- unsigned int i, j;
+ size_t i, j;
for (i = 0, j = 0; j < len; i++, j += 4)
output[i] = ((u_int32_t)input[j]) | (((u_int32_t)input[j+1]) << 8) |
@@ -130,7 +130,7 @@ unsigned int len;
void MD4Init (context)
MD4_CTX *context; /* context */
{
- context->count[0] = context->count[1] = 0;
+ context->count = 0;
/* Load magic initialization constants.
*/
@@ -147,21 +147,18 @@ MD4_CTX *context; /* context */
void MD4Update (context, input, inputLen)
MD4_CTX *context; /* context */
const unsigned char *input; /* input block */
-unsigned int inputLen; /* length of input block */
+size_t inputLen; /* length of input block */
{
unsigned int i, index, partLen;
/* Compute number of bytes mod 64 */
- index = (unsigned int)((context->count[0] >> 3) & 0x3F);
+ index = (unsigned int)((context->count >> 3) & 0x3F);
+
/* Update number of bits */
- if ((context->count[0] += ((u_int32_t)inputLen << 3))
- < ((u_int32_t)inputLen << 3))
- context->count[1]++;
- context->count[1] += ((u_int32_t)inputLen >> 29);
+ context->count += (inputLen << 3);
partLen = 64 - index;
- /* Transform as many times as possible.
- */
+ /* Transform as many times as possible. */
if (inputLen >= partLen) {
memcpy
((POINTER)&context->buffer[index], (POINTER)input, partLen);
@@ -192,11 +189,11 @@ MD4_CTX *context; /* context */
unsigned int index, padLen;
/* Save number of bits */
- Encode (bits, context->count, 8);
+ Encode (bits, &context->count, 8);
/* Pad out to 56 mod 64.
*/
- index = (unsigned int)((context->count[0] >> 3) & 0x3f);
+ index = (unsigned int)((context->count >> 3) & 0x3f);
padLen = (index < 56) ? (56 - index) : (120 - index);
MD4Update (context, PADDING, padLen);