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
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
|
/* $Copyright:
*
* Copyright 1998-2006 by the Massachusetts Institute of Technology.
*
* All rights reserved.
*
* Export of this software from the United States of America may require a
* specific license from the United States Government. It is the
* responsibility of any person or organization contemplating export to
* obtain such a license before exporting.
*
* WITHIN THAT CONSTRAINT, permission to use, copy, modify, and distribute
* this software and its documentation for any purpose and without fee is
* hereby granted, provided that the above copyright notice appear in all
* copies and that both that copyright notice and this permission notice
* appear in supporting documentation, and that the name of M.I.T. not be
* used in advertising or publicity pertaining to distribution of the
* software without specific, written prior permission. Furthermore if you
* modify this software you must label your software as modified software
* and not distribute it in such a fashion that it might be confused with
* the original MIT software. M.I.T. makes no representations about the
* suitability of this software for any purpose. It is provided "as is"
* without express or implied warranty.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* Individual source code files are copyright MIT, Cygnus Support,
* OpenVision, Oracle, Sun Soft, FundsXpress, and others.
*
* Project Athena, Athena, Athena MUSE, Discuss, Hesiod, Kerberos, Moira,
* and Zephyr are trademarks of the Massachusetts Institute of Technology
* (MIT). No commercial use of these trademarks may be made without prior
* written permission of MIT.
*
* "Commercial use" means use of a name in a product or other for-profit
* manner. It does NOT prevent a commercial firm from referring to the MIT
* trademarks in order to convey information (although in doing so,
* recognition of their trademark status should be given).
* $
*/
/* $Header$ */
/*
* Declarations for Credentials Cache API Library
*
* API specification: <http://web.mit.edu/pismere/kerberos/ccache-api-v3.html>
*
* Revision 1: Frank Dabek, 6/4/1998
* Revision 2: meeroh, 2/24/1999
* Revision 3: meeroh, 11/12/1999
* Revision 6: jaltman, 10/27/2004
*
*/
#ifndef __CREDENTIALSCACHE__
#define __CREDENTIALSCACHE__
#if defined(macintosh) || (defined(__MACH__) && defined(__APPLE__))
#include <TargetConditionals.h>
#if TARGET_RT_MAC_CFM
#error "Use KfM 4.0 SDK headers for CFM compilation."
#endif
#endif
#if TARGET_OS_MAC
#include <sys/types.h>
#endif
#if defined(_WIN32)
#include <winsock.h>
#endif
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
#if TARGET_OS_MAC
#if defined(__MWERKS__)
#pragma import on
#pragma enumsalwaysint on
#endif
#pragma options align=mac68k
#endif
#if defined(_WIN32)
#define CCACHE_API __declspec(dllexport)
#if _INTEGRAL_MAX_BITS >= 64 && _MSC_VER >= 1400 && !defined(_WIN64) && !defined(_USE_32BIT_TIME_T)
#if defined(_TIME_T_DEFINED) || defined(_INC_IO) || defined(_INC_TIME) || defined(_INC_WCHAR)
#error time_t has been defined as a 64-bit integer which is incompatible with Kerberos on this platform.
#endif /* _TIME_T_DEFINED */
#define _USE_32BIT_TIME_T
#endif
#endif
#include <time.h>
/*
* Constants
*/
/* API versions */
enum {
ccapi_version_2 = 2,
ccapi_version_3 = 3,
ccapi_version_4 = 4,
ccapi_version_5 = 5,
ccapi_version_6 = 6,
ccapi_version_max = ccapi_version_6
};
/* Errors */
enum {
ccNoError = 0,
ccIteratorEnd = 201,
ccErrBadParam,
ccErrNoMem,
ccErrInvalidContext,
ccErrInvalidCCache,
ccErrInvalidString, /* 206 */
ccErrInvalidCredentials,
ccErrInvalidCCacheIterator,
ccErrInvalidCredentialsIterator,
ccErrInvalidLock,
ccErrBadName, /* 211 */
ccErrBadCredentialsVersion,
ccErrBadAPIVersion,
ccErrContextLocked,
ccErrContextUnlocked,
ccErrCCacheLocked, /* 216 */
ccErrCCacheUnlocked,
ccErrBadLockType,
ccErrNeverDefault,
ccErrCredentialsNotFound,
ccErrCCacheNotFound, /* 221 */
ccErrContextNotFound,
ccErrServerUnavailable,
ccErrServerInsecure,
ccErrServerCantBecomeUID,
ccErrTimeOffsetNotSet, /* 226 */
ccErrBadInternalMessage,
ccErrNotImplemented
};
/* Credentials versions */
enum cc_credential_versions {
cc_credentials_v4 = 1,
cc_credentials_v5 = 2,
cc_credentials_v4_v5 = 3
};
/* Lock types */
enum cc_lock_types {
cc_lock_read = 0,
cc_lock_write = 1,
cc_lock_upgrade = 2,
cc_lock_downgrade = 3
};
/* Locking Modes */
enum cc_lock_modes {
cc_lock_noblock = 0,
cc_lock_block = 1
};
/*
* Basic types
*/
typedef char cc_int8;
typedef unsigned char cc_uint8;
typedef int cc_int32;
typedef unsigned int cc_uint32;
#if defined (WIN32)
typedef __int64 cc_int64;
typedef unsigned __int64 cc_uint64;
#else
typedef long long cc_int64;
typedef unsigned long long cc_uint64;
#endif
typedef time_t cc_time;
typedef cc_int64 cc_time64;
typedef cc_uint64 cc_handle;
/*
* API types
*/
/* Forward declarations */
struct cc_context_f;
typedef struct cc_context_f cc_context_f;
struct cc_ccache_f;
typedef struct cc_ccache_f cc_ccache_f;
struct cc_ccache_iterator_f;
typedef struct cc_ccache_iterator_f cc_ccache_iterator_f;
struct cc_ccache_iterator_f;
typedef struct cc_credentials_iterator_f cc_credentials_iterator_f;
struct cc_string_f;
typedef struct cc_string_f cc_string_f;
struct cc_credentials_f;
typedef struct cc_credentials_f cc_credentials_f;
/* Credentials types */
enum { /* Make sure all of these are multiples of four (for alignment sanity) */
cc_v4_name_size = 40,
cc_v4_instance_size = 40,
cc_v4_realm_size = 40,
cc_v4_ticket_size = 1254,
cc_v4_key_size = 8
};
enum cc_string_to_key_type {
cc_v4_stk_afs = 0,
cc_v4_stk_des = 1,
cc_v4_stk_columbia_special = 2,
cc_v4_stk_krb5 = 3,
cc_v4_stk_unknown = 4
};
struct cc_credentials_v4_t {
cc_uint32 version;
char principal [cc_v4_name_size];
char principal_instance [cc_v4_instance_size];
char service [cc_v4_name_size];
char service_instance [cc_v4_instance_size];
char realm [cc_v4_realm_size];
unsigned char session_key [cc_v4_key_size];
cc_int32 kvno;
cc_int32 string_to_key_type;
cc_time issue_date;
cc_int32 lifetime;
cc_uint32 address;
cc_int32 ticket_size;
unsigned char ticket [cc_v4_ticket_size];
};
typedef struct cc_credentials_v4_t cc_credentials_v4_t;
struct cc_data {
cc_uint32 type;
cc_uint32 length;
void* data;
};
typedef struct cc_data cc_data;
struct cc_credentials_v5_t {
char* client;
char* server;
cc_data keyblock;
cc_time authtime;
cc_time starttime;
cc_time endtime;
cc_time renew_till;
cc_uint32 is_skey;
cc_uint32 ticket_flags;
cc_data** addresses;
cc_data ticket;
cc_data second_ticket;
cc_data** authdata;
};
typedef struct cc_credentials_v5_t cc_credentials_v5_t;
struct cc_credentials_union {
cc_int32 version;
union {
cc_credentials_v4_t* credentials_v4;
cc_credentials_v5_t* credentials_v5;
} credentials;
};
typedef struct cc_credentials_union cc_credentials_union;
/* Exposed parts */
struct cc_context_d {
const cc_context_f* functions;
#if TARGET_OS_MAC
const cc_context_f* otherFunctions;
#endif
};
typedef struct cc_context_d cc_context_d;
typedef cc_context_d* cc_context_t;
struct cc_ccache_d {
const cc_ccache_f* functions;
#if TARGET_OS_MAC
const cc_ccache_f* otherFunctions;
#endif
};
typedef struct cc_ccache_d cc_ccache_d;
typedef cc_ccache_d* cc_ccache_t;
struct cc_ccache_iterator_d {
const cc_ccache_iterator_f* functions;
#if TARGET_OS_MAC
const cc_ccache_iterator_f* otherFunctions;
#endif
};
typedef struct cc_ccache_iterator_d cc_ccache_iterator_d;
typedef cc_ccache_iterator_d* cc_ccache_iterator_t;
struct cc_credentials_iterator_d {
const cc_credentials_iterator_f* functions;
#if TARGET_OS_MAC
const cc_credentials_iterator_f* otherFunctions;
#endif
};
typedef struct cc_credentials_iterator_d cc_credentials_iterator_d;
typedef cc_credentials_iterator_d* cc_credentials_iterator_t;
struct cc_string_d {
const char* data;
const cc_string_f* functions;
#if TARGET_OS_MAC
const cc_string_f* otherFunctions;
#endif
};
typedef struct cc_string_d cc_string_d;
typedef cc_string_d* cc_string_t;
struct cc_credentials_d {
const cc_credentials_union* data;
const cc_credentials_f* functions;
#if TARGET_OS_MAC
const cc_credentials_f* otherFunctions;
#endif
};
typedef struct cc_credentials_d cc_credentials_d;
typedef cc_credentials_d* cc_credentials_t;
/* Function pointer structs */
struct cc_context_f {
cc_int32 (*release) (
cc_context_t context);
cc_int32 (*get_change_time) (
cc_context_t context,
cc_time* time);
cc_int32 (*get_default_ccache_name) (
cc_context_t context,
cc_string_t* name);
cc_int32 (*open_ccache) (
cc_context_t context,
const char* name,
cc_ccache_t* ccache);
cc_int32 (*open_default_ccache) (
cc_context_t context,
cc_ccache_t* ccache);
cc_int32 (*create_ccache) (
cc_context_t context,
const char* name,
cc_uint32 cred_vers,
const char* principal,
cc_ccache_t* ccache);
cc_int32 (*create_default_ccache) (
cc_context_t context,
cc_uint32 cred_vers,
const char* principal,
cc_ccache_t* ccache);
cc_int32 (*create_new_ccache) (
cc_context_t context,
cc_uint32 cred_vers,
const char* principal,
cc_ccache_t* ccache);
cc_int32 (*new_ccache_iterator) (
cc_context_t context,
cc_ccache_iterator_t* iterator);
cc_int32 (*lock) (
cc_context_t context,
cc_uint32 lock_type,
cc_uint32 block);
cc_int32 (*unlock) (
cc_context_t context);
cc_int32 (*compare) (
cc_context_t context,
cc_context_t compare_to,
cc_uint32* equal);
};
struct cc_ccache_f {
cc_int32 (*release) (
cc_ccache_t ccache);
cc_int32 (*destroy) (
cc_ccache_t ccache);
cc_int32 (*set_default) (
cc_ccache_t ccache);
cc_int32 (*get_credentials_version) (
cc_ccache_t ccache,
cc_uint32* credentials_version);
cc_int32 (*get_name) (
cc_ccache_t ccache,
cc_string_t* name);
cc_int32 (*get_principal) (
cc_ccache_t ccache,
cc_uint32 credentials_version,
cc_string_t* principal);
cc_int32 (*set_principal) (
cc_ccache_t ccache,
cc_uint32 credentials_version,
const char* principal);
cc_int32 (*store_credentials) (
cc_ccache_t ccache,
const cc_credentials_union* credentials);
cc_int32 (*remove_credentials) (
cc_ccache_t ccache,
cc_credentials_t credentials);
cc_int32 (*new_credentials_iterator) (
cc_ccache_t ccache,
cc_credentials_iterator_t* iterator);
cc_int32 (*move) (
cc_ccache_t source,
cc_ccache_t destination);
cc_int32 (*lock) (
cc_ccache_t ccache,
cc_uint32 lock_type,
cc_uint32 block);
cc_int32 (*unlock) (
cc_ccache_t ccache);
cc_int32 (*get_last_default_time) (
cc_ccache_t ccache,
cc_time* time);
cc_int32 (*get_change_time) (
cc_ccache_t ccache,
cc_time* time);
cc_int32 (*compare) (
cc_ccache_t ccache,
cc_ccache_t compare_to,
cc_uint32* equal);
cc_int32 (*get_kdc_time_offset) (
cc_ccache_t ccache,
cc_int32 credentials_version,
cc_time* time_offset);
cc_int32 (*set_kdc_time_offset) (
cc_ccache_t ccache,
cc_int32 credentials_version,
cc_time time_offset);
cc_int32 (*clear_kdc_time_offset) (
cc_ccache_t ccache,
cc_int32 credentials_version);
};
struct cc_string_f {
cc_int32 (*release) (
cc_string_t string);
};
struct cc_credentials_f {
cc_int32 (*release) (
cc_credentials_t credentials);
cc_int32 (*compare) (
cc_credentials_t credentials,
cc_credentials_t compare_to,
cc_uint32* equal);
};
struct cc_ccache_iterator_f {
cc_int32 (*release) (
cc_ccache_iterator_t iter);
cc_int32 (*next) (
cc_ccache_iterator_t iter,
cc_ccache_t* ccache);
cc_int32 (*clone) ( cc_ccache_iterator_t iter,
cc_ccache_iterator_t* new_iter);
};
struct cc_credentials_iterator_f {
cc_int32 (*release) (
cc_credentials_iterator_t iter);
cc_int32 (*next) (
cc_credentials_iterator_t iter,
cc_credentials_t* ccache);
cc_int32 (*clone) ( cc_credentials_iterator_t iter,
cc_credentials_iterator_t* new_iter);
};
/*
* API functions
*/
CCACHE_API cc_int32 cc_initialize (
cc_context_t* outContext,
cc_int32 inVersion,
cc_int32* outSupportedVersion,
char const** outVendor);
/*
* Convenience macros
*/
#define cc_context_release(context) \
((context) -> functions -> release (context))
#define cc_context_get_change_time(context, time) \
((context) -> functions -> get_change_time (context, time))
#define cc_context_get_default_ccache_name(context, name) \
((context) -> functions -> get_default_ccache_name (context, name))
#define cc_context_open_ccache(context, name, ccache) \
((context) -> functions -> open_ccache (context, name, ccache))
#define cc_context_open_default_ccache(context, ccache) \
((context) -> functions -> open_default_ccache (context, ccache))
#define cc_context_create_ccache(context, name, version, principal, ccache) \
((context) -> functions -> create_ccache (context, name, version, principal, ccache))
#define cc_context_create_default_ccache(context, version, principal, ccache) \
((context) -> functions -> create_default_ccache (context, version, principal, ccache))
#define cc_context_create_new_ccache(context, version, principal, ccache) \
((context) -> functions -> create_new_ccache (context, version, principal, ccache))
#define cc_context_new_ccache_iterator(context, iterator) \
((context) -> functions -> new_ccache_iterator (context, iterator))
#define cc_context_lock(context, type, block) \
((context) -> functions -> lock (context, type, block))
#define cc_context_unlock(context) \
((context) -> functions -> unlock (context))
#define cc_context_compare(context, compare_to, equal) \
((context) -> functions -> compare (context, compare_to, equal))
#define cc_ccache_release(ccache) \
((ccache) -> functions -> release (ccache))
#define cc_ccache_destroy(ccache) \
((ccache) -> functions -> destroy (ccache))
#define cc_ccache_set_default(ccache) \
((ccache) -> functions -> set_default (ccache))
#define cc_ccache_get_credentials_version(ccache, version) \
((ccache) -> functions -> get_credentials_version (ccache, version))
#define cc_ccache_get_name(ccache, name) \
((ccache) -> functions -> get_name (ccache, name))
#define cc_ccache_get_principal(ccache, version, principal) \
((ccache) -> functions -> get_principal (ccache, version, principal))
#define cc_ccache_set_principal(ccache, version, principal) \
((ccache) -> functions -> set_principal (ccache, version, principal))
#define cc_ccache_store_credentials(ccache, credentials) \
((ccache) -> functions -> store_credentials (ccache, credentials))
#define cc_ccache_remove_credentials(ccache, credentials) \
((ccache) -> functions -> remove_credentials (ccache, credentials))
#define cc_ccache_new_credentials_iterator(ccache, iterator) \
((ccache) -> functions -> new_credentials_iterator (ccache, iterator))
#define cc_ccache_lock(ccache, type, block) \
((ccache) -> functions -> lock (ccache, type, block))
#define cc_ccache_unlock(ccache, unlock) \
((ccache) -> functions -> unlock (ccache, unlock))
#define cc_ccache_get_last_default_time(ccache, time) \
((ccache) -> functions -> get_last_default_time (ccache, time))
#define cc_ccache_get_change_time(ccache, time) \
((ccache) -> functions -> get_change_time (ccache, time))
#define cc_ccache_move(source, destination) \
((source) -> functions -> move (source, destination))
#define cc_ccache_compare(ccache, compare_to, equal) \
((ccache) -> functions -> compare (ccache, compare_to, equal))
#define cc_ccache_get_kdc_time_offset(ccache, version, time) \
((ccache) -> functions -> get_kdc_time_offset (version, time))
#define cc_ccache_set_kdc_time_offset(ccache, version, time) \
((ccache) -> functions -> set_kdc_time_offset (version, time))
#define cc_ccache_clear_kdc_time_offset(ccache, version) \
((ccache) -> functions -> clear_kdc_time_offset (version))
#define cc_string_release(string) \
((string) -> functions -> release (string))
#define cc_credentials_release(credentials) \
((credentials) -> functions -> release (credentials))
#define cc_credentials_compare(credentials, compare_to, equal) \
((credentials) -> functions -> compare (credentials, compare_to, equal))
#define cc_ccache_iterator_release(iterator) \
((iterator) -> functions -> release (iterator))
#define cc_ccache_iterator_next(iterator, ccache) \
((iterator) -> functions -> next (iterator, ccache))
#define cc_ccache_iterator_clone(iterator, new_iter) \
((iterator) -> functions -> clone (iterator, new_iter))
#define cc_credentials_iterator_release(iterator) \
((iterator) -> functions -> release (iterator))
#define cc_credentials_iterator_next(iterator, credentials) \
((iterator) -> functions -> next (iterator, credentials))
#define cc_credentials_iterator_clone(iterator, new_iter) \
((iterator) -> functions -> clone (iterator, new_iter))
#if TARGET_OS_MAC
#if defined(__MWERKS__)
#pragma enumsalwaysint reset
#pragma import reset
#endif
#pragma options align=reset
#endif
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __CREDENTIALSCACHE__ */
|