code:
/*
 * Copyright (c) 1997 - 2007 Kungliga Tekniska H�gskolan
 * (Royal Institute of Technology, Stockholm, Sweden).
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 *
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 *
 * 3. Neither the name of the Institute nor the names of its contributors
 *    may be used to endorse or promote products derived from this software
 *    without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 */

/* $Id: krb5.h 22100 2007-12-03 17:15:00Z lha $ */

#ifndef __KRB5_H__
#define __KRB5_H__

#include <time.h>
#include <krb5-types.h>

#include <asn1_err.h>
#include <krb5_err.h>
#include <heim_err.h>
#include <k524_err.h>

#include <krb5_asn1.h>

/* name confusion with MIT */
#ifndef KRB5KDC_ERR_KEY_EXP
#define KRB5KDC_ERR_KEY_EXP KRB5KDC_ERR_KEY_EXPIRED
#endif

/* simple constants */

#ifndef TRUE
#define TRUE  1
#define FALSE 0
#endif

typedef int krb5_boolean;

typedef int32_t krb5_error_code;

typedef int krb5_kvno;

typedef uint32_t krb5_flags;

typedef void *krb5_pointer;
typedef const void *krb5_const_pointer;

struct krb5_crypto_data;
typedef struct krb5_crypto_data *krb5_crypto;

struct krb5_get_creds_opt_data;
typedef struct krb5_get_creds_opt_data *krb5_get_creds_opt;

struct krb5_digest_data;
typedef struct krb5_digest_data *krb5_digest;
struct krb5_ntlm_data;
typedef struct krb5_ntlm_data *krb5_ntlm;

struct krb5_pac_data;
typedef struct krb5_pac_data *krb5_pac;

typedef struct krb5_rd_req_in_ctx_data *krb5_rd_req_in_ctx;
typedef struct krb5_rd_req_out_ctx_data *krb5_rd_req_out_ctx;

typedef CKSUMTYPE krb5_cksumtype;

typedef Checksum krb5_checksum;

typedef ENCTYPE krb5_enctype;

typedef heim_octet_string krb5_data;

/* PKINIT related forward declarations */
struct ContentInfo;
struct krb5_pk_identity;
struct krb5_pk_cert;

/* krb5_enc_data is a mit compat structure */
typedef struct krb5_enc_data {
    krb5_enctype enctype;
    krb5_kvno kvno;
    krb5_data ciphertext;
} krb5_enc_data;

/* alternative names */
enum {
    ENCTYPE_NULL		= ETYPE_NULL,
    ENCTYPE_DES_CBC_CRC		= ETYPE_DES_CBC_CRC,
    ENCTYPE_DES_CBC_MD4		= ETYPE_DES_CBC_MD4,
    ENCTYPE_DES_CBC_MD5		= ETYPE_DES_CBC_MD5,
    ENCTYPE_DES3_CBC_MD5	= ETYPE_DES3_CBC_MD5,
    ENCTYPE_OLD_DES3_CBC_SHA1	= ETYPE_OLD_DES3_CBC_SHA1,
    ENCTYPE_SIGN_DSA_GENERATE	= ETYPE_SIGN_DSA_GENERATE,
    ENCTYPE_ENCRYPT_RSA_PRIV	= ETYPE_ENCRYPT_RSA_PRIV,
    ENCTYPE_ENCRYPT_RSA_PUB	= ETYPE_ENCRYPT_RSA_PUB,
    ENCTYPE_DES3_CBC_SHA1	= ETYPE_DES3_CBC_SHA1,
    ENCTYPE_AES128_CTS_HMAC_SHA1_96 = ETYPE_AES128_CTS_HMAC_SHA1_96,
    ENCTYPE_AES256_CTS_HMAC_SHA1_96 = ETYPE_AES256_CTS_HMAC_SHA1_96,
    ENCTYPE_ARCFOUR_HMAC	= ETYPE_ARCFOUR_HMAC_MD5,
    ENCTYPE_ARCFOUR_HMAC_MD5	= ETYPE_ARCFOUR_HMAC_MD5,
    ENCTYPE_ARCFOUR_HMAC_MD5_56	= ETYPE_ARCFOUR_HMAC_MD5_56,
    ENCTYPE_ENCTYPE_PK_CROSS	= ETYPE_ENCTYPE_PK_CROSS,
    ENCTYPE_DES_CBC_NONE	= ETYPE_DES_CBC_NONE,
    ENCTYPE_DES3_CBC_NONE	= ETYPE_DES3_CBC_NONE,
    ENCTYPE_DES_CFB64_NONE	= ETYPE_DES_CFB64_NONE,
    ENCTYPE_DES_PCBC_NONE	= ETYPE_DES_PCBC_NONE
};

typedef PADATA_TYPE krb5_preauthtype;

typedef enum krb5_key_usage {
    KRB5_KU_PA_ENC_TIMESTAMP = 1,
    /* AS-REQ PA-ENC-TIMESTAMP padata timestamp, encrypted with the
       client key (section 5.4.1) */
    KRB5_KU_TICKET = 2,
    /* AS-REP Ticket and TGS-REP Ticket (includes tgs session key or
       application session key), encrypted with the service key
       (section 5.4.2) */
    KRB5_KU_AS_REP_ENC_PART = 3,
    /* AS-REP encrypted part (includes tgs session key or application
       session key), encrypted with the client key (section 5.4.2) */
    KRB5_KU_TGS_REQ_AUTH_DAT_SESSION = 4,
    /* TGS-REQ KDC-REQ-BODY AuthorizationData, encrypted with the tgs
       session key (section 5.4.1) */
    KRB5_KU_TGS_REQ_AUTH_DAT_SUBKEY = 5,
    /* TGS-REQ KDC-REQ-BODY AuthorizationData, encrypted with the tgs
          authenticator subkey (section 5.4.1) */
    KRB5_KU_TGS_REQ_AUTH_CKSUM = 6,
    /* TGS-REQ PA-TGS-REQ padata AP-REQ Authenticator cksum, keyed
       with the tgs session key (sections 5.3.2, 5.4.1) */
    KRB5_KU_TGS_REQ_AUTH = 7,
    /* TGS-REQ PA-TGS-REQ padata AP-REQ Authenticator (includes tgs
       authenticator subkey), encrypted with the tgs session key
       (section 5.3.2) */
    KRB5_KU_TGS_REP_ENC_PART_SESSION = 8,
    /* TGS-REP encrypted part (includes application session key),
       encrypted with the tgs session key (section 5.4.2) */
    KRB5_KU_TGS_REP_ENC_PART_SUB_KEY = 9,
    /* TGS-REP encrypted part (includes application session key),
       encrypted with the tgs authenticator subkey (section 5.4.2) */
    KRB5_KU_AP_REQ_AUTH_CKSUM = 10,
    /* AP-REQ Authenticator cksum, keyed with the application session
       key (section 5.3.2) */
    KRB5_KU_AP_REQ_AUTH = 11,
    /* AP-REQ Authenticator (includes application authenticator
       subkey), encrypted with the application session key (section
       5.3.2) */
    KRB5_KU_AP_REQ_ENC_PART = 12,
    /* AP-REP encrypted part (includes application session subkey),
       encrypted with the application session key (section 5.5.2) */
    KRB5_KU_KRB_PRIV = 13,
    /* KRB-PRIV encrypted part, encrypted with a key chosen by the
       application (section 5.7.1) */
    KRB5_KU_KRB_CRED = 14,
    /* KRB-CRED encrypted part, encrypted with a key chosen by the
       application (section 5.8.1) */
    KRB5_KU_KRB_SAFE_CKSUM = 15,
    /* KRB-SAFE cksum, keyed with a key chosen by the application
       (section 5.6.1) */
    KRB5_KU_OTHER_ENCRYPTED = 16,
    /* Data which is defined in some specification outside of
       Kerberos to be encrypted using an RFC1510 encryption type. */
    KRB5_KU_OTHER_CKSUM = 17,
    /* Data which is defined in some specification outside of
       Kerberos to be checksummed using an RFC1510 checksum type. */
    KRB5_KU_KRB_ERROR = 18,
    /* Krb-error checksum */
    KRB5_KU_AD_KDC_ISSUED = 19,
    /* AD-KDCIssued checksum */
    KRB5_KU_MANDATORY_TICKET_EXTENSION = 20,
    /* Checksum for Mandatory Ticket Extensions */
    KRB5_KU_AUTH_DATA_TICKET_EXTENSION = 21,
    /* Checksum in Authorization Data in Ticket Extensions */
    KRB5_KU_USAGE_SEAL = 22,
    /* seal in GSSAPI krb5 mechanism */
    KRB5_KU_USAGE_SIGN = 23,
    /* sign in GSSAPI krb5 mechanism */
    KRB5_KU_USAGE_SEQ = 24,
    /* SEQ in GSSAPI krb5 mechanism */
    KRB5_KU_USAGE_ACCEPTOR_SEAL = 22,
    /* acceptor sign in GSSAPI CFX krb5 mechanism */
    KRB5_KU_USAGE_ACCEPTOR_SIGN = 23,
    /* acceptor seal in GSSAPI CFX krb5 mechanism */
    KRB5_KU_USAGE_INITIATOR_SEAL = 24,
    /* initiator sign in GSSAPI CFX krb5 mechanism */
    KRB5_KU_USAGE_INITIATOR_SIGN = 25,
    /* initiator seal in GSSAPI CFX krb5 mechanism */
    KRB5_KU_PA_SERVER_REFERRAL_DATA = 22,
    /* encrypted server referral data */
    KRB5_KU_SAM_CHECKSUM = 25,
    /* Checksum for the SAM-CHECKSUM field */
    KRB5_KU_SAM_ENC_TRACK_ID = 26,
    /* Encryption of the SAM-TRACK-ID field */
    KRB5_KU_PA_SERVER_REFERRAL = 26,
    /* Keyusage for the server referral in a TGS req */
    KRB5_KU_SAM_ENC_NONCE_SAD = 27,
    /* Encryption of the SAM-NONCE-OR-SAD field */
    KRB5_KU_DIGEST_ENCRYPT = -18,
    /* Encryption key usage used in the digest encryption field */
    KRB5_KU_DIGEST_OPAQUE = -19,
    /* Checksum key usage used in the digest opaque field */
    KRB5_KU_KRB5SIGNEDPATH = -21,
    /* Checksum key usage on KRB5SignedPath */
    KRB5_KU_CANONICALIZED_NAMES = -23
    /* Checksum key usage on PA-CANONICALIZED */
} krb5_key_usage;

typedef krb5_key_usage krb5_keyusage;

typedef enum krb5_salttype {
    KRB5_PW_SALT = KRB5_PADATA_PW_SALT,
    KRB5_AFS3_SALT = KRB5_PADATA_AFS3_SALT
}krb5_salttype;

typedef struct krb5_salt {
    krb5_salttype salttype;
    krb5_data saltvalue;
} krb5_salt;

typedef ETYPE_INFO krb5_preauthinfo;

typedef struct {
    krb5_preauthtype type;
    krb5_preauthinfo info; /* list of preauthinfo for this type */
} krb5_preauthdata_entry;

typedef struct krb5_preauthdata {
    unsigned len;
    krb5_preauthdata_entry *val;
}krb5_preauthdata;

typedef enum krb5_address_type {
    KRB5_ADDRESS_INET     =   2,
    KRB5_ADDRESS_NETBIOS  =  20,
    KRB5_ADDRESS_INET6    =  24,
    KRB5_ADDRESS_ADDRPORT = 256,
    KRB5_ADDRESS_IPPORT   = 257
} krb5_address_type;

enum {
  AP_OPTS_USE_SESSION_KEY = 1,
  AP_OPTS_MUTUAL_REQUIRED = 2,
  AP_OPTS_USE_SUBKEY = 4		/* library internal */
};

typedef HostAddress krb5_address;

typedef HostAddresses krb5_addresses;

typedef enum krb5_keytype {
    KEYTYPE_NULL	= 0,
    KEYTYPE_DES		= 1,
    KEYTYPE_DES3	= 7,
    KEYTYPE_AES128	= 17,
    KEYTYPE_AES256	= 18,
    KEYTYPE_ARCFOUR	= 23,
    KEYTYPE_ARCFOUR_56	= 24
} krb5_keytype;

typedef EncryptionKey krb5_keyblock;

typedef AP_REQ krb5_ap_req;

struct krb5_cc_ops;

#define KRB5_DEFAULT_CCFILE_ROOT "/tmp/krb5cc_"

#define KRB5_DEFAULT_CCROOT "FILE:" KRB5_DEFAULT_CCFILE_ROOT

#define KRB5_ACCEPT_NULL_ADDRESSES(C) 					 \
    krb5_config_get_bool_default((C), NULL, TRUE, 			 \
				 "libdefaults", "accept_null_addresses", \
				 NULL)

typedef void *krb5_cc_cursor;

typedef struct krb5_ccache_data {
    const struct krb5_cc_ops *ops;
    krb5_data data;
}krb5_ccache_data;

typedef struct krb5_ccache_data *krb5_ccache;

typedef struct krb5_context_data *krb5_context;

typedef Realm krb5_realm;
typedef const char *krb5_const_realm; /* stupid language */

#define krb5_realm_length(r) strlen(r)
#define krb5_realm_data(r) (r)

typedef Principal krb5_principal_data;
typedef struct Principal *krb5_principal;
typedef const struct Principal *krb5_const_principal;

typedef time_t krb5_deltat;
typedef time_t krb5_timestamp;

typedef struct krb5_times {
  krb5_timestamp authtime;
  krb5_timestamp starttime;
  krb5_timestamp endtime;
  krb5_timestamp renew_till;
} krb5_times;

typedef union {
    TicketFlags b;
    krb5_flags i;
} krb5_ticket_flags;

/* options for krb5_get_in_tkt() */
#define KDC_OPT_FORWARDABLE		(1 << 1)
#define KDC_OPT_FORWARDED		(1 << 2)
#define KDC_OPT_PROXIABLE		(1 << 3)
#define KDC_OPT_PROXY			(1 << 4)
#define KDC_OPT_ALLOW_POSTDATE		(1 << 5)
#define KDC_OPT_POSTDATED		(1 << 6)
#define KDC_OPT_RENEWABLE		(1 << 8)
#define KDC_OPT_REQUEST_ANONYMOUS	(1 << 14)
#define KDC_OPT_DISABLE_TRANSITED_CHECK	(1 << 26)
#define KDC_OPT_RENEWABLE_OK		(1 << 27)
#define KDC_OPT_ENC_TKT_IN_SKEY		(1 << 28)
#define KDC_OPT_RENEW			(1 << 30)
#define KDC_OPT_VALIDATE		(1 << 31)

typedef union {
    KDCOptions b;
    krb5_flags i;
} krb5_kdc_flags;

/* flags for krb5_verify_ap_req */

#define KRB5_VERIFY_AP_REQ_IGNORE_INVALID	(1 << 0)

#define KRB5_GC_CACHED			(1U << 0)
#define KRB5_GC_USER_USER		(1U << 1)
#define KRB5_GC_EXPIRED_OK		(1U << 2)
#define KRB5_GC_NO_STORE		(1U << 3)
#define KRB5_GC_FORWARDABLE		(1U << 4)
#define KRB5_GC_NO_TRANSIT_CHECK	(1U << 5)
#define KRB5_GC_CONSTRAINED_DELEGATION	(1U << 6)

/* constants for compare_creds (and cc_retrieve_cred) */
#define KRB5_TC_DONT_MATCH_REALM	(1U << 31)
#define KRB5_TC_MATCH_KEYTYPE		(1U << 30)
#define KRB5_TC_MATCH_KTYPE		KRB5_TC_MATCH_KEYTYPE    /* MIT name */
#define KRB5_TC_MATCH_SRV_NAMEONLY	(1 << 29)
#define KRB5_TC_MATCH_FLAGS_EXACT	(1 << 28)
#define KRB5_TC_MATCH_FLAGS		(1 << 27)
#define KRB5_TC_MATCH_TIMES_EXACT	(1 << 26)
#define KRB5_TC_MATCH_TIMES		(1 << 25)
#define KRB5_TC_MATCH_AUTHDATA		(1 << 24)
#define KRB5_TC_MATCH_2ND_TKT		(1 << 23)
#define KRB5_TC_MATCH_IS_SKEY		(1 << 22)

typedef AuthorizationData krb5_authdata;

typedef KRB_ERROR krb5_error;

typedef struct krb5_creds {
    krb5_principal client;
    krb5_principal server;
    krb5_keyblock session;
    krb5_times times;
    krb5_data ticket;
    krb5_data second_ticket;
    krb5_authdata authdata;
    krb5_addresses addresses;
    krb5_ticket_flags flags;
} krb5_creds;

typedef struct krb5_cc_cache_cursor_data *krb5_cc_cache_cursor;

