1 /*	$NetBSD: krb5.h,v 1.1.1.3 2014/04/24 12:45:50 pettai Exp $	*/
2 
3 /*
4  * Copyright (c) 1997 - 2007 Kungliga Tekniska Högskolan
5  * (Royal Institute of Technology, Stockholm, Sweden).
6  * All rights reserved.
7  *
8  * Portions Copyright (c) 2009 Apple Inc. All rights reserved.
9  *
10  * Redistribution and use in source and binary forms, with or without
11  * modification, are permitted provided that the following conditions
12  * are met:
13  *
14  * 1. Redistributions of source code must retain the above copyright
15  *    notice, this list of conditions and the following disclaimer.
16  *
17  * 2. Redistributions in binary form must reproduce the above copyright
18  *    notice, this list of conditions and the following disclaimer in the
19  *    documentation and/or other materials provided with the distribution.
20  *
21  * 3. Neither the name of the Institute nor the names of its contributors
22  *    may be used to endorse or promote products derived from this software
23  *    without specific prior written permission.
24  *
25  * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
26  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
28  * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
29  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
30  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
31  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
32  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
33  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
34  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
35  * SUCH DAMAGE.
36  */
37 
38 /* Id */
39 
40 #ifndef __KRB5_H__
41 #define __KRB5_H__
42 
43 #include <time.h>
44 #include <krb5/krb5-types.h>
45 
46 #include <krb5/asn1_err.h>
47 #include <krb5/krb5_err.h>
48 #include <krb5/heim_err.h>
49 #include <krb5/k524_err.h>
50 
51 #include <krb5/krb5_asn1.h>
52 
53 /* name confusion with MIT */
54 #ifndef KRB5KDC_ERR_KEY_EXP
55 #define KRB5KDC_ERR_KEY_EXP KRB5KDC_ERR_KEY_EXPIRED
56 #endif
57 
58 #ifdef _WIN32
59 #define KRB5_CALLCONV __stdcall
60 #else
61 #define KRB5_CALLCONV
62 #endif
63 
64 /* simple constants */
65 
66 #ifndef TRUE
67 #define TRUE  1
68 #define FALSE 0
69 #endif
70 
71 typedef int krb5_boolean;
72 
73 typedef int32_t krb5_error_code;
74 
75 typedef int32_t krb5_kvno;
76 
77 typedef uint32_t krb5_flags;
78 
79 typedef void *krb5_pointer;
80 typedef const void *krb5_const_pointer;
81 
82 struct krb5_crypto_data;
83 typedef struct krb5_crypto_data *krb5_crypto;
84 
85 struct krb5_get_creds_opt_data;
86 typedef struct krb5_get_creds_opt_data *krb5_get_creds_opt;
87 
88 struct krb5_digest_data;
89 typedef struct krb5_digest_data *krb5_digest;
90 struct krb5_ntlm_data;
91 typedef struct krb5_ntlm_data *krb5_ntlm;
92 
93 struct krb5_pac_data;
94 typedef struct krb5_pac_data *krb5_pac;
95 
96 typedef struct krb5_rd_req_in_ctx_data *krb5_rd_req_in_ctx;
97 typedef struct krb5_rd_req_out_ctx_data *krb5_rd_req_out_ctx;
98 
99 typedef CKSUMTYPE krb5_cksumtype;
100 
101 typedef Checksum krb5_checksum;
102 
103 typedef ENCTYPE krb5_enctype;
104 
105 typedef struct krb5_get_init_creds_ctx *krb5_init_creds_context;
106 
107 typedef heim_octet_string krb5_data;
108 
109 /* PKINIT related forward declarations */
110 struct ContentInfo;
111 struct krb5_pk_identity;
112 struct krb5_pk_cert;
113 
114 /* krb5_enc_data is a mit compat structure */
115 typedef struct krb5_enc_data {
116     krb5_enctype enctype;
117     krb5_kvno kvno;
118     krb5_data ciphertext;
119 } krb5_enc_data;
120 
121 /* alternative names */
122 enum {
123     ENCTYPE_NULL		= KRB5_ENCTYPE_NULL,
124     ENCTYPE_DES_CBC_CRC		= KRB5_ENCTYPE_DES_CBC_CRC,
125     ENCTYPE_DES_CBC_MD4		= KRB5_ENCTYPE_DES_CBC_MD4,
126     ENCTYPE_DES_CBC_MD5		= KRB5_ENCTYPE_DES_CBC_MD5,
127     ENCTYPE_DES3_CBC_MD5	= KRB5_ENCTYPE_DES3_CBC_MD5,
128     ENCTYPE_OLD_DES3_CBC_SHA1	= KRB5_ENCTYPE_OLD_DES3_CBC_SHA1,
129     ENCTYPE_SIGN_DSA_GENERATE	= KRB5_ENCTYPE_SIGN_DSA_GENERATE,
130     ENCTYPE_ENCRYPT_RSA_PRIV	= KRB5_ENCTYPE_ENCRYPT_RSA_PRIV,
131     ENCTYPE_ENCRYPT_RSA_PUB	= KRB5_ENCTYPE_ENCRYPT_RSA_PUB,
132     ENCTYPE_DES3_CBC_SHA1	= KRB5_ENCTYPE_DES3_CBC_SHA1,
133     ENCTYPE_AES128_CTS_HMAC_SHA1_96 = KRB5_ENCTYPE_AES128_CTS_HMAC_SHA1_96,
134     ENCTYPE_AES256_CTS_HMAC_SHA1_96 = KRB5_ENCTYPE_AES256_CTS_HMAC_SHA1_96,
135     ENCTYPE_ARCFOUR_HMAC	= KRB5_ENCTYPE_ARCFOUR_HMAC_MD5,
136     ENCTYPE_ARCFOUR_HMAC_MD5	= KRB5_ENCTYPE_ARCFOUR_HMAC_MD5,
137     ENCTYPE_ARCFOUR_HMAC_MD5_56	= KRB5_ENCTYPE_ARCFOUR_HMAC_MD5_56,
138     ENCTYPE_ENCTYPE_PK_CROSS	= KRB5_ENCTYPE_ENCTYPE_PK_CROSS,
139     ENCTYPE_DES_CBC_NONE	= KRB5_ENCTYPE_DES_CBC_NONE,
140     ENCTYPE_DES3_CBC_NONE	= KRB5_ENCTYPE_DES3_CBC_NONE,
141     ENCTYPE_DES_CFB64_NONE	= KRB5_ENCTYPE_DES_CFB64_NONE,
142     ENCTYPE_DES_PCBC_NONE	= KRB5_ENCTYPE_DES_PCBC_NONE,
143     ETYPE_NULL			= KRB5_ENCTYPE_NULL,
144     ETYPE_DES_CBC_CRC		= KRB5_ENCTYPE_DES_CBC_CRC,
145     ETYPE_DES_CBC_MD4		= KRB5_ENCTYPE_DES_CBC_MD4,
146     ETYPE_DES_CBC_MD5		= KRB5_ENCTYPE_DES_CBC_MD5,
147     ETYPE_DES3_CBC_MD5		= KRB5_ENCTYPE_DES3_CBC_MD5,
148     ETYPE_OLD_DES3_CBC_SHA1	= KRB5_ENCTYPE_OLD_DES3_CBC_SHA1,
149     ETYPE_SIGN_DSA_GENERATE	= KRB5_ENCTYPE_SIGN_DSA_GENERATE,
150     ETYPE_ENCRYPT_RSA_PRIV	= KRB5_ENCTYPE_ENCRYPT_RSA_PRIV,
151     ETYPE_ENCRYPT_RSA_PUB	= KRB5_ENCTYPE_ENCRYPT_RSA_PUB,
152     ETYPE_DES3_CBC_SHA1		= KRB5_ENCTYPE_DES3_CBC_SHA1,
153     ETYPE_AES128_CTS_HMAC_SHA1_96	= KRB5_ENCTYPE_AES128_CTS_HMAC_SHA1_96,
154     ETYPE_AES256_CTS_HMAC_SHA1_96	= KRB5_ENCTYPE_AES256_CTS_HMAC_SHA1_96,
155     ETYPE_ARCFOUR_HMAC_MD5	= KRB5_ENCTYPE_ARCFOUR_HMAC_MD5,
156     ETYPE_ARCFOUR_HMAC_MD5_56	= KRB5_ENCTYPE_ARCFOUR_HMAC_MD5_56,
157     ETYPE_ENCTYPE_PK_CROSS	= KRB5_ENCTYPE_ENCTYPE_PK_CROSS,
158     ETYPE_ARCFOUR_MD4		= KRB5_ENCTYPE_ARCFOUR_MD4,
159     ETYPE_ARCFOUR_HMAC_OLD	= KRB5_ENCTYPE_ARCFOUR_HMAC_OLD,
160     ETYPE_ARCFOUR_HMAC_OLD_EXP	= KRB5_ENCTYPE_ARCFOUR_HMAC_OLD_EXP,
161     ETYPE_DES_CBC_NONE		= KRB5_ENCTYPE_DES_CBC_NONE,
162     ETYPE_DES3_CBC_NONE		= KRB5_ENCTYPE_DES3_CBC_NONE,
163     ETYPE_DES_CFB64_NONE	= KRB5_ENCTYPE_DES_CFB64_NONE,
164     ETYPE_DES_PCBC_NONE		= KRB5_ENCTYPE_DES_PCBC_NONE,
165     ETYPE_DIGEST_MD5_NONE	= KRB5_ENCTYPE_DIGEST_MD5_NONE,
166     ETYPE_CRAM_MD5_NONE		= KRB5_ENCTYPE_CRAM_MD5_NONE
167 
168 };
169 
170 /* PDU types */
171 typedef enum krb5_pdu {
172     KRB5_PDU_ERROR = 0,
173     KRB5_PDU_TICKET = 1,
174     KRB5_PDU_AS_REQUEST = 2,
175     KRB5_PDU_AS_REPLY = 3,
176     KRB5_PDU_TGS_REQUEST = 4,
177     KRB5_PDU_TGS_REPLY = 5,
178     KRB5_PDU_AP_REQUEST = 6,
179     KRB5_PDU_AP_REPLY = 7,
180     KRB5_PDU_KRB_SAFE = 8,
181     KRB5_PDU_KRB_PRIV = 9,
182     KRB5_PDU_KRB_CRED = 10,
183     KRB5_PDU_NONE = 11 /* See krb5_get_permitted_enctypes() */
184 } krb5_pdu;
185 
186 typedef PADATA_TYPE krb5_preauthtype;
187 
188 typedef enum krb5_key_usage {
189     KRB5_KU_PA_ENC_TIMESTAMP = 1,
190     /* AS-REQ PA-ENC-TIMESTAMP padata timestamp, encrypted with the
191        client key (section 5.4.1) */
192     KRB5_KU_TICKET = 2,
193     /* AS-REP Ticket and TGS-REP Ticket (includes tgs session key or
194        application session key), encrypted with the service key
195        (section 5.4.2) */
196     KRB5_KU_AS_REP_ENC_PART = 3,
197     /* AS-REP encrypted part (includes tgs session key or application
198        session key), encrypted with the client key (section 5.4.2) */
199     KRB5_KU_TGS_REQ_AUTH_DAT_SESSION = 4,
200     /* TGS-REQ KDC-REQ-BODY AuthorizationData, encrypted with the tgs
201        session key (section 5.4.1) */
202     KRB5_KU_TGS_REQ_AUTH_DAT_SUBKEY = 5,
203     /* TGS-REQ KDC-REQ-BODY AuthorizationData, encrypted with the tgs
204           authenticator subkey (section 5.4.1) */
205     KRB5_KU_TGS_REQ_AUTH_CKSUM = 6,
206     /* TGS-REQ PA-TGS-REQ padata AP-REQ Authenticator cksum, keyed
207        with the tgs session key (sections 5.3.2, 5.4.1) */
208     KRB5_KU_TGS_REQ_AUTH = 7,
209     /* TGS-REQ PA-TGS-REQ padata AP-REQ Authenticator (includes tgs
210        authenticator subkey), encrypted with the tgs session key
211        (section 5.3.2) */
212     KRB5_KU_TGS_REP_ENC_PART_SESSION = 8,
213     /* TGS-REP encrypted part (includes application session key),
214        encrypted with the tgs session key (section 5.4.2) */
215     KRB5_KU_TGS_REP_ENC_PART_SUB_KEY = 9,
216     /* TGS-REP encrypted part (includes application session key),
217        encrypted with the tgs authenticator subkey (section 5.4.2) */
218     KRB5_KU_AP_REQ_AUTH_CKSUM = 10,
219     /* AP-REQ Authenticator cksum, keyed with the application session
220        key (section 5.3.2) */
221     KRB5_KU_AP_REQ_AUTH = 11,
222     /* AP-REQ Authenticator (includes application authenticator
223        subkey), encrypted with the application session key (section
224        5.3.2) */
225     KRB5_KU_AP_REQ_ENC_PART = 12,
226     /* AP-REP encrypted part (includes application session subkey),
227        encrypted with the application session key (section 5.5.2) */
228     KRB5_KU_KRB_PRIV = 13,
229     /* KRB-PRIV encrypted part, encrypted with a key chosen by the
230        application (section 5.7.1) */
231     KRB5_KU_KRB_CRED = 14,
232     /* KRB-CRED encrypted part, encrypted with a key chosen by the
233        application (section 5.8.1) */
234     KRB5_KU_KRB_SAFE_CKSUM = 15,
235     /* KRB-SAFE cksum, keyed with a key chosen by the application
236        (section 5.6.1) */
237     KRB5_KU_OTHER_ENCRYPTED = 16,
238     /* Data which is defined in some specification outside of
239        Kerberos to be encrypted using an RFC1510 encryption type. */
240     KRB5_KU_OTHER_CKSUM = 17,
241     /* Data which is defined in some specification outside of
242        Kerberos to be checksummed using an RFC1510 checksum type. */
243     KRB5_KU_KRB_ERROR = 18,
244     /* Krb-error checksum */
245     KRB5_KU_AD_KDC_ISSUED = 19,
246     /* AD-KDCIssued checksum */
247     KRB5_KU_MANDATORY_TICKET_EXTENSION = 20,
248     /* Checksum for Mandatory Ticket Extensions */
249     KRB5_KU_AUTH_DATA_TICKET_EXTENSION = 21,
250     /* Checksum in Authorization Data in Ticket Extensions */
251     KRB5_KU_USAGE_SEAL = 22,
252     /* seal in GSSAPI krb5 mechanism */
253     KRB5_KU_USAGE_SIGN = 23,
254     /* sign in GSSAPI krb5 mechanism */
255     KRB5_KU_USAGE_SEQ = 24,
256     /* SEQ in GSSAPI krb5 mechanism */
257     KRB5_KU_USAGE_ACCEPTOR_SEAL = 22,
258     /* acceptor sign in GSSAPI CFX krb5 mechanism */
259     KRB5_KU_USAGE_ACCEPTOR_SIGN = 23,
260     /* acceptor seal in GSSAPI CFX krb5 mechanism */
261     KRB5_KU_USAGE_INITIATOR_SEAL = 24,
262     /* initiator sign in GSSAPI CFX krb5 mechanism */
263     KRB5_KU_USAGE_INITIATOR_SIGN = 25,
264     /* initiator seal in GSSAPI CFX krb5 mechanism */
265     KRB5_KU_PA_SERVER_REFERRAL_DATA = 22,
266     /* encrypted server referral data */
267     KRB5_KU_SAM_CHECKSUM = 25,
268     /* Checksum for the SAM-CHECKSUM field */
269     KRB5_KU_SAM_ENC_TRACK_ID = 26,
270     /* Encryption of the SAM-TRACK-ID field */
271     KRB5_KU_PA_SERVER_REFERRAL = 26,
272     /* Keyusage for the server referral in a TGS req */
273     KRB5_KU_SAM_ENC_NONCE_SAD = 27,
274     /* Encryption of the SAM-NONCE-OR-SAD field */
275     KRB5_KU_PA_PKINIT_KX = 44,
276     /* Encryption type of the kdc session contribution in pk-init */
277     KRB5_KU_AS_REQ = 56,
278     /* Checksum of over the AS-REQ send by the KDC in PA-REQ-ENC-PA-REP */
279     KRB5_KU_DIGEST_ENCRYPT = -18,
280     /* Encryption key usage used in the digest encryption field */
281     KRB5_KU_DIGEST_OPAQUE = -19,
282     /* Checksum key usage used in the digest opaque field */
283     KRB5_KU_KRB5SIGNEDPATH = -21,
284     /* Checksum key usage on KRB5SignedPath */
285     KRB5_KU_CANONICALIZED_NAMES = -23
286     /* Checksum key usage on PA-CANONICALIZED */
287 } krb5_key_usage;
288 
289 typedef krb5_key_usage krb5_keyusage;
290 
291 typedef enum krb5_salttype {
292     KRB5_PW_SALT = KRB5_PADATA_PW_SALT,
293     KRB5_AFS3_SALT = KRB5_PADATA_AFS3_SALT
294 }krb5_salttype;
295 
296 typedef struct krb5_salt {
297     krb5_salttype salttype;
298     krb5_data saltvalue;
299 } krb5_salt;
300 
301 typedef ETYPE_INFO krb5_preauthinfo;
302 
303 typedef struct {
304     krb5_preauthtype type;
305     krb5_preauthinfo info; /* list of preauthinfo for this type */
306 } krb5_preauthdata_entry;
307 
308 typedef struct krb5_preauthdata {
309     unsigned len;
310     krb5_preauthdata_entry *val;
311 }krb5_preauthdata;
312 
313 typedef enum krb5_address_type {
314     KRB5_ADDRESS_INET     =   2,
315     KRB5_ADDRESS_NETBIOS  =  20,
316     KRB5_ADDRESS_INET6    =  24,
317     KRB5_ADDRESS_ADDRPORT = 256,
318     KRB5_ADDRESS_IPPORT   = 257
319 } krb5_address_type;
320 
321 enum {
322   AP_OPTS_USE_SESSION_KEY = 1,
323   AP_OPTS_MUTUAL_REQUIRED = 2,
324   AP_OPTS_USE_SUBKEY = 4		/* library internal */
325 };
326 
327 typedef HostAddress krb5_address;
328 
329 typedef HostAddresses krb5_addresses;
330 
331 typedef krb5_enctype krb5_keytype;
332 
333 enum krb5_keytype_old {
334     KEYTYPE_NULL	= ETYPE_NULL,
335     KEYTYPE_DES		= ETYPE_DES_CBC_CRC,
336     KEYTYPE_DES3	= ETYPE_OLD_DES3_CBC_SHA1,
337     KEYTYPE_AES128	= ETYPE_AES128_CTS_HMAC_SHA1_96,
338     KEYTYPE_AES256	= ETYPE_AES256_CTS_HMAC_SHA1_96,
339     KEYTYPE_ARCFOUR	= ETYPE_ARCFOUR_HMAC_MD5,
340     KEYTYPE_ARCFOUR_56	= ETYPE_ARCFOUR_HMAC_MD5_56
341 };
342 
343 typedef EncryptionKey krb5_keyblock;
344 
345 typedef AP_REQ krb5_ap_req;
346 
347 struct krb5_cc_ops;
348 
349 #ifdef _WIN32
350 #define KRB5_USE_PATH_TOKENS 1
351 #endif
352 
353 #ifdef KRB5_USE_PATH_TOKENS
354 #define KRB5_DEFAULT_CCFILE_ROOT "%{TEMP}/krb5cc_"
355 #else
356 #define KRB5_DEFAULT_CCFILE_ROOT "/tmp/krb5cc_"
357 #endif
358 
359 #define KRB5_DEFAULT_CCROOT "FILE:" KRB5_DEFAULT_CCFILE_ROOT
360 
361 #define KRB5_ACCEPT_NULL_ADDRESSES(C) 					 \
362     krb5_config_get_bool_default((C), NULL, TRUE, 			 \
363 				 "libdefaults", "accept_null_addresses", \
364 				 NULL)
365 
366 typedef void *krb5_cc_cursor;
367 typedef struct krb5_cccol_cursor_data *krb5_cccol_cursor;
368 
369 typedef struct krb5_ccache_data {
370     const struct krb5_cc_ops *ops;
371     krb5_data data;
372 }krb5_ccache_data;
373 
374 typedef struct krb5_ccache_data *krb5_ccache;
375 
376 typedef struct krb5_context_data *krb5_context;
377 
378 typedef Realm krb5_realm;
379 typedef const char *krb5_const_realm; /* stupid language */
380 
381 #define krb5_realm_length(r) strlen(r)
382 #define krb5_realm_data(r) (r)
383 
384 typedef Principal krb5_principal_data;
385 typedef struct Principal *krb5_principal;
386 typedef const struct Principal *krb5_const_principal;
387 typedef struct Principals *krb5_principals;
388 
389 typedef time_t krb5_deltat;
390 typedef time_t krb5_timestamp;
391 
392 typedef struct krb5_times {
393   krb5_timestamp authtime;
394   krb5_timestamp starttime;
395   krb5_timestamp endtime;
396   krb5_timestamp renew_till;
397 } krb5_times;
398 
399 typedef union {
400     TicketFlags b;
401     krb5_flags i;
402 } krb5_ticket_flags;
403 
404 /* options for krb5_get_in_tkt() */
405 #define KDC_OPT_FORWARDABLE		(1 << 1)
406 #define KDC_OPT_FORWARDED		(1 << 2)
407 #define KDC_OPT_PROXIABLE		(1 << 3)
408 #define KDC_OPT_PROXY			(1 << 4)
409 #define KDC_OPT_ALLOW_POSTDATE		(1 << 5)
410 #define KDC_OPT_POSTDATED		(1 << 6)
411 #define KDC_OPT_RENEWABLE		(1 << 8)
412 #define KDC_OPT_REQUEST_ANONYMOUS	(1 << 14)
413 #define KDC_OPT_DISABLE_TRANSITED_CHECK	(1 << 26)
414 #define KDC_OPT_RENEWABLE_OK		(1 << 27)
415 #define KDC_OPT_ENC_TKT_IN_SKEY		(1 << 28)
416 #define KDC_OPT_RENEW			(1 << 30)
417 #define KDC_OPT_VALIDATE		(1 << 31)
418 
419 typedef union {
420     KDCOptions b;
421     krb5_flags i;
422 } krb5_kdc_flags;
423 
424 /* flags for krb5_verify_ap_req */
425 
426 #define KRB5_VERIFY_AP_REQ_IGNORE_INVALID	(1 << 0)
427 
428 #define KRB5_GC_CACHED			(1U << 0)
429 #define KRB5_GC_USER_USER		(1U << 1)
430 #define KRB5_GC_EXPIRED_OK		(1U << 2)
431 #define KRB5_GC_NO_STORE		(1U << 3)
432 #define KRB5_GC_FORWARDABLE		(1U << 4)
433 #define KRB5_GC_NO_TRANSIT_CHECK	(1U << 5)
434 #define KRB5_GC_CONSTRAINED_DELEGATION	(1U << 6)
435 #define KRB5_GC_CANONICALIZE		(1U << 7)
436 
437 /* constants for compare_creds (and cc_retrieve_cred) */
438 #define KRB5_TC_DONT_MATCH_REALM	(1U << 31)
439 #define KRB5_TC_MATCH_KEYTYPE		(1U << 30)
440 #define KRB5_TC_MATCH_KTYPE		KRB5_TC_MATCH_KEYTYPE    /* MIT name */
441 #define KRB5_TC_MATCH_SRV_NAMEONLY	(1 << 29)
442 #define KRB5_TC_MATCH_FLAGS_EXACT	(1 << 28)
443 #define KRB5_TC_MATCH_FLAGS		(1 << 27)
444 #define KRB5_TC_MATCH_TIMES_EXACT	(1 << 26)
445 #define KRB5_TC_MATCH_TIMES		(1 << 25)
446 #define KRB5_TC_MATCH_AUTHDATA		(1 << 24)
447 #define KRB5_TC_MATCH_2ND_TKT		(1 << 23)
448 #define KRB5_TC_MATCH_IS_SKEY		(1 << 22)
449 
450 /* constants for get_flags and set_flags */
451 #define KRB5_TC_OPENCLOSE 0x00000001
452 #define KRB5_TC_NOTICKET  0x00000002
453 
454 typedef AuthorizationData krb5_authdata;
455 
456 typedef KRB_ERROR krb5_error;
457 
458 typedef struct krb5_creds {
459     krb5_principal client;
460     krb5_principal server;
461     krb5_keyblock session;
462     krb5_times times;
463     krb5_data ticket;
464     krb5_data second_ticket;
465     krb5_authdata authdata;
466     krb5_addresses addresses;
467     krb5_ticket_flags flags;
468 } krb5_creds;
469 
470 typedef struct krb5_cc_cache_cursor_data *krb5_cc_cache_cursor;
471 
472 #define KRB5_CC_OPS_VERSION 3
473 
474 typedef struct krb5_cc_ops {
475     int version;
476     const char *prefix;
477     const char* (KRB5_CALLCONV * get_name)(krb5_context, krb5_ccache);
478     krb5_error_code (KRB5_CALLCONV * resolve)(krb5_context, krb5_ccache *, const char *);
479     krb5_error_code (KRB5_CALLCONV * gen_new)(krb5_context, krb5_ccache *);
480     krb5_error_code (KRB5_CALLCONV * init)(krb5_context, krb5_ccache, krb5_principal);
481     krb5_error_code (KRB5_CALLCONV * destroy)(krb5_context, krb5_ccache);
482     krb5_error_code (KRB5_CALLCONV * close)(krb5_context, krb5_ccache);
483     krb5_error_code (KRB5_CALLCONV * store)(krb5_context, krb5_ccache, krb5_creds*);
484     krb5_error_code (KRB5_CALLCONV * retrieve)(krb5_context, krb5_ccache,
485 					       krb5_flags, const krb5_creds*, krb5_creds *);
486     krb5_error_code (KRB5_CALLCONV * get_princ)(krb5_context, krb5_ccache, krb5_principal*);
487     krb5_error_code (KRB5_CALLCONV * get_first)(krb5_context, krb5_ccache, krb5_cc_cursor *);
488     krb5_error_code (KRB5_CALLCONV * get_next)(krb5_context, krb5_ccache,
489 					       krb5_cc_cursor*, krb5_creds*);
490     krb5_error_code (KRB5_CALLCONV * end_get)(krb5_context, krb5_ccache, krb5_cc_cursor*);
491     krb5_error_code (KRB5_CALLCONV * remove_cred)(krb5_context, krb5_ccache,
492 						  krb5_flags, krb5_creds*);
493     krb5_error_code (KRB5_CALLCONV * set_flags)(krb5_context, krb5_ccache, krb5_flags);
494     int (KRB5_CALLCONV * get_version)(krb5_context, krb5_ccache);
495     krb5_error_code (KRB5_CALLCONV * get_cache_first)(krb5_context, krb5_cc_cursor *);
496     krb5_error_code (KRB5_CALLCONV * get_cache_next)(krb5_context, krb5_cc_cursor,
497 						     krb5_ccache *);
498     krb5_error_code (KRB5_CALLCONV * end_cache_get)(krb5_context, krb5_cc_cursor);
499     krb5_error_code (KRB5_CALLCONV * move)(krb5_context, krb5_ccache, krb5_ccache);
500     krb5_error_code (KRB5_CALLCONV * get_default_name)(krb5_context, char **);
501     krb5_error_code (KRB5_CALLCONV * set_default)(krb5_context, krb5_ccache);
502     krb5_error_code (KRB5_CALLCONV * lastchange)(krb5_context, krb5_ccache, krb5_timestamp *);
503     krb5_error_code (KRB5_CALLCONV * set_kdc_offset)(krb5_context, krb5_ccache, krb5_deltat);
504     krb5_error_code (KRB5_CALLCONV * get_kdc_offset)(krb5_context, krb5_ccache, krb5_deltat *);
505 } krb5_cc_ops;
506 
507 struct krb5_log_facility;
508 
509 struct krb5_config_binding {
510     enum { krb5_config_string, krb5_config_list } type;
511     char *name;
512     struct krb5_config_binding *next;
513     union {
514 	char *string;
515 	struct krb5_config_binding *list;
516 	void *generic;
517     } u;
518 };
519 
520 typedef struct krb5_config_binding krb5_config_binding;
521 
522 typedef krb5_config_binding krb5_config_section;
523 
524 typedef struct krb5_ticket {
525     EncTicketPart ticket;
526     krb5_principal client;
527     krb5_principal server;
528 } krb5_ticket;
529 
530 typedef Authenticator krb5_authenticator_data;
531 
532 typedef krb5_authenticator_data *krb5_authenticator;
533 
534 struct krb5_rcache_data;
535 typedef struct krb5_rcache_data *krb5_rcache;
536 typedef Authenticator krb5_donot_replay;
537 
538 #define KRB5_STORAGE_HOST_BYTEORDER			0x01 /* old */
539 #define KRB5_STORAGE_PRINCIPAL_WRONG_NUM_COMPONENTS	0x02
540 #define KRB5_STORAGE_PRINCIPAL_NO_NAME_TYPE		0x04
541 #define KRB5_STORAGE_KEYBLOCK_KEYTYPE_TWICE		0x08
542 #define KRB5_STORAGE_BYTEORDER_MASK			0x60
543 #define KRB5_STORAGE_BYTEORDER_BE			0x00 /* default */
544 #define KRB5_STORAGE_BYTEORDER_LE			0x20
545 #define KRB5_STORAGE_BYTEORDER_HOST			0x40
546 #define KRB5_STORAGE_CREDS_FLAGS_WRONG_BITORDER		0x80
547 
548 struct krb5_storage_data;
549 typedef struct krb5_storage_data krb5_storage;
550 
551 typedef struct krb5_keytab_entry {
552     krb5_principal principal;
553     krb5_kvno vno;
554     krb5_keyblock keyblock;
555     uint32_t timestamp;
556     uint32_t flags;
557     krb5_principals aliases;
558 } krb5_keytab_entry;
559 
560 typedef struct krb5_kt_cursor {
561     int fd;
562     krb5_storage *sp;
563     void *data;
564 } krb5_kt_cursor;
565 
566 struct krb5_keytab_data;
567 
568 typedef struct krb5_keytab_data *krb5_keytab;
569 
570 #define KRB5_KT_PREFIX_MAX_LEN	30
571 
572 struct krb5_keytab_data {
573     const char *prefix;
574     krb5_error_code (KRB5_CALLCONV * resolve)(krb5_context, const char*, krb5_keytab);
575     krb5_error_code (KRB5_CALLCONV * get_name)(krb5_context, krb5_keytab, char*, size_t);
576     krb5_error_code (KRB5_CALLCONV * close)(krb5_context, krb5_keytab);
577     krb5_error_code (KRB5_CALLCONV * destroy)(krb5_context, krb5_keytab);
578     krb5_error_code (KRB5_CALLCONV * get)(krb5_context, krb5_keytab, krb5_const_principal,
579 					  krb5_kvno, krb5_enctype, krb5_keytab_entry*);
580     krb5_error_code (KRB5_CALLCONV * start_seq_get)(krb5_context, krb5_keytab, krb5_kt_cursor*);
581     krb5_error_code (KRB5_CALLCONV * next_entry)(krb5_context, krb5_keytab,
582 						 krb5_keytab_entry*, krb5_kt_cursor*);
583     krb5_error_code (KRB5_CALLCONV * end_seq_get)(krb5_context, krb5_keytab, krb5_kt_cursor*);
584     krb5_error_code (KRB5_CALLCONV * add)(krb5_context, krb5_keytab, krb5_keytab_entry*);
585     krb5_error_code (KRB5_CALLCONV * remove)(krb5_context, krb5_keytab, krb5_keytab_entry*);
586     void *data;
587     int32_t version;
588 };
589 
590 typedef struct krb5_keytab_data krb5_kt_ops;
591 
592 struct krb5_keytab_key_proc_args {
593     krb5_keytab keytab;
594     krb5_principal principal;
595 };
596 
597 typedef struct krb5_keytab_key_proc_args krb5_keytab_key_proc_args;
598 
599 typedef struct krb5_replay_data {
600     krb5_timestamp timestamp;
601     int32_t usec;
602     uint32_t seq;
603 } krb5_replay_data;
604 
605 /* flags for krb5_auth_con_setflags */
606 enum {
607     KRB5_AUTH_CONTEXT_DO_TIME      		= 1,
608     KRB5_AUTH_CONTEXT_RET_TIME     		= 2,
609     KRB5_AUTH_CONTEXT_DO_SEQUENCE  		= 4,
610     KRB5_AUTH_CONTEXT_RET_SEQUENCE 		= 8,
611     KRB5_AUTH_CONTEXT_PERMIT_ALL   		= 16,
612     KRB5_AUTH_CONTEXT_USE_SUBKEY   		= 32,
613     KRB5_AUTH_CONTEXT_CLEAR_FORWARDED_CRED	= 64
614 };
615 
616 /* flags for krb5_auth_con_genaddrs */
617 enum {
618     KRB5_AUTH_CONTEXT_GENERATE_LOCAL_ADDR       = 1,
619     KRB5_AUTH_CONTEXT_GENERATE_LOCAL_FULL_ADDR  = 3,
620     KRB5_AUTH_CONTEXT_GENERATE_REMOTE_ADDR      = 4,
621     KRB5_AUTH_CONTEXT_GENERATE_REMOTE_FULL_ADDR = 12
622 };
623 
624 typedef struct krb5_auth_context_data {
625     unsigned int flags;
626 
627     krb5_address *local_address;
628     krb5_address *remote_address;
629     int16_t local_port;
630     int16_t remote_port;
631     krb5_keyblock *keyblock;
632     krb5_keyblock *local_subkey;
633     krb5_keyblock *remote_subkey;
634 
635     uint32_t local_seqnumber;
636     uint32_t remote_seqnumber;
637 
638     krb5_authenticator authenticator;
639 
640     krb5_pointer i_vector;
641 
642     krb5_rcache rcache;
643 
644     krb5_keytype keytype;	/* ¿requested key type ? */
645     krb5_cksumtype cksumtype;	/* ¡requested checksum type! */
646 
647 }krb5_auth_context_data, *krb5_auth_context;
648 
649 typedef struct {
650     KDC_REP kdc_rep;
651     EncKDCRepPart enc_part;
652     KRB_ERROR error;
653 } krb5_kdc_rep;
654 
655 extern const char *heimdal_version, *heimdal_long_version;
656 
657 typedef void (KRB5_CALLCONV * krb5_log_log_func_t)(const char*, const char*, void*);
658 typedef void (KRB5_CALLCONV * krb5_log_close_func_t)(void*);
659 
660 typedef struct krb5_log_facility {
661     char *program;
662     int len;
663     struct facility *val;
664 } krb5_log_facility;
665 
666 typedef EncAPRepPart krb5_ap_rep_enc_part;
667 
668 #define KRB5_RECVAUTH_IGNORE_VERSION 1
669 
670 #define KRB5_SENDAUTH_VERSION "KRB5_SENDAUTH_V1.0"
671 
672 #define KRB5_TGS_NAME_SIZE (6)
673 #define KRB5_TGS_NAME ("krbtgt")
674 #define KRB5_WELLKNOWN_NAME ("WELLKNOWN")
675 #define KRB5_ANON_NAME ("ANONYMOUS")
676 #define KRB5_DIGEST_NAME ("digest")
677 
678 typedef enum {
679     KRB5_PROMPT_TYPE_PASSWORD		= 0x1,
680     KRB5_PROMPT_TYPE_NEW_PASSWORD	= 0x2,
681     KRB5_PROMPT_TYPE_NEW_PASSWORD_AGAIN = 0x3,
682     KRB5_PROMPT_TYPE_PREAUTH		= 0x4,
683     KRB5_PROMPT_TYPE_INFO		= 0x5
684 } krb5_prompt_type;
685 
686 typedef struct _krb5_prompt {
687     const char *prompt;
688     int hidden;
689     krb5_data *reply;
690     krb5_prompt_type type;
691 } krb5_prompt;
692 
693 typedef int (KRB5_CALLCONV * krb5_prompter_fct)(krb5_context /*context*/,
694 						void * /*data*/,
695 						const char * /*name*/,
696 						const char * /*banner*/,
697 						int /*num_prompts*/,
698 						krb5_prompt /*prompts*/[]);
699 typedef krb5_error_code (KRB5_CALLCONV * krb5_key_proc)(krb5_context /*context*/,
700 							krb5_enctype /*type*/,
701 							krb5_salt /*salt*/,
702 							krb5_const_pointer /*keyseed*/,
703 							krb5_keyblock ** /*key*/);
704 typedef krb5_error_code (KRB5_CALLCONV * krb5_decrypt_proc)(krb5_context /*context*/,
705 							    krb5_keyblock * /*key*/,
706 							    krb5_key_usage /*usage*/,
707 							    krb5_const_pointer /*decrypt_arg*/,
708 							    krb5_kdc_rep * /*dec_rep*/);
709 typedef krb5_error_code (KRB5_CALLCONV * krb5_s2k_proc)(krb5_context /*context*/,
710 							krb5_enctype /*type*/,
711 							krb5_const_pointer /*keyseed*/,
712 							krb5_salt /*salt*/,
713 							krb5_data * /*s2kparms*/,
714 							krb5_keyblock ** /*key*/);
715 
716 struct _krb5_get_init_creds_opt_private;
717 
718 struct _krb5_get_init_creds_opt {
719     krb5_flags flags;
720     krb5_deltat tkt_life;
721     krb5_deltat renew_life;
722     int forwardable;
723     int proxiable;
724     int anonymous;
725     krb5_enctype *etype_list;
726     int etype_list_length;
727     krb5_addresses *address_list;
728     /* XXX the next three should not be used, as they may be
729        removed later */
730     krb5_preauthtype *preauth_list;
731     int preauth_list_length;
732     krb5_data *salt;
733     struct _krb5_get_init_creds_opt_private *opt_private;
734 };
735 
736 typedef struct _krb5_get_init_creds_opt krb5_get_init_creds_opt;
737 
738 #define KRB5_GET_INIT_CREDS_OPT_TKT_LIFE	0x0001
739 #define KRB5_GET_INIT_CREDS_OPT_RENEW_LIFE	0x0002
740 #define KRB5_GET_INIT_CREDS_OPT_FORWARDABLE	0x0004
741 #define KRB5_GET_INIT_CREDS_OPT_PROXIABLE	0x0008
742 #define KRB5_GET_INIT_CREDS_OPT_ETYPE_LIST	0x0010
743 #define KRB5_GET_INIT_CREDS_OPT_ADDRESS_LIST	0x0020
744 #define KRB5_GET_INIT_CREDS_OPT_PREAUTH_LIST	0x0040
745 #define KRB5_GET_INIT_CREDS_OPT_SALT		0x0080 /* no supported */
746 #define KRB5_GET_INIT_CREDS_OPT_ANONYMOUS	0x0100
747 #define KRB5_GET_INIT_CREDS_OPT_DISABLE_TRANSITED_CHECK	0x0200
748 
749 /* krb5_init_creds_step flags argument */
750 #define KRB5_INIT_CREDS_STEP_FLAG_CONTINUE	0x0001
751 
752 typedef struct _krb5_verify_init_creds_opt {
753     krb5_flags flags;
754     int ap_req_nofail;
755 } krb5_verify_init_creds_opt;
756 
757 #define KRB5_VERIFY_INIT_CREDS_OPT_AP_REQ_NOFAIL	0x0001
758 
759 typedef struct krb5_verify_opt {
760     unsigned int flags;
761     krb5_ccache ccache;
762     krb5_keytab keytab;
763     krb5_boolean secure;
764     const char *service;
765 } krb5_verify_opt;
766 
767 #define KRB5_VERIFY_LREALMS		1
768 #define KRB5_VERIFY_NO_ADDRESSES	2
769 
770 #define KRB5_KPASSWD_VERS_CHANGEPW      1
771 #define KRB5_KPASSWD_VERS_SETPW         0xff80
772 
773 #define KRB5_KPASSWD_SUCCESS	0
774 #define KRB5_KPASSWD_MALFORMED	1
775 #define KRB5_KPASSWD_HARDERROR	2
776 #define KRB5_KPASSWD_AUTHERROR	3
777 #define KRB5_KPASSWD_SOFTERROR	4
778 #define KRB5_KPASSWD_ACCESSDENIED 5
779 #define KRB5_KPASSWD_BAD_VERSION 6
780 #define KRB5_KPASSWD_INITIAL_FLAG_NEEDED 7
781 
782 #define KPASSWD_PORT 464
783 
784 /* types for the new krbhst interface */
785 struct krb5_krbhst_data;
786 typedef struct krb5_krbhst_data *krb5_krbhst_handle;
787 
788 #define KRB5_KRBHST_KDC		1
789 #define KRB5_KRBHST_ADMIN	2
790 #define KRB5_KRBHST_CHANGEPW	3
791 #define KRB5_KRBHST_KRB524	4
792 #define KRB5_KRBHST_KCA		5
793 
794 typedef struct krb5_krbhst_info {
795     enum { KRB5_KRBHST_UDP,
796 	   KRB5_KRBHST_TCP,
797 	   KRB5_KRBHST_HTTP } proto;
798     unsigned short port;
799     unsigned short def_port;
800     struct addrinfo *ai;
801     struct krb5_krbhst_info *next;
802     char hostname[1]; /* has to come last */
803 } krb5_krbhst_info;
804 
805 /* flags for krb5_krbhst_init_flags (and krb5_send_to_kdc_flags) */
806 enum {
807     KRB5_KRBHST_FLAGS_MASTER      = 1,
808     KRB5_KRBHST_FLAGS_LARGE_MSG	  = 2
809 };
810 
811 typedef krb5_error_code
812 (KRB5_CALLCONV * krb5_send_to_kdc_func)(krb5_context, void *, krb5_krbhst_info *, time_t,
813 					const krb5_data *, krb5_data *);
814 
815 /** flags for krb5_parse_name_flags */
816 enum {
817     KRB5_PRINCIPAL_PARSE_NO_REALM = 1, /**< Require that there are no realm */
818     KRB5_PRINCIPAL_PARSE_REQUIRE_REALM = 2, /**< Require a realm present */
819     KRB5_PRINCIPAL_PARSE_ENTERPRISE = 4 /**< Parse as a NT-ENTERPRISE name */
820 };
821 
822 /** flags for krb5_unparse_name_flags */
823 enum {
824     KRB5_PRINCIPAL_UNPARSE_SHORT = 1, /**< No realm if it is the default realm */
825     KRB5_PRINCIPAL_UNPARSE_NO_REALM = 2, /**< No realm */
826     KRB5_PRINCIPAL_UNPARSE_DISPLAY = 4 /**< No quoting */
827 };
828 
829 typedef struct krb5_sendto_ctx_data *krb5_sendto_ctx;
830 
831 #define KRB5_SENDTO_DONE	0
832 #define KRB5_SENDTO_RESTART	1
833 #define KRB5_SENDTO_CONTINUE	2
834 
835 typedef krb5_error_code
836 (KRB5_CALLCONV * krb5_sendto_ctx_func)(krb5_context, krb5_sendto_ctx, void *,
837 				       const krb5_data *, int *);
838 
839 struct krb5_plugin;
840 enum krb5_plugin_type {
841     PLUGIN_TYPE_DATA = 1,
842     PLUGIN_TYPE_FUNC
843 };
844 
845 struct credentials; /* this is to keep the compiler happy */
846 struct getargs;
847 struct sockaddr;
848 
849 /**
850  * Semi private, not stable yet
851  */
852 
853 typedef struct krb5_crypto_iov {
854     unsigned int flags;
855     /* ignored */
856 #define KRB5_CRYPTO_TYPE_EMPTY		0
857     /* OUT krb5_crypto_length(KRB5_CRYPTO_TYPE_HEADER) */
858 #define KRB5_CRYPTO_TYPE_HEADER		1
859     /* IN and OUT */
860 #define KRB5_CRYPTO_TYPE_DATA		2
861     /* IN */
862 #define KRB5_CRYPTO_TYPE_SIGN_ONLY	3
863    /* (only for encryption) OUT krb5_crypto_length(KRB5_CRYPTO_TYPE_TRAILER) */
864 #define KRB5_CRYPTO_TYPE_PADDING	4
865    /* OUT krb5_crypto_length(KRB5_CRYPTO_TYPE_TRAILER) */
866 #define KRB5_CRYPTO_TYPE_TRAILER	5
867    /* OUT krb5_crypto_length(KRB5_CRYPTO_TYPE_CHECKSUM) */
868 #define KRB5_CRYPTO_TYPE_CHECKSUM	6
869     krb5_data data;
870 } krb5_crypto_iov;
871 
872 
873 /* Glue for MIT */
874 
875 typedef struct {
876     int32_t lr_type;
877     krb5_timestamp value;
878 } krb5_last_req_entry;
879 
880 typedef krb5_error_code
881 (KRB5_CALLCONV * krb5_gic_process_last_req)(krb5_context, krb5_last_req_entry **, void *);
882 
883 /*
884  *
885  */
886 
887 struct hx509_certs_data;
888 
889 #include <krb5/krb5-protos.h>
890 
891 /* variables */
892 
893 extern KRB5_LIB_VARIABLE const char *krb5_config_file;
894 extern KRB5_LIB_VARIABLE const char *krb5_defkeyname;
895 
896 
897 extern KRB5_LIB_VARIABLE const krb5_cc_ops krb5_acc_ops;
898 extern KRB5_LIB_VARIABLE const krb5_cc_ops krb5_fcc_ops;
899 extern KRB5_LIB_VARIABLE const krb5_cc_ops krb5_mcc_ops;
900 extern KRB5_LIB_VARIABLE const krb5_cc_ops krb5_kcm_ops;
901 extern KRB5_LIB_VARIABLE const krb5_cc_ops krb5_akcm_ops;
902 extern KRB5_LIB_VARIABLE const krb5_cc_ops krb5_scc_ops;
903 
904 extern KRB5_LIB_VARIABLE const krb5_kt_ops krb5_fkt_ops;
905 extern KRB5_LIB_VARIABLE const krb5_kt_ops krb5_wrfkt_ops;
906 extern KRB5_LIB_VARIABLE const krb5_kt_ops krb5_javakt_ops;
907 extern KRB5_LIB_VARIABLE const krb5_kt_ops krb5_mkt_ops;
908 extern KRB5_LIB_VARIABLE const krb5_kt_ops krb5_akf_ops;
909 extern KRB5_LIB_VARIABLE const krb5_kt_ops krb5_any_ops;
910 
911 extern KRB5_LIB_VARIABLE const char *krb5_cc_type_api;
912 extern KRB5_LIB_VARIABLE const char *krb5_cc_type_file;
913 extern KRB5_LIB_VARIABLE const char *krb5_cc_type_memory;
914 extern KRB5_LIB_VARIABLE const char *krb5_cc_type_kcm;
915 extern KRB5_LIB_VARIABLE const char *krb5_cc_type_scc;
916 
917 #endif /* __KRB5_H__ */
918 
919