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