typedef struct krb5_cc_ops {
    const char *prefix;
    const char* (*get_name)(krb5_context, krb5_ccache);
    krb5_error_code (*resolve)(krb5_context, krb5_ccache *, const char *);
    krb5_error_code (*gen_new)(krb5_context, krb5_ccache *);
    krb5_error_code (*init)(krb5_context, krb5_ccache, krb5_principal);
    krb5_error_code (*destroy)(krb5_context, krb5_ccache);
    krb5_error_code (*close)(krb5_context, krb5_ccache);
    krb5_error_code (*store)(krb5_context, krb5_ccache, krb5_creds*);
    krb5_error_code (*retrieve)(krb5_context, krb5_ccache,
				krb5_flags, const krb5_creds*, krb5_creds *);
    krb5_error_code (*get_princ)(krb5_context, krb5_ccache, krb5_principal*);
    krb5_error_code (*get_first)(krb5_context, krb5_ccache, krb5_cc_cursor *);
    krb5_error_code (*get_next)(krb5_context, krb5_ccache,
				krb5_cc_cursor*, krb5_creds*);
    krb5_error_code (*end_get)(krb5_context, krb5_ccache, krb5_cc_cursor*);
    krb5_error_code (*remove_cred)(krb5_context, krb5_ccache,
				   krb5_flags, krb5_creds*);
    krb5_error_code (*set_flags)(krb5_context, krb5_ccache, krb5_flags);
    int (*get_version)(krb5_context, krb5_ccache);
    krb5_error_code (*get_cache_first)(krb5_context, krb5_cc_cursor *);
    krb5_error_code (*get_cache_next)(krb5_context, krb5_cc_cursor, krb5_ccache *);
    krb5_error_code (*end_cache_get)(krb5_context, krb5_cc_cursor);
    krb5_error_code (*move)(krb5_context, krb5_ccache, krb5_ccache);
    krb5_error_code (*default_name)(krb5_context, char **);
} krb5_cc_ops;

struct krb5_log_facility;

struct krb5_config_binding {
    enum { krb5_config_string, krb5_config_list } type;
    char *name;
    struct krb5_config_binding *next;
    union {
	char *string;
	struct krb5_config_binding *list;
	void *generic;
    } u;
};

typedef struct krb5_config_binding krb5_config_binding;

typedef krb5_config_binding krb5_config_section;

typedef struct krb5_ticket {
    EncTicketPart ticket;
    krb5_principal client;
    krb5_principal server;
} krb5_ticket;

typedef Authenticator krb5_authenticator_data;

typedef krb5_authenticator_data *krb5_authenticator;

struct krb5_rcache_data;
typedef struct krb5_rcache_data *krb5_rcache;
typedef Authenticator krb5_donot_replay;

#define KRB5_STORAGE_HOST_BYTEORDER			0x01 /* old */
#define KRB5_STORAGE_PRINCIPAL_WRONG_NUM_COMPONENTS	0x02
#define KRB5_STORAGE_PRINCIPAL_NO_NAME_TYPE		0x04
#define KRB5_STORAGE_KEYBLOCK_KEYTYPE_TWICE		0x08
#define KRB5_STORAGE_BYTEORDER_MASK			0x60
#define KRB5_STORAGE_BYTEORDER_BE			0x00 /* default */
#define KRB5_STORAGE_BYTEORDER_LE			0x20
#define KRB5_STORAGE_BYTEORDER_HOST			0x40
#define KRB5_STORAGE_CREDS_FLAGS_WRONG_BITORDER		0x80

struct krb5_storage_data;
typedef struct krb5_storage_data krb5_storage;

typedef struct krb5_keytab_entry {
    krb5_principal principal;
    krb5_kvno vno;
    krb5_keyblock keyblock;
    uint32_t timestamp;
} krb5_keytab_entry;

typedef struct krb5_kt_cursor {
    int fd;
    krb5_storage *sp;
    void *data;
} krb5_kt_cursor;

struct krb5_keytab_data;

typedef struct krb5_keytab_data *krb5_keytab;

#define KRB5_KT_PREFIX_MAX_LEN	30

struct krb5_keytab_data {
    const char *prefix;
    krb5_error_code (*resolve)(krb5_context, const char*, krb5_keytab);
    krb5_error_code (*get_name)(krb5_context, krb5_keytab, char*, size_t);
    krb5_error_code (*close)(krb5_context, krb5_keytab);
    krb5_error_code (*get)(krb5_context, krb5_keytab, krb5_const_principal,
			   krb5_kvno, krb5_enctype, krb5_keytab_entry*);
    krb5_error_code (*start_seq_get)(krb5_context, krb5_keytab, krb5_kt_cursor*);
    krb5_error_code (*next_entry)(krb5_context, krb5_keytab,
				  krb5_keytab_entry*, krb5_kt_cursor*);
    krb5_error_code (*end_seq_get)(krb5_context, krb5_keytab, krb5_kt_cursor*);
    krb5_error_code (*add)(krb5_context, krb5_keytab, krb5_keytab_entry*);
    krb5_error_code (*remove)(krb5_context, krb5_keytab, krb5_keytab_entry*);
    void *data;
    int32_t version;
};

typedef struct krb5_keytab_data krb5_kt_ops;

struct krb5_keytab_key_proc_args {
    krb5_keytab keytab;
    krb5_principal principal;
};

typedef struct krb5_keytab_key_proc_args krb5_keytab_key_proc_args;

typedef struct krb5_replay_data {
    krb5_timestamp timestamp;
    int32_t usec;
    uint32_t seq;
} krb5_replay_data;

/* flags for krb5_auth_con_setflags */
enum {
    KRB5_AUTH_CONTEXT_DO_TIME      		= 1,
    KRB5_AUTH_CONTEXT_RET_TIME     		= 2,
    KRB5_AUTH_CONTEXT_DO_SEQUENCE  		= 4,
    KRB5_AUTH_CONTEXT_RET_SEQUENCE 		= 8,
    KRB5_AUTH_CONTEXT_PERMIT_ALL   		= 16,
    KRB5_AUTH_CONTEXT_USE_SUBKEY   		= 32,
    KRB5_AUTH_CONTEXT_CLEAR_FORWARDED_CRED	= 64
};

/* flags for krb5_auth_con_genaddrs */
enum {
    KRB5_AUTH_CONTEXT_GENERATE_LOCAL_ADDR       = 1,
    KRB5_AUTH_CONTEXT_GENERATE_LOCAL_FULL_ADDR  = 3,
    KRB5_AUTH_CONTEXT_GENERATE_REMOTE_ADDR      = 4,
    KRB5_AUTH_CONTEXT_GENERATE_REMOTE_FULL_ADDR = 12
};

typedef struct krb5_auth_context_data {
    unsigned int flags;

    krb5_address *local_address;
    krb5_address *remote_address;
    int16_t local_port;
    int16_t remote_port;
    krb5_keyblock *keyblock;
    krb5_keyblock *local_subkey;
    krb5_keyblock *remote_subkey;

    uint32_t local_seqnumber;
    uint32_t remote_seqnumber;

    krb5_authenticator authenticator;

    krb5_pointer i_vector;

    krb5_rcache rcache;

    krb5_keytype keytype;	/* �requested key type ? */
    krb5_cksumtype cksumtype;	/* �requested checksum type! */

}krb5_auth_context_data, *krb5_auth_context;

typedef struct {
    KDC_REP kdc_rep;
    EncKDCRepPart enc_part;
    KRB_ERROR error;
} krb5_kdc_rep;

extern const char *heimdal_version, *heimdal_long_version;

typedef void (*krb5_log_log_func_t)(const char*, const char*, void*);
typedef void (*krb5_log_close_func_t)(void*);

typedef struct krb5_log_facility {
    char *program;
    int len;
    struct facility *val;
} krb5_log_facility;

typedef EncAPRepPart krb5_ap_rep_enc_part;

#define KRB5_RECVAUTH_IGNORE_VERSION 1

#define KRB5_SENDAUTH_VERSION "KRB5_SENDAUTH_V1.0"

#define KRB5_TGS_NAME_SIZE (6)
#define KRB5_TGS_NAME ("krbtgt")

#define KRB5_DIGEST_NAME ("digest")

/* variables */

extern const char *krb5_config_file;
extern const char *krb5_defkeyname;

typedef enum {
    KRB5_PROMPT_TYPE_PASSWORD		= 0x1,
    KRB5_PROMPT_TYPE_NEW_PASSWORD	= 0x2,
    KRB5_PROMPT_TYPE_NEW_PASSWORD_AGAIN = 0x3,
    KRB5_PROMPT_TYPE_PREAUTH		= 0x4,
    KRB5_PROMPT_TYPE_INFO		= 0x5
} krb5_prompt_type;

typedef struct _krb5_prompt {
    const char *prompt;
    int hidden;
    krb5_data *reply;
    krb5_prompt_type type;
} krb5_prompt;

typedef int (*krb5_prompter_fct)(krb5_context /*context*/,
				 void * /*data*/,
				 const char * /*name*/,
				 const char * /*banner*/,
				 int /*num_prompts*/,
				 krb5_prompt /*prompts*/[]);
typedef krb5_error_code (*krb5_key_proc)(krb5_context /*context*/,
					 krb5_enctype /*type*/,
					 krb5_salt /*salt*/,
					 krb5_const_pointer /*keyseed*/,
					 krb5_keyblock ** /*key*/);
typedef krb5_error_code (*krb5_decrypt_proc)(krb5_context /*context*/,
					     krb5_keyblock * /*key*/,
					     krb5_key_usage /*usage*/,
					     krb5_const_pointer /*decrypt_arg*/,
					     krb5_kdc_rep * /*dec_rep*/);
typedef krb5_error_code (*krb5_s2k_proc)(krb5_context /*context*/,
					 krb5_enctype /*type*/,
					 krb5_const_pointer /*keyseed*/,
					 krb5_salt /*salt*/,
					 krb5_data * /*s2kparms*/,
					 krb5_keyblock ** /*key*/);

struct _krb5_get_init_creds_opt_private;

typedef struct _krb5_get_init_creds_opt {
    krb5_flags flags;
    krb5_deltat tkt_life;
    krb5_deltat renew_life;
    int forwardable;
    int proxiable;
    int anonymous;
    krb5_enctype *etype_list;
    int etype_list_length;
    krb5_addresses *address_list;
    /* XXX the next three should not be used, as they may be
       removed later */
    krb5_preauthtype *preauth_list;
    int preauth_list_length;
    krb5_data *salt;
    struct _krb5_get_init_creds_opt_private *opt_private;
} krb5_get_init_creds_opt;

#define KRB5_GET_INIT_CREDS_OPT_TKT_LIFE	0x0001
#define KRB5_GET_INIT_CREDS_OPT_RENEW_LIFE	0x0002
#define KRB5_GET_INIT_CREDS_OPT_FORWARDABLE	0x0004
#define KRB5_GET_INIT_CREDS_OPT_PROXIABLE	0x0008
#define KRB5_GET_INIT_CREDS_OPT_ETYPE_LIST	0x0010
#define KRB5_GET_INIT_CREDS_OPT_ADDRESS_LIST	0x0020
#define KRB5_GET_INIT_CREDS_OPT_PREAUTH_LIST	0x0040
#define KRB5_GET_INIT_CREDS_OPT_SALT		0x0080
#define KRB5_GET_INIT_CREDS_OPT_ANONYMOUS	0x0100
#define KRB5_GET_INIT_CREDS_OPT_DISABLE_TRANSITED_CHECK	0x0200

typedef struct _krb5_verify_init_creds_opt {
    krb5_flags flags;
    int ap_req_nofail;
} krb5_verify_init_creds_opt;

#define KRB5_VERIFY_INIT_CREDS_OPT_AP_REQ_NOFAIL	0x0001

typedef struct krb5_verify_opt {
    unsigned int flags;
    krb5_ccache ccache;
    krb5_keytab keytab;
    krb5_boolean secure;
    const char *service;
} krb5_verify_opt;

#define KRB5_VERIFY_LREALMS		1
#define KRB5_VERIFY_NO_ADDRESSES	2

extern const krb5_cc_ops krb5_acc_ops;
extern const krb5_cc_ops krb5_fcc_ops;
extern const krb5_cc_ops krb5_mcc_ops;
extern const krb5_cc_ops krb5_kcm_ops;

extern const krb5_kt_ops krb5_fkt_ops;
extern const krb5_kt_ops krb5_wrfkt_ops;
extern const krb5_kt_ops krb5_javakt_ops;
extern const krb5_kt_ops krb5_mkt_ops;
extern const krb5_kt_ops krb5_akf_ops;
extern const krb5_kt_ops krb4_fkt_ops;
extern const krb5_kt_ops krb5_srvtab_fkt_ops;
extern const krb5_kt_ops krb5_any_ops;

#define KRB5_KPASSWD_VERS_CHANGEPW      1
#define KRB5_KPASSWD_VERS_SETPW         0xff80

#define KRB5_KPASSWD_SUCCESS	0
#define KRB5_KPASSWD_MALFORMED	1
#define KRB5_KPASSWD_HARDERROR	2
#define KRB5_KPASSWD_AUTHERROR	3
#define KRB5_KPASSWD_SOFTERROR	4
#define KRB5_KPASSWD_ACCESSDENIED 5
#define KRB5_KPASSWD_BAD_VERSION 6
#define KRB5_KPASSWD_INITIAL_FLAG_NEEDED 7

#define KPASSWD_PORT 464

/* types for the new krbhst interface */
struct krb5_krbhst_data;
typedef struct krb5_krbhst_data *krb5_krbhst_handle;

#define KRB5_KRBHST_KDC		1
#define KRB5_KRBHST_ADMIN	2
#define KRB5_KRBHST_CHANGEPW	3
#define KRB5_KRBHST_KRB524	4
#define KRB5_KRBHST_KCA		5

typedef struct krb5_krbhst_info {
    enum { KRB5_KRBHST_UDP,
	   KRB5_KRBHST_TCP,
	   KRB5_KRBHST_HTTP } proto;
    unsigned short port;
    unsigned short def_port;
    struct addrinfo *ai;
    struct krb5_krbhst_info *next;
    char hostname[1]; /* has to come last */
} krb5_krbhst_info;

/* flags for krb5_krbhst_init_flags (and krb5_send_to_kdc_flags) */
enum {
    KRB5_KRBHST_FLAGS_MASTER      = 1,
    KRB5_KRBHST_FLAGS_LARGE_MSG	  = 2
};

typedef krb5_error_code (*krb5_send_to_kdc_func)(krb5_context,
						 void *,
						 krb5_krbhst_info *,
						 const krb5_data *,
						 krb5_data *);

/* flags for krb5_parse_name_flags */
enum {
    KRB5_PRINCIPAL_PARSE_NO_REALM = 1,
    KRB5_PRINCIPAL_PARSE_MUST_REALM = 2,
    KRB5_PRINCIPAL_PARSE_ENTERPRISE = 4
};

/* flags for krb5_unparse_name_flags */
enum {
    KRB5_PRINCIPAL_UNPARSE_SHORT = 1,
    KRB5_PRINCIPAL_UNPARSE_NO_REALM = 2,
    KRB5_PRINCIPAL_UNPARSE_DISPLAY = 4
};

typedef struct krb5_sendto_ctx_data *krb5_sendto_ctx;

#define KRB5_SENDTO_DONE	0
#define KRB5_SENDTO_RESTART	1
#define KRB5_SENDTO_CONTINUE	2

typedef krb5_error_code (*krb5_sendto_ctx_func)(krb5_context, krb5_sendto_ctx, void *, const krb5_data *, int *);

struct krb5_plugin;
enum krb5_plugin_type {
    PLUGIN_TYPE_DATA = 1,
    PLUGIN_TYPE_FUNC
};

struct credentials; /* this is to keep the compiler happy */
struct getargs;
struct sockaddr;

#include <krb5-protos.h>

#endif /* __KRB5_H__ */


code:
/* Generated from /usr/src/kerberos5/lib/libasn1/../../../crypto/heimdal/lib/asn1/k5.asn1 */
/* Do not edit */

#ifndef __krb5_asn1_h__
#define __krb5_asn1_h__

#include <stddef.h>
#include <time.h>

#ifndef __asn1_common_definitions__
#define __asn1_common_definitions__

typedef struct heim_integer {
  size_t length;
  void *data;
  int negative;
} heim_integer;

typedef struct heim_octet_string {
  size_t length;
  void *data;
} heim_octet_string;

typedef char *heim_general_string;

typedef char *heim_utf8_string;

typedef char *heim_printable_string;

typedef char *heim_ia5_string;

typedef struct heim_bmp_string {
  size_t length;
  uint16_t *data;
} heim_bmp_string;

typedef struct heim_universal_string {
  size_t length;
  uint32_t *data;
} heim_universal_string;

typedef char *heim_visible_string;

typedef struct heim_oid {
  size_t length;
  unsigned *components;
} heim_oid;

typedef struct heim_bit_string {
  size_t length;
  void *data;
} heim_bit_string;

typedef struct heim_octet_string heim_any;
typedef struct heim_octet_string heim_any_set;

#define ASN1_MALLOC_ENCODE(T, B, BL, S, L, R)                  \
  do {                                                         \
    (BL) = length_##T((S));                                    \
    (B) = malloc((BL));                                        \
    if((B) == NULL) {                                          \
      (R) = ENOMEM;                                            \
    } else {                                                   \
      (R) = encode_##T(((unsigned char*)(B)) + (BL) - 1, (BL), \
                       (S), (L));                              \
      if((R) != 0) {                                           \
        free((B));                                             \
        (B) = NULL;                                            \
      }                                                        \
    }                                                          \
  } while (0)

struct units;

#endif

