X-Git-Url: https://git.distorted.org.uk/u/mdw/putty/blobdiff_plain/222d54dc209210b6e43589c798e35e21273b4082..8f1612752a89ea821dbd63491aef858f7f7e5bef:/sshpubk.c?ds=sidebyside diff --git a/sshpubk.c b/sshpubk.c index 1659acec..dd06ebd5 100644 --- a/sshpubk.c +++ b/sshpubk.c @@ -433,8 +433,7 @@ int saversakey(const Filename *filename, struct RSAKey *key, char *passphrase) * data "putty-private-key-file-mac-key" * data passphrase * - * Encrypted keys should have a MAC, whereas unencrypted ones must - * have a hash. + * (An empty passphrase is used for unencrypted keys.) * * If the key is encrypted, the encryption key is derived from the * passphrase by means of a succession of SHA-1 hashes. Each hash @@ -784,7 +783,7 @@ struct ssh2_userkey *ssh2_load_userkey(const Filename *filename, SHA_Init(&s); SHA_Bytes(&s, header, sizeof(header)-1); - if (passphrase) + if (cipher && passphrase) SHA_Bytes(&s, passphrase, passlen); SHA_Final(&s, mackey); @@ -836,7 +835,8 @@ struct ssh2_userkey *ssh2_load_userkey(const Filename *filename, sfree(public_blob); sfree(private_blob); sfree(encryption); - *errorstr = NULL; + if (errorstr) + *errorstr = NULL; return ret; /*