xref: /minix3/crypto/external/bsd/heimdal/dist/lib/krb5/krb5_ccapi.h (revision ebfedea0ce5bbe81e252ddf32d732e40fb633fae)
1*ebfedea0SLionel Sambuc /*	$NetBSD: krb5_ccapi.h,v 1.1.1.2 2011/04/14 14:09:23 elric Exp $	*/
2*ebfedea0SLionel Sambuc 
3*ebfedea0SLionel Sambuc /*
4*ebfedea0SLionel Sambuc  * Copyright (c) 2004 Kungliga Tekniska Högskolan
5*ebfedea0SLionel Sambuc  * (Royal Institute of Technology, Stockholm, Sweden).
6*ebfedea0SLionel Sambuc  * All rights reserved.
7*ebfedea0SLionel Sambuc  *
8*ebfedea0SLionel Sambuc  * Redistribution and use in source and binary forms, with or without
9*ebfedea0SLionel Sambuc  * modification, are permitted provided that the following conditions
10*ebfedea0SLionel Sambuc  * are met:
11*ebfedea0SLionel Sambuc  *
12*ebfedea0SLionel Sambuc  * 1. Redistributions of source code must retain the above copyright
13*ebfedea0SLionel Sambuc  *    notice, this list of conditions and the following disclaimer.
14*ebfedea0SLionel Sambuc  *
15*ebfedea0SLionel Sambuc  * 2. Redistributions in binary form must reproduce the above copyright
16*ebfedea0SLionel Sambuc  *    notice, this list of conditions and the following disclaimer in the
17*ebfedea0SLionel Sambuc  *    documentation and/or other materials provided with the distribution.
18*ebfedea0SLionel Sambuc  *
19*ebfedea0SLionel Sambuc  * 3. Neither the name of the Institute nor the names of its contributors
20*ebfedea0SLionel Sambuc  *    may be used to endorse or promote products derived from this software
21*ebfedea0SLionel Sambuc  *    without specific prior written permission.
22*ebfedea0SLionel Sambuc  *
23*ebfedea0SLionel Sambuc  * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
24*ebfedea0SLionel Sambuc  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25*ebfedea0SLionel Sambuc  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26*ebfedea0SLionel Sambuc  * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
27*ebfedea0SLionel Sambuc  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28*ebfedea0SLionel Sambuc  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29*ebfedea0SLionel Sambuc  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30*ebfedea0SLionel Sambuc  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31*ebfedea0SLionel Sambuc  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32*ebfedea0SLionel Sambuc  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33*ebfedea0SLionel Sambuc  * SUCH DAMAGE.
34*ebfedea0SLionel Sambuc  */
35*ebfedea0SLionel Sambuc 
36*ebfedea0SLionel Sambuc /* Id */
37*ebfedea0SLionel Sambuc 
38*ebfedea0SLionel Sambuc #ifndef KRB5_CCAPI_H
39*ebfedea0SLionel Sambuc #define KRB5_CCAPI_H 1
40*ebfedea0SLionel Sambuc 
41*ebfedea0SLionel Sambuc #include <krb5/krb5-types.h>
42*ebfedea0SLionel Sambuc 
43*ebfedea0SLionel Sambuc  #ifdef __APPLE__
44*ebfedea0SLionel Sambuc #pragma pack(push,2)
45*ebfedea0SLionel Sambuc #endif
46*ebfedea0SLionel Sambuc 
47*ebfedea0SLionel Sambuc enum {
48*ebfedea0SLionel Sambuc     cc_credentials_v5 = 2
49*ebfedea0SLionel Sambuc };
50*ebfedea0SLionel Sambuc 
51*ebfedea0SLionel Sambuc enum {
52*ebfedea0SLionel Sambuc     ccapi_version_3 = 3,
53*ebfedea0SLionel Sambuc     ccapi_version_4 = 4
54*ebfedea0SLionel Sambuc };
55*ebfedea0SLionel Sambuc 
56*ebfedea0SLionel Sambuc enum {
57*ebfedea0SLionel Sambuc     ccNoError						= 0,
58*ebfedea0SLionel Sambuc 
59*ebfedea0SLionel Sambuc     ccIteratorEnd					= 201,
60*ebfedea0SLionel Sambuc     ccErrBadParam,
61*ebfedea0SLionel Sambuc     ccErrNoMem,
62*ebfedea0SLionel Sambuc     ccErrInvalidContext,
63*ebfedea0SLionel Sambuc     ccErrInvalidCCache,
64*ebfedea0SLionel Sambuc 
65*ebfedea0SLionel Sambuc     ccErrInvalidString,					/* 206 */
66*ebfedea0SLionel Sambuc     ccErrInvalidCredentials,
67*ebfedea0SLionel Sambuc     ccErrInvalidCCacheIterator,
68*ebfedea0SLionel Sambuc     ccErrInvalidCredentialsIterator,
69*ebfedea0SLionel Sambuc     ccErrInvalidLock,
70*ebfedea0SLionel Sambuc 
71*ebfedea0SLionel Sambuc     ccErrBadName,					/* 211 */
72*ebfedea0SLionel Sambuc     ccErrBadCredentialsVersion,
73*ebfedea0SLionel Sambuc     ccErrBadAPIVersion,
74*ebfedea0SLionel Sambuc     ccErrContextLocked,
75*ebfedea0SLionel Sambuc     ccErrContextUnlocked,
76*ebfedea0SLionel Sambuc 
77*ebfedea0SLionel Sambuc     ccErrCCacheLocked,					/* 216 */
78*ebfedea0SLionel Sambuc     ccErrCCacheUnlocked,
79*ebfedea0SLionel Sambuc     ccErrBadLockType,
80*ebfedea0SLionel Sambuc     ccErrNeverDefault,
81*ebfedea0SLionel Sambuc     ccErrCredentialsNotFound,
82*ebfedea0SLionel Sambuc 
83*ebfedea0SLionel Sambuc     ccErrCCacheNotFound,				/* 221 */
84*ebfedea0SLionel Sambuc     ccErrContextNotFound,
85*ebfedea0SLionel Sambuc     ccErrServerUnavailable,
86*ebfedea0SLionel Sambuc     ccErrServerInsecure,
87*ebfedea0SLionel Sambuc     ccErrServerCantBecomeUID,
88*ebfedea0SLionel Sambuc 
89*ebfedea0SLionel Sambuc     ccErrTimeOffsetNotSet				/* 226 */
90*ebfedea0SLionel Sambuc };
91*ebfedea0SLionel Sambuc 
92*ebfedea0SLionel Sambuc typedef int32_t cc_int32;
93*ebfedea0SLionel Sambuc typedef uint32_t cc_uint32;
94*ebfedea0SLionel Sambuc typedef struct cc_context_t *cc_context_t;
95*ebfedea0SLionel Sambuc typedef struct cc_ccache_t *cc_ccache_t;
96*ebfedea0SLionel Sambuc typedef struct cc_ccache_iterator_t *cc_ccache_iterator_t;
97*ebfedea0SLionel Sambuc typedef struct cc_credentials_v5_t cc_credentials_v5_t;
98*ebfedea0SLionel Sambuc typedef struct cc_credentials_t *cc_credentials_t;
99*ebfedea0SLionel Sambuc typedef struct cc_credentials_iterator_t *cc_credentials_iterator_t;
100*ebfedea0SLionel Sambuc typedef struct cc_string_t *cc_string_t;
101*ebfedea0SLionel Sambuc typedef cc_uint32 cc_time_t;
102*ebfedea0SLionel Sambuc 
103*ebfedea0SLionel Sambuc typedef struct cc_data {
104*ebfedea0SLionel Sambuc     cc_uint32 type;
105*ebfedea0SLionel Sambuc     cc_uint32 length;
106*ebfedea0SLionel Sambuc     void *data;
107*ebfedea0SLionel Sambuc } cc_data;
108*ebfedea0SLionel Sambuc 
109*ebfedea0SLionel Sambuc struct cc_credentials_v5_t {
110*ebfedea0SLionel Sambuc     char *client;
111*ebfedea0SLionel Sambuc     char *server;
112*ebfedea0SLionel Sambuc     cc_data keyblock;
113*ebfedea0SLionel Sambuc     cc_time_t authtime;
114*ebfedea0SLionel Sambuc     cc_time_t starttime;
115*ebfedea0SLionel Sambuc     cc_time_t endtime;
116*ebfedea0SLionel Sambuc     cc_time_t renew_till;
117*ebfedea0SLionel Sambuc     cc_uint32 is_skey;
118*ebfedea0SLionel Sambuc     cc_uint32 ticket_flags;
119*ebfedea0SLionel Sambuc #define	KRB5_CCAPI_TKT_FLG_FORWARDABLE			0x40000000
120*ebfedea0SLionel Sambuc #define	KRB5_CCAPI_TKT_FLG_FORWARDED			0x20000000
121*ebfedea0SLionel Sambuc #define	KRB5_CCAPI_TKT_FLG_PROXIABLE			0x10000000
122*ebfedea0SLionel Sambuc #define	KRB5_CCAPI_TKT_FLG_PROXY			0x08000000
123*ebfedea0SLionel Sambuc #define	KRB5_CCAPI_TKT_FLG_MAY_POSTDATE			0x04000000
124*ebfedea0SLionel Sambuc #define	KRB5_CCAPI_TKT_FLG_POSTDATED			0x02000000
125*ebfedea0SLionel Sambuc #define	KRB5_CCAPI_TKT_FLG_INVALID			0x01000000
126*ebfedea0SLionel Sambuc #define	KRB5_CCAPI_TKT_FLG_RENEWABLE			0x00800000
127*ebfedea0SLionel Sambuc #define	KRB5_CCAPI_TKT_FLG_INITIAL			0x00400000
128*ebfedea0SLionel Sambuc #define	KRB5_CCAPI_TKT_FLG_PRE_AUTH			0x00200000
129*ebfedea0SLionel Sambuc #define	KRB5_CCAPI_TKT_FLG_HW_AUTH			0x00100000
130*ebfedea0SLionel Sambuc #define	KRB5_CCAPI_TKT_FLG_TRANSIT_POLICY_CHECKED	0x00080000
131*ebfedea0SLionel Sambuc #define	KRB5_CCAPI_TKT_FLG_OK_AS_DELEGATE		0x00040000
132*ebfedea0SLionel Sambuc #define	KRB5_CCAPI_TKT_FLG_ANONYMOUS			0x00020000
133*ebfedea0SLionel Sambuc     cc_data **addresses;
134*ebfedea0SLionel Sambuc     cc_data ticket;
135*ebfedea0SLionel Sambuc     cc_data second_ticket;
136*ebfedea0SLionel Sambuc     cc_data **authdata;
137*ebfedea0SLionel Sambuc };
138*ebfedea0SLionel Sambuc 
139*ebfedea0SLionel Sambuc 
140*ebfedea0SLionel Sambuc typedef struct cc_string_functions {
141*ebfedea0SLionel Sambuc     cc_int32 (*release)(cc_string_t);
142*ebfedea0SLionel Sambuc } cc_string_functions;
143*ebfedea0SLionel Sambuc 
144*ebfedea0SLionel Sambuc struct cc_string_t {
145*ebfedea0SLionel Sambuc     const char *data;
146*ebfedea0SLionel Sambuc     const cc_string_functions *func;
147*ebfedea0SLionel Sambuc };
148*ebfedea0SLionel Sambuc 
149*ebfedea0SLionel Sambuc typedef struct cc_credentials_union {
150*ebfedea0SLionel Sambuc     cc_int32 version;
151*ebfedea0SLionel Sambuc     union {
152*ebfedea0SLionel Sambuc 	cc_credentials_v5_t* credentials_v5;
153*ebfedea0SLionel Sambuc     } credentials;
154*ebfedea0SLionel Sambuc } cc_credentials_union;
155*ebfedea0SLionel Sambuc 
156*ebfedea0SLionel Sambuc struct cc_credentials_functions {
157*ebfedea0SLionel Sambuc     cc_int32 (*release)(cc_credentials_t);
158*ebfedea0SLionel Sambuc     cc_int32 (*compare)(cc_credentials_t, cc_credentials_t, cc_uint32*);
159*ebfedea0SLionel Sambuc };
160*ebfedea0SLionel Sambuc 
161*ebfedea0SLionel Sambuc struct cc_credentials_t {
162*ebfedea0SLionel Sambuc     const cc_credentials_union* data;
163*ebfedea0SLionel Sambuc     const struct cc_credentials_functions* func;
164*ebfedea0SLionel Sambuc };
165*ebfedea0SLionel Sambuc 
166*ebfedea0SLionel Sambuc struct cc_credentials_iterator_functions {
167*ebfedea0SLionel Sambuc     cc_int32 (*release)(cc_credentials_iterator_t);
168*ebfedea0SLionel Sambuc     cc_int32 (*next)(cc_credentials_iterator_t, cc_credentials_t*);
169*ebfedea0SLionel Sambuc };
170*ebfedea0SLionel Sambuc 
171*ebfedea0SLionel Sambuc struct cc_credentials_iterator_t {
172*ebfedea0SLionel Sambuc     const struct cc_credentials_iterator_functions *func;
173*ebfedea0SLionel Sambuc };
174*ebfedea0SLionel Sambuc 
175*ebfedea0SLionel Sambuc struct cc_ccache_iterator_functions {
176*ebfedea0SLionel Sambuc     cc_int32 (*release) (cc_ccache_iterator_t);
177*ebfedea0SLionel Sambuc     cc_int32 (*next)(cc_ccache_iterator_t, cc_ccache_t*);
178*ebfedea0SLionel Sambuc };
179*ebfedea0SLionel Sambuc 
180*ebfedea0SLionel Sambuc struct cc_ccache_iterator_t {
181*ebfedea0SLionel Sambuc     const struct cc_ccache_iterator_functions* func;
182*ebfedea0SLionel Sambuc };
183*ebfedea0SLionel Sambuc 
184*ebfedea0SLionel Sambuc typedef struct cc_ccache_functions {
185*ebfedea0SLionel Sambuc     cc_int32 (*release)(cc_ccache_t);
186*ebfedea0SLionel Sambuc     cc_int32 (*destroy)(cc_ccache_t);
187*ebfedea0SLionel Sambuc     cc_int32 (*set_default)(cc_ccache_t);
188*ebfedea0SLionel Sambuc     cc_int32 (*get_credentials_version)(cc_ccache_t, cc_uint32*);
189*ebfedea0SLionel Sambuc     cc_int32 (*get_name)(cc_ccache_t, cc_string_t*);
190*ebfedea0SLionel Sambuc     cc_int32 (*get_principal)(cc_ccache_t, cc_uint32, cc_string_t*);
191*ebfedea0SLionel Sambuc     cc_int32 (*set_principal)(cc_ccache_t, cc_uint32, const char*);
192*ebfedea0SLionel Sambuc     cc_int32 (*store_credentials)(cc_ccache_t, const cc_credentials_union*);
193*ebfedea0SLionel Sambuc     cc_int32 (*remove_credentials)(cc_ccache_t, cc_credentials_t);
194*ebfedea0SLionel Sambuc     cc_int32 (*new_credentials_iterator)(cc_ccache_t,
195*ebfedea0SLionel Sambuc 					 cc_credentials_iterator_t*);
196*ebfedea0SLionel Sambuc     cc_int32 (*move)(cc_ccache_t, cc_ccache_t);
197*ebfedea0SLionel Sambuc     cc_int32 (*lock)(cc_ccache_t, cc_uint32, cc_uint32);
198*ebfedea0SLionel Sambuc     cc_int32 (*unlock)(cc_ccache_t);
199*ebfedea0SLionel Sambuc     cc_int32 (*get_last_default_time)(cc_ccache_t, cc_time_t*);
200*ebfedea0SLionel Sambuc     cc_int32 (*get_change_time)(cc_ccache_t, cc_time_t*);
201*ebfedea0SLionel Sambuc     cc_int32 (*compare)(cc_ccache_t, cc_ccache_t, cc_uint32*);
202*ebfedea0SLionel Sambuc     cc_int32 (*get_kdc_time_offset)(cc_ccache_t, cc_int32, cc_time_t *);
203*ebfedea0SLionel Sambuc     cc_int32 (*set_kdc_time_offset)(cc_ccache_t, cc_int32, cc_time_t);
204*ebfedea0SLionel Sambuc     cc_int32 (*clear_kdc_time_offset)(cc_ccache_t, cc_int32);
205*ebfedea0SLionel Sambuc } cc_ccache_functions;
206*ebfedea0SLionel Sambuc 
207*ebfedea0SLionel Sambuc struct cc_ccache_t {
208*ebfedea0SLionel Sambuc     const cc_ccache_functions *func;
209*ebfedea0SLionel Sambuc };
210*ebfedea0SLionel Sambuc 
211*ebfedea0SLionel Sambuc struct  cc_context_functions {
212*ebfedea0SLionel Sambuc     cc_int32 (*release)(cc_context_t);
213*ebfedea0SLionel Sambuc     cc_int32 (*get_change_time)(cc_context_t, cc_time_t *);
214*ebfedea0SLionel Sambuc     cc_int32 (*get_default_ccache_name)(cc_context_t, cc_string_t*);
215*ebfedea0SLionel Sambuc     cc_int32 (*open_ccache)(cc_context_t, const char*, cc_ccache_t *);
216*ebfedea0SLionel Sambuc     cc_int32 (*open_default_ccache)(cc_context_t, cc_ccache_t*);
217*ebfedea0SLionel Sambuc     cc_int32 (*create_ccache)(cc_context_t,const char*, cc_uint32,
218*ebfedea0SLionel Sambuc 			      const char*, cc_ccache_t*);
219*ebfedea0SLionel Sambuc     cc_int32 (*create_default_ccache)(cc_context_t, cc_uint32,
220*ebfedea0SLionel Sambuc 				      const char*, cc_ccache_t*);
221*ebfedea0SLionel Sambuc     cc_int32 (*create_new_ccache)(cc_context_t, cc_uint32,
222*ebfedea0SLionel Sambuc 				  const char*, cc_ccache_t*);
223*ebfedea0SLionel Sambuc     cc_int32 (*new_ccache_iterator)(cc_context_t, cc_ccache_iterator_t*);
224*ebfedea0SLionel Sambuc     cc_int32 (*lock)(cc_context_t, cc_uint32, cc_uint32);
225*ebfedea0SLionel Sambuc     cc_int32 (*unlock)(cc_context_t);
226*ebfedea0SLionel Sambuc     cc_int32 (*compare)(cc_context_t, cc_context_t, cc_uint32*);
227*ebfedea0SLionel Sambuc };
228*ebfedea0SLionel Sambuc 
229*ebfedea0SLionel Sambuc struct cc_context_t {
230*ebfedea0SLionel Sambuc     const struct cc_context_functions* func;
231*ebfedea0SLionel Sambuc };
232*ebfedea0SLionel Sambuc 
233*ebfedea0SLionel Sambuc typedef cc_int32
234*ebfedea0SLionel Sambuc (*cc_initialize_func)(cc_context_t*, cc_int32, cc_int32 *, char const **);
235*ebfedea0SLionel Sambuc 
236*ebfedea0SLionel Sambuc #ifdef __APPLE__
237*ebfedea0SLionel Sambuc #pragma pack(pop)
238*ebfedea0SLionel Sambuc #endif
239*ebfedea0SLionel Sambuc 
240*ebfedea0SLionel Sambuc 
241*ebfedea0SLionel Sambuc #endif /* KRB5_CCAPI_H */
242