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/sha2.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/sha2.c')
-rw-r--r-- | lib/libc/hash/sha2.c | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/lib/libc/hash/sha2.c b/lib/libc/hash/sha2.c index cd95d68064d..c99ed4d6a02 100644 --- a/lib/libc/hash/sha2.c +++ b/lib/libc/hash/sha2.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sha2.c,v 1.9 2004/05/07 14:34:40 millert Exp $ */ +/* $OpenBSD: sha2.c,v 1.10 2004/05/28 15:10:27 millert Exp $ */ /* * FILE: sha2.c @@ -35,7 +35,7 @@ */ #if defined(LIBC_SCCS) && !defined(lint) -static const char rcsid[] = "$OpenBSD: sha2.c,v 1.9 2004/05/07 14:34:40 millert Exp $"; +static const char rcsid[] = "$OpenBSD: sha2.c,v 1.10 2004/05/28 15:10:27 millert Exp $"; #endif /* LIBC_SCCS and not lint */ #include <sys/types.h> @@ -549,10 +549,8 @@ SHA256_Final(u_int8_t digest[SHA256_DIGEST_LENGTH], SHA256_CTX *context) #else memcpy(digest, context->state, SHA256_DIGEST_LENGTH); #endif + memset(context, 0, sizeof(*context)); } - - /* Zero out state data */ - memset(context, 0, sizeof(*context)); } @@ -832,10 +830,8 @@ SHA512_Final(u_int8_t digest[SHA512_DIGEST_LENGTH], SHA512_CTX *context) #else memcpy(digest, context->state, SHA512_DIGEST_LENGTH); #endif + memset(context, 0, sizeof(*context)); } - - /* Zero out state data */ - memset(context, 0, sizeof(*context)); } |