code:
/*
 * Copyright (c) 1983, 1987, 1989
 *    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.
 * 3. 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.
 */

/*
 * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
 * Portions Copyright (c) 1996-1999 by Internet Software Consortium.
 *
 * Permission to use, copy, modify, and distribute this software for any
 * purpose with or without fee is hereby granted, provided that the above
 * copyright notice and this permission notice appear in all copies.
 *
 * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR
 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
 * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 */

/*%
 *	@(#)resolv.h	8.1 (Berkeley) 6/2/93
 *	$Id: resolv.h,v 1.19.18.4 2008/04/03 23:15:15 marka Exp $
 * $FreeBSD: release/9.0.0/include/resolv.h 203964 2010-02-16 19:39:50Z imp $
 */

#ifndef _RESOLV_H_
#define	_RESOLV_H_

#include <sys/param.h>
#include <sys/types.h>
#include <sys/cdefs.h>
#include <sys/socket.h>
#include <stdio.h>
#include <arpa/nameser.h>

/*%
 * Revision information.  This is the release date in YYYYMMDD format.
 * It can change every day so the right thing to do with it is use it
 * in preprocessor commands such as "#if (__RES > 19931104)".  Do not
 * compare for equality; rather, use it to determine whether your resolver
 * is new enough to contain a certain feature.
 */

#define	__RES	20030124

/*%
 * This used to be defined in res_query.c, now it's in herror.c.
 * [XXX no it's not.  It's in irs/irs_data.c]
 * It was
 * never extern'd by any *.h file before it was placed here.  For thread
 * aware programs, the last h_errno value set is stored in res->h_errno.
 *
 * XXX:	There doesn't seem to be a good reason for exposing RES_SET_H_ERRNO
 *	(and __h_errno_set) to the public via <resolv.h>.
 * XXX:	__h_errno_set is really part of IRS, not part of the resolver.
 *	If somebody wants to build and use a resolver that doesn't use IRS,
 *	what do they do?  Perhaps something like
 *		#ifdef WANT_IRS
 *		# define RES_SET_H_ERRNO(r,x) __h_errno_set(r,x)
 *		#else
 *		# define RES_SET_H_ERRNO(r,x) (h_errno = (r)->res_h_errno = (x))
 *		#endif
 */

#define RES_SET_H_ERRNO(r,x) __h_errno_set(r,x)
struct __res_state; /*%< forward */
__BEGIN_DECLS
void __h_errno_set(struct __res_state *, int);
__END_DECLS

/*%
 * Resolver configuration file.
 * Normally not present, but may contain the address of the
 * initial name server(s) to query and the domain search list.
 */

#ifndef _PATH_RESCONF
#define	_PATH_RESCONF        "/etc/resolv.conf"
#endif

typedef enum { res_goahead, res_nextns, res_modified, res_done, res_error }
	res_sendhookact;

typedef res_sendhookact (*res_send_qhook)(struct sockaddr * const *,
					  const u_char **, int *,
					  u_char *, int, int *);

typedef res_sendhookact (*res_send_rhook)(const struct sockaddr *,
					  const u_char *, int, u_char *,
					  int, int *);

struct res_sym {
	int		number;	   /*%< Identifying number, like T_MX */
	const char *	name;	   /*%< Its symbolic name, like "MX" */
	const char *	humanname; /*%< Its fun name, like "mail exchanger" */
};

/*%
 * Global defines and variables for resolver stub.
 */
#define	MAXNS			3	/*%< max # name servers we'll track */
#define	MAXDFLSRCH		3	/*%< # default domain levels to try */
#define	MAXDNSRCH		6	/*%< max # domains in search path */
#define	LOCALDOMAINPARTS	2	/*%< min levels in name that is "local" */
#define	RES_TIMEOUT		5	/*%< min. seconds between retries */
#define	MAXRESOLVSORT		10	/*%< number of net to sort on */
#define	RES_MAXNDOTS		15	/*%< should reflect bit field size */
#define	RES_MAXRETRANS		30	/*%< only for resolv.conf/RES_OPTIONS */
#define	RES_MAXRETRY		5	/*%< only for resolv.conf/RES_OPTIONS */
#define	RES_DFLRETRY		2	/*%< Default #/tries. */
#define	RES_MAXTIME		65535	/*%< Infinity, in milliseconds. */
struct __res_state_ext;

struct __res_state {
	int	retrans;	 	/*%< retransmission time interval */
	int	retry;			/*%< number of times to retransmit */
	/*
	 * XXX: If `sun' is defined, `options' and `pfcode' are
	 * defined as u_int in original BIND9 distribution.  However,
	 * it breaks binary backward compatibility against FreeBSD's
	 * resolver.  So, we changed not to see `sun'.
	 */
#if defined(sun) && 0
	u_int	options;		/*%< option flags - see below. */
#else
	u_long	options;		/*%< option flags - see below. */
#endif
	int	nscount;		/*%< number of name servers */
	struct sockaddr_in
		nsaddr_list[MAXNS];	/*%< address of name server */
#define	nsaddr	nsaddr_list[0]		/*%< for backward compatibility */
	u_short	id;			/*%< current message id */
	char	*dnsrch[MAXDNSRCH+1];	/*%< components of domain to search */
	char	defdname[256];		/*%< default domain (deprecated) */
#if defined(sun) && 0
	u_int	pfcode;			/*%< RES_PRF_ flags - see below. */
#else
	u_long	pfcode;			/*%< RES_PRF_ flags - see below. */
#endif
	unsigned ndots:4;		/*%< threshold for initial abs. query */
	unsigned nsort:4;		/*%< number of elements in sort_list[] */
	char	unused[3];
	struct {
		struct in_addr	addr;
		u_int32_t	mask;
	} sort_list[MAXRESOLVSORT];
	res_send_qhook qhook;		/*%< query hook */
	res_send_rhook rhook;		/*%< response hook */
	int	res_h_errno;		/*%< last one set for this context */
	int	_vcsock;		/*%< PRIVATE: for res_send VC i/o */
	u_int	_flags;			/*%< PRIVATE: see below */
	u_int	_pad;			/*%< make _u 64 bit aligned */
	union {
		/* On an 32-bit arch this means 512b total. */
		char	pad[72 - 4*sizeof (int) - 2*sizeof (void *)];
		struct {
			u_int16_t		nscount;
			u_int16_t		nstimes[MAXNS];	/*%< ms. */
			int			nssocks[MAXNS];
			struct __res_state_ext *ext;	/*%< extention for IPv6 */
		} _ext;
	} _u;
};

typedef struct __res_state *res_state;

union res_sockaddr_union {
	struct sockaddr_in	sin;
#ifdef IN6ADDR_ANY_INIT
	struct sockaddr_in6	sin6;
#endif
#ifdef ISC_ALIGN64
	int64_t			__align64;	/*%< 64bit alignment */
#else
	int32_t			__align32;	/*%< 32bit alignment */
#endif
	char			__space[128];   /*%< max size */
};

/*%
 * Resolver flags (used to be discrete per-module statics ints).
 */
#define	RES_F_VC	0x00000001	/*%< socket is TCP */
#define	RES_F_CONN	0x00000002	/*%< socket is connected */
#define	RES_F_EDNS0ERR	0x00000004	/*%< EDNS0 caused errors */
#define	RES_F__UNUSED	0x00000008	/*%< (unused) */
#define	RES_F_LASTMASK	0x000000F0	/*%< ordinal server of last res_nsend */
#define	RES_F_LASTSHIFT	4		/*%< bit position of LASTMASK "flag" */
#define	RES_GETLAST(res) (((res)._flags & RES_F_LASTMASK) >> RES_F_LASTSHIFT)

/* res_findzonecut2() options */
#define	RES_EXHAUSTIVE	0x00000001	/*%< always do all queries */
#define	RES_IPV4ONLY	0x00000002	/*%< IPv4 only */
#define	RES_IPV6ONLY	0x00000004	/*%< IPv6 only */

/*%
 * Resolver options (keep these in synch with res_debug.c, please)
 */
#define RES_INIT	0x00000001	/*%< address initialized */
#define RES_DEBUG	0x00000002	/*%< print debug messages */
#define RES_AAONLY	0x00000004	/*%< authoritative answers only (!IMPL)*/
#define RES_USEVC	0x00000008	/*%< use virtual circuit */
#define RES_PRIMARY	0x00000010	/*%< query primary server only (!IMPL) */
#define RES_IGNTC	0x00000020	/*%< ignore truncation errors */
#define RES_RECURSE	0x00000040	/*%< recursion desired */
#define RES_DEFNAMES	0x00000080	/*%< use default domain name */
#define RES_STAYOPEN	0x00000100	/*%< Keep TCP socket open */
#define RES_DNSRCH	0x00000200	/*%< search up local domain tree */
#define	RES_INSECURE1	0x00000400	/*%< type 1 security disabled */
#define	RES_INSECURE2	0x00000800	/*%< type 2 security disabled */
#define	RES_NOALIASES	0x00001000	/*%< shuts off HOSTALIASES feature */
#define	RES_USE_INET6	0x00002000	/*%< use/map IPv6 in gethostbyname() */
#define RES_ROTATE	0x00004000	/*%< rotate ns list after each query */
#define	RES_NOCHECKNAME	0x00008000	/*%< do not check names for sanity. */
#define	RES_KEEPTSIG	0x00010000	/*%< do not strip TSIG records */
#define	RES_BLAST	0x00020000	/*%< blast all recursive servers */
#define RES_NSID	0x00040000      /*%< request name server ID */
#define RES_NOTLDQUERY	0x00100000	/*%< don't unqualified name as a tld */
#define RES_USE_DNSSEC	0x00200000	/*%< use DNSSEC using OK bit in OPT */
/* #define RES_DEBUG2	0x00400000 */	/* nslookup internal */
/* KAME extensions: use higher bit to avoid conflict with ISC use */
#define RES_USE_DNAME	0x10000000	/*%< use DNAME */
#define RES_USE_EDNS0	0x40000000	/*%< use EDNS0 if configured */
#define RES_NO_NIBBLE2	0x80000000	/*%< disable alternate nibble lookup */

#define RES_DEFAULT	(RES_RECURSE | RES_DEFNAMES | \
			 RES_DNSRCH | RES_NO_NIBBLE2)

/*%
 * Resolver "pfcode" values.  Used by dig.
 */
#define	RES_PRF_STATS	0x00000001
#define	RES_PRF_UPDATE	0x00000002
#define	RES_PRF_CLASS   0x00000004
#define	RES_PRF_CMD	0x00000008
#define	RES_PRF_QUES	0x00000010
#define	RES_PRF_ANS	0x00000020
#define	RES_PRF_AUTH	0x00000040
#define	RES_PRF_ADD	0x00000080
#define	RES_PRF_HEAD1	0x00000100
#define	RES_PRF_HEAD2	0x00000200
#define	RES_PRF_TTLID	0x00000400
#define	RES_PRF_HEADX	0x00000800
#define	RES_PRF_QUERY	0x00001000
#define	RES_PRF_REPLY	0x00002000
#define	RES_PRF_INIT	0x00004000
#define	RES_PRF_TRUNC	0x00008000
/*			0x00010000	*/

/* Things involving an internal (static) resolver context. */
__BEGIN_DECLS
extern struct __res_state *__res_state(void);
__END_DECLS
#define _res (*__res_state())

#ifndef __BIND_NOSTATIC
#define fp_nquery		__fp_nquery
#define fp_query		__fp_query
#define hostalias		__hostalias
#define p_query			__p_query
#define res_close		__res_close
#define res_init		__res_init
#define res_isourserver		__res_isourserver
#define res_mkquery		__res_mkquery
#define res_opt			__res_opt
#define res_query		__res_query
#define res_querydomain		__res_querydomain
#define res_search		__res_search
#define res_send		__res_send
#define res_sendsigned		__res_sendsigned

__BEGIN_DECLS
void		fp_nquery(const u_char *, int, FILE *);
void		fp_query(const u_char *, FILE *);
const char *	hostalias(const char *);
void		p_query(const u_char *);
void		res_close(void);
int		res_init(void);
int		res_isourserver(const struct sockaddr_in *);
int		res_mkquery(int, const char *, int, int, const u_char *,
				 int, const u_char *, u_char *, int);
int		res_opt(int, u_char *, int, int);
int		res_query(const char *, int, int, u_char *, int);
int		res_querydomain(const char *, const char *, int, int,
				     u_char *, int);
int		res_search(const char *, int, int, u_char *, int);
int		res_send(const u_char *, int, u_char *, int);
int		res_sendsigned(const u_char *, int, ns_tsig_key *,
				    u_char *, int);
__END_DECLS
#endif

#if !defined(SHARED_LIBBIND) || defined(LIB)
/*
 * If libbind is a shared object (well, DLL anyway)
 * these externs break the linker when resolv.h is
 * included by a lib client (like named)
 * Make them go away if a client is including this
 *
 */
extern const struct res_sym __p_key_syms[];
extern const struct res_sym __p_cert_syms[];
extern const struct res_sym __p_class_syms[];
extern const struct res_sym __p_type_syms[];
extern const struct res_sym __p_rcode_syms[];
#endif /* SHARED_LIBBIND */

