components/openssh/patches/023-gsskex.patch
author Huie-Ying Lee <huieying.lee@oracle.com>
Thu, 03 Mar 2016 14:55:30 -0800
changeset 5544 16204c8a93ff
parent 5027 c71f34180df2
child 5818 5f0e7a0f17c2
permissions -rw-r--r--
PSARC 2015/227 SunSSH EOF and Removal 22451594 Add SSH service/config files and re-arrange OpenSSH packages (step 3-2) 22012870 ssh should handle LANG and LC_* variables from client to server 22707439 The IPS version number should be 7.1.0.2 for OpenSSH 7.1p2 22102387 Misleading LoginGraceTime comment in default sshd_config 19806472 ssh filesystem dependencies to allow earlier start
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
#
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
     9
# Upstream rejected GSS-API key exchange several times before.
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    10
#
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    11
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
    12
--- old/Makefile.in
bdd7dc7d2af4 PSARC/2015/395 OpenSSH 7.1p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 4503
diff changeset
    13
+++ new/Makefile.in
4503
bf30d46ab06e PSARC/2015/179 OpenSSH 6.8
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 3642
diff changeset
    14
@@ -87,6 +87,7 @@ LIBSSH_OBJS=${LIBOPENSSH_OBJS} \
3574
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    15
 	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
    16
 	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
    17
 	sftp_provider.o \
3574
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    18
+	kexgssc.o \
4503
bf30d46ab06e PSARC/2015/179 OpenSSH 6.8
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 3642
diff changeset
    19
 	ssh-pkcs11.o smult_curve25519_ref.o \
bf30d46ab06e PSARC/2015/179 OpenSSH 6.8
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 3642
diff changeset
    20
 	poly1305.o chacha.o cipher-chachapoly.o \
bf30d46ab06e PSARC/2015/179 OpenSSH 6.8
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 3642
diff changeset
    21
 	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
    22
@@ -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
    23
 	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
    24
 	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
    25
 	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
    26
-	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
    27
+	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
    28
 	loginrec.o auth-pam.o auth-shadow.o auth-sia.o md5crypt.o \
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    29
 	sftp-server.o sftp-common.o \
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    30
 	roaming_common.o roaming_serv.o \
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    31
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
    32
--- old/auth2-gss.c
bdd7dc7d2af4 PSARC/2015/395 OpenSSH 7.1p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 4503
diff changeset
    33
