summaryrefslogtreecommitdiff
path: root/sshd.c
diff options
context:
space:
mode:
authorSimon Wilkinson <simon@sxw.org.uk>2014-02-09 16:09:48 +0000
committerColin Watson <cjwatson@debian.org>2020-02-21 12:01:36 +0000
commit34aff3aa136e5a65f441b25811dd466488fda087 (patch)
treee2170faeed03d67545255d3d3c9d62280414c0b2 /sshd.c
parentf0de78bd4f29fa688c5df116f3f9cd43543a76d0 (diff)
GSSAPI key exchange support
This patch has been rejected upstream: "None of the OpenSSH developers are in favour of adding this, and this situation has not changed for several years. This is not a slight on Simon's patch, which is of fine quality, but just that a) we don't trust GSSAPI implementations that much and b) we don't like adding new KEX since they are pre-auth attack surface. This one is particularly scary, since it requires hooks out to typically root-owned system resources." However, quite a lot of people rely on this in Debian, and it's better to have it merged into the main openssh package rather than having separate -krb5 packages (as we used to have). It seems to have a generally good security history. Origin: other, https://github.com/openssh-gsskex/openssh-gsskex/commits/debian/master Bug: https://bugzilla.mindrot.org/show_bug.cgi?id=1242 Last-Updated: 2020-02-21 Patch-Name: gssapi.patch
Diffstat (limited to 'sshd.c')
-rw-r--r--sshd.c62
1 files changed, 58 insertions, 4 deletions
diff --git a/sshd.c b/sshd.c
index 60b2aaf73..d92f03aaf 100644
--- a/sshd.c
+++ b/sshd.c
@@ -817,8 +817,8 @@ notify_hostkeys(struct ssh *ssh)
817 } 817 }
818 debug3("%s: sent %u hostkeys", __func__, nkeys); 818 debug3("%s: sent %u hostkeys", __func__, nkeys);
819 if (nkeys == 0) 819 if (nkeys == 0)
820 fatal("%s: no hostkeys", __func__); 820 debug3("%s: no hostkeys", __func__);
821 if ((r = sshpkt_send(ssh)) != 0) 821 else if ((r = sshpkt_send(ssh)) != 0)
822 sshpkt_fatal(ssh, r, "%s: send", __func__); 822 sshpkt_fatal(ssh, r, "%s: send", __func__);
823 sshbuf_free(buf); 823 sshbuf_free(buf);
824} 824}
@@ -1852,7 +1852,8 @@ main(int ac, char **av)
1852 free(fp); 1852 free(fp);
1853 } 1853 }
1854 accumulate_host_timing_secret(cfg, NULL); 1854 accumulate_host_timing_secret(cfg, NULL);
1855 if (!sensitive_data.have_ssh2_key) { 1855 /* The GSSAPI key exchange can run without a host key */
1856 if (!sensitive_data.have_ssh2_key && !options.gss_keyex) {
1856 logit("sshd: no hostkeys available -- exiting."); 1857 logit("sshd: no hostkeys available -- exiting.");
1857 exit(1); 1858 exit(1);
1858 } 1859 }
@@ -2347,6 +2348,48 @@ do_ssh2_kex(struct ssh *ssh)
2347 myproposal[PROPOSAL_SERVER_HOST_KEY_ALGS] = compat_pkalg_proposal( 2348 myproposal[PROPOSAL_SERVER_HOST_KEY_ALGS] = compat_pkalg_proposal(
2348 list_hostkey_types()); 2349 list_hostkey_types());
2349 2350
2351#if defined(GSSAPI) && defined(WITH_OPENSSL)
2352 {
2353 char *orig;
2354 char *gss = NULL;
2355 char *newstr = NULL;
2356 orig = myproposal[PROPOSAL_KEX_ALGS];
2357
2358 /*
2359 * If we don't have a host key, then there's no point advertising
2360 * the other key exchange algorithms
2361 */
2362
2363 if (strlen(myproposal[PROPOSAL_SERVER_HOST_KEY_ALGS]) == 0)
2364 orig = NULL;
2365
2366 if (options.gss_keyex)
2367 gss = ssh_gssapi_server_mechanisms();
2368 else
2369 gss = NULL;
2370
2371 if (gss && orig)
2372 xasprintf(&newstr, "%s,%s", gss, orig);
2373 else if (gss)
2374 newstr = gss;
2375 else if (orig)
2376 newstr = orig;
2377
2378 /*
2379 * If we've got GSSAPI mechanisms, then we've got the 'null' host
2380 * key alg, but we can't tell people about it unless its the only
2381 * host key algorithm we support
2382 */
2383 if (gss && (strlen(myproposal[PROPOSAL_SERVER_HOST_KEY_ALGS])) == 0)
2384 myproposal[PROPOSAL_SERVER_HOST_KEY_ALGS] = "null";
2385
2386 if (newstr)
2387 myproposal[PROPOSAL_KEX_ALGS] = newstr;
2388 else
2389 fatal("No supported key exchange algorithms");
2390 }
2391#endif
2392
2350 /* start key exchange */ 2393 /* start key exchange */
2351 if ((r = kex_setup(ssh, myproposal)) != 0) 2394 if ((r = kex_setup(ssh, myproposal)) != 0)
2352 fatal("kex_setup: %s", ssh_err(r)); 2395 fatal("kex_setup: %s", ssh_err(r));
@@ -2362,7 +2405,18 @@ do_ssh2_kex(struct ssh *ssh)
2362# ifdef OPENSSL_HAS_ECC 2405# ifdef OPENSSL_HAS_ECC
2363 kex->kex[KEX_ECDH_SHA2] = kex_gen_server; 2406 kex->kex[KEX_ECDH_SHA2] = kex_gen_server;
2364# endif 2407# endif
2365#endif 2408# ifdef GSSAPI
2409 if (options.gss_keyex) {
2410 kex->kex[KEX_GSS_GRP1_SHA1] = kexgss_server;
2411 kex->kex[KEX_GSS_GRP14_SHA1] = kexgss_server;
2412 kex->kex[KEX_GSS_GRP14_SHA256] = kexgss_server;
2413 kex->kex[KEX_GSS_GRP16_SHA512] = kexgss_server;
2414 kex->kex[KEX_GSS_GEX_SHA1] = kexgssgex_server;
2415 kex->kex[KEX_GSS_NISTP256_SHA256] = kexgss_server;
2416 kex->kex[KEX_GSS_C25519_SHA256] = kexgss_server;
2417 }
2418# endif
2419#endif /* WITH_OPENSSL */
2366 kex->kex[KEX_C25519_SHA256] = kex_gen_server; 2420 kex->kex[KEX_C25519_SHA256] = kex_gen_server;
2367 kex->kex[KEX_KEM_SNTRUP4591761X25519_SHA512] = kex_gen_server; 2421 kex->kex[KEX_KEM_SNTRUP4591761X25519_SHA512] = kex_gen_server;
2368 kex->load_host_public_key=&get_hostkey_public_by_type; 2422 kex->load_host_public_key=&get_hostkey_public_by_type;