diff --git a/lib/libcrypt/crypt-md5.c b/lib/libcrypt/crypt-md5.c --- a/lib/libcrypt/crypt-md5.c +++ b/lib/libcrypt/crypt-md5.c @@ -32,6 +32,7 @@ #include #include #include +#include #include #include "crypt.h" @@ -84,7 +85,7 @@ (u_int)(pl > MD5_SIZE ? MD5_SIZE : pl)); /* Don't leave anything around in vm they could use. */ - memset(final, 0, sizeof(final)); + explicit_bzero(final, sizeof(final)); /* Then something really weird... */ for (i = strlen(pw); i; i >>= 1) @@ -140,7 +141,7 @@ *buffer = '\0'; /* Don't leave anything around in vm they could use. */ - memset(final, 0, sizeof(final)); + explicit_bzero(final, sizeof(final)); return (0); } diff --git a/lib/libcrypt/crypt-sha256.c b/lib/libcrypt/crypt-sha256.c --- a/lib/libcrypt/crypt-sha256.c +++ b/lib/libcrypt/crypt-sha256.c @@ -41,6 +41,7 @@ #include #include #include +#include #include "crypt.h" @@ -234,9 +235,9 @@ * the SHA256 implementation as well. */ SHA256_Init(&ctx); SHA256_Final(alt_result, &ctx); - memset(temp_result, '\0', sizeof(temp_result)); - memset(p_bytes, '\0', key_len); - memset(s_bytes, '\0', salt_len); + explicit_bzero(temp_result, sizeof(temp_result)); + explicit_bzero(p_bytes, key_len); + explicit_bzero(s_bytes, salt_len); return (0); } diff --git a/lib/libcrypt/crypt-sha512.c b/lib/libcrypt/crypt-sha512.c --- a/lib/libcrypt/crypt-sha512.c +++ b/lib/libcrypt/crypt-sha512.c @@ -41,6 +41,7 @@ #include #include #include +#include #include "crypt.h" @@ -246,9 +247,9 @@ * the SHA512 implementation as well. */ SHA512_Init(&ctx); SHA512_Final(alt_result, &ctx); - memset(temp_result, '\0', sizeof(temp_result)); - memset(p_bytes, '\0', key_len); - memset(s_bytes, '\0', salt_len); + explicit_bzero(temp_result, sizeof(temp_result)); + explicit_bzero(p_bytes, key_len); + explicit_bzero(s_bytes, salt_len); return (0); }