diff options
author | Markus Friedl <markus@cvs.openbsd.org> | 2014-06-27 18:50:40 +0000 |
---|---|---|
committer | Markus Friedl <markus@cvs.openbsd.org> | 2014-06-27 18:50:40 +0000 |
commit | 37270d97ae207de1970bb699456caa14ce41b504 (patch) | |
tree | 862140edc9e8bdc1c15479fd9b7bb8a5cbe6db07 | |
parent | b9133b0418b59b639fea174eaa9d7687d350589e (diff) |
fix loading of private keys
-rw-r--r-- | usr.bin/ssh/ssh-add.c | 10 | ||||
-rw-r--r-- | usr.bin/ssh/sshkey.c | 8 |
2 files changed, 9 insertions, 9 deletions
diff --git a/usr.bin/ssh/ssh-add.c b/usr.bin/ssh/ssh-add.c index 7b2b06be758..ece9d2b20f8 100644 --- a/usr.bin/ssh/ssh-add.c +++ b/usr.bin/ssh/ssh-add.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ssh-add.c,v 1.110 2014/06/24 01:13:21 djm Exp $ */ +/* $OpenBSD: ssh-add.c,v 1.111 2014/06/27 18:50:39 markus Exp $ */ /* * Author: Tatu Ylonen <ylo@cs.hut.fi> * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland @@ -196,14 +196,14 @@ add_file(AuthenticationConnection *ac, const char *filename, int key_only) close(fd); /* At first, try empty passphrase */ - if ((r = sshkey_parse_private_fileblob(&keyblob, filename, "", + if ((r = sshkey_parse_private_fileblob(&keyblob, "", filename, &private, &comment)) != 0 && r != SSH_ERR_KEY_WRONG_PASSPHRASE) - fatal("Cannot parse %s: %s", filename, ssh_err(r)); + fatal("Cannot parse %s: %s", filename, ssh_err(r)); if (comment == NULL) comment = xstrdup(filename); /* try last */ if (private == NULL && pass != NULL) { - if ((r = sshkey_parse_private_fileblob(&keyblob, filename, pass, + if ((r = sshkey_parse_private_fileblob(&keyblob, pass, filename, &private, &comment)) != 0 && r != SSH_ERR_KEY_WRONG_PASSPHRASE) fatal("Cannot parse %s: %s", filename, ssh_err(r)); @@ -222,7 +222,7 @@ add_file(AuthenticationConnection *ac, const char *filename, int key_only) return -1; } if ((r = sshkey_parse_private_fileblob(&keyblob, - filename, pass, &private, &comment)) != 0 && + pass, filename, &private, NULL)) != 0 && r != SSH_ERR_KEY_WRONG_PASSPHRASE) fatal("Cannot parse %s: %s", filename, ssh_err(r)); diff --git a/usr.bin/ssh/sshkey.c b/usr.bin/ssh/sshkey.c index cab8251719b..1648b7e62be 100644 --- a/usr.bin/ssh/sshkey.c +++ b/usr.bin/ssh/sshkey.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sshkey.c,v 1.1 2014/06/24 01:16:58 djm Exp $ */ +/* $OpenBSD: sshkey.c,v 1.2 2014/06/27 18:50:39 markus Exp $ */ /* * Copyright (c) 2000, 2001 Markus Friedl. All rights reserved. * Copyright (c) 2008 Alexander von Gernler. All rights reserved. @@ -3775,9 +3775,6 @@ sshkey_parse_private_fileblob(struct sshbuf *buffer, const char *passphrase, if (commentp != NULL) *commentp = NULL; - if ((r = sshkey_parse_private_fileblob_type(buffer, KEY_UNSPEC, - passphrase, keyp, commentp)) == 0) - return 0; #ifdef WITH_SSH1 /* it's a SSH v1 key if the public key part is readable */ if ((r = sshkey_parse_public_rsa1_fileblob(buffer, NULL, NULL)) == 0) { @@ -3785,5 +3782,8 @@ sshkey_parse_private_fileblob(struct sshbuf *buffer, const char *passphrase, passphrase, keyp, commentp); } #endif /* WITH_SSH1 */ + if ((r = sshkey_parse_private_fileblob_type(buffer, KEY_UNSPEC, + passphrase, keyp, commentp)) == 0) + return 0; return r; } |