diff options
| author | drochner <drochner@NetBSD.org> | 2012-08-30 12:16:48 +0000 |
|---|---|---|
| committer | drochner <drochner@NetBSD.org> | 2012-08-30 12:16:48 +0000 |
| commit | 23bb9c3d2a6b4e05b1262696420e976fc6b15cc6 (patch) | |
| tree | 25b7e2933fe8ca6f1d0a4afbeb776da833de014e /lib/libcrypt/bcrypt.c | |
| parent | 3ac5dbc4e542b7cd06bcb2ec8788fdd376152196 (diff) | |
Add "consttime_bcmp" and "explicit_bzero" functions for both kernel
abd userland, as proposed on tech-security, with explicit_bzero using
a volatile function pointer as suggested by Alan Barrett.
Both do what the name says. For userland, both are prefixed by "__"
to keep them out of the user namespace.
Change some memset/memcmp uses to the new functions where it makes
sense -- these are just some examples, more to come.
Diffstat (limited to 'lib/libcrypt/bcrypt.c')
| -rw-r--r-- | lib/libcrypt/bcrypt.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/libcrypt/bcrypt.c b/lib/libcrypt/bcrypt.c index 8cd559e8d55..106b1edb61d 100644 --- a/lib/libcrypt/bcrypt.c +++ b/lib/libcrypt/bcrypt.c @@ -1,4 +1,4 @@ -/* $NetBSD: bcrypt.c,v 1.16 2012/03/21 05:33:26 matt Exp $ */ +/* $NetBSD: bcrypt.c,v 1.17 2012/08/30 12:16:49 drochner Exp $ */ /* $OpenBSD: bcrypt.c,v 1.16 2002/02/19 19:39:36 millert Exp $ */ /* @@ -46,7 +46,7 @@ * */ #include <sys/cdefs.h> -__RCSID("$NetBSD: bcrypt.c,v 1.16 2012/03/21 05:33:26 matt Exp $"); +__RCSID("$NetBSD: bcrypt.c,v 1.17 2012/08/30 12:16:49 drochner Exp $"); #include <stdio.h> #include <stdlib.h> @@ -314,7 +314,7 @@ __bcrypt(const char *key, const char *salt) encode_base64((u_int8_t *) encrypted + i + 3, csalt, BCRYPT_MAXSALT); encode_base64((u_int8_t *) encrypted + strlen(encrypted), ciphertext, 4 * BCRYPT_BLOCKS - 1); - memset(&state, 0, sizeof(state)); + __explicit_bzero(&state, sizeof(state)); return encrypted; } |
