xref: /onnv-gate/usr/src/common/openssl/crypto/asn1/asn1.h (revision 9318:704e5a016b38)
10Sstevel@tonic-gate /* crypto/asn1/asn1.h */
20Sstevel@tonic-gate /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
30Sstevel@tonic-gate  * All rights reserved.
40Sstevel@tonic-gate  *
50Sstevel@tonic-gate  * This package is an SSL implementation written
60Sstevel@tonic-gate  * by Eric Young (eay@cryptsoft.com).
70Sstevel@tonic-gate  * The implementation was written so as to conform with Netscapes SSL.
80Sstevel@tonic-gate  *
90Sstevel@tonic-gate  * This library is free for commercial and non-commercial use as long as
100Sstevel@tonic-gate  * the following conditions are aheared to.  The following conditions
110Sstevel@tonic-gate  * apply to all code found in this distribution, be it the RC4, RSA,
120Sstevel@tonic-gate  * lhash, DES, etc., code; not just the SSL code.  The SSL documentation
130Sstevel@tonic-gate  * included with this distribution is covered by the same copyright terms
140Sstevel@tonic-gate  * except that the holder is Tim Hudson (tjh@cryptsoft.com).
150Sstevel@tonic-gate  *
160Sstevel@tonic-gate  * Copyright remains Eric Young's, and as such any Copyright notices in
170Sstevel@tonic-gate  * the code are not to be removed.
180Sstevel@tonic-gate  * If this package is used in a product, Eric Young should be given attribution
190Sstevel@tonic-gate  * as the author of the parts of the library used.
200Sstevel@tonic-gate  * This can be in the form of a textual message at program startup or
210Sstevel@tonic-gate  * in documentation (online or textual) provided with the package.
220Sstevel@tonic-gate  *
230Sstevel@tonic-gate  * Redistribution and use in source and binary forms, with or without
240Sstevel@tonic-gate  * modification, are permitted provided that the following conditions
250Sstevel@tonic-gate  * are met:
260Sstevel@tonic-gate  * 1. Redistributions of source code must retain the copyright
270Sstevel@tonic-gate  *    notice, this list of conditions and the following disclaimer.
280Sstevel@tonic-gate  * 2. Redistributions in binary form must reproduce the above copyright
290Sstevel@tonic-gate  *    notice, this list of conditions and the following disclaimer in the
300Sstevel@tonic-gate  *    documentation and/or other materials provided with the distribution.
310Sstevel@tonic-gate  * 3. All advertising materials mentioning features or use of this software
320Sstevel@tonic-gate  *    must display the following acknowledgement:
330Sstevel@tonic-gate  *    "This product includes cryptographic software written by
340Sstevel@tonic-gate  *     Eric Young (eay@cryptsoft.com)"
350Sstevel@tonic-gate  *    The word 'cryptographic' can be left out if the rouines from the library
360Sstevel@tonic-gate  *    being used are not cryptographic related :-).
370Sstevel@tonic-gate  * 4. If you include any Windows specific code (or a derivative thereof) from
380Sstevel@tonic-gate  *    the apps directory (application code) you must include an acknowledgement:
390Sstevel@tonic-gate  *    "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
400Sstevel@tonic-gate  *
410Sstevel@tonic-gate  * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
420Sstevel@tonic-gate  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
430Sstevel@tonic-gate  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
440Sstevel@tonic-gate  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
450Sstevel@tonic-gate  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
460Sstevel@tonic-gate  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
470Sstevel@tonic-gate  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
480Sstevel@tonic-gate  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
490Sstevel@tonic-gate  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
500Sstevel@tonic-gate  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
510Sstevel@tonic-gate  * SUCH DAMAGE.
520Sstevel@tonic-gate  *
530Sstevel@tonic-gate  * The licence and distribution terms for any publically available version or
540Sstevel@tonic-gate  * derivative of this code cannot be changed.  i.e. this code cannot simply be
550Sstevel@tonic-gate  * copied and put under another distribution licence
560Sstevel@tonic-gate  * [including the GNU Public Licence.]
570Sstevel@tonic-gate  */
580Sstevel@tonic-gate 
590Sstevel@tonic-gate #ifndef HEADER_ASN1_H
600Sstevel@tonic-gate #define HEADER_ASN1_H
610Sstevel@tonic-gate 
620Sstevel@tonic-gate #include <time.h>
632139Sjp161948 #include <openssl/e_os2.h>
640Sstevel@tonic-gate #ifndef OPENSSL_NO_BIO
650Sstevel@tonic-gate #include <openssl/bio.h>
660Sstevel@tonic-gate #endif
670Sstevel@tonic-gate #include <openssl/stack.h>
680Sstevel@tonic-gate #include <openssl/safestack.h>
690Sstevel@tonic-gate 
700Sstevel@tonic-gate #include <openssl/symhacks.h>
710Sstevel@tonic-gate 
720Sstevel@tonic-gate #include <openssl/ossl_typ.h>
732139Sjp161948 #ifndef OPENSSL_NO_DEPRECATED
742139Sjp161948 #include <openssl/bn.h>
752139Sjp161948 #endif
760Sstevel@tonic-gate 
770Sstevel@tonic-gate #ifdef OPENSSL_BUILD_SHLIBCRYPTO
780Sstevel@tonic-gate # undef OPENSSL_EXTERN
790Sstevel@tonic-gate # define OPENSSL_EXTERN OPENSSL_EXPORT
800Sstevel@tonic-gate #endif
810Sstevel@tonic-gate 
820Sstevel@tonic-gate #ifdef  __cplusplus
830Sstevel@tonic-gate extern "C" {
840Sstevel@tonic-gate #endif
850Sstevel@tonic-gate 
860Sstevel@tonic-gate #define V_ASN1_UNIVERSAL		0x00
870Sstevel@tonic-gate #define	V_ASN1_APPLICATION		0x40
880Sstevel@tonic-gate #define V_ASN1_CONTEXT_SPECIFIC		0x80
890Sstevel@tonic-gate #define V_ASN1_PRIVATE			0xc0
900Sstevel@tonic-gate 
910Sstevel@tonic-gate #define V_ASN1_CONSTRUCTED		0x20
920Sstevel@tonic-gate #define V_ASN1_PRIMITIVE_TAG		0x1f
930Sstevel@tonic-gate #define V_ASN1_PRIMATIVE_TAG		0x1f
940Sstevel@tonic-gate 
950Sstevel@tonic-gate #define V_ASN1_APP_CHOOSE		-2	/* let the recipient choose */
960Sstevel@tonic-gate #define V_ASN1_OTHER			-3	/* used in ASN1_TYPE */
970Sstevel@tonic-gate #define V_ASN1_ANY			-4	/* used in ASN1 template code */
980Sstevel@tonic-gate 
990Sstevel@tonic-gate #define V_ASN1_NEG			0x100	/* negative flag */
1000Sstevel@tonic-gate 
1010Sstevel@tonic-gate #define V_ASN1_UNDEF			-1
1020Sstevel@tonic-gate #define V_ASN1_EOC			0
1030Sstevel@tonic-gate #define V_ASN1_BOOLEAN			1	/**/
1040Sstevel@tonic-gate #define V_ASN1_INTEGER			2
1050Sstevel@tonic-gate #define V_ASN1_NEG_INTEGER		(2 | V_ASN1_NEG)
1060Sstevel@tonic-gate #define V_ASN1_BIT_STRING		3
1070Sstevel@tonic-gate #define V_ASN1_OCTET_STRING		4
1080Sstevel@tonic-gate #define V_ASN1_NULL			5
1090Sstevel@tonic-gate #define V_ASN1_OBJECT			6
1100Sstevel@tonic-gate #define V_ASN1_OBJECT_DESCRIPTOR	7
1110Sstevel@tonic-gate #define V_ASN1_EXTERNAL			8
1120Sstevel@tonic-gate #define V_ASN1_REAL			9
1130Sstevel@tonic-gate #define V_ASN1_ENUMERATED		10
1140Sstevel@tonic-gate #define V_ASN1_NEG_ENUMERATED		(10 | V_ASN1_NEG)
1150Sstevel@tonic-gate #define V_ASN1_UTF8STRING		12
1160Sstevel@tonic-gate #define V_ASN1_SEQUENCE			16
1170Sstevel@tonic-gate #define V_ASN1_SET			17
1180Sstevel@tonic-gate #define V_ASN1_NUMERICSTRING		18	/**/
1190Sstevel@tonic-gate #define V_ASN1_PRINTABLESTRING		19
1200Sstevel@tonic-gate #define V_ASN1_T61STRING		20
1210Sstevel@tonic-gate #define V_ASN1_TELETEXSTRING		20	/* alias */
1220Sstevel@tonic-gate #define V_ASN1_VIDEOTEXSTRING		21	/**/
1230Sstevel@tonic-gate #define V_ASN1_IA5STRING		22
1240Sstevel@tonic-gate #define V_ASN1_UTCTIME			23
1250Sstevel@tonic-gate #define V_ASN1_GENERALIZEDTIME		24	/**/
1260Sstevel@tonic-gate #define V_ASN1_GRAPHICSTRING		25	/**/
1270Sstevel@tonic-gate #define V_ASN1_ISO64STRING		26	/**/
1280Sstevel@tonic-gate #define V_ASN1_VISIBLESTRING		26	/* alias */
1290Sstevel@tonic-gate #define V_ASN1_GENERALSTRING		27	/**/
1300Sstevel@tonic-gate #define V_ASN1_UNIVERSALSTRING		28	/**/
1310Sstevel@tonic-gate #define V_ASN1_BMPSTRING		30
1320Sstevel@tonic-gate 
1330Sstevel@tonic-gate /* For use with d2i_ASN1_type_bytes() */
1340Sstevel@tonic-gate #define B_ASN1_NUMERICSTRING	0x0001
1350Sstevel@tonic-gate #define B_ASN1_PRINTABLESTRING	0x0002
1360Sstevel@tonic-gate #define B_ASN1_T61STRING	0x0004
1370Sstevel@tonic-gate #define B_ASN1_TELETEXSTRING	0x0004
1380Sstevel@tonic-gate #define B_ASN1_VIDEOTEXSTRING	0x0008
1390Sstevel@tonic-gate #define B_ASN1_IA5STRING	0x0010
1400Sstevel@tonic-gate #define B_ASN1_GRAPHICSTRING	0x0020
1410Sstevel@tonic-gate #define B_ASN1_ISO64STRING	0x0040
1420Sstevel@tonic-gate #define B_ASN1_VISIBLESTRING	0x0040
1430Sstevel@tonic-gate #define B_ASN1_GENERALSTRING	0x0080
1440Sstevel@tonic-gate #define B_ASN1_UNIVERSALSTRING	0x0100
1450Sstevel@tonic-gate #define B_ASN1_OCTET_STRING	0x0200
1460Sstevel@tonic-gate #define B_ASN1_BIT_STRING	0x0400
1470Sstevel@tonic-gate #define B_ASN1_BMPSTRING	0x0800
1480Sstevel@tonic-gate #define B_ASN1_UNKNOWN		0x1000
1490Sstevel@tonic-gate #define B_ASN1_UTF8STRING	0x2000
1500Sstevel@tonic-gate #define B_ASN1_UTCTIME		0x4000
1510Sstevel@tonic-gate #define B_ASN1_GENERALIZEDTIME	0x8000
1520Sstevel@tonic-gate 
1530Sstevel@tonic-gate /* For use with ASN1_mbstring_copy() */
1540Sstevel@tonic-gate #define MBSTRING_FLAG		0x1000
1552139Sjp161948 #define MBSTRING_UTF8		(MBSTRING_FLAG)
1560Sstevel@tonic-gate #define MBSTRING_ASC		(MBSTRING_FLAG|1)
1570Sstevel@tonic-gate #define MBSTRING_BMP		(MBSTRING_FLAG|2)
1582139Sjp161948 #define MBSTRING_UNIV		(MBSTRING_FLAG|4)
1590Sstevel@tonic-gate 
1600Sstevel@tonic-gate struct X509_algor_st;
1610Sstevel@tonic-gate 
1620Sstevel@tonic-gate #define DECLARE_ASN1_SET_OF(type) /* filled in by mkstack.pl */
1630Sstevel@tonic-gate #define IMPLEMENT_ASN1_SET_OF(type) /* nothing, no longer needed */
1640Sstevel@tonic-gate 
1652139Sjp161948 /* We MUST make sure that, except for constness, asn1_ctx_st and
1662139Sjp161948    asn1_const_ctx are exactly the same.  Fortunately, as soon as
1672139Sjp161948    the old ASN1 parsing macros are gone, we can throw this away
1682139Sjp161948    as well... */
1690Sstevel@tonic-gate typedef struct asn1_ctx_st
1700Sstevel@tonic-gate 	{
1710Sstevel@tonic-gate 	unsigned char *p;/* work char pointer */
1720Sstevel@tonic-gate 	int eos;	/* end of sequence read for indefinite encoding */
1730Sstevel@tonic-gate 	int error;	/* error code to use when returning an error */
1740Sstevel@tonic-gate 	int inf;	/* constructed if 0x20, indefinite is 0x21 */
1750Sstevel@tonic-gate 	int tag;	/* tag from last 'get object' */
1760Sstevel@tonic-gate 	int xclass;	/* class from last 'get object' */
1770Sstevel@tonic-gate 	long slen;	/* length of last 'get object' */
1780Sstevel@tonic-gate 	unsigned char *max; /* largest value of p allowed */
1790Sstevel@tonic-gate 	unsigned char *q;/* temporary variable */
1800Sstevel@tonic-gate 	unsigned char **pp;/* variable */
1810Sstevel@tonic-gate 	int line;	/* used in error processing */
1820Sstevel@tonic-gate 	} ASN1_CTX;
1830Sstevel@tonic-gate 
1842139Sjp161948 typedef struct asn1_const_ctx_st
1852139Sjp161948 	{
1862139Sjp161948 	const unsigned char *p;/* work char pointer */
1872139Sjp161948 	int eos;	/* end of sequence read for indefinite encoding */
1882139Sjp161948 	int error;	/* error code to use when returning an error */
1892139Sjp161948 	int inf;	/* constructed if 0x20, indefinite is 0x21 */
1902139Sjp161948 	int tag;	/* tag from last 'get object' */
1912139Sjp161948 	int xclass;	/* class from last 'get object' */
1922139Sjp161948 	long slen;	/* length of last 'get object' */
1932139Sjp161948 	const unsigned char *max; /* largest value of p allowed */
1942139Sjp161948 	const unsigned char *q;/* temporary variable */
1952139Sjp161948 	const unsigned char **pp;/* variable */
1962139Sjp161948 	int line;	/* used in error processing */
1972139Sjp161948 	} ASN1_const_CTX;
1982139Sjp161948 
1990Sstevel@tonic-gate /* These are used internally in the ASN1_OBJECT to keep track of
2000Sstevel@tonic-gate  * whether the names and data need to be free()ed */
2010Sstevel@tonic-gate #define ASN1_OBJECT_FLAG_DYNAMIC	 0x01	/* internal use */
2020Sstevel@tonic-gate #define ASN1_OBJECT_FLAG_CRITICAL	 0x02	/* critical x509v3 object id */
2030Sstevel@tonic-gate #define ASN1_OBJECT_FLAG_DYNAMIC_STRINGS 0x04	/* internal use */
2040Sstevel@tonic-gate #define ASN1_OBJECT_FLAG_DYNAMIC_DATA 	 0x08	/* internal use */
2050Sstevel@tonic-gate typedef struct asn1_object_st
2060Sstevel@tonic-gate 	{
2070Sstevel@tonic-gate 	const char *sn,*ln;
2080Sstevel@tonic-gate 	int nid;
2090Sstevel@tonic-gate 	int length;
2100Sstevel@tonic-gate 	unsigned char *data;
2110Sstevel@tonic-gate 	int flags;	/* Should we free this one */
2120Sstevel@tonic-gate 	} ASN1_OBJECT;
2130Sstevel@tonic-gate 
2140Sstevel@tonic-gate #define ASN1_STRING_FLAG_BITS_LEFT 0x08 /* Set if 0x07 has bits left value */
2152139Sjp161948 /* This indicates that the ASN1_STRING is not a real value but just a place
2162139Sjp161948  * holder for the location where indefinite length constructed data should
2172139Sjp161948  * be inserted in the memory buffer
2182139Sjp161948  */
2192139Sjp161948 #define ASN1_STRING_FLAG_NDEF 0x010
2200Sstevel@tonic-gate /* This is the base type that holds just about everything :-) */
2210Sstevel@tonic-gate typedef struct asn1_string_st
2220Sstevel@tonic-gate 	{
2230Sstevel@tonic-gate 	int length;
2240Sstevel@tonic-gate 	int type;
2250Sstevel@tonic-gate 	unsigned char *data;
2260Sstevel@tonic-gate 	/* The value of the following field depends on the type being
2270Sstevel@tonic-gate 	 * held.  It is mostly being used for BIT_STRING so if the
2280Sstevel@tonic-gate 	 * input data has a non-zero 'unused bits' value, it will be
2290Sstevel@tonic-gate 	 * handled correctly */
2300Sstevel@tonic-gate 	long flags;
2310Sstevel@tonic-gate 	} ASN1_STRING;
2320Sstevel@tonic-gate 
2330Sstevel@tonic-gate /* ASN1_ENCODING structure: this is used to save the received
2340Sstevel@tonic-gate  * encoding of an ASN1 type. This is useful to get round
2350Sstevel@tonic-gate  * problems with invalid encodings which can break signatures.
2360Sstevel@tonic-gate  */
2370Sstevel@tonic-gate 
2380Sstevel@tonic-gate typedef struct ASN1_ENCODING_st
2390Sstevel@tonic-gate 	{
2400Sstevel@tonic-gate 	unsigned char *enc;	/* DER encoding */
2410Sstevel@tonic-gate 	long len;		/* Length of encoding */
2420Sstevel@tonic-gate 	int modified;		 /* set to 1 if 'enc' is invalid */
2430Sstevel@tonic-gate 	} ASN1_ENCODING;
2440Sstevel@tonic-gate 
2450Sstevel@tonic-gate /* Used with ASN1 LONG type: if a long is set to this it is omitted */
2460Sstevel@tonic-gate #define ASN1_LONG_UNDEF	0x7fffffffL
2470Sstevel@tonic-gate 
2480Sstevel@tonic-gate #define STABLE_FLAGS_MALLOC	0x01
2490Sstevel@tonic-gate #define STABLE_NO_MASK		0x02
2500Sstevel@tonic-gate #define DIRSTRING_TYPE	\
2510Sstevel@tonic-gate  (B_ASN1_PRINTABLESTRING|B_ASN1_T61STRING|B_ASN1_BMPSTRING|B_ASN1_UTF8STRING)
2520Sstevel@tonic-gate #define PKCS9STRING_TYPE (DIRSTRING_TYPE|B_ASN1_IA5STRING)
2530Sstevel@tonic-gate 
2540Sstevel@tonic-gate typedef struct asn1_string_table_st {
2550Sstevel@tonic-gate 	int nid;
2560Sstevel@tonic-gate 	long minsize;
2570Sstevel@tonic-gate 	long maxsize;
2580Sstevel@tonic-gate 	unsigned long mask;
2590Sstevel@tonic-gate 	unsigned long flags;
2600Sstevel@tonic-gate } ASN1_STRING_TABLE;
2610Sstevel@tonic-gate 
2620Sstevel@tonic-gate DECLARE_STACK_OF(ASN1_STRING_TABLE)
2630Sstevel@tonic-gate 
2640Sstevel@tonic-gate /* size limits: this stuff is taken straight from RFC2459 */
2650Sstevel@tonic-gate 
2660Sstevel@tonic-gate #define ub_name				32768
2670Sstevel@tonic-gate #define ub_common_name			64
2680Sstevel@tonic-gate #define ub_locality_name		128
2690Sstevel@tonic-gate #define ub_state_name			128
2700Sstevel@tonic-gate #define ub_organization_name		64
2710Sstevel@tonic-gate #define ub_organization_unit_name	64
2720Sstevel@tonic-gate #define ub_title			64
2730Sstevel@tonic-gate #define ub_email_address		128
2740Sstevel@tonic-gate 
2750Sstevel@tonic-gate /* Declarations for template structures: for full definitions
2760Sstevel@tonic-gate  * see asn1t.h
2770Sstevel@tonic-gate  */
2780Sstevel@tonic-gate typedef struct ASN1_TEMPLATE_st ASN1_TEMPLATE;
2790Sstevel@tonic-gate typedef struct ASN1_ITEM_st ASN1_ITEM;
2800Sstevel@tonic-gate typedef struct ASN1_TLC_st ASN1_TLC;
2810Sstevel@tonic-gate /* This is just an opaque pointer */
2820Sstevel@tonic-gate typedef struct ASN1_VALUE_st ASN1_VALUE;
2830Sstevel@tonic-gate 
2840Sstevel@tonic-gate /* Declare ASN1 functions: the implement macro in in asn1t.h */
2850Sstevel@tonic-gate 
2860Sstevel@tonic-gate #define DECLARE_ASN1_FUNCTIONS(type) DECLARE_ASN1_FUNCTIONS_name(type, type)
2870Sstevel@tonic-gate 
2882139Sjp161948 #define DECLARE_ASN1_ALLOC_FUNCTIONS(type) \
2892139Sjp161948 	DECLARE_ASN1_ALLOC_FUNCTIONS_name(type, type)
2902139Sjp161948 
2910Sstevel@tonic-gate #define DECLARE_ASN1_FUNCTIONS_name(type, name) \
2922139Sjp161948 	DECLARE_ASN1_ALLOC_FUNCTIONS_name(type, name) \
2930Sstevel@tonic-gate 	DECLARE_ASN1_ENCODE_FUNCTIONS(type, name, name)
2940Sstevel@tonic-gate 
2950Sstevel@tonic-gate #define DECLARE_ASN1_FUNCTIONS_fname(type, itname, name) \
2962139Sjp161948 	DECLARE_ASN1_ALLOC_FUNCTIONS_name(type, name) \
2970Sstevel@tonic-gate 	DECLARE_ASN1_ENCODE_FUNCTIONS(type, itname, name)
2980Sstevel@tonic-gate 
2990Sstevel@tonic-gate #define	DECLARE_ASN1_ENCODE_FUNCTIONS(type, itname, name) \
3002139Sjp161948 	type *d2i_##name(type **a, const unsigned char **in, long len); \
3010Sstevel@tonic-gate 	int i2d_##name(type *a, unsigned char **out); \
3020Sstevel@tonic-gate 	DECLARE_ASN1_ITEM(itname)
3030Sstevel@tonic-gate 
3040Sstevel@tonic-gate #define	DECLARE_ASN1_ENCODE_FUNCTIONS_const(type, name) \
3050Sstevel@tonic-gate 	type *d2i_##name(type **a, const unsigned char **in, long len); \
3060Sstevel@tonic-gate 	int i2d_##name(const type *a, unsigned char **out); \
3070Sstevel@tonic-gate 	DECLARE_ASN1_ITEM(name)
3080Sstevel@tonic-gate 
3092139Sjp161948 #define	DECLARE_ASN1_NDEF_FUNCTION(name) \
3102139Sjp161948 	int i2d_##name##_NDEF(name *a, unsigned char **out);
3112139Sjp161948 
3120Sstevel@tonic-gate #define DECLARE_ASN1_FUNCTIONS_const(name) \
3130Sstevel@tonic-gate 	name *name##_new(void); \
3140Sstevel@tonic-gate 	void name##_free(name *a);
3150Sstevel@tonic-gate 
3162139Sjp161948 #define DECLARE_ASN1_ALLOC_FUNCTIONS_name(type, name) \
3172139Sjp161948 	type *name##_new(void); \
3182139Sjp161948 	void name##_free(type *a);
3192139Sjp161948 
3202139Sjp161948 #define D2I_OF(type) type *(*)(type **,const unsigned char **,long)
3212139Sjp161948 #define I2D_OF(type) int (*)(type *,unsigned char **)
3222139Sjp161948 #define I2D_OF_const(type) int (*)(const type *,unsigned char **)
3232139Sjp161948 
3242139Sjp161948 #define TYPEDEF_D2I_OF(type) typedef type *d2i_of_##type(type **,const unsigned char **,long)
3252139Sjp161948 #define TYPEDEF_I2D_OF(type) typedef int i2d_of_##type(type *,unsigned char **)
3262139Sjp161948 #define TYPEDEF_D2I2D_OF(type) TYPEDEF_D2I_OF(type); TYPEDEF_I2D_OF(type)
3272139Sjp161948 
3282139Sjp161948 TYPEDEF_D2I2D_OF(void);
3290Sstevel@tonic-gate 
3300Sstevel@tonic-gate /* The following macros and typedefs allow an ASN1_ITEM
3310Sstevel@tonic-gate  * to be embedded in a structure and referenced. Since
3320Sstevel@tonic-gate  * the ASN1_ITEM pointers need to be globally accessible
3330Sstevel@tonic-gate  * (possibly from shared libraries) they may exist in
3340Sstevel@tonic-gate  * different forms. On platforms that support it the
3350Sstevel@tonic-gate  * ASN1_ITEM structure itself will be globally exported.
3360Sstevel@tonic-gate  * Other platforms will export a function that returns
3370Sstevel@tonic-gate  * an ASN1_ITEM pointer.
3380Sstevel@tonic-gate  *
3390Sstevel@tonic-gate  * To handle both cases transparently the macros below
3400Sstevel@tonic-gate  * should be used instead of hard coding an ASN1_ITEM
3410Sstevel@tonic-gate  * pointer in a structure.
3420Sstevel@tonic-gate  *
3430Sstevel@tonic-gate  * The structure will look like this:
3440Sstevel@tonic-gate  *
3450Sstevel@tonic-gate  * typedef struct SOMETHING_st {
3460Sstevel@tonic-gate  *      ...
3470Sstevel@tonic-gate  *      ASN1_ITEM_EXP *iptr;
3480Sstevel@tonic-gate  *      ...
3490Sstevel@tonic-gate  * } SOMETHING;
3500Sstevel@tonic-gate  *
3510Sstevel@tonic-gate  * It would be initialised as e.g.:
3520Sstevel@tonic-gate  *
3530Sstevel@tonic-gate  * SOMETHING somevar = {...,ASN1_ITEM_ref(X509),...};
3540Sstevel@tonic-gate  *
3550Sstevel@tonic-gate  * and the actual pointer extracted with:
3560Sstevel@tonic-gate  *
3570Sstevel@tonic-gate  * const ASN1_ITEM *it = ASN1_ITEM_ptr(somevar.iptr);
3580Sstevel@tonic-gate  *
3590Sstevel@tonic-gate  * Finally an ASN1_ITEM pointer can be extracted from an
3600Sstevel@tonic-gate  * appropriate reference with: ASN1_ITEM_rptr(X509). This
3610Sstevel@tonic-gate  * would be used when a function takes an ASN1_ITEM * argument.
3620Sstevel@tonic-gate  *
3630Sstevel@tonic-gate  */
3640Sstevel@tonic-gate 
3650Sstevel@tonic-gate #ifndef OPENSSL_EXPORT_VAR_AS_FUNCTION
3660Sstevel@tonic-gate 
3670Sstevel@tonic-gate /* ASN1_ITEM pointer exported type */
3680Sstevel@tonic-gate typedef const ASN1_ITEM ASN1_ITEM_EXP;
3690Sstevel@tonic-gate 
3700Sstevel@tonic-gate /* Macro to obtain ASN1_ITEM pointer from exported type */
3710Sstevel@tonic-gate #define ASN1_ITEM_ptr(iptr) (iptr)
3720Sstevel@tonic-gate 
3730Sstevel@tonic-gate /* Macro to include ASN1_ITEM pointer from base type */
3740Sstevel@tonic-gate #define ASN1_ITEM_ref(iptr) (&(iptr##_it))
3750Sstevel@tonic-gate 
3760Sstevel@tonic-gate #define ASN1_ITEM_rptr(ref) (&(ref##_it))
3770Sstevel@tonic-gate 
3780Sstevel@tonic-gate #define DECLARE_ASN1_ITEM(name) \
3790Sstevel@tonic-gate 	OPENSSL_EXTERN const ASN1_ITEM name##_it;
3800Sstevel@tonic-gate 
3810Sstevel@tonic-gate #else
3820Sstevel@tonic-gate 
3830Sstevel@tonic-gate /* Platforms that can't easily handle shared global variables are declared
3840Sstevel@tonic-gate  * as functions returning ASN1_ITEM pointers.
3850Sstevel@tonic-gate  */
3860Sstevel@tonic-gate 
3870Sstevel@tonic-gate /* ASN1_ITEM pointer exported type */
3880Sstevel@tonic-gate typedef const ASN1_ITEM * ASN1_ITEM_EXP(void);
3890Sstevel@tonic-gate 
3900Sstevel@tonic-gate /* Macro to obtain ASN1_ITEM pointer from exported type */
3910Sstevel@tonic-gate #define ASN1_ITEM_ptr(iptr) (iptr())
3920Sstevel@tonic-gate 
3930Sstevel@tonic-gate /* Macro to include ASN1_ITEM pointer from base type */
3940Sstevel@tonic-gate #define ASN1_ITEM_ref(iptr) (iptr##_it)
3950Sstevel@tonic-gate 
3960Sstevel@tonic-gate #define ASN1_ITEM_rptr(ref) (ref##_it())
3970Sstevel@tonic-gate 
3980Sstevel@tonic-gate #define DECLARE_ASN1_ITEM(name) \
3990Sstevel@tonic-gate 	const ASN1_ITEM * name##_it(void);
4000Sstevel@tonic-gate 
4010Sstevel@tonic-gate #endif
4020Sstevel@tonic-gate 
4030Sstevel@tonic-gate /* Parameters used by ASN1_STRING_print_ex() */
4040Sstevel@tonic-gate 
4050Sstevel@tonic-gate /* These determine which characters to escape:
4060Sstevel@tonic-gate  * RFC2253 special characters, control characters and
4070Sstevel@tonic-gate  * MSB set characters
4080Sstevel@tonic-gate  */
4090Sstevel@tonic-gate 
4100Sstevel@tonic-gate #define ASN1_STRFLGS_ESC_2253		1
4110Sstevel@tonic-gate #define ASN1_STRFLGS_ESC_CTRL		2
4120Sstevel@tonic-gate #define ASN1_STRFLGS_ESC_MSB		4
4130Sstevel@tonic-gate 
4140Sstevel@tonic-gate 
4150Sstevel@tonic-gate /* This flag determines how we do escaping: normally
4160Sstevel@tonic-gate  * RC2253 backslash only, set this to use backslash and
4170Sstevel@tonic-gate  * quote.
4180Sstevel@tonic-gate  */
4190Sstevel@tonic-gate 
4200Sstevel@tonic-gate #define ASN1_STRFLGS_ESC_QUOTE		8
4210Sstevel@tonic-gate 
4220Sstevel@tonic-gate 
4230Sstevel@tonic-gate /* These three flags are internal use only. */
4240Sstevel@tonic-gate 
4250Sstevel@tonic-gate /* Character is a valid PrintableString character */
4260Sstevel@tonic-gate #define CHARTYPE_PRINTABLESTRING	0x10
4270Sstevel@tonic-gate /* Character needs escaping if it is the first character */
4280Sstevel@tonic-gate #define CHARTYPE_FIRST_ESC_2253		0x20
4290Sstevel@tonic-gate /* Character needs escaping if it is the last character */
4300Sstevel@tonic-gate #define CHARTYPE_LAST_ESC_2253		0x40
4310Sstevel@tonic-gate 
4320Sstevel@tonic-gate /* NB the internal flags are safely reused below by flags
4330Sstevel@tonic-gate  * handled at the top level.
4340Sstevel@tonic-gate  */
4350Sstevel@tonic-gate 
4360Sstevel@tonic-gate /* If this is set we convert all character strings
4370Sstevel@tonic-gate  * to UTF8 first
4380Sstevel@tonic-gate  */
4390Sstevel@tonic-gate 
4400Sstevel@tonic-gate #define ASN1_STRFLGS_UTF8_CONVERT	0x10
4410Sstevel@tonic-gate 
4420Sstevel@tonic-gate /* If this is set we don't attempt to interpret content:
4430Sstevel@tonic-gate  * just assume all strings are 1 byte per character. This
4440Sstevel@tonic-gate  * will produce some pretty odd looking output!
4450Sstevel@tonic-gate  */
4460Sstevel@tonic-gate 
4470Sstevel@tonic-gate #define ASN1_STRFLGS_IGNORE_TYPE	0x20
4480Sstevel@tonic-gate 
4490Sstevel@tonic-gate /* If this is set we include the string type in the output */
4500Sstevel@tonic-gate #define ASN1_STRFLGS_SHOW_TYPE		0x40
4510Sstevel@tonic-gate 
4520Sstevel@tonic-gate /* This determines which strings to display and which to
4530Sstevel@tonic-gate  * 'dump' (hex dump of content octets or DER encoding). We can
4540Sstevel@tonic-gate  * only dump non character strings or everything. If we
4550Sstevel@tonic-gate  * don't dump 'unknown' they are interpreted as character
4560Sstevel@tonic-gate  * strings with 1 octet per character and are subject to
4570Sstevel@tonic-gate  * the usual escaping options.
4580Sstevel@tonic-gate  */
4590Sstevel@tonic-gate 
4600Sstevel@tonic-gate #define ASN1_STRFLGS_DUMP_ALL		0x80
4610Sstevel@tonic-gate #define ASN1_STRFLGS_DUMP_UNKNOWN	0x100
4620Sstevel@tonic-gate 
4630Sstevel@tonic-gate /* These determine what 'dumping' does, we can dump the
4640Sstevel@tonic-gate  * content octets or the DER encoding: both use the
4650Sstevel@tonic-gate  * RFC2253 #XXXXX notation.
4660Sstevel@tonic-gate  */
4670Sstevel@tonic-gate 
4680Sstevel@tonic-gate #define ASN1_STRFLGS_DUMP_DER		0x200
4690Sstevel@tonic-gate 
4700Sstevel@tonic-gate /* All the string flags consistent with RFC2253,
4710Sstevel@tonic-gate  * escaping control characters isn't essential in
4720Sstevel@tonic-gate  * RFC2253 but it is advisable anyway.
4730Sstevel@tonic-gate  */
4740Sstevel@tonic-gate 
4750Sstevel@tonic-gate #define ASN1_STRFLGS_RFC2253	(ASN1_STRFLGS_ESC_2253 | \
4760Sstevel@tonic-gate 				ASN1_STRFLGS_ESC_CTRL | \
4770Sstevel@tonic-gate 				ASN1_STRFLGS_ESC_MSB | \
4780Sstevel@tonic-gate 				ASN1_STRFLGS_UTF8_CONVERT | \
4790Sstevel@tonic-gate 				ASN1_STRFLGS_DUMP_UNKNOWN | \
4800Sstevel@tonic-gate 				ASN1_STRFLGS_DUMP_DER)
4810Sstevel@tonic-gate 
4820Sstevel@tonic-gate DECLARE_STACK_OF(ASN1_INTEGER)
4830Sstevel@tonic-gate DECLARE_ASN1_SET_OF(ASN1_INTEGER)
4840Sstevel@tonic-gate 
4850Sstevel@tonic-gate DECLARE_STACK_OF(ASN1_GENERALSTRING)
4860Sstevel@tonic-gate 
4870Sstevel@tonic-gate typedef struct asn1_type_st
4880Sstevel@tonic-gate 	{
4890Sstevel@tonic-gate 	int type;
4900Sstevel@tonic-gate 	union	{
4910Sstevel@tonic-gate 		char *ptr;
4920Sstevel@tonic-gate 		ASN1_BOOLEAN		boolean;
4930Sstevel@tonic-gate 		ASN1_STRING *		asn1_string;
4940Sstevel@tonic-gate 		ASN1_OBJECT *		object;
4950Sstevel@tonic-gate 		ASN1_INTEGER *		integer;
4960Sstevel@tonic-gate 		ASN1_ENUMERATED *	enumerated;
4970Sstevel@tonic-gate 		ASN1_BIT_STRING *	bit_string;
4980Sstevel@tonic-gate 		ASN1_OCTET_STRING *	octet_string;
4990Sstevel@tonic-gate 		ASN1_PRINTABLESTRING *	printablestring;
5000Sstevel@tonic-gate 		ASN1_T61STRING *	t61string;
5010Sstevel@tonic-gate 		ASN1_IA5STRING *	ia5string;
5020Sstevel@tonic-gate 		ASN1_GENERALSTRING *	generalstring;
5030Sstevel@tonic-gate 		ASN1_BMPSTRING *	bmpstring;
5040Sstevel@tonic-gate 		ASN1_UNIVERSALSTRING *	universalstring;
5050Sstevel@tonic-gate 		ASN1_UTCTIME *		utctime;
5060Sstevel@tonic-gate 		ASN1_GENERALIZEDTIME *	generalizedtime;
5070Sstevel@tonic-gate 		ASN1_VISIBLESTRING *	visiblestring;
5080Sstevel@tonic-gate 		ASN1_UTF8STRING *	utf8string;
5090Sstevel@tonic-gate 		/* set and sequence are left complete and still
5100Sstevel@tonic-gate 		 * contain the set or sequence bytes */
5110Sstevel@tonic-gate 		ASN1_STRING *		set;
5120Sstevel@tonic-gate 		ASN1_STRING *		sequence;
5130Sstevel@tonic-gate 		} value;
5140Sstevel@tonic-gate 	} ASN1_TYPE;
5150Sstevel@tonic-gate 
5160Sstevel@tonic-gate DECLARE_STACK_OF(ASN1_TYPE)
5170Sstevel@tonic-gate DECLARE_ASN1_SET_OF(ASN1_TYPE)
5180Sstevel@tonic-gate 
5190Sstevel@tonic-gate typedef struct asn1_method_st
5200Sstevel@tonic-gate 	{
5212139Sjp161948 	i2d_of_void *i2d;
5222139Sjp161948 	d2i_of_void *d2i;
5232139Sjp161948 	void *(*create)(void);
5242139Sjp161948 	void (*destroy)(void *);
5250Sstevel@tonic-gate 	} ASN1_METHOD;
5260Sstevel@tonic-gate 
5270Sstevel@tonic-gate /* This is used when parsing some Netscape objects */
5280Sstevel@tonic-gate typedef struct asn1_header_st
5290Sstevel@tonic-gate 	{
5300Sstevel@tonic-gate 	ASN1_OCTET_STRING *header;
5312139Sjp161948 	void *data;
5320Sstevel@tonic-gate 	ASN1_METHOD *meth;
5330Sstevel@tonic-gate 	} ASN1_HEADER;
5340Sstevel@tonic-gate 
5350Sstevel@tonic-gate /* This is used to contain a list of bit names */
5360Sstevel@tonic-gate typedef struct BIT_STRING_BITNAME_st {
5370Sstevel@tonic-gate 	int bitnum;
5380Sstevel@tonic-gate 	const char *lname;
5390Sstevel@tonic-gate 	const char *sname;
5400Sstevel@tonic-gate } BIT_STRING_BITNAME;
5410Sstevel@tonic-gate 
5420Sstevel@tonic-gate 
5430Sstevel@tonic-gate #define M_ASN1_STRING_length(x)	((x)->length)
5440Sstevel@tonic-gate #define M_ASN1_STRING_length_set(x, n)	((x)->length = (n))
5450Sstevel@tonic-gate #define M_ASN1_STRING_type(x)	((x)->type)
5460Sstevel@tonic-gate #define M_ASN1_STRING_data(x)	((x)->data)
5470Sstevel@tonic-gate 
5480Sstevel@tonic-gate /* Macros for string operations */
5490Sstevel@tonic-gate #define M_ASN1_BIT_STRING_new()	(ASN1_BIT_STRING *)\
5500Sstevel@tonic-gate 		ASN1_STRING_type_new(V_ASN1_BIT_STRING)
5510Sstevel@tonic-gate #define M_ASN1_BIT_STRING_free(a)	ASN1_STRING_free((ASN1_STRING *)a)
5520Sstevel@tonic-gate #define M_ASN1_BIT_STRING_dup(a) (ASN1_BIT_STRING *)\
5530Sstevel@tonic-gate 		ASN1_STRING_dup((ASN1_STRING *)a)
5540Sstevel@tonic-gate #define M_ASN1_BIT_STRING_cmp(a,b) ASN1_STRING_cmp(\
5550Sstevel@tonic-gate 		(ASN1_STRING *)a,(ASN1_STRING *)b)
5560Sstevel@tonic-gate #define M_ASN1_BIT_STRING_set(a,b,c) ASN1_STRING_set((ASN1_STRING *)a,b,c)
5570Sstevel@tonic-gate 
5580Sstevel@tonic-gate #define M_ASN1_INTEGER_new()	(ASN1_INTEGER *)\
5590Sstevel@tonic-gate 		ASN1_STRING_type_new(V_ASN1_INTEGER)
5600Sstevel@tonic-gate #define M_ASN1_INTEGER_free(a)		ASN1_STRING_free((ASN1_STRING *)a)
5610Sstevel@tonic-gate #define M_ASN1_INTEGER_dup(a) (ASN1_INTEGER *)ASN1_STRING_dup((ASN1_STRING *)a)
5620Sstevel@tonic-gate #define M_ASN1_INTEGER_cmp(a,b)	ASN1_STRING_cmp(\
5630Sstevel@tonic-gate 		(ASN1_STRING *)a,(ASN1_STRING *)b)
5640Sstevel@tonic-gate 
5650Sstevel@tonic-gate #define M_ASN1_ENUMERATED_new()	(ASN1_ENUMERATED *)\
5660Sstevel@tonic-gate 		ASN1_STRING_type_new(V_ASN1_ENUMERATED)
5670Sstevel@tonic-gate #define M_ASN1_ENUMERATED_free(a)	ASN1_STRING_free((ASN1_STRING *)a)
5680Sstevel@tonic-gate #define M_ASN1_ENUMERATED_dup(a) (ASN1_ENUMERATED *)ASN1_STRING_dup((ASN1_STRING *)a)
5690Sstevel@tonic-gate #define M_ASN1_ENUMERATED_cmp(a,b)	ASN1_STRING_cmp(\
5700Sstevel@tonic-gate 		(ASN1_STRING *)a,(ASN1_STRING *)b)
5710Sstevel@tonic-gate 
5720Sstevel@tonic-gate #define M_ASN1_OCTET_STRING_new()	(ASN1_OCTET_STRING *)\
5730Sstevel@tonic-gate 		ASN1_STRING_type_new(V_ASN1_OCTET_STRING)
5740Sstevel@tonic-gate #define M_ASN1_OCTET_STRING_free(a)	ASN1_STRING_free((ASN1_STRING *)a)
5750Sstevel@tonic-gate #define M_ASN1_OCTET_STRING_dup(a) (ASN1_OCTET_STRING *)\
5760Sstevel@tonic-gate 		ASN1_STRING_dup((ASN1_STRING *)a)
5770Sstevel@tonic-gate #define M_ASN1_OCTET_STRING_cmp(a,b) ASN1_STRING_cmp(\
5780Sstevel@tonic-gate 		(ASN1_STRING *)a,(ASN1_STRING *)b)
5790Sstevel@tonic-gate #define M_ASN1_OCTET_STRING_set(a,b,c)	ASN1_STRING_set((ASN1_STRING *)a,b,c)
5800Sstevel@tonic-gate #define M_ASN1_OCTET_STRING_print(a,b)	ASN1_STRING_print(a,(ASN1_STRING *)b)
5810Sstevel@tonic-gate #define M_i2d_ASN1_OCTET_STRING(a,pp) \
5820Sstevel@tonic-gate 		i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_OCTET_STRING,\
5830Sstevel@tonic-gate 		V_ASN1_UNIVERSAL)
5840Sstevel@tonic-gate 
5850Sstevel@tonic-gate #define B_ASN1_TIME \
5860Sstevel@tonic-gate 			B_ASN1_UTCTIME | \
5870Sstevel@tonic-gate 			B_ASN1_GENERALIZEDTIME
5880Sstevel@tonic-gate 
5890Sstevel@tonic-gate #define B_ASN1_PRINTABLE \
5900Sstevel@tonic-gate 			B_ASN1_PRINTABLESTRING| \
5910Sstevel@tonic-gate 			B_ASN1_T61STRING| \
5920Sstevel@tonic-gate 			B_ASN1_IA5STRING| \
5930Sstevel@tonic-gate 			B_ASN1_BIT_STRING| \
5940Sstevel@tonic-gate 			B_ASN1_UNIVERSALSTRING|\
5950Sstevel@tonic-gate 			B_ASN1_BMPSTRING|\
5960Sstevel@tonic-gate 			B_ASN1_UTF8STRING|\
5970Sstevel@tonic-gate 			B_ASN1_UNKNOWN
5980Sstevel@tonic-gate 
5990Sstevel@tonic-gate #define B_ASN1_DIRECTORYSTRING \
6000Sstevel@tonic-gate 			B_ASN1_PRINTABLESTRING| \
6010Sstevel@tonic-gate 			B_ASN1_TELETEXSTRING|\
6020Sstevel@tonic-gate 			B_ASN1_BMPSTRING|\
6030Sstevel@tonic-gate 			B_ASN1_UNIVERSALSTRING|\
6040Sstevel@tonic-gate 			B_ASN1_UTF8STRING
6050Sstevel@tonic-gate 
6060Sstevel@tonic-gate #define B_ASN1_DISPLAYTEXT \
6070Sstevel@tonic-gate 			B_ASN1_IA5STRING| \
6080Sstevel@tonic-gate 			B_ASN1_VISIBLESTRING| \
6090Sstevel@tonic-gate 			B_ASN1_BMPSTRING|\
6100Sstevel@tonic-gate 			B_ASN1_UTF8STRING
6110Sstevel@tonic-gate 
6120Sstevel@tonic-gate #define M_ASN1_PRINTABLE_new()	ASN1_STRING_type_new(V_ASN1_T61STRING)
6130Sstevel@tonic-gate #define M_ASN1_PRINTABLE_free(a)	ASN1_STRING_free((ASN1_STRING *)a)
6140Sstevel@tonic-gate #define M_i2d_ASN1_PRINTABLE(a,pp) i2d_ASN1_bytes((ASN1_STRING *)a,\
6150Sstevel@tonic-gate 		pp,a->type,V_ASN1_UNIVERSAL)
6160Sstevel@tonic-gate #define M_d2i_ASN1_PRINTABLE(a,pp,l) \
6170Sstevel@tonic-gate 		d2i_ASN1_type_bytes((ASN1_STRING **)a,pp,l, \
6180Sstevel@tonic-gate 			B_ASN1_PRINTABLE)
6190Sstevel@tonic-gate 
6200Sstevel@tonic-gate #define M_DIRECTORYSTRING_new() ASN1_STRING_type_new(V_ASN1_PRINTABLESTRING)
6210Sstevel@tonic-gate #define M_DIRECTORYSTRING_free(a)	ASN1_STRING_free((ASN1_STRING *)a)
6220Sstevel@tonic-gate #define M_i2d_DIRECTORYSTRING(a,pp) i2d_ASN1_bytes((ASN1_STRING *)a,\
6230Sstevel@tonic-gate 						pp,a->type,V_ASN1_UNIVERSAL)
6240Sstevel@tonic-gate #define M_d2i_DIRECTORYSTRING(a,pp,l) \
6250Sstevel@tonic-gate 		d2i_ASN1_type_bytes((ASN1_STRING **)a,pp,l, \
6260Sstevel@tonic-gate 			B_ASN1_DIRECTORYSTRING)
6270Sstevel@tonic-gate 
6280Sstevel@tonic-gate #define M_DISPLAYTEXT_new() ASN1_STRING_type_new(V_ASN1_VISIBLESTRING)
6290Sstevel@tonic-gate #define M_DISPLAYTEXT_free(a) ASN1_STRING_free((ASN1_STRING *)a)
6300Sstevel@tonic-gate #define M_i2d_DISPLAYTEXT(a,pp) i2d_ASN1_bytes((ASN1_STRING *)a,\
6310Sstevel@tonic-gate 						pp,a->type,V_ASN1_UNIVERSAL)
6320Sstevel@tonic-gate #define M_d2i_DISPLAYTEXT(a,pp,l) \
6330Sstevel@tonic-gate 		d2i_ASN1_type_bytes((ASN1_STRING **)a,pp,l, \
6340Sstevel@tonic-gate 			B_ASN1_DISPLAYTEXT)
6350Sstevel@tonic-gate 
6360Sstevel@tonic-gate #define M_ASN1_PRINTABLESTRING_new() (ASN1_PRINTABLESTRING *)\
6370Sstevel@tonic-gate 		ASN1_STRING_type_new(V_ASN1_PRINTABLESTRING)
6380Sstevel@tonic-gate #define M_ASN1_PRINTABLESTRING_free(a)	ASN1_STRING_free((ASN1_STRING *)a)
6390Sstevel@tonic-gate #define M_i2d_ASN1_PRINTABLESTRING(a,pp) \
6400Sstevel@tonic-gate 		i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_PRINTABLESTRING,\
6410Sstevel@tonic-gate 		V_ASN1_UNIVERSAL)
6420Sstevel@tonic-gate #define M_d2i_ASN1_PRINTABLESTRING(a,pp,l) \
6430Sstevel@tonic-gate 		(ASN1_PRINTABLESTRING *)d2i_ASN1_type_bytes\
6440Sstevel@tonic-gate 		((ASN1_STRING **)a,pp,l,B_ASN1_PRINTABLESTRING)
6450Sstevel@tonic-gate 
6460Sstevel@tonic-gate #define M_ASN1_T61STRING_new()	(ASN1_T61STRING *)\
6470Sstevel@tonic-gate 		ASN1_STRING_type_new(V_ASN1_T61STRING)
6480Sstevel@tonic-gate #define M_ASN1_T61STRING_free(a)	ASN1_STRING_free((ASN1_STRING *)a)
6490Sstevel@tonic-gate #define M_i2d_ASN1_T61STRING(a,pp) \
6500Sstevel@tonic-gate 		i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_T61STRING,\
6510Sstevel@tonic-gate 		V_ASN1_UNIVERSAL)
6520Sstevel@tonic-gate #define M_d2i_ASN1_T61STRING(a,pp,l) \
6530Sstevel@tonic-gate 		(ASN1_T61STRING *)d2i_ASN1_type_bytes\
6540Sstevel@tonic-gate 		((ASN1_STRING **)a,pp,l,B_ASN1_T61STRING)
6550Sstevel@tonic-gate 
6560Sstevel@tonic-gate #define M_ASN1_IA5STRING_new()	(ASN1_IA5STRING *)\
6570Sstevel@tonic-gate 		ASN1_STRING_type_new(V_ASN1_IA5STRING)
6580Sstevel@tonic-gate #define M_ASN1_IA5STRING_free(a)	ASN1_STRING_free((ASN1_STRING *)a)
6590Sstevel@tonic-gate #define M_ASN1_IA5STRING_dup(a)	\
6600Sstevel@tonic-gate 			(ASN1_IA5STRING *)ASN1_STRING_dup((ASN1_STRING *)a)
6610Sstevel@tonic-gate #define M_i2d_ASN1_IA5STRING(a,pp) \
6620Sstevel@tonic-gate 		i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_IA5STRING,\
6630Sstevel@tonic-gate 			V_ASN1_UNIVERSAL)
6640Sstevel@tonic-gate #define M_d2i_ASN1_IA5STRING(a,pp,l) \
6650Sstevel@tonic-gate 		(ASN1_IA5STRING *)d2i_ASN1_type_bytes((ASN1_STRING **)a,pp,l,\
6660Sstevel@tonic-gate 			B_ASN1_IA5STRING)
6670Sstevel@tonic-gate 
6680Sstevel@tonic-gate #define M_ASN1_UTCTIME_new()	(ASN1_UTCTIME *)\
6690Sstevel@tonic-gate 		ASN1_STRING_type_new(V_ASN1_UTCTIME)
6700Sstevel@tonic-gate #define M_ASN1_UTCTIME_free(a)	ASN1_STRING_free((ASN1_STRING *)a)
6710Sstevel@tonic-gate #define M_ASN1_UTCTIME_dup(a) (ASN1_UTCTIME *)ASN1_STRING_dup((ASN1_STRING *)a)
6720Sstevel@tonic-gate 
6730Sstevel@tonic-gate #define M_ASN1_GENERALIZEDTIME_new()	(ASN1_GENERALIZEDTIME *)\
6740Sstevel@tonic-gate 		ASN1_STRING_type_new(V_ASN1_GENERALIZEDTIME)
6750Sstevel@tonic-gate #define M_ASN1_GENERALIZEDTIME_free(a)	ASN1_STRING_free((ASN1_STRING *)a)
6760Sstevel@tonic-gate #define M_ASN1_GENERALIZEDTIME_dup(a) (ASN1_GENERALIZEDTIME *)ASN1_STRING_dup(\
6770Sstevel@tonic-gate 	(ASN1_STRING *)a)
6780Sstevel@tonic-gate 
6790Sstevel@tonic-gate #define M_ASN1_TIME_new()	(ASN1_TIME *)\
6800Sstevel@tonic-gate 		ASN1_STRING_type_new(V_ASN1_UTCTIME)
6810Sstevel@tonic-gate #define M_ASN1_TIME_free(a)	ASN1_STRING_free((ASN1_STRING *)a)
6820Sstevel@tonic-gate #define M_ASN1_TIME_dup(a) (ASN1_TIME *)ASN1_STRING_dup((ASN1_STRING *)a)
6830Sstevel@tonic-gate 
6840Sstevel@tonic-gate #define M_ASN1_GENERALSTRING_new()	(ASN1_GENERALSTRING *)\
6850Sstevel@tonic-gate 		ASN1_STRING_type_new(V_ASN1_GENERALSTRING)
6860Sstevel@tonic-gate #define M_ASN1_GENERALSTRING_free(a)	ASN1_STRING_free((ASN1_STRING *)a)
6870Sstevel@tonic-gate #define M_i2d_ASN1_GENERALSTRING(a,pp) \
6880Sstevel@tonic-gate 		i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_GENERALSTRING,\
6890Sstevel@tonic-gate 			V_ASN1_UNIVERSAL)
6900Sstevel@tonic-gate #define M_d2i_ASN1_GENERALSTRING(a,pp,l) \
6910Sstevel@tonic-gate 		(ASN1_GENERALSTRING *)d2i_ASN1_type_bytes\
6920Sstevel@tonic-gate 		((ASN1_STRING **)a,pp,l,B_ASN1_GENERALSTRING)
6930Sstevel@tonic-gate 
6940Sstevel@tonic-gate #define M_ASN1_UNIVERSALSTRING_new()	(ASN1_UNIVERSALSTRING *)\
6950Sstevel@tonic-gate 		ASN1_STRING_type_new(V_ASN1_UNIVERSALSTRING)
6960Sstevel@tonic-gate #define M_ASN1_UNIVERSALSTRING_free(a)	ASN1_STRING_free((ASN1_STRING *)a)
6970Sstevel@tonic-gate #define M_i2d_ASN1_UNIVERSALSTRING(a,pp) \
6980Sstevel@tonic-gate 		i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_UNIVERSALSTRING,\
6990Sstevel@tonic-gate 			V_ASN1_UNIVERSAL)
7000Sstevel@tonic-gate #define M_d2i_ASN1_UNIVERSALSTRING(a,pp,l) \
7010Sstevel@tonic-gate 		(ASN1_UNIVERSALSTRING *)d2i_ASN1_type_bytes\
7020Sstevel@tonic-gate 		((ASN1_STRING **)a,pp,l,B_ASN1_UNIVERSALSTRING)
7030Sstevel@tonic-gate 
7040Sstevel@tonic-gate #define M_ASN1_BMPSTRING_new()	(ASN1_BMPSTRING *)\
7050Sstevel@tonic-gate 		ASN1_STRING_type_new(V_ASN1_BMPSTRING)
7060Sstevel@tonic-gate #define M_ASN1_BMPSTRING_free(a)	ASN1_STRING_free((ASN1_STRING *)a)
7070Sstevel@tonic-gate #define M_i2d_ASN1_BMPSTRING(a,pp) \
7080Sstevel@tonic-gate 		i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_BMPSTRING,\
7090Sstevel@tonic-gate 			V_ASN1_UNIVERSAL)
7100Sstevel@tonic-gate #define M_d2i_ASN1_BMPSTRING(a,pp,l) \
7110Sstevel@tonic-gate 		(ASN1_BMPSTRING *)d2i_ASN1_type_bytes\
7120Sstevel@tonic-gate 		((ASN1_STRING **)a,pp,l,B_ASN1_BMPSTRING)
7130Sstevel@tonic-gate 
7140Sstevel@tonic-gate #define M_ASN1_VISIBLESTRING_new()	(ASN1_VISIBLESTRING *)\
7150Sstevel@tonic-gate 		ASN1_STRING_type_new(V_ASN1_VISIBLESTRING)
7160Sstevel@tonic-gate #define M_ASN1_VISIBLESTRING_free(a)	ASN1_STRING_free((ASN1_STRING *)a)
7170Sstevel@tonic-gate #define M_i2d_ASN1_VISIBLESTRING(a,pp) \
7180Sstevel@tonic-gate 		i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_VISIBLESTRING,\
7190Sstevel@tonic-gate 			V_ASN1_UNIVERSAL)
7200Sstevel@tonic-gate #define M_d2i_ASN1_VISIBLESTRING(a,pp,l) \
7210Sstevel@tonic-gate 		(ASN1_VISIBLESTRING *)d2i_ASN1_type_bytes\
7220Sstevel@tonic-gate 		((ASN1_STRING **)a,pp,l,B_ASN1_VISIBLESTRING)
7230Sstevel@tonic-gate 
7240Sstevel@tonic-gate #define M_ASN1_UTF8STRING_new()	(ASN1_UTF8STRING *)\
7250Sstevel@tonic-gate 		ASN1_STRING_type_new(V_ASN1_UTF8STRING)
7260Sstevel@tonic-gate #define M_ASN1_UTF8STRING_free(a)	ASN1_STRING_free((ASN1_STRING *)a)
7270Sstevel@tonic-gate #define M_i2d_ASN1_UTF8STRING(a,pp) \
7280Sstevel@tonic-gate 		i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_UTF8STRING,\
7290Sstevel@tonic-gate 			V_ASN1_UNIVERSAL)
7300Sstevel@tonic-gate #define M_d2i_ASN1_UTF8STRING(a,pp,l) \
7310Sstevel@tonic-gate 		(ASN1_UTF8STRING *)d2i_ASN1_type_bytes\
7320Sstevel@tonic-gate 		((ASN1_STRING **)a,pp,l,B_ASN1_UTF8STRING)
7330Sstevel@tonic-gate 
7340Sstevel@tonic-gate   /* for the is_set parameter to i2d_ASN1_SET */
7350Sstevel@tonic-gate #define IS_SEQUENCE	0
7360Sstevel@tonic-gate #define IS_SET		1
7370Sstevel@tonic-gate 
7380Sstevel@tonic-gate DECLARE_ASN1_FUNCTIONS_fname(ASN1_TYPE, ASN1_ANY, ASN1_TYPE)
7390Sstevel@tonic-gate 
7400Sstevel@tonic-gate int ASN1_TYPE_get(ASN1_TYPE *a);
7410Sstevel@tonic-gate void ASN1_TYPE_set(ASN1_TYPE *a, int type, void *value);
7420Sstevel@tonic-gate 
7430Sstevel@tonic-gate ASN1_OBJECT *	ASN1_OBJECT_new(void );
7440Sstevel@tonic-gate void		ASN1_OBJECT_free(ASN1_OBJECT *a);
7450Sstevel@tonic-gate int		i2d_ASN1_OBJECT(ASN1_OBJECT *a,unsigned char **pp);
7462139Sjp161948 ASN1_OBJECT *	c2i_ASN1_OBJECT(ASN1_OBJECT **a,const unsigned char **pp,
7470Sstevel@tonic-gate 			long length);
7482139Sjp161948 ASN1_OBJECT *	d2i_ASN1_OBJECT(ASN1_OBJECT **a,const unsigned char **pp,
7490Sstevel@tonic-gate 			long length);
7500Sstevel@tonic-gate 
7510Sstevel@tonic-gate DECLARE_ASN1_ITEM(ASN1_OBJECT)
7520Sstevel@tonic-gate 
7530Sstevel@tonic-gate DECLARE_STACK_OF(ASN1_OBJECT)
7540Sstevel@tonic-gate DECLARE_ASN1_SET_OF(ASN1_OBJECT)
7550Sstevel@tonic-gate 
7560Sstevel@tonic-gate ASN1_STRING *	ASN1_STRING_new(void);
7570Sstevel@tonic-gate void		ASN1_STRING_free(ASN1_STRING *a);
7580Sstevel@tonic-gate ASN1_STRING *	ASN1_STRING_dup(ASN1_STRING *a);
7590Sstevel@tonic-gate ASN1_STRING *	ASN1_STRING_type_new(int type );
7600Sstevel@tonic-gate int 		ASN1_STRING_cmp(ASN1_STRING *a, ASN1_STRING *b);
7610Sstevel@tonic-gate   /* Since this is used to store all sorts of things, via macros, for now, make
7620Sstevel@tonic-gate      its data void * */
7630Sstevel@tonic-gate int 		ASN1_STRING_set(ASN1_STRING *str, const void *data, int len);
7640Sstevel@tonic-gate int ASN1_STRING_length(ASN1_STRING *x);
7650Sstevel@tonic-gate void ASN1_STRING_length_set(ASN1_STRING *x, int n);
7660Sstevel@tonic-gate int ASN1_STRING_type(ASN1_STRING *x);
7670Sstevel@tonic-gate unsigned char * ASN1_STRING_data(ASN1_STRING *x);
7680Sstevel@tonic-gate 
7690Sstevel@tonic-gate DECLARE_ASN1_FUNCTIONS(ASN1_BIT_STRING)
7700Sstevel@tonic-gate int		i2c_ASN1_BIT_STRING(ASN1_BIT_STRING *a,unsigned char **pp);
7712139Sjp161948 ASN1_BIT_STRING *c2i_ASN1_BIT_STRING(ASN1_BIT_STRING **a,const unsigned char **pp,
7720Sstevel@tonic-gate 			long length);
7730Sstevel@tonic-gate int		ASN1_BIT_STRING_set(ASN1_BIT_STRING *a, unsigned char *d,
7740Sstevel@tonic-gate 			int length );
7750Sstevel@tonic-gate int		ASN1_BIT_STRING_set_bit(ASN1_BIT_STRING *a, int n, int value);
7760Sstevel@tonic-gate int		ASN1_BIT_STRING_get_bit(ASN1_BIT_STRING *a, int n);
7770Sstevel@tonic-gate 
7780Sstevel@tonic-gate #ifndef OPENSSL_NO_BIO
7790Sstevel@tonic-gate int ASN1_BIT_STRING_name_print(BIO *out, ASN1_BIT_STRING *bs,
7800Sstevel@tonic-gate 				BIT_STRING_BITNAME *tbl, int indent);
7810Sstevel@tonic-gate #endif
7820Sstevel@tonic-gate int ASN1_BIT_STRING_num_asc(char *name, BIT_STRING_BITNAME *tbl);
7830Sstevel@tonic-gate int ASN1_BIT_STRING_set_asc(ASN1_BIT_STRING *bs, char *name, int value,
7840Sstevel@tonic-gate 				BIT_STRING_BITNAME *tbl);
7850Sstevel@tonic-gate 
7860Sstevel@tonic-gate int		i2d_ASN1_BOOLEAN(int a,unsigned char **pp);
7872139Sjp161948 int 		d2i_ASN1_BOOLEAN(int *a,const unsigned char **pp,long length);
7880Sstevel@tonic-gate 
7890Sstevel@tonic-gate DECLARE_ASN1_FUNCTIONS(ASN1_INTEGER)
7900Sstevel@tonic-gate int		i2c_ASN1_INTEGER(ASN1_INTEGER *a,unsigned char **pp);
7912139Sjp161948 ASN1_INTEGER *c2i_ASN1_INTEGER(ASN1_INTEGER **a,const unsigned char **pp,
7920Sstevel@tonic-gate 			long length);
7932139Sjp161948 ASN1_INTEGER *d2i_ASN1_UINTEGER(ASN1_INTEGER **a,const unsigned char **pp,
7940Sstevel@tonic-gate 			long length);
7950Sstevel@tonic-gate ASN1_INTEGER *	ASN1_INTEGER_dup(ASN1_INTEGER *x);
7960Sstevel@tonic-gate int ASN1_INTEGER_cmp(ASN1_INTEGER *x, ASN1_INTEGER *y);
7970Sstevel@tonic-gate 
7980Sstevel@tonic-gate DECLARE_ASN1_FUNCTIONS(ASN1_ENUMERATED)
7990Sstevel@tonic-gate 
8000Sstevel@tonic-gate int ASN1_UTCTIME_check(ASN1_UTCTIME *a);
8010Sstevel@tonic-gate ASN1_UTCTIME *ASN1_UTCTIME_set(ASN1_UTCTIME *s,time_t t);
8022139Sjp161948 int ASN1_UTCTIME_set_string(ASN1_UTCTIME *s, const char *str);
8030Sstevel@tonic-gate int ASN1_UTCTIME_cmp_time_t(const ASN1_UTCTIME *s, time_t t);
8040Sstevel@tonic-gate #if 0
8050Sstevel@tonic-gate time_t ASN1_UTCTIME_get(const ASN1_UTCTIME *s);
8060Sstevel@tonic-gate #endif
8070Sstevel@tonic-gate 
8080Sstevel@tonic-gate int ASN1_GENERALIZEDTIME_check(ASN1_GENERALIZEDTIME *a);
8090Sstevel@tonic-gate ASN1_GENERALIZEDTIME *ASN1_GENERALIZEDTIME_set(ASN1_GENERALIZEDTIME *s,time_t t);
8102139Sjp161948 int ASN1_GENERALIZEDTIME_set_string(ASN1_GENERALIZEDTIME *s, const char *str);
8110Sstevel@tonic-gate 
8120Sstevel@tonic-gate DECLARE_ASN1_FUNCTIONS(ASN1_OCTET_STRING)
8130Sstevel@tonic-gate ASN1_OCTET_STRING *	ASN1_OCTET_STRING_dup(ASN1_OCTET_STRING *a);
8140Sstevel@tonic-gate int 	ASN1_OCTET_STRING_cmp(ASN1_OCTET_STRING *a, ASN1_OCTET_STRING *b);
8152139Sjp161948 int 	ASN1_OCTET_STRING_set(ASN1_OCTET_STRING *str, const unsigned char *data, int len);
8160Sstevel@tonic-gate 
8170Sstevel@tonic-gate DECLARE_ASN1_FUNCTIONS(ASN1_VISIBLESTRING)
8180Sstevel@tonic-gate DECLARE_ASN1_FUNCTIONS(ASN1_UNIVERSALSTRING)
8190Sstevel@tonic-gate DECLARE_ASN1_FUNCTIONS(ASN1_UTF8STRING)
8200Sstevel@tonic-gate DECLARE_ASN1_FUNCTIONS(ASN1_NULL)
8210Sstevel@tonic-gate DECLARE_ASN1_FUNCTIONS(ASN1_BMPSTRING)
8220Sstevel@tonic-gate 
8230Sstevel@tonic-gate int UTF8_getc(const unsigned char *str, int len, unsigned long *val);
8240Sstevel@tonic-gate int UTF8_putc(unsigned char *str, int len, unsigned long value);
8250Sstevel@tonic-gate 
8260Sstevel@tonic-gate DECLARE_ASN1_FUNCTIONS_name(ASN1_STRING, ASN1_PRINTABLE)
8270Sstevel@tonic-gate 
8280Sstevel@tonic-gate DECLARE_ASN1_FUNCTIONS_name(ASN1_STRING, DIRECTORYSTRING)
8290Sstevel@tonic-gate DECLARE_ASN1_FUNCTIONS_name(ASN1_STRING, DISPLAYTEXT)
8300Sstevel@tonic-gate DECLARE_ASN1_FUNCTIONS(ASN1_PRINTABLESTRING)
8310Sstevel@tonic-gate DECLARE_ASN1_FUNCTIONS(ASN1_T61STRING)
8320Sstevel@tonic-gate DECLARE_ASN1_FUNCTIONS(ASN1_IA5STRING)
8330Sstevel@tonic-gate DECLARE_ASN1_FUNCTIONS(ASN1_GENERALSTRING)
8340Sstevel@tonic-gate DECLARE_ASN1_FUNCTIONS(ASN1_UTCTIME)
8350Sstevel@tonic-gate DECLARE_ASN1_FUNCTIONS(ASN1_GENERALIZEDTIME)
8360Sstevel@tonic-gate DECLARE_ASN1_FUNCTIONS(ASN1_TIME)
8370Sstevel@tonic-gate 
8382139Sjp161948 DECLARE_ASN1_ITEM(ASN1_OCTET_STRING_NDEF)
8392139Sjp161948 
8400Sstevel@tonic-gate ASN1_TIME *ASN1_TIME_set(ASN1_TIME *s,time_t t);
8410Sstevel@tonic-gate int ASN1_TIME_check(ASN1_TIME *t);
8420Sstevel@tonic-gate ASN1_GENERALIZEDTIME *ASN1_TIME_to_generalizedtime(ASN1_TIME *t, ASN1_GENERALIZEDTIME **out);
8430Sstevel@tonic-gate 
8442139Sjp161948 int i2d_ASN1_SET(STACK *a, unsigned char **pp,
8452139Sjp161948 		 i2d_of_void *i2d, int ex_tag, int ex_class, int is_set);
8462139Sjp161948 STACK *	d2i_ASN1_SET(STACK **a, const unsigned char **pp, long length,
8472139Sjp161948 		     d2i_of_void *d2i, void (*free_func)(void *),
8482139Sjp161948 		     int ex_tag, int ex_class);
8490Sstevel@tonic-gate 
8500Sstevel@tonic-gate #ifndef OPENSSL_NO_BIO
8510Sstevel@tonic-gate int i2a_ASN1_INTEGER(BIO *bp, ASN1_INTEGER *a);
8520Sstevel@tonic-gate int a2i_ASN1_INTEGER(BIO *bp,ASN1_INTEGER *bs,char *buf,int size);
8530Sstevel@tonic-gate int i2a_ASN1_ENUMERATED(BIO *bp, ASN1_ENUMERATED *a);
8540Sstevel@tonic-gate int a2i_ASN1_ENUMERATED(BIO *bp,ASN1_ENUMERATED *bs,char *buf,int size);
8550Sstevel@tonic-gate int i2a_ASN1_OBJECT(BIO *bp,ASN1_OBJECT *a);
8560Sstevel@tonic-gate int a2i_ASN1_STRING(BIO *bp,ASN1_STRING *bs,char *buf,int size);
8570Sstevel@tonic-gate int i2a_ASN1_STRING(BIO *bp, ASN1_STRING *a, int type);
8580Sstevel@tonic-gate #endif
8590Sstevel@tonic-gate int i2t_ASN1_OBJECT(char *buf,int buf_len,ASN1_OBJECT *a);
8600Sstevel@tonic-gate 
8610Sstevel@tonic-gate int a2d_ASN1_OBJECT(unsigned char *out,int olen, const char *buf, int num);
8620Sstevel@tonic-gate ASN1_OBJECT *ASN1_OBJECT_create(int nid, unsigned char *data,int len,
8630Sstevel@tonic-gate 	const char *sn, const char *ln);
8640Sstevel@tonic-gate 
8650Sstevel@tonic-gate int ASN1_INTEGER_set(ASN1_INTEGER *a, long v);
8660Sstevel@tonic-gate long ASN1_INTEGER_get(ASN1_INTEGER *a);
8670Sstevel@tonic-gate ASN1_INTEGER *BN_to_ASN1_INTEGER(BIGNUM *bn, ASN1_INTEGER *ai);
8680Sstevel@tonic-gate BIGNUM *ASN1_INTEGER_to_BN(ASN1_INTEGER *ai,BIGNUM *bn);
8690Sstevel@tonic-gate 
8700Sstevel@tonic-gate int ASN1_ENUMERATED_set(ASN1_ENUMERATED *a, long v);
8710Sstevel@tonic-gate long ASN1_ENUMERATED_get(ASN1_ENUMERATED *a);
8720Sstevel@tonic-gate ASN1_ENUMERATED *BN_to_ASN1_ENUMERATED(BIGNUM *bn, ASN1_ENUMERATED *ai);
8730Sstevel@tonic-gate BIGNUM *ASN1_ENUMERATED_to_BN(ASN1_ENUMERATED *ai,BIGNUM *bn);
8740Sstevel@tonic-gate 
8750Sstevel@tonic-gate /* General */
8760Sstevel@tonic-gate /* given a string, return the correct type, max is the maximum length */
8772139Sjp161948 int ASN1_PRINTABLE_type(const unsigned char *s, int max);
8780Sstevel@tonic-gate 
8790Sstevel@tonic-gate int i2d_ASN1_bytes(ASN1_STRING *a, unsigned char **pp, int tag, int xclass);
8802139Sjp161948 ASN1_STRING *d2i_ASN1_bytes(ASN1_STRING **a, const unsigned char **pp,
8810Sstevel@tonic-gate 	long length, int Ptag, int Pclass);
8820Sstevel@tonic-gate unsigned long ASN1_tag2bit(int tag);
8830Sstevel@tonic-gate /* type is one or more of the B_ASN1_ values. */
8842139Sjp161948 ASN1_STRING *d2i_ASN1_type_bytes(ASN1_STRING **a,const unsigned char **pp,
8850Sstevel@tonic-gate 		long length,int type);
8860Sstevel@tonic-gate 
8870Sstevel@tonic-gate /* PARSING */
8880Sstevel@tonic-gate int asn1_Finish(ASN1_CTX *c);
8892139Sjp161948 int asn1_const_Finish(ASN1_const_CTX *c);
8900Sstevel@tonic-gate 
8910Sstevel@tonic-gate /* SPECIALS */
8922139Sjp161948 int ASN1_get_object(const unsigned char **pp, long *plength, int *ptag,
8930Sstevel@tonic-gate 	int *pclass, long omax);
8940Sstevel@tonic-gate int ASN1_check_infinite_end(unsigned char **p,long len);
8952139Sjp161948 int ASN1_const_check_infinite_end(const unsigned char **p,long len);
8960Sstevel@tonic-gate void ASN1_put_object(unsigned char **pp, int constructed, int length,
8970Sstevel@tonic-gate 	int tag, int xclass);
8982139Sjp161948 int ASN1_put_eoc(unsigned char **pp);
8990Sstevel@tonic-gate int ASN1_object_size(int constructed, int length, int tag);
9000Sstevel@tonic-gate 
9010Sstevel@tonic-gate /* Used to implement other functions */
9022139Sjp161948 void *ASN1_dup(i2d_of_void *i2d, d2i_of_void *d2i, char *x);
9032139Sjp161948 #define ASN1_dup_of(type,i2d,d2i,x) \
9042139Sjp161948 	((type *(*)(I2D_OF(type),D2I_OF(type),type *))openssl_fcast(ASN1_dup))(i2d,d2i,x)
9052139Sjp161948 #define ASN1_dup_of_const(type,i2d,d2i,x) \
9062139Sjp161948 	((type *(*)(I2D_OF_const(type),D2I_OF(type),type *))openssl_fcast(ASN1_dup))(i2d,d2i,x)
9070Sstevel@tonic-gate 
9080Sstevel@tonic-gate void *ASN1_item_dup(const ASN1_ITEM *it, void *x);
9090Sstevel@tonic-gate 
9100Sstevel@tonic-gate #ifndef OPENSSL_NO_FP_API
9112139Sjp161948 void *ASN1_d2i_fp(void *(*xnew)(void), d2i_of_void *d2i, FILE *in, void **x);
9122139Sjp161948 #define ASN1_d2i_fp_of(type,xnew,d2i,in,x) \
9132139Sjp161948 	((type *(*)(type *(*)(void),D2I_OF(type),FILE *,type **))openssl_fcast(ASN1_d2i_fp))(xnew,d2i,in,x)
9140Sstevel@tonic-gate void *ASN1_item_d2i_fp(const ASN1_ITEM *it, FILE *in, void *x);
9152139Sjp161948 int ASN1_i2d_fp(i2d_of_void *i2d,FILE *out,void *x);
9162139Sjp161948 #define ASN1_i2d_fp_of(type,i2d,out,x) \
9172139Sjp161948 	((int (*)(I2D_OF(type),FILE *,type *))openssl_fcast(ASN1_i2d_fp))(i2d,out,x)
9182139Sjp161948 #define ASN1_i2d_fp_of_const(type,i2d,out,x) \
9192139Sjp161948 	((int (*)(I2D_OF_const(type),FILE *,type *))openssl_fcast(ASN1_i2d_fp))(i2d,out,x)
9200Sstevel@tonic-gate int ASN1_item_i2d_fp(const ASN1_ITEM *it, FILE *out, void *x);
9210Sstevel@tonic-gate int ASN1_STRING_print_ex_fp(FILE *fp, ASN1_STRING *str, unsigned long flags);
9220Sstevel@tonic-gate #endif
9230Sstevel@tonic-gate 
9240Sstevel@tonic-gate int ASN1_STRING_to_UTF8(unsigned char **out, ASN1_STRING *in);
9250Sstevel@tonic-gate 
9260Sstevel@tonic-gate #ifndef OPENSSL_NO_BIO
9272139Sjp161948 void *ASN1_d2i_bio(void *(*xnew)(void), d2i_of_void *d2i, BIO *in, void **x);
9282139Sjp161948 #define ASN1_d2i_bio_of(type,xnew,d2i,in,x) \
9292139Sjp161948 	((type *(*)(type *(*)(void),D2I_OF(type),BIO *,type **))openssl_fcast(ASN1_d2i_bio))(xnew,d2i,in,x)
9300Sstevel@tonic-gate void *ASN1_item_d2i_bio(const ASN1_ITEM *it, BIO *in, void *x);
9312139Sjp161948 int ASN1_i2d_bio(i2d_of_void *i2d,BIO *out, unsigned char *x);
9322139Sjp161948 #define ASN1_i2d_bio_of(type,i2d,out,x) \
9332139Sjp161948 	((int (*)(I2D_OF(type),BIO *,type *))openssl_fcast(ASN1_i2d_bio))(i2d,out,x)
9342139Sjp161948 #define ASN1_i2d_bio_of_const(type,i2d,out,x) \
9352139Sjp161948 	((int (*)(I2D_OF_const(type),BIO *,const type *))openssl_fcast(ASN1_i2d_bio))(i2d,out,x)
9360Sstevel@tonic-gate int ASN1_item_i2d_bio(const ASN1_ITEM *it, BIO *out, void *x);
9370Sstevel@tonic-gate int ASN1_UTCTIME_print(BIO *fp,ASN1_UTCTIME *a);
9380Sstevel@tonic-gate int ASN1_GENERALIZEDTIME_print(BIO *fp,ASN1_GENERALIZEDTIME *a);
9390Sstevel@tonic-gate int ASN1_TIME_print(BIO *fp,ASN1_TIME *a);
9400Sstevel@tonic-gate int ASN1_STRING_print(BIO *bp,ASN1_STRING *v);
9410Sstevel@tonic-gate int ASN1_STRING_print_ex(BIO *out, ASN1_STRING *str, unsigned long flags);
9422139Sjp161948 int ASN1_parse(BIO *bp,const unsigned char *pp,long len,int indent);
9432139Sjp161948 int ASN1_parse_dump(BIO *bp,const unsigned char *pp,long len,int indent,int dump);
9440Sstevel@tonic-gate #endif
9450Sstevel@tonic-gate const char *ASN1_tag2str(int tag);
9460Sstevel@tonic-gate 
9470Sstevel@tonic-gate /* Used to load and write netscape format cert/key */
9480Sstevel@tonic-gate int i2d_ASN1_HEADER(ASN1_HEADER *a,unsigned char **pp);
9492139Sjp161948 ASN1_HEADER *d2i_ASN1_HEADER(ASN1_HEADER **a,const unsigned char **pp, long length);
9500Sstevel@tonic-gate ASN1_HEADER *ASN1_HEADER_new(void );
9510Sstevel@tonic-gate void ASN1_HEADER_free(ASN1_HEADER *a);
9520Sstevel@tonic-gate 
9530Sstevel@tonic-gate int ASN1_UNIVERSALSTRING_to_string(ASN1_UNIVERSALSTRING *s);
9540Sstevel@tonic-gate 
9550Sstevel@tonic-gate /* Not used that much at this point, except for the first two */
9560Sstevel@tonic-gate ASN1_METHOD *X509_asn1_meth(void);
9570Sstevel@tonic-gate ASN1_METHOD *RSAPrivateKey_asn1_meth(void);
9580Sstevel@tonic-gate ASN1_METHOD *ASN1_IA5STRING_asn1_meth(void);
9590Sstevel@tonic-gate ASN1_METHOD *ASN1_BIT_STRING_asn1_meth(void);
9600Sstevel@tonic-gate 
9610Sstevel@tonic-gate int ASN1_TYPE_set_octetstring(ASN1_TYPE *a,
9620Sstevel@tonic-gate 	unsigned char *data, int len);
9630Sstevel@tonic-gate int ASN1_TYPE_get_octetstring(ASN1_TYPE *a,
9640Sstevel@tonic-gate 	unsigned char *data, int max_len);
9650Sstevel@tonic-gate int ASN1_TYPE_set_int_octetstring(ASN1_TYPE *a, long num,
9660Sstevel@tonic-gate 	unsigned char *data, int len);
9670Sstevel@tonic-gate int ASN1_TYPE_get_int_octetstring(ASN1_TYPE *a,long *num,
9680Sstevel@tonic-gate 	unsigned char *data, int max_len);
9690Sstevel@tonic-gate 
9702139Sjp161948 STACK *ASN1_seq_unpack(const unsigned char *buf, int len,
9712139Sjp161948 		       d2i_of_void *d2i, void (*free_func)(void *));
9722139Sjp161948 unsigned char *ASN1_seq_pack(STACK *safes, i2d_of_void *i2d,
9732139Sjp161948 			     unsigned char **buf, int *len );
9742139Sjp161948 void *ASN1_unpack_string(ASN1_STRING *oct, d2i_of_void *d2i);
9750Sstevel@tonic-gate void *ASN1_item_unpack(ASN1_STRING *oct, const ASN1_ITEM *it);
9762139Sjp161948 ASN1_STRING *ASN1_pack_string(void *obj, i2d_of_void *i2d,
9772139Sjp161948 			      ASN1_OCTET_STRING **oct);
9782139Sjp161948 #define ASN1_pack_string_of(type,obj,i2d,oct) \
9792139Sjp161948 	((ASN1_STRING *(*)(type *,I2D_OF(type),ASN1_OCTET_STRING **))openssl_fcast(ASN1_pack_string))(obj,i2d,oct)
9800Sstevel@tonic-gate ASN1_STRING *ASN1_item_pack(void *obj, const ASN1_ITEM *it, ASN1_OCTET_STRING **oct);
9810Sstevel@tonic-gate 
9820Sstevel@tonic-gate void ASN1_STRING_set_default_mask(unsigned long mask);
9830Sstevel@tonic-gate int ASN1_STRING_set_default_mask_asc(char *p);
9840Sstevel@tonic-gate unsigned long ASN1_STRING_get_default_mask(void);
9850Sstevel@tonic-gate int ASN1_mbstring_copy(ASN1_STRING **out, const unsigned char *in, int len,
9860Sstevel@tonic-gate 					int inform, unsigned long mask);
9870Sstevel@tonic-gate int ASN1_mbstring_ncopy(ASN1_STRING **out, const unsigned char *in, int len,
9880Sstevel@tonic-gate 					int inform, unsigned long mask,
9890Sstevel@tonic-gate 					long minsize, long maxsize);
9900Sstevel@tonic-gate 
9910Sstevel@tonic-gate ASN1_STRING *ASN1_STRING_set_by_NID(ASN1_STRING **out,
9920Sstevel@tonic-gate 		const unsigned char *in, int inlen, int inform, int nid);
9930Sstevel@tonic-gate ASN1_STRING_TABLE *ASN1_STRING_TABLE_get(int nid);
9940Sstevel@tonic-gate int ASN1_STRING_TABLE_add(int, long, long, unsigned long, unsigned long);
9950Sstevel@tonic-gate void ASN1_STRING_TABLE_cleanup(void);
9960Sstevel@tonic-gate 
9970Sstevel@tonic-gate /* ASN1 template functions */
9980Sstevel@tonic-gate 
9990Sstevel@tonic-gate /* Old API compatible functions */
10000Sstevel@tonic-gate ASN1_VALUE *ASN1_item_new(const ASN1_ITEM *it);
10010Sstevel@tonic-gate void ASN1_item_free(ASN1_VALUE *val, const ASN1_ITEM *it);
10022139Sjp161948 ASN1_VALUE * ASN1_item_d2i(ASN1_VALUE **val, const unsigned char **in, long len, const ASN1_ITEM *it);
10030Sstevel@tonic-gate int ASN1_item_i2d(ASN1_VALUE *val, unsigned char **out, const ASN1_ITEM *it);
10042139Sjp161948 int ASN1_item_ndef_i2d(ASN1_VALUE *val, unsigned char **out, const ASN1_ITEM *it);
10050Sstevel@tonic-gate 
10060Sstevel@tonic-gate void ASN1_add_oid_module(void);
10070Sstevel@tonic-gate 
10082139Sjp161948 ASN1_TYPE *ASN1_generate_nconf(char *str, CONF *nconf);
10092139Sjp161948 ASN1_TYPE *ASN1_generate_v3(char *str, X509V3_CTX *cnf);
10102139Sjp161948 
10110Sstevel@tonic-gate /* BEGIN ERROR CODES */
10120Sstevel@tonic-gate /* The following lines are auto generated by the script mkerr.pl. Any changes
10130Sstevel@tonic-gate  * made after this point may be overwritten when the script is next run.
10140Sstevel@tonic-gate  */
10150Sstevel@tonic-gate void ERR_load_ASN1_strings(void);
10160Sstevel@tonic-gate 
10170Sstevel@tonic-gate /* Error codes for the ASN1 functions. */
10180Sstevel@tonic-gate 
10190Sstevel@tonic-gate /* Function codes. */
10200Sstevel@tonic-gate #define ASN1_F_A2D_ASN1_OBJECT				 100
10210Sstevel@tonic-gate #define ASN1_F_A2I_ASN1_ENUMERATED			 101
10220Sstevel@tonic-gate #define ASN1_F_A2I_ASN1_INTEGER				 102
10230Sstevel@tonic-gate #define ASN1_F_A2I_ASN1_STRING				 103
10242139Sjp161948 #define ASN1_F_APPEND_EXP				 176
10252139Sjp161948 #define ASN1_F_ASN1_BIT_STRING_SET_BIT			 183
10262139Sjp161948 #define ASN1_F_ASN1_CB					 177
10270Sstevel@tonic-gate #define ASN1_F_ASN1_CHECK_TLEN				 104
10280Sstevel@tonic-gate #define ASN1_F_ASN1_COLLATE_PRIMITIVE			 105
10290Sstevel@tonic-gate #define ASN1_F_ASN1_COLLECT				 106
10300Sstevel@tonic-gate #define ASN1_F_ASN1_D2I_EX_PRIMITIVE			 108
10310Sstevel@tonic-gate #define ASN1_F_ASN1_D2I_FP				 109
10322139Sjp161948 #define ASN1_F_ASN1_D2I_READ_BIO			 107
10332139Sjp161948 #define ASN1_F_ASN1_DIGEST				 184
10340Sstevel@tonic-gate #define ASN1_F_ASN1_DO_ADB				 110
10350Sstevel@tonic-gate #define ASN1_F_ASN1_DUP					 111
10360Sstevel@tonic-gate #define ASN1_F_ASN1_ENUMERATED_SET			 112
10370Sstevel@tonic-gate #define ASN1_F_ASN1_ENUMERATED_TO_BN			 113
10382139Sjp161948 #define ASN1_F_ASN1_EX_C2I				 204
10392139Sjp161948 #define ASN1_F_ASN1_FIND_END				 190
10402139Sjp161948 #define ASN1_F_ASN1_GENERALIZEDTIME_SET			 185
10412139Sjp161948 #define ASN1_F_ASN1_GENERATE_V3				 178
10420Sstevel@tonic-gate #define ASN1_F_ASN1_GET_OBJECT				 114
10430Sstevel@tonic-gate #define ASN1_F_ASN1_HEADER_NEW				 115
10440Sstevel@tonic-gate #define ASN1_F_ASN1_I2D_BIO				 116
10450Sstevel@tonic-gate #define ASN1_F_ASN1_I2D_FP				 117
10460Sstevel@tonic-gate #define ASN1_F_ASN1_INTEGER_SET				 118
10470Sstevel@tonic-gate #define ASN1_F_ASN1_INTEGER_TO_BN			 119
10482139Sjp161948 #define ASN1_F_ASN1_ITEM_D2I_FP				 190
10492139Sjp161948 #define ASN1_F_ASN1_ITEM_DUP				 191
10502139Sjp161948 #define ASN1_F_ASN1_ITEM_EX_COMBINE_NEW			 121
10510Sstevel@tonic-gate #define ASN1_F_ASN1_ITEM_EX_D2I				 120
10522139Sjp161948 #define ASN1_F_ASN1_ITEM_I2D_BIO			 192
10532139Sjp161948 #define ASN1_F_ASN1_ITEM_I2D_FP				 193
10542139Sjp161948 #define ASN1_F_ASN1_ITEM_PACK				 198
10552139Sjp161948 #define ASN1_F_ASN1_ITEM_SIGN				 195
10562139Sjp161948 #define ASN1_F_ASN1_ITEM_UNPACK				 199
10572139Sjp161948 #define ASN1_F_ASN1_ITEM_VERIFY				 197
10582139Sjp161948 #define ASN1_F_ASN1_MBSTRING_NCOPY			 122
10590Sstevel@tonic-gate #define ASN1_F_ASN1_OBJECT_NEW				 123
10600Sstevel@tonic-gate #define ASN1_F_ASN1_PACK_STRING				 124
10612139Sjp161948 #define ASN1_F_ASN1_PCTX_NEW				 205
10622139Sjp161948 #define ASN1_F_ASN1_PKCS5_PBE_SET			 125
10630Sstevel@tonic-gate #define ASN1_F_ASN1_SEQ_PACK				 126
10640Sstevel@tonic-gate #define ASN1_F_ASN1_SEQ_UNPACK				 127
10650Sstevel@tonic-gate #define ASN1_F_ASN1_SIGN				 128
10662139Sjp161948 #define ASN1_F_ASN1_STR2TYPE				 179
10672139Sjp161948 #define ASN1_F_ASN1_STRING_SET				 186
10680Sstevel@tonic-gate #define ASN1_F_ASN1_STRING_TABLE_ADD			 129
10690Sstevel@tonic-gate #define ASN1_F_ASN1_STRING_TYPE_NEW			 130
10700Sstevel@tonic-gate #define ASN1_F_ASN1_TEMPLATE_EX_D2I			 132
10710Sstevel@tonic-gate #define ASN1_F_ASN1_TEMPLATE_NEW			 133
10722139Sjp161948 #define ASN1_F_ASN1_TEMPLATE_NOEXP_D2I			 131
10730Sstevel@tonic-gate #define ASN1_F_ASN1_TIME_SET				 175
10740Sstevel@tonic-gate #define ASN1_F_ASN1_TYPE_GET_INT_OCTETSTRING		 134
10750Sstevel@tonic-gate #define ASN1_F_ASN1_TYPE_GET_OCTETSTRING		 135
10760Sstevel@tonic-gate #define ASN1_F_ASN1_UNPACK_STRING			 136
10772139Sjp161948 #define ASN1_F_ASN1_UTCTIME_SET				 187
10780Sstevel@tonic-gate #define ASN1_F_ASN1_VERIFY				 137
10792139Sjp161948 #define ASN1_F_BITSTR_CB				 180
10800Sstevel@tonic-gate #define ASN1_F_BN_TO_ASN1_ENUMERATED			 138
10810Sstevel@tonic-gate #define ASN1_F_BN_TO_ASN1_INTEGER			 139
10822139Sjp161948 #define ASN1_F_C2I_ASN1_BIT_STRING			 189
10832139Sjp161948 #define ASN1_F_C2I_ASN1_INTEGER				 194
10842139Sjp161948 #define ASN1_F_C2I_ASN1_OBJECT				 196
10850Sstevel@tonic-gate #define ASN1_F_COLLECT_DATA				 140
10860Sstevel@tonic-gate #define ASN1_F_D2I_ASN1_BIT_STRING			 141
10870Sstevel@tonic-gate #define ASN1_F_D2I_ASN1_BOOLEAN				 142
10880Sstevel@tonic-gate #define ASN1_F_D2I_ASN1_BYTES				 143
10890Sstevel@tonic-gate #define ASN1_F_D2I_ASN1_GENERALIZEDTIME			 144
10900Sstevel@tonic-gate #define ASN1_F_D2I_ASN1_HEADER				 145
10910Sstevel@tonic-gate #define ASN1_F_D2I_ASN1_INTEGER				 146
10920Sstevel@tonic-gate #define ASN1_F_D2I_ASN1_OBJECT				 147
10930Sstevel@tonic-gate #define ASN1_F_D2I_ASN1_SET				 148
10940Sstevel@tonic-gate #define ASN1_F_D2I_ASN1_TYPE_BYTES			 149
10950Sstevel@tonic-gate #define ASN1_F_D2I_ASN1_UINTEGER			 150
10960Sstevel@tonic-gate #define ASN1_F_D2I_ASN1_UTCTIME				 151
10970Sstevel@tonic-gate #define ASN1_F_D2I_NETSCAPE_RSA				 152
10980Sstevel@tonic-gate #define ASN1_F_D2I_NETSCAPE_RSA_2			 153
10990Sstevel@tonic-gate #define ASN1_F_D2I_PRIVATEKEY				 154
11000Sstevel@tonic-gate #define ASN1_F_D2I_PUBLICKEY				 155
11012139Sjp161948 #define ASN1_F_D2I_RSA_NET				 200
11022139Sjp161948 #define ASN1_F_D2I_RSA_NET_2				 201
11030Sstevel@tonic-gate #define ASN1_F_D2I_X509					 156
11040Sstevel@tonic-gate #define ASN1_F_D2I_X509_CINF				 157
11050Sstevel@tonic-gate #define ASN1_F_D2I_X509_PKEY				 159
11062139Sjp161948 #define ASN1_F_I2D_ASN1_SET				 188
11070Sstevel@tonic-gate #define ASN1_F_I2D_ASN1_TIME				 160
11080Sstevel@tonic-gate #define ASN1_F_I2D_DSA_PUBKEY				 161
11092139Sjp161948 #define ASN1_F_I2D_EC_PUBKEY				 181
11100Sstevel@tonic-gate #define ASN1_F_I2D_PRIVATEKEY				 163
11110Sstevel@tonic-gate #define ASN1_F_I2D_PUBLICKEY				 164
11122139Sjp161948 #define ASN1_F_I2D_RSA_NET				 162
11130Sstevel@tonic-gate #define ASN1_F_I2D_RSA_PUBKEY				 165
11140Sstevel@tonic-gate #define ASN1_F_LONG_C2I					 166
11150Sstevel@tonic-gate #define ASN1_F_OID_MODULE_INIT				 174
11162139Sjp161948 #define ASN1_F_PARSE_TAGGING				 182
11170Sstevel@tonic-gate #define ASN1_F_PKCS5_PBE2_SET				 167
11182139Sjp161948 #define ASN1_F_PKCS5_PBE_SET				 202
11190Sstevel@tonic-gate #define ASN1_F_X509_CINF_NEW				 168
11200Sstevel@tonic-gate #define ASN1_F_X509_CRL_ADD0_REVOKED			 169
11210Sstevel@tonic-gate #define ASN1_F_X509_INFO_NEW				 170
11222139Sjp161948 #define ASN1_F_X509_NAME_ENCODE				 203
11232139Sjp161948 #define ASN1_F_X509_NAME_EX_D2I				 158
11242139Sjp161948 #define ASN1_F_X509_NAME_EX_NEW				 171
11250Sstevel@tonic-gate #define ASN1_F_X509_NEW					 172
11260Sstevel@tonic-gate #define ASN1_F_X509_PKEY_NEW				 173
11270Sstevel@tonic-gate 
11280Sstevel@tonic-gate /* Reason codes. */
11290Sstevel@tonic-gate #define ASN1_R_ADDING_OBJECT				 171
11300Sstevel@tonic-gate #define ASN1_R_AUX_ERROR				 100
11310Sstevel@tonic-gate #define ASN1_R_BAD_CLASS				 101
11320Sstevel@tonic-gate #define ASN1_R_BAD_OBJECT_HEADER			 102
11330Sstevel@tonic-gate #define ASN1_R_BAD_PASSWORD_READ			 103
11340Sstevel@tonic-gate #define ASN1_R_BAD_TAG					 104
1135*9318SJan.Pechanec@Sun.COM #define ASN1_R_BMPSTRING_IS_WRONG_LENGTH		 210
11360Sstevel@tonic-gate #define ASN1_R_BN_LIB					 105
11370Sstevel@tonic-gate #define ASN1_R_BOOLEAN_IS_WRONG_LENGTH			 106
11380Sstevel@tonic-gate #define ASN1_R_BUFFER_TOO_SMALL				 107
11390Sstevel@tonic-gate #define ASN1_R_CIPHER_HAS_NO_OBJECT_IDENTIFIER		 108
11400Sstevel@tonic-gate #define ASN1_R_DATA_IS_WRONG				 109
11410Sstevel@tonic-gate #define ASN1_R_DECODE_ERROR				 110
11420Sstevel@tonic-gate #define ASN1_R_DECODING_ERROR				 111
11432139Sjp161948 #define ASN1_R_DEPTH_EXCEEDED				 174
11440Sstevel@tonic-gate #define ASN1_R_ENCODE_ERROR				 112
11450Sstevel@tonic-gate #define ASN1_R_ERROR_GETTING_TIME			 173
11460Sstevel@tonic-gate #define ASN1_R_ERROR_LOADING_SECTION			 172
11470Sstevel@tonic-gate #define ASN1_R_ERROR_PARSING_SET_ELEMENT		 113
11480Sstevel@tonic-gate #define ASN1_R_ERROR_SETTING_CIPHER_PARAMS		 114
11490Sstevel@tonic-gate #define ASN1_R_EXPECTING_AN_INTEGER			 115
11500Sstevel@tonic-gate #define ASN1_R_EXPECTING_AN_OBJECT			 116
11510Sstevel@tonic-gate #define ASN1_R_EXPECTING_A_BOOLEAN			 117
11520Sstevel@tonic-gate #define ASN1_R_EXPECTING_A_TIME				 118
11530Sstevel@tonic-gate #define ASN1_R_EXPLICIT_LENGTH_MISMATCH			 119
11540Sstevel@tonic-gate #define ASN1_R_EXPLICIT_TAG_NOT_CONSTRUCTED		 120
11550Sstevel@tonic-gate #define ASN1_R_FIELD_MISSING				 121
11560Sstevel@tonic-gate #define ASN1_R_FIRST_NUM_TOO_LARGE			 122
11570Sstevel@tonic-gate #define ASN1_R_HEADER_TOO_LONG				 123
11582139Sjp161948 #define ASN1_R_ILLEGAL_BITSTRING_FORMAT			 175
11592139Sjp161948 #define ASN1_R_ILLEGAL_BOOLEAN				 176
11600Sstevel@tonic-gate #define ASN1_R_ILLEGAL_CHARACTERS			 124
11612139Sjp161948 #define ASN1_R_ILLEGAL_FORMAT				 177
11622139Sjp161948 #define ASN1_R_ILLEGAL_HEX				 178
11632139Sjp161948 #define ASN1_R_ILLEGAL_IMPLICIT_TAG			 179
11642139Sjp161948 #define ASN1_R_ILLEGAL_INTEGER				 180
11652139Sjp161948 #define ASN1_R_ILLEGAL_NESTED_TAGGING			 181
11660Sstevel@tonic-gate #define ASN1_R_ILLEGAL_NULL				 125
11672139Sjp161948 #define ASN1_R_ILLEGAL_NULL_VALUE			 182
11682139Sjp161948 #define ASN1_R_ILLEGAL_OBJECT				 183
11690Sstevel@tonic-gate #define ASN1_R_ILLEGAL_OPTIONAL_ANY			 126
11700Sstevel@tonic-gate #define ASN1_R_ILLEGAL_OPTIONS_ON_ITEM_TEMPLATE		 170
11710Sstevel@tonic-gate #define ASN1_R_ILLEGAL_TAGGED_ANY			 127
11722139Sjp161948 #define ASN1_R_ILLEGAL_TIME_VALUE			 184
11732139Sjp161948 #define ASN1_R_INTEGER_NOT_ASCII_FORMAT			 185
11740Sstevel@tonic-gate #define ASN1_R_INTEGER_TOO_LARGE_FOR_LONG		 128
11750Sstevel@tonic-gate #define ASN1_R_INVALID_BMPSTRING_LENGTH			 129
11760Sstevel@tonic-gate #define ASN1_R_INVALID_DIGIT				 130
11772139Sjp161948 #define ASN1_R_INVALID_MODIFIER				 186
11782139Sjp161948 #define ASN1_R_INVALID_NUMBER				 187
11790Sstevel@tonic-gate #define ASN1_R_INVALID_SEPARATOR			 131
11800Sstevel@tonic-gate #define ASN1_R_INVALID_TIME_FORMAT			 132
11810Sstevel@tonic-gate #define ASN1_R_INVALID_UNIVERSALSTRING_LENGTH		 133
11820Sstevel@tonic-gate #define ASN1_R_INVALID_UTF8STRING			 134
11830Sstevel@tonic-gate #define ASN1_R_IV_TOO_LARGE				 135
11840Sstevel@tonic-gate #define ASN1_R_LENGTH_ERROR				 136
11852139Sjp161948 #define ASN1_R_LIST_ERROR				 188
11860Sstevel@tonic-gate #define ASN1_R_MISSING_EOC				 137
11870Sstevel@tonic-gate #define ASN1_R_MISSING_SECOND_NUMBER			 138
11882139Sjp161948 #define ASN1_R_MISSING_VALUE				 189
11890Sstevel@tonic-gate #define ASN1_R_MSTRING_NOT_UNIVERSAL			 139
11900Sstevel@tonic-gate #define ASN1_R_MSTRING_WRONG_TAG			 140
11912139Sjp161948 #define ASN1_R_NESTED_ASN1_STRING			 197
11920Sstevel@tonic-gate #define ASN1_R_NON_HEX_CHARACTERS			 141
11932139Sjp161948 #define ASN1_R_NOT_ASCII_FORMAT				 190
11940Sstevel@tonic-gate #define ASN1_R_NOT_ENOUGH_DATA				 142
11950Sstevel@tonic-gate #define ASN1_R_NO_MATCHING_CHOICE_TYPE			 143
11960Sstevel@tonic-gate #define ASN1_R_NULL_IS_WRONG_LENGTH			 144
11972139Sjp161948 #define ASN1_R_OBJECT_NOT_ASCII_FORMAT			 191
11980Sstevel@tonic-gate #define ASN1_R_ODD_NUMBER_OF_CHARS			 145
11990Sstevel@tonic-gate #define ASN1_R_PRIVATE_KEY_HEADER_MISSING		 146
12000Sstevel@tonic-gate #define ASN1_R_SECOND_NUMBER_TOO_LARGE			 147
12010Sstevel@tonic-gate #define ASN1_R_SEQUENCE_LENGTH_MISMATCH			 148
12020Sstevel@tonic-gate #define ASN1_R_SEQUENCE_NOT_CONSTRUCTED			 149
12032139Sjp161948 #define ASN1_R_SEQUENCE_OR_SET_NEEDS_CONFIG		 192
12040Sstevel@tonic-gate #define ASN1_R_SHORT_LINE				 150
12050Sstevel@tonic-gate #define ASN1_R_STRING_TOO_LONG				 151
12060Sstevel@tonic-gate #define ASN1_R_STRING_TOO_SHORT				 152
12070Sstevel@tonic-gate #define ASN1_R_TAG_VALUE_TOO_HIGH			 153
12080Sstevel@tonic-gate #define ASN1_R_THE_ASN1_OBJECT_IDENTIFIER_IS_NOT_KNOWN_FOR_THIS_MD 154
12092139Sjp161948 #define ASN1_R_TIME_NOT_ASCII_FORMAT			 193
12100Sstevel@tonic-gate #define ASN1_R_TOO_LONG					 155
12110Sstevel@tonic-gate #define ASN1_R_TYPE_NOT_CONSTRUCTED			 156
12120Sstevel@tonic-gate #define ASN1_R_UNABLE_TO_DECODE_RSA_KEY			 157
12130Sstevel@tonic-gate #define ASN1_R_UNABLE_TO_DECODE_RSA_PRIVATE_KEY		 158
12140Sstevel@tonic-gate #define ASN1_R_UNEXPECTED_EOC				 159
1215*9318SJan.Pechanec@Sun.COM #define ASN1_R_UNIVERSALSTRING_IS_WRONG_LENGTH		 211
12160Sstevel@tonic-gate #define ASN1_R_UNKNOWN_FORMAT				 160
12170Sstevel@tonic-gate #define ASN1_R_UNKNOWN_MESSAGE_DIGEST_ALGORITHM		 161
12180Sstevel@tonic-gate #define ASN1_R_UNKNOWN_OBJECT_TYPE			 162
12190Sstevel@tonic-gate #define ASN1_R_UNKNOWN_PUBLIC_KEY_TYPE			 163
12202139Sjp161948 #define ASN1_R_UNKNOWN_TAG				 194
12212139Sjp161948 #define ASN1_R_UNKOWN_FORMAT				 195
12220Sstevel@tonic-gate #define ASN1_R_UNSUPPORTED_ANY_DEFINED_BY_TYPE		 164
12230Sstevel@tonic-gate #define ASN1_R_UNSUPPORTED_CIPHER			 165
12240Sstevel@tonic-gate #define ASN1_R_UNSUPPORTED_ENCRYPTION_ALGORITHM		 166
12250Sstevel@tonic-gate #define ASN1_R_UNSUPPORTED_PUBLIC_KEY_TYPE		 167
12262139Sjp161948 #define ASN1_R_UNSUPPORTED_TYPE				 196
12270Sstevel@tonic-gate #define ASN1_R_WRONG_TAG				 168
12280Sstevel@tonic-gate #define ASN1_R_WRONG_TYPE				 169
12290Sstevel@tonic-gate 
12300Sstevel@tonic-gate #ifdef  __cplusplus
12310Sstevel@tonic-gate }
12320Sstevel@tonic-gate #endif
12330Sstevel@tonic-gate #endif
1234