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