diff options
| author | drochner <drochner@NetBSD.org> | 2011-11-29 13:18:52 +0000 |
|---|---|---|
| committer | drochner <drochner@NetBSD.org> | 2011-11-29 13:18:52 +0000 |
| commit | 0a939522eac305c8ea3fb31e4d81a6f903cd1614 (patch) | |
| tree | ee2c267b3a7a65ad864abf7ddf2c0f920e7e9264 /lib/libcrypt | |
| parent | 280502151afd697b8ac14130d79d1a2b64f12474 (diff) | |
zero out hash context after use, to avoid traces in RAM
(hint from "Solar Designer")
Diffstat (limited to 'lib/libcrypt')
| -rw-r--r-- | lib/libcrypt/md5crypt.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/lib/libcrypt/md5crypt.c b/lib/libcrypt/md5crypt.c index 4b04da11da5..d85180cc631 100644 --- a/lib/libcrypt/md5crypt.c +++ b/lib/libcrypt/md5crypt.c @@ -1,4 +1,4 @@ -/* $NetBSD: md5crypt.c,v 1.9 2007/01/17 23:24:22 hubertf Exp $ */ +/* $NetBSD: md5crypt.c,v 1.10 2011/11/29 13:18:52 drochner Exp $ */ /* * ---------------------------------------------------------------------------- @@ -15,7 +15,7 @@ #include <sys/cdefs.h> #if !defined(lint) -__RCSID("$NetBSD: md5crypt.c,v 1.9 2007/01/17 23:24:22 hubertf Exp $"); +__RCSID("$NetBSD: md5crypt.c,v 1.10 2011/11/29 13:18:52 drochner Exp $"); #endif /* not lint */ /* @@ -117,6 +117,9 @@ __md5crypt(const char *pw, const char *salt) FINAL(final, &ctx); + /* Don't leave anything around in vm they could use. */ + memset(&ctx, 0, sizeof(ctx)); + /* * And now, just to make sure things don't run too fast. On a 60 MHz * Pentium this takes 34 msec, so you would need 30 seconds to build @@ -144,6 +147,9 @@ __md5crypt(const char *pw, const char *salt) FINAL(final, &ctx1); } + /* Don't leave anything around in vm they could use. */ + memset(&ctx1, 0, sizeof(ctx1)); + p = passwd + sl + MD5_MAGIC_LEN + 1; l = (final[ 0]<<16) | (final[ 6]<<8) | final[12]; __crypt_to64(p,l,4); p += 4; |
