1 /* $NetBSD: krb5_ccapi.h,v 1.1.1.2 2011/04/14 14:09:23 elric Exp $ */ 2 3 /* 4 * Copyright (c) 2004 Kungliga Tekniska Högskolan 5 * (Royal Institute of Technology, Stockholm, Sweden). 6 * All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without 9 * modification, are permitted provided that the following conditions 10 * are met: 11 * 12 * 1. Redistributions of source code must retain the above copyright 13 * notice, this list of conditions and the following disclaimer. 14 * 15 * 2. Redistributions in binary form must reproduce the above copyright 16 * notice, this list of conditions and the following disclaimer in the 17 * documentation and/or other materials provided with the distribution. 18 * 19 * 3. Neither the name of the Institute nor the names of its contributors 20 * may be used to endorse or promote products derived from this software 21 * without specific prior written permission. 22 * 23 * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 24 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 25 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 26 * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 27 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 28 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 29 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 30 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 33 * SUCH DAMAGE. 34 */ 35 36 /* Id */ 37 38 #ifndef KRB5_CCAPI_H 39 #define KRB5_CCAPI_H 1 40 41 #include <krb5/krb5-types.h> 42 43 #ifdef __APPLE__ 44 #pragma pack(push,2) 45 #endif 46 47 enum { 48 cc_credentials_v5 = 2 49 }; 50 51 enum { 52 ccapi_version_3 = 3, 53 ccapi_version_4 = 4 54 }; 55 56 enum { 57 ccNoError = 0, 58 59 ccIteratorEnd = 201, 60 ccErrBadParam, 61 ccErrNoMem, 62 ccErrInvalidContext, 63 ccErrInvalidCCache, 64 65 ccErrInvalidString, /* 206 */ 66 ccErrInvalidCredentials, 67 ccErrInvalidCCacheIterator, 68 ccErrInvalidCredentialsIterator, 69 ccErrInvalidLock, 70 71 ccErrBadName, /* 211 */ 72 ccErrBadCredentialsVersion, 73 ccErrBadAPIVersion, 74 ccErrContextLocked, 75 ccErrContextUnlocked, 76 77 ccErrCCacheLocked, /* 216 */ 78 ccErrCCacheUnlocked, 79 ccErrBadLockType, 80 ccErrNeverDefault, 81 ccErrCredentialsNotFound, 82 83 ccErrCCacheNotFound, /* 221 */ 84 ccErrContextNotFound, 85 ccErrServerUnavailable, 86 ccErrServerInsecure, 87 ccErrServerCantBecomeUID, 88 89 ccErrTimeOffsetNotSet /* 226 */ 90 }; 91 92 typedef int32_t cc_int32; 93 typedef uint32_t cc_uint32; 94 typedef struct cc_context_t *cc_context_t; 95 typedef struct cc_ccache_t *cc_ccache_t; 96 typedef struct cc_ccache_iterator_t *cc_ccache_iterator_t; 97 typedef struct cc_credentials_v5_t cc_credentials_v5_t; 98 typedef struct cc_credentials_t *cc_credentials_t; 99 typedef struct cc_credentials_iterator_t *cc_credentials_iterator_t; 100 typedef struct cc_string_t *cc_string_t; 101 typedef cc_uint32 cc_time_t; 102 103 typedef struct cc_data { 104 cc_uint32 type; 105 cc_uint32 length; 106 void *data; 107 } cc_data; 108 109 struct cc_credentials_v5_t { 110 char *client; 111 char *server; 112 cc_data keyblock; 113 cc_time_t authtime; 114 cc_time_t starttime; 115 cc_time_t endtime; 116 cc_time_t renew_till; 117 cc_uint32 is_skey; 118 cc_uint32 ticket_flags; 119 #define KRB5_CCAPI_TKT_FLG_FORWARDABLE 0x40000000 120 #define KRB5_CCAPI_TKT_FLG_FORWARDED 0x20000000 121 #define KRB5_CCAPI_TKT_FLG_PROXIABLE 0x10000000 122 #define KRB5_CCAPI_TKT_FLG_PROXY 0x08000000 123 #define KRB5_CCAPI_TKT_FLG_MAY_POSTDATE 0x04000000 124 #define KRB5_CCAPI_TKT_FLG_POSTDATED 0x02000000 125 #define KRB5_CCAPI_TKT_FLG_INVALID 0x01000000 126 #define KRB5_CCAPI_TKT_FLG_RENEWABLE 0x00800000 127 #define KRB5_CCAPI_TKT_FLG_INITIAL 0x00400000 128 #define KRB5_CCAPI_TKT_FLG_PRE_AUTH 0x00200000 129 #define KRB5_CCAPI_TKT_FLG_HW_AUTH 0x00100000 130 #define KRB5_CCAPI_TKT_FLG_TRANSIT_POLICY_CHECKED 0x00080000 131 #define KRB5_CCAPI_TKT_FLG_OK_AS_DELEGATE 0x00040000 132 #define KRB5_CCAPI_TKT_FLG_ANONYMOUS 0x00020000 133 cc_data **addresses; 134 cc_data ticket; 135 cc_data second_ticket; 136 cc_data **authdata; 137 }; 138 139 140 typedef struct cc_string_functions { 141 cc_int32 (*release)(cc_string_t); 142 } cc_string_functions; 143 144 struct cc_string_t { 145 const char *data; 146 const cc_string_functions *func; 147 }; 148 149 typedef struct cc_credentials_union { 150 cc_int32 version; 151 union { 152 cc_credentials_v5_t* credentials_v5; 153 } credentials; 154 } cc_credentials_union; 155 156 struct cc_credentials_functions { 157 cc_int32 (*release)(cc_credentials_t); 158 cc_int32 (*compare)(cc_credentials_t, cc_credentials_t, cc_uint32*); 159 }; 160 161 struct cc_credentials_t { 162 const cc_credentials_union* data; 163 const struct cc_credentials_functions* func; 164 }; 165 166 struct cc_credentials_iterator_functions { 167 cc_int32 (*release)(cc_credentials_iterator_t); 168 cc_int32 (*next)(cc_credentials_iterator_t, cc_credentials_t*); 169 }; 170 171 struct cc_credentials_iterator_t { 172 const struct cc_credentials_iterator_functions *func; 173 }; 174 175 struct cc_ccache_iterator_functions { 176 cc_int32 (*release) (cc_ccache_iterator_t); 177 cc_int32 (*next)(cc_ccache_iterator_t, cc_ccache_t*); 178 }; 179 180 struct cc_ccache_iterator_t { 181 const struct cc_ccache_iterator_functions* func; 182 }; 183 184 typedef struct cc_ccache_functions { 185 cc_int32 (*release)(cc_ccache_t); 186 cc_int32 (*destroy)(cc_ccache_t); 187 cc_int32 (*set_default)(cc_ccache_t); 188 cc_int32 (*get_credentials_version)(cc_ccache_t, cc_uint32*); 189 cc_int32 (*get_name)(cc_ccache_t, cc_string_t*); 190 cc_int32 (*get_principal)(cc_ccache_t, cc_uint32, cc_string_t*); 191 cc_int32 (*set_principal)(cc_ccache_t, cc_uint32, const char*); 192 cc_int32 (*store_credentials)(cc_ccache_t, const cc_credentials_union*); 193 cc_int32 (*remove_credentials)(cc_ccache_t, cc_credentials_t); 194 cc_int32 (*new_credentials_iterator)(cc_ccache_t, 195 cc_credentials_iterator_t*); 196 cc_int32 (*move)(cc_ccache_t, cc_ccache_t); 197 cc_int32 (*lock)(cc_ccache_t, cc_uint32, cc_uint32); 198 cc_int32 (*unlock)(cc_ccache_t); 199 cc_int32 (*get_last_default_time)(cc_ccache_t, cc_time_t*); 200 cc_int32 (*get_change_time)(cc_ccache_t, cc_time_t*); 201 cc_int32 (*compare)(cc_ccache_t, cc_ccache_t, cc_uint32*); 202 cc_int32 (*get_kdc_time_offset)(cc_ccache_t, cc_int32, cc_time_t *); 203 cc_int32 (*set_kdc_time_offset)(cc_ccache_t, cc_int32, cc_time_t); 204 cc_int32 (*clear_kdc_time_offset)(cc_ccache_t, cc_int32); 205 } cc_ccache_functions; 206 207 struct cc_ccache_t { 208 const cc_ccache_functions *func; 209 }; 210 211 struct cc_context_functions { 212 cc_int32 (*release)(cc_context_t); 213 cc_int32 (*get_change_time)(cc_context_t, cc_time_t *); 214 cc_int32 (*get_default_ccache_name)(cc_context_t, cc_string_t*); 215 cc_int32 (*open_ccache)(cc_context_t, const char*, cc_ccache_t *); 216 cc_int32 (*open_default_ccache)(cc_context_t, cc_ccache_t*); 217 cc_int32 (*create_ccache)(cc_context_t,const char*, cc_uint32, 218 const char*, cc_ccache_t*); 219 cc_int32 (*create_default_ccache)(cc_context_t, cc_uint32, 220 const char*, cc_ccache_t*); 221 cc_int32 (*create_new_ccache)(cc_context_t, cc_uint32, 222 const char*, cc_ccache_t*); 223 cc_int32 (*new_ccache_iterator)(cc_context_t, cc_ccache_iterator_t*); 224 cc_int32 (*lock)(cc_context_t, cc_uint32, cc_uint32); 225 cc_int32 (*unlock)(cc_context_t); 226 cc_int32 (*compare)(cc_context_t, cc_context_t, cc_uint32*); 227 }; 228 229 struct cc_context_t { 230 const struct cc_context_functions* func; 231 }; 232 233 typedef cc_int32 234 (*cc_initialize_func)(cc_context_t*, cc_int32, cc_int32 *, char const **); 235 236 #ifdef __APPLE__ 237 #pragma pack(pop) 238 #endif 239 240 241 #endif /* KRB5_CCAPI_H */ 242