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