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