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