]>
Commit | Line | Data |
---|---|---|
1 | /* $OpenBSD: ssh-gss.h,v 1.10 2007/06/12 08:20:00 djm Exp $ */ | |
2 | /* | |
3 | * Copyright (c) 2001-2009 Simon Wilkinson. All rights reserved. | |
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 | ||
26 | #ifndef _SSH_GSS_H | |
27 | #define _SSH_GSS_H | |
28 | ||
29 | #ifdef GSSAPI | |
30 | ||
31 | #ifdef HAVE_GSSAPI_H | |
32 | #include <gssapi.h> | |
33 | #elif defined(HAVE_GSSAPI_GSSAPI_H) | |
34 | #include <gssapi/gssapi.h> | |
35 | #endif | |
36 | ||
37 | #ifdef KRB5 | |
38 | # ifndef HEIMDAL | |
39 | # ifdef HAVE_GSSAPI_GENERIC_H | |
40 | # include <gssapi_generic.h> | |
41 | # elif defined(HAVE_GSSAPI_GSSAPI_GENERIC_H) | |
42 | # include <gssapi/gssapi_generic.h> | |
43 | # endif | |
44 | ||
45 | /* MIT Kerberos doesn't seem to define GSS_NT_HOSTBASED_SERVICE */ | |
46 | ||
47 | #ifndef GSS_C_NT_HOSTBASED_SERVICE | |
48 | #define GSS_C_NT_HOSTBASED_SERVICE gss_nt_service_name | |
49 | #endif /* GSS_C_NT_... */ | |
50 | #endif /* !HEIMDAL */ | |
51 | #endif /* KRB5 */ | |
52 | ||
53 | /* draft-ietf-secsh-gsskeyex-06 */ | |
54 | #define SSH2_MSG_USERAUTH_GSSAPI_RESPONSE 60 | |
55 | #define SSH2_MSG_USERAUTH_GSSAPI_TOKEN 61 | |
56 | #define SSH2_MSG_USERAUTH_GSSAPI_EXCHANGE_COMPLETE 63 | |
57 | #define SSH2_MSG_USERAUTH_GSSAPI_ERROR 64 | |
58 | #define SSH2_MSG_USERAUTH_GSSAPI_ERRTOK 65 | |
59 | #define SSH2_MSG_USERAUTH_GSSAPI_MIC 66 | |
60 | ||
61 | #define SSH_GSS_OIDTYPE 0x06 | |
62 | ||
63 | #define SSH2_MSG_KEXGSS_INIT 30 | |
64 | #define SSH2_MSG_KEXGSS_CONTINUE 31 | |
65 | #define SSH2_MSG_KEXGSS_COMPLETE 32 | |
66 | #define SSH2_MSG_KEXGSS_HOSTKEY 33 | |
67 | #define SSH2_MSG_KEXGSS_ERROR 34 | |
68 | #define SSH2_MSG_KEXGSS_GROUPREQ 40 | |
69 | #define SSH2_MSG_KEXGSS_GROUP 41 | |
70 | #define KEX_GSS_GRP1_SHA1_ID "gss-group1-sha1-" | |
71 | #define KEX_GSS_GRP14_SHA1_ID "gss-group14-sha1-" | |
72 | #define KEX_GSS_GEX_SHA1_ID "gss-gex-sha1-" | |
73 | ||
74 | typedef struct { | |
75 | char *filename; | |
76 | char *envvar; | |
77 | char *envval; | |
78 | struct passwd *owner; | |
79 | void *data; | |
80 | } ssh_gssapi_ccache; | |
81 | ||
82 | typedef struct { | |
83 | gss_buffer_desc displayname; | |
84 | gss_buffer_desc exportedname; | |
85 | gss_cred_id_t creds; | |
86 | gss_name_t name; | |
87 | struct ssh_gssapi_mech_struct *mech; | |
88 | ssh_gssapi_ccache store; | |
89 | int used; | |
90 | int updated; | |
91 | } ssh_gssapi_client; | |
92 | ||
93 | typedef struct ssh_gssapi_mech_struct { | |
94 | char *enc_name; | |
95 | char *name; | |
96 | gss_OID_desc oid; | |
97 | int (*dochild) (ssh_gssapi_client *); | |
98 | int (*userok) (ssh_gssapi_client *, char *); | |
99 | int (*localname) (ssh_gssapi_client *, char **); | |
100 | void (*storecreds) (ssh_gssapi_client *); | |
101 | int (*updatecreds) (ssh_gssapi_ccache *, ssh_gssapi_client *); | |
102 | } ssh_gssapi_mech; | |
103 | ||
104 | typedef struct { | |
105 | OM_uint32 major; /* both */ | |
106 | OM_uint32 minor; /* both */ | |
107 | gss_ctx_id_t context; /* both */ | |
108 | gss_name_t name; /* both */ | |
109 | gss_OID oid; /* client */ | |
110 | gss_cred_id_t creds; /* server */ | |
111 | gss_name_t client; /* server */ | |
112 | gss_cred_id_t client_creds; /* both */ | |
113 | } Gssctxt; | |
114 | ||
115 | extern ssh_gssapi_mech *supported_mechs[]; | |
116 | extern Gssctxt *gss_kex_context; | |
117 | ||
118 | int ssh_gssapi_check_oid(Gssctxt *, void *, size_t); | |
119 | void ssh_gssapi_set_oid_data(Gssctxt *, void *, size_t); | |
120 | void ssh_gssapi_set_oid(Gssctxt *, gss_OID); | |
121 | void ssh_gssapi_supported_oids(gss_OID_set *); | |
122 | ssh_gssapi_mech *ssh_gssapi_get_ctype(Gssctxt *); | |
123 | ||
124 | OM_uint32 ssh_gssapi_import_name(Gssctxt *, const char *); | |
125 | OM_uint32 ssh_gssapi_init_ctx(Gssctxt *, int, | |
126 | gss_buffer_desc *, gss_buffer_desc *, OM_uint32 *); | |
127 | OM_uint32 ssh_gssapi_accept_ctx(Gssctxt *, | |
128 | gss_buffer_desc *, gss_buffer_desc *, OM_uint32 *); | |
129 | OM_uint32 ssh_gssapi_getclient(Gssctxt *, ssh_gssapi_client *); | |
130 | void ssh_gssapi_error(Gssctxt *); | |
131 | char *ssh_gssapi_last_error(Gssctxt *, OM_uint32 *, OM_uint32 *); | |
132 | void ssh_gssapi_build_ctx(Gssctxt **); | |
133 | void ssh_gssapi_delete_ctx(Gssctxt **); | |
134 | OM_uint32 ssh_gssapi_sign(Gssctxt *, gss_buffer_t, gss_buffer_t); | |
135 | void ssh_gssapi_buildmic(Buffer *, const char *, const char *, const char *); | |
136 | int ssh_gssapi_check_mechanism(Gssctxt **, gss_OID, const char *, const char *); | |
137 | OM_uint32 ssh_gssapi_client_identity(Gssctxt *, const char *); | |
138 | int ssh_gssapi_credentials_updated(Gssctxt *); | |
139 | ||
140 | /* In the server */ | |
141 | typedef int ssh_gssapi_check_fn(Gssctxt **, gss_OID, const char *, | |
142 | const char *); | |
143 | char *ssh_gssapi_client_mechanisms(const char *, const char *); | |
144 | char *ssh_gssapi_kex_mechs(gss_OID_set, ssh_gssapi_check_fn *, const char *, | |
145 | const char *); | |
146 | gss_OID ssh_gssapi_id_kex(Gssctxt *, char *, int); | |
147 | int ssh_gssapi_server_check_mech(Gssctxt **,gss_OID, const char *, | |
148 | const char *); | |
149 | OM_uint32 ssh_gssapi_server_ctx(Gssctxt **, gss_OID); | |
150 | int ssh_gssapi_userok(char *name, struct passwd *); | |
151 | OM_uint32 ssh_gssapi_checkmic(Gssctxt *, gss_buffer_t, gss_buffer_t); | |
152 | void ssh_gssapi_do_child(char ***, u_int *); | |
153 | void ssh_gssapi_cleanup_creds(void); | |
154 | void ssh_gssapi_storecreds(void); | |
155 | ||
156 | char *ssh_gssapi_server_mechanisms(void); | |
157 | int ssh_gssapi_oid_table_ok(); | |
158 | ||
159 | int ssh_gssapi_update_creds(ssh_gssapi_ccache *store); | |
160 | #endif /* GSSAPI */ | |
161 | ||
162 | #endif /* _SSH_GSS_H */ |