/*
NAME-TYPE ::= INTEGER {
  KRB5_NT_UNKNOWN(0),
  KRB5_NT_PRINCIPAL(1),
  KRB5_NT_SRV_INST(2),
  KRB5_NT_SRV_HST(3),
  KRB5_NT_SRV_XHST(4),
  KRB5_NT_UID(5),
  KRB5_NT_X500_PRINCIPAL(6),
  KRB5_NT_SMTP_NAME(7),
  KRB5_NT_ENTERPRISE_PRINCIPAL(10),
  KRB5_NT_ENT_PRINCIPAL_AND_ID(-130),
  KRB5_NT_MS_PRINCIPAL(-128),
  KRB5_NT_MS_PRINCIPAL_AND_ID(-129)
}
*/

typedef enum NAME_TYPE {
  KRB5_NT_UNKNOWN = 0,
  KRB5_NT_PRINCIPAL = 1,
  KRB5_NT_SRV_INST = 2,
  KRB5_NT_SRV_HST = 3,
  KRB5_NT_SRV_XHST = 4,
  KRB5_NT_UID = 5,
  KRB5_NT_X500_PRINCIPAL = 6,
  KRB5_NT_SMTP_NAME = 7,
  KRB5_NT_ENTERPRISE_PRINCIPAL = 10,
  KRB5_NT_ENT_PRINCIPAL_AND_ID = -130,
  KRB5_NT_MS_PRINCIPAL = -128,
  KRB5_NT_MS_PRINCIPAL_AND_ID = -129
} NAME_TYPE;

int    encode_NAME_TYPE(unsigned char *, size_t, const NAME_TYPE *, size_t *);
int    decode_NAME_TYPE(const unsigned char *, size_t, NAME_TYPE *, size_t *);
void   free_NAME_TYPE  (NAME_TYPE *);
size_t length_NAME_TYPE(const NAME_TYPE *);
int    copy_NAME_TYPE  (const NAME_TYPE *, NAME_TYPE *);

/*
MESSAGE-TYPE ::= INTEGER {
  krb_as_req(10),
  krb_as_rep(11),
  krb_tgs_req(12),
  krb_tgs_rep(13),
  krb_ap_req(14),
  krb_ap_rep(15),
  krb_safe(20),
  krb_priv(21),
  krb_cred(22),
  krb_error(30)
}
*/

typedef enum MESSAGE_TYPE {
  krb_as_req = 10,
  krb_as_rep = 11,
  krb_tgs_req = 12,
  krb_tgs_rep = 13,
  krb_ap_req = 14,
  krb_ap_rep = 15,
  krb_safe = 20,
  krb_priv = 21,
  krb_cred = 22,
  krb_error = 30
} MESSAGE_TYPE;

int    encode_MESSAGE_TYPE(unsigned char *, size_t, const MESSAGE_TYPE *, size_t *);
int    decode_MESSAGE_TYPE(const unsigned char *, size_t, MESSAGE_TYPE *, size_t *);
void   free_MESSAGE_TYPE  (MESSAGE_TYPE *);
size_t length_MESSAGE_TYPE(const MESSAGE_TYPE *);
int    copy_MESSAGE_TYPE  (const MESSAGE_TYPE *, MESSAGE_TYPE *);

/*
PADATA-TYPE ::= INTEGER {
  KRB5_PADATA_NONE(0),
  KRB5_PADATA_TGS_REQ(1),
  KRB5_PADATA_AP_REQ(1),
  KRB5_PADATA_ENC_TIMESTAMP(2),
  KRB5_PADATA_PW_SALT(3),
  KRB5_PADATA_ENC_UNIX_TIME(5),
  KRB5_PADATA_SANDIA_SECUREID(6),
  KRB5_PADATA_SESAME(7),
  KRB5_PADATA_OSF_DCE(8),
  KRB5_PADATA_CYBERSAFE_SECUREID(9),
  KRB5_PADATA_AFS3_SALT(10),
  KRB5_PADATA_ETYPE_INFO(11),
  KRB5_PADATA_SAM_CHALLENGE(12),
  KRB5_PADATA_SAM_RESPONSE(13),
  KRB5_PADATA_PK_AS_REQ_19(14),
  KRB5_PADATA_PK_AS_REP_19(15),
  KRB5_PADATA_PK_AS_REQ_WIN(15),
  KRB5_PADATA_PK_AS_REQ(16),
  KRB5_PADATA_PK_AS_REP(17),
  KRB5_PADATA_PA_PK_OCSP_RESPONSE(18),
  KRB5_PADATA_ETYPE_INFO2(19),
  KRB5_PADATA_USE_SPECIFIED_KVNO(20),
  KRB5_PADATA_SVR_REFERRAL_INFO(20),
  KRB5_PADATA_SAM_REDIRECT(21),
  KRB5_PADATA_GET_FROM_TYPED_DATA(22),
  KRB5_PADATA_SAM_ETYPE_INFO(23),
  KRB5_PADATA_SERVER_REFERRAL(25),
  KRB5_PADATA_TD_KRB_PRINCIPAL(102),
  KRB5_PADATA_PK_TD_TRUSTED_CERTIFIERS(104),
  KRB5_PADATA_PK_TD_CERTIFICATE_INDEX(105),
  KRB5_PADATA_TD_APP_DEFINED_ERROR(106),
  KRB5_PADATA_TD_REQ_NONCE(107),
  KRB5_PADATA_TD_REQ_SEQ(108),
  KRB5_PADATA_PA_PAC_REQUEST(128),
  KRB5_PADATA_S4U2SELF(129),
  KRB5_PADATA_PK_AS_09_BINDING(132),
  KRB5_PADATA_CLIENT_CANONICALIZED(133)
}
*/

typedef enum PADATA_TYPE {
  KRB5_PADATA_NONE = 0,
  KRB5_PADATA_TGS_REQ = 1,
  KRB5_PADATA_AP_REQ = 1,
  KRB5_PADATA_ENC_TIMESTAMP = 2,
  KRB5_PADATA_PW_SALT = 3,
  KRB5_PADATA_ENC_UNIX_TIME = 5,
  KRB5_PADATA_SANDIA_SECUREID = 6,
  KRB5_PADATA_SESAME = 7,
  KRB5_PADATA_OSF_DCE = 8,
  KRB5_PADATA_CYBERSAFE_SECUREID = 9,
  KRB5_PADATA_AFS3_SALT = 10,
  KRB5_PADATA_ETYPE_INFO = 11,
  KRB5_PADATA_SAM_CHALLENGE = 12,
  KRB5_PADATA_SAM_RESPONSE = 13,
  KRB5_PADATA_PK_AS_REQ_19 = 14,
  KRB5_PADATA_PK_AS_REP_19 = 15,
  KRB5_PADATA_PK_AS_REQ_WIN = 15,
  KRB5_PADATA_PK_AS_REQ = 16,
  KRB5_PADATA_PK_AS_REP = 17,
  KRB5_PADATA_PA_PK_OCSP_RESPONSE = 18,
  KRB5_PADATA_ETYPE_INFO2 = 19,
  KRB5_PADATA_USE_SPECIFIED_KVNO = 20,
  KRB5_PADATA_SVR_REFERRAL_INFO = 20,
  KRB5_PADATA_SAM_REDIRECT = 21,
  KRB5_PADATA_GET_FROM_TYPED_DATA = 22,
  KRB5_PADATA_SAM_ETYPE_INFO = 23,
  KRB5_PADATA_SERVER_REFERRAL = 25,
  KRB5_PADATA_TD_KRB_PRINCIPAL = 102,
  KRB5_PADATA_PK_TD_TRUSTED_CERTIFIERS = 104,
  KRB5_PADATA_PK_TD_CERTIFICATE_INDEX = 105,
  KRB5_PADATA_TD_APP_DEFINED_ERROR = 106,
  KRB5_PADATA_TD_REQ_NONCE = 107,
  KRB5_PADATA_TD_REQ_SEQ = 108,
  KRB5_PADATA_PA_PAC_REQUEST = 128,
  KRB5_PADATA_S4U2SELF = 129,
  KRB5_PADATA_PK_AS_09_BINDING = 132,
  KRB5_PADATA_CLIENT_CANONICALIZED = 133
} PADATA_TYPE;

int    encode_PADATA_TYPE(unsigned char *, size_t, const PADATA_TYPE *, size_t *);
int    decode_PADATA_TYPE(const unsigned char *, size_t, PADATA_TYPE *, size_t *);
void   free_PADATA_TYPE  (PADATA_TYPE *);
size_t length_PADATA_TYPE(const PADATA_TYPE *);
int    copy_PADATA_TYPE  (const PADATA_TYPE *, PADATA_TYPE *);

/*
AUTHDATA-TYPE ::= INTEGER {
  KRB5_AUTHDATA_IF_RELEVANT(1),
  KRB5_AUTHDATA_INTENDED_FOR_SERVER(2),
  KRB5_AUTHDATA_INTENDED_FOR_APPLICATION_CLASS(3),
  KRB5_AUTHDATA_KDC_ISSUED(4),
  KRB5_AUTHDATA_AND_OR(5),
  KRB5_AUTHDATA_MANDATORY_TICKET_EXTENSIONS(6),
  KRB5_AUTHDATA_IN_TICKET_EXTENSIONS(7),
  KRB5_AUTHDATA_MANDATORY_FOR_KDC(8),
  KRB5_AUTHDATA_INITIAL_VERIFIED_CAS(9),
  KRB5_AUTHDATA_OSF_DCE(64),
  KRB5_AUTHDATA_SESAME(65),
  KRB5_AUTHDATA_OSF_DCE_PKI_CERTID(66),
  KRB5_AUTHDATA_WIN2K_PAC(128),
  KRB5_AUTHDATA_GSS_API_ETYPE_NEGOTIATION(129),
  KRB5_AUTHDATA_SIGNTICKET(-17)
}
*/

typedef enum AUTHDATA_TYPE {
  KRB5_AUTHDATA_IF_RELEVANT = 1,
  KRB5_AUTHDATA_INTENDED_FOR_SERVER = 2,
  KRB5_AUTHDATA_INTENDED_FOR_APPLICATION_CLASS = 3,
  KRB5_AUTHDATA_KDC_ISSUED = 4,
  KRB5_AUTHDATA_AND_OR = 5,
  KRB5_AUTHDATA_MANDATORY_TICKET_EXTENSIONS = 6,
  KRB5_AUTHDATA_IN_TICKET_EXTENSIONS = 7,
  KRB5_AUTHDATA_MANDATORY_FOR_KDC = 8,
  KRB5_AUTHDATA_INITIAL_VERIFIED_CAS = 9,
  KRB5_AUTHDATA_OSF_DCE = 64,
  KRB5_AUTHDATA_SESAME = 65,
  KRB5_AUTHDATA_OSF_DCE_PKI_CERTID = 66,
  KRB5_AUTHDATA_WIN2K_PAC = 128,
  KRB5_AUTHDATA_GSS_API_ETYPE_NEGOTIATION = 129,
  KRB5_AUTHDATA_SIGNTICKET = -17
} AUTHDATA_TYPE;

int    encode_AUTHDATA_TYPE(unsigned char *, size_t, const AUTHDATA_TYPE *, size_t *);
int    decode_AUTHDATA_TYPE(const unsigned char *, size_t, AUTHDATA_TYPE *, size_t *);
void   free_AUTHDATA_TYPE  (AUTHDATA_TYPE *);
size_t length_AUTHDATA_TYPE(const AUTHDATA_TYPE *);
int    copy_AUTHDATA_TYPE  (const AUTHDATA_TYPE *, AUTHDATA_TYPE *);

/*
CKSUMTYPE ::= INTEGER {
  CKSUMTYPE_NONE(0),
  CKSUMTYPE_CRC32(1),
  CKSUMTYPE_RSA_MD4(2),
  CKSUMTYPE_RSA_MD4_DES(3),
  CKSUMTYPE_DES_MAC(4),
  CKSUMTYPE_DES_MAC_K(5),
  CKSUMTYPE_RSA_MD4_DES_K(6),
  CKSUMTYPE_RSA_MD5(7),
  CKSUMTYPE_RSA_MD5_DES(8),
  CKSUMTYPE_RSA_MD5_DES3(9),
  CKSUMTYPE_SHA1_OTHER(10),
  CKSUMTYPE_HMAC_SHA1_DES3(12),
  CKSUMTYPE_SHA1(14),
  CKSUMTYPE_HMAC_SHA1_96_AES_128(15),
  CKSUMTYPE_HMAC_SHA1_96_AES_256(16),
  CKSUMTYPE_GSSAPI(32771),
  CKSUMTYPE_HMAC_MD5(-138),
  CKSUMTYPE_HMAC_MD5_ENC(-1138)
}
*/

typedef enum CKSUMTYPE {
  CKSUMTYPE_NONE = 0,
  CKSUMTYPE_CRC32 = 1,
  CKSUMTYPE_RSA_MD4 = 2,
  CKSUMTYPE_RSA_MD4_DES = 3,
  CKSUMTYPE_DES_MAC = 4,
  CKSUMTYPE_DES_MAC_K = 5,
  CKSUMTYPE_RSA_MD4_DES_K = 6,
  CKSUMTYPE_RSA_MD5 = 7,
  CKSUMTYPE_RSA_MD5_DES = 8,
  CKSUMTYPE_RSA_MD5_DES3 = 9,
  CKSUMTYPE_SHA1_OTHER = 10,
  CKSUMTYPE_HMAC_SHA1_DES3 = 12,
  CKSUMTYPE_SHA1 = 14,
  CKSUMTYPE_HMAC_SHA1_96_AES_128 = 15,
  CKSUMTYPE_HMAC_SHA1_96_AES_256 = 16,
  CKSUMTYPE_GSSAPI = 32771,
  CKSUMTYPE_HMAC_MD5 = -138,
  CKSUMTYPE_HMAC_MD5_ENC = -1138
} CKSUMTYPE;

int    encode_CKSUMTYPE(unsigned char *, size_t, const CKSUMTYPE *, size_t *);
int    decode_CKSUMTYPE(const unsigned char *, size_t, CKSUMTYPE *, size_t *);
void   free_CKSUMTYPE  (CKSUMTYPE *);
size_t length_CKSUMTYPE(const CKSUMTYPE *);
int    copy_CKSUMTYPE  (const CKSUMTYPE *, CKSUMTYPE *);

/*
ENCTYPE ::= INTEGER {
  ETYPE_NULL(0),
  ETYPE_DES_CBC_CRC(1),
  ETYPE_DES_CBC_MD4(2),
  ETYPE_DES_CBC_MD5(3),
  ETYPE_DES3_CBC_MD5(5),
  ETYPE_OLD_DES3_CBC_SHA1(7),
  ETYPE_SIGN_DSA_GENERATE(8),
  ETYPE_ENCRYPT_RSA_PRIV(9),
  ETYPE_ENCRYPT_RSA_PUB(10),
  ETYPE_DES3_CBC_SHA1(16),
  ETYPE_AES128_CTS_HMAC_SHA1_96(17),
  ETYPE_AES256_CTS_HMAC_SHA1_96(18),
  ETYPE_ARCFOUR_HMAC_MD5(23),
  ETYPE_ARCFOUR_HMAC_MD5_56(24),
  ETYPE_ENCTYPE_PK_CROSS(48),
  ETYPE_ARCFOUR_MD4(-128),
  ETYPE_ARCFOUR_HMAC_OLD(-133),
  ETYPE_ARCFOUR_HMAC_OLD_EXP(-135),
  ETYPE_DES_CBC_NONE(-4096),
  ETYPE_DES3_CBC_NONE(-4097),
  ETYPE_DES_CFB64_NONE(-4098),
  ETYPE_DES_PCBC_NONE(-4099),
  ETYPE_DIGEST_MD5_NONE(-4100),
  ETYPE_CRAM_MD5_NONE(-4101)
}
*/

typedef enum ENCTYPE {
  ETYPE_NULL = 0,
  ETYPE_DES_CBC_CRC = 1,
  ETYPE_DES_CBC_MD4 = 2,
  ETYPE_DES_CBC_MD5 = 3,
  ETYPE_DES3_CBC_MD5 = 5,
  ETYPE_OLD_DES3_CBC_SHA1 = 7,
  ETYPE_SIGN_DSA_GENERATE = 8,
  ETYPE_ENCRYPT_RSA_PRIV = 9,
  ETYPE_ENCRYPT_RSA_PUB = 10,
  ETYPE_DES3_CBC_SHA1 = 16,
  ETYPE_AES128_CTS_HMAC_SHA1_96 = 17,
  ETYPE_AES256_CTS_HMAC_SHA1_96 = 18,
  ETYPE_ARCFOUR_HMAC_MD5 = 23,
  ETYPE_ARCFOUR_HMAC_MD5_56 = 24,
  ETYPE_ENCTYPE_PK_CROSS = 48,
  ETYPE_ARCFOUR_MD4 = -128,
  ETYPE_ARCFOUR_HMAC_OLD = -133,
  ETYPE_ARCFOUR_HMAC_OLD_EXP = -135,
  ETYPE_DES_CBC_NONE = -4096,
  ETYPE_DES3_CBC_NONE = -4097,
  ETYPE_DES_CFB64_NONE = -4098,
  ETYPE_DES_PCBC_NONE = -4099,
  ETYPE_DIGEST_MD5_NONE = -4100,
  ETYPE_CRAM_MD5_NONE = -4101
} ENCTYPE;

