summaryrefslogtreecommitdiff
path: root/ssh-keygen.c
diff options
context:
space:
mode:
Diffstat (limited to 'ssh-keygen.c')
-rw-r--r--ssh-keygen.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/ssh-keygen.c b/ssh-keygen.c
index 166ec6231..d1b2a583a 100644
--- a/ssh-keygen.c
+++ b/ssh-keygen.c
@@ -12,7 +12,7 @@
12 */ 12 */
13 13
14#include "includes.h" 14#include "includes.h"
15RCSID("$OpenBSD: ssh-keygen.c,v 1.60 2001/04/23 22:14:13 markus Exp $"); 15RCSID("$OpenBSD: ssh-keygen.c,v 1.61 2001/05/25 14:37:32 markus Exp $");
16 16
17#include <openssl/evp.h> 17#include <openssl/evp.h>
18#include <openssl/pem.h> 18#include <openssl/pem.h>
@@ -113,14 +113,17 @@ ask_filename(struct passwd *pw, const char *prompt)
113} 113}
114 114
115Key * 115Key *
116try_load_pem_key(char *filename) 116load_identity(char *filename)
117{ 117{
118 char *pass; 118 char *pass;
119 Key *prv; 119 Key *prv;
120 120
121 prv = key_load_private(filename, "", NULL); 121 prv = key_load_private(filename, "", NULL);
122 if (prv == NULL) { 122 if (prv == NULL) {
123 pass = read_passphrase("Enter passphrase: ", 1); 123 if (identity_passphrase)
124 pass = xstrdup(identity_passphrase);
125 else
126 pass = read_passphrase("Enter passphrase: ", 1);
124 prv = key_load_private(filename, pass, NULL); 127 prv = key_load_private(filename, pass, NULL);
125 memset(pass, 0, strlen(pass)); 128 memset(pass, 0, strlen(pass));
126 xfree(pass); 129 xfree(pass);
@@ -148,7 +151,7 @@ do_convert_to_ssh2(struct passwd *pw)
148 exit(1); 151 exit(1);
149 } 152 }
150 if ((k = key_load_public(identity_file, NULL)) == NULL) { 153 if ((k = key_load_public(identity_file, NULL)) == NULL) {
151 if ((k = try_load_pem_key(identity_file)) == NULL) { 154 if ((k = load_identity(identity_file)) == NULL) {
152 fprintf(stderr, "load failed\n"); 155 fprintf(stderr, "load failed\n");
153 exit(1); 156 exit(1);
154 } 157 }
@@ -348,7 +351,7 @@ do_print_public(struct passwd *pw)
348 perror(identity_file); 351 perror(identity_file);
349 exit(1); 352 exit(1);
350 } 353 }
351 prv = try_load_pem_key(identity_file); 354 prv = load_identity(identity_file);
352 if (prv == NULL) { 355 if (prv == NULL) {
353 fprintf(stderr, "load failed\n"); 356 fprintf(stderr, "load failed\n");
354 exit(1); 357 exit(1);