1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-07-01 03:22:48 -05:00

Adopt the new hash API functions where they're useful.

This commit switches as many ssh_hash_free / ssh_hash_new pairs as
possible to reuse the previous hash object via ssh_hash_reset. Also a
few other cleanups: use the wrapper function hash_simple() where
possible, and I've also introduced ssh_hash_digest_nondestructive()
and switched to that where possible as well.
This commit is contained in:
Simon Tatham
2019-12-15 09:57:30 +00:00
parent 3fd334b5ca
commit 1344d4d1cd
12 changed files with 57 additions and 47 deletions

View File

@ -516,9 +516,9 @@ static void openssh_pem_derivekey(
h = ssh_hash_new(&ssh_md5);
put_datapl(h, passphrase);
put_data(h, iv, 8);
ssh_hash_final(h, keybuf);
ssh_hash_digest(h, keybuf);
h = ssh_hash_new(&ssh_md5);
ssh_hash_reset(h);
put_data(h, keybuf, 16);
put_datapl(h, passphrase);
put_data(h, iv, 8);
@ -1932,7 +1932,7 @@ static void sshcom_derivekey(ptrlen passphrase, uint8_t *keybuf)
h = ssh_hash_new(&ssh_md5);
put_datapl(h, passphrase);
ssh_hash_final(ssh_hash_copy(h), keybuf);
ssh_hash_digest_nondestructive(h, keybuf);
put_data(h, keybuf, 16);
ssh_hash_final(h, keybuf + 16);
}