+++ new/auth2-gss.c
3574
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    34
@@ -1,7 +1,7 @@
4503
bf30d46ab06e PSARC/2015/179 OpenSSH 6.8
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 3642
diff changeset
    35
 /* $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
    36
 
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    37
 /*
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    38
- * Copyright (c) 2001-2003 Simon Wilkinson. All rights reserved.
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    39
+ * Copyright (c) 2001-2007 Simon Wilkinson. All rights reserved.
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    40
  *
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    41
  * 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
    42
  * 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
    43
@@ -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
    44
 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
    45
 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
    46
 
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    47
+/* 
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    48
+ * The 'gssapi_keyex' userauth mechanism.
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    49
+ */
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    50
+static int
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    51
+userauth_gsskeyex(Authctxt *authctxt)
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    52
+{
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    53
+	int authenticated = 0;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    54
+	Buffer b;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    55
+	gss_buffer_desc mic, gssbuf;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    56
+	u_int len;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    57
+
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    58
+	mic.value = packet_get_string(&len);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    59
+	mic.length = len;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    60
+
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    61
+	packet_check_eom();
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    62
+
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    63
+	ssh_gssapi_buildmic(&b, authctxt->user, authctxt->service,
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    64
+	    "gssapi-keyex");
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    65
+
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    66
+	gssbuf.value = buffer_ptr(&b);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    67
+	gssbuf.length = buffer_len(&b);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    68
+
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    69
+	/* 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
    70
+	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
    71
+	    &gssbuf, &mic))))
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    72
+		authenticated = PRIVSEP(ssh_gssapi_userok(authctxt->user));
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    73
+	
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    74
+	buffer_free(&b);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    75
+	free(mic.value);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    76
+
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    77
+	return (authenticated);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    78
+}
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    79
+
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    80
 /*
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    81
  * 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
    82
  * 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
    83
@@ -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
    84
 	return 0;
3574
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    85
 }
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    86
 
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    87
+Authmethod method_gsskeyex = {
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    88
+	"gssapi-keyex",
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    89
+	userauth_gsskeyex,
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    90
+	&options.gss_authentication
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    91
+};
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    92
+
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    93
 Authmethod method_gssapi = {
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    94
 	"gssapi-with-mic",
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    95
 	userauth_gssapi,
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
    96
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
    97
--- old/auth2.c
bdd7dc7d2af4 PSARC/2015/395 OpenSSH 7.1p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 4503
diff changeset
    98
+++ new/auth2.c
4503
bf30d46ab06e PSARC/2015/179 OpenSSH 6.8
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 3642
diff changeset
    99
@@ -70,6 +70,7 @@ extern Authmethod method_passwd;
3574
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   100
 extern Authmethod method_kbdint;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   101
 extern Authmethod method_hostbased;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   102
 #ifdef GSSAPI
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   103
+extern Authmethod method_gsskeyex;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   104
 extern Authmethod method_gssapi;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   105
 #endif
4503
bf30d46ab06e PSARC/2015/179 OpenSSH 6.8
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 3642
diff changeset
   106
 
bf30d46ab06e PSARC/2015/179 OpenSSH 6.8
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 3642
diff changeset
   107
@@ -77,6 +78,7 @@ Authmethod *authmethods[] = {
3574
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   108
 	&method_none,
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   109
 	&method_pubkey,
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   110
 #ifdef GSSAPI
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   111
+	&method_gsskeyex,
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   112
 	&method_gssapi,
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   113
 #endif
4503
bf30d46ab06e PSARC/2015/179 OpenSSH 6.8
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 3642
diff changeset
   114
 	&method_passwd,
bf30d46ab06e PSARC/2015/179 OpenSSH 6.8
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 3642
diff changeset
   115
diff -pur old/configure new/configure
5025
bdd7dc7d2af4 PSARC/2015/395 OpenSSH 7.1p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 4503
diff changeset
   116
--- old/configure
bdd7dc7d2af4 PSARC/2015/395 OpenSSH 7.1p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 4503
diff changeset
   117
+++ new/configure
bdd7dc7d2af4 PSARC/2015/395 OpenSSH 7.1p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 4503
diff changeset
   118
@@ -10944,8 +10944,10 @@ fi
4503
bf30d46ab06e PSARC/2015/179 OpenSSH 6.8
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 3642
diff changeset
   119
 
bf30d46ab06e PSARC/2015/179 OpenSSH 6.8
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 3642
diff changeset
   120
 fi
bf30d46ab06e PSARC/2015/179 OpenSSH 6.8
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 3642
diff changeset
   121
 
bf30d46ab06e PSARC/2015/179 OpenSSH 6.8
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 3642
diff changeset
   122
-        $as_echo "#define USE_GSS_STORE_CRED 1" >>confdefs.h
bf30d46ab06e PSARC/2015/179 OpenSSH 6.8
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 3642
diff changeset
   123
-        $as_echo "#define GSSAPI_STORECREDS_NEEDS_RUID 1" >>confdefs.h
bf30d46ab06e PSARC/2015/179 OpenSSH 6.8
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 3642
diff changeset
   124
+cat >>confdefs.h <<\_ACEOF
bf30d46ab06e PSARC/2015/179 OpenSSH 6.8
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 3642
diff changeset
   125
+#define	USE_GSS_STORE_CRED 1
bf30d46ab06e PSARC/2015/179 OpenSSH 6.8
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 3642
diff changeset
   126
+#define	GSSAPI_STORECREDS_NEEDS_RUID 1
bf30d46ab06e PSARC/2015/179 OpenSSH 6.8
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 3642
diff changeset
   127
+_ACEOF
bf30d46ab06e PSARC/2015/179 OpenSSH 6.8
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 3642
diff changeset
   128
 
bf30d46ab06e PSARC/2015/179 OpenSSH 6.8
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 3642
diff changeset
   129
 	TEST_SHELL=$SHELL	# let configure find us a capable shell
bf30d46ab06e PSARC/2015/179 OpenSSH 6.8
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 3642
diff changeset
   130
 	;;
3574
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   131
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
   132
--- old/gss-genr.c
bdd7dc7d2af4 PSARC/2015/395 OpenSSH 7.1p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 4503
diff changeset
   133
+++ new/gss-genr.c
3574
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   134
@@ -1,7 +1,7 @@
4503
bf30d46ab06e PSARC/2015/179 OpenSSH 6.8
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 3642
diff changeset
   135
 /* $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
   136
 
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   137
 /*
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   138
- * Copyright (c) 2001-2007 Simon Wilkinson. All rights reserved.
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   139
+ * Copyright (c) 2001-2009 Simon Wilkinson. All rights reserved.
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   140
  *
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   141
  * 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
   142
  * 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
   143
@@ -41,12 +41,167 @@
3574
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   144
 #include "buffer.h"
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   145
 #include "log.h"
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   146
 #include "ssh2.h"
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   147
+#include "cipher.h"
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   148
+#include "key.h"
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   149
+#include "kex.h"
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   150
+#include <openssl/evp.h>
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
 #include "ssh-gss.h"
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   153
 
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   154
 extern u_char *session_id2;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   155
 extern u_int session_id2_len;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   156
 
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   157
+typedef struct {
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   158
+	char *encoded;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   159
+	gss_OID oid;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   160
+} ssh_gss_kex_mapping;
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
+/*
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   163
+ * 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
   164
+ * 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
   165
+ */
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
+Gssctxt *gss_kex_context = NULL;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   168
+
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   169
+static ssh_gss_kex_mapping *gss_enc2oid = NULL;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   170
+
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   171
+int 
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   172
+ssh_gssapi_oid_table_ok() {
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   173
+	return (gss_enc2oid != NULL);
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
+
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
+ * 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
   178
+ *
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   179
+ * 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
   180
+ * a key exchange with a bad mechanism
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   181
+ */
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
+char *
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   184
+ssh_gssapi_client_mechanisms(const char *host) {
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   185
+	gss_OID_set gss_supported;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   186
+	OM_uint32 min_status;
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
+	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
   189
+		return NULL;
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(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
   192
+	    host));
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
+char *
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   196
+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
   197
+    const char *data) {
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   198
+	Buffer buf;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   199
+	size_t i;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   200
+	int oidpos, enclen;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   201
+	char *mechs, *encoded;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   202
+	u_char digest[EVP_MAX_MD_SIZE];
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   203
+	char deroid[2];
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   204
+	const EVP_MD *evp_md = EVP_md5();
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   205
+	EVP_MD_CTX md;
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
+	if (gss_enc2oid != NULL) {
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   208
+		for (i = 0; gss_enc2oid[i].encoded != NULL; i++)
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   209
+			free(gss_enc2oid[i].encoded);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   210
+		free(gss_enc2oid);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   211
+	}
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   212
+
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   213
+	gss_enc2oid = xmalloc(sizeof(ssh_gss_kex_mapping) *
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   214
+	    (gss_supported->count + 1));
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   215
+
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   216
+	buffer_init(&buf);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   217
+
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   218
+	oidpos = 0;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   219
+	for (i = 0; i < gss_supported->count; i++) {
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   220
+		if (gss_supported->elements[i].length < 128 &&
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   221
+		    (*check)(NULL, &(gss_supported->elements[i]), data)) {
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   222
+
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   223
+			deroid[0] = SSH_GSS_OIDTYPE;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   224
+			deroid[1] = gss_supported->elements[i].length;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   225
+
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   226
+			EVP_DigestInit(&md, evp_md);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   227
+			EVP_DigestUpdate(&md, deroid, 2);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   228
+			EVP_DigestUpdate(&md,
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   229
+			    gss_supported->elements[i].elements,
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   230
+			    gss_supported->elements[i].length);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   231
+			EVP_DigestFinal(&md, digest, NULL);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   232
+
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   233
+			encoded = xmalloc(EVP_MD_size(evp_md) * 2);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   234
+			enclen = __b64_ntop(digest, EVP_MD_size(evp_md),
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   235
+			    encoded, EVP_MD_size(evp_md) * 2);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   236
+
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   237
+			if (oidpos != 0)
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   238
+				buffer_put_char(&buf, ',');
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   239
+
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   240
+			buffer_append(&buf, KEX_GSS_GEX_SHA1_ID,
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   241
+			    sizeof(KEX_GSS_GEX_SHA1_ID) - 1);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   242
+			buffer_append(&buf, encoded, enclen);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   243
+			buffer_put_char(&buf, ',');
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   244
+			buffer_append(&buf, KEX_GSS_GRP1_SHA1_ID, 
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   245
+			    sizeof(KEX_GSS_GRP1_SHA1_ID) - 1);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   246
+			buffer_append(&buf, encoded, enclen);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   247
+			buffer_put_char(&buf, ',');
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   248
+			buffer_append(&buf, KEX_GSS_GRP14_SHA1_ID,
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   249
+			    sizeof(KEX_GSS_GRP14_SHA1_ID) - 1);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   250
+			buffer_append(&buf, encoded, enclen);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   251
+
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   252
+			gss_enc2oid[oidpos].oid = &(gss_supported->elements[i]);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   253
+			gss_enc2oid[oidpos].encoded = encoded;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   254
+			oidpos++;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   255
+		}
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   256
+	}
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   257
+	gss_enc2oid[oidpos].oid = NULL;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   258
+	gss_enc2oid[oidpos].encoded = NULL;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   259
+
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   260
+	buffer_put_char(&buf, '\0');
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   261
+
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   262
+	mechs = xmalloc(buffer_len(&buf));
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   263
+	buffer_get(&buf, mechs, buffer_len(&buf));
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   264
+	buffer_free(&buf);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   265
+
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   266
+	if (strlen(mechs) == 0) {
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   267
+		free(mechs);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   268
+		mechs = NULL;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   269
+	}
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   270
+	
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   271
+	return (mechs);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   272
+}
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   273
+
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   274
+gss_OID
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   275
+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
   276
+	int i = 0;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   277
+	
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   278
+	switch (kex_type) {
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   279
+	case KEX_GSS_GRP1_SHA1:
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   280
+		if (strlen(name) < sizeof(KEX_GSS_GRP1_SHA1_ID))
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   281
+			return GSS_C_NO_OID;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   282
+		name += sizeof(KEX_GSS_GRP1_SHA1_ID) - 1;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   283
+		break;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   284
+	case KEX_GSS_GRP14_SHA1:
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   285
+		if (strlen(name) < sizeof(KEX_GSS_GRP14_SHA1_ID))
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   286
+			return GSS_C_NO_OID;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   287
+		name += sizeof(KEX_GSS_GRP14_SHA1_ID) - 1;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   288
+		break;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   289
+	case KEX_GSS_GEX_SHA1:
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   290
+		if (strlen(name) < sizeof(KEX_GSS_GEX_SHA1_ID))
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   291
+			return GSS_C_NO_OID;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   292
+		name += sizeof(KEX_GSS_GEX_SHA1_ID) - 1;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   293
+		break;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   294
+	default:
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   295
+		return GSS_C_NO_OID;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   296
+	}
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   297
+
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   298
+	while (gss_enc2oid[i].encoded != NULL &&
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   299
+	    strcmp(name, gss_enc2oid[i].encoded) != 0)
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   300
+		i++;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   301
+
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   302
+	if (gss_enc2oid[i].oid != NULL && ctx != NULL)
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   303
+		ssh_gssapi_set_oid(ctx, gss_enc2oid[i].oid);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   304
+
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   305
+	return gss_enc2oid[i].oid;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   306
+}
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   307
+
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   308
 /* 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
   309
 int
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   310
 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
   311
@@ -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
   312
 OM_uint32
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   313
 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
   314
 {
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   315
+	if (ctx == NULL) 
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   316
+		return -1;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   317
+
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   318
 	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
   319
 	    GSS_C_QOP_DEFAULT, buffer, hash)))
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   320
 		ssh_gssapi_error(ctx);
5025
bdd7dc7d2af4 PSARC/2015/395 OpenSSH 7.1p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 4503
diff changeset
   321
@@ -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
   322
 	return (ctx->major);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   323
 }
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   324
 
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   325
+/* Priviledged when used by server */
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   326
+OM_uint32
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   327
+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
   328
+{
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   329
+	if (ctx == NULL)
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   330
+		return -1;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   331
+
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   332
+	ctx->major = gss_verify_mic(&ctx->minor, ctx->context,
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   333
+	    gssbuf, gssmic, NULL);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   334
+
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   335
+	return (ctx->major);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   336
+}
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   337
+
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   338
 void
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   339
 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
   340
     const char *context)
5025
bdd7dc7d2af4 PSARC/2015/395 OpenSSH 7.1p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 4503
diff changeset
   341
@@ -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
   342
 	gss_buffer_desc token = GSS_C_EMPTY_BUFFER;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   343
 	OM_uint32 major, minor;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   344
 	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
   345
+	Gssctxt *intctx = NULL;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   346
+
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   347
+	if (ctx == NULL)
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   348
+		ctx = &intctx;
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
 	/* RFC 4462 says we MUST NOT do SPNEGO */
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   351
 	if (oid->length == spnego_oid.length && 
5025
bdd7dc7d2af4 PSARC/2015/395 OpenSSH 7.1p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 4503
diff changeset
   352
@@ -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
   353
 			    GSS_C_NO_BUFFER);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   354
 	}
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   355
 
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   356
-	if (GSS_ERROR(major)) 
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   357
+	if (GSS_ERROR(major) || intctx != NULL) 
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   358
 		ssh_gssapi_delete_ctx(ctx);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   359
 
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   360
 	return (!GSS_ERROR(major));
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   361
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
   362
--- old/gss-serv.c
bdd7dc7d2af4 PSARC/2015/395 OpenSSH 7.1p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 4503
diff changeset
   363
