From: Simon Tatham Date: Sun, 26 Apr 2015 22:55:33 +0000 (+0100) Subject: Add smemclrs of all hash states we destroy. X-Git-Tag: 0.68~612 X-Git-Url: https://asedeno.scripts.mit.edu/gitweb/?a=commitdiff_plain;h=16c46ecdaf71e4c9dddcd933778f02d78425f6a5;p=PuTTY.git Add smemclrs of all hash states we destroy. --- diff --git a/sshmd5.c b/sshmd5.c index b7a03b5e..f34f851d 100644 --- a/sshmd5.c +++ b/sshmd5.c @@ -210,6 +210,7 @@ void MD5Simple(void const *p, unsigned len, unsigned char output[16]) MD5Init(&s); MD5Update(&s, (unsigned char const *)p, len); MD5Final(output, &s); + smemclr(&s, sizeof(s)); } /* ---------------------------------------------------------------------- @@ -227,6 +228,7 @@ void *hmacmd5_make_context(void) void hmacmd5_free_context(void *handle) { + smemclr(handle, 3*sizeof(struct MD5Context)); sfree(handle); } diff --git a/sshsh256.c b/sshsh256.c index fdc8a3a5..76b77efe 100644 --- a/sshsh256.c +++ b/sshsh256.c @@ -184,6 +184,7 @@ void SHA256_Simple(const void *p, int len, unsigned char *output) { SHA256_Init(&s); SHA256_Bytes(&s, p, len); SHA256_Final(&s, output); + smemclr(&s, sizeof(s)); } /* @@ -211,6 +212,7 @@ static void sha256_final(void *handle, unsigned char *output) SHA256_State *s = handle; SHA256_Final(s, output); + smemclr(s, sizeof(*s)); sfree(s); } @@ -230,6 +232,7 @@ static void *sha256_make_context(void) static void sha256_free_context(void *handle) { + smemclr(handle, 3 * sizeof(SHA256_State)); sfree(handle); } diff --git a/sshsh512.c b/sshsh512.c index cd2b296e..b734c735 100644 --- a/sshsh512.c +++ b/sshsh512.c @@ -306,6 +306,7 @@ void SHA512_Simple(const void *p, int len, unsigned char *output) { SHA512_Init(&s); SHA512_Bytes(&s, p, len); SHA512_Final(&s, output); + smemclr(&s, sizeof(s)); } void SHA384_Simple(const void *p, int len, unsigned char *output) { @@ -314,6 +315,7 @@ void SHA384_Simple(const void *p, int len, unsigned char *output) { SHA384_Init(&s); SHA512_Bytes(&s, p, len); SHA384_Final(&s, output); + smemclr(&s, sizeof(s)); } /* @@ -341,6 +343,7 @@ static void sha512_final(void *handle, unsigned char *output) SHA512_State *s = handle; SHA512_Final(s, output); + smemclr(s, sizeof(*s)); sfree(s); } @@ -362,6 +365,7 @@ static void sha384_final(void *handle, unsigned char *output) SHA512_State *s = handle; SHA384_Final(s, output); + smemclr(s, sizeof(*s)); sfree(s); } diff --git a/sshsha.c b/sshsha.c index 579bf4de..4870bba8 100644 --- a/sshsha.c +++ b/sshsha.c @@ -214,6 +214,7 @@ void SHA_Simple(const void *p, int len, unsigned char *output) SHA_Init(&s); SHA_Bytes(&s, p, len); SHA_Final(&s, output); + smemclr(&s, sizeof(s)); } /* @@ -241,6 +242,7 @@ static void sha1_final(void *handle, unsigned char *output) SHA_State *s = handle; SHA_Final(s, output); + smemclr(s, sizeof(*s)); sfree(s); } @@ -260,6 +262,7 @@ static void *sha1_make_context(void) static void sha1_free_context(void *handle) { + smemclr(handle, 3 * sizeof(SHA_State)); sfree(handle); }