components/openssh/patches/023-gsskex.patch
author Tomas Kuthan <tomas.kuthan@oracle.com>
Tue, 20 Sep 2016 03:54:40 -0700
changeset 6930 31ef2580c45d
parent 5819 c5f05bd2a9bc
child 7560 9732971b7855
permissions -rw-r--r--
24525860 upgrade OpenSSH to 7.3p1 24320031 problem in UTILITY/OPENSSH 24461706 problem in UTILITY/OPENSSH
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
3574
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
     1
#
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
     2
# GSS-API key exchange support
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
     3
#
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
     4
# Based on https://github.com/SimonWilkinson/gss-openssh/commit/ffae842
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
     5
# Updated to apply to OpenSSH 6.5.
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
     6
# Default value for GSSAPIKeyExchange changed to yes to match SunSSH behavior.
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
     7
# New files kexgssc.c and kexgsss.c moved to ../sources/ and made cstyle clean.
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
     8
#
6930
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
     9
# Update Sep 5, 2016:
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
    10
# Upstream renamed and moved canohost.c`get_canonical_hostname to sshd-specific
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
    11
# auth.c`auth_get_canonical_hostname. In Solaris specific GSS-API key exchange
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
    12
# code we need this functionality on the client side too, for canonicalizing
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
    13
# server hostbased service principal. We have moved remote_hostname back to
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
    14
# canohost.c.
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
    15
#
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
    16
# TODO:
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
    17
# When we upgrade Kerberos in Solaris to future version 1.15, we will use
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
    18
# krb5_expand_hostname for hostname canonicalization instead.
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
    19
#
3574
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    20
# Upstream rejected GSS-API key exchange several times before.
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    21
#
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    22
diff -pur old/Makefile.in new/Makefile.in
5025
bdd7dc7d2af4 PSARC/2015/395 OpenSSH 7.1p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 4503
diff changeset
    23
--- old/Makefile.in
bdd7dc7d2af4 PSARC/2015/395 OpenSSH 7.1p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 4503
diff changeset
    24
+++ new/Makefile.in
4503
bf30d46ab06e PSARC/2015/179 OpenSSH 6.8
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 3642
diff changeset
    25
@@ -87,6 +87,7 @@ LIBSSH_OBJS=${LIBOPENSSH_OBJS} \
3574
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    26
 	monitor_fdpass.o rijndael.o ssh-dss.o ssh-ecdsa.o ssh-rsa.o dh.o \
4503
bf30d46ab06e PSARC/2015/179 OpenSSH 6.8
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 3642
diff changeset
    27
 	msg.o progressmeter.o dns.o entropy.o gss-genr.o umac.o umac128.o \
bf30d46ab06e PSARC/2015/179 OpenSSH 6.8
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 3642
diff changeset
    28
 	sftp_provider.o \
3574
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    29
+	kexgssc.o \
4503
bf30d46ab06e PSARC/2015/179 OpenSSH 6.8
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 3642
diff changeset
    30
 	ssh-pkcs11.o smult_curve25519_ref.o \
bf30d46ab06e PSARC/2015/179 OpenSSH 6.8
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 3642
diff changeset
    31
 	poly1305.o chacha.o cipher-chachapoly.o \
bf30d46ab06e PSARC/2015/179 OpenSSH 6.8
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 3642
diff changeset
    32
 	ssh-ed25519.o digest-openssl.o digest-libc.o hmac.o \
bf30d46ab06e PSARC/2015/179 OpenSSH 6.8
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 3642
diff changeset
    33
@@ -107,7 +108,7 @@ SSHDOBJS=sshd.o auth-rhosts.o auth-passw
bf30d46ab06e PSARC/2015/179 OpenSSH 6.8
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 3642
diff changeset
    34
 	auth-skey.o auth-bsdauth.o auth2-hostbased.o auth2-kbdint.o \
bf30d46ab06e PSARC/2015/179 OpenSSH 6.8
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 3642
diff changeset
    35
 	auth2-none.o auth2-passwd.o auth2-pubkey.o \
bf30d46ab06e PSARC/2015/179 OpenSSH 6.8
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 3642
diff changeset
    36
 	monitor_mm.o monitor.o monitor_wrap.o auth-krb5.o \
3574
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    37
-	auth2-gss.o gss-serv.o gss-serv-krb5.o \
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    38
+	auth2-gss.o gss-serv.o gss-serv-krb5.o kexgsss.o \
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    39
 	loginrec.o auth-pam.o auth-shadow.o auth-sia.o md5crypt.o \
5819
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5818
diff changeset
    40
 	sftp-server.o sftp-common.o sftp_provider.o \
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5818
diff changeset
    41
 	sandbox-null.o sandbox-rlimit.o sandbox-systrace.o sandbox-darwin.o \
6930
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
    42
diff -pur old/auth.c new/auth.c
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
    43
--- old/auth.c
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
    44
+++ new/auth.c
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
    45
@@ -786,99 +786,6 @@ fakepw(void)
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
    46
 }
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
    47
 
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
    48
 /*
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
    49
- * Returns the remote DNS hostname as a string. The returned string must not
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
    50
- * be freed. NB. this will usually trigger a DNS query the first time it is
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
    51
- * called.
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
    52
- * This function does additional checks on the hostname to mitigate some
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
    53
- * attacks on legacy rhosts-style authentication.
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
    54
- * XXX is RhostsRSAAuthentication vulnerable to these?
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
    55
- * XXX Can we remove these checks? (or if not, remove RhostsRSAAuthentication?)
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
    56
- */
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
    57
-
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
    58
-static char *
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
    59
-remote_hostname(struct ssh *ssh)
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
    60
-{
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
    61
-	struct sockaddr_storage from;
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
    62
-	socklen_t fromlen;
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
    63
-	struct addrinfo hints, *ai, *aitop;
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
    64
-	char name[NI_MAXHOST], ntop2[NI_MAXHOST];
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
    65
-	const char *ntop = ssh_remote_ipaddr(ssh);
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
    66
-
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
    67
-	/* Get IP address of client. */
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
    68
-	fromlen = sizeof(from);
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
    69
-	memset(&from, 0, sizeof(from));
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
    70
-	if (getpeername(ssh_packet_get_connection_in(ssh),
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
    71
-	    (struct sockaddr *)&from, &fromlen) < 0) {
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
    72
-		debug("getpeername failed: %.100s", strerror(errno));
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
    73
-		return strdup(ntop);
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
    74
-	}
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
    75
-
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
    76
-	ipv64_normalise_mapped(&from, &fromlen);
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
    77
-	if (from.ss_family == AF_INET6)
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
    78
-		fromlen = sizeof(struct sockaddr_in6);
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
    79
-
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
    80
-	debug3("Trying to reverse map address %.100s.", ntop);
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
    81
-	/* Map the IP address to a host name. */
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
    82
-	if (getnameinfo((struct sockaddr *)&from, fromlen, name, sizeof(name),
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
    83
-	    NULL, 0, NI_NAMEREQD) != 0) {
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
    84
-		/* Host name not found.  Use ip address. */
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
    85
-		return strdup(ntop);
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
    86
-	}
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
    87
-
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
    88
-	/*
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
    89
-	 * if reverse lookup result looks like a numeric hostname,
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
    90
-	 * someone is trying to trick us by PTR record like following:
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
    91
-	 *	1.1.1.10.in-addr.arpa.	IN PTR	2.3.4.5
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
    92
-	 */
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
    93
-	memset(&hints, 0, sizeof(hints));
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
    94
-	hints.ai_socktype = SOCK_DGRAM;	/*dummy*/
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
    95
-	hints.ai_flags = AI_NUMERICHOST;
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
    96
-	if (getaddrinfo(name, NULL, &hints, &ai) == 0) {
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
    97
-		logit("Nasty PTR record \"%s\" is set up for %s, ignoring",
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
    98
-		    name, ntop);
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
    99
-		freeaddrinfo(ai);
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
   100
-		return strdup(ntop);
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
   101
-	}
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
   102
-
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
   103
-	/* Names are stored in lowercase. */
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
   104
-	lowercase(name);
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
   105
-
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
   106
-	/*
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
   107
-	 * Map it back to an IP address and check that the given
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
   108
-	 * address actually is an address of this host.  This is
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
   109
-	 * necessary because anyone with access to a name server can
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
   110
-	 * define arbitrary names for an IP address. Mapping from
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
   111
-	 * name to IP address can be trusted better (but can still be
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
   112
-	 * fooled if the intruder has access to the name server of
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
   113
-	 * the domain).
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
   114
-	 */
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
   115
-	memset(&hints, 0, sizeof(hints));
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
   116
-	hints.ai_family = from.ss_family;
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
   117
-	hints.ai_socktype = SOCK_STREAM;
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
   118
-	if (getaddrinfo(name, NULL, &hints, &aitop) != 0) {
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
   119
-		logit("reverse mapping checking getaddrinfo for %.700s "
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
   120
-		    "[%s] failed.", name, ntop);
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
   121
-		return strdup(ntop);
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
   122
-	}
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
   123
-	/* Look for the address from the list of addresses. */
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
   124
-	for (ai = aitop; ai; ai = ai->ai_next) {
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
   125
-		if (getnameinfo(ai->ai_addr, ai->ai_addrlen, ntop2,
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
   126
-		    sizeof(ntop2), NULL, 0, NI_NUMERICHOST) == 0 &&
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
   127
-		    (strcmp(ntop, ntop2) == 0))
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
   128
-				break;
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
   129
-	}
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
   130
-	freeaddrinfo(aitop);
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
   131
-	/* If we reached the end of the list, the address was not there. */
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
   132
-	if (ai == NULL) {
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
   133
-		/* Address not found for the host name. */
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
   134
-		logit("Address %.100s maps to %.600s, but this does not "
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
   135
-		    "map back to the address.", ntop, name);
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
   136
-		return strdup(ntop);
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
   137
-	}
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
   138
-	return strdup(name);
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
   139
-}
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
   140
-
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
   141
-/*
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
   142
  * Return the canonical name of the host in the other side of the current
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
   143
  * connection.  The host name is cached, so it is efficient to call this
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
   144
  * several times.
3574
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   145
diff -pur old/auth2-gss.c new/auth2-gss.c
5025
bdd7dc7d2af4 PSARC/2015/395 OpenSSH 7.1p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 4503
diff changeset
   146
--- old/auth2-gss.c
bdd7dc7d2af4 PSARC/2015/395 OpenSSH 7.1p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 4503
diff changeset
   147
+++ new/auth2-gss.c
3574
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   148
@@ -1,7 +1,7 @@
4503
bf30d46ab06e PSARC/2015/179 OpenSSH 6.8
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 3642
diff changeset
   149
 /* $OpenBSD: auth2-gss.c,v 1.22 2015/01/19 20:07:45 markus Exp $ */