+++ new/gss-serv.c
3574
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   364
@@ -1,7 +1,7 @@
5025
bdd7dc7d2af4 PSARC/2015/395 OpenSSH 7.1p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 4503
diff changeset
   365
 /* $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
   366
 
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   367
 /*
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   368
- * Copyright (c) 2001-2003 Simon Wilkinson. All rights reserved.
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   369
+ * Copyright (c) 2001-2009 Simon Wilkinson. All rights reserved.
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   370
  *
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   371
  * 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
   372
  * 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
   373
@@ -47,6 +47,7 @@
bdd7dc7d2af4 PSARC/2015/395 OpenSSH 7.1p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 4503
diff changeset
   374
 #include "servconf.h"
3574
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   375
 
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   376
 #include "ssh-gss.h"
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   377
+#include "monitor_wrap.h"
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   378
 
5025
bdd7dc7d2af4 PSARC/2015/395 OpenSSH 7.1p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 4503
diff changeset
   379
 extern ServerOptions options;
bdd7dc7d2af4 PSARC/2015/395 OpenSSH 7.1p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 4503
diff changeset
   380
 
bdd7dc7d2af4 PSARC/2015/395 OpenSSH 7.1p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 4503
diff changeset
   381
@@ -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
   382
 }
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   383
 
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   384
 /* Unprivileged */
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   385
+char *
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   386
+ssh_gssapi_server_mechanisms() {
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   387
+	gss_OID_set	supported;
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
+	ssh_gssapi_supported_oids(&supported);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   390
+	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
   391
+	    NULL));
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   392
+}
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
+/* Unprivileged */
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   395
+int
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   396
+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
   397
+	Gssctxt *ctx = NULL;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   398
+	int res;
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
+	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
   401