int    encode_ENCTYPE(unsigned char *, size_t, const ENCTYPE *, size_t *);
int    decode_ENCTYPE(const unsigned char *, size_t, ENCTYPE *, size_t *);
void   free_ENCTYPE  (ENCTYPE *);
size_t length_ENCTYPE(const ENCTYPE *);
int    copy_ENCTYPE  (const ENCTYPE *, ENCTYPE *);

/*
krb5uint32 ::= INTEGER (0..-1)
*/

typedef unsigned int krb5uint32;

int    encode_krb5uint32(unsigned char *, size_t, const krb5uint32 *, size_t *);
int    decode_krb5uint32(const unsigned char *, size_t, krb5uint32 *, size_t *);
void   free_krb5uint32  (krb5uint32 *);
size_t length_krb5uint32(const krb5uint32 *);
int    copy_krb5uint32  (const krb5uint32 *, krb5uint32 *);

/*
krb5int32 ::= INTEGER (-2147483648..2147483647)
*/

typedef int krb5int32;

int    encode_krb5int32(unsigned char *, size_t, const krb5int32 *, size_t *);
int    decode_krb5int32(const unsigned char *, size_t, krb5int32 *, size_t *);
void   free_krb5int32  (krb5int32 *);
size_t length_krb5int32(const krb5int32 *);
int    copy_krb5int32  (const krb5int32 *, krb5int32 *);

/*
KerberosString ::= GeneralString
*/

typedef heim_general_string KerberosString;

int    encode_KerberosString(unsigned char *, size_t, const KerberosString *, size_t *);
int    decode_KerberosString(const unsigned char *, size_t, KerberosString *, size_t *);
void   free_KerberosString  (KerberosString *);
size_t length_KerberosString(const KerberosString *);
int    copy_KerberosString  (const KerberosString *, KerberosString *);

/*
Realm ::= GeneralString
*/

typedef heim_general_string Realm;

int    encode_Realm(unsigned char *, size_t, const Realm *, size_t *);
int    decode_Realm(const unsigned char *, size_t, Realm *, size_t *);
void   free_Realm  (Realm *);
size_t length_Realm(const Realm *);
int    copy_Realm  (const Realm *, Realm *);

/*
PrincipalName ::= SEQUENCE {
  name-type       [0] NAME-TYPE,
  name-string     [1] SEQUENCE OF GeneralString,
}
*/

typedef struct PrincipalName {
  NAME_TYPE name_type;
  struct  {
    unsigned int len;
    heim_general_string *val;
  } name_string;
} PrincipalName;

int    encode_PrincipalName(unsigned char *, size_t, const PrincipalName *, size_t *);
int    decode_PrincipalName(const unsigned char *, size_t, PrincipalName *, size_t *);
void   free_PrincipalName  (PrincipalName *);
size_t length_PrincipalName(const PrincipalName *);
int    copy_PrincipalName  (const PrincipalName *, PrincipalName *);

/*
Principal ::= SEQUENCE {
  name            [0] PrincipalName,
  realm           [1] Realm,
}
*/

typedef struct Principal {
  PrincipalName name;
  Realm realm;
} Principal;

int    encode_Principal(unsigned char *, size_t, const Principal *, size_t *);
int    decode_Principal(const unsigned char *, size_t, Principal *, size_t *);
void   free_Principal  (Principal *);
size_t length_Principal(const Principal *);
int    copy_Principal  (const Principal *, Principal *);

/*
HostAddress ::= SEQUENCE {
  addr-type       [0] krb5int32,
  address         [1] OCTET STRING,
}
*/

typedef struct HostAddress {
  krb5int32 addr_type;
  heim_octet_string address;
} HostAddress;

int    encode_HostAddress(unsigned char *, size_t, const HostAddress *, size_t *);
int    decode_HostAddress(const unsigned char *, size_t, HostAddress *, size_t *);
void   free_HostAddress  (HostAddress *);
size_t length_HostAddress(const HostAddress *);
int    copy_HostAddress  (const HostAddress *, HostAddress *);

/*
HostAddresses ::= SEQUENCE OF HostAddress
*/

typedef struct HostAddresses {
  unsigned int len;
  HostAddress *val;
} HostAddresses;

int    encode_HostAddresses(unsigned char *, size_t, const HostAddresses *, size_t *);
int    decode_HostAddresses(const unsigned char *, size_t, HostAddresses *, size_t *);
void   free_HostAddresses  (HostAddresses *);
size_t length_HostAddresses(const HostAddresses *);
int    copy_HostAddresses  (const HostAddresses *, HostAddresses *);

/*
KerberosTime ::= GeneralizedTime
*/

typedef time_t KerberosTime;

int    encode_KerberosTime(unsigned char *, size_t, const KerberosTime *, size_t *);
int    decode_KerberosTime(const unsigned char *, size_t, KerberosTime *, size_t *);
void   free_KerberosTime  (KerberosTime *);
size_t length_KerberosTime(const KerberosTime *);
int    copy_KerberosTime  (const KerberosTime *, KerberosTime *);

/*
AuthorizationDataElement ::= SEQUENCE {
  ad-type         [0] krb5int32,
  ad-data         [1] OCTET STRING,
}
*/

typedef struct AuthorizationDataElement {
  krb5int32 ad_type;
  heim_octet_string ad_data;
} AuthorizationDataElement;

int    encode_AuthorizationDataElement(unsigned char *, size_t, const AuthorizationDataElement *, size_t *);
int    decode_AuthorizationDataElement(const unsigned char *, size_t, AuthorizationDataElement *, size_t *);
void   free_AuthorizationDataElement  (AuthorizationDataElement *);
size_t length_AuthorizationDataElement(const AuthorizationDataElement *);
int    copy_AuthorizationDataElement  (const AuthorizationDataElement *, AuthorizationDataElement *);

/*
AuthorizationData ::= SEQUENCE OF AuthorizationDataElement
*/

typedef struct AuthorizationData {
  unsigned int len;
  AuthorizationDataElement *val;
} AuthorizationData;

int    encode_AuthorizationData(unsigned char *, size_t, const AuthorizationData *, size_t *);
int    decode_AuthorizationData(const unsigned char *, size_t, AuthorizationData *, size_t *);
void   free_AuthorizationData  (AuthorizationData *);
size_t length_AuthorizationData(const AuthorizationData *);
int    copy_AuthorizationData  (const AuthorizationData *, AuthorizationData *);
int   add_AuthorizationData  (AuthorizationData *, const AuthorizationDataElement *);
int   remove_AuthorizationData  (AuthorizationData *, unsigned int);

/*
APOptions ::= BIT STRING {
  reserved(0),
  use-session-key(1),
  mutual-required(2)
}
*/

typedef struct APOptions {
  unsigned int reserved:1;
  unsigned int use_session_key:1;
  unsigned int mutual_required:1;
} APOptions;

int    encode_APOptions(unsigned char *, size_t, const APOptions *, size_t *);
int    decode_APOptions(const unsigned char *, size_t, APOptions *, size_t *);
void   free_APOptions  (APOptions *);
size_t length_APOptions(const APOptions *);
int    copy_APOptions  (const APOptions *, APOptions *);
unsigned APOptions2int(APOptions);
APOptions int2APOptions(unsigned);
#ifdef __PARSE_UNITS_H__
const struct units * asn1_APOptions_units(void);
#endif

/*
TicketFlags ::= BIT STRING {
  reserved(0),
  forwardable(1),
  forwarded(2),
  proxiable(3),
  proxy(4),
  may-postdate(5),
  postdated(6),
  invalid(7),
  renewable(8),
  initial(9),
  pre-authent(10),
  hw-authent(11),
  transited-policy-checked(12),
  ok-as-delegate(13),
  anonymous(14)
}
*/

typedef struct TicketFlags {
  unsigned int reserved:1;
  unsigned int forwardable:1;
  unsigned int forwarded:1;
  unsigned int proxiable:1;
  unsigned int proxy:1;
  unsigned int may_postdate:1;
  unsigned int postdated:1;
  unsigned int invalid:1;
  unsigned int renewable:1;
  unsigned int initial:1;
  unsigned int pre_authent:1;
  unsigned int hw_authent:1;
  unsigned int transited_policy_checked:1;
  unsigned int ok_as_delegate:1;
  unsigned int anonymous:1;
} TicketFlags;

int    encode_TicketFlags(unsigned char *, size_t, const TicketFlags *, size_t *);
int    decode_TicketFlags(const unsigned char *, size_t, TicketFlags *, size_t *);
void   free_TicketFlags  (TicketFlags *);
size_t length_TicketFlags(const TicketFlags *);
int    copy_TicketFlags  (const TicketFlags *, TicketFlags *);
unsigned TicketFlags2int(TicketFlags);
TicketFlags int2TicketFlags(unsigned);
#ifdef __PARSE_UNITS_H__
const struct units * asn1_TicketFlags_units(void);
#endif

/*
KDCOptions ::= BIT STRING {
  reserved(0),
  forwardable(1),
  forwarded(2),
  proxiable(3),
  proxy(4),
  allow-postdate(5),
  postdated(6),
  unused7(7),
  renewable(8),
  unused9(9),
  unused10(10),
  unused11(11),
  request-anonymous(14),
  canonicalize(15),
  constrained-delegation(16),
  disable-transited-check(26),
  renewable-ok(27),
  enc-tkt-in-skey(28),
  renew(30),
  validate(31)
}
*/

typedef struct KDCOptions {
  unsigned int reserved:1;
  unsigned int forwardable:1;
  unsigned int forwarded:1;
  unsigned int proxiable:1;
  unsigned int proxy:1;
  unsigned int allow_postdate:1;
  unsigned int postdated:1;
  unsigned int unused7:1;
  unsigned int renewable:1;
  unsigned int unused9:1;
  unsigned int unused10:1;
  unsigned int unused11:1;
  unsigned int request_anonymous:1;
  unsigned int canonicalize:1;
  unsigned int constrained_delegation:1;
  unsigned int disable_transited_check:1;
  unsigned int renewable_ok:1;
  unsigned int enc_tkt_in_skey:1;
  unsigned int renew:1;
  unsigned int validate:1;
} KDCOptions;

int    encode_KDCOptions(unsigned char *, size_t, const KDCOptions *, size_t *);
int    decode_KDCOptions(const unsigned char *, size_t, KDCOptions *, size_t *);
void   free_KDCOptions  (KDCOptions *);
size_t length_KDCOptions(const KDCOptions *);
int    copy_KDCOptions  (const KDCOptions *, KDCOptions *);
unsigned KDCOptions2int(KDCOptions);
KDCOptions int2KDCOptions(unsigned);
#ifdef __PARSE_UNITS_H__
const struct units * asn1_KDCOptions_units(void);
#endif

/*
LR-TYPE ::= INTEGER {
  LR_NONE(0),
  LR_INITIAL_TGT(1),
  LR_INITIAL(2),
  LR_ISSUE_USE_TGT(3),
  LR_RENEWAL(4),
  LR_REQUEST(5),
  LR_PW_EXPTIME(6),
  LR_ACCT_EXPTIME(7)
}
*/

typedef enum LR_TYPE {
  LR_NONE = 0,
  LR_INITIAL_TGT = 1,
  LR_INITIAL = 2,
  LR_ISSUE_USE_TGT = 3,
  LR_RENEWAL = 4,
  LR_REQUEST = 5,
  LR_PW_EXPTIME = 6,
  LR_ACCT_EXPTIME = 7
} LR_TYPE;

int    encode_LR_TYPE(unsigned char *, size_t, const LR_TYPE *, size_t *);
int    decode_LR_TYPE(const unsigned char *, size_t, LR_TYPE *, size_t *);
void   free_LR_TYPE  (LR_TYPE *);
size_t length_LR_TYPE(const LR_TYPE *);
int    copy_LR_TYPE  (const LR_TYPE *, LR_TYPE *);

/*
LastReq ::= SEQUENCE OF SEQUENCE {
  lr-type         [0] LR-TYPE,
  lr-value        [1] KerberosTime,
}
*/

typedef struct LastReq {
  unsigned int len;
  struct  {
    LR_TYPE lr_type;
    KerberosTime lr_value;
  } *val;
} LastReq;

int    encode_LastReq(unsigned char *, size_t, const LastReq *, size_t *);
int    decode_LastReq(const unsigned char *, size_t, LastReq *, size_t *);
void   free_LastReq  (LastReq *);
size_t length_LastReq(const LastReq *);
int    copy_LastReq  (const LastReq *, LastReq *);

/*
EncryptedData ::= SEQUENCE {
  etype           [0] ENCTYPE,
  kvno            [1] krb5int32 OPTIONAL,
  cipher          [2] OCTET STRING,
}
*/

typedef struct EncryptedData {
  ENCTYPE etype;
  krb5int32 *kvno;
  heim_octet_string cipher;
} EncryptedData;

int    encode_EncryptedData(unsigned char *, size_t, const EncryptedData *, size_t *);
int    decode_EncryptedData(const unsigned char *, size_t, EncryptedData *, size_t *);
void   free_EncryptedData  (EncryptedData *);
size_t length_EncryptedData(const EncryptedData *);
int    copy_EncryptedData  (const EncryptedData *, EncryptedData *);

/*
EncryptionKey ::= SEQUENCE {
  keytype         [0] krb5int32,
  keyvalue        [1] OCTET STRING,
}
*/

typedef struct EncryptionKey {
  krb5int32 keytype;
  heim_octet_string keyvalue;
} EncryptionKey;

int    encode_EncryptionKey(unsigned char *, size_t, const EncryptionKey *, size_t *);
int    decode_EncryptionKey(const unsigned char *, size_t, EncryptionKey *, size_t *);
void   free_EncryptionKey  (EncryptionKey *);
size_t length_EncryptionKey(const EncryptionKey *);
int    copy_EncryptionKey  (const EncryptionKey *, EncryptionKey *);

/*
TransitedEncoding ::= SEQUENCE {
  tr-type         [0] krb5int32,
  contents        [1] OCTET STRING,
}
*/

typedef struct TransitedEncoding {
  krb5int32 tr_type;
  heim_octet_string contents;
} TransitedEncoding;

int    encode_TransitedEncoding(unsigned char *, size_t, const TransitedEncoding *, size_t *);
int    decode_TransitedEncoding(const unsigned char *, size_t, TransitedEncoding *, size_t *);
void   free_TransitedEncoding  (TransitedEncoding *);
size_t length_TransitedEncoding(const TransitedEncoding *);
int    copy_TransitedEncoding  (const TransitedEncoding *, TransitedEncoding *);

/*
Ticket ::= [APPLICATION 1] SEQUENCE {
  tkt-vno         [0] krb5int32,
  realm           [1] Realm,
  sname           [2] PrincipalName,
  enc-part        [3] EncryptedData,
}
*/

typedef struct Ticket {
  krb5int32 tkt_vno;
  Realm realm;
  PrincipalName sname;
  EncryptedData enc_part;
} Ticket;

int    encode_Ticket(unsigned char *, size_t, const Ticket *, size_t *);
int    decode_Ticket(const unsigned char *, size_t, Ticket *, size_t *);
void   free_Ticket  (Ticket *);
size_t length_Ticket(const Ticket *);
int    copy_Ticket  (const Ticket *, Ticket *);

/*
EncTicketPart ::= [APPLICATION 3] SEQUENCE {
  flags                [0] TicketFlags,
  key                  [1] EncryptionKey,
  crealm               [2] Realm,
  cname                [3] PrincipalName,
  transited            [4] TransitedEncoding,
  authtime             [5] KerberosTime,
  starttime            [6] KerberosTime OPTIONAL,
  endtime              [7] KerberosTime,
  renew-till           [8] KerberosTime OPTIONAL,
  caddr                [9] HostAddresses OPTIONAL,
  authorization-data   [10] AuthorizationData OPTIONAL,
}
*/

typedef struct EncTicketPart {
  TicketFlags flags;
  EncryptionKey key;
  Realm crealm;
  PrincipalName cname;
  TransitedEncoding transited;
  KerberosTime authtime;
  KerberosTime *starttime;
  KerberosTime endtime;
  KerberosTime *renew_till;
  HostAddresses *caddr;
  AuthorizationData *authorization_data;
} EncTicketPart;

int    encode_EncTicketPart(unsigned char *, size_t, const EncTicketPart *, size_t *);
int    decode_EncTicketPart(const unsigned char *, size_t, EncTicketPart *, size_t *);
void   free_EncTicketPart  (EncTicketPart *);
size_t length_EncTicketPart(const EncTicketPart *);
int    copy_EncTicketPart  (const EncTicketPart *, EncTicketPart *);

/*
Checksum ::= SEQUENCE {
  cksumtype       [0] CKSUMTYPE,
  checksum        [1] OCTET STRING,
}
*/

typedef struct Checksum {
  CKSUMTYPE cksumtype;
  heim_octet_string checksum;
} Checksum;

int    encode_Checksum(unsigned char *, size_t, const Checksum *, size_t *);
int    decode_Checksum(const unsigned char *, size_t, Checksum *, size_t *);
void   free_Checksum  (Checksum *);
size_t length_Checksum(const Checksum *);
int    copy_Checksum  (const Checksum *, Checksum *);

/*
Authenticator ::= [APPLICATION 2] SEQUENCE {
  authenticator-vno    [0] krb5int32,
  crealm               [1] Realm,
  cname                [2] PrincipalName,
  cksum                [3] Checksum OPTIONAL,
  cusec                [4] krb5int32,
  ctime                [5] KerberosTime,
  subkey               [6] EncryptionKey OPTIONAL,
  seq-number           [7] krb5uint32 OPTIONAL,
  authorization-data   [8] AuthorizationData OPTIONAL,
}
*/

