X-Git-Url: https://git.distorted.org.uk/~mdw/sgt/putty/blobdiff_plain/9916cc1e8d26f1caef36fc1ee525819e6ca62f42..3d5040f8f85f049cbb072a827a6184b4b4314b08:/sshsha.c diff --git a/sshsha.c b/sshsha.c index cbe9d78b..9e9ef8c6 100644 --- a/sshsha.c +++ b/sshsha.c @@ -28,6 +28,21 @@ void SHATransform(word32 * digest, word32 * block) word32 a, b, c, d, e; int t; +#ifdef RANDOM_DIAGNOSTICS + { + extern int random_diagnostics; + if (random_diagnostics) { + int i; + printf("SHATransform:"); + for (i = 0; i < 5; i++) + printf(" %08x", digest[i]); + printf(" +"); + for (i = 0; i < 16; i++) + printf(" %08x", block[i]); + } + } +#endif + for (t = 0; t < 16; t++) w[t] = block[t]; @@ -83,6 +98,19 @@ void SHATransform(word32 * digest, word32 * block) digest[2] += c; digest[3] += d; digest[4] += e; + +#ifdef RANDOM_DIAGNOSTICS + { + extern int random_diagnostics; + if (random_diagnostics) { + int i; + printf(" ="); + for (i = 0; i < 5; i++) + printf(" %08x", digest[i]); + printf("\n"); + } + } +#endif } /* ---------------------------------------------------------------------- @@ -253,7 +281,7 @@ static void sha1_key_internal(void *handle, unsigned char *key, int len) SHA_Init(&keys[1]); SHA_Bytes(&keys[1], foo, 64); - memset(foo, 0, 64); /* burn the evidence */ + smemclr(foo, 64); /* burn the evidence */ } static void sha1_key(void *handle, unsigned char *key) @@ -297,11 +325,7 @@ static void sha1_do_hmac(void *handle, unsigned char *blk, int len, { unsigned char seqbuf[4]; - seqbuf[0] = (unsigned char) ((seq >> 24) & 0xFF); - seqbuf[1] = (unsigned char) ((seq >> 16) & 0xFF); - seqbuf[2] = (unsigned char) ((seq >> 8) & 0xFF); - seqbuf[3] = (unsigned char) ((seq) & 0xFF); - + PUT_32BIT_MSB_FIRST(seqbuf, seq); hmacsha1_start(handle); hmacsha1_bytes(handle, seqbuf, 4); hmacsha1_bytes(handle, blk, len);