#define b64_ntop		__b64_ntop
#define b64_pton		__b64_pton
#define dn_comp			__dn_comp
#define dn_count_labels		__dn_count_labels
#define dn_expand		__dn_expand
#define dn_skipname		__dn_skipname
#define fp_resstat		__fp_resstat
#define loc_aton		__loc_aton
#define loc_ntoa		__loc_ntoa
#define p_cdname		__p_cdname
#define p_cdnname		__p_cdnname
#define p_class			__p_class
#define p_fqname		__p_fqname
#define p_fqnname		__p_fqnname
#define p_option		__p_option
#define p_secstodate		__p_secstodate
#define p_section		__p_section
#define p_time			__p_time
#define p_type			__p_type
#define p_rcode			__p_rcode
#define p_sockun		__p_sockun
#define putlong			__putlong
#define putshort		__putshort
#define res_dnok		__res_dnok
#if 0
#define res_findzonecut		__res_findzonecut
#endif
#define res_findzonecut2	__res_findzonecut2
#define res_hnok		__res_hnok
#define res_hostalias		__res_hostalias
#define res_mailok		__res_mailok
#define res_nameinquery		__res_nameinquery
#define res_nclose		__res_nclose
#define res_ninit		__res_ninit
#define res_nmkquery		__res_nmkquery
#define res_pquery		__res_pquery
#define res_nquery		__res_nquery
#define res_nquerydomain	__res_nquerydomain
#define res_nsearch		__res_nsearch
#define res_nsend		__res_nsend
#if 0
#define res_nsendsigned		__res_nsendsigned
#endif
#define res_nisourserver	__res_nisourserver
#define res_ownok		__res_ownok
#define res_queriesmatch	__res_queriesmatch
#define res_randomid		__res_randomid
#define sym_ntop		__sym_ntop
#define sym_ntos		__sym_ntos
#define sym_ston		__sym_ston
#define res_nopt		__res_nopt
#define res_nopt_rdata       	__res_nopt_rdata
#define res_ndestroy		__res_ndestroy
#define	res_nametoclass		__res_nametoclass
#define	res_nametotype		__res_nametotype
#define	res_setservers		__res_setservers
#define	res_getservers		__res_getservers
#if 0
#define	res_buildprotolist	__res_buildprotolist
#define	res_destroyprotolist	__res_destroyprotolist
#define	res_destroyservicelist	__res_destroyservicelist
#define	res_get_nibblesuffix	__res_get_nibblesuffix
#define	res_get_nibblesuffix2	__res_get_nibblesuffix2
#endif
#define	res_ourserver_p		__res_ourserver_p
#if 0
#define	res_protocolname	__res_protocolname
#define	res_protocolnumber	__res_protocolnumber
#endif
#define	res_send_setqhook	__res_send_setqhook
#define	res_send_setrhook	__res_send_setrhook
#if 0
#define	res_servicename		__res_servicename
#define	res_servicenumber	__res_servicenumber
#endif
__BEGIN_DECLS
int		res_hnok(const char *);
int		res_ownok(const char *);
int		res_mailok(const char *);
int		res_dnok(const char *);
int		sym_ston(const struct res_sym *, const char *, int *);
const char *	sym_ntos(const struct res_sym *, int, int *);
const char *	sym_ntop(const struct res_sym *, int, int *);
int		b64_ntop(u_char const *, size_t, char *, size_t);
int		b64_pton(char const *, u_char *, size_t);
int		loc_aton(const char *, u_char *);
const char *	loc_ntoa(const u_char *, char *);
int		dn_skipname(const u_char *, const u_char *);
void		putlong(u_int32_t, u_char *);
void		putshort(u_int16_t, u_char *);
#ifndef __ultrix__
u_int16_t	_getshort(const u_char *);
u_int32_t	_getlong(const u_char *);
#endif
const char *	p_class(int);
const char *	p_time(u_int32_t);
const char *	p_type(int);
const char *	p_rcode(int);
const char *	p_sockun(union res_sockaddr_union, char *, size_t);
const u_char *	p_cdnname(const u_char *, const u_char *, int, FILE *);
const u_char *	p_cdname(const u_char *, const u_char *, FILE *);
const u_char *	p_fqnname(const u_char *, const u_char *, int, char *, int);
const u_char *	p_fqname(const u_char *, const u_char *, FILE *);
const char *	p_option(u_long);
char *		p_secstodate(u_long);
int		dn_count_labels(const char *);
int		dn_comp(const char *, u_char *, int, u_char **, u_char **);
int		dn_expand(const u_char *, const u_char *, const u_char *,
			  char *, int);
u_int		res_randomid(void);
int		res_nameinquery(const char *, int, int, const u_char *,
				const u_char *);
int		res_queriesmatch(const u_char *, const u_char *,
				 const u_char *, const u_char *);
const char *	p_section(int, int);
/* Things involving a resolver context. */
int		res_ninit(res_state);
int		res_nisourserver(const res_state, const struct sockaddr_in *);
void		fp_resstat(const res_state, FILE *);
void		res_pquery(const res_state, const u_char *, int, FILE *);
const char *	res_hostalias(const res_state, const char *, char *, size_t);
int		res_nquery(res_state, const char *, int, int, u_char *, int);
int		res_nsearch(res_state, const char *, int, int, u_char *, int);
int		res_nquerydomain(res_state, const char *, const char *,
				 int, int, u_char *, int);
int		res_nmkquery(res_state, int, const char *, int, int,
			     const u_char *, int, const u_char *,
			     u_char *, int);
int		res_nsend(res_state, const u_char *, int, u_char *, int);
#if 0
int		res_nsendsigned(res_state, const u_char *, int,
				ns_tsig_key *, u_char *, int);
int		res_findzonecut(res_state, const char *, ns_class, int,
				char *, size_t, struct in_addr *, int);
#endif
int		res_findzonecut2(res_state, const char *, ns_class, int,
				 char *, size_t,
				 union res_sockaddr_union *, int);
void		res_nclose(res_state);
int		res_nopt(res_state, int, u_char *, int, int);
int		res_nopt_rdata(res_state, int, u_char *, int, u_char *,
			       u_short, u_short, u_char *);
void		res_send_setqhook(res_send_qhook);
void		res_send_setrhook(res_send_rhook);
int		__res_vinit(res_state, int);
#if 0
void		res_destroyservicelist(void);
const char *	res_servicename(u_int16_t, const char *);
const char *	res_protocolname(int);
void		res_destroyprotolist(void);
void		res_buildprotolist(void);
const char *	res_get_nibblesuffix(res_state);
const char *	res_get_nibblesuffix2(res_state);
#endif
void		res_ndestroy(res_state);
u_int16_t	res_nametoclass(const char *, int *);
u_int16_t	res_nametotype(const char *, int *);
void		res_setservers(res_state, const union res_sockaddr_union *,
			       int);
int		res_getservers(res_state, union res_sockaddr_union *, int);
__END_DECLS

#endif /* !_RESOLV_H_ */
/*! \file */


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

#ifndef __rfc2459_asn1_h__
#define __rfc2459_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

#include <heim_asn1.h>
/*
Version ::= INTEGER {
  rfc3280_version_1(0),
  rfc3280_version_2(1),
  rfc3280_version_3(2)
}
*/

typedef enum Version {
  rfc3280_version_1 = 0,
  rfc3280_version_2 = 1,
  rfc3280_version_3 = 2
} Version;

int    encode_Version(unsigned char *, size_t, const Version *, size_t *);
int    decode_Version(const unsigned char *, size_t, Version *, size_t *);
void   free_Version  (Version *);
size_t length_Version(const Version *);
int    copy_Version  (const Version *, Version *);

/* OBJECT IDENTIFIER id-pkcs-1 ::= { iso(1) member-body(2) us(840) rsadsi(113549) pkcs(1) label-less(1) } */
const heim_oid *oid_id_pkcs_1(void);

/* OBJECT IDENTIFIER id-pkcs1-rsaEncryption ::= { iso(1) member-body(2) us(840) rsadsi(113549) pkcs(1) label-less(1) label-less(1) } */
const heim_oid *oid_id_pkcs1_rsaEncryption(void);

/* OBJECT IDENTIFIER id-pkcs1-md2WithRSAEncryption ::= { iso(1) member-body(2) us(840) rsadsi(113549) pkcs(1) label-less(1) label-less(2) } */
const heim_oid *oid_id_pkcs1_md2WithRSAEncryption(void);

/* OBJECT IDENTIFIER id-pkcs1-md5WithRSAEncryption ::= { iso(1) member-body(2) us(840) rsadsi(113549) pkcs(1) label-less(1) label-less(4) } */
const heim_oid *oid_id_pkcs1_md5WithRSAEncryption(void);

/* OBJECT IDENTIFIER id-pkcs1-sha1WithRSAEncryption ::= { iso(1) member-body(2) us(840) rsadsi(113549) pkcs(1) label-less(1) label-less(5) } */
const heim_oid *oid_id_pkcs1_sha1WithRSAEncryption(void);

/* OBJECT IDENTIFIER id-pkcs1-sha256WithRSAEncryption ::= { iso(1) member-body(2) us(840) rsadsi(113549) pkcs(1) label-less(1) label-less(11) } */
const heim_oid *oid_id_pkcs1_sha256WithRSAEncryption(void);

/* OBJECT IDENTIFIER id-pkcs1-sha384WithRSAEncryption ::= { iso(1) member-body(2) us(840) rsadsi(113549) pkcs(1) label-less(1) label-less(12) } */
const heim_oid *oid_id_pkcs1_sha384WithRSAEncryption(void);

/* OBJECT IDENTIFIER id-pkcs1-sha512WithRSAEncryption ::= { iso(1) member-body(2) us(840) rsadsi(113549) pkcs(1) label-less(1) label-less(13) } */
const heim_oid *oid_id_pkcs1_sha512WithRSAEncryption(void);

/* OBJECT IDENTIFIER id-heim-rsa-pkcs1-x509 ::= { label-less(1) label-less(2) label-less(752) label-less(43) label-less(16) label-less(1) } */
const heim_oid *oid_id_heim_rsa_pkcs1_x509(void);

/* OBJECT IDENTIFIER id-pkcs-2 ::= { iso(1) member-body(2) us(840) rsadsi(113549) pkcs(1) label-less(2) } */
const heim_oid *oid_id_pkcs_2(void);

/* OBJECT IDENTIFIER id-pkcs2-md2 ::= { iso(1) member-body(2) us(840) rsadsi(113549) pkcs(1) label-less(2) label-less(2) } */
const heim_oid *oid_id_pkcs2_md2(void);

/* OBJECT IDENTIFIER id-pkcs2-md4 ::= { iso(1) member-body(2) us(840) rsadsi(113549) pkcs(1) label-less(2) label-less(4) } */
const heim_oid *oid_id_pkcs2_md4(void);

/* OBJECT IDENTIFIER id-pkcs2-md5 ::= { iso(1) member-body(2) us(840) rsadsi(113549) pkcs(1) label-less(2) label-less(5) } */
const heim_oid *oid_id_pkcs2_md5(void);

/* OBJECT IDENTIFIER id-rsa-digestAlgorithm ::= { iso(1) member-body(2) us(840) rsadsi(113549) label-less(2) } */
const heim_oid *oid_id_rsa_digestAlgorithm(void);

/* OBJECT IDENTIFIER id-rsa-digest-md2 ::= { iso(1) member-body(2) us(840) rsadsi(113549) label-less(2) label-less(2) } */
const heim_oid *oid_id_rsa_digest_md2(void);

/* OBJECT IDENTIFIER id-rsa-digest-md4 ::= { iso(1) member-body(2) us(840) rsadsi(113549) label-less(2) label-less(4) } */
const heim_oid *oid_id_rsa_digest_md4(void);

/* OBJECT IDENTIFIER id-rsa-digest-md5 ::= { iso(1) member-body(2) us(840) rsadsi(113549) label-less(2) label-less(5) } */
const heim_oid *oid_id_rsa_digest_md5(void);

/* OBJECT IDENTIFIER id-pkcs-3 ::= { iso(1) member-body(2) us(840) rsadsi(113549) pkcs(1) label-less(3) } */
const heim_oid *oid_id_pkcs_3(void);

/* OBJECT IDENTIFIER id-pkcs3-rc2-cbc ::= { iso(1) member-body(2) us(840) rsadsi(113549) pkcs(1) label-less(3) label-less(2) } */
const heim_oid *oid_id_pkcs3_rc2_cbc(void);

/* OBJECT IDENTIFIER id-pkcs3-rc4 ::= { iso(1) member-body(2) us(840) rsadsi(113549) pkcs(1) label-less(3) label-less(4) } */
const heim_oid *oid_id_pkcs3_rc4(void);

/* OBJECT IDENTIFIER id-pkcs3-des-ede3-cbc ::= { iso(1) member-body(2) us(840) rsadsi(113549) pkcs(1) label-less(3) label-less(7) } */
const heim_oid *oid_id_pkcs3_des_ede3_cbc(void);

/* OBJECT IDENTIFIER id-rsadsi-encalg ::= { iso(1) member-body(2) us(840) rsadsi(113549) label-less(3) } */
const heim_oid *oid_id_rsadsi_encalg(void);