typedef struct Authenticator {
  krb5int32 authenticator_vno;
  Realm crealm;
  PrincipalName cname;
  Checksum *cksum;
  krb5int32 cusec;
  KerberosTime ctime;
  EncryptionKey *subkey;
  krb5uint32 *seq_number;
  AuthorizationData *authorization_data;
} Authenticator;

int    encode_Authenticator(unsigned char *, size_t, const Authenticator *, size_t *);
int    decode_Authenticator(const unsigned char *, size_t, Authenticator *, size_t *);
void   free_Authenticator  (Authenticator *);
size_t length_Authenticator(const Authenticator *);
int    copy_Authenticator  (const Authenticator *, Authenticator *);

/*
PA-DATA ::= SEQUENCE {
  padata-type     [1] PADATA-TYPE,
  padata-value    [2] OCTET STRING,
}
*/

typedef struct PA_DATA {
  PADATA_TYPE padata_type;
  heim_octet_string padata_value;
} PA_DATA;

int    encode_PA_DATA(unsigned char *, size_t, const PA_DATA *, size_t *);
int    decode_PA_DATA(const unsigned char *, size_t, PA_DATA *, size_t *);
void   free_PA_DATA  (PA_DATA *);
size_t length_PA_DATA(const PA_DATA *);
int    copy_PA_DATA  (const PA_DATA *, PA_DATA *);

/*
ETYPE-INFO-ENTRY ::= SEQUENCE {
  etype           [0] ENCTYPE,
  salt            [1] OCTET STRING OPTIONAL,
  salttype        [2] krb5int32 OPTIONAL,
}
*/

typedef struct ETYPE_INFO_ENTRY {
  ENCTYPE etype;
  heim_octet_string *salt;
  krb5int32 *salttype;
} ETYPE_INFO_ENTRY;

int    encode_ETYPE_INFO_ENTRY(unsigned char *, size_t, const ETYPE_INFO_ENTRY *, size_t *);
int    decode_ETYPE_INFO_ENTRY(const unsigned char *, size_t, ETYPE_INFO_ENTRY *, size_t *);
void   free_ETYPE_INFO_ENTRY  (ETYPE_INFO_ENTRY *);
size_t length_ETYPE_INFO_ENTRY(const ETYPE_INFO_ENTRY *);
int    copy_ETYPE_INFO_ENTRY  (const ETYPE_INFO_ENTRY *, ETYPE_INFO_ENTRY *);

/*
ETYPE-INFO ::= SEQUENCE OF ETYPE-INFO-ENTRY
*/

typedef struct ETYPE_INFO {
  unsigned int len;
  ETYPE_INFO_ENTRY *val;
} ETYPE_INFO;

int    encode_ETYPE_INFO(unsigned char *, size_t, const ETYPE_INFO *, size_t *);
int    decode_ETYPE_INFO(const unsigned char *, size_t, ETYPE_INFO *, size_t *);
void   free_ETYPE_INFO  (ETYPE_INFO *);
size_t length_ETYPE_INFO(const ETYPE_INFO *);
int    copy_ETYPE_INFO  (const ETYPE_INFO *, ETYPE_INFO *);
int   add_ETYPE_INFO  (ETYPE_INFO *, const ETYPE_INFO_ENTRY *);
int   remove_ETYPE_INFO  (ETYPE_INFO *, unsigned int);

/*
ETYPE-INFO2-ENTRY ::= SEQUENCE {
  etype           [0] ENCTYPE,
  salt            [1] KerberosString OPTIONAL,
  s2kparams       [2] OCTET STRING OPTIONAL,
}
*/

typedef struct ETYPE_INFO2_ENTRY {
  ENCTYPE etype;
  KerberosString *salt;
  heim_octet_string *s2kparams;
} ETYPE_INFO2_ENTRY;

int    encode_ETYPE_INFO2_ENTRY(unsigned char *, size_t, const ETYPE_INFO2_ENTRY *, size_t *);
int    decode_ETYPE_INFO2_ENTRY(const unsigned char *, size_t, ETYPE_INFO2_ENTRY *, size_t *);
void   free_ETYPE_INFO2_ENTRY  (ETYPE_INFO2_ENTRY *);
size_t length_ETYPE_INFO2_ENTRY(const ETYPE_INFO2_ENTRY *);
int    copy_ETYPE_INFO2_ENTRY  (const ETYPE_INFO2_ENTRY *, ETYPE_INFO2_ENTRY *);

/*
ETYPE-INFO2 ::= SEQUENCE OF ETYPE-INFO2-ENTRY
*/

typedef struct ETYPE_INFO2 {
  unsigned int len;
  ETYPE_INFO2_ENTRY *val;
} ETYPE_INFO2;

int    encode_ETYPE_INFO2(unsigned char *, size_t, const ETYPE_INFO2 *, size_t *);
int    decode_ETYPE_INFO2(const unsigned char *, size_t, ETYPE_INFO2 *, size_t *);
void   free_ETYPE_INFO2  (ETYPE_INFO2 *);
size_t length_ETYPE_INFO2(const ETYPE_INFO2 *);
int    copy_ETYPE_INFO2  (const ETYPE_INFO2 *, ETYPE_INFO2 *);
int   add_ETYPE_INFO2  (ETYPE_INFO2 *, const ETYPE_INFO2_ENTRY *);
int   remove_ETYPE_INFO2  (ETYPE_INFO2 *, unsigned int);

/*
METHOD-DATA ::= SEQUENCE OF PA-DATA
*/

typedef struct METHOD_DATA {
  unsigned int len;
  PA_DATA *val;
} METHOD_DATA;

int    encode_METHOD_DATA(unsigned char *, size_t, const METHOD_DATA *, size_t *);
int    decode_METHOD_DATA(const unsigned char *, size_t, METHOD_DATA *, size_t *);
void   free_METHOD_DATA  (METHOD_DATA *);
size_t length_METHOD_DATA(const METHOD_DATA *);
int    copy_METHOD_DATA  (const METHOD_DATA *, METHOD_DATA *);
int   add_METHOD_DATA  (METHOD_DATA *, const PA_DATA *);
int   remove_METHOD_DATA  (METHOD_DATA *, unsigned int);

/*
TypedData ::= SEQUENCE {
  data-type       [0] krb5int32,
  data-value      [1] OCTET STRING OPTIONAL,
}
*/

typedef struct TypedData {
  krb5int32 data_type;
  heim_octet_string *data_value;
} TypedData;

int    encode_TypedData(unsigned char *, size_t, const TypedData *, size_t *);
int    decode_TypedData(const unsigned char *, size_t, TypedData *, size_t *);
void   free_TypedData  (TypedData *);
size_t length_TypedData(const TypedData *);
int    copy_TypedData  (const TypedData *, TypedData *);

/*
TYPED-DATA ::= SEQUENCE OF TypedData
*/

typedef struct TYPED_DATA {
  unsigned int len;
  TypedData *val;
} TYPED_DATA;

int    encode_TYPED_DATA(unsigned char *, size_t, const TYPED_DATA *, size_t *);
int    decode_TYPED_DATA(const unsigned char *, size_t, TYPED_DATA *, size_t *);
void   free_TYPED_DATA  (TYPED_DATA *);
size_t length_TYPED_DATA(const TYPED_DATA *);
int    copy_TYPED_DATA  (const TYPED_DATA *, TYPED_DATA *);

/*
KDC-REQ-BODY ::= SEQUENCE {
  kdc-options              [0] KDCOptions,
  cname                    [1] PrincipalName OPTIONAL,
  realm                    [2] Realm,
  sname                    [3] PrincipalName OPTIONAL,
  from                     [4] KerberosTime OPTIONAL,
  till                     [5] KerberosTime OPTIONAL,
  rtime                    [6] KerberosTime OPTIONAL,
  nonce                    [7] krb5int32,
  etype                    [8] SEQUENCE OF ENCTYPE,
  addresses                [9] HostAddresses OPTIONAL,
  enc-authorization-data   [10] EncryptedData OPTIONAL,
  additional-tickets       [11] SEQUENCE OF Ticket OPTIONAL,
}
*/

typedef struct KDC_REQ_BODY {
  KDCOptions kdc_options;
  PrincipalName *cname;
  Realm realm;
  PrincipalName *sname;
  KerberosTime *from;
  KerberosTime *till;
  KerberosTime *rtime;
  krb5int32 nonce;
  struct  {
    unsigned int len;
    ENCTYPE *val;
  } etype;
  HostAddresses *addresses;
  EncryptedData *enc_authorization_data;
  struct  {
    unsigned int len;
    Ticket *val;
  } *additional_tickets;
} KDC_REQ_BODY;

int    encode_KDC_REQ_BODY(unsigned char *, size_t, const KDC_REQ_BODY *, size_t *);
int    decode_KDC_REQ_BODY(const unsigned char *, size_t, KDC_REQ_BODY *, size_t *);
void   free_KDC_REQ_BODY  (KDC_REQ_BODY *);
size_t length_KDC_REQ_BODY(const KDC_REQ_BODY *);
int    copy_KDC_REQ_BODY  (const KDC_REQ_BODY *, KDC_REQ_BODY *);

/*
KDC-REQ ::= SEQUENCE {
  pvno            [1] krb5int32,
  msg-type        [2] MESSAGE-TYPE,
  padata          [3] METHOD-DATA OPTIONAL,
  req-body        [4] KDC-REQ-BODY,
}
*/

typedef struct KDC_REQ {
  krb5int32 pvno;
  MESSAGE_TYPE msg_type;
  METHOD_DATA *padata;
  KDC_REQ_BODY req_body;
} KDC_REQ;

int    encode_KDC_REQ(unsigned char *, size_t, const KDC_REQ *, size_t *);
int    decode_KDC_REQ(const unsigned char *, size_t, KDC_REQ *, size_t *);
void   free_KDC_REQ  (KDC_REQ *);
size_t length_KDC_REQ(const KDC_REQ *);
int    copy_KDC_REQ  (const KDC_REQ *, KDC_REQ *);

/*
AS-REQ ::= [APPLICATION 10] KDC-REQ
*/

typedef KDC_REQ AS_REQ;

int    encode_AS_REQ(unsigned char *, size_t, const AS_REQ *, size_t *);
int    decode_AS_REQ(const unsigned char *, size_t, AS_REQ *, size_t *);
void   free_AS_REQ  (AS_REQ *);
size_t length_AS_REQ(const AS_REQ *);
int    copy_AS_REQ  (const AS_REQ *, AS_REQ *);

/*
TGS-REQ ::= [APPLICATION 12] KDC-REQ
*/

typedef KDC_REQ TGS_REQ;

int    encode_TGS_REQ(unsigned char *, size_t, const TGS_REQ *, size_t *);
int    decode_TGS_REQ(const unsigned char *, size_t, TGS_REQ *, size_t *);
void   free_TGS_REQ  (TGS_REQ *);
size_t length_TGS_REQ(const TGS_REQ *);
int    copy_TGS_REQ  (const TGS_REQ *, TGS_REQ *);

/*
PA-ENC-TS-ENC ::= SEQUENCE {
  patimestamp     [0] KerberosTime,
  pausec          [1] krb5int32 OPTIONAL,
}
*/

typedef struct PA_ENC_TS_ENC {
  KerberosTime patimestamp;
  krb5int32 *pausec;
} PA_ENC_TS_ENC;

int    encode_PA_ENC_TS_ENC(unsigned char *, size_t, const PA_ENC_TS_ENC *, size_t *);
int    decode_PA_ENC_TS_ENC(const unsigned char *, size_t, PA_ENC_TS_ENC *, size_t *);
void   free_PA_ENC_TS_ENC  (PA_ENC_TS_ENC *);
size_t length_PA_ENC_TS_ENC(const PA_ENC_TS_ENC *);
int    copy_PA_ENC_TS_ENC  (const PA_ENC_TS_ENC *, PA_ENC_TS_ENC *);

/*
PA-PAC-REQUEST ::= SEQUENCE {
  include-pac     [0] BOOLEAN,
}
*/

typedef struct PA_PAC_REQUEST {
  int include_pac;
} PA_PAC_REQUEST;

int    encode_PA_PAC_REQUEST(unsigned char *, size_t, const PA_PAC_REQUEST *, size_t *);
int    decode_PA_PAC_REQUEST(const unsigned char *, size_t, PA_PAC_REQUEST *, size_t *);
void   free_PA_PAC_REQUEST  (PA_PAC_REQUEST *);
size_t length_PA_PAC_REQUEST(const PA_PAC_REQUEST *);
int    copy_PA_PAC_REQUEST  (const PA_PAC_REQUEST *, PA_PAC_REQUEST *);

/*
PROV-SRV-LOCATION ::= GeneralString
*/

typedef heim_general_string PROV_SRV_LOCATION;

int    encode_PROV_SRV_LOCATION(unsigned char *, size_t, const PROV_SRV_LOCATION *, size_t *);
int    decode_PROV_SRV_LOCATION(const unsigned char *, size_t, PROV_SRV_LOCATION *, size_t *);
void   free_PROV_SRV_LOCATION  (PROV_SRV_LOCATION *);
size_t length_PROV_SRV_LOCATION(const PROV_SRV_LOCATION *);
int    copy_PROV_SRV_LOCATION  (const PROV_SRV_LOCATION *, PROV_SRV_LOCATION *);

/*
KDC-REP ::= SEQUENCE {
  pvno            [0] krb5int32,
  msg-type        [1] MESSAGE-TYPE,
  padata          [2] METHOD-DATA OPTIONAL,
  crealm          [3] Realm,
  cname           [4] PrincipalName,
  ticket          [5] Ticket,
  enc-part        [6] EncryptedData,
}
*/

typedef struct KDC_REP {
  krb5int32 pvno;
  MESSAGE_TYPE msg_type;
  METHOD_DATA *padata;
  Realm crealm;
  PrincipalName cname;
  Ticket ticket;
  EncryptedData enc_part;
} KDC_REP;

int    encode_KDC_REP(unsigned char *, size_t, const KDC_REP *, size_t *);
int    decode_KDC_REP(const unsigned char *, size_t, KDC_REP *, size_t *);
void   free_KDC_REP  (KDC_REP *);
size_t length_KDC_REP(const KDC_REP *);
int    copy_KDC_REP  (const KDC_REP *, KDC_REP *);

/*
AS-REP ::= [APPLICATION 11] KDC-REP
*/

typedef KDC_REP AS_REP;

int    encode_AS_REP(unsigned char *, size_t, const AS_REP *, size_t *);
int    decode_AS_REP(const unsigned char *, size_t, AS_REP *, size_t *);
void   free_AS_REP  (AS_REP *);
size_t length_AS_REP(const AS_REP *);
int    copy_AS_REP  (const AS_REP *, AS_REP *);

/*
TGS-REP ::= [APPLICATION 13] KDC-REP
*/

typedef KDC_REP TGS_REP;

int    encode_TGS_REP(unsigned char *, size_t, const TGS_REP *, size_t *);
int    decode_TGS_REP(const unsigned char *, size_t, TGS_REP *, size_t *);
void   free_TGS_REP  (TGS_REP *);
size_t length_TGS_REP(const TGS_REP *);
int    copy_TGS_REP  (const TGS_REP *, TGS_REP *);

/*
EncKDCRepPart ::= SEQUENCE {
  key                 [0] EncryptionKey,
  last-req            [1] LastReq,
  nonce               [2] krb5int32,
  key-expiration      [3] KerberosTime OPTIONAL,
  flags               [4] TicketFlags,
  authtime            [5] KerberosTime,
  starttime           [6] KerberosTime OPTIONAL,
  endtime             [7] KerberosTime,
  renew-till          [8] KerberosTime OPTIONAL,
  srealm              [9] Realm,
  sname               [10] PrincipalName,
  caddr               [11] HostAddresses OPTIONAL,
  encrypted-pa-data   [12] METHOD-DATA OPTIONAL,
}
*/

typedef struct EncKDCRepPart {
  EncryptionKey key;
  LastReq last_req;
  krb5int32 nonce;
  KerberosTime *key_expiration;
  TicketFlags flags;
  KerberosTime authtime;
  KerberosTime *starttime;
  KerberosTime endtime;
  KerberosTime *renew_till;
  Realm srealm;
  PrincipalName sname;
  HostAddresses *caddr;
  METHOD_DATA *encrypted_pa_data;
} EncKDCRepPart;

int    encode_EncKDCRepPart(unsigned char *, size_t, const EncKDCRepPart *, size_t *);
int    decode_EncKDCRepPart(const unsigned char *, size_t, EncKDCRepPart *, size_t *);
void   free_EncKDCRepPart  (EncKDCRepPart *);
size_t length_EncKDCRepPart(const EncKDCRepPart *);
int    copy_EncKDCRepPart  (const EncKDCRepPart *, EncKDCRepPart *);

/*
EncASRepPart ::= [APPLICATION 25] EncKDCRepPart
*/

typedef EncKDCRepPart EncASRepPart;

