X-Git-Url: https://git.distorted.org.uk/u/mdw/putty/blobdiff_plain/2e85c969d67eb14a07314802d4ac5dd63eef660b..b672f405dd2bfa3bdd7d11c1d616d674fe8d9d7a:/sshsha.c?ds=inline diff --git a/sshsha.c b/sshsha.c index c17149ee..29908b62 100644 --- a/sshsha.c +++ b/sshsha.c @@ -188,6 +188,38 @@ void SHA_Simple(void *p, int len, unsigned char *output) SHA_Final(&s, output); } +/* + * Thin abstraction for things where hashes are pluggable. + */ + +static void *sha1_init(void) +{ + SHA_State *s; + + s = snew(SHA_State); + SHA_Init(s); + return s; +} + +static void sha1_bytes(void *handle, void *p, int len) +{ + SHA_State *s = handle; + + SHA_Bytes(s, p, len); +} + +static void sha1_final(void *handle, unsigned char *output) +{ + SHA_State *s = handle; + + SHA_Final(s, output); + sfree(s); +} + +const struct ssh_hash ssh_sha1 = { + sha1_init, sha1_bytes, sha1_final, 20 +}; + /* ---------------------------------------------------------------------- * The above is the SHA-1 algorithm itself. Now we implement the * HMAC wrapper on it. @@ -282,7 +314,7 @@ void hmac_sha1_simple(void *key, int keylen, void *data, int datalen, SHA_Final(&states[1], output); } -const struct ssh_mac ssh_sha1 = { +const struct ssh_mac ssh_hmac_sha1 = { sha1_make_context, sha1_free_context, sha1_key, sha1_generate, sha1_verify, "hmac-sha1", @@ -290,7 +322,7 @@ const struct ssh_mac ssh_sha1 = { "HMAC-SHA1" }; -const struct ssh_mac ssh_sha1_buggy = { +const struct ssh_mac ssh_hmac_sha1_buggy = { sha1_make_context, sha1_free_context, sha1_key_buggy, sha1_generate, sha1_verify, "hmac-sha1",