s4:torture: Adapt KDC canon test to Heimdal upstream changes
[samba.git] / source4 / heimdal / lib / gssapi / gssapi_mech.h
1 /*-
2  * Copyright (c) 2005 Doug Rabson
3  * Copyright (c) 2018 Kungliga Tekniska Högskolan
4  * (Royal Institute of Technology, Stockholm, Sweden).
5  * All rights reserved.
6  *
7  * Portions Copyright (c) 2009 Apple Inc. All rights reserved.
8  *
9  * Redistribution and use in source and binary forms, with or without
10  * modification, are permitted provided that the following conditions
11  * are met:
12  * 1. Redistributions of source code must retain the above copyright
13  *    notice, this list of conditions and the following disclaimer.
14  * 2. Redistributions in binary form must reproduce the above copyright
15  *    notice, this list of conditions and the following disclaimer in the
16  *    documentation and/or other materials provided with the distribution.
17  *
18  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
19  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
22  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28  * SUCH DAMAGE.
29  *
30  *      $FreeBSD: src/lib/libgssapi/mech_switch.h,v 1.1 2005/12/29 14:40:20 dfr Exp $
31  */
32
33 #ifndef GSSAPI_MECH_H
34 #define GSSAPI_MECH_H 1
35
36 #include <gssapi.h>
37
38 typedef OM_uint32 GSSAPI_CALLCONV _gss_acquire_cred_t
39               (OM_uint32 *,            /* minor_status */
40                gss_const_name_t,       /* desired_name */
41                OM_uint32,              /* time_req */
42                const gss_OID_set,      /* desired_mechs */
43                gss_cred_usage_t,       /* cred_usage */
44                gss_cred_id_t *,        /* output_cred_handle */
45                gss_OID_set *,          /* actual_mechs */
46                OM_uint32 *             /* time_rec */
47               );
48
49 typedef OM_uint32 GSSAPI_CALLCONV _gss_release_cred_t
50               (OM_uint32 *,            /* minor_status */
51                gss_cred_id_t *         /* cred_handle */
52               );
53
54 typedef OM_uint32 GSSAPI_CALLCONV _gss_init_sec_context_t
55               (OM_uint32 *,            /* minor_status */
56                gss_const_cred_id_t,    /* initiator_cred_handle */
57                gss_ctx_id_t *,         /* context_handle */
58                gss_const_name_t,       /* target_name */
59                const gss_OID,          /* mech_type */
60                OM_uint32,              /* req_flags */
61                OM_uint32,              /* time_req */
62                const gss_channel_bindings_t,
63                                        /* input_chan_bindings */
64                const gss_buffer_t,     /* input_token */
65                gss_OID *,              /* actual_mech_type */
66                gss_buffer_t,           /* output_token */
67                OM_uint32 *,            /* ret_flags */
68                OM_uint32 *             /* time_rec */
69               );
70
71 typedef OM_uint32 GSSAPI_CALLCONV _gss_accept_sec_context_t
72               (OM_uint32 *,            /* minor_status */
73                gss_ctx_id_t *,         /* context_handle */
74                gss_const_cred_id_t,    /* acceptor_cred_handle */
75                const gss_buffer_t,     /* input_token_buffer */
76                const gss_channel_bindings_t,
77                                        /* input_chan_bindings */
78                gss_name_t *,           /* src_name */
79                gss_OID *,              /* mech_type */
80                gss_buffer_t,           /* output_token */
81                OM_uint32 *,            /* ret_flags */
82                OM_uint32 *,            /* time_rec */
83                gss_cred_id_t *         /* delegated_cred_handle */
84               );
85
86 typedef OM_uint32 GSSAPI_CALLCONV _gss_process_context_token_t
87               (OM_uint32 *,            /* minor_status */
88                gss_const_ctx_id_t,     /* context_handle */
89                const gss_buffer_t      /* token_buffer */
90               );
91
92 typedef OM_uint32 GSSAPI_CALLCONV _gss_delete_sec_context_t
93               (OM_uint32 *,            /* minor_status */
94                gss_ctx_id_t *,         /* context_handle */
95                gss_buffer_t            /* output_token */
96               );
97
98 typedef OM_uint32 GSSAPI_CALLCONV _gss_context_time_t
99               (OM_uint32 *,            /* minor_status */
100                gss_const_ctx_id_t,     /* context_handle */
101                OM_uint32 *             /* time_rec */
102               );
103
104 typedef OM_uint32 GSSAPI_CALLCONV _gss_get_mic_t
105               (OM_uint32 *,            /* minor_status */
106                gss_const_ctx_id_t,     /* context_handle */
107                gss_qop_t,              /* qop_req */
108                const gss_buffer_t,     /* message_buffer */
109                gss_buffer_t            /* message_token */
110               );
111
112 typedef OM_uint32 GSSAPI_CALLCONV _gss_verify_mic_t
113               (OM_uint32 *,            /* minor_status */
114                gss_const_ctx_id_t,     /* context_handle */
115                const gss_buffer_t,     /* message_buffer */
116                const gss_buffer_t,     /* token_buffer */
117                gss_qop_t *             /* qop_state */
118               );
119
120 typedef OM_uint32 GSSAPI_CALLCONV _gss_wrap_t
121               (OM_uint32 *,            /* minor_status */
122                gss_const_ctx_id_t,     /* context_handle */
123                int,                    /* conf_req_flag */
124                gss_qop_t,              /* qop_req */
125                const gss_buffer_t,     /* input_message_buffer */
126                int *,                  /* conf_state */
127                gss_buffer_t            /* output_message_buffer */
128               );
129
130 typedef OM_uint32 GSSAPI_CALLCONV _gss_unwrap_t
131               (OM_uint32 *,            /* minor_status */
132                gss_const_ctx_id_t,     /* context_handle */
133                const gss_buffer_t,     /* input_message_buffer */
134                gss_buffer_t,           /* output_message_buffer */
135                int *,                  /* conf_state */
136                gss_qop_t *             /* qop_state */
137               );
138
139 typedef OM_uint32 GSSAPI_CALLCONV _gss_display_status_t
140               (OM_uint32 *,            /* minor_status */
141                OM_uint32,              /* status_value */
142                int,                    /* status_type */
143                const gss_OID,          /* mech_type */
144                OM_uint32 *,            /* message_context */
145                gss_buffer_t            /* status_string */
146               );
147
148 typedef OM_uint32 GSSAPI_CALLCONV _gss_indicate_mechs_t
149               (OM_uint32 *,            /* minor_status */
150                gss_OID_set *           /* mech_set */
151               );
152
153 typedef OM_uint32 GSSAPI_CALLCONV _gss_compare_name_t
154               (OM_uint32 *,            /* minor_status */
155                gss_const_name_t,       /* name1 */
156                gss_const_name_t,       /* name2 */
157                int *                   /* name_equal */
158               );
159
160 typedef OM_uint32 GSSAPI_CALLCONV _gss_display_name_t
161               (OM_uint32 *,            /* minor_status */
162                gss_const_name_t,       /* input_name */
163                gss_buffer_t,           /* output_name_buffer */
164                gss_OID *               /* output_name_type */
165               );
166
167 typedef OM_uint32 GSSAPI_CALLCONV _gss_import_name_t
168               (OM_uint32 *,            /* minor_status */
169                const gss_buffer_t,     /* input_name_buffer */
170                const gss_OID,          /* input_name_type */
171                gss_name_t *            /* output_name */
172               );
173
174 typedef OM_uint32 GSSAPI_CALLCONV _gss_export_name_t
175               (OM_uint32 *,            /* minor_status */
176                gss_const_name_t,       /* input_name */
177                gss_buffer_t            /* exported_name */
178               );
179
180 typedef OM_uint32 GSSAPI_CALLCONV _gss_release_name_t
181               (OM_uint32 *,            /* minor_status */
182                gss_name_t *            /* input_name */
183               );
184
185 typedef OM_uint32 GSSAPI_CALLCONV _gss_inquire_cred_t
186               (OM_uint32 *,            /* minor_status */
187                gss_const_cred_id_t,    /* cred_handle */
188                gss_name_t *,           /* name */
189                OM_uint32 *,            /* lifetime */
190                gss_cred_usage_t *,     /* cred_usage */
191                gss_OID_set *           /* mechanisms */
192               );
193
194 typedef OM_uint32 GSSAPI_CALLCONV _gss_inquire_context_t
195               (OM_uint32 *,            /* minor_status */
196                gss_const_ctx_id_t,     /* context_handle */
197                gss_name_t *,           /* src_name */
198                gss_name_t *,           /* targ_name */
199                OM_uint32 *,            /* lifetime_rec */
200                gss_OID *,              /* mech_type */
201                OM_uint32 *,            /* ctx_flags */
202                int *,                  /* locally_initiated */
203                int *                   /* open */
204               );
205
206 typedef OM_uint32 GSSAPI_CALLCONV _gss_wrap_size_limit_t
207               (OM_uint32 *,            /* minor_status */
208                gss_const_ctx_id_t,     /* context_handle */
209                int,                    /* conf_req_flag */
210                gss_qop_t,              /* qop_req */
211                OM_uint32,              /* req_output_size */
212                OM_uint32 *             /* max_input_size */
213               );
214
215 typedef OM_uint32 GSSAPI_CALLCONV _gss_add_cred_t (
216                OM_uint32 *,            /* minor_status */
217                gss_const_cred_id_t,    /* input_cred_handle */
218                gss_const_name_t,       /* desired_name */
219                const gss_OID,          /* desired_mech */
220                gss_cred_usage_t,       /* cred_usage */
221                OM_uint32,              /* initiator_time_req */
222                OM_uint32,              /* acceptor_time_req */
223                gss_cred_id_t *,        /* output_cred_handle */
224                gss_OID_set *,          /* actual_mechs */
225                OM_uint32 *,            /* initiator_time_rec */
226                OM_uint32 *             /* acceptor_time_rec */
227               );
228
229 typedef OM_uint32 GSSAPI_CALLCONV _gss_duplicate_cred_t (
230                OM_uint32 *,            /* minor_status */
231                gss_const_cred_id_t,    /* input_cred_handle */
232                gss_cred_id_t *         /* output_cred_handle */
233               );
234
235 typedef OM_uint32 GSSAPI_CALLCONV _gss_inquire_cred_by_mech_t (
236                OM_uint32 *,            /* minor_status */
237                gss_const_cred_id_t,    /* cred_handle */
238                const gss_OID,          /* mech_type */
239                gss_name_t *,           /* name */
240                OM_uint32 *,            /* initiator_lifetime */
241                OM_uint32 *,            /* acceptor_lifetime */
242                gss_cred_usage_t *      /* cred_usage */
243               );
244
245 typedef OM_uint32 GSSAPI_CALLCONV _gss_export_sec_context_t (
246                OM_uint32 *,            /* minor_status */
247                gss_ctx_id_t *,         /* context_handle */
248                gss_buffer_t            /* interprocess_token */
249               );
250
251 typedef OM_uint32 GSSAPI_CALLCONV _gss_import_sec_context_t (
252                OM_uint32 *,            /* minor_status */
253                const gss_buffer_t,     /* interprocess_token */
254                gss_ctx_id_t *          /* context_handle */
255               );
256
257 typedef OM_uint32 GSSAPI_CALLCONV _gss_inquire_names_for_mech_t (
258                OM_uint32 *,            /* minor_status */
259                const gss_OID,          /* mechanism */
260                gss_OID_set *           /* name_types */
261               );
262
263 typedef OM_uint32 GSSAPI_CALLCONV _gss_inquire_mechs_for_name_t (
264                OM_uint32 *,            /* minor_status */
265                gss_const_name_t,       /* input_name */
266                gss_OID_set *           /* mech_types */
267               );
268
269 typedef OM_uint32 GSSAPI_CALLCONV _gss_canonicalize_name_t (
270                OM_uint32 *,            /* minor_status */
271                gss_const_name_t,       /* input_name */
272                const gss_OID,          /* mech_type */
273                gss_name_t *            /* output_name */
274               );
275
276 typedef OM_uint32 GSSAPI_CALLCONV _gss_duplicate_name_t (
277                OM_uint32 *,            /* minor_status */
278                gss_const_name_t,       /* src_name */
279                gss_name_t *            /* dest_name */
280               );
281
282 typedef OM_uint32 GSSAPI_CALLCONV _gss_inquire_sec_context_by_oid_t (
283                OM_uint32 *minor_status,
284                gss_const_ctx_id_t context_handle,
285                const gss_OID desired_object,
286                gss_buffer_set_t *data_set
287               );
288
289 typedef OM_uint32 GSSAPI_CALLCONV _gss_inquire_cred_by_oid_t (
290                OM_uint32 *minor_status,
291                gss_const_cred_id_t cred,
292                const gss_OID desired_object,
293                gss_buffer_set_t *data_set
294               );
295
296 typedef OM_uint32 GSSAPI_CALLCONV _gss_set_sec_context_option_t (
297                OM_uint32 *minor_status,
298                gss_ctx_id_t *cred_handle,
299                const gss_OID desired_object,
300                const gss_buffer_t value
301               );
302
303 typedef OM_uint32 GSSAPI_CALLCONV _gss_set_cred_option_t (
304                OM_uint32 *minor_status,
305                gss_cred_id_t *cred_handle,
306                const gss_OID desired_object,
307                const gss_buffer_t value
308               );
309
310
311 typedef OM_uint32 GSSAPI_CALLCONV _gss_pseudo_random_t (
312                OM_uint32 *minor_status,
313                gss_ctx_id_t context,
314                int prf_key,
315                const gss_buffer_t prf_in,
316                ssize_t desired_output_len,
317                gss_buffer_t prf_out
318               );
319
320 typedef OM_uint32 GSSAPI_CALLCONV
321 _gss_wrap_iov_t(OM_uint32 *minor_status,
322                 gss_ctx_id_t  context_handle,
323                 int conf_req_flag,
324                 gss_qop_t qop_req,
325                 int * conf_state,
326                 gss_iov_buffer_desc *iov,
327                 int iov_count);
328
329 typedef OM_uint32 GSSAPI_CALLCONV
330 _gss_unwrap_iov_t(OM_uint32 *minor_status,
331                   gss_ctx_id_t context_handle,
332                   int *conf_state,
333                   gss_qop_t *qop_state,
334                   gss_iov_buffer_desc *iov,
335                   int iov_count);
336
337 typedef OM_uint32 GSSAPI_CALLCONV
338 _gss_wrap_iov_length_t(OM_uint32 * minor_status,
339                        gss_ctx_id_t context_handle,
340                        int conf_req_flag,
341                        gss_qop_t qop_req,
342                        int *conf_state,
343                        gss_iov_buffer_desc *iov,
344                        int iov_count);
345
346 typedef OM_uint32 GSSAPI_CALLCONV
347 _gss_store_cred_t(OM_uint32         *minor_status,
348                   gss_cred_id_t     input_cred_handle,
349                   gss_cred_usage_t  cred_usage,
350                   const gss_OID     desired_mech,
351                   OM_uint32         overwrite_cred,
352                   OM_uint32         default_cred,
353                   gss_OID_set       *elements_stored,
354                   gss_cred_usage_t  *cred_usage_stored);
355
356 typedef OM_uint32 GSSAPI_CALLCONV
357 _gss_export_cred_t(OM_uint32 *minor_status,
358                    gss_cred_id_t cred_handle,
359                    gss_buffer_t cred_token);
360
361 typedef OM_uint32 GSSAPI_CALLCONV
362 _gss_import_cred_t(OM_uint32 * minor_status,
363                    gss_buffer_t cred_token,
364                    gss_cred_id_t * cred_handle);
365  
366 typedef void GSSAPI_CALLCONV
367 _gss_iter_creds_t(OM_uint32 /* flags */,
368                   void * /* userctx */,
369                   void (* /*cred_iter */ )(void *, gss_OID, gss_cred_id_t));
370
371 typedef OM_uint32 GSSAPI_CALLCONV
372 _gss_destroy_cred_t(OM_uint32 * /* minor_status */,
373                     gss_cred_id_t * /* cred */);
374
375 typedef OM_uint32 GSSAPI_CALLCONV
376 _gss_cred_hold_t(OM_uint32 * /* minor_status */,
377                  gss_cred_id_t /* cred */);
378
379 typedef OM_uint32 GSSAPI_CALLCONV
380 _gss_cred_unhold_t(OM_uint32 * /* minor_status */,
381                    gss_cred_id_t /* cred */);
382
383 typedef OM_uint32 GSSAPI_CALLCONV
384 _gss_cred_label_set_t(OM_uint32 * /* minor_status */,
385                       gss_cred_id_t /* cred */,
386                       const char * /* label */,
387                       gss_buffer_t /* value */);
388
389 typedef OM_uint32 GSSAPI_CALLCONV
390 _gss_cred_label_get_t(OM_uint32 * /* minor_status */,
391                       gss_cred_id_t /* cred */,
392                       const char * /* label */,
393                       gss_buffer_t /* value */);
394
395 typedef OM_uint32 GSSAPI_CALLCONV _gss_display_name_ext_t (
396                OM_uint32 *,            /* minor_status */
397                gss_name_t,             /* name */
398                gss_OID,                /* display_as_name_type */
399                gss_buffer_t            /* display_name */
400               );
401
402 typedef OM_uint32 GSSAPI_CALLCONV _gss_inquire_name_t (
403                OM_uint32 *,            /* minor_status */
404                gss_name_t,             /* name */
405                int *,                  /* name_is_MN */
406                gss_OID *,              /* MN_mech */
407                gss_buffer_set_t *      /* attrs */
408               );
409
410 typedef OM_uint32 GSSAPI_CALLCONV _gss_get_name_attribute_t (
411                OM_uint32 *,           /* minor_status */
412                gss_name_t,            /* name */
413                gss_buffer_t,          /* attr */
414                int *,                 /* authenticated */
415                int *,                 /* complete */
416                gss_buffer_t,          /* value */
417                gss_buffer_t,          /* display_value */
418                int *                  /* more */
419             );
420
421 typedef OM_uint32 GSSAPI_CALLCONV _gss_set_name_attribute_t (
422                OM_uint32 *,           /* minor_status */
423                gss_name_t,            /* name */
424                int,                   /* complete */
425                gss_buffer_t,          /* attr */
426                gss_buffer_t           /* value */
427             );
428
429 typedef OM_uint32 GSSAPI_CALLCONV _gss_delete_name_attribute_t (
430                OM_uint32 *,           /* minor_status */
431                gss_name_t,            /* name */
432                gss_buffer_t           /* attr */
433             );
434
435 typedef OM_uint32 GSSAPI_CALLCONV _gss_export_name_composite_t (
436                OM_uint32 *,           /* minor_status */
437                gss_name_t,            /* name */
438                gss_buffer_t           /* exp_composite_name */
439             );
440
441 typedef OM_uint32 GSSAPI_CALLCONV
442 _gss_acquire_cred_from_t(OM_uint32 *minor_status,
443                          gss_const_name_t desired_name,
444                          OM_uint32 time_req,
445                          gss_OID_set desired_mechs,
446                          gss_cred_usage_t cred_usage,
447                          gss_const_key_value_set_t cred_store,
448                          gss_cred_id_t *output_cred_handle,
449                          gss_OID_set *actual_mechs,
450                          OM_uint32 *time_rec);
451
452 typedef OM_uint32 GSSAPI_CALLCONV
453 _gss_acquire_cred_impersonate_name_t(OM_uint32 *minor_status,
454                                      gss_const_cred_id_t icred,
455                                      gss_const_name_t desired_name,
456                                      OM_uint32 time_req,
457                                      gss_OID_set desired_mechs,
458                                      gss_cred_usage_t cred_usage,
459                                      gss_cred_id_t *output_cred_handle,
460                                      gss_OID_set *actual_mechs,
461                                      OM_uint32 *time_rec);
462
463 typedef OM_uint32 GSSAPI_CALLCONV
464 _gss_add_cred_from_t(OM_uint32 *minor_status,
465                      gss_cred_id_t input_cred_handle,
466                      gss_const_name_t desired_name,
467                      const gss_OID desired_mech,
468                      gss_cred_usage_t cred_usage,
469                      OM_uint32 initiator_time_req,
470                      OM_uint32 acceptor_time_req,
471                      gss_const_key_value_set_t cred_store,
472                      gss_cred_id_t *output_cred_handle,
473                      gss_OID_set *actual_mechs,
474                      OM_uint32 *initiator_time_rec,
475                      OM_uint32 *acceptor_time_rec);
476
477 typedef OM_uint32 GSSAPI_CALLCONV
478 _gss_store_cred_into_t(OM_uint32 *minor_status,
479                        gss_const_cred_id_t input_cred_handle,
480                        gss_cred_usage_t input_usage,
481                        gss_OID desired_mech,
482                        OM_uint32 overwrite_cred,
483                        OM_uint32 default_cred,
484                        gss_const_key_value_set_t cred_store,
485                        gss_OID_set *elements_stored,
486                        gss_cred_usage_t *cred_usage_stored);
487
488 typedef OM_uint32 GSSAPI_CALLCONV
489 _gss_store_cred_into2_t(OM_uint32 *minor_status,
490                         gss_const_cred_id_t input_cred_handle,
491                         gss_cred_usage_t input_usage,
492                         gss_OID desired_mech,
493                         OM_uint32 store_cred_flags,
494                         gss_const_key_value_set_t cred_store,
495                         gss_OID_set *elements_stored,
496                         gss_cred_usage_t *cred_usage_stored,
497                         gss_buffer_set_t *env);
498
499 typedef OM_uint32 GSSAPI_CALLCONV
500 _gss_query_mechanism_info_t(OM_uint32 *minor_status,
501                             gss_const_OID mech_oid,
502                             unsigned char auth_scheme[16]);
503
504 typedef OM_uint32 GSSAPI_CALLCONV
505 _gss_query_meta_data_t(OM_uint32 *minor_status,
506                        gss_const_OID mech_oid,
507                        gss_cred_id_t cred_handle,
508                        gss_ctx_id_t *ctx_handle,
509                        gss_const_name_t targ_name,
510                        OM_uint32 req_flags,
511                        gss_buffer_t meta_data);
512
513 typedef OM_uint32 GSSAPI_CALLCONV
514 _gss_exchange_meta_data_t(OM_uint32 *minor_status,
515                           gss_const_OID mech_oid,
516                           gss_cred_id_t cred_handle,
517                           gss_ctx_id_t *ctx_handle,
518                           gss_const_name_t targ_name,
519                           OM_uint32 req_flags,
520                           gss_const_buffer_t meta_data);
521
522 /*
523  *
524  */
525
526 typedef struct gss_mo_desc_struct gss_mo_desc;
527
528 typedef OM_uint32 GSSAPI_CALLCONV
529 _gss_mo_init (OM_uint32 *, gss_OID, gss_mo_desc **, size_t *);
530
531
532 struct gss_mo_desc_struct {
533     gss_OID option;
534     OM_uint32 flags;
535 #define GSS_MO_MA               1
536 #define GSS_MO_MA_CRITICAL      2
537     const char *name;
538     void *ctx;
539     int (*get)(gss_const_OID, gss_mo_desc *, gss_buffer_t);
540     int (*set)(gss_const_OID, gss_mo_desc *, int, gss_buffer_t);
541 };
542
543 typedef OM_uint32 GSSAPI_CALLCONV _gss_localname_t (
544                OM_uint32 *,             /* minor_status */
545                gss_const_name_t,        /* name */
546                const gss_OID,           /* mech_type */
547                gss_buffer_t             /* localname */
548               );
549
550 typedef OM_uint32 GSSAPI_CALLCONV _gss_authorize_localname_t (
551                OM_uint32 *,             /* minor_status */
552                gss_const_name_t,        /* name */
553                gss_const_buffer_t,      /* user */
554                gss_const_OID            /* user_name_type */
555               );
556
557 struct _gss_name;
558 struct _gss_cred;
559
560 /* mechglue internal */
561 struct gss_mech_compat_desc_struct;
562
563 #define GMI_VERSION 6
564
565 /* gm_flags */
566 #define GM_USE_MG_CRED          1       /* uses mech glue credentials */
567 #define GM_USE_MG_NAME          2       /* uses mech glue names       */
568
569 typedef struct gssapi_mech_interface_desc {
570         unsigned                        gm_version;
571         const char                      *gm_name;
572         gss_OID_desc                    gm_mech_oid;
573         unsigned                        gm_flags;
574         _gss_acquire_cred_t             *gm_acquire_cred;
575         _gss_release_cred_t             *gm_release_cred;
576         _gss_init_sec_context_t         *gm_init_sec_context;
577         _gss_accept_sec_context_t       *gm_accept_sec_context;
578         _gss_process_context_token_t    *gm_process_context_token;
579         _gss_delete_sec_context_t       *gm_delete_sec_context;
580         _gss_context_time_t             *gm_context_time;
581         _gss_get_mic_t                  *gm_get_mic;
582         _gss_verify_mic_t               *gm_verify_mic;
583         _gss_wrap_t                     *gm_wrap;
584         _gss_unwrap_t                   *gm_unwrap;
585         _gss_display_status_t           *gm_display_status;
586         _gss_indicate_mechs_t           *gm_indicate_mechs;
587         _gss_compare_name_t             *gm_compare_name;
588         _gss_display_name_t             *gm_display_name;
589         _gss_import_name_t              *gm_import_name;
590         _gss_export_name_t              *gm_export_name;
591         _gss_release_name_t             *gm_release_name;
592         _gss_inquire_cred_t             *gm_inquire_cred;
593         _gss_inquire_context_t          *gm_inquire_context;
594         _gss_wrap_size_limit_t          *gm_wrap_size_limit;
595         _gss_add_cred_t                 *gm_add_cred;
596         _gss_inquire_cred_by_mech_t     *gm_inquire_cred_by_mech;
597         _gss_export_sec_context_t       *gm_export_sec_context;
598         _gss_import_sec_context_t       *gm_import_sec_context;
599         _gss_inquire_names_for_mech_t   *gm_inquire_names_for_mech;
600         _gss_inquire_mechs_for_name_t   *gm_inquire_mechs_for_name;
601         _gss_canonicalize_name_t        *gm_canonicalize_name;
602         _gss_duplicate_name_t           *gm_duplicate_name;
603         _gss_inquire_sec_context_by_oid_t       *gm_inquire_sec_context_by_oid;
604         _gss_inquire_cred_by_oid_t      *gm_inquire_cred_by_oid;
605         _gss_set_sec_context_option_t   *gm_set_sec_context_option;
606         _gss_set_cred_option_t          *gm_set_cred_option;
607         _gss_pseudo_random_t            *gm_pseudo_random;
608         _gss_wrap_iov_t                 *gm_wrap_iov;
609         _gss_unwrap_iov_t               *gm_unwrap_iov;
610         _gss_wrap_iov_length_t          *gm_wrap_iov_length;
611         _gss_store_cred_t               *gm_store_cred;
612         _gss_export_cred_t              *gm_export_cred;
613         _gss_import_cred_t              *gm_import_cred;
614         _gss_acquire_cred_from_t        *gm_acquire_cred_from; /* was acquire_cred_ext */
615         _gss_acquire_cred_impersonate_name_t    *gm_acquire_cred_impersonate_name;
616         _gss_iter_creds_t               *gm_iter_creds;
617         _gss_destroy_cred_t             *gm_destroy_cred;
618         _gss_cred_hold_t                *gm_cred_hold;
619         _gss_cred_unhold_t              *gm_cred_unhold;
620         _gss_cred_label_get_t           *gm_cred_label_get;
621         _gss_cred_label_set_t           *gm_cred_label_set;
622         gss_mo_desc                     *gm_mo;
623         size_t                           gm_mo_num;
624         _gss_localname_t                *gm_localname;
625         _gss_authorize_localname_t      *gm_authorize_localname;
626         _gss_display_name_ext_t         *gm_display_name_ext;
627         _gss_inquire_name_t             *gm_inquire_name;
628         _gss_get_name_attribute_t       *gm_get_name_attribute;
629         _gss_set_name_attribute_t       *gm_set_name_attribute;
630         _gss_delete_name_attribute_t    *gm_delete_name_attribute;
631         _gss_export_name_composite_t    *gm_export_name_composite;
632         _gss_duplicate_cred_t           *gm_duplicate_cred;
633         _gss_add_cred_from_t            *gm_add_cred_from;
634         _gss_store_cred_into_t          *gm_store_cred_into;
635         _gss_query_mechanism_info_t     *gm_query_mechanism_info;
636         _gss_query_meta_data_t          *gm_query_meta_data;
637         _gss_exchange_meta_data_t       *gm_exchange_meta_data;
638         _gss_store_cred_into2_t         *gm_store_cred_into2;
639         struct gss_mech_compat_desc_struct  *gm_compat;
640 } gssapi_mech_interface_desc, *gssapi_mech_interface;
641
642 gssapi_mech_interface
643 __gss_get_mechanism(gss_const_OID /* oid */);
644
645 gss_OID
646 _gss_mg_support_mechanism(gss_const_OID mech);
647
648 gssapi_mech_interface __gss_spnego_initialize(void);
649 gssapi_mech_interface __gss_krb5_initialize(void);
650 gssapi_mech_interface __gss_ntlm_initialize(void);
651 gssapi_mech_interface __gss_sanon_initialize(void);
652
653 void            gss_mg_collect_error(gss_OID, OM_uint32, OM_uint32);
654
655 int _gss_mo_get_option_1(gss_const_OID, gss_mo_desc *, gss_buffer_t);
656 int _gss_mo_get_option_0(gss_const_OID, gss_mo_desc *, gss_buffer_t);
657 int _gss_mo_get_ctx_as_string(gss_const_OID, gss_mo_desc *, gss_buffer_t);
658
659 struct _gss_name_type {
660     gss_OID    gnt_name_type;
661     OM_uint32  (*gnt_parse)(OM_uint32 *, gss_const_OID, const gss_buffer_t,
662                             gss_const_OID, gss_name_t *);
663 };
664
665 struct _gss_oid_name_table {
666     gss_OID oid;
667     const char *name;
668     const char *short_desc;
669     const char *long_desc;
670 };
671
672 extern struct _gss_oid_name_table _gss_ont_mech[];
673 extern struct _gss_oid_name_table _gss_ont_ma[];
674
675 int
676 _gss_mg_log_level(int level);
677
678 void
679 _gss_mg_log(int level, const char *fmt, ...)
680     HEIMDAL_PRINTF_ATTRIBUTE((printf, 2, 3));
681
682 void
683 _gss_mg_log_name(int level,
684                  struct _gss_name *name,
685                  gss_OID mech_type,
686                  const char *fmt, ...);
687
688 void
689 _gss_mg_log_cred(int level,
690                  struct _gss_cred *cred,
691                  const char *fmt, ...);
692
693
694 void
695 _gss_load_plugins(void);
696
697 gss_iov_buffer_desc *
698 _gss_mg_find_buffer(gss_iov_buffer_desc *iov,
699                     int iov_count,
700                     OM_uint32 type);
701
702 OM_uint32
703 _gss_mg_allocate_buffer(OM_uint32 *minor_status,
704                         gss_iov_buffer_desc *buffer,
705                         size_t size);
706
707 OM_uint32
708 gss_mg_set_error_string(gss_OID mech,
709                        OM_uint32 maj, OM_uint32 min,
710                        const char *fmt, ...);
711
712 gss_cred_id_t
713 _gss_mg_find_mech_cred(gss_const_cred_id_t cred_handle,
714                        gss_const_OID mech_type);
715
716 #include <krb5.h>
717
718 /*
719  * Mechglue krb5 context for use by NegoEx. This is not shared with the
720  * krb5 GSS mechanism so we don't clobber its error state.
721  */
722 krb5_context
723 _gss_mg_krb5_context(void);
724
725 #endif /* GSSAPI_MECH_H */