3574
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   150
 
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   151
 /*
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   152
- * Copyright (c) 2001-2003 Simon Wilkinson. All rights reserved.
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   153
+ * Copyright (c) 2001-2007 Simon Wilkinson. All rights reserved.
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   154
  *
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   155
  * Redistribution and use in source and binary forms, with or without
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   156
  * modification, are permitted provided that the following conditions
4503
bf30d46ab06e PSARC/2015/179 OpenSSH 6.8
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 3642
diff changeset
   157
@@ -53,6 +53,39 @@ static int input_gssapi_mic(int type, u_
bf30d46ab06e PSARC/2015/179 OpenSSH 6.8
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 3642
diff changeset
   158
 static int input_gssapi_exchange_complete(int type, u_int32_t plen, void *ctxt);
bf30d46ab06e PSARC/2015/179 OpenSSH 6.8
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 3642
diff changeset
   159
 static int input_gssapi_errtok(int, u_int32_t, void *);
3574
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   160
 
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   161
+/* 
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   162
+ * The 'gssapi_keyex' userauth mechanism.
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   163
+ */
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   164
+static int
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   165
+userauth_gsskeyex(Authctxt *authctxt)
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   166
+{
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   167
+	int authenticated = 0;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   168
+	Buffer b;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   169
+	gss_buffer_desc mic, gssbuf;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   170
+	u_int len;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   171
+
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   172
+	mic.value = packet_get_string(&len);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   173
+	mic.length = len;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   174
+
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   175
+	packet_check_eom();
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   176
+
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   177
+	ssh_gssapi_buildmic(&b, authctxt->user, authctxt->service,
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   178
+	    "gssapi-keyex");
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   179
+
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   180
+	gssbuf.value = buffer_ptr(&b);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   181
+	gssbuf.length = buffer_len(&b);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   182
+
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   183
+	/* gss_kex_context is NULL with privsep, so we can't check it here */
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   184
+	if (!GSS_ERROR(PRIVSEP(ssh_gssapi_checkmic(gss_kex_context, 
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   185
+	    &gssbuf, &mic))))
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   186
+		authenticated = PRIVSEP(ssh_gssapi_userok(authctxt->user));
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   187
+	
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   188
+	buffer_free(&b);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   189
+	free(mic.value);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   190
+
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   191
+	return (authenticated);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   192
+}
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   193
+
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   194
 /*
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   195
  * We only support those mechanisms that we know about (ie ones that we know
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   196
  * how to check local user kuserok and the like)
4503
bf30d46ab06e PSARC/2015/179 OpenSSH 6.8
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 3642
diff changeset
   197
@@ -290,6 +323,12 @@ input_gssapi_mic(int type, u_int32_t ple
bf30d46ab06e PSARC/2015/179 OpenSSH 6.8
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 3642
diff changeset
   198
 	return 0;
3574
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   199
 }
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   200
 
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   201
+Authmethod method_gsskeyex = {
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   202
+	"gssapi-keyex",
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   203
+	userauth_gsskeyex,
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   204
+	&options.gss_authentication
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   205
+};
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   206
+
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   207
 Authmethod method_gssapi = {
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   208
 	"gssapi-with-mic",
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   209
 	userauth_gssapi,
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   210
diff -pur old/auth2.c new/auth2.c
5025
bdd7dc7d2af4 PSARC/2015/395 OpenSSH 7.1p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 4503
diff changeset
   211
--- old/auth2.c
bdd7dc7d2af4 PSARC/2015/395 OpenSSH 7.1p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 4503
diff changeset
   212
+++ new/auth2.c
4503
bf30d46ab06e PSARC/2015/179 OpenSSH 6.8
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 3642
diff changeset
   213
@@ -70,6 +70,7 @@ extern Authmethod method_passwd;
3574
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   214
 extern Authmethod method_kbdint;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   215
 extern Authmethod method_hostbased;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   216
 #ifdef GSSAPI
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   217
+extern Authmethod method_gsskeyex;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   218
 extern Authmethod method_gssapi;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   219
 #endif
4503
bf30d46ab06e PSARC/2015/179 OpenSSH 6.8
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 3642
diff changeset
   220
 
bf30d46ab06e PSARC/2015/179 OpenSSH 6.8
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 3642
diff changeset
   221
@@ -77,6 +78,7 @@ Authmethod *authmethods[] = {
3574
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   222
 	&method_none,
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   223
 	&method_pubkey,
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   224
 #ifdef GSSAPI
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   225
+	&method_gsskeyex,
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   226
 	&method_gssapi,
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   227
 #endif
4503
bf30d46ab06e PSARC/2015/179 OpenSSH 6.8
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 3642
diff changeset
   228
 	&method_passwd,
6930
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
   229
diff -pur old/canohost.c new/canohost.c
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
   230
--- old/canohost.c
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
   231
+++ new/canohost.c
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
   232
@@ -202,3 +202,97 @@ get_local_port(int sock)
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
   233
 {
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
   234
 	return get_sock_port(sock, 1);
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
   235
 }
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
   236
+
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
   237
+/*
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
   238
+ * Returns the remote DNS hostname as a string. The returned string must not
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
   239
+ * be freed. NB. this will usually trigger a DNS query the first time it is
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
   240
+ * called.
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
   241
+ * This function does additional checks on the hostname to mitigate some
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
   242
+ * attacks on legacy rhosts-style authentication.
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
   243
+ * XXX is RhostsRSAAuthentication vulnerable to these?
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
   244
+ * XXX Can we remove these checks? (or if not, remove RhostsRSAAuthentication?)
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
   245
+ */
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
   246
+
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
   247
+/* Oracle Solaris - moved out of auth.c for use in GSSKEX in sshconnect2.c */
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
   248
+char *
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
   249
+remote_hostname(struct ssh *ssh)
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
   250
+{
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
   251
+	struct sockaddr_storage from;
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
   252
+	socklen_t fromlen;
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
   253
+	struct addrinfo hints, *ai, *aitop;
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
   254
+	char name[NI_MAXHOST], ntop2[NI_MAXHOST];
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
   255
+	const char *ntop = ssh_remote_ipaddr(ssh);
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
   256
+
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
   257
+	/* Get IP address of client. */
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
   258
+	fromlen = sizeof(from);
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
   259
+	memset(&from, 0, sizeof(from));
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
   260
+	if (getpeername(ssh_packet_get_connection_in(ssh),
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
   261
+	    (struct sockaddr *)&from, &fromlen) < 0) {
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
   262
+		debug("getpeername failed: %.100s", strerror(errno));
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
   263
+		return strdup(ntop);
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
   264
+	}
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
   265
+
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
   266
+	ipv64_normalise_mapped(&from, &fromlen);
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
   267
+	if (from.ss_family == AF_INET6)
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
   268
+		fromlen = sizeof(struct sockaddr_in6);
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
   269
+
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
   270
+	debug3("Trying to reverse map address %.100s.", ntop);
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
   271
+	/* Map the IP address to a host name. */
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
   272
+	if (getnameinfo((struct sockaddr *)&from, fromlen, name, sizeof(name),
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
   273
+	    NULL, 0, NI_NAMEREQD) != 0) {
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
   274
+		/* Host name not found.  Use ip address. */
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
   275
+		return strdup(ntop);
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
   276
+	}
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
   277
+
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
   278
+	/*
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
   279
+	 * if reverse lookup result looks like a numeric hostname,
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
   280
+	 * someone is trying to trick us by PTR record like following:
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
   281
+	 *	1.1.1.10.in-addr.arpa.	IN PTR	2.3.4.5
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
   282
+	 */
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
   283
+	memset(&hints, 0, sizeof(hints));
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
   284
+	hints.ai_socktype = SOCK_DGRAM;	/*dummy*/
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
   285
+	hints.ai_flags = AI_NUMERICHOST;
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
   286
+	if (getaddrinfo(name, NULL, &hints, &ai) == 0) {
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
   287
+		logit("Nasty PTR record \"%s\" is set up for %s, ignoring",
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
   288
+		    name, ntop);
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
   289
+		freeaddrinfo(ai);
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
   290
+		return strdup(ntop);
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
   291
+	}
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
   292
+
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
   293
+	/* Names are stored in lowercase. */
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
   294
+	lowercase(name);
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
   295
+
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
   296
+	/*
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
   297
+	 * Map it back to an IP address and check that the given
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
   298
+	 * address actually is an address of this host.  This is
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
   299
+	 * necessary because anyone with access to a name server can
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
   300
+	 * define arbitrary names for an IP address. Mapping from
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
   301
+	 * name to IP address can be trusted better (but can still be
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
   302
+	 * fooled if the intruder has access to the name server of
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
   303
+	 * the domain).
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
   304
+	 */
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
   305
+	memset(&hints, 0, sizeof(hints));
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
   306
+	hints.ai_family = from.ss_family;
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
   307
+	hints.ai_socktype = SOCK_STREAM;
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
   308
+	if (getaddrinfo(name, NULL, &hints, &aitop) != 0) {
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
   309
+		logit("reverse mapping checking getaddrinfo for %.700s "
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
   310
+		    "[%s] failed.", name, ntop);
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
   311
+		return strdup(ntop);
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
   312
+	}
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
   313
+	/* Look for the address from the list of addresses. */
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
   314
+	for (ai = aitop; ai; ai = ai->ai_next) {
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
   315
+		if (getnameinfo(ai->ai_addr, ai->ai_addrlen, ntop2,
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
   316
+		    sizeof(ntop2), NULL, 0, NI_NUMERICHOST) == 0 &&
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
   317
+		    (strcmp(ntop, ntop2) == 0))
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
   318
+				break;
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
   319
+	}
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
   320
+	freeaddrinfo(aitop);
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
   321
+	/* If we reached the end of the list, the address was not there. */
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
   322
+	if (ai == NULL) {
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
   323
+		/* Address not found for the host name. */
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
   324
+		logit("Address %.100s maps to %.600s, but this does not "
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
   325
+		    "map back to the address.", ntop, name);
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
   326
+		return strdup(ntop);
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
   327
+	}
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
   328
+	return strdup(name);
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
   329
+}
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
   330
diff -pur old/canohost.h new/canohost.h
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
   331
--- old/canohost.h
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
   332
+++ new/canohost.h
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
   333
@@ -21,6 +21,9 @@ char		*get_local_ipaddr(int);
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
   334
 char		*get_local_name(int);
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
   335
 int		get_local_port(int);
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
   336
 
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
   337
+#include "packet.h"
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
   338
+char		*remote_hostname(struct ssh *);
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
   339
+
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
   340
 #endif /* _CANOHOST_H */
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
   341
 
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
   342
 void		 ipv64_normalise_mapped(struct sockaddr_storage *, socklen_t *);
3574
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   343
diff -pur old/gss-genr.c new/gss-genr.c
5025
bdd7dc7d2af4 PSARC/2015/395 OpenSSH 7.1p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 4503
diff changeset
   344
--- old/gss-genr.c
bdd7dc7d2af4 PSARC/2015/395 OpenSSH 7.1p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 4503
diff changeset
   345
+++ new/gss-genr.c
3574
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   346
@@ -1,7 +1,7 @@
4503
bf30d46ab06e PSARC/2015/179 OpenSSH 6.8
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 3642
diff changeset
   347
 /* $OpenBSD: gss-genr.c,v 1.23 2015/01/20 23:14:00 deraadt Exp $ */
