1 /* $Copyright:
\r *
\r * Copyright 1998-2000 by the Massachusetts Institute of Technology.
\r *
\r * All rights reserved.
\r *
\r * Export of this software from the United States of America may require a
\r * specific license from the United States Government. It is the
\r * responsibility of any person or organization contemplating export to
\r * obtain such a license before exporting.
\r *
\r * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and distribute
\r * this software and its documentation for any purpose and without fee is
\r * hereby granted, provided that the above copyright notice appear in all
\r * copies and that both that copyright notice and this permission notice
\r * appear in supporting documentation, and that the name of M.I.T. not be
\r * used in advertising or publicity pertaining to distribution of the
\r * software without specific, written prior permission. Furthermore if you
\r * modify this software you must label your software as modified software
\r * and not distribute it in such a fashion that it might be confused with
\r * the original MIT software. M.I.T. makes no representations about the
\r * suitability of this software for any purpose. It is provided "as is"
\r * without express or implied warranty.
\r *
\r * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
\r * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
\r * MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
\r *
\r * Individual source code files are copyright MIT, Cygnus Support,
\r * OpenVision, Oracle, Sun Soft, FundsXpress, and others.
\r *
\r * Project Athena, Athena, Athena MUSE, Discuss, Hesiod, Kerberos, Moira,
\r * and Zephyr are trademarks of the Massachusetts Institute of Technology
\r * (MIT). No commercial use of these trademarks may be made without prior
\r * written permission of MIT.
\r *
\r * "Commercial use" means use of a name in a product or other for-profit
\r * manner. It does NOT prevent a commercial firm from referring to the MIT
\r * trademarks in order to convey information (although in doing so,
\r * recognition of their trademark status should be given).
\r * $
\r */
\r\r/* $Header: /afs/andrew/system/cvs/src/sasl/mac/CommonKClient/mac_kclient3/Headers/CredentialsCache/CredentialsCache.h,v 1.2 2001/12/04 02:05:36 rjs3 Exp $ */
\r\r/*
\r * Declarations for Credentials Cache API Library
\r *
\r * API specification: <http://web.mit.edu/pismere/kerberos/ccache-api-v2.html>
\r *
\r * Revision 1: Frank Dabek, 6/4/1998
\r * Revision 2: meeroh, 2/24/1999
\r * Revision 3: meeroh, 11/12/1999
\r *
\r */
\r \r#ifndef __CREDENTIALSCACHE__
\r#define __CREDENTIALSCACHE__
\r\r#ifdef __cplusplus
\rextern "C" {
\r#endif /* __cplusplus */
\r\r#include <KerberosSupport/KerberosConditionalMacros.h>
\r\r#if TARGET_API_MAC_OSX && TARGET_API_MAC_CARBON
\r #include <CoreServices/CoreServices.h>
\r#elif TARGET_API_MAC_OS8 || TARGET_API_MAC_CARBON
\r #include <MacTypes.h>
\r#else
\r #error "Unknown OS; no system types available"
\r#endif
\r\r#if PRAGMA_IMPORT
\r# pragma import on
\r#endif
\r\r/* This stuff is to make sure that we always use the same compiler options for
\r this header file. Otherwise we get really exciting failure modes -- meeroh */
\r#if PRAGMA_STRUCT_ALIGN
\r #pragma options align=mac68k4byte
\r#elif PRAGMA_STRUCT_PACKPUSH
\r #pragma pack(push, 4)
\r#elif PRAGMA_STRUCT_PACK
\r #pragma pack(4)
\r#endif
\r\r#if PRAGMA_ENUM_ALWAYSINT
\r #pragma enumsalwaysint on
\r#endif
\r\r#if TARGET_CPU_68K
\r #pragma fourbyteints on
\r#endif
\r\r/*
\r * Constants
\r */
\r \r/* API versions */
\renum {
\r ccapi_version_2 = 2,
\r ccapi_version_3 = 3,
\r ccapi_version_4 = 4
\r};
\r \r/* Errors */
\renum {
\r ccNoError = 0,
\r\r ccIteratorEnd = 201,
\r ccErrBadParam,
\r ccErrNoMem,
\r ccErrInvalidContext,
\r ccErrInvalidCCache,
\r\r ccErrInvalidString, /* 206 */
\r ccErrInvalidCredentials,
\r ccErrInvalidCCacheIterator,
\r ccErrInvalidCredentialsIterator,
\r ccErrInvalidLock,
\r\r ccErrBadName, /* 211 */
\r ccErrBadCredentialsVersion,
\r ccErrBadAPIVersion,
\r ccErrContextLocked,
\r ccErrContextUnlocked,
\r\r ccErrCCacheLocked, /* 216 */
\r ccErrCCacheUnlocked,
\r ccErrBadLockType,
\r ccErrNeverDefault,
\r ccErrCredentialsNotFound,
\r\r ccErrCCacheNotFound, /* 221 */
\r ccErrContextNotFound,
\r ccErrServerUnavailable
\r};
\r\r/* Credentials versions */
\renum {
\r cc_credentials_v4 = 1,
\r cc_credentials_v5 = 2,
\r cc_credentials_v4_v5 = 3
\r};
\r\r/*
\r * Basic types
\r */
\r \rtypedef UInt32 cc_uint32;
\rtypedef SInt32 cc_int32;
\rtypedef cc_uint32 cc_time_t;
\r\r/*
\r * API types
\r */
\r \r/* Forward declarations */
\rstruct cc_context_f;
\rtypedef struct cc_context_f cc_context_f;
\r\rstruct cc_ccache_f;
\rtypedef struct cc_ccache_f cc_ccache_f;
\r\rstruct cc_ccache_iterator_f;
\rtypedef struct cc_ccache_iterator_f cc_ccache_iterator_f;
\r\rstruct cc_ccache_iterator_f;
\rtypedef struct cc_credentials_iterator_f cc_credentials_iterator_f;
\r\rstruct cc_string_f;
\rtypedef struct cc_string_f cc_string_f;
\r\rstruct cc_credentials_f;
\rtypedef struct cc_credentials_f cc_credentials_f;
\r\r/* Credentials types */
\r\renum { /* Make sure all of these are multiples of four (for alignment sanity) */
\r cc_v4_name_size = 40,
\r cc_v4_instance_size = 40,
\r cc_v4_realm_size = 40,
\r cc_v4_ticket_size = 1254
\r};
\r\renum cc_string_to_key_type {
\r cc_v4_stk_afs = 0,
\r cc_v4_stk_des = 1,
\r cc_v4_stk_columbia_special = 2,
\r cc_v4_stk_unknown = 3
\r};
\r\rstruct cc_credentials_v4_t {
\r cc_uint32 version;
\r char principal [cc_v4_name_size];
\r char principal_instance [cc_v4_instance_size];
\r char service [cc_v4_name_size];
\r char service_instance [cc_v4_instance_size];
\r char realm [cc_v4_realm_size];
\r unsigned char session_key [8];
\r cc_int32 kvno;
\r cc_int32 string_to_key_type;
\r cc_time_t issue_date;
\r cc_int32 lifetime;
\r cc_uint32 address;
\r cc_int32 ticket_size;
\r unsigned char ticket [cc_v4_ticket_size];
\r};
\rtypedef struct cc_credentials_v4_t cc_credentials_v4_t;
\r\rstruct cc_data {
\r cc_uint32 type;
\r cc_uint32 length;
\r void* data;
\r};
\rtypedef struct cc_data cc_data;
\r\rstruct cc_credentials_v5_t {
\r char* client;
\r char* server;
\r cc_data keyblock;
\r cc_time_t authtime;
\r cc_time_t starttime;
\r cc_time_t endtime;
\r cc_time_t renew_till;
\r cc_uint32 is_skey;
\r cc_uint32 ticket_flags;
\r cc_data** addresses;
\r cc_data ticket;
\r cc_data second_ticket;
\r cc_data** authdata;
\r};
\rtypedef struct cc_credentials_v5_t cc_credentials_v5_t;
\r\rstruct cc_credentials_union {
\r cc_int32 version;
\r union {
\r cc_credentials_v4_t* credentials_v4;
\r cc_credentials_v5_t* credentials_v5;
\r } credentials;
\r};
\rtypedef struct cc_credentials_union cc_credentials_union;
\r\r/* Exposed parts */
\r\rstruct cc_context_d {
\r const cc_context_f* functions;
\r#if TARGET_OS_MAC
\r const cc_context_f* otherFunctions;
\r#endif
\r};
\rtypedef struct cc_context_d cc_context_d;
\rtypedef cc_context_d* cc_context_t;
\r\rstruct cc_ccache_d {
\r const cc_ccache_f* functions;
\r#if TARGET_OS_MAC
\r const cc_ccache_f* otherFunctions;
\r#endif
\r};
\rtypedef struct cc_ccache_d cc_ccache_d;
\rtypedef cc_ccache_d* cc_ccache_t;
\r\rstruct cc_ccache_iterator_d {
\r const cc_ccache_iterator_f* functions;
\r#if TARGET_OS_MAC
\r const cc_ccache_iterator_f* otherFunctions;
\r#endif
\r};
\rtypedef struct cc_ccache_iterator_d cc_ccache_iterator_d;
\rtypedef cc_ccache_iterator_d* cc_ccache_iterator_t;
\r\rstruct cc_credentials_iterator_d {
\r const cc_credentials_iterator_f* functions;
\r#if TARGET_OS_MAC
\r const cc_credentials_iterator_f* otherFunctions;
\r#endif
\r};
\rtypedef struct cc_credentials_iterator_d cc_credentials_iterator_d;
\rtypedef cc_credentials_iterator_d* cc_credentials_iterator_t;
\r\rstruct cc_string_d {
\r const char* data;
\r const cc_string_f* functions;
\r#if TARGET_OS_MAC
\r const cc_string_f* otherFunctions;
\r#endif
\r};
\rtypedef struct cc_string_d cc_string_d;
\rtypedef cc_string_d* cc_string_t;
\r\rstruct cc_credentials_d {
\r const cc_credentials_union* data;
\r const cc_credentials_f* functions;
\r#if TARGET_OS_MAC
\r const cc_credentials_f* otherFunctions;
\r#endif
\r};
\rtypedef struct cc_credentials_d cc_credentials_d;
\rtypedef cc_credentials_d* cc_credentials_t;
\r\r/* Function pointer structs */
\r\rstruct cc_context_f {
\r cc_int32 (*release) (
\r cc_context_t context);
\r cc_int32 (*get_change_time) (
\r cc_context_t context,
\r cc_time_t* time);
\r cc_int32 (*get_default_ccache_name) (
\r cc_context_t context,
\r cc_string_t* name);
\r cc_int32 (*open_ccache) (
\r cc_context_t context,
\r const char* name,
\r cc_ccache_t* ccache);
\r cc_int32 (*open_default_ccache) (
\r cc_context_t context,
\r cc_ccache_t* ccache);
\r cc_int32 (*create_ccache) (
\r cc_context_t context,
\r const char* name,
\r cc_uint32 cred_vers,
\r const char* principal,
\r cc_ccache_t* ccache);
\r cc_int32 (*create_default_ccache) (
\r cc_context_t context,
\r cc_uint32 cred_vers,
\r const char* principal,
\r cc_ccache_t* ccache);
\r cc_int32 (*create_new_ccache) (
\r cc_context_t context,
\r cc_uint32 cred_vers,
\r const char* principal,
\r cc_ccache_t* ccache);
\r cc_int32 (*new_ccache_iterator) (
\r cc_context_t context,
\r cc_ccache_iterator_t* iterator);
\r cc_int32 (*lock) (
\r cc_context_t context,
\r cc_uint32 lock_type,
\r cc_uint32 block);
\r cc_int32 (*unlock) (
\r cc_context_t context);
\r cc_int32 (*compare) (
\r cc_context_t context,
\r cc_context_t compare_to,
\r cc_uint32* equal);
\r};
\r\rstruct cc_ccache_f {
\r cc_int32 (*release) (
\r cc_ccache_t ccache);
\r cc_int32 (*destroy) (
\r cc_ccache_t ccache);
\r cc_int32 (*set_default) (
\r cc_ccache_t ccache);
\r cc_int32 (*get_credentials_version) (
\r cc_ccache_t ccache,
\r cc_uint32* credentials_version);
\r cc_int32 (*get_name) (
\r cc_ccache_t ccache,
\r cc_string_t* name);
\r cc_int32 (*get_principal) (
\r cc_ccache_t ccache,
\r cc_uint32 credentials_version,
\r cc_string_t* principal);
\r cc_int32 (*set_principal) (
\r cc_ccache_t ccache,
\r cc_uint32 credentials_version,
\r const char* principal);
\r cc_int32 (*store_credentials) (
\r cc_ccache_t ccache,
\r const cc_credentials_union* credentials);
\r cc_int32 (*remove_credentials) (
\r cc_ccache_t ccache,
\r cc_credentials_t credentials);
\r cc_int32 (*new_credentials_iterator) (
\r cc_ccache_t ccache,
\r cc_credentials_iterator_t* iterator);
\r cc_int32 (*move) (
\r cc_ccache_t source,
\r cc_ccache_t destination);
\r cc_int32 (*lock) (
\r cc_ccache_t ccache,
\r cc_uint32 block,
\r cc_uint32 lock_type);
\r cc_int32 (*unlock) (
\r cc_ccache_t ccache);
\r cc_int32 (*get_last_default_time) (
\r cc_ccache_t ccache,
\r cc_time_t* time);
\r cc_int32 (*get_change_time) (
\r cc_ccache_t ccache,
\r cc_time_t* time);
\r cc_int32 (*compare) (
\r cc_ccache_t ccache,
\r cc_ccache_t compare_to,
\r cc_uint32* equal);
\r};
\r\rstruct cc_string_f {
\r cc_int32 (*release) (
\r cc_string_t string);
\r};
\r\rstruct cc_credentials_f {
\r cc_int32 (*release) (
\r cc_credentials_t credentials);
\r cc_int32 (*compare) (
\r cc_credentials_t credentials,
\r cc_credentials_t compare_to,
\r cc_uint32* equal);
\r};
\r\r \rstruct cc_ccache_iterator_f {
\r cc_int32 (*release) (
\r cc_ccache_iterator_t iter);
\r cc_int32 (*next) (
\r cc_ccache_iterator_t iter,
\r cc_ccache_t* ccache);
\r};
\r\rstruct cc_credentials_iterator_f {
\r cc_int32 (*release) (
\r cc_credentials_iterator_t iter);
\r cc_int32 (*next) (
\r cc_credentials_iterator_t iter,
\r cc_credentials_t* ccache);
\r};
\r\r/*
\r * API functions
\r */
\r \rcc_int32 cc_initialize (
\r cc_context_t* outContext,
\r cc_int32 inVersion,
\r cc_int32* outSupportedVersion,
\r char const** outVendor);
\r \r/*
\r * Convenience macros
\r */
\r \r#define cc_context_release(context) \
\r ((context) -> functions -> release (context))
\r#define cc_context_get_change_time(context, time) \
\r ((context) -> functions -> get_change_time (context, time))
\r#define cc_context_get_default_ccache_name(context, name) \
\r ((context) -> functions -> get_default_ccache_name (context, name))
\r#define cc_context_open_ccache(context, name, ccache) \
\r ((context) -> functions -> open_ccache (context, name, ccache))
\r#define cc_context_open_default_ccache(context, ccache) \
\r ((context) -> functions -> open_default_ccache (context, ccache))
\r#define cc_context_create_ccache(context, name, version, principal, ccache) \
\r ((context) -> functions -> create_ccache (context, name, version, principal, ccache))
\r#define cc_context_create_default_ccache(context, version, principal, ccache) \
\r ((context) -> functions -> create_default_ccache (context, version, principal, ccache))
\r#define cc_context_create_new_ccache(context, version, principal, ccache) \
\r ((context) -> functions -> create_new_ccache (context, version, principal, ccache))
\r#define cc_context_new_ccache_iterator(context, iterator) \
\r ((context) -> functions -> new_ccache_iterator (context, iterator))
\r#define cc_context_lock(context, type, lock) \
\r ((context) -> functions -> lock (context, type, lock))
\r#define cc_context_unlock(context) \
\r ((context) -> functions -> unlock (context))
\r#define cc_context_compare(context, compare_to, equal) \
\r ((context) -> functions -> compare (context, compare_to, equal))
\r\r#define cc_ccache_release(ccache) \
\r ((ccache) -> functions -> release (ccache))
\r#define cc_ccache_destroy(ccache) \
\r ((ccache) -> functions -> destroy (ccache))
\r#define cc_ccache_set_default(ccache) \
\r ((ccache) -> functions -> set_default (ccache))
\r#define cc_ccache_get_credentials_version(ccache, version) \
\r ((ccache) -> functions -> get_credentials_version (ccache, version))
\r#define cc_ccache_get_name(ccache, name) \
\r ((ccache) -> functions -> get_name (ccache, name))
\r#define cc_ccache_get_principal(ccache, version, principal) \
\r ((ccache) -> functions -> get_principal (ccache, version, principal))
\r#define cc_ccache_set_principal(ccache, version, principal) \
\r ((ccache) -> functions -> set_principal (ccache, version, principal))
\r#define cc_ccache_store_credentials(ccache, credentials) \
\r ((ccache) -> functions -> store_credentials (ccache, credentials))
\r#define cc_ccache_remove_credentials(ccache, credentials) \
\r ((ccache) -> functions -> remove_credentials (ccache, credentials))
\r#define cc_ccache_new_credentials_iterator(ccache, iterator) \
\r ((ccache) -> functions -> new_credentials_iterator (ccache, iterator))
\r#define cc_ccache_lock(ccache, lock) \
\r ((ccache) -> functions -> lock (ccache, lock))
\r#define cc_ccache_unlock(ccache, unlock) \
\r ((ccache) -> functions -> unlock (ccache, unlock))
\r#define cc_ccache_get_last_default_time(ccache, time) \
\r ((ccache) -> functions -> get_last_default_time (ccache, time))
\r#define cc_ccache_get_change_time(ccache, time) \
\r ((ccache) -> functions -> get_change_time (ccache, time))
\r#define cc_ccache_move(source, destination) \
\r ((source) -> functions -> move (source, destination))
\r#define cc_ccache_compare(ccache, compare_to, equal) \
\r ((ccache) -> functions -> compare (ccache, compare_to, equal))
\r\r#define cc_string_release(string) \
\r ((string) -> functions -> release (string))
\r\r#define cc_credentials_release(credentials) \
\r ((credentials) -> functions -> release (credentials))
\r#define cc_credentials_compare(credentials, compare_to, equal) \
\r ((credentials) -> functions -> compare (credentials, compare_to, equal))
\r\r#define cc_ccache_iterator_release(iterator) \
\r ((iterator) -> functions -> release (iterator))
\r#define cc_ccache_iterator_next(iterator, ccache) \
\r ((iterator) -> functions -> next (iterator, ccache))
\r \r#define cc_credentials_iterator_release(iterator) \
\r ((iterator) -> functions -> release (iterator))
\r#define cc_credentials_iterator_next(iterator, credentials) \
\r ((iterator) -> functions -> next (iterator, credentials))
\r \r#if PRAGMA_STRUCT_ALIGN
\r #pragma options align=reset
\r#elif PRAGMA_STRUCT_PACKPUSH
\r #pragma pack(pop)
\r#elif PRAGMA_STRUCT_PACK
\r #pragma pack()
\r#endif
\r\r#if PRAGMA_ENUM_ALWAYSINT
\r #pragma enumsalwaysint reset
\r#endif
\r\r#if TARGET_CPU_68K
\r #pragma fourbyteints reset
\r#endif
\r\r#if PRAGMA_IMPORT
\r# pragma import reset
\r#endif
\r\r#ifdef __cplusplus
\r}
\r#endif /* __cplusplus */
\r\r#endif /* __CREDENTIALSCACHE__ */
\r