int    encode_EncASRepPart(unsigned char *, size_t, const EncASRepPart *, size_t *);
int    decode_EncASRepPart(const unsigned char *, size_t, EncASRepPart *, size_t *);
void   free_EncASRepPart  (EncASRepPart *);
size_t length_EncASRepPart(const EncASRepPart *);
int    copy_EncASRepPart  (const EncASRepPart *, EncASRepPart *);

/*
EncTGSRepPart ::= [APPLICATION 26] EncKDCRepPart
*/

typedef EncKDCRepPart EncTGSRepPart;

int    encode_EncTGSRepPart(unsigned char *, size_t, const EncTGSRepPart *, size_t *);
int    decode_EncTGSRepPart(const unsigned char *, size_t, EncTGSRepPart *, size_t *);
void   free_EncTGSRepPart  (EncTGSRepPart *);
size_t length_EncTGSRepPart(const EncTGSRepPart *);
int    copy_EncTGSRepPart  (const EncTGSRepPart *, EncTGSRepPart *);

/*
AP-REQ ::= [APPLICATION 14] SEQUENCE {
  pvno            [0] krb5int32,
  msg-type        [1] MESSAGE-TYPE,
  ap-options      [2] APOptions,
  ticket          [3] Ticket,
  authenticator   [4] EncryptedData,
}
*/

typedef struct AP_REQ {
  krb5int32 pvno;
  MESSAGE_TYPE msg_type;
  APOptions ap_options;
  Ticket ticket;
  EncryptedData authenticator;
} AP_REQ;

int    encode_AP_REQ(unsigned char *, size_t, const AP_REQ *, size_t *);
int    decode_AP_REQ(const unsigned char *, size_t, AP_REQ *, size_t *);
void   free_AP_REQ  (AP_REQ *);
size_t length_AP_REQ(const AP_REQ *);
int    copy_AP_REQ  (const AP_REQ *, AP_REQ *);

/*
AP-REP ::= [APPLICATION 15] SEQUENCE {
  pvno            [0] krb5int32,
  msg-type        [1] MESSAGE-TYPE,
  enc-part        [2] EncryptedData,
}
*/

typedef struct AP_REP {
  krb5int32 pvno;
  MESSAGE_TYPE msg_type;
  EncryptedData enc_part;
} AP_REP;

int    encode_AP_REP(unsigned char *, size_t, const AP_REP *, size_t *);
int    decode_AP_REP(const unsigned char *, size_t, AP_REP *, size_t *);
void   free_AP_REP  (AP_REP *);
size_t length_AP_REP(const AP_REP *);
int    copy_AP_REP  (const AP_REP *, AP_REP *);

/*
EncAPRepPart ::= [APPLICATION 27] SEQUENCE {
  ctime           [0] KerberosTime,
  cusec           [1] krb5int32,
  subkey          [2] EncryptionKey OPTIONAL,
  seq-number      [3] krb5uint32 OPTIONAL,
}
*/

typedef struct EncAPRepPart {
  KerberosTime ctime;
  krb5int32 cusec;
  EncryptionKey *subkey;
  krb5uint32 *seq_number;
} EncAPRepPart;

int    encode_EncAPRepPart(unsigned char *, size_t, const EncAPRepPart *, size_t *);
int    decode_EncAPRepPart(const unsigned char *, size_t, EncAPRepPart *, size_t *);
void   free_EncAPRepPart  (EncAPRepPart *);
size_t length_EncAPRepPart(const EncAPRepPart *);
int    copy_EncAPRepPart  (const EncAPRepPart *, EncAPRepPart *);

/*
KRB-SAFE-BODY ::= SEQUENCE {
  user-data       [0] OCTET STRING,
  timestamp       [1] KerberosTime OPTIONAL,
  usec            [2] krb5int32 OPTIONAL,
  seq-number      [3] krb5uint32 OPTIONAL,
  s-address       [4] HostAddress OPTIONAL,
  r-address       [5] HostAddress OPTIONAL,
}
*/

typedef struct KRB_SAFE_BODY {
  heim_octet_string user_data;
  KerberosTime *timestamp;
  krb5int32 *usec;
  krb5uint32 *seq_number;
  HostAddress *s_address;
  HostAddress *r_address;
} KRB_SAFE_BODY;

int    encode_KRB_SAFE_BODY(unsigned char *, size_t, const KRB_SAFE_BODY *, size_t *);
int    decode_KRB_SAFE_BODY(const unsigned char *, size_t, KRB_SAFE_BODY *, size_t *);
void   free_KRB_SAFE_BODY  (KRB_SAFE_BODY *);
size_t length_KRB_SAFE_BODY(const KRB_SAFE_BODY *);
int    copy_KRB_SAFE_BODY  (const KRB_SAFE_BODY *, KRB_SAFE_BODY *);

/*
KRB-SAFE ::= [APPLICATION 20] SEQUENCE {
  pvno            [0] krb5int32,
  msg-type        [1] MESSAGE-TYPE,
  safe-body       [2] KRB-SAFE-BODY,
  cksum           [3] Checksum,
}
*/

typedef struct KRB_SAFE {
  krb5int32 pvno;
  MESSAGE_TYPE msg_type;
  KRB_SAFE_BODY safe_body;
  Checksum cksum;
} KRB_SAFE;

int    encode_KRB_SAFE(unsigned char *, size_t, const KRB_SAFE *, size_t *);
int    decode_KRB_SAFE(const unsigned char *, size_t, KRB_SAFE *, size_t *);
void   free_KRB_SAFE  (KRB_SAFE *);
size_t length_KRB_SAFE(const KRB_SAFE *);
int    copy_KRB_SAFE  (const KRB_SAFE *, KRB_SAFE *);

/*
KRB-PRIV ::= [APPLICATION 21] SEQUENCE {
  pvno            [0] krb5int32,
  msg-type        [1] MESSAGE-TYPE,
  enc-part        [3] EncryptedData,
}
*/

typedef struct KRB_PRIV {
  krb5int32 pvno;
  MESSAGE_TYPE msg_type;
  EncryptedData enc_part;
} KRB_PRIV;

int    encode_KRB_PRIV(unsigned char *, size_t, const KRB_PRIV *, size_t *);
int    decode_KRB_PRIV(const unsigned char *, size_t, KRB_PRIV *, size_t *);
void   free_KRB_PRIV  (KRB_PRIV *);
size_t length_KRB_PRIV(const KRB_PRIV *);
int    copy_KRB_PRIV  (const KRB_PRIV *, KRB_PRIV *);

/*
EncKrbPrivPart ::= [APPLICATION 28] SEQUENCE {
  user-data       [0] OCTET STRING,
  timestamp       [1] KerberosTime OPTIONAL,
  usec            [2] krb5int32 OPTIONAL,
  seq-number      [3] krb5uint32 OPTIONAL,
  s-address       [4] HostAddress OPTIONAL,
  r-address       [5] HostAddress OPTIONAL,
}
*/

typedef struct EncKrbPrivPart {
  heim_octet_string user_data;
  KerberosTime *timestamp;
  krb5int32 *usec;
  krb5uint32 *seq_number;
  HostAddress *s_address;
  HostAddress *r_address;
} EncKrbPrivPart;

int    encode_EncKrbPrivPart(unsigned char *, size_t, const EncKrbPrivPart *, size_t *);
int    decode_EncKrbPrivPart(const unsigned char *, size_t, EncKrbPrivPart *, size_t *);
void   free_EncKrbPrivPart  (EncKrbPrivPart *);
size_t length_EncKrbPrivPart(const EncKrbPrivPart *);
int    copy_EncKrbPrivPart  (const EncKrbPrivPart *, EncKrbPrivPart *);

/*
KRB-CRED ::= [APPLICATION 22] SEQUENCE {
  pvno            [0] krb5int32,
  msg-type        [1] MESSAGE-TYPE,
  tickets         [2] SEQUENCE OF Ticket,
  enc-part        [3] EncryptedData,
}
*/

typedef struct KRB_CRED {
  krb5int32 pvno;
  MESSAGE_TYPE msg_type;
  struct  {
    unsigned int len;
    Ticket *val;
  } tickets;
  EncryptedData enc_part;
} KRB_CRED;

int    encode_KRB_CRED(unsigned char *, size_t, const KRB_CRED *, size_t *);
int    decode_KRB_CRED(const unsigned char *, size_t, KRB_CRED *, size_t *);
void   free_KRB_CRED  (KRB_CRED *);
size_t length_KRB_CRED(const KRB_CRED *);
int    copy_KRB_CRED  (const KRB_CRED *, KRB_CRED *);

/*
KrbCredInfo ::= SEQUENCE {
  key             [0] EncryptionKey,
  prealm          [1] Realm OPTIONAL,
  pname           [2] PrincipalName OPTIONAL,
  flags           [3] TicketFlags OPTIONAL,
  authtime        [4] KerberosTime OPTIONAL,
  starttime       [5] KerberosTime OPTIONAL,
  endtime         [6] KerberosTime OPTIONAL,
  renew-till      [7] KerberosTime OPTIONAL,
  srealm          [8] Realm OPTIONAL,
  sname           [9] PrincipalName OPTIONAL,
  caddr           [10] HostAddresses OPTIONAL,
}
*/

typedef struct KrbCredInfo {
  EncryptionKey key;
  Realm *prealm;
  PrincipalName *pname;
  TicketFlags *flags;
  KerberosTime *authtime;
  KerberosTime *starttime;
  KerberosTime *endtime;
  KerberosTime *renew_till;
  Realm *srealm;
  PrincipalName *sname;
  HostAddresses *caddr;
} KrbCredInfo;

int    encode_KrbCredInfo(unsigned char *, size_t, const KrbCredInfo *, size_t *);
int    decode_KrbCredInfo(const unsigned char *, size_t, KrbCredInfo *, size_t *);
void   free_KrbCredInfo  (KrbCredInfo *);
size_t length_KrbCredInfo(const KrbCredInfo *);
int    copy_KrbCredInfo  (const KrbCredInfo *, KrbCredInfo *);

/*
EncKrbCredPart ::= [APPLICATION 29] SEQUENCE {
  ticket-info     [0] SEQUENCE OF KrbCredInfo,
  nonce           [1] krb5int32 OPTIONAL,
  timestamp       [2] KerberosTime OPTIONAL,
  usec            [3] krb5int32 OPTIONAL,
  s-address       [4] HostAddress OPTIONAL,
  r-address       [5] HostAddress OPTIONAL,
}
*/

typedef struct EncKrbCredPart {
  struct  {
    unsigned int len;
    KrbCredInfo *val;
  } ticket_info;
  krb5int32 *nonce;
  KerberosTime *timestamp;
  krb5int32 *usec;
  HostAddress *s_address;
  HostAddress *r_address;
} EncKrbCredPart;

int    encode_EncKrbCredPart(unsigned char *, size_t, const EncKrbCredPart *, size_t *);
int    decode_EncKrbCredPart(const unsigned char *, size_t, EncKrbCredPart *, size_t *);
void   free_EncKrbCredPart  (EncKrbCredPart *);
size_t length_EncKrbCredPart(const EncKrbCredPart *);
int    copy_EncKrbCredPart  (const EncKrbCredPart *, EncKrbCredPart *);

/*
KRB-ERROR ::= [APPLICATION 30] SEQUENCE {
  pvno            [0] krb5int32,
  msg-type        [1] MESSAGE-TYPE,
  ctime           [2] KerberosTime OPTIONAL,
  cusec           [3] krb5int32 OPTIONAL,
  stime           [4] KerberosTime,
  susec           [5] krb5int32,
  error-code      [6] krb5int32,
  crealm          [7] Realm OPTIONAL,
  cname           [8] PrincipalName OPTIONAL,
  realm           [9] Realm,
  sname           [10] PrincipalName,
  e-text          [11] GeneralString OPTIONAL,
  e-data          [12] OCTET STRING OPTIONAL,
}
*/

typedef struct KRB_ERROR {
  krb5int32 pvno;
  MESSAGE_TYPE msg_type;
  KerberosTime *ctime;
  krb5int32 *cusec;
  KerberosTime stime;
  krb5int32 susec;
  krb5int32 error_code;
  Realm *crealm;
  PrincipalName *cname;
  Realm realm;
  PrincipalName sname;
  heim_general_string *e_text;
  heim_octet_string *e_data;
} KRB_ERROR;

int    encode_KRB_ERROR(unsigned char *, size_t, const KRB_ERROR *, size_t *);
int    decode_KRB_ERROR(const unsigned char *, size_t, KRB_ERROR *, size_t *);
void   free_KRB_ERROR  (KRB_ERROR *);
size_t length_KRB_ERROR(const KRB_ERROR *);
int    copy_KRB_ERROR  (const KRB_ERROR *, KRB_ERROR *);

/*
ChangePasswdDataMS ::= SEQUENCE {
  newpasswd       [0] OCTET STRING,
  targname        [1] PrincipalName OPTIONAL,
  targrealm       [2] Realm OPTIONAL,
}
*/

typedef struct ChangePasswdDataMS {
  heim_octet_string newpasswd;
  PrincipalName *targname;
  Realm *targrealm;
} ChangePasswdDataMS;

int    encode_ChangePasswdDataMS(unsigned char *, size_t, const ChangePasswdDataMS *, size_t *);
int    decode_ChangePasswdDataMS(const unsigned char *, size_t, ChangePasswdDataMS *, size_t *);
void   free_ChangePasswdDataMS  (ChangePasswdDataMS *);
size_t length_ChangePasswdDataMS(const ChangePasswdDataMS *);
int    copy_ChangePasswdDataMS  (const ChangePasswdDataMS *, ChangePasswdDataMS *);

/*
EtypeList ::= SEQUENCE OF krb5int32
*/

typedef struct EtypeList {
  unsigned int len;
  krb5int32 *val;
} EtypeList;

int    encode_EtypeList(unsigned char *, size_t, const EtypeList *, size_t *);
int    decode_EtypeList(const unsigned char *, size_t, EtypeList *, size_t *);
void   free_EtypeList  (EtypeList *);
size_t length_EtypeList(const EtypeList *);
int    copy_EtypeList  (const EtypeList *, EtypeList *);

enum { krb5_pvno = 5 };

enum { DOMAIN_X500_COMPRESS = 1 };

/*
AD-IF-RELEVANT ::= AuthorizationData
*/

typedef AuthorizationData AD_IF_RELEVANT;

int    encode_AD_IF_RELEVANT(unsigned char *, size_t, const AD_IF_RELEVANT *, size_t *);
int    decode_AD_IF_RELEVANT(const unsigned char *, size_t, AD_IF_RELEVANT *, size_t *);
void   free_AD_IF_RELEVANT  (AD_IF_RELEVANT *);
size_t length_AD_IF_RELEVANT(const AD_IF_RELEVANT *);
int    copy_AD_IF_RELEVANT  (const AD_IF_RELEVANT *, AD_IF_RELEVANT *);

/*
AD-KDCIssued ::= SEQUENCE {
  ad-checksum     [0] Checksum,
  i-realm         [1] Realm OPTIONAL,
  i-sname         [2] PrincipalName OPTIONAL,
  elements        [3] AuthorizationData,
}
*/

typedef struct AD_KDCIssued {
  Checksum ad_checksum;
  Realm *i_realm;
  PrincipalName *i_sname;
  AuthorizationData elements;
} AD_KDCIssued;

int    encode_AD_KDCIssued(unsigned char *, size_t, const AD_KDCIssued *, size_t *);
int    decode_AD_KDCIssued(const unsigned char *, size_t, AD_KDCIssued *, size_t *);
void   free_AD_KDCIssued  (AD_KDCIssued *);
size_t length_AD_KDCIssued(const AD_KDCIssued *);
int    copy_AD_KDCIssued  (const AD_KDCIssued *, AD_KDCIssued *);

/*
AD-AND-OR ::= SEQUENCE {
  condition-count   [0] INTEGER,
  elements          [1] AuthorizationData,
}
*/

typedef struct AD_AND_OR {
  heim_integer condition_count;
  AuthorizationData elements;
} AD_AND_OR;

int    encode_AD_AND_OR(unsigned char *, size_t, const AD_AND_OR *, size_t *);
int    decode_AD_AND_OR(const unsigned char *, size_t, AD_AND_OR *, size_t *);
void   free_AD_AND_OR  (AD_AND_OR *);
size_t length_AD_AND_OR(const AD_AND_OR *);
int    copy_AD_AND_OR  (const AD_AND_OR *, AD_AND_OR *);

/*
AD-MANDATORY-FOR-KDC ::= AuthorizationData
*/

typedef AuthorizationData AD_MANDATORY_FOR_KDC;

int    encode_AD_MANDATORY_FOR_KDC(unsigned char *, size_t, const AD_MANDATORY_FOR_KDC *, size_t *);
int    decode_AD_MANDATORY_FOR_KDC(const unsigned char *, size_t, AD_MANDATORY_FOR_KDC *, size_t *);
void   free_AD_MANDATORY_FOR_KDC  (AD_MANDATORY_FOR_KDC *);
size_t length_AD_MANDATORY_FOR_KDC(const AD_MANDATORY_FOR_KDC *);
int    copy_AD_MANDATORY_FOR_KDC  (const AD_MANDATORY_FOR_KDC *, AD_MANDATORY_FOR_KDC *);

/*
PA-SAM-TYPE ::= INTEGER {
  PA_SAM_TYPE_ENIGMA(1),
  PA_SAM_TYPE_DIGI_PATH(2),
  PA_SAM_TYPE_SKEY_K0(3),
  PA_SAM_TYPE_SKEY(4),
  PA_SAM_TYPE_SECURID(5),
  PA_SAM_TYPE_CRYPTOCARD(6)
}
*/

