diff --git a/lib/libmd/md2.h b/lib/libmd/md2.h index 73e8b5a58dce..9c1ac5d269cc 100644 --- a/lib/libmd/md2.h +++ b/lib/libmd/md2.h @@ -1,5 +1,5 @@ /* MD2.H - header file for MD2C.C - * $Id: md2.h,v 1.5 1997/02/22 15:07:12 peter Exp $ + * $Id: md2.h,v 1.6 1997/08/25 05:24:24 joerg Exp $ */ /* Copyright (C) 1990-2, RSA Data Security, Inc. Created 1990. All @@ -35,6 +35,7 @@ typedef struct MD2Context { __BEGIN_DECLS void MD2Init(MD2_CTX *); void MD2Update(MD2_CTX *, const unsigned char *, unsigned int); +void MD2Pad(MD2_CTX *); void MD2Final(unsigned char [16], MD2_CTX *); char * MD2End(MD2_CTX *, char *); char * MD2File(const char *, char *); diff --git a/lib/libmd/md2c.c b/lib/libmd/md2c.c index ebf9edcbfc43..561337a87ea9 100644 --- a/lib/libmd/md2c.c +++ b/lib/libmd/md2c.c @@ -1,5 +1,5 @@ /* MD2C.C - RSA Data Security, Inc., MD2 message-digest algorithm - * $Id$ + * $Id: md2c.c,v 1.5 1997/02/22 15:07:15 peter Exp $ */ /* Copyright (C) 1990-2, RSA Data Security, Inc. Created 1990. All @@ -131,11 +131,9 @@ unsigned int inputLen; /* length of input block */ inputLen-i); } -/* MD2 finalization. Ends an MD2 message-digest operation, writing the - message digest and zeroizing the context. +/* MD2 padding. */ -void MD2Final (digest, context) -unsigned char digest[16]; /* message digest */ +void MD2Pad (context) MD2_CTX *context; /* context */ { unsigned int index, padLen; @@ -148,6 +146,17 @@ MD2_CTX *context; /* context */ /* Extend with checksum */ MD2Update (context, context->checksum, 16); +} + +/* MD2 finalization. Ends an MD2 message-digest operation, writing the + message digest and zeroizing the context. + */ +void MD2Final (digest, context) +unsigned char digest[16]; /* message digest */ +MD2_CTX *context; /* context */ +{ + /* Do padding */ + MD2Pad (context); /* Store state in digest */ memcpy ((POINTER)digest, (POINTER)context->state, 16); diff --git a/lib/libmd/md4.h b/lib/libmd/md4.h index 10058a858d29..cee0e4a6b10f 100644 --- a/lib/libmd/md4.h +++ b/lib/libmd/md4.h @@ -1,5 +1,5 @@ /* MD4.H - header file for MD4C.C - * $Id: md4.h,v 1.6 1997/02/22 15:07:17 peter Exp $ + * $Id: md4.h,v 1.7 1997/08/25 05:24:24 joerg Exp $ */ /* Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All @@ -37,6 +37,7 @@ typedef struct MD4Context { __BEGIN_DECLS void MD4Init(MD4_CTX *); void MD4Update(MD4_CTX *, const unsigned char *, unsigned int); +void MD4Pad(MD4_CTX *); void MD4Final(unsigned char [16], MD4_CTX *); char * MD4End(MD4_CTX *, char *); char * MD4File(const char *, char *); diff --git a/lib/libmd/md4c.c b/lib/libmd/md4c.c index a0eba4d8cf58..71c3af7ffd7a 100644 --- a/lib/libmd/md4c.c +++ b/lib/libmd/md4c.c @@ -1,5 +1,5 @@ /* MD4C.C - RSA Data Security, Inc., MD4 message-digest algorithm - * $Id$ + * $Id: md4c.c,v 1.5 1997/02/22 15:07:19 peter Exp $ */ /* Copyright (C) 1990-2, RSA Data Security, Inc. All rights reserved. @@ -141,11 +141,8 @@ unsigned int inputLen; /* length of input block */ inputLen-i); } -/* MD4 finalization. Ends an MD4 message-digest operation, writing the - the message digest and zeroizing the context. - */ -void MD4Final (digest, context) -unsigned char digest[16]; /* message digest */ +/* MD4 padding. */ +void MD4Pad (context) MD4_CTX *context; /* context */ { unsigned char bits[8]; @@ -162,6 +159,18 @@ MD4_CTX *context; /* context */ /* Append length (before padding) */ MD4Update (context, bits, 8); +} + +/* MD4 finalization. Ends an MD4 message-digest operation, writing the + the message digest and zeroizing the context. + */ +void MD4Final (digest, context) +unsigned char digest[16]; /* message digest */ +MD4_CTX *context; /* context */ +{ + /* Do padding */ + MD4Pad (context); + /* Store state in digest */ Encode (digest, context->state, 16); diff --git a/lib/libmd/md5c.c b/lib/libmd/md5c.c index 583d009d97f1..c1fdc6d864f2 100644 --- a/lib/libmd/md5c.c +++ b/lib/libmd/md5c.c @@ -22,7 +22,7 @@ * These notices must be retained in any copies of any part of this * documentation and/or software. * - * $Id$ + * $Id: md5c.c,v 1.10 1997/10/21 13:28:36 phk Exp $ * * This code is the same as the code published by RSA Inc. It has been * edited for clarity and style only. @@ -31,7 +31,6 @@ #include #ifdef KERNEL -#include #include #else #include @@ -174,7 +173,7 @@ MD5Update (context, input, inputLen) /* Transform as many times as possible. */ if (inputLen >= partLen) { - memcpy((void *)&context->buffer[index], (void *)input, + memcpy((void *)&context->buffer[index], (const void *)input, partLen); MD5Transform (context->state, context->buffer); @@ -187,18 +186,16 @@ MD5Update (context, input, inputLen) i = 0; /* Buffer remaining input */ - memcpy ((void *)&context->buffer[index], (void *)&input[i], + memcpy ((void *)&context->buffer[index], (const void *)&input[i], inputLen-i); } /* - * MD5 finalization. Ends an MD5 message-digest operation, writing the - * the message digest and zeroizing the context. + * MD5 padding. Adds padding followed by original length. */ void -MD5Final (digest, context) - unsigned char digest[16]; +MD5Pad (context) MD5_CTX *context; { unsigned char bits[8]; @@ -214,6 +211,20 @@ MD5Final (digest, context) /* Append length (before padding) */ MD5Update (context, bits, 8); +} + +/* + * MD5 finalization. Ends an MD5 message-digest operation, writing the + * the message digest and zeroizing the context. + */ + +void +MD5Final (digest, context) + unsigned char digest[16]; + MD5_CTX *context; +{ + /* Do padding. */ + MD5Pad (context); /* Store state in digest */ Encode (digest, context->state, 16); diff --git a/lib/libmd/mdX.3 b/lib/libmd/mdX.3 index 7174f7d24750..21e4d45875e2 100644 --- a/lib/libmd/mdX.3 +++ b/lib/libmd/mdX.3 @@ -6,7 +6,7 @@ .\" this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp .\" ---------------------------------------------------------------------------- .\" -.\" $Id: mdX.3,v 1.11 1997/08/25 05:24:25 joerg Exp $ +.\" $Id: mdX.3,v 1.12 1998/03/19 07:34:12 charnier Exp $ .\" .Dd October 9, 1996 .Dt MDX 3 @@ -14,6 +14,7 @@ .Sh NAME .Nm MDXInit , .Nm MDXUpdate , +.Nm MDXPad , .Nm MDXFinal , .Nm MDXEnd , .Nm MDXFile , @@ -27,6 +28,8 @@ .Ft void .Fn MDXUpdate "MDX_CTX *context" "const unsigned char *data" "unsigned int len" .Ft void +.Fn MDXPad "MDX_CTX *context" +.Ft void .Fn MDXFinal "unsigned char digest[16]" "MDX_CTX *context" .Ft "char *" .Fn MDXEnd "MDX_CTX *context" "char *buf" @@ -59,6 +62,12 @@ run over the data with and finally extract the result using .Fn MDXFinal . .Pp +.Fn MDXPad +can be used to pad message data in same way +as done by +.Fn MDXFinal +without terminating calculation. +.Pp .Fn MDXEnd is a wrapper for .Fn MDXFinal diff --git a/sys/kern/md5c.c b/sys/kern/md5c.c index 606e3c86f1ec..c1fdc6d864f2 100644 --- a/sys/kern/md5c.c +++ b/sys/kern/md5c.c @@ -22,7 +22,7 @@ * These notices must be retained in any copies of any part of this * documentation and/or software. * - * $Id: md5c.c,v 1.9 1997/08/02 14:31:35 bde Exp $ + * $Id: md5c.c,v 1.10 1997/10/21 13:28:36 phk Exp $ * * This code is the same as the code published by RSA Inc. It has been * edited for clarity and style only. @@ -191,13 +191,11 @@ MD5Update (context, input, inputLen) } /* - * MD5 finalization. Ends an MD5 message-digest operation, writing the - * the message digest and zeroizing the context. + * MD5 padding. Adds padding followed by original length. */ void -MD5Final (digest, context) - unsigned char digest[16]; +MD5Pad (context) MD5_CTX *context; { unsigned char bits[8]; @@ -213,6 +211,20 @@ MD5Final (digest, context) /* Append length (before padding) */ MD5Update (context, bits, 8); +} + +/* + * MD5 finalization. Ends an MD5 message-digest operation, writing the + * the message digest and zeroizing the context. + */ + +void +MD5Final (digest, context) + unsigned char digest[16]; + MD5_CTX *context; +{ + /* Do padding. */ + MD5Pad (context); /* Store state in digest */ Encode (digest, context->state, 16); diff --git a/sys/sys/md5.h b/sys/sys/md5.h index d06cef85f51a..f8f4469882c6 100644 --- a/sys/sys/md5.h +++ b/sys/sys/md5.h @@ -1,5 +1,5 @@ /* MD5.H - header file for MD5C.C - * $Id: md5.h,v 1.8 1997/02/22 09:45:33 peter Exp $ + * $Id: md5.h,v 1.9 1997/08/25 05:24:31 joerg Exp $ */ /* Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All @@ -38,6 +38,7 @@ typedef struct MD5Context { __BEGIN_DECLS void MD5Init (MD5_CTX *); void MD5Update (MD5_CTX *, const unsigned char *, unsigned int); +void MD5Pad (MD5_CTX *); void MD5Final (unsigned char [16], MD5_CTX *); char * MD5End(MD5_CTX *, char *); char * MD5File(const char *, char *);