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