diff --git a/src/lib/libc/hash/md4.c b/src/lib/libc/hash/md4.c index a1006dbf..0979ae34 100644 --- a/src/lib/libc/hash/md4.c +++ b/src/lib/libc/hash/md4.c @@ -1,4 +1,4 @@ -/* $OpenBSD: md4.c,v 1.5 2004/05/03 18:07:07 millert Exp $ */ +/* $OpenBSD: md4.c,v 1.6 2004/05/28 15:10:27 millert Exp $ */ /* * This code implements the MD4 message-digest algorithm. @@ -19,7 +19,7 @@ */ #if defined(LIBC_SCCS) && !defined(lint) -static const char rcsid[] = "$OpenBSD: md4.c,v 1.5 2004/05/03 18:07:07 millert Exp $"; +static const char rcsid[] = "$OpenBSD: md4.c,v 1.6 2004/05/28 15:10:27 millert Exp $"; #endif /* LIBC_SCCS and not lint */ #include @@ -134,8 +134,8 @@ MD4Final(unsigned char digest[MD4_DIGEST_LENGTH], MD4_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 */ } diff --git a/src/lib/libc/hash/md5.c b/src/lib/libc/hash/md5.c index 85e71d81..a1ff135e 100644 --- a/src/lib/libc/hash/md5.c +++ b/src/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 @@ -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 */ } diff --git a/src/lib/libc/hash/rmd160.c b/src/lib/libc/hash/rmd160.c index bea97614..4fb64cd1 100644 --- a/src/lib/libc/hash/rmd160.c +++ b/src/lib/libc/hash/rmd160.c @@ -32,7 +32,7 @@ #include #if defined(LIBC_SCCS) && !defined(lint) -static char rcsid[] = "$OpenBSD: rmd160.c,v 1.16 2004/05/03 18:07:07 millert Exp $"; +static char rcsid[] = "$OpenBSD: rmd160.c,v 1.17 2004/05/28 15:10:27 millert Exp $"; #endif /* LIBC_SCCS and not lint */ #define PUT_64BIT_LE(cp, value) do { \ @@ -155,11 +155,11 @@ RMD160Final(u_int8_t digest[RMD160_DIGEST_LENGTH], RMD160_CTX *ctx) int i; RMD160Pad(ctx); - if (digest != NULL) + if (digest != NULL) { for (i = 0; i < 5; i++) PUT_32BIT_LE(digest + i*4, ctx->state[i]); - - memset(ctx, 0, sizeof (*ctx)); + memset(ctx, 0, sizeof (*ctx)); + } } void diff --git a/src/lib/libc/hash/sha1.c b/src/lib/libc/hash/sha1.c index bb901ff4..968c2b32 100644 --- a/src/lib/libc/hash/sha1.c +++ b/src/lib/libc/hash/sha1.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sha1.c,v 1.18 2004/05/05 17:09:46 millert Exp $ */ +/* $OpenBSD: sha1.c,v 1.19 2004/05/28 15:10:27 millert Exp $ */ /* * SHA-1 in C @@ -15,7 +15,7 @@ */ #if defined(LIBC_SCCS) && !defined(lint) -static const char rcsid[] = "$OpenBSD: sha1.c,v 1.18 2004/05/05 17:09:46 millert Exp $"; +static const char rcsid[] = "$OpenBSD: sha1.c,v 1.19 2004/05/28 15:10:27 millert Exp $"; #endif /* LIBC_SCCS and not lint */ #include @@ -173,6 +173,6 @@ SHA1Final(u_int8_t digest[SHA1_DIGEST_LENGTH], SHA1_CTX *context) digest[i] = (u_int8_t) ((context->state[i>>2] >> ((3-(i & 3)) * 8) ) & 255); } + memset(context, 0, sizeof(*context)); } - memset(context, 0, sizeof(*context)); } diff --git a/src/lib/libc/hash/sha2.c b/src/lib/libc/hash/sha2.c index cd95d680..c99ed4d6 100644 --- a/src/lib/libc/hash/sha2.c +++ b/src/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 @@ -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)); }