Sync MD5 changes from OpenBSD
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
diff --git a/include/md5.h b/include/md5.h
index 596b276..a6d5ed4 100644
--- a/include/md5.h
+++ b/include/md5.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: md5.h,v 1.15 2004/05/03 17:30:14 millert Exp $ */
+/* $OpenBSD: md5.h,v 1.17 2012/12/05 23:19:57 deraadt Exp $ */
/*
* This code implements the MD5 message-digest algorithm.
diff --git a/src/md5.c b/src/md5.c
index a6877bc..450415b 100644
--- a/src/md5.c
+++ b/src/md5.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: md5.c,v 1.7 2004/05/28 15:10:27 millert Exp $ */
+/* $OpenBSD: md5.c,v 1.12 2020/10/13 04:42:28 guenther Exp $ */
/*
* This code implements the MD5 message-digest algorithm.
@@ -39,7 +39,7 @@
(cp)[1] = (value) >> 8; \
(cp)[0] = (value); } while (0)
-static uint8_t PADDING[MD5_BLOCK_LENGTH] = {
+static const uint8_t PADDING[MD5_BLOCK_LENGTH] = {
0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
@@ -128,11 +128,9 @@ MD5Final(unsigned char digest[MD5_DIGEST_LENGTH], MD5_CTX *ctx)
int i;
MD5Pad(ctx);
- if (digest != NULL) {
- for (i = 0; i < 4; i++)
- PUT_32BIT_LE(digest + i * 4, ctx->state[i]);
- memset(ctx, 0, sizeof(*ctx));
- }
+ for (i = 0; i < 4; i++)
+ PUT_32BIT_LE(digest + i * 4, ctx->state[i]);
+ memset(ctx, 0, sizeof(*ctx));
}