3574
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   348
 
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   349
 /*
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   350
- * Copyright (c) 2001-2007 Simon Wilkinson. All rights reserved.
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   351
+ * Copyright (c) 2001-2009 Simon Wilkinson. All rights reserved.
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   352
  *
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   353
  * Redistribution and use in source and binary forms, with or without
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   354
  * modification, are permitted provided that the following conditions
5025
bdd7dc7d2af4 PSARC/2015/395 OpenSSH 7.1p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 4503
diff changeset
   355
@@ -41,12 +41,167 @@
3574
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   356
 #include "buffer.h"
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   357
 #include "log.h"
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   358
 #include "ssh2.h"
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   359
+#include "cipher.h"
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   360
+#include "key.h"
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   361
+#include "kex.h"
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   362
+#include <openssl/evp.h>
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   363
 
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   364
 #include "ssh-gss.h"
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   365
 
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   366
 extern u_char *session_id2;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   367
 extern u_int session_id2_len;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   368
 
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   369
+typedef struct {
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   370
+	char *encoded;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   371
+	gss_OID oid;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   372
+} ssh_gss_kex_mapping;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   373
+
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   374
+/*
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   375
+ * XXX - It would be nice to find a more elegant way of handling the
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   376
+ * XXX   passing of the key exchange context to the userauth routines
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   377
+ */
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   378
+
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   379
+Gssctxt *gss_kex_context = NULL;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   380
+
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   381
+static ssh_gss_kex_mapping *gss_enc2oid = NULL;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   382
+
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   383
+int 
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   384
+ssh_gssapi_oid_table_ok() {
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   385
+	return (gss_enc2oid != NULL);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   386
+}
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   387
+
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   388
+/*
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   389
+ * Return a list of the gss-group1-sha1 mechanisms supported by this program
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   390
+ *
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   391
+ * We test mechanisms to ensure that we can use them, to avoid starting
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   392
+ * a key exchange with a bad mechanism
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   393
+ */
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   394
+
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   395
+char *
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   396
+ssh_gssapi_client_mechanisms(const char *host) {
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   397
+	gss_OID_set gss_supported;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   398
+	OM_uint32 min_status;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   399
+
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   400
+	if (GSS_ERROR(gss_indicate_mechs(&min_status, &gss_supported)))
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   401
+		return NULL;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   402
+
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   403
+	return(ssh_gssapi_kex_mechs(gss_supported, ssh_gssapi_check_mechanism,
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   404
+	    host));
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   405
+}
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   406
+
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   407
+char *
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   408
+ssh_gssapi_kex_mechs(gss_OID_set gss_supported, ssh_gssapi_check_fn *check,
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   409
+    const char *data) {
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   410
+	Buffer buf;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   411
+	size_t i;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   412
+	int oidpos, enclen;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   413
+	char *mechs, *encoded;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   414
+	u_char digest[EVP_MAX_MD_SIZE];
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   415
+	char deroid[2];
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   416
+	const EVP_MD *evp_md = EVP_md5();
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   417
+	EVP_MD_CTX md;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   418
+
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   419
+	if (gss_enc2oid != NULL) {
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   420
+		for (i = 0; gss_enc2oid[i].encoded != NULL; i++)
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   421
+			free(gss_enc2oid[i].encoded);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   422
+		free(gss_enc2oid);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   423
+	}
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   424
+
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   425
+	gss_enc2oid = xmalloc(sizeof(ssh_gss_kex_mapping) *
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   426
+	    (gss_supported->count + 1));
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   427
+
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   428
+	buffer_init(&buf);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   429
+
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   430
+	oidpos = 0;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   431
+	for (i = 0; i < gss_supported->count; i++) {
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   432
+		if (gss_supported->elements[i].length < 128 &&
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   433
+		    (*check)(NULL, &(gss_supported->elements[i]), data)) {
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   434
+
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   435
+			deroid[0] = SSH_GSS_OIDTYPE;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   436
+			deroid[1] = gss_supported->elements[i].length;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   437
+
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   438
+			EVP_DigestInit(&md, evp_md);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   439
+			EVP_DigestUpdate(&md, deroid, 2);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   440
+			EVP_DigestUpdate(&md,
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   441
+			    gss_supported->elements[i].elements,
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   442
+			    gss_supported->elements[i].length);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   443
+			EVP_DigestFinal(&md, digest, NULL);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   444
+
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   445
+			encoded = xmalloc(EVP_MD_size(evp_md) * 2);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   446
+			enclen = __b64_ntop(digest, EVP_MD_size(evp_md),
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   447
+			    encoded, EVP_MD_size(evp_md) * 2);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   448
+
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   449
+			if (oidpos != 0)
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   450
+				buffer_put_char(&buf, ',');
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   451
+
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   452
+			buffer_append(&buf, KEX_GSS_GEX_SHA1_ID,
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   453
+			    sizeof(KEX_GSS_GEX_SHA1_ID) - 1);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   454
+			buffer_append(&buf, encoded, enclen);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   455
+			buffer_put_char(&buf, ',');
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   456
+			buffer_append(&buf, KEX_GSS_GRP1_SHA1_ID, 
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   457
+			    sizeof(KEX_GSS_GRP1_SHA1_ID) - 1);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   458
+			buffer_append(&buf, encoded, enclen);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   459
+			buffer_put_char(&buf, ',');
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   460
+			buffer_append(&buf, KEX_GSS_GRP14_SHA1_ID,
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   461
+			    sizeof(KEX_GSS_GRP14_SHA1_ID) - 1);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   462
+			buffer_append(&buf, encoded, enclen);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   463
+
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   464
+			gss_enc2oid[oidpos].oid = &(gss_supported->elements[i]);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   465
+			gss_enc2oid[oidpos].encoded = encoded;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   466
+			oidpos++;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   467
+		}
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   468
+	}
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   469
+	gss_enc2oid[oidpos].oid = NULL;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   470
+	gss_enc2oid[oidpos].encoded = NULL;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   471
+
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   472
+	buffer_put_char(&buf, '\0');
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   473
+
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   474
+	mechs = xmalloc(buffer_len(&buf));
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   475
+	buffer_get(&buf, mechs, buffer_len(&buf));
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   476
+	buffer_free(&buf);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   477
+
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   478
+	if (strlen(mechs) == 0) {
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   479
+		free(mechs);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   480
+		mechs = NULL;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   481
+	}
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   482
+	
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   483
+	return (mechs);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   484
+}
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   485
+
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   486
+gss_OID
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   487
+ssh_gssapi_id_kex(Gssctxt *ctx, char *name, int kex_type) {
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   488
+	int i = 0;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   489
+	
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   490
+	switch (kex_type) {
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   491
+	case KEX_GSS_GRP1_SHA1:
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   492
+		if (strlen(name) < sizeof(KEX_GSS_GRP1_SHA1_ID))
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   493
+			return GSS_C_NO_OID;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   494
+		name += sizeof(KEX_GSS_GRP1_SHA1_ID) - 1;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   495
+		break;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   496
+	case KEX_GSS_GRP14_SHA1:
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   497
+		if (strlen(name) < sizeof(KEX_GSS_GRP14_SHA1_ID))
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   498
+			return GSS_C_NO_OID;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   499
+		name += sizeof(KEX_GSS_GRP14_SHA1_ID) - 1;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   500
+		break;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   501
+	case KEX_GSS_GEX_SHA1:
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   502
+		if (strlen(name) < sizeof(KEX_GSS_GEX_SHA1_ID))
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   503
+			return GSS_C_NO_OID;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   504
+		name += sizeof(KEX_GSS_GEX_SHA1_ID) - 1;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   505
+		break;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   506
+	default:
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   507
+		return GSS_C_NO_OID;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   508
+	}
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   509
+
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   510
+	while (gss_enc2oid[i].encoded != NULL &&
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   511
+	    strcmp(name, gss_enc2oid[i].encoded) != 0)
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   512
+		i++;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   513
+
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   514
+	if (gss_enc2oid[i].oid != NULL && ctx != NULL)
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   515
+		ssh_gssapi_set_oid(ctx, gss_enc2oid[i].oid);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   516
+
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   517
+	return gss_enc2oid[i].oid;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   518
+}
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   519
+
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   520
 /* Check that the OID in a data stream matches that in the context */
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   521
 int
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   522
 ssh_gssapi_check_oid(Gssctxt *ctx, void *data, size_t len)
5025
bdd7dc7d2af4 PSARC/2015/395 OpenSSH 7.1p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 4503
diff changeset
   523