+	ssh_gssapi_delete_ctx(&ctx);
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 (res);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   404
+}
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
+/* Unprivileged */
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   407
 void
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   408
 ssh_gssapi_supported_oids(gss_OID_set *oidset)
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   409
 {
5025
bdd7dc7d2af4 PSARC/2015/395 OpenSSH 7.1p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 4503
diff changeset
   410
@@ -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
   411
 	gss_OID_set supported;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   412
 
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   413
 	gss_create_empty_oid_set(&min_status, oidset);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   414
-	gss_indicate_mechs(&min_status, &supported);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   415
+
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   416
+	if (GSS_ERROR(gss_indicate_mechs(&min_status, &supported)))
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   417
+		return;
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
 	while (supported_mechs[i]->name != NULL) {
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   420
 		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
   421
@@ -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
   422
 	return (0);
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
-/* Privileged */
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   426
-OM_uint32
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   427
-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
   428
-{
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   429
-	ctx->major = gss_verify_mic(&ctx->minor, ctx->context,
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   430
-	    gssbuf, gssmic, NULL);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   431
-
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   432
-	return (ctx->major);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   433
-}
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
 #endif
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   436
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
   437
--- old/kex.c
bdd7dc7d2af4 PSARC/2015/395 OpenSSH 7.1p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 4503
diff changeset
   438
+++ new/kex.c
4503
bf30d46ab06e PSARC/2015/179 OpenSSH 6.8
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 3642
diff changeset
   439
@@ -55,6 +55,10 @@
bf30d46ab06e PSARC/2015/179 OpenSSH 6.8
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 3642
diff changeset
   440
 #include "sshbuf.h"
3574
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   441
 #include "digest.h"
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   442
 
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   443
+#ifdef GSSAPI
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   444
+#include "ssh-gss.h"
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   445
+#endif
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   446
+
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   447
 #if OPENSSL_VERSION_NUMBER >= 0x00907000L
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   448
 # if defined(HAVE_EVP_SHA256)
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   449
 # define evp_ssh_sha256 EVP_sha256
4503
bf30d46ab06e PSARC/2015/179 OpenSSH 6.8
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 3642
diff changeset
   450
@@ -95,6 +99,11 @@ static const struct kexalg kexalgs[] = {
bf30d46ab06e PSARC/2015/179 OpenSSH 6.8
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 3642
diff changeset
   451
 #if defined(HAVE_EVP_SHA256) || !defined(WITH_OPENSSL)
3574
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   452
 	{ 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
   453
 #endif /* HAVE_EVP_SHA256 || !WITH_OPENSSL */
3574
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   454
+#ifdef GSSAPI
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   455
+	{ 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
   456
+	{ 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
   457
+	{ 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
   458
+#endif
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   459
 	{ NULL, -1, -1, -1},
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   460
 };
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   461
 
4503
bf30d46ab06e PSARC/2015/179 OpenSSH 6.8
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 3642
diff changeset
   462
@@ -126,7 +135,7 @@ kex_alg_by_name(const char *name)
3574
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   463
 	const struct kexalg *k;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   464
 
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   465
 	for (k = kexalgs; k->name != NULL; k++) {
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   466
-		if (strcmp(k->name, name) == 0)
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   467
+		if (strncmp(k->name, name, strlen(k->name)) == 0)
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   468
 			return k;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   469
 	}
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   470
 	return NULL;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   471
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
   472
--- old/kex.h
bdd7dc7d2af4 PSARC/2015/395 OpenSSH 7.1p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 4503
diff changeset
   473
+++ new/kex.h
4503
bf30d46ab06e PSARC/2015/179 OpenSSH 6.8
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 3642
diff changeset
   474
@@ -93,6 +93,9 @@ enum kex_exchange {
3574
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   475
 	KEX_DH_GEX_SHA256,
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   476
 	KEX_ECDH_SHA2,
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   477
 	KEX_C25519_SHA256,
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   478
+	KEX_GSS_GRP1_SHA1,
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   479
+	KEX_GSS_GRP14_SHA1,
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   480
+	KEX_GSS_GEX_SHA1,
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   481
 	KEX_MAX
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
 
4503
bf30d46ab06e PSARC/2015/179 OpenSSH 6.8
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 3642
diff changeset
   484
@@ -139,6 +142,10 @@ struct kex {
bf30d46ab06e PSARC/2015/179 OpenSSH 6.8
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 3642
diff changeset
   485
 	u_int	flags;
3574
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   486
 	int	hash_alg;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   487
 	int	ec_nid;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   488
+#ifdef GSSAPI
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   489
+	int	gss_deleg_creds;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   490
+	char    *gss_host;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   491
+#endif
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   492
 	char	*client_version_string;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   493
 	char	*server_version_string;
5025
bdd7dc7d2af4 PSARC/2015/395 OpenSSH 7.1p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 4503
diff changeset
   494
 	char	*failed_choice;
bdd7dc7d2af4 PSARC/2015/395 OpenSSH 7.1p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 4503
diff changeset
   495
@@ -186,6 +193,10 @@ int	 kexecdh_client(struct ssh *);
4503
bf30d46ab06e PSARC/2015/179 OpenSSH 6.8
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 3642
diff changeset
   496
 int	 kexecdh_server(struct ssh *);
bf30d46ab06e PSARC/2015/179 OpenSSH 6.8
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 3642
diff changeset
   497
 int	 kexc25519_client(struct ssh *);
bf30d46ab06e PSARC/2015/179 OpenSSH 6.8
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 3642
diff changeset
   498
 int	 kexc25519_server(struct ssh *);
3574
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   499
+#ifdef GSSAPI
4503
bf30d46ab06e PSARC/2015/179 OpenSSH 6.8
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 3642
diff changeset
   500
+int	 kexgss_client(struct ssh *);
bf30d46ab06e PSARC/2015/179 OpenSSH 6.8
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 3642
diff changeset
   501
+int	 kexgss_server(struct ssh *);
3574
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   502
+#endif
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   503
 
4503
bf30d46ab06e PSARC/2015/179 OpenSSH 6.8
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 3642
diff changeset
   504
 int	 kex_dh_hash(const char *, const char *,
bf30d46ab06e PSARC/2015/179 OpenSSH 6.8
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 3642
diff changeset
   505
     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
   506
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
   507
--- old/monitor.c
bdd7dc7d2af4 PSARC/2015/395 OpenSSH 7.1p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 4503
diff changeset
   508
+++ new/monitor.c
4503
bf30d46ab06e PSARC/2015/179 OpenSSH 6.8
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 3642
diff changeset
   509
@@ -160,6 +160,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
   510
 int mm_answer_gss_accept_ctx(int, Buffer *);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   511
 int mm_answer_gss_userok(int, Buffer *);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   512
 int mm_answer_gss_checkmic(int, Buffer *);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   513
+int mm_answer_gss_sign(int, Buffer *);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   514
 #endif
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   515
 
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   516
 #ifdef SSH_AUDIT_EVENTS
4503
bf30d46ab06e PSARC/2015/179 OpenSSH 6.8
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 3642
diff changeset
   517
@@ -244,11 +245,17 @@ struct mon_table mon_dispatch_proto20[]
3574
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   518
     {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
   519
     {MONITOR_REQ_GSSUSEROK, MON_AUTH, mm_answer_gss_userok},
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   520
     {MONITOR_REQ_GSSCHECKMIC, MON_ISAUTH, mm_answer_gss_checkmic},
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   521
+    {MONITOR_REQ_GSSSIGN, MON_ONCE, mm_answer_gss_sign},
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   522
 #endif
4503
bf30d46ab06e PSARC/2015/179 OpenSSH 6.8
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 3642
diff changeset
   523
     {0, 0, NULL}
3574
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   524
 };
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   525
 
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   526
 struct mon_table mon_dispatch_postauth20[] = {
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   527
+#ifdef GSSAPI
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   528
+    {MONITOR_REQ_GSSSETUP, 0, mm_answer_gss_setup_ctx},
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   529
+    {MONITOR_REQ_GSSSTEP, 0, mm_answer_gss_accept_ctx},
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   530
+    {MONITOR_REQ_GSSSIGN, 0, mm_answer_gss_sign},
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   531
+#endif
4503
bf30d46ab06e PSARC/2015/179 OpenSSH 6.8
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 3642
diff changeset
   532
 #ifdef WITH_OPENSSL
3574
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   533
     {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
   534
 #endif
bf30d46ab06e PSARC/2015/179 OpenSSH 6.8
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 3642
diff changeset
   535
@@ -363,6 +370,10 @@ monitor_child_preauth(Authctxt *_authctx
3574
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   536
 		/* Permit requests for moduli and signatures */
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   537
 		monitor_permit(mon_dispatch, MONITOR_REQ_MODULI, 1);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   538
 		monitor_permit(mon_dispatch, MONITOR_REQ_SIGN, 1);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   539
+#ifdef GSSAPI
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   540
+		/* and for the GSSAPI key exchange */
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   541
+		monitor_permit(mon_dispatch, MONITOR_REQ_GSSSETUP, 1);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   542
+#endif
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   543
 	} else {
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   544
 		mon_dispatch = mon_dispatch_proto15;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   545
 
4503
bf30d46ab06e PSARC/2015/179 OpenSSH 6.8
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 3642
diff changeset
   546
@@ -502,6 +513,10 @@ monitor_child_postauth(struct monitor *p
3574
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   547
 		monitor_permit(mon_dispatch, MONITOR_REQ_MODULI, 1);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   548
 		monitor_permit(mon_dispatch, MONITOR_REQ_SIGN, 1);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   549
 		monitor_permit(mon_dispatch, MONITOR_REQ_TERM, 1);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   550
+#ifdef GSSAPI
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   551
+		/* and for the GSSAPI key exchange */
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   552
+		monitor_permit(mon_dispatch, MONITOR_REQ_GSSSETUP, 1);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   553
+#endif		
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   554
 	} else {
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   555
 		mon_dispatch = mon_dispatch_postauth15;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   556
 		monitor_permit(mon_dispatch, MONITOR_REQ_TERM, 1);
5025
bdd7dc7d2af4 PSARC/2015/395 OpenSSH 7.1p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 4503
diff changeset
   557
@@ -1927,6 +1942,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
   558
 # endif
bf30d46ab06e PSARC/2015/179 OpenSSH 6.8
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 3642
diff changeset
   559
 #endif /* WITH_OPENSSL */
bf30d46ab06e PSARC/2015/179 OpenSSH 6.8
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 3642
diff changeset
   560
 		kex->kex[KEX_C25519_SHA256] = kexc25519_server;
3574
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   561
+#ifdef GSSAPI
4503
bf30d46ab06e PSARC/2015/179 OpenSSH 6.8
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 3642
diff changeset
   562
+		if (options.gss_keyex) {
bf30d46ab06e PSARC/2015/179 OpenSSH 6.8
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 3642
diff changeset
   563
+			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
   564
+			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
   565
+			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
   566
+		}
3574
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   567
+#endif
4503
bf30d46ab06e PSARC/2015/179 OpenSSH 6.8
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 3642
diff changeset
   568
 		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
   569
 		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
   570
 		kex->host_key_index=&get_hostkey_index;
5025
bdd7dc7d2af4 PSARC/2015/395 OpenSSH 7.1p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 4503
diff changeset
   571
@@ -2026,6 +2048,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
   572
 	OM_uint32 major;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   573
 	u_int len;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   574
 
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   575
+	if (!options.gss_authentication && !options.gss_keyex)
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   576
+		fatal("In GSSAPI monitor when GSSAPI is disabled");
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   577
+
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   578
 	goid.elements = buffer_get_string(m, &len);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   579
 	goid.length = len;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   580
 
5025
bdd7dc7d2af4 PSARC/2015/395 OpenSSH 7.1p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 4503
diff changeset
   581
@@ -2053,6 +2078,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
   582
 	OM_uint32 flags = 0; /* GSI needs this */
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   583
 	u_int len;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   584
 
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   585
+	if (!options.gss_authentication && !options.gss_keyex)
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   586
+		fatal("In GSSAPI monitor when GSSAPI is disabled");
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
 	in.value = buffer_get_string(m, &len);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   589
 	in.length = len;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   590
 	major = ssh_gssapi_accept_ctx(gsscontext, &in, &out, &flags);
5025
bdd7dc7d2af4 PSARC/2015/395 OpenSSH 7.1p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 4503
diff changeset
   591
@@ -2070,6 +2098,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
   592
 		monitor_permit(mon_dispatch, MONITOR_REQ_GSSSTEP, 0);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   593
 		monitor_permit(mon_dispatch, MONITOR_REQ_GSSUSEROK, 1);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   594
 		monitor_permit(mon_dispatch, MONITOR_REQ_GSSCHECKMIC, 1);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   595
+		monitor_permit(mon_dispatch, MONITOR_REQ_GSSSIGN, 1);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   596
 	}
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   597
 	return (0);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   598
 }
5025
bdd7dc7d2af4 PSARC/2015/395 OpenSSH 7.1p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 4503
diff changeset
   599
@@ -2081,6 +2110,9 @@ mm_answer_gss_checkmic(int sock, Buffer
3574
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   600
 	OM_uint32 ret;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   601
 	u_int len;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   602
 
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   603
+	if (!options.gss_authentication && !options.gss_keyex)
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   604
+		fatal("In GSSAPI monitor when GSSAPI is disabled");
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
 	gssbuf.value = buffer_get_string(m, &len);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   607
 	gssbuf.length = len;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   608
 	mic.value = buffer_get_string(m, &len);
5025
bdd7dc7d2af4 PSARC/2015/395 OpenSSH 7.1p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 4503
diff changeset
   609
@@ -2107,6 +2139,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
   610
 {
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   611
 	int authenticated;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   612
 
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   613
+	if (!options.gss_authentication && !options.gss_keyex)
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   614
+		fatal("In GSSAPI monitor when GSSAPI is disabled");
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   615
+
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   616
 	authenticated = authctxt->valid && ssh_gssapi_userok(authctxt->user);
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
 	buffer_clear(m);
5025
bdd7dc7d2af4 PSARC/2015/395 OpenSSH 7.1p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 4503
diff changeset
   619
@@ -2120,5 +2155,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
   620
 	/* Monitor loop will terminate if authenticated */
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   621
 	return (authenticated);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   622
 }
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   623
+
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   624
+int 
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   625
+mm_answer_gss_sign(int socket, Buffer *m)
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   626
+{
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   627
+	gss_buffer_desc data;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   628
+	gss_buffer_desc hash = GSS_C_EMPTY_BUFFER;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   629
+	OM_uint32 major, minor;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   630
+	u_int len;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   631
+
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   632
+	if (!options.gss_authentication && !options.gss_keyex)
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   633
+		fatal("In GSSAPI monitor when GSSAPI is disabled");
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   634
+
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   635
+	data.value = buffer_get_string(m, &len);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   636
+	data.length = len;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   637
+	if (data.length != 20) 
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   638
+		fatal("%s: data length incorrect: %d", __func__, 
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   639
+		    (int) data.length);
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
+	/* Save the session ID on the first time around */
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   642
+	if (session_id2_len == 0) {
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   643
+		session_id2_len = data.length;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   644
+		session_id2 = xmalloc(session_id2_len);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   645
+		memcpy(session_id2, data.value, session_id2_len);
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
+	major = ssh_gssapi_sign(gsscontext, &data, &hash);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   648
+
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   649
+	free(data.value);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   650
+
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   651
+	buffer_clear(m);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   652
+	buffer_put_int(m, major);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   653
+	buffer_put_string(m, hash.value, hash.length);
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
+	mm_request_send(socket, MONITOR_ANS_GSSSIGN, m);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   656
+
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   657
+	gss_release_buffer(&minor, &hash);
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
+	/* Turn on getpwnam permissions */
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   660
+	monitor_permit(mon_dispatch, MONITOR_REQ_PWNAM, 1);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   661
+
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   662
+	return (0);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   663
+}
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   664
+
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   665
 #endif /* GSSAPI */
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   666
 
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   667
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
   668
--- old/monitor.h
bdd7dc7d2af4 PSARC/2015/395 OpenSSH 7.1p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 4503
diff changeset
   669
+++ new/monitor.h
4503
bf30d46ab06e PSARC/2015/179 OpenSSH 6.8
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 3642
diff changeset
   670
@@ -68,6 +68,9 @@ enum monitor_reqtype {
3574
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   671
 #ifdef PAM_ENHANCEMENT
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   672
         MONITOR_REQ_AUTHMETHOD = 114,
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   673
 #endif        
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   674
+#ifdef GSSAPI
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   675
+	MONITOR_REQ_GSSSIGN = 130, MONITOR_ANS_GSSSIGN = 131,
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   676
+#endif        
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   677
 };
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   678
 
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   679
 struct mm_master;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   680
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
   681
--- old/monitor_wrap.c
bdd7dc7d2af4 PSARC/2015/395 OpenSSH 7.1p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 4503
diff changeset
   682
+++ new/monitor_wrap.c
4503
bf30d46ab06e PSARC/2015/179 OpenSSH 6.8
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 3642
diff changeset
   683
@@ -1103,5 +1103,28 @@ mm_ssh_gssapi_userok(char *user)
3574
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   684
 	debug3("%s: user %sauthenticated",__func__, authenticated ? "" : "not ");
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   685
 	return (authenticated);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   686
 }
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   687
+
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   688
+OM_uint32
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   689
+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
   690
+{
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   691
+	Buffer m;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   692
+	OM_uint32 major;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   693
+	u_int len;
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
+	buffer_init(&m);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   696
+	buffer_put_string(&m, data->value, data->length);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   697
+
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   698
+	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
   699
+	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
   700
+
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   701
+	major = buffer_get_int(&m);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   702
+	hash->value = buffer_get_string(&m, &len);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   703
+	hash->length = len;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   704
+
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   705
+	buffer_free(&m);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   706
+
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   707
+	return(major);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   708
+}
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   709
+
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   710
 #endif /* GSSAPI */
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   711
 
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   712
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
   713
--- old/monitor_wrap.h
bdd7dc7d2af4 PSARC/2015/395 OpenSSH 7.1p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 4503
diff changeset
   714
+++ new/monitor_wrap.h
3574
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   715
@@ -60,6 +60,7 @@ OM_uint32 mm_ssh_gssapi_accept_ctx(Gssct
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   716
    gss_buffer_desc *, gss_buffer_desc *, OM_uint32 *);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   717
 int mm_ssh_gssapi_userok(char *user);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   718
 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
   719
+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
   720
 #endif
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   721
 
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   722
 #ifdef USE_PAM
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   723
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
   724
--- old/readconf.c
bdd7dc7d2af4 PSARC/2015/395 OpenSSH 7.1p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 4503
diff changeset
   725
+++ new/readconf.c
4503
bf30d46ab06e PSARC/2015/179 OpenSSH 6.8
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 3642
diff changeset
   726
@@ -147,6 +147,7 @@ typedef enum {
3574
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   727
 	oClearAllForwardings, oNoHostAuthenticationForLocalhost,
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   728
 	oEnableSSHKeysign, oRekeyLimit, oVerifyHostKeyDNS, oConnectTimeout,
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   729
 	oAddressFamily, oGssAuthentication, oGssDelegateCreds,
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   730
+	oGssKeyEx,
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   731
 	oServerAliveInterval, oServerAliveCountMax, oIdentitiesOnly,
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   732
 	oSendEnv, oControlPath, oControlMaster, oControlPersist,
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   733
 	oHashKnownHosts,
5027
c71f34180df2 PSARC/2015/427 Old SunSSH Gss* Option Names in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5025
diff changeset
   734
@@ -198,11 +199,15 @@ static struct {
c71f34180df2 PSARC/2015/427 Old SunSSH Gss* Option Names in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5025
diff changeset
   735
 	{ "gssauthentication", oGssAuthentication },                /* alias */
3574
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   736
 	{ "gssapidelegatecredentials", oGssDelegateCreds },
5027
c71f34180df2 PSARC/2015/427 Old SunSSH Gss* Option Names in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5025
diff changeset
   737
 	{ "gssdelegatecreds", oGssDelegateCreds },                  /* alias */
3574
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   738
+	{ "gssapikeyexchange", oGssKeyEx },
5027
c71f34180df2 PSARC/2015/427 Old SunSSH Gss* Option Names in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5025
diff changeset
   739
+	{ "gsskeyex", oGssKeyEx },                                  /* alias */
3574
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   740
 #else
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   741
 	{ "gssapiauthentication", oUnsupported },
5027
c71f34180df2 PSARC/2015/427 Old SunSSH Gss* Option Names in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5025
diff changeset
   742
 	{ "gssauthentication", oUnsupported },
3574
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   743
 	{ "gssapidelegatecredentials", oUnsupported },
5027
c71f34180df2 PSARC/2015/427 Old SunSSH Gss* Option Names in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5025
diff changeset
   744
 	{ "gssdelegatecreds", oUnsupported },
3574
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   745
+	{ "gssapikeyexchange", oUnsupported },
5027
c71f34180df2 PSARC/2015/427 Old SunSSH Gss* Option Names in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5025
diff changeset
   746
+	{ "gsskeyex", oUnsupported },
3574
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   747
 #endif
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   748
 	{ "fallbacktorsh", oDeprecated },
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   749
 	{ "usersh", oDeprecated },
5027
c71f34180df2 PSARC/2015/427 Old SunSSH Gss* Option Names in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5025
diff changeset
   750
@@ -933,6 +938,10 @@ parse_time:
3574
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   751
 		intptr = &options->gss_authentication;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   752
 		goto parse_flag;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   753
 
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   754
+	case oGssKeyEx:
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   755
+		intptr = &options->gss_keyex;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   756
+		goto parse_flag;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   757
+
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   758
 	case oGssDelegateCreds:
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   759
 		intptr = &options->gss_deleg_creds;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   760
 		goto parse_flag;
5027
c71f34180df2 PSARC/2015/427 Old SunSSH Gss* Option Names in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5025
diff changeset
   761
@@ -1647,6 +1656,7 @@ initialize_options(Options * options)
3574
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   762
 	options->pubkey_authentication = -1;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   763
 	options->challenge_response_authentication = -1;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   764
 	options->gss_authentication = -1;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   765
+	options->gss_keyex = -1;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   766
 	options->gss_deleg_creds = -1;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   767
 	options->password_authentication = -1;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   768
 	options->kbd_interactive_authentication = -1;
5027
c71f34180df2 PSARC/2015/427 Old SunSSH Gss* Option Names in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5025
diff changeset
   769
@@ -1786,6 +1796,12 @@ fill_default_options(Options * options)
3574
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   770
 #else
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   771
 		options->gss_authentication = 0;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   772
 #endif
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   773
+	if (options->gss_keyex == -1)
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   774
+#ifdef OPTION_DEFAULT_VALUE
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   775
+		options->gss_keyex = 1;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   776
+#else
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   777
+		options->gss_keyex = 0;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   778
+#endif
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   779
 	if (options->gss_deleg_creds == -1)
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   780
 		options->gss_deleg_creds = 0;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   781
 	if (options->password_authentication == -1)
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   782
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
   783
--- old/readconf.h
bdd7dc7d2af4 PSARC/2015/395 OpenSSH 7.1p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 4503
diff changeset
   784
+++ new/readconf.h
4503
bf30d46ab06e PSARC/2015/179 OpenSSH 6.8
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 3642
diff changeset
   785
@@ -45,6 +45,7 @@ typedef struct {
3574
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   786
 	int     challenge_response_authentication;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   787
 					/* Try S/Key or TIS, authentication. */
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   788
 	int     gss_authentication;	/* Try GSS authentication */
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   789
+	int     gss_keyex;		/* Try GSS key exchange */
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   790
 	int     gss_deleg_creds;	/* Delegate GSS credentials */
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   791
 	int     password_authentication;	/* Try password
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   792
 						 * authentication. */
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   793
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
   794
--- old/servconf.c
bdd7dc7d2af4 PSARC/2015/395 OpenSSH 7.1p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 4503
diff changeset
   795
+++ new/servconf.c
bdd7dc7d2af4 PSARC/2015/395 OpenSSH 7.1p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 4503
diff changeset
   796
@@ -117,6 +117,7 @@ initialize_server_options(ServerOptions
3574
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   797
 	options->kerberos_ticket_cleanup = -1;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   798
 	options->kerberos_get_afs_token = -1;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   799
 	options->gss_authentication=-1;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   800
+	options->gss_keyex = -1;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   801
 	options->gss_cleanup_creds = -1;
5025
bdd7dc7d2af4 PSARC/2015/395 OpenSSH 7.1p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 4503
diff changeset
   802
 	options->gss_strict_acceptor = -1;
3574
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   803
 	options->password_authentication = -1;
5025
bdd7dc7d2af4 PSARC/2015/395 OpenSSH 7.1p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 4503
diff changeset
   804
@@ -300,6 +301,12 @@ fill_default_server_options(ServerOption
3574
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   805
 #else
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   806
 		options->gss_authentication = 0;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   807
 #endif
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   808
+	if (options->gss_keyex == -1)
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   809
+#ifdef OPTION_DEFAULT_VALUE
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   810
+		options->gss_keyex = 1;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   811
+#else
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   812
+		options->gss_keyex = 0;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   813
+#endif
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   814
 	if (options->gss_cleanup_creds == -1)
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   815
 		options->gss_cleanup_creds = 1;
5025
bdd7dc7d2af4 PSARC/2015/395 OpenSSH 7.1p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 4503
diff changeset
   816
 	if (options->gss_strict_acceptor == -1)
bdd7dc7d2af4 PSARC/2015/395 OpenSSH 7.1p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 4503
diff changeset
   817
@@ -442,6 +449,7 @@ typedef enum {
4503
bf30d46ab06e PSARC/2015/179 OpenSSH 6.8
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 3642
diff changeset
   818
 	sHostbasedUsesNameFromPacketOnly, sHostbasedAcceptedKeyTypes,
5025
bdd7dc7d2af4 PSARC/2015/395 OpenSSH 7.1p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 4503
diff changeset
   819
 	sHostKeyAlgorithms,
4503
bf30d46ab06e PSARC/2015/179 OpenSSH 6.8
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 3642
diff changeset
   820
 	sClientAliveInterval, sClientAliveCountMax, sAuthorizedKeysFile,
3574
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   821
+	sGssKeyEx,
5025
bdd7dc7d2af4 PSARC/2015/395 OpenSSH 7.1p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 4503
diff changeset
   822
 	sGssAuthentication, sGssCleanupCreds, sGssStrictAcceptor,
bdd7dc7d2af4 PSARC/2015/395 OpenSSH 7.1p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 4503
diff changeset
   823
 	sAcceptEnv, sPermitTunnel,
3574
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   824
 	sMatch, sPermitOpen, sForceCommand, sChrootDirectory,
5027
c71f34180df2 PSARC/2015/427 Old SunSSH Gss* Option Names in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5025
diff changeset
   825
@@ -519,6 +527,8 @@ static struct {
3574
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   826
 #ifdef GSSAPI
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   827
 	{ "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
   828
 	{ "gssauthentication", sGssAuthentication, SSHCFG_ALL },   /* alias */
3574
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   829
+	{ "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
   830
+	{ "gsskeyex", sGssKeyEx, SSHCFG_ALL },                     /* alias */
3574
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   831
 #ifdef USE_GSS_STORE_CRED
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   832
 	{ "gssapicleanupcredentials", sUnsupported, SSHCFG_GLOBAL },
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   833
 #else /* USE_GSS_STORE_CRED */
5027
c71f34180df2 PSARC/2015/427 Old SunSSH Gss* Option Names in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5025
diff changeset
   834
@@ -528,6 +538,8 @@ static struct {
3574
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   835
 #else
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   836
 	{ "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
   837
 	{ "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
   838
+	{ "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
   839
+	{ "gsskeyex", sUnsupported,, SSHCFG_ALL },
3574
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   840
 	{ "gssapicleanupcredentials", sUnsupported, SSHCFG_GLOBAL },
5025
bdd7dc7d2af4 PSARC/2015/395 OpenSSH 7.1p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 4503
diff changeset
   841
 	{ "gssapistrictacceptorcheck", sUnsupported, SSHCFG_GLOBAL },
3574
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   842
 #endif
5027
c71f34180df2 PSARC/2015/427 Old SunSSH Gss* Option Names in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5025
diff changeset
   843
@@ -1311,6 +1323,10 @@ process_server_config_line(ServerOptions
3574
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   844
 		intptr = &options->gss_authentication;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   845
 		goto parse_flag;
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
+	case sGssKeyEx:
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   848
+		intptr = &options->gss_keyex;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   849
+		goto parse_flag;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   850
+
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   851
 	case sGssCleanupCreds:
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   852
 		intptr = &options->gss_cleanup_creds;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   853
 		goto parse_flag;
5027
c71f34180df2 PSARC/2015/427 Old SunSSH Gss* Option Names in OpenSSH
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 5025
diff changeset
   854
@@ -2357,6 +2373,7 @@ dump_config(ServerOptions *o)
3574
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   855
 #endif
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   856
 #ifdef GSSAPI
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   857
 	dump_cfg_fmtint(sGssAuthentication, o->gss_authentication);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   858
+	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
   859
 #ifndef USE_GSS_STORE_CRED
3574
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   860
 	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
   861
 #endif /* !USE_GSS_STORE_CRED */
3574
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   862
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
   863
--- old/servconf.h
bdd7dc7d2af4 PSARC/2015/395 OpenSSH 7.1p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 4503
diff changeset
   864
+++ new/servconf.h
bdd7dc7d2af4 PSARC/2015/395 OpenSSH 7.1p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 4503
diff changeset
   865
@@ -122,6 +122,7 @@ typedef struct {
3574
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   866
 	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
   867
 						 * authenticated with Kerberos. */
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   868
 	int     gss_authentication;	/* If true, permit GSSAPI authentication */
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   869
+	int     gss_keyex;		/* If true, permit GSSAPI key exchange */
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   870
 	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
   871
 	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
   872
 	int     password_authentication;	/* If true, permit password
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   873
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
   874
--- old/ssh-gss.h
bdd7dc7d2af4 PSARC/2015/395 OpenSSH 7.1p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 4503
diff changeset
   875
+++ new/ssh-gss.h
3574
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   876
@@ -61,6 +61,17 @@
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   877
 
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   878
 #define SSH_GSS_OIDTYPE 0x06
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   879
 
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   880
+#define SSH2_MSG_KEXGSS_INIT                            30
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   881
+#define SSH2_MSG_KEXGSS_CONTINUE                        31
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   882
+#define SSH2_MSG_KEXGSS_COMPLETE                        32
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   883
+#define SSH2_MSG_KEXGSS_HOSTKEY                         33
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   884
+#define SSH2_MSG_KEXGSS_ERROR                           34
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   885
+#define SSH2_MSG_KEXGSS_GROUPREQ			40
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   886
+#define SSH2_MSG_KEXGSS_GROUP				41
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   887
+#define KEX_GSS_GRP1_SHA1_ID				"gss-group1-sha1-"
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   888
+#define KEX_GSS_GRP14_SHA1_ID				"gss-group14-sha1-"
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   889
+#define KEX_GSS_GEX_SHA1_ID				"gss-gex-sha1-"
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
 typedef struct {
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   892
 	char *filename;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   893
 	char *envvar;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   894
@@ -98,6 +109,7 @@ typedef struct {
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   895
 } Gssctxt;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   896
 
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   897
 extern ssh_gssapi_mech *supported_mechs[];
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   898
+extern Gssctxt *gss_kex_context;
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
 int  ssh_gssapi_check_oid(Gssctxt *, void *, size_t);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   901
 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
   902
@@ -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
   903
 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
   904
 
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   905
 /* In the server */
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   906
+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
   907
+char *ssh_gssapi_client_mechanisms(const char *host);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   908
+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
   909
+gss_OID ssh_gssapi_id_kex(Gssctxt *, char *, int);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   910
+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
   911
 OM_uint32 ssh_gssapi_server_ctx(Gssctxt **, gss_OID);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   912
 int ssh_gssapi_userok(char *name);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   913
 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
   914
@@ -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
   915
 void ssh_gssapi_cleanup_creds(void);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   916
 void ssh_gssapi_storecreds(void);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   917
 
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   918
+char *ssh_gssapi_server_mechanisms(void);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   919
+int ssh_gssapi_oid_table_ok();
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   920
 #endif /* GSSAPI */
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 /* _SSH_GSS_H */
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   923
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
   924
--- old/ssh_config.5
bdd7dc7d2af4 PSARC/2015/395 OpenSSH 7.1p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 4503
diff changeset
   925
+++ new/ssh_config.5
bdd7dc7d2af4 PSARC/2015/395 OpenSSH 7.1p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 4503
diff changeset
   926
@@ -757,6 +757,12 @@ Specifies whether user authentication ba
3574
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   927
 The default on Solaris is
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   928
 .Dq yes .
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   929
 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
   930
+.It Cm GSSAPIKeyExchange
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   931
+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
   932
+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
   933
+The default on Solaris is
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   934
+.Dq yes .
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   935
+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
   936
 .It Cm GSSAPIDelegateCredentials
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   937
 Forward (delegate) credentials to the server.
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   938
 The default is
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   939
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
   940
--- old/sshconnect2.c
bdd7dc7d2af4 PSARC/2015/395 OpenSSH 7.1p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 4503
diff changeset
   941
+++ new/sshconnect2.c
bdd7dc7d2af4 PSARC/2015/395 OpenSSH 7.1p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 4503
diff changeset
   942
@@ -163,12 +163,37 @@ ssh_kex2(char *host, struct sockaddr *ho
bdd7dc7d2af4 PSARC/2015/395 OpenSSH 7.1p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 4503
diff changeset
   943
 	char *myproposal[PROPOSAL_MAX] = { KEX_CLIENT };
4503
bf30d46ab06e PSARC/2015/179 OpenSSH 6.8
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 3642
diff changeset
   944
 	struct kex *kex;
bf30d46ab06e PSARC/2015/179 OpenSSH 6.8
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 3642
diff changeset
   945
 	int r;
3574
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   946
+#ifdef GSSAPI
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   947
+	char *orig = NULL, *gss = NULL;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   948
+	char *gss_host = NULL;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   949
+#endif
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   950
+
5025
bdd7dc7d2af4 PSARC/2015/395 OpenSSH 7.1p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 4503
diff changeset
   951
 
3574
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   952
 	xxx_host = host;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   953
 	xxx_hostaddr = hostaddr;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   954
 
5025
bdd7dc7d2af4 PSARC/2015/395 OpenSSH 7.1p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 4503
diff changeset
   955
+	if (options.kex_algorithms != NULL)
bdd7dc7d2af4 PSARC/2015/395 OpenSSH 7.1p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 4503
diff changeset
   956
+		myproposal[PROPOSAL_KEX_ALGS] = options.kex_algorithms;
bdd7dc7d2af4 PSARC/2015/395 OpenSSH 7.1p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 4503
diff changeset
   957
+
3574
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   958
+#ifdef GSSAPI
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   959
+	if (options.gss_keyex) {
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   960
+		/* Add the GSSAPI mechanisms currently supported on this 
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   961
+		 * client to the key exchange algorithm proposal */
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   962
+		orig = myproposal[PROPOSAL_KEX_ALGS];
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   963
+
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   964
+		gss_host = (char *)get_canonical_hostname(1);
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
+		gss = ssh_gssapi_client_mechanisms(gss_host);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   967
+		if (gss) {
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   968
+			debug("Offering GSSAPI proposal: %s", gss);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   969
+			xasprintf(&myproposal[PROPOSAL_KEX_ALGS],
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   970
+			    "%s,%s", gss, orig);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   971
+		}
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   972
+	}
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   973
+#endif
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   974
+
4503
bf30d46ab06e PSARC/2015/179 OpenSSH 6.8
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 3642
diff changeset
   975
 	myproposal[PROPOSAL_KEX_ALGS] = compat_kex_proposal(
5025
bdd7dc7d2af4 PSARC/2015/395 OpenSSH 7.1p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 4503
diff changeset
   976
-	    options.kex_algorithms);
bdd7dc7d2af4 PSARC/2015/395 OpenSSH 7.1p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 4503
diff changeset
   977
+	    myproposal[PROPOSAL_KEX_ALGS]);
bdd7dc7d2af4 PSARC/2015/395 OpenSSH 7.1p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 4503
diff changeset
   978
 	myproposal[PROPOSAL_ENC_ALGS_CTOS] =
bdd7dc7d2af4 PSARC/2015/395 OpenSSH 7.1p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 4503
diff changeset
   979
 	    compat_cipher_proposal(options.ciphers);
bdd7dc7d2af4 PSARC/2015/395 OpenSSH 7.1p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 4503
diff changeset
   980
 	myproposal[PROPOSAL_ENC_ALGS_STOC] =
bdd7dc7d2af4 PSARC/2015/395 OpenSSH 7.1p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 4503
diff changeset
   981
@@ -197,6 +222,17 @@ ssh_kex2(char *host, struct sockaddr *ho
bdd7dc7d2af4 PSARC/2015/395 OpenSSH 7.1p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 4503
diff changeset
   982
 		    order_hostkeyalgs(host, hostaddr, port));
bdd7dc7d2af4 PSARC/2015/395 OpenSSH 7.1p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 4503
diff changeset
   983
 	}
3574
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   984
 
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   985
+#ifdef GSSAPI
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   986
+	/* 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
   987
+	 * 'null' hostkey, as a last resort */
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   988
+	if (options.gss_keyex && gss) {
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   989
+		orig = myproposal[PROPOSAL_SERVER_HOST_KEY_ALGS];
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   990
+		xasprintf(&myproposal[PROPOSAL_SERVER_HOST_KEY_ALGS], 
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   991
+		    "%s,null", orig);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   992
+		free(gss);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   993
+	}
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   994
+#endif
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   995
+
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   996
 	if (options.rekey_limit || options.rekey_interval)
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
   997
 		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
   998
 		    (time_t)options.rekey_interval);
5025
bdd7dc7d2af4 PSARC/2015/395 OpenSSH 7.1p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 4503
diff changeset
   999
@@ -215,9 +251,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
  1000
 # endif
bf30d46ab06e PSARC/2015/179 OpenSSH 6.8
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 3642
diff changeset
  1001
 #endif
3574
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1002
 	kex->kex[KEX_C25519_SHA256] = kexc25519_client;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1003
+#ifdef GSSAPI
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1004
+	if (options.gss_keyex) {
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1005
+		kex->kex[KEX_GSS_GRP1_SHA1] = kexgss_client;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1006
+		kex->kex[KEX_GSS_GRP14_SHA1] = kexgss_client;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1007
+		kex->kex[KEX_GSS_GEX_SHA1] = kexgss_client;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1008
+	}
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1009
+#endif
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1010
 	kex->client_version_string=client_version_string;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1011
 	kex->server_version_string=server_version_string;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1012
 	kex->verify_host_key=&verify_host_key_callback;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1013
+#ifdef GSSAPI
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1014
+	if (options.gss_keyex) {
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1015
+		kex->gss_deleg_creds = options.gss_deleg_creds;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1016
+		kex->gss_host = gss_host;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1017
+	}
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1018
+#endif
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1019
 
4503
bf30d46ab06e PSARC/2015/179 OpenSSH 6.8
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 3642
diff changeset
  1020
 	dispatch_run(DISPATCH_BLOCK, &kex->done, active_state);
3574
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1021
 
5025
bdd7dc7d2af4 PSARC/2015/395 OpenSSH 7.1p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 4503
diff changeset
  1022
@@ -310,6 +359,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
  1023
 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
  1024
 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
  1025
 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
  1026
+int	userauth_gsskeyex(Authctxt *authctxt);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1027
 #endif
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1028
 
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1029
 void	userauth(Authctxt *, char *);
5025
bdd7dc7d2af4 PSARC/2015/395 OpenSSH 7.1p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 4503
diff changeset
  1030
@@ -325,6 +375,11 @@ static char *authmethods_get(void);
3574
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1031
 
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1032
 Authmethod authmethods[] = {
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1033
 #ifdef GSSAPI
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1034
+	{"gssapi-keyex",
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1035
+		userauth_gsskeyex,
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1036
+		NULL,
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1037
+		&options.gss_authentication,
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1038
+		NULL},
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1039
 	{"gssapi-with-mic",
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1040
 		userauth_gssapi,
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1041
 		NULL,
5025
bdd7dc7d2af4 PSARC/2015/395 OpenSSH 7.1p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 4503
diff changeset
  1042
@@ -649,7 +704,10 @@ userauth_gssapi(Authctxt *authctxt)
3574
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1043
 	 * once. */
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1044
 
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1045
 	if (gss_supported == NULL)
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1046
-		gss_indicate_mechs(&min, &gss_supported);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1047
+		if (GSS_ERROR(gss_indicate_mechs(&min, &gss_supported))) {
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1048
+			gss_supported = NULL;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1049
+			return 0;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1050
+		}
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1051
 
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1052
 	/* 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
  1053
 	while (mech < gss_supported->count && !ok) {
5025
bdd7dc7d2af4 PSARC/2015/395 OpenSSH 7.1p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 4503
diff changeset
  1054
@@ -753,8 +811,8 @@ input_gssapi_response(int type, u_int32_
3574
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1055
 {
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1056
 	Authctxt *authctxt = ctxt;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1057
 	Gssctxt *gssctxt;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1058
-	int oidlen;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1059
-	char *oidv;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1060
+	u_int oidlen;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1061
+	u_char *oidv;
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
 	if (authctxt == NULL)
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1064
 		fatal("input_gssapi_response: no authentication context");
5025
bdd7dc7d2af4 PSARC/2015/395 OpenSSH 7.1p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 4503
diff changeset
  1065
@@ -867,6 +925,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
  1066
 	free(lang);
4503
bf30d46ab06e PSARC/2015/179 OpenSSH 6.8
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 3642
diff changeset
  1067
 	return 0;
3574
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1068
 }
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1069
+
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1070
+int
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1071
+userauth_gsskeyex(Authctxt *authctxt)
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1072
+{
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1073
+	Buffer b;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1074
+	gss_buffer_desc gssbuf;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1075
+	gss_buffer_desc mic = GSS_C_EMPTY_BUFFER;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1076
+	OM_uint32 ms;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1077
+
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1078
+	static int attempt = 0;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1079
+	if (attempt++ >= 1)
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1080
+		return (0);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1081
+
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1082
+	if (gss_kex_context == NULL) {
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1083
+		debug("No valid Key exchange context"); 
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1084
+		return (0);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1085
+	}
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1086
+
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1087
+	ssh_gssapi_buildmic(&b, authctxt->server_user, authctxt->service,
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1088
+	    "gssapi-keyex");
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
+	gssbuf.value = buffer_ptr(&b);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1091
+	gssbuf.length = buffer_len(&b);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1092
+
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1093
+	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
  1094
+		buffer_free(&b);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1095
+		return (0);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1096
+	}
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1097
+
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1098
+	packet_start(SSH2_MSG_USERAUTH_REQUEST);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1099
+	packet_put_cstring(authctxt->server_user);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1100
+	packet_put_cstring(authctxt->service);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1101
+	packet_put_cstring(authctxt->method->name);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1102
+	packet_put_string(mic.value, mic.length);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1103
+	packet_send();
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1104
+
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1105
+	buffer_free(&b);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1106
+	gss_release_buffer(&ms, &mic);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1107
+
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1108
+	return (1);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1109
+}
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1110
+
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1111
 #endif /* GSSAPI */
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1112
 
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1113
 int
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1114
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
  1115
--- old/sshd.c
bdd7dc7d2af4 PSARC/2015/395 OpenSSH 7.1p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 4503
diff changeset
  1116
+++ new/sshd.c
bdd7dc7d2af4 PSARC/2015/395 OpenSSH 7.1p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 4503
diff changeset
  1117
@@ -1827,10 +1827,13 @@ main(int ac, char **av)
3574
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1118
 		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
  1119
 		options.protocol &= ~SSH_PROTO_1;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1120
 	}
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1121
+#ifndef GSSAPI
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1122
+	/* 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
  1123
 	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
  1124
 		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
  1125
 		options.protocol &= ~SSH_PROTO_2;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1126
 	}
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1127
+#endif
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1128
 	if (!(options.protocol & (SSH_PROTO_1|SSH_PROTO_2))) {
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1129
 		logit("sshd: no hostkeys available -- exiting.");
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1130
 		exit(1);
5025
bdd7dc7d2af4 PSARC/2015/395 OpenSSH 7.1p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 4503
diff changeset
  1131
@@ -2588,6 +2591,48 @@ do_ssh2_kex(void)
3574
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1132
 	myproposal[PROPOSAL_SERVER_HOST_KEY_ALGS] = compat_pkalg_proposal(
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1133
 	    list_hostkey_types());
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1134
 
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1135
+#ifdef GSSAPI
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1136
+	{
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1137
+	char *orig;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1138
+	char *gss = NULL;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1139
+	char *newstr = NULL;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1140
+	orig = myproposal[PROPOSAL_KEX_ALGS];
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1141
+
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1142
+	/* 
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1143
+	 * 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
  1144
+	 * the other key exchange algorithms
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1145
+	 */
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1146
+
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1147
+	if (strlen(myproposal[PROPOSAL_SERVER_HOST_KEY_ALGS]) == 0)
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1148
+		orig = NULL;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1149
+
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1150
+	if (options.gss_keyex)
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1151
+		gss = ssh_gssapi_server_mechanisms();
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1152
+	else
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1153
+		gss = NULL;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1154
+
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1155
+	if (gss && orig)
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1156
+		xasprintf(&newstr, "%s,%s", gss, orig);
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1157
+	else if (gss)
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1158
+		newstr = gss;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1159
+	else if (orig)
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1160
+		newstr = orig;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1161
+
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1162
+	/* 
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1163
+	 * 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
  1164
+	 * 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
  1165
+  	 * host key algorithm we support
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1166
+	 */
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1167
+	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
  1168
+		myproposal[PROPOSAL_SERVER_HOST_KEY_ALGS] = "null";
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1169
+
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1170
+	if (newstr)
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1171
+		myproposal[PROPOSAL_KEX_ALGS] = newstr;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1172
+	else
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1173
+		fatal("No supported key exchange algorithms");
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1174
+	}
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1175
+#endif
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1176
+
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1177
 	/* start key exchange */
4503
bf30d46ab06e PSARC/2015/179 OpenSSH 6.8
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 3642
diff changeset
  1178
 	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
  1179
 		fatal("kex_setup: %s", ssh_err(r));
5025
bdd7dc7d2af4 PSARC/2015/395 OpenSSH 7.1p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 4503
diff changeset
  1180
@@ -2602,6 +2647,13 @@ do_ssh2_kex(void)
4503
bf30d46ab06e PSARC/2015/179 OpenSSH 6.8
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 3642
diff changeset
  1181
 # endif
bf30d46ab06e PSARC/2015/179 OpenSSH 6.8
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 3642
diff changeset
  1182
 #endif
3574
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1183
 	kex->kex[KEX_C25519_SHA256] = kexc25519_server;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1184
+#ifdef GSSAPI
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1185
+	if (options.gss_keyex) {
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1186
+		kex->kex[KEX_GSS_GRP1_SHA1] = kexgss_server;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1187
+		kex->kex[KEX_GSS_GRP14_SHA1] = kexgss_server;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1188
+		kex->kex[KEX_GSS_GEX_SHA1] = kexgss_server;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1189
+	}
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1190
+#endif
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1191
 	kex->server = 1;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1192
 	kex->client_version_string=client_version_string;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1193
 	kex->server_version_string=server_version_string;
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1194
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
  1195
--- old/sshd_config.5
bdd7dc7d2af4 PSARC/2015/395 OpenSSH 7.1p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 4503
diff changeset
  1196
+++ new/sshd_config.5
bdd7dc7d2af4 PSARC/2015/395 OpenSSH 7.1p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 4503
diff changeset
  1197
@@ -621,6 +621,12 @@ Specifies whether user authentication ba
3574
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1198
 The default on Solaris is
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1199
 .Dq yes .
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1200
 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
  1201
+.It Cm GSSAPIKeyExchange
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1202
+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
  1203
+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
  1204
+The default on Solaris is
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1205
+.Dq yes .
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1206
+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
  1207
 .It Cm GSSAPICleanupCredentials
80e9a4e240d3 PSARC/2014/390 OpenSSH GSSKEY
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff changeset
  1208
 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
  1209
 on logout.
4503
bf30d46ab06e PSARC/2015/179 OpenSSH 6.8
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 3642
diff changeset
  1210
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
  1211
--- old/sshkey.c
bdd7dc7d2af4 PSARC/2015/395 OpenSSH 7.1p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 4503
diff changeset
  1212
+++ new/sshkey.c
bdd7dc7d2af4 PSARC/2015/395 OpenSSH 7.1p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 4503
diff changeset
  1213
@@ -112,6 +112,7 @@ static const struct keytype keytypes[] =
bdd7dc7d2af4 PSARC/2015/395 OpenSSH 7.1p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 4503
diff changeset
  1214
 #  endif /* OPENSSL_HAS_NISTP521 */
bdd7dc7d2af4 PSARC/2015/395 OpenSSH 7.1p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 4503
diff changeset
  1215
 # endif /* OPENSSL_HAS_ECC */
4503
bf30d46ab06e PSARC/2015/179 OpenSSH 6.8
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 3642
diff changeset
  1216
 #endif /* WITH_OPENSSL */
bf30d46ab06e PSARC/2015/179 OpenSSH 6.8
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 3642
diff changeset
  1217
+	{ "null", "null", KEY_NULL, 0, 0 },
bf30d46ab06e PSARC/2015/179 OpenSSH 6.8
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 3642
diff changeset
  1218
 	{ NULL, NULL, -1, -1, 0 }
bf30d46ab06e PSARC/2015/179 OpenSSH 6.8
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 3642
diff changeset
  1219
 };
bf30d46ab06e PSARC/2015/179 OpenSSH 6.8
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 3642
diff changeset
  1220
 
bf30d46ab06e PSARC/2015/179 OpenSSH 6.8
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 3642
diff changeset
  1221
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
  1222
--- old/sshkey.h
bdd7dc7d2af4 PSARC/2015/395 OpenSSH 7.1p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 4503
diff changeset
  1223
+++ new/sshkey.h
bdd7dc7d2af4 PSARC/2015/395 OpenSSH 7.1p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 4503
diff changeset
  1224
@@ -62,6 +62,7 @@ enum sshkey_types {
bdd7dc7d2af4 PSARC/2015/395 OpenSSH 7.1p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 4503
diff changeset
  1225
 	KEY_DSA_CERT,
bdd7dc7d2af4 PSARC/2015/395 OpenSSH 7.1p1
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 4503
diff changeset
  1226
 	KEY_ECDSA_CERT,
4503
bf30d46ab06e PSARC/2015/179 OpenSSH 6.8
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 3642
diff changeset
  1227
 	KEY_ED25519_CERT,
bf30d46ab06e PSARC/2015/179 OpenSSH 6.8
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 3642
diff changeset
  1228
+	KEY_NULL,
bf30d46ab06e PSARC/2015/179 OpenSSH 6.8
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 3642
diff changeset
  1229
 	KEY_UNSPEC
bf30d46ab06e PSARC/2015/179 OpenSSH 6.8
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 3642
diff changeset
  1230
 };
bf30d46ab06e PSARC/2015/179 OpenSSH 6.8
Tomas Kuthan <tomas.kuthan@oracle.com>
parents: 3642
diff changeset
  1231