X-Git-Url: https://asedeno.scripts.mit.edu/gitweb/?a=blobdiff_plain;f=sshsh256.c;h=b583c9b3f2dd9d4a920fed4112f4878a986d888d;hb=79fe96155a9486a58c1ce588069975346b4f4a22;hp=7ea25fbe1193c7ed1d062c798b63bc41c3fd2d77;hpb=183a9ee98b6535f8d059b4c488f198532ad84586;p=PuTTY.git diff --git a/sshsh256.c b/sshsh256.c index 7ea25fbe..b583c9b3 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)); } /* @@ -199,7 +200,7 @@ static void *sha256_init(void) return s; } -static void sha256_bytes(void *handle, void *p, int len) +static void sha256_bytes(void *handle, const void *p, int len) { SHA256_State *s = handle; @@ -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); } @@ -307,7 +310,7 @@ static int hmacsha256_verresult(void *handle, unsigned char const *hmac) { unsigned char correct[32]; hmacsha256_genresult(handle, correct); - return !memcmp(correct, hmac, 32); + return smemeq(correct, hmac, 32); } static int sha256_verify(void *handle, unsigned char *blk, int len, @@ -315,7 +318,7 @@ static int sha256_verify(void *handle, unsigned char *blk, int len, { unsigned char correct[32]; sha256_do_hmac(handle, blk, len, seq, correct); - return !memcmp(correct, blk + len, 32); + return smemeq(correct, blk + len, 32); } const struct ssh_mac ssh_hmac_sha256 = {