summaryrefslogtreecommitdiffstats
path: root/src/mac/libraries/CCache API/include/CCache.h
blob: 9fce4f915a96e0e8d4fbe48ba42d4a55d160b849 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
/*
 * Declarations for Credentials Cache API Library
 *
 * API specification: <http://web.mit.edu/pismere/kerberos/ccache-api-v2-draft.html>
 *
 *	Revision 1: Frank Dabek, 6/4/1998
 *	Revision 2: meeroh, 2/24/1999
 *
 * $Header$
 */
 
#ifndef __CCache_h__
#define __CCache_h__

#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */

#include <ConditionalMacros.h>

#if PRAGMA_IMPORT
#	pragma import on
#endif

/* This stuff is to make sure that we always use the same compiler options for
   this header file. Otherwise we get really exciting failure modes -- meeroh */
#if PRAGMA_STRUCT_ALIGN
	#pragma options align=mac68k
#elif PRAGMA_STRUCT_PACKPUSH
	#pragma pack(push, 2)
#elif PRAGMA_STRUCT_PACK
	#pragma pack(2)
#endif

#if PRAGMA_ENUM_ALWAYSINT
	#pragma enumsalwaysint on
#endif

#if TARGET_CPU_68K
	#pragma fourbyteints on
#endif 

#include <Processes.h>

/*
 * Constants
 */
 
/* Error codes */

enum {
	CC_NOERROR				= 0,
	CC_BADNAME				= 1,
	CC_NOTFOUND				= 2,
	CC_END					= 3,
	CC_IO					= 4,
	CC_WRITE				= 5,
	CC_NOMEM				= 6,
	CC_FORMAT				= 7,
	CC_LOCKED				= 8,
	CC_BAD_API_VERSION		= 9,
	CC_NO_EXIST				= 10,
	CC_NOT_SUPP				= 11,
	CC_BAD_PARM				= 12,
	CC_ERR_CACHE_ATTACH		= 13,
	CC_ERR_CACHE_RELEASE	= 14,
	CC_ERR_CACHE_FULL 		= 15,
	CC_ERR_CRED_VERSION		= 16
};

/* Kerberos v4 key types */

enum StringToKey_Type {
	STK_AFS = 0,
	STK_DES = 1
};

/* Credential version types */

enum {  
    CC_CRED_VUNKNOWN		= 0,
    CC_CRED_V4				= 1,
    CC_CRED_V5				= 2,
    CC_CRED_VMAX			= 3
};

/* API versions */

enum {
	CC_API_VER_1	= 1,
	CC_API_VER_2	= 2
};

/*
 * Types
 */
 
/* Basic integer types */

typedef		SInt32					cc_int32;
typedef		UInt32					cc_uint32;

/* Other simple types */

typedef		cc_int32				cc_time_t;
typedef		cc_int32				cc_nc_flags;

typedef		cc_int32				cc_result;
typedef		cc_int32				cc_api_version;
typedef		cc_int32				cc_cred_vers;
typedef		cc_uint32				cc_flags;

/* Credential structures */

/* V4 credentials */
enum {  
	MAX_V4_CRED_LEN = 1250, 
	KRB_PRINCIPAL_SZ = 40, 
	KRB_INSTANCE_SZ = 40,
	KRB_REALM_SZ = 40,
	KRB_SERVICE_SZ = 40,
	ADDR_SZ = 16 
};

typedef struct _V4credential {
	unsigned char	kversion;								/* Always 4 */
    char			principal[KRB_PRINCIPAL_SZ];			/* Principal name */
    char			principal_instance[KRB_INSTANCE_SZ];	/* Principal instance */
    char			service[KRB_SERVICE_SZ];				/* Service name */
    char			service_instance[KRB_INSTANCE_SZ];		/* Service instance */
    char			realm[KRB_REALM_SZ];					/* Realm */
    unsigned char	session_key[8];							/* Session key */
    cc_int32		kvno;									/* Key version number */
    cc_int32		str_to_key;								/* Key password hash type */
    long			issue_date;  							/* Ticket issue date */
    cc_int32		lifetime;          						/* Ticket lifetime */
    cc_uint32		address;								/* IP address of local host */
    cc_int32		ticket_sz;								/* Ticket size */
    unsigned char	ticket[MAX_V4_CRED_LEN];				/* Ticket date */
    unsigned long	oops;									/* unused. ignore */
} V4Cred_type;

/* V5 credentials */
typedef struct _cc_data {
	cc_uint32		type;
	cc_uint32		length;
	unsigned char*	data;
} cc_data;

typedef struct _cc_creds {
	char*		client;
	char*		server;
	cc_data		keyblock;
	cc_time_t	authtime;
	cc_time_t	starttime;
	cc_time_t	endtime;
	cc_time_t	renew_till;
	cc_uint32	is_skey;
	cc_uint32	ticket_flags;
	cc_data     **addresses;
	cc_data		ticket;
	cc_data		second_ticket;
	cc_data     **authdata;
} cc_creds;

