diff options
author | Todd C. Miller <millert@cvs.openbsd.org> | 2004-05-28 15:10:28 +0000 |
---|---|---|
committer | Todd C. Miller <millert@cvs.openbsd.org> | 2004-05-28 15:10:28 +0000 |
commit | 17d2c85d9d3efc20e6eff3b12f905ed70ba24983 (patch) | |
tree | 99becf88119a703a8b275748133ee7fcde045163 /lib/libc/hash/md5.c | |
parent | c2888a975d59102b19a3bfe63b7e9ac0f50fe419 (diff) |
In the Final function, move the context zeroing into the digest != NULL
scope so that passing a NULL digest is equivalent to the Pad function
(like it used to be). Fixes skey w/ sha1 as noticed by David Krause.
Diffstat (limited to 'lib/libc/hash/md5.c')
-rw-r--r-- | lib/libc/hash/md5.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/libc/hash/md5.c b/lib/libc/hash/md5.c index 85e71d81824..a1ff135e3cf 100644 --- a/lib/libc/hash/md5.c +++ b/lib/libc/hash/md5.c @@ -1,4 +1,4 @@ -/* $OpenBSD: md5.c,v 1.6 2004/05/03 18:07:07 millert Exp $ */ +/* $OpenBSD: md5.c,v 1.7 2004/05/28 15:10:27 millert Exp $ */ /* * This code implements the MD5 message-digest algorithm. @@ -18,7 +18,7 @@ */ #if defined(LIBC_SCCS) && !defined(lint) -static const char rcsid[] = "$OpenBSD: md5.c,v 1.6 2004/05/03 18:07:07 millert Exp $"; +static const char rcsid[] = "$OpenBSD: md5.c,v 1.7 2004/05/28 15:10:27 millert Exp $"; #endif /* LIBC_SCCS and not lint */ #include <sys/types.h> @@ -133,8 +133,8 @@ MD5Final(unsigned char digest[MD5_DIGEST_LENGTH], MD5_CTX *ctx) if (digest != NULL) { for (i = 0; i < 4; i++) PUT_32BIT_LE(digest + i * 4, ctx->state[i]); + memset(ctx, 0, sizeof(*ctx)); } - memset(ctx, 0, sizeof(*ctx)); /* in case it's sensitive */ } |