/* OBJECT IDENTIFIER id-rsadsi-rc2-cbc ::= { iso(1) member-body(2) us(840) rsadsi(113549) label-less(3) label-less(2) } */
const heim_oid *oid_id_rsadsi_rc2_cbc(void);

/* OBJECT IDENTIFIER id-rsadsi-des-ede3-cbc ::= { iso(1) member-body(2) us(840) rsadsi(113549) label-less(3) label-less(7) } */
const heim_oid *oid_id_rsadsi_des_ede3_cbc(void);

/* OBJECT IDENTIFIER id-secsig-sha-1 ::= { iso(1) identified-organization(3) oiw(14) secsig(3) algorithm(2) label-less(26) } */
const heim_oid *oid_id_secsig_sha_1(void);

/* OBJECT IDENTIFIER id-nistAlgorithm ::= { joint-iso-itu-t(2) country(16) us(840) organization(1) gov(101) csor(3) label-less(4) } */
const heim_oid *oid_id_nistAlgorithm(void);

/* OBJECT IDENTIFIER id-nist-aes-algs ::= { joint-iso-itu-t(2) country(16) us(840) organization(1) gov(101) csor(3) label-less(4) label-less(1) } */
const heim_oid *oid_id_nist_aes_algs(void);

/* OBJECT IDENTIFIER id-aes-128-cbc ::= { joint-iso-itu-t(2) country(16) us(840) organization(1) gov(101) csor(3) label-less(4) label-less(1) label-less(2) } */
const heim_oid *oid_id_aes_128_cbc(void);

/* OBJECT IDENTIFIER id-aes-192-cbc ::= { joint-iso-itu-t(2) country(16) us(840) organization(1) gov(101) csor(3) label-less(4) label-less(1) label-less(22) } */
const heim_oid *oid_id_aes_192_cbc(void);

/* OBJECT IDENTIFIER id-aes-256-cbc ::= { joint-iso-itu-t(2) country(16) us(840) organization(1) gov(101) csor(3) label-less(4) label-less(1) label-less(42) } */
const heim_oid *oid_id_aes_256_cbc(void);

/* OBJECT IDENTIFIER id-nist-sha-algs ::= { joint-iso-itu-t(2) country(16) us(840) organization(1) gov(101) csor(3) label-less(4) label-less(2) } */
const heim_oid *oid_id_nist_sha_algs(void);

/* OBJECT IDENTIFIER id-sha256 ::= { joint-iso-itu-t(2) country(16) us(840) organization(1) gov(101) csor(3) label-less(4) label-less(2) label-less(1) } */
const heim_oid *oid_id_sha256(void);

/* OBJECT IDENTIFIER id-sha224 ::= { joint-iso-itu-t(2) country(16) us(840) organization(1) gov(101) csor(3) label-less(4) label-less(2) label-less(4) } */
const heim_oid *oid_id_sha224(void);

/* OBJECT IDENTIFIER id-sha384 ::= { joint-iso-itu-t(2) country(16) us(840) organization(1) gov(101) csor(3) label-less(4) label-less(2) label-less(2) } */
const heim_oid *oid_id_sha384(void);

/* OBJECT IDENTIFIER id-sha512 ::= { joint-iso-itu-t(2) country(16) us(840) organization(1) gov(101) csor(3) label-less(4) label-less(2) label-less(3) } */
const heim_oid *oid_id_sha512(void);

/* OBJECT IDENTIFIER id-dhpublicnumber ::= { iso(1) member-body(2) us(840) ansi-x942(10046) number-type(2) label-less(1) } */
const heim_oid *oid_id_dhpublicnumber(void);

/* OBJECT IDENTIFIER id-x9-57 ::= { iso(1) member-body(2) us(840) ansi-x942(10046) label-less(4) } */
const heim_oid *oid_id_x9_57(void);

/* OBJECT IDENTIFIER id-dsa ::= { iso(1) member-body(2) us(840) ansi-x942(10046) label-less(4) label-less(1) } */
const heim_oid *oid_id_dsa(void);

/* OBJECT IDENTIFIER id-dsa-with-sha1 ::= { iso(1) member-body(2) us(840) ansi-x942(10046) label-less(4) label-less(3) } */
const heim_oid *oid_id_dsa_with_sha1(void);

/* OBJECT IDENTIFIER id-x520-at ::= { joint-iso-ccitt(2) ds(5) label-less(4) } */
const heim_oid *oid_id_x520_at(void);

/* OBJECT IDENTIFIER id-at-commonName ::= { joint-iso-ccitt(2) ds(5) label-less(4) label-less(3) } */
const heim_oid *oid_id_at_commonName(void);

/* OBJECT IDENTIFIER id-at-surname ::= { joint-iso-ccitt(2) ds(5) label-less(4) label-less(4) } */
const heim_oid *oid_id_at_surname(void);

/* OBJECT IDENTIFIER id-at-serialNumber ::= { joint-iso-ccitt(2) ds(5) label-less(4) label-less(5) } */
const heim_oid *oid_id_at_serialNumber(void);

/* OBJECT IDENTIFIER id-at-countryName ::= { joint-iso-ccitt(2) ds(5) label-less(4) label-less(6) } */
const heim_oid *oid_id_at_countryName(void);

/* OBJECT IDENTIFIER id-at-localityName ::= { joint-iso-ccitt(2) ds(5) label-less(4) label-less(7) } */
const heim_oid *oid_id_at_localityName(void);

/* OBJECT IDENTIFIER id-at-stateOrProvinceName ::= { joint-iso-ccitt(2) ds(5) label-less(4) label-less(8) } */
const heim_oid *oid_id_at_stateOrProvinceName(void);

/* OBJECT IDENTIFIER id-at-streetAddress ::= { joint-iso-ccitt(2) ds(5) label-less(4) label-less(9) } */
const heim_oid *oid_id_at_streetAddress(void);

/* OBJECT IDENTIFIER id-at-organizationName ::= { joint-iso-ccitt(2) ds(5) label-less(4) label-less(10) } */
const heim_oid *oid_id_at_organizationName(void);

/* OBJECT IDENTIFIER id-at-organizationalUnitName ::= { joint-iso-ccitt(2) ds(5) label-less(4) label-less(11) } */
const heim_oid *oid_id_at_organizationalUnitName(void);

/* OBJECT IDENTIFIER id-at-name ::= { joint-iso-ccitt(2) ds(5) label-less(4) label-less(41) } */
const heim_oid *oid_id_at_name(void);

/* OBJECT IDENTIFIER id-at-givenName ::= { joint-iso-ccitt(2) ds(5) label-less(4) label-less(42) } */
const heim_oid *oid_id_at_givenName(void);

/* OBJECT IDENTIFIER id-at-initials ::= { joint-iso-ccitt(2) ds(5) label-less(4) label-less(43) } */
const heim_oid *oid_id_at_initials(void);

/* OBJECT IDENTIFIER id-at-generationQualifier ::= { joint-iso-ccitt(2) ds(5) label-less(4) label-less(44) } */
const heim_oid *oid_id_at_generationQualifier(void);

/* OBJECT IDENTIFIER id-at-pseudonym ::= { joint-iso-ccitt(2) ds(5) label-less(4) label-less(65) } */
const heim_oid *oid_id_at_pseudonym(void);

/* OBJECT IDENTIFIER id-Userid ::= { label-less(0) label-less(9) label-less(2342) label-less(19200300) label-less(100) label-less(1) label-less(1) } */
const heim_oid *oid_id_Userid(void);

/* OBJECT IDENTIFIER id-domainComponent ::= { label-less(0) label-less(9) label-less(2342) label-less(19200300) label-less(100) label-less(1) label-less(25) } */
const heim_oid *oid_id_domainComponent(void);

/* OBJECT IDENTIFIER id-x509-ce ::= { joint-iso-ccitt(2) ds(5) label-less(29) } */
const heim_oid *oid_id_x509_ce(void);

/*
AlgorithmIdentifier ::= SEQUENCE {
  algorithm         OBJECT IDENTIFIER,
  parameters      heim_any OPTIONAL,
}
*/

typedef struct AlgorithmIdentifier {
  heim_oid algorithm;
  heim_any *parameters;
} AlgorithmIdentifier;

int    encode_AlgorithmIdentifier(unsigned char *, size_t, const AlgorithmIdentifier *, size_t *);
int    decode_AlgorithmIdentifier(const unsigned char *, size_t, AlgorithmIdentifier *, size_t *);
void   free_AlgorithmIdentifier  (AlgorithmIdentifier *);
size_t length_AlgorithmIdentifier(const AlgorithmIdentifier *);
int    copy_AlgorithmIdentifier  (const AlgorithmIdentifier *, AlgorithmIdentifier *);

/*
AttributeType ::= OBJECT IDENTIFIER
*/

typedef heim_oid AttributeType;

int    encode_AttributeType(unsigned char *, size_t, const AttributeType *, size_t *);
int    decode_AttributeType(const unsigned char *, size_t, AttributeType *, size_t *);
void   free_AttributeType  (AttributeType *);
size_t length_AttributeType(const AttributeType *);
int    copy_AttributeType  (const AttributeType *, AttributeType *);

/*
AttributeValue ::= heim_any
*/

typedef heim_any AttributeValue;

int    encode_AttributeValue(unsigned char *, size_t, const AttributeValue *, size_t *);
int    decode_AttributeValue(const unsigned char *, size_t, AttributeValue *, size_t *);
void   free_AttributeValue  (AttributeValue *);
size_t length_AttributeValue(const AttributeValue *);
int    copy_AttributeValue  (const AttributeValue *, AttributeValue *);

/*
TeletexStringx ::= IMPLICIT OCTET STRING
*/

typedef heim_octet_string TeletexStringx;

int    encode_TeletexStringx(unsigned char *, size_t, const TeletexStringx *, size_t *);
int    decode_TeletexStringx(const unsigned char *, size_t, TeletexStringx *, size_t *);
void   free_TeletexStringx  (TeletexStringx *);
size_t length_TeletexStringx(const TeletexStringx *);
int    copy_TeletexStringx  (const TeletexStringx *, TeletexStringx *);

/*
DirectoryString ::= CHOICE {
  ia5String           IA5String,
  teletexString     TeletexStringx,
  printableString     PrintableString,
  universalString     UniversalString,
  utf8String          UTF8String,
  bmpString           BMPString,
}
*/

typedef struct DirectoryString {
  enum {
    choice_DirectoryString_ia5String = 1,
    choice_DirectoryString_teletexString,
    choice_DirectoryString_printableString,
    choice_DirectoryString_universalString,
    choice_DirectoryString_utf8String,
    choice_DirectoryString_bmpString
  } element;
  union {
    heim_ia5_string ia5String;
    TeletexStringx teletexString;
    heim_printable_string printableString;
    heim_universal_string universalString;
    heim_utf8_string utf8String;
    heim_bmp_string bmpString;
  } u;
} DirectoryString;

int    encode_DirectoryString(unsigned char *, size_t, const DirectoryString *, size_t *);
int    decode_DirectoryString(const unsigned char *, size_t, DirectoryString *, size_t *);
void   free_DirectoryString  (DirectoryString *);
size_t length_DirectoryString(const DirectoryString *);
int    copy_DirectoryString  (const DirectoryString *, DirectoryString *);

/*
Attribute ::= SEQUENCE {
  type            AttributeType,
  value           SET OF heim_any,
}
*/

typedef struct Attribute {
  AttributeType type;
  struct  {
    unsigned int len;
    heim_any *val;
  } value;
} Attribute;

int    encode_Attribute(unsigned char *, size_t, const Attribute *, size_t *);
int    decode_Attribute(const unsigned char *, size_t, Attribute *, size_t *);
void   free_Attribute  (Attribute *);
size_t length_Attribute(const Attribute *);
int    copy_Attribute  (const Attribute *, Attribute *);

/*
AttributeTypeAndValue ::= SEQUENCE {
  type            AttributeType,
  value           DirectoryString,
}
*/

typedef struct AttributeTypeAndValue {
  AttributeType type;
  DirectoryString value;
} AttributeTypeAndValue;

int    encode_AttributeTypeAndValue(unsigned char *, size_t, const AttributeTypeAndValue *, size_t *);
int    decode_AttributeTypeAndValue(const unsigned char *, size_t, AttributeTypeAndValue *, size_t *);
void   free_AttributeTypeAndValue  (AttributeTypeAndValue *);
size_t length_AttributeTypeAndValue(const AttributeTypeAndValue *);
int    copy_AttributeTypeAndValue  (const AttributeTypeAndValue *, AttributeTypeAndValue *);

/*
RelativeDistinguishedName ::= SET OF AttributeTypeAndValue
*/

typedef struct RelativeDistinguishedName {
  unsigned int len;
  AttributeTypeAndValue *val;
} RelativeDistinguishedName;

int    encode_RelativeDistinguishedName(unsigned char *, size_t, const RelativeDistinguishedName *, size_t *);
int    decode_RelativeDistinguishedName(const unsigned char *, size_t, RelativeDistinguishedName *, size_t *);
void   free_RelativeDistinguishedName  (RelativeDistinguishedName *);
size_t length_RelativeDistinguishedName(const RelativeDistinguishedName *);
int    copy_RelativeDistinguishedName  (const RelativeDistinguishedName *, RelativeDistinguishedName *);