/* union of v4 and v5 pointers */
typedef union cred_ptr_union_type {
    V4Cred_type* pV4Cred;
    cc_creds*    pV5Cred;
} cred_ptr_union;

/* common credentials structure */
typedef struct cred_union_type {
    cc_cred_vers cred_type;
    cred_ptr_union cred;
} cred_union;

/* Cache info structures */
typedef struct _infoNC  {
	char*			name;
	char*			principal;
	cc_cred_vers	vers;
} infoNC;

/* Opaque API references */
 
struct ccache_p;
typedef struct ccache_p ccache_p;

struct apiCB;
typedef struct apiCB apiCB;

struct ccache_cit;
typedef struct ccache_cit ccache_cit;

/*
 * Functions
 */
 
/* Initialization / termination */

cc_result
cc_initialize (
		apiCB**				cc_ctx,
		cc_api_version		api_version,
		cc_api_version*		api_supported,
		char**				vendor);

cc_result
cc_shutdown (
		apiCB**				cc_ctx);
		
/* ccache access */

cc_result
cc_open (
		apiCB*				cc_ctx,
		char*				name,
		cc_cred_vers		vers,
		cc_flags			flags,
		ccache_p**			handle);

cc_result
cc_close (
		apiCB*				cc_ctx,
		ccache_p**			handle);

cc_result
cc_create (
		apiCB*				cc_ctx,
		char*				name,
		char*				principal,
		cc_cred_vers		vers,
		cc_flags			flags,
		ccache_p**			handle);

cc_result
cc_destroy (
		apiCB*				cc_ctx,
		ccache_p**			handle);
		
cc_result
cc_set_principal (
		apiCB*				cc_ctx,
		const ccache_p*		ccache_pointer,
		cc_cred_vers		vers,
		const char*			principal);

cc_result
cc_get_principal (
		apiCB*				cc_ctx,
		const ccache_p*		ccache_pointer,
		char**				principal);

cc_result
cc_get_cred_version (
		apiCB*				cc_ctx,
		const ccache_p*		ccache_pointer,
		cc_cred_vers*		vers);

cc_result
cc_get_name (
		apiCB*				cc_ctx,
		const ccache_p*		ccache_pointer,
		char**				name);

/* credentials access */

cc_result
cc_store (
		apiCB*				cc_ctx,
		const ccache_p*		ccache_pointer,
		cred_union			cred);

cc_result
cc_remove_cred (
		apiCB*				cc_ctx,
		const ccache_p*		ccache_pointer,
		cred_union			cred);

/* Iterators */

cc_result
cc_seq_fetch_NCs_begin (
		apiCB*				cc_ctx,
		ccache_cit**		itCache);

cc_result
cc_seq_fetch_NCs_next (
		apiCB*				cc_ctx,
		ccache_p**			ccache_pointer,
		ccache_cit*			itCache);

cc_result
cc_seq_fetch_NCs_end (
		apiCB*				cc_ctx,
		ccache_cit**		itCache);

cc_result
cc_seq_fetch_creds_begin (
		apiCB*				cc_ctx,
		ccache_p*			ccache_pointer,
		ccache_cit**		itCreds);

cc_result
cc_seq_fetch_creds_next (
		apiCB*				cc_ctx,
		cred_union**		creds,
		ccache_cit*			itCreds);

cc_result
cc_seq_fetch_creds_end (
		apiCB*				cc_ctx,
		ccache_cit**		itCreds);
		
/* global ccache info */

cc_result
cc_get_change_time (
		apiCB*				cc_ctx,
		cc_time_t*			time);

cc_result
cc_get_NC_info (
		apiCB*				cc_ctx,
		infoNC***			ppNCi);

/* memory recovery */

cc_result
cc_free_principal (
		apiCB*				cc_ctx,
		char**				principal);

cc_result
cc_free_name (
		apiCB*				cc_ctx,
		char**				name);

cc_result
cc_free_creds (
		apiCB*				cc_ctx,
		cred_union**		creds);

cc_result
cc_free_NC_info (
		apiCB*				cc_ctx,
		infoNC***			ppNCi);

/* Locking -- not implemented */
enum {
	CC_LOCK_UNLOCK		= 1,
	CC_LOCK_READER		= 2,
	CC_LOCK_WRITER		= 3,
	CC_LOCK_NOBLOCK		= 16
};

cc_result
cc_lock_request (
		apiCB*				cc_ctx,
		ccache_p*			ccache_pointer,
		cc_uint32			lock_type);
			   
#if PRAGMA_STRUCT_ALIGN
	#pragma options align=reset
#elif PRAGMA_STRUCT_PACKPUSH
	#pragma pack(pop)
#elif PRAGMA_STRUCT_PACK
	#pragma pack()
#endif

#if PRAGMA_ENUM_ALWAYSINT
	#pragma enumsalwaysint reset
#endif

#if TARGET_CPU_68K
	#pragma fourbyteints reset
#endif 

#if PRAGMA_IMPORT
#	pragma import reset
#endif

#ifdef __cplusplus
}
#endif /* __cplusplus */

#endif /* __CCache_h__ */