⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 asn1.h

📁 ssl client side program,you can use it to test the ssl server.
💻 H
📖 第 1 页 / 共 3 页
字号:
/* crypto/asn1/asn1.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.] */#ifndef HEADER_ASN1_H#define HEADER_ASN1_H#ifdef  __cplusplusextern "C" {#endif#include <time.h>#include <openssl/bn.h>#include <openssl/stack.h>#include <openssl/safestack.h>#ifdef VMS#include <openssl/vms_idhacks.h>#endif#define V_ASN1_UNIVERSAL		0x00#define	V_ASN1_APPLICATION		0x40#define V_ASN1_CONTEXT_SPECIFIC		0x80#define V_ASN1_PRIVATE			0xc0#define V_ASN1_CONSTRUCTED		0x20#define V_ASN1_PRIMITIVE_TAG		0x1f#define V_ASN1_PRIMATIVE_TAG		0x1f#define V_ASN1_APP_CHOOSE		-2	/* let the recipient choose */#define V_ASN1_UNDEF			-1#define V_ASN1_EOC			0#define V_ASN1_BOOLEAN			1	/**/#define V_ASN1_INTEGER			2#define V_ASN1_NEG_INTEGER		(2+0x100)#define V_ASN1_BIT_STRING		3#define V_ASN1_OCTET_STRING		4#define V_ASN1_NULL			5#define V_ASN1_OBJECT			6#define V_ASN1_OBJECT_DESCRIPTOR	7#define V_ASN1_EXTERNAL			8#define V_ASN1_REAL			9#define V_ASN1_ENUMERATED		10#define V_ASN1_NEG_ENUMERATED		(10+0x100)#define V_ASN1_UTF8STRING		12#define V_ASN1_SEQUENCE			16#define V_ASN1_SET			17#define V_ASN1_NUMERICSTRING		18	/**/#define V_ASN1_PRINTABLESTRING		19#define V_ASN1_T61STRING		20#define V_ASN1_TELETEXSTRING		20	/* alias */#define V_ASN1_VIDEOTEXSTRING		21	/**/#define V_ASN1_IA5STRING		22#define V_ASN1_UTCTIME			23#define V_ASN1_GENERALIZEDTIME		24	/**/#define V_ASN1_GRAPHICSTRING		25	/**/#define V_ASN1_ISO64STRING		26	/**/#define V_ASN1_VISIBLESTRING		26	/* alias */#define V_ASN1_GENERALSTRING		27	/**/#define V_ASN1_UNIVERSALSTRING		28	/**/#define V_ASN1_BMPSTRING		30/* For use with d2i_ASN1_type_bytes() */#define B_ASN1_NUMERICSTRING	0x0001#define B_ASN1_PRINTABLESTRING	0x0002#define B_ASN1_T61STRING	0x0004#define B_ASN1_TELETEXSTRING	0x0008#define B_ASN1_VIDEOTEXSTRING	0x0008#define B_ASN1_IA5STRING	0x0010#define B_ASN1_GRAPHICSTRING	0x0020#define B_ASN1_ISO64STRING	0x0040#define B_ASN1_VISIBLESTRING	0x0040#define B_ASN1_GENERALSTRING	0x0080#define B_ASN1_UNIVERSALSTRING	0x0100#define B_ASN1_OCTET_STRING	0x0200#define B_ASN1_BIT_STRING	0x0400#define B_ASN1_BMPSTRING	0x0800#define B_ASN1_UNKNOWN		0x1000#define B_ASN1_UTF8STRING	0x2000/* For use with ASN1_mbstring_copy() */#define MBSTRING_FLAG		0x1000#define MBSTRING_ASC		(MBSTRING_FLAG|1)#define MBSTRING_BMP		(MBSTRING_FLAG|2)#define MBSTRING_UNIV		(MBSTRING_FLAG|3)#define MBSTRING_UTF8		(MBSTRING_FLAG|4)#define DECLARE_ASN1_SET_OF(type) \int i2d_ASN1_SET_OF_##type(STACK_OF(type) *a,unsigned char **pp, \			   int (*func)(type *,unsigned char **), int ex_tag, \			   int ex_class, int is_set); \STACK_OF(type) *d2i_ASN1_SET_OF_##type(STACK_OF(type) **a,unsigned char **pp, \				       long length, \				       type *(*func)(type **, \						     unsigned char **,long), \				       void (*free_func)(type *), \				       int ex_tag,int ex_class);#define IMPLEMENT_ASN1_SET_OF(type) \int i2d_ASN1_SET_OF_##type(STACK_OF(type) *a,unsigned char **pp, \			   int (*func)(type *,unsigned char **), int ex_tag, \			   int ex_class, int is_set) \    { return i2d_ASN1_SET((STACK *)a,pp,func,ex_tag,ex_class,is_set); } \STACK_OF(type) *d2i_ASN1_SET_OF_##type(STACK_OF(type) **a,unsigned char **pp, \				       long length, \				       type *(*func)(type **, \						     unsigned char **,long), \				       void (*free_func)(type *), \				       int ex_tag,int ex_class) \    { return (STACK_OF(type) *)d2i_ASN1_SET((STACK **)a,pp,length, \					    (char *(*)())func, \					    (void (*)())free_func, \					    ex_tag,ex_class); }typedef struct asn1_ctx_st	{	unsigned char *p;/* work char pointer */	int eos;	/* end of sequence read for indefinite encoding */	int error;	/* error code to use when returning an error */	int inf;	/* constructed if 0x20, indefinite is 0x21 */	int tag;	/* tag from last 'get object' */	int xclass;	/* class from last 'get object' */	long slen;	/* length of last 'get object' */	unsigned char *max; /* largest value of p allowed */	unsigned char *q;/* temporary variable */	unsigned char **pp;/* variable */	int line;	/* used in error processing */	} ASN1_CTX;/* These are used internally in the ASN1_OBJECT to keep track of * whether the names and data need to be free()ed */#define ASN1_OBJECT_FLAG_DYNAMIC	 0x01	/* internal use */#define ASN1_OBJECT_FLAG_CRITICAL	 0x02	/* critical x509v3 object id */#define ASN1_OBJECT_FLAG_DYNAMIC_STRINGS 0x04	/* internal use */#define ASN1_OBJECT_FLAG_DYNAMIC_DATA 	 0x08	/* internal use */typedef struct asn1_object_st	{	const char *sn,*ln;	int nid;	int length;	unsigned char *data;	int flags;	/* Should we free this one */	} ASN1_OBJECT;#define ASN1_STRING_FLAG_BITS_LEFT 0x08 /* Set if 0x07 has bits left value *//* This is the base type that holds just about everything :-) */typedef struct asn1_string_st	{	int length;	int type;	unsigned char *data;	/* The value of the following field depends on the type being	 * held.  It is mostly being used for BIT_STRING so if the	 * input data has a non-zero 'unused bits' value, it will be	 * handled correctly */	long flags;	} ASN1_STRING;#define STABLE_FLAGS_MALLOC	0x01#define STABLE_NO_MASK		0x02#define DIRSTRING_TYPE	\ (B_ASN1_PRINTABLESTRING|B_ASN1_T61STRING|B_ASN1_BMPSTRING|B_ASN1_UTF8STRING)#define PKCS9STRING_TYPE (DIRSTRING_TYPE|B_ASN1_IA5STRING)typedef struct asn1_string_table_st {	int nid;	long minsize;	long maxsize;	unsigned long mask;	unsigned long flags;} ASN1_STRING_TABLE;DECLARE_STACK_OF(ASN1_STRING_TABLE)/* size limits: this stuff is taken straight from RFC2459 */#define ub_name				32768#define ub_common_name			64#define ub_locality_name		128#define ub_state_name			128#define ub_organization_name		64#define ub_organization_unit_name	64#define ub_title			64#define ub_email_address		128#ifdef NO_ASN1_TYPEDEFS#define ASN1_INTEGER		ASN1_STRING#define ASN1_ENUMERATED		ASN1_STRING#define ASN1_BIT_STRING		ASN1_STRING#define ASN1_OCTET_STRING	ASN1_STRING#define ASN1_PRINTABLESTRING	ASN1_STRING#define ASN1_T61STRING		ASN1_STRING#define ASN1_IA5STRING		ASN1_STRING#define ASN1_UTCTIME		ASN1_STRING#define ASN1_GENERALIZEDTIME	ASN1_STRING#define ASN1_TIME		ASN1_STRING#define ASN1_GENERALSTRING	ASN1_STRING#define ASN1_UNIVERSALSTRING	ASN1_STRING#define ASN1_BMPSTRING		ASN1_STRING#define ASN1_VISIBLESTRING	ASN1_STRING#define ASN1_UTF8STRING		ASN1_STRING#elsetypedef struct asn1_string_st ASN1_INTEGER;typedef struct asn1_string_st ASN1_ENUMERATED;typedef struct asn1_string_st ASN1_BIT_STRING;typedef struct asn1_string_st ASN1_OCTET_STRING;typedef struct asn1_string_st ASN1_PRINTABLESTRING;typedef struct asn1_string_st ASN1_T61STRING;typedef struct asn1_string_st ASN1_IA5STRING;typedef struct asn1_string_st ASN1_GENERALSTRING;typedef struct asn1_string_st ASN1_UNIVERSALSTRING;typedef struct asn1_string_st ASN1_BMPSTRING;typedef struct asn1_string_st ASN1_UTCTIME;typedef struct asn1_string_st ASN1_TIME;typedef struct asn1_string_st ASN1_GENERALIZEDTIME;typedef struct asn1_string_st ASN1_VISIBLESTRING;typedef struct asn1_string_st ASN1_UTF8STRING;#endiftypedef int ASN1_NULL;typedef struct asn1_type_st	{	int type;	union	{		char *ptr;		ASN1_STRING *		asn1_string;		ASN1_OBJECT *		object;		ASN1_INTEGER *		integer;		ASN1_ENUMERATED *	enumerated;		ASN1_BIT_STRING *	bit_string;		ASN1_OCTET_STRING *	octet_string;		ASN1_PRINTABLESTRING *	printablestring;		ASN1_T61STRING *	t61string;		ASN1_IA5STRING *	ia5string;		ASN1_GENERALSTRING *	generalstring;		ASN1_BMPSTRING *	bmpstring;		ASN1_UNIVERSALSTRING *	universalstring;		ASN1_UTCTIME *		utctime;		ASN1_GENERALIZEDTIME *	generalizedtime;		ASN1_VISIBLESTRING *	visiblestring;		ASN1_UTF8STRING *	utf8string;		/* set and sequence are left complete and still		 * contain the set or sequence bytes */		ASN1_STRING *		set;		ASN1_STRING *		sequence;		} value;	} ASN1_TYPE;DECLARE_STACK_OF(ASN1_TYPE)DECLARE_ASN1_SET_OF(ASN1_TYPE)typedef struct asn1_method_st	{	int (*i2d)();	char *(*d2i)();	char *(*create)();	void (*destroy)();	} ASN1_METHOD;/* This is used when parsing some Netscape objects */typedef struct asn1_header_st	{	ASN1_OCTET_STRING *header;	char *data;	ASN1_METHOD *meth;	} ASN1_HEADER;/* This is used to contain a list of bit names */typedef struct BIT_STRING_BITNAME_st {	int bitnum;	const char *lname;	const char *sname;} BIT_STRING_BITNAME;#define M_ASN1_STRING_length(x)	((x)->length)#define M_ASN1_STRING_length_set(x, n)	((x)->length = (n))#define M_ASN1_STRING_type(x)	((x)->type)#define M_ASN1_STRING_data(x)	((x)->data)/* Macros for string operations */#define M_ASN1_BIT_STRING_new()	(ASN1_BIT_STRING *)\		ASN1_STRING_type_new(V_ASN1_BIT_STRING)#define M_ASN1_BIT_STRING_free(a)	ASN1_STRING_free((ASN1_STRING *)a)#define M_ASN1_BIT_STRING_dup(a) (ASN1_BIT_STRING *)\		ASN1_STRING_dup((ASN1_STRING *)a)#define M_ASN1_BIT_STRING_cmp(a,b) ASN1_STRING_cmp(\		(ASN1_STRING *)a,(ASN1_STRING *)b)#define M_ASN1_BIT_STRING_set(a,b,c) ASN1_STRING_set((ASN1_STRING *)a,b,c)#define M_ASN1_INTEGER_new()	(ASN1_INTEGER *)\		ASN1_STRING_type_new(V_ASN1_INTEGER)#define M_ASN1_INTEGER_free(a)		ASN1_STRING_free((ASN1_STRING *)a)#define M_ASN1_INTEGER_dup(a) (ASN1_INTEGER *)ASN1_STRING_dup((ASN1_STRING *)a)#define M_ASN1_INTEGER_cmp(a,b)	ASN1_STRING_cmp(\		(ASN1_STRING *)a,(ASN1_STRING *)b)#define M_ASN1_ENUMERATED_new()	(ASN1_ENUMERATED *)\		ASN1_STRING_type_new(V_ASN1_ENUMERATED)#define M_ASN1_ENUMERATED_free(a)	ASN1_STRING_free((ASN1_STRING *)a)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -