summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorprovos <provos@openbsd.org>1997-07-03 23:30:20 +0000
committerprovos <provos@openbsd.org>1997-07-03 23:30:20 +0000
commit379ca6e6a6084d9512273f834d08bb1b71393f74 (patch)
treec06172e545a5a3d5f5b706f16679886a1dbb4e6a /lib
parentThere is no undelete(2) manpage. (diff)
downloadwireguard-openbsd-379ca6e6a6084d9512273f834d08bb1b71393f74.tar.xz
wireguard-openbsd-379ca6e6a6084d9512273f834d08bb1b71393f74.zip
MD[45]Final(NULL,&ctx) applies padding to context and can still be used with M[45]Update afterwards.
Diffstat (limited to 'lib')
-rw-r--r--lib/libc/md/md4c.c15
-rw-r--r--lib/libc/md/md5c.c13
-rw-r--r--lib/libc/md/mdX.37
3 files changed, 23 insertions, 12 deletions
diff --git a/lib/libc/md/md4c.c b/lib/libc/md/md4c.c
index f85d41cc6c3..c1af994a56d 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.9 1997/04/30 05:56:05 tholo Exp $";
+static char rcsid[] = "$OpenBSD: md4c.c,v 1.10 1997/07/03 23:30:20 provos Exp $";
#endif /* LIBC_SCCS and not lint */
#include <string.h>
@@ -205,12 +205,15 @@ MD4_CTX *context; /* context */
/* Append length (before padding) */
MD4Update (context, bits, 8);
- /* Store state in digest */
- Encode (digest, context->state, 16);
- /* Zeroize sensitive information.
- */
- memset ((POINTER)context, 0, sizeof (*context));
+ if (digest != NULL) {
+ /* Store state in digest */
+ Encode (digest, context->state, 16);
+
+ /* Zeroize sensitive information.
+ */
+ memset ((POINTER)context, 0, sizeof (*context));
+ }
}
/* MD4 basic transformation. Transforms state based on block.
diff --git a/lib/libc/md/md5c.c b/lib/libc/md/md5c.c
index 672c45afffc..520ef87bc90 100644
--- a/lib/libc/md/md5c.c
+++ b/lib/libc/md/md5c.c
@@ -23,7 +23,7 @@ documentation and/or software.
*/
#if defined(LIBC_SCCS) && !defined(lint)
-static char rcsid[] = "$OpenBSD: md5c.c,v 1.9 1997/04/30 05:56:06 tholo Exp $";
+static char rcsid[] = "$OpenBSD: md5c.c,v 1.10 1997/07/03 23:30:21 provos Exp $";
#endif /* LIBC_SCCS and not lint */
#include <string.h>
@@ -216,11 +216,14 @@ MD5_CTX *context; /* context */
/* Append length (before padding) */
MD5Update (context, bits, 8);
- /* Store state in digest */
- Encode (digest, context->state, 16);
- /* Zeroize sensitive information. */
- memset ((POINTER)context, 0, sizeof (*context));
+ if (digest != NULL) {
+ /* Store state in digest */
+ Encode (digest, context->state, 16);
+
+ /* Zeroize sensitive information. */
+ memset ((POINTER)context, 0, sizeof (*context));
+ }
}
/* MD5 basic transformation. Transforms state based on block.
diff --git a/lib/libc/md/mdX.3 b/lib/libc/md/mdX.3
index 70d5f0aabe3..842ab175ef6 100644
--- a/lib/libc/md/mdX.3
+++ b/lib/libc/md/mdX.3
@@ -6,7 +6,7 @@
.\" this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp
.\" ----------------------------------------------------------------------------
.\"
-.\" $OpenBSD: mdX.3,v 1.6 1997/06/05 21:12:47 provos Exp $
+.\" $OpenBSD: mdX.3,v 1.7 1997/07/03 23:30:22 provos Exp $
.\"
.Dd October 9, 1996
.Dt MDX 3
@@ -57,6 +57,11 @@ run over the data with
.Fn MDXUpdate ,
and finally extract the result using
.Fn MDXFinal .
+When a null pointer is passed to
+.Fn MDXFinal
+as first argument only the final padding will be applied and the
+current context can still be used with
+.Fn MDXUpdate .
.Pp
.Fn MDXEnd
is a wrapper for