summaryrefslogtreecommitdiff
path: root/debian/patches/gssapi.patch
diff options
context:
space:
mode:
authorColin Watson <cjwatson@debian.org>2010-02-27 14:05:10 +0000
committerColin Watson <cjwatson@debian.org>2010-02-27 14:05:10 +0000
commit8dcc7c5ef45cf5032dca7a308ffe17d3935e62d5 (patch)
tree2e0d8058bdfc24a60a20c5bcbfd1075ef1048ff3 /debian/patches/gssapi.patch
parente44a1fb6e8e59e67e5c8b6e83c0d8566d146aad9 (diff)
Convert to source format 3.0 (quilt).
Diffstat (limited to 'debian/patches/gssapi.patch')
-rw-r--r--debian/patches/gssapi.patch2975
1 files changed, 2975 insertions, 0 deletions
diff --git a/debian/patches/gssapi.patch b/debian/patches/gssapi.patch
new file mode 100644
index 000000000..a60a8b4e1
--- /dev/null
+++ b/debian/patches/gssapi.patch
@@ -0,0 +1,2975 @@
1Index: b/ChangeLog.gssapi
2===================================================================
3--- /dev/null
4+++ b/ChangeLog.gssapi
5@@ -0,0 +1,103 @@
6+20100124
7+ - [ sshconnect2.c ]
8+ Adapt to deal with additional element in Authmethod structure. Thanks to
9+ Colin Wilson
10+ - [ clientloop.c ]
11+ Protect credentials updated code with suitable #ifdefs. Thanks to Colin
12+ Wilson
13+
14+20090615
15+ - [ gss-genr.c gss-serv.c kexgssc.c kexgsss.c monitor.c sshconnect2.c
16+ sshd.c ]
17+ Fix issues identified by Greg Hudson following a code review
18+ Check return value of gss_indicate_mechs
19+ Protect GSSAPI calls in monitor, so they can only be used if enabled
20+ Check return values of bignum functions in key exchange
21+ Use BN_clear_free to clear other side's DH value
22+ Make ssh_gssapi_id_kex more robust
23+ Only configure kex table pointers if GSSAPI is enabled
24+ Don't leak mechanism list, or gss mechanism list
25+ Cast data.length before printing
26+ If serverkey isn't provided, use an empty string, rather than NULL
27+
28+20090201
29+ - [ gss-genr.c gss-serv.c kex.h kexgssc.c readconf.c readconf.h ssh-gss.h
30+ ssh_config.5 sshconnet2.c ]
31+ Add support for the GSSAPIClientIdentity option, which allows the user
32+ to specify which GSSAPI identity to use to contact a given server
33+
34+20080404
35+ - [ gss-serv.c ]
36+ Add code to actually implement GSSAPIStrictAcceptCheck, which had somehow
37+ been omitted from a previous version of this patch. Reported by Borislav
38+ Stoichkov
39+
40+20070317
41+ - [ gss-serv-krb5.c ]
42+ Remove C99ism, where new_ccname was being declared in the middle of a
43+ function
44+
45+20061220
46+ - [ servconf.c ]
47+ Make default for GSSAPIStrictAcceptorCheck be Yes, to match previous, and
48+ documented, behaviour. Reported by Dan Watson.
49+
50+20060910
51+ - [ gss-genr.c kexgssc.c kexgsss.c kex.h monitor.c sshconnect2.c sshd.c
52+ ssh-gss.h ]
53+ add support for gss-group14-sha1 key exchange mechanisms
54+ - [ gss-serv.c servconf.c servconf.h sshd_config sshd_config.5 ]
55+ Add GSSAPIStrictAcceptorCheck option to allow the disabling of
56+ acceptor principal checking on multi-homed machines.
57+ <Bugzilla #928>
58+ - [ sshd_config ssh_config ]
59+ Add settings for GSSAPIKeyExchange and GSSAPITrustDNS to the sample
60+ configuration files
61+ - [ kexgss.c kegsss.c sshconnect2.c sshd.c ]
62+ Code cleanup. Replace strlen/xmalloc/snprintf sequences with xasprintf()
63+ Limit length of error messages displayed by client
64+
65+20060909
66+ - [ gss-genr.c gss-serv.c ]
67+ move ssh_gssapi_acquire_cred() and ssh_gssapi_server_ctx to be server
68+ only, where they belong
69+ <Bugzilla #1225>
70+
71+20060829
72+ - [ gss-serv-krb5.c ]
73+ Fix CCAPI credentials cache name when creating KRB5CCNAME environment
74+ variable
75+
76+20060828
77+ - [ gss-genr.c ]
78+ Avoid Heimdal context freeing problem
79+ <Fixed upstream 20060829>
80+
81+20060818
82+ - [ gss-genr.c ssh-gss.h sshconnect2.c ]
83+ Make sure that SPENGO is disabled
84+ <Bugzilla #1218 - Fixed upstream 20060818>
85+
86+20060421
87+ - [ gssgenr.c, sshconnect2.c ]
88+ a few type changes (signed versus unsigned, int versus size_t) to
89+ fix compiler errors/warnings
90+ (from jbasney AT ncsa.uiuc.edu)
91+ - [ kexgssc.c, sshconnect2.c ]
92+ fix uninitialized variable warnings
93+ (from jbasney AT ncsa.uiuc.edu)
94+ - [ gssgenr.c ]
95+ pass oid to gss_display_status (helpful when using GSSAPI mechglue)
96+ (from jbasney AT ncsa.uiuc.edu)
97+ <Bugzilla #1220 >
98+ - [ gss-serv-krb5.c ]
99+ #ifdef HAVE_GSSAPI_KRB5 should be #ifdef HAVE_GSSAPI_KRB5_H
100+ (from jbasney AT ncsa.uiuc.edu)
101+ <Fixed upstream 20060304>
102+ - [ readconf.c, readconf.h, ssh_config.5, sshconnect2.c
103+ add client-side GssapiKeyExchange option
104+ (from jbasney AT ncsa.uiuc.edu)
105+ - [ sshconnect2.c ]
106+ add support for GssapiTrustDns option for gssapi-with-mic
107+ (from jbasney AT ncsa.uiuc.edu)
108+ <gssapi-with-mic support is Bugzilla #1008>
109Index: b/Makefile.in
110===================================================================
111--- a/Makefile.in
112+++ b/Makefile.in
113@@ -71,7 +71,8 @@
114 atomicio.o key.o dispatch.o kex.o mac.o uidswap.o uuencode.o misc.o \
115 monitor_fdpass.o rijndael.o ssh-dss.o ssh-rsa.o dh.o kexdh.o \
116 kexgex.o kexdhc.o kexgexc.o scard.o msg.o progressmeter.o dns.o \
117- entropy.o scard-opensc.o gss-genr.o umac.o jpake.o schnorr.o
118+ entropy.o scard-opensc.o gss-genr.o umac.o jpake.o schnorr.o \
119+ kexgssc.o
120
121 SSHOBJS= ssh.o readconf.o clientloop.o sshtty.o \
122 sshconnect.o sshconnect1.o sshconnect2.o mux.o \
123@@ -85,7 +86,7 @@
124 auth2-none.o auth2-passwd.o auth2-pubkey.o auth2-jpake.o \
125 monitor_mm.o monitor.o monitor_wrap.o kexdhs.o kexgexs.o \
126 auth-krb5.o \
127- auth2-gss.o gss-serv.o gss-serv-krb5.o \
128+ auth2-gss.o gss-serv.o gss-serv-krb5.o kexgsss.o\
129 loginrec.o auth-pam.o auth-shadow.o auth-sia.o md5crypt.o \
130 audit.o audit-bsm.o platform.o sftp-server.o sftp-common.o \
131 roaming_common.o
132Index: b/auth-krb5.c
133===================================================================
134--- a/auth-krb5.c
135+++ b/auth-krb5.c
136@@ -166,8 +166,13 @@
137
138 len = strlen(authctxt->krb5_ticket_file) + 6;
139 authctxt->krb5_ccname = xmalloc(len);
140+#ifdef USE_CCAPI
141+ snprintf(authctxt->krb5_ccname, len, "API:%s",
142+ authctxt->krb5_ticket_file);
143+#else
144 snprintf(authctxt->krb5_ccname, len, "FILE:%s",
145 authctxt->krb5_ticket_file);
146+#endif
147
148 #ifdef USE_PAM
149 if (options.use_pam)
150@@ -219,15 +224,22 @@
151 #ifndef HEIMDAL
152 krb5_error_code
153 ssh_krb5_cc_gen(krb5_context ctx, krb5_ccache *ccache) {
154- int tmpfd, ret;
155+ int ret;
156 char ccname[40];
157 mode_t old_umask;
158+#ifdef USE_CCAPI
159+ char cctemplate[] = "API:krb5cc_%d";
160+#else
161+ char cctemplate[] = "FILE:/tmp/krb5cc_%d_XXXXXXXXXX";
162+ int tmpfd;
163+#endif
164
165 ret = snprintf(ccname, sizeof(ccname),
166- "FILE:/tmp/krb5cc_%d_XXXXXXXXXX", geteuid());
167+ cctemplate, geteuid());
168 if (ret < 0 || (size_t)ret >= sizeof(ccname))
169 return ENOMEM;
170
171+#ifndef USE_CCAPI
172 old_umask = umask(0177);
173 tmpfd = mkstemp(ccname + strlen("FILE:"));
174 umask(old_umask);
175@@ -242,6 +254,7 @@
176 return errno;
177 }
178 close(tmpfd);
179+#endif
180
181 return (krb5_cc_resolve(ctx, ccname, ccache));
182 }
183Index: b/auth.h
184===================================================================
185--- a/auth.h
186+++ b/auth.h
187@@ -53,6 +53,7 @@
188 int valid; /* user exists and is allowed to login */
189 int attempt;
190 int failures;
191+ int server_caused_failure;
192 int force_pwchange;
193 char *user; /* username sent by the client */
194 char *service;
195Index: b/auth2-gss.c
196===================================================================
197--- a/auth2-gss.c
198+++ b/auth2-gss.c
199@@ -1,7 +1,7 @@
200 /* $OpenBSD: auth2-gss.c,v 1.16 2007/10/29 00:52:45 dtucker Exp $ */
201
202 /*
203- * Copyright (c) 2001-2003 Simon Wilkinson. All rights reserved.
204+ * Copyright (c) 2001-2007 Simon Wilkinson. All rights reserved.
205 *
206 * Redistribution and use in source and binary forms, with or without
207 * modification, are permitted provided that the following conditions
208@@ -52,6 +52,40 @@
209 static void input_gssapi_exchange_complete(int type, u_int32_t plen, void *ctxt);
210 static void input_gssapi_errtok(int, u_int32_t, void *);
211
212+/*
213+ * The 'gssapi_keyex' userauth mechanism.
214+ */
215+static int
216+userauth_gsskeyex(Authctxt *authctxt)
217+{
218+ int authenticated = 0;
219+ Buffer b;
220+ gss_buffer_desc mic, gssbuf;
221+ u_int len;
222+
223+ mic.value = packet_get_string(&len);
224+ mic.length = len;
225+
226+ packet_check_eom();
227+
228+ ssh_gssapi_buildmic(&b, authctxt->user, authctxt->service,
229+ "gssapi-keyex");
230+
231+ gssbuf.value = buffer_ptr(&b);
232+ gssbuf.length = buffer_len(&b);
233+
234+ /* gss_kex_context is NULL with privsep, so we can't check it here */
235+ if (!GSS_ERROR(PRIVSEP(ssh_gssapi_checkmic(gss_kex_context,
236+ &gssbuf, &mic))))
237+ authenticated = PRIVSEP(ssh_gssapi_userok(authctxt->user,
238+ authctxt->pw));
239+
240+ buffer_free(&b);
241+ xfree(mic.value);
242+
243+ return (authenticated);
244+}
245+
246 /*
247 * We only support those mechanisms that we know about (ie ones that we know
248 * how to check local user kuserok and the like)
249@@ -102,6 +136,7 @@
250
251 if (!present) {
252 xfree(doid);
253+ authctxt->server_caused_failure = 1;
254 return (0);
255 }
256
257@@ -109,6 +144,7 @@
258 if (ctxt != NULL)
259 ssh_gssapi_delete_ctx(&ctxt);
260 xfree(doid);
261+ authctxt->server_caused_failure = 1;
262 return (0);
263 }
264
265@@ -242,7 +278,8 @@
266
267 packet_check_eom();
268
269- authenticated = PRIVSEP(ssh_gssapi_userok(authctxt->user));
270+ authenticated = PRIVSEP(ssh_gssapi_userok(authctxt->user,
271+ authctxt->pw));
272
273 authctxt->postponed = 0;
274 dispatch_set(SSH2_MSG_USERAUTH_GSSAPI_TOKEN, NULL);
275@@ -277,7 +314,8 @@
276 gssbuf.length = buffer_len(&b);
277
278 if (!GSS_ERROR(PRIVSEP(ssh_gssapi_checkmic(gssctxt, &gssbuf, &mic))))
279- authenticated = PRIVSEP(ssh_gssapi_userok(authctxt->user));
280+ authenticated =
281+ PRIVSEP(ssh_gssapi_userok(authctxt->user, authctxt->pw));
282 else
283 logit("GSSAPI MIC check failed");
284
285@@ -292,6 +330,12 @@
286 userauth_finish(authctxt, authenticated, "gssapi-with-mic");
287 }
288
289+Authmethod method_gsskeyex = {
290+ "gssapi-keyex",
291+ userauth_gsskeyex,
292+ &options.gss_authentication
293+};
294+
295 Authmethod method_gssapi = {
296 "gssapi-with-mic",
297 userauth_gssapi,
298Index: b/auth2.c
299===================================================================
300--- a/auth2.c
301+++ b/auth2.c
302@@ -69,6 +69,7 @@
303 extern Authmethod method_kbdint;
304 extern Authmethod method_hostbased;
305 #ifdef GSSAPI
306+extern Authmethod method_gsskeyex;
307 extern Authmethod method_gssapi;
308 #endif
309 #ifdef JPAKE
310@@ -79,6 +80,7 @@
311 &method_none,
312 &method_pubkey,
313 #ifdef GSSAPI
314+ &method_gsskeyex,
315 &method_gssapi,
316 #endif
317 #ifdef JPAKE
318@@ -274,6 +276,7 @@
319 #endif
320
321 authctxt->postponed = 0;
322+ authctxt->server_caused_failure = 0;
323
324 /* try to authenticate user */
325 m = authmethod_lookup(method);
326@@ -346,7 +349,8 @@
327 } else {
328
329 /* Allow initial try of "none" auth without failure penalty */
330- if (authctxt->attempt > 1 || strcmp(method, "none") != 0)
331+ if (!authctxt->server_caused_failure &&
332+ (authctxt->attempt > 1 || strcmp(method, "none") != 0))
333 authctxt->failures++;
334 if (authctxt->failures >= options.max_authtries) {
335 #ifdef SSH_AUDIT_EVENTS
336Index: b/clientloop.c
337===================================================================
338--- a/clientloop.c
339+++ b/clientloop.c
340@@ -111,6 +111,10 @@
341 #include "msg.h"
342 #include "roaming.h"
343
344+#ifdef GSSAPI
345+#include "ssh-gss.h"
346+#endif
347+
348 /* import options */
349 extern Options options;
350
351@@ -1430,6 +1434,15 @@
352 /* Do channel operations unless rekeying in progress. */
353 if (!rekeying) {
354 channel_after_select(readset, writeset);
355+
356+#ifdef GSSAPI
357+ if (options.gss_renewal_rekey &&
358+ ssh_gssapi_credentials_updated(GSS_C_NO_CONTEXT)) {
359+ debug("credentials updated - forcing rekey");
360+ need_rekeying = 1;
361+ }
362+#endif
363+
364 if (need_rekeying || packet_need_rekeying()) {
365 debug("need rekeying");
366 xxx_kex->done = 0;
367Index: b/configure.ac
368===================================================================
369--- a/configure.ac
370+++ b/configure.ac
371@@ -477,6 +477,30 @@
372 [Use tunnel device compatibility to OpenBSD])
373 AC_DEFINE(SSH_TUN_PREPEND_AF, 1,
374 [Prepend the address family to IP tunnel traffic])
375+ AC_MSG_CHECKING(if we have the Security Authorization Session API)
376+ AC_TRY_COMPILE([#include <Security/AuthSession.h>],
377+ [SessionCreate(0, 0);],
378+ [ac_cv_use_security_session_api="yes"
379+ AC_DEFINE(USE_SECURITY_SESSION_API, 1,
380+ [platform has the Security Authorization Session API])
381+ LIBS="$LIBS -framework Security"
382+ AC_MSG_RESULT(yes)],
383+ [ac_cv_use_security_session_api="no"
384+ AC_MSG_RESULT(no)])
385+ AC_MSG_CHECKING(if we have an in-memory credentials cache)
386+ AC_TRY_COMPILE(
387+ [#include <Kerberos/Kerberos.h>],
388+ [cc_context_t c;
389+ (void) cc_initialize (&c, 0, NULL, NULL);],
390+ [AC_DEFINE(USE_CCAPI, 1,
391+ [platform uses an in-memory credentials cache])
392+ LIBS="$LIBS -framework Security"
393+ AC_MSG_RESULT(yes)
394+ if test "x$ac_cv_use_security_session_api" = "xno"; then
395+ AC_MSG_ERROR(*** Need a security framework to use the credentials cache API ***)
396+ fi],
397+ [AC_MSG_RESULT(no)]
398+ )
399 m4_pattern_allow(AU_IPv)
400 AC_CHECK_DECL(AU_IPv4, [],
401 AC_DEFINE(AU_IPv4, 0, [System only supports IPv4 audit records])
402Index: b/gss-genr.c
403===================================================================
404--- a/gss-genr.c
405+++ b/gss-genr.c
406@@ -1,7 +1,7 @@
407 /* $OpenBSD: gss-genr.c,v 1.20 2009/06/22 05:39:28 dtucker Exp $ */
408
409 /*
410- * Copyright (c) 2001-2007 Simon Wilkinson. All rights reserved.
411+ * Copyright (c) 2001-2009 Simon Wilkinson. All rights reserved.
412 *
413 * Redistribution and use in source and binary forms, with or without
414 * modification, are permitted provided that the following conditions
415@@ -39,12 +39,167 @@
416 #include "buffer.h"
417 #include "log.h"
418 #include "ssh2.h"
419+#include "cipher.h"
420+#include "key.h"
421+#include "kex.h"
422+#include <openssl/evp.h>
423
424 #include "ssh-gss.h"
425
426 extern u_char *session_id2;
427 extern u_int session_id2_len;
428
429+typedef struct {
430+ char *encoded;
431+ gss_OID oid;
432+} ssh_gss_kex_mapping;
433+
434+/*
435+ * XXX - It would be nice to find a more elegant way of handling the
436+ * XXX passing of the key exchange context to the userauth routines
437+ */
438+
439+Gssctxt *gss_kex_context = NULL;
440+
441+static ssh_gss_kex_mapping *gss_enc2oid = NULL;
442+
443+int
444+ssh_gssapi_oid_table_ok() {
445+ return (gss_enc2oid != NULL);
446+}
447+
448+/*
449+ * Return a list of the gss-group1-sha1 mechanisms supported by this program
450+ *
451+ * We test mechanisms to ensure that we can use them, to avoid starting
452+ * a key exchange with a bad mechanism
453+ */
454+
455+char *
456+ssh_gssapi_client_mechanisms(const char *host, const char *client) {
457+ gss_OID_set gss_supported;
458+ OM_uint32 min_status;
459+
460+ if (GSS_ERROR(gss_indicate_mechs(&min_status, &gss_supported)))
461+ return NULL;
462+
463+ return(ssh_gssapi_kex_mechs(gss_supported, ssh_gssapi_check_mechanism,
464+ host, client));
465+}
466+
467+char *
468+ssh_gssapi_kex_mechs(gss_OID_set gss_supported, ssh_gssapi_check_fn *check,
469+ const char *host, const char *client) {
470+ Buffer buf;
471+ size_t i;
472+ int oidpos, enclen;
473+ char *mechs, *encoded;
474+ u_char digest[EVP_MAX_MD_SIZE];
475+ char deroid[2];
476+ const EVP_MD *evp_md = EVP_md5();
477+ EVP_MD_CTX md;
478+
479+ if (gss_enc2oid != NULL) {
480+ for (i = 0; gss_enc2oid[i].encoded != NULL; i++)
481+ xfree(gss_enc2oid[i].encoded);
482+ xfree(gss_enc2oid);
483+ }
484+
485+ gss_enc2oid = xmalloc(sizeof(ssh_gss_kex_mapping) *
486+ (gss_supported->count + 1));
487+
488+ buffer_init(&buf);
489+
490+ oidpos = 0;
491+ for (i = 0; i < gss_supported->count; i++) {
492+ if (gss_supported->elements[i].length < 128 &&
493+ (*check)(NULL, &(gss_supported->elements[i]), host, client)) {
494+
495+ deroid[0] = SSH_GSS_OIDTYPE;
496+ deroid[1] = gss_supported->elements[i].length;
497+
498+ EVP_DigestInit(&md, evp_md);
499+ EVP_DigestUpdate(&md, deroid, 2);
500+ EVP_DigestUpdate(&md,
501+ gss_supported->elements[i].elements,
502+ gss_supported->elements[i].length);
503+ EVP_DigestFinal(&md, digest, NULL);
504+
505+ encoded = xmalloc(EVP_MD_size(evp_md) * 2);
506+ enclen = __b64_ntop(digest, EVP_MD_size(evp_md),
507+ encoded, EVP_MD_size(evp_md) * 2);
508+
509+ if (oidpos != 0)
510+ buffer_put_char(&buf, ',');
511+
512+ buffer_append(&buf, KEX_GSS_GEX_SHA1_ID,
513+ sizeof(KEX_GSS_GEX_SHA1_ID) - 1);
514+ buffer_append(&buf, encoded, enclen);
515+ buffer_put_char(&buf, ',');
516+ buffer_append(&buf, KEX_GSS_GRP1_SHA1_ID,
517+ sizeof(KEX_GSS_GRP1_SHA1_ID) - 1);
518+ buffer_append(&buf, encoded, enclen);
519+ buffer_put_char(&buf, ',');
520+ buffer_append(&buf, KEX_GSS_GRP14_SHA1_ID,
521+ sizeof(KEX_GSS_GRP14_SHA1_ID) - 1);
522+ buffer_append(&buf, encoded, enclen);
523+
524+ gss_enc2oid[oidpos].oid = &(gss_supported->elements[i]);
525+ gss_enc2oid[oidpos].encoded = encoded;
526+ oidpos++;
527+ }
528+ }
529+ gss_enc2oid[oidpos].oid = NULL;
530+ gss_enc2oid[oidpos].encoded = NULL;
531+
532+ buffer_put_char(&buf, '\0');
533+
534+ mechs = xmalloc(buffer_len(&buf));
535+ buffer_get(&buf, mechs, buffer_len(&buf));
536+ buffer_free(&buf);
537+
538+ if (strlen(mechs) == 0) {
539+ xfree(mechs);
540+ mechs = NULL;
541+ }
542+
543+ return (mechs);
544+}
545+
546+gss_OID
547+ssh_gssapi_id_kex(Gssctxt *ctx, char *name, int kex_type) {
548+ int i = 0;
549+
550+ switch (kex_type) {
551+ case KEX_GSS_GRP1_SHA1:
552+ if (strlen(name) < sizeof(KEX_GSS_GRP1_SHA1_ID))
553+ return GSS_C_NO_OID;
554+ name += sizeof(KEX_GSS_GRP1_SHA1_ID) - 1;
555+ break;
556+ case KEX_GSS_GRP14_SHA1:
557+ if (strlen(name) < sizeof(KEX_GSS_GRP14_SHA1_ID))
558+ return GSS_C_NO_OID;
559+ name += sizeof(KEX_GSS_GRP14_SHA1_ID) - 1;
560+ break;
561+ case KEX_GSS_GEX_SHA1:
562+ if (strlen(name) < sizeof(KEX_GSS_GEX_SHA1_ID))
563+ return GSS_C_NO_OID;
564+ name += sizeof(KEX_GSS_GEX_SHA1_ID) - 1;
565+ break;
566+ default:
567+ return GSS_C_NO_OID;
568+ }
569+
570+ while (gss_enc2oid[i].encoded != NULL &&
571+ strcmp(name, gss_enc2oid[i].encoded) != 0)
572+ i++;
573+
574+ if (gss_enc2oid[i].oid != NULL && ctx != NULL)
575+ ssh_gssapi_set_oid(ctx, gss_enc2oid[i].oid);
576+
577+ return gss_enc2oid[i].oid;
578+}
579+
580 /* Check that the OID in a data stream matches that in the context */
581 int
582 ssh_gssapi_check_oid(Gssctxt *ctx, void *data, size_t len)
583@@ -197,7 +352,7 @@
584 }
585
586 ctx->major = gss_init_sec_context(&ctx->minor,
587- GSS_C_NO_CREDENTIAL, &ctx->context, ctx->name, ctx->oid,
588+ ctx->client_creds, &ctx->context, ctx->name, ctx->oid,
589 GSS_C_MUTUAL_FLAG | GSS_C_INTEG_FLAG | deleg_flag,
590 0, NULL, recv_tok, NULL, send_tok, flags, NULL);
591
592@@ -227,8 +382,42 @@
593 }
594
595 OM_uint32
596+ssh_gssapi_client_identity(Gssctxt *ctx, const char *name)
597+{
598+ gss_buffer_desc gssbuf;
599+ gss_name_t gssname;
600+ OM_uint32 status;
601+ gss_OID_set oidset;
602+
603+ gssbuf.value = (void *) name;
604+ gssbuf.length = strlen(gssbuf.value);
605+
606+ gss_create_empty_oid_set(&status, &oidset);
607+ gss_add_oid_set_member(&status, ctx->oid, &oidset);
608+
609+ ctx->major = gss_import_name(&ctx->minor, &gssbuf,
610+ GSS_C_NT_USER_NAME, &gssname);
611+
612+ if (!ctx->major)
613+ ctx->major = gss_acquire_cred(&ctx->minor,
614+ gssname, 0, oidset, GSS_C_INITIATE,
615+ &ctx->client_creds, NULL, NULL);
616+
617+ gss_release_name(&status, &gssname);
618+ gss_release_oid_set(&status, &oidset);
619+
620+ if (ctx->major)
621+ ssh_gssapi_error(ctx);
622+
623+ return(ctx->major);
624+}
625+
626+OM_uint32
627 ssh_gssapi_sign(Gssctxt *ctx, gss_buffer_t buffer, gss_buffer_t hash)
628 {
629+ if (ctx == NULL)
630+ return -1;
631+
632 if ((ctx->major = gss_get_mic(&ctx->minor, ctx->context,
633 GSS_C_QOP_DEFAULT, buffer, hash)))
634 ssh_gssapi_error(ctx);
635@@ -236,6 +425,19 @@
636 return (ctx->major);
637 }
638
639+/* Priviledged when used by server */
640+OM_uint32
641+ssh_gssapi_checkmic(Gssctxt *ctx, gss_buffer_t gssbuf, gss_buffer_t gssmic)
642+{
643+ if (ctx == NULL)
644+ return -1;
645+
646+ ctx->major = gss_verify_mic(&ctx->minor, ctx->context,
647+ gssbuf, gssmic, NULL);
648+
649+ return (ctx->major);
650+}
651+
652 void
653 ssh_gssapi_buildmic(Buffer *b, const char *user, const char *service,
654 const char *context)
655@@ -249,11 +451,16 @@
656 }
657
658 int
659-ssh_gssapi_check_mechanism(Gssctxt **ctx, gss_OID oid, const char *host)
660+ssh_gssapi_check_mechanism(Gssctxt **ctx, gss_OID oid, const char *host,
661+ const char *client)
662 {
663 gss_buffer_desc token = GSS_C_EMPTY_BUFFER;
664 OM_uint32 major, minor;
665 gss_OID_desc spnego_oid = {6, (void *)"\x2B\x06\x01\x05\x05\x02"};
666+ Gssctxt *intctx = NULL;
667+
668+ if (ctx == NULL)
669+ ctx = &intctx;
670
671 /* RFC 4462 says we MUST NOT do SPNEGO */
672 if (oid->length == spnego_oid.length &&
673@@ -263,6 +470,10 @@
674 ssh_gssapi_build_ctx(ctx);
675 ssh_gssapi_set_oid(*ctx, oid);
676 major = ssh_gssapi_import_name(*ctx, host);
677+
678+ if (!GSS_ERROR(major) && client)
679+ major = ssh_gssapi_client_identity(*ctx, client);
680+
681 if (!GSS_ERROR(major)) {
682 major = ssh_gssapi_init_ctx(*ctx, 0, GSS_C_NO_BUFFER, &token,
683 NULL);
684@@ -272,10 +483,67 @@
685 GSS_C_NO_BUFFER);
686 }
687
688- if (GSS_ERROR(major))
689+ if (GSS_ERROR(major) || intctx != NULL)
690 ssh_gssapi_delete_ctx(ctx);
691
692 return (!GSS_ERROR(major));
693 }
694
695+int
696+ssh_gssapi_credentials_updated(Gssctxt *ctxt) {
697+ static gss_name_t saved_name = GSS_C_NO_NAME;
698+ static OM_uint32 saved_lifetime = 0;
699+ static gss_OID saved_mech = GSS_C_NO_OID;
700+ static gss_name_t name;
701+ static OM_uint32 last_call = 0;
702+ OM_uint32 lifetime, now, major, minor;
703+ int equal;
704+ gss_cred_usage_t usage = GSS_C_INITIATE;
705+
706+ now = time(NULL);
707+
708+ if (ctxt) {
709+ debug("Rekey has happened - updating saved versions");
710+
711+ if (saved_name != GSS_C_NO_NAME)
712+ gss_release_name(&minor, &saved_name);
713+
714+ major = gss_inquire_cred(&minor, GSS_C_NO_CREDENTIAL,
715+ &saved_name, &saved_lifetime, NULL, NULL);
716+
717+ if (!GSS_ERROR(major)) {
718+ saved_mech = ctxt->oid;
719+ saved_lifetime+= now;
720+ } else {
721+ /* Handle the error */
722+ }
723+ return 0;
724+ }
725+
726+ if (now - last_call < 10)
727+ return 0;
728+
729+ last_call = now;
730+
731+ if (saved_mech == GSS_C_NO_OID)
732+ return 0;
733+
734+ major = gss_inquire_cred(&minor, GSS_C_NO_CREDENTIAL,
735+ &name, &lifetime, NULL, NULL);
736+ if (major == GSS_S_CREDENTIALS_EXPIRED)
737+ return 0;
738+ else if (GSS_ERROR(major))
739+ return 0;
740+
741+ major = gss_compare_name(&minor, saved_name, name, &equal);
742+ gss_release_name(&minor, &name);
743+ if (GSS_ERROR(major))
744+ return 0;
745+
746+ if (equal && (saved_lifetime < lifetime + now - 10))
747+ return 1;
748+
749+ return 0;
750+}
751+
752 #endif /* GSSAPI */
753Index: b/gss-serv-krb5.c
754===================================================================
755--- a/gss-serv-krb5.c
756+++ b/gss-serv-krb5.c
757@@ -1,7 +1,7 @@
758 /* $OpenBSD: gss-serv-krb5.c,v 1.7 2006/08/03 03:34:42 deraadt Exp $ */
759
760 /*
761- * Copyright (c) 2001-2003 Simon Wilkinson. All rights reserved.
762+ * Copyright (c) 2001-2007 Simon Wilkinson. All rights reserved.
763 *
764 * Redistribution and use in source and binary forms, with or without
765 * modification, are permitted provided that the following conditions
766@@ -120,6 +120,7 @@
767 krb5_principal princ;
768 OM_uint32 maj_status, min_status;
769 int len;
770+ const char *new_ccname;
771
772 if (client->creds == NULL) {
773 debug("No credentials stored");
774@@ -168,11 +169,16 @@
775 return;
776 }
777
778- client->store.filename = xstrdup(krb5_cc_get_name(krb_context, ccache));
779+ new_ccname = krb5_cc_get_name(krb_context, ccache);
780+
781 client->store.envvar = "KRB5CCNAME";
782- len = strlen(client->store.filename) + 6;
783- client->store.envval = xmalloc(len);
784- snprintf(client->store.envval, len, "FILE:%s", client->store.filename);
785+#ifdef USE_CCAPI
786+ xasprintf(&client->store.envval, "API:%s", new_ccname);
787+ client->store.filename = NULL;
788+#else
789+ xasprintf(&client->store.envval, "FILE:%s", new_ccname);
790+ client->store.filename = xstrdup(new_ccname);
791+#endif
792
793 #ifdef USE_PAM
794 if (options.use_pam)
795@@ -184,6 +190,71 @@
796 return;
797 }
798
799+int
800+ssh_gssapi_krb5_updatecreds(ssh_gssapi_ccache *store,
801+ ssh_gssapi_client *client)
802+{
803+ krb5_ccache ccache = NULL;
804+ krb5_principal principal = NULL;
805+ char *name = NULL;
806+ krb5_error_code problem;
807+ OM_uint32 maj_status, min_status;
808+
809+ if ((problem = krb5_cc_resolve(krb_context, store->envval, &ccache))) {
810+ logit("krb5_cc_resolve(): %.100s",
811+ krb5_get_err_text(krb_context, problem));
812+ return 0;
813+ }
814+
815+ /* Find out who the principal in this cache is */
816+ if ((problem = krb5_cc_get_principal(krb_context, ccache,
817+ &principal))) {
818+ logit("krb5_cc_get_principal(): %.100s",
819+ krb5_get_err_text(krb_context, problem));
820+ krb5_cc_close(krb_context, ccache);
821+ return 0;
822+ }
823+
824+ if ((problem = krb5_unparse_name(krb_context, principal, &name))) {
825+ logit("krb5_unparse_name(): %.100s",
826+ krb5_get_err_text(krb_context, problem));
827+ krb5_free_principal(krb_context, principal);
828+ krb5_cc_close(krb_context, ccache);
829+ return 0;
830+ }
831+
832+
833+ if (strcmp(name,client->exportedname.value)!=0) {
834+ debug("Name in local credentials cache differs. Not storing");
835+ krb5_free_principal(krb_context, principal);
836+ krb5_cc_close(krb_context, ccache);
837+ krb5_free_unparsed_name(krb_context, name);
838+ return 0;
839+ }
840+ krb5_free_unparsed_name(krb_context, name);
841+
842+ /* Name matches, so lets get on with it! */
843+
844+ if ((problem = krb5_cc_initialize(krb_context, ccache, principal))) {
845+ logit("krb5_cc_initialize(): %.100s",
846+ krb5_get_err_text(krb_context, problem));
847+ krb5_free_principal(krb_context, principal);
848+ krb5_cc_close(krb_context, ccache);
849+ return 0;
850+ }
851+
852+ krb5_free_principal(krb_context, principal);
853+
854+ if ((maj_status = gss_krb5_copy_ccache(&min_status, client->creds,
855+ ccache))) {
856+ logit("gss_krb5_copy_ccache() failed. Sorry!");
857+ krb5_cc_close(krb_context, ccache);
858+ return 0;
859+ }
860+
861+ return 1;
862+}
863+
864 ssh_gssapi_mech gssapi_kerberos_mech = {
865 "toWM5Slw5Ew8Mqkay+al2g==",
866 "Kerberos",
867@@ -191,7 +262,8 @@
868 NULL,
869 &ssh_gssapi_krb5_userok,
870 NULL,
871- &ssh_gssapi_krb5_storecreds
872+ &ssh_gssapi_krb5_storecreds,
873+ &ssh_gssapi_krb5_updatecreds
874 };
875
876 #endif /* KRB5 */
877Index: b/gss-serv.c
878===================================================================
879--- a/gss-serv.c
880+++ b/gss-serv.c
881@@ -1,7 +1,7 @@
882 /* $OpenBSD: gss-serv.c,v 1.22 2008/05/08 12:02:23 djm Exp $ */
883
884 /*
885- * Copyright (c) 2001-2003 Simon Wilkinson. All rights reserved.
886+ * Copyright (c) 2001-2009 Simon Wilkinson. All rights reserved.
887 *
888 * Redistribution and use in source and binary forms, with or without
889 * modification, are permitted provided that the following conditions
890@@ -45,15 +45,20 @@
891 #include "channels.h"
892 #include "session.h"
893 #include "misc.h"
894+#include "servconf.h"
895+#include "uidswap.h"
896
897 #include "ssh-gss.h"
898+#include "monitor_wrap.h"
899+
900+extern ServerOptions options;
901
902 static ssh_gssapi_client gssapi_client =
903 { GSS_C_EMPTY_BUFFER, GSS_C_EMPTY_BUFFER,
904- GSS_C_NO_CREDENTIAL, NULL, {NULL, NULL, NULL}};
905+ GSS_C_NO_CREDENTIAL, GSS_C_NO_NAME, NULL, {NULL, NULL, NULL}, 0, 0};
906
907 ssh_gssapi_mech gssapi_null_mech =
908- { NULL, NULL, {0, NULL}, NULL, NULL, NULL, NULL};
909+ { NULL, NULL, {0, NULL}, NULL, NULL, NULL, NULL, NULL};
910
911 #ifdef KRB5
912 extern ssh_gssapi_mech gssapi_kerberos_mech;
913@@ -81,25 +86,32 @@
914 char lname[MAXHOSTNAMELEN];
915 gss_OID_set oidset;
916
917- gss_create_empty_oid_set(&status, &oidset);
918- gss_add_oid_set_member(&status, ctx->oid, &oidset);
919+ if (options.gss_strict_acceptor) {
920+ gss_create_empty_oid_set(&status, &oidset);
921+ gss_add_oid_set_member(&status, ctx->oid, &oidset);
922+
923+ if (gethostname(lname, MAXHOSTNAMELEN)) {
924+ gss_release_oid_set(&status, &oidset);
925+ return (-1);
926+ }
927
928- if (gethostname(lname, MAXHOSTNAMELEN)) {
929- gss_release_oid_set(&status, &oidset);
930- return (-1);
931- }
932+ if (GSS_ERROR(ssh_gssapi_import_name(ctx, lname))) {
933+ gss_release_oid_set(&status, &oidset);
934+ return (ctx->major);
935+ }
936+
937+ if ((ctx->major = gss_acquire_cred(&ctx->minor,
938+ ctx->name, 0, oidset, GSS_C_ACCEPT, &ctx->creds,
939+ NULL, NULL)))
940+ ssh_gssapi_error(ctx);
941
942- if (GSS_ERROR(ssh_gssapi_import_name(ctx, lname))) {
943 gss_release_oid_set(&status, &oidset);
944 return (ctx->major);
945+ } else {
946+ ctx->name = GSS_C_NO_NAME;
947+ ctx->creds = GSS_C_NO_CREDENTIAL;
948 }
949-
950- if ((ctx->major = gss_acquire_cred(&ctx->minor,
951- ctx->name, 0, oidset, GSS_C_ACCEPT, &ctx->creds, NULL, NULL)))
952- ssh_gssapi_error(ctx);
953-
954- gss_release_oid_set(&status, &oidset);
955- return (ctx->major);
956+ return GSS_S_COMPLETE;
957 }
958
959 /* Privileged */
960@@ -114,6 +126,29 @@
961 }
962
963 /* Unprivileged */
964+char *
965+ssh_gssapi_server_mechanisms() {
966+ gss_OID_set supported;
967+
968+ ssh_gssapi_supported_oids(&supported);
969+ return (ssh_gssapi_kex_mechs(supported, &ssh_gssapi_server_check_mech,
970+ NULL, NULL));
971+}
972+
973+/* Unprivileged */
974+int
975+ssh_gssapi_server_check_mech(Gssctxt **dum, gss_OID oid, const char *data,
976+ const char *dummy) {
977+ Gssctxt *ctx = NULL;
978+ int res;
979+
980+ res = !GSS_ERROR(PRIVSEP(ssh_gssapi_server_ctx(&ctx, oid)));
981+ ssh_gssapi_delete_ctx(&ctx);
982+
983+ return (res);
984+}
985+
986+/* Unprivileged */
987 void
988 ssh_gssapi_supported_oids(gss_OID_set *oidset)
989 {
990@@ -123,7 +158,9 @@
991 gss_OID_set supported;
992
993 gss_create_empty_oid_set(&min_status, oidset);
994- gss_indicate_mechs(&min_status, &supported);
995+
996+ if (GSS_ERROR(gss_indicate_mechs(&min_status, &supported)))
997+ return;
998
999 while (supported_mechs[i]->name != NULL) {
1000 if (GSS_ERROR(gss_test_oid_set_member(&min_status,
1001@@ -247,8 +284,48 @@
1002 ssh_gssapi_getclient(Gssctxt *ctx, ssh_gssapi_client *client)
1003 {
1004 int i = 0;
1005+ int equal = 0;
1006+ gss_name_t new_name = GSS_C_NO_NAME;
1007+ gss_buffer_desc ename = GSS_C_EMPTY_BUFFER;
1008+
1009+ if (options.gss_store_rekey && client->used && ctx->client_creds) {
1010+ if (client->mech->oid.length != ctx->oid->length ||
1011+ (memcmp(client->mech->oid.elements,
1012+ ctx->oid->elements, ctx->oid->length) !=0)) {
1013+ debug("Rekeyed credentials have different mechanism");
1014+ return GSS_S_COMPLETE;
1015+ }
1016+
1017+ if ((ctx->major = gss_inquire_cred_by_mech(&ctx->minor,
1018+ ctx->client_creds, ctx->oid, &new_name,
1019+ NULL, NULL, NULL))) {
1020+ ssh_gssapi_error(ctx);
1021+ return (ctx->major);
1022+ }
1023+
1024+ ctx->major = gss_compare_name(&ctx->minor, client->name,
1025+ new_name, &equal);
1026
1027- gss_buffer_desc ename;
1028+ if (GSS_ERROR(ctx->major)) {
1029+ ssh_gssapi_error(ctx);
1030+ return (ctx->major);
1031+ }
1032+
1033+ if (!equal) {
1034+ debug("Rekeyed credentials have different name");
1035+ return GSS_S_COMPLETE;
1036+ }
1037+
1038+ debug("Marking rekeyed credentials for export");
1039+
1040+ gss_release_name(&ctx->minor, &client->name);
1041+ gss_release_cred(&ctx->minor, &client->creds);
1042+ client->name = new_name;
1043+ client->creds = ctx->client_creds;
1044+ ctx->client_creds = GSS_C_NO_CREDENTIAL;
1045+ client->updated = 1;
1046+ return GSS_S_COMPLETE;
1047+ }
1048
1049 client->mech = NULL;
1050
1051@@ -263,6 +340,13 @@
1052 if (client->mech == NULL)
1053 return GSS_S_FAILURE;
1054
1055+ if (ctx->client_creds &&
1056+ (ctx->major = gss_inquire_cred_by_mech(&ctx->minor,
1057+ ctx->client_creds, ctx->oid, &client->name, NULL, NULL, NULL))) {
1058+ ssh_gssapi_error(ctx);
1059+ return (ctx->major);
1060+ }
1061+
1062 if ((ctx->major = gss_display_name(&ctx->minor, ctx->client,
1063 &client->displayname, NULL))) {
1064 ssh_gssapi_error(ctx);
1065@@ -280,6 +364,8 @@
1066 return (ctx->major);
1067 }
1068
1069+ gss_release_buffer(&ctx->minor, &ename);
1070+
1071 /* We can't copy this structure, so we just move the pointer to it */
1072 client->creds = ctx->client_creds;
1073 ctx->client_creds = GSS_C_NO_CREDENTIAL;
1074@@ -327,7 +413,7 @@
1075
1076 /* Privileged */
1077 int
1078-ssh_gssapi_userok(char *user)
1079+ssh_gssapi_userok(char *user, struct passwd *pw)
1080 {
1081 OM_uint32 lmin;
1082
1083@@ -337,9 +423,11 @@
1084 return 0;
1085 }
1086 if (gssapi_client.mech && gssapi_client.mech->userok)
1087- if ((*gssapi_client.mech->userok)(&gssapi_client, user))
1088+ if ((*gssapi_client.mech->userok)(&gssapi_client, user)) {
1089+ gssapi_client.used = 1;
1090+ gssapi_client.store.owner = pw;
1091 return 1;
1092- else {
1093+ } else {
1094 /* Destroy delegated credentials if userok fails */
1095 gss_release_buffer(&lmin, &gssapi_client.displayname);
1096 gss_release_buffer(&lmin, &gssapi_client.exportedname);
1097@@ -352,14 +440,90 @@
1098 return (0);
1099 }
1100
1101-/* Privileged */
1102-OM_uint32
1103-ssh_gssapi_checkmic(Gssctxt *ctx, gss_buffer_t gssbuf, gss_buffer_t gssmic)
1104+/* These bits are only used for rekeying. The unpriviledged child is running
1105+ * as the user, the monitor is root.
1106+ *
1107+ * In the child, we want to :
1108+ * *) Ask the monitor to store our credentials into the store we specify
1109+ * *) If it succeeds, maybe do a PAM update
1110+ */
1111+
1112+/* Stuff for PAM */
1113+
1114+#ifdef USE_PAM
1115+static int ssh_gssapi_simple_conv(int n, const struct pam_message **msg,
1116+ struct pam_response **resp, void *data)
1117 {
1118- ctx->major = gss_verify_mic(&ctx->minor, ctx->context,
1119- gssbuf, gssmic, NULL);
1120+ return (PAM_CONV_ERR);
1121+}
1122+#endif
1123
1124- return (ctx->major);
1125+void
1126+ssh_gssapi_rekey_creds() {
1127+ int ok;
1128+ int ret;
1129+#ifdef USE_PAM
1130+ pam_handle_t *pamh = NULL;
1131+ struct pam_conv pamconv = {ssh_gssapi_simple_conv, NULL};
1132+ char *envstr;
1133+#endif
1134+
1135+ if (gssapi_client.store.filename == NULL &&
1136+ gssapi_client.store.envval == NULL &&
1137+ gssapi_client.store.envvar == NULL)
1138+ return;
1139+
1140+ ok = PRIVSEP(ssh_gssapi_update_creds(&gssapi_client.store));
1141+
1142+ if (!ok)
1143+ return;
1144+
1145+ debug("Rekeyed credentials stored successfully");
1146+
1147+ /* Actually managing to play with the ssh pam stack from here will
1148+ * be next to impossible. In any case, we may want different options
1149+ * for rekeying. So, use our own :)
1150+ */
1151+#ifdef USE_PAM
1152+ if (!use_privsep) {
1153+ debug("Not even going to try and do PAM with privsep disabled");
1154+ return;
1155+ }
1156+
1157+ ret = pam_start("sshd-rekey", gssapi_client.store.owner->pw_name,
1158+ &pamconv, &pamh);
1159+ if (ret)
1160+ return;
1161+
1162+ xasprintf(&envstr, "%s=%s", gssapi_client.store.envvar,
1163+ gssapi_client.store.envval);
1164+
1165+ ret = pam_putenv(pamh, envstr);
1166+ if (!ret)
1167+ pam_setcred(pamh, PAM_REINITIALIZE_CRED);
1168+ pam_end(pamh, PAM_SUCCESS);
1169+#endif
1170+}
1171+
1172+int
1173+ssh_gssapi_update_creds(ssh_gssapi_ccache *store) {
1174+ int ok = 0;
1175+
1176+ /* Check we've got credentials to store */
1177+ if (!gssapi_client.updated)
1178+ return 0;
1179+
1180+ gssapi_client.updated = 0;
1181+
1182+ temporarily_use_uid(gssapi_client.store.owner);
1183+ if (gssapi_client.mech && gssapi_client.mech->updatecreds)
1184+ ok = (*gssapi_client.mech->updatecreds)(store, &gssapi_client);
1185+ else
1186+ debug("No update function for this mechanism");
1187+
1188+ restore_uid();
1189+
1190+ return ok;
1191 }
1192
1193 #endif
1194Index: b/kex.c
1195===================================================================
1196--- a/kex.c
1197+++ b/kex.c
1198@@ -49,6 +49,10 @@
1199 #include "dispatch.h"
1200 #include "monitor.h"
1201
1202+#ifdef GSSAPI
1203+#include "ssh-gss.h"
1204+#endif
1205+
1206 #if OPENSSL_VERSION_NUMBER >= 0x00907000L
1207 # if defined(HAVE_EVP_SHA256)
1208 # define evp_ssh_sha256 EVP_sha256
1209@@ -325,6 +329,20 @@
1210 k->kex_type = KEX_DH_GEX_SHA256;
1211 k->evp_md = evp_ssh_sha256();
1212 #endif
1213+#ifdef GSSAPI
1214+ } else if (strncmp(k->name, KEX_GSS_GEX_SHA1_ID,
1215+ sizeof(KEX_GSS_GEX_SHA1_ID) - 1) == 0) {
1216+ k->kex_type = KEX_GSS_GEX_SHA1;
1217+ k->evp_md = EVP_sha1();
1218+ } else if (strncmp(k->name, KEX_GSS_GRP1_SHA1_ID,
1219+ sizeof(KEX_GSS_GRP1_SHA1_ID) - 1) == 0) {
1220+ k->kex_type = KEX_GSS_GRP1_SHA1;
1221+ k->evp_md = EVP_sha1();
1222+ } else if (strncmp(k->name, KEX_GSS_GRP14_SHA1_ID,
1223+ sizeof(KEX_GSS_GRP14_SHA1_ID) - 1) == 0) {
1224+ k->kex_type = KEX_GSS_GRP14_SHA1;
1225+ k->evp_md = EVP_sha1();
1226+#endif
1227 } else
1228 fatal("bad kex alg %s", k->name);
1229 }
1230Index: b/kex.h
1231===================================================================
1232--- a/kex.h
1233+++ b/kex.h
1234@@ -66,6 +66,9 @@
1235 KEX_DH_GRP14_SHA1,
1236 KEX_DH_GEX_SHA1,
1237 KEX_DH_GEX_SHA256,
1238+ KEX_GSS_GRP1_SHA1,
1239+ KEX_GSS_GRP14_SHA1,
1240+ KEX_GSS_GEX_SHA1,
1241 KEX_MAX
1242 };
1243
1244@@ -121,6 +124,12 @@
1245 sig_atomic_t done;
1246 int flags;
1247 const EVP_MD *evp_md;
1248+#ifdef GSSAPI
1249+ int gss_deleg_creds;
1250+ int gss_trust_dns;
1251+ char *gss_host;
1252+ char *gss_client;
1253+#endif
1254 char *client_version_string;
1255 char *server_version_string;
1256 int (*verify_host_key)(Key *);
1257@@ -143,6 +152,11 @@
1258 void kexgex_client(Kex *);
1259 void kexgex_server(Kex *);
1260
1261+#ifdef GSSAPI
1262+void kexgss_client(Kex *);
1263+void kexgss_server(Kex *);
1264+#endif
1265+
1266 void
1267 kex_dh_hash(char *, char *, char *, int, char *, int, u_char *, int,
1268 BIGNUM *, BIGNUM *, BIGNUM *, u_char **, u_int *);
1269Index: b/kexgssc.c
1270===================================================================
1271--- /dev/null
1272+++ b/kexgssc.c
1273@@ -0,0 +1,334 @@
1274+/*
1275+ * Copyright (c) 2001-2009 Simon Wilkinson. All rights reserved.
1276+ *
1277+ * Redistribution and use in source and binary forms, with or without
1278+ * modification, are permitted provided that the following conditions
1279+ * are met:
1280+ * 1. Redistributions of source code must retain the above copyright
1281+ * notice, this list of conditions and the following disclaimer.
1282+ * 2. Redistributions in binary form must reproduce the above copyright
1283+ * notice, this list of conditions and the following disclaimer in the
1284+ * documentation and/or other materials provided with the distribution.
1285+ *
1286+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR `AS IS'' AND ANY EXPRESS OR
1287+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
1288+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
1289+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
1290+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
1291+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
1292+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
1293+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
1294+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
1295+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1296+ */
1297+
1298+#include "includes.h"
1299+
1300+#ifdef GSSAPI
1301+
1302+#include "includes.h"
1303+
1304+#include <openssl/crypto.h>
1305+#include <openssl/bn.h>
1306+
1307+#include <string.h>
1308+
1309+#include "xmalloc.h"
1310+#include "buffer.h"
1311+#include "ssh2.h"
1312+#include "key.h"
1313+#include "cipher.h"
1314+#include "kex.h"
1315+#include "log.h"
1316+#include "packet.h"
1317+#include "dh.h"
1318+
1319+#include "ssh-gss.h"
1320+
1321+void
1322+kexgss_client(Kex *kex) {
1323+ gss_buffer_desc send_tok = GSS_C_EMPTY_BUFFER;
1324+ gss_buffer_desc recv_tok, gssbuf, msg_tok, *token_ptr;
1325+ Gssctxt *ctxt;
1326+ OM_uint32 maj_status, min_status, ret_flags;
1327+ u_int klen, kout, slen = 0, hashlen, strlen;
1328+ DH *dh;
1329+ BIGNUM *dh_server_pub = NULL;
1330+ BIGNUM *shared_secret = NULL;
1331+ BIGNUM *p = NULL;
1332+ BIGNUM *g = NULL;
1333+ u_char *kbuf, *hash;
1334+ u_char *serverhostkey = NULL;
1335+ u_char *empty = "";
1336+ char *msg;
1337+ char *lang;
1338+ int type = 0;
1339+ int first = 1;
1340+ int nbits = 0, min = DH_GRP_MIN, max = DH_GRP_MAX;
1341+
1342+ /* Initialise our GSSAPI world */
1343+ ssh_gssapi_build_ctx(&ctxt);
1344+ if (ssh_gssapi_id_kex(ctxt, kex->name, kex->kex_type)
1345+ == GSS_C_NO_OID)
1346+ fatal("Couldn't identify host exchange");
1347+
1348+ if (ssh_gssapi_import_name(ctxt, kex->gss_host))
1349+ fatal("Couldn't import hostname");
1350+
1351+ if (kex->gss_client &&
1352+ ssh_gssapi_client_identity(ctxt, kex->gss_client))
1353+ fatal("Couldn't acquire client credentials");
1354+
1355+ switch (kex->kex_type) {
1356+ case KEX_GSS_GRP1_SHA1:
1357+ dh = dh_new_group1();
1358+ break;
1359+ case KEX_GSS_GRP14_SHA1:
1360+ dh = dh_new_group14();
1361+ break;
1362+ case KEX_GSS_GEX_SHA1:
1363+ debug("Doing group exchange\n");
1364+ nbits = dh_estimate(kex->we_need * 8);
1365+ packet_start(SSH2_MSG_KEXGSS_GROUPREQ);
1366+ packet_put_int(min);
1367+ packet_put_int(nbits);
1368+ packet_put_int(max);
1369+
1370+ packet_send();
1371+
1372+ packet_read_expect(SSH2_MSG_KEXGSS_GROUP);
1373+
1374+ if ((p = BN_new()) == NULL)
1375+ fatal("BN_new() failed");
1376+ packet_get_bignum2(p);
1377+ if ((g = BN_new()) == NULL)
1378+ fatal("BN_new() failed");
1379+ packet_get_bignum2(g);
1380+ packet_check_eom();
1381+
1382+ if (BN_num_bits(p) < min || BN_num_bits(p) > max)
1383+ fatal("GSSGRP_GEX group out of range: %d !< %d !< %d",
1384+ min, BN_num_bits(p), max);
1385+
1386+ dh = dh_new_group(g, p);
1387+ break;
1388+ default:
1389+ fatal("%s: Unexpected KEX type %d", __func__, kex->kex_type);
1390+ }
1391+
1392+ /* Step 1 - e is dh->pub_key */
1393+ dh_gen_key(dh, kex->we_need * 8);
1394+
1395+ /* This is f, we initialise it now to make life easier */
1396+ dh_server_pub = BN_new();
1397+ if (dh_server_pub == NULL)
1398+ fatal("dh_server_pub == NULL");
1399+
1400+ token_ptr = GSS_C_NO_BUFFER;
1401+
1402+ do {
1403+ debug("Calling gss_init_sec_context");
1404+
1405+ maj_status = ssh_gssapi_init_ctx(ctxt,
1406+ kex->gss_deleg_creds, token_ptr, &send_tok,
1407+ &ret_flags);
1408+
1409+ if (GSS_ERROR(maj_status)) {
1410+ if (send_tok.length != 0) {
1411+ packet_start(SSH2_MSG_KEXGSS_CONTINUE);
1412+ packet_put_string(send_tok.value,
1413+ send_tok.length);
1414+ }
1415+ fatal("gss_init_context failed");
1416+ }
1417+
1418+ /* If we've got an old receive buffer get rid of it */
1419+ if (token_ptr != GSS_C_NO_BUFFER)
1420+ xfree(recv_tok.value);
1421+
1422+ if (maj_status == GSS_S_COMPLETE) {
1423+ /* If mutual state flag is not true, kex fails */
1424+ if (!(ret_flags & GSS_C_MUTUAL_FLAG))
1425+ fatal("Mutual authentication failed");
1426+
1427+ /* If integ avail flag is not true kex fails */
1428+ if (!(ret_flags & GSS_C_INTEG_FLAG))
1429+ fatal("Integrity check failed");
1430+ }
1431+
1432+ /*
1433+ * If we have data to send, then the last message that we
1434+ * received cannot have been a 'complete'.
1435+ */
1436+ if (send_tok.length != 0) {
1437+ if (first) {
1438+ packet_start(SSH2_MSG_KEXGSS_INIT);
1439+ packet_put_string(send_tok.value,
1440+ send_tok.length);
1441+ packet_put_bignum2(dh->pub_key);
1442+ first = 0;
1443+ } else {
1444+ packet_start(SSH2_MSG_KEXGSS_CONTINUE);
1445+ packet_put_string(send_tok.value,
1446+ send_tok.length);
1447+ }
1448+ packet_send();
1449+ gss_release_buffer(&min_status, &send_tok);
1450+
1451+ /* If we've sent them data, they should reply */
1452+ do {
1453+ type = packet_read();
1454+ if (type == SSH2_MSG_KEXGSS_HOSTKEY) {
1455+ debug("Received KEXGSS_HOSTKEY");
1456+ if (serverhostkey)
1457+ fatal("Server host key received more than once");
1458+ serverhostkey =
1459+ packet_get_string(&slen);
1460+ }
1461+ } while (type == SSH2_MSG_KEXGSS_HOSTKEY);
1462+
1463+ switch (type) {
1464+ case SSH2_MSG_KEXGSS_CONTINUE:
1465+ debug("Received GSSAPI_CONTINUE");
1466+ if (maj_status == GSS_S_COMPLETE)
1467+ fatal("GSSAPI Continue received from server when complete");
1468+ recv_tok.value = packet_get_string(&strlen);
1469+ recv_tok.length = strlen;
1470+ break;
1471+ case SSH2_MSG_KEXGSS_COMPLETE:
1472+ debug("Received GSSAPI_COMPLETE");
1473+ packet_get_bignum2(dh_server_pub);
1474+ msg_tok.value = packet_get_string(&strlen);
1475+ msg_tok.length = strlen;
1476+
1477+ /* Is there a token included? */
1478+ if (packet_get_char()) {
1479+ recv_tok.value=
1480+ packet_get_string(&strlen);
1481+ recv_tok.length = strlen;
1482+ /* If we're already complete - protocol error */
1483+ if (maj_status == GSS_S_COMPLETE)
1484+ packet_disconnect("Protocol error: received token when complete");
1485+ } else {
1486+ /* No token included */
1487+ if (maj_status != GSS_S_COMPLETE)
1488+ packet_disconnect("Protocol error: did not receive final token");
1489+ }
1490+ break;
1491+ case SSH2_MSG_KEXGSS_ERROR:
1492+ debug("Received Error");
1493+ maj_status = packet_get_int();
1494+ min_status = packet_get_int();
1495+ msg = packet_get_string(NULL);
1496+ lang = packet_get_string(NULL);
1497+ fatal("GSSAPI Error: \n%.400s",msg);
1498+ default:
1499+ packet_disconnect("Protocol error: didn't expect packet type %d",
1500+ type);
1501+ }
1502+ token_ptr = &recv_tok;
1503+ } else {
1504+ /* No data, and not complete */
1505+ if (maj_status != GSS_S_COMPLETE)
1506+ fatal("Not complete, and no token output");
1507+ }
1508+ } while (maj_status & GSS_S_CONTINUE_NEEDED);
1509+
1510+ /*
1511+ * We _must_ have received a COMPLETE message in reply from the
1512+ * server, which will have set dh_server_pub and msg_tok
1513+ */
1514+
1515+ if (type != SSH2_MSG_KEXGSS_COMPLETE)
1516+ fatal("Didn't receive a SSH2_MSG_KEXGSS_COMPLETE when I expected it");
1517+
1518+ /* Check f in range [1, p-1] */
1519+ if (!dh_pub_is_valid(dh, dh_server_pub))
1520+ packet_disconnect("bad server public DH value");
1521+
1522+ /* compute K=f^x mod p */
1523+ klen = DH_size(dh);
1524+ kbuf = xmalloc(klen);
1525+ kout = DH_compute_key(kbuf, dh_server_pub, dh);
1526+ if (kout < 0)
1527+ fatal("DH_compute_key: failed");
1528+
1529+ shared_secret = BN_new();
1530+ if (shared_secret == NULL)
1531+ fatal("kexgss_client: BN_new failed");
1532+
1533+ if (BN_bin2bn(kbuf, kout, shared_secret) == NULL)
1534+ fatal("kexdh_client: BN_bin2bn failed");
1535+
1536+ memset(kbuf, 0, klen);
1537+ xfree(kbuf);
1538+
1539+ switch (kex->kex_type) {
1540+ case KEX_GSS_GRP1_SHA1:
1541+ case KEX_GSS_GRP14_SHA1:
1542+ kex_dh_hash( kex->client_version_string,
1543+ kex->server_version_string,
1544+ buffer_ptr(&kex->my), buffer_len(&kex->my),
1545+ buffer_ptr(&kex->peer), buffer_len(&kex->peer),
1546+ (serverhostkey ? serverhostkey : empty), slen,
1547+ dh->pub_key, /* e */
1548+ dh_server_pub, /* f */
1549+ shared_secret, /* K */
1550+ &hash, &hashlen
1551+ );
1552+ break;
1553+ case KEX_GSS_GEX_SHA1:
1554+ kexgex_hash(
1555+ kex->evp_md,
1556+ kex->client_version_string,
1557+ kex->server_version_string,
1558+ buffer_ptr(&kex->my), buffer_len(&kex->my),
1559+ buffer_ptr(&kex->peer), buffer_len(&kex->peer),
1560+ (serverhostkey ? serverhostkey : empty), slen,
1561+ min, nbits, max,
1562+ dh->p, dh->g,
1563+ dh->pub_key,
1564+ dh_server_pub,
1565+ shared_secret,
1566+ &hash, &hashlen
1567+ );
1568+ break;
1569+ default:
1570+ fatal("%s: Unexpected KEX type %d", __func__, kex->kex_type);
1571+ }
1572+
1573+ gssbuf.value = hash;
1574+ gssbuf.length = hashlen;
1575+
1576+ /* Verify that the hash matches the MIC we just got. */
1577+ if (GSS_ERROR(ssh_gssapi_checkmic(ctxt, &gssbuf, &msg_tok)))
1578+ packet_disconnect("Hash's MIC didn't verify");
1579+
1580+ xfree(msg_tok.value);
1581+
1582+ DH_free(dh);
1583+ if (serverhostkey)
1584+ xfree(serverhostkey);
1585+ BN_clear_free(dh_server_pub);
1586+
1587+ /* save session id */
1588+ if (kex->session_id == NULL) {
1589+ kex->session_id_len = hashlen;
1590+ kex->session_id = xmalloc(kex->session_id_len);
1591+ memcpy(kex->session_id, hash, kex->session_id_len);
1592+ }
1593+
1594+ if (kex->gss_deleg_creds)
1595+ ssh_gssapi_credentials_updated(ctxt);
1596+
1597+ if (gss_kex_context == NULL)
1598+ gss_kex_context = ctxt;
1599+ else
1600+ ssh_gssapi_delete_ctx(&ctxt);
1601+
1602+ kex_derive_keys(kex, hash, hashlen, shared_secret);
1603+ BN_clear_free(shared_secret);
1604+ kex_finish(kex);
1605+}
1606+
1607+#endif /* GSSAPI */
1608Index: b/kexgsss.c
1609===================================================================
1610--- /dev/null
1611+++ b/kexgsss.c
1612@@ -0,0 +1,288 @@
1613+/*
1614+ * Copyright (c) 2001-2009 Simon Wilkinson. All rights reserved.
1615+ *
1616+ * Redistribution and use in source and binary forms, with or without
1617+ * modification, are permitted provided that the following conditions
1618+ * are met:
1619+ * 1. Redistributions of source code must retain the above copyright
1620+ * notice, this list of conditions and the following disclaimer.
1621+ * 2. Redistributions in binary form must reproduce the above copyright
1622+ * notice, this list of conditions and the following disclaimer in the
1623+ * documentation and/or other materials provided with the distribution.
1624+ *
1625+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR `AS IS'' AND ANY EXPRESS OR
1626+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
1627+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
1628+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
1629+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
1630+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
1631+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
1632+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
1633+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
1634+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1635+ */
1636+
1637+#include "includes.h"
1638+
1639+#ifdef GSSAPI
1640+
1641+#include <string.h>
1642+
1643+#include <openssl/crypto.h>
1644+#include <openssl/bn.h>
1645+
1646+#include "xmalloc.h"
1647+#include "buffer.h"
1648+#include "ssh2.h"
1649+#include "key.h"
1650+#include "cipher.h"
1651+#include "kex.h"
1652+#include "log.h"
1653+#include "packet.h"
1654+#include "dh.h"
1655+#include "ssh-gss.h"
1656+#include "monitor_wrap.h"
1657+#include "servconf.h"
1658+
1659+extern ServerOptions options;
1660+
1661+void
1662+kexgss_server(Kex *kex)
1663+{
1664+ OM_uint32 maj_status, min_status;
1665+
1666+ /*
1667+ * Some GSSAPI implementations use the input value of ret_flags (an
1668+ * output variable) as a means of triggering mechanism specific
1669+ * features. Initializing it to zero avoids inadvertently
1670+ * activating this non-standard behaviour.
1671+ */
1672+
1673+ OM_uint32 ret_flags = 0;
1674+ gss_buffer_desc gssbuf, recv_tok, msg_tok;
1675+ gss_buffer_desc send_tok = GSS_C_EMPTY_BUFFER;
1676+ Gssctxt *ctxt = NULL;
1677+ u_int slen, klen, kout, hashlen;
1678+ u_char *kbuf, *hash;
1679+ DH *dh;
1680+ int min = -1, max = -1, nbits = -1;
1681+ BIGNUM *shared_secret = NULL;
1682+ BIGNUM *dh_client_pub = NULL;
1683+ int type = 0;
1684+ gss_OID oid;
1685+ char *mechs;
1686+
1687+ /* Initialise GSSAPI */
1688+
1689+ /* If we're rekeying, privsep means that some of the private structures
1690+ * in the GSSAPI code are no longer available. This kludges them back
1691+ * into life
1692+ */
1693+ if (!ssh_gssapi_oid_table_ok())
1694+ if ((mechs = ssh_gssapi_server_mechanisms()))
1695+ xfree(mechs);
1696+
1697+ debug2("%s: Identifying %s", __func__, kex->name);
1698+ oid = ssh_gssapi_id_kex(NULL, kex->name, kex->kex_type);
1699+ if (oid == GSS_C_NO_OID)
1700+ fatal("Unknown gssapi mechanism");
1701+
1702+ debug2("%s: Acquiring credentials", __func__);
1703+
1704+ if (GSS_ERROR(PRIVSEP(ssh_gssapi_server_ctx(&ctxt, oid))))
1705+ fatal("Unable to acquire credentials for the server");
1706+
1707+ switch (kex->kex_type) {
1708+ case KEX_GSS_GRP1_SHA1:
1709+ dh = dh_new_group1();
1710+ break;
1711+ case KEX_GSS_GRP14_SHA1:
1712+ dh = dh_new_group14();
1713+ break;
1714+ case KEX_GSS_GEX_SHA1:
1715+ debug("Doing group exchange");
1716+ packet_read_expect(SSH2_MSG_KEXGSS_GROUPREQ);
1717+ min = packet_get_int();
1718+ nbits = packet_get_int();
1719+ max = packet_get_int();
1720+ min = MAX(DH_GRP_MIN, min);
1721+ max = MIN(DH_GRP_MAX, max);
1722+ packet_check_eom();
1723+ if (max < min || nbits < min || max < nbits)
1724+ fatal("GSS_GEX, bad parameters: %d !< %d !< %d",
1725+ min, nbits, max);
1726+ dh = PRIVSEP(choose_dh(min, nbits, max));
1727+ if (dh == NULL)
1728+ packet_disconnect("Protocol error: no matching group found");
1729+
1730+ packet_start(SSH2_MSG_KEXGSS_GROUP);
1731+ packet_put_bignum2(dh->p);
1732+ packet_put_bignum2(dh->g);
1733+ packet_send();
1734+
1735+ packet_write_wait();
1736+ break;
1737+ default:
1738+ fatal("%s: Unexpected KEX type %d", __func__, kex->kex_type);
1739+ }
1740+
1741+ dh_gen_key(dh, kex->we_need * 8);
1742+
1743+ do {
1744+ debug("Wait SSH2_MSG_GSSAPI_INIT");
1745+ type = packet_read();
1746+ switch(type) {
1747+ case SSH2_MSG_KEXGSS_INIT:
1748+ if (dh_client_pub != NULL)
1749+ fatal("Received KEXGSS_INIT after initialising");
1750+ recv_tok.value = packet_get_string(&slen);
1751+ recv_tok.length = slen;
1752+
1753+ if ((dh_client_pub = BN_new()) == NULL)
1754+ fatal("dh_client_pub == NULL");
1755+
1756+ packet_get_bignum2(dh_client_pub);
1757+
1758+ /* Send SSH_MSG_KEXGSS_HOSTKEY here, if we want */
1759+ break;
1760+ case SSH2_MSG_KEXGSS_CONTINUE:
1761+ recv_tok.value = packet_get_string(&slen);
1762+ recv_tok.length = slen;
1763+ break;
1764+ default:
1765+ packet_disconnect(
1766+ "Protocol error: didn't expect packet type %d",
1767+ type);
1768+ }
1769+
1770+ maj_status = PRIVSEP(ssh_gssapi_accept_ctx(ctxt, &recv_tok,
1771+ &send_tok, &ret_flags));
1772+
1773+ xfree(recv_tok.value);
1774+
1775+ if (maj_status != GSS_S_COMPLETE && send_tok.length == 0)
1776+ fatal("Zero length token output when incomplete");
1777+
1778+ if (dh_client_pub == NULL)
1779+ fatal("No client public key");
1780+
1781+ if (maj_status & GSS_S_CONTINUE_NEEDED) {
1782+ debug("Sending GSSAPI_CONTINUE");
1783+ packet_start(SSH2_MSG_KEXGSS_CONTINUE);
1784+ packet_put_string(send_tok.value, send_tok.length);
1785+ packet_send();
1786+ gss_release_buffer(&min_status, &send_tok);
1787+ }
1788+ } while (maj_status & GSS_S_CONTINUE_NEEDED);
1789+
1790+ if (GSS_ERROR(maj_status)) {
1791+ if (send_tok.length > 0) {
1792+ packet_start(SSH2_MSG_KEXGSS_CONTINUE);
1793+ packet_put_string(send_tok.value, send_tok.length);
1794+ packet_send();
1795+ }
1796+ fatal("accept_ctx died");
1797+ }
1798+
1799+ if (!(ret_flags & GSS_C_MUTUAL_FLAG))
1800+ fatal("Mutual Authentication flag wasn't set");
1801+
1802+ if (!(ret_flags & GSS_C_INTEG_FLAG))
1803+ fatal("Integrity flag wasn't set");
1804+
1805+ if (!dh_pub_is_valid(dh, dh_client_pub))
1806+ packet_disconnect("bad client public DH value");
1807+
1808+ klen = DH_size(dh);
1809+ kbuf = xmalloc(klen);
1810+ kout = DH_compute_key(kbuf, dh_client_pub, dh);
1811+ if (kout < 0)
1812+ fatal("DH_compute_key: failed");
1813+
1814+ shared_secret = BN_new();
1815+ if (shared_secret == NULL)
1816+ fatal("kexgss_server: BN_new failed");
1817+
1818+ if (BN_bin2bn(kbuf, kout, shared_secret) == NULL)
1819+ fatal("kexgss_server: BN_bin2bn failed");
1820+
1821+ memset(kbuf, 0, klen);
1822+ xfree(kbuf);
1823+
1824+ switch (kex->kex_type) {
1825+ case KEX_GSS_GRP1_SHA1:
1826+ case KEX_GSS_GRP14_SHA1:
1827+ kex_dh_hash(
1828+ kex->client_version_string, kex->server_version_string,
1829+ buffer_ptr(&kex->peer), buffer_len(&kex->peer),
1830+ buffer_ptr(&kex->my), buffer_len(&kex->my),
1831+ NULL, 0, /* Change this if we start sending host keys */
1832+ dh_client_pub, dh->pub_key, shared_secret,
1833+ &hash, &hashlen
1834+ );
1835+ break;
1836+ case KEX_GSS_GEX_SHA1:
1837+ kexgex_hash(
1838+ kex->evp_md,
1839+ kex->client_version_string, kex->server_version_string,
1840+ buffer_ptr(&kex->peer), buffer_len(&kex->peer),
1841+ buffer_ptr(&kex->my), buffer_len(&kex->my),
1842+ NULL, 0,
1843+ min, nbits, max,
1844+ dh->p, dh->g,
1845+ dh_client_pub,
1846+ dh->pub_key,
1847+ shared_secret,
1848+ &hash, &hashlen
1849+ );
1850+ break;
1851+ default:
1852+ fatal("%s: Unexpected KEX type %d", __func__, kex->kex_type);
1853+ }
1854+
1855+ BN_clear_free(dh_client_pub);
1856+
1857+ if (kex->session_id == NULL) {
1858+ kex->session_id_len = hashlen;
1859+ kex->session_id = xmalloc(kex->session_id_len);
1860+ memcpy(kex->session_id, hash, kex->session_id_len);
1861+ }
1862+
1863+ gssbuf.value = hash;
1864+ gssbuf.length = hashlen;
1865+
1866+ if (GSS_ERROR(PRIVSEP(ssh_gssapi_sign(ctxt,&gssbuf,&msg_tok))))
1867+ fatal("Couldn't get MIC");
1868+
1869+ packet_start(SSH2_MSG_KEXGSS_COMPLETE);
1870+ packet_put_bignum2(dh->pub_key);
1871+ packet_put_string(msg_tok.value,msg_tok.length);
1872+
1873+ if (send_tok.length != 0) {
1874+ packet_put_char(1); /* true */
1875+ packet_put_string(send_tok.value, send_tok.length);
1876+ } else {
1877+ packet_put_char(0); /* false */
1878+ }
1879+ packet_send();
1880+
1881+ gss_release_buffer(&min_status, &send_tok);
1882+ gss_release_buffer(&min_status, &msg_tok);
1883+
1884+ if (gss_kex_context == NULL)
1885+ gss_kex_context = ctxt;
1886+ else
1887+ ssh_gssapi_delete_ctx(&ctxt);
1888+
1889+ DH_free(dh);
1890+
1891+ kex_derive_keys(kex, hash, hashlen, shared_secret);
1892+ BN_clear_free(shared_secret);
1893+ kex_finish(kex);
1894+
1895+ /* If this was a rekey, then save out any delegated credentials we
1896+ * just exchanged. */
1897+ if (options.gss_store_rekey)
1898+ ssh_gssapi_rekey_creds();
1899+}
1900+#endif /* GSSAPI */
1901Index: b/key.c
1902===================================================================
1903--- a/key.c
1904+++ b/key.c
1905@@ -764,6 +764,8 @@
1906 return KEY_RSA;
1907 } else if (strcmp(name, "ssh-dss") == 0) {
1908 return KEY_DSA;
1909+ } else if (strcmp(name, "null") == 0) {
1910+ return KEY_NULL;
1911 }
1912 debug2("key_type_from_name: unknown key type '%s'", name);
1913 return KEY_UNSPEC;
1914Index: b/key.h
1915===================================================================
1916--- a/key.h
1917+++ b/key.h
1918@@ -34,6 +34,7 @@
1919 KEY_RSA1,
1920 KEY_RSA,
1921 KEY_DSA,
1922+ KEY_NULL,
1923 KEY_UNSPEC
1924 };
1925 enum fp_type {
1926Index: b/monitor.c
1927===================================================================
1928--- a/monitor.c
1929+++ b/monitor.c
1930@@ -172,6 +172,8 @@
1931 int mm_answer_gss_accept_ctx(int, Buffer *);
1932 int mm_answer_gss_userok(int, Buffer *);
1933 int mm_answer_gss_checkmic(int, Buffer *);
1934+int mm_answer_gss_sign(int, Buffer *);
1935+int mm_answer_gss_updatecreds(int, Buffer *);
1936 #endif
1937
1938 #ifdef SSH_AUDIT_EVENTS
1939@@ -241,6 +243,7 @@
1940 {MONITOR_REQ_GSSSTEP, MON_ISAUTH, mm_answer_gss_accept_ctx},
1941 {MONITOR_REQ_GSSUSEROK, MON_AUTH, mm_answer_gss_userok},
1942 {MONITOR_REQ_GSSCHECKMIC, MON_ISAUTH, mm_answer_gss_checkmic},
1943+ {MONITOR_REQ_GSSSIGN, MON_ONCE, mm_answer_gss_sign},
1944 #endif
1945 #ifdef JPAKE
1946 {MONITOR_REQ_JPAKE_GET_PWDATA, MON_ONCE, mm_answer_jpake_get_pwdata},
1947@@ -253,6 +256,12 @@
1948 };
1949
1950 struct mon_table mon_dispatch_postauth20[] = {
1951+#ifdef GSSAPI
1952+ {MONITOR_REQ_GSSSETUP, 0, mm_answer_gss_setup_ctx},
1953+ {MONITOR_REQ_GSSSTEP, 0, mm_answer_gss_accept_ctx},
1954+ {MONITOR_REQ_GSSSIGN, 0, mm_answer_gss_sign},
1955+ {MONITOR_REQ_GSSUPCREDS, 0, mm_answer_gss_updatecreds},
1956+#endif
1957 {MONITOR_REQ_MODULI, 0, mm_answer_moduli},
1958 {MONITOR_REQ_SIGN, 0, mm_answer_sign},
1959 {MONITOR_REQ_PTY, 0, mm_answer_pty},
1960@@ -357,6 +366,10 @@
1961 /* Permit requests for moduli and signatures */
1962 monitor_permit(mon_dispatch, MONITOR_REQ_MODULI, 1);
1963 monitor_permit(mon_dispatch, MONITOR_REQ_SIGN, 1);
1964+#ifdef GSSAPI
1965+ /* and for the GSSAPI key exchange */
1966+ monitor_permit(mon_dispatch, MONITOR_REQ_GSSSETUP, 1);
1967+#endif
1968 } else {
1969 mon_dispatch = mon_dispatch_proto15;
1970
1971@@ -443,6 +456,10 @@
1972 monitor_permit(mon_dispatch, MONITOR_REQ_MODULI, 1);
1973 monitor_permit(mon_dispatch, MONITOR_REQ_SIGN, 1);
1974 monitor_permit(mon_dispatch, MONITOR_REQ_TERM, 1);
1975+#ifdef GSSAPI
1976+ /* and for the GSSAPI key exchange */
1977+ monitor_permit(mon_dispatch, MONITOR_REQ_GSSSETUP, 1);
1978+#endif
1979 } else {
1980 mon_dispatch = mon_dispatch_postauth15;
1981 monitor_permit(mon_dispatch, MONITOR_REQ_TERM, 1);
1982@@ -1706,6 +1723,13 @@
1983 kex->kex[KEX_DH_GRP14_SHA1] = kexdh_server;
1984 kex->kex[KEX_DH_GEX_SHA1] = kexgex_server;
1985 kex->kex[KEX_DH_GEX_SHA256] = kexgex_server;
1986+#ifdef GSSAPI
1987+ if (options.gss_keyex) {
1988+ kex->kex[KEX_GSS_GRP1_SHA1] = kexgss_server;
1989+ kex->kex[KEX_GSS_GRP14_SHA1] = kexgss_server;
1990+ kex->kex[KEX_GSS_GEX_SHA1] = kexgss_server;
1991+ }
1992+#endif
1993 kex->server = 1;
1994 kex->hostkey_type = buffer_get_int(m);
1995 kex->kex_type = buffer_get_int(m);
1996@@ -1911,6 +1935,9 @@
1997 OM_uint32 major;
1998 u_int len;
1999
2000+ if (!options.gss_authentication && !options.gss_keyex)
2001+ fatal("In GSSAPI monitor when GSSAPI is disabled");
2002+
2003 goid.elements = buffer_get_string(m, &len);
2004 goid.length = len;
2005
2006@@ -1938,6 +1965,9 @@
2007 OM_uint32 flags = 0; /* GSI needs this */
2008 u_int len;
2009
2010+ if (!options.gss_authentication && !options.gss_keyex)
2011+ fatal("In GSSAPI monitor when GSSAPI is disabled");
2012+
2013 in.value = buffer_get_string(m, &len);
2014 in.length = len;
2015 major = ssh_gssapi_accept_ctx(gsscontext, &in, &out, &flags);
2016@@ -1955,6 +1985,7 @@
2017 monitor_permit(mon_dispatch, MONITOR_REQ_GSSSTEP, 0);
2018 monitor_permit(mon_dispatch, MONITOR_REQ_GSSUSEROK, 1);
2019 monitor_permit(mon_dispatch, MONITOR_REQ_GSSCHECKMIC, 1);
2020+ monitor_permit(mon_dispatch, MONITOR_REQ_GSSSIGN, 1);
2021 }
2022 return (0);
2023 }
2024@@ -1966,6 +1997,9 @@
2025 OM_uint32 ret;
2026 u_int len;
2027
2028+ if (!options.gss_authentication && !options.gss_keyex)
2029+ fatal("In GSSAPI monitor when GSSAPI is disabled");
2030+
2031 gssbuf.value = buffer_get_string(m, &len);
2032 gssbuf.length = len;
2033 mic.value = buffer_get_string(m, &len);
2034@@ -1992,7 +2026,11 @@
2035 {
2036 int authenticated;
2037
2038- authenticated = authctxt->valid && ssh_gssapi_userok(authctxt->user);
2039+ if (!options.gss_authentication && !options.gss_keyex)
2040+ fatal("In GSSAPI monitor when GSSAPI is disabled");
2041+
2042+ authenticated = authctxt->valid &&
2043+ ssh_gssapi_userok(authctxt->user, authctxt->pw);
2044
2045 buffer_clear(m);
2046 buffer_put_int(m, authenticated);
2047@@ -2005,6 +2043,74 @@
2048 /* Monitor loop will terminate if authenticated */
2049 return (authenticated);
2050 }
2051+
2052+int
2053+mm_answer_gss_sign(int socket, Buffer *m)
2054+{
2055+ gss_buffer_desc data;
2056+ gss_buffer_desc hash = GSS_C_EMPTY_BUFFER;
2057+ OM_uint32 major, minor;
2058+ u_int len;
2059+
2060+ if (!options.gss_authentication && !options.gss_keyex)
2061+ fatal("In GSSAPI monitor when GSSAPI is disabled");
2062+
2063+ data.value = buffer_get_string(m, &len);
2064+ data.length = len;
2065+ if (data.length != 20)
2066+ fatal("%s: data length incorrect: %d", __func__,
2067+ (int) data.length);
2068+
2069+ /* Save the session ID on the first time around */
2070+ if (session_id2_len == 0) {
2071+ session_id2_len = data.length;
2072+ session_id2 = xmalloc(session_id2_len);
2073+ memcpy(session_id2, data.value, session_id2_len);
2074+ }
2075+ major = ssh_gssapi_sign(gsscontext, &data, &hash);
2076+
2077+ xfree(data.value);
2078+
2079+ buffer_clear(m);
2080+ buffer_put_int(m, major);
2081+ buffer_put_string(m, hash.value, hash.length);
2082+
2083+ mm_request_send(socket, MONITOR_ANS_GSSSIGN, m);
2084+
2085+ gss_release_buffer(&minor, &hash);
2086+
2087+ /* Turn on getpwnam permissions */
2088+ monitor_permit(mon_dispatch, MONITOR_REQ_PWNAM, 1);
2089+
2090+ /* And credential updating, for when rekeying */
2091+ monitor_permit(mon_dispatch, MONITOR_REQ_GSSUPCREDS, 1);
2092+
2093+ return (0);
2094+}
2095+
2096+int
2097+mm_answer_gss_updatecreds(int socket, Buffer *m) {
2098+ ssh_gssapi_ccache store;
2099+ int ok;
2100+
2101+ store.filename = buffer_get_string(m, NULL);
2102+ store.envvar = buffer_get_string(m, NULL);
2103+ store.envval = buffer_get_string(m, NULL);
2104+
2105+ ok = ssh_gssapi_update_creds(&store);
2106+
2107+ xfree(store.filename);
2108+ xfree(store.envvar);
2109+ xfree(store.envval);
2110+
2111+ buffer_clear(m);
2112+ buffer_put_int(m, ok);
2113+
2114+ mm_request_send(socket, MONITOR_ANS_GSSUPCREDS, m);
2115+
2116+ return(0);
2117+}
2118+
2119 #endif /* GSSAPI */
2120
2121 #ifdef JPAKE
2122Index: b/monitor.h
2123===================================================================
2124--- a/monitor.h
2125+++ b/monitor.h
2126@@ -53,6 +53,8 @@
2127 MONITOR_REQ_GSSSTEP, MONITOR_ANS_GSSSTEP,
2128 MONITOR_REQ_GSSUSEROK, MONITOR_ANS_GSSUSEROK,
2129 MONITOR_REQ_GSSCHECKMIC, MONITOR_ANS_GSSCHECKMIC,
2130+ MONITOR_REQ_GSSSIGN, MONITOR_ANS_GSSSIGN,
2131+ MONITOR_REQ_GSSUPCREDS, MONITOR_ANS_GSSUPCREDS,
2132 MONITOR_REQ_PAM_START,
2133 MONITOR_REQ_PAM_ACCOUNT, MONITOR_ANS_PAM_ACCOUNT,
2134 MONITOR_REQ_PAM_INIT_CTX, MONITOR_ANS_PAM_INIT_CTX,
2135Index: b/monitor_wrap.c
2136===================================================================
2137--- a/monitor_wrap.c
2138+++ b/monitor_wrap.c
2139@@ -1248,7 +1248,7 @@
2140 }
2141
2142 int
2143-mm_ssh_gssapi_userok(char *user)
2144+mm_ssh_gssapi_userok(char *user, struct passwd *pw)
2145 {
2146 Buffer m;
2147 int authenticated = 0;
2148@@ -1265,6 +1265,51 @@
2149 debug3("%s: user %sauthenticated",__func__, authenticated ? "" : "not ");
2150 return (authenticated);
2151 }
2152+
2153+OM_uint32
2154+mm_ssh_gssapi_sign(Gssctxt *ctx, gss_buffer_desc *data, gss_buffer_desc *hash)
2155+{
2156+ Buffer m;
2157+ OM_uint32 major;
2158+ u_int len;
2159+
2160+ buffer_init(&m);
2161+ buffer_put_string(&m, data->value, data->length);
2162+
2163+ mm_request_send(pmonitor->m_recvfd, MONITOR_REQ_GSSSIGN, &m);
2164+ mm_request_receive_expect(pmonitor->m_recvfd, MONITOR_ANS_GSSSIGN, &m);
2165+
2166+ major = buffer_get_int(&m);
2167+ hash->value = buffer_get_string(&m, &len);
2168+ hash->length = len;
2169+
2170+ buffer_free(&m);
2171+
2172+ return(major);
2173+}
2174+
2175+int
2176+mm_ssh_gssapi_update_creds(ssh_gssapi_ccache *store)
2177+{
2178+ Buffer m;
2179+ int ok;
2180+
2181+ buffer_init(&m);
2182+
2183+ buffer_put_cstring(&m, store->filename ? store->filename : "");
2184+ buffer_put_cstring(&m, store->envvar ? store->envvar : "");
2185+ buffer_put_cstring(&m, store->envval ? store->envval : "");
2186+
2187+ mm_request_send(pmonitor->m_recvfd, MONITOR_REQ_GSSUPCREDS, &m);
2188+ mm_request_receive_expect(pmonitor->m_recvfd, MONITOR_ANS_GSSUPCREDS, &m);
2189+
2190+ ok = buffer_get_int(&m);
2191+
2192+ buffer_free(&m);
2193+
2194+ return (ok);
2195+}
2196+
2197 #endif /* GSSAPI */
2198
2199 #ifdef JPAKE
2200Index: b/monitor_wrap.h
2201===================================================================
2202--- a/monitor_wrap.h
2203+++ b/monitor_wrap.h
2204@@ -57,8 +57,10 @@
2205 OM_uint32 mm_ssh_gssapi_server_ctx(Gssctxt **, gss_OID);
2206 OM_uint32 mm_ssh_gssapi_accept_ctx(Gssctxt *,
2207 gss_buffer_desc *, gss_buffer_desc *, OM_uint32 *);
2208-int mm_ssh_gssapi_userok(char *user);
2209+int mm_ssh_gssapi_userok(char *user, struct passwd *);
2210 OM_uint32 mm_ssh_gssapi_checkmic(Gssctxt *, gss_buffer_t, gss_buffer_t);
2211+OM_uint32 mm_ssh_gssapi_sign(Gssctxt *, gss_buffer_t, gss_buffer_t);
2212+int mm_ssh_gssapi_update_creds(ssh_gssapi_ccache *);
2213 #endif
2214
2215 #ifdef USE_PAM
2216Index: b/readconf.c
2217===================================================================
2218--- a/readconf.c
2219+++ b/readconf.c
2220@@ -127,6 +127,7 @@
2221 oClearAllForwardings, oNoHostAuthenticationForLocalhost,
2222 oEnableSSHKeysign, oRekeyLimit, oVerifyHostKeyDNS, oConnectTimeout,
2223 oAddressFamily, oGssAuthentication, oGssDelegateCreds,
2224+ oGssTrustDns, oGssKeyEx, oGssClientIdentity, oGssRenewalRekey,
2225 oServerAliveInterval, oServerAliveCountMax, oIdentitiesOnly,
2226 oSendEnv, oControlPath, oControlMaster, oHashKnownHosts,
2227 oTunnel, oTunnelDevice, oLocalCommand, oPermitLocalCommand,
2228@@ -164,10 +165,18 @@
2229 { "afstokenpassing", oUnsupported },
2230 #if defined(GSSAPI)
2231 { "gssapiauthentication", oGssAuthentication },
2232+ { "gssapikeyexchange", oGssKeyEx },
2233 { "gssapidelegatecredentials", oGssDelegateCreds },
2234+ { "gssapitrustdns", oGssTrustDns },
2235+ { "gssapiclientidentity", oGssClientIdentity },
2236+ { "gssapirenewalforcesrekey", oGssRenewalRekey },
2237 #else
2238 { "gssapiauthentication", oUnsupported },
2239+ { "gssapikeyexchange", oUnsupported },
2240 { "gssapidelegatecredentials", oUnsupported },
2241+ { "gssapitrustdns", oUnsupported },
2242+ { "gssapiclientidentity", oUnsupported },
2243+ { "gssapirenewalforcesrekey", oUnsupported },
2244 #endif
2245 { "fallbacktorsh", oDeprecated },
2246 { "usersh", oDeprecated },
2247@@ -454,10 +463,26 @@
2248 intptr = &options->gss_authentication;
2249 goto parse_flag;
2250
2251+ case oGssKeyEx:
2252+ intptr = &options->gss_keyex;
2253+ goto parse_flag;
2254+
2255 case oGssDelegateCreds:
2256 intptr = &options->gss_deleg_creds;
2257 goto parse_flag;
2258
2259+ case oGssTrustDns:
2260+ intptr = &options->gss_trust_dns;
2261+ goto parse_flag;
2262+
2263+ case oGssClientIdentity:
2264+ charptr = &options->gss_client_identity;
2265+ goto parse_string;
2266+
2267+ case oGssRenewalRekey:
2268+ intptr = &options->gss_renewal_rekey;
2269+ goto parse_flag;
2270+
2271 case oBatchMode:
2272 intptr = &options->batch_mode;
2273 goto parse_flag;
2274@@ -1013,7 +1038,11 @@
2275 options->pubkey_authentication = -1;
2276 options->challenge_response_authentication = -1;
2277 options->gss_authentication = -1;
2278+ options->gss_keyex = -1;
2279 options->gss_deleg_creds = -1;
2280+ options->gss_trust_dns = -1;
2281+ options->gss_renewal_rekey = -1;
2282+ options->gss_client_identity = NULL;
2283 options->password_authentication = -1;
2284 options->kbd_interactive_authentication = -1;
2285 options->kbd_interactive_devices = NULL;
2286@@ -1105,8 +1134,14 @@
2287 options->challenge_response_authentication = 1;
2288 if (options->gss_authentication == -1)
2289 options->gss_authentication = 0;
2290+ if (options->gss_keyex == -1)
2291+ options->gss_keyex = 0;
2292 if (options->gss_deleg_creds == -1)
2293 options->gss_deleg_creds = 0;
2294+ if (options->gss_trust_dns == -1)
2295+ options->gss_trust_dns = 0;
2296+ if (options->gss_renewal_rekey == -1)
2297+ options->gss_renewal_rekey = 0;
2298 if (options->password_authentication == -1)
2299 options->password_authentication = 1;
2300 if (options->kbd_interactive_authentication == -1)
2301Index: b/readconf.h
2302===================================================================
2303--- a/readconf.h
2304+++ b/readconf.h
2305@@ -44,7 +44,11 @@
2306 int challenge_response_authentication;
2307 /* Try S/Key or TIS, authentication. */
2308 int gss_authentication; /* Try GSS authentication */
2309+ int gss_keyex; /* Try GSS key exchange */
2310 int gss_deleg_creds; /* Delegate GSS credentials */
2311+ int gss_trust_dns; /* Trust DNS for GSS canonicalization */
2312+ int gss_renewal_rekey; /* Credential renewal forces rekey */
2313+ char *gss_client_identity; /* Principal to initiate GSSAPI with */
2314 int password_authentication; /* Try password
2315 * authentication. */
2316 int kbd_interactive_authentication; /* Try keyboard-interactive auth. */
2317Index: b/servconf.c
2318===================================================================
2319--- a/servconf.c
2320+++ b/servconf.c
2321@@ -92,7 +92,10 @@
2322 options->kerberos_ticket_cleanup = -1;
2323 options->kerberos_get_afs_token = -1;
2324 options->gss_authentication=-1;
2325+ options->gss_keyex = -1;
2326 options->gss_cleanup_creds = -1;
2327+ options->gss_strict_acceptor = -1;
2328+ options->gss_store_rekey = -1;
2329 options->password_authentication = -1;
2330 options->kbd_interactive_authentication = -1;
2331 options->challenge_response_authentication = -1;
2332@@ -210,8 +213,14 @@
2333 options->kerberos_get_afs_token = 0;
2334 if (options->gss_authentication == -1)
2335 options->gss_authentication = 0;
2336+ if (options->gss_keyex == -1)
2337+ options->gss_keyex = 0;
2338 if (options->gss_cleanup_creds == -1)
2339 options->gss_cleanup_creds = 1;
2340+ if (options->gss_strict_acceptor == -1)
2341+ options->gss_strict_acceptor = 1;
2342+ if (options->gss_store_rekey == -1)
2343+ options->gss_store_rekey = 0;
2344 if (options->password_authentication == -1)
2345 options->password_authentication = 1;
2346 if (options->kbd_interactive_authentication == -1)
2347@@ -302,7 +311,9 @@
2348 sBanner, sUseDNS, sHostbasedAuthentication,
2349 sHostbasedUsesNameFromPacketOnly, sClientAliveInterval,
2350 sClientAliveCountMax, sAuthorizedKeysFile, sAuthorizedKeysFile2,
2351- sGssAuthentication, sGssCleanupCreds, sAcceptEnv, sPermitTunnel,
2352+ sGssAuthentication, sGssCleanupCreds, sGssStrictAcceptor,
2353+ sGssKeyEx, sGssStoreRekey,
2354+ sAcceptEnv, sPermitTunnel,
2355 sMatch, sPermitOpen, sForceCommand, sChrootDirectory,
2356 sUsePrivilegeSeparation, sAllowAgentForwarding,
2357 sZeroKnowledgePasswordAuthentication,
2358@@ -364,9 +375,15 @@
2359 #ifdef GSSAPI
2360 { "gssapiauthentication", sGssAuthentication, SSHCFG_ALL },
2361 { "gssapicleanupcredentials", sGssCleanupCreds, SSHCFG_GLOBAL },
2362+ { "gssapistrictacceptorcheck", sGssStrictAcceptor, SSHCFG_GLOBAL },
2363+ { "gssapikeyexchange", sGssKeyEx, SSHCFG_GLOBAL },
2364+ { "gssapistorecredentialsonrekey", sGssStoreRekey, SSHCFG_GLOBAL },
2365 #else
2366 { "gssapiauthentication", sUnsupported, SSHCFG_ALL },
2367 { "gssapicleanupcredentials", sUnsupported, SSHCFG_GLOBAL },
2368+ { "gssapistrictacceptorcheck", sUnsupported, SSHCFG_GLOBAL },
2369+ { "gssapikeyexchange", sUnsupported, SSHCFG_GLOBAL },
2370+ { "gssapistorecredentialsonrekey", sUnsupported, SSHCFG_GLOBAL },
2371 #endif
2372 { "passwordauthentication", sPasswordAuthentication, SSHCFG_ALL },
2373 { "kbdinteractiveauthentication", sKbdInteractiveAuthentication, SSHCFG_ALL },
2374@@ -891,10 +908,22 @@
2375 intptr = &options->gss_authentication;
2376 goto parse_flag;
2377
2378+ case sGssKeyEx:
2379+ intptr = &options->gss_keyex;
2380+ goto parse_flag;
2381+
2382 case sGssCleanupCreds:
2383 intptr = &options->gss_cleanup_creds;
2384 goto parse_flag;
2385
2386+ case sGssStrictAcceptor:
2387+ intptr = &options->gss_strict_acceptor;
2388+ goto parse_flag;
2389+
2390+ case sGssStoreRekey:
2391+ intptr = &options->gss_store_rekey;
2392+ goto parse_flag;
2393+
2394 case sPasswordAuthentication:
2395 intptr = &options->password_authentication;
2396 goto parse_flag;
2397Index: b/servconf.h
2398===================================================================
2399--- a/servconf.h
2400+++ b/servconf.h
2401@@ -91,7 +91,10 @@
2402 int kerberos_get_afs_token; /* If true, try to get AFS token if
2403 * authenticated with Kerberos. */
2404 int gss_authentication; /* If true, permit GSSAPI authentication */
2405+ int gss_keyex; /* If true, permit GSSAPI key exchange */
2406 int gss_cleanup_creds; /* If true, destroy cred cache on logout */
2407+ int gss_strict_acceptor; /* If true, restrict the GSSAPI acceptor name */
2408+ int gss_store_rekey;
2409 int password_authentication; /* If true, permit password
2410 * authentication. */
2411 int kbd_interactive_authentication; /* If true, permit */
2412Index: b/ssh-gss.h
2413===================================================================
2414--- a/ssh-gss.h
2415+++ b/ssh-gss.h
2416@@ -1,6 +1,6 @@
2417 /* $OpenBSD: ssh-gss.h,v 1.10 2007/06/12 08:20:00 djm Exp $ */
2418 /*
2419- * Copyright (c) 2001-2003 Simon Wilkinson. All rights reserved.
2420+ * Copyright (c) 2001-2009 Simon Wilkinson. All rights reserved.
2421 *
2422 * Redistribution and use in source and binary forms, with or without
2423 * modification, are permitted provided that the following conditions
2424@@ -60,10 +60,22 @@
2425
2426 #define SSH_GSS_OIDTYPE 0x06
2427
2428+#define SSH2_MSG_KEXGSS_INIT 30
2429+#define SSH2_MSG_KEXGSS_CONTINUE 31
2430+#define SSH2_MSG_KEXGSS_COMPLETE 32
2431+#define SSH2_MSG_KEXGSS_HOSTKEY 33
2432+#define SSH2_MSG_KEXGSS_ERROR 34
2433+#define SSH2_MSG_KEXGSS_GROUPREQ 40
2434+#define SSH2_MSG_KEXGSS_GROUP 41
2435+#define KEX_GSS_GRP1_SHA1_ID "gss-group1-sha1-"
2436+#define KEX_GSS_GRP14_SHA1_ID "gss-group14-sha1-"
2437+#define KEX_GSS_GEX_SHA1_ID "gss-gex-sha1-"
2438+
2439 typedef struct {
2440 char *filename;
2441 char *envvar;
2442 char *envval;
2443+ struct passwd *owner;
2444 void *data;
2445 } ssh_gssapi_ccache;
2446
2447@@ -71,8 +83,11 @@
2448 gss_buffer_desc displayname;
2449 gss_buffer_desc exportedname;
2450 gss_cred_id_t creds;
2451+ gss_name_t name;
2452 struct ssh_gssapi_mech_struct *mech;
2453 ssh_gssapi_ccache store;
2454+ int used;
2455+ int updated;
2456 } ssh_gssapi_client;
2457
2458 typedef struct ssh_gssapi_mech_struct {
2459@@ -83,6 +98,7 @@
2460 int (*userok) (ssh_gssapi_client *, char *);
2461 int (*localname) (ssh_gssapi_client *, char **);
2462 void (*storecreds) (ssh_gssapi_client *);
2463+ int (*updatecreds) (ssh_gssapi_ccache *, ssh_gssapi_client *);
2464 } ssh_gssapi_mech;
2465
2466 typedef struct {
2467@@ -93,10 +109,11 @@
2468 gss_OID oid; /* client */
2469 gss_cred_id_t creds; /* server */
2470 gss_name_t client; /* server */
2471- gss_cred_id_t client_creds; /* server */
2472+ gss_cred_id_t client_creds; /* both */
2473 } Gssctxt;
2474
2475 extern ssh_gssapi_mech *supported_mechs[];
2476+extern Gssctxt *gss_kex_context;
2477
2478 int ssh_gssapi_check_oid(Gssctxt *, void *, size_t);
2479 void ssh_gssapi_set_oid_data(Gssctxt *, void *, size_t);
2480@@ -116,16 +133,30 @@
2481 void ssh_gssapi_delete_ctx(Gssctxt **);
2482 OM_uint32 ssh_gssapi_sign(Gssctxt *, gss_buffer_t, gss_buffer_t);
2483 void ssh_gssapi_buildmic(Buffer *, const char *, const char *, const char *);
2484-int ssh_gssapi_check_mechanism(Gssctxt **, gss_OID, const char *);
2485+int ssh_gssapi_check_mechanism(Gssctxt **, gss_OID, const char *, const char *);
2486+OM_uint32 ssh_gssapi_client_identity(Gssctxt *, const char *);
2487+int ssh_gssapi_credentials_updated(Gssctxt *);
2488
2489 /* In the server */
2490+typedef int ssh_gssapi_check_fn(Gssctxt **, gss_OID, const char *,
2491+ const char *);
2492+char *ssh_gssapi_client_mechanisms(const char *, const char *);
2493+char *ssh_gssapi_kex_mechs(gss_OID_set, ssh_gssapi_check_fn *, const char *,
2494+ const char *);
2495+gss_OID ssh_gssapi_id_kex(Gssctxt *, char *, int);
2496+int ssh_gssapi_server_check_mech(Gssctxt **,gss_OID, const char *,
2497+ const char *);
2498 OM_uint32 ssh_gssapi_server_ctx(Gssctxt **, gss_OID);
2499-int ssh_gssapi_userok(char *name);
2500+int ssh_gssapi_userok(char *name, struct passwd *);
2501 OM_uint32 ssh_gssapi_checkmic(Gssctxt *, gss_buffer_t, gss_buffer_t);
2502 void ssh_gssapi_do_child(char ***, u_int *);
2503 void ssh_gssapi_cleanup_creds(void);
2504 void ssh_gssapi_storecreds(void);
2505
2506+char *ssh_gssapi_server_mechanisms(void);
2507+int ssh_gssapi_oid_table_ok();
2508+
2509+int ssh_gssapi_update_creds(ssh_gssapi_ccache *store);
2510 #endif /* GSSAPI */
2511
2512 #endif /* _SSH_GSS_H */
2513Index: b/ssh_config
2514===================================================================
2515--- a/ssh_config
2516+++ b/ssh_config
2517@@ -26,6 +26,8 @@
2518 # HostbasedAuthentication no
2519 # GSSAPIAuthentication no
2520 # GSSAPIDelegateCredentials no
2521+# GSSAPIKeyExchange no
2522+# GSSAPITrustDNS no
2523 # BatchMode no
2524 # CheckHostIP yes
2525 # AddressFamily any
2526Index: b/ssh_config.5
2527===================================================================
2528--- a/ssh_config.5
2529+++ b/ssh_config.5
2530@@ -478,11 +478,38 @@
2531 The default is
2532 .Dq no .
2533 Note that this option applies to protocol version 2 only.
2534+.It Cm GSSAPIKeyExchange
2535+Specifies whether key exchange based on GSSAPI may be used. When using
2536+GSSAPI key exchange the server need not have a host key.
2537+The default is
2538+.Dq no .
2539+Note that this option applies to protocol version 2 only.
2540+.It Cm GSSAPIClientIdentity
2541+If set, specifies the GSSAPI client identity that ssh should use when
2542+connecting to the server. The default is unset, which means that the default
2543+identity will be used.
2544 .It Cm GSSAPIDelegateCredentials
2545 Forward (delegate) credentials to the server.
2546 The default is
2547 .Dq no .
2548-Note that this option applies to protocol version 2 only.
2549+Note that this option applies to protocol version 2 connections using GSSAPI.
2550+.It Cm GSSAPIRenewalForcesRekey
2551+If set to
2552+.Dq yes
2553+then renewal of the client's GSSAPI credentials will force the rekeying of the
2554+ssh connection. With a compatible server, this can delegate the renewed
2555+credentials to a session on the server.
2556+The default is
2557+.Dq no .
2558+.It Cm GSSAPITrustDns
2559+Set to
2560+.Dq yes to indicate that the DNS is trusted to securely canonicalize
2561+the name of the host being connected to. If
2562+.Dq no, the hostname entered on the
2563+command line will be passed untouched to the GSSAPI library.
2564+The default is
2565+.Dq no .
2566+This option only applies to protocol version 2 connections using GSSAPI.
2567 .It Cm HashKnownHosts
2568 Indicates that
2569 .Xr ssh 1
2570Index: b/sshconnect2.c
2571===================================================================
2572--- a/sshconnect2.c
2573+++ b/sshconnect2.c
2574@@ -105,9 +105,34 @@
2575 {
2576 Kex *kex;
2577
2578+#ifdef GSSAPI
2579+ char *orig = NULL, *gss = NULL;
2580+ char *gss_host = NULL;
2581+#endif
2582+
2583 xxx_host = host;
2584 xxx_hostaddr = hostaddr;
2585
2586+#ifdef GSSAPI
2587+ if (options.gss_keyex) {
2588+ /* Add the GSSAPI mechanisms currently supported on this
2589+ * client to the key exchange algorithm proposal */
2590+ orig = myproposal[PROPOSAL_KEX_ALGS];
2591+
2592+ if (options.gss_trust_dns)
2593+ gss_host = (char *)get_canonical_hostname(1);
2594+ else
2595+ gss_host = host;
2596+
2597+ gss = ssh_gssapi_client_mechanisms(gss_host, options.gss_client_identity);
2598+ if (gss) {
2599+ debug("Offering GSSAPI proposal: %s", gss);
2600+ xasprintf(&myproposal[PROPOSAL_KEX_ALGS],
2601+ "%s,%s", gss, orig);
2602+ }
2603+ }
2604+#endif
2605+
2606 if (options.ciphers == (char *)-1) {
2607 logit("No valid ciphers for protocol version 2 given, using defaults.");
2608 options.ciphers = NULL;
2609@@ -135,6 +160,17 @@
2610 myproposal[PROPOSAL_SERVER_HOST_KEY_ALGS] =
2611 options.hostkeyalgorithms;
2612
2613+#ifdef GSSAPI
2614+ /* If we've got GSSAPI algorithms, then we also support the
2615+ * 'null' hostkey, as a last resort */
2616+ if (options.gss_keyex && gss) {
2617+ orig = myproposal[PROPOSAL_SERVER_HOST_KEY_ALGS];
2618+ xasprintf(&myproposal[PROPOSAL_SERVER_HOST_KEY_ALGS],
2619+ "%s,null", orig);
2620+ xfree(gss);
2621+ }
2622+#endif
2623+
2624 if (options.rekey_limit)
2625 packet_set_rekey_limit((u_int32_t)options.rekey_limit);
2626
2627@@ -144,10 +180,26 @@
2628 kex->kex[KEX_DH_GRP14_SHA1] = kexdh_client;
2629 kex->kex[KEX_DH_GEX_SHA1] = kexgex_client;
2630 kex->kex[KEX_DH_GEX_SHA256] = kexgex_client;
2631+#ifdef GSSAPI
2632+ if (options.gss_keyex) {
2633+ kex->kex[KEX_GSS_GRP1_SHA1] = kexgss_client;
2634+ kex->kex[KEX_GSS_GRP14_SHA1] = kexgss_client;
2635+ kex->kex[KEX_GSS_GEX_SHA1] = kexgss_client;
2636+ }
2637+#endif
2638 kex->client_version_string=client_version_string;
2639 kex->server_version_string=server_version_string;
2640 kex->verify_host_key=&verify_host_key_callback;
2641
2642+#ifdef GSSAPI
2643+ if (options.gss_keyex) {
2644+ kex->gss_deleg_creds = options.gss_deleg_creds;
2645+ kex->gss_trust_dns = options.gss_trust_dns;
2646+ kex->gss_client = options.gss_client_identity;
2647+ kex->gss_host = gss_host;
2648+ }
2649+#endif
2650+
2651 xxx_kex = kex;
2652
2653 dispatch_run(DISPATCH_BLOCK, &kex->done, kex);
2654@@ -236,6 +288,7 @@
2655 void input_gssapi_hash(int type, u_int32_t, void *);
2656 void input_gssapi_error(int, u_int32_t, void *);
2657 void input_gssapi_errtok(int, u_int32_t, void *);
2658+int userauth_gsskeyex(Authctxt *authctxt);
2659 #endif
2660
2661 void userauth(Authctxt *, char *);
2662@@ -251,6 +304,11 @@
2663
2664 Authmethod authmethods[] = {
2665 #ifdef GSSAPI
2666+ {"gssapi-keyex",
2667+ userauth_gsskeyex,
2668+ NULL,
2669+ &options.gss_authentication,
2670+ NULL},
2671 {"gssapi-with-mic",
2672 userauth_gssapi,
2673 NULL,
2674@@ -542,19 +600,29 @@
2675 static u_int mech = 0;
2676 OM_uint32 min;
2677 int ok = 0;
2678+ const char *gss_host;
2679+
2680+ if (options.gss_trust_dns)
2681+ gss_host = get_canonical_hostname(1);
2682+ else
2683+ gss_host = authctxt->host;
2684
2685 /* Try one GSSAPI method at a time, rather than sending them all at
2686 * once. */
2687
2688 if (gss_supported == NULL)
2689- gss_indicate_mechs(&min, &gss_supported);
2690+ if (GSS_ERROR(gss_indicate_mechs(&min, &gss_supported))) {
2691+ gss_supported = NULL;
2692+ return 0;
2693+ }
2694
2695 /* Check to see if the mechanism is usable before we offer it */
2696 while (mech < gss_supported->count && !ok) {
2697 /* My DER encoding requires length<128 */
2698 if (gss_supported->elements[mech].length < 128 &&
2699 ssh_gssapi_check_mechanism(&gssctxt,
2700- &gss_supported->elements[mech], authctxt->host)) {
2701+ &gss_supported->elements[mech], gss_host,
2702+ options.gss_client_identity)) {
2703 ok = 1; /* Mechanism works */
2704 } else {
2705 mech++;
2706@@ -651,8 +719,8 @@
2707 {
2708 Authctxt *authctxt = ctxt;
2709 Gssctxt *gssctxt;
2710- int oidlen;
2711- char *oidv;
2712+ u_int oidlen;
2713+ u_char *oidv;
2714
2715 if (authctxt == NULL)
2716 fatal("input_gssapi_response: no authentication context");
2717@@ -762,6 +830,48 @@
2718 xfree(msg);
2719 xfree(lang);
2720 }
2721+
2722+int
2723+userauth_gsskeyex(Authctxt *authctxt)
2724+{
2725+ Buffer b;
2726+ gss_buffer_desc gssbuf;
2727+ gss_buffer_desc mic = GSS_C_EMPTY_BUFFER;
2728+ OM_uint32 ms;
2729+
2730+ static int attempt = 0;
2731+ if (attempt++ >= 1)
2732+ return (0);
2733+
2734+ if (gss_kex_context == NULL) {
2735+ debug("No valid Key exchange context");
2736+ return (0);
2737+ }
2738+
2739+ ssh_gssapi_buildmic(&b, authctxt->server_user, authctxt->service,
2740+ "gssapi-keyex");
2741+
2742+ gssbuf.value = buffer_ptr(&b);
2743+ gssbuf.length = buffer_len(&b);
2744+
2745+ if (GSS_ERROR(ssh_gssapi_sign(gss_kex_context, &gssbuf, &mic))) {
2746+ buffer_free(&b);
2747+ return (0);
2748+ }
2749+
2750+ packet_start(SSH2_MSG_USERAUTH_REQUEST);
2751+ packet_put_cstring(authctxt->server_user);
2752+ packet_put_cstring(authctxt->service);
2753+ packet_put_cstring(authctxt->method->name);
2754+ packet_put_string(mic.value, mic.length);
2755+ packet_send();
2756+
2757+ buffer_free(&b);
2758+ gss_release_buffer(&ms, &mic);
2759+
2760+ return (1);
2761+}
2762+
2763 #endif /* GSSAPI */
2764
2765 int
2766Index: b/sshd.c
2767===================================================================
2768--- a/sshd.c
2769+++ b/sshd.c
2770@@ -120,6 +120,10 @@
2771 #include "roaming.h"
2772 #include "version.h"
2773
2774+#ifdef USE_SECURITY_SESSION_API
2775+#include <Security/AuthSession.h>
2776+#endif
2777+
2778 #ifdef LIBWRAP
2779 #include <tcpd.h>
2780 #include <syslog.h>
2781@@ -1531,10 +1535,13 @@
2782 logit("Disabling protocol version 1. Could not load host key");
2783 options.protocol &= ~SSH_PROTO_1;
2784 }
2785+#ifndef GSSAPI
2786+ /* The GSSAPI key exchange can run without a host key */
2787 if ((options.protocol & SSH_PROTO_2) && !sensitive_data.have_ssh2_key) {
2788 logit("Disabling protocol version 2. Could not load host key");
2789 options.protocol &= ~SSH_PROTO_2;
2790 }
2791+#endif
2792 if (!(options.protocol & (SSH_PROTO_1|SSH_PROTO_2))) {
2793 logit("sshd: no hostkeys available -- exiting.");
2794 exit(1);
2795@@ -1818,6 +1825,60 @@
2796 /* Log the connection. */
2797 verbose("Connection from %.500s port %d", remote_ip, remote_port);
2798
2799+#ifdef USE_SECURITY_SESSION_API
2800+ /*
2801+ * Create a new security session for use by the new user login if
2802+ * the current session is the root session or we are not launched
2803+ * by inetd (eg: debugging mode or server mode). We do not
2804+ * necessarily need to create a session if we are launched from
2805+ * inetd because Panther xinetd will create a session for us.
2806+ *
2807+ * The only case where this logic will fail is if there is an
2808+ * inetd running in a non-root session which is not creating
2809+ * new sessions for us. Then all the users will end up in the
2810+ * same session (bad).
2811+ *
2812+ * When the client exits, the session will be destroyed for us
2813+ * automatically.
2814+ *
2815+ * We must create the session before any credentials are stored
2816+ * (including AFS pags, which happens a few lines below).
2817+ */
2818+ {
2819+ OSStatus err = 0;
2820+ SecuritySessionId sid = 0;
2821+ SessionAttributeBits sattrs = 0;
2822+
2823+ err = SessionGetInfo(callerSecuritySession, &sid, &sattrs);
2824+ if (err)
2825+ error("SessionGetInfo() failed with error %.8X",
2826+ (unsigned) err);
2827+ else
2828+ debug("Current Session ID is %.8X / Session Attributes are %.8X",
2829+ (unsigned) sid, (unsigned) sattrs);
2830+
2831+ if (inetd_flag && !(sattrs & sessionIsRoot))
2832+ debug("Running in inetd mode in a non-root session... "
2833+ "assuming inetd created the session for us.");
2834+ else {
2835+ debug("Creating new security session...");
2836+ err = SessionCreate(0, sessionHasTTY | sessionIsRemote);
2837+ if (err)
2838+ error("SessionCreate() failed with error %.8X",
2839+ (unsigned) err);
2840+
2841+ err = SessionGetInfo(callerSecuritySession, &sid,
2842+ &sattrs);
2843+ if (err)
2844+ error("SessionGetInfo() failed with error %.8X",
2845+ (unsigned) err);
2846+ else
2847+ debug("New Session ID is %.8X / Session Attributes are %.8X",
2848+ (unsigned) sid, (unsigned) sattrs);
2849+ }
2850+ }
2851+#endif
2852+
2853 /*
2854 * We don't want to listen forever unless the other side
2855 * successfully authenticates itself. So we set up an alarm which is
2856@@ -2195,12 +2256,61 @@
2857
2858 myproposal[PROPOSAL_SERVER_HOST_KEY_ALGS] = list_hostkey_types();
2859
2860+#ifdef GSSAPI
2861+ {
2862+ char *orig;
2863+ char *gss = NULL;
2864+ char *newstr = NULL;
2865+ orig = myproposal[PROPOSAL_KEX_ALGS];
2866+
2867+ /*
2868+ * If we don't have a host key, then there's no point advertising
2869+ * the other key exchange algorithms
2870+ */
2871+
2872+ if (strlen(myproposal[PROPOSAL_SERVER_HOST_KEY_ALGS]) == 0)
2873+ orig = NULL;
2874+
2875+ if (options.gss_keyex)
2876+ gss = ssh_gssapi_server_mechanisms();
2877+ else
2878+ gss = NULL;
2879+
2880+ if (gss && orig)
2881+ xasprintf(&newstr, "%s,%s", gss, orig);
2882+ else if (gss)
2883+ newstr = gss;
2884+ else if (orig)
2885+ newstr = orig;
2886+
2887+ /*
2888+ * If we've got GSSAPI mechanisms, then we've got the 'null' host
2889+ * key alg, but we can't tell people about it unless its the only
2890+ * host key algorithm we support
2891+ */
2892+ if (gss && (strlen(myproposal[PROPOSAL_SERVER_HOST_KEY_ALGS])) == 0)
2893+ myproposal[PROPOSAL_SERVER_HOST_KEY_ALGS] = "null";
2894+
2895+ if (newstr)
2896+ myproposal[PROPOSAL_KEX_ALGS] = newstr;
2897+ else
2898+ fatal("No supported key exchange algorithms");
2899+ }
2900+#endif
2901+
2902 /* start key exchange */
2903 kex = kex_setup(myproposal);
2904 kex->kex[KEX_DH_GRP1_SHA1] = kexdh_server;
2905 kex->kex[KEX_DH_GRP14_SHA1] = kexdh_server;
2906 kex->kex[KEX_DH_GEX_SHA1] = kexgex_server;
2907 kex->kex[KEX_DH_GEX_SHA256] = kexgex_server;
2908+#ifdef GSSAPI
2909+ if (options.gss_keyex) {
2910+ kex->kex[KEX_GSS_GRP1_SHA1] = kexgss_server;
2911+ kex->kex[KEX_GSS_GRP14_SHA1] = kexgss_server;
2912+ kex->kex[KEX_GSS_GEX_SHA1] = kexgss_server;
2913+ }
2914+#endif
2915 kex->server = 1;
2916 kex->client_version_string=client_version_string;
2917 kex->server_version_string=server_version_string;
2918Index: b/sshd_config
2919===================================================================
2920--- a/sshd_config
2921+++ b/sshd_config
2922@@ -73,6 +73,8 @@
2923 # GSSAPI options
2924 #GSSAPIAuthentication no
2925 #GSSAPICleanupCredentials yes
2926+#GSSAPIStrictAcceptorCheck yes
2927+#GSSAPIKeyExchange no
2928
2929 # Set this to 'yes' to enable PAM authentication, account processing,
2930 # and session processing. If this is enabled, PAM authentication will
2931Index: b/sshd_config.5
2932===================================================================
2933--- a/sshd_config.5
2934+++ b/sshd_config.5
2935@@ -379,12 +379,40 @@
2936 The default is
2937 .Dq no .
2938 Note that this option applies to protocol version 2 only.
2939+.It Cm GSSAPIKeyExchange
2940+Specifies whether key exchange based on GSSAPI is allowed. GSSAPI key exchange
2941+doesn't rely on ssh keys to verify host identity.
2942+The default is
2943+.Dq no .
2944+Note that this option applies to protocol version 2 only.
2945 .It Cm GSSAPICleanupCredentials
2946 Specifies whether to automatically destroy the user's credentials cache
2947 on logout.
2948 The default is
2949 .Dq yes .
2950 Note that this option applies to protocol version 2 only.
2951+.It Cm GSSAPIStrictAcceptorCheck
2952+Determines whether to be strict about the identity of the GSSAPI acceptor
2953+a client authenticates against. If
2954+.Dq yes
2955+then the client must authenticate against the
2956+.Pa host
2957+service on the current hostname. If
2958+.Dq no
2959+then the client may authenticate against any service key stored in the
2960+machine's default store. This facility is provided to assist with operation
2961+on multi homed machines.
2962+The default is
2963+.Dq yes .
2964+Note that this option applies only to protocol version 2 GSSAPI connections,
2965+and setting it to
2966+.Dq no
2967+may only work with recent Kerberos GSSAPI libraries.
2968+.It Cm GSSAPIStoreCredentialsOnRekey
2969+Controls whether the user's GSSAPI credentials should be updated following a
2970+successful connection rekeying. This option can be used to accepted renewed
2971+or updated credentials from a compatible client. The default is
2972+.Dq no .
2973 .It Cm HostbasedAuthentication
2974 Specifies whether rhosts or /etc/hosts.equiv authentication together
2975 with successful public key client host authentication is allowed