typedef enum PA_SAM_TYPE {
  PA_SAM_TYPE_ENIGMA = 1,
  PA_SAM_TYPE_DIGI_PATH = 2,
  PA_SAM_TYPE_SKEY_K0 = 3,
  PA_SAM_TYPE_SKEY = 4,
  PA_SAM_TYPE_SECURID = 5,
  PA_SAM_TYPE_CRYPTOCARD = 6
} PA_SAM_TYPE;

int    encode_PA_SAM_TYPE(unsigned char *, size_t, const PA_SAM_TYPE *, size_t *);
int    decode_PA_SAM_TYPE(const unsigned char *, size_t, PA_SAM_TYPE *, size_t *);
void   free_PA_SAM_TYPE  (PA_SAM_TYPE *);
size_t length_PA_SAM_TYPE(const PA_SAM_TYPE *);
int    copy_PA_SAM_TYPE  (const PA_SAM_TYPE *, PA_SAM_TYPE *);

/*
PA-SAM-REDIRECT ::= HostAddresses
*/

typedef HostAddresses PA_SAM_REDIRECT;

int    encode_PA_SAM_REDIRECT(unsigned char *, size_t, const PA_SAM_REDIRECT *, size_t *);
int    decode_PA_SAM_REDIRECT(const unsigned char *, size_t, PA_SAM_REDIRECT *, size_t *);
void   free_PA_SAM_REDIRECT  (PA_SAM_REDIRECT *);
size_t length_PA_SAM_REDIRECT(const PA_SAM_REDIRECT *);
int    copy_PA_SAM_REDIRECT  (const PA_SAM_REDIRECT *, PA_SAM_REDIRECT *);

/*
SAMFlags ::= BIT STRING {
  use-sad-as-key(0),
  send-encrypted-sad(1),
  must-pk-encrypt-sad(2)
}
*/

typedef struct SAMFlags {
  unsigned int use_sad_as_key:1;
  unsigned int send_encrypted_sad:1;
  unsigned int must_pk_encrypt_sad:1;
} SAMFlags;

int    encode_SAMFlags(unsigned char *, size_t, const SAMFlags *, size_t *);
int    decode_SAMFlags(const unsigned char *, size_t, SAMFlags *, size_t *);
void   free_SAMFlags  (SAMFlags *);
size_t length_SAMFlags(const SAMFlags *);
int    copy_SAMFlags  (const SAMFlags *, SAMFlags *);
unsigned SAMFlags2int(SAMFlags);
SAMFlags int2SAMFlags(unsigned);
#ifdef __PARSE_UNITS_H__
const struct units * asn1_SAMFlags_units(void);
#endif

/*
PA-SAM-CHALLENGE-2-BODY ::= SEQUENCE {
  sam-type              [0] krb5int32,
  sam-flags             [1] SAMFlags,
  sam-type-name         [2] GeneralString OPTIONAL,
  sam-track-id          [3] GeneralString OPTIONAL,
  sam-challenge-label   [4] GeneralString OPTIONAL,
  sam-challenge         [5] GeneralString OPTIONAL,
  sam-response-prompt   [6] GeneralString OPTIONAL,
  sam-pk-for-sad        [7] EncryptionKey OPTIONAL,
  sam-nonce             [8] krb5int32,
  sam-etype             [9] krb5int32,
  ...,
}
*/

typedef struct PA_SAM_CHALLENGE_2_BODY {
  krb5int32 sam_type;
  SAMFlags sam_flags;
  heim_general_string *sam_type_name;
  heim_general_string *sam_track_id;
  heim_general_string *sam_challenge_label;
  heim_general_string *sam_challenge;
  heim_general_string *sam_response_prompt;
  EncryptionKey *sam_pk_for_sad;
  krb5int32 sam_nonce;
  krb5int32 sam_etype;
} PA_SAM_CHALLENGE_2_BODY;

int    encode_PA_SAM_CHALLENGE_2_BODY(unsigned char *, size_t, const PA_SAM_CHALLENGE_2_BODY *, size_t *);
int    decode_PA_SAM_CHALLENGE_2_BODY(const unsigned char *, size_t, PA_SAM_CHALLENGE_2_BODY *, size_t *);
void   free_PA_SAM_CHALLENGE_2_BODY  (PA_SAM_CHALLENGE_2_BODY *);
size_t length_PA_SAM_CHALLENGE_2_BODY(const PA_SAM_CHALLENGE_2_BODY *);
int    copy_PA_SAM_CHALLENGE_2_BODY  (const PA_SAM_CHALLENGE_2_BODY *, PA_SAM_CHALLENGE_2_BODY *);

/*
PA-SAM-CHALLENGE-2 ::= SEQUENCE {
  sam-body        [0] PA-SAM-CHALLENGE-2-BODY,
  sam-cksum       [1] SEQUENCE OF Checksum,
  ...,
}
*/

typedef struct PA_SAM_CHALLENGE_2 {
  PA_SAM_CHALLENGE_2_BODY sam_body;
  struct  {
    unsigned int len;
    Checksum *val;
  } sam_cksum;
} PA_SAM_CHALLENGE_2;

int    encode_PA_SAM_CHALLENGE_2(unsigned char *, size_t, const PA_SAM_CHALLENGE_2 *, size_t *);
int    decode_PA_SAM_CHALLENGE_2(const unsigned char *, size_t, PA_SAM_CHALLENGE_2 *, size_t *);
void   free_PA_SAM_CHALLENGE_2  (PA_SAM_CHALLENGE_2 *);
size_t length_PA_SAM_CHALLENGE_2(const PA_SAM_CHALLENGE_2 *);
int    copy_PA_SAM_CHALLENGE_2  (const PA_SAM_CHALLENGE_2 *, PA_SAM_CHALLENGE_2 *);

/*
PA-SAM-RESPONSE-2 ::= SEQUENCE {
  sam-type               [0] krb5int32,
  sam-flags              [1] SAMFlags,
  sam-track-id           [2] GeneralString OPTIONAL,
  sam-enc-nonce-or-sad   [3] EncryptedData,
  sam-nonce              [4] krb5int32,
  ...,
}
*/

typedef struct PA_SAM_RESPONSE_2 {
  krb5int32 sam_type;
  SAMFlags sam_flags;
  heim_general_string *sam_track_id;
  EncryptedData sam_enc_nonce_or_sad;
  krb5int32 sam_nonce;
} PA_SAM_RESPONSE_2;

int    encode_PA_SAM_RESPONSE_2(unsigned char *, size_t, const PA_SAM_RESPONSE_2 *, size_t *);
int    decode_PA_SAM_RESPONSE_2(const unsigned char *, size_t, PA_SAM_RESPONSE_2 *, size_t *);
void   free_PA_SAM_RESPONSE_2  (PA_SAM_RESPONSE_2 *);
size_t length_PA_SAM_RESPONSE_2(const PA_SAM_RESPONSE_2 *);
int    copy_PA_SAM_RESPONSE_2  (const PA_SAM_RESPONSE_2 *, PA_SAM_RESPONSE_2 *);

/*
PA-ENC-SAM-RESPONSE-ENC ::= SEQUENCE {
  sam-nonce       [0] krb5int32,
  sam-sad         [1] GeneralString OPTIONAL,
  ...,
}
*/

typedef struct PA_ENC_SAM_RESPONSE_ENC {
  krb5int32 sam_nonce;
  heim_general_string *sam_sad;
} PA_ENC_SAM_RESPONSE_ENC;

int    encode_PA_ENC_SAM_RESPONSE_ENC(unsigned char *, size_t, const PA_ENC_SAM_RESPONSE_ENC *, size_t *);
int    decode_PA_ENC_SAM_RESPONSE_ENC(const unsigned char *, size_t, PA_ENC_SAM_RESPONSE_ENC *, size_t *);
void   free_PA_ENC_SAM_RESPONSE_ENC  (PA_ENC_SAM_RESPONSE_ENC *);
size_t length_PA_ENC_SAM_RESPONSE_ENC(const PA_ENC_SAM_RESPONSE_ENC *);
int    copy_PA_ENC_SAM_RESPONSE_ENC  (const PA_ENC_SAM_RESPONSE_ENC *, PA_ENC_SAM_RESPONSE_ENC *);

/*
PA-S4U2Self ::= SEQUENCE {
  name            [0] PrincipalName,
  realm           [1] Realm,
  cksum           [2] Checksum,
  auth            [3] GeneralString,
}
*/

typedef struct PA_S4U2Self {
  PrincipalName name;
  Realm realm;
  Checksum cksum;
  heim_general_string auth;
} PA_S4U2Self;

int    encode_PA_S4U2Self(unsigned char *, size_t, const PA_S4U2Self *, size_t *);
int    decode_PA_S4U2Self(const unsigned char *, size_t, PA_S4U2Self *, size_t *);
void   free_PA_S4U2Self  (PA_S4U2Self *);
size_t length_PA_S4U2Self(const PA_S4U2Self *);
int    copy_PA_S4U2Self  (const PA_S4U2Self *, PA_S4U2Self *);

/*
KRB5SignedPathPrincipals ::= SEQUENCE OF Principal
*/

typedef struct KRB5SignedPathPrincipals {
  unsigned int len;
  Principal *val;
} KRB5SignedPathPrincipals;

int    encode_KRB5SignedPathPrincipals(unsigned char *, size_t, const KRB5SignedPathPrincipals *, size_t *);
int    decode_KRB5SignedPathPrincipals(const unsigned char *, size_t, KRB5SignedPathPrincipals *, size_t *);
void   free_KRB5SignedPathPrincipals  (KRB5SignedPathPrincipals *);
size_t length_KRB5SignedPathPrincipals(const KRB5SignedPathPrincipals *);
int    copy_KRB5SignedPathPrincipals  (const KRB5SignedPathPrincipals *, KRB5SignedPathPrincipals *);
int   add_KRB5SignedPathPrincipals  (KRB5SignedPathPrincipals *, const Principal *);
int   remove_KRB5SignedPathPrincipals  (KRB5SignedPathPrincipals *, unsigned int);

/*
KRB5SignedPathData ::= SEQUENCE {
  encticket       [0] EncTicketPart,
  delegated       [1] KRB5SignedPathPrincipals OPTIONAL,
}
*/

typedef struct KRB5SignedPathData {
  EncTicketPart encticket;
  KRB5SignedPathPrincipals *delegated;
} KRB5SignedPathData;

int    encode_KRB5SignedPathData(unsigned char *, size_t, const KRB5SignedPathData *, size_t *);
int    decode_KRB5SignedPathData(const unsigned char *, size_t, KRB5SignedPathData *, size_t *);
void   free_KRB5SignedPathData  (KRB5SignedPathData *);
size_t length_KRB5SignedPathData(const KRB5SignedPathData *);
int    copy_KRB5SignedPathData  (const KRB5SignedPathData *, KRB5SignedPathData *);

/*
KRB5SignedPath ::= SEQUENCE {
  etype           [0] ENCTYPE,
  cksum           [1] Checksum,
  delegated       [2] KRB5SignedPathPrincipals OPTIONAL,
}
*/

typedef struct KRB5SignedPath {
  ENCTYPE etype;
  Checksum cksum;
  KRB5SignedPathPrincipals *delegated;
} KRB5SignedPath;

int    encode_KRB5SignedPath(unsigned char *, size_t, const KRB5SignedPath *, size_t *);
int    decode_KRB5SignedPath(const unsigned char *, size_t, KRB5SignedPath *, size_t *);
void   free_KRB5SignedPath  (KRB5SignedPath *);
size_t length_KRB5SignedPath(const KRB5SignedPath *);
int    copy_KRB5SignedPath  (const KRB5SignedPath *, KRB5SignedPath *);

/*
PA-ClientCanonicalizedNames ::= SEQUENCE {
  requested-name   [0] PrincipalName,
  real-name        [1] PrincipalName,
}
*/

typedef struct PA_ClientCanonicalizedNames {
  PrincipalName requested_name;
  PrincipalName real_name;
} PA_ClientCanonicalizedNames;

int    encode_PA_ClientCanonicalizedNames(unsigned char *, size_t, const PA_ClientCanonicalizedNames *, size_t *);
int    decode_PA_ClientCanonicalizedNames(const unsigned char *, size_t, PA_ClientCanonicalizedNames *, size_t *);
void   free_PA_ClientCanonicalizedNames  (PA_ClientCanonicalizedNames *);
size_t length_PA_ClientCanonicalizedNames(const PA_ClientCanonicalizedNames *);
int    copy_PA_ClientCanonicalizedNames  (const PA_ClientCanonicalizedNames *, PA_ClientCanonicalizedNames *);

/*
PA-ClientCanonicalized ::= SEQUENCE {
  names            [0] PA-ClientCanonicalizedNames,
  canon-checksum   [1] Checksum,
}
*/

typedef struct PA_ClientCanonicalized {
  PA_ClientCanonicalizedNames names;
  Checksum canon_checksum;
} PA_ClientCanonicalized;

int    encode_PA_ClientCanonicalized(unsigned char *, size_t, const PA_ClientCanonicalized *, size_t *);
int    decode_PA_ClientCanonicalized(const unsigned char *, size_t, PA_ClientCanonicalized *, size_t *);
void   free_PA_ClientCanonicalized  (PA_ClientCanonicalized *);
size_t length_PA_ClientCanonicalized(const PA_ClientCanonicalized *);
int    copy_PA_ClientCanonicalized  (const PA_ClientCanonicalized *, PA_ClientCanonicalized *);

/*
AD-LoginAlias ::= SEQUENCE {
  login-alias     [0] PrincipalName,
  checksum        [1] Checksum,
}
*/

typedef struct AD_LoginAlias {
  PrincipalName login_alias;
  Checksum checksum;
} AD_LoginAlias;

int    encode_AD_LoginAlias(unsigned char *, size_t, const AD_LoginAlias *, size_t *);
int    decode_AD_LoginAlias(const unsigned char *, size_t, AD_LoginAlias *, size_t *);
void   free_AD_LoginAlias  (AD_LoginAlias *);
size_t length_AD_LoginAlias(const AD_LoginAlias *);
int    copy_AD_LoginAlias  (const AD_LoginAlias *, AD_LoginAlias *);

/*
PA-SvrReferralData ::= SEQUENCE {
  referred-name    [1] PrincipalName OPTIONAL,
  referred-realm   [0] Realm,
}
*/

typedef struct PA_SvrReferralData {
  PrincipalName *referred_name;
  Realm referred_realm;
} PA_SvrReferralData;

int    encode_PA_SvrReferralData(unsigned char *, size_t, const PA_SvrReferralData *, size_t *);
int    decode_PA_SvrReferralData(const unsigned char *, size_t, PA_SvrReferralData *, size_t *);
void   free_PA_SvrReferralData  (PA_SvrReferralData *);
size_t length_PA_SvrReferralData(const PA_SvrReferralData *);
int    copy_PA_SvrReferralData  (const PA_SvrReferralData *, PA_SvrReferralData *);

#endif /* __krb5_asn1_h__ */

repo_name: veiledmerc/mira

license: mit


code:
/* Generated from /usr/src/kerberos5/lib/libkrb5/../../../crypto/heimdal/lib/krb5/krb5_err.et */
/* $Id: krb5_err.et 21050 2007-06-12 02:00:40Z lha $ */

#ifndef __krb5_err_h__
#define __krb5_err_h__

struct et_list;

void initialize_krb5_error_table_r(struct et_list **);

void initialize_krb5_error_table(void);
#define init_krb5_err_tbl initialize_krb5_error_table

