X-Git-Url: https://git.distorted.org.uk/u/mdw/putty/blobdiff_plain/0016d70b76e2706064b54c9dd24d45a45646b0de..dee42491003c8fdd01bd039da46b9d6a2d171584:/sshpubk.c diff --git a/sshpubk.c b/sshpubk.c index 13a182a5..166afbcb 100644 --- a/sshpubk.c +++ b/sshpubk.c @@ -376,7 +376,8 @@ int saversakey(const Filename *filename, struct RSAKey *key, char *passphrase) fp = f_open(*filename, "wb"); if (fp) { int ret = (fwrite(buf, 1, p - buf, fp) == (size_t) (p - buf)); - ret = ret && (fclose(fp) == 0); + if (fclose(fp)) + ret = 0; return ret; } else return 0; @@ -460,10 +461,9 @@ int saversakey(const Filename *filename, struct RSAKey *key, char *passphrase) * with "PuTTY-User-Key-File-1" (version number differs). In this * format the Private-MAC: field only covers the private-plaintext * field and nothing else (and without the 4-byte string length on - * the front too). Moreover, for RSA keys the Private-MAC: field - * can be replaced with a Private-Hash: field which is a plain - * SHA-1 hash instead of an HMAC. This is not allowable in DSA - * keys. (Yes, the old format was a mess. Guess why it changed :-) + * the front too). Moreover, the Private-MAC: field can be replaced + * with a Private-Hash: field which is a plain SHA-1 hash instead of + * an HMAC (this was generated for unencrypted keys). */ static int read_header(FILE * fp, char *header) @@ -722,8 +722,7 @@ struct ssh2_userkey *ssh2_load_userkey(const Filename *filename, if ((mac = read_body(fp)) == NULL) goto error; is_mac = 1; - } else if (0 == strcmp(header, "Private-Hash") && - alg == &ssh_rsa && old_fmt) { + } else if (0 == strcmp(header, "Private-Hash") && old_fmt) { if ((mac = read_body(fp)) == NULL) goto error; is_mac = 0;