summaryrefslogtreecommitdiff
path: root/usr.bin/ssh/sshd.c
diff options
context:
space:
mode:
authorMarkus Friedl <markus@cvs.openbsd.org>2001-03-26 08:07:10 +0000
committerMarkus Friedl <markus@cvs.openbsd.org>2001-03-26 08:07:10 +0000
commit5197bb0e77fbb51e9b575c8ced78d232b9b45a43 (patch)
tree0906a92133bce6dd08f7fae1801c7c05a8f3680a /usr.bin/ssh/sshd.c
parentf4eb1785519495ac3cd38888663c189ea6e3b526 (diff)
simpler key load/save interface, see authfile.h
Diffstat (limited to 'usr.bin/ssh/sshd.c')
-rw-r--r--usr.bin/ssh/sshd.c43
1 files changed, 7 insertions, 36 deletions
diff --git a/usr.bin/ssh/sshd.c b/usr.bin/ssh/sshd.c
index 507a3ab1a9d..fcd531b31ef 100644
--- a/usr.bin/ssh/sshd.c
+++ b/usr.bin/ssh/sshd.c
@@ -40,7 +40,7 @@
*/
#include "includes.h"
-RCSID("$OpenBSD: sshd.c,v 1.178 2001/03/23 14:28:32 markus Exp $");
+RCSID("$OpenBSD: sshd.c,v 1.179 2001/03/26 08:07:09 markus Exp $");
#include <openssl/dh.h>
#include <openssl/bn.h>
@@ -445,39 +445,6 @@ destroy_sensitive_data(void)
sensitive_data.ssh1_host_key = NULL;
memset(sensitive_data.ssh1_cookie, 0, SSH_SESSION_KEY_LENGTH);
}
-Key *
-load_private_key_autodetect(const char *filename)
-{
- struct stat st;
- int type;
- Key *public, *private;
-
- if (stat(filename, &st) < 0) {
- perror(filename);
- return NULL;
- }
- /*
- * try to load the public key. right now this only works for RSA1,
- * since SSH2 keys are fully encrypted
- */
- type = KEY_RSA1;
- public = key_new(type);
- if (!load_public_key(filename, public, NULL)) {
- /* ok, so we will assume this is 'some' key */
- type = KEY_UNSPEC;
- }
- key_free(public);
-
- /* Ok, try key with empty passphrase */
- private = key_new(type);
- if (load_private_key(filename, "", private, NULL)) {
- debug("load_private_key_autodetect: type %d %s",
- private->type, key_type(private));
- return private;
- }
- key_free(private);
- return NULL;
-}
char *
list_hostkey_types(void)
@@ -570,6 +537,7 @@ main(int ac, char **av)
int listen_sock, maxfd;
int startup_p[2];
int startups = 0;
+ Key *key;
int ret, key_used = 0;
/* Save argv. */
@@ -701,10 +669,12 @@ main(int ac, char **av)
sensitive_data.have_ssh2_key = 0;
for(i = 0; i < options.num_host_key_files; i++) {
- Key *key = load_private_key_autodetect(options.host_key_files[i]);
+ key = key_load_private(options.host_key_files[i], "", NULL);
+ sensitive_data.host_keys[i] = key;
if (key == NULL) {
error("Could not load host key: %.200s: %.100s",
options.host_key_files[i], strerror(errno));
+ sensitive_data.host_keys[i] = NULL;
continue;
}
switch(key->type){
@@ -717,7 +687,8 @@ main(int ac, char **av)
sensitive_data.have_ssh2_key = 1;
break;
}
- sensitive_data.host_keys[i] = key;
+ debug("private host key: #%d type %d %s", i, key->type,
+ key_type(key));
}
if ((options.protocol & SSH_PROTO_1) && !sensitive_data.have_ssh1_key) {
log("Disabling protocol version 1. Could not load host key");