]>
Commit | Line | Data |
---|---|---|
25d429a2 | 1 | /* $OpenBSD: ssh-gss.h,v 1.10 2007/06/12 08:20:00 djm Exp $ */ |
5598e598 | 2 | /* |
46201ce0 | 3 | * Copyright (c) 2001-2009 Simon Wilkinson. All rights reserved. |
5598e598 | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | |
6 | * modification, are permitted provided that the following conditions | |
7 | * are met: | |
8 | * 1. Redistributions of source code must retain the above copyright | |
9 | * notice, this list of conditions and the following disclaimer. | |
10 | * 2. Redistributions in binary form must reproduce the above copyright | |
11 | * notice, this list of conditions and the following disclaimer in the | |
12 | * documentation and/or other materials provided with the distribution. | |
13 | * | |
14 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR `AS IS'' AND ANY EXPRESS OR | |
15 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | |
16 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | |
17 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | |
18 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | |
19 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
20 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
21 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | |
23 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
24 | */ | |
25 | ||
ff2d7a98 | 26 | #ifndef _SSH_GSS_H |
27 | #define _SSH_GSS_H | |
28 | ||
5598e598 | 29 | #ifdef GSSAPI |
30 | ||
3e6b30f6 | 31 | /* Need this include to fix GSI AIX 64-bit builds. */ |
32 | #include <unistd.h> | |
33 | ||
416fd2a8 | 34 | #ifdef HAVE_GSSAPI_H |
5598e598 | 35 | #include <gssapi.h> |
416fd2a8 | 36 | #elif defined(HAVE_GSSAPI_GSSAPI_H) |
37 | #include <gssapi/gssapi.h> | |
38 | #endif | |
5598e598 | 39 | |
c2397a66 | 40 | #ifndef MECHGLUE |
5598e598 | 41 | #ifdef KRB5 |
416fd2a8 | 42 | # ifndef HEIMDAL |
43 | # ifdef HAVE_GSSAPI_GENERIC_H | |
44 | # include <gssapi_generic.h> | |
45 | # elif defined(HAVE_GSSAPI_GSSAPI_GENERIC_H) | |
46 | # include <gssapi/gssapi_generic.h> | |
47 | # endif | |
5598e598 | 48 | |
49 | /* MIT Kerberos doesn't seem to define GSS_NT_HOSTBASED_SERVICE */ | |
70791e56 | 50 | |
5598e598 | 51 | #ifndef GSS_C_NT_HOSTBASED_SERVICE |
52 | #define GSS_C_NT_HOSTBASED_SERVICE gss_nt_service_name | |
53 | #endif /* GSS_C_NT_... */ | |
54 | #endif /* !HEIMDAL */ | |
55 | #endif /* KRB5 */ | |
c2397a66 | 56 | #endif /* !MECHGLUE */ |
5598e598 | 57 | |
70791e56 | 58 | /* draft-ietf-secsh-gsskeyex-06 */ |
70791e56 | 59 | #define SSH2_MSG_USERAUTH_GSSAPI_RESPONSE 60 |
60 | #define SSH2_MSG_USERAUTH_GSSAPI_TOKEN 61 | |
61 | #define SSH2_MSG_USERAUTH_GSSAPI_EXCHANGE_COMPLETE 63 | |
62 | #define SSH2_MSG_USERAUTH_GSSAPI_ERROR 64 | |
88928908 | 63 | #define SSH2_MSG_USERAUTH_GSSAPI_ERRTOK 65 |
416fd2a8 | 64 | #define SSH2_MSG_USERAUTH_GSSAPI_MIC 66 |
ff2d7a98 | 65 | |
70791e56 | 66 | #define SSH_GSS_OIDTYPE 0x06 |
67 | ||
2e437378 | 68 | #define SSH2_MSG_KEXGSS_INIT 30 |
69 | #define SSH2_MSG_KEXGSS_CONTINUE 31 | |
70 | #define SSH2_MSG_KEXGSS_COMPLETE 32 | |
71 | #define SSH2_MSG_KEXGSS_HOSTKEY 33 | |
72 | #define SSH2_MSG_KEXGSS_ERROR 34 | |
34fee935 | 73 | #define SSH2_MSG_KEXGSS_GROUPREQ 40 |
74 | #define SSH2_MSG_KEXGSS_GROUP 41 | |
75 | #define KEX_GSS_GRP1_SHA1_ID "gss-group1-sha1-" | |
2e437378 | 76 | #define KEX_GSS_GRP14_SHA1_ID "gss-group14-sha1-" |
34fee935 | 77 | #define KEX_GSS_GEX_SHA1_ID "gss-gex-sha1-" |
5598e598 | 78 | |
88928908 | 79 | typedef struct { |
70791e56 | 80 | char *filename; |
81 | char *envvar; | |
82 | char *envval; | |
46201ce0 | 83 | struct passwd *owner; |
70791e56 | 84 | void *data; |
88928908 | 85 | } ssh_gssapi_ccache; |
5598e598 | 86 | |
88928908 | 87 | typedef struct { |
70791e56 | 88 | gss_buffer_desc displayname; |
89 | gss_buffer_desc exportedname; | |
90 | gss_cred_id_t creds; | |
46201ce0 | 91 | gss_name_t name; |
88928908 | 92 | struct ssh_gssapi_mech_struct *mech; |
93 | ssh_gssapi_ccache store; | |
e00da40d | 94 | gss_ctx_id_t context; |
46201ce0 | 95 | int used; |
96 | int updated; | |
88928908 | 97 | } ssh_gssapi_client; |
98 | ||
99 | typedef struct ssh_gssapi_mech_struct { | |
70791e56 | 100 | char *enc_name; |
101 | char *name; | |
102 | gss_OID_desc oid; | |
88928908 | 103 | int (*dochild) (ssh_gssapi_client *); |
104 | int (*userok) (ssh_gssapi_client *, char *); | |
105 | int (*localname) (ssh_gssapi_client *, char **); | |
106 | void (*storecreds) (ssh_gssapi_client *); | |
46201ce0 | 107 | int (*updatecreds) (ssh_gssapi_ccache *, ssh_gssapi_client *); |
5598e598 | 108 | } ssh_gssapi_mech; |
109 | ||
110 | typedef struct { | |
88928908 | 111 | OM_uint32 major; /* both */ |
112 | OM_uint32 minor; /* both */ | |
5598e598 | 113 | gss_ctx_id_t context; /* both */ |
114 | gss_name_t name; /* both */ | |
67e2750c | 115 | gss_OID oid; /* both */ |
5598e598 | 116 | gss_cred_id_t creds; /* server */ |
117 | gss_name_t client; /* server */ | |
46201ce0 | 118 | gss_cred_id_t client_creds; /* both */ |
5598e598 | 119 | } Gssctxt; |
120 | ||
88928908 | 121 | extern ssh_gssapi_mech *supported_mechs[]; |
34fee935 | 122 | extern Gssctxt *gss_kex_context; |
1b56ff3d | 123 | |
124 | int ssh_gssapi_check_oid(Gssctxt *, void *, size_t); | |
125 | void ssh_gssapi_set_oid_data(Gssctxt *, void *, size_t); | |
126 | void ssh_gssapi_set_oid(Gssctxt *, gss_OID); | |
127 | void ssh_gssapi_supported_oids(gss_OID_set *); | |
128 | ssh_gssapi_mech *ssh_gssapi_get_ctype(Gssctxt *); | |
129 | ||
130 | OM_uint32 ssh_gssapi_import_name(Gssctxt *, const char *); | |
1b56ff3d | 131 | OM_uint32 ssh_gssapi_init_ctx(Gssctxt *, int, |
132 | gss_buffer_desc *, gss_buffer_desc *, OM_uint32 *); | |
133 | OM_uint32 ssh_gssapi_accept_ctx(Gssctxt *, | |
134 | gss_buffer_desc *, gss_buffer_desc *, OM_uint32 *); | |
135 | OM_uint32 ssh_gssapi_getclient(Gssctxt *, ssh_gssapi_client *); | |
136 | void ssh_gssapi_error(Gssctxt *); | |
137 | char *ssh_gssapi_last_error(Gssctxt *, OM_uint32 *, OM_uint32 *); | |
138 | void ssh_gssapi_build_ctx(Gssctxt **); | |
139 | void ssh_gssapi_delete_ctx(Gssctxt **); | |
416fd2a8 | 140 | OM_uint32 ssh_gssapi_sign(Gssctxt *, gss_buffer_t, gss_buffer_t); |
416fd2a8 | 141 | void ssh_gssapi_buildmic(Buffer *, const char *, const char *, const char *); |
46201ce0 | 142 | int ssh_gssapi_check_mechanism(Gssctxt **, gss_OID, const char *, const char *); |
143 | OM_uint32 ssh_gssapi_client_identity(Gssctxt *, const char *); | |
144 | int ssh_gssapi_credentials_updated(Gssctxt *); | |
5598e598 | 145 | |
88928908 | 146 | int ssh_gssapi_localname(char **name); |
46201ce0 | 147 | void ssh_gssapi_rekey_creds(); |
1b56ff3d | 148 | |
2e437378 | 149 | /* In the server */ |
46201ce0 | 150 | typedef int ssh_gssapi_check_fn(Gssctxt **, gss_OID, const char *, |
151 | const char *); | |
152 | char *ssh_gssapi_client_mechanisms(const char *, const char *); | |
153 | char *ssh_gssapi_kex_mechs(gss_OID_set, ssh_gssapi_check_fn *, const char *, | |
154 | const char *); | |
2e437378 | 155 | gss_OID ssh_gssapi_id_kex(Gssctxt *, char *, int); |
46201ce0 | 156 | int ssh_gssapi_server_check_mech(Gssctxt **,gss_OID, const char *, |
157 | const char *); | |
25d429a2 | 158 | OM_uint32 ssh_gssapi_server_ctx(Gssctxt **, gss_OID); |
46201ce0 | 159 | int ssh_gssapi_userok(char *name, struct passwd *); |
416fd2a8 | 160 | OM_uint32 ssh_gssapi_checkmic(Gssctxt *, gss_buffer_t, gss_buffer_t); |
1b56ff3d | 161 | void ssh_gssapi_do_child(char ***, u_int *); |
416fd2a8 | 162 | void ssh_gssapi_cleanup_creds(void); |
70791e56 | 163 | void ssh_gssapi_storecreds(void); |
ff2d7a98 | 164 | |
c2397a66 | 165 | #ifdef MECHGLUE |
166 | gss_cred_id_t __gss_get_mechanism_cred | |
167 | (gss_cred_id_t, /* union_cred */ | |
168 | gss_OID /* mech_type */ | |
169 | ); | |
ff2d7a98 | 170 | #endif |
f2fd21a2 | 171 | |
46201ce0 | 172 | char *ssh_gssapi_server_mechanisms(void); |
173 | int ssh_gssapi_oid_table_ok(); | |
174 | ||
175 | int ssh_gssapi_update_creds(ssh_gssapi_ccache *store); | |
5598e598 | 176 | #endif /* GSSAPI */ |
ff2d7a98 | 177 | |
178 | #endif /* _SSH_GSS_H */ |