/*
RDNSequence ::= SEQUENCE OF RelativeDistinguishedName
*/

typedef struct RDNSequence {
  unsigned int len;
  RelativeDistinguishedName *val;
} RDNSequence;

int    encode_RDNSequence(unsigned char *, size_t, const RDNSequence *, size_t *);
int    decode_RDNSequence(const unsigned char *, size_t, RDNSequence *, size_t *);
void   free_RDNSequence  (RDNSequence *);
size_t length_RDNSequence(const RDNSequence *);
int    copy_RDNSequence  (const RDNSequence *, RDNSequence *);

/*
Name ::= CHOICE {
  rdnSequence     RDNSequence,
}
*/

typedef struct Name {
  heim_octet_string _save;
  enum {
    choice_Name_rdnSequence = 1
  } element;
  union {
    RDNSequence rdnSequence;
  } u;
} Name;

int    encode_Name(unsigned char *, size_t, const Name *, size_t *);
int    decode_Name(const unsigned char *, size_t, Name *, size_t *);
void   free_Name  (Name *);
size_t length_Name(const Name *);
int    copy_Name  (const Name *, Name *);

/*
CertificateSerialNumber ::= INTEGER
*/

typedef heim_integer CertificateSerialNumber;

int    encode_CertificateSerialNumber(unsigned char *, size_t, const CertificateSerialNumber *, size_t *);
int    decode_CertificateSerialNumber(const unsigned char *, size_t, CertificateSerialNumber *, size_t *);
void   free_CertificateSerialNumber  (CertificateSerialNumber *);
size_t length_CertificateSerialNumber(const CertificateSerialNumber *);
int    copy_CertificateSerialNumber  (const CertificateSerialNumber *, CertificateSerialNumber *);

/*
Time ::= CHOICE {
  utcTime         UTCTime,
  generalTime     GeneralizedTime,
}
*/

typedef struct Time {
  enum {
    choice_Time_utcTime = 1,
    choice_Time_generalTime
  } element;
  union {
    time_t utcTime;
    time_t generalTime;
  } u;
} Time;

int    encode_Time(unsigned char *, size_t, const Time *, size_t *);
int    decode_Time(const unsigned char *, size_t, Time *, size_t *);
void   free_Time  (Time *);
size_t length_Time(const Time *);
int    copy_Time  (const Time *, Time *);

/*
Validity ::= SEQUENCE {
  notBefore       Time,
  notAfter        Time,
}
*/

typedef struct Validity {
  Time notBefore;
  Time notAfter;
} Validity;

int    encode_Validity(unsigned char *, size_t, const Validity *, size_t *);
int    decode_Validity(const unsigned char *, size_t, Validity *, size_t *);
void   free_Validity  (Validity *);
size_t length_Validity(const Validity *);
int    copy_Validity  (const Validity *, Validity *);

/*
UniqueIdentifier ::= BIT STRING {
}
*/

typedef heim_bit_string UniqueIdentifier;

int    encode_UniqueIdentifier(unsigned char *, size_t, const UniqueIdentifier *, size_t *);
int    decode_UniqueIdentifier(const unsigned char *, size_t, UniqueIdentifier *, size_t *);
void   free_UniqueIdentifier  (UniqueIdentifier *);
size_t length_UniqueIdentifier(const UniqueIdentifier *);
int    copy_UniqueIdentifier  (const UniqueIdentifier *, UniqueIdentifier *);

/*
SubjectPublicKeyInfo ::= SEQUENCE {
  algorithm          AlgorithmIdentifier,
  subjectPublicKey     BIT STRING {
  },
}
*/

typedef struct SubjectPublicKeyInfo {
  AlgorithmIdentifier algorithm;
  heim_bit_string subjectPublicKey;
} SubjectPublicKeyInfo;

int    encode_SubjectPublicKeyInfo(unsigned char *, size_t, const SubjectPublicKeyInfo *, size_t *);
int    decode_SubjectPublicKeyInfo(const unsigned char *, size_t, SubjectPublicKeyInfo *, size_t *);
void   free_SubjectPublicKeyInfo  (SubjectPublicKeyInfo *);
size_t length_SubjectPublicKeyInfo(const SubjectPublicKeyInfo *);
int    copy_SubjectPublicKeyInfo  (const SubjectPublicKeyInfo *, SubjectPublicKeyInfo *);

/*
Extension ::= SEQUENCE {
  extnID            OBJECT IDENTIFIER,
  critical        BOOLEAN OPTIONAL,
  extnValue       OCTET STRING,
}
*/

typedef struct Extension {
  heim_oid extnID;
  int *critical;
  heim_octet_string extnValue;
} Extension;

int    encode_Extension(unsigned char *, size_t, const Extension *, size_t *);
int    decode_Extension(const unsigned char *, size_t, Extension *, size_t *);
void   free_Extension  (Extension *);
size_t length_Extension(const Extension *);
int    copy_Extension  (const Extension *, Extension *);

/*
Extensions ::= SEQUENCE OF Extension
*/

typedef struct Extensions {
  unsigned int len;
  Extension *val;
} Extensions;

int    encode_Extensions(unsigned char *, size_t, const Extensions *, size_t *);
int    decode_Extensions(const unsigned char *, size_t, Extensions *, size_t *);
void   free_Extensions  (Extensions *);
size_t length_Extensions(const Extensions *);
int    copy_Extensions  (const Extensions *, Extensions *);
int   add_Extensions  (Extensions *, const Extension *);
int   remove_Extensions  (Extensions *, unsigned int);

/*
TBSCertificate ::= SEQUENCE {
  version                [0] Version OPTIONAL,
  serialNumber           CertificateSerialNumber,
  signature              AlgorithmIdentifier,
  issuer                 Name,
  validity               Validity,
  subject                Name,
  subjectPublicKeyInfo   SubjectPublicKeyInfo,
  issuerUniqueID         [1] IMPLICIT   BIT STRING {
  } OPTIONAL,
  subjectUniqueID        [2] IMPLICIT   BIT STRING {
  } OPTIONAL,
  extensions             [3] Extensions OPTIONAL,
}
*/

typedef struct TBSCertificate {
  heim_octet_string _save;
  Version *version;
  CertificateSerialNumber serialNumber;
  AlgorithmIdentifier signature;
  Name issuer;
  Validity validity;
  Name subject;
  SubjectPublicKeyInfo subjectPublicKeyInfo;
  heim_bit_string *issuerUniqueID;
  heim_bit_string *subjectUniqueID;
  Extensions *extensions;
} TBSCertificate;

int    encode_TBSCertificate(unsigned char *, size_t, const TBSCertificate *, size_t *);
int    decode_TBSCertificate(const unsigned char *, size_t, TBSCertificate *, size_t *);
void   free_TBSCertificate  (TBSCertificate *);
size_t length_TBSCertificate(const TBSCertificate *);
int    copy_TBSCertificate  (const TBSCertificate *, TBSCertificate *);

/*
Certificate ::= SEQUENCE {
  tbsCertificate       TBSCertificate,
  signatureAlgorithm   AlgorithmIdentifier,
  signatureValue         BIT STRING {
  },
}
*/

typedef struct Certificate {
  TBSCertificate tbsCertificate;
  AlgorithmIdentifier signatureAlgorithm;
  heim_bit_string signatureValue;
} Certificate;

int    encode_Certificate(unsigned char *, size_t, const Certificate *, size_t *);
int    decode_Certificate(const unsigned char *, size_t, Certificate *, size_t *);
void   free_Certificate  (Certificate *);
size_t length_Certificate(const Certificate *);
int    copy_Certificate  (const Certificate *, Certificate *);

/*
Certificates ::= SEQUENCE OF Certificate
*/

typedef struct Certificates {
  unsigned int len;
  Certificate *val;
} Certificates;

int    encode_Certificates(unsigned char *, size_t, const Certificates *, size_t *);
int    decode_Certificates(const unsigned char *, size_t, Certificates *, size_t *);
void   free_Certificates  (Certificates *);
size_t length_Certificates(const Certificates *);
int    copy_Certificates  (const Certificates *, Certificates *);

/*
ValidationParms ::= SEQUENCE {
  seed              BIT STRING {
  },
  pgenCounter     INTEGER,
}
*/

typedef struct ValidationParms {
  heim_bit_string seed;
  heim_integer pgenCounter;
} ValidationParms;

int    encode_ValidationParms(unsigned char *, size_t, const ValidationParms *, size_t *);
int    decode_ValidationParms(const unsigned char *, size_t, ValidationParms *, size_t *);
void   free_ValidationParms  (ValidationParms *);
size_t length_ValidationParms(const ValidationParms *);
int    copy_ValidationParms  (const ValidationParms *, ValidationParms *);

/*
DomainParameters ::= SEQUENCE {
  p                 INTEGER,
  g                 INTEGER,
  q                 INTEGER,
  j                 INTEGER OPTIONAL,
  validationParms   ValidationParms OPTIONAL,
}
*/

typedef struct DomainParameters {
  heim_integer p;
  heim_integer g;
  heim_integer q;
  heim_integer *j;
  ValidationParms *validationParms;
} DomainParameters;

int    encode_DomainParameters(unsigned char *, size_t, const DomainParameters *, size_t *);
int    decode_DomainParameters(const unsigned char *, size_t, DomainParameters *, size_t *);
void   free_DomainParameters  (DomainParameters *);
size_t length_DomainParameters(const DomainParameters *);
int    copy_DomainParameters  (const DomainParameters *, DomainParameters *);

/*
DHPublicKey ::= INTEGER
*/

typedef heim_integer DHPublicKey;

int    encode_DHPublicKey(unsigned char *, size_t, const DHPublicKey *, size_t *);
int    decode_DHPublicKey(const unsigned char *, size_t, DHPublicKey *, size_t *);
void   free_DHPublicKey  (DHPublicKey *);
size_t length_DHPublicKey(const DHPublicKey *);
int    copy_DHPublicKey  (const DHPublicKey *, DHPublicKey *);

/*
OtherName ::= SEQUENCE {
  type-id           OBJECT IDENTIFIER,
  value           [0] heim_any,
}
*/

typedef struct OtherName {
  heim_oid type_id;
  heim_any value;
} OtherName;

int    encode_OtherName(unsigned char *, size_t, const OtherName *, size_t *);
int    decode_OtherName(const unsigned char *, size_t, OtherName *, size_t *);
void   free_OtherName  (OtherName *);
size_t length_OtherName(const OtherName *);
int    copy_OtherName  (const OtherName *, OtherName *);

/*
GeneralName ::= CHOICE {
  otherName                   [0] IMPLICIT SEQUENCE {
    type-id             OBJECT IDENTIFIER,
    value           [0] heim_any,
  },
  rfc822Name                  [1] IMPLICIT   IA5String,
  dNSName                     [2] IMPLICIT   IA5String,
  directoryName               [4] IMPLICIT CHOICE {
    rdnSequence     RDNSequence,
  },
  uniformResourceIdentifier   [6] IMPLICIT   IA5String,
  iPAddress                   [7] IMPLICIT OCTET STRING,
  registeredID                [8] IMPLICIT   OBJECT IDENTIFIER,
}
*/

typedef struct GeneralName {
  enum {
    choice_GeneralName_otherName = 1,
    choice_GeneralName_rfc822Name,
    choice_GeneralName_dNSName,
    choice_GeneralName_directoryName,
    choice_GeneralName_uniformResourceIdentifier,
    choice_GeneralName_iPAddress,
    choice_GeneralName_registeredID
  } element;
  union {
    struct  {
      heim_oid type_id;
      heim_any value;
    } otherName;
    heim_ia5_string rfc822Name;
    heim_ia5_string dNSName;
    struct  {
      enum {
        choice_GeneralName_directoryName_rdnSequence = 1
      } element;
      union {
        RDNSequence rdnSequence;
      } u;
    } directoryName;
    heim_ia5_string uniformResourceIdentifier;
    heim_octet_string iPAddress;
    heim_oid registeredID;
  } u;
} GeneralName;

int    encode_GeneralName(unsigned char *, size_t, const GeneralName *, size_t *);
int    decode_GeneralName(const unsigned char *, size_t, GeneralName *, size_t *);
void   free_GeneralName  (GeneralName *);
size_t length_GeneralName(const GeneralName *);
int    copy_GeneralName  (const GeneralName *, GeneralName *);

/*
GeneralNames ::= SEQUENCE OF GeneralName
*/

typedef struct GeneralNames {
  unsigned int len;
  GeneralName *val;
} GeneralNames;

int    encode_GeneralNames(unsigned char *, size_t, const GeneralNames *, size_t *);
int    decode_GeneralNames(const unsigned char *, size_t, GeneralNames *, size_t *);
void   free_GeneralNames  (GeneralNames *);
size_t length_GeneralNames(const GeneralNames *);
int    copy_GeneralNames  (const GeneralNames *, GeneralNames *);
int   add_GeneralNames  (GeneralNames *, const GeneralName *);
int   remove_GeneralNames  (GeneralNames *, unsigned int);

/* OBJECT IDENTIFIER id-x509-ce-keyUsage ::= { joint-iso-ccitt(2) ds(5) label-less(29) label-less(15) } */
const heim_oid *oid_id_x509_ce_keyUsage(void);

