summaryrefslogtreecommitdiff
path: root/sshd.c
diff options
context:
space:
mode:
Diffstat (limited to 'sshd.c')
-rw-r--r--sshd.c35
1 files changed, 23 insertions, 12 deletions
diff --git a/sshd.c b/sshd.c
index 4282bdc1b..aaa63d497 100644
--- a/sshd.c
+++ b/sshd.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: sshd.c,v 1.441 2015/01/31 20:30:05 djm Exp $ */ 1/* $OpenBSD: sshd.c,v 1.442 2015/02/16 22:13:32 djm Exp $ */
2/* 2/*
3 * Author: Tatu Ylonen <ylo@cs.hut.fi> 3 * Author: Tatu Ylonen <ylo@cs.hut.fi>
4 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 4 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@@ -894,18 +894,25 @@ get_hostkey_public_by_index(int ind, struct ssh *ssh)
894} 894}
895 895
896int 896int
897get_hostkey_index(Key *key, struct ssh *ssh) 897get_hostkey_index(Key *key, int compare, struct ssh *ssh)
898{ 898{
899 int i; 899 int i;
900 900
901 for (i = 0; i < options.num_host_key_files; i++) { 901 for (i = 0; i < options.num_host_key_files; i++) {
902 if (key_is_cert(key)) { 902 if (key_is_cert(key)) {
903 if (key == sensitive_data.host_certificates[i]) 903 if (key == sensitive_data.host_certificates[i] ||
904 (compare && sensitive_data.host_certificates[i] &&
905 sshkey_equal(key,
906 sensitive_data.host_certificates[i])))
904 return (i); 907 return (i);
905 } else { 908 } else {
906 if (key == sensitive_data.host_keys[i]) 909 if (key == sensitive_data.host_keys[i] ||
910 (compare && sensitive_data.host_keys[i] &&
911 sshkey_equal(key, sensitive_data.host_keys[i])))
907 return (i); 912 return (i);
908 if (key == sensitive_data.host_pubkeys[i]) 913 if (key == sensitive_data.host_pubkeys[i] ||
914 (compare && sensitive_data.host_pubkeys[i] &&
915 sshkey_equal(key, sensitive_data.host_pubkeys[i])))
909 return (i); 916 return (i);
910 } 917 }
911 } 918 }
@@ -933,19 +940,23 @@ notify_hostkeys(struct ssh *ssh)
933 debug3("%s: key %d: %s %s", __func__, i, 940 debug3("%s: key %d: %s %s", __func__, i,
934 sshkey_ssh_name(key), fp); 941 sshkey_ssh_name(key), fp);
935 free(fp); 942 free(fp);
936 if ((r = sshkey_puts(key, buf)) != 0) 943 if (nkeys == 0) {
944 packet_start(SSH2_MSG_GLOBAL_REQUEST);
945 packet_put_cstring("hostkeys@openssh.com");
946 packet_put_char(0); /* want-reply */
947 }
948 sshbuf_reset(buf);
949 if ((r = sshkey_putb(key, buf)) != 0)
937 fatal("%s: couldn't put hostkey %d: %s", 950 fatal("%s: couldn't put hostkey %d: %s",
938 __func__, i, ssh_err(r)); 951 __func__, i, ssh_err(r));
952 packet_put_string(sshbuf_ptr(buf), sshbuf_len(buf));
939 nkeys++; 953 nkeys++;
940 } 954 }
955 debug3("%s: sent %d hostkeys", __func__, nkeys);
941 if (nkeys == 0) 956 if (nkeys == 0)
942 fatal("%s: no hostkeys", __func__); 957 fatal("%s: no hostkeys", __func__);
943 debug3("%s: send %d hostkeys", __func__, nkeys);
944 packet_start(SSH2_MSG_GLOBAL_REQUEST);
945 packet_put_cstring("hostkeys@openssh.com");
946 packet_put_char(0); /* want-reply */
947 packet_put_string(sshbuf_ptr(buf), sshbuf_len(buf));
948 packet_send(); 958 packet_send();
959 sshbuf_free(buf);
949} 960}
950 961
951/* 962/*
@@ -2484,7 +2495,7 @@ do_ssh1_kex(void)
2484 2495
2485int 2496int
2486sshd_hostkey_sign(Key *privkey, Key *pubkey, u_char **signature, size_t *slen, 2497sshd_hostkey_sign(Key *privkey, Key *pubkey, u_char **signature, size_t *slen,
2487 u_char *data, size_t dlen, u_int flag) 2498 const u_char *data, size_t dlen, u_int flag)
2488{ 2499{
2489 int r; 2500 int r;
2490 u_int xxx_slen, xxx_dlen = dlen; 2501 u_int xxx_slen, xxx_dlen = dlen;