Cosmetic, to fix ssh2-des-cbc-is-std
[u/mdw/putty] / sshpubk.c
index 1659ace..dd06ebd 100644 (file)
--- 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;
 
     /*