bc4ef0f
diff -up openssh-7.0p1/gss-genr.c.gsskexalg openssh-7.0p1/gss-genr.c
bc4ef0f
--- openssh-7.0p1/gss-genr.c.gsskexalg	2015-08-19 12:28:38.024518959 +0200
bc4ef0f
+++ openssh-7.0p1/gss-genr.c	2015-08-19 12:28:38.078518839 +0200
bc4ef0f
@@ -78,7 +78,8 @@ ssh_gssapi_oid_table_ok() {
bc4ef0f
  */
bc4ef0f
 
bc4ef0f
 char *
bc4ef0f
-ssh_gssapi_client_mechanisms(const char *host, const char *client) {
bc4ef0f
+ssh_gssapi_client_mechanisms(const char *host, const char *client,
bc4ef0f
+    const char *kex) {
bc4ef0f
 	gss_OID_set gss_supported;
bc4ef0f
 	OM_uint32 min_status;
bc4ef0f
 
bc4ef0f
@@ -86,12 +87,12 @@ ssh_gssapi_client_mechanisms(const char
bc4ef0f
 		return NULL;
bc4ef0f
 
bc4ef0f
 	return(ssh_gssapi_kex_mechs(gss_supported, ssh_gssapi_check_mechanism,
bc4ef0f
-	    host, client));
bc4ef0f
+	    host, client, kex));
bc4ef0f
 }
bc4ef0f
 
bc4ef0f
 char *
bc4ef0f
 ssh_gssapi_kex_mechs(gss_OID_set gss_supported, ssh_gssapi_check_fn *check,
bc4ef0f
-    const char *host, const char *client) {
bc4ef0f
+    const char *host, const char *client, const char *kex) {
bc4ef0f
 	Buffer buf;
bc4ef0f
 	size_t i;
bc4ef0f
 	int oidpos, enclen;
bc4ef0f
@@ -100,6 +101,7 @@ ssh_gssapi_kex_mechs(gss_OID_set gss_sup
bc4ef0f
 	char deroid[2];
bc4ef0f
 	const EVP_MD *evp_md = EVP_md5();
bc4ef0f
 	EVP_MD_CTX md;
bc4ef0f
+	char *s, *cp, *p;
bc4ef0f
 
bc4ef0f
 	if (gss_enc2oid != NULL) {
bc4ef0f
 		for (i = 0; gss_enc2oid[i].encoded != NULL; i++)
bc4ef0f
@@ -113,6 +115,7 @@ ssh_gssapi_kex_mechs(gss_OID_set gss_sup
bc4ef0f
 	buffer_init(&buf;;
bc4ef0f
 
bc4ef0f
 	oidpos = 0;
bc4ef0f
+	s = cp = xstrdup(kex);
bc4ef0f
 	for (i = 0; i < gss_supported->count; i++) {
bc4ef0f
 		if (gss_supported->elements[i].length < 128 &&
bc4ef0f
 		    (*check)(NULL, &(gss_supported->elements[i]), host, client)) {
bc4ef0f
@@ -131,26 +134,22 @@ ssh_gssapi_kex_mechs(gss_OID_set gss_sup
bc4ef0f
 			enclen = __b64_ntop(digest, EVP_MD_size(evp_md),
bc4ef0f
 			    encoded, EVP_MD_size(evp_md) * 2);
bc4ef0f
 
bc4ef0f
-			if (oidpos != 0)
bc4ef0f
-				buffer_put_char(&buf, ',');
bc4ef0f
-
bc4ef0f
-			buffer_append(&buf, KEX_GSS_GEX_SHA1_ID,
bc4ef0f
-			    sizeof(KEX_GSS_GEX_SHA1_ID) - 1);
bc4ef0f
-			buffer_append(&buf, encoded, enclen);
bc4ef0f
-			buffer_put_char(&buf, ',');
bc4ef0f
-			buffer_append(&buf, KEX_GSS_GRP1_SHA1_ID, 
bc4ef0f
-			    sizeof(KEX_GSS_GRP1_SHA1_ID) - 1);
bc4ef0f
-			buffer_append(&buf, encoded, enclen);
bc4ef0f
-			buffer_put_char(&buf, ',');
bc4ef0f
-			buffer_append(&buf, KEX_GSS_GRP14_SHA1_ID,
bc4ef0f
-			    sizeof(KEX_GSS_GRP14_SHA1_ID) - 1);
bc4ef0f
-			buffer_append(&buf, encoded, enclen);
bc4ef0f
+			cp = strncpy(s, kex, strlen(kex));
bc4ef0f
+			for ((p = strsep(&cp, ",")); p && *p != '\0';
bc4ef0f
+				(p = strsep(&cp, ","))) {
bc4ef0f
+				if (buffer_len(&buf) != 0)
bc4ef0f
+					buffer_put_char(&buf, ',');
bc4ef0f
+				buffer_append(&buf, p,
bc4ef0f
+				    strlen(p));
bc4ef0f
+				buffer_append(&buf, encoded, enclen);
bc4ef0f
+			}
bc4ef0f
 
bc4ef0f
 			gss_enc2oid[oidpos].oid = &(gss_supported->elements[i]);
bc4ef0f
 			gss_enc2oid[oidpos].encoded = encoded;
bc4ef0f
 			oidpos++;
bc4ef0f
 		}
bc4ef0f
 	}
bc4ef0f
+	free(s);
bc4ef0f
 	gss_enc2oid[oidpos].oid = NULL;
bc4ef0f
 	gss_enc2oid[oidpos].encoded = NULL;
bc4ef0f
 
bc4ef0f
diff -up openssh-7.0p1/gss-serv.c.gsskexalg openssh-7.0p1/gss-serv.c
bc4ef0f
--- openssh-7.0p1/gss-serv.c.gsskexalg	2015-08-19 12:28:38.024518959 +0200
bc4ef0f
+++ openssh-7.0p1/gss-serv.c	2015-08-19 12:28:38.078518839 +0200
4189ceb
@@ -149,7 +149,8 @@ ssh_gssapi_server_mechanisms() {
4189ceb
 	if (supported_oids == NULL)
4189ceb
 		ssh_gssapi_prepare_supported_oids();
4189ceb
 	return (ssh_gssapi_kex_mechs(supported_oids,
4189ceb
-	    &ssh_gssapi_server_check_mech, NULL, NULL));
4189ceb
+	    &ssh_gssapi_server_check_mech, NULL, NULL,
4189ceb
+	    options.gss_kex_algorithms));
bc4ef0f
 }
bc4ef0f
 
bc4ef0f
 /* Unprivileged */
bc4ef0f
diff -up openssh-7.0p1/kex.c.gsskexalg openssh-7.0p1/kex.c
bc4ef0f
--- openssh-7.0p1/kex.c.gsskexalg	2015-08-19 12:28:38.078518839 +0200
bc4ef0f
+++ openssh-7.0p1/kex.c	2015-08-19 12:30:13.249306371 +0200
c4c52b0
@@ -50,6 +50,7 @@
13073f8
 #include "misc.h"
c4c52b0
 #include "dispatch.h"
c4c52b0
 #include "monitor.h"
c4c52b0
+#include "xmalloc.h"
c4c52b0
 
c4c52b0
 #include "ssherr.h"
c4c52b0
 #include "sshbuf.h"
bc4ef0f
@@ -232,6 +232,29 @@ kex_assemble_names(const char *def, char
bc4ef0f
 	return 0;
bc4ef0f
 }
bc4ef0f
 
bc4ef0f
+/* Validate GSS KEX method name list */
bc4ef0f
+int
bc4ef0f
+gss_kex_names_valid(const char *names)
bc4ef0f
+{
bc4ef0f
+	char *s, *cp, *p;
bc4ef0f
+
bc4ef0f
+	if (names == NULL || *names == '\0')
bc4ef0f
+		return 0;
bc4ef0f
+	s = cp = xstrdup(names);
bc4ef0f
+	for ((p = strsep(&cp, ",")); p && *p != '\0';
bc4ef0f
+	    (p = strsep(&cp, ","))) {
bc4ef0f
+		if (strncmp(p, "gss-", 4) != 0
bc4ef0f
+		  || kex_alg_by_name(p) == NULL) {
bc4ef0f
+			error("Unsupported KEX algorithm \"%.100s\"", p);
bc4ef0f
+			free(s);
bc4ef0f
+			return 0;
bc4ef0f
+		}
bc4ef0f
+	}
bc4ef0f
+	debug3("gss kex names ok: [%s]", names);
bc4ef0f
+	free(s);
bc4ef0f
+	return 1;
bc4ef0f
+}
bc4ef0f
+
bc4ef0f
 /* put algorithm proposal into buffer */
bc4ef0f
 int
bc4ef0f
 kex_prop2buf(struct sshbuf *b, char *proposal[PROPOSAL_MAX])
bc4ef0f
diff -up openssh-7.0p1/kex.h.gsskexalg openssh-7.0p1/kex.h
bc4ef0f
--- openssh-7.0p1/kex.h.gsskexalg	2015-08-19 12:28:38.078518839 +0200
bc4ef0f
+++ openssh-7.0p1/kex.h	2015-08-19 12:30:52.404218958 +0200
bc4ef0f
@@ -173,6 +173,7 @@ int	 kex_names_valid(const char *);
bc4ef0f
 char	*kex_alg_list(char);
bc4ef0f
 char	*kex_names_cat(const char *, const char *);
bc4ef0f
 int	 kex_assemble_names(const char *, char **);
bc4ef0f
+int	 gss_kex_names_valid(const char *);
bc4ef0f
 
bc4ef0f
 int	 kex_new(struct ssh *, char *[PROPOSAL_MAX], struct kex **);
bc4ef0f
 int	 kex_setup(struct ssh *, char *[PROPOSAL_MAX]);
bc4ef0f
diff -up openssh-7.0p1/readconf.c.gsskexalg openssh-7.0p1/readconf.c
bc4ef0f
--- openssh-7.0p1/readconf.c.gsskexalg	2015-08-19 12:28:38.026518955 +0200
bc4ef0f
+++ openssh-7.0p1/readconf.c	2015-08-19 12:31:28.333138747 +0200
bc4ef0f
@@ -61,6 +61,7 @@
bc4ef0f
 #include "uidswap.h"
bc4ef0f
 #include "myproposal.h"
bc4ef0f
 #include "digest.h"
bc4ef0f
+#include "ssh-gss.h"
bc4ef0f
 
bc4ef0f
 /* Format of the configuration file:
bc4ef0f
 
bc4ef0f
@@ -148,7 +149,7 @@ typedef enum {
bc4ef0f
 	oEnableSSHKeysign, oRekeyLimit, oVerifyHostKeyDNS, oConnectTimeout,
bc4ef0f
 	oAddressFamily, oGssAuthentication, oGssDelegateCreds,
bc4ef0f
 	oGssTrustDns, oGssKeyEx, oGssClientIdentity, oGssRenewalRekey,
bc4ef0f
-	oGssServerIdentity, 
bc4ef0f
+	oGssServerIdentity, oGssKexAlgorithms,
bc4ef0f
 	oServerAliveInterval, oServerAliveCountMax, oIdentitiesOnly,
bc4ef0f
 	oSendEnv, oControlPath, oControlMaster, oControlPersist,
bc4ef0f
 	oHashKnownHosts,
bc4ef0f
@@ -200,6 +201,7 @@ static struct {
bc4ef0f
 	{ "gssapiclientidentity", oGssClientIdentity },
bc4ef0f
 	{ "gssapiserveridentity", oGssServerIdentity },
bc4ef0f
 	{ "gssapirenewalforcesrekey", oGssRenewalRekey },
bc4ef0f
+	{ "gssapikexalgorithms", oGssKexAlgorithms },
bc4ef0f
 #else
bc4ef0f
 	{ "gssapiauthentication", oUnsupported },
bc4ef0f
 	{ "gssapikeyexchange", oUnsupported },
bc4ef0f
@@ -207,6 +209,7 @@ static struct {
bc4ef0f
 	{ "gssapitrustdns", oUnsupported },
bc4ef0f
 	{ "gssapiclientidentity", oUnsupported },
bc4ef0f
 	{ "gssapirenewalforcesrekey", oUnsupported },
bc4ef0f
+	{ "gssapikexalgorithms", oUnsupported },
bc4ef0f
 #endif
bc4ef0f
 	{ "fallbacktorsh", oDeprecated },
bc4ef0f
 	{ "usersh", oDeprecated },
bc4ef0f
@@ -929,6 +932,18 @@ parse_time:
bc4ef0f
 		intptr = &options->gss_renewal_rekey;
bc4ef0f
 		goto parse_flag;
bc4ef0f
 
bc4ef0f
+	case oGssKexAlgorithms:
bc4ef0f
+		arg = strdelim(&s);
bc4ef0f
+		if (!arg || *arg == '\0')
bc4ef0f
+			fatal("%.200s line %d: Missing argument.",
bc4ef0f
+			    filename, linenum);
bc4ef0f
+		if (!gss_kex_names_valid(arg))
bc4ef0f
+			fatal("%.200s line %d: Bad GSSAPI KexAlgorithms '%s'.",
bc4ef0f
+			    filename, linenum, arg ? arg : "<NONE>");
bc4ef0f
+		if (*activep && options->gss_kex_algorithms == NULL)
bc4ef0f
+			options->gss_kex_algorithms = xstrdup(arg);
bc4ef0f
+		break;
bc4ef0f
+
bc4ef0f
 	case oBatchMode:
bc4ef0f
 		intptr = &options->batch_mode;
bc4ef0f
 		goto parse_flag;
bc4ef0f
@@ -1638,6 +1653,7 @@ initialize_options(Options * options)
bc4ef0f
 	options->gss_renewal_rekey = -1;
bc4ef0f
 	options->gss_client_identity = NULL;
bc4ef0f
 	options->gss_server_identity = NULL;
bc4ef0f
+	options->gss_kex_algorithms = NULL;
bc4ef0f
 	options->password_authentication = -1;
bc4ef0f
 	options->kbd_interactive_authentication = -1;
bc4ef0f
 	options->kbd_interactive_devices = NULL;
62897e5
@@ -1773,6 +1789,10 @@ fill_default_options(Options * options)
bc4ef0f
 		options->gss_trust_dns = 0;
bc4ef0f
 	if (options->gss_renewal_rekey == -1)
bc4ef0f
 		options->gss_renewal_rekey = 0;
62897e5
+#ifdef GSSAPI
bc4ef0f
+	if (options->gss_kex_algorithms == NULL)
bc4ef0f
+		options->gss_kex_algorithms = strdup(GSS_KEX_DEFAULT_KEX);
62897e5
+#endif
bc4ef0f
 	if (options->password_authentication == -1)
bc4ef0f
 		options->password_authentication = 1;
bc4ef0f
 	if (options->kbd_interactive_authentication == -1)
bc4ef0f
diff -up openssh-7.0p1/readconf.h.gsskexalg openssh-7.0p1/readconf.h
bc4ef0f
--- openssh-7.0p1/readconf.h.gsskexalg	2015-08-19 12:28:38.026518955 +0200
bc4ef0f
+++ openssh-7.0p1/readconf.h	2015-08-19 12:28:38.079518836 +0200
bc4ef0f
@@ -51,6 +51,7 @@ typedef struct {
bc4ef0f
 	int	gss_renewal_rekey;	/* Credential renewal forces rekey */
bc4ef0f
 	char    *gss_client_identity;   /* Principal to initiate GSSAPI with */
bc4ef0f
 	char    *gss_server_identity;   /* GSSAPI target principal */
bc4ef0f
+	char   *gss_kex_algorithms;	/* GSSAPI kex methods to be offered by client. */
bc4ef0f
 	int     password_authentication;	/* Try password
bc4ef0f
 						 * authentication. */
bc4ef0f
 	int     kbd_interactive_authentication; /* Try keyboard-interactive auth. */
bc4ef0f
diff -up openssh-7.0p1/servconf.c.gsskexalg openssh-7.0p1/servconf.c
bc4ef0f
--- openssh-7.0p1/servconf.c.gsskexalg	2015-08-19 12:28:38.074518847 +0200
bc4ef0f
+++ openssh-7.0p1/servconf.c	2015-08-19 12:33:13.599902732 +0200
bc4ef0f
@@ -57,6 +57,7 @@
bc4ef0f
 #include "auth.h"
bc4ef0f
 #include "myproposal.h"
bc4ef0f
 #include "digest.h"
bc4ef0f
+#include "ssh-gss.h"
bc4ef0f
 
bc4ef0f
 static void add_listen_addr(ServerOptions *, char *, int);
bc4ef0f
 static void add_one_listen_addr(ServerOptions *, char *, int);
bc4ef0f
@@ -121,6 +122,7 @@ initialize_server_options(ServerOptions
bc4ef0f
 	options->gss_cleanup_creds = -1;
bc4ef0f
 	options->gss_strict_acceptor = -1;
bc4ef0f
 	options->gss_store_rekey = -1;
bc4ef0f
+	options->gss_kex_algorithms = NULL;
bc4ef0f
 	options->password_authentication = -1;
bc4ef0f
 	options->kbd_interactive_authentication = -1;
bc4ef0f
 	options->challenge_response_authentication = -1;
62897e5
@@ -288,6 +290,10 @@ fill_default_server_options(ServerOption
bc4ef0f
 		options->gss_strict_acceptor = 0;
bc4ef0f
 	if (options->gss_store_rekey == -1)
bc4ef0f
 		options->gss_store_rekey = 0;
62897e5
+#ifdef GSSAPI
bc4ef0f
+	if (options->gss_kex_algorithms == NULL)
bc4ef0f
+		options->gss_kex_algorithms = strdup(GSS_KEX_DEFAULT_KEX);
62897e5
+#endif
bc4ef0f
 	if (options->password_authentication == -1)
bc4ef0f
 		options->password_authentication = 1;
bc4ef0f
 	if (options->kbd_interactive_authentication == -1)
bc4ef0f
@@ -427,7 +431,7 @@ typedef enum {
bc4ef0f
 	sHostKeyAlgorithms,
bc4ef0f
 	sClientAliveInterval, sClientAliveCountMax, sAuthorizedKeysFile,
bc4ef0f
 	sGssAuthentication, sGssCleanupCreds, sGssEnablek5users, sGssStrictAcceptor,
bc4ef0f
-	sGssKeyEx, sGssStoreRekey, sAcceptEnv, sPermitTunnel,
bc4ef0f
+	sGssKeyEx, sGssStoreRekey, sGssKexAlgorithms, sAcceptEnv, sPermitTunnel,
bc4ef0f
 	sMatch, sPermitOpen, sForceCommand, sChrootDirectory,
bc4ef0f
 	sUsePrivilegeSeparation, sAllowAgentForwarding,
bc4ef0f
 	sHostCertificate,
bc4ef0f
@@ -506,6 +510,7 @@ static struct {
bc4ef0f
 	{ "gssapikeyexchange", sGssKeyEx, SSHCFG_GLOBAL },
bc4ef0f
 	{ "gssapistorecredentialsonrekey", sGssStoreRekey, SSHCFG_GLOBAL },
bc4ef0f
 	{ "gssapienablek5users", sGssEnablek5users, SSHCFG_ALL },
bc4ef0f
+	{ "gssapikexalgorithms", sGssKexAlgorithms, SSHCFG_GLOBAL },
bc4ef0f
 #else
bc4ef0f
 	{ "gssapiauthentication", sUnsupported, SSHCFG_ALL },
bc4ef0f
 	{ "gssapicleanupcredentials", sUnsupported, SSHCFG_GLOBAL },
bc4ef0f
@@ -513,6 +518,7 @@ static struct {
bc4ef0f
 	{ "gssapikeyexchange", sUnsupported, SSHCFG_GLOBAL },
bc4ef0f
 	{ "gssapistorecredentialsonrekey", sUnsupported, SSHCFG_GLOBAL },
bc4ef0f
 	{ "gssapienablek5users", sUnsupported, SSHCFG_ALL },
bc4ef0f
+	{ "gssapikexalgorithms", sUnsupported, SSHCFG_GLOBAL },
bc4ef0f
 #endif
bc4ef0f
 	{ "gssusesessionccache", sUnsupported, SSHCFG_GLOBAL },
bc4ef0f
 	{ "gssapiusesessioncredcache", sUnsupported, SSHCFG_GLOBAL },
bc4ef0f
@@ -1273,6 +1279,18 @@ process_server_config_line(ServerOptions
bc4ef0f
 		intptr = &options->gss_store_rekey;
bc4ef0f
 		goto parse_flag;
bc4ef0f
 
bc4ef0f
+	case sGssKexAlgorithms:
bc4ef0f
+		arg = strdelim(&cp;;
bc4ef0f
+		if (!arg || *arg == '\0')
bc4ef0f
+			fatal("%.200s line %d: Missing argument.",
bc4ef0f
+			    filename, linenum);
bc4ef0f
+		if (!gss_kex_names_valid(arg))
bc4ef0f
+			fatal("%.200s line %d: Bad GSSAPI KexAlgorithms '%s'.",
bc4ef0f
+			    filename, linenum, arg ? arg : "<NONE>");
bc4ef0f
+		if (*activep && options->gss_kex_algorithms == NULL)
bc4ef0f
+			options->gss_kex_algorithms = xstrdup(arg);
bc4ef0f
+		break;
bc4ef0f
+
bc4ef0f
 	case sPasswordAuthentication:
bc4ef0f
 		intptr = &options->password_authentication;
bc4ef0f
 		goto parse_flag;
bc4ef0f
@@ -2304,6 +2322,7 @@ dump_config(ServerOptions *o)
bc4ef0f
 	dump_cfg_fmtint(sGssKeyEx, o->gss_keyex);
bc4ef0f
 	dump_cfg_fmtint(sGssStrictAcceptor, o->gss_strict_acceptor);
bc4ef0f
 	dump_cfg_fmtint(sGssStoreRekey, o->gss_store_rekey);
bc4ef0f
+	dump_cfg_string(sGssKexAlgorithms, o->gss_kex_algorithms);
bc4ef0f
 #endif
bc4ef0f
 	dump_cfg_fmtint(sPasswordAuthentication, o->password_authentication);
bc4ef0f
 	dump_cfg_fmtint(sKbdInteractiveAuthentication,
bc4ef0f
diff -up openssh-7.0p1/servconf.h.gsskexalg openssh-7.0p1/servconf.h
bc4ef0f
--- openssh-7.0p1/servconf.h.gsskexalg	2015-08-19 12:28:38.080518834 +0200
bc4ef0f
+++ openssh-7.0p1/servconf.h	2015-08-19 12:34:46.328693944 +0200
bc4ef0f
@@ -122,6 +122,7 @@ typedef struct {
bc4ef0f
 	int     gss_cleanup_creds;	/* If true, destroy cred cache on logout */
bc4ef0f
 	int     gss_strict_acceptor;	/* If true, restrict the GSSAPI acceptor name */
bc4ef0f
 	int 	gss_store_rekey;
bc4ef0f
+	char   *gss_kex_algorithms;	/* GSSAPI kex methods to be offered by client. */
bc4ef0f
 	int     password_authentication;	/* If true, permit password
bc4ef0f
 						 * authentication. */
bc4ef0f
 	int     kbd_interactive_authentication;	/* If true, permit */
bc4ef0f
diff -up openssh-7.0p1/ssh.1.gsskexalg openssh-7.0p1/ssh.1
bc4ef0f
--- openssh-7.0p1/ssh.1.gsskexalg	2015-08-19 12:28:38.081518832 +0200
bc4ef0f
+++ openssh-7.0p1/ssh.1	2015-08-19 12:35:31.741591692 +0200
bc4ef0f
@@ -496,6 +496,7 @@ For full details of the options listed b
bc4ef0f
 .It GSSAPIDelegateCredentials
bc4ef0f
 .It GSSAPIRenewalForcesRekey
bc4ef0f
 .It GSSAPITrustDNS
bc4ef0f
+.It GSSAPIKexAlgorithms
bc4ef0f
 .It HashKnownHosts
bc4ef0f
 .It Host
bc4ef0f
 .It HostbasedAuthentication
bc4ef0f
diff -up openssh-7.0p1/ssh_config.5.gsskexalg openssh-7.0p1/ssh_config.5
bc4ef0f
--- openssh-7.0p1/ssh_config.5.gsskexalg	2015-08-19 12:28:38.028518950 +0200
bc4ef0f
+++ openssh-7.0p1/ssh_config.5	2015-08-19 12:28:38.082518830 +0200
bc4ef0f
@@ -786,6 +786,18 @@ command line will be passed untouched to
13073f8
 command line will be passed untouched to the GSSAPI library.
bc4ef0f
 The default is
bc4ef0f
 .Dq no .
bc4ef0f
+.It Cm GSSAPIKexAlgorithms
bc4ef0f
+The list of key exchange algorithms that are offered for GSSAPI
bc4ef0f
+key exchange. Possible values are
bc4ef0f
+.Bd -literal -offset 3n
bc4ef0f
+gss-gex-sha1-,
bc4ef0f
+gss-group1-sha1-,
bc4ef0f
+gss-group14-sha1-
bc4ef0f
+.Ed
bc4ef0f
+.Pp
bc4ef0f
+The default is
bc4ef0f
+.Dq gss-gex-sha1-,gss-group14-sha1- .
bc4ef0f
+This option only applies to protocol version 2 connections using GSSAPI.
bc4ef0f
 .It Cm HashKnownHosts
bc4ef0f
 Indicates that
bc4ef0f
 .Xr ssh 1
bc4ef0f
diff -up openssh-7.0p1/sshconnect2.c.gsskexalg openssh-7.0p1/sshconnect2.c
bc4ef0f
--- openssh-7.0p1/sshconnect2.c.gsskexalg	2015-08-19 12:28:38.045518912 +0200
bc4ef0f
+++ openssh-7.0p1/sshconnect2.c	2015-08-19 12:28:38.081518832 +0200
bc4ef0f
@@ -179,7 +179,8 @@ ssh_kex2(char *host, struct sockaddr *ho
bc4ef0f
 		else
bc4ef0f
 			gss_host = host;
bc4ef0f
 
bc4ef0f
-		gss = ssh_gssapi_client_mechanisms(gss_host, options.gss_client_identity);
bc4ef0f
+		gss = ssh_gssapi_client_mechanisms(gss_host,
bc4ef0f
+		    options.gss_client_identity, options.gss_kex_algorithms);
bc4ef0f
 		if (gss) {
bc4ef0f
 			debug("Offering GSSAPI proposal: %s", gss);
9a804fa
 			xasprintf(&options.kex_algorithms,
d9d9575
--- openssh-7.1p1/sshd_config.5.gsskexalg	2015-12-10 15:32:48.105418092 +0100
d9d9575
+++ openssh-7.1p1/sshd_config.5	2015-12-10 15:33:47.771279548 +0100
d9d9575
@@ -663,6 +663,18 @@ or updated credentials from a compatible
d9d9575
 For this to work
d9d9575
 .Cm GSSAPIKeyExchange
d9d9575
 needs to be enabled in the server and also used by the client.
bc4ef0f
+.It Cm GSSAPIKexAlgorithms
bc4ef0f
+The list of key exchange algorithms that are accepted by GSSAPI
bc4ef0f
+key exchange. Possible values are
bc4ef0f
+.Bd -literal -offset 3n
bc4ef0f
+gss-gex-sha1-,
bc4ef0f
+gss-group1-sha1-,
bc4ef0f
+gss-group14-sha1-
bc4ef0f
+.Ed
bc4ef0f
+.Pp
bc4ef0f
+The default is
bc4ef0f
+.Dq gss-gex-sha1-,gss-group14-sha1- .
bc4ef0f
+This option only applies to protocol version 2 connections using GSSAPI.
bc4ef0f
 .It Cm HostbasedAcceptedKeyTypes
bc4ef0f
 Specifies the key types that will be accepted for hostbased authentication
bc4ef0f
 as a comma-separated pattern list.
bc4ef0f
diff -up openssh-7.0p1/ssh-gss.h.gsskexalg openssh-7.0p1/ssh-gss.h
bc4ef0f
--- openssh-7.0p1/ssh-gss.h.gsskexalg	2015-08-19 12:28:38.031518944 +0200
bc4ef0f
+++ openssh-7.0p1/ssh-gss.h	2015-08-19 12:28:38.081518832 +0200
bc4ef0f
@@ -76,6 +76,10 @@ extern char **k5users_allowed_cmds;
bc4ef0f
 #define KEX_GSS_GRP14_SHA1_ID				"gss-group14-sha1-"
bc4ef0f
 #define KEX_GSS_GEX_SHA1_ID				"gss-gex-sha1-"
bc4ef0f
 
bc4ef0f
+#define        GSS_KEX_DEFAULT_KEX \
bc4ef0f
+	KEX_GSS_GEX_SHA1_ID "," \
bc4ef0f
+	KEX_GSS_GRP14_SHA1_ID
bc4ef0f
+
bc4ef0f
 typedef struct {
bc4ef0f
 	char *filename;
bc4ef0f
 	char *envvar;
bc4ef0f
@@ -147,9 +151,9 @@ int ssh_gssapi_credentials_updated(Gssct
bc4ef0f
 /* In the server */
bc4ef0f
 typedef int ssh_gssapi_check_fn(Gssctxt **, gss_OID, const char *, 
bc4ef0f
     const char *);
bc4ef0f
-char *ssh_gssapi_client_mechanisms(const char *, const char *);
bc4ef0f
+char *ssh_gssapi_client_mechanisms(const char *, const char *, const char *);
bc4ef0f
 char *ssh_gssapi_kex_mechs(gss_OID_set, ssh_gssapi_check_fn *, const char *,
bc4ef0f
-    const char *);
bc4ef0f
+    const char *, const char *);
bc4ef0f
 gss_OID ssh_gssapi_id_kex(Gssctxt *, char *, int);
bc4ef0f
 int ssh_gssapi_server_check_mech(Gssctxt **,gss_OID, const char *, 
bc4ef0f
     const char *);