xref: /freebsd/crypto/krb5/src/include/krb5/authdata_plugin.h (revision 7f2fe78b9dd5f51c821d771b63d2e096f6fd49e9)
1 /* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2 /*
3  * Copyright (C) 2007 Apple Inc.  All Rights Reserved.
4  *
5  * Export of this software from the United States of America may
6  *   require a specific license from the United States Government.
7  *   It is the responsibility of any person or organization contemplating
8  *   export to obtain such a license before exporting.
9  *
10  * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and
11  * distribute this software and its documentation for any purpose and
12  * without fee is hereby granted, provided that the above copyright
13  * notice appear in all copies and that both that copyright notice and
14  * this permission notice appear in supporting documentation, and that
15  * the name of M.I.T. not be used in advertising or publicity pertaining
16  * to distribution of the software without specific, written prior
17  * permission.  Furthermore if you modify this software you must label
18  * your software as modified software and not distribute it in such a
19  * fashion that it might be confused with the original M.I.T. software.
20  * M.I.T. makes no representations about the suitability of
21  * this software for any purpose.  It is provided "as is" without express
22  * or implied warranty.
23  */
24 
25 /*
26  * Authorization data plugin definitions for Kerberos 5.
27  * This is considered an INTERNAL interface at this time.
28  *
29  * Some work is needed before exporting it:
30  *
31  * + Documentation.
32  * + Sample code.
33  * + Test cases (preferably automated testing under "make check").
34  *
35  * Other changes that would be nice to have, but not necessarily
36  * before making this interface public:
37  *
38  * + Library support for AD-IF-RELEVANT and similar wrappers.  (We can
39  *   make the plugin construct them if it wants them.)
40  * + KDC could combine/optimize wrapped AD elements provided by
41  *   multiple plugins, e.g., two IF-RELEVANT sequences could be
42  *   merged.  (The preauth plugin API also has this bug, we're going
43  *   to need a general fix.)
44  */
45 
46 #ifndef KRB5_AUTHDATA_PLUGIN_H_INCLUDED
47 #define KRB5_AUTHDATA_PLUGIN_H_INCLUDED
48 #include <krb5/krb5.h>
49 
50 typedef krb5_error_code
51 (*authdata_client_plugin_init_proc)(krb5_context context,
52                                     void **plugin_context);
53 
54 #define AD_USAGE_AS_REQ         0x01
55 #define AD_USAGE_TGS_REQ        0x02
56 #define AD_USAGE_AP_REQ         0x04
57 #define AD_USAGE_KDC_ISSUED     0x08
58 #define AD_INFORMATIONAL        0x10
59 #define AD_CAMMAC_PROTECTED     0x20
60 #define AD_USAGE_MASK           0x2F
61 
62 struct _krb5_authdata_context;
63 
64 typedef void
65 (*authdata_client_plugin_flags_proc)(krb5_context kcontext,
66                                      void *plugin_context,
67                                      krb5_authdatatype ad_type,
68                                      krb5_flags *flags);
69 
70 typedef void
71 (*authdata_client_plugin_fini_proc)(krb5_context kcontext,
72                                     void *plugin_context);
73 
74 typedef krb5_error_code
75 (*authdata_client_request_init_proc)(krb5_context kcontext,
76                                      struct _krb5_authdata_context *context,
77                                      void *plugin_context,
78                                      void **request_context);
79 
80 typedef void
81 (*authdata_client_request_fini_proc)(krb5_context kcontext,
82                                      struct _krb5_authdata_context *context,
83                                      void *plugin_context,
84                                      void *request_context);
85 
86 typedef krb5_error_code
87 (*authdata_client_import_authdata_proc)(krb5_context kcontext,
88                                         struct _krb5_authdata_context *context,
89                                         void *plugin_context,
90                                         void *request_context,
91                                         krb5_authdata **authdata,
92                                         krb5_boolean kdc_issued_flag,
93                                         krb5_const_principal issuer);
94 
95 typedef krb5_error_code
96 (*authdata_client_export_authdata_proc)(krb5_context kcontext,
97                                         struct _krb5_authdata_context *context,
98                                         void *plugin_context,
99                                         void *request_context,
100                                         krb5_flags usage,
101                                         krb5_authdata ***authdata);
102 
103 typedef krb5_error_code
104 (*authdata_client_get_attribute_types_proc)(krb5_context kcontext,
105                                             struct _krb5_authdata_context *context,
106                                             void *plugin_context,
107                                             void *request_context,
108                                             krb5_data **attrs);
109 
110 typedef krb5_error_code
111 (*authdata_client_get_attribute_proc)(krb5_context kcontext,
112                                       struct _krb5_authdata_context *context,
113                                       void *plugin_context,
114                                       void *request_context,
115                                       const krb5_data *attribute,
116                                       krb5_boolean *authenticated,
117                                       krb5_boolean *complete,
118                                       krb5_data *value,
119                                       krb5_data *display_value,
120                                       int *more);
121 
122 typedef krb5_error_code
123 (*authdata_client_set_attribute_proc)(krb5_context kcontext,
124                                       struct _krb5_authdata_context *context,
125                                       void *plugin_context,
126                                       void *request_context,
127                                       krb5_boolean complete,
128                                       const krb5_data *attribute,
129                                       const krb5_data *value);
130 
131 typedef krb5_error_code
132 (*authdata_client_delete_attribute_proc)(krb5_context kcontext,
133                                          struct _krb5_authdata_context *context,
134                                          void *plugin_context,
135                                          void *request_context,
136                                          const krb5_data *attribute);
137 
138 typedef krb5_error_code
139 (*authdata_client_export_internal_proc)(krb5_context kcontext,
140                                         struct _krb5_authdata_context *context,
141                                         void *plugin_context,
142                                         void *request_context,
143                                         krb5_boolean restrict_authenticated,
144                                         void **ptr);
145 
146 typedef void
147 (*authdata_client_free_internal_proc)(krb5_context kcontext,
148                                       struct _krb5_authdata_context *context,
149                                       void *plugin_context,
150                                       void *request_context,
151                                       void *ptr);
152 
153 typedef krb5_error_code
154 (*authdata_client_verify_proc)(krb5_context kcontext,
155                                struct _krb5_authdata_context *context,
156                                void *plugin_context,
157                                void *request_context,
158                                const krb5_auth_context *auth_context,
159                                const krb5_keyblock *key,
160                                const krb5_ap_req *req);
161 
162 typedef krb5_error_code
163 (*authdata_client_size_proc)(krb5_context kcontext,
164                              struct _krb5_authdata_context *context,
165                              void *plugin_context,
166                              void *request_context,
167                              size_t *sizep);
168 
169 typedef krb5_error_code
170 (*authdata_client_externalize_proc)(krb5_context kcontext,
171                                     struct _krb5_authdata_context *context,
172                                     void *plugin_context,
173                                     void *request_context,
174                                     krb5_octet **buffer,
175                                     size_t *lenremain);
176 
177 typedef krb5_error_code
178 (*authdata_client_internalize_proc)(krb5_context kcontext,
179                                     struct _krb5_authdata_context *context,
180                                     void *plugin_context,
181                                     void *request_context,
182                                     krb5_octet **buffer,
183                                     size_t *lenremain);
184 
185 typedef krb5_error_code
186 (*authdata_client_copy_proc)(krb5_context kcontext,
187                              struct _krb5_authdata_context *context,
188                              void *plugin_context,
189                              void *request_context,
190                              void *dst_plugin_context,
191                              void *dst_request_context);
192 
193 typedef struct krb5plugin_authdata_client_ftable_v0 {
194     const char *name;
195     krb5_authdatatype *ad_type_list;
196     authdata_client_plugin_init_proc init;
197     authdata_client_plugin_fini_proc fini;
198     authdata_client_plugin_flags_proc flags;
199     authdata_client_request_init_proc request_init;
200     authdata_client_request_fini_proc request_fini;
201     authdata_client_get_attribute_types_proc get_attribute_types;
202     authdata_client_get_attribute_proc get_attribute;
203     authdata_client_set_attribute_proc set_attribute;
204     authdata_client_delete_attribute_proc delete_attribute;
205     authdata_client_export_authdata_proc export_authdata;
206     authdata_client_import_authdata_proc import_authdata;
207     authdata_client_export_internal_proc export_internal;
208     authdata_client_free_internal_proc free_internal;
209     authdata_client_verify_proc verify;
210     authdata_client_size_proc size;
211     authdata_client_externalize_proc externalize;
212     authdata_client_internalize_proc internalize;
213     authdata_client_copy_proc copy; /* optional */
214 } krb5plugin_authdata_client_ftable_v0;
215 
216 #endif /* KRB5_AUTHDATA_PLUGIN_H_INCLUDED */
217