mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-07-02 12:02:47 -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:
@ -372,9 +372,7 @@ bool rsa_ssh1_savekey(const Filename *filename, RSAKey *key,
|
||||
if (passphrase) {
|
||||
unsigned char keybuf[16];
|
||||
|
||||
ssh_hash *h = ssh_hash_new(&ssh_md5);
|
||||
put_data(h, passphrase, strlen(passphrase));
|
||||
ssh_hash_final(h, keybuf);
|
||||
hash_simple(&ssh_md5, ptrlen_from_asciz(passphrase), keybuf);
|
||||
des3_encrypt_pubkey(keybuf, buf->u + estart, buf->len - estart);
|
||||
smemclr(keybuf, sizeof(keybuf)); /* burn the evidence */
|
||||
}
|
||||
@ -591,8 +589,8 @@ static void ssh2_ppk_derivekey(ptrlen passphrase, uint8_t *key)
|
||||
h = ssh_hash_new(&ssh_sha1);
|
||||
put_uint32(h, 0);
|
||||
put_datapl(h, passphrase);
|
||||
ssh_hash_final(h, key + 0);
|
||||
h = ssh_hash_new(&ssh_sha1);
|
||||
ssh_hash_digest(h, key + 0);
|
||||
ssh_hash_reset(h);
|
||||
put_uint32(h, 1);
|
||||
put_datapl(h, passphrase);
|
||||
ssh_hash_final(h, key + 20);
|
||||
|
Reference in New Issue
Block a user