1178825Sdfr/*
2233294Sstas * Copyright (c) 2004 Kungliga Tekniska H��gskolan
3233294Sstas * (Royal Institute of Technology, Stockholm, Sweden).
4233294Sstas * All rights reserved.
5178825Sdfr *
6233294Sstas * Redistribution and use in source and binary forms, with or without
7233294Sstas * modification, are permitted provided that the following conditions
8233294Sstas * are met:
9178825Sdfr *
10233294Sstas * 1. Redistributions of source code must retain the above copyright
11233294Sstas *    notice, this list of conditions and the following disclaimer.
12178825Sdfr *
13233294Sstas * 2. Redistributions in binary form must reproduce the above copyright
14233294Sstas *    notice, this list of conditions and the following disclaimer in the
15233294Sstas *    documentation and/or other materials provided with the distribution.
16178825Sdfr *
17233294Sstas * 3. Neither the name of the Institute nor the names of its contributors
18233294Sstas *    may be used to endorse or promote products derived from this software
19233294Sstas *    without specific prior written permission.
20178825Sdfr *
21233294Sstas * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
22233294Sstas * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23233294Sstas * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24233294Sstas * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
25233294Sstas * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26233294Sstas * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27233294Sstas * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28233294Sstas * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29233294Sstas * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30233294Sstas * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31233294Sstas * SUCH DAMAGE.
32178825Sdfr */
33178825Sdfr
34233294Sstas/* $Id$ */
35178825Sdfr
36178825Sdfr#ifndef KRB5_CCAPI_H
37178825Sdfr#define KRB5_CCAPI_H 1
38178825Sdfr
39178825Sdfr#include <krb5-types.h>
40178825Sdfr
41233294Sstas #ifdef __APPLE__
42233294Sstas#pragma pack(push,2)
43233294Sstas#endif
44233294Sstas
45178825Sdfrenum {
46178825Sdfr    cc_credentials_v5 = 2
47178825Sdfr};
48178825Sdfr
49178825Sdfrenum {
50178825Sdfr    ccapi_version_3 = 3,
51178825Sdfr    ccapi_version_4 = 4
52178825Sdfr};
53178825Sdfr
54178825Sdfrenum {
55178825Sdfr    ccNoError						= 0,
56233294Sstas
57178825Sdfr    ccIteratorEnd					= 201,
58178825Sdfr    ccErrBadParam,
59178825Sdfr    ccErrNoMem,
60178825Sdfr    ccErrInvalidContext,
61178825Sdfr    ccErrInvalidCCache,
62178825Sdfr
63178825Sdfr    ccErrInvalidString,					/* 206 */
64178825Sdfr    ccErrInvalidCredentials,
65178825Sdfr    ccErrInvalidCCacheIterator,
66178825Sdfr    ccErrInvalidCredentialsIterator,
67178825Sdfr    ccErrInvalidLock,
68233294Sstas
69178825Sdfr    ccErrBadName,					/* 211 */
70178825Sdfr    ccErrBadCredentialsVersion,
71178825Sdfr    ccErrBadAPIVersion,
72178825Sdfr    ccErrContextLocked,
73178825Sdfr    ccErrContextUnlocked,
74233294Sstas
75178825Sdfr    ccErrCCacheLocked,					/* 216 */
76178825Sdfr    ccErrCCacheUnlocked,
77178825Sdfr    ccErrBadLockType,
78178825Sdfr    ccErrNeverDefault,
79178825Sdfr    ccErrCredentialsNotFound,
80233294Sstas
81178825Sdfr    ccErrCCacheNotFound,				/* 221 */
82178825Sdfr    ccErrContextNotFound,
83178825Sdfr    ccErrServerUnavailable,
84178825Sdfr    ccErrServerInsecure,
85178825Sdfr    ccErrServerCantBecomeUID,
86233294Sstas
87178825Sdfr    ccErrTimeOffsetNotSet				/* 226 */
88178825Sdfr};
89178825Sdfr
90178825Sdfrtypedef int32_t cc_int32;
91178825Sdfrtypedef uint32_t cc_uint32;
92178825Sdfrtypedef struct cc_context_t *cc_context_t;
93178825Sdfrtypedef struct cc_ccache_t *cc_ccache_t;
94178825Sdfrtypedef struct cc_ccache_iterator_t *cc_ccache_iterator_t;
95178825Sdfrtypedef struct cc_credentials_v5_t cc_credentials_v5_t;
96178825Sdfrtypedef struct cc_credentials_t *cc_credentials_t;
97178825Sdfrtypedef struct cc_credentials_iterator_t *cc_credentials_iterator_t;
98178825Sdfrtypedef struct cc_string_t *cc_string_t;
99233294Sstastypedef cc_uint32 cc_time_t;
100178825Sdfr
101178825Sdfrtypedef struct cc_data {
102178825Sdfr    cc_uint32 type;
103178825Sdfr    cc_uint32 length;
104178825Sdfr    void *data;
105178825Sdfr} cc_data;
106178825Sdfr
107178825Sdfrstruct cc_credentials_v5_t {
108178825Sdfr    char *client;
109178825Sdfr    char *server;
110178825Sdfr    cc_data keyblock;
111178825Sdfr    cc_time_t authtime;
112178825Sdfr    cc_time_t starttime;
113178825Sdfr    cc_time_t endtime;
114178825Sdfr    cc_time_t renew_till;
115178825Sdfr    cc_uint32 is_skey;
116178825Sdfr    cc_uint32 ticket_flags;
117178825Sdfr#define	KRB5_CCAPI_TKT_FLG_FORWARDABLE			0x40000000
118178825Sdfr#define	KRB5_CCAPI_TKT_FLG_FORWARDED			0x20000000
119178825Sdfr#define	KRB5_CCAPI_TKT_FLG_PROXIABLE			0x10000000
120178825Sdfr#define	KRB5_CCAPI_TKT_FLG_PROXY			0x08000000
121178825Sdfr#define	KRB5_CCAPI_TKT_FLG_MAY_POSTDATE			0x04000000
122178825Sdfr#define	KRB5_CCAPI_TKT_FLG_POSTDATED			0x02000000
123178825Sdfr#define	KRB5_CCAPI_TKT_FLG_INVALID			0x01000000
124178825Sdfr#define	KRB5_CCAPI_TKT_FLG_RENEWABLE			0x00800000
125178825Sdfr#define	KRB5_CCAPI_TKT_FLG_INITIAL			0x00400000
126178825Sdfr#define	KRB5_CCAPI_TKT_FLG_PRE_AUTH			0x00200000
127178825Sdfr#define	KRB5_CCAPI_TKT_FLG_HW_AUTH			0x00100000
128178825Sdfr#define	KRB5_CCAPI_TKT_FLG_TRANSIT_POLICY_CHECKED	0x00080000
129178825Sdfr#define	KRB5_CCAPI_TKT_FLG_OK_AS_DELEGATE		0x00040000
130178825Sdfr#define	KRB5_CCAPI_TKT_FLG_ANONYMOUS			0x00020000
131178825Sdfr    cc_data **addresses;
132178825Sdfr    cc_data ticket;
133178825Sdfr    cc_data second_ticket;
134178825Sdfr    cc_data **authdata;
135178825Sdfr};
136178825Sdfr
137178825Sdfr
138178825Sdfrtypedef struct cc_string_functions {
139178825Sdfr    cc_int32 (*release)(cc_string_t);
140178825Sdfr} cc_string_functions;
141178825Sdfr
142178825Sdfrstruct cc_string_t {
143178825Sdfr    const char *data;
144178825Sdfr    const cc_string_functions *func;
145178825Sdfr};
146178825Sdfr
147178825Sdfrtypedef struct cc_credentials_union {
148178825Sdfr    cc_int32 version;
149178825Sdfr    union {
150178825Sdfr	cc_credentials_v5_t* credentials_v5;
151178825Sdfr    } credentials;
152178825Sdfr} cc_credentials_union;
153178825Sdfr
154178825Sdfrstruct cc_credentials_functions {
155178825Sdfr    cc_int32 (*release)(cc_credentials_t);
156178825Sdfr    cc_int32 (*compare)(cc_credentials_t, cc_credentials_t, cc_uint32*);
157178825Sdfr};
158178825Sdfr
159178825Sdfrstruct cc_credentials_t {
160178825Sdfr    const cc_credentials_union* data;
161178825Sdfr    const struct cc_credentials_functions* func;
162178825Sdfr};
163178825Sdfr
164178825Sdfrstruct cc_credentials_iterator_functions {
165178825Sdfr    cc_int32 (*release)(cc_credentials_iterator_t);
166178825Sdfr    cc_int32 (*next)(cc_credentials_iterator_t, cc_credentials_t*);
167178825Sdfr};
168178825Sdfr
169178825Sdfrstruct cc_credentials_iterator_t {
170178825Sdfr    const struct cc_credentials_iterator_functions *func;
171178825Sdfr};
172178825Sdfr
173178825Sdfrstruct cc_ccache_iterator_functions {
174178825Sdfr    cc_int32 (*release) (cc_ccache_iterator_t);
175178825Sdfr    cc_int32 (*next)(cc_ccache_iterator_t, cc_ccache_t*);
176178825Sdfr};
177178825Sdfr
178178825Sdfrstruct cc_ccache_iterator_t {
179178825Sdfr    const struct cc_ccache_iterator_functions* func;
180178825Sdfr};
181178825Sdfr
182178825Sdfrtypedef struct cc_ccache_functions {
183178825Sdfr    cc_int32 (*release)(cc_ccache_t);
184178825Sdfr    cc_int32 (*destroy)(cc_ccache_t);
185178825Sdfr    cc_int32 (*set_default)(cc_ccache_t);
186178825Sdfr    cc_int32 (*get_credentials_version)(cc_ccache_t, cc_uint32*);
187178825Sdfr    cc_int32 (*get_name)(cc_ccache_t, cc_string_t*);
188178825Sdfr    cc_int32 (*get_principal)(cc_ccache_t, cc_uint32, cc_string_t*);
189178825Sdfr    cc_int32 (*set_principal)(cc_ccache_t, cc_uint32, const char*);
190178825Sdfr    cc_int32 (*store_credentials)(cc_ccache_t, const cc_credentials_union*);
191178825Sdfr    cc_int32 (*remove_credentials)(cc_ccache_t, cc_credentials_t);
192178825Sdfr    cc_int32 (*new_credentials_iterator)(cc_ccache_t,
193178825Sdfr					 cc_credentials_iterator_t*);
194178825Sdfr    cc_int32 (*move)(cc_ccache_t, cc_ccache_t);
195178825Sdfr    cc_int32 (*lock)(cc_ccache_t, cc_uint32, cc_uint32);
196178825Sdfr    cc_int32 (*unlock)(cc_ccache_t);
197178825Sdfr    cc_int32 (*get_last_default_time)(cc_ccache_t, cc_time_t*);
198178825Sdfr    cc_int32 (*get_change_time)(cc_ccache_t, cc_time_t*);
199178825Sdfr    cc_int32 (*compare)(cc_ccache_t, cc_ccache_t, cc_uint32*);
200178825Sdfr    cc_int32 (*get_kdc_time_offset)(cc_ccache_t, cc_int32, cc_time_t *);
201178825Sdfr    cc_int32 (*set_kdc_time_offset)(cc_ccache_t, cc_int32, cc_time_t);
202178825Sdfr    cc_int32 (*clear_kdc_time_offset)(cc_ccache_t, cc_int32);
203178825Sdfr} cc_ccache_functions;
204178825Sdfr
205178825Sdfrstruct cc_ccache_t {
206178825Sdfr    const cc_ccache_functions *func;
207178825Sdfr};
208178825Sdfr
209178825Sdfrstruct  cc_context_functions {
210178825Sdfr    cc_int32 (*release)(cc_context_t);
211178825Sdfr    cc_int32 (*get_change_time)(cc_context_t, cc_time_t *);
212178825Sdfr    cc_int32 (*get_default_ccache_name)(cc_context_t, cc_string_t*);
213178825Sdfr    cc_int32 (*open_ccache)(cc_context_t, const char*, cc_ccache_t *);
214178825Sdfr    cc_int32 (*open_default_ccache)(cc_context_t, cc_ccache_t*);
215178825Sdfr    cc_int32 (*create_ccache)(cc_context_t,const char*, cc_uint32,
216178825Sdfr			      const char*, cc_ccache_t*);
217178825Sdfr    cc_int32 (*create_default_ccache)(cc_context_t, cc_uint32,
218178825Sdfr				      const char*, cc_ccache_t*);
219178825Sdfr    cc_int32 (*create_new_ccache)(cc_context_t, cc_uint32,
220178825Sdfr				  const char*, cc_ccache_t*);
221178825Sdfr    cc_int32 (*new_ccache_iterator)(cc_context_t, cc_ccache_iterator_t*);
222178825Sdfr    cc_int32 (*lock)(cc_context_t, cc_uint32, cc_uint32);
223178825Sdfr    cc_int32 (*unlock)(cc_context_t);
224178825Sdfr    cc_int32 (*compare)(cc_context_t, cc_context_t, cc_uint32*);
225178825Sdfr};
226178825Sdfr
227178825Sdfrstruct cc_context_t {
228178825Sdfr    const struct cc_context_functions* func;
229178825Sdfr};
230178825Sdfr
231233294Sstastypedef cc_int32
232178825Sdfr(*cc_initialize_func)(cc_context_t*, cc_int32, cc_int32 *, char const **);
233178825Sdfr
234233294Sstas#ifdef __APPLE__
235233294Sstas#pragma pack(pop)
236233294Sstas#endif
237233294Sstas
238233294Sstas
239178825Sdfr#endif /* KRB5_CCAPI_H */
240