xref: /freebsd/lib/libgssapi/mech_switch.h (revision 1e413cf93298b5b97441a21d9a50fdcd0ee9945e)
1 /*-
2  * Copyright (c) 2005 Doug Rabson
3  * 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 AND CONTRIBUTORS ``AS IS'' AND
15  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24  * SUCH DAMAGE.
25  *
26  *	$FreeBSD$
27  */
28 
29 #include <sys/queue.h>
30 
31 typedef OM_uint32 _gss_acquire_cred_t
32 	      (OM_uint32 *,            /* minor_status */
33 	       const gss_name_t,       /* desired_name */
34 	       OM_uint32,              /* time_req */
35 	       const gss_OID_set,      /* desired_mechs */
36 	       gss_cred_usage_t,       /* cred_usage */
37 	       gss_cred_id_t *,        /* output_cred_handle */
38 	       gss_OID_set *,          /* actual_mechs */
39 	       OM_uint32 *             /* time_rec */
40 	      );
41 
42 typedef OM_uint32 _gss_release_cred_t
43 	      (OM_uint32 *,            /* minor_status */
44 	       gss_cred_id_t *         /* cred_handle */
45 	      );
46 
47 typedef OM_uint32 _gss_init_sec_context_t
48 	      (OM_uint32 *,            /* minor_status */
49 	       const gss_cred_id_t,    /* initiator_cred_handle */
50 	       gss_ctx_id_t *,         /* context_handle */
51 	       const gss_name_t,       /* target_name */
52 	       const gss_OID,          /* mech_type */
53 	       OM_uint32,              /* req_flags */
54 	       OM_uint32,              /* time_req */
55 	       const gss_channel_bindings_t,
56 				       /* input_chan_bindings */
57 	       const gss_buffer_t,     /* input_token */
58 	       gss_OID *,              /* actual_mech_type */
59 	       gss_buffer_t,           /* output_token */
60 	       OM_uint32 *,            /* ret_flags */
61 	       OM_uint32 *             /* time_rec */
62 	      );
63 
64 typedef OM_uint32 _gss_accept_sec_context_t
65 	      (OM_uint32 *,            /* minor_status */
66 	       gss_ctx_id_t *,         /* context_handle */
67 	       const gss_cred_id_t,    /* acceptor_cred_handle */
68 	       const gss_buffer_t,     /* input_token_buffer */
69 	       const gss_channel_bindings_t,
70 				       /* input_chan_bindings */
71 	       gss_name_t *,           /* src_name */
72 	       gss_OID *,              /* mech_type */
73 	       gss_buffer_t,           /* output_token */
74 	       OM_uint32 *,            /* ret_flags */
75 	       OM_uint32 *,            /* time_rec */
76 	       gss_cred_id_t *         /* delegated_cred_handle */
77 	      );
78 
79 typedef OM_uint32 _gss_process_context_token_t
80 	      (OM_uint32 *,            /* minor_status */
81 	       const gss_ctx_id_t,     /* context_handle */
82 	       const gss_buffer_t      /* token_buffer */
83 	      );
84 
85 typedef OM_uint32 _gss_delete_sec_context_t
86 	      (OM_uint32 *,            /* minor_status */
87 	       gss_ctx_id_t *,         /* context_handle */
88 	       gss_buffer_t            /* output_token */
89 	      );
90 
91 typedef OM_uint32 _gss_context_time_t
92 	      (OM_uint32 *,            /* minor_status */
93 	       const gss_ctx_id_t,     /* context_handle */
94 	       OM_uint32 *             /* time_rec */
95 	      );
96 
97 typedef OM_uint32 _gss_get_mic_t
98 	      (OM_uint32 *,            /* minor_status */
99 	       const gss_ctx_id_t,     /* context_handle */
100 	       gss_qop_t,              /* qop_req */
101 	       const gss_buffer_t,     /* message_buffer */
102 	       gss_buffer_t            /* message_token */
103 	      );
104 
105 typedef OM_uint32 _gss_verify_mic_t
106 	      (OM_uint32 *,            /* minor_status */
107 	       const gss_ctx_id_t,     /* context_handle */
108 	       const gss_buffer_t,     /* message_buffer */
109 	       const gss_buffer_t,     /* token_buffer */
110 	       gss_qop_t *             /* qop_state */
111 	      );
112 
113 typedef OM_uint32 _gss_wrap_t
114 	      (OM_uint32 *,            /* minor_status */
115 	       const gss_ctx_id_t,     /* context_handle */
116 	       int,                    /* conf_req_flag */
117 	       gss_qop_t,              /* qop_req */
118 	       const gss_buffer_t,     /* input_message_buffer */
119 	       int *,                  /* conf_state */
120 	       gss_buffer_t            /* output_message_buffer */
121 	      );
122 
123 typedef OM_uint32 _gss_unwrap_t
124 	      (OM_uint32 *,            /* minor_status */
125 	       const gss_ctx_id_t,     /* context_handle */
126 	       const gss_buffer_t,     /* input_message_buffer */
127 	       gss_buffer_t,           /* output_message_buffer */
128 	       int *,                  /* conf_state */
129 	       gss_qop_t *             /* qop_state */
130 	      );
131 
132 typedef OM_uint32 _gss_display_status_t
133 	      (OM_uint32 *,            /* minor_status */
134 	       OM_uint32,              /* status_value */
135 	       int,                    /* status_type */
136 	       const gss_OID,          /* mech_type */
137 	       OM_uint32 *,            /* message_context */
138 	       gss_buffer_t            /* status_string */
139 	      );
140 
141 typedef OM_uint32 _gss_indicate_mechs_t
142 	      (OM_uint32 *,            /* minor_status */
143 	       gss_OID_set *           /* mech_set */
144 	      );
145 
146 typedef OM_uint32 _gss_compare_name_t
147 	      (OM_uint32 *,            /* minor_status */
148 	       const gss_name_t,       /* name1 */
149 	       const gss_name_t,       /* name2 */
150 	       int *                   /* name_equal */
151 	      );
152 
153 typedef OM_uint32 _gss_display_name_t
154 	      (OM_uint32 *,            /* minor_status */
155 	       const gss_name_t,       /* input_name */
156 	       gss_buffer_t,           /* output_name_buffer */
157 	       gss_OID *               /* output_name_type */
158 	      );
159 
160 typedef OM_uint32 _gss_import_name_t
161 	      (OM_uint32 *,            /* minor_status */
162 	       const gss_buffer_t,     /* input_name_buffer */
163 	       const gss_OID,          /* input_name_type */
164 	       gss_name_t *            /* output_name */
165 	      );
166 
167 typedef OM_uint32 _gss_export_name_t
168 	      (OM_uint32 *,            /* minor_status */
169 	       const gss_name_t,       /* input_name */
170 	       gss_buffer_t            /* exported_name */
171 	      );
172 
173 typedef OM_uint32 _gss_release_name_t
174 	      (OM_uint32 *,            /* minor_status */
175 	       gss_name_t *            /* input_name */
176 	      );
177 
178 typedef OM_uint32 _gss_inquire_cred_t
179 	      (OM_uint32 *,            /* minor_status */
180 	       const gss_cred_id_t,    /* cred_handle */
181 	       gss_name_t *,           /* name */
182 	       OM_uint32 *,            /* lifetime */
183 	       gss_cred_usage_t *,     /* cred_usage */
184 	       gss_OID_set *           /* mechanisms */
185 	      );
186 
187 typedef OM_uint32 _gss_inquire_context_t
188 	      (OM_uint32 *,            /* minor_status */
189 	       const gss_ctx_id_t,     /* context_handle */
190 	       gss_name_t *,           /* src_name */
191 	       gss_name_t *,           /* targ_name */
192 	       OM_uint32 *,            /* lifetime_rec */
193 	       gss_OID *,              /* mech_type */
194 	       OM_uint32 *,            /* ctx_flags */
195 	       int *,                  /* locally_initiated */
196 	       int *                   /* open */
197 	      );
198 
199 typedef OM_uint32 _gss_wrap_size_limit_t
200 	      (OM_uint32 *,            /* minor_status */
201 	       const gss_ctx_id_t,     /* context_handle */
202 	       int,                    /* conf_req_flag */
203 	       gss_qop_t,              /* qop_req */
204 	       OM_uint32,              /* req_output_size */
205 	       OM_uint32 *             /* max_input_size */
206 	      );
207 
208 typedef OM_uint32 _gss_add_cred_t (
209 	       OM_uint32 *,            /* minor_status */
210 	       const gss_cred_id_t,    /* input_cred_handle */
211 	       const gss_name_t,       /* desired_name */
212 	       const gss_OID,          /* desired_mech */
213 	       gss_cred_usage_t,       /* cred_usage */
214 	       OM_uint32,              /* initiator_time_req */
215 	       OM_uint32,              /* acceptor_time_req */
216 	       gss_cred_id_t *,        /* output_cred_handle */
217 	       gss_OID_set *,          /* actual_mechs */
218 	       OM_uint32 *,            /* initiator_time_rec */
219 	       OM_uint32 *             /* acceptor_time_rec */
220 	      );
221 
222 typedef OM_uint32 _gss_inquire_cred_by_mech_t (
223 	       OM_uint32 *,            /* minor_status */
224 	       const gss_cred_id_t,    /* cred_handle */
225 	       const gss_OID,          /* mech_type */
226 	       gss_name_t *,           /* name */
227 	       OM_uint32 *,            /* initiator_lifetime */
228 	       OM_uint32 *,            /* acceptor_lifetime */
229 	       gss_cred_usage_t *      /* cred_usage */
230 	      );
231 
232 typedef OM_uint32 _gss_export_sec_context_t (
233 	       OM_uint32 *,            /* minor_status */
234 	       gss_ctx_id_t *,         /* context_handle */
235 	       gss_buffer_t            /* interprocess_token */
236 	      );
237 
238 typedef OM_uint32 _gss_import_sec_context_t (
239 	       OM_uint32 *,            /* minor_status */
240 	       const gss_buffer_t,     /* interprocess_token */
241 	       gss_ctx_id_t *          /* context_handle */
242 	      );
243 
244 typedef OM_uint32 _gss_inquire_names_for_mech_t (
245 	       OM_uint32 *,            /* minor_status */
246 	       const gss_OID,          /* mechanism */
247 	       gss_OID_set *           /* name_types */
248 	      );
249 
250 typedef OM_uint32 _gss_inquire_mechs_for_name_t (
251 	       OM_uint32 *,            /* minor_status */
252 	       const gss_name_t,       /* input_name */
253 	       gss_OID_set *           /* mech_types */
254 	      );
255 
256 typedef OM_uint32 _gss_canonicalize_name_t (
257 	       OM_uint32 *,            /* minor_status */
258 	       const gss_name_t,       /* input_name */
259 	       const gss_OID,          /* mech_type */
260 	       gss_name_t *            /* output_name */
261 	      );
262 
263 typedef OM_uint32 _gss_duplicate_name_t (
264 	       OM_uint32 *,            /* minor_status */
265 	       const gss_name_t,       /* src_name */
266 	       gss_name_t *            /* dest_name */
267 	      );
268 
269 typedef OM_uint32 _gsskrb5_register_acceptor_identity (
270 	       const char *	       /* identity */
271 	      );
272 
273 typedef OM_uint32 _gss_krb5_copy_ccache (
274 	       OM_uint32 *,	       /* minor_status */
275 	       gss_cred_id_t,	       /* cred_handle */
276 	       struct krb5_ccache_data * /* out */
277 	      );
278 
279 typedef OM_uint32 _gss_krb5_compat_des3_mic (
280 	       OM_uint32 *,	       /* minor_status */
281 	       gss_ctx_id_t,	       /* context_handle */
282 	       int		       /* flag */
283 	      );
284 
285 struct _gss_mech_switch {
286 	SLIST_ENTRY(_gss_mech_switch)	gm_link;
287 	gss_OID_desc			gm_mech_oid;
288 	void				*gm_so;
289 	_gss_acquire_cred_t		*gm_acquire_cred;
290 	_gss_release_cred_t		*gm_release_cred;
291 	_gss_init_sec_context_t		*gm_init_sec_context;
292 	_gss_accept_sec_context_t	*gm_accept_sec_context;
293 	_gss_process_context_token_t	*gm_process_context_token;
294 	_gss_delete_sec_context_t	*gm_delete_sec_context;
295 	_gss_context_time_t		*gm_context_time;
296 	_gss_get_mic_t			*gm_get_mic;
297 	_gss_verify_mic_t		*gm_verify_mic;
298 	_gss_wrap_t			*gm_wrap;
299 	_gss_unwrap_t			*gm_unwrap;
300 	_gss_display_status_t		*gm_display_status;
301 	_gss_indicate_mechs_t		*gm_indicate_mechs;
302 	_gss_compare_name_t		*gm_compare_name;
303 	_gss_display_name_t		*gm_display_name;
304 	_gss_import_name_t		*gm_import_name;
305 	_gss_export_name_t		*gm_export_name;
306 	_gss_release_name_t		*gm_release_name;
307 	_gss_inquire_cred_t		*gm_inquire_cred;
308 	_gss_inquire_context_t		*gm_inquire_context;
309 	_gss_wrap_size_limit_t		*gm_wrap_size_limit;
310 	_gss_add_cred_t			*gm_add_cred;
311 	_gss_inquire_cred_by_mech_t	*gm_inquire_cred_by_mech;
312 	_gss_export_sec_context_t	*gm_export_sec_context;
313 	_gss_import_sec_context_t	*gm_import_sec_context;
314 	_gss_inquire_names_for_mech_t	*gm_inquire_names_for_mech;
315 	_gss_inquire_mechs_for_name_t	*gm_inquire_mechs_for_name;
316 	_gss_canonicalize_name_t	*gm_canonicalize_name;
317 	_gss_duplicate_name_t		*gm_duplicate_name;
318 	_gsskrb5_register_acceptor_identity *gm_krb5_register_acceptor_identity;
319 	_gss_krb5_copy_ccache		*gm_krb5_copy_ccache;
320 	_gss_krb5_compat_des3_mic	*gm_krb5_compat_des3_mic;
321 };
322 SLIST_HEAD(_gss_mech_switch_list, _gss_mech_switch);
323 extern struct _gss_mech_switch_list _gss_mechs;
324 extern gss_OID_set _gss_mech_oids;
325 
326 extern void _gss_load_mech(void);
327 extern struct _gss_mech_switch *_gss_find_mech_switch(gss_OID);
328