/*
KeyUsage ::= BIT STRING {
  digitalSignature(0),
  nonRepudiation(1),
  keyEncipherment(2),
  dataEncipherment(3),
  keyAgreement(4),
  keyCertSign(5),
  cRLSign(6),
  encipherOnly(7),
  decipherOnly(8)
}
*/

typedef struct KeyUsage {
  unsigned int digitalSignature:1;
  unsigned int nonRepudiation:1;
  unsigned int keyEncipherment:1;
  unsigned int dataEncipherment:1;
  unsigned int keyAgreement:1;
  unsigned int keyCertSign:1;
  unsigned int cRLSign:1;
  unsigned int encipherOnly:1;
  unsigned int decipherOnly:1;
} KeyUsage;

int    encode_KeyUsage(unsigned char *, size_t, const KeyUsage *, size_t *);
int    decode_KeyUsage(const unsigned char *, size_t, KeyUsage *, size_t *);
void   free_KeyUsage  (KeyUsage *);
size_t length_KeyUsage(const KeyUsage *);
int    copy_KeyUsage  (const KeyUsage *, KeyUsage *);
unsigned KeyUsage2int(KeyUsage);
KeyUsage int2KeyUsage(unsigned);
#ifdef __PARSE_UNITS_H__
const struct units * asn1_KeyUsage_units(void);
#endif

/* OBJECT IDENTIFIER id-x509-ce-authorityKeyIdentifier ::= { joint-iso-ccitt(2) ds(5) label-less(29) label-less(35) } */
const heim_oid *oid_id_x509_ce_authorityKeyIdentifier(void);

/*
KeyIdentifier ::= OCTET STRING
*/

typedef heim_octet_string KeyIdentifier;

int    encode_KeyIdentifier(unsigned char *, size_t, const KeyIdentifier *, size_t *);
int    decode_KeyIdentifier(const unsigned char *, size_t, KeyIdentifier *, size_t *);
void   free_KeyIdentifier  (KeyIdentifier *);
size_t length_KeyIdentifier(const KeyIdentifier *);
int    copy_KeyIdentifier  (const KeyIdentifier *, KeyIdentifier *);

/*
AuthorityKeyIdentifier ::= SEQUENCE {
  keyIdentifier               [0] IMPLICIT OCTET STRING OPTIONAL,
  authorityCertIssuer         [1] IMPLICIT SEQUENCE OF GeneralName OPTIONAL,
  authorityCertSerialNumber   [2] IMPLICIT INTEGER OPTIONAL,
}
*/

typedef struct AuthorityKeyIdentifier {
  heim_octet_string *keyIdentifier;
  struct  {
    unsigned int len;
    GeneralName *val;
  } *authorityCertIssuer;
  heim_integer *authorityCertSerialNumber;
} AuthorityKeyIdentifier;

int    encode_AuthorityKeyIdentifier(unsigned char *, size_t, const AuthorityKeyIdentifier *, size_t *);
int    decode_AuthorityKeyIdentifier(const unsigned char *, size_t, AuthorityKeyIdentifier *, size_t *);
void   free_AuthorityKeyIdentifier  (AuthorityKeyIdentifier *);
size_t length_AuthorityKeyIdentifier(const AuthorityKeyIdentifier *);
int    copy_AuthorityKeyIdentifier  (const AuthorityKeyIdentifier *, AuthorityKeyIdentifier *);

/* OBJECT IDENTIFIER id-x509-ce-subjectKeyIdentifier ::= { joint-iso-ccitt(2) ds(5) label-less(29) label-less(14) } */
const heim_oid *oid_id_x509_ce_subjectKeyIdentifier(void);

/*
SubjectKeyIdentifier ::= KeyIdentifier
*/

typedef KeyIdentifier SubjectKeyIdentifier;

int    encode_SubjectKeyIdentifier(unsigned char *, size_t, const SubjectKeyIdentifier *, size_t *);
int    decode_SubjectKeyIdentifier(const unsigned char *, size_t, SubjectKeyIdentifier *, size_t *);
void   free_SubjectKeyIdentifier  (SubjectKeyIdentifier *);
size_t length_SubjectKeyIdentifier(const SubjectKeyIdentifier *);
int    copy_SubjectKeyIdentifier  (const SubjectKeyIdentifier *, SubjectKeyIdentifier *);

/* OBJECT IDENTIFIER id-x509-ce-basicConstraints ::= { joint-iso-ccitt(2) ds(5) label-less(29) label-less(19) } */
const heim_oid *oid_id_x509_ce_basicConstraints(void);

/*
BasicConstraints ::= SEQUENCE {
  cA                  BOOLEAN OPTIONAL,
  pathLenConstraint   INTEGER (0..-1) OPTIONAL,
}
*/

typedef struct BasicConstraints {
  int *cA;
  unsigned int *pathLenConstraint;
} BasicConstraints;

int    encode_BasicConstraints(unsigned char *, size_t, const BasicConstraints *, size_t *);
int    decode_BasicConstraints(const unsigned char *, size_t, BasicConstraints *, size_t *);
void   free_BasicConstraints  (BasicConstraints *);
size_t length_BasicConstraints(const BasicConstraints *);
int    copy_BasicConstraints  (const BasicConstraints *, BasicConstraints *);

/* OBJECT IDENTIFIER id-x509-ce-nameConstraints ::= { joint-iso-ccitt(2) ds(5) label-less(29) label-less(30) } */
const heim_oid *oid_id_x509_ce_nameConstraints(void);

/*
BaseDistance ::= INTEGER
*/

typedef heim_integer BaseDistance;

int    encode_BaseDistance(unsigned char *, size_t, const BaseDistance *, size_t *);
int    decode_BaseDistance(const unsigned char *, size_t, BaseDistance *, size_t *);
void   free_BaseDistance  (BaseDistance *);
size_t length_BaseDistance(const BaseDistance *);
int    copy_BaseDistance  (const BaseDistance *, BaseDistance *);

/*
GeneralSubtree ::= SEQUENCE {
  base            GeneralName,
  minimum         [0] IMPLICIT INTEGER OPTIONAL,
  maximum         [1] IMPLICIT INTEGER OPTIONAL,
}
*/

typedef struct GeneralSubtree {
  GeneralName base;
  heim_integer *minimum;
  heim_integer *maximum;
} GeneralSubtree;

int    encode_GeneralSubtree(unsigned char *, size_t, const GeneralSubtree *, size_t *);
int    decode_GeneralSubtree(const unsigned char *, size_t, GeneralSubtree *, size_t *);
void   free_GeneralSubtree  (GeneralSubtree *);
size_t length_GeneralSubtree(const GeneralSubtree *);
int    copy_GeneralSubtree  (const GeneralSubtree *, GeneralSubtree *);

/*
GeneralSubtrees ::= SEQUENCE OF GeneralSubtree
*/

typedef struct GeneralSubtrees {
  unsigned int len;
  GeneralSubtree *val;
} GeneralSubtrees;

int    encode_GeneralSubtrees(unsigned char *, size_t, const GeneralSubtrees *, size_t *);
int    decode_GeneralSubtrees(const unsigned char *, size_t, GeneralSubtrees *, size_t *);
void   free_GeneralSubtrees  (GeneralSubtrees *);
size_t length_GeneralSubtrees(const GeneralSubtrees *);
int    copy_GeneralSubtrees  (const GeneralSubtrees *, GeneralSubtrees *);

/*
NameConstraints ::= SEQUENCE {
  permittedSubtrees   [0] IMPLICIT SEQUENCE OF GeneralSubtree OPTIONAL,
  excludedSubtrees    [1] IMPLICIT SEQUENCE OF GeneralSubtree OPTIONAL,
}
*/

typedef struct NameConstraints {
  struct  {
    unsigned int len;
    GeneralSubtree *val;
  } *permittedSubtrees;
  struct  {
    unsigned int len;
    GeneralSubtree *val;
  } *excludedSubtrees;
} NameConstraints;

int    encode_NameConstraints(unsigned char *, size_t, const NameConstraints *, size_t *);
int    decode_NameConstraints(const unsigned char *, size_t, NameConstraints *, size_t *);
void   free_NameConstraints  (NameConstraints *);
size_t length_NameConstraints(const NameConstraints *);
int    copy_NameConstraints  (const NameConstraints *, NameConstraints *);

/* OBJECT IDENTIFIER id-x509-ce-privateKeyUsagePeriod ::= { joint-iso-ccitt(2) ds(5) label-less(29) label-less(16) } */
const heim_oid *oid_id_x509_ce_privateKeyUsagePeriod(void);

/* OBJECT IDENTIFIER id-x509-ce-certificatePolicies ::= { joint-iso-ccitt(2) ds(5) label-less(29) label-less(32) } */
const heim_oid *oid_id_x509_ce_certificatePolicies(void);

/* OBJECT IDENTIFIER id-x509-ce-policyMappings ::= { joint-iso-ccitt(2) ds(5) label-less(29) label-less(33) } */
const heim_oid *oid_id_x509_ce_policyMappings(void);

/* OBJECT IDENTIFIER id-x509-ce-subjectAltName ::= { joint-iso-ccitt(2) ds(5) label-less(29) label-less(17) } */
const heim_oid *oid_id_x509_ce_subjectAltName(void);

/* OBJECT IDENTIFIER id-x509-ce-issuerAltName ::= { joint-iso-ccitt(2) ds(5) label-less(29) label-less(18) } */
const heim_oid *oid_id_x509_ce_issuerAltName(void);

/* OBJECT IDENTIFIER id-x509-ce-subjectDirectoryAttributes ::= { joint-iso-ccitt(2) ds(5) label-less(29) label-less(9) } */
const heim_oid *oid_id_x509_ce_subjectDirectoryAttributes(void);

/* OBJECT IDENTIFIER id-x509-ce-policyConstraints ::= { joint-iso-ccitt(2) ds(5) label-less(29) label-less(36) } */
const heim_oid *oid_id_x509_ce_policyConstraints(void);

/* OBJECT IDENTIFIER id-x509-ce-extKeyUsage ::= { joint-iso-ccitt(2) ds(5) label-less(29) label-less(37) } */
const heim_oid *oid_id_x509_ce_extKeyUsage(void);

/*
ExtKeyUsage ::= SEQUENCE OF OBJECT IDENTIFIER
*/

typedef struct ExtKeyUsage {
  unsigned int len;
  heim_oid *val;
} ExtKeyUsage;

int    encode_ExtKeyUsage(unsigned char *, size_t, const ExtKeyUsage *, size_t *);
int    decode_ExtKeyUsage(const unsigned char *, size_t, ExtKeyUsage *, size_t *);
void   free_ExtKeyUsage  (ExtKeyUsage *);
size_t length_ExtKeyUsage(const ExtKeyUsage *);
int    copy_ExtKeyUsage  (const ExtKeyUsage *, ExtKeyUsage *);

/* OBJECT IDENTIFIER id-x509-ce-cRLDistributionPoints ::= { joint-iso-ccitt(2) ds(5) label-less(29) label-less(31) } */
const heim_oid *oid_id_x509_ce_cRLDistributionPoints(void);

/* OBJECT IDENTIFIER id-x509-ce-deltaCRLIndicator ::= { joint-iso-ccitt(2) ds(5) label-less(29) label-less(27) } */
const heim_oid *oid_id_x509_ce_deltaCRLIndicator(void);

/* OBJECT IDENTIFIER id-x509-ce-issuingDistributionPoint ::= { joint-iso-ccitt(2) ds(5) label-less(29) label-less(28) } */
const heim_oid *oid_id_x509_ce_issuingDistributionPoint(void);

/* OBJECT IDENTIFIER id-x509-ce-holdInstructionCode ::= { joint-iso-ccitt(2) ds(5) label-less(29) label-less(23) } */
const heim_oid *oid_id_x509_ce_holdInstructionCode(void);

/* OBJECT IDENTIFIER id-x509-ce-invalidityDate ::= { joint-iso-ccitt(2) ds(5) label-less(29) label-less(24) } */
const heim_oid *oid_id_x509_ce_invalidityDate(void);

/* OBJECT IDENTIFIER id-x509-ce-certificateIssuer ::= { joint-iso-ccitt(2) ds(5) label-less(29) label-less(29) } */
const heim_oid *oid_id_x509_ce_certificateIssuer(void);

/* OBJECT IDENTIFIER id-x509-ce-inhibitAnyPolicy ::= { joint-iso-ccitt(2) ds(5) label-less(29) label-less(54) } */
const heim_oid *oid_id_x509_ce_inhibitAnyPolicy(void);

/*
DistributionPointReasonFlags ::= BIT STRING {
  unused(0),
  keyCompromise(1),
  cACompromise(2),
  affiliationChanged(3),
  superseded(4),
  cessationOfOperation(5),
  certificateHold(6),
  privilegeWithdrawn(7),
  aACompromise(8)
}
*/

typedef struct DistributionPointReasonFlags {
  unsigned int unused:1;
  unsigned int keyCompromise:1;
  unsigned int cACompromise:1;
  unsigned int affiliationChanged:1;
  unsigned int superseded:1;
  unsigned int cessationOfOperation:1;
  unsigned int certificateHold:1;
  unsigned int privilegeWithdrawn:1;
  unsigned int aACompromise:1;
} DistributionPointReasonFlags;

