summaryrefslogtreecommitdiff
path: root/ssh-add.c
diff options
context:
space:
mode:
Diffstat (limited to 'ssh-add.c')
-rw-r--r--ssh-add.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/ssh-add.c b/ssh-add.c
index a5d785ce7..482229c22 100644
--- a/ssh-add.c
+++ b/ssh-add.c
@@ -7,7 +7,7 @@
7 */ 7 */
8 8
9#include "includes.h" 9#include "includes.h"
10RCSID("$OpenBSD: ssh-add.c,v 1.17 2000/06/20 01:39:44 markus Exp $"); 10RCSID("$OpenBSD: ssh-add.c,v 1.18 2000/07/16 08:27:21 markus Exp $");
11 11
12#include <openssl/rsa.h> 12#include <openssl/rsa.h>
13#include <openssl/dsa.h> 13#include <openssl/dsa.h>
@@ -15,9 +15,9 @@ RCSID("$OpenBSD: ssh-add.c,v 1.17 2000/06/20 01:39:44 markus Exp $");
15#include "rsa.h" 15#include "rsa.h"
16#include "ssh.h" 16#include "ssh.h"
17#include "xmalloc.h" 17#include "xmalloc.h"
18#include "authfd.h"
19#include "fingerprint.h" 18#include "fingerprint.h"
20#include "key.h" 19#include "key.h"
20#include "authfd.h"
21#include "authfile.h" 21#include "authfile.h"
22 22
23#ifdef HAVE___PROGNAME 23#ifdef HAVE___PROGNAME
@@ -102,11 +102,17 @@ add_file(AuthenticationConnection *ac, const char *filename)
102 char buf[1024], msg[1024]; 102 char buf[1024], msg[1024];
103 int success; 103 int success;
104 int interactive = isatty(STDIN_FILENO); 104 int interactive = isatty(STDIN_FILENO);
105 int type = KEY_RSA;
105 106
107 /*
108 * try to load the public key. right now this only works for RSA,
109 * since DSA keys are fully encrypted
110 */
106 public = key_new(KEY_RSA); 111 public = key_new(KEY_RSA);
107 if (!load_public_key(filename, public, &saved_comment)) { 112 if (!load_public_key(filename, public, &saved_comment)) {
108 printf("Bad key file %s: %s\n", filename, strerror(errno)); 113 /* ok, so we will asume this is a DSA key */
109 return; 114 type = KEY_DSA;
115 saved_comment = xstrdup(filename);
110 } 116 }
111 key_free(public); 117 key_free(public);
112 118
@@ -118,7 +124,7 @@ add_file(AuthenticationConnection *ac, const char *filename)
118 } 124 }
119 125
120 /* At first, try empty passphrase */ 126 /* At first, try empty passphrase */
121 private = key_new(KEY_RSA); 127 private = key_new(type);
122 success = load_private_key(filename, "", private, &comment); 128 success = load_private_key(filename, "", private, &comment);
123 if (!success) { 129 if (!success) {
124 printf("Need passphrase for %.200s\n", filename); 130 printf("Need passphrase for %.200s\n", filename);
@@ -150,7 +156,7 @@ add_file(AuthenticationConnection *ac, const char *filename)
150 } 156 }
151 xfree(saved_comment); 157 xfree(saved_comment);
152 158
153 if (ssh_add_identity(ac, private->rsa, comment)) 159 if (ssh_add_identity(ac, private, comment))
154 fprintf(stderr, "Identity added: %s (%s)\n", filename, comment); 160 fprintf(stderr, "Identity added: %s (%s)\n", filename, comment);
155 else 161 else
156 fprintf(stderr, "Could not add identity: %s\n", filename); 162 fprintf(stderr, "Could not add identity: %s\n", filename);