Consolidate the IOV and non-IOV encryption/decryption code paths, and
[krb5.git] / src / include / CredentialsCache2.h
1 /* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2 /*
3  * $Header$
4  *
5  * Copyright 2006 Massachusetts Institute of Technology.
6  * All Rights Reserved.
7  *
8  * Export of this software from the United States of America may
9  * require a specific license from the United States Government.
10  * It is the responsibility of any person or organization contemplating
11  * export to obtain such a license before exporting.
12  *
13  * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and
14  * distribute this software and its documentation for any purpose and
15  * without fee is hereby granted, provided that the above copyright
16  * notice appear in all copies and that both that copyright notice and
17  * this permission notice appear in supporting documentation, and that
18  * the name of M.I.T. not be used in advertising or publicity pertaining
19  * to distribution of the software without specific, written prior
20  * permission.  Furthermore if you modify this software you must label
21  * your software as modified software and not distribute it in such a
22  * fashion that it might be confused with the original M.I.T. software.
23  * M.I.T. makes no representations about the suitability of
24  * this software for any purpose.  It is provided "as is" without express
25  * or implied warranty.
26  */
27
28 /*
29  * This is backwards compatibility for CCache API v2 clients to be able to run
30  * against the CCache API v3 library
31  */
32
33 #ifndef CCAPI_V2_H
34 #define CCAPI_V2_H
35
36 #include <CredentialsCache.h>
37
38 #if defined(macintosh) || (defined(__MACH__) && defined(__APPLE__))
39 #include <TargetConditionals.h>
40 #include <AvailabilityMacros.h>
41 #ifdef DEPRECATED_IN_MAC_OS_X_VERSION_10_5_AND_LATER
42 #define CCAPI_DEPRECATED DEPRECATED_IN_MAC_OS_X_VERSION_10_5_AND_LATER
43 #endif
44 #endif
45
46 #ifndef CCAPI_DEPRECATED
47 #define CCAPI_DEPRECATED
48 #endif
49
50 #ifdef __cplusplus
51 extern "C" {
52 #endif /* __cplusplus */
53
54 #if TARGET_OS_MAC
55 #pragma pack(push,2)
56 #endif
57
58 /* Some old types get directly mapped to new types */
59
60 typedef cc_context_d apiCB;
61 typedef cc_ccache_d ccache_p;
62 typedef cc_credentials_iterator_d ccache_cit_creds;
63 typedef cc_ccache_iterator_d ccache_cit_ccache;
64 typedef cc_data cc_data_compat;
65 typedef cc_int32 cc_cred_vers;
66 typedef cc_int32 cc_result;
67
68 /* This doesn't exist in API v3 */
69 typedef cc_uint32 cc_flags;
70
71 /* Credentials types are visible to the caller so we have to keep binary compatibility */
72
73 typedef struct cc_credentials_v5_compat {
74     char*                       client;
75     char*                       server;
76     cc_data_compat              keyblock;
77     cc_time_t                   authtime;
78     cc_time_t                   starttime;
79     cc_time_t                   endtime;
80     cc_time_t                   renew_till;
81     cc_uint32                   is_skey;
82     cc_uint32                   ticket_flags;
83     cc_data_compat**            addresses;
84     cc_data_compat              ticket;
85     cc_data_compat              second_ticket;
86     cc_data_compat**            authdata;
87 } cc_credentials_v5_compat;
88
89 enum {
90     MAX_V4_CRED_LEN = 1250
91 };
92
93 enum {
94     KRB_NAME_SZ = 40,
95     KRB_INSTANCE_SZ = 40,
96     KRB_REALM_SZ = 40
97 };
98
99 typedef struct cc_credentials_v4_compat {
100     unsigned char       kversion;
101     char                principal[KRB_NAME_SZ+1];
102     char                principal_instance[KRB_INSTANCE_SZ+1];
103     char                service[KRB_NAME_SZ+1];
104     char                service_instance[KRB_INSTANCE_SZ+1];
105     char                realm[KRB_REALM_SZ+1];
106     unsigned char       session_key[8];
107     cc_int32            kvno;
108     cc_int32            str_to_key;
109     long                issue_date;
110     cc_int32            lifetime;
111     cc_uint32           address;
112     cc_int32            ticket_sz;
113     unsigned char       ticket[MAX_V4_CRED_LEN];
114     unsigned long       oops;
115 } cc_credentials_v4_compat;
116
117 typedef union cred_ptr_union_compat {
118     cc_credentials_v4_compat* pV4Cred;
119     cc_credentials_v5_compat* pV5Cred;
120 } cred_ptr_union_compat;
121
122 typedef struct cred_union {
123     cc_int32              cred_type;  /* cc_cred_vers */
124     cred_ptr_union_compat cred;
125 } cred_union;
126
127 /* NC info structure is gone in v3 */
128
129 struct infoNC {
130     char*       name;
131     char*       principal;
132     cc_int32    vers;
133 };
134
135 typedef struct infoNC infoNC;
136
137 /* Some old type names */
138
139 typedef cc_credentials_v4_compat V4Cred_type;
140 typedef cc_credentials_v5_compat cc_creds;
141 struct ccache_cit;
142 typedef struct ccache_cit ccache_cit;
143
144 enum {
145     CC_API_VER_2 = ccapi_version_2
146 };
147
148 enum {
149     CC_NOERROR,
150     CC_BADNAME,
151     CC_NOTFOUND,
152     CC_END,
153     CC_IO,
154     CC_WRITE,
155     CC_NOMEM,
156     CC_FORMAT,
157     CC_LOCKED,
158     CC_BAD_API_VERSION,
159     CC_NO_EXIST,
160     CC_NOT_SUPP,
161     CC_BAD_PARM,
162     CC_ERR_CACHE_ATTACH,
163     CC_ERR_CACHE_RELEASE,
164     CC_ERR_CACHE_FULL,
165     CC_ERR_CRED_VERSION
166 };
167
168 enum {
169     CC_CRED_UNKNOWN,
170     CC_CRED_V4,
171     CC_CRED_V5,
172     CC_CRED_MAX
173 };
174
175 enum {
176     CC_LOCK_UNLOCK = 1,
177     CC_LOCK_READER = 2,
178     CC_LOCK_WRITER = 3,
179     CC_LOCK_NOBLOCK = 16
180 };
181
182 CCACHE_API cc_int32
183 cc_shutdown (apiCB **io_context)
184     CCAPI_DEPRECATED;
185
186 CCACHE_API cc_int32
187 cc_get_NC_info (apiCB    *in_context,
188                 infoNC ***out_info)
189     CCAPI_DEPRECATED;
190
191 CCACHE_API cc_int32
192 cc_get_change_time (apiCB     *in_context,
193                     cc_time_t *out_change_time)
194     CCAPI_DEPRECATED;
195
196 CCACHE_API cc_int32
197 cc_open (apiCB       *in_context,
198          const char  *in_name,
199          cc_int32     in_version,
200          cc_uint32    in_flags,
201          ccache_p   **out_ccache)
202     CCAPI_DEPRECATED;
203
204 CCACHE_API cc_int32
205 cc_create (apiCB       *in_context,
206            const char  *in_name,
207            const char  *in_principal,
208            cc_int32     in_version,
209            cc_uint32    in_flags,
210            ccache_p   **out_ccache)
211     CCAPI_DEPRECATED;
212
213 CCACHE_API cc_int32
214 cc_close (apiCB     *in_context,
215           ccache_p **ioCCache)
216     CCAPI_DEPRECATED;
217
218 CCACHE_API cc_int32
219 cc_destroy (apiCB     *in_context,
220             ccache_p **io_ccache)
221     CCAPI_DEPRECATED;
222
223 CCACHE_API cc_int32
224 cc_seq_fetch_NCs_begin (apiCB       *in_context,
225                         ccache_cit **out_nc_iterator)
226     CCAPI_DEPRECATED;
227
228 CCACHE_API cc_int32
229 cc_seq_fetch_NCs_next (apiCB       *in_context,
230                        ccache_p   **out_ccache,
231                        ccache_cit  *in_nc_iterator)
232     CCAPI_DEPRECATED;
233
234 CCACHE_API cc_int32
235 cc_seq_fetch_NCs_end (apiCB       *in_context,
236                       ccache_cit **io_nc_iterator)
237     CCAPI_DEPRECATED;
238
239 CCACHE_API cc_int32
240 cc_get_name (apiCB     *in_context,
241              ccache_p  *in_ccache,
242              char     **out_name)
243     CCAPI_DEPRECATED;
244
245 CCACHE_API cc_int32
246 cc_get_cred_version (apiCB    *in_context,
247                      ccache_p *in_ccache,
248                      cc_int32 *out_version)
249     CCAPI_DEPRECATED;
250
251 CCACHE_API cc_int32
252 cc_set_principal (apiCB    *in_context,
253                   ccache_p *in_ccache,
254                   cc_int32  in_version,
255                   char     *in_principal)
256     CCAPI_DEPRECATED;
257
258 CCACHE_API cc_int32
259 cc_get_principal (apiCB     *in_context,
260                   ccache_p  *in_ccache,
261                   char     **out_principal)
262     CCAPI_DEPRECATED;
263
264 CCACHE_API cc_int32
265 cc_store (apiCB      *in_context,
266           ccache_p   *in_ccache,
267           cred_union  in_credentials)
268     CCAPI_DEPRECATED;
269
270 CCACHE_API cc_int32
271 cc_remove_cred (apiCB      *in_context,
272                 ccache_p   *in_ccache,
273                 cred_union  in_credentials)
274     CCAPI_DEPRECATED;
275
276 CCACHE_API cc_int32
277 cc_seq_fetch_creds_begin (apiCB           *in_context,
278                           const ccache_p  *in_ccache,
279                           ccache_cit     **out_ccache_iterator)
280     CCAPI_DEPRECATED;
281
282 CCACHE_API cc_int32
283 cc_seq_fetch_creds_next (apiCB       *in_context,
284                          cred_union **out_cred_union,
285                          ccache_cit  *in_ccache_iterator)
286     CCAPI_DEPRECATED;
287
288 CCACHE_API cc_int32
289 cc_seq_fetch_creds_end (apiCB       *in_context,
290                         ccache_cit **io_ccache_iterator)
291     CCAPI_DEPRECATED;
292
293 CCACHE_API cc_int32
294 cc_free_principal (apiCB  *in_context,
295                    char  **io_principal)
296     CCAPI_DEPRECATED;
297
298 CCACHE_API cc_int32
299 cc_free_name (apiCB  *in_context,
300               char  **io_name)
301     CCAPI_DEPRECATED;
302
303 CCACHE_API cc_int32
304 cc_free_creds (apiCB       *in_context,
305                cred_union **io_cred_union)
306     CCAPI_DEPRECATED;
307
308 CCACHE_API cc_int32
309 cc_free_NC_info (apiCB    *in_context,
310                  infoNC ***io_info)
311     CCAPI_DEPRECATED;
312
313 CCACHE_API cc_int32
314 cc_lock_request (apiCB          *in_context,
315                  const ccache_p *in_ccache,
316                  const cc_int32  in_lock_type)
317     CCAPI_DEPRECATED;
318
319 #if TARGET_OS_MAC
320 #pragma pack(pop)
321 #endif
322
323 #ifdef __cplusplus
324 }
325 #endif /* __cplusplus */
326
327 #endif /* CCAPI_V2_H */