krb5_sys/
lib.rs

1#![allow(non_camel_case_types, non_upper_case_globals, overflowing_literals)]
2
3pub mod plugin;
4
5use std::os::raw::*;
6
7// krb5/krb5.h:136
8
9pub enum _profile_t {}
10
11pub type krb5_octet = u8;
12pub type krb5_int16 = i16;
13pub type krb5_ui_2 = u16;
14pub type krb5_int32 = i32;
15pub type krb5_ui_4  = u32;
16
17pub const VALID_INT_BITS: krb5_int32 = 2147483647;
18pub const VALID_UINT_BITS: krb5_ui_4 = 4294967295;
19
20pub const KRB5_INT32_MAX: krb5_int32 = 2147483647;
21pub const KRB5_INT32_MIN: krb5_int32 = (-KRB5_INT32_MAX-1);
22
23// not sure, it overflows a signed value, but its like this in
24// the orignal source code.
25pub const KRB5_INT16_MAX: krb5_int16 = 65535;
26pub const KRB5_INT16_MIN: krb5_int16 = (-KRB5_INT16_MAX-1);
27
28// krb5/krb5.h:167
29pub const FALSE: krb5_boolean = 0;
30pub const TRUE: krb5_boolean = 1;
31
32pub type krb5_boolean = c_uint;
33pub type krb5_msgtype = c_uint;
34pub type krb5_kvno = c_uint;
35
36pub type krb5_addrtype = krb5_int32;
37pub type krb5_enctype = krb5_int32;
38pub type krb5_cksumtype = krb5_int32;
39pub type krb5_authdatatype = krb5_int32;
40pub type krb5_keyusage = krb5_int32;
41pub type krb5_cryptotype = krb5_int32;
42
43pub type krb5_preauthtype = krb5_int32;
44pub type krb5_flags = krb5_int32;
45pub type krb5_timestamp = krb5_int32;
46pub type krb5_error_code = krb5_int32;
47pub type krb5_deltat = krb5_int32;
48
49pub type krb5_magic = krb5_error_code;
50
51#[repr(C)]
52pub struct krb5_data {
53    pub magic: krb5_magic,
54    pub length: c_uint,
55    pub data: *mut c_char,
56}
57
58#[repr(C)]
59pub struct krb5_octet_data {
60    pub magic: krb5_magic,
61    pub length: c_uint,
62    pub data: *mut krb5_octet,
63}
64
65pub const SALT_TYPE_AFS_LENGTH: c_uint = 65535;
66pub const SALT_TYPE_NO_LENGTH: c_uint = 65535;
67
68pub type krb5_pointer = *mut c_void;
69pub type krb5_const_pointer = *const c_void;
70
71#[repr(C)]
72pub struct krb5_principal_data {
73    pub magic: krb5_magic,
74    pub realm: krb5_data,
75    /// An array of strings
76    pub data: *mut krb5_data,
77    pub length: krb5_int32,
78    pub type_: krb5_int32,
79}
80
81pub type krb5_principal = *mut krb5_principal_data;
82
83/// Name type not known
84pub const KRB5_NT_UNKNOWN: krb5_int32 = 0;
85/// Just the name of the principal as in DCE, or for users
86pub const KRB5_NT_PRINCIPAL: krb5_int32 = 1;
87/// Service and ohter unique instance (krbtgt)
88pub const KRB5_NT_SRV_INST: krb5_int32 = 2;
89/// Service with host name as isntance (telnet, rcommands)
90pub const KRB5_NT_SRV_HST: krb5_int32 = 3;
91/// Service with host as remaining components
92pub const KRB5_NT_SRV_XHST: krb5_int32 = 4;
93/// Unique ID
94pub const KRB5_NT_UID: krb5_int32 = 5;
95/// PKINIT
96pub const KRB5_NT_X500_PRINCIPAL: krb5_int32 = 6;
97/// Name in form of SMTP email name
98pub const KRB5_NT_SMTP_NAME: krb5_int32 = 7;
99/// Windows 2000 UPN
100pub const KRB5_NT_ENTERPRISE_PRINCIPAL: krb5_int32 = 10;
101/// Well-known (special) principal
102pub const KRB5_NT_WELLKNOWN: krb5_int32 = 11;
103/// First component of NT_WELLKNOWN principals
104pub const KRB5_WELLKNOWN_NAMESTR: &'static str = "WELLKNOWN";
105
106/// Windows 2000 UPN and SID
107pub const KRB5_NT_MS_PRINCIPAL: krb5_int32 = -128;
108/// NT 4 style name
109pub const KRB5_NT_MS_PRINCIPAL_AND_ID: krb5_int32 = -129;
110/// NT 4 style name and SID
111pub const KRB5_NT_ENT_PRINCIPAL_AND_ID: krb5_int32 = -130;
112
113/// Constant version of `krb5_principal_data`
114pub type krb5_const_principal = *const krb5_principal_data;
115
116// not sure how to translate these functions since I'm unsure
117// about the type of `context`.
118
119// krb5/krb5.h:261
120/// Constant for realm referrals
121pub const KRB5_REFERRAL_REALM: &'static str = "";
122
123// krb5/krb5.h:267
124#[link(name = "krb5")]
125extern "C" {
126    /// Check for a match with KRB5_REFERRAL_REALM
127    ///
128    /// `r`: Realm to check
129    /// returns `TRUE` if `r` is zero-length, `FALSE` otherwise
130    pub fn krb5_is_referral_realm(r: *const krb5_data) -> krb5_boolean;
131    /// Return an anonymous realm data.
132    ///
133    /// This function returns constant storage that must not be freed.
134    ///
135    /// see also: `KRB5_ANONYMOUS_REALMSTR`
136    pub fn krb5_anonymous_realm() -> *const krb5_data;
137    /// Build an anonymous principal.
138    ///
139    /// This function returns constant storage that must not be freed.
140    ///
141    /// see also: `KRB5_ANONYMOUS_PRINCSTR`
142    pub fn krb5_anonymous_principal() -> krb5_const_principal;
143}
144
145/// Anonymous realm
146pub const KRB5_ANONYMOUS_REALMSTR: &'static str = "WELLKNOWN:ANONYMOUS";
147/// Anonymous principal name
148pub const KRB5_ANONYMOUS_PRINCSTR: &'static str = "ANONYMOUS";
149
150/// Structure for address
151#[repr(C)]
152pub struct krb5_address {
153    pub magic: krb5_magic,
154    pub addrtype: krb5_addrtype,
155    pub length: c_uint,
156    pub contents: *mut krb5_octet,
157}
158
159// krb5/krb5.h:316
160pub const ADDRTYPE_INET: krb5_addrtype = 0x0002;
161pub const ADDRTYPE_CHAOS: krb5_addrtype = 0x0005;
162pub const ADDRTYPE_XNS: krb5_addrtype = 0x0006;
163pub const ADDRTYPE_ISO: krb5_addrtype = 0x0007;
164pub const ADDRTYPE_DDP: krb5_addrtype = 0x0010;
165pub const ADDRTYPE_NETBIOS: krb5_addrtype = 0x0014;
166pub const ADDRTYPE_INET6: krb5_addrtype = 0x0018;
167pub const ADDRTYPE_ADDRPORT: krb5_addrtype = 0x0100;
168pub const ADDRTYPE_IPPORT: krb5_addrtype = 0x0101;
169
170#[allow(non_snake_case)]
171pub fn ADDRTYPE_IS_LOCAL(addr: krb5_addrtype) -> bool {
172    addr & 0x8000 != 0
173}
174
175pub enum _krb5_context {}
176pub type krb5_context = *mut _krb5_context;
177
178pub enum _krb5_auth_context {}
179pub type krb5_auth_context = *mut _krb5_auth_context;
180
181pub enum _krb5_cryptosystem_entry {}
182
183/// Exposed contents of a key
184#[repr(C)]
185pub struct krb5_keyblock {
186    pub magic: krb5_magic,
187    pub enctype: krb5_enctype,
188    pub length: c_uint,
189    pub contents: *mut krb5_octet,
190}
191
192pub enum krb5_key_st {}
193
194/// Opaque identifier for a key.
195///
196/// Use with the `krb5_k` APIs for better performance for repeated operations with
197/// the same key and usage. Key identifiers must not be used simultaneously
198/// within multiple threads, as they may contain mutable internal state and are
199/// not mutex-protected.
200pub type krb5_key = *mut krb5_key_st;
201
202// ifdef KRB5_OLD_CRYPTO
203#[cfg(feature = "krb5_old_crypto")]
204#[repr(C)]
205pub struct krb5_encrypt_block {
206    pub magic: krb5_magic,
207    pub crypto_entry: krb5_enctype,
208
209    pub key: *mut krb5_keyblock,
210}
211
212#[repr(C)]
213pub struct krb5_checksum {
214    pub magic: krb5_magic,
215    pub checksum_type: krb5_cksumtype,
216    pub length: c_uint,
217    pub contents: *mut krb5_octet,
218}
219
220#[repr(C)]
221pub struct krb5_enc_data {
222    pub magic: krb5_magic,
223    pub enctype: krb5_enctype,
224    pub kvno: krb5_kvno,
225    pub ciphertext: krb5_data,
226}
227
228/// Structure to describe a region of text to be encrypted or decrypted.
229///
230/// The `flags` member describes the type of the iov
231/// The `data` member points to the memory that will be manipulated.
232/// All iov APIs take a ponter to the first element of an array of `krb5_crypto_iov`'s
233/// alogn with the size of that array. Buffer contents are manipulated in-place;
234/// data is overwritten. Callers must allocate the right numbers of `krb5_crypt_iov`
235/// structures before calling into an iov API.
236#[repr(C)]
237pub struct krb5_crypto_iov {
238    /// `KRB5_CRYPTO_TYPE` type of the iov
239    pub flags: krb5_cryptotype,
240    pub data: krb5_data,
241}
242
243
244pub const ENCTYPE_NULL: krb5_enctype = 0x0000;
245/// DES cbc mode with CRC-32
246pub const ENCTYPE_DES_CBC_CRC: krb5_enctype = 0x0001;
247/// DES cbc mode with RSA-MD4
248pub const ENCTYPE_DES_CBC_MD4: krb5_enctype = 0x0002;
249/// DES cbc mode with RSA-MD5
250pub const ENCTYPE_DES_CBC_MD5: krb5_enctype = 0x0003;
251/// DES cbc mode raw
252#[deprecated]
253pub const ENCTYPE_DES_CBC_RAW: krb5_enctype = 0x0004;
254/// DES-3 cbc with SHA1
255#[deprecated]
256pub const ENCTYPE_DES3_CBC_SHA: krb5_enctype = 0x0005;
257/// DES-3 cbc mode raw
258#[deprecated]
259pub const ENCTYPE_DES3_CBC_RAW: krb5_enctype = 0x0006;
260#[deprecated]
261pub const ENCTYPE_DES_HMAC_SHA1: krb5_enctype = 0x0008;
262// PKINIT
263/// DSA with SHA1, CMS signature
264pub const ENCTYPE_DSA_SHA1_CMS: krb5_enctype = 0x0009;
265/// MD5 with RSA, CMS signature
266pub const ENCTYPE_MD5_RSA_CMS: krb5_enctype = 0x000a;
267/// SHA1 with RSA, CMS signature
268pub const ENCTYPE_SHA1_RSA_CMS: krb5_enctype = 0x000b;
269/// RC2 cbc mode, CMS enveloped data
270pub const ENCTYPE_RC2_CBC_ENV: krb5_enctype = 0x000c;
271/// RSA encryption, CMS enveloped data
272pub const ENCTYPE_RSA_ENV: krb5_enctype = 0x000d;
273/// RSA w/OEAP encryption, CMS enveloped data
274pub const ENCTYPE_RSA_ES_OAEP_ENV: krb5_enctype = 0x000e;
275/// DES-3 cbc mode, CMS enveloped data
276pub const ENCTYPE_DES3_CBC_ENV: krb5_enctype = 0x000f;
277
278pub const ENCTYPE_DES3_CBC_SHA1: krb5_enctype = 0x0010;
279/// RFC 3962
280pub const ENCTYPE_AES128_CTS_HMAC_SHA1_96: krb5_enctype = 0x0011;
281/// RFC 3962
282pub const ENCTYPE_AES256_CTS_HMAC_SHA1_96: krb5_enctype = 0x0012;
283pub const ENCTYPE_ARCFOUR_HMAC: krb5_enctype = 0x0017;
284pub const ENCTYPE_ARCFOUR_HMAC_EXP: krb5_enctype = 0x0018;
285/// RFC 6803
286pub const ENCTYPE_CAMELLIA128_CTS_CMAC: krb5_enctype = 0x0019;
287/// RFC 6803
288pub const ENCTYPE_CAMELLIA256_CTS_CMAC: krb5_enctype = 0x001a;
289pub const ENCTYPE_UNKNOWN: krb5_enctype = 0x01ff;
290
291pub const CKSUMTYPE_CRC32: krb5_cksumtype = 0x0001;
292pub const CKSUMTYPE_RSA_MD4: krb5_cksumtype = 0x0002;
293pub const CKSUMTYPE_RSA_MD4_DES: krb5_cksumtype = 0x0003;
294pub const CKSUMTYPE_DESCBC: krb5_cksumtype = 0x0004;
295pub const CKSUMTYPE_RSA_MD5: krb5_cksumtype = 0x0007;
296pub const CKSUMTYPE_RSA_MD5_DES: krb5_cksumtype = 0x0008;
297pub const CKSUMTYPE_NIST_SHA: krb5_cksumtype = 0x0009;
298pub const CKSUMTYPE_HMAC_SHA1_DES3: krb5_cksumtype = 0x000c;
299/// RFC 3962. Used with `ENCTYPE_AES128_CTS_HMAC_SHA1_96`
300pub const CKSUMTYPE_HMAC_SHA1_96_AES128: krb5_cksumtype = 0x000f;
301/// RFC 3962. Used with `ENCTYPE_AES256_CTS_HMAC_SHA1_96`
302pub const CKSUMTYPE_HMAC_SHA1_96_AES256: krb5_cksumtype = 0x0010;
303/// RFC 6803.
304pub const CKSUMTYPE_CMAC_CAMELLIA128: krb5_cksumtype = 0x0011;
305/// RFC 6803
306pub const CKSUMTYPE_CMAC_CAMELLIA256: krb5_cksumtype = 0x0012;
307/// Microsoft netlogon cksumtype
308pub const CKSUMTYPE_MD5_HMAC_ARCFOUR: krb5_cksumtype = -137;
309/// Micorsoft md5 hmac cksumtype
310pub const CKSUMTYPE_HMAC_MD5_ARCFOUR: krb5_cksumtype = -138;
311
312// A wild enum appears!
313pub const KRB5_C_RANDSOURCE_OLDAPI: u32 = 0;
314pub const KRB5_C_RANDSORUCE_OSRAND: u32 = 1;
315pub const KRB5_C_RANDSOURCE_TRUSTEDPARTY: u32 = 2;
316pub const KRB5_C_RANDSOURCE_TIMING: u32 = 3;
317pub const KRB5_C_RANDSOURCE_EXTERNAL_PROTOCOL: u32 = 4;
318pub const KRB5_C_RANDSOURCE_MAX: u32 = 5;
319
320// TODO: krb5_roundup
321//       krb5_x
322//       krb5_xc
323
324#[link(name = "krb5")]
325extern "C" {
326    /// Encrypt data using a key (operates on keyblock).
327    ///
328    /// `context`: Library context
329    /// `key`: Encryption key
330    /// `usage`: Key usage (see `KRB5_KEYUSAGE` types)
331    /// `cipher_state`: Cipher state; specify `NULL` if not needed.
332    /// `input`: Data to be encrypted
333    /// `output`: Encrypted data.
334    ///
335    /// This function encrypts the data block `input` and stores the output into
336    /// `output`. The actual encryption key will be derived from `key` and `usage`
337    /// if key derivation is specified for the encryption type. If non-null,
338    /// `cipher_state` specifies the beginning state for the encryption operation,
339    /// and is updated with the state to be passed as input to the next operation.
340    ///
341    /// Note: the caller must initialize `output` and allocate at least enough
342    /// space for the result (using `krb5_c_encrypt_length()` to determine the amount
343    /// of space needed). `output.length` will be set to the actual length of the
344    /// ciphertetxt.
345    ///
346    /// returns `0` on success, otherwise - Kerberos error codes
347    pub fn krb5_c_encrypt(context: krb5_context,
348                          key: *const krb5_keyblock,
349                          usage: krb5_keyusage,
350                          cipher_state: *const krb5_data,
351                          input: *const krb5_data,
352                          output: *mut krb5_enc_data) -> krb5_error_code;
353
354    /// Decrypt data using a key (operates on keyblock)
355    ///
356    /// `context`: Library context
357    /// `key`: Encryption key
358    /// `usage`: Key usage (see `KRB5_KEYUSAGE` types)
359    /// `cipher_state`: Cipher state; specify NULL if not needed.
360    /// `input`: Encrypted data
361    /// `output`: Decrypted data
362    ///
363    /// This function decryptes the data block `input` and stores the output into
364    /// `output`. The actual decryption key will be derived from `key` and `usage`
365    /// if key derivation is specified for the encryption type. If non-null,
366    /// `cipher_state` specifies the beginning state for the decryption operation,
367    /// and is updated with the state to be passed as input to the next operation.
368    ///
369    /// Note: The caller must initialize `output` and allocate at least enough
370    /// space for the result. The usual practice is to allocate an output buffer as
371    /// long as the ciphertext, and let `krb5_c_decrypt()` trim `output.length`.
372    /// For some enctypes, the resulting `output.length` may include padding bytes.
373    ///
374    /// returns 0 on success, kerberos error codes otherwise.
375    pub fn krb5_c_decrypt(context: krb5_context,
376                          key: *const krb5_keyblock,
377                          usage: krb5_keyusage,
378                          cipher_state: *const krb5_data,
379                          input: *const krb5_enc_data,
380                          output: *mut krb5_data) -> krb5_error_code;
381    // TODO: Doc
382    pub fn krb5_c_encrypt_length(context: krb5_context,
383                                 enctype: krb5_enctype,
384                                 inputlen: usize,
385                                 length: *mut usize) -> krb5_error_code;
386    // TODO: Doc
387    pub fn krb5_c_block_size(context: krb5_context,
388                             enctype: krb5_enctype,
389                             blocksize: *mut usize) -> krb5_error_code;
390    // TODO: Doc
391    pub fn krb5_c_keylengths(context: krb5_context,
392                             enctype: krb5_enctype,
393                             keybytes: *mut usize,
394                             keylength: *mut usize) -> krb5_error_code;
395    // TODO: Doc
396    pub fn krb5_c_init_state(context: krb5_context,
397                             key: *const krb5_keyblock,
398                             usage: krb5_keyusage,
399                             new_state: *mut krb5_data) -> krb5_error_code;
400    // TODO: Doc
401    pub fn krb_c_free_state(context: krb5_context,
402                            key: *const krb5_keyblock,
403                            state: *mut krb5_data) -> krb5_error_code;
404    // TODO: Doc
405    pub fn krb5_c_prf(context: krb5_context,
406                      keyblock: *const krb5_keyblock,
407                      input: *mut krb5_data,
408                      output: *mut krb5_data)-> krb5_error_code;
409    // TODO: Doc
410    pub fn krb5_c_prf_length(context: krb5_context,
411                             enctype: krb5_enctype,
412                             len: *mut usize) -> krb5_error_code;
413    // TODO: Doc
414    pub fn krb5_c_fx_cf2_simple(context: krb5_context,
415                                k1: *mut krb5_keyblock,
416                                pepper1: *const c_char,
417                                k2: *mut krb5_keyblock,
418                                pepper2: *const c_char,
419                                out: *mut *mut krb5_keyblock) -> krb5_error_code;
420    // TODO: Doc
421    pub fn krb5_c_make_random_key(context: krb5_context,
422                                  enctype: krb5_enctype,
423                                  k5_random_key: *mut krb5_keyblock) -> krb5_error_code;
424    // TODO: Doc
425    pub fn krb5_c_random_to_key(context: krb5_context,
426                                enctype: krb5_enctype,
427                                random_data: *mut krb5_data,
428                                k5_random_key: *mut krb5_keyblock) -> krb5_error_code;
429    // TODO: Doc
430    pub fn krb5_c_random_add_entropy(context: krb5_context,
431                                     randsource: c_uint,
432                                     data: *const krb5_data) -> krb5_error_code;
433    // TODO: Doc
434    pub fn krb5_c_random_make_octets(context: krb5_context,
435                                     data: *mut krb5_data) -> krb5_error_code;
436    // TODO: Doc
437    pub fn krb5_c_random_os_entropy(context: krb5_context,
438                                    strong: c_int,
439                                    success: *mut c_int) -> krb5_error_code;
440    // TODO: Doc
441    #[deprecated]
442    pub fn krb5_c_random_seed(context: krb5_context,
443                              data: *mut krb5_data) -> krb5_error_code;
444    // TODO: Doc
445    pub fn krb5_c_string_to_key(context: krb5_context,
446                                enctype: krb5_enctype,
447                                string: *const krb5_data,
448                                salt: *const krb5_data,
449                                key: *mut krb5_keyblock) -> krb5_error_code;
450    // TODO: Doc
451    pub fn krb5_c_string_to_key_with_params(context: krb5_context,
452                                            enctype: krb5_enctype,
453                                            string: *const krb5_data,
454                                            salt: *const krb5_data,
455                                            params: *const krb5_data,
456                                            key: *mut krb5_keyblock) -> krb5_error_code;
457    // TODO: Doc
458    pub fn krb5_c_enctype_compare(context: krb5_context,
459                                  e1: krb5_enctype,
460                                  e2: krb5_enctype,
461                                  similiar: *mut krb5_boolean) -> krb5_error_code;
462    // TODO: Doc
463    pub fn krb5_c_make_checksum(context: krb5_context,
464                                cksumtype: krb5_cksumtype,
465                                key: *const krb5_keyblock,
466                                usage: krb5_keyusage,
467                                input: *const krb5_data,
468                                cksum: *mut krb5_checksum) -> krb5_error_code;
469    // TODO: Doc
470    pub fn krb5_c_verify_checksum(context: krb5_context,
471                                  key: *const krb5_keyblock,
472                                  usage: krb5_keyusage,
473                                  data: *const krb5_data,
474                                  cksum: *const krb5_checksum,
475                                  valid: *mut krb5_boolean) -> krb5_error_code;
476    // TODO Doc
477    pub fn krb5_c_checksum_length(context: krb5_context,
478                                  cksumtype: krb5_cksumtype,
479                                  length: *mut usize) -> krb5_error_code;
480    // TODO: Doc
481    pub fn krb5_c_keyed_checksum_types(context: krb5_context,
482                                       enctype: krb5_enctype,
483                                       count: *mut c_uint,
484                                       cksumtypes: *mut *mut krb5_cksumtype) -> krb5_error_code;
485}
486
487pub const KRB5_KEYUSAGE_AS_REQ_PA_ENC_TS: krb5_keyusage = 1;
488pub const KRB5_KEYUSAGE_KDC_REP_TICKET: krb5_keyusage = 2;
489pub const KRB5_KEYUSAGE_AS_REP_ENCPART: krb5_keyusage = 3;
490pub const KRB5_KEYUSAGE_TGS_REQ_AD_SESSKEY: krb5_keyusage = 4;
491pub const KRB5_KEYUSAGE_TGS_REQ_AD_SUBKEY: krb5_keyusage = 5;
492pub const KRB5_KEYUSAGE_TGS_REQ_AUTH_CKSUM: krb5_keyusage = 6;
493pub const KRB5_KEYUSAGE_TGS_REQ_AUTH: krb5_keyusage = 7;
494pub const KRB5_KEYUSAGE_TGS_REP_ENCPART_SESSKEY: krb5_keyusage = 8;
495pub const KRB5_KEYUSAGE_TGS_REP_ENCPART_SUBKEY: krb5_keyusage = 9;
496pub const KRB5_KEYUSAGE_AP_REQ_AUTH_CKSUM: krb5_keyusage = 10;
497pub const KRB5_KEYUSAGE_AP_REQ_AUTH: krb5_keyusage = 11;
498pub const KRB5_KEYUSAGE_AP_REP_ENCPART: krb5_keyusage = 12;
499pub const KRB5_KEYUSAGE_KRB_PRIV_ENCPART: krb5_keyusage = 13;
500pub const KRB5_KEYUSAGE_KRB_CRED_ENCPART: krb5_keyusage = 14;
501pub const KRB5_KEYUSAGE_KRB_SAFE_CKSUM: krb5_keyusage = 15;
502pub const KRB5_KEYUSAGE_APP_DATA_ENCRYPT: krb5_keyusage = 16;
503pub const KRB5_KEYUSAGE_APP_DATA_CKSUM: krb5_keyusage = 17;
504pub const KRB5_KEYUSAGE_KRB_ERROR_CKSUM: krb5_keyusage = 18;
505pub const KRB5_KEYUSAGE_AD_KDCISSUED_CKSUM: krb5_keyusage = 19;
506pub const KRB5_KEYUSAGE_AD_MTE: krb5_keyusage = 20;
507pub const KRB5_KEYUSAGE_AD_ITE: krb5_keyusage = 21;
508
509pub const KRB5_KEYUSAGE_GSS_TOK_MIC: krb5_keyusage = 22;
510pub const KRB5_KEYUSAGE_GSS_TOK_WRAP_INTEG: krb5_keyusage = 23;
511pub const KRB5_KEYUSAGE_GSS_TOK_WRAP_PRIV: krb5_keyusage = 24;
512pub const KRB5_KEYUSAGE_PA_SAM_CHALLENGE_CKSUM: krb5_keyusage = 25;
513/// Note conflict with `KRB5_KEYUSAGE_PA_SAM_CHALLENGE_TRAKCID`
514pub const KRB5_KEYUSAGE_PA_S4U_X509_USER_REQUEST: krb5_keyusage = 26;
515// Note conflict with `KRB5_KEYUSAGE_PA_SAM_RESPONSE`
516pub const KRB5_KEYUSAGE_PA_S4U_X509_USER_REPLY: krb5_keyusage = 27;
517pub const KRB5_KEYUSAGE_PA_REFERRAL: krb5_keyusage = 26;
518
519pub const KRB5_KEYUSAGE_AD_SIGNEDPATH: krb5_keyusage = -21;
520pub const KRB5_KEYUSAGE_IAKERB_FINISHED: krb5_keyusage = 42;
521pub const KRB5_KEYUSAGE_PA_PKINIT_KX: krb5_keyusage = 44;
522/// See RFC 6560 section 4.2
523pub const KRB5_KEYUSAGE_PA_OTP_REQUEST: krb5_keyusage = 45;
524pub const KRB5_KEYUSAGE_FAST_REQ_CHKSUM: krb5_keyusage = 50;
525pub const KRB5_KEYUSAGE_FAST_ENC: krb5_keyusage = 51;
526pub const KRB5_KEYUSAGE_FAST_REP: krb5_keyusage = 52;
527pub const KRB5_KEYUSAGE_FAST_FINISHED: krb5_keyusage = 53;
528pub const KRB5_KEYUSAGE_ENC_CHALLENGE_CLIENT: krb5_keyusage = 54;
529pub const KRB5_KEYUSAGE_ENC_CHALLENGE_KDC: krb5_keyusage = 55;
530pub const KRB5_KEYUSAGE_AS_REQ: krb5_keyusage = 56;
531
532#[link(name = "krb5")]
533extern "C" {
534    // TODO: Doc
535    pub fn krb5_c_valid_enctype(ktype: krb5_enctype) -> krb5_boolean;
536    // TODO: Doc
537    pub fn krb5_c_valid_cksumtype(ctype: krb5_cksumtype) -> krb5_boolean;
538    // TODO: Doc
539    pub fn krb5_c_is_coll_proof_cksum(ctype: krb5_cksumtype) -> krb5_boolean;
540    // TODO: Doc
541    pub fn krb5_c_is_keyed_cksum(ctype: krb5_cksumtype) -> krb5_boolean;
542}
543
544/// [in] ignored
545pub const KRB5_CRYPTO_TYPE_EMPTY: krb5_cryptotype = 0;
546/// [out] header
547pub const KRB5_CRYPTO_TYPE_HEADER: krb5_cryptotype = 1;
548/// [in, out] plaintext
549pub const KRB5_CRYPTO_TYPE_DATA: krb5_cryptotype = 2;
550/// [in] associated data
551pub const KRB5_CRYPTO_TYPE_SIGN_ONLY: krb5_cryptotype = 3;
552/// [out] padding
553pub const KRB5_CRYPTO_TYPE_PADDING: krb5_cryptotype = 4;
554/// [out] checksum for encrypt
555pub const KRB5_CRYPTO_TYPE_TRAILER: krb5_cryptotype = 5;
556/// [out] checksum for MIC
557pub const KRB5_CRYPTO_TYPE_CHECKSUM: krb5_cryptotype = 6;
558/// [in] entire message without decomposing the strucutre into
559/// header, data and trailer buffers
560pub const KRB5_CRYPTO_TYPE_STREAM: krb5_cryptotype = 7;
561
562#[link(name = "krb5")]
563extern "C" {
564    // TODO: Doc
565    pub fn krb5_c_make_checksum_iov(context: krb5_context,
566                                    cksumtype: krb5_cksumtype,
567                                    key: *const krb5_keyblock,
568                                    usage: krb5_keyusage,
569                                    data: *mut krb5_crypto_iov,
570                                    num_data: usize) -> krb5_error_code;
571    // TODO: Doc
572    pub fn krb5_c_verify_checksum_iov(context: krb5_context,
573                                      cksumtype: krb5_cksumtype,
574                                      key: *const krb5_keyblock,
575                                      usage: krb5_keyusage,
576                                      data: *const krb5_crypto_iov,
577                                      num_data: usize,
578                                      valid: *mut krb5_boolean) -> krb5_error_code;
579    // TODO: Doc
580    pub fn krb5_c_encrypt_iov(context: krb5_context,
581                              keyblock: *const krb5_keyblock,
582                              usage: krb5_keyusage,
583                              cipher_state: *const krb5_data,
584                              data: *mut krb5_crypto_iov,
585                              num_data: usize) -> krb5_error_code;
586    // TODO: Doc
587    pub fn krb5_c_decypt_iov(context: krb5_context,
588                             keyblock: *const krb5_keyblock,
589                             usage: krb5_keyusage,
590                             cipher_state: *const krb5_data,
591                             data: *mut krb5_crypto_iov,
592                             num_data: usize) -> krb5_error_code;
593    // TODO: Doc
594    pub fn krb5_c_crypto_length(context: krb5_context,
595                                enctype: krb5_enctype,
596                                type_: krb5_cryptotype,
597                                size: *mut c_uint) -> krb5_error_code;
598    // TODO: Doc
599    pub fn krb5_c_crypto_length_iov(context: krb5_context,
600                                    enctype: krb5_enctype,
601                                    data: *mut krb5_crypto_iov,
602                                    num_data: usize) -> krb5_error_code;
603    // TODO: Doc
604    pub fn krb5_c_padding_length(context: krb5_context,
605                                 enctype: krb5_enctype,
606                                 data_length: usize,
607                                 size: *mut c_uint) -> krb5_error_code;
608    // TODO: Doc
609    pub fn krb5_k_create_key(context: krb5_context,
610                             key_data: *const krb5_keyblock,
611                             out: *mut krb5_key) -> krb5_error_code;
612    // TODO: Doc
613    pub fn krb5_k_reference_key(context: krb5_context,
614                                key: krb5_key);
615    // TODO: Doc
616    pub fn krb5_k_key_keyblock(context: krb5_context,
617                               key: krb5_key,
618                               key_data: *mut *mut krb5_keyblock) -> krb5_error_code;
619    // TODO: Doc
620    pub fn krb5_k_key_enctype(context: krb5_context,
621                              key: krb5_key) -> krb5_enctype;
622    // TODO: Doc
623    pub fn krb5_k_encrypt(context: krb5_context,
624                          key: krb5_key,
625                          usage: krb5_keyusage,
626                          cipher_state: *const krb5_data,
627                          input: *const krb5_data,
628                          output: *mut krb5_enc_data) -> krb5_error_code;
629    // TODO: Doc
630    pub fn krb5_k_encrypt_iov(context: krb5_context,
631                              key: krb5_key,
632                              usage: krb5_keyusage,
633                              cipher_state: *const krb5_data,
634                              data: *mut krb5_crypto_iov,
635                              num_data: usize) -> krb5_error_code;
636    // TODO: Doc
637    pub fn krb5_k_decrypt(context: krb5_context,
638                          key: krb5_key,
639                          usage: krb5_keyusage,
640                          cipher_state: *const krb5_data,
641                          input: *const krb5_enc_data,
642                          output: *mut krb5_data) -> krb5_error_code;
643    // TODO: Doc
644    pub fn krb5_k_decrypt_iov(context: krb5_context,
645                              key: krb5_key,
646                              usage: krb5_keyusage,
647                              cipher_state: *const krb5_data,
648                              data: *mut krb5_crypto_iov,
649                              num_data: usize) -> krb5_error_code;
650    // TODO: Doc
651    pub fn krb5_k_make_checksum(context: krb5_context,
652                                cksumtype: krb5_cksumtype,
653                                key: krb5_key,
654                                usage: krb5_keyusage,
655                                input: *const krb5_data,
656                                cksum: *mut krb5_checksum) -> krb5_error_code;
657    // TODO: Doc
658    pub fn krb5_k_make_checksum_iov(context: krb5_context,
659                                    cksumtype: krb5_cksumtype,
660                                    key: krb5_key,
661                                    usage: krb5_keyusage,
662                                    data: *mut krb5_crypto_iov,
663                                    num_data: usize) -> krb5_error_code;
664    // TODO: Doc
665    pub fn krb5_k_verify_checksum(context: krb5_context,
666                                  key: krb5_key,
667                                  usage: krb5_keyusage,
668                                  data: *const krb5_data,
669                                  cksum: *const krb5_checksum,
670                                  valid: *mut krb5_boolean) -> krb5_error_code;
671    // TODO: Doc
672    pub fn krb5_k_verify_checksum_iov(context: krb5_context,
673                                      cksumtype: krb5_cksumtype,
674                                      key: krb5_key,
675                                      usage: krb5_keyusage,
676                                      data: *const krb5_crypto_iov,
677                                      num_data: usize,
678                                      valid: *mut krb5_boolean) -> krb5_error_code;
679    // TODO: Doc
680    pub fn krb5_k_prf(context: krb5_context,
681                      key: krb5_key,
682                      input: *mut krb5_data,
683                      output: *mut krb5_data) -> krb5_error_code;
684    //ifdef KRB5_OLD_CRYPTO
685    // TODO: Doc
686    #[cfg(feature = "krb5_old_crypto")]
687    #[deprecated(note = "Replaced by krb5_c_* API family.")]
688    pub fn krb5_encrypt(context: krb5_context,
689                        inptr: krb5_const_pointer,
690                        outptr: krb5_pointer,
691                        size: usize,
692                        eblock: *mut krb5_encrypt_block,
693                        ivec: krb5_pointer) -> krb5_error_code;
694    // TODO: Doc
695    #[cfg(feature = "krb5_old_crypto")]
696    #[deprecated(note = "Replaced by krb5_c_* API family.")]
697    pub fn krb5_decrypt(context: krb5_context,
698                        inptr: krb5_const_pointer,
699                        outpt: krb5_pointer,
700                        size: usize,
701                        eblock: *mut krb5_encrypt_block,
702                        ivec: krb5_pointer) -> krb5_error_code;
703    // TODO: Doc
704    #[cfg(feature = "krb5_old_crypto")]
705    #[deprecated(note = "Replaced by krb5_c_* API family.")]
706    pub fn krb5_process_key(context: krb5_context,
707                            eblock: *mut krb5_encrypt_block,
708                            key: *const krb5_keyblock) -> krb5_error_code;
709    // TODO: Doc
710    #[cfg(feature = "krb5_old_crypto")]
711    #[deprecated(note = "Replaced by krb5_c_* API family.")]
712    pub fn krb5_finish_key(context: krb5_context,
713                           eblock: *mut krb5_encrypt_block) -> krb5_error_code;
714    // TODO: Doc
715    #[cfg(feature = "krb5_old_crypto")]
716    #[deprecated(note = "Replaced by krb5_c_* API family.")]
717    pub fn krb5_string_to_key(context: krb5_context,
718                              eblock: *const krb5_encrypt_block,
719                              keyblock: *mut krb5_keyblock,
720                              data: *const krb5_data,
721                              salt: *const krb5_data) -> krb5_error_code;
722    // TODO: Doc
723    #[cfg(feature = "krb5_old_crypto")]
724    #[deprecated(note = "Replaced by krb5_c_* API family.")]
725    pub fn krb5_init_random_key(context: krb5_context,
726                                eblock: *const krb5_encrypt_block,
727                                keyblock: *const krb5_keyblock,
728                                ptr: *mut krb5_pointer) -> krb5_error_code;
729    // TODO: Doc
730    #[cfg(feature = "krb5_old_crypto")]
731    #[deprecated(note = "Replaced by krb5_c_* API family.")]
732    pub fn krb5_finish_random_key(context: krb5_context,
733                                  eblock: *const krb5_encrypt_block,
734                                  ptr: *mut krb5_pointer) -> krb5_error_code;
735    // TODO: Doc
736    #[cfg(feature = "krb5_old_crypto")]
737    #[deprecated(note = "Replaced by krb5_c_* API family.")]
738    pub fn krb5_random_key(context: krb5_context,
739                           eblock: *const krb5_encrypt_block,
740                           ptr: krb5_pointer,
741                           keyblock: *mut *mut krb5_keyblock) -> krb5_error_code;
742    // TODO: Doc
743    #[cfg(feature = "krb5_old_crypto")]
744    #[deprecated(note = "Replaced by krb5_c_* API family.")]
745    pub fn krb5_eblock_enctype(context: krb5_context,
746                               eblock: *const krb5_encrypt_block) -> krb5_enctype;
747    // TODO: Doc
748    #[cfg(feature = "krb5_old_crypto")]
749    #[deprecated(note = "Replaced by krb5_c_* API family.")]
750    pub fn krb5_use_enctype(context: krb5_context,
751                            eblock: *mut krb5_encrypt_block,
752                            enctype: krb5_enctype) -> krb5_error_code;
753    // TODO: Doc
754    #[cfg(feature = "krb5_old_crypto")]
755    #[deprecated(note = "Replaced by krb5_c_* API family.")]
756    pub fn krb5_encrypt_size(length: usize, crypto: krb5_enctype) -> usize;
757    // TODO: Doc
758    #[cfg(feature = "krb5_old_crypto")]
759    #[deprecated(note = "See `krb5_c_checksum_length()`")]
760    pub fn krb5_checksum_size(context: krb5_context, ctype: krb5_cksumtype) -> usize;
761    // TODO: Doc
762    #[cfg(feature = "krb5_old_crypto")]
763    #[deprecated(note = "See `krb5_c_make_chekcsum()`")]
764    pub fn krb5_calculate_checksum(context: krb5_context,
765                                   ctype: krb5_cksumtype,
766                                   in_: krb5_const_pointer,
767                                   in_length: usize,
768                                   seed: krb5_const_pointer,
769                                   seed_length: usize,
770                                   outcksum: *mut krb5_checksum) -> krb5_error_code;
771    // TODO: Doc
772    #[cfg(feature = "krb5_old_crypto")]
773    #[deprecated(note = "See `krb5_c_verify_checksum()`")]
774    pub fn krb5_verify_checksum(context: krb5_context,
775                                ctype: krb5_cksumtype,
776                                cksum: *const krb5_checksum,
777                                in_: krb5_const_pointer,
778                                in_length: usize,
779                                seed: krb5_const_pointer,
780                                seed_length: usize) -> krb5_error_code;
781    // endif KRB5_OLD_CRYPTO
782}
783
784pub const KDC_OPT_FORWARDABLE: krb5_flags             = 0x40000000;
785pub const KDC_OPT_FORWARDED: krb5_flags               = 0x20000000;
786pub const KDC_OPT_PROXIABLE: krb5_flags               = 0x10000000;
787pub const KDC_OPT_PROXY: krb5_flags                   = 0x08000000;
788pub const KDC_OPT_ALLOW_POSTDATED: krb5_flags         = 0x04000000;
789pub const KDC_OPT_POSTDATED: krb5_flags               = 0x02000000;
790
791pub const KDC_OPT_RENEWABLE: krb5_flags               = 0x00800000;
792
793pub const KDC_OPT_CNAME_IN_ADDL_TKT: krb5_flags       = 0x00020000;
794pub const KDC_OPT_CANONICALIZE: krb5_flags            = 0x00010000;
795pub const KDC_OPT_REQUEST_ANONYMOUS: krb5_flags       = 0x00008000;
796
797pub const KDC_OPT_DISABLE_TRANSITED_CHEDK: krb5_flags = 0x00000020;
798pub const KDC_OPT_RENEWABLE_OK: krb5_flags            = 0x00000010;
799pub const KDC_OPT_ENC_TKT_IN_SKEY: krb5_flags         = 0x00000008;
800
801pub const KDC_OPT_RENEW: krb5_flags                   = 0x00000002;
802pub const KDC_OPT_VALIDATE: krb5_flags                = 0x00000001;
803
804pub const KDC_TKT_COMMON_MASK: krb5_flags             = 0x54800000;
805
806pub const AP_OPTS_RESERVERD: krb5_flags               = 0x80000000;
807/// Use session key
808pub const AP_OPTS_USE_SESSION_KEY: krb5_flags         = 0x40000000;
809/// Perform a mutual authentiction exchange
810pub const AP_OPTS_MUTUAL_REQUIRED: krb5_flags         = 0x20000000;
811
812pub const AP_OPTS_ETYPE_NEGOTIATION: krb5_flags       = 0x00000002;
813/// Generate a subsession key from the curretn session key obtained from
814/// the credentials
815pub const AP_OPTS_USE_SUBKEY: krb5_flags              = 0x00000001;
816
817pub const AP_OPTS_WIRE_MASK: krb5_flags               = 0xfffffff0;
818
819pub const AD_TYPE_RESERVED: u16                = 0x8000;
820pub const AD_TYPE_EXTERNAL: u16                = 0x4000;
821pub const AD_TYPE_REGISTERED: u16              = 0x2000;
822
823pub const AD_TYPE_FIELD_TYPE_MASK: u16         = 0x1fff;
824
825pub const TKT_FLG_FORWARDABLE: krb5_flags             = 0x40000000;
826pub const TKT_FLG_FORWARDED: krb5_flags               = 0x20000000;
827pub const TKT_FLG_PROXIABLE: krb5_flags               = 0x10000000;
828pub const TKT_FLG_PROXY: krb5_flags                   = 0x08000000;
829pub const TKT_FLG_MAY_POSTDATE: krb5_flags            = 0x04000000;
830pub const TKT_FLG_POSTDATED: krb5_flags               = 0x02000000;
831pub const TKT_FLG_INVALID: krb5_flags                 = 0x01000000;
832pub const TKT_FLG_RENEWABLE: krb5_flags               = 0x00800000;
833pub const TKT_FLG_INITIAL: krb5_flags                 = 0x00400000;
834pub const TKT_FLG_PRE_AUTH: krb5_flags                = 0x00200000;
835pub const TKT_FLG_HW_AUTH: krb5_flags                 = 0x00100000;
836pub const TKT_FLG_TRANSIT_POLICY_CHECKED: krb5_flags  = 0x00080000;
837pub const TKT_FLG_OK_AS_DELEGATE: krb5_flags          = 0x00040000;
838pub const TKT_FLG_ENC_PA_REP: krb5_flags              = 0x00010000;
839pub const TKT_FLG_ANONYMOUS: krb5_flags               = 0x00008000;
840
841pub const LR_TYPE_THIS_SERVER_ONLY: u16        = 0x8000;
842pub const LR_TYPE_INTERPRETATION_MASK: u16     = 0x7fff;
843
844pub const MSEC_DIRBIT: u16                     = 0x8000;
845pub const MSEC_VAL_MASK: u16                   = 0x7fff;
846
847pub const KRB5_PVNO: usize = 4;
848
849/// Initial authentication request
850pub const KRB5_AS_REQ: krb5_msgtype = 10;
851/// Response to AS requset
852pub const KRB5_AS_REP: krb5_msgtype = 11;
853/// Ticket granting server request
854pub const KRB5_TGS_REQ: krb5_msgtype = 12;
855/// Response to TGS request
856pub const KRB5_TGS_REP: krb5_msgtype = 13;
857/// Auth req to application server
858pub const KRB5_AP_REQ: krb5_msgtype = 14;
859/// Repsonse to mutual AP request
860pub const KRB5_AP_REP: krb5_msgtype = 15;
861/// Safe application message
862pub const KRB5_SAFE: krb5_msgtype = 20;
863/// Private application message
864pub const KRB5_PRIV: krb5_msgtype = 21;
865/// Cred forwarding message
866pub const KRB5_CRED: krb5_msgtype = 22;
867/// Error response
868pub const KRB5_ERROR: krb5_msgtype = 30;
869
870// TODO: Find the proper type for these
871pub const KRB5_LRQ_NONE: isize = 0;
872pub const KRB5_LRQ_ALL_LAST_TGT: isize = 1;
873pub const KRB5_LRQ_ONE_LAST_TGT: isize = -1;
874pub const KRB5_LRQ_ALL_LAST_INITIAL: isize = 2;
875pub const KRB5_LRQ_ONE_LAST_INITIAL: isize = -2;
876pub const KRB5_LRQ_ALL_LAST_TGT_ISSUED: isize = 3;
877pub const KRB5_LRQ_ONE_LAST_TGT_ISSUED: isize = -3;
878pub const KRB5_LRQ_ALL_LAST_RENEWAL: isize = 4;
879pub const KRB5_LRQ_ONE_LAST_RENEWAL: isize = -4;
880pub const KRB5_LRQ_ALL_LAST_REQ: isize = 5;
881pub const KRB5_LRQ_ONE_LAST_REQ: isize = -5;
882pub const KRB5_LRQ_ALL_PW_EXPTIME: isize = 6;
883pub const KRB5_LRQ_ONE_PW_EXPTIME: isize = -6;
884pub const KRB5_LRQ_ALL_ACCT_EXPTIME: isize = 7;
885pub const KRB5_LRQ_ONE_ACCT_EXPTIME: isize = -7;
886
887pub const KRB5_PADATA_NONE: isize = 0;
888pub const KRB5_PADATA_AP_REQ: isize = 1;
889pub const KRB5_PADATA_TGS_REQ: isize = KRB5_PADATA_AP_REQ;
890/// RFC 4120
891pub const KRB5_PADATA_ENC_TIMESTAMP: isize = 2;
892/// RFC 4120
893pub const KRB5_PADATA_PW_SALT: isize = 3;
894/// Not used, key encrypted within self
895pub const KRB5_PADATA_ENC_ENCKEY: isize = 4;
896/// timestamp encrytped in key, RFC 4120
897pub const KRB5_PADATA_ENC_UNIX_TIME: isize = 5;
898/// SecurId passcode. RFC 4120
899pub const KRB5_PADATA_ENC_SANDIA_SECURID: isize = 6;
900/// Sesame project. RFC 4120
901pub const KRB5_PADATA_SESAME: isize = 7;
902/// OSF DCE. RFC 4120
903pub const KRB5_PADATA_OSF_DCE: isize = 8;
904/// Cybersafe, RFC 4120
905pub const KRB5_CYBERSAFE_SECUREID: isize = 9;
906/// Cygnus, RFC 4120, 3961
907pub const KRB5_PADATA_AFS3_SALT: isize = 10;
908/// Etype info for preauth. RFC 4120
909pub const KRB5_PADATA_ETYPE_INFO: isize = 11;
910/// SAM/OTP
911pub const KRB5_PADATA_SAM_CHALLENGE: isize = 12;
912/// SAM/OTP
913pub const KRB5_PADATA_SAM_RESPONSE: isize = 13;
914/// PKINIT
915pub const KRB5_PADATA_PK_AS_REQ_OLD: isize = 14;
916/// PKINIT
917pub const KRB5_PADATA_PK_AS_REP_OLD: isize = 15;
918/// PKINIT. RFC 4556
919pub const KRB5_PADATA_PK_AS_REQ: isize = 16;
920/// PKINIT. RFC 4556
921pub const KRB5_PADATA_PK_AS_REP: isize = 17;
922/// RFC 4120
923pub const KRB5_PADATA_ETYPE_INFO2: isize = 19;
924/// RFC 4120
925pub const KRB5_PADATA_USE_SEPCIFIED_KVNO: isize = 20;
926/// Windows 2000 referrals. RFC 6820
927pub const KRB5_PADATA_SVR_REFERRAL_INFO: isize = 20;
928/// SAM/OTP. RFC 4120
929pub const KRB5_PADATA_SAM_REDIRECT: isize = 21;
930/// Embedded in typed data. RFC 4120
931pub const KRB5_PADATA_GET_FROM_TYPED_DATA: isize = 22;
932/// Draft challenge system
933pub const KRB5_PADATA_REFERRAL: isize = 25;
934/// draft challenge system, updated
935pub const KRB5_PADATA_SAM_CHALLENGE_2: isize = 30;
936/// draft challenge system, updated
937pub const KRB5_PADATA_SAM_RESPONSE_2: isize = 31;
938/// include Windows PAC
939pub const KRB5_PADATA_PAC_REQUEST: isize = 128;
940/// username protocol transition request
941pub const KRB5_PADATA_FOR_USER: isize = 129;
942/// certificate protocol transition request
943pub const KRB5_PADATA_S4U_X509_USER: isize = 130;
944/// AS checksum
945pub const KRB5_PADATA_AS_CHECKSUM: isize = 132;
946/// RFC 6113
947pub const KRB5_PADATA_FX_COOKIE: isize = 133;
948/// RFC 6113
949pub const KRB5_PADATA_FX_FAST: isize = 136;
950/// RFC 6113
951pub const KRB5_PADATA_FX_ERROR: isize = 137;
952/// RFC 6113
953pub const KRB5_PADATA_ENCRYPTED_CHALLENGE: isize = 138;
954/// RFC 6560 section 4.1
955pub const KRB5_PADATA_OTP_CHALLENGE: isize = 141;
956/// RFC 6560 section 4.2
957pub const KRB5_PADATA_OTP_REQUEST: isize = 142;
958/// RFC 6560 section 4.3
959pub const KRB5_PADATA_OTP_PIN_CHANGE: isize = 144;
960/// RFC 6112
961pub const KRB5_PADATA_PKINIT_KX: isize = 147;
962/// RFC 6806
963pub const KRB5_ENCPADATA_REQ_ENC_PA_REP: isize = 149;
964
965pub const KRB5_SAM_USE_SAD_AS_KEY: isize = 0x80000000;
966pub const KRB5_SAM_SEND_ENCRYPTED_SAD: isize = 0x40000000;
967/// currently must be zero
968pub const KRB5_SAM_MUST_PK_ENCRYPT_SAD: isize = 0x20000000;
969
970/// Transited encoding types
971pub const KRB5_DOMAIN_X500_COMPRESS: isize = 1;
972/// alternate authentication types
973pub const KRB5_ALTAUTH_ATT_CHALLENGE_RESPONSE: isize = 64;
974
975pub const KBR5_AUTHDATA_IF_RELEVANT: krb5_authdatatype = 1;
976pub const KRB5_AUTHDATA_KDC_ISSUED: krb5_authdatatype = 4;
977pub const KRB5_AUTHDATA_AND_OR: krb5_authdatatype = 5;
978pub const KRB5_AUTHDATA_MANDATORY_FOR_KDC: krb5_authdatatype = 8;
979pub const KRB5_AUTHDATA_INITIAL_VERIFIED_CAS: krb5_authdatatype = 9;
980pub const KRB5_AUTHDATA_OSF_DC: krb5_authdatatype = 64;
981pub const KRB5_AUTHDATA_SESAME: krb5_authdatatype = 65;
982pub const KRB5_AUTHDATA_WIN2K_PAC: krb5_authdatatype = 128;
983/// RFC 4537
984pub const KRB5_AUTHDATA_ETYPE_NEGOTIATION: krb5_authdatatype = 129;
985/// formerly 142 in krb5 1.8
986pub const KRB5_AUTHDATA_SIGNTICKET: krb5_authdatatype = 512;
987pub const KRB5_AUTHDATA_FX_ARMOR: krb5_authdatatype = 71;
988
989// TODO: find the proper type for these
990/// Success
991pub const KRB5_KPASSWD_SUCCESS: isize = 0;
992/// Malformed request
993pub const KRB5_KPASSWD_MALFORMED: isize = 1;
994/// Server error
995pub const KRB5_KPASSWD_HARDERROR: isize = 2;
996/// Authentication error
997pub const KRB5_KPASSWD_AUTHERROR: isize = 3;
998/// Password change rejected
999pub const KRB5_KPASSWD_SOFTERROR: isize = 4;
1000/// Not authorized
1001pub const KRB5_KPASSWD_ACCESSDENIED: isize = 5;
1002/// Unknown RPC version
1003pub const KRB5_KPASSWD_BAD_VERSION: isize = 6;
1004/// The presented credentials were not obtained using a password directly
1005pub const KRB5_KPASSWD_INITIAL_FLAG_NEEDED: isize = 7;
1006
1007// TODO: Docs
1008#[repr(C)]
1009pub struct krb5_ticket_times {
1010    pub authtime: krb5_timestamp,
1011    pub starttime: krb5_timestamp,
1012    pub endtime: krb5_timestamp,
1013    pub renew_till: krb5_timestamp,
1014}
1015
1016// TODO: Docs
1017#[repr(C)]
1018pub struct krb5_authdata {
1019    pub magic: krb5_magic,
1020    pub ad_type: krb5_authdatatype,
1021    pub length: c_uint,
1022    pub contents: *mut krb5_octet,
1023}
1024
1025// TODO: Docs
1026#[repr(C)]
1027pub struct krb5_transited {
1028    pub magic: krb5_magic,
1029    pub tr_type: krb5_octet,
1030    pub tr_contents: krb5_data,
1031}
1032
1033// TODO: Docs
1034#[repr(C)]
1035pub struct krb5_enc_tkt_part {
1036    pub magic: krb5_magic,
1037    pub flags: krb5_flags,
1038    pub session: *mut krb5_keyblock,
1039    pub client: krb5_principal,
1040    pub transited: krb5_transited,
1041    pub times: krb5_ticket_times,
1042    pub caddrs: *mut *mut krb5_address,
1043    pub authorization_data: *mut *mut krb5_authdata,
1044}
1045
1046// TODO: Docs
1047#[repr(C)]
1048pub struct krb5_ticket {
1049    pub magic: krb5_magic,
1050    pub server: krb5_principal,
1051    pub enc_part: krb5_enc_data,
1052    pub enc_part2: *mut krb5_enc_tkt_part,
1053}
1054
1055// TODO: Docs
1056#[repr(C)]
1057pub struct krb5_authenticator {
1058    pub magic: krb5_magic,
1059    pub client: krb5_principal,
1060    pub checksum: *mut krb5_checksum,
1061    pub cusec: krb5_int32,
1062    pub ctime: krb5_timestamp,
1063    pub subkey: *mut krb5_keyblock,
1064    pub seq_number: krb5_ui_4,
1065    pub authorization_data: *mut *mut krb5_authdata,
1066}
1067
1068// TODO: Docs
1069#[repr(C)]
1070pub struct krb5_tkt_authent {
1071    pub magic: krb5_magic,
1072    pub ticket: *mut krb5_ticket,
1073    pub authenticator: *mut krb5_authenticator,
1074    pub ap_options: krb5_flags,
1075}
1076
1077// TODO: Docs
1078#[repr(C)]
1079pub struct krb5_creds {
1080    pub magic: krb5_magic,
1081    pub client: krb5_principal,
1082    pub server: krb5_principal,
1083    pub keyblock: krb5_keyblock,
1084    pub times: krb5_ticket_times,
1085    pub is_skey: krb5_boolean,
1086    pub ticket_flags: krb5_flags,
1087    pub addresses: *mut *mut krb5_address,
1088    pub ticket: krb5_data,
1089    pub second_ticket: krb5_data,
1090    pub authdata: *mut *mut krb5_authdata,
1091}
1092
1093// TODO: Docs
1094#[repr(C)]
1095pub struct krb5_last_req_entry {
1096    pub magic: krb5_magic,
1097    pub lr_type: krb5_int32,
1098    pub value: krb5_timestamp,
1099}
1100
1101// TODO: Docs
1102#[repr(C)]
1103pub struct krb5_pa_data {
1104    pub magic: krb5_magic,
1105    pub pa_type: krb5_preauthtype,
1106    pub length: c_uint,
1107    pub contents: *mut krb5_octet,
1108}
1109
1110// TODO: Docs
1111#[repr(C)]
1112pub struct krb5_typed_data {
1113    pub magic: krb5_magic,
1114    pub type_: krb5_int32,
1115    pub length: c_uint,
1116    pub data: *mut krb5_octet,
1117}
1118
1119// TODO: Docs
1120#[repr(C)]
1121pub struct krb5_kdc_req {
1122    pub magic: krb5_magic,
1123    pub msg_type: krb5_msgtype,
1124    pub padata: *mut *mut krb5_pa_data,
1125    pub kdc_options: krb5_flags,
1126    pub client: krb5_principal,
1127    pub server: krb5_principal,
1128    pub from: krb5_timestamp,
1129    pub till: krb5_timestamp,
1130    pub rtime: krb5_timestamp,
1131    pub nonce: krb5_int32,
1132    pub nktypes: c_int,
1133    pub ktype: *mut krb5_enctype,
1134    pub addressses: *mut *mut krb5_address,
1135    pub authorization_data: krb5_enc_data,
1136    pub unenc_authdata: *mut *mut krb5_authdata,
1137    pub second_ticket: *mut *mut krb5_ticket,
1138}
1139
1140// TODO: Docs
1141#[repr(C)]
1142pub struct krb5_enc_kdc_rep_part {
1143    pub magic: krb5_magic,
1144    pub msg_type: krb5_msgtype,
1145    pub session: *mut krb5_keyblock,
1146    pub last_req: *mut *mut krb5_last_req_entry,
1147    pub nonce: krb5_int32,
1148    pub key_exp: krb5_timestamp,
1149    pub flags: krb5_flags,
1150    pub times: krb5_ticket_times,
1151    pub server: krb5_principal,
1152    pub caddrs: *mut *mut krb5_address,
1153    pub enc_padata: *mut *mut krb5_pa_data,
1154}
1155
1156// TODO: Docs
1157#[repr(C)]
1158pub struct krb5_kdc_rep {
1159    pub magic: krb5_magic,
1160    pub msg_type: krb5_msgtype,
1161    pub padata: *mut *mut krb5_pa_data,
1162    pub client: krb5_principal,
1163    pub ticket: *mut krb5_ticket,
1164    pub enc_part: krb5_enc_data,
1165    pub enc_part2: *mut krb5_enc_kdc_rep_part,
1166}
1167
1168// TODO: Docs
1169#[repr(C)]
1170pub struct krb5_error {
1171    pub magic: krb5_magic,
1172    pub ctime: krb5_timestamp,
1173    pub cusec: krb5_int32,
1174    pub susec: krb5_int32,
1175    pub stime: krb5_timestamp,
1176    pub error: krb5_ui_4,
1177    pub client: krb5_principal,
1178    pub server: krb5_principal,
1179    pub text: krb5_data,
1180    pub e_data: krb5_data,
1181}
1182
1183// TODO: Docs
1184#[repr(C)]
1185pub struct krb5_ap_req {
1186    pub magic: krb5_magic,
1187    pub ap_options: krb5_flags,
1188    pub ticket: *mut krb5_ticket,
1189    pub authenticator: krb5_enc_data,
1190}
1191
1192// TODO: Docs
1193#[repr(C)]
1194pub struct krb5_ap_rep {
1195    pub magic: krb5_magic,
1196    pub enc_part: krb5_enc_data,
1197}
1198
1199// TODO: Docs
1200#[repr(C)]
1201pub struct krb5_ap_rep_enc_part {
1202    pub magic: krb5_magic,
1203    pub ctime: krb5_timestamp,
1204    pub cusec: krb5_int32,
1205    pub subkey: *mut krb5_keyblock,
1206    pub seq_number: krb5_ui_4,
1207}
1208
1209// TODO: Docs
1210#[repr(C)]
1211pub struct krb5_response {
1212    pub magic: krb5_magic,
1213    pub message_type: krb5_octet,
1214    pub response: krb5_data,
1215    pub expected_nonce: krb5_int32,
1216    pub request_time: krb5_timestamp,
1217}
1218
1219// TODO: Docs
1220#[repr(C)]
1221pub struct krb5_cred_info {
1222    pub magic: krb5_magic,
1223    pub session: *mut krb5_keyblock,
1224    pub client: krb5_principal,
1225    pub server: krb5_principal,
1226    pub flags: krb5_flags,
1227    pub times: krb5_ticket_times,
1228    pub caddrs: *mut *mut krb5_address,
1229}
1230
1231// TODO: Docs
1232#[repr(C)]
1233pub struct krb5_cred_enc_part {
1234    pub magic: krb5_magic,
1235    pub nonce: krb5_int32,
1236    pub timestamp: krb5_timestamp,
1237    pub usec: krb5_int32,
1238    pub s_address: *mut krb5_address,
1239    pub r_address: *mut krb5_address,
1240    pub ticket_info: *mut *mut krb5_cred_info,
1241}
1242
1243// TODO: Docs
1244#[repr(C)]
1245pub struct krb5_cred {
1246    pub magic: krb5_magic,
1247    pub tickets: *mut *mut krb5_ticket,
1248    pub enc_part: krb5_enc_data,
1249    pub enc_part2: *mut krb5_cred_enc_part,
1250}
1251
1252// TODO: Docs
1253#[repr(C)]
1254pub struct passwd_phrase_element {
1255    pub magic: krb5_magic,
1256    pub passwd: *mut krb5_data,
1257    pub phrase: *mut krb5_data,
1258}
1259
1260// TODO: Docs
1261#[repr(C)]
1262pub struct krb5_pwd_data {
1263    pub magic: krb5_magic,
1264    pub sequence_count: c_int,
1265    pub element: *mut *mut passwd_phrase_element,
1266}
1267
1268// TODO: Docs
1269#[repr(C)]
1270pub struct krb5_pa_svr_referral_data {
1271    pub principal: krb5_principal,
1272}
1273
1274// TODO: Docs
1275#[repr(C)]
1276pub struct krb5_pa_server_referral_data {
1277    pub referred_realm: *mut krb5_data,
1278    pub true_principal_name: krb5_principal,
1279    pub requested_principal_name: krb5_principal,
1280    pub referral_valid_until: krb5_timestamp,
1281    pub rep_cksum: krb5_checksum,
1282}
1283
1284// TODO: Docs
1285#[repr(C)]
1286pub struct krb5_pa_pac_req {
1287    pub include_pac: krb5_boolean,
1288}
1289
1290// krb5/krb5.h:2151
1291// TODO: Find the proper datatypes
1292/// Prevent replays with timestamps and replay cache
1293pub const KRB5_AUTH_CONTEXT_DO_TIME: krb5_flags      = 0x00000001;
1294/// Save timestamps for application
1295pub const KRB5_AUTH_CONTEXT_RET_TIME: krb5_flags     = 0x00000002;
1296/// Prevent replays with sequence numbers
1297pub const KRB5_AUTH_CONTEXT_DO_SEQUENCE: krb5_flags  = 0x00000004;
1298/// Save sequence numbers for application
1299pub const KRB5_AUTH_CONTEXT_RET_SEQUENCE: krb5_flags = 0x00000008;
1300pub const KRB5_AUTH_CONTEXT_PERMIT_ALL: krb5_flags   = 0x00000010;
1301pub const KRB5_AUTH_CONTEXT_USE_SUBKEY: krb5_flags   = 0x00000020;
1302
1303// TODO: Docs
1304#[repr(C)]
1305pub struct krb5_replay_data {
1306    pub timestamp: krb5_timestamp,
1307    pub usec: krb5_int32,
1308    pub seq: krb5_ui_4,
1309}
1310
1311/// Generate the local network address
1312pub const KRB5_AUTH_CONTEXT_GENERATE_LOCAL_ADDR: krb5_flags       = 0x00000001;
1313/// Generate the remote network address
1314pub const KRB5_AUTH_CONTEXT_GENERATE_REMOTE_ADDR: krb5_flags      = 0x00000002;
1315/// Generate the local network address and the local port
1316pub const KRB5_AUTH_CONTEXT_GENERATE_LOCAL_FULL_ADDR: krb5_flags  = 0x00000004;
1317/// Generate the remote network address and the remote port
1318pub const KRB5_AUTH_CONTEXT_GENERATE_REMOTE_FULL_ADDR: krb5_flags = 0x00000008;
1319
1320pub type krb5_mk_req_checksum_func = extern "C" fn(krb5_context, krb5_auth_context, *mut c_void, *mut *mut krb5_data) -> krb5_error_code;
1321
1322pub type krb5_cc_cursor = krb5_pointer;
1323
1324pub enum _krb5_ccache {}
1325pub type krb5_ccache = *mut _krb5_ccache;
1326pub enum _krb5_cc_ops {}
1327pub type krb5_cc_ops = *mut _krb5_cc_ops;
1328pub enum _krb5_cccol_cursor {}
1329pub type krb5_cccol_cursor = *mut _krb5_cccol_cursor;
1330
1331/// The requested lifetime must be at least as great as the time specified.
1332pub const KRB5_TC_MATCH_TIMES: krb5_flags        = 0x00000001;
1333/// The is_skey field must match exactly
1334pub const KRB5_TC_MATCH_IS_KEY: krb5_flags       = 0x00000002;
1335/// All the flags set in the match credentials must be set
1336pub const KRB5_TC_MATCH_FLAGS: krb5_flags        = 0x00000004;
1337/// All the time fields must match exactly
1338pub const KRB5_TC_MATCH_TIMES_EXACT: krb5_flags  = 0x00000008;
1339/// All the flags must match exactly
1340pub const KRB5_TC_MATCH_FLAGS_EXACT: krb5_flags  = 0x00000010;
1341/// The authorization data must match
1342pub const KRB5_TC_MATCH_AUTHDATA: krb5_flags     = 0x00000020;
1343/// Only the name portion of the principal name must match
1344pub const KRB5_TC_MATCH_SRV_NAMEONLY: krb5_flags = 0x00000040;
1345/// The second ticket must match
1346pub const KRB5_TC_MATCH_2ND_TKT: krb5_flags      = 0x00000080;
1347/// The encryption key type must match
1348pub const KRB5_TC_MATCH_KTYPE: krb5_flags        = 0x00000100;
1349/// The supported key types must match
1350pub const KRB5_TC_SUPPORTED_KTYPES: krb5_flags   = 0x00000200;
1351
1352/// Open and close the file for each cache operation
1353pub const KRB5_TC_OPENCLOSE: krb5_flags = 0x00000001;
1354pub const KRB5_TC_NOTICKKET: krb5_flags = 0x00000002;
1355
1356#[link(name = "krb5")]
1357extern "C" {
1358    // TODO: Doc
1359    pub fn krb5_cc_get_name(context: krb5_context,
1360                            cache: krb5_ccache) -> *const c_char;
1361    // TODO: Doc
1362    pub fn krb5_cc_get_full_name(context: krb5_context,
1363                                 cache: krb5_ccache,
1364                                 fullname_out: *mut *mut c_char) -> krb5_error_code;
1365    // TODO: Doc
1366    #[cfg(feature = "krb5_deprecated")]
1367    pub fn krb5_cc_gen_new(context: krb5_context,
1368                           cache: *mut krb5_ccache) -> krb5_error_code;
1369    // TODO: Doc
1370    pub fn krb5_cc_initialize(context: krb5_context,
1371                              cache: krb5_ccache,
1372                              principal: krb5_principal) -> krb5_error_code;
1373    // TODO: Doc
1374    pub fn krb5_cc_destroy(context: krb5_context,
1375                           cache: krb5_ccache) -> krb5_error_code;
1376    // TODO: Doc
1377    pub fn krb5_cc_close(context: krb5_context,
1378                         cache: krb5_ccache) -> krb5_error_code;
1379    // TODO: Doc
1380    pub fn krb5_cc_store_cred(context: krb5_context,
1381                              cache: krb5_ccache,
1382                              creds: *mut krb5_creds) -> krb5_error_code;
1383    // TODO: Doc
1384    pub fn krb5_cc_retrieve_cred(context: krb5_context,
1385                                 cache: krb5_ccache,
1386                                 flags: krb5_flags,
1387                                 mcreds: *mut krb5_creds,
1388                                 creds: *mut krb5_creds) -> krb5_error_code;
1389    // TODO: Doc
1390    pub fn krb5_cc_get_principal(context: krb5_context,
1391                                 cache: krb5_ccache,
1392                                 principal: *mut krb5_principal) -> krb5_error_code;
1393    // TODO: Doc
1394    pub fn krb5_cc_start_seq_get(context: krb5_context,
1395                                 cache: krb5_ccache,
1396                                 cursor: *mut krb5_cc_cursor) -> krb5_error_code;
1397    // TODO: Doc
1398    pub fn krb5_cc_next_cred(context: krb5_context,
1399                             cache: krb5_ccache,
1400                             cursor: *mut krb5_cc_cursor,
1401                             creds: *mut krb5_creds) -> krb5_error_code;
1402    // TODO: Doc
1403    pub fn krb5_cc_end_seq_get(context: krb5_context,
1404                               cache: krb5_ccache,
1405                               cursor: *mut krb5_cc_cursor) -> krb5_error_code;
1406    // TODO: Doc
1407    pub fn krb5_cc_remove_cred(context: krb5_context,
1408                               cache: krb5_ccache,
1409                               flags: krb5_flags) -> krb5_error_code;
1410    // TODO: Doc
1411    pub fn krb5_cc_set_flags(context: krb5_context,
1412                             cache: krb5_ccache,
1413                             flags: krb5_flags) -> krb5_error_code;
1414    // TODO: Doc
1415    pub fn krb5_cc_get_flags(context: krb5_context,
1416                             cache: krb5_ccache,
1417                             flags: *mut krb5_flags) -> krb5_error_code;
1418    // TODO: Doc
1419    pub fn krb5_cc_get_type(context: krb5_context,
1420                            cache: krb5_ccache) -> *const c_char;
1421    // TODO: Doc
1422    pub fn krb5_cc_move(context: krb5_context,
1423                        src: krb5_ccache,
1424                        dst: krb5_ccache) -> krb5_error_code;
1425    // TODO: Doc
1426    pub fn krb5_cc_last_change_time(context: krb5_context,
1427                                    ccache: krb5_ccache,
1428                                    change_time: *mut krb5_timestamp) -> krb5_error_code;
1429    // TODO: Doc
1430    pub fn krb5_cc_lock(context: krb5_context,
1431                        ccache: krb5_ccache) -> krb5_error_code;
1432    // TODO: Doc
1433    pub fn krb5_cc_unlock(context: krb5_context,
1434                          ccache: krb5_ccache) -> krb5_error_code;
1435    // TODO: Doc
1436    pub fn krb5_cccol_cursor_new(context: krb5_context,
1437                                 cursor: *mut krb5_cccol_cursor) -> krb5_error_code;
1438    // TODO: Doc
1439    pub fn krb5_cccol_cursor_next(context: krb5_context,
1440                                  cursor: krb5_cccol_cursor,
1441                                  ccache: *mut krb5_ccache) -> krb5_error_code;
1442    // TODO: Doc
1443    pub fn krb5_cccol_cursor_free(context: krb5_context,
1444                                  cursor: *mut krb5_cccol_cursor) -> krb5_error_code;
1445    // TODO: Doc
1446    pub fn krb5_cccol_have_content(context: krb5_context) -> krb5_error_code;
1447    // TODO: Doc
1448    pub fn krb5_cccol_last_change_time(context: krb5_context,
1449                                       change_time: *mut krb5_timestamp) -> krb5_error_code;
1450    // TODO: Doc
1451    pub fn krb5_cccol_lock(context: krb5_context) -> krb5_error_code;
1452    // TODO: Doc
1453    pub fn krb5_cccol_unlock(context: krb5_context) -> krb5_error_code;
1454    // TODO: Doc
1455    pub fn krb5_cc_new_unique(context: krb5_context,
1456                              type_: *const c_char,
1457                              hint: *const c_char,
1458                              id: *mut krb5_ccache) -> krb5_error_code;
1459}
1460
1461pub enum krb5_rc_st {}
1462pub type krb5_rcache = *mut krb5_rc_st;
1463
1464/// Long enough for MAXPATHLEN + some extra
1465pub const MAX_KEYTAB_NAME_LEN: usize = 1100;
1466
1467pub type krb5_kt_cursor = krb5_pointer;
1468
1469// TODO: Docs
1470#[repr(C)]
1471pub struct krb5_keytab_entry {
1472    pub magic: krb5_magic,
1473    pub principal: krb5_principal,
1474    pub timestamp: krb5_timestamp,
1475    pub vno: krb5_kvno,
1476    pub key: krb5_keyblock
1477}
1478
1479pub enum _krb5_kt {}
1480pub type krb5_keytab = *mut _krb5_kt;
1481
1482#[link(name = "krb5")]
1483extern "C" {
1484    // TODO: Doc
1485    pub fn krb5_kt_get_type(context: krb5_context,
1486                            keytab: krb5_keytab) -> *const c_char;
1487    // TODO: Doc
1488    pub fn krb5_kt_get_name(context: krb5_context,
1489                            keytab: krb5_keytab,
1490                            name: *mut c_char,
1491                            namelen: c_uint) -> krb5_error_code;
1492    // TODO: Doc
1493    pub fn krb5_kt_close(context: krb5_context,
1494                         keytab: krb5_keytab) -> krb5_error_code;
1495    // TODO: Doc
1496    pub fn krb5_kt_get_entry(context: krb5_context,
1497                             keytab: krb5_keytab,
1498                             principal: krb5_principal,
1499                             vno: krb5_kvno,
1500                             enctype: krb5_enctype,
1501                             entry: *mut krb5_keytab_entry) -> krb5_error_code;
1502    // TODO: Doc
1503    pub fn krb5_kt_start_seq_get(context: krb5_context,
1504                                 keytab: krb5_keytab,
1505                                 cursor: *mut krb5_kt_cursor) -> krb5_error_code;
1506    // TODO: Doc
1507    pub fn krb5_kt_next_entry(context: krb5_context,
1508                              keytab: krb5_keytab,
1509                              entry: *mut krb5_keytab_entry,
1510                              cursor: *mut krb5_kt_cursor) -> krb5_error_code;
1511    // TODO: Doc
1512    pub fn krb5_kt_end_seq_get(context: krb5_context,
1513                               keytab: krb5_keytab,
1514                               cursor: *mut krb5_kt_cursor) -> krb5_error_code;
1515    // TODO: Doc
1516    pub fn krb5_kt_have_content(context: krb5_context,
1517                                keytab: krb5_keytab) -> krb5_error_code;
1518}
1519
1520/// Use secure context configuration
1521pub const KRB5_INIT_CONTEXT_SECURE: krb5_flags = 0x1;
1522/// Use KDC configuration if available
1523pub const KRB5_INIT_CONTEXT_KDC: krb5_flags = 0x2;
1524
1525#[link(name = "krb5")]
1526extern "C" {
1527    // TODO: Doc
1528    pub fn krb5_init_context(context: *mut krb5_context) -> krb5_error_code;
1529    // TODO: Doc
1530    pub fn krb5_init_secure_context(context: *mut krb5_context) -> krb5_error_code;
1531    // TODO: Doc
1532    pub fn krb5_init_context_profile(profile: *mut _profile_t,
1533                                     flags: krb5_flags,
1534                                     context: krb5_context) -> krb5_error_code;
1535    // TODO: Doc
1536    pub fn krb5_free_context(context: krb5_context);
1537    // TODO: Doc
1538    pub fn krb5_copy_context(ctx: krb5_context,
1539                             nctx_out: krb5_context) -> krb5_error_code;
1540    // TODO: Doc
1541    pub fn krb5_set_default_tgs_enctypes(context: krb5_context,
1542                                         etypes: *const krb5_enctype) -> krb5_error_code;
1543    // TODO: Doc
1544    pub fn krb5_get_permitted_enctypes(context: krb5_context,
1545                                       ktypes: *mut *mut krb5_enctype) -> krb5_error_code;
1546    // TODO: Doc
1547    pub fn krb5_is_thread_safe() -> krb5_boolean;
1548    // TODO: Doc
1549    pub fn krb5_server_decrypt_ticket_keytab(context: krb5_context,
1550                                             kt: krb5_keytab,
1551                                             ticket: *mut krb5_ticket) -> krb5_error_code;
1552    // TODO: Doc
1553    pub fn krb5_free_tgt_creds(context: krb5_context,
1554                               rgts: *mut *mut krb5_creds);
1555
1556}
1557
1558/// Want user-user ticket
1559pub const KRB5_GC_USER_USER: krb5_flags = 1;
1560/// Want cached ticket only
1561pub const KRB5_GC_CACHED: krb5_flags = 2;
1562/// Set canonicalize KDC option
1563pub const KRB5_GC_CANONICALIZE: krb5_flags = 4;
1564/// Do not store in credential cache
1565pub const KRB5_GC_NO_STORE: krb5_flags = 8;
1566/// Acquire forwardable tickets
1567pub const KRB5_GC_FORWARDABLE: krb5_flags = 16;
1568/// Disable transited check
1569pub const KRB5_GC_NO_TRANSIT_CHECK: krb5_flags = 32;
1570/// Constrained delegation
1571pub const KRB5_GC_CONSTRAINED_DELEGATION: krb5_flags = 64;
1572
1573#[link(name = "krb5")]
1574extern "C" {
1575    // TODO: Doc
1576    pub fn krb5_get_credentials(context: krb5_context,
1577                                options: krb5_flags,
1578                                ccache: krb5_ccache,
1579                                in_creds: *mut krb5_creds,
1580                                out_creds: *mut *mut krb5_creds) -> krb5_error_code;
1581    // TODO: Doc
1582    pub fn krb5_get_credentials_validate(context: krb5_context,
1583                                         options: krb5_flags,
1584                                         ccache: krb5_ccache,
1585                                         in_creds: *mut krb5_creds,
1586                                         out_creds: *mut *mut krb5_creds) -> krb5_error_code;
1587    // TODO: Doc
1588    pub fn krb5_get_credentials_renew(context: krb5_context,
1589                                      options: krb5_flags,
1590                                      ccache: krb5_ccache,
1591                                      in_creds: *mut krb5_creds,
1592                                      out_creds: *mut *mut krb5_creds) -> krb5_error_code;
1593    // TODO: Doc
1594    pub fn krb5_mk_req(context: krb5_context,
1595                       auth_context: *mut krb5_auth_context,
1596                       ap_req_options: krb5_flags,
1597                       service: *mut c_char,
1598                       hostname: *mut c_char,
1599                       in_data: *mut krb5_data,
1600                       ccache: krb5_ccache,
1601                       outbuf: *mut krb5_data) -> krb5_error_code;
1602    // TODO: Doc
1603    pub fn krb5_mk_req_extended(context: krb5_context,
1604                                auth_context: *mut krb5_auth_context,
1605                                ap_req_options: krb5_flags,
1606                                in_data: *mut krb5_data,
1607                                in_creds: *mut krb5_creds,
1608                                outbuf: *mut krb5_data) -> krb5_error_code;
1609    // TODO: Doc
1610    pub fn krb5_mk_rep(context: krb5_context,
1611                       auth_context: krb5_auth_context,
1612                       outbuf: *mut krb5_data) -> krb5_error_code;
1613    // TODO: Doc
1614    pub fn krb5_mk_rep_dce(context: krb5_context,
1615                           auth_context: krb5_auth_context,
1616                           outbuf: *mut krb5_data) -> krb5_error_code;
1617    // TODO: Doc
1618    pub fn krb5_rd_rep(context: krb5_context,
1619                       auth_context: krb5_auth_context,
1620                       inbuf: *const krb5_data,
1621                       repl: *mut *mut krb5_ap_rep_enc_part) -> krb5_error_code;
1622    // TODO: Doc
1623    pub fn krb5_rd_rep_dce(context: krb5_context,
1624                           auth_context: krb5_auth_context,
1625                           inbuf: *const krb5_data,
1626                           nonce: *mut krb5_ui_4) -> krb5_error_code;
1627    // TODO: Doc
1628    pub fn krb5_mk_error(context: krb5_context,
1629                         dec_err: *const krb5_error,
1630                         enc_err: *mut krb5_data) -> krb5_error_code;
1631    // TODO: Doc
1632    pub fn krb5_rd_error(context: krb5_context,
1633                         enc_errbuf: *const krb5_data,
1634                         dec_error: *mut *mut krb5_error) -> krb5_error_code;
1635    // TODO: Doc
1636    pub fn krb5_rd_safe(context: krb5_context,
1637                        auth_context: krb5_auth_context,
1638                        inbuf: *const krb5_data,
1639                        outbuf: *mut krb5_data,
1640                        outdata: *mut krb5_replay_data) -> krb5_error_code;
1641    // TODO: Doc
1642    pub fn krb5_rd_priv(context: krb5_context,
1643                        auth_context: krb5_auth_context,
1644                        inbuf: *const krb5_data,
1645                        outbuf: *mut krb5_data,
1646                        outdata: *mut krb5_replay_data) -> krb5_error_code;
1647    // TODO: Doc
1648    pub fn krb5_parse_name(context: krb5_context,
1649                           name: *const c_char,
1650                           principal_out: *mut krb5_principal) -> krb5_error_code;
1651}
1652
1653/// Error if realm is present
1654pub const KRB5_PRINCIPAL_PARSE_NO_REALM: krb5_flags = 0x1;
1655/// Error if realm is not present
1656pub const KRB5_PRINCIPAL_PARSE_REQUIRE_REALM: krb5_flags = 0x2;
1657/// Create singe-component enterprise principle
1658pub const KRB5_PRINCIPAL_PARSE_ENTERPRSIE: krb5_flags = 0x4;
1659/// Ignore realm if present
1660pub const KRB5_PRINCIPAL_PARSE_IGNORE_REALM: krb5_flags = 0x8;
1661
1662#[link(name = "krb5")]
1663extern "C" {
1664    // TODO: Doc
1665    pub fn krb5_parse_name_flags(context: krb5_context,
1666                                 name: *const c_char,
1667                                 flags: krb5_flags,
1668                                 principal_out: *mut krb5_principal) -> krb5_error_code;
1669    // TODO: Doc
1670    pub fn krb5_unparse_name(context: krb5_context,
1671                             principal: krb5_const_principal,
1672                             name: *mut *mut c_char) -> krb5_error_code;
1673    // TODO: Doc
1674    pub fn krb5_unparse_name_ext(context: krb5_context,
1675                                 principal: krb5_const_principal,
1676                                 name: *mut *mut c_char,
1677                                 size: *mut c_uint) -> krb5_error_code;
1678}
1679
1680/// Omit realm if it is the local realm
1681pub const KRB5_PRINCIPAL_UNPARSE_SHORT: krb5_flags = 0x1;
1682/// Omit realm always
1683pub const KRB5_PRINCIPAL_UNPARSE_NO_REALM: krb5_flags = 0x2;
1684/// Don't escape special characters
1685pub const KRB5_PRINCIPAL_UNPARSE_DISPLAY: krb5_flags = 0x4;
1686
1687#[link(name = "krb5")]
1688extern "C" {
1689    // TODO: Doc
1690    pub fn krb5_unparse_name_flags(context: krb5_context,
1691                                   principal: krb5_const_principal,
1692                                   flags: krb5_flags,
1693                                   name: *mut *mut c_char) -> krb5_error_code;
1694    // TODO: Doc
1695    pub fn krb5_unparse_name_flags_ext(context: krb5_context,
1696                                       principal: krb5_const_principal,
1697                                       flags: krb5_flags,
1698                                       name: *mut *mut c_char,
1699                                       size: c_uint) -> krb5_error_code;
1700    // TODO: Doc
1701    pub fn krb5_set_principal_realm(context: krb5_context,
1702                                    principal: krb5_principal,
1703                                    realm: *const c_char) -> krb5_error_code;
1704    // TODO: Doc
1705    pub fn krb5_address_search(context: krb5_context,
1706                               addr: *const krb5_address,
1707                               addrlist: *mut krb5_address) -> krb5_boolean;
1708    // TODO: Doc
1709    pub fn krb5_address_compare(context: krb5_context,
1710                                addr1: *const krb5_address,
1711                                addr2: *const krb5_address) -> krb5_boolean;
1712    // TODO: Doc
1713    pub fn krb5_address_order(context: krb5_context,
1714                              addr1: *const krb5_address,
1715                              addr2: *const krb5_address) -> c_int;
1716    // TODO: Doc
1717    pub fn krb5_realm_compare(context: krb5_context,
1718                              princ1: krb5_const_principal,
1719                              princ2: krb5_const_principal) -> krb5_boolean;
1720    // TODO: Doc
1721    pub fn krb5_principal_compare(context: krb5_context,
1722                                  princ1: krb5_const_principal,
1723                                  princ2: krb5_const_principal) -> krb5_boolean;
1724    // TODO: Doc
1725    pub fn krb5_principal_compare_any_realm(context: krb5_context,
1726                                            princ1: krb5_const_principal,
1727                                            princ2: krb5_const_principal) -> krb5_boolean;
1728}
1729
1730// TODO: Doc
1731pub const KRB5_PRINCIPAL_COMPARE_INGORE_REALM: krb5_flags = 1;
1732// TODO: Doc
1733pub const KRB5_PRINCIPAL_COMPARE_ENTERPRSIE: krb5_flags = 2;
1734// TODO: Doc
1735pub const KRB5_PRINCIPAL_COMPARE_CASEFOLD: krb5_flags = 4;
1736// TODO: Doc
1737pub const KRB5_PRINCIPAL_COMPARE_UTF8: krb5_flags = 8;
1738
1739#[link(name = "krb5")]
1740extern "C" {
1741    // TODO: Doc
1742    pub fn krb5_principal_compare_flags(context: krb5_context,
1743                                        princ1: krb5_const_principal,
1744                                        princ2: krb5_const_principal,
1745                                        flags: krb5_flags) -> krb5_boolean;
1746    // TODO: Doc
1747    pub fn krb5_init_keyblock(context: krb5_context,
1748                              enctype: krb5_enctype,
1749                              length: usize,
1750                              out: *mut *mut krb5_keyblock) -> krb5_error_code;
1751    // TODO: Doc
1752    pub fn krb5_copy_keyblock(context: krb5_context,
1753                              from: *const krb5_keyblock,
1754                              to: *mut *mut krb5_keyblock) -> krb5_error_code;
1755    // TODO: Doc
1756    pub fn krb5_copy_keyblock_contents(context: krb5_context,
1757                                       from: *const krb5_keyblock,
1758                                       to: *mut krb5_keyblock) -> krb5_error_code;
1759    // TODO: Doc
1760    pub fn krb5_copy_creds(context: krb5_context,
1761                           incred: *const krb5_creds,
1762                           outcred: *mut *mut krb5_creds) -> krb5_error_code;
1763    // TODO: Doc
1764    pub fn krb5_copy_data(context: krb5_context,
1765                          indata: *const krb5_data,
1766                          outdata: *mut *mut krb5_data) -> krb5_error_code;
1767    // TODO: Doc
1768    pub fn krb5_copy_principal(context: krb5_context,
1769                               inprinc: krb5_const_principal,
1770                               outprinc: *mut krb5_principal) -> krb5_error_code;
1771    // TODO: Doc
1772    pub fn krb5_copy_addresses(context: krb5_context,
1773                               inaddr: *mut *const krb5_address,
1774                               outaddr: *mut *mut krb5_address) -> krb5_error_code;
1775    // TODO: Doc
1776    pub fn krb5_copy_ticket(context: krb5_context,
1777                            from: *const krb5_ticket,
1778                            pto: *mut *mut krb5_ticket) -> krb5_error_code;
1779    // TODO: Doc
1780    pub fn krb5_copy_authdata(context: krb5_context,
1781                              in_authdat: *mut *const krb5_authdata,
1782                              out: *mut *mut krb5_authdata) -> krb5_error_code;
1783    // TODO: Doc
1784    pub fn krb5_find_authdata(context: krb5_context,
1785                              ticket_authdata: *mut *const krb5_authdata,
1786                              ap_req_authdata: *mut *const krb5_authdata,
1787                              ad_type: krb5_authdatatype,
1788                              results: *mut *mut *mut krb5_authdata) -> krb5_error_code;
1789    // TODO: Doc
1790    pub fn krb5_merge_authdata(context: krb5_context,
1791                               inauthdat1: *mut *const krb5_authdata,
1792                               inauthdat2: *mut *const krb5_authdata,
1793                               outauthdat: *mut *mut *mut krb5_authdata) -> krb5_error_code;
1794    // TODO: Doc
1795    pub fn krb5_copy_authenticator(context: krb5_context,
1796                                   authfrom: *const krb5_authenticator,
1797                                   authto: *mut *mut krb5_authenticator) -> krb5_error_code;
1798    // TODO: Doc
1799    pub fn krb5_copy_checksum(context: krb5_context,
1800                              ckfrom: *const krb5_checksum,
1801                              ckto: *mut *mut krb5_checksum) -> krb5_error_code;
1802    // TODO: Doc
1803    pub fn krb5_get_server_rcache(context: krb5_context,
1804                                  piece: *const krb5_data,
1805                                  rcptr: *mut krb5_rcache) -> krb5_error_code;
1806    // TODO: Doc
1807    pub fn krb5_build_principal_ext(context: krb5_context,
1808                                    princ: *mut krb5_principal,
1809                                    rlen: c_uint,
1810                                    realm: *const c_char, ...) -> krb5_error_code;
1811    // TODO: Doc
1812    pub fn krb5_build_principal(context: krb5_context,
1813                                princ: *mut krb5_principal,
1814                                rlen: c_uint,
1815                                real: *const c_char, ...) -> krb5_error_code;
1816
1817    // #[cfg(feature = "krb5_deprecated")]
1818    // TODO: Doc
1819    // TODO:  krb5_build_principal_va
1820
1821    // TODO: Doc
1822    // TODO: pub fn krb5_build_principal_alloc_va
1823
1824    // TODO: Doc
1825    pub fn krb5_425_conv_principal(context: krb5_context,
1826                                   name: *const c_char,
1827                                   instance: *const c_char,
1828                                   realm: *const c_char,
1829                                   princ: *mut krb5_principal) -> krb5_error_code;
1830    // TODO: Doc
1831    pub fn krb5_524_conv_principal(context: krb5_context,
1832                                   princ: krb5_const_principal,
1833                                   name: *mut c_char,
1834                                   inst: *mut c_char,
1835                                   realm: *mut c_char) -> krb5_error_code;
1836}
1837
1838#[deprecated]
1839pub enum credentials {}
1840
1841#[link(name = "krb5")]
1842extern "C" {
1843    // TODO: Doc
1844    #[allow(deprecated)]
1845    pub fn krb5_524_convert_creds(context: krb5_context,
1846                                  v5creds: *mut krb5_creds,
1847                                  v4creds: *mut credentials) -> c_int;
1848
1849    // TODO: krb524_init_ets
1850
1851    // TODO: Doc
1852    pub fn krb5_kt_resolve(context: krb5_context,
1853                           name: *const c_char,
1854                           ktid: *mut krb5_keytab) -> krb5_error_code;
1855    // TODO: Doc
1856    pub fn krb5_kt_dup(context: krb5_context,
1857                       in_: krb5_keytab,
1858                       out: *mut krb5_keytab) -> krb5_error_code;
1859    // TODO: Doc
1860    pub fn krb5_kt_default_name(context: krb5_context,
1861                                name: *mut c_char,
1862                                name_size: c_int) -> krb5_error_code;
1863    // TODO: Doc
1864    pub fn krb5_kt_default(context: krb5_context,
1865                           id: *mut krb5_keytab) -> krb5_error_code;
1866    // TODO: Doc
1867    pub fn krb5_kt_client_default(context: krb5_context,
1868                                  keytab_out: *mut krb5_keytab) -> krb5_error_code;
1869    // TODO: Doc
1870    pub fn krb5_free_keytab_entry_contents(context: krb5_context,
1871                                           entry: *mut krb5_keytab_entry) -> krb5_error_code;
1872    // TODO: Doc
1873    pub fn krb5_kt_free_entry(context: krb5_context,
1874                              entry: *mut krb5_keytab_entry) -> krb5_error_code;
1875    // TODO: Doc
1876    pub fn krb5_kt_remove_entry(context: krb5_context,
1877                                id: krb5_keytab,
1878                                entry: *mut krb5_keytab_entry) -> krb5_error_code;
1879    // TODO: Doc
1880    pub fn krb5_kt_add_entry(context: krb5_context,
1881                             id: krb5_keytab,
1882                             entry: *mut krb5_keytab_entry) -> krb5_error_code;
1883    // TODO: Doc
1884    pub fn krb5_principal2salt(context: krb5_context,
1885                               pr: krb5_const_principal,
1886                               ret: *mut krb5_data) -> krb5_error_code;
1887    // TODO: Doc
1888    pub fn krb5_cc_resolve(context: krb5_context,
1889                           name: *const c_char,
1890                           cache: *mut krb5_ccache) -> krb5_error_code;
1891    // TODO: Doc
1892    pub fn krb5_cc_dup(context: krb5_context,
1893                       in_: krb5_ccache,
1894                       out: *mut krb5_ccache) -> krb5_error_code;
1895    // TODO: Doc
1896    pub fn krb5_cc_default_name(context: krb5_context) -> *const c_char;
1897    // TODO: Doc
1898    pub fn krb5_cc_set_default_name(context: krb5_context,
1899                                    name: *const c_char) -> krb5_error_code;
1900    // TODO: Doc
1901    pub fn krb5_cc_default(context: krb5_context,
1902                           ccache: *mut krb5_ccache) -> krb5_error_code;
1903    // TODO: Doc
1904    pub fn krb5_cc_copy_creds(context: krb5_context,
1905                              incc: krb5_ccache,
1906                              outcc: krb5_ccache) -> krb5_error_code;
1907    // TODO: Doc
1908    pub fn krb5_cc_get_config(context: krb5_context,
1909                              id: krb5_ccache,
1910                              principal: krb5_const_principal,
1911                              key: *const c_char,
1912                              data: *mut krb5_data) -> krb5_error_code;
1913    // TODO: Doc
1914    pub fn krb5_cc_set_config(context: krb5_context,
1915                              id: krb5_ccache,
1916                              principal: krb5_const_principal,
1917                              key: *const c_char,
1918                              data: *mut krb5_data) -> krb5_error_code;
1919    // TODO: Doc
1920    pub fn krb5_is_config_principal(context: krb5_context,
1921                                    principal: krb5_const_principal) -> krb5_boolean;
1922    // TODO: Doc
1923    pub fn krb5_cc_switch(context: krb5_context,
1924                          cache: krb5_ccache) -> krb5_error_code;
1925    // TODO: Doc
1926    pub fn krb5_cc_support_switch(context: krb5_context,
1927                                  type_: *const c_char) -> krb5_boolean;
1928    // TODO: Doc
1929    pub fn krb5_cc_cache_match(context: krb5_context,
1930                               client: krb5_principal,
1931                               cache_out: *mut krb5_ccache) -> krb5_error_code;
1932    // TODO: Doc
1933    pub fn krb5_cc_select(context: krb5_context,
1934                          server: krb5_principal,
1935                          cache_out: *mut krb5_ccache,
1936                          princ_out: *mut krb5_principal) -> krb5_error_code;
1937    // TODO: Doc
1938    pub fn krb5_free_principal(context: krb5_context,
1939                               val: krb5_principal);
1940    // TODO: Doc
1941    pub fn krb5_free_authenticator(context: krb5_context,
1942                                   val: *mut krb5_authenticator);
1943    // TODO: Doc
1944    pub fn krb5_free_addresses(context: krb5_context,
1945                               val: *mut *mut krb5_address);
1946    // TODO: Doc
1947    pub fn krb5_free_authdata(context: krb5_context,
1948                              val: *mut *mut krb5_authdata);
1949    // TODO: Doc
1950    pub fn krb5_free_ticket(context: krb5_context,
1951                            val: *mut krb5_ticket);
1952    // TODO: Doc
1953    pub fn krb5_free_error(context: krb5_context,
1954                           val: *mut krb5_error);
1955    // TODO: Doc
1956    pub fn krb5_free_creds(context: krb5_context,
1957                           val: *mut krb5_creds);
1958    // TODO: Doc
1959    pub fn krb5_free_cred_contents(context: krb5_context,
1960                                   val: *mut krb5_creds);
1961    // TODO: Doc
1962    pub fn krb5_free_checksum(context: krb5_context,
1963                              val: *mut krb5_checksum);
1964    // TODO: Doc
1965    pub fn krb5_free_checksum_contents(context: krb5_context,
1966                                       val: *mut krb5_checksum);
1967    // TODO: Doc
1968    pub fn krb5_free_keyblock(context: krb5_context,
1969                              val: *mut krb5_keyblock);
1970    // TODO: Doc
1971    pub fn krb5_free_keyblock_contents(context: krb5_context,
1972                                       val: *mut krb5_keyblock);
1973    // TODO: Doc
1974    pub fn krb5_free_ap_rep_enc_part(context: krb5_context,
1975                                     val: *mut krb5_ap_rep_enc_part);
1976    // TODO: Doc
1977    pub fn krb5_free_data(context: krb5_context,
1978                          val: *mut krb5_data);
1979    // TODO: Doc
1980    pub fn krb5_free_octet_data(context: krb5_context,
1981                                val: *mut krb5_octet_data);
1982    // TODO: Doc
1983    pub fn krb5_free_data_contents(context: krb5_context,
1984                                   val: *mut krb5_data);
1985    // TODO: Doc
1986    pub fn krb5_free_unparsed_name(context: krb5_context,
1987                                   val: *mut c_char);
1988    // TODO: Doc
1989    pub fn krb5_free_string(context: krb5_context,
1990                            val: *mut c_char);
1991    // TODO: Doc
1992    pub fn krb5_free_enctypes(context: krb5_context,
1993                              val: *mut krb5_enctype);
1994    // TODO: Doc
1995    pub fn krb5_free_cksumtypes(context: krb5_context,
1996                                val: *mut krb5_cksumtype);
1997    // TODO: Doc
1998    pub fn krb5_us_timeofday(context: krb5_context,
1999                             seconds: *mut krb5_timestamp,
2000                             microseconds: *mut krb5_int32) -> krb5_error_code;
2001    // TODO: Doc
2002    pub fn krb5_timeofday(context: krb5_context,
2003                          timeret: *mut krb5_timestamp) -> krb5_error_code;
2004    // TODO: Doc
2005    pub fn krb5_check_clockskew(context: krb5_context,
2006                                date: krb5_timestamp) -> krb5_error_code;
2007    // TODO: Doc
2008    pub fn krb5_os_localaddr(context: krb5_context,
2009                             addr: *mut *mut *mut krb5_address) -> krb5_error_code;
2010    // TODO: Doc
2011    pub fn krb5_get_default_realm(context: krb5_context,
2012                                  lrealm: *mut *mut c_char) -> krb5_error_code;
2013    // TODO: Doc
2014    pub fn krb5_set_default_realm(context: krb5_context,
2015                                  lrealm: *const c_char) -> krb5_error_code;
2016    // TODO: Doc
2017    pub fn krb5_free_default_realm(context: krb5_context,
2018                                   lrealm: *mut c_char);
2019    // TODO: Doc
2020    pub fn krb5_sname_to_principal(context: krb5_context,
2021                                   hostname: *const c_char,
2022                                   sname: *const c_char,
2023                                   type_: krb5_int32,
2024                                   ret_princ: *mut krb5_principal) -> krb5_error_code;
2025    // TODO: Doc
2026    pub fn krb5_sname_match(context: krb5_context,
2027                            matching: krb5_const_principal,
2028                            princ: krb5_const_principal) -> krb5_boolean;
2029    // TODO: Doc
2030    pub fn krb5_change_password(context: krb5_context,
2031                                creds: *mut krb5_creds,
2032                                newpw: *mut c_char,
2033                                result_code: *mut c_int,
2034                                result_code_string: *mut krb5_data,
2035                                result_string: *mut krb5_data) -> krb5_error_code;
2036    // TODO: Doc
2037    pub fn krb5_set_password(context: krb5_context,
2038                             creds: *mut krb5_creds,
2039                             newpw: *mut c_char,
2040                             change_password_for: krb5_principal,
2041                             result_code: *mut c_int,
2042                             result_code_string: *mut krb5_data,
2043                             result_string: *mut krb5_data) -> krb5_error_code;
2044    // TODO: Doc
2045    pub fn krb5_set_password_useing_ccache(context: krb5_context,
2046                                           ccache: krb5_ccache,
2047                                           newpw: *mut c_char,
2048                                           change_password_for: krb5_principal,
2049                                           result_code: *mut c_int,
2050                                           result_code_string: *mut krb5_data,
2051                                           result_string: *mut krb5_data) -> krb5_error_code;
2052    // TODO: Doc
2053    pub fn krb5_chpw_message(context: krb5_context,
2054                             server_string: *const krb5_data,
2055                             message_out: *mut *mut c_char) -> krb5_error_code;
2056    // TODO: Doc
2057    pub fn krb5_get_profile(context: krb5_context,
2058                            profile: *mut *mut _profile_t) -> krb5_error_code;
2059
2060    // TODO: Doc
2061    #[cfg(feature = "krb5_deprecated")]
2062    #[deprectated]
2063    pub fn krb5_get_in_tkt_with_password(context: krb5_context,
2064                                         options: krb5_flags,
2065                                         addrs: *mut *const krb5_address,
2066                                         ktypes: *mut krb5_enctype,
2067                                         pre_auth_types: *mut krb5_preauthtype,
2068                                         password: *const c_char,
2069                                         ccache: krb5_ccache,
2070                                         creds: *mut krb5_creds,
2071                                         ret_as_reply: *mut *mut krb5_kdc_rep) -> krb5_error_code;
2072    // TODO: Doc
2073    #[cfg(feature = "krb5_deprecated")]
2074    #[deprectated]
2075    pub fn krb5_get_in_tkt_with_skey(context: krb5_context,
2076                                     options: krb5_flags,
2077                                     addrs: *mut *const krb5_address,
2078                                     ktypes: *mut krb5_enctype,
2079                                     pre_auth_types: *mut krb5_preauthtype,
2080                                     password: *const c_char,
2081                                     ccache: krb5_ccache,
2082                                     creds: *mut krb5_creds,
2083                                     ret_as_reply: *mut *mut krb5_kdc_rep) -> krb5_error_code;
2084    // krb5/krb5.h:5133
2085    // TODO: Doc
2086    #[cfg(feature = "krb5_deprecated")]
2087    #[deprectated]
2088    pub fn krb5_get_in_tkt_with_keytab(context: krb5_context,
2089                                       options: krb5_flags,
2090                                       addrs: *mut *const krb5_address,
2091                                       ktypes: *mut krb5_enctype,
2092                                       pre_auth_types: *mut krb5_preauthtype,
2093                                       arg_keytab: krb5_keytab,
2094                                       ccache: krb5_ccache,
2095                                       creds: *mut krb5_creds,
2096                                       ret_as_reply: *mut *mut krb5_kdc_rep) -> krb5_error_code;
2097    // TODO: Doc
2098    pub fn krb5_rd_req(context: krb5_context,
2099                       auht_context: *mut krb5_auth_context,
2100                       inbuf: *const krb5_data,
2101                       server: krb5_const_principal,
2102                       keytab: krb5_keytab,
2103                       ap_req_options: *mut krb5_flags,
2104                       ticket: *mut *mut krb5_ticket) -> krb5_error_code;
2105    // TODO: Doc
2106    pub fn krb5_kt_read_service_key(context: krb5_context,
2107                                    keyprocarg: krb5_pointer,
2108                                    principal: krb5_principal,
2109                                    vno: krb5_kvno,
2110                                    enctype: krb5_enctype,
2111                                    key: *mut *mut krb5_keyblock) -> krb5_error_code;
2112    // TODO: Doc
2113    pub fn krb5_mk_safe(context: krb5_context,
2114                        auth_context: krb5_auth_context,
2115                        userdata: *mut krb5_data,
2116                        outbuf: *mut krb5_data,
2117                        outdat: krb5_replay_data) -> krb5_error_code;
2118    // TODO: Doc
2119    pub fn krb5_mk_priv(context: krb5_context,
2120                        auth_context: krb5_auth_context,
2121                        userdata: *const krb5_data,
2122                        outbuf: *mut krb5_data,
2123                        outdata: *mut krb5_replay_data) -> krb5_error_code;
2124    // TODO: Doc
2125    pub fn krb5_sendauth(context: krb5_context,
2126                         auth_context: *mut krb5_auth_context,
2127                         fd: krb5_pointer,
2128                         aapl_version: *mut c_char,
2129                         client: krb5_principal,
2130                         server: krb5_principal,
2131                         ap_req_options: krb5_flags,
2132                         in_data: *mut krb5_data,
2133                         in_creds: *mut krb5_creds,
2134                         ccache: krb5_ccache,
2135                         error: *mut *mut krb5_error,
2136                         rep_result: *mut *mut krb5_ap_rep_enc_part,
2137                         out_creds: *mut *mut krb5_creds) -> krb5_error_code;
2138    // TODO: Doc
2139    pub fn krb5_recvauth(context: krb5_context,
2140                         auth_context: krb5_auth_context,
2141                         fd: krb5_pointer,
2142                         appl_version: *mut c_char,
2143                         server: krb5_principal,
2144                         flags: krb5_int32,
2145                         keytab: krb5_keytab,
2146                         ticket: *mut *mut krb5_ticket) -> krb5_error_code;
2147    // TODO: Doc
2148    pub fn krb5_recvauth_version(context: krb5_context,
2149                                 auth_context: *mut krb5_auth_context,
2150                                 fd: krb5_pointer,
2151                                 server: krb5_principal,
2152                                 flags: krb5_int32,
2153                                 keytab: krb5_keytab,
2154                                 ticket: *mut *mut krb5_ticket,
2155                                 version: *mut krb5_data) -> krb5_error_code;
2156    // TODO: Doc
2157    pub fn krb5_mk_ncred(context: krb5_context,
2158                         auth_context: krb5_auth_context,
2159                         ppcreds: *mut *mut krb5_creds,
2160                         ppdata: *mut *mut krb5_data,
2161                         outdata: *mut krb5_replay_data) -> krb5_error_code;
2162    // TODO: Doc
2163    pub fn krb5_mk_1cred(context: krb5_context,
2164                         auth_context: krb5_auth_context,
2165                         pcreds: *mut krb5_creds,
2166                         ppdata: *mut *mut krb5_data,
2167                         outdata: *mut krb5_replay_data) -> krb5_error_code;
2168    // TODO: Doc
2169    pub fn krb5_rd_cred(context: krb5_context,
2170                        auth_context: krb5_auth_context,
2171                        pcreddata: *mut krb5_data,
2172                        pppcreds: *mut *mut *mut krb5_creds,
2173                        outdata: *mut krb5_replay_data) -> krb5_error_code;
2174    // TODO: Doc
2175    pub fn krb5_fwd_tgt_creds(context: krb5_context,
2176                              auth_context: krb5_auth_context,
2177                              rhost: *mut c_char,
2178                              client: krb5_principal,
2179                              server: krb5_principal,
2180                              cc: krb5_ccache,
2181                              forwardable: c_int,
2182                              outbuf: *mut krb5_data) -> krb5_error_code;
2183    // TODO: Doc
2184    pub fn krb5_auth_con_init(context: krb5_context,
2185                              auth_context: *mut krb5_auth_context) -> krb5_error_code;
2186    // TODO: Doc
2187    pub fn krb5_auth_con_free(context: krb5_context,
2188                              auth_context: krb5_auth_context) -> krb5_error_code;
2189    // TODO: Doc
2190    pub fn krb5_auth_con_setflags(context: krb5_context,
2191                                  auth_context: krb5_auth_context,
2192                                  flags: krb5_int32) -> krb5_error_code;
2193    // TODO: Doc
2194    pub fn krb5_auth_con_getflags(context: krb5_context,
2195                                  auth_context: krb5_auth_context,
2196                                  flags: *mut krb5_int32) -> krb5_error_code;
2197    // TODO: Doc
2198    pub fn krb5_auth_con_set_checksum_func(context: krb5_context,
2199                                           auth_context: krb5_auth_context,
2200                                           func: Option<krb5_mk_req_checksum_func>,
2201                                           data: *mut c_void) -> krb5_error_code;
2202    // TODO: Doc
2203    pub fn krb5_auth_con_get_checksum_func(context: krb5_context,
2204                                           auth_context: krb5_auth_context,
2205                                           func: *mut Option<krb5_mk_req_checksum_func>,
2206                                           data: *mut *mut c_void) -> krb5_error_code;
2207    // TODO: Doc
2208    pub fn krb5_auth_con_setaddrs(context: krb5_context,
2209                                  auth_context: krb5_auth_context,
2210                                  local_addr: *mut krb5_address,
2211                                  remote_addr: *mut krb5_address) -> krb5_error_code;
2212    // TODO: Doc
2213    pub fn krb5_auth_con_getaddrs(context: krb5_context,
2214                                  auth_context: krb5_auth_context,
2215                                  local_addr: *mut *mut krb5_address,
2216                                  remote_addr: *mut *mut krb5_address) -> krb5_error_code;
2217    // TODO: Doc
2218    pub fn krb5_auth_con_setports(context: krb5_context,
2219                                  auth_context: krb5_auth_context,
2220                                  local_port: *mut krb5_address,
2221                                  remote_port: *mut krb5_address) -> krb5_error_code;
2222    // TODO: Doc
2223    pub fn krb5_auth_con_setuseruserkey(context: krb5_context,
2224                                        auth_context: krb5_auth_context,
2225                                        keyblock: *mut krb5_keyblock) -> krb5_error_code;
2226    // TODO: Doc
2227    pub fn krb5_auth_con_getkey(context: krb5_context,
2228                                auth_context: krb5_auth_context,
2229                                keyblock: *mut *mut krb5_keyblock) -> krb5_error_code;
2230    // TODO: Doc
2231    pub fn krb5_auth_con_getkey_k(context: krb5_context,
2232                                  auth_context: krb5_auth_context,
2233                                  key: *mut krb5_key) -> krb5_error_code;
2234    // TODO: Doc
2235    pub fn krb5_auth_con_getsendsubkey(ctx: krb5_context,
2236                                       ac: krb5_auth_context,
2237                                       keyblock: *mut *mut krb5_keyblock) -> krb5_error_code;
2238    // TODO: Doc
2239    pub fn krb5_auth_con_getsendsubkey_k(ctx: krb5_context,
2240                                         ac: krb5_auth_context,
2241                                         key: *mut krb5_key) -> krb5_error_code;
2242    // TODO: Doc
2243    pub fn krb5_auth_con_getrecvsubkey(ctx: krb5_context,
2244                                       ac: krb5_auth_context,
2245                                       keyblock: *mut *mut krb5_keyblock) -> krb5_error_code;
2246    // TODO: Doc
2247    pub fn krb5_auth_con_getrecvsubkey_k(ctx: krb5_context,
2248                                         ac: krb5_auth_context,
2249                                         key: *mut krb5_key) -> krb5_error_code;
2250    // TODO: Doc
2251    pub fn krb5_auth_con_setsendsubkey(ctx: krb5_context,
2252                                       ac: krb5_auth_context,
2253                                       keyblock: *mut krb5_keyblock) -> krb5_error_code;
2254    // TODO: Doc
2255    pub fn krb5_auth_con_setsendsubkey_k(ctx: krb5_context,
2256                                         ac: krb5_auth_context,
2257                                         key: krb5_key) -> krb5_error_code;
2258    // TODO: Doc
2259    pub fn krb5_auth_con_setrecvsubkey(ctx: krb5_context,
2260                                       ac: krb5_auth_context,
2261                                       keyblock: *mut krb5_keyblock) -> krb5_error_code;
2262    // TODO: Doc
2263    pub fn krb5_auth_con_setrecvsubkey_k(ctx: krb5_context,
2264                                         ac: krb5_auth_context,
2265                                         key: krb5_key) -> krb5_error_code;
2266    // TODO: Doc
2267    #[cfg(feature = "krb5_deprecated")]
2268    #[deprecated]
2269    pub fn krb5_auth_con_getlocalsubkey(context: krb5_context,
2270                                        auth_context: krb5_auth_context,
2271                                        keyblock: *mut *mut krb5_keyblock) -> krb5_error_code;
2272    // TODO: Doc
2273    #[cfg(feature = "krb5_deprecated")]
2274    #[deprecated]
2275    pub fn krb5_auth_con_getremotesubkey(context: krb5_context,
2276                                         auth_context: krb5_auth_context,
2277                                         keyblock: *mut *mut krb5_keyblock) -> krb5_error_code;
2278    // TODO: Doc
2279    pub fn krb5_auth_con_getlocalseqnumber(context: krb5_context,
2280                                           auth_context: krb5_auth_context,
2281                                           seqnumber: *mut krb5_int32) -> krb5_error_code;
2282    // TODO: Doc
2283    pub fn krb5_auth_con_getremoteseqnumber(context: krb5_context,
2284                                            auth_context: krb5_auth_context,
2285                                            seqnumber: *mut krb5_int32) -> krb5_error_code;
2286    // TODO: Doc
2287    #[cfg(feature = "krb5_deprecated")]
2288    #[deprecated]
2289    pub fn krb5_auth_con_initivector(context: krb5_context,
2290                                     auth_context: krb5_auth_context) -> krb5_error_code;
2291    // TODO: Doc
2292    pub fn krb5_auth_con_setrcache(context: krb5_context,
2293                                   auth_context: krb5_auth_context,
2294                                   rcache: krb5_rcache) -> krb5_error_code;
2295    // TODO: Doc
2296    pub fn krb5_auth_con_getrcache(context: krb5_context,
2297                                   auth_context: krb5_auth_context,
2298                                   rcache: *mut krb5_rcache) -> krb5_error_code;
2299    // TODO: Doc
2300    pub fn krb5_auth_con_getauthenticator(context: krb5_context,
2301                                          auth_context: krb5_auth_context,
2302                                          authenticator: *mut *mut krb5_authenticator) -> krb5_error_code;
2303    // TODO: Doc
2304    pub fn krb5_auth_con_set_req_cksumtype(context: krb5_context,
2305                                           auth_context: krb5_auth_context,
2306                                           cksumtype: krb5_cksumtype) -> krb5_error_code;
2307}
2308
2309pub const KRB5_REALM_BRANCH_CHAR: c_char = b'.' as c_char;
2310
2311#[link(name = "krb5")]
2312extern "C" {
2313    // TODO: Doc
2314    pub fn krb5_read_password(context: krb5_context,
2315                              prompt: *const c_char,
2316                              prompt2: *const c_char,
2317                              return_pwd: *mut c_char,
2318                              size_return: *mut c_uint) -> krb5_error_code;
2319    // TODO: Doc
2320    pub fn krb5_aname_to_localname(context: krb5_context,
2321                                   aname: krb5_const_principal,
2322                                   lnsize_in: c_int,
2323                                   lname: *mut c_char) -> krb5_error_code;
2324    // TODO: Doc
2325    pub fn krb5_get_host_realm(context: krb5_error_code,
2326                               host: *const c_char,
2327                               realmsp: *mut *mut *mut c_char) -> krb5_error_code;
2328    // TODO: Doc
2329    pub fn krb5_get_fallback_host_realm(context: krb5_context,
2330                                        hdata: *mut krb5_data,
2331                                        realmsp: *mut *mut *mut c_char) -> krb5_error_code;
2332    // TODO: Doc
2333    pub fn krb5_free_host_realm(context: krb5_context,
2334                                realmlist: *mut *const c_char) -> krb5_error_code;
2335    // TODO: Doc
2336    pub fn krb5_kuserok(context: krb5_error_code,
2337                        principal: krb5_principal,
2338                        luser: *const c_char) -> krb5_boolean;
2339    // TODO: Doc
2340    pub fn krb5_auth_con_getnaddrs(context: krb5_context,
2341                                   auth_context: krb5_auth_context,
2342                                   infd: c_int,
2343                                   flags: c_int) -> krb5_error_code;
2344    // TODO: Doc
2345    pub fn krb5_set_real_time(context: krb5_context,
2346                              seconds: krb5_timestamp,
2347                              microseconds: krb5_int32) -> krb5_error_code;
2348    // TODO: Doc
2349    pub fn krb5_get_time_offsets(context: krb5_context,
2350                                 seconds: *mut krb5_timestamp,
2351                                 microseconds: *mut krb5_int32) -> krb5_error_code;
2352    // TODO: Doc
2353    pub fn krb5_string_to_enctype(string: *mut c_char,
2354                                  enctypep: *mut krb5_enctype) -> krb5_error_code;
2355    // TODO: Doc
2356    pub fn krb5_string_to_salttype(string: *mut c_char,
2357                                   salttypep: *mut krb5_int32) -> krb5_error_code;
2358    // TODO: Doc
2359    pub fn krb5_string_to_cksumtypep(string: *mut c_char,
2360                                     cksumtypep: *mut krb5_cksumtype) -> krb5_error_code;
2361    // TODO: Doc
2362    pub fn krb5_string_to_timestamp(string: *mut c_char,
2363                                    timestamp: *mut krb5_timestamp) -> krb5_error_code;
2364    // TODO: Doc
2365    pub fn krb5_string_to_deltat(string: *mut c_char,
2366                                 deltatp: *mut krb5_deltat) -> krb5_error_code;
2367    // TODO: Doc
2368    pub fn krb5_enctype_to_string(enctype: krb5_enctype,
2369                                  buffer: *mut c_char,
2370                                  buflen: usize) -> krb5_error_code;
2371    // TODO: Doc
2372    pub fn krb5_enctype_to_name(enctype: krb5_enctype,
2373                                shortest: krb5_boolean,
2374                                buffer: *mut c_char,
2375                                buflen: usize) -> krb5_error_code;
2376    // TODO: Doc
2377    pub fn krb5_salttype_to_string(salttype: krb5_int32,
2378                                   buffer: *mut c_char,
2379                                   buflen: usize) -> krb5_error_code;
2380    // TODO: Doc
2381    pub fn krb5_cksumtype_to_string(cksumtype: krb5_cksumtype,
2382                                    buffer: *mut c_char,
2383                                    buflen: usize) -> krb5_error_code;
2384    // TODO: Doc
2385    pub fn krb5_timestamp_to_string(timestamp: krb5_timestamp,
2386                                    buffer: *mut c_char,
2387                                    buflen: usize) -> krb5_error_code;
2388    // TODO: Doc
2389    pub fn krb5_timestamp_to_sfstring(timestamp: krb5_timestamp,
2390                                      buffer: *mut c_char,
2391                                      buflen: usize,
2392                                      pad: *mut c_char) -> krb5_error_code;
2393    // TODO: Doc
2394    pub fn krb5_deltat_to_string(deltat: krb5_deltat,
2395                                 buffer: *mut c_char,
2396                                 buflen: usize) -> krb5_error_code;
2397}
2398
2399// TODO: `KRB5_TGS_NAME` constant
2400
2401pub const KRB5_TGS_NAME_SIZE: usize = 6;
2402
2403pub const KRB5_RECVAUTH_SKIP_VERSION: krb5_flags = 0x0001;
2404pub const KRB5_RECVAUTH_BADAUTHVERS: krb5_flags = 0x0002;
2405// TODO: Doc
2406#[repr(C)]
2407pub struct krb5_prompt {
2408    pub prompt: *mut c_char,
2409    pub hidden: c_int,
2410    pub reply: *mut krb5_data,
2411}
2412
2413// NOTE: last argument is actually `krb5_prompt prompts[]` in the orignal source,
2414//       But this should be equivalent.
2415pub type krb5_prompter_fct = extern "C" fn(context: krb5_context,
2416                                           data: *mut c_void,
2417                                           name: *const c_char,
2418                                           banner: *const c_char,
2419                                           num_prompts: c_int,
2420                                           prompts: *mut krb5_prompt) -> krb5_error_code;
2421#[link(name = "krb5")]
2422extern "C" {
2423    // TODO: Doc
2424    // NOTE: last argument is actually `krb5_prompt prompts[]` in the orignal source,
2425    //       But this should be equivalent.
2426    pub fn krb5_prompter_posix(context: krb5_context,
2427                               data: *mut c_void,
2428                               name: *const c_char,
2429                               banner: *const c_char,
2430                               num_prompts: c_int,
2431                               prompts: *mut krb5_prompt) -> krb5_error_code;
2432}
2433
2434// TODO: `KRB5_RESPONDER_QUESTION_PASSWRD` constant
2435// TODO: `KRB5_RESPONDER_QUESTION_OTP` constant
2436
2437// TODO: Doc
2438pub const KRB5_RESPONDER_OTP_FORMAT_DECIMAL: krb5_flags = 0;
2439// TODO: Doc
2440pub const KRB5_RESPONDER_OTP_FORMAT_HEXADECIMAL: krb5_flags = 1;
2441// TODO: Doc
2442pub const KRB5_RESPONDER_OTP_FORMAT_ALPHANUMERIC: krb5_flags = 2;
2443
2444// TODO: Doc
2445pub const KRB5_RESPONDER_OTP_FLAGS_COLLECT_TOKEN: krb5_flags = 0x0001;
2446// TODO: Doc
2447pub const KRB5_RESPONDER_OTP_FLAGS_COLLECT_PIN: krb5_flags = 0x0002;
2448// TODO: Doc
2449pub const KRB5_RESPONDER_OTP_FLAGS_NEXTOTP: krb5_flags = 0x0004;
2450// TODO: Doc
2451pub const KRB5_RESPONDER_OTP_FLAGS_SEPERATE_PIN: krb5_flags = 0x0008;
2452
2453// TODO: `KRB5_RESPONDER_QUESTION_PKINIT` cosntant
2454
2455// TODO: Doc
2456pub const KRB5_RESPONDER_PKINIT_FLAGS_TOKEN_USER_PIN_COUNT_LOW: krb5_flags = (1 << 0);
2457// TODO: Doc
2458pub const KRB5_RESPONDER_PKINIT_FLAGS_TOKEN_USER_PIN_FINAL_TRY: krb5_flags = (1 << 1);
2459// TODO: Doc
2460pub const KRB5_RESPONDER_PKINIT_FLAGS_TOKEN_USER_PIN_LOCKED: krb5_flags = (1 << 2);
2461
2462// TODO: Doc
2463// NOTE: where is `krb5_respoinder_context_st` really defined?
2464//       I cannot find it in the orignal source file.
2465//       Opaque struct for now
2466pub enum krb5_responder_context_st {}
2467pub type krb5_responder_context = *mut krb5_responder_context_st;
2468
2469#[link(name = "krb5")]
2470extern "C" {
2471    // TODO: Doc
2472    pub fn krb5_responder_list_questions(ctx: krb5_context,
2473                                         rctx: krb5_responder_context) -> *const *const c_char;
2474    // TODO: Doc
2475    pub fn krb5_responder_get_challenge(ctx: krb5_context,
2476                                        rctx: krb5_responder_context,
2477                                        question: *const c_char) -> *const c_char;
2478    // TODO: Doc
2479    pub fn krb5_responder_set_answer(ctx: krb5_context,
2480                                     rctx: krb5_responder_context,
2481                                     question: *const c_char,
2482                                     answer: *const c_char) -> krb5_error_code;
2483}
2484
2485// TODO: Doc
2486pub type krb5_responder_fn = extern "C" fn(ctx: krb5_context,
2487                                           data: *mut c_void,
2488                                           rctx: krb5_responder_context) -> krb5_error_code;
2489
2490// TODO: Doc
2491#[repr(C)]
2492pub struct krb5_responder_otp_tokeninfo {
2493    pub flags: krb5_flags,
2494    pub format: krb5_int32,
2495    pub length: krb5_int32,
2496    pub vendor: *mut c_char,
2497    pub challenge: *mut c_char,
2498    pub token_id: *mut c_char,
2499    pub alg_id: *mut c_char,
2500}
2501
2502// TODO: Doc
2503#[repr(C)]
2504pub struct krb5_responder_otp_challenge {
2505    pub service: *mut c_char,
2506    pub tokeninfo: *mut *mut krb5_responder_otp_challenge,
2507}
2508
2509#[link(name = "krb5")]
2510extern "C" {
2511    // TODO: Doc
2512    pub fn krb5_responder_otp_get_challenge(ctx: krb5_context,
2513                                            rctx: krb5_responder_context,
2514                                            chl: *mut *mut krb5_responder_otp_challenge) -> krb5_error_code;
2515    // TODO: Doc
2516    pub fn krb5_responder_otp_set_answer(ctx: krb5_context,
2517                                         rctx: krb5_responder_context,
2518                                         ti: usize,
2519                                         value: *const c_char,
2520                                         pin: *const c_char) -> krb5_error_code;
2521    // TODO: Doc
2522    pub fn krb5_responder_otp_challenge_free(ctx: krb5_context,
2523                                             rctx: krb5_responder_context,
2524                                             chl: *mut krb5_responder_otp_challenge);
2525
2526}
2527
2528// TODO: Doc
2529#[repr(C)]
2530pub struct krb5_responder_pkinit_identity {
2531    pub identity: *mut c_char,
2532    pub token_flags: krb5_int32,
2533}
2534
2535// TODO: Doc
2536#[repr(C)]
2537pub struct krb5_responder_pkinit_challenge {
2538    pub identities: *mut *mut krb5_responder_pkinit_identity,
2539}
2540
2541#[link(name = "krb5")]
2542extern "C" {
2543    // TODO: Doc
2544    pub fn krb5_responder_pkinit_get_challenge(ctx: krb5_context,
2545                                               rctx: krb5_responder_context,
2546                                               chl_out: *mut *mut krb5_responder_pkinit_challenge) -> krb5_error_code;
2547    // TODO: Doc
2548    pub fn krb5_responder_pkinit_set_answer(ctx: krb5_context,
2549                                            rctx: krb5_responder_context,
2550                                            identity: *const c_char,
2551                                            pin: *const c_char) -> krb5_error_code;
2552    // TODO: Doc
2553    pub fn krb5_responder_pkinit_challenge_free(ctx: krb5_context,
2554                                                rctx: krb5_responder_context,
2555                                                chl: *mut krb5_responder_pkinit_identity);
2556}
2557
2558// TODO: Doc
2559#[repr(C)]
2560pub struct krb5_get_init_creds_opt {
2561    pub flags: krb5_flags,
2562    pub tkt_life: krb5_deltat,
2563    pub renew_life: krb5_deltat,
2564    pub forwardable: c_int,
2565    pub proxiable: c_int,
2566    pub etype_list: *mut krb5_enctype,
2567    pub etype_list_length: c_int,
2568    pub address_list: *mut *mut krb5_address,
2569    pub preauth_list: *mut krb5_preauthtype,
2570    pub preauth_list_length: c_int,
2571    pub salt: *mut krb5_data,
2572}
2573
2574pub const KRB5_GET_INIT_CREDS_OPT_TKT_LIFE: krb5_flags      = 0x0001;
2575pub const KRB5_GET_INIT_CREDS_OPT_RENEW_LIFE: krb5_flags    = 0x0002;
2576pub const KRB5_GET_INIT_CREDS_OPT_FORWARDABLE: krb5_flags   = 0x0004;
2577pub const KRB5_GET_INIT_CREDS_OPT_PROXIABLE: krb5_flags     = 0x0008;
2578pub const KRB5_GET_INIT_CREDS_OPT_ETYPE_LIST: krb5_flags    = 0x0010;
2579pub const KRB5_GET_INIT_CREDS_OPT_ADDRESS_LIST: krb5_flags  = 0x0020;
2580pub const KRB5_GET_INIT_CREDS_OPT_PREAUTH_LIST: krb5_flags  = 0x0040;
2581pub const KRB5_GET_INIT_CREDS_OPT_SALT: krb5_flags          = 0x0080;
2582pub const KRB5_GET_INIT_CREDS_OPT_CHG_PWD_PRMPT: krb5_flags = 0x0100;
2583pub const KRB5_GET_INIT_CREDS_OPT_CANONICALIZE: krb5_flags  = 0x0200;
2584pub const KRB5_GET_INIT_CREDS_OPT_ANONYMOUS: krb5_flags     = 0x0400;
2585
2586#[link(name = "krb5")]
2587extern "C" {
2588    // TODO: Doc
2589    pub fn krb5_get_init_creds_opt_alloc(context: krb5_context,
2590                                         opt: *mut *mut krb5_get_init_creds_opt) -> krb5_error_code;
2591    // TODO: Doc
2592    pub fn krb5_get_init_creds_opt_free(context: krb5_context,
2593                                        opt: *mut krb5_get_init_creds_opt);
2594    // TODO: Doc
2595    pub fn krb5_get_init_creds_opt_set_tkt_life(opt: *mut krb5_get_init_creds_opt,
2596                                                tkt_life: krb5_deltat);
2597    // TODO: Doc
2598    pub fn krb5_get_init_creds_opt_set_renew_life(opt: *mut krb5_get_init_creds_opt,
2599                                                  renew_life: krb5_deltat);
2600    // TODO: Doc
2601    pub fn krb5_get_init_creds_opt_set_forwardable(opt: *mut krb5_get_init_creds_opt,
2602                                                   forwardable: c_int);
2603    // TODO: Doc
2604    pub fn krb5_get_init_creds_opt_set_proxiable(opt: *mut krb5_get_init_creds_opt,
2605                                                 proxiable: c_int);
2606    // TODO: Doc
2607    pub fn krb5_get_init_creds_opt_set_canonicalize(opt: *mut krb5_get_init_creds_opt,
2608                                                    canonicalize: c_int);
2609    // TODO: Doc
2610    pub fn krb5_get_init_creds_opt_set_anonymous(opt: *mut krb5_get_init_creds_opt,
2611                                                 anonymous: c_int);
2612    // TODO: Doc
2613    pub fn krb5_get_init_creds_opt_set_etype_list(opt: *mut krb5_get_init_creds_opt,
2614                                                  etype_list: *mut krb5_enctype,
2615                                                  etype_list_length: c_int);
2616    // TODO: Doc
2617    pub fn krb5_get_init_creds_opt_set_address_list(opt: *mut krb5_get_init_creds_opt,
2618                                                    addresses: *mut *mut krb5_address);
2619    // TODO: Doc
2620    pub fn krb5_get_init_creds_opt_set_preauth_list(opt: *mut krb5_get_init_creds_opt,
2621                                                    preauth_list: *mut krb5_preauthtype,
2622                                                    preauth_list_length: c_int);
2623    // TODO: Doc
2624    pub fn krb5_get_init_creds_opt_set_salt(opt: *mut krb5_get_init_creds_opt,
2625                                            salt: *mut krb5_data);
2626    // TODO: Doc
2627    pub fn krb5_get_init_creds_opt_set_change_password_prompt(opt: *mut krb5_get_init_creds_opt,
2628                                                              prompt: c_int);
2629}
2630
2631// TODO: Doc
2632#[repr(C)]
2633pub struct krb5_gic_opt_pa_data {
2634    pub attr: *mut c_char,
2635    pub value: *mut c_char,
2636}
2637
2638#[link(name = "krb5")]
2639extern "C" {
2640    // TODO: Doc
2641    pub fn krb5_get_init_creds_opt_set_pa(context: krb5_context,
2642                                          opt: *mut krb5_get_init_creds_opt,
2643                                          attr: *const c_char,
2644                                          value: *const c_char) -> krb5_error_code;
2645    // TODO: Doc
2646    pub fn krb5_get_init_creds_opt_set_fast_ccache_name(context: krb5_context,
2647                                                        opt: *mut krb5_get_init_creds_opt,
2648                                                        fast_ccache_name: *const c_char) -> krb5_error_code;
2649    // TODO: Doc
2650    pub fn krb5_get_init_creds_opt_set_fast_ccache(context: krb5_context,
2651                                                   opt: *mut krb5_get_init_creds_opt,
2652                                                   ccache: krb5_ccache) -> krb5_error_code;
2653    // TODO: Doc
2654    pub fn krb5_get_init_creds_opt_set_in_ccache(context: krb5_context,
2655                                                 opt: *mut krb5_get_init_creds_opt,
2656                                                 ccache: krb5_ccache) -> krb5_error_code;
2657    // TODO: Doc
2658    pub fn krb5_get_init_creds_opt_set_out_ccache(context: krb5_context,
2659                                                  opt: *mut krb5_get_init_creds_opt,
2660                                                  ccache: krb5_ccache) -> krb5_error_code;
2661    // TODO: Doc
2662    pub fn krb5_get_init_creds_opt_set_fast_flags(context: krb5_context,
2663                                                  opt: *mut krb5_get_init_creds_opt,
2664                                                  flags: krb5_flags) -> krb5_error_code;
2665    // TODO: Doc
2666    pub fn krb5_get_init_creds_opt_get_fast_flags(context: krb5_context,
2667                                                  opt: *mut krb5_get_init_creds_opt,
2668                                                  out_flags: *mut krb5_flags) -> krb5_error_code;
2669}
2670
2671// TODO: Doc
2672pub const KRB5_FAST_REQUIRED: krb5_flags = 0x0001;
2673
2674type krb5_expire_callback_func = extern "C" fn(context: krb5_context,
2675                                               data: *mut c_void,
2676                                               password_expiration: krb5_timestamp,
2677                                               account_expiration: krb5_timestamp,
2678                                               is_last_req: krb5_boolean);
2679#[link(name = "krb5")]
2680extern "C" {
2681    // TODO: Doc
2682    pub fn krb5_get_init_creds_opt_set_expire_callback(context: krb5_context,
2683                                                       opt: *mut krb5_get_init_creds_opt,
2684                                                       cb: krb5_expire_callback_func,
2685                                                       data: *mut c_void) -> krb5_error_code;
2686    // TODO: Doc
2687    pub fn krb5_get_init_creds_opt_set_responder(context: krb5_context,
2688                                                 opt: *mut krb5_get_init_creds_opt,
2689                                                 responder: Option<krb5_responder_fn>,
2690                                                 data: *mut c_void) -> krb5_error_code;
2691    // TODO: Doc
2692    pub fn krb5_get_init_creds_password(context: krb5_context,
2693                                        creds: *mut krb5_creds,
2694                                        client: krb5_principal,
2695                                        password: *const c_char,
2696                                        prompter: Option<krb5_prompter_fct>,
2697                                        data: *mut c_void,
2698                                        start_time: krb5_deltat,
2699                                        in_tkt_service: *const c_char,
2700                                        k5_gic_options: *const krb5_get_init_creds_opt) -> krb5_error_code;
2701}
2702
2703pub enum _krb5_init_creds_context {}
2704pub type krb5_init_creds_context = *mut _krb5_init_creds_context;
2705
2706// TODO: Doc
2707pub const KRB5_INIT_CREDS_STEP_FLAG_CONTINUE: krb5_flags = 0x1;
2708
2709#[link(name = "krb5")]
2710extern "C" {
2711    // TODO: Doc
2712    pub fn krb5_init_creds_free(context: krb5_context,
2713                                ctx: krb5_init_creds_context);
2714    // TODO: Doc
2715    pub fn krb5_init_creds_get(context: krb5_context,
2716                               ctx: krb5_init_creds_context) -> krb5_error_code;
2717    // TODO: Doc
2718    pub fn krb5_init_creds_get_creds(context: krb5_context,
2719                                     ctx: krb5_init_creds_context,
2720                                     creds: *mut krb5_creds) -> krb5_error_code;
2721    // TODO: Doc
2722    pub fn krb5_init_creds_get_error(context: krb5_context,
2723                                     ctx: krb5_init_creds_context,
2724                                     error: *mut *mut krb5_error) -> krb5_error_code;
2725    // TODO: Doc
2726    pub fn krb5_init_creds_init(context: krb5_context,
2727                                client: krb5_principal,
2728                                prompter: Option<krb5_prompter_fct>,
2729                                data: *mut c_void,
2730                                start_time: krb5_deltat,
2731                                options: *mut krb5_get_init_creds_opt,
2732                                ctx: *mut krb5_init_creds_context) -> krb5_error_code;
2733    // TODO: Doc
2734    pub fn krb5_init_creds_set_keytab(context: krb5_context,
2735                                      ctx: krb5_init_creds_context,
2736                                      keytab: krb5_keytab) -> krb5_error_code;
2737    // TODO: Doc
2738    pub fn krb5_init_creds_step(context: krb5_context,
2739                                ctx: krb5_init_creds_context,
2740                                in_: *mut krb5_data,
2741                                out: *mut krb5_data,
2742                                realm: *mut krb5_data,
2743                                flags: *mut c_uint) -> krb5_error_code;
2744    // TODO: Doc
2745    pub fn krb5_init_creds_set_password(context: krb5_context,
2746                                        ctx: krb5_init_creds_context,
2747                                        password: *const c_char) -> krb5_error_code;
2748    // TODO: Doc
2749    pub fn krb5_init_creds_set_service(context: krb5_context,
2750                                       ctx: krb5_init_creds_context,
2751                                       service: *const c_char) -> krb5_error_code;
2752    // TODO: Doc
2753    pub fn krb5_init_creds_get_times(context: krb5_context,
2754                                     ctx: krb5_init_creds_context,
2755                                     times: *mut krb5_ticket_times) -> krb5_error_code;
2756}
2757
2758pub enum _krb5_tkt_creds_context {}
2759pub type krb5_tkt_creds_context = *mut _krb5_tkt_creds_context;
2760
2761#[link(name = "krb5")]
2762extern "C" {
2763    // TODO: Doc
2764    pub fn krb5_tkt_creds_init(context: krb5_context,
2765                               ccache: krb5_ccache,
2766                               creds: *mut krb5_creds,
2767                               options: krb5_flags,
2768                               ctx: krb5_tkt_creds_context) -> krb5_error_code;
2769    // TODO: Doc
2770    pub fn krb5_tkt_creds_get(context: krb5_context,
2771                              ctx: krb5_tkt_creds_context) -> krb5_error_code;
2772    // TODO: Doc
2773    pub fn krb5_tkt_creds_get_creds(context: krb5_context,
2774                                    ctx: krb5_tkt_creds_context,
2775                                    creds: *mut krb5_creds) -> krb5_error_code;
2776    // TODO: Doc
2777    pub fn krb5_tkt_creds_free(context: krb5_context,
2778                               ctx: krb5_tkt_creds_context);
2779}
2780
2781// TODO: Doc
2782pub const KRB5_TKT_CREDS_STEP_FLAG_CONTINUE: krb5_flags = 0x1;
2783
2784#[link(name = "krb5")]
2785extern "C" {
2786    // TODO: Doc
2787    pub fn krb5_tkt_creds_step(context: krb5_context,
2788                               ctx: krb5_tkt_creds_context,
2789                               in_: *mut krb5_data,
2790                               out: *mut krb5_data,
2791                               realm: *mut krb5_data,
2792                               flags: *mut c_uint) -> krb5_error_code;
2793    // TODO: Doc
2794    pub fn krb5_tkt_creds_get_times(context: krb5_context,
2795                                    ctx: krb5_tkt_creds_context,
2796                                    times: *mut krb5_ticket_times) -> krb5_error_code;
2797    // TODO: Doc
2798    pub fn krb5_get_init_creds_keytab(context: krb5_context,
2799                                      creds: *mut krb5_creds,
2800                                      client: krb5_principal,
2801                                      arg_keytab: krb5_keytab,
2802                                      start_time: krb5_deltat,
2803                                      in_tkt_service: *const c_char,
2804                                      k5_gic_options: *const krb5_get_init_creds_opt) -> krb5_error_code;
2805}
2806
2807// TODO: Docs
2808#[repr(C)]
2809pub struct krb5_verify_init_creds_opt {
2810    pub flags: krb5_flags,
2811    pub ap_req_nofail: c_int,
2812}
2813
2814// TODO: Doc
2815pub const KRB5_VERIFY_INIT_CREDS_OPT_AP_REQ_NOFAIL: krb5_flags = 0x0001;
2816
2817#[link(name = "krb5")]
2818extern "C" {
2819    // TODO: Doc
2820    pub fn krb5_verify_init_creds_opt_init(k5_vic_options: *mut krb5_verify_init_creds_opt);
2821    // TODO: Doc
2822    pub fn krb5_verify_init_creds_opt_set_ap_req_nofail(k5_vic_options: *mut krb5_verify_init_creds_opt,
2823                                                        ap_req_nofail: c_int);
2824    // TODO: Doc
2825    pub fn krb5_verify_init_creds(context: krb5_context,
2826                                  creds: *mut krb5_creds,
2827                                  server: krb5_principal,
2828                                  keytab: krb5_keytab,
2829                                  ccache: *mut krb5_ccache,
2830                                  options: *mut krb5_verify_init_creds_opt) -> krb5_error_code;
2831    // TODO: Doc
2832    pub fn krb5_get_validated_creds(context: krb5_context,
2833                                    creds: *mut krb5_creds,
2834                                    client: krb5_principal,
2835                                    ccache: krb5_ccache,
2836                                    in_tkt_service: *const c_char) -> krb5_error_code;
2837    // TODO: Doc
2838    pub fn krb5_get_renewed_creds(context: krb5_context,
2839                                  creds: *mut krb5_creds,
2840                                  client: krb5_principal,
2841                                  ccache: krb5_ccache,
2842                                  in_tkt_service: *const c_char) -> krb5_error_code;
2843    // TODO: Doc
2844    pub fn krb5_decode_ticket(code: *const krb5_data,
2845                              rep: *mut *mut krb5_ticket) -> krb5_error_code;
2846    // TODO: Doc
2847    pub fn krb5_appdefault_string(context: krb5_context,
2848                                  appname: *const c_char,
2849                                  realm: *const krb5_data,
2850                                  option: *const c_char,
2851                                  default_value: *const c_char,
2852                                  ret_value: *mut *mut c_char);
2853    // TODO: Doc
2854    pub fn krb5_appdefault_boolean(context: krb5_context,
2855                                   appname: *const c_char,
2856                                   realm: *const krb5_data,
2857                                   option: *const c_char,
2858                                   default_value: c_int,
2859                                   ret_value: *mut c_int);
2860}
2861
2862// TODO: Doc
2863pub const KRB5_PROMPT_TYPE_PASSWORD: krb5_prompt_type = 0x1;
2864// TODO: Doc
2865pub const KRB5_PROMPT_TYPE_NEW_PASSWORD: krb5_prompt_type = 0x2;
2866// TODO: Doc
2867pub const KRB5_PROMPT_TYPE_NEW_PASSWORD_AGAIN: krb5_prompt_type = 0x3;
2868// TODO: Doc
2869pub const KRB5_PROMPT_TYPE_PREAUTH: krb5_prompt_type = 0x4;
2870
2871pub type krb5_prompt_type = krb5_int32;
2872
2873#[link(name = "krb5")]
2874extern "C" {
2875    // TODO: Doc
2876    pub fn krb5_get_prompt_types(context: krb5_context) -> *mut krb5_prompt_type;
2877    // TODO: Doc
2878    pub fn krb5_set_error_message(ctx: krb5_context,
2879                                  code: krb5_error_code,
2880                                  fmt: *const c_char, ...);
2881    // TODO: Doc
2882    // TODO: `krb5_vset_error_message` function (va_list)!
2883
2884    // TODO: Doc
2885    pub fn krb5_copy_error_message(dest_ctx: krb5_context,
2886                                   src_ctx: krb5_context);
2887    // TODO: Doc
2888    pub fn krb5_get_error_message(ctx: krb5_context,
2889                                  code: krb5_error_code) -> *const c_char;
2890    // TODO: Doc
2891    pub fn krb5_free_error_message(ctx: krb5_context,
2892                                   msg: *const c_char);
2893    // TODO: Doc
2894    pub fn krb5_clear_error_message(ctx: krb5_context);
2895    // TODO: Doc
2896    pub fn krb5_decode_authdata_container(context: krb5_context,
2897                                          type_: krb5_authdatatype,
2898                                          container: *const krb5_authdata,
2899                                          authdata: *mut *mut *mut krb5_authdata) -> krb5_error_code;
2900    // TODO: Doc
2901    pub fn krb5_make_authdata_kdc_issued(context: krb5_context,
2902                                         key: *const krb5_keyblock,
2903                                         issuer: krb5_const_principal,
2904                                         authdata: *mut *const krb5_authdata,
2905                                         ad_kdcissued: *mut *mut *mut krb5_authdata) -> krb5_error_code;
2906    // TODO: Doc
2907    pub fn krb5_verify_authdata_kdc_issued(context: krb5_context,
2908                                           key: *const krb5_keyblock,
2909                                           ad_kdcissued: *const krb5_authdata,
2910                                           issuer: *mut krb5_principal,
2911                                           authdata: *mut *mut *mut krb5_authdata) -> krb5_error_code;
2912}
2913
2914// TODO: Doc
2915pub const KRB5_PAC_LOGON_INFO: krb5_ui_4 = 1;
2916// TODO: Doc
2917pub const KRB5_PAC_CREDENTIALS_INFO: krb5_ui_4 = 2;
2918// TODO: Doc
2919pub const KRB5_PAC_SERVER_CHECKSUM: krb5_ui_4 = 6;
2920// TODO: Doc
2921pub const KRB5_PRIVSVR_CHECKSUM: krb5_ui_4 = 7;
2922// TODO: Doc
2923pub const KRB5_PAC_CLIENT_INFO: krb5_ui_4 = 10;
2924// TODO: Doc
2925pub const KRB5_PAC_DELEGATION_INFO: krb5_ui_4 = 11;
2926// TODO: Doc
2927pub const KRB5_PAC_UPN_DNS_INFO: krb5_ui_4 = 12;
2928
2929pub enum krb5_pac_data {}
2930pub type krb5_pac = *mut krb5_pac_data;
2931
2932#[link(name = "krb5")]
2933extern "C" {
2934    // TODO: Doc
2935    pub fn krb5_pac_add_buffer(context: krb5_context,
2936                               pac: krb5_pac,
2937                               type_: krb5_ui_4,
2938                               data: *const krb5_data) -> krb5_error_code;
2939    // TODO: Doc
2940    pub fn krb5_pac_free(context: krb5_context,
2941                         pac: krb5_pac);
2942    // TODO: Doc
2943    pub fn krb5_pac_get_buffer(context: krb5_context,
2944                               pac: krb5_pac,
2945                               type_: krb5_ui_4,
2946                               data: *mut krb5_data) -> krb5_error_code;
2947    // TODO: Doc
2948    pub fn krb5_pac_get_types(context: krb5_context,
2949                              pac: krb5_pac,
2950                              len: *mut usize,
2951                              types: *mut *mut krb5_ui_4) -> krb5_error_code;
2952    // TODO: Doc
2953    pub fn krb5_pac_init(context: krb5_context,
2954                         pac: *mut krb5_pac) -> krb5_error_code;
2955    // TODO: Doc
2956    pub fn krb5_pac_parse(context: krb5_context,
2957                          ptr: *const c_void,
2958                          len: usize,
2959                          pac: *mut krb5_pac) -> krb5_error_code;
2960    // TODO: Doc
2961    pub fn krb5_pac_verify(context: krb5_context,
2962                           pac: krb5_pac,
2963                           authtime: krb5_timestamp,
2964                           principal: krb5_const_principal,
2965                           server: *const krb5_keyblock,
2966                           privsvr: *const krb5_keyblock) -> krb5_error_code;
2967    // TODO: Doc
2968    pub fn krb5_pac_sign(context: krb5_context,
2969                         pac: krb5_pac,
2970                         authtime: krb5_timestamp,
2971                         principal: krb5_const_principal,
2972                         server_key: *const krb5_keyblock,
2973                         privsvr_key: *const krb5_keyblock,
2974                         data: *mut krb5_data) -> krb5_error_code;
2975    // TODO: Doc
2976    pub fn krb5_allow_weak_crypt(context: krb5_context,
2977                                 enable: krb5_boolean) -> krb5_error_code;
2978}
2979
2980// TODO: Docs
2981#[repr(C)]
2982pub struct krb5_trace_info {
2983    pub message: *const c_char,
2984}
2985
2986pub type krb5_trace_callback = extern "C" fn(context: krb5_context,
2987                                             info: *const krb5_trace_info,
2988                                             cb_data: *mut c_void);
2989#[link(name = "krb5")]
2990extern "C" {
2991    // TODO: Doc
2992    pub fn krb5_set_trace_callback(context: krb5_context,
2993                                   fn_: Option<krb5_trace_callback>,
2994                                   cb_data: *mut c_void) -> krb5_error_code;
2995    // TODO: Doc
2996    pub fn krb5_set_trace_filename(context: krb5_context,
2997                                   filename: *const c_char) -> krb5_error_code;
2998}
2999
3000// include <et/com_err.h>
3001
3002pub const KRB5KDC_ERR_NONE: krb5_error_code                                = (-1765328384);
3003pub const KRB5KDC_ERR_NAME_EXP: krb5_error_code                            = (-1765328383);
3004pub const KRB5KDC_ERR_SERVICE_EXP: krb5_error_code                         = (-1765328382);
3005pub const KRB5KDC_ERR_BAD_PVNO: krb5_error_code                            = (-1765328381);
3006pub const KRB5KDC_ERR_C_OLD_MAST_KVNO: krb5_error_code                     = (-1765328380);
3007pub const KRB5KDC_ERR_S_OLD_MAST_KVNO: krb5_error_code                     = (-1765327379);
3008pub const KRB5KDC_ERR_C_PRINCIPAL_UNKNOWN: krb5_error_code                 = (-1765328378);
3009pub const KRB5KDC_ERR_S_PRINCIPAL_UNKNOWN: krb5_error_code                 = (-1765328377);
3010pub const KRB5KDC_ERR_PRINCIPAL_NOT_UNIQUE: krb5_error_code                = (-1765328376);
3011pub const KRB5KDC_ERR_NULL_KEY: krb5_error_code                            = (-1765328375);
3012pub const KRB5KDC_ERR_CANNOT_POSTDATE: krb5_error_code                     = (-1765328374);
3013pub const KRB5KDC_ERR_NEVER_VALID: krb5_error_code                         = (-1765328373);
3014pub const KRB5KDC_ERR_POLICY: krb5_error_code                              = (-1765328372);
3015pub const KRB5KDC_ERR_BADOPTION: krb5_error_code                           = (-1765328371);
3016pub const KRB5KDC_ERR_ETYPE_NOSUPP: krb5_error_code                        = (-1765328370);
3017pub const KRB5KDC_ERR_SUMTYPE_NOSUPP: krb5_error_code                      = (-1765328369);
3018pub const KRB5KDC_ERR_PADATA_TYPE_NOSUPP: krb5_error_code                  = (-1765328368);
3019pub const KRB5KDC_ERR_TRTYPE_NOSUPPP: krb5_error_code                      = (-1765328367);
3020pub const KRB5KDC_ERR_CLIENT_REVOKED: krb5_error_code                      = (-1765328366);
3021pub const KRB5KDC_ERR_SERVICE_REVOKED: krb5_error_code                     = (-1765328365);
3022pub const KRB5KDC_ERR_TGT_REVOKED: krb5_error_code                         = (-1765328364);
3023pub const KRB5KDC_ERR_CLIENT_NOTYET: krb5_error_code                       = (-1765328363);
3024pub const KRB5KDC_ERR_SERVICE_NOTYET: krb5_error_code                      = (-1765328362);
3025pub const KRB5KDC_ERR_KEY_EXP: krb5_error_code                             = (-1765328361);
3026pub const KRB5KDC_ERR_PREAUTH_FAILED: krb5_error_code                      = (-1765328360);
3027pub const KRB5KDC_ERR_PREAUTH_REQUIRED: krb5_error_code                    = (-1765328359);
3028pub const KRB5KDC_ERR_SERVER_NOMATCH: krb5_error_code                      = (-1765328358);
3029pub const KRB5KDC_ERR_MUST_USE_USER2USER: krb5_error_code                  = (-1765328357);
3030pub const KRB5KDC_ERR_PATH_NOT_ACCEPTED: krb5_error_code                   = (-1765328356);
3031pub const KRB5KDC_ERR_SVC_UNAVAILABLE: krb5_error_code                     = (-1765328355);
3032pub const KRB5PLACEHOLD_30: krb5_error_code                                = (-1765328354);
3033pub const KRB5KRB_AP_ERR_BAD_INTEGRITY: krb5_error_code                    = (-1765328353);
3034pub const KRB5KRB_AP_ERR_TKT_EXPIRED: krb5_error_code                      = (-1765328352);
3035pub const KRB5KRB_AP_ERR_TKT_NYV: krb5_error_code                          = (-1765328351);
3036pub const KRB5KRB_AP_ERR_REPEAT: krb5_error_code                           = (-1765328350);
3037pub const KRB5KRB_AP_ERR_NOT_US: krb5_error_code                           = (-1765328349);
3038pub const KRB5KRB_AP_ERR_BADMATCH: krb5_error_code                         = (-1765328348);
3039pub const KRB5KRB_AP_ERR_SKES: krb5_error_code                             = (-1765328347);
3040pub const KRB5KRB_AP_ERR_BADADDR: krb5_error_code                          = (-1765328346);
3041pub const KRB5KRB_AP_ERR_BADVERSION: krb5_error_code                       = (-1765328345);
3042pub const KRB5KRB_AP_ERR_MSG_TYPE: krb5_error_code                         = (-1765328344);
3043pub const KRB5KRB_AP_ERR_MODIFIED: krb5_error_code                         = (-1765328343);
3044pub const KRB5KRB_AP_ERR_BADORDER: krb5_error_code                         = (-1765328342);
3045pub const KRB5KRB_AP_ERR_ILL_CR_TKT: krb5_error_code                       = (-1765328341);
3046pub const KRB5KRB_AP_ERR_BADKEYVER: krb5_error_code                        = (-1765328340);
3047pub const KRB5KRB_AP_ERR_NOKEY: krb5_error_code                            = (-1765328339);
3048pub const KRB5KRB_AP_ERR_MUT_FAIL: krb5_error_code                         = (-1765328338);
3049pub const KRB5KRB_AP_ERR_BADDIRECTION: krb5_error_code                     = (-1765328337);
3050pub const KRB5KRB_AP_ERR_METHOD: krb5_error_code                           = (-1765328336);
3051pub const KRB5KRB_AP_ERR_BADSEQ: krb5_error_code                           = (-1765328335);
3052pub const KRB5KRB_AP_ERR_INAPP_CKSUM: krb5_error_code                      = (-1765328334);
3053pub const KRB5KRB_AP_PATH_NOT_ACCEPTED: krb5_error_code                    = (-1765328333);
3054pub const KRB5KRB_ERR_RESPONSE_TOO_BIG: krb5_error_code                    = (-1765328332);
3055pub const KRB5PLACEHOLD_53: krb5_error_code                                = (-1765328331);
3056pub const KRB5PLACEHOLD_54: krb5_error_code                                = (-1765328330);
3057pub const KRB5PLACEHOLD_55: krb5_error_code                                = (-1765328329);
3058pub const KRB5PLACEHOLD_56: krb5_error_code                                = (-1765328328);
3059pub const KRB5PLACEHOLD_57: krb5_error_code                                = (-1765328327);
3060pub const KRB5PLACEHOLD_58: krb5_error_code                                = (-1765328326);
3061pub const KRB5PLACEHOLD_59: krb5_error_code                                = (-1765328325);
3062pub const KRB5KRB_ERR_GENERIC: krb5_error_code                             = (-1765328324);
3063pub const KRB5KRB_ERR_FIELD_TOOLONG: krb5_error_code                       = (-1765328323);
3064pub const KRB5KRB_ERR_CLIENT_NOT_TRUSTED: krb5_error_code                  = (-1765328322);
3065pub const KRB5KRB_ERR_KDC_NOT_TRUSTED: krb5_error_code                     = (-1765328321);
3066pub const KRB5KRB_ERR_INVALID_SIG: krb5_error_code                         = (-1765328320);
3067pub const KRB5KRB_ERR_DH_KEY_PARAMETERS_NOT_ACCEPTED: krb5_error_code      = (-1765328319);
3068pub const KRB5KRB_ERR_CERTIFICATE_MISMATCH: krb5_error_code                = (-1765328318);
3069pub const KRB5KRB_AP_ERR_NO_TGT: krb5_error_code                           = (-1765328317);
3070pub const KRB5KDC_ERR_WRONG_REALM: krb5_error_code                         = (-1765328316);
3071pub const KRB5KRB_APP_ERR_USER_TO_USER_REQUIRED: krb5_error_code           = (-1765328315);
3072pub const KRB5KDC_ERR_CANT_VERIFY_CERTIFICATE: krb5_error_code             = (-1765328314);
3073pub const KRB5KDC_ERR_INVALID_CERTIFICATE: krb5_error_code                 = (-1765328313);
3074pub const KRB5KDC_ERR_REVOKED_CERTIFICATE: krb5_error_code                 = (-1765328312);
3075pub const KRB5KDC_ERR_REVOCATION_STATUS_UNKNOWN: krb5_error_code           = (-1765328311);
3076pub const KRB5KDC_ERR_REVOCATION_STATUS_UNAVAILABLE: krb5_error_code       = (-1765328310);
3077pub const KRB5KDC_ERR_CLIENT_NAME_MISMATCH: krb5_error_code                = (-1765328309);
3078pub const KRB5KDC_ERR_KDC_NAME_MISMATCH: krb5_error_code                   = (-1765328308);
3079pub const KRB5KDC_ERR_INCONSISTENT_KEY_PURPOSE: krb5_error_code            = (-1765328307);
3080pub const KRB5KDC_ERR_DIGEST_IN_CERT_NOT_ACCEPTED: krb5_error_code         = (-1765328306);
3081pub const KRB5KDC_ERR_PA_CHECKSUM_IN_CERT_NOT_ACCEPTED: krb5_error_code    = (-1765328305);
3082pub const KRB5KDC_ERR_DIGEST_IN_SIGNED_DATA_NOT_ACCEPTED: krb5_error_code  = (-1765328304);
3083pub const KRB5KDC_ERR_PUBLIC_KEY_ENCRYPTION_NOT_SUPPORTED: krb5_error_code = (-1765328303);
3084pub const KRB5PLACEHOLD_82: krb5_error_code                                = (-1765328302);
3085pub const KRB5PLACEHOLD_83: krb5_error_code                                = (-1765328301);
3086pub const KRB5PLACEHOLD_84: krb5_error_code                                = (-1765328300);
3087pub const KRB5KRB_AP_ERR_IAKERB_KDC_NOT_FOUND: krb5_error_code             = (-1765328299);
3088pub const KRB5KRB_AP_ERR_IAKERB_KDC_NO_RESPONSE: krb5_error_code           = (-1765328298);
3089pub const KRB5PLACEHOLD_87: krb5_error_code                                = (-1765328297);
3090pub const KRB5PLACEHOLD_88: krb5_error_code                                = (-1765328296);
3091pub const KRB5PLACEHOLD_89: krb5_error_code                                = (-1765328295);
3092pub const KRB5PLACEHOLD_90: krb5_error_code                                = (-1765328294);
3093pub const KRB5PLACEHOLD_91: krb5_error_code                                = (-1765328293);
3094pub const KRB5PLACEHOLD_92: krb5_error_code                                = (-1765328292);
3095pub const KRB5KDC_ERR_UNKNOWN_CRITICAL_FAST_OPTION: krb5_error_code        = (-1765328291);
3096pub const KRB5PLACEHOLD_94: krb5_error_code                                = (-1765328290);
3097pub const KRB5PLACEHOLD_95: krb5_error_code                                = (-1765328289);
3098pub const KRB5PLACEHOLD_96: krb5_error_code                                = (-1765328288);
3099pub const KRB5PLACEHOLD_97: krb5_error_code                                = (-1765328287);
3100pub const KRB5PLACEHOLD_98: krb5_error_code                                = (-1765328286);
3101pub const KRB5PLACEHOLD_99: krb5_error_code                                = (-1765328285);
3102pub const KRB5KDC_ERR_NO_ACCEPTABLE_KDF: krb5_error_code                   = (-1765328284);
3103pub const KRB5PLACEHOLD_101: krb5_error_code                               = (-1765328283);
3104pub const KRB5PLACEHOLD_102: krb5_error_code                               = (-1765328282);
3105pub const KRB5PLACEHOLD_103: krb5_error_code                               = (-1765328281);
3106pub const KRB5PLACEHOLD_104: krb5_error_code                               = (-1765328280);
3107pub const KRB5PLACEHOLD_105: krb5_error_code                               = (-1765328279);
3108pub const KRB5PLACEHOLD_106: krb5_error_code                               = (-1765328278);
3109pub const KRB5PLACEHOLD_107: krb5_error_code                               = (-1765328277);
3110pub const KRB5PLACEHOLD_108: krb5_error_code                               = (-1765328276);
3111pub const KRB5PLACEHOLD_109: krb5_error_code                               = (-1765328275);
3112pub const KRB5PLACEHOLD_110: krb5_error_code                               = (-1765328274);
3113pub const KRB5PLACEHOLD_111: krb5_error_code                               = (-1765328273);
3114pub const KRB5PLACEHOLD_112: krb5_error_code                               = (-1765328272);
3115pub const KRB5PLACEHOLD_113: krb5_error_code                               = (-1765328271);
3116pub const KRB5PLACEHOLD_114: krb5_error_code                               = (-1765328270);
3117pub const KRB5PLACEHOLD_115: krb5_error_code                               = (-1765328269);
3118pub const KRB5PLACEHOLD_116: krb5_error_code                               = (-1765328268);
3119pub const KRB5PLACEHOLD_117: krb5_error_code                               = (-1765328267);
3120pub const KRB5PLACEHOLD_118: krb5_error_code                               = (-1765328266);
3121pub const KRB5PLACEHOLD_119: krb5_error_code                               = (-1765328265);
3122pub const KRB5PLACEHOLD_120: krb5_error_code                               = (-1765328264);
3123pub const KRB5PLACEHOLD_121: krb5_error_code                               = (-1765328263);
3124pub const KRB5PLACEHOLD_122: krb5_error_code                               = (-1765328262);
3125pub const KRB5PLACEHOLD_123: krb5_error_code                               = (-1765328261);
3126pub const KRB5PLACEHOLD_124: krb5_error_code                               = (-1765328260);
3127pub const KRB5PLACEHOLD_125: krb5_error_code                               = (-1765328259);
3128pub const KRB5PLACEHOLD_126: krb5_error_code                               = (-1765328258);
3129pub const KRB5PLACEHOLD_127: krb5_error_code                               = (-1765328257);
3130pub const KRB5_ERR_RCSID: krb5_error_code                                  = (-1765328256);
3131pub const KRB5_LIBOS_BADLOCKFLAG: krb5_error_code                          = (-1765328255);
3132pub const KRB5_LIBOS_CANTREADPWD: krb5_error_code                          = (-1765328254);
3133pub const KRB5_LIBOS_BADPWDMATCH: krb5_error_code                          = (-1765328253);
3134pub const KRB5_LIBOS_PWDINTR: krb5_error_code                              = (-1765328252);
3135pub const KRB5_PARSE_ILLCHAR: krb5_error_code                              = (-1765328251);
3136pub const KRB5_PARSE_MALFORMED: krb5_error_code                            = (-1765328250);
3137pub const KRB5_CONFIG_CANTOPEN: krb5_error_code                            = (-1765328249);
3138pub const KRB5_CONFIG_BADFORMAT: krb5_error_code                           = (-1765328248);
3139pub const KRB5_CONFIG_NOTENUFSPACE: krb5_error_code                        = (-1765328247);
3140pub const KRB5_BADMSGTYPE: krb5_error_code                                 = (-1765328246);
3141pub const KRB5_CC_BADNAME: krb5_error_code                                 = (-1765328245);
3142pub const KRB5_CC_UNKNOWN_TYPE: krb5_error_code                            = (-1765328244);
3143pub const KRB5_CC_NOTFOUND: krb5_error_code                                = (-1765328243);
3144pub const KRB5_CC_END: krb5_error_code                                     = (-1765328242);
3145pub const KRB5_NO_TKT_SUPPLIED: krb5_error_code                            = (-1765328241);
3146pub const KRB5KRB_AP_WRONG_PRINC: krb5_error_code                          = (-1765328240);
3147pub const KRB5KRB_AP_ERR_TKT_INVALID: krb5_error_code                      = (-1765328239);
3148pub const KRB5_PRINC_NOMATCH: krb5_error_code                              = (-1765328238);
3149pub const KRB5_KDCREP_MODIFIED: krb5_error_code                            = (-1765328237);
3150pub const KRB5_KDCREP_SKEW: krb5_error_code                                = (-1765328236);
3151pub const KRB5_IN_TKT_REALM_MISMATCH: krb5_error_code                      = (-1765328235);
3152pub const KRB5_PROG_ETYPE_NOSUPP: krb5_error_code                          = (-1765328234);
3153pub const KRB5_PROG_KEYTYPE_NOSUPP: krb5_error_code                        = (-1765328233);
3154pub const KRB5_WRONG_ETYPE: krb5_error_code                                = (-1765328232);
3155pub const KRB5_PROG_SUMTYPE_NOSUPP: krb5_error_code                        = (-1765328231);
3156pub const KRB5_REALM_UNKNOWN: krb5_error_code                              = (-1765328230);
3157pub const KRB5_SERVICE_UNKNOWN: krb5_error_code                            = (-1765328229);
3158pub const KRB5_KDC_UNREACH: krb5_error_code                                = (-1765328228);
3159pub const KRB5_NO_LOCALNAME: krb5_error_code                               = (-1765328227);
3160pub const KRB5_MUTUAL_FAILED: krb5_error_code                              = (-1765328226);
3161pub const KRB5_RC_TYPE_EXISTS: krb5_error_code                             = (-1765328225);
3162pub const KRB5_RC_MALLOC: krb5_error_code                                  = (-1765328224);
3163pub const KRB5_RC_TYPE_NOTFOUND: krb5_error_code                           = (-1765328223);
3164pub const KRB5_RC_UNKNOWN: krb5_error_code                                 = (-1765328222);
3165pub const KRB5_RC_REPLAY: krb5_error_code                                  = (-1765328221);
3166pub const KRB5_RC_IO: krb5_error_code                                      = (-1765328220);
3167pub const KRB5_RC_NOIO: krb5_error_code                                    = (-1765328219);
3168pub const KRB5_RC_PARSE: krb5_error_code                                   = (-1765328218);
3169pub const KRB5_RC_IO_EOF: krb5_error_code                                  = (-1765328217);
3170pub const KRB5_RC_IO_MALLOC: krb5_error_code                               = (-1765328216);
3171pub const KRB5_RC_IO_PERM: krb5_error_code                                 = (-1765328215);
3172pub const KRB5_RC_IO_IO: krb5_error_code                                   = (-1765328214);
3173pub const KRB5_RC_IO_SPACE: krb5_error_code                                = (-1765328212);
3174pub const KRB5_TRANS_CANTOPEN: krb5_error_code                             = (-1765328211);
3175pub const KRB5_TRANS_BADFORMAT: krb5_error_code                            = (-1765328210);
3176pub const KRB5_LNAME_CANTOPEN: krb5_error_code                             = (-1765328209);
3177pub const KRB5_LNAME_NOTRANS: krb5_error_code                              = (-1765328208);
3178pub const KRB5_LNAME_BADFORMAT: krb5_error_code                            = (-1765328207);
3179pub const KRB5_CRYPTO_INTERNAL: krb5_error_code                            = (-1765328206);
3180pub const KRB5_KT_BADNAME: krb5_error_code                                 = (-1765328205);
3181pub const KRB5_KT_UNKNOWN_TYPE: krb5_error_code                            = (-1765328204);
3182pub const KRB5_KT_NOTFOUND: krb5_error_code                                = (-1765328203);
3183pub const KRB5_KT_END: krb5_error_code                                     = (-1765328202);
3184pub const KRB5_KT_NOWRITE: krb5_error_code                                 = (-1765328201);
3185pub const KRB5_KT_IOERR: krb5_error_code                                   = (-1765328200);
3186pub const KRB5_NO_TKT_IN_RLM: krb5_error_code                              = (-1765328199);
3187pub const KRB5DES_BAD_KEYPAR: krb5_error_code                              = (-1765328198);
3188pub const KRB5DES_WEAK_KEY: krb5_error_code                                = (-1765328197);
3189pub const KRB5_BAD_ENCTYPE: krb5_error_code                                = (-1765328196);
3190pub const KRB5_BAD_KEYSIZE: krb5_error_code                                = (-1765328195);
3191pub const KRB5_BAD_MSIZE: krb5_error_code                                  = (-1765328194);
3192pub const KRB5_CC_TYPE_EXISTS: krb5_error_code                             = (-1765328193);
3193pub const KRB5_KT_TYPE_EXISTS: krb5_error_code                             = (-1765328192);
3194pub const KRB5_CC_IO: krb5_error_code                                      = (-1765328191);
3195pub const KRB5_FCC_PERM: krb5_error_code                                   = (-1765328190);
3196pub const KRB5_FCC_NOFILE: krb5_error_code                                 = (-1765328189);
3197pub const KRB5_FCC_INTERNAL: krb5_error_code                               = (-1765328188);
3198pub const KRB5_CC_WRITE: krb5_error_code                                   = (-1765328187);
3199pub const KRB5_CC_NOMEM: krb5_error_code                                   = (-1765328186);
3200pub const KRB5_CC_FORMAT: krb5_error_code                                  = (-1765328185);
3201pub const KRB5_CC_NOT_KTYPE: krb5_error_code                               = (-1765328184);
3202pub const KRB5_INVALID_FLAGS: krb5_error_code                              = (-1765328183);
3203pub const KRB5_NO_2ND_TKT: krb5_error_code                                 = (-1765328182);
3204pub const KRB5_NOCREDS_SUPPLIED: krb5_error_code                           = (-1765328181);
3205pub const KRB5_SENDAUTH_BADAUTHVERS: krb5_error_code                       = (-1765328180);
3206pub const KRB5_SENDAUTH_BADAPPLVERS: krb5_error_code                       = (-1765328179);
3207pub const KRB5_SENDAUTH_BADRESPONSE: krb5_error_code                       = (-1765328178);
3208pub const KRB5_SENDAUTH_REJECTED: krb5_error_code                          = (-1765328177);
3209pub const KRB5_PREAUTH_BAD_TYPE: krb5_error_code                           = (-1765328176);
3210pub const KRB5_PREAUTH_NO_KEY: krb5_error_code                             = (-1765328175);
3211pub const KRB5_PREAUTH_FAILED: krb5_error_code                             = (-1765328174);
3212pub const KRB5_RCACHE_BADVNO: krb5_error_code                              = (-1765328173);
3213pub const KRB5_CCACHE_BADVNO: krb5_error_code                              = (-1765328172);
3214pub const KRB5_KEYTAB_BADVNO: krb5_error_code                              = (-1765328171);
3215pub const KRB5_PROG_ATYPE_NOSUPP: krb5_error_code                          = (-1765328170);
3216pub const KRB5_RC_REQUIRED: krb5_error_code                                = (-1765328169);
3217pub const KRB5_ERR_BAD_HOSTNAME: krb5_error_code                           = (-1765328168);
3218pub const KRB5_ERR_HOST_REALM_UNKNOWN: krb5_error_code                     = (-1765328167);
3219pub const KRB5_SNAME_UNSUPP_NAMETYPE: krb5_error_code                      = (-1765328166);
3220pub const KRB5KRB_AP_ERR_V4_REPLY: krb5_error_code                         = (-1765328165);
3221pub const KRB5_REALM_CANT_RESOLVE: krb5_error_code                         = (-1765328164);
3222pub const KRB5_TKT_NOT_FORWARDABLE: krb5_error_code                        = (-1765328163);
3223pub const KRB5_FWD_BAD_PRINCIPAL: krb5_error_code                          = (-1765328162);
3224pub const KRB5_GET_IN_TKT_LOOP: krb5_error_code                            = (-1765328161);
3225pub const KRB5_CONFIG_NODEFREALM: krb5_error_code                          = (-1765328160);
3226pub const KRB5_SAM_UNSUPPORTED: krb5_error_code                            = (-1765328159);
3227pub const KRB5_SAM_INVALID_ETYPE: krb5_error_code                          = (-1765328158);
3228pub const KRB5_SAM_NO_CHECKSUM: krb5_error_code                            = (-1765328157);
3229pub const KRB5_SAM_BAD_CHECKSUM: krb5_error_code                           = (-1765328156);
3230pub const KRB5_KT_NAME_TOOLONG: krb5_error_code                            = (-1765328155);
3231pub const KRB5_KT_KVNONOTFOUND: krb5_error_code                            = (-1765328154);
3232pub const KRB5_APPL_EXPIRED: krb5_error_code                               = (-1765328153);
3233pub const KRB5_LIB_EXPIRED: krb5_error_code                                = (-1765328152);
3234pub const KRB5_CHPW_PWDNULL: krb5_error_code                               = (-1765328151);
3235pub const KRB5_CHPW_FAIL: krb5_error_code                                  = (-1765328150);
3236pub const KRB5_KT_FORMAT: krb5_error_code                                  = (-1765328149);
3237pub const KRB5_NOPERM_ETYPE: krb5_error_code                               = (-1765328148);
3238pub const KRB5_CONFIG_ETYPE_NOSUPP: krb5_error_code                        = (-1765328147);
3239pub const KRB5_OBSOLETE_FN: krb5_error_code                                = (-1765328146);
3240pub const KRB5_EAI_FAIL: krb5_error_code                                   = (-1765328145);
3241pub const KRB5_EAI_NODATA: krb5_error_code                                 = (-1765328144);
3242pub const KRB5_EAI_NONAME: krb5_error_code                                 = (-1765328143);
3243pub const KRB5_EAI_SERVICE: krb5_error_code                                = (-1765328142);
3244pub const KRB5_ERR_NUMERIC_REALM: krb5_error_code                          = (-1765328141);
3245pub const KRB5_ERR_BAD_S2K_PARAMS: krb5_error_code                         = (-1765328140);
3246pub const KRB5_ERR_NO_SERVICE: krb5_error_code                             = (-1765328139);
3247pub const KRB5_CC_READONLY: krb5_error_code                                = (-1765328138);
3248pub const KRB5_CC_NOSUPP: krb5_error_code                                  = (-1765328137);
3249pub const KRB5_DELTAT_BADFORMAT: krb5_error_code                           = (-1765328136);
3250pub const KRB5_PLUGIN_NO_HANDLE: krb5_error_code                           = (-1765328135);
3251pub const KRB5_PLUGIN_OP_NOTSUPP: krb5_error_code                          = (-1765328134);
3252pub const KRB5_ERR_INVALID_UTF8: krb5_error_code                           = (-1765328133);
3253pub const KRB5_ERR_FAST_REQUIRED: krb5_error_code                          = (-1765328132);
3254pub const KRB5_LOCAL_ADDR_REQUIRED: krb5_error_code                        = (-1765328131);
3255pub const KRB5_REMOTE_ADDR_REQUIRED: krb5_error_code                       = (-1765328130);
3256pub const KRB5_TRACE_NOSUPP: krb5_error_code                               = (-1765328129);
3257
3258// NOTE: from krb5/krb5.h : 8445
3259//       not quite sure how to translate this.
3260pub enum error_table {}
3261pub enum et_krb5_error_table {}
3262
3263// TODO: not defined here. search where from!
3264pub enum et_list {}
3265
3266#[link(name = "krb5")]
3267extern "C" {
3268    // TODO: Doc
3269    // NOTE: also extern in header
3270    pub fn initialize_krb5_error_table();
3271    pub fn initialize_krb5_error_table_r(list: *mut *mut et_list);
3272}
3273
3274pub const ERROR_TABLE_BASE_krb5: krb5_error_code = (-1765328384);
3275
3276// TODO: Two defines here for compability with older versions
3277
3278// include et/com_err.h
3279
3280pub const KRB5_PLUGIN_VER_NOTSUPP: krb5_error_code     = (-1750600192);
3281pub const KRB5_PLUGIN_BAD_MODULE_SPEC: krb5_error_code = (-1750600191);
3282pub const KRB5_PLUGIN_NAME_NOTFOUND: krb5_error_code   = (-1750600190);
3283pub const KRB5KDC_ERR_DISCARD: krb5_error_code         = (-1750600189);
3284pub const KRB5_DCC_CANNOT_CREATE: krb5_error_code      = (-1750600188);
3285pub const KRB5_KCC_INVALID_ANCHOR: krb5_error_code     = (-1750600187);
3286pub const KRB5_KCC_UNKNOWN_VERSION: krb5_error_code    = (-1750600186);
3287pub const KRB5_KCC_INVALID_UID: krb5_error_code        = (-1750600185);
3288pub const KRB5_KCM_MALFORMED_REPLY: krb5_error_code    = (-1750600184);
3289pub const KRB5_KCM_RPC_ERROR: krb5_error_code          = (-1750600183);
3290pub const KRB5_KCM_REPLY_TOO_BIG: krb5_error_code      = (-1750600182);
3291pub const KRB5_KCM_NO_SERVER: krb5_error_code          = (-1750600181);
3292
3293// extern const here
3294
3295#[link(name = "krb5")]
3296extern "C" {
3297    // TODO: Doc
3298    // NOTE: Also extern in header
3299    pub fn initialize_k5e1_error_table();
3300    // TODO: Doc
3301    // NOTE: also extern in header
3302    pub fn initialize_k5e1_error_table_r(list: *mut *mut et_list);
3303}
3304
3305pub const ERROR_TABLE_BASE_k5e1: krb5_error_code = (-1750600192);
3306
3307// TODO: two defines for compability with older versions.
3308
3309// TODO: include et/com_err.h
3310
3311pub const KRB5_KDB_RCSID: krb5_error_code                  = (-1780008448);
3312pub const KRB5_KDB_INUSE: krb5_error_code                  = (-1780008447);
3313pub const KRB5_KDB_UK_SERROR: krb5_error_code              = (-1780008446);
3314pub const KRB5_KDB_UK_RERROR: krb5_error_code              = (-1780008445);
3315pub const KRB5_KDB_UNAUTH: krb5_error_code                 = (-1780008444);
3316pub const KRB5_KDB_NOENTRY: krb5_error_code                = (-1780008443);
3317pub const KRB5_KDB_ILL_WILDCARD: krb5_error_code           = (-1780008442);
3318pub const KRB5_KDB_DB_INUSE: krb5_error_code               = (-1780008441);
3319pub const KRB5_KDB_DB_CHANGED: krb5_error_code             = (-1780008440);
3320pub const KRB5_KDB_TRUNCATED_RECORD: krb5_error_code       = (-1780008439);
3321pub const KRB5_KDB_RECURSIVELOCK: krb5_error_code          = (-1780008438);
3322pub const KRB5_KDB_NOTLOCKED: krb5_error_code              = (-1780008437);
3323pub const KRB5_KDB_BADLOCKMODE: krb5_error_code            = (-1780008436);
3324pub const KRB5_KDB_DBNOTINITED: krb5_error_code            = (-1780008435);
3325pub const KRB5_KDB_DBINITED: krb5_error_code               = (-1780008434);
3326pub const KRB5_KDB_ILLDIRECTION: krb5_error_code           = (-1780008433);
3327pub const KRB5_KDB_NOMASTERKEY: krb5_error_code            = (-1780008432);
3328pub const KRB5_KDB_BADMASTERKEY: krb5_error_code           = (-1780008431);
3329pub const KRB5_KDB_INVALIDKEYSIZE: krb5_error_code         = (-1780008430);
3330pub const KRB5_KDB_CANTREAD_STORED: krb5_error_code        = (-1780008429);
3331pub const KRB5_KDB_BADSTORED_MKEY: krb5_error_code         = (-1780008428);
3332pub const KRB5_KDB_NOACTMASTERKEY: krb5_error_code         = (-1780008427);
3333pub const KRB5_KDB_KVNONOMATCH: krb5_error_code            = (-1780008426);
3334pub const KRB5_KDB_STORED_MKEY_NOTCURRENT: krb5_error_code = (-1780008425);
3335pub const KRB5_KDB_CANTLOCK_DB: krb5_error_code            = (-1780008424);
3336pub const KRB5_KDB_DB_CORRUPT: krb5_error_code             = (-1780008423);
3337pub const KRB5_KDB_BAD_VERSION: krb5_error_code            = (-1780008422);
3338pub const KRB5_KDB_BAD_SALTTYPE: krb5_error_code           = (-1780008421);
3339pub const KRB5_KDB_BAD_ENCTYPE: krb5_error_code            = (-1780008420);
3340pub const KRB5_KDB_BAD_CREATEFLAGS: krb5_error_code        = (-1780008419);
3341pub const KRB5_KDB_NO_PERMITTED_KEY: krb5_error_code       = (-1780008418);
3342pub const KRB5_KDB_NO_MATCHING_KEY: krb5_error_code        = (-1780008417);
3343pub const KRB5_KDB_DBTYPE_NOTFOUND: krb5_error_code        = (-1780008416);
3344pub const KRB5_KDB_DBTYPE_NOSUP: krb5_error_code           = (-1780008415);
3345pub const KRB5_KDB_DBTYPE_INIT: krb5_error_code            = (-1780008414);
3346pub const KRB5_KDB_SERVER_INTERNAL_ERR: krb5_error_code    = (-1780008413);
3347pub const KRB5_KDB_ACCESS_ERROR: krb5_error_code           = (-1780008412);
3348pub const KRB5_KDB_INTERNAL_ERROR: krb5_error_code         = (-1780008411);
3349pub const KRB5_KDB_CONSTRAINT_VIOLATION: krb5_error_code   = (-1780008410);
3350pub const KRB5_LOG_CONV: krb5_error_code                   = (-1780008409);
3351pub const KRB5_LOG_UNSTABLE: krb5_error_code               = (-1780008408);
3352pub const KRB5_LOG_CORRUPT: krb5_error_code                = (-1780008407);
3353pub const KRB5_LOG_ERROR: krb5_error_code                  = (-1780008406);
3354pub const KRB5_KDB_DBTYPE_MISMATCH: krb5_error_code        = (-1780008405);
3355pub const KRB5_KDB_POLICY_REF: krb5_error_code             = (-1780008404);
3356pub const KRB5_KDB_STRINGS_TOOLONG: krb5_error_code        = (-1780008403);
3357
3358// TODO: extern const struct.
3359
3360#[link(name = "krb5")]
3361extern "C" {
3362    // NOTE: also extern in header
3363    pub fn initialize_kdb5_error_table();
3364    // NOTE: also extern in header
3365    pub fn initialize_kdb5_error_table_r(list: *mut *mut et_list);
3366}
3367
3368pub const ERROR_TABLE_BASE_kdb5: krb5_error_code = (-1780008448);
3369
3370// TODO: two macros for compability with older versions
3371
3372// TODO: include et/com_err.h
3373
3374pub const KV5M_NONE: krb5_error_code                   = (-1760647424);
3375pub const KV5M_PRINCIPAL: krb5_error_code              = (-1760647423);
3376pub const KV5M_DATA: krb5_error_code                   = (-1760647422);
3377pub const KV5M_KEYBLOCK: krb5_error_code               = (-1760647421);
3378pub const KV5M_CHECKSUM: krb5_error_code               = (-1760647420);
3379pub const KV5M_ENCRYPT_BLOCK: krb5_error_code          = (-1760647419);
3380pub const KV5M_ENC_DATA: krb5_error_code               = (-1760647418);
3381pub const KV5M_CRYPTOSYSTEM_ENTRY: krb5_error_code     = (-1760647417);
3382pub const KV5M_CS_TABLE_ENTRY: krb5_error_code         = (-1760647416);
3383pub const KV5M_CHECKSUM_ENTRY: krb5_error_code         = (-1760647415);
3384pub const KV5M_AUTHDATA: krb5_error_code               = (-1760647414);
3385pub const KV5M_TRANSITED: krb5_error_code              = (-1760647413);
3386pub const KV5M_ENC_TKT_PART: krb5_error_code           = (-1760647412);
3387pub const KV5M_TICKET: krb5_error_code                 = (-1760647411);
3388pub const KV5M_AUTHENTICATOR: krb5_error_code          = (-1760647410);
3389pub const KV5M_TKT_AUTHENT: krb5_error_code            = (-1760647409);
3390pub const KV5M_CREDS: krb5_error_code                  = (-1760647408);
3391pub const KV5M_LAST_REQ_ENTRY: krb5_error_code         = (-1760647407);
3392pub const KV5M_PA_DATA: krb5_error_code                = (-1760647406);
3393pub const KV5M_KDC_REQ: krb5_error_code                = (-1760647405);
3394pub const KV5M_ENC_KDC_REP_PART: krb5_error_code       = (-1760647404);
3395pub const KV5M_KDC_REP: krb5_error_code                = (-1760647403);
3396pub const KV5M_ERROR: krb5_error_code                  = (-1760647402);
3397pub const KV5M_AP_REQ: krb5_error_code                 = (-1760647401);
3398pub const KV5M_AP_REP: krb5_error_code                 = (-1760647400);
3399pub const KV5M_AP_REP_ENC_PART: krb5_error_code        = (-1760647399);
3400pub const KV5M_RESPONSE: krb5_error_code               = (-1760647398);
3401pub const KV5M_SAFE: krb5_error_code                   = (-1760647397);
3402pub const KV5M_PRIV: krb5_error_code                   = (-1760647396);
3403pub const KV5M_PRIV_ENC_PART: krb5_error_code          = (-1760647395);
3404pub const KV5M_CRED: krb5_error_code                   = (-1760647394);
3405pub const KV5M_CRED_INFO: krb5_error_code              = (-1760647393);
3406pub const KV5M_CRED_ENC_PART: krb5_error_code          = (-1760647392);
3407pub const KV5M_PWD_DATA: krb5_error_code               = (-1760647391);
3408pub const KV5M_ADDRESS: krb5_error_code                = (-1760647390);
3409pub const KV5M_KEYTAB_ENTRY: krb5_error_code           = (-1760647389);
3410pub const KV5M_CONTEXT: krb5_error_code                = (-1760647388);
3411pub const KV5M_OS_CONTEXT: krb5_error_code             = (-1760647387);
3412pub const KV5M_ALT_METHOD: krb5_error_code             = (-1760647386);
3413pub const KV5M_ETYPE_INFO_ENTRY: krb5_error_code       = (-1760647385);
3414pub const KV5M_DB_CONTEXT: krb5_error_code             = (-1760647384);
3415pub const KV5M_AUTH_CONTEXT: krb5_error_code           = (-1760647383);
3416pub const KV5M_KEYTAB: krb5_error_code                 = (-1760647382);
3417pub const KV5M_RCACHE: krb5_error_code                 = (-1760647381);
3418pub const KV5M_CCACHE: krb5_error_code                 = (-1760647380);
3419pub const KV5M_PREAUTH_OPS: krb5_error_code            = (-1760647379);
3420pub const KV5M_SAM_CHALLENGE: krb5_error_code          = (-1760647378);
3421pub const KV5M_SAM_CHALLENGE_2: krb5_error_code        = (-1760647377);
3422pub const KV5M_SAM_KEY: krb5_error_code                = (-1760647376);
3423pub const KV5M_ENC_SAM_RESPONSE_ENC: krb5_error_code   = (-1760647375);
3424pub const KV5M_ENC_SAM_RESPONSE_ENC_2: krb5_error_code = (-1760647374);
3425pub const KV5M_SAM_RESPONSE: krb5_error_code           = (-1760647373);
3426pub const KV5M_SAM_RESPONSE_2: krb5_error_code         = (-1760647372);
3427pub const KV5M_PREDICTED_SAM_RESPONSE: krb5_error_code = (-1760647371);
3428pub const KV5M_PASSWD_PHRASE_ELEMENT: krb5_error_code  = (-1760647370);
3429pub const KV5M_GSS_OID: krb5_error_code                = (-1760647369);
3430pub const KV5M_GSS_QUEUE: krb5_error_code              = (-1760647368);
3431pub const KV5M_FAST_ARMORED_REQ: krb5_error_code       = (-1760647367);
3432pub const KV5M_FAST_REQ: krb5_error_code               = (-1760647366);
3433pub const KV5M_FAST_RESPONSE: krb5_error_code          = (-1760647365);
3434pub const KV5M_AUTHDATA_CONTEXT: krb5_error_code       = (-1760647364);
3435// TODO: extern const here
3436
3437#[link(name = "krb5")]
3438extern "C" {
3439    // NOTE: also extern in the header
3440    pub fn initialize_kv5m_error_table();
3441    // NOTE: also extern in the header
3442    pub fn initialize_kv5m_error_table_r(list: *mut *mut et_list);
3443}
3444
3445pub const ERROR_TABLE_BASE_kv5m: krb5_error_code = (-1760647424);
3446
3447// TODO: Two macros for compability with older versions
3448
3449// TODO: include et/com_err.h
3450
3451pub const KRB524_BADKEY: krb5_error_code        = (-1750206208);
3452pub const KRB524_BADADDR: krb5_error_code       = (-1750206207);
3453pub const KRB524_BADPRINC: krb5_error_code      = (-1750206206);
3454pub const KRB524_BADREALM: krb5_error_code      = (-1750206205);
3455pub const KRB524_V4ERR: krb5_error_code         = (-1750206204);
3456pub const KRB524_ENCFULL: krb5_error_code       = (-1750206203);
3457pub const KRB524_DECEMPTY: krb5_error_code      = (-1750206202);
3458pub const KRB524_NOTRESP: krb5_error_code       = (-1750206201);
3459pub const KRB524_KRB4_DISABLED: krb5_error_code = (-1750206200);
3460// TODO extern const here
3461
3462#[link(name = "krb5")]
3463extern "C" {
3464    // NOTE: also extern in header
3465    pub fn initialize_k524_error_table();
3466    // NOTE: also extern in header
3467    pub fn initialize_k524_error_table_r(list: *mut *mut et_list);
3468}
3469
3470pub const ERROR_TABLE_BASE_k524: krb5_error_code = (-1750206208);
3471
3472// TODO: two macros for compability with older versions
3473
3474// TODO: include et/com_err.h
3475
3476
3477pub const ASN1_BAD_TIMEFORMAT: krb5_error_code  = (1859794432);
3478pub const ASN1_MISSING_FIELD: krb5_error_code   = (1859794433);
3479pub const ASN1_MISPLACED_FIELD: krb5_error_code = (1859794434);
3480pub const ASN1_TYPE_MISMATCH: krb5_error_code   = (1859794435);
3481pub const ASN1_OVERFLOW: krb5_error_code        = (1859794436);
3482pub const ASN1_OVERRUN: krb5_error_code         = (1859794437);
3483pub const ASN1_BAD_ID: krb5_error_code          = (1859794438);
3484pub const ASN1_BAD_LENGTH: krb5_error_code      = (1859794439);
3485pub const ASN1_BAD_FORMAT: krb5_error_code      = (1859794440);
3486pub const ASN1_PARSE_ERROR: krb5_error_code     = (1859794441);
3487pub const ASN1_BAD_GMTIME: krb5_error_code      = (1859794442);
3488pub const ASN1_MISMATCH_INDEF: krb5_error_code  = (1859794443);
3489pub const ASN1_MISSING_EOC: krb5_error_code     = (1859794444);
3490pub const ASN1_OMITTED: krb5_error_code         = (1859794445);
3491// TODO: extern const here..
3492
3493#[link(name = "krb5")]
3494extern "C" {
3495    // NOTE: also extern in header
3496    pub fn initlialize_asn1_error_table();
3497    // NOTE: also extern in header
3498    pub fn initlialize_asn1_error_table_r(list: *mut *mut et_list);
3499}
3500
3501pub const ERROR_TABLE_BASE_asn1: krb5_error_code = (1859794432);
3502
3503// TODO: two macros for compatibility with older versions
3504#[cfg(test)]
3505mod test_nullable_callbacks {
3506    use std::ptr;
3507    use std::os::raw::*;
3508    use crate as k5;
3509
3510    #[test]
3511    fn test_checksum_fn_set_get_null() {
3512        let mut ctx : k5::krb5_context = ptr::null_mut();
3513        let mut actx: k5::krb5_auth_context = ptr::null_mut();
3514
3515        assert_eq!(0, unsafe {
3516            k5::krb5_init_context(&mut ctx)
3517        });
3518
3519        assert_eq!(0, unsafe {
3520            k5::krb5_auth_con_init(ctx, &mut actx)
3521        });
3522
3523        /* Erase callback. */
3524        assert_eq!(0, unsafe {
3525            k5::krb5_auth_con_set_checksum_func
3526                (ctx, actx, None, ptr::null_mut())
3527        });
3528
3529        let mut dst_func: Option<k5::krb5_mk_req_checksum_func> = None;
3530        let mut dst_data: *mut c_void = ptr::null_mut();
3531
3532        /* Retrieve callback; result should be None. */
3533        assert_eq!(0, unsafe {
3534            k5::krb5_auth_con_get_checksum_func
3535                (ctx, actx, &mut dst_func, &mut dst_data)
3536        });
3537
3538        assert_eq!(dst_func, None);
3539        assert_eq!(dst_data, ptr::null_mut());
3540
3541        assert_eq!(0, unsafe { k5::krb5_auth_con_free(ctx, actx) });
3542
3543        unsafe { k5::krb5_free_context(ctx) };
3544    }
3545
3546    #[test]
3547    fn test_responder_fn_set_null() {
3548        let mut ctx : k5::krb5_context = ptr::null_mut();
3549
3550        assert_eq!(0, unsafe {
3551            k5::krb5_init_context(&mut ctx)
3552        });
3553
3554        let mut opts: *mut k5::krb5_get_init_creds_opt = ptr::null_mut();
3555
3556        assert_eq!(0, unsafe {
3557            k5::krb5_get_init_creds_opt_alloc(ctx, &mut opts)
3558        });
3559
3560        /* Erase callback. */
3561        assert_eq!(0, unsafe {
3562            k5::krb5_get_init_creds_opt_set_responder
3563                (ctx, opts, None, ptr::null_mut())
3564        });
3565
3566        unsafe { k5::krb5_get_init_creds_opt_free(ctx, opts) };
3567
3568        unsafe { k5::krb5_free_context(ctx) };
3569    }
3570
3571    /* Test ignored by default as it will normally cause a contacting a
3572       non-existent KDC or another error. */
3573    #[ignore]
3574    #[test]
3575    fn test_prompter_fn_set_null() {
3576        let mut ctx : k5::krb5_context = ptr::null_mut();
3577
3578        assert_eq!(0, unsafe {
3579            k5::krb5_init_context(&mut ctx)
3580        });
3581
3582        let mut creds: k5::krb5_creds = unsafe {
3583            std::mem::MaybeUninit::zeroed().assume_init()
3584        };
3585
3586        let name: &'static [u8] = b"test\0";
3587        let mut princ: k5::krb5_principal = ptr::null_mut();
3588
3589        assert_eq!(0, unsafe {
3590            k5::krb5_parse_name(ctx, name.as_ptr() as *const c_char, &mut princ)
3591        });
3592
3593        /* Call without password and with a null callback; this operation
3594           is expected to fail. The test is considered successful if below
3595           call does not segfault on account of a null pointer dereference. */
3596        assert_ne!(0, unsafe {
3597            k5::krb5_get_init_creds_password
3598                (ctx,
3599                 &mut creds,
3600                 princ,
3601                 ptr::null(),       /* don't set password -> use prompter */
3602                 None,              /* unset prompter callback */
3603                 ptr::null_mut(),
3604                 0,
3605                 ptr::null(),
3606                 ptr::null())
3607        });
3608
3609        unsafe { k5::krb5_free_principal(ctx, princ) };
3610        unsafe { k5::krb5_free_context(ctx) };
3611    }
3612
3613    #[test]
3614    fn test_trace_fn_set_null() {
3615        let mut ctx : k5::krb5_context = ptr::null_mut();
3616
3617        assert_eq!(0, unsafe {
3618            k5::krb5_init_context(&mut ctx)
3619        });
3620
3621        /* Erase callback. */
3622        assert_eq!(0, unsafe {
3623            k5::krb5_set_trace_callback
3624                (ctx, None, ptr::null_mut())
3625        });
3626
3627        unsafe { k5::krb5_free_context(ctx) };
3628    }
3629}
3630