g_glue.c (__gss_get_mech_type): Fix code to properly parse token
[krb5.git] / src / lib / gssapi / mechglue / mglueP.h
1 #ident  "@(#)mglueP.h 1.2     96/01/18 SMI"
2 /*
3  * This header contains the private mechglue definitions.
4  *
5  * Copyright (c) 1995, by Sun Microsystems, Inc.
6  * All rights reserved.
7  */
8
9 #ifndef _GSS_MECHGLUEP_H
10 #define _GSS_MECHGLUEP_H
11
12 #include "mechglue.h"
13 #include <sys/types.h>
14
15 #ifdef _MSDOS
16 #include <malloc.h>
17 #endif
18
19 /*
20  * Array of context IDs typed by mechanism OID
21  */
22 typedef struct gss_union_ctx_id_t {
23         gss_OID                 mech_type;
24         gss_ctx_id_t            internal_ctx_id;
25 } gss_union_ctx_id_desc, *gss_union_ctx_id_t;
26
27 /*
28  * Generic GSSAPI names.  A name can either be a generic name, or a
29  * mechanism specific name....
30  */
31 typedef struct gss_union_name_t {
32         gss_OID                 name_type;
33         gss_buffer_t            external_name;
34         /*
35          * These last two fields are only filled in for mechanism
36          * names.
37          */
38         gss_OID                 mech_type;
39         gss_name_t              mech_name;
40 } gss_union_name_desc, *gss_union_name_t;
41
42 /*
43  * Structure for holding list of mechanism-specific name types
44  */
45 typedef struct gss_mech_spec_name_t {
46     gss_OID     name_type;
47     gss_OID     mech;
48     struct gss_mech_spec_name_t *next, *prev;
49 } gss_mech_spec_name_desc, *gss_mech_spec_name;
50
51 /*
52  * Credential auxiliary info, used in the credential structure
53  */
54 typedef struct gss_union_cred_auxinfo {
55         gss_buffer_desc         name;
56         gss_OID                 name_type;
57         time_t                  creation_time;
58         OM_uint32               time_rec;
59         int                     cred_usage;
60 } gss_union_cred_auxinfo;
61
62 /*
63  * Set of Credentials typed on mechanism OID
64  */
65 typedef struct gss_union_cred_t {
66         int                     count;
67         gss_OID                 mechs_array;
68         gss_cred_id_t *         cred_array;
69         gss_union_cred_auxinfo  auxinfo;
70 } gss_union_cred_desc, *gss_union_cred_t;
71  
72 /********************************************************/
73 /* The Mechanism Dispatch Table -- a mechanism needs to */
74 /* define one of these and provide a function to return */
75 /* it to initialize the GSSAPI library                  */
76
77 /*
78  * This is the definition of the mechs_array struct, which is used to
79  * define the mechs array table. This table is used to indirectly
80  * access mechanism specific versions of the gssapi routines through
81  * the routines in the glue module (gssd_mech_glue.c)
82  *
83  * This contants all of the functions defined in gssapi.h except for
84  * gss_release_buffer() and gss_release_oid_set(), which I am
85  * assuming, for now, to be equal across mechanisms.  
86  */
87  
88 typedef struct gss_config {
89     gss_OID_desc    mech_type;
90     void *          context;
91     OM_uint32       (*gss_acquire_cred)
92         NPROTOTYPE((
93                     void*,              /* context */
94                     OM_uint32*,         /* minor_status */
95                     gss_name_t,         /* desired_name */
96                     OM_uint32,          /* time_req */
97                     gss_OID_set,        /* desired_mechs */
98                     int,                /* cred_usage */
99                     gss_cred_id_t*,     /* output_cred_handle */
100                     gss_OID_set*,       /* actual_mechs */
101                     OM_uint32*          /* time_rec */
102                     ));
103     OM_uint32       (*gss_release_cred)
104         NPROTOTYPE((
105                     void*,              /* context */                  
106                     OM_uint32*,         /* minor_status */
107                     gss_cred_id_t*      /* cred_handle */
108                     ));
109     OM_uint32       (*gss_init_sec_context)
110         NPROTOTYPE((
111                     void*,                      /* context */
112                     OM_uint32*,                 /* minor_status */
113                     gss_cred_id_t,              /* claimant_cred_handle */
114                     gss_ctx_id_t*,              /* context_handle */
115                     gss_name_t,                 /* target_name */
116                     gss_OID,                    /* mech_type */
117                     OM_uint32,                  /* req_flags */
118                     OM_uint32,                  /* time_req */
119                     gss_channel_bindings_t,     /* input_chan_bindings */
120                     gss_buffer_t,               /* input_token */
121                     gss_OID*,                   /* actual_mech_type */
122                     gss_buffer_t,               /* output_token */
123                     OM_uint32*,                 /* ret_flags */
124                     OM_uint32*                  /* time_rec */
125                     ));
126     OM_uint32       (*gss_accept_sec_context)
127         NPROTOTYPE((
128                     void*,                      /* context */
129                     OM_uint32*,                 /* minor_status */
130                     gss_ctx_id_t*,              /* context_handle */
131                     gss_cred_id_t,              /* verifier_cred_handle */
132                     gss_buffer_t,               /* input_token_buffer */
133                     gss_channel_bindings_t,     /* input_chan_bindings */
134                     gss_name_t*,                /* src_name */
135                     gss_OID*,                   /* mech_type */
136                     gss_buffer_t,               /* output_token */
137                     OM_uint32*,                 /* ret_flags */
138                     OM_uint32*,                 /* time_rec */
139                     gss_cred_id_t*              /* delegated_cred_handle */
140                     ));
141     OM_uint32       (*gss_process_context_token)
142         NPROTOTYPE((
143                     void*,              /* context */
144                     OM_uint32*,         /* minor_status */
145                     gss_ctx_id_t,       /* context_handle */
146                     gss_buffer_t        /* token_buffer */
147                     ));
148     OM_uint32       (*gss_delete_sec_context)
149         NPROTOTYPE((
150                     void*,              /* context */
151                     OM_uint32*,         /* minor_status */
152                     gss_ctx_id_t*,      /* context_handle */
153                     gss_buffer_t        /* output_token */
154                     ));
155     OM_uint32       (*gss_context_time)
156         NPROTOTYPE((
157                     void*,              /* context */
158                     OM_uint32*,         /* minor_status */
159                     gss_ctx_id_t,       /* context_handle */
160                     OM_uint32*          /* time_rec */
161                     ));
162     OM_uint32       (*gss_sign)
163         NPROTOTYPE((
164                     void*,              /* context */
165                     OM_uint32*,         /* minor_status */
166                     gss_ctx_id_t,       /* context_handle */
167                     int,                /* qop_req */
168                     gss_buffer_t,       /* message_buffer */
169                     gss_buffer_t        /* message_token */
170                     ));
171     OM_uint32       (*gss_verify)
172         NPROTOTYPE((
173                     void*,              /* context */
174                     OM_uint32*,         /* minor_status */
175                     gss_ctx_id_t,       /* context_handle */
176                     gss_buffer_t,       /* message_buffer */
177                     gss_buffer_t,       /* token_buffer */
178                     int*                /* qop_state */
179                     ));
180     OM_uint32       (*gss_seal)
181         NPROTOTYPE((
182                     void*,              /* context */
183                     OM_uint32*,         /* minor_status */
184                     gss_ctx_id_t,       /* context_handle */
185                     int,                /* conf_req_flag */
186                     int,                /* qop_req */
187                     gss_buffer_t,       /* input_message_buffer */
188                     int*,               /* conf_state */
189                     gss_buffer_t        /* output_message_buffer */
190                     ));
191     OM_uint32       (*gss_unseal)
192         NPROTOTYPE((
193                     void*,              /* context */
194                     OM_uint32*,         /* minor_status */
195                     gss_ctx_id_t,       /* context_handle */
196                     gss_buffer_t,       /* input_message_buffer */
197                     gss_buffer_t,       /* output_message_buffer */
198                     int*,               /* conf_state */
199                     int*                /* qop_state */
200                     ));
201     OM_uint32       (*gss_display_status)
202         NPROTOTYPE((
203                     void*,              /* context */
204                     OM_uint32*,         /* minor_status */
205                     OM_uint32,          /* status_value */
206                     int,                /* status_type */
207                     gss_OID,            /* mech_type */
208                     OM_uint32*,         /* message_context */
209                     gss_buffer_t        /* status_string */
210                     ));
211     OM_uint32       (*gss_indicate_mechs)
212         NPROTOTYPE((
213                     void*,              /* context */
214                     OM_uint32*,         /* minor_status */
215                     gss_OID_set*        /* mech_set */
216                     ));
217     OM_uint32       (*gss_compare_name)
218         NPROTOTYPE((
219                     void*,              /* context */
220                     OM_uint32*,         /* minor_status */
221                     gss_name_t,         /* name1 */
222                     gss_name_t,         /* name2 */
223                     int*                /* name_equal */
224                     ));
225     OM_uint32       (*gss_display_name)
226         NPROTOTYPE((
227                     void*,              /* context */
228                     OM_uint32*,         /* minor_status */
229                     gss_name_t,         /* input_name */
230                     gss_buffer_t,       /* output_name_buffer */
231                     gss_OID*            /* output_name_type */
232                     ));
233     OM_uint32       (*gss_import_name)
234         NPROTOTYPE((
235                     void*,              /* context */
236                     OM_uint32*,         /* minor_status */
237                     gss_buffer_t,       /* input_name_buffer */
238                     gss_OID,            /* input_name_type */
239                     gss_name_t*         /* output_name */
240                     ));
241     OM_uint32       (*gss_release_name)
242         NPROTOTYPE((
243                     void*,              /* context */
244                     OM_uint32*,         /* minor_status */
245                     gss_name_t*         /* input_name */
246                     ));
247     OM_uint32       (*gss_inquire_cred)
248         NPROTOTYPE((
249                     void*,                      /* context */
250                     OM_uint32 *,                /* minor_status */
251                     gss_cred_id_t,              /* cred_handle */
252                     gss_name_t *,               /* name */
253                     OM_uint32 *,                /* lifetime */
254                     int *,                      /* cred_usage */
255                     gss_OID_set *               /* mechanisms */
256                     ));
257     OM_uint32       (*gss_add_cred)
258         NPROTOTYPE((
259                     void*,              /* context */
260                     OM_uint32 *,        /* minor_status */
261                     gss_cred_id_t,      /* input_cred_handle */
262                     gss_name_t,         /* desired_name */
263                     gss_OID,            /* desired_mech */
264                     gss_cred_usage_t,   /* cred_usage */
265                     OM_uint32,          /* initiator_time_req */
266                     OM_uint32,          /* acceptor_time_req */
267                     gss_cred_id_t *,    /* output_cred_handle */
268                     gss_OID_set *,      /* actual_mechs */
269                     OM_uint32 *,        /* initiator_time_rec */
270                     OM_uint32 *         /* acceptor_time_rec */
271                     ));
272     OM_uint32       (*gss_export_sec_context)
273         NPROTOTYPE((
274                     void*,              /* context */
275                     OM_uint32 *,        /* minor_status */
276                     gss_ctx_id_t *,     /* context_handle */
277                     gss_buffer_t        /* interprocess_token */
278                     ));
279     OM_uint32       (*gss_import_sec_context)
280         NPROTOTYPE((
281                     void *,             /* context */
282                     OM_uint32 *,        /* minor_status */
283                     gss_buffer_t,       /* interprocess_token */
284                     gss_ctx_id_t *      /* context_handle */
285                     ));
286     OM_uint32       (*gss_inquire_cred_by_mech)
287         NPROTOTYPE((
288                     void *,             /* context */
289                     OM_uint32 *,        /* minor_status */
290                     gss_cred_id_t,      /* cred_handle */
291                     gss_OID,            /* mech_type */
292                     gss_name_t *,       /* name */
293                     OM_uint32 *,        /* initiator_lifetime */
294                     OM_uint32 *,        /* acceptor_lifetime */
295                     gss_cred_usage_t *  /* cred_usage */
296                     ));
297     OM_uint32       (*gss_inquire_names_for_mech)
298         NPROTOTYPE((
299                     void *,             /* context */
300                     OM_uint32 *,        /* minor_status */
301                     gss_OID,            /* mechanism */
302                     gss_OID_set *       /* name_types */
303                     ));
304     OM_uint32   (*gss_inquire_context)
305         NPROTOTYPE((
306                     void *,             /* context */
307                     OM_uint32 *,        /* minor_status */
308                     gss_ctx_id_t,       /* context_handle */
309                     gss_name_t *,       /* src_name */
310                     gss_name_t *,       /* targ_name */
311                     OM_uint32 *,        /* lifetime_rec */
312                     gss_OID *,          /* mech_type */
313                     OM_uint32 *,        /* ctx_flags */
314                     int *,              /* locally_initiated */
315                     int *               /* open */
316                     ));
317     OM_uint32       (*gss_internal_release_oid)
318         NPROTOTYPE((
319                     void *,             /* context */
320                     OM_uint32 *,        /* minor_status */
321                     gss_OID *           /* OID */
322          ));
323     OM_uint32        (*gss_wrap_size_limit)
324         NPROTOTYPE((
325                     void *,             /* context */
326                     OM_uint32 *,        /* minor_status */
327                     gss_ctx_id_t,       /* context_handle */
328                     int,                /* conf_req_flag */
329                     gss_qop_t,          /* qop_req */
330                     OM_uint32,          /* req_output_size */
331                     OM_uint32 *         /* max_input_size */
332          ));
333     int              (*pname_to_uid)
334         NPROTOTYPE((
335                     void *,             /* context */
336                     char *,             /* pname */
337                     gss_OID,            /* name type */
338                     gss_OID,            /* mech type */
339                     uid_t *             /* uid */
340                     ));
341
342 } *gss_mechanism;
343
344 /********************************************************/
345 /* Internal mechglue routines */
346
347 gss_mechanism __gss_get_mechanism
348 PROTOTYPE((gss_OID));
349 OM_uint32 __gss_get_mech_type
350 PROTOTYPE((gss_OID, gss_buffer_t));
351 OM_uint32 __gss_import_internal_name
352 PROTOTYPE((OM_uint32 *, gss_OID, gss_union_name_t,
353            gss_name_t *));
354 OM_uint32 __gss_display_internal_name
355 PROTOTYPE((OM_uint32 *, gss_OID, gss_name_t,
356            gss_buffer_t, gss_OID *));
357 OM_uint32 __gss_release_internal_name
358 PROTOTYPE((OM_uint32 *, gss_OID, gss_name_t *));
359
360 OM_uint32 __gss_convert_name_to_union_name
361 PROTOTYPE((OM_uint32 *,         /* minor_status */
362            gss_mechanism,       /* mech */
363            gss_name_t,          /* internal_name */
364            gss_name_t *         /* external_name */
365            ));
366 gss_cred_id_t __gss_get_mechanism_cred
367 PROTOTYPE((gss_union_cred_t,    /* union_cred */
368            gss_OID              /* mech_type */
369            ));
370
371 OM_uint32 generic_gss_release_oid
372 PROTOTYPE( (OM_uint32 *,        /* minor_status */
373             gss_OID *           /* oid */
374            ));
375
376 OM_uint32 generic_gss_copy_oid
377 PROTOTYPE( (OM_uint32 *,        /* minor_status */
378             gss_OID,            /* oid */
379             gss_OID *           /* new_oid */
380             ));
381
382 OM_uint32 generic_gss_create_empty_oid_set
383 PROTOTYPE( (OM_uint32 *,        /* minor_status */
384             gss_OID_set *       /* oid_set */
385            ));
386
387 OM_uint32 generic_gss_add_oid_set_member
388 PROTOTYPE( (OM_uint32 *,        /* minor_status */
389             gss_OID,            /* member_oid */
390             gss_OID_set *       /* oid_set */
391            ));
392
393 OM_uint32 generic_gss_test_oid_set_member
394 PROTOTYPE( (OM_uint32 *,        /* minor_status */
395             gss_OID,            /* member */
396             gss_OID_set,        /* set */
397             int *               /* present */
398            ));
399
400 OM_uint32 generic_gss_oid_to_str
401 PROTOTYPE( (OM_uint32 *,        /* minor_status */
402             gss_OID,            /* oid */
403             gss_buffer_t        /* oid_str */
404            ));
405
406 OM_uint32 generic_gss_str_to_oid
407 PROTOTYPE( (OM_uint32 *,        /* minor_status */
408             gss_buffer_t,       /* oid_str */
409             gss_OID *           /* oid */
410            ));
411
412
413 gss_OID gss_find_mechanism_from_name_type
414 PROTOTYPE ( (gss_OID            /* name_type */
415              ));
416
417 OM_uint32 gss_add_mech_name_type
418 PROTOTYPE ( (OM_uint32 *,       /* minor_status */
419              gss_OID,           /* name_type */
420              gss_OID            /* mech */
421              ));
422
423 #endif /* _GSS_MECHGLUEP_H */