1/* $Copyright: 2 * 3 * Copyright 1998-2000 by the Massachusetts Institute of Technology. 4 * 5 * All rights reserved. 6 * 7 * Export of this software from the United States of America may require a 8 * specific license from the United States Government. It is the 9 * responsibility of any person or organization contemplating export to 10 * obtain such a license before exporting. 11 * 12 * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and distribute 13 * this software and its documentation for any purpose and without fee is 14 * hereby granted, provided that the above copyright notice appear in all 15 * copies and that both that copyright notice and this permission notice 16 * appear in supporting documentation, and that the name of M.I.T. not be 17 * used in advertising or publicity pertaining to distribution of the 18 * software without specific, written prior permission. Furthermore if you 19 * modify this software you must label your software as modified software 20 * and not distribute it in such a fashion that it might be confused with 21 * the original MIT software. M.I.T. makes no representations about the 22 * suitability of this software for any purpose. It is provided "as is" 23 * without express or implied warranty. 24 * 25 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED 26 * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF 27 * MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. 28 * 29 * Individual source code files are copyright MIT, Cygnus Support, 30 * OpenVision, Oracle, Sun Soft, FundsXpress, and others. 31 * 32 * Project Athena, Athena, Athena MUSE, Discuss, Hesiod, Kerberos, Moira, 33 * and Zephyr are trademarks of the Massachusetts Institute of Technology 34 * (MIT). No commercial use of these trademarks may be made without prior 35 * written permission of MIT. 36 * 37 * "Commercial use" means use of a name in a product or other for-profit 38 * manner. It does NOT prevent a commercial firm from referring to the MIT 39 * trademarks in order to convey information (although in doing so, 40 * recognition of their trademark status should be given). 41 * $ 42 */ 43 44/* $Header: /Volumes/backup/dsmigrate/Dumps/../CVS/passwordserver_sasl/cyrus_sasl/mac/CommonKClient/mac_kclient3/Headers/CredentialsCache/CredentialsCache.h,v 1.4 2005/01/10 19:17:31 snsimon Exp $ */ 45 46/* 47 * Declarations for Credentials Cache API Library 48 * 49 * API specification: <http://web.mit.edu/pismere/kerberos/ccache-api-v2.html> 50 * 51 * Revision 1: Frank Dabek, 6/4/1998 52 * Revision 2: meeroh, 2/24/1999 53 * Revision 3: meeroh, 11/12/1999 54 * 55 */ 56 57#ifndef __CREDENTIALSCACHE__ 58#define __CREDENTIALSCACHE__ 59 60#ifdef __cplusplus 61extern "C" { 62#endif /* __cplusplus */ 63 64#include <KerberosSupport/KerberosConditionalMacros.h> 65 66#if TARGET_API_MAC_OSX && TARGET_API_MAC_CARBON 67 #include <CoreServices/CoreServices.h> 68#elif TARGET_API_MAC_OS8 || TARGET_API_MAC_CARBON 69 #include <MacTypes.h> 70#else 71 #error "Unknown OS; no system types available" 72#endif 73 74#if PRAGMA_IMPORT 75# pragma import on 76#endif 77 78/* This stuff is to make sure that we always use the same compiler options for 79 this header file. Otherwise we get really exciting failure modes -- meeroh */ 80#if PRAGMA_STRUCT_ALIGN 81 #pragma options align=mac68k4byte 82#elif PRAGMA_STRUCT_PACKPUSH 83 #pragma pack(push, 4) 84#elif PRAGMA_STRUCT_PACK 85 #pragma pack(4) 86#endif 87 88#if PRAGMA_ENUM_ALWAYSINT 89 #pragma enumsalwaysint on 90#endif 91 92#if TARGET_CPU_68K 93 #pragma fourbyteints on 94#endif 95 96/* 97 * Constants 98 */ 99 100/* API versions */ 101enum { 102 ccapi_version_2 = 2, 103 ccapi_version_3 = 3, 104 ccapi_version_4 = 4 105}; 106 107/* Errors */ 108enum { 109 ccNoError = 0, 110 111 ccIteratorEnd = 201, 112 ccErrBadParam, 113 ccErrNoMem, 114 ccErrInvalidContext, 115 ccErrInvalidCCache, 116 117 ccErrInvalidString, /* 206 */ 118 ccErrInvalidCredentials, 119 ccErrInvalidCCacheIterator, 120 ccErrInvalidCredentialsIterator, 121 ccErrInvalidLock, 122 123 ccErrBadName, /* 211 */ 124 ccErrBadCredentialsVersion, 125 ccErrBadAPIVersion, 126 ccErrContextLocked, 127 ccErrContextUnlocked, 128 129 ccErrCCacheLocked, /* 216 */ 130 ccErrCCacheUnlocked, 131 ccErrBadLockType, 132 ccErrNeverDefault, 133 ccErrCredentialsNotFound, 134 135 ccErrCCacheNotFound, /* 221 */ 136 ccErrContextNotFound, 137 ccErrServerUnavailable 138}; 139 140/* Credentials versions */ 141enum { 142 cc_credentials_v4 = 1, 143 cc_credentials_v5 = 2, 144 cc_credentials_v4_v5 = 3 145}; 146 147/* 148 * Basic types 149 */ 150 151typedef UInt32 cc_uint32; 152typedef SInt32 cc_int32; 153typedef cc_uint32 cc_time_t; 154 155/* 156 * API types 157 */ 158 159/* Forward declarations */ 160struct cc_context_f; 161typedef struct cc_context_f cc_context_f; 162 163struct cc_ccache_f; 164typedef struct cc_ccache_f cc_ccache_f; 165 166struct cc_ccache_iterator_f; 167typedef struct cc_ccache_iterator_f cc_ccache_iterator_f; 168 169struct cc_ccache_iterator_f; 170typedef struct cc_credentials_iterator_f cc_credentials_iterator_f; 171 172struct cc_string_f; 173typedef struct cc_string_f cc_string_f; 174 175struct cc_credentials_f; 176typedef struct cc_credentials_f cc_credentials_f; 177 178/* Credentials types */ 179 180enum { /* Make sure all of these are multiples of four (for alignment sanity) */ 181 cc_v4_name_size = 40, 182 cc_v4_instance_size = 40, 183 cc_v4_realm_size = 40, 184 cc_v4_ticket_size = 1254 185}; 186 187enum cc_string_to_key_type { 188 cc_v4_stk_afs = 0, 189 cc_v4_stk_des = 1, 190 cc_v4_stk_columbia_special = 2, 191 cc_v4_stk_unknown = 3 192}; 193 194struct cc_credentials_v4_t { 195 cc_uint32 version; 196 char principal [cc_v4_name_size]; 197 char principal_instance [cc_v4_instance_size]; 198 char service [cc_v4_name_size]; 199 char service_instance [cc_v4_instance_size]; 200 char realm [cc_v4_realm_size]; 201 unsigned char session_key [8]; 202 cc_int32 kvno; 203 cc_int32 string_to_key_type; 204 cc_time_t issue_date; 205 cc_int32 lifetime; 206 cc_uint32 address; 207 cc_int32 ticket_size; 208 unsigned char ticket [cc_v4_ticket_size]; 209}; 210typedef struct cc_credentials_v4_t cc_credentials_v4_t; 211 212struct cc_data { 213 cc_uint32 type; 214 cc_uint32 length; 215 void* data; 216}; 217typedef struct cc_data cc_data; 218 219struct cc_credentials_v5_t { 220 char* client; 221 char* server; 222 cc_data keyblock; 223 cc_time_t authtime; 224 cc_time_t starttime; 225 cc_time_t endtime; 226 cc_time_t renew_till; 227 cc_uint32 is_skey; 228 cc_uint32 ticket_flags; 229 cc_data** addresses; 230 cc_data ticket; 231 cc_data second_ticket; 232 cc_data** authdata; 233}; 234typedef struct cc_credentials_v5_t cc_credentials_v5_t; 235 236struct cc_credentials_union { 237 cc_int32 version; 238 union { 239 cc_credentials_v4_t* credentials_v4; 240 cc_credentials_v5_t* credentials_v5; 241 } credentials; 242}; 243typedef struct cc_credentials_union cc_credentials_union; 244 245/* Exposed parts */ 246 247struct cc_context_d { 248 const cc_context_f* functions; 249#if TARGET_OS_MAC 250 const cc_context_f* otherFunctions; 251#endif 252}; 253typedef struct cc_context_d cc_context_d; 254typedef cc_context_d* cc_context_t; 255 256struct cc_ccache_d { 257 const cc_ccache_f* functions; 258#if TARGET_OS_MAC 259 const cc_ccache_f* otherFunctions; 260#endif 261}; 262typedef struct cc_ccache_d cc_ccache_d; 263typedef cc_ccache_d* cc_ccache_t; 264 265struct cc_ccache_iterator_d { 266 const cc_ccache_iterator_f* functions; 267#if TARGET_OS_MAC 268 const cc_ccache_iterator_f* otherFunctions; 269#endif 270}; 271typedef struct cc_ccache_iterator_d cc_ccache_iterator_d; 272typedef cc_ccache_iterator_d* cc_ccache_iterator_t; 273 274struct cc_credentials_iterator_d { 275 const cc_credentials_iterator_f* functions; 276#if TARGET_OS_MAC 277 const cc_credentials_iterator_f* otherFunctions; 278#endif 279}; 280typedef struct cc_credentials_iterator_d cc_credentials_iterator_d; 281typedef cc_credentials_iterator_d* cc_credentials_iterator_t; 282 283struct cc_string_d { 284 const char* data; 285 const cc_string_f* functions; 286#if TARGET_OS_MAC 287 const cc_string_f* otherFunctions; 288#endif 289}; 290typedef struct cc_string_d cc_string_d; 291typedef cc_string_d* cc_string_t; 292 293struct cc_credentials_d { 294 const cc_credentials_union* data; 295 const cc_credentials_f* functions; 296#if TARGET_OS_MAC 297 const cc_credentials_f* otherFunctions; 298#endif 299}; 300typedef struct cc_credentials_d cc_credentials_d; 301typedef cc_credentials_d* cc_credentials_t; 302 303/* Function pointer structs */ 304 305struct cc_context_f { 306 cc_int32 (*release) ( 307 cc_context_t context); 308 cc_int32 (*get_change_time) ( 309 cc_context_t context, 310 cc_time_t* time); 311 cc_int32 (*get_default_ccache_name) ( 312 cc_context_t context, 313 cc_string_t* name); 314 cc_int32 (*open_ccache) ( 315 cc_context_t context, 316 const char* name, 317 cc_ccache_t* ccache); 318 cc_int32 (*open_default_ccache) ( 319 cc_context_t context, 320 cc_ccache_t* ccache); 321 cc_int32 (*create_ccache) ( 322 cc_context_t context, 323 const char* name, 324 cc_uint32 cred_vers, 325 const char* principal, 326 cc_ccache_t* ccache); 327 cc_int32 (*create_default_ccache) ( 328 cc_context_t context, 329 cc_uint32 cred_vers, 330 const char* principal, 331 cc_ccache_t* ccache); 332 cc_int32 (*create_new_ccache) ( 333 cc_context_t context, 334 cc_uint32 cred_vers, 335 const char* principal, 336 cc_ccache_t* ccache); 337 cc_int32 (*new_ccache_iterator) ( 338 cc_context_t context, 339 cc_ccache_iterator_t* iterator); 340 cc_int32 (*lock) ( 341 cc_context_t context, 342 cc_uint32 lock_type, 343 cc_uint32 block); 344 cc_int32 (*unlock) ( 345 cc_context_t context); 346 cc_int32 (*compare) ( 347 cc_context_t context, 348 cc_context_t compare_to, 349 cc_uint32* equal); 350}; 351 352struct cc_ccache_f { 353 cc_int32 (*release) ( 354 cc_ccache_t ccache); 355 cc_int32 (*destroy) ( 356 cc_ccache_t ccache); 357 cc_int32 (*set_default) ( 358 cc_ccache_t ccache); 359 cc_int32 (*get_credentials_version) ( 360 cc_ccache_t ccache, 361 cc_uint32* credentials_version); 362 cc_int32 (*get_name) ( 363 cc_ccache_t ccache, 364 cc_string_t* name); 365 cc_int32 (*get_principal) ( 366 cc_ccache_t ccache, 367 cc_uint32 credentials_version, 368 cc_string_t* principal); 369 cc_int32 (*set_principal) ( 370 cc_ccache_t ccache, 371 cc_uint32 credentials_version, 372 const char* principal); 373 cc_int32 (*store_credentials) ( 374 cc_ccache_t ccache, 375 const cc_credentials_union* credentials); 376 cc_int32 (*remove_credentials) ( 377 cc_ccache_t ccache, 378 cc_credentials_t credentials); 379 cc_int32 (*new_credentials_iterator) ( 380 cc_ccache_t ccache, 381 cc_credentials_iterator_t* iterator); 382 cc_int32 (*move) ( 383 cc_ccache_t source, 384 cc_ccache_t destination); 385 cc_int32 (*lock) ( 386 cc_ccache_t ccache, 387 cc_uint32 block, 388 cc_uint32 lock_type); 389 cc_int32 (*unlock) ( 390 cc_ccache_t ccache); 391 cc_int32 (*get_last_default_time) ( 392 cc_ccache_t ccache, 393 cc_time_t* time); 394 cc_int32 (*get_change_time) ( 395 cc_ccache_t ccache, 396 cc_time_t* time); 397 cc_int32 (*compare) ( 398 cc_ccache_t ccache, 399 cc_ccache_t compare_to, 400 cc_uint32* equal); 401}; 402 403struct cc_string_f { 404 cc_int32 (*release) ( 405 cc_string_t string); 406}; 407 408struct cc_credentials_f { 409 cc_int32 (*release) ( 410 cc_credentials_t credentials); 411 cc_int32 (*compare) ( 412 cc_credentials_t credentials, 413 cc_credentials_t compare_to, 414 cc_uint32* equal); 415}; 416 417 418struct cc_ccache_iterator_f { 419 cc_int32 (*release) ( 420 cc_ccache_iterator_t iter); 421 cc_int32 (*next) ( 422 cc_ccache_iterator_t iter, 423 cc_ccache_t* ccache); 424}; 425 426struct cc_credentials_iterator_f { 427 cc_int32 (*release) ( 428 cc_credentials_iterator_t iter); 429 cc_int32 (*next) ( 430 cc_credentials_iterator_t iter, 431 cc_credentials_t* ccache); 432}; 433 434/* 435 * API functions 436 */ 437 438cc_int32 cc_initialize ( 439 cc_context_t* outContext, 440 cc_int32 inVersion, 441 cc_int32* outSupportedVersion, 442 char const** outVendor); 443 444/* 445 * Convenience macros 446 */ 447 448#define cc_context_release(context) \ 449 ((context) -> functions -> release (context)) 450#define cc_context_get_change_time(context, time) \ 451 ((context) -> functions -> get_change_time (context, time)) 452#define cc_context_get_default_ccache_name(context, name) \ 453 ((context) -> functions -> get_default_ccache_name (context, name)) 454#define cc_context_open_ccache(context, name, ccache) \ 455 ((context) -> functions -> open_ccache (context, name, ccache)) 456#define cc_context_open_default_ccache(context, ccache) \ 457 ((context) -> functions -> open_default_ccache (context, ccache)) 458#define cc_context_create_ccache(context, name, version, principal, ccache) \ 459 ((context) -> functions -> create_ccache (context, name, version, principal, ccache)) 460#define cc_context_create_default_ccache(context, version, principal, ccache) \ 461 ((context) -> functions -> create_default_ccache (context, version, principal, ccache)) 462#define cc_context_create_new_ccache(context, version, principal, ccache) \ 463 ((context) -> functions -> create_new_ccache (context, version, principal, ccache)) 464#define cc_context_new_ccache_iterator(context, iterator) \ 465 ((context) -> functions -> new_ccache_iterator (context, iterator)) 466#define cc_context_lock(context, type, lock) \ 467 ((context) -> functions -> lock (context, type, lock)) 468#define cc_context_unlock(context) \ 469 ((context) -> functions -> unlock (context)) 470#define cc_context_compare(context, compare_to, equal) \ 471 ((context) -> functions -> compare (context, compare_to, equal)) 472 473#define cc_ccache_release(ccache) \ 474 ((ccache) -> functions -> release (ccache)) 475#define cc_ccache_destroy(ccache) \ 476 ((ccache) -> functions -> destroy (ccache)) 477#define cc_ccache_set_default(ccache) \ 478 ((ccache) -> functions -> set_default (ccache)) 479#define cc_ccache_get_credentials_version(ccache, version) \ 480 ((ccache) -> functions -> get_credentials_version (ccache, version)) 481#define cc_ccache_get_name(ccache, name) \ 482 ((ccache) -> functions -> get_name (ccache, name)) 483#define cc_ccache_get_principal(ccache, version, principal) \ 484 ((ccache) -> functions -> get_principal (ccache, version, principal)) 485#define cc_ccache_set_principal(ccache, version, principal) \ 486 ((ccache) -> functions -> set_principal (ccache, version, principal)) 487#define cc_ccache_store_credentials(ccache, credentials) \ 488 ((ccache) -> functions -> store_credentials (ccache, credentials)) 489#define cc_ccache_remove_credentials(ccache, credentials) \ 490 ((ccache) -> functions -> remove_credentials (ccache, credentials)) 491#define cc_ccache_new_credentials_iterator(ccache, iterator) \ 492 ((ccache) -> functions -> new_credentials_iterator (ccache, iterator)) 493#define cc_ccache_lock(ccache, lock) \ 494 ((ccache) -> functions -> lock (ccache, lock)) 495#define cc_ccache_unlock(ccache, unlock) \ 496 ((ccache) -> functions -> unlock (ccache, unlock)) 497#define cc_ccache_get_last_default_time(ccache, time) \ 498 ((ccache) -> functions -> get_last_default_time (ccache, time)) 499#define cc_ccache_get_change_time(ccache, time) \ 500 ((ccache) -> functions -> get_change_time (ccache, time)) 501#define cc_ccache_move(source, destination) \ 502 ((source) -> functions -> move (source, destination)) 503#define cc_ccache_compare(ccache, compare_to, equal) \ 504 ((ccache) -> functions -> compare (ccache, compare_to, equal)) 505 506#define cc_string_release(string) \ 507 ((string) -> functions -> release (string)) 508 509#define cc_credentials_release(credentials) \ 510 ((credentials) -> functions -> release (credentials)) 511#define cc_credentials_compare(credentials, compare_to, equal) \ 512 ((credentials) -> functions -> compare (credentials, compare_to, equal)) 513 514#define cc_ccache_iterator_release(iterator) \ 515 ((iterator) -> functions -> release (iterator)) 516#define cc_ccache_iterator_next(iterator, ccache) \ 517 ((iterator) -> functions -> next (iterator, ccache)) 518 519#define cc_credentials_iterator_release(iterator) \ 520 ((iterator) -> functions -> release (iterator)) 521#define cc_credentials_iterator_next(iterator, credentials) \ 522 ((iterator) -> functions -> next (iterator, credentials)) 523 524#if PRAGMA_STRUCT_ALIGN 525 #pragma options align=reset 526#elif PRAGMA_STRUCT_PACKPUSH 527 #pragma pack(pop) 528#elif PRAGMA_STRUCT_PACK 529 #pragma pack() 530#endif 531 532#if PRAGMA_ENUM_ALWAYSINT 533 #pragma enumsalwaysint reset 534#endif 535 536#if TARGET_CPU_68K 537 #pragma fourbyteints reset 538#endif 539 540#if PRAGMA_IMPORT 541# pragma import reset 542#endif 543 544#ifdef __cplusplus 545} 546#endif /* __cplusplus */ 547 548#endif /* __CREDENTIALSCACHE__ */ 549