typedef enum krb5_error_number{
	KRB5KDC_ERR_NONE = -1765328384,
	KRB5KDC_ERR_NAME_EXP = -1765328383,
	KRB5KDC_ERR_SERVICE_EXP = -1765328382,
	KRB5KDC_ERR_BAD_PVNO = -1765328381,
	KRB5KDC_ERR_C_OLD_MAST_KVNO = -1765328380,
	KRB5KDC_ERR_S_OLD_MAST_KVNO = -1765328379,
	KRB5KDC_ERR_C_PRINCIPAL_UNKNOWN = -1765328378,
	KRB5KDC_ERR_S_PRINCIPAL_UNKNOWN = -1765328377,
	KRB5KDC_ERR_PRINCIPAL_NOT_UNIQUE = -1765328376,
	KRB5KDC_ERR_NULL_KEY = -1765328375,
	KRB5KDC_ERR_CANNOT_POSTDATE = -1765328374,
	KRB5KDC_ERR_NEVER_VALID = -1765328373,
	KRB5KDC_ERR_POLICY = -1765328372,
	KRB5KDC_ERR_BADOPTION = -1765328371,
	KRB5KDC_ERR_ETYPE_NOSUPP = -1765328370,
	KRB5KDC_ERR_SUMTYPE_NOSUPP = -1765328369,
	KRB5KDC_ERR_PADATA_TYPE_NOSUPP = -1765328368,
	KRB5KDC_ERR_TRTYPE_NOSUPP = -1765328367,
	KRB5KDC_ERR_CLIENT_REVOKED = -1765328366,
	KRB5KDC_ERR_SERVICE_REVOKED = -1765328365,
	KRB5KDC_ERR_TGT_REVOKED = -1765328364,
	KRB5KDC_ERR_CLIENT_NOTYET = -1765328363,
	KRB5KDC_ERR_SERVICE_NOTYET = -1765328362,
	KRB5KDC_ERR_KEY_EXPIRED = -1765328361,
	KRB5KDC_ERR_PREAUTH_FAILED = -1765328360,
	KRB5KDC_ERR_PREAUTH_REQUIRED = -1765328359,
	KRB5KDC_ERR_SERVER_NOMATCH = -1765328358,
	KRB5KDC_ERR_KDC_ERR_MUST_USE_USER2USER = -1765328357,
	KRB5KDC_ERR_PATH_NOT_ACCEPTED = -1765328356,
	KRB5KDC_ERR_SVC_UNAVAILABLE = -1765328355,
	KRB5KRB_AP_ERR_BAD_INTEGRITY = -1765328353,
	KRB5KRB_AP_ERR_TKT_EXPIRED = -1765328352,
	KRB5KRB_AP_ERR_TKT_NYV = -1765328351,
	KRB5KRB_AP_ERR_REPEAT = -1765328350,
	KRB5KRB_AP_ERR_NOT_US = -1765328349,
	KRB5KRB_AP_ERR_BADMATCH = -1765328348,
	KRB5KRB_AP_ERR_SKEW = -1765328347,
	KRB5KRB_AP_ERR_BADADDR = -1765328346,
	KRB5KRB_AP_ERR_BADVERSION = -1765328345,
	KRB5KRB_AP_ERR_MSG_TYPE = -1765328344,
	KRB5KRB_AP_ERR_MODIFIED = -1765328343,
	KRB5KRB_AP_ERR_BADORDER = -1765328342,
	KRB5KRB_AP_ERR_ILL_CR_TKT = -1765328341,
	KRB5KRB_AP_ERR_BADKEYVER = -1765328340,
	KRB5KRB_AP_ERR_NOKEY = -1765328339,
	KRB5KRB_AP_ERR_MUT_FAIL = -1765328338,
	KRB5KRB_AP_ERR_BADDIRECTION = -1765328337,
	KRB5KRB_AP_ERR_METHOD = -1765328336,
	KRB5KRB_AP_ERR_BADSEQ = -1765328335,
	KRB5KRB_AP_ERR_INAPP_CKSUM = -1765328334,
	KRB5KRB_AP_PATH_NOT_ACCEPTED = -1765328333,
	KRB5KRB_ERR_RESPONSE_TOO_BIG = -1765328332,
	KRB5KRB_ERR_GENERIC = -1765328324,
	KRB5KRB_ERR_FIELD_TOOLONG = -1765328323,
	KRB5_KDC_ERR_CLIENT_NOT_TRUSTED = -1765328322,
	KRB5_KDC_ERR_KDC_NOT_TRUSTED = -1765328321,
	KRB5_KDC_ERR_INVALID_SIG = -1765328320,
	KRB5_KDC_ERR_DH_KEY_PARAMETERS_NOT_ACCEPTED = -1765328319,
	KRB5_KDC_ERR_WRONG_REALM = -1765328316,
	KRB5_AP_ERR_USER_TO_USER_REQUIRED = -1765328315,
	KRB5_KDC_ERR_CANT_VERIFY_CERTIFICATE = -1765328314,
	KRB5_KDC_ERR_INVALID_CERTIFICATE = -1765328313,
	KRB5_KDC_ERR_REVOKED_CERTIFICATE = -1765328312,
	KRB5_KDC_ERR_REVOCATION_STATUS_UNKNOWN = -1765328311,
	KRB5_KDC_ERR_REVOCATION_STATUS_UNAVAILABLE = -1765328310,
	KRB5_KDC_ERR_CLIENT_NAME_MISMATCH = -1765328309,
	KRB5_KDC_ERR_INCONSISTENT_KEY_PURPOSE = -1765328308,
	KRB5_KDC_ERR_DIGEST_IN_CERT_NOT_ACCEPTED = -1765328307,
	KRB5_KDC_ERR_PA_CHECKSUM_MUST_BE_INCLUDED = -1765328306,
	KRB5_KDC_ERR_DIGEST_IN_SIGNED_DATA_NOT_ACCEPTED = -1765328305,
	KRB5_KDC_ERR_PUBLIC_KEY_ENCRYPTION_NOT_SUPPORTED = -1765328304,
	KRB5_ERR_RCSID = -1765328256,
	KRB5_LIBOS_BADLOCKFLAG = -1765328255,
	KRB5_LIBOS_CANTREADPWD = -1765328254,
	KRB5_LIBOS_BADPWDMATCH = -1765328253,
	KRB5_LIBOS_PWDINTR = -1765328252,
	KRB5_PARSE_ILLCHAR = -1765328251,
	KRB5_PARSE_MALFORMED = -1765328250,
	KRB5_CONFIG_CANTOPEN = -1765328249,
	KRB5_CONFIG_BADFORMAT = -1765328248,
	KRB5_CONFIG_NOTENUFSPACE = -1765328247,
	KRB5_BADMSGTYPE = -1765328246,
	KRB5_CC_BADNAME = -1765328245,
	KRB5_CC_UNKNOWN_TYPE = -1765328244,
	KRB5_CC_NOTFOUND = -1765328243,
	KRB5_CC_END = -1765328242,
	KRB5_NO_TKT_SUPPLIED = -1765328241,
	KRB5KRB_AP_WRONG_PRINC = -1765328240,
	KRB5KRB_AP_ERR_TKT_INVALID = -1765328239,
	KRB5_PRINC_NOMATCH = -1765328238,
	KRB5_KDCREP_MODIFIED = -1765328237,
	KRB5_KDCREP_SKEW = -1765328236,
	KRB5_IN_TKT_REALM_MISMATCH = -1765328235,
	KRB5_PROG_ETYPE_NOSUPP = -1765328234,
	KRB5_PROG_KEYTYPE_NOSUPP = -1765328233,
	KRB5_WRONG_ETYPE = -1765328232,
	KRB5_PROG_SUMTYPE_NOSUPP = -1765328231,
	KRB5_REALM_UNKNOWN = -1765328230,
	KRB5_SERVICE_UNKNOWN = -1765328229,
	KRB5_KDC_UNREACH = -1765328228,
	KRB5_NO_LOCALNAME = -1765328227,
	KRB5_MUTUAL_FAILED = -1765328226,
	KRB5_RC_TYPE_EXISTS = -1765328225,
	KRB5_RC_MALLOC = -1765328224,
	KRB5_RC_TYPE_NOTFOUND = -1765328223,
	KRB5_RC_UNKNOWN = -1765328222,
	KRB5_RC_REPLAY = -1765328221,
	KRB5_RC_IO = -1765328220,
	KRB5_RC_NOIO = -1765328219,
	KRB5_RC_PARSE = -1765328218,
	KRB5_RC_IO_EOF = -1765328217,
	KRB5_RC_IO_MALLOC = -1765328216,
	KRB5_RC_IO_PERM = -1765328215,
	KRB5_RC_IO_IO = -1765328214,
	KRB5_RC_IO_UNKNOWN = -1765328213,
	KRB5_RC_IO_SPACE = -1765328212,
	KRB5_TRANS_CANTOPEN = -1765328211,
	KRB5_TRANS_BADFORMAT = -1765328210,
	KRB5_LNAME_CANTOPEN = -1765328209,
	KRB5_LNAME_NOTRANS = -1765328208,
	KRB5_LNAME_BADFORMAT = -1765328207,
	KRB5_CRYPTO_INTERNAL = -1765328206,
	KRB5_KT_BADNAME = -1765328205,
	KRB5_KT_UNKNOWN_TYPE = -1765328204,
	KRB5_KT_NOTFOUND = -1765328203,
	KRB5_KT_END = -1765328202,
	KRB5_KT_NOWRITE = -1765328201,
	KRB5_KT_IOERR = -1765328200,
	KRB5_NO_TKT_IN_RLM = -1765328199,
	KRB5DES_BAD_KEYPAR = -1765328198,
	KRB5DES_WEAK_KEY = -1765328197,
	KRB5_BAD_ENCTYPE = -1765328196,
	KRB5_BAD_KEYSIZE = -1765328195,
	KRB5_BAD_MSIZE = -1765328194,
	KRB5_CC_TYPE_EXISTS = -1765328193,
	KRB5_KT_TYPE_EXISTS = -1765328192,
	KRB5_CC_IO = -1765328191,
	KRB5_FCC_PERM = -1765328190,
	KRB5_FCC_NOFILE = -1765328189,
	KRB5_FCC_INTERNAL = -1765328188,
	KRB5_CC_WRITE = -1765328187,
	KRB5_CC_NOMEM = -1765328186,
	KRB5_CC_FORMAT = -1765328185,
	KRB5_CC_NOT_KTYPE = -1765328184,
	KRB5_INVALID_FLAGS = -1765328183,
	KRB5_NO_2ND_TKT = -1765328182,
	KRB5_NOCREDS_SUPPLIED = -1765328181,
	KRB5_SENDAUTH_BADAUTHVERS = -1765328180,
	KRB5_SENDAUTH_BADAPPLVERS = -1765328179,
	KRB5_SENDAUTH_BADRESPONSE = -1765328178,
	KRB5_SENDAUTH_REJECTED = -1765328177,
	KRB5_PREAUTH_BAD_TYPE = -1765328176,
	KRB5_PREAUTH_NO_KEY = -1765328175,
	KRB5_PREAUTH_FAILED = -1765328174,
	KRB5_RCACHE_BADVNO = -1765328173,
	KRB5_CCACHE_BADVNO = -1765328172,
	KRB5_KEYTAB_BADVNO = -1765328171,
	KRB5_PROG_ATYPE_NOSUPP = -1765328170,
	KRB5_RC_REQUIRED = -1765328169,
	KRB5_ERR_BAD_HOSTNAME = -1765328168,
	KRB5_ERR_HOST_REALM_UNKNOWN = -1765328167,
	KRB5_SNAME_UNSUPP_NAMETYPE = -1765328166,
	KRB5KRB_AP_ERR_V4_REPLY = -1765328165,
	KRB5_REALM_CANT_RESOLVE = -1765328164,
	KRB5_TKT_NOT_FORWARDABLE = -1765328163,
	KRB5_FWD_BAD_PRINCIPAL = -1765328162,
	KRB5_GET_IN_TKT_LOOP = -1765328161,
	KRB5_CONFIG_NODEFREALM = -1765328160,
	KRB5_SAM_UNSUPPORTED = -1765328159,
	KRB5_SAM_INVALID_ETYPE = -1765328158,
	KRB5_SAM_NO_CHECKSUM = -1765328157,
	KRB5_SAM_BAD_CHECKSUM = -1765328156,
	KRB5_OBSOLETE_FN = -1765328146,
	KRB5_ERR_BAD_S2K_PARAMS = -1765328139,
	KRB5_ERR_NO_SERVICE = -1765328138,
	KRB5_CC_NOSUPP = -1765328137,
	KRB5_DELTAT_BADFORMAT = -1765328136
} krb5_error_number;

#define ERROR_TABLE_BASE_krb5 -1765328384

#endif /* __krb5_err_h__ */


code:
/* Generated from /usr/src/kerberos5/lib/libkrb5/../../../crypto/heimdal/lib/krb5/krb_err.et */
/* $Id: krb_err.et,v 1.7 1998/03/29 14:19:52 bg Exp $ */

#ifndef __krb_err_h__
#define __krb_err_h__

struct et_list;

void initialize_krb_error_table_r(struct et_list **);

void initialize_krb_error_table(void);
#define init_krb_err_tbl initialize_krb_error_table

typedef enum krb_error_number{
	KRB4ET_KSUCCESS = 39525376,
	KRB4ET_KDC_NAME_EXP = 39525377,
	KRB4ET_KDC_SERVICE_EXP = 39525378,
	KRB4ET_KDC_AUTH_EXP = 39525379,
	KRB4ET_KDC_PKT_VER = 39525380,
	KRB4ET_KDC_P_MKEY_VER = 39525381,
	KRB4ET_KDC_S_MKEY_VER = 39525382,
	KRB4ET_KDC_BYTE_ORDER = 39525383,
	KRB4ET_KDC_PR_UNKNOWN = 39525384,
	KRB4ET_KDC_PR_N_UNIQUE = 39525385,
	KRB4ET_KDC_NULL_KEY = 39525386,
	KRB4ET_KDC_GEN_ERR = 39525396,
	KRB4ET_GC_TKFIL = 39525397,
	KRB4ET_GC_NOTKT = 39525398,
	KRB4ET_MK_AP_TGTEXP = 39525402,
	KRB4ET_RD_AP_UNDEC = 39525407,
	KRB4ET_RD_AP_EXP = 39525408,
	KRB4ET_RD_AP_NYV = 39525409,
	KRB4ET_RD_AP_REPEAT = 39525410,
	KRB4ET_RD_AP_NOT_US = 39525411,
	KRB4ET_RD_AP_INCON = 39525412,
	KRB4ET_RD_AP_TIME = 39525413,
	KRB4ET_RD_AP_BADD = 39525414,
	KRB4ET_RD_AP_VERSION = 39525415,
	KRB4ET_RD_AP_MSG_TYPE = 39525416,
	KRB4ET_RD_AP_MODIFIED = 39525417,
	KRB4ET_RD_AP_ORDER = 39525418,
	KRB4ET_RD_AP_UNAUTHOR = 39525419,
	KRB4ET_GT_PW_NULL = 39525427,
	KRB4ET_GT_PW_BADPW = 39525428,
	KRB4ET_GT_PW_PROT = 39525429,
	KRB4ET_GT_PW_KDCERR = 39525430,
	KRB4ET_GT_PW_NULLTKT = 39525431,
	KRB4ET_SKDC_RETRY = 39525432,
	KRB4ET_SKDC_CANT = 39525433,
	KRB4ET_INTK_W_NOTALL = 39525437,
	KRB4ET_INTK_BADPW = 39525438,
	KRB4ET_INTK_PROT = 39525439,
	KRB4ET_INTK_ERR = 39525446,
	KRB4ET_AD_NOTGT = 39525447,
	KRB4ET_NO_TKT_FIL = 39525452,
	KRB4ET_TKT_FIL_ACC = 39525453,
	KRB4ET_TKT_FIL_LCK = 39525454,
	KRB4ET_TKT_FIL_FMT = 39525455,
	KRB4ET_TKT_FIL_INI = 39525456,
	KRB4ET_KNAME_FMT = 39525457
} krb_error_number;

#define ERROR_TABLE_BASE_krb 39525376

#endif /* __krb_err_h__ */


code:
/*-
 * Copyright (c) 1989, 1993
 *	The Regents of the University of California.  All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 * 4. Neither the name of the University nor the names of its contributors
 *    may be used to endorse or promote products derived from this software
 *    without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 *
 *	@(#)kvm.h	8.1 (Berkeley) 6/2/93
 * $FreeBSD: release/9.0.0/lib/libkvm/kvm.h 217744 2011-01-23 11:08:28Z uqs $
 */

#ifndef _KVM_H_
#define	_KVM_H_

#include <sys/cdefs.h>
#include <sys/_types.h>
#include <nlist.h>

/* Default version symbol. */
#define	VRS_SYM		"_version"
#define	VRS_KEY		"VERSION"

#ifndef _SIZE_T_DECLARED
typedef	__size_t	size_t;
#define	_SIZE_T_DECLARED
#endif

#ifndef _SSIZE_T_DECLARED
typedef	__ssize_t	ssize_t;
#define	_SSIZE_T_DECLARED
#endif

typedef struct __kvm kvm_t;

struct kinfo_proc;
struct proc;

struct kvm_swap {
	char	ksw_devname[32];
	int	ksw_used;
	int	ksw_total;
	int	ksw_flags;
	int	ksw_reserved1;
	int	ksw_reserved2;
};

#define SWIF_DEV_PREFIX	0x0002

__BEGIN_DECLS
int	  kvm_close(kvm_t *);
int	  kvm_dpcpu_setcpu(kvm_t *, unsigned int);
char	**kvm_getargv(kvm_t *, const struct kinfo_proc *, int);
int	  kvm_getcptime(kvm_t *, long *);
char	**kvm_getenvv(kvm_t *, const struct kinfo_proc *, int);
char	 *kvm_geterr(kvm_t *);
char	 *kvm_getfiles(kvm_t *, int, int, int *);
int	  kvm_getloadavg(kvm_t *, double [], int);
int	  kvm_getmaxcpu(kvm_t *);
void	 *kvm_getpcpu(kvm_t *, int);
struct kinfo_proc *
	  kvm_getprocs(kvm_t *, int, int, int *);
int	  kvm_getswapinfo(kvm_t *, struct kvm_swap *, int, int);
int	  kvm_nlist(kvm_t *, struct nlist *);
kvm_t	 *kvm_open
	    (const char *, const char *, const char *, int, const char *);
kvm_t	 *kvm_openfiles
	    (const char *, const char *, const char *, int, char *);
ssize_t	  kvm_read(kvm_t *, unsigned long, void *, size_t);
ssize_t	  kvm_uread
	    (kvm_t *, const struct kinfo_proc *, unsigned long, char *, size_t);
ssize_t	  kvm_write(kvm_t *, unsigned long, const void *, size_t);
__END_DECLS

#endif /* !_KVM_H_ */