X-Git-Url: https://asedeno.scripts.mit.edu/gitweb/?a=blobdiff_plain;f=sshsha.c;h=4870bba86ee2f0e04fb2b5afc33b91f35e552ef0;hb=460c45dd235fae180256c9606df865066f8a791c;hp=a5b3a60c8465493578b08c9b1c74b5e3c1e27287;hpb=808df44e54192d5d41b8ce988d064566027a53bc;p=PuTTY.git diff --git a/sshsha.c b/sshsha.c index a5b3a60c..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); } @@ -342,7 +345,7 @@ static int hmacsha1_verresult(void *handle, unsigned char const *hmac) { unsigned char correct[20]; hmacsha1_genresult(handle, correct); - return !memcmp(correct, hmac, 20); + return smemeq(correct, hmac, 20); } static int sha1_verify(void *handle, unsigned char *blk, int len, @@ -350,7 +353,7 @@ static int sha1_verify(void *handle, unsigned char *blk, int len, { unsigned char correct[20]; sha1_do_hmac(handle, blk, len, seq, correct); - return !memcmp(correct, blk + len, 20); + return smemeq(correct, blk + len, 20); } static void hmacsha1_96_genresult(void *handle, unsigned char *hmac) @@ -372,7 +375,7 @@ static int hmacsha1_96_verresult(void *handle, unsigned char const *hmac) { unsigned char correct[20]; hmacsha1_genresult(handle, correct); - return !memcmp(correct, hmac, 12); + return smemeq(correct, hmac, 12); } static int sha1_96_verify(void *handle, unsigned char *blk, int len, @@ -380,7 +383,7 @@ static int sha1_96_verify(void *handle, unsigned char *blk, int len, { unsigned char correct[20]; sha1_do_hmac(handle, blk, len, seq, correct); - return !memcmp(correct, blk + len, 12); + return smemeq(correct, blk + len, 12); } void hmac_sha1_simple(void *key, int keylen, void *data, int datalen, @@ -400,7 +403,7 @@ const struct ssh_mac ssh_hmac_sha1 = { sha1_make_context, sha1_free_context, sha1_key, sha1_generate, sha1_verify, hmacsha1_start, hmacsha1_bytes, hmacsha1_genresult, hmacsha1_verresult, - "hmac-sha1", + "hmac-sha1", "hmac-sha1-etm@openssh.com", 20, "HMAC-SHA1" }; @@ -410,7 +413,7 @@ const struct ssh_mac ssh_hmac_sha1_96 = { sha1_96_generate, sha1_96_verify, hmacsha1_start, hmacsha1_bytes, hmacsha1_96_genresult, hmacsha1_96_verresult, - "hmac-sha1-96", + "hmac-sha1-96", "hmac-sha1-96-etm@openssh.com", 12, "HMAC-SHA1-96" }; @@ -419,7 +422,7 @@ const struct ssh_mac ssh_hmac_sha1_buggy = { sha1_make_context, sha1_free_context, sha1_key_buggy, sha1_generate, sha1_verify, hmacsha1_start, hmacsha1_bytes, hmacsha1_genresult, hmacsha1_verresult, - "hmac-sha1", + "hmac-sha1", NULL, 20, "bug-compatible HMAC-SHA1" }; @@ -429,7 +432,7 @@ const struct ssh_mac ssh_hmac_sha1_96_buggy = { sha1_96_generate, sha1_96_verify, hmacsha1_start, hmacsha1_bytes, hmacsha1_96_genresult, hmacsha1_96_verresult, - "hmac-sha1-96", + "hmac-sha1-96", NULL, 12, "bug-compatible HMAC-SHA1-96" };