@@ -231,6 +386,9 @@ ssh_gssapi_import_name(Gssctxt *ctx, con
3574
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   524
 OM_uint32
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   525
 ssh_gssapi_sign(Gssctxt *ctx, gss_buffer_t buffer, gss_buffer_t hash)
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   526
 {
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   527
+	if (ctx == NULL) 
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   528
+		return -1;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   529
+
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   530
 	if ((ctx->major = gss_get_mic(&ctx->minor, ctx->context,
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   531
 	    GSS_C_QOP_DEFAULT, buffer, hash)))
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   532
 		ssh_gssapi_error(ctx);
5025
bdd7dc7d2af4 PSARC/2015/395 OpenSSH 7.1p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 4503
diff changeset
   533
@@ -238,6 +396,19 @@ ssh_gssapi_sign(Gssctxt *ctx, gss_buffer
3574
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   534
 	return (ctx->major);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   535
 }
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   536
 
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   537
+/* Priviledged when used by server */
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   538
+OM_uint32
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   539
+ssh_gssapi_checkmic(Gssctxt *ctx, gss_buffer_t gssbuf, gss_buffer_t gssmic)
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   540
+{
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   541
+	if (ctx == NULL)
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   542
+		return -1;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   543
+
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   544
+	ctx->major = gss_verify_mic(&ctx->minor, ctx->context,
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   545
+	    gssbuf, gssmic, NULL);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   546
+
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   547
+	return (ctx->major);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   548
+}
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   549
+
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   550
 void
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   551
 ssh_gssapi_buildmic(Buffer *b, const char *user, const char *service,
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   552
     const char *context)
5025
bdd7dc7d2af4 PSARC/2015/395 OpenSSH 7.1p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 4503
diff changeset
   553
@@ -256,6 +427,10 @@ ssh_gssapi_check_mechanism(Gssctxt **ctx
3574
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   554
 	gss_buffer_desc token = GSS_C_EMPTY_BUFFER;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   555
 	OM_uint32 major, minor;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   556
 	gss_OID_desc spnego_oid = {6, (void *)"\x2B\x06\x01\x05\x05\x02"};
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   557
+	Gssctxt *intctx = NULL;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   558
+
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   559
+	if (ctx == NULL)
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   560
+		ctx = &intctx;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   561
 
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   562
 	/* RFC 4462 says we MUST NOT do SPNEGO */
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   563
 	if (oid->length == spnego_oid.length && 
5025
bdd7dc7d2af4 PSARC/2015/395 OpenSSH 7.1p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 4503
diff changeset
   564
@@ -274,7 +449,7 @@ ssh_gssapi_check_mechanism(Gssctxt **ctx
3574
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   565
 			    GSS_C_NO_BUFFER);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   566
 	}
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   567
 
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   568
-	if (GSS_ERROR(major)) 
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   569
+	if (GSS_ERROR(major) || intctx != NULL) 
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   570
 		ssh_gssapi_delete_ctx(ctx);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   571
 
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   572
 	return (!GSS_ERROR(major));
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   573
diff -pur old/gss-serv.c new/gss-serv.c
5025
bdd7dc7d2af4 PSARC/2015/395 OpenSSH 7.1p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 4503
diff changeset
   574
--- old/gss-serv.c
bdd7dc7d2af4 PSARC/2015/395 OpenSSH 7.1p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 4503
diff changeset
   575
+++ new/gss-serv.c
3574
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   576
@@ -1,7 +1,7 @@
5025
bdd7dc7d2af4 PSARC/2015/395 OpenSSH 7.1p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 4503
diff changeset
   577
 /* $OpenBSD: gss-serv.c,v 1.29 2015/05/22 03:50:02 djm Exp $ */
3574
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   578
 
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   579
 /*
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   580
- * Copyright (c) 2001-2003 Simon Wilkinson. All rights reserved.
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   581
+ * Copyright (c) 2001-2009 Simon Wilkinson. All rights reserved.
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   582
  *
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   583
  * Redistribution and use in source and binary forms, with or without
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   584
  * modification, are permitted provided that the following conditions
5025
bdd7dc7d2af4 PSARC/2015/395 OpenSSH 7.1p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 4503
diff changeset
   585
@@ -47,6 +47,7 @@
bdd7dc7d2af4 PSARC/2015/395 OpenSSH 7.1p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 4503
diff changeset
   586
 #include "servconf.h"
3574
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   587
 
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   588
 #include "ssh-gss.h"
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   589
+#include "monitor_wrap.h"
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   590
 
5025
bdd7dc7d2af4 PSARC/2015/395 OpenSSH 7.1p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 4503
diff changeset
   591
 extern ServerOptions options;
bdd7dc7d2af4 PSARC/2015/395 OpenSSH 7.1p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 4503
diff changeset
   592
 
bdd7dc7d2af4 PSARC/2015/395 OpenSSH 7.1p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 4503
diff changeset
   593
@@ -142,6 +143,28 @@ ssh_gssapi_server_ctx(Gssctxt **ctx, gss
3574
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   594
 }
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   595
 
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   596
 /* Unprivileged */
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   597
+char *
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   598
+ssh_gssapi_server_mechanisms() {
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   599
+	gss_OID_set	supported;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   600
+
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   601
+	ssh_gssapi_supported_oids(&supported);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   602
+	return (ssh_gssapi_kex_mechs(supported, &ssh_gssapi_server_check_mech,
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   603
+	    NULL));
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   604
+}
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   605
+
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   606
+/* Unprivileged */
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   607
+int
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   608
+ssh_gssapi_server_check_mech(Gssctxt **dum, gss_OID oid, const char *data) {
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   609
+	Gssctxt *ctx = NULL;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   610
+	int res;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   611
+ 
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   612
+	res = !GSS_ERROR(PRIVSEP(ssh_gssapi_server_ctx(&ctx, oid)));
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   613
+	ssh_gssapi_delete_ctx(&ctx);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   614
+
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   615
+	return (res);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   616
+}
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   617
+
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   618
+/* Unprivileged */
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   619
 void
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   620
 ssh_gssapi_supported_oids(gss_OID_set *oidset)
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   621
 {
5025
bdd7dc7d2af4 PSARC/2015/395 OpenSSH 7.1p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 4503
diff changeset
   622
@@ -151,7 +174,9 @@ ssh_gssapi_supported_oids(gss_OID_set *o
3574
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   623
 	gss_OID_set supported;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   624
 
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   625
 	gss_create_empty_oid_set(&min_status, oidset);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   626
-	gss_indicate_mechs(&min_status, &supported);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   627
+
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   628
+	if (GSS_ERROR(gss_indicate_mechs(&min_status, &supported)))
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   629
+		return;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   630
 
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   631
 	while (supported_mechs[i]->name != NULL) {
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   632
 		if (GSS_ERROR(gss_test_oid_set_member(&min_status,
5025
bdd7dc7d2af4 PSARC/2015/395 OpenSSH 7.1p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 4503
diff changeset
   633
@@ -427,14 +452,4 @@ ssh_gssapi_userok(char *user)
3574
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   634
 	return (0);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   635
 }
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   636
 
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   637
-/* Privileged */
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   638
-OM_uint32
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   639
-ssh_gssapi_checkmic(Gssctxt *ctx, gss_buffer_t gssbuf, gss_buffer_t gssmic)
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   640
-{
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   641
-	ctx->major = gss_verify_mic(&ctx->minor, ctx->context,
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   642
-	    gssbuf, gssmic, NULL);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   643
-
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   644
-	return (ctx->major);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   645
-}
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   646
-
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   647
 #endif
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   648
diff -pur old/kex.c new/kex.c
5025
bdd7dc7d2af4 PSARC/2015/395 OpenSSH 7.1p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 4503
diff changeset
   649
--- old/kex.c
bdd7dc7d2af4 PSARC/2015/395 OpenSSH 7.1p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 4503
diff changeset
   650
+++ new/kex.c
6930
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
   651
@@ -55,6 +55,10 @@
4503
bf30d46ab06e PSARC/2015/179 OpenSSH 6.8
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 3642
diff changeset
   652
 #include "sshbuf.h"
3574
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   653
 #include "digest.h"
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   654
 
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   655
+#ifdef GSSAPI
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   656
+#include "ssh-gss.h"
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   657
+#endif
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   658
+
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   659
 #if OPENSSL_VERSION_NUMBER >= 0x00907000L
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   660
 # if defined(HAVE_EVP_SHA256)
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   661
 # define evp_ssh_sha256 EVP_sha256
6930
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
   662
@@ -111,6 +115,11 @@ static const struct kexalg kexalgs[] = {
4503
bf30d46ab06e PSARC/2015/179 OpenSSH 6.8
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 3642
diff changeset
   663
 #if defined(HAVE_EVP_SHA256) || !defined(WITH_OPENSSL)
3574
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   664
 	{ KEX_CURVE25519_SHA256, KEX_C25519_SHA256, 0, SSH_DIGEST_SHA256 },
4503
bf30d46ab06e PSARC/2015/179 OpenSSH 6.8
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 3642
diff changeset
   665
 #endif /* HAVE_EVP_SHA256 || !WITH_OPENSSL */
3574
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   666
+#ifdef GSSAPI
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   667
+	{ KEX_GSS_GEX_SHA1_ID, KEX_GSS_GEX_SHA1, 0, SSH_DIGEST_SHA1 },
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   668
+	{ KEX_GSS_GRP1_SHA1_ID, KEX_GSS_GRP1_SHA1, 0, SSH_DIGEST_SHA1 },
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   669
+	{ KEX_GSS_GRP14_SHA1_ID, KEX_GSS_GRP14_SHA1, 0, SSH_DIGEST_SHA1 },
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   670
+#endif
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   671
 	{ NULL, -1, -1, -1},
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   672
 };
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   673
 
6930
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
   674
@@ -142,7 +151,7 @@ kex_alg_by_name(const char *name)
3574
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   675
 	const struct kexalg *k;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   676
 
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   677
 	for (k = kexalgs; k->name != NULL; k++) {
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   678
-		if (strcmp(k->name, name) == 0)
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   679
+		if (strncmp(k->name, name, strlen(k->name)) == 0)
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   680
 			return k;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   681
 	}
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   682
 	return NULL;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   683
diff -pur old/kex.h new/kex.h
5025
bdd7dc7d2af4 PSARC/2015/395 OpenSSH 7.1p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 4503
diff changeset
   684
--- old/kex.h
bdd7dc7d2af4 PSARC/2015/395 OpenSSH 7.1p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 4503
diff changeset
   685
+++ new/kex.h
6930
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
   686
@@ -98,6 +98,9 @@ enum kex_exchange {
3574
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   687
 	KEX_DH_GEX_SHA256,
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   688
 	KEX_ECDH_SHA2,
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   689
 	KEX_C25519_SHA256,
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   690
+	KEX_GSS_GRP1_SHA1,
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   691
+	KEX_GSS_GRP14_SHA1,
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   692
+	KEX_GSS_GEX_SHA1,
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   693
 	KEX_MAX
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   694
 };
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   695
 
6930
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
   696
@@ -146,6 +149,10 @@ struct kex {
4503
bf30d46ab06e PSARC/2015/179 OpenSSH 6.8
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 3642
diff changeset
   697
 	u_int	flags;
3574
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   698
 	int	hash_alg;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   699
 	int	ec_nid;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   700
+#ifdef GSSAPI
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   701
+	int	gss_deleg_creds;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   702
+	char    *gss_host;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   703
+#endif
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   704
 	char	*client_version_string;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   705
 	char	*server_version_string;
5025
bdd7dc7d2af4 PSARC/2015/395 OpenSSH 7.1p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 4503
diff changeset
   706
 	char	*failed_choice;
6930
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
   707
@@ -195,6 +202,10 @@ int	 kexecdh_client(struct ssh *);
4503
bf30d46ab06e PSARC/2015/179 OpenSSH 6.8
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 3642
diff changeset
   708
 int	 kexecdh_server(struct ssh *);
bf30d46ab06e PSARC/2015/179 OpenSSH 6.8
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 3642
diff changeset
   709
 int	 kexc25519_client(struct ssh *);
bf30d46ab06e PSARC/2015/179 OpenSSH 6.8
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 3642
diff changeset
   710
 int	 kexc25519_server(struct ssh *);
3574
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   711
+#ifdef GSSAPI
4503
bf30d46ab06e PSARC/2015/179 OpenSSH 6.8
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 3642
diff changeset
   712
+int	 kexgss_client(struct ssh *);
bf30d46ab06e PSARC/2015/179 OpenSSH 6.8
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 3642
diff changeset
   713
+int	 kexgss_server(struct ssh *);
3574
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   714
+#endif
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   715
 
6930
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
   716
 int	 kex_dh_hash(int, const char *, const char *,
4503
bf30d46ab06e PSARC/2015/179 OpenSSH 6.8
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 3642
diff changeset
   717
     const u_char *, size_t, const u_char *, size_t, const u_char *, size_t,
3574
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   718
diff -pur old/monitor.c new/monitor.c
5025
bdd7dc7d2af4 PSARC/2015/395 OpenSSH 7.1p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 4503
diff changeset
   719
--- old/monitor.c
bdd7dc7d2af4 PSARC/2015/395 OpenSSH 7.1p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 4503
diff changeset
   720
+++ new/monitor.c
6930
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
   721
@@ -161,6 +161,7 @@ int mm_answer_gss_setup_ctx(int, Buffer
3574
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   722
 int mm_answer_gss_accept_ctx(int, Buffer *);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   723
 int mm_answer_gss_userok(int, Buffer *);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   724
 int mm_answer_gss_checkmic(int, Buffer *);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   725
+int mm_answer_gss_sign(int, Buffer *);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   726
 #endif
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   727
 
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   728
 #ifdef SSH_AUDIT_EVENTS
6930
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
   729
@@ -245,11 +246,17 @@ struct mon_table mon_dispatch_proto20[]
3574
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   730
     {MONITOR_REQ_GSSSTEP, MON_ISAUTH, mm_answer_gss_accept_ctx},
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   731
     {MONITOR_REQ_GSSUSEROK, MON_AUTH, mm_answer_gss_userok},
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   732
     {MONITOR_REQ_GSSCHECKMIC, MON_ISAUTH, mm_answer_gss_checkmic},
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   733
+    {MONITOR_REQ_GSSSIGN, MON_ONCE, mm_answer_gss_sign},
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   734
 #endif
4503
bf30d46ab06e PSARC/2015/179 OpenSSH 6.8
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 3642
diff changeset
   735
     {0, 0, NULL}
3574
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   736
 };
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   737
 
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   738
 struct mon_table mon_dispatch_postauth20[] = {
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   739
+#ifdef GSSAPI
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   740
+    {MONITOR_REQ_GSSSETUP, 0, mm_answer_gss_setup_ctx},
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   741
+    {MONITOR_REQ_GSSSTEP, 0, mm_answer_gss_accept_ctx},
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   742
+    {MONITOR_REQ_GSSSIGN, 0, mm_answer_gss_sign},
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   743
+#endif
4503
bf30d46ab06e PSARC/2015/179 OpenSSH 6.8
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 3642
diff changeset
   744
 #ifdef WITH_OPENSSL
3574
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   745
     {MONITOR_REQ_MODULI, 0, mm_answer_moduli},
4503
bf30d46ab06e PSARC/2015/179 OpenSSH 6.8
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 3642
diff changeset
   746
 #endif
6930
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
   747
@@ -364,6 +371,10 @@ monitor_child_preauth(Authctxt *_authctx
3574
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   748
 		/* Permit requests for moduli and signatures */
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   749
 		monitor_permit(mon_dispatch, MONITOR_REQ_MODULI, 1);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   750
 		monitor_permit(mon_dispatch, MONITOR_REQ_SIGN, 1);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   751
+#ifdef GSSAPI
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   752
+		/* and for the GSSAPI key exchange */
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   753
+		monitor_permit(mon_dispatch, MONITOR_REQ_GSSSETUP, 1);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   754
+#endif
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   755
 	} else {
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   756
 		mon_dispatch = mon_dispatch_proto15;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   757
 
6930
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
   758
@@ -503,6 +514,10 @@ monitor_child_postauth(struct monitor *p
3574
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   759
 		monitor_permit(mon_dispatch, MONITOR_REQ_MODULI, 1);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   760
 		monitor_permit(mon_dispatch, MONITOR_REQ_SIGN, 1);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   761
 		monitor_permit(mon_dispatch, MONITOR_REQ_TERM, 1);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   762
+#ifdef GSSAPI
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   763
+		/* and for the GSSAPI key exchange */
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   764
+		monitor_permit(mon_dispatch, MONITOR_REQ_GSSSETUP, 1);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   765
+#endif		
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   766
 	} else {
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   767
 		mon_dispatch = mon_dispatch_postauth15;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   768
 		monitor_permit(mon_dispatch, MONITOR_REQ_TERM, 1);
6930
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
   769
@@ -1939,6 +1954,13 @@ monitor_apply_keystate(struct monitor *p
4503
bf30d46ab06e PSARC/2015/179 OpenSSH 6.8
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 3642
diff changeset
   770
 # endif
bf30d46ab06e PSARC/2015/179 OpenSSH 6.8
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 3642
diff changeset
   771
 #endif /* WITH_OPENSSL */
bf30d46ab06e PSARC/2015/179 OpenSSH 6.8
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 3642
diff changeset
   772
 		kex->kex[KEX_C25519_SHA256] = kexc25519_server;
3574
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   773
+#ifdef GSSAPI
4503
bf30d46ab06e PSARC/2015/179 OpenSSH 6.8
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 3642
diff changeset
   774
+		if (options.gss_keyex) {
bf30d46ab06e PSARC/2015/179 OpenSSH 6.8
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 3642
diff changeset
   775
+			kex->kex[KEX_GSS_GRP1_SHA1] = kexgss_server;
bf30d46ab06e PSARC/2015/179 OpenSSH 6.8
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 3642
diff changeset
   776
+			kex->kex[KEX_GSS_GRP14_SHA1] = kexgss_server;
bf30d46ab06e PSARC/2015/179 OpenSSH 6.8
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 3642
diff changeset
   777
+			kex->kex[KEX_GSS_GEX_SHA1] = kexgss_server;
bf30d46ab06e PSARC/2015/179 OpenSSH 6.8
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 3642
diff changeset
   778
+		}
3574
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   779
+#endif
4503
bf30d46ab06e PSARC/2015/179 OpenSSH 6.8
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 3642
diff changeset
   780
 		kex->load_host_public_key=&get_hostkey_public_by_type;
bf30d46ab06e PSARC/2015/179 OpenSSH 6.8
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 3642
diff changeset
   781
 		kex->load_host_private_key=&get_hostkey_private_by_type;
bf30d46ab06e PSARC/2015/179 OpenSSH 6.8
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 3642
diff changeset
   782
 		kex->host_key_index=&get_hostkey_index;
6930
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
   783
@@ -2038,6 +2060,9 @@ mm_answer_gss_setup_ctx(int sock, Buffer
3574
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   784
 	OM_uint32 major;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   785
 	u_int len;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   786
 
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   787
+	if (!options.gss_authentication && !options.gss_keyex)
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   788
+		fatal("In GSSAPI monitor when GSSAPI is disabled");
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   789
+
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   790
 	goid.elements = buffer_get_string(m, &len);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   791
 	goid.length = len;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   792
 
6930
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
   793
@@ -2065,6 +2090,9 @@ mm_answer_gss_accept_ctx(int sock, Buffe
3574
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   794
 	OM_uint32 flags = 0; /* GSI needs this */
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   795
 	u_int len;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   796
 
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   797
+	if (!options.gss_authentication && !options.gss_keyex)
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   798
+		fatal("In GSSAPI monitor when GSSAPI is disabled");
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   799
+
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   800
 	in.value = buffer_get_string(m, &len);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   801
 	in.length = len;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   802
 	major = ssh_gssapi_accept_ctx(gsscontext, &in, &out, &flags);
6930
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
   803
@@ -2082,6 +2110,7 @@ mm_answer_gss_accept_ctx(int sock, Buffe
3574
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   804
 		monitor_permit(mon_dispatch, MONITOR_REQ_GSSSTEP, 0);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   805
 		monitor_permit(mon_dispatch, MONITOR_REQ_GSSUSEROK, 1);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   806
 		monitor_permit(mon_dispatch, MONITOR_REQ_GSSCHECKMIC, 1);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   807
+		monitor_permit(mon_dispatch, MONITOR_REQ_GSSSIGN, 1);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   808
 	}
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   809
 	return (0);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   810
 }
6930
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
   811
@@ -2093,6 +2122,9 @@ mm_answer_gss_checkmic(int sock, Buffer
3574
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   812
 	OM_uint32 ret;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   813
 	u_int len;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   814
 
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   815
+	if (!options.gss_authentication && !options.gss_keyex)
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   816
+		fatal("In GSSAPI monitor when GSSAPI is disabled");
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   817
+
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   818
 	gssbuf.value = buffer_get_string(m, &len);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   819
 	gssbuf.length = len;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   820
 	mic.value = buffer_get_string(m, &len);
6930
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
   821
@@ -2119,6 +2151,9 @@ mm_answer_gss_userok(int sock, Buffer *m
3574
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   822
 {
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   823
 	int authenticated;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   824
 
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   825
+	if (!options.gss_authentication && !options.gss_keyex)
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   826
+		fatal("In GSSAPI monitor when GSSAPI is disabled");
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   827
+
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   828
 	authenticated = authctxt->valid && ssh_gssapi_userok(authctxt->user);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   829
 
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   830
 	buffer_clear(m);
6930
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
   831
@@ -2132,5 +2167,47 @@ mm_answer_gss_userok(int sock, Buffer *m
3574
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   832
 	/* Monitor loop will terminate if authenticated */
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   833
 	return (authenticated);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   834
 }
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   835
+
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   836
+int 
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   837
+mm_answer_gss_sign(int socket, Buffer *m)
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   838
+{
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   839
+	gss_buffer_desc data;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   840
+	gss_buffer_desc hash = GSS_C_EMPTY_BUFFER;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   841
+	OM_uint32 major, minor;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   842
+	u_int len;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   843
+
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   844
+	if (!options.gss_authentication && !options.gss_keyex)
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   845
+		fatal("In GSSAPI monitor when GSSAPI is disabled");
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   846
+
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   847
+	data.value = buffer_get_string(m, &len);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   848
+	data.length = len;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   849
+	if (data.length != 20) 
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   850
+		fatal("%s: data length incorrect: %d", __func__, 
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   851
+		    (int) data.length);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   852
+
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   853
+	/* Save the session ID on the first time around */
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   854
+	if (session_id2_len == 0) {
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   855
+		session_id2_len = data.length;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   856
+		session_id2 = xmalloc(session_id2_len);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   857
+		memcpy(session_id2, data.value, session_id2_len);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   858
+	}
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   859
+	major = ssh_gssapi_sign(gsscontext, &data, &hash);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   860
+
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   861
+	free(data.value);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   862
+
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   863
+	buffer_clear(m);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   864
+	buffer_put_int(m, major);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   865
+	buffer_put_string(m, hash.value, hash.length);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   866
+
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   867
+	mm_request_send(socket, MONITOR_ANS_GSSSIGN, m);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   868
+
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   869
+	gss_release_buffer(&minor, &hash);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   870
+
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   871
+	/* Turn on getpwnam permissions */
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   872
+	monitor_permit(mon_dispatch, MONITOR_REQ_PWNAM, 1);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   873
+
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   874
+	return (0);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   875
+}
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   876
+
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   877
 #endif /* GSSAPI */
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   878
 
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   879
diff -pur old/monitor.h new/monitor.h
5025
bdd7dc7d2af4 PSARC/2015/395 OpenSSH 7.1p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 4503
diff changeset
   880
--- old/monitor.h
bdd7dc7d2af4 PSARC/2015/395 OpenSSH 7.1p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 4503
diff changeset
   881
+++ new/monitor.h
4503
bf30d46ab06e PSARC/2015/179 OpenSSH 6.8
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 3642
diff changeset
   882
@@ -68,6 +68,9 @@ enum monitor_reqtype {
3574
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   883
 #ifdef PAM_ENHANCEMENT
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   884
         MONITOR_REQ_AUTHMETHOD = 114,
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   885
 #endif        
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   886
+#ifdef GSSAPI
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   887
+	MONITOR_REQ_GSSSIGN = 130, MONITOR_ANS_GSSSIGN = 131,
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   888
+#endif        
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   889
 };
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   890
 
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   891
 struct mm_master;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   892
diff -pur old/monitor_wrap.c new/monitor_wrap.c
5025
bdd7dc7d2af4 PSARC/2015/395 OpenSSH 7.1p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 4503
diff changeset
   893
--- old/monitor_wrap.c
bdd7dc7d2af4 PSARC/2015/395 OpenSSH 7.1p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 4503
diff changeset
   894
+++ new/monitor_wrap.c
6930
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
   895
@@ -1108,5 +1108,28 @@ mm_ssh_gssapi_userok(char *user)
3574
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   896
 	debug3("%s: user %sauthenticated",__func__, authenticated ? "" : "not ");
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   897
 	return (authenticated);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   898
 }
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   899
+
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   900
+OM_uint32
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   901
+mm_ssh_gssapi_sign(Gssctxt *ctx, gss_buffer_desc *data, gss_buffer_desc *hash)
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   902
+{
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   903
+	Buffer m;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   904
+	OM_uint32 major;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   905
+	u_int len;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   906
+
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   907
+	buffer_init(&m);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   908
+	buffer_put_string(&m, data->value, data->length);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   909
+
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   910
+	mm_request_send(pmonitor->m_recvfd, MONITOR_REQ_GSSSIGN, &m);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   911
+	mm_request_receive_expect(pmonitor->m_recvfd, MONITOR_ANS_GSSSIGN, &m);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   912
+
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   913
+	major = buffer_get_int(&m);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   914
+	hash->value = buffer_get_string(&m, &len);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   915
+	hash->length = len;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   916
+
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   917
+	buffer_free(&m);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   918
+
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   919
+	return(major);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   920
+}
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   921
+
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   922
 #endif /* GSSAPI */
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   923
 
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   924
diff -pur old/monitor_wrap.h new/monitor_wrap.h
5025
bdd7dc7d2af4 PSARC/2015/395 OpenSSH 7.1p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 4503
diff changeset
   925
--- old/monitor_wrap.h
bdd7dc7d2af4 PSARC/2015/395 OpenSSH 7.1p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 4503
diff changeset
   926
+++ new/monitor_wrap.h
6930
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
   927
@@ -62,6 +62,7 @@ OM_uint32 mm_ssh_gssapi_accept_ctx(Gssct
3574
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   928
    gss_buffer_desc *, gss_buffer_desc *, OM_uint32 *);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   929
 int mm_ssh_gssapi_userok(char *user);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   930
 OM_uint32 mm_ssh_gssapi_checkmic(Gssctxt *, gss_buffer_t, gss_buffer_t);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   931
+OM_uint32 mm_ssh_gssapi_sign(Gssctxt *, gss_buffer_t, gss_buffer_t);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   932
 #endif
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   933
 
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   934
 #ifdef USE_PAM
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   935
diff -pur old/readconf.c new/readconf.c
5025
bdd7dc7d2af4 PSARC/2015/395 OpenSSH 7.1p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 4503
diff changeset
   936
--- old/readconf.c
bdd7dc7d2af4 PSARC/2015/395 OpenSSH 7.1p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 4503
diff changeset
   937
+++ new/readconf.c
6930
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
   938
@@ -160,6 +160,7 @@ typedef enum {
3574
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   939
 	oClearAllForwardings, oNoHostAuthenticationForLocalhost,
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   940
 	oEnableSSHKeysign, oRekeyLimit, oVerifyHostKeyDNS, oConnectTimeout,
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   941
 	oAddressFamily, oGssAuthentication, oGssDelegateCreds,
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   942
+	oGssKeyEx,
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   943
 	oServerAliveInterval, oServerAliveCountMax, oIdentitiesOnly,
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   944
 	oSendEnv, oControlPath, oControlMaster, oControlPersist,
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   945
 	oHashKnownHosts,
6930
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
   946
@@ -211,11 +212,15 @@ static struct {
5027
c71f34180df2 PSARC/2015/427 Old SunSSH Gss* Option Names in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5025
diff changeset
   947
 	{ "gssauthentication", oGssAuthentication },                /* alias */
3574
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   948
 	{ "gssapidelegatecredentials", oGssDelegateCreds },
5027
c71f34180df2 PSARC/2015/427 Old SunSSH Gss* Option Names in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5025
diff changeset
   949
 	{ "gssdelegatecreds", oGssDelegateCreds },                  /* alias */
3574
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   950
+	{ "gssapikeyexchange", oGssKeyEx },
5027
c71f34180df2 PSARC/2015/427 Old SunSSH Gss* Option Names in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5025
diff changeset
   951
+	{ "gsskeyex", oGssKeyEx },                                  /* alias */
3574
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   952
 #else
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   953
 	{ "gssapiauthentication", oUnsupported },
5027
c71f34180df2 PSARC/2015/427 Old SunSSH Gss* Option Names in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5025
diff changeset
   954
 	{ "gssauthentication", oUnsupported },
3574
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   955
 	{ "gssapidelegatecredentials", oUnsupported },
5027
c71f34180df2 PSARC/2015/427 Old SunSSH Gss* Option Names in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5025
diff changeset
   956
 	{ "gssdelegatecreds", oUnsupported },
3574
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   957
+	{ "gssapikeyexchange", oUnsupported },
5027
c71f34180df2 PSARC/2015/427 Old SunSSH Gss* Option Names in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5025
diff changeset
   958
+	{ "gsskeyex", oUnsupported },
3574
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   959
 #endif
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   960
 	{ "fallbacktorsh", oDeprecated },
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   961
 	{ "usersh", oDeprecated },
6930
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
   962
@@ -1002,6 +1007,10 @@ parse_time:
3574
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   963
 		intptr = &options->gss_authentication;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   964
 		goto parse_flag;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   965
 
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   966
+	case oGssKeyEx:
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   967
+		intptr = &options->gss_keyex;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   968
+		goto parse_flag;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   969
+
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   970
 	case oGssDelegateCreds:
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   971
 		intptr = &options->gss_deleg_creds;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   972
 		goto parse_flag;
6930
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
   973
@@ -1824,6 +1833,7 @@ initialize_options(Options * options)
3574
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   974
 	options->pubkey_authentication = -1;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   975
 	options->challenge_response_authentication = -1;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   976
 	options->gss_authentication = -1;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   977
+	options->gss_keyex = -1;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   978
 	options->gss_deleg_creds = -1;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   979
 	options->password_authentication = -1;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   980
 	options->kbd_interactive_authentication = -1;
6930
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
   981
@@ -1979,6 +1989,12 @@ fill_default_options(Options * options)
3574
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   982
 #else
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   983
 		options->gss_authentication = 0;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   984
 #endif
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   985
+	if (options->gss_keyex == -1)
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   986
+#ifdef OPTION_DEFAULT_VALUE
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   987
+		options->gss_keyex = 1;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   988
+#else
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   989
+		options->gss_keyex = 0;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   990
+#endif
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   991
 	if (options->gss_deleg_creds == -1)
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   992
 		options->gss_deleg_creds = 0;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   993
 	if (options->password_authentication == -1)
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   994
diff -pur old/readconf.h new/readconf.h
5025
bdd7dc7d2af4 PSARC/2015/395 OpenSSH 7.1p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 4503
diff changeset
   995
--- old/readconf.h
bdd7dc7d2af4 PSARC/2015/395 OpenSSH 7.1p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 4503
diff changeset
   996
+++ new/readconf.h
4503
bf30d46ab06e PSARC/2015/179 OpenSSH 6.8
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 3642
diff changeset
   997
@@ -45,6 +45,7 @@ typedef struct {
3574
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   998
 	int     challenge_response_authentication;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   999
 					/* Try S/Key or TIS, authentication. */
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1000
 	int     gss_authentication;	/* Try GSS authentication */
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1001
+	int     gss_keyex;		/* Try GSS key exchange */
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1002
 	int     gss_deleg_creds;	/* Delegate GSS credentials */
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1003
 	int     password_authentication;	/* Try password
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1004
 						 * authentication. */
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1005
diff -pur old/servconf.c new/servconf.c
5025
bdd7dc7d2af4 PSARC/2015/395 OpenSSH 7.1p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 4503
diff changeset
  1006
--- old/servconf.c
bdd7dc7d2af4 PSARC/2015/395 OpenSSH 7.1p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 4503
diff changeset
  1007
+++ new/servconf.c
bdd7dc7d2af4 PSARC/2015/395 OpenSSH 7.1p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 4503
diff changeset
  1008
@@ -117,6 +117,7 @@ initialize_server_options(ServerOptions
3574
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1009
 	options->kerberos_ticket_cleanup = -1;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1010
 	options->kerberos_get_afs_token = -1;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1011
 	options->gss_authentication=-1;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1012
+	options->gss_keyex = -1;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1013
 	options->gss_cleanup_creds = -1;
5025
bdd7dc7d2af4 PSARC/2015/395 OpenSSH 7.1p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 4503
diff changeset
  1014
 	options->gss_strict_acceptor = -1;
3574
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1015
 	options->password_authentication = -1;
5819
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5818
diff changeset
  1016
@@ -312,6 +313,12 @@ fill_default_server_options(ServerOption
3574
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1017
 #else
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1018
 		options->gss_authentication = 0;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1019
 #endif
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1020
+	if (options->gss_keyex == -1)
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1021
+#ifdef OPTION_DEFAULT_VALUE
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1022
+		options->gss_keyex = 1;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1023
+#else
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1024
+		options->gss_keyex = 0;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1025
+#endif
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1026
 	if (options->gss_cleanup_creds == -1)
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1027
 		options->gss_cleanup_creds = 1;
5025
bdd7dc7d2af4 PSARC/2015/395 OpenSSH 7.1p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 4503
diff changeset
  1028
 	if (options->gss_strict_acceptor == -1)
6930
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
  1029
@@ -457,6 +464,7 @@ typedef enum {
4503
bf30d46ab06e PSARC/2015/179 OpenSSH 6.8
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 3642
diff changeset
  1030
 	sHostbasedUsesNameFromPacketOnly, sHostbasedAcceptedKeyTypes,
5025
bdd7dc7d2af4 PSARC/2015/395 OpenSSH 7.1p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 4503
diff changeset
  1031
 	sHostKeyAlgorithms,
4503
bf30d46ab06e PSARC/2015/179 OpenSSH 6.8
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 3642
diff changeset
  1032
 	sClientAliveInterval, sClientAliveCountMax, sAuthorizedKeysFile,
3574
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1033
+	sGssKeyEx,
5025
bdd7dc7d2af4 PSARC/2015/395 OpenSSH 7.1p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 4503
diff changeset
  1034
 	sGssAuthentication, sGssCleanupCreds, sGssStrictAcceptor,
bdd7dc7d2af4 PSARC/2015/395 OpenSSH 7.1p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 4503
diff changeset
  1035
 	sAcceptEnv, sPermitTunnel,
3574
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1036
 	sMatch, sPermitOpen, sForceCommand, sChrootDirectory,
6930
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
  1037
@@ -534,6 +542,8 @@ static struct {
3574
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1038
 #ifdef GSSAPI
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1039
 	{ "gssapiauthentication", sGssAuthentication, SSHCFG_ALL },
5027
c71f34180df2 PSARC/2015/427 Old SunSSH Gss* Option Names in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5025
diff changeset
  1040
 	{ "gssauthentication", sGssAuthentication, SSHCFG_ALL },   /* alias */
3574
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1041
+	{ "gssapikeyexchange", sGssKeyEx, SSHCFG_ALL },
5027
c71f34180df2 PSARC/2015/427 Old SunSSH Gss* Option Names in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5025
diff changeset
  1042
+	{ "gsskeyex", sGssKeyEx, SSHCFG_ALL },                     /* alias */
3574
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1043
 #ifdef USE_GSS_STORE_CRED
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1044
 	{ "gssapicleanupcredentials", sUnsupported, SSHCFG_GLOBAL },
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1045
 #else /* USE_GSS_STORE_CRED */
6930
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
  1046
@@ -543,6 +553,8 @@ static struct {
3574
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1047
 #else
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1048
 	{ "gssapiauthentication", sUnsupported, SSHCFG_ALL },
5027
c71f34180df2 PSARC/2015/427 Old SunSSH Gss* Option Names in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5025
diff changeset
  1049
 	{ "gssauthentication", sUnsupported, SSHCFG_ALL },          /* alias */
c71f34180df2 PSARC/2015/427 Old SunSSH Gss* Option Names in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5025
diff changeset
  1050
+	{ "gssapikeyexchange", sUnsupported,, SSHCFG_ALL },
c71f34180df2 PSARC/2015/427 Old SunSSH Gss* Option Names in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5025
diff changeset
  1051
+	{ "gsskeyex", sUnsupported,, SSHCFG_ALL },
3574
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1052
 	{ "gssapicleanupcredentials", sUnsupported, SSHCFG_GLOBAL },
5025
bdd7dc7d2af4 PSARC/2015/395 OpenSSH 7.1p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 4503
diff changeset
  1053
 	{ "gssapistrictacceptorcheck", sUnsupported, SSHCFG_GLOBAL },
3574
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1054
 #endif
6930
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
  1055
@@ -1328,6 +1340,10 @@ process_server_config_line(ServerOptions
3574
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1056
 		intptr = &options->gss_authentication;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1057
 		goto parse_flag;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1058
 
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1059
+	case sGssKeyEx:
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1060
+		intptr = &options->gss_keyex;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1061
+		goto parse_flag;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1062
+
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1063
 	case sGssCleanupCreds:
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1064
 		intptr = &options->gss_cleanup_creds;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1065
 		goto parse_flag;
6930
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
  1066
@@ -2416,6 +2432,7 @@ dump_config(ServerOptions *o)
3574
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1067
 #endif
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1068
 #ifdef GSSAPI
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1069
 	dump_cfg_fmtint(sGssAuthentication, o->gss_authentication);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1070
+	dump_cfg_fmtint(sGssKeyEx, o->gss_keyex);
5025
bdd7dc7d2af4 PSARC/2015/395 OpenSSH 7.1p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 4503
diff changeset
  1071
 #ifndef USE_GSS_STORE_CRED
3574
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1072
 	dump_cfg_fmtint(sGssCleanupCreds, o->gss_cleanup_creds);
5025
bdd7dc7d2af4 PSARC/2015/395 OpenSSH 7.1p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 4503
diff changeset
  1073
 #endif /* !USE_GSS_STORE_CRED */
3574
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1074
diff -pur old/servconf.h new/servconf.h
5025
bdd7dc7d2af4 PSARC/2015/395 OpenSSH 7.1p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 4503
diff changeset
  1075
--- old/servconf.h
bdd7dc7d2af4 PSARC/2015/395 OpenSSH 7.1p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 4503
diff changeset
  1076
+++ new/servconf.h
bdd7dc7d2af4 PSARC/2015/395 OpenSSH 7.1p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 4503
diff changeset
  1077
@@ -122,6 +122,7 @@ typedef struct {
3574
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1078
 	int     kerberos_get_afs_token;		/* If true, try to get AFS token if
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1079
 						 * authenticated with Kerberos. */
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1080
 	int     gss_authentication;	/* If true, permit GSSAPI authentication */
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1081
+	int     gss_keyex;		/* If true, permit GSSAPI key exchange */
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1082
 	int     gss_cleanup_creds;	/* If true, destroy cred cache on logout */
5025
bdd7dc7d2af4 PSARC/2015/395 OpenSSH 7.1p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 4503
diff changeset
  1083
 	int     gss_strict_acceptor;	/* If true, restrict the GSSAPI acceptor name */
3574
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1084
 	int     password_authentication;	/* If true, permit password
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1085
diff -pur old/ssh-gss.h new/ssh-gss.h
5025
bdd7dc7d2af4 PSARC/2015/395 OpenSSH 7.1p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 4503
diff changeset
  1086
--- old/ssh-gss.h
bdd7dc7d2af4 PSARC/2015/395 OpenSSH 7.1p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 4503
diff changeset
  1087
+++ new/ssh-gss.h
3574
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1088
@@ -61,6 +61,17 @@
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1089
 
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1090
 #define SSH_GSS_OIDTYPE 0x06
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1091
 
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1092
+#define SSH2_MSG_KEXGSS_INIT                            30
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1093
+#define SSH2_MSG_KEXGSS_CONTINUE                        31
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1094
+#define SSH2_MSG_KEXGSS_COMPLETE                        32
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1095
+#define SSH2_MSG_KEXGSS_HOSTKEY                         33
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1096
+#define SSH2_MSG_KEXGSS_ERROR                           34
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1097
+#define SSH2_MSG_KEXGSS_GROUPREQ			40
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1098
+#define SSH2_MSG_KEXGSS_GROUP				41
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1099
+#define KEX_GSS_GRP1_SHA1_ID				"gss-group1-sha1-"
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1100
+#define KEX_GSS_GRP14_SHA1_ID				"gss-group14-sha1-"
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1101
+#define KEX_GSS_GEX_SHA1_ID				"gss-gex-sha1-"
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1102
+
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1103
 typedef struct {
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1104
 	char *filename;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1105
 	char *envvar;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1106
@@ -98,6 +109,7 @@ typedef struct {
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1107
 } Gssctxt;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1108
 
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1109
 extern ssh_gssapi_mech *supported_mechs[];
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1110
+extern Gssctxt *gss_kex_context;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1111
 
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1112
 int  ssh_gssapi_check_oid(Gssctxt *, void *, size_t);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1113
 void ssh_gssapi_set_oid_data(Gssctxt *, void *, size_t);
4503
bf30d46ab06e PSARC/2015/179 OpenSSH 6.8
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 3642
diff changeset
  1114
@@ -122,6 +134,11 @@ void ssh_gssapi_buildmic(Buffer *, const
3574
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1115
 int ssh_gssapi_check_mechanism(Gssctxt **, gss_OID, const char *);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1116
 
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1117
 /* In the server */
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1118
+typedef int ssh_gssapi_check_fn(Gssctxt **, gss_OID, const char *);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1119
+char *ssh_gssapi_client_mechanisms(const char *host);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1120
+char *ssh_gssapi_kex_mechs(gss_OID_set, ssh_gssapi_check_fn *, const char *);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1121
+gss_OID ssh_gssapi_id_kex(Gssctxt *, char *, int);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1122
+int ssh_gssapi_server_check_mech(Gssctxt **,gss_OID, const char *);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1123
 OM_uint32 ssh_gssapi_server_ctx(Gssctxt **, gss_OID);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1124
 int ssh_gssapi_userok(char *name);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1125
 OM_uint32 ssh_gssapi_checkmic(Gssctxt *, gss_buffer_t, gss_buffer_t);
4503
bf30d46ab06e PSARC/2015/179 OpenSSH 6.8
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 3642
diff changeset
  1126
@@ -129,6 +146,8 @@ void ssh_gssapi_do_child(char ***, u_int
3574
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1127
 void ssh_gssapi_cleanup_creds(void);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1128
 void ssh_gssapi_storecreds(void);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1129
 
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1130
+char *ssh_gssapi_server_mechanisms(void);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1131
+int ssh_gssapi_oid_table_ok();
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1132
 #endif /* GSSAPI */
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1133
 
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1134
 #endif /* _SSH_GSS_H */
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1135
diff -pur old/ssh_config.5 new/ssh_config.5
5025
bdd7dc7d2af4 PSARC/2015/395 OpenSSH 7.1p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 4503
diff changeset
  1136
--- old/ssh_config.5
bdd7dc7d2af4 PSARC/2015/395 OpenSSH 7.1p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 4503
diff changeset
  1137
+++ new/ssh_config.5
5819
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5818
diff changeset
  1138
@@ -834,6 +834,12 @@ The default is
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5818
diff changeset
  1139
 Specifies whether user authentication based on GSSAPI is allowed.
3574
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1140
 The default on Solaris is
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1141
 .Dq yes .
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1142
+.It Cm GSSAPIKeyExchange
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1143
+Specifies whether key exchange based on GSSAPI may be used. When using
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1144
+GSSAPI key exchange the server need not have a host key.
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1145
+The default on Solaris is
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1146
+.Dq yes .
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1147
+Note that this option applies to protocol version 2 only.
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1148
 .It Cm GSSAPIDelegateCredentials
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1149
 Forward (delegate) credentials to the server.
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1150
 The default is
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1151
diff -pur old/sshconnect2.c new/sshconnect2.c
5025
bdd7dc7d2af4 PSARC/2015/395 OpenSSH 7.1p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 4503
diff changeset
  1152
--- old/sshconnect2.c
bdd7dc7d2af4 PSARC/2015/395 OpenSSH 7.1p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 4503
diff changeset
  1153
+++ new/sshconnect2.c
6930
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
  1154
@@ -165,11 +165,35 @@ ssh_kex2(char *host, struct sockaddr *ho
5819
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5818
diff changeset
  1155
 	char *s;
4503
bf30d46ab06e PSARC/2015/179 OpenSSH 6.8
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 3642
diff changeset
  1156
 	struct kex *kex;
bf30d46ab06e PSARC/2015/179 OpenSSH 6.8
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 3642
diff changeset
  1157
 	int r;
3574
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1158
+#ifdef GSSAPI
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1159
+	char *orig = NULL, *gss = NULL;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1160
+	char *gss_host = NULL;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1161
+#endif
5025
bdd7dc7d2af4 PSARC/2015/395 OpenSSH 7.1p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 4503
diff changeset
  1162
 
3574
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1163
 	xxx_host = host;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1164
 	xxx_hostaddr = hostaddr;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1165
 
5819
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5818
diff changeset
  1166
-	if ((s = kex_names_cat(options.kex_algorithms, "ext-info-c")) == NULL)
5025
bdd7dc7d2af4 PSARC/2015/395 OpenSSH 7.1p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 4503
diff changeset
  1167
+	if (options.kex_algorithms != NULL)
bdd7dc7d2af4 PSARC/2015/395 OpenSSH 7.1p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 4503
diff changeset
  1168
+		myproposal[PROPOSAL_KEX_ALGS] = options.kex_algorithms;
bdd7dc7d2af4 PSARC/2015/395 OpenSSH 7.1p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 4503
diff changeset
  1169
+
3574
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1170
+#ifdef GSSAPI
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1171
+	if (options.gss_keyex) {
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1172
+		/* Add the GSSAPI mechanisms currently supported on this 
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1173
+		 * client to the key exchange algorithm proposal */
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1174
+		orig = myproposal[PROPOSAL_KEX_ALGS];
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1175
+
6930
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
  1176
+		gss_host = (char *)remote_hostname(active_state);
3574
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1177
+
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1178
+		gss = ssh_gssapi_client_mechanisms(gss_host);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1179
+		if (gss) {
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1180
+			debug("Offering GSSAPI proposal: %s", gss);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1181
+			xasprintf(&myproposal[PROPOSAL_KEX_ALGS],
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1182
+			    "%s,%s", gss, orig);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1183
+		}
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1184
+	}
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1185
+#endif
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1186
+
5819
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5818
diff changeset
  1187
+	if (!(s = kex_names_cat(myproposal[PROPOSAL_KEX_ALGS], "ext-info-c")))
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5818
diff changeset
  1188
 		fatal("%s: kex_names_cat", __func__);
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5818
diff changeset
  1189
 	myproposal[PROPOSAL_KEX_ALGS] = compat_kex_proposal(s);
5025
bdd7dc7d2af4 PSARC/2015/395 OpenSSH 7.1p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 4503
diff changeset
  1190
 	myproposal[PROPOSAL_ENC_ALGS_CTOS] =
6930
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
  1191
@@ -196,6 +220,17 @@ ssh_kex2(char *host, struct sockaddr *ho
5025
bdd7dc7d2af4 PSARC/2015/395 OpenSSH 7.1p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 4503
diff changeset
  1192
 		    order_hostkeyalgs(host, hostaddr, port));
bdd7dc7d2af4 PSARC/2015/395 OpenSSH 7.1p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 4503
diff changeset
  1193
 	}
3574
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1194
 
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1195
+#ifdef GSSAPI
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1196
+	/* If we've got GSSAPI algorithms, then we also support the
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1197
+	 * 'null' hostkey, as a last resort */
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1198
+	if (options.gss_keyex && gss) {
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1199
+		orig = myproposal[PROPOSAL_SERVER_HOST_KEY_ALGS];
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1200
+		xasprintf(&myproposal[PROPOSAL_SERVER_HOST_KEY_ALGS], 
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1201
+		    "%s,null", orig);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1202
+		free(gss);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1203
+	}
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1204
+#endif
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1205
+
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1206
 	if (options.rekey_limit || options.rekey_interval)
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1207
 		packet_set_rekey_limits((u_int32_t)options.rekey_limit,
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1208
 		    (time_t)options.rekey_interval);
5819
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5818
diff changeset
  1209
@@ -217,9 +252,22 @@ ssh_kex2(char *host, struct sockaddr *ho
4503
bf30d46ab06e PSARC/2015/179 OpenSSH 6.8
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 3642
diff changeset
  1210
 # endif
bf30d46ab06e PSARC/2015/179 OpenSSH 6.8
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 3642
diff changeset
  1211
 #endif
3574
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1212
 	kex->kex[KEX_C25519_SHA256] = kexc25519_client;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1213
+#ifdef GSSAPI
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1214
+	if (options.gss_keyex) {
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1215
+		kex->kex[KEX_GSS_GRP1_SHA1] = kexgss_client;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1216
+		kex->kex[KEX_GSS_GRP14_SHA1] = kexgss_client;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1217
+		kex->kex[KEX_GSS_GEX_SHA1] = kexgss_client;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1218
+	}
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1219
+#endif
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1220
 	kex->client_version_string=client_version_string;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1221
 	kex->server_version_string=server_version_string;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1222
 	kex->verify_host_key=&verify_host_key_callback;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1223
+#ifdef GSSAPI
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1224
+	if (options.gss_keyex) {
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1225
+		kex->gss_deleg_creds = options.gss_deleg_creds;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1226
+		kex->gss_host = gss_host;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1227
+	}
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1228
+#endif
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1229
 
4503
bf30d46ab06e PSARC/2015/179 OpenSSH 6.8
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 3642
diff changeset
  1230
 	dispatch_run(DISPATCH_BLOCK, &kex->done, active_state);
3574
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1231
 
5819
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5818
diff changeset
  1232
@@ -315,6 +363,7 @@ int	input_gssapi_token(int type, u_int32
4503
bf30d46ab06e PSARC/2015/179 OpenSSH 6.8
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 3642
diff changeset
  1233
 int	input_gssapi_hash(int type, u_int32_t, void *);
bf30d46ab06e PSARC/2015/179 OpenSSH 6.8
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 3642
diff changeset
  1234
 int	input_gssapi_error(int, u_int32_t, void *);
bf30d46ab06e PSARC/2015/179 OpenSSH 6.8
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 3642
diff changeset
  1235
 int	input_gssapi_errtok(int, u_int32_t, void *);
3574
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1236
+int	userauth_gsskeyex(Authctxt *authctxt);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1237
 #endif
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1238
 
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1239
 void	userauth(Authctxt *, char *);
5819
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5818
diff changeset
  1240
@@ -330,6 +379,11 @@ static char *authmethods_get(void);
3574
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1241
 
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1242
 Authmethod authmethods[] = {
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1243
 #ifdef GSSAPI
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1244
+	{"gssapi-keyex",
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1245
+		userauth_gsskeyex,
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1246
+		NULL,
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1247
+		&options.gss_authentication,
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1248
+		NULL},
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1249
 	{"gssapi-with-mic",
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1250
 		userauth_gssapi,
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1251
 		NULL,
6930
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
  1252
@@ -672,7 +726,10 @@ userauth_gssapi(Authctxt *authctxt)
3574
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1253
 	 * once. */
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1254
 
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1255
 	if (gss_supported == NULL)
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1256
-		gss_indicate_mechs(&min, &gss_supported);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1257
+		if (GSS_ERROR(gss_indicate_mechs(&min, &gss_supported))) {
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1258
+			gss_supported = NULL;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1259
+			return 0;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1260
+		}
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1261
 
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1262
 	/* Check to see if the mechanism is usable before we offer it */
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1263
 	while (mech < gss_supported->count && !ok) {
6930
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
  1264
@@ -776,8 +833,8 @@ input_gssapi_response(int type, u_int32_
3574
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1265
 {
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1266
 	Authctxt *authctxt = ctxt;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1267
 	Gssctxt *gssctxt;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1268
-	int oidlen;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1269
-	char *oidv;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1270
+	u_int oidlen;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1271
+	u_char *oidv;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1272
 
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1273
 	if (authctxt == NULL)
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1274
 		fatal("input_gssapi_response: no authentication context");
6930
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
  1275
@@ -890,6 +947,48 @@ input_gssapi_error(int type, u_int32_t p
3574
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1276
 	free(lang);
4503
bf30d46ab06e PSARC/2015/179 OpenSSH 6.8
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 3642
diff changeset
  1277
 	return 0;
3574
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1278
 }
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1279
+
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1280
+int
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1281
+userauth_gsskeyex(Authctxt *authctxt)
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1282
+{
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1283
+	Buffer b;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1284
+	gss_buffer_desc gssbuf;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1285
+	gss_buffer_desc mic = GSS_C_EMPTY_BUFFER;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1286
+	OM_uint32 ms;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1287
+
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1288
+	static int attempt = 0;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1289
+	if (attempt++ >= 1)
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1290
+		return (0);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1291
+
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1292
+	if (gss_kex_context == NULL) {
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1293
+		debug("No valid Key exchange context"); 
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1294
+		return (0);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1295
+	}
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1296
+
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1297
+	ssh_gssapi_buildmic(&b, authctxt->server_user, authctxt->service,
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1298
+	    "gssapi-keyex");
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1299
+
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1300
+	gssbuf.value = buffer_ptr(&b);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1301
+	gssbuf.length = buffer_len(&b);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1302
+
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1303
+	if (GSS_ERROR(ssh_gssapi_sign(gss_kex_context, &gssbuf, &mic))) {
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1304
+		buffer_free(&b);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1305
+		return (0);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1306
+	}
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1307
+
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1308
+	packet_start(SSH2_MSG_USERAUTH_REQUEST);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1309
+	packet_put_cstring(authctxt->server_user);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1310
+	packet_put_cstring(authctxt->service);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1311
+	packet_put_cstring(authctxt->method->name);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1312
+	packet_put_string(mic.value, mic.length);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1313
+	packet_send();
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1314
+
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1315
+	buffer_free(&b);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1316
+	gss_release_buffer(&ms, &mic);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1317
+
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1318
+	return (1);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1319
+}
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1320
+
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1321
 #endif /* GSSAPI */
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1322
 
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1323
 int
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1324
diff -pur old/sshd.c new/sshd.c
5025
bdd7dc7d2af4 PSARC/2015/395 OpenSSH 7.1p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 4503
diff changeset
  1325
--- old/sshd.c
bdd7dc7d2af4 PSARC/2015/395 OpenSSH 7.1p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 4503
diff changeset
  1326
+++ new/sshd.c
6930
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
  1327
@@ -1892,10 +1892,13 @@ main(int ac, char **av)
3574
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1328
 		logit("Disabling protocol version 1. Could not load host key");
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1329
 		options.protocol &= ~SSH_PROTO_1;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1330
 	}
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1331
+#ifndef GSSAPI
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1332
+	/* The GSSAPI key exchange can run without a host key */
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1333
 	if ((options.protocol & SSH_PROTO_2) && !sensitive_data.have_ssh2_key) {
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1334
 		logit("Disabling protocol version 2. Could not load host key");
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1335
 		options.protocol &= ~SSH_PROTO_2;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1336
 	}
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1337
+#endif
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1338
 	if (!(options.protocol & (SSH_PROTO_1|SSH_PROTO_2))) {
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1339
 		logit("sshd: no hostkeys available -- exiting.");
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1340
 		exit(1);
6930
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
  1341
@@ -2656,6 +2659,48 @@ do_ssh2_kex(void)
3574
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1342
 	myproposal[PROPOSAL_SERVER_HOST_KEY_ALGS] = compat_pkalg_proposal(
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1343
 	    list_hostkey_types());
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1344
 
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1345
+#ifdef GSSAPI
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1346
+	{
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1347
+	char *orig;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1348
+	char *gss = NULL;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1349
+	char *newstr = NULL;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1350
+	orig = myproposal[PROPOSAL_KEX_ALGS];
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1351
+
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1352
+	/* 
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1353
+	 * If we don't have a host key, then there's no point advertising
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1354
+	 * the other key exchange algorithms
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1355
+	 */
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1356
+
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1357
+	if (strlen(myproposal[PROPOSAL_SERVER_HOST_KEY_ALGS]) == 0)
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1358
+		orig = NULL;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1359
+
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1360
+	if (options.gss_keyex)
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1361
+		gss = ssh_gssapi_server_mechanisms();
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1362
+	else
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1363
+		gss = NULL;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1364
+
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1365
+	if (gss && orig)
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1366
+		xasprintf(&newstr, "%s,%s", gss, orig);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1367
+	else if (gss)
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1368
+		newstr = gss;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1369
+	else if (orig)
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1370
+		newstr = orig;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1371
+
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1372
+	/* 
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1373
+	 * If we've got GSSAPI mechanisms, then we've got the 'null' host
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1374
+	 * key alg, but we can't tell people about it unless its the only
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1375
+  	 * host key algorithm we support
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1376
+	 */
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1377
+	if (gss && (strlen(myproposal[PROPOSAL_SERVER_HOST_KEY_ALGS])) == 0)
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1378
+		myproposal[PROPOSAL_SERVER_HOST_KEY_ALGS] = "null";
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1379
+
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1380
+	if (newstr)
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1381
+		myproposal[PROPOSAL_KEX_ALGS] = newstr;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1382
+	else
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1383
+		fatal("No supported key exchange algorithms");
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1384
+	}
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1385
+#endif
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1386
+
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1387
 	/* start key exchange */
4503
bf30d46ab06e PSARC/2015/179 OpenSSH 6.8
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 3642
diff changeset
  1388
 	if ((r = kex_setup(active_state, myproposal)) != 0)
bf30d46ab06e PSARC/2015/179 OpenSSH 6.8
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 3642
diff changeset
  1389
 		fatal("kex_setup: %s", ssh_err(r));
6930
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
  1390
@@ -2673,6 +2718,13 @@ do_ssh2_kex(void)
4503
bf30d46ab06e PSARC/2015/179 OpenSSH 6.8
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 3642
diff changeset
  1391
 # endif
bf30d46ab06e PSARC/2015/179 OpenSSH 6.8
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 3642
diff changeset
  1392
 #endif
3574
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1393
 	kex->kex[KEX_C25519_SHA256] = kexc25519_server;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1394
+#ifdef GSSAPI
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1395
+	if (options.gss_keyex) {
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1396
+		kex->kex[KEX_GSS_GRP1_SHA1] = kexgss_server;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1397
+		kex->kex[KEX_GSS_GRP14_SHA1] = kexgss_server;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1398
+		kex->kex[KEX_GSS_GEX_SHA1] = kexgss_server;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1399
+	}
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1400
+#endif
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1401
 	kex->server = 1;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1402
 	kex->client_version_string=client_version_string;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1403
 	kex->server_version_string=server_version_string;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1404
diff -pur old/sshd_config.5 new/sshd_config.5
5025
bdd7dc7d2af4 PSARC/2015/395 OpenSSH 7.1p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 4503
diff changeset
  1405
--- old/sshd_config.5
bdd7dc7d2af4 PSARC/2015/395 OpenSSH 7.1p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 4503
diff changeset
  1406
+++ new/sshd_config.5
6930
31ef2580c45d 24525860 upgrade OpenSSH to 7.3p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5819
diff changeset
  1407
@@ -632,6 +632,11 @@ The default is
5819
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5818
diff changeset
  1408
 Specifies whether user authentication based on GSSAPI is allowed.
3574
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1409
 The default on Solaris is
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1410
 .Dq yes .
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1411
+.It Cm GSSAPIKeyExchange
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1412
+Specifies whether key exchange based on GSSAPI is allowed. GSSAPI key exchange
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1413
+doesn't rely on ssh keys to verify host identity.
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1414
+The default on Solaris is
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1415
+.Dq yes .
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1416
 .It Cm GSSAPICleanupCredentials
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1417
 Specifies whether to automatically destroy the user's credentials cache
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1418
 on logout.
4503
bf30d46ab06e PSARC/2015/179 OpenSSH 6.8
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 3642
diff changeset
  1419
diff -pur old/sshkey.c new/sshkey.c
5025
bdd7dc7d2af4 PSARC/2015/395 OpenSSH 7.1p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 4503
diff changeset
  1420
--- old/sshkey.c
bdd7dc7d2af4 PSARC/2015/395 OpenSSH 7.1p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 4503
diff changeset
  1421
+++ new/sshkey.c
5819
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5818
diff changeset
  1422
@@ -115,6 +115,7 @@ static const struct keytype keytypes[] =
5025
bdd7dc7d2af4 PSARC/2015/395 OpenSSH 7.1p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 4503
diff changeset
  1423
 #  endif /* OPENSSL_HAS_NISTP521 */
bdd7dc7d2af4 PSARC/2015/395 OpenSSH 7.1p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 4503
diff changeset
  1424
 # endif /* OPENSSL_HAS_ECC */
4503
bf30d46ab06e PSARC/2015/179 OpenSSH 6.8
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 3642
diff changeset
  1425
 #endif /* WITH_OPENSSL */
bf30d46ab06e PSARC/2015/179 OpenSSH 6.8
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 3642
diff changeset
  1426
+	{ "null", "null", KEY_NULL, 0, 0 },
5819
c5f05bd2a9bc PSARC/2016/216 OpenSSH 7.2p2 upgrade. Host keys and moduli updates
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5818
diff changeset
  1427
 	{ NULL, NULL, -1, -1, 0, 0 }
4503
bf30d46ab06e PSARC/2015/179 OpenSSH 6.8
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 3642
diff changeset
  1428
 };
bf30d46ab06e PSARC/2015/179 OpenSSH 6.8
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 3642
diff changeset
  1429
 
bf30d46ab06e PSARC/2015/179 OpenSSH 6.8
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 3642
diff changeset
  1430
diff -pur old/sshkey.h new/sshkey.h
5025
bdd7dc7d2af4 PSARC/2015/395 OpenSSH 7.1p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 4503
diff changeset
  1431
--- old/sshkey.h
bdd7dc7d2af4 PSARC/2015/395 OpenSSH 7.1p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 4503
diff changeset
  1432
+++ new/sshkey.h
bdd7dc7d2af4 PSARC/2015/395 OpenSSH 7.1p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 4503
diff changeset
  1433
@@ -62,6 +62,7 @@ enum sshkey_types {
bdd7dc7d2af4 PSARC/2015/395 OpenSSH 7.1p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 4503
diff changeset
  1434
 	KEY_DSA_CERT,
bdd7dc7d2af4 PSARC/2015/395 OpenSSH 7.1p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 4503
diff changeset
  1435
 	KEY_ECDSA_CERT,
4503
bf30d46ab06e PSARC/2015/179 OpenSSH 6.8
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 3642
diff changeset
  1436
 	KEY_ED25519_CERT,
bf30d46ab06e PSARC/2015/179 OpenSSH 6.8
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 3642
diff changeset
  1437
+	KEY_NULL,
bf30d46ab06e PSARC/2015/179 OpenSSH 6.8
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 3642
diff changeset
  1438
 	KEY_UNSPEC
bf30d46ab06e PSARC/2015/179 OpenSSH 6.8
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 3642
diff changeset
  1439
 };
bf30d46ab06e PSARC/2015/179 OpenSSH 6.8
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 3642
diff changeset
  1440