insert _FLAG into the name
[heimdal.git] / lib / krb5 / krb5.h
blobac7ac63a425d142e7b8d860ad94c91dbb23ef8c4
1 /*
2 * Copyright (c) 1997 - 2007 Kungliga Tekniska Högskolan
3 * (Royal Institute of Technology, Stockholm, Sweden).
4 * All rights reserved.
6 * Portions Copyright (c) 2009 Apple Inc. All rights reserved.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
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.
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.
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.
36 /* $Id$ */
38 #ifndef __KRB5_H__
39 #define __KRB5_H__
41 #include <time.h>
42 #include <krb5-types.h>
44 #include <asn1_err.h>
45 #include <krb5_err.h>
46 #include <heim_err.h>
47 #include <k524_err.h>
49 #include <krb5_asn1.h>
51 /* name confusion with MIT */
52 #ifndef KRB5KDC_ERR_KEY_EXP
53 #define KRB5KDC_ERR_KEY_EXP KRB5KDC_ERR_KEY_EXPIRED
54 #endif
56 #ifndef KRB5_DEPRECATED
57 #if defined(__GNUC__) && ((__GNUC__ > 3) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 1 )))
58 #define KRB5_DEPRECATED __attribute__((deprecated))
59 #elif defined(_MSC_VER) && (_MSC_VER>1200)
60 #define KRB5_DEPRECATED __declspec(deprecated)
61 #else
62 #define KRB5_DEPRECATED
63 #endif
64 #endif
66 /* simple constants */
68 #ifndef TRUE
69 #define TRUE 1
70 #define FALSE 0
71 #endif
73 typedef int krb5_boolean;
75 typedef int32_t krb5_error_code;
77 typedef int krb5_kvno;
79 typedef uint32_t krb5_flags;
81 typedef void *krb5_pointer;
82 typedef const void *krb5_const_pointer;
84 struct krb5_crypto_data;
85 typedef struct krb5_crypto_data *krb5_crypto;
87 struct krb5_get_creds_opt_data;
88 typedef struct krb5_get_creds_opt_data *krb5_get_creds_opt;
90 struct krb5_digest_data;
91 typedef struct krb5_digest_data *krb5_digest;
92 struct krb5_ntlm_data;
93 typedef struct krb5_ntlm_data *krb5_ntlm;
95 struct krb5_pac_data;
96 typedef struct krb5_pac_data *krb5_pac;
98 typedef struct krb5_rd_req_in_ctx_data *krb5_rd_req_in_ctx;
99 typedef struct krb5_rd_req_out_ctx_data *krb5_rd_req_out_ctx;
101 typedef CKSUMTYPE krb5_cksumtype;
103 typedef Checksum krb5_checksum;
105 typedef ENCTYPE krb5_enctype;
107 typedef struct krb5_get_init_creds_ctx *krb5_init_creds_context;
109 typedef heim_octet_string krb5_data;
111 /* PKINIT related forward declarations */
112 struct ContentInfo;
113 struct krb5_pk_identity;
114 struct krb5_pk_cert;
116 /* krb5_enc_data is a mit compat structure */
117 typedef struct krb5_enc_data {
118 krb5_enctype enctype;
119 krb5_kvno kvno;
120 krb5_data ciphertext;
121 } krb5_enc_data;
123 /* alternative names */
124 enum {
125 ENCTYPE_NULL = ETYPE_NULL,
126 ENCTYPE_DES_CBC_CRC = ETYPE_DES_CBC_CRC,
127 ENCTYPE_DES_CBC_MD4 = ETYPE_DES_CBC_MD4,
128 ENCTYPE_DES_CBC_MD5 = ETYPE_DES_CBC_MD5,
129 ENCTYPE_DES3_CBC_MD5 = ETYPE_DES3_CBC_MD5,
130 ENCTYPE_OLD_DES3_CBC_SHA1 = ETYPE_OLD_DES3_CBC_SHA1,
131 ENCTYPE_SIGN_DSA_GENERATE = ETYPE_SIGN_DSA_GENERATE,
132 ENCTYPE_ENCRYPT_RSA_PRIV = ETYPE_ENCRYPT_RSA_PRIV,
133 ENCTYPE_ENCRYPT_RSA_PUB = ETYPE_ENCRYPT_RSA_PUB,
134 ENCTYPE_DES3_CBC_SHA1 = ETYPE_DES3_CBC_SHA1,
135 ENCTYPE_AES128_CTS_HMAC_SHA1_96 = ETYPE_AES128_CTS_HMAC_SHA1_96,
136 ENCTYPE_AES256_CTS_HMAC_SHA1_96 = ETYPE_AES256_CTS_HMAC_SHA1_96,
137 ENCTYPE_ARCFOUR_HMAC = ETYPE_ARCFOUR_HMAC_MD5,
138 ENCTYPE_ARCFOUR_HMAC_MD5 = ETYPE_ARCFOUR_HMAC_MD5,
139 ENCTYPE_ARCFOUR_HMAC_MD5_56 = ETYPE_ARCFOUR_HMAC_MD5_56,
140 ENCTYPE_ENCTYPE_PK_CROSS = ETYPE_ENCTYPE_PK_CROSS,
141 ENCTYPE_DES_CBC_NONE = ETYPE_DES_CBC_NONE,
142 ENCTYPE_DES3_CBC_NONE = ETYPE_DES3_CBC_NONE,
143 ENCTYPE_DES_CFB64_NONE = ETYPE_DES_CFB64_NONE,
144 ENCTYPE_DES_PCBC_NONE = ETYPE_DES_PCBC_NONE
147 typedef PADATA_TYPE krb5_preauthtype;
149 typedef enum krb5_key_usage {
150 KRB5_KU_PA_ENC_TIMESTAMP = 1,
151 /* AS-REQ PA-ENC-TIMESTAMP padata timestamp, encrypted with the
152 client key (section 5.4.1) */
153 KRB5_KU_TICKET = 2,
154 /* AS-REP Ticket and TGS-REP Ticket (includes tgs session key or
155 application session key), encrypted with the service key
156 (section 5.4.2) */
157 KRB5_KU_AS_REP_ENC_PART = 3,
158 /* AS-REP encrypted part (includes tgs session key or application
159 session key), encrypted with the client key (section 5.4.2) */
160 KRB5_KU_TGS_REQ_AUTH_DAT_SESSION = 4,
161 /* TGS-REQ KDC-REQ-BODY AuthorizationData, encrypted with the tgs
162 session key (section 5.4.1) */
163 KRB5_KU_TGS_REQ_AUTH_DAT_SUBKEY = 5,
164 /* TGS-REQ KDC-REQ-BODY AuthorizationData, encrypted with the tgs
165 authenticator subkey (section 5.4.1) */
166 KRB5_KU_TGS_REQ_AUTH_CKSUM = 6,
167 /* TGS-REQ PA-TGS-REQ padata AP-REQ Authenticator cksum, keyed
168 with the tgs session key (sections 5.3.2, 5.4.1) */
169 KRB5_KU_TGS_REQ_AUTH = 7,
170 /* TGS-REQ PA-TGS-REQ padata AP-REQ Authenticator (includes tgs
171 authenticator subkey), encrypted with the tgs session key
172 (section 5.3.2) */
173 KRB5_KU_TGS_REP_ENC_PART_SESSION = 8,
174 /* TGS-REP encrypted part (includes application session key),
175 encrypted with the tgs session key (section 5.4.2) */
176 KRB5_KU_TGS_REP_ENC_PART_SUB_KEY = 9,
177 /* TGS-REP encrypted part (includes application session key),
178 encrypted with the tgs authenticator subkey (section 5.4.2) */
179 KRB5_KU_AP_REQ_AUTH_CKSUM = 10,
180 /* AP-REQ Authenticator cksum, keyed with the application session
181 key (section 5.3.2) */
182 KRB5_KU_AP_REQ_AUTH = 11,
183 /* AP-REQ Authenticator (includes application authenticator
184 subkey), encrypted with the application session key (section
185 5.3.2) */
186 KRB5_KU_AP_REQ_ENC_PART = 12,
187 /* AP-REP encrypted part (includes application session subkey),
188 encrypted with the application session key (section 5.5.2) */
189 KRB5_KU_KRB_PRIV = 13,
190 /* KRB-PRIV encrypted part, encrypted with a key chosen by the
191 application (section 5.7.1) */
192 KRB5_KU_KRB_CRED = 14,
193 /* KRB-CRED encrypted part, encrypted with a key chosen by the
194 application (section 5.8.1) */
195 KRB5_KU_KRB_SAFE_CKSUM = 15,
196 /* KRB-SAFE cksum, keyed with a key chosen by the application
197 (section 5.6.1) */
198 KRB5_KU_OTHER_ENCRYPTED = 16,
199 /* Data which is defined in some specification outside of
200 Kerberos to be encrypted using an RFC1510 encryption type. */
201 KRB5_KU_OTHER_CKSUM = 17,
202 /* Data which is defined in some specification outside of
203 Kerberos to be checksummed using an RFC1510 checksum type. */
204 KRB5_KU_KRB_ERROR = 18,
205 /* Krb-error checksum */
206 KRB5_KU_AD_KDC_ISSUED = 19,
207 /* AD-KDCIssued checksum */
208 KRB5_KU_MANDATORY_TICKET_EXTENSION = 20,
209 /* Checksum for Mandatory Ticket Extensions */
210 KRB5_KU_AUTH_DATA_TICKET_EXTENSION = 21,
211 /* Checksum in Authorization Data in Ticket Extensions */
212 KRB5_KU_USAGE_SEAL = 22,
213 /* seal in GSSAPI krb5 mechanism */
214 KRB5_KU_USAGE_SIGN = 23,
215 /* sign in GSSAPI krb5 mechanism */
216 KRB5_KU_USAGE_SEQ = 24,
217 /* SEQ in GSSAPI krb5 mechanism */
218 KRB5_KU_USAGE_ACCEPTOR_SEAL = 22,
219 /* acceptor sign in GSSAPI CFX krb5 mechanism */
220 KRB5_KU_USAGE_ACCEPTOR_SIGN = 23,
221 /* acceptor seal in GSSAPI CFX krb5 mechanism */
222 KRB5_KU_USAGE_INITIATOR_SEAL = 24,
223 /* initiator sign in GSSAPI CFX krb5 mechanism */
224 KRB5_KU_USAGE_INITIATOR_SIGN = 25,
225 /* initiator seal in GSSAPI CFX krb5 mechanism */
226 KRB5_KU_PA_SERVER_REFERRAL_DATA = 22,
227 /* encrypted server referral data */
228 KRB5_KU_SAM_CHECKSUM = 25,
229 /* Checksum for the SAM-CHECKSUM field */
230 KRB5_KU_SAM_ENC_TRACK_ID = 26,
231 /* Encryption of the SAM-TRACK-ID field */
232 KRB5_KU_PA_SERVER_REFERRAL = 26,
233 /* Keyusage for the server referral in a TGS req */
234 KRB5_KU_SAM_ENC_NONCE_SAD = 27,
235 /* Encryption of the SAM-NONCE-OR-SAD field */
236 KRB5_KU_PA_PKINIT_KX = 44,
237 /* Encryption type of the kdc session contribution in pk-init */
238 KRB5_KU_DIGEST_ENCRYPT = -18,
239 /* Encryption key usage used in the digest encryption field */
240 KRB5_KU_DIGEST_OPAQUE = -19,
241 /* Checksum key usage used in the digest opaque field */
242 KRB5_KU_KRB5SIGNEDPATH = -21,
243 /* Checksum key usage on KRB5SignedPath */
244 KRB5_KU_CANONICALIZED_NAMES = -23
245 /* Checksum key usage on PA-CANONICALIZED */
246 } krb5_key_usage;
248 typedef krb5_key_usage krb5_keyusage;
250 typedef enum krb5_salttype {
251 KRB5_PW_SALT = KRB5_PADATA_PW_SALT,
252 KRB5_AFS3_SALT = KRB5_PADATA_AFS3_SALT
253 }krb5_salttype;
255 typedef struct krb5_salt {
256 krb5_salttype salttype;
257 krb5_data saltvalue;
258 } krb5_salt;
260 typedef ETYPE_INFO krb5_preauthinfo;
262 typedef struct {
263 krb5_preauthtype type;
264 krb5_preauthinfo info; /* list of preauthinfo for this type */
265 } krb5_preauthdata_entry;
267 typedef struct krb5_preauthdata {
268 unsigned len;
269 krb5_preauthdata_entry *val;
270 }krb5_preauthdata;
272 typedef enum krb5_address_type {
273 KRB5_ADDRESS_INET = 2,
274 KRB5_ADDRESS_NETBIOS = 20,
275 KRB5_ADDRESS_INET6 = 24,
276 KRB5_ADDRESS_ADDRPORT = 256,
277 KRB5_ADDRESS_IPPORT = 257
278 } krb5_address_type;
280 enum {
281 AP_OPTS_USE_SESSION_KEY = 1,
282 AP_OPTS_MUTUAL_REQUIRED = 2,
283 AP_OPTS_USE_SUBKEY = 4 /* library internal */
286 typedef HostAddress krb5_address;
288 typedef HostAddresses krb5_addresses;
290 typedef enum krb5_keytype {
291 KEYTYPE_NULL = ETYPE_NULL,
292 KEYTYPE_DES = ETYPE_DES_CBC_CRC,
293 KEYTYPE_DES3 = ETYPE_OLD_DES3_CBC_SHA1,
294 KEYTYPE_AES128 = ETYPE_AES128_CTS_HMAC_SHA1_96,
295 KEYTYPE_AES256 = ETYPE_AES256_CTS_HMAC_SHA1_96,
296 KEYTYPE_ARCFOUR = ETYPE_ARCFOUR_HMAC_MD5,
297 KEYTYPE_ARCFOUR_56 = ETYPE_ARCFOUR_HMAC_MD5_56
298 } krb5_keytype;
300 typedef EncryptionKey krb5_keyblock;
302 typedef AP_REQ krb5_ap_req;
304 struct krb5_cc_ops;
306 #ifdef _WIN32
307 #define KRB5_USE_PATH_TOKENS 1
308 #endif
310 #ifdef KRB5_USE_PATH_TOKENS
311 #define KRB5_DEFAULT_CCFILE_ROOT "%{TEMP}/krb5cc_"
312 #else
313 #define KRB5_DEFAULT_CCFILE_ROOT "/tmp/krb5cc_"
314 #endif
316 #define KRB5_DEFAULT_CCROOT "FILE:" KRB5_DEFAULT_CCFILE_ROOT
318 #define KRB5_ACCEPT_NULL_ADDRESSES(C) \
319 krb5_config_get_bool_default((C), NULL, TRUE, \
320 "libdefaults", "accept_null_addresses", \
321 NULL)
323 typedef void *krb5_cc_cursor;
324 typedef struct krb5_cccol_cursor_data *krb5_cccol_cursor;
326 typedef struct krb5_ccache_data {
327 const struct krb5_cc_ops *ops;
328 krb5_data data;
329 }krb5_ccache_data;
331 typedef struct krb5_ccache_data *krb5_ccache;
333 typedef struct krb5_context_data *krb5_context;
335 typedef Realm krb5_realm;
336 typedef const char *krb5_const_realm; /* stupid language */
338 #define krb5_realm_length(r) strlen(r)
339 #define krb5_realm_data(r) (r)
341 typedef Principal krb5_principal_data;
342 typedef struct Principal *krb5_principal;
343 typedef const struct Principal *krb5_const_principal;
344 typedef struct Principals *krb5_principals;
346 typedef time_t krb5_deltat;
347 typedef time_t krb5_timestamp;
349 typedef struct krb5_times {
350 krb5_timestamp authtime;
351 krb5_timestamp starttime;
352 krb5_timestamp endtime;
353 krb5_timestamp renew_till;
354 } krb5_times;
356 typedef union {
357 TicketFlags b;
358 krb5_flags i;
359 } krb5_ticket_flags;
361 /* options for krb5_get_in_tkt() */
362 #define KDC_OPT_FORWARDABLE (1 << 1)
363 #define KDC_OPT_FORWARDED (1 << 2)
364 #define KDC_OPT_PROXIABLE (1 << 3)
365 #define KDC_OPT_PROXY (1 << 4)
366 #define KDC_OPT_ALLOW_POSTDATE (1 << 5)
367 #define KDC_OPT_POSTDATED (1 << 6)
368 #define KDC_OPT_RENEWABLE (1 << 8)
369 #define KDC_OPT_REQUEST_ANONYMOUS (1 << 14)
370 #define KDC_OPT_DISABLE_TRANSITED_CHECK (1 << 26)
371 #define KDC_OPT_RENEWABLE_OK (1 << 27)
372 #define KDC_OPT_ENC_TKT_IN_SKEY (1 << 28)
373 #define KDC_OPT_RENEW (1 << 30)
374 #define KDC_OPT_VALIDATE (1 << 31)
376 typedef union {
377 KDCOptions b;
378 krb5_flags i;
379 } krb5_kdc_flags;
381 /* flags for krb5_verify_ap_req */
383 #define KRB5_VERIFY_AP_REQ_IGNORE_INVALID (1 << 0)
385 #define KRB5_GC_CACHED (1U << 0)
386 #define KRB5_GC_USER_USER (1U << 1)
387 #define KRB5_GC_EXPIRED_OK (1U << 2)
388 #define KRB5_GC_NO_STORE (1U << 3)
389 #define KRB5_GC_FORWARDABLE (1U << 4)
390 #define KRB5_GC_NO_TRANSIT_CHECK (1U << 5)
391 #define KRB5_GC_CONSTRAINED_DELEGATION (1U << 6)
392 #define KRB5_GC_CANONICALIZE (1U << 7)
394 /* constants for compare_creds (and cc_retrieve_cred) */
395 #define KRB5_TC_DONT_MATCH_REALM (1U << 31)
396 #define KRB5_TC_MATCH_KEYTYPE (1U << 30)
397 #define KRB5_TC_MATCH_KTYPE KRB5_TC_MATCH_KEYTYPE /* MIT name */
398 #define KRB5_TC_MATCH_SRV_NAMEONLY (1 << 29)
399 #define KRB5_TC_MATCH_FLAGS_EXACT (1 << 28)
400 #define KRB5_TC_MATCH_FLAGS (1 << 27)
401 #define KRB5_TC_MATCH_TIMES_EXACT (1 << 26)
402 #define KRB5_TC_MATCH_TIMES (1 << 25)
403 #define KRB5_TC_MATCH_AUTHDATA (1 << 24)
404 #define KRB5_TC_MATCH_2ND_TKT (1 << 23)
405 #define KRB5_TC_MATCH_IS_SKEY (1 << 22)
407 typedef AuthorizationData krb5_authdata;
409 typedef KRB_ERROR krb5_error;
411 typedef struct krb5_creds {
412 krb5_principal client;
413 krb5_principal server;
414 krb5_keyblock session;
415 krb5_times times;
416 krb5_data ticket;
417 krb5_data second_ticket;
418 krb5_authdata authdata;
419 krb5_addresses addresses;
420 krb5_ticket_flags flags;
421 } krb5_creds;
423 typedef struct krb5_cc_cache_cursor_data *krb5_cc_cache_cursor;
425 #define KRB5_CC_OPS_VERSION 3
427 typedef struct krb5_cc_ops {
428 int version;
429 const char *prefix;
430 const char* (*get_name)(krb5_context, krb5_ccache);
431 krb5_error_code (*resolve)(krb5_context, krb5_ccache *, const char *);
432 krb5_error_code (*gen_new)(krb5_context, krb5_ccache *);
433 krb5_error_code (*init)(krb5_context, krb5_ccache, krb5_principal);
434 krb5_error_code (*destroy)(krb5_context, krb5_ccache);
435 krb5_error_code (*close)(krb5_context, krb5_ccache);
436 krb5_error_code (*store)(krb5_context, krb5_ccache, krb5_creds*);
437 krb5_error_code (*retrieve)(krb5_context, krb5_ccache,
438 krb5_flags, const krb5_creds*, krb5_creds *);
439 krb5_error_code (*get_princ)(krb5_context, krb5_ccache, krb5_principal*);
440 krb5_error_code (*get_first)(krb5_context, krb5_ccache, krb5_cc_cursor *);
441 krb5_error_code (*get_next)(krb5_context, krb5_ccache,
442 krb5_cc_cursor*, krb5_creds*);
443 krb5_error_code (*end_get)(krb5_context, krb5_ccache, krb5_cc_cursor*);
444 krb5_error_code (*remove_cred)(krb5_context, krb5_ccache,
445 krb5_flags, krb5_creds*);
446 krb5_error_code (*set_flags)(krb5_context, krb5_ccache, krb5_flags);
447 int (*get_version)(krb5_context, krb5_ccache);
448 krb5_error_code (*get_cache_first)(krb5_context, krb5_cc_cursor *);
449 krb5_error_code (*get_cache_next)(krb5_context, krb5_cc_cursor, krb5_ccache *);
450 krb5_error_code (*end_cache_get)(krb5_context, krb5_cc_cursor);
451 krb5_error_code (*move)(krb5_context, krb5_ccache, krb5_ccache);
452 krb5_error_code (*get_default_name)(krb5_context, char **);
453 krb5_error_code (*set_default)(krb5_context, krb5_ccache);
454 krb5_error_code (*lastchange)(krb5_context, krb5_ccache, krb5_timestamp *);
455 krb5_error_code (*set_kdc_offset)(krb5_context, krb5_ccache, krb5_deltat);
456 krb5_error_code (*get_kdc_offset)(krb5_context, krb5_ccache, krb5_deltat *);
457 } krb5_cc_ops;
459 struct krb5_log_facility;
461 struct krb5_config_binding {
462 enum { krb5_config_string, krb5_config_list } type;
463 char *name;
464 struct krb5_config_binding *next;
465 union {
466 char *string;
467 struct krb5_config_binding *list;
468 void *generic;
469 } u;
472 typedef struct krb5_config_binding krb5_config_binding;
474 typedef krb5_config_binding krb5_config_section;
476 typedef struct krb5_ticket {
477 EncTicketPart ticket;
478 krb5_principal client;
479 krb5_principal server;
480 } krb5_ticket;
482 typedef Authenticator krb5_authenticator_data;
484 typedef krb5_authenticator_data *krb5_authenticator;
486 struct krb5_rcache_data;
487 typedef struct krb5_rcache_data *krb5_rcache;
488 typedef Authenticator krb5_donot_replay;
490 #define KRB5_STORAGE_HOST_BYTEORDER 0x01 /* old */
491 #define KRB5_STORAGE_PRINCIPAL_WRONG_NUM_COMPONENTS 0x02
492 #define KRB5_STORAGE_PRINCIPAL_NO_NAME_TYPE 0x04
493 #define KRB5_STORAGE_KEYBLOCK_KEYTYPE_TWICE 0x08
494 #define KRB5_STORAGE_BYTEORDER_MASK 0x60
495 #define KRB5_STORAGE_BYTEORDER_BE 0x00 /* default */
496 #define KRB5_STORAGE_BYTEORDER_LE 0x20
497 #define KRB5_STORAGE_BYTEORDER_HOST 0x40
498 #define KRB5_STORAGE_CREDS_FLAGS_WRONG_BITORDER 0x80
500 struct krb5_storage_data;
501 typedef struct krb5_storage_data krb5_storage;
503 typedef struct krb5_keytab_entry {
504 krb5_principal principal;
505 krb5_kvno vno;
506 krb5_keyblock keyblock;
507 uint32_t timestamp;
508 uint32_t flags;
509 krb5_principals aliases;
510 } krb5_keytab_entry;
512 typedef struct krb5_kt_cursor {
513 int fd;
514 krb5_storage *sp;
515 void *data;
516 } krb5_kt_cursor;
518 struct krb5_keytab_data;
520 typedef struct krb5_keytab_data *krb5_keytab;
522 #define KRB5_KT_PREFIX_MAX_LEN 30
524 struct krb5_keytab_data {
525 const char *prefix;
526 krb5_error_code (*resolve)(krb5_context, const char*, krb5_keytab);
527 krb5_error_code (*get_name)(krb5_context, krb5_keytab, char*, size_t);
528 krb5_error_code (*close)(krb5_context, krb5_keytab);
529 krb5_error_code (*destroy)(krb5_context, krb5_keytab);
530 krb5_error_code (*get)(krb5_context, krb5_keytab, krb5_const_principal,
531 krb5_kvno, krb5_enctype, krb5_keytab_entry*);
532 krb5_error_code (*start_seq_get)(krb5_context, krb5_keytab, krb5_kt_cursor*);
533 krb5_error_code (*next_entry)(krb5_context, krb5_keytab,
534 krb5_keytab_entry*, krb5_kt_cursor*);
535 krb5_error_code (*end_seq_get)(krb5_context, krb5_keytab, krb5_kt_cursor*);
536 krb5_error_code (*add)(krb5_context, krb5_keytab, krb5_keytab_entry*);
537 krb5_error_code (*remove)(krb5_context, krb5_keytab, krb5_keytab_entry*);
538 void *data;
539 int32_t version;
542 typedef struct krb5_keytab_data krb5_kt_ops;
544 struct krb5_keytab_key_proc_args {
545 krb5_keytab keytab;
546 krb5_principal principal;
549 typedef struct krb5_keytab_key_proc_args krb5_keytab_key_proc_args;
551 typedef struct krb5_replay_data {
552 krb5_timestamp timestamp;
553 int32_t usec;
554 uint32_t seq;
555 } krb5_replay_data;
557 /* flags for krb5_auth_con_setflags */
558 enum {
559 KRB5_AUTH_CONTEXT_DO_TIME = 1,
560 KRB5_AUTH_CONTEXT_RET_TIME = 2,
561 KRB5_AUTH_CONTEXT_DO_SEQUENCE = 4,
562 KRB5_AUTH_CONTEXT_RET_SEQUENCE = 8,
563 KRB5_AUTH_CONTEXT_PERMIT_ALL = 16,
564 KRB5_AUTH_CONTEXT_USE_SUBKEY = 32,
565 KRB5_AUTH_CONTEXT_CLEAR_FORWARDED_CRED = 64
568 /* flags for krb5_auth_con_genaddrs */
569 enum {
570 KRB5_AUTH_CONTEXT_GENERATE_LOCAL_ADDR = 1,
571 KRB5_AUTH_CONTEXT_GENERATE_LOCAL_FULL_ADDR = 3,
572 KRB5_AUTH_CONTEXT_GENERATE_REMOTE_ADDR = 4,
573 KRB5_AUTH_CONTEXT_GENERATE_REMOTE_FULL_ADDR = 12
576 typedef struct krb5_auth_context_data {
577 unsigned int flags;
579 krb5_address *local_address;
580 krb5_address *remote_address;
581 int16_t local_port;
582 int16_t remote_port;
583 krb5_keyblock *keyblock;
584 krb5_keyblock *local_subkey;
585 krb5_keyblock *remote_subkey;
587 uint32_t local_seqnumber;
588 uint32_t remote_seqnumber;
590 krb5_authenticator authenticator;
592 krb5_pointer i_vector;
594 krb5_rcache rcache;
596 krb5_keytype keytype; /* ¿requested key type ? */
597 krb5_cksumtype cksumtype; /* ¡requested checksum type! */
599 }krb5_auth_context_data, *krb5_auth_context;
601 typedef struct {
602 KDC_REP kdc_rep;
603 EncKDCRepPart enc_part;
604 KRB_ERROR error;
605 } krb5_kdc_rep;
607 extern const char *heimdal_version, *heimdal_long_version;
609 typedef void (*krb5_log_log_func_t)(const char*, const char*, void*);
610 typedef void (*krb5_log_close_func_t)(void*);
612 typedef struct krb5_log_facility {
613 char *program;
614 int len;
615 struct facility *val;
616 } krb5_log_facility;
618 typedef EncAPRepPart krb5_ap_rep_enc_part;
620 #define KRB5_RECVAUTH_IGNORE_VERSION 1
622 #define KRB5_SENDAUTH_VERSION "KRB5_SENDAUTH_V1.0"
624 #define KRB5_TGS_NAME_SIZE (6)
625 #define KRB5_TGS_NAME ("krbtgt")
626 #define KRB5_WELLKNOWN_NAME ("WELLKNOWN")
627 #define KRB5_ANON_NAME ("ANONYMOUS")
628 #define KRB5_DIGEST_NAME ("digest")
630 typedef enum {
631 KRB5_PROMPT_TYPE_PASSWORD = 0x1,
632 KRB5_PROMPT_TYPE_NEW_PASSWORD = 0x2,
633 KRB5_PROMPT_TYPE_NEW_PASSWORD_AGAIN = 0x3,
634 KRB5_PROMPT_TYPE_PREAUTH = 0x4,
635 KRB5_PROMPT_TYPE_INFO = 0x5
636 } krb5_prompt_type;
638 typedef struct _krb5_prompt {
639 const char *prompt;
640 int hidden;
641 krb5_data *reply;
642 krb5_prompt_type type;
643 } krb5_prompt;
645 typedef int (*krb5_prompter_fct)(krb5_context /*context*/,
646 void * /*data*/,
647 const char * /*name*/,
648 const char * /*banner*/,
649 int /*num_prompts*/,
650 krb5_prompt /*prompts*/[]);
651 typedef krb5_error_code (*krb5_key_proc)(krb5_context /*context*/,
652 krb5_enctype /*type*/,
653 krb5_salt /*salt*/,
654 krb5_const_pointer /*keyseed*/,
655 krb5_keyblock ** /*key*/);
656 typedef krb5_error_code (*krb5_decrypt_proc)(krb5_context /*context*/,
657 krb5_keyblock * /*key*/,
658 krb5_key_usage /*usage*/,
659 krb5_const_pointer /*decrypt_arg*/,
660 krb5_kdc_rep * /*dec_rep*/);
661 typedef krb5_error_code (*krb5_s2k_proc)(krb5_context /*context*/,
662 krb5_enctype /*type*/,
663 krb5_const_pointer /*keyseed*/,
664 krb5_salt /*salt*/,
665 krb5_data * /*s2kparms*/,
666 krb5_keyblock ** /*key*/);
668 struct _krb5_get_init_creds_opt_private;
670 struct _krb5_get_init_creds_opt {
671 krb5_flags flags;
672 krb5_deltat tkt_life;
673 krb5_deltat renew_life;
674 int forwardable;
675 int proxiable;
676 int anonymous;
677 krb5_enctype *etype_list;
678 int etype_list_length;
679 krb5_addresses *address_list;
680 /* XXX the next three should not be used, as they may be
681 removed later */
682 krb5_preauthtype *preauth_list;
683 int preauth_list_length;
684 krb5_data *salt;
685 struct _krb5_get_init_creds_opt_private *opt_private;
688 typedef struct _krb5_get_init_creds_opt krb5_get_init_creds_opt;
690 #define KRB5_GET_INIT_CREDS_OPT_TKT_LIFE 0x0001
691 #define KRB5_GET_INIT_CREDS_OPT_RENEW_LIFE 0x0002
692 #define KRB5_GET_INIT_CREDS_OPT_FORWARDABLE 0x0004
693 #define KRB5_GET_INIT_CREDS_OPT_PROXIABLE 0x0008
694 #define KRB5_GET_INIT_CREDS_OPT_ETYPE_LIST 0x0010
695 #define KRB5_GET_INIT_CREDS_OPT_ADDRESS_LIST 0x0020
696 #define KRB5_GET_INIT_CREDS_OPT_PREAUTH_LIST 0x0040
697 #define KRB5_GET_INIT_CREDS_OPT_SALT 0x0080 /* no supported */
698 #define KRB5_GET_INIT_CREDS_OPT_ANONYMOUS 0x0100
699 #define KRB5_GET_INIT_CREDS_OPT_DISABLE_TRANSITED_CHECK 0x0200
701 /* krb5_init_creds_step flags argument */
702 #define KRB5_INIT_CREDS_STEP_FLAG_CONTINUE 0x0001
704 typedef struct _krb5_verify_init_creds_opt {
705 krb5_flags flags;
706 int ap_req_nofail;
707 } krb5_verify_init_creds_opt;
709 #define KRB5_VERIFY_INIT_CREDS_OPT_AP_REQ_NOFAIL 0x0001
711 typedef struct krb5_verify_opt {
712 unsigned int flags;
713 krb5_ccache ccache;
714 krb5_keytab keytab;
715 krb5_boolean secure;
716 const char *service;
717 } krb5_verify_opt;
719 #define KRB5_VERIFY_LREALMS 1
720 #define KRB5_VERIFY_NO_ADDRESSES 2
722 #define KRB5_KPASSWD_VERS_CHANGEPW 1
723 #define KRB5_KPASSWD_VERS_SETPW 0xff80
725 #define KRB5_KPASSWD_SUCCESS 0
726 #define KRB5_KPASSWD_MALFORMED 1
727 #define KRB5_KPASSWD_HARDERROR 2
728 #define KRB5_KPASSWD_AUTHERROR 3
729 #define KRB5_KPASSWD_SOFTERROR 4
730 #define KRB5_KPASSWD_ACCESSDENIED 5
731 #define KRB5_KPASSWD_BAD_VERSION 6
732 #define KRB5_KPASSWD_INITIAL_FLAG_NEEDED 7
734 #define KPASSWD_PORT 464
736 /* types for the new krbhst interface */
737 struct krb5_krbhst_data;
738 typedef struct krb5_krbhst_data *krb5_krbhst_handle;
740 #define KRB5_KRBHST_KDC 1
741 #define KRB5_KRBHST_ADMIN 2
742 #define KRB5_KRBHST_CHANGEPW 3
743 #define KRB5_KRBHST_KRB524 4
744 #define KRB5_KRBHST_KCA 5
746 typedef struct krb5_krbhst_info {
747 enum { KRB5_KRBHST_UDP,
748 KRB5_KRBHST_TCP,
749 KRB5_KRBHST_HTTP } proto;
750 unsigned short port;
751 unsigned short def_port;
752 struct addrinfo *ai;
753 struct krb5_krbhst_info *next;
754 char hostname[1]; /* has to come last */
755 } krb5_krbhst_info;
757 /* flags for krb5_krbhst_init_flags (and krb5_send_to_kdc_flags) */
758 enum {
759 KRB5_KRBHST_FLAGS_MASTER = 1,
760 KRB5_KRBHST_FLAGS_LARGE_MSG = 2
763 typedef krb5_error_code (*krb5_send_to_kdc_func)(krb5_context,
764 void *,
765 krb5_krbhst_info *,
766 time_t,
767 const krb5_data *,
768 krb5_data *);
770 /** flags for krb5_parse_name_flags */
771 enum {
772 KRB5_PRINCIPAL_PARSE_NO_REALM = 1, /**< Require that there are no realm */
773 KRB5_PRINCIPAL_PARSE_REQUIRE_REALM = 2, /**< Require a realm present */
774 KRB5_PRINCIPAL_PARSE_ENTERPRISE = 4 /**< Parse as a NT-ENTERPRISE name */
777 /** flags for krb5_unparse_name_flags */
778 enum {
779 KRB5_PRINCIPAL_UNPARSE_SHORT = 1, /**< No realm if it is the default realm */
780 KRB5_PRINCIPAL_UNPARSE_NO_REALM = 2, /**< No realm */
781 KRB5_PRINCIPAL_UNPARSE_DISPLAY = 4 /**< No quoting */
784 typedef struct krb5_sendto_ctx_data *krb5_sendto_ctx;
786 #define KRB5_SENDTO_DONE 0
787 #define KRB5_SENDTO_RESTART 1
788 #define KRB5_SENDTO_CONTINUE 2
790 typedef krb5_error_code (*krb5_sendto_ctx_func)(krb5_context, krb5_sendto_ctx, void *, const krb5_data *, int *);
792 struct krb5_plugin;
793 enum krb5_plugin_type {
794 PLUGIN_TYPE_DATA = 1,
795 PLUGIN_TYPE_FUNC
798 struct credentials; /* this is to keep the compiler happy */
799 struct getargs;
800 struct sockaddr;
803 * Semi private, not stable yet
806 typedef struct krb5_crypto_iov {
807 unsigned int flags;
808 /* ignored */
809 #define KRB5_CRYPTO_TYPE_EMPTY 0
810 /* OUT krb5_crypto_length(KRB5_CRYPTO_TYPE_HEADER) */
811 #define KRB5_CRYPTO_TYPE_HEADER 1
812 /* IN and OUT */
813 #define KRB5_CRYPTO_TYPE_DATA 2
814 /* IN */
815 #define KRB5_CRYPTO_TYPE_SIGN_ONLY 3
816 /* (only for encryption) OUT krb5_crypto_length(KRB5_CRYPTO_TYPE_TRAILER) */
817 #define KRB5_CRYPTO_TYPE_PADDING 4
818 /* OUT krb5_crypto_length(KRB5_CRYPTO_TYPE_TRAILER) */
819 #define KRB5_CRYPTO_TYPE_TRAILER 5
820 /* OUT krb5_crypto_length(KRB5_CRYPTO_TYPE_CHECKSUM) */
821 #define KRB5_CRYPTO_TYPE_CHECKSUM 6
822 krb5_data data;
823 } krb5_crypto_iov;
826 /* Glue for MIT */
828 typedef struct {
829 int32_t lr_type;
830 krb5_timestamp value;
831 } krb5_last_req_entry;
833 typedef krb5_error_code
834 (*krb5_gic_process_last_req)(krb5_context, krb5_last_req_entry **, void *);
840 #include <krb5-protos.h>
842 /* variables */
844 extern KRB5_LIB_VARIABLE const char *krb5_config_file;
845 extern KRB5_LIB_VARIABLE const char *krb5_defkeyname;
848 extern KRB5_LIB_VARIABLE const krb5_cc_ops krb5_acc_ops;
849 extern KRB5_LIB_VARIABLE const krb5_cc_ops krb5_fcc_ops;
850 extern KRB5_LIB_VARIABLE const krb5_cc_ops krb5_mcc_ops;
851 extern KRB5_LIB_VARIABLE const krb5_cc_ops krb5_kcm_ops;
852 extern KRB5_LIB_VARIABLE const krb5_cc_ops krb5_akcm_ops;
853 extern KRB5_LIB_VARIABLE const krb5_cc_ops krb5_scc_ops;
855 extern KRB5_LIB_VARIABLE const krb5_kt_ops krb5_fkt_ops;
856 extern KRB5_LIB_VARIABLE const krb5_kt_ops krb5_wrfkt_ops;
857 extern KRB5_LIB_VARIABLE const krb5_kt_ops krb5_javakt_ops;
858 extern KRB5_LIB_VARIABLE const krb5_kt_ops krb5_mkt_ops;
859 extern KRB5_LIB_VARIABLE const krb5_kt_ops krb5_akf_ops;
860 extern KRB5_LIB_VARIABLE const krb5_kt_ops krb4_fkt_ops;
861 extern KRB5_LIB_VARIABLE const krb5_kt_ops krb5_srvtab_fkt_ops;
862 extern KRB5_LIB_VARIABLE const krb5_kt_ops krb5_any_ops;
864 extern KRB5_LIB_VARIABLE const char *krb5_cc_type_api;
865 extern KRB5_LIB_VARIABLE const char *krb5_cc_type_file;
866 extern KRB5_LIB_VARIABLE const char *krb5_cc_type_memory;
867 extern KRB5_LIB_VARIABLE const char *krb5_cc_type_kcm;
868 extern KRB5_LIB_VARIABLE const char *krb5_cc_type_scc;
870 #endif /* __KRB5_H__ */