int    encode_DistributionPointReasonFlags(unsigned char *, size_t, const DistributionPointReasonFlags *, size_t *);
int    decode_DistributionPointReasonFlags(const unsigned char *, size_t, DistributionPointReasonFlags *, size_t *);
void   free_DistributionPointReasonFlags  (DistributionPointReasonFlags *);
size_t length_DistributionPointReasonFlags(const DistributionPointReasonFlags *);
int    copy_DistributionPointReasonFlags  (const DistributionPointReasonFlags *, DistributionPointReasonFlags *);
unsigned DistributionPointReasonFlags2int(DistributionPointReasonFlags);
DistributionPointReasonFlags int2DistributionPointReasonFlags(unsigned);
#ifdef __PARSE_UNITS_H__
const struct units * asn1_DistributionPointReasonFlags_units(void);
#endif

/*
DistributionPointName ::= CHOICE {
  fullName                  [0] IMPLICIT SEQUENCE OF GeneralName,
  nameRelativeToCRLIssuer   [1] RelativeDistinguishedName,
}
*/

typedef struct DistributionPointName {
  enum {
    choice_DistributionPointName_fullName = 1,
    choice_DistributionPointName_nameRelativeToCRLIssuer
  } element;
  union {
    struct  {
      unsigned int len;
      GeneralName *val;
    } fullName;
    RelativeDistinguishedName nameRelativeToCRLIssuer;
  } u;
} DistributionPointName;

int    encode_DistributionPointName(unsigned char *, size_t, const DistributionPointName *, size_t *);
int    decode_DistributionPointName(const unsigned char *, size_t, DistributionPointName *, size_t *);
void   free_DistributionPointName  (DistributionPointName *);
size_t length_DistributionPointName(const DistributionPointName *);
int    copy_DistributionPointName  (const DistributionPointName *, DistributionPointName *);

/*
DistributionPoint ::= SEQUENCE {
  distributionPoint   [0] IMPLICIT heim_any OPTIONAL,
  reasons             [1] IMPLICIT heim_any OPTIONAL,
  cRLIssuer           [2] IMPLICIT heim_any OPTIONAL,
}
*/

typedef struct DistributionPoint {
  heim_any *distributionPoint;
  heim_any *reasons;
  heim_any *cRLIssuer;
} DistributionPoint;

int    encode_DistributionPoint(unsigned char *, size_t, const DistributionPoint *, size_t *);
int    decode_DistributionPoint(const unsigned char *, size_t, DistributionPoint *, size_t *);
void   free_DistributionPoint  (DistributionPoint *);
size_t length_DistributionPoint(const DistributionPoint *);
int    copy_DistributionPoint  (const DistributionPoint *, DistributionPoint *);

/*
CRLDistributionPoints ::= SEQUENCE OF DistributionPoint
*/

typedef struct CRLDistributionPoints {
  unsigned int len;
  DistributionPoint *val;
} CRLDistributionPoints;

int    encode_CRLDistributionPoints(unsigned char *, size_t, const CRLDistributionPoints *, size_t *);
int    decode_CRLDistributionPoints(const unsigned char *, size_t, CRLDistributionPoints *, size_t *);
void   free_CRLDistributionPoints  (CRLDistributionPoints *);
size_t length_CRLDistributionPoints(const CRLDistributionPoints *);
int    copy_CRLDistributionPoints  (const CRLDistributionPoints *, CRLDistributionPoints *);
int   add_CRLDistributionPoints  (CRLDistributionPoints *, const DistributionPoint *);
int   remove_CRLDistributionPoints  (CRLDistributionPoints *, unsigned int);

/*
DSASigValue ::= SEQUENCE {
  r               INTEGER,
  s               INTEGER,
}
*/

typedef struct DSASigValue {
  heim_integer r;
  heim_integer s;
} DSASigValue;

int    encode_DSASigValue(unsigned char *, size_t, const DSASigValue *, size_t *);
int    decode_DSASigValue(const unsigned char *, size_t, DSASigValue *, size_t *);
void   free_DSASigValue  (DSASigValue *);
size_t length_DSASigValue(const DSASigValue *);
int    copy_DSASigValue  (const DSASigValue *, DSASigValue *);

/*
DSAPublicKey ::= INTEGER
*/

typedef heim_integer DSAPublicKey;

int    encode_DSAPublicKey(unsigned char *, size_t, const DSAPublicKey *, size_t *);
int    decode_DSAPublicKey(const unsigned char *, size_t, DSAPublicKey *, size_t *);
void   free_DSAPublicKey  (DSAPublicKey *);
size_t length_DSAPublicKey(const DSAPublicKey *);
int    copy_DSAPublicKey  (const DSAPublicKey *, DSAPublicKey *);

/*
DSAParams ::= SEQUENCE {
  p               INTEGER,
  q               INTEGER,
  g               INTEGER,
}
*/

typedef struct DSAParams {
  heim_integer p;
  heim_integer q;
  heim_integer g;
} DSAParams;

int    encode_DSAParams(unsigned char *, size_t, const DSAParams *, size_t *);
int    decode_DSAParams(const unsigned char *, size_t, DSAParams *, size_t *);
void   free_DSAParams  (DSAParams *);
size_t length_DSAParams(const DSAParams *);
int    copy_DSAParams  (const DSAParams *, DSAParams *);

/*
RSAPublicKey ::= SEQUENCE {
  modulus          INTEGER,
  publicExponent   INTEGER,
}
*/

typedef struct RSAPublicKey {
  heim_integer modulus;
  heim_integer publicExponent;
} RSAPublicKey;

int    encode_RSAPublicKey(unsigned char *, size_t, const RSAPublicKey *, size_t *);
int    decode_RSAPublicKey(const unsigned char *, size_t, RSAPublicKey *, size_t *);
void   free_RSAPublicKey  (RSAPublicKey *);
size_t length_RSAPublicKey(const RSAPublicKey *);
int    copy_RSAPublicKey  (const RSAPublicKey *, RSAPublicKey *);

/*
RSAPrivateKey ::= SEQUENCE {
  version           INTEGER (0..-1),
  modulus           INTEGER,
  publicExponent    INTEGER,
  privateExponent   INTEGER,
  prime1            INTEGER,
  prime2            INTEGER,
  exponent1         INTEGER,
  exponent2         INTEGER,
  coefficient       INTEGER,
}
*/

typedef struct RSAPrivateKey {
  unsigned int version;
  heim_integer modulus;
  heim_integer publicExponent;
  heim_integer privateExponent;
  heim_integer prime1;
  heim_integer prime2;
  heim_integer exponent1;
  heim_integer exponent2;
  heim_integer coefficient;
} RSAPrivateKey;

int    encode_RSAPrivateKey(unsigned char *, size_t, const RSAPrivateKey *, size_t *);
int    decode_RSAPrivateKey(const unsigned char *, size_t, RSAPrivateKey *, size_t *);
void   free_RSAPrivateKey  (RSAPrivateKey *);
size_t length_RSAPrivateKey(const RSAPrivateKey *);
int    copy_RSAPrivateKey  (const RSAPrivateKey *, RSAPrivateKey *);

/*
DigestInfo ::= SEQUENCE {
  digestAlgorithm   AlgorithmIdentifier,
  digest            OCTET STRING,
}
*/

typedef struct DigestInfo {
  AlgorithmIdentifier digestAlgorithm;
  heim_octet_string digest;
} DigestInfo;

int    encode_DigestInfo(unsigned char *, size_t, const DigestInfo *, size_t *);
int    decode_DigestInfo(const unsigned char *, size_t, DigestInfo *, size_t *);
void   free_DigestInfo  (DigestInfo *);
size_t length_DigestInfo(const DigestInfo *);
int    copy_DigestInfo  (const DigestInfo *, DigestInfo *);

/*
TBSCRLCertList ::= SEQUENCE {
  version               Version OPTIONAL,
  signature             AlgorithmIdentifier,
  issuer                Name,
  thisUpdate            Time,
  nextUpdate            Time OPTIONAL,
  revokedCertificates   SEQUENCE OF SEQUENCE {
  userCertificate      CertificateSerialNumber,
  revocationDate       Time,
  crlEntryExtensions   Extensions OPTIONAL,
} OPTIONAL,
  crlExtensions         [0] Extensions OPTIONAL,
}
*/

typedef struct TBSCRLCertList {
  heim_octet_string _save;
  Version *version;
  AlgorithmIdentifier signature;
  Name issuer;
  Time thisUpdate;
  Time *nextUpdate;
  struct  {
    unsigned int len;
    struct  {
      CertificateSerialNumber userCertificate;
      Time revocationDate;
      Extensions *crlEntryExtensions;
    } *val;
  } *revokedCertificates;
  Extensions *crlExtensions;
} TBSCRLCertList;

int    encode_TBSCRLCertList(unsigned char *, size_t, const TBSCRLCertList *, size_t *);
int    decode_TBSCRLCertList(const unsigned char *, size_t, TBSCRLCertList *, size_t *);
void   free_TBSCRLCertList  (TBSCRLCertList *);
size_t length_TBSCRLCertList(const TBSCRLCertList *);
int    copy_TBSCRLCertList  (const TBSCRLCertList *, TBSCRLCertList *);

/*
CRLCertificateList ::= SEQUENCE {
  tbsCertList          TBSCRLCertList,
  signatureAlgorithm   AlgorithmIdentifier,
  signatureValue         BIT STRING {
  },
}
*/

typedef struct CRLCertificateList {
  TBSCRLCertList tbsCertList;
  AlgorithmIdentifier signatureAlgorithm;
  heim_bit_string signatureValue;
} CRLCertificateList;

int    encode_CRLCertificateList(unsigned char *, size_t, const CRLCertificateList *, size_t *);
int    decode_CRLCertificateList(const unsigned char *, size_t, CRLCertificateList *, size_t *);
void   free_CRLCertificateList  (CRLCertificateList *);
size_t length_CRLCertificateList(const CRLCertificateList *);
int    copy_CRLCertificateList  (const CRLCertificateList *, CRLCertificateList *);

/* OBJECT IDENTIFIER id-x509-ce-cRLNumber ::= { joint-iso-ccitt(2) ds(5) label-less(29) label-less(20) } */
const heim_oid *oid_id_x509_ce_cRLNumber(void);

/* OBJECT IDENTIFIER id-x509-ce-freshestCRL ::= { joint-iso-ccitt(2) ds(5) label-less(29) label-less(46) } */
const heim_oid *oid_id_x509_ce_freshestCRL(void);

/* OBJECT IDENTIFIER id-x509-ce-cRLReason ::= { joint-iso-ccitt(2) ds(5) label-less(29) label-less(21) } */
const heim_oid *oid_id_x509_ce_cRLReason(void);

/*
CRLReason ::= INTEGER {
  unspecified(0),
  keyCompromise(1),
  cACompromise(2),
  affiliationChanged(3),
  superseded(4),
  cessationOfOperation(5),
  certificateHold(6),
  removeFromCRL(8),
  privilegeWithdrawn(9),
  aACompromise(10)
}
*/

typedef enum CRLReason {
  unspecified = 0,
  keyCompromise = 1,
  cACompromise = 2,
  affiliationChanged = 3,
  superseded = 4,
  cessationOfOperation = 5,
  certificateHold = 6,
  removeFromCRL = 8,
  privilegeWithdrawn = 9,
  aACompromise = 10
} CRLReason;

int    encode_CRLReason(unsigned char *, size_t, const CRLReason *, size_t *);
int    decode_CRLReason(const unsigned char *, size_t, CRLReason *, size_t *);
void   free_CRLReason  (CRLReason *);
size_t length_CRLReason(const CRLReason *);
int    copy_CRLReason  (const CRLReason *, CRLReason *);

/*
PKIXXmppAddr ::= UTF8String
*/

typedef heim_utf8_string PKIXXmppAddr;

int    encode_PKIXXmppAddr(unsigned char *, size_t, const PKIXXmppAddr *, size_t *);
int    decode_PKIXXmppAddr(const unsigned char *, size_t, PKIXXmppAddr *, size_t *);
void   free_PKIXXmppAddr  (PKIXXmppAddr *);
size_t length_PKIXXmppAddr(const PKIXXmppAddr *);
int    copy_PKIXXmppAddr  (const PKIXXmppAddr *, PKIXXmppAddr *);

/* OBJECT IDENTIFIER id-pkix ::= { iso(1) identified-organization(3) dod(6) internet(1) security(5) mechanisms(5) pkix(7) } */
const heim_oid *oid_id_pkix(void);

/* OBJECT IDENTIFIER id-pkix-on ::= { iso(1) identified-organization(3) dod(6) internet(1) security(5) mechanisms(5) pkix(7) label-less(8) } */
const heim_oid *oid_id_pkix_on(void);

/* OBJECT IDENTIFIER id-pkix-on-xmppAddr ::= { iso(1) identified-organization(3) dod(6) internet(1) security(5) mechanisms(5) pkix(7) label-less(8) label-less(5) } */
const heim_oid *oid_id_pkix_on_xmppAddr(void);

/* OBJECT IDENTIFIER id-pkix-on-dnsSRV ::= { iso(1) identified-organization(3) dod(6) internet(1) security(5) mechanisms(5) pkix(7) label-less(8) label-less(7) } */
const heim_oid *oid_id_pkix_on_dnsSRV(void);

/* OBJECT IDENTIFIER id-pkix-kp ::= { iso(1) identified-organization(3) dod(6) internet(1) security(5) mechanisms(5) pkix(7) label-less(3) } */
const heim_oid *oid_id_pkix_kp(void);

/* OBJECT IDENTIFIER id-pkix-kp-serverAuth ::= { iso(1) identified-organization(3) dod(6) internet(1) security(5) mechanisms(5) pkix(7) label-less(3) label-less(1) } */
const heim_oid *oid_id_pkix_kp_serverAuth(void);

/* OBJECT IDENTIFIER id-pkix-kp-clientAuth ::= { iso(1) identified-organization(3) dod(6) internet(1) security(5) mechanisms(5) pkix(7) label-less(3) label-less(2) } */
const heim_oid *oid_id_pkix_kp_clientAuth(void);

/* OBJECT IDENTIFIER id-pkix-kp-emailProtection ::= { iso(1) identified-organization(3) dod(6) internet(1) security(5) mechanisms(5) pkix(7) label-less(3) label-less(4) } */
const heim_oid *oid_id_pkix_kp_emailProtection(void);

/* OBJECT IDENTIFIER id-pkix-kp-timeStamping ::= { iso(1) identified-organization(3) dod(6) internet(1) security(5) mechanisms(5) pkix(7) label-less(3) label-less(8) } */
const heim_oid *oid_id_pkix_kp_timeStamping(void);

/* OBJECT IDENTIFIER id-pkix-kp-OCSPSigning ::= { iso(1) identified-organization(3) dod(6) internet(1) security(5) mechanisms(5) pkix(7) label-less(3) label-less(9) } */
const heim_oid *oid_id_pkix_kp_OCSPSigning(void);

/* OBJECT IDENTIFIER id-pkix-pe ::= { iso(1) identified-organization(3) dod(6) internet(1) security(5) mechanisms(5) pkix(7) label-less(1) } */
const heim_oid *oid_id_pkix_pe(void);

/* OBJECT IDENTIFIER id-pkix-pe-authorityInfoAccess ::= { iso(1) identified-organization(3) dod(6) internet(1) security(5) mechanisms(5) pkix(7) label-less(1) label-less(1) } */
const heim_oid *oid_id_pkix_pe_authorityInfoAccess(void);

/*
AccessDescription ::= SEQUENCE {
  accessMethod       OBJECT IDENTIFIER,
  accessLocation   GeneralName,
}
*/

typedef struct AccessDescription {
  heim_oid accessMethod;
  GeneralName accessLocation;
} AccessDescription;

int    encode_AccessDescription(unsigned char *, size_t, const AccessDescription *, size_t *);
int    decode_AccessDescription(const unsigned char *, size_t, AccessDescription *, size_t *);
void   free_AccessDescription  (AccessDescription *);
size_t length_AccessDescription(const AccessDescription *);
int    copy_AccessDescription  (const AccessDescription *, AccessDescription *);

/*
AuthorityInfoAccessSyntax ::= SEQUENCE OF AccessDescription
*/

typedef struct AuthorityInfoAccessSyntax {
  unsigned int len;
  AccessDescription *val;
} AuthorityInfoAccessSyntax;

int    encode_AuthorityInfoAccessSyntax(unsigned char *, size_t, const AuthorityInfoAccessSyntax *, size_t *);
int    decode_AuthorityInfoAccessSyntax(const unsigned char *, size_t, AuthorityInfoAccessSyntax *, size_t *);
void   free_AuthorityInfoAccessSyntax  (AuthorityInfoAccessSyntax *);
size_t length_AuthorityInfoAccessSyntax(const AuthorityInfoAccessSyntax *);
int    copy_AuthorityInfoAccessSyntax  (const AuthorityInfoAccessSyntax *, AuthorityInfoAccessSyntax *);

/* OBJECT IDENTIFIER id-pkix-pe-proxyCertInfo ::= { iso(1) identified-organization(3) dod(6) internet(1) security(5) mechanisms(5) pkix(7) label-less(1) label-less(14) } */
const heim_oid *oid_id_pkix_pe_proxyCertInfo(void);

/* OBJECT IDENTIFIER id-pkix-ppl ::= { iso(1) identified-organization(3) dod(6) internet(1) security(5) mechanisms(5) pkix(7) label-less(21) } */
const heim_oid *oid_id_pkix_ppl(void);

/* OBJECT IDENTIFIER id-pkix-ppl-anyLanguage ::= { iso(1) identified-organization(3) dod(6) internet(1) security(5) mechanisms(5) pkix(7) label-less(21) label-less(0) } */
const heim_oid *oid_id_pkix_ppl_anyLanguage(void);

/* OBJECT IDENTIFIER id-pkix-ppl-inheritAll ::= { iso(1) identified-organization(3) dod(6) internet(1) security(5) mechanisms(5) pkix(7) label-less(21) label-less(1) } */
const heim_oid *oid_id_pkix_ppl_inheritAll(void);

/* OBJECT IDENTIFIER id-pkix-ppl-independent ::= { iso(1) identified-organization(3) dod(6) internet(1) security(5) mechanisms(5) pkix(7) label-less(21) label-less(2) } */
const heim_oid *oid_id_pkix_ppl_independent(void);

/*
ProxyPolicy ::= SEQUENCE {
  policyLanguage     OBJECT IDENTIFIER,
  policy           OCTET STRING OPTIONAL,
}
*/

typedef struct ProxyPolicy {
  heim_oid policyLanguage;
  heim_octet_string *policy;
} ProxyPolicy;

int    encode_ProxyPolicy(unsigned char *, size_t, const ProxyPolicy *, size_t *);
int    decode_ProxyPolicy(const unsigned char *, size_t, ProxyPolicy *, size_t *);
void   free_ProxyPolicy  (ProxyPolicy *);
size_t length_ProxyPolicy(const ProxyPolicy *);
int    copy_ProxyPolicy  (const ProxyPolicy *, ProxyPolicy *);

/*
ProxyCertInfo ::= SEQUENCE {
  pCPathLenConstraint   INTEGER (0..-1) OPTIONAL,
  proxyPolicy           ProxyPolicy,
}
*/

typedef struct ProxyCertInfo {
  unsigned int *pCPathLenConstraint;
  ProxyPolicy proxyPolicy;
} ProxyCertInfo;

int    encode_ProxyCertInfo(unsigned char *, size_t, const ProxyCertInfo *, size_t *);
int    decode_ProxyCertInfo(const unsigned char *, size_t, ProxyCertInfo *, size_t *);
void   free_ProxyCertInfo  (ProxyCertInfo *);
size_t length_ProxyCertInfo(const ProxyCertInfo *);
int    copy_ProxyCertInfo  (const ProxyCertInfo *, ProxyCertInfo *);

/* OBJECT IDENTIFIER id-uspkicommon-card-id ::= { label-less(2) label-less(16) label-less(840) label-less(1) label-less(101) label-less(3) label-less(6) label-less(6) } */
const heim_oid *oid_id_uspkicommon_card_id(void);

/* OBJECT IDENTIFIER id-uspkicommon-piv-interim ::= { label-less(2) label-less(16) label-less(840) label-less(1) label-less(101) label-less(3) label-less(6) label-less(9) label-less(1) } */
const heim_oid *oid_id_uspkicommon_piv_interim(void);

/* OBJECT IDENTIFIER id-netscape ::= { joint-iso-itu-t(2) country(16) us(840) organization(1) netscape(113730) } */
const heim_oid *oid_id_netscape(void);

/* OBJECT IDENTIFIER id-netscape-cert-comment ::= { joint-iso-itu-t(2) country(16) us(840) organization(1) netscape(113730) label-less(1) label-less(13) } */
const heim_oid *oid_id_netscape_cert_comment(void);

/* OBJECT IDENTIFIER id-ms-cert-enroll-domaincontroller ::= { label-less(1) label-less(3) label-less(6) label-less(1) label-less(4) label-less(1) label-less(311) label-less(20) label-less(2) } */
const heim_oid *oid_id_ms_cert_enroll_domaincontroller(void);

/* OBJECT IDENTIFIER id-ms-client-authentication ::= { label-less(1) label-less(3) label-less(6) label-less(1) label-less(5) label-less(5) label-less(7) label-less(3) label-less(2) } */
const heim_oid *oid_id_ms_client_authentication(void);

#endif /* __rfc2459_asn1_h__ */

repo_name: veiledmerc/mira

license: mit


code:
/* crypto/ripemd/ripemd.h */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
 * All rights reserved.
 *
 * This package is an SSL implementation written
 * by Eric Young (eay@cryptsoft.com).
 * The implementation was written so as to conform with Netscapes SSL.
 *
 * This library is free for commercial and non-commercial use as long as
 * the following conditions are aheared to.  The following conditions
 * apply to all code found in this distribution, be it the RC4, RSA,
 * lhash, DES, etc., code; not just the SSL code.  The SSL documentation
 * included with this distribution is covered by the same copyright terms
 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
 *
 * Copyright remains Eric Young's, and as such any Copyright notices in
 * the code are not to be removed.
 * If this package is used in a product, Eric Young should be given attribution
 * as the author of the parts of the library used.
 * This can be in the form of a textual message at program startup or
 * in documentation (online or textual) provided with the package.
 *
 * 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 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. All advertising materials mentioning features or use of this software
 *    must display the following acknowledgement:
 *    "This product includes cryptographic software written by
 *     Eric Young (eay@cryptsoft.com)"
 *    The word 'cryptographic' can be left out if the rouines from the library
 *    being used are not cryptographic related :-).
 * 4. If you include any Windows specific code (or a derivative thereof) from
 *    the apps directory (application code) you must include an acknowledgement:
 *    "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
 *
 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 AUTHOR 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.
 *
 * The licence and distribution terms for any publically available version or
 * derivative of this code cannot be changed.  i.e. this code cannot simply be
 * copied and put under another distribution licence
 * [including the GNU Public Licence.]
 */

/*
 * $FreeBSD: release/9.0.0/lib/libmd/ripemd.h 154479 2006-01-17 15:35:57Z phk $
 */

#ifndef HEADER_RIPEMD_H
#define HEADER_RIPEMD_H

#include <sys/cdefs.h>
#include <sys/types.h>		/* XXX switch to machine/ansi.h and __ types */

#define RIPEMD160_CBLOCK	64
#define RIPEMD160_LBLOCK	16
#define RIPEMD160_BLOCK		16
#define RIPEMD160_LAST_BLOCK	56
#define RIPEMD160_LENGTH_BLOCK	8
#define RIPEMD160_DIGEST_LENGTH	20

typedef struct RIPEMD160state_st {
	u_int32_t A,B,C,D,E;
	u_int32_t Nl,Nh;
	u_int32_t data[RIPEMD160_LBLOCK];
	int num;
} RIPEMD160_CTX;

__BEGIN_DECLS
void	RIPEMD160_Init(RIPEMD160_CTX *c);
void	RIPEMD160_Update(RIPEMD160_CTX *c, const void *data,
			 size_t len);
void	RIPEMD160_Final(unsigned char *md, RIPEMD160_CTX *c);
char   *RIPEMD160_End(RIPEMD160_CTX *, char *);
char   *RIPEMD160_File(const char *, char *);
char   *RIPEMD160_FileChunk(const char *, char *, off_t, off_t);
char   *RIPEMD160_Data(const void *, unsigned int, char *);
__END_DECLS

#endif


code:
/*
 * Copyright (c) 1995 - 2005 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: roken-common.h 20867 2007-06-03 21:00:45Z lha $ */

#ifndef __ROKEN_COMMON_H__
#define __ROKEN_COMMON_H__

#ifndef ROKEN_LIB_FUNCTION
#ifdef _WIN32
#define ROKEN_LIB_FUNCTION _stdcall
#else
#define ROKEN_LIB_FUNCTION
#endif
#endif

#ifdef __cplusplus
#define ROKEN_CPP_START	extern "C" {
#define ROKEN_CPP_END	}
#else
#define ROKEN_CPP_START
#define ROKEN_CPP_END
#endif

#ifndef INADDR_NONE
#define INADDR_NONE 0xffffffff
#endif

#ifndef INADDR_LOOPBACK
#define INADDR_LOOPBACK 0x7f000001
#endif

#ifndef SOMAXCONN
#define SOMAXCONN 5
#endif

#ifndef STDIN_FILENO
#define STDIN_FILENO 0
#endif

#ifndef STDOUT_FILENO
#define STDOUT_FILENO 1
#endif

#ifndef STDERR_FILENO
#define STDERR_FILENO 2
#endif

#ifndef max
#define max(a,b) (((a)>(b))?(a):(b))
#endif

#ifndef min
#define min(a,b) (((a)<(b))?(a):(b))
#endif

#ifndef TRUE
#define TRUE 1
#endif

#ifndef FALSE
#define FALSE 0
#endif

#ifndef LOG_DAEMON
#define openlog(id,option,facility) openlog((id),(option))
#define	LOG_DAEMON	0
#endif
#ifndef LOG_ODELAY
#define LOG_ODELAY 0
#endif
#ifndef LOG_NDELAY
#define LOG_NDELAY 0x08
#endif
#ifndef LOG_CONS
#define LOG_CONS 0
#endif
#ifndef LOG_AUTH
#define LOG_AUTH 0
#endif
#ifndef LOG_AUTHPRIV
#define LOG_AUTHPRIV LOG_AUTH
#endif

#ifndef F_OK
#define F_OK 0
#endif

#ifndef O_ACCMODE
#define O_ACCMODE	003
#endif

#ifndef _PATH_DEV
#define _PATH_DEV "/dev/"
#endif

#ifndef _PATH_DEVNULL
#define _PATH_DEVNULL "/dev/null"
#endif

#ifndef _PATH_HEQUIV
#define _PATH_HEQUIV "/etc/hosts.equiv"
#endif

#ifndef _PATH_VARRUN
#define _PATH_VARRUN "/var/run/"
#endif

#ifndef _PATH_BSHELL
#define _PATH_BSHELL "/bin/sh"
#endif

#ifndef MAXPATHLEN
#define MAXPATHLEN (1024+4)
#endif

#ifndef SIG_ERR
#define SIG_ERR ((RETSIGTYPE (*)(int))-1)
#endif

/*
 * error code for getipnodeby{name,addr}
 */

#ifndef HOST_NOT_FOUND
#define HOST_NOT_FOUND 1
#endif

#ifndef TRY_AGAIN
#define TRY_AGAIN 2
#endif

#ifndef NO_RECOVERY
#define NO_RECOVERY 3
#endif

#ifndef NO_DATA
#define NO_DATA 4
#endif

#ifndef NO_ADDRESS
#define NO_ADDRESS NO_DATA
#endif

/*
 * error code for getaddrinfo
 */

#ifndef EAI_NOERROR
#define EAI_NOERROR	0	/* no error */
#endif

#ifndef EAI_NONAME

#define EAI_ADDRFAMILY	1	/* address family for nodename not supported */
#define EAI_AGAIN	2	/* temporary failure in name resolution */
#define EAI_BADFLAGS	3	/* invalid value for ai_flags */
#define EAI_FAIL	4	/* non-recoverable failure in name resolution */
#define EAI_FAMILY	5	/* ai_family not supported */
#define EAI_MEMORY	6	/* memory allocation failure */
#define EAI_NODATA	7	/* no address associated with nodename */
#define EAI_NONAME	8	/* nodename nor servname provided, or not known */
#define EAI_SERVICE	9	/* servname not supported for ai_socktype */
#define EAI_SOCKTYPE   10	/* ai_socktype not supported */
#define EAI_SYSTEM     11	/* system error returned in errno */

#endif /* EAI_NONAME */

/* flags for getaddrinfo() */

#ifndef AI_PASSIVE
#define AI_PASSIVE	0x01
#define AI_CANONNAME	0x02
#endif /* AI_PASSIVE */

#ifndef AI_NUMERICHOST
#define AI_NUMERICHOST	0x04
#endif

/* flags for getnameinfo() */

#ifndef NI_DGRAM
#define NI_DGRAM	0x01
#define NI_NAMEREQD	0x02
#define NI_NOFQDN	0x04
#define NI_NUMERICHOST	0x08
#define NI_NUMERICSERV	0x10
#endif

/*
 * constants for getnameinfo
 */

#ifndef NI_MAXHOST
#define NI_MAXHOST  1025
#define NI_MAXSERV    32
#endif

/*
 * constants for inet_ntop
 */

#ifndef INET_ADDRSTRLEN
#define INET_ADDRSTRLEN    16
#endif

#ifndef INET6_ADDRSTRLEN
#define INET6_ADDRSTRLEN   46
#endif

/*
 * for shutdown(2)
 */

#ifndef SHUT_RD
#define SHUT_RD 0
#endif

#ifndef SHUT_WR
#define SHUT_WR 1
#endif

#ifndef SHUT_RDWR
#define SHUT_RDWR 2
#endif

#ifndef HAVE___ATTRIBUTE__
#define __attribute__(x)
#endif

ROKEN_CPP_START

#ifndef IRIX4 /* fix for compiler bug */
#ifdef RETSIGTYPE
typedef RETSIGTYPE (*SigAction)(int);
SigAction signal(int iSig, SigAction pAction); /* BSD compatible */
#endif
#endif

int ROKEN_LIB_FUNCTION
simple_execve(const char*, char*const[], char*const[]);

int ROKEN_LIB_FUNCTION
simple_execve_timed(const char *, char *const[],
		    char *const [], time_t (*)(void *),
		    void *, time_t);
int ROKEN_LIB_FUNCTION
simple_execvp(const char*, char *const[]);

int ROKEN_LIB_FUNCTION
simple_execvp_timed(const char *, char *const[],
		    time_t (*)(void *), void *, time_t);
int ROKEN_LIB_FUNCTION
simple_execlp(const char*, ...);

int ROKEN_LIB_FUNCTION
simple_execle(const char*, ...);

int ROKEN_LIB_FUNCTION
simple_execl(const char *file, ...);

int ROKEN_LIB_FUNCTION
wait_for_process(pid_t);

int ROKEN_LIB_FUNCTION
wait_for_process_timed(pid_t, time_t (*)(void *),
					      void *, time_t);
int ROKEN_LIB_FUNCTION
pipe_execv(FILE**, FILE**, FILE**, const char*, ...);

void ROKEN_LIB_FUNCTION
print_version(const char *);

ssize_t ROKEN_LIB_FUNCTION
eread (int fd, void *buf, size_t nbytes);

ssize_t ROKEN_LIB_FUNCTION
ewrite (int fd, const void *buf, size_t nbytes);

struct hostent;

const char * ROKEN_LIB_FUNCTION
hostent_find_fqdn (const struct hostent *);

void ROKEN_LIB_FUNCTION
esetenv(const char *, const char *, int);

void ROKEN_LIB_FUNCTION
socket_set_address_and_port (struct sockaddr *, const void *, int);

size_t ROKEN_LIB_FUNCTION
socket_addr_size (const struct sockaddr *);

void ROKEN_LIB_FUNCTION
socket_set_any (struct sockaddr *, int);

size_t ROKEN_LIB_FUNCTION
socket_sockaddr_size (const struct sockaddr *);

void * ROKEN_LIB_FUNCTION
socket_get_address (struct sockaddr *);

int ROKEN_LIB_FUNCTION
socket_get_port (const struct sockaddr *);

void ROKEN_LIB_FUNCTION
socket_set_port (struct sockaddr *, int);

void ROKEN_LIB_FUNCTION
socket_set_portrange (int, int, int);

void ROKEN_LIB_FUNCTION
socket_set_debug (int);

void ROKEN_LIB_FUNCTION
socket_set_tos (int, int);

void ROKEN_LIB_FUNCTION
socket_set_reuseaddr (int, int);

void ROKEN_LIB_FUNCTION
socket_set_ipv6only (int, int);

char ** ROKEN_LIB_FUNCTION
vstrcollect(va_list *ap);

char ** ROKEN_LIB_FUNCTION
strcollect(char *first, ...);

void ROKEN_LIB_FUNCTION
timevalfix(struct timeval *t1);

void ROKEN_LIB_FUNCTION
timevaladd(struct timeval *t1, const struct timeval *t2);

void ROKEN_LIB_FUNCTION
timevalsub(struct timeval *t1, const struct timeval *t2);

char *ROKEN_LIB_FUNCTION
pid_file_write (const char *progname);

void ROKEN_LIB_FUNCTION
pid_file_delete (char **);

int ROKEN_LIB_FUNCTION
read_environment(const char *file, char ***env);

void ROKEN_LIB_FUNCTION
free_environment(char **);

void ROKEN_LIB_FUNCTION
warnerr(int doerrno, const char *fmt, va_list ap)
    __attribute__ ((format (printf, 2, 0)));

void * ROKEN_LIB_FUNCTION
rk_realloc(void *, size_t);

struct rk_strpool;

char * ROKEN_LIB_FUNCTION
rk_strpoolcollect(struct rk_strpool *);

struct rk_strpool * ROKEN_LIB_FUNCTION
rk_strpoolprintf(struct rk_strpool *, const char *, ...)
    __attribute__ ((format (printf, 2, 3)));

void ROKEN_LIB_FUNCTION
rk_strpoolfree(struct rk_strpool *);

void ROKEN_LIB_FUNCTION
rk_dumpdata (const char *, const void *, size_t);

ROKEN_CPP_END

#endif /* __ROKEN_COMMON_H__ */


code:
/* This is an OS dependent, generated file */

#ifndef __ROKEN_H__
#define __ROKEN_H__

/* -*- C -*- */
/*
 * Copyright (c) 1995-2005 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: roken.h.in 18612 2006-10-19 16:35:16Z lha $ */

#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <stdint.h>
#include <string.h>
#include <signal.h>

#include <sys/param.h>
#include <inttypes.h>
#include <sys/types.h>
#include <unistd.h>
#include <sys/socket.h>
#include <sys/uio.h>
#include <grp.h>
#include <sys/stat.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <arpa/nameser.h>
#include <resolv.h>
#include <syslog.h>
#include <fcntl.h>
#include <errno.h>
#include <err.h>
#include <termios.h>
#include <sys/ioctl.h>
#include <sys/time.h>
#include <time.h>
#include <strings.h>

#include <paths.h>

#include <roken-common.h>

ROKEN_CPP_START

#define rk_UNCONST(x) ((void *)(uintptr_t)(const void *)(x))

int ROKEN_LIB_FUNCTION
    asnprintf (char **, size_t, const char *, ...)
     __attribute__ ((format (printf, 3, 4)));

int ROKEN_LIB_FUNCTION
    vasnprintf (char **, size_t, const char *, va_list)
     __attribute__((format (printf, 3, 0)));

char * ROKEN_LIB_FUNCTION strndup(const char *, size_t);

char * ROKEN_LIB_FUNCTION strlwr(char *);

size_t ROKEN_LIB_FUNCTION strnlen(const char*, size_t);

ssize_t ROKEN_LIB_FUNCTION strsep_copy(const char**, const char*, char*, size_t);

char * ROKEN_LIB_FUNCTION strupr(char *);

#include <pwd.h>
struct passwd * ROKEN_LIB_FUNCTION k_getpwnam (const char *);
struct passwd * ROKEN_LIB_FUNCTION k_getpwuid (uid_t);

const char * ROKEN_LIB_FUNCTION get_default_username (void);

int ROKEN_LIB_FUNCTION daemon(int, int);

void ROKEN_LIB_FUNCTION pidfile (const char*);

unsigned int ROKEN_LIB_FUNCTION bswap32(unsigned int);

unsigned short ROKEN_LIB_FUNCTION bswap16(unsigned short);

time_t ROKEN_LIB_FUNCTION tm2time (struct tm, int);

int ROKEN_LIB_FUNCTION unix_verify_user(char *, char *);

int ROKEN_LIB_FUNCTION roken_concat (char *, size_t, ...);

size_t ROKEN_LIB_FUNCTION roken_mconcat (char **, size_t, ...);

int ROKEN_LIB_FUNCTION roken_vconcat (char *, size_t, va_list);

size_t ROKEN_LIB_FUNCTION
    roken_vmconcat (char **, size_t, va_list);

ssize_t ROKEN_LIB_FUNCTION net_write (int, const void *, size_t);

ssize_t ROKEN_LIB_FUNCTION net_read (int, void *, size_t);

int ROKEN_LIB_FUNCTION issuid(void);

int ROKEN_LIB_FUNCTION get_window_size(int fd, struct winsize *);

extern char **environ;

struct hostent * ROKEN_LIB_FUNCTION
copyhostent (const struct hostent *);

int ROKEN_LIB_FUNCTION
getnameinfo_verified(const struct sockaddr *, socklen_t,
		     char *, size_t,
		     char *, size_t,
		     int);

int ROKEN_LIB_FUNCTION
roken_getaddrinfo_hostspec(const char *, int, struct addrinfo **);
int ROKEN_LIB_FUNCTION
roken_getaddrinfo_hostspec2(const char *, int, int, struct addrinfo **);

void * ROKEN_LIB_FUNCTION emalloc (size_t);
void * ROKEN_LIB_FUNCTION ecalloc(size_t, size_t);
void * ROKEN_LIB_FUNCTION erealloc (void *, size_t);
char * ROKEN_LIB_FUNCTION estrdup (const char *);

/*
 * kludges and such
 */

int ROKEN_LIB_FUNCTION
roken_gethostby_setup(const char*, const char*);
struct hostent* ROKEN_LIB_FUNCTION
roken_gethostbyname(const char*);
struct hostent* ROKEN_LIB_FUNCTION
roken_gethostbyaddr(const void*, size_t, int);

#define roken_getservbyname(x,y) getservbyname(x,y)

#define roken_openlog(a,b,c) openlog(a,b,c)

#define roken_getsockname(a,b,c) getsockname(a,b,c)

void ROKEN_LIB_FUNCTION mini_inetd_addrinfo (struct addrinfo*);
void ROKEN_LIB_FUNCTION mini_inetd (int);

int ROKEN_LIB_FUNCTION
strsvis(char *, const char *, int, const char *);

char * ROKEN_LIB_FUNCTION
svis(char *, int, int, int, const char *);

ROKEN_CPP_END
#define ROKEN_VERSION 1.1

#endif /* __ROKEN_H__ */