|
Lines 90-95
Link Here
|
| 90 |
#include "canohost.h" |
90 |
#include "canohost.h" |
| 91 |
#include "hostfile.h" |
91 |
#include "hostfile.h" |
| 92 |
#include "auth.h" |
92 |
#include "auth.h" |
|
|
93 |
#include "authfd.h" |
| 93 |
#include "misc.h" |
94 |
#include "misc.h" |
| 94 |
#include "msg.h" |
95 |
#include "msg.h" |
| 95 |
#include "dispatch.h" |
96 |
#include "dispatch.h" |
|
Lines 177-182
char *server_version_string = NULL;
Link Here
|
| 177 |
/* for rekeying XXX fixme */ |
178 |
/* for rekeying XXX fixme */ |
| 178 |
Kex *xxx_kex; |
179 |
Kex *xxx_kex; |
| 179 |
|
180 |
|
|
|
181 |
/* Daemon's agent connection */ |
| 182 |
AuthenticationConnection *auth_conn = NULL; |
| 183 |
|
| 180 |
/* |
184 |
/* |
| 181 |
* Any really sensitive data in the application is contained in this |
185 |
* Any really sensitive data in the application is contained in this |
| 182 |
* structure. The idea is that this structure could be locked into memory so |
186 |
* structure. The idea is that this structure could be locked into memory so |
|
Lines 189-194
struct {
Link Here
|
| 189 |
Key *server_key; /* ephemeral server key */ |
193 |
Key *server_key; /* ephemeral server key */ |
| 190 |
Key *ssh1_host_key; /* ssh1 host key */ |
194 |
Key *ssh1_host_key; /* ssh1 host key */ |
| 191 |
Key **host_keys; /* all private host keys */ |
195 |
Key **host_keys; /* all private host keys */ |
|
|
196 |
Key **host_pubkeys; /* all public host keys */ |
| 192 |
Key **host_certificates; /* all public host certificates */ |
197 |
Key **host_certificates; /* all public host certificates */ |
| 193 |
int have_ssh1_key; |
198 |
int have_ssh1_key; |
| 194 |
int have_ssh2_key; |
199 |
int have_ssh2_key; |
|
Lines 639-644
privsep_preauth(Authctxt *authctxt)
Link Here
|
| 639 |
} else if (pid != 0) { |
644 |
} else if (pid != 0) { |
| 640 |
debug2("Network child is on pid %ld", (long)pid); |
645 |
debug2("Network child is on pid %ld", (long)pid); |
| 641 |
|
646 |
|
|
|
647 |
auth_conn = ssh_get_authentication_connection(); |
| 648 |
|
| 642 |
pmonitor->m_pid = pid; |
649 |
pmonitor->m_pid = pid; |
| 643 |
if (box != NULL) |
650 |
if (box != NULL) |
| 644 |
ssh_sandbox_parent_preauth(box, pid); |
651 |
ssh_sandbox_parent_preauth(box, pid); |
|
Lines 750-755
list_hostkey_types(void)
Link Here
|
| 750 |
for (i = 0; i < options.num_host_key_files; i++) { |
757 |
for (i = 0; i < options.num_host_key_files; i++) { |
| 751 |
key = sensitive_data.host_keys[i]; |
758 |
key = sensitive_data.host_keys[i]; |
| 752 |
if (key == NULL) |
759 |
if (key == NULL) |
|
|
760 |
key = sensitive_data.host_pubkeys[i]; |
| 761 |
if (key == NULL) |
| 753 |
continue; |
762 |
continue; |
| 754 |
switch (key->type) { |
763 |
switch (key->type) { |
| 755 |
case KEY_RSA: |
764 |
case KEY_RSA: |
|
Lines 802-807
get_hostkey_by_type(int type, int need_private)
Link Here
|
| 802 |
break; |
811 |
break; |
| 803 |
default: |
812 |
default: |
| 804 |
key = sensitive_data.host_keys[i]; |
813 |
key = sensitive_data.host_keys[i]; |
|
|
814 |
if (key == NULL && !need_private) |
| 815 |
key = sensitive_data.host_pubkeys[i]; |
| 805 |
break; |
816 |
break; |
| 806 |
} |
817 |
} |
| 807 |
if (key != NULL && key->type == type) |
818 |
if (key != NULL && key->type == type) |
|
Lines 831-836
get_hostkey_by_index(int ind)
Link Here
|
| 831 |
return (sensitive_data.host_keys[ind]); |
842 |
return (sensitive_data.host_keys[ind]); |
| 832 |
} |
843 |
} |
| 833 |
|
844 |
|
|
|
845 |
Key * |
| 846 |
get_hostkey_public_by_index(int ind) |
| 847 |
{ |
| 848 |
if (ind < 0 || ind >= options.num_host_key_files) |
| 849 |
return (NULL); |
| 850 |
return (sensitive_data.host_pubkeys[ind]); |
| 851 |
} |
| 852 |
|
| 834 |
int |
853 |
int |
| 835 |
get_hostkey_index(Key *key) |
854 |
get_hostkey_index(Key *key) |
| 836 |
{ |
855 |
{ |
|
Lines 843-848
get_hostkey_index(Key *key)
Link Here
|
| 843 |
} else { |
862 |
} else { |
| 844 |
if (key == sensitive_data.host_keys[i]) |
863 |
if (key == sensitive_data.host_keys[i]) |
| 845 |
return (i); |
864 |
return (i); |
|
|
865 |
if (key == sensitive_data.host_pubkeys[i]) |
| 866 |
return (i); |
| 846 |
} |
867 |
} |
| 847 |
} |
868 |
} |
| 848 |
return (-1); |
869 |
return (-1); |
|
Lines 1310-1315
main(int ac, char **av)
Link Here
|
| 1310 |
u_int64_t ibytes, obytes; |
1331 |
u_int64_t ibytes, obytes; |
| 1311 |
mode_t new_umask; |
1332 |
mode_t new_umask; |
| 1312 |
Key *key; |
1333 |
Key *key; |
|
|
1334 |
Key *pubkey; |
| 1335 |
int have_agent = 0, keytype; |
| 1313 |
Authctxt *authctxt; |
1336 |
Authctxt *authctxt; |
| 1314 |
struct connection_info *connection_info = get_connection_info(0, 0); |
1337 |
struct connection_info *connection_info = get_connection_info(0, 0); |
| 1315 |
|
1338 |
|
|
Lines 1542-1563
main(int ac, char **av)
Link Here
|
| 1542 |
debug("sshd version %s, %s", SSH_VERSION, |
1565 |
debug("sshd version %s, %s", SSH_VERSION, |
| 1543 |
SSLeay_version(SSLEAY_VERSION)); |
1566 |
SSLeay_version(SSLEAY_VERSION)); |
| 1544 |
|
1567 |
|
| 1545 |
/* load private host keys */ |
1568 |
/* load host keys */ |
| 1546 |
sensitive_data.host_keys = xcalloc(options.num_host_key_files, |
1569 |
sensitive_data.host_keys = xcalloc(options.num_host_key_files, |
| 1547 |
sizeof(Key *)); |
1570 |
sizeof(Key *)); |
| 1548 |
for (i = 0; i < options.num_host_key_files; i++) |
1571 |
sensitive_data.host_pubkeys = xcalloc(options.num_host_key_files, |
|
|
1572 |
sizeof(Key *)); |
| 1573 |
for (i = 0; i < options.num_host_key_files; i++) { |
| 1549 |
sensitive_data.host_keys[i] = NULL; |
1574 |
sensitive_data.host_keys[i] = NULL; |
|
|
1575 |
sensitive_data.host_pubkeys[i] = NULL; |
| 1576 |
} |
| 1577 |
|
| 1578 |
if (options.host_key_agent) { |
| 1579 |
if (strcmp(options.host_key_agent, SSH_AUTHSOCKET_ENV_NAME)) |
| 1580 |
setenv(SSH_AUTHSOCKET_ENV_NAME, |
| 1581 |
options.host_key_agent, 1); |
| 1582 |
have_agent = ssh_agent_present(); |
| 1583 |
} |
| 1550 |
|
1584 |
|
| 1551 |
for (i = 0; i < options.num_host_key_files; i++) { |
1585 |
for (i = 0; i < options.num_host_key_files; i++) { |
| 1552 |
key = key_load_private(options.host_key_files[i], "", NULL); |
1586 |
key = key_load_private(options.host_key_files[i], "", NULL); |
|
|
1587 |
pubkey = key_load_public(options.host_key_files[i], NULL); |
| 1553 |
sensitive_data.host_keys[i] = key; |
1588 |
sensitive_data.host_keys[i] = key; |
| 1554 |
if (key == NULL) { |
1589 |
sensitive_data.host_pubkeys[i] = pubkey; |
|
|
1590 |
|
| 1591 |
if (key == NULL && pubkey != NULL && pubkey->type != KEY_RSA1 && |
| 1592 |
have_agent) { |
| 1593 |
debug("will rely on agent for hostkey %s", |
| 1594 |
options.host_key_files[i]); |
| 1595 |
keytype = pubkey->type; |
| 1596 |
} else if (key != NULL) { |
| 1597 |
keytype = key->type; |
| 1598 |
} else { |
| 1555 |
error("Could not load host key: %s", |
1599 |
error("Could not load host key: %s", |
| 1556 |
options.host_key_files[i]); |
1600 |
options.host_key_files[i]); |
| 1557 |
sensitive_data.host_keys[i] = NULL; |
1601 |
sensitive_data.host_keys[i] = NULL; |
|
|
1602 |
sensitive_data.host_pubkeys[i] = NULL; |
| 1558 |
continue; |
1603 |
continue; |
| 1559 |
} |
1604 |
} |
| 1560 |
switch (key->type) { |
1605 |
|
|
|
1606 |
switch (keytype) { |
| 1561 |
case KEY_RSA1: |
1607 |
case KEY_RSA1: |
| 1562 |
sensitive_data.ssh1_host_key = key; |
1608 |
sensitive_data.ssh1_host_key = key; |
| 1563 |
sensitive_data.have_ssh1_key = 1; |
1609 |
sensitive_data.have_ssh1_key = 1; |
|
Lines 1568-1575
main(int ac, char **av)
Link Here
|
| 1568 |
sensitive_data.have_ssh2_key = 1; |
1614 |
sensitive_data.have_ssh2_key = 1; |
| 1569 |
break; |
1615 |
break; |
| 1570 |
} |
1616 |
} |
| 1571 |
debug("private host key: #%d type %d %s", i, key->type, |
1617 |
debug("private host key: #%d type %d %s", i, keytype, |
| 1572 |
key_type(key)); |
1618 |
key_type(key ? key : pubkey)); |
| 1573 |
} |
1619 |
} |
| 1574 |
if ((options.protocol & SSH_PROTO_1) && !sensitive_data.have_ssh1_key) { |
1620 |
if ((options.protocol & SSH_PROTO_1) && !sensitive_data.have_ssh1_key) { |
| 1575 |
logit("Disabling protocol version 1. Could not load host key"); |
1621 |
logit("Disabling protocol version 1. Could not load host key"); |
|
Lines 1906-1914
main(int ac, char **av)
Link Here
|
| 1906 |
buffer_init(&loginmsg); |
1952 |
buffer_init(&loginmsg); |
| 1907 |
auth_debug_reset(); |
1953 |
auth_debug_reset(); |
| 1908 |
|
1954 |
|
| 1909 |
if (use_privsep) |
1955 |
if (use_privsep) { |
| 1910 |
if (privsep_preauth(authctxt) == 1) |
1956 |
if (privsep_preauth(authctxt) == 1) |
| 1911 |
goto authenticated; |
1957 |
goto authenticated; |
|
|
1958 |
} else if (compat20) |
| 1959 |
auth_conn = ssh_get_authentication_connection(); |
| 1912 |
|
1960 |
|
| 1913 |
/* perform the key exchange */ |
1961 |
/* perform the key exchange */ |
| 1914 |
/* authenticate user and start session */ |
1962 |
/* authenticate user and start session */ |
|
Lines 2194-2199
do_ssh1_kex(void)
Link Here
|
| 2194 |
packet_write_wait(); |
2242 |
packet_write_wait(); |
| 2195 |
} |
2243 |
} |
| 2196 |
|
2244 |
|
|
|
2245 |
void |
| 2246 |
sshd_hostkey_sign(Key *privkey, Key *pubkey, u_char **signature, u_int *slen, |
| 2247 |
u_char *data, u_int dlen) |
| 2248 |
{ |
| 2249 |
if (privkey) { |
| 2250 |
if (PRIVSEP(key_sign(privkey, signature, slen, data, dlen) < 0)) |
| 2251 |
fatal("%s: key_sign failed", __func__); |
| 2252 |
} else if (use_privsep) { |
| 2253 |
if (mm_key_sign(pubkey, signature, slen, data, dlen) < 0) |
| 2254 |
fatal("%s: pubkey_sign failed", __func__); |
| 2255 |
} else { |
| 2256 |
if (ssh_agent_sign(auth_conn, pubkey, signature, slen, data, |
| 2257 |
dlen)) |
| 2258 |
fatal("%s: ssh_agent_sign failed", __func__); |
| 2259 |
} |
| 2260 |
} |
| 2261 |
|
| 2197 |
/* |
2262 |
/* |
| 2198 |
* SSH2 key exchange: diffie-hellman-group1-sha1 |
2263 |
* SSH2 key exchange: diffie-hellman-group1-sha1 |
| 2199 |
*/ |
2264 |
*/ |
|
Lines 2244-2249
do_ssh2_kex(void)
Link Here
|
| 2244 |
kex->load_host_public_key=&get_hostkey_public_by_type; |
2309 |
kex->load_host_public_key=&get_hostkey_public_by_type; |
| 2245 |
kex->load_host_private_key=&get_hostkey_private_by_type; |
2310 |
kex->load_host_private_key=&get_hostkey_private_by_type; |
| 2246 |
kex->host_key_index=&get_hostkey_index; |
2311 |
kex->host_key_index=&get_hostkey_index; |
|
|
2312 |
kex->sign = sshd_hostkey_sign; |
| 2247 |
|
2313 |
|
| 2248 |
xxx_kex = kex; |
2314 |
xxx_kex = kex; |
| 2249 |
|
2315 |
|