asn1.h revision 296341
1104477Ssam/* crypto/asn1/asn1.h */ 2104477Ssam/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 3104477Ssam * All rights reserved. 4104477Ssam * 5104477Ssam * This package is an SSL implementation written 6104477Ssam * by Eric Young (eay@cryptsoft.com). 7104477Ssam * The implementation was written so as to conform with Netscapes SSL. 8104477Ssam * 9104477Ssam * This library is free for commercial and non-commercial use as long as 10104477Ssam * the following conditions are aheared to. The following conditions 11104477Ssam * apply to all code found in this distribution, be it the RC4, RSA, 12104477Ssam * lhash, DES, etc., code; not just the SSL code. The SSL documentation 13104477Ssam * included with this distribution is covered by the same copyright terms 14104477Ssam * except that the holder is Tim Hudson (tjh@cryptsoft.com). 15104477Ssam * 16104477Ssam * Copyright remains Eric Young's, and as such any Copyright notices in 17104477Ssam * the code are not to be removed. 18104477Ssam * If this package is used in a product, Eric Young should be given attribution 19104477Ssam * as the author of the parts of the library used. 20104477Ssam * This can be in the form of a textual message at program startup or 21104477Ssam * in documentation (online or textual) provided with the package. 22104477Ssam * 23104477Ssam * Redistribution and use in source and binary forms, with or without 24104477Ssam * modification, are permitted provided that the following conditions 25104477Ssam * are met: 26104477Ssam * 1. Redistributions of source code must retain the copyright 27104477Ssam * notice, this list of conditions and the following disclaimer. 28104477Ssam * 2. Redistributions in binary form must reproduce the above copyright 29104477Ssam * notice, this list of conditions and the following disclaimer in the 30104477Ssam * documentation and/or other materials provided with the distribution. 31104477Ssam * 3. All advertising materials mentioning features or use of this software 32104477Ssam * must display the following acknowledgement: 33104477Ssam * "This product includes cryptographic software written by 34104477Ssam * Eric Young (eay@cryptsoft.com)" 35104477Ssam * The word 'cryptographic' can be left out if the rouines from the library 36104477Ssam * being used are not cryptographic related :-). 37104477Ssam * 4. If you include any Windows specific code (or a derivative thereof) from 38104477Ssam * the apps directory (application code) you must include an acknowledgement: 39104477Ssam * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" 40104477Ssam * 41104477Ssam * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND 42104477Ssam * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 43104477Ssam * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 44104477Ssam * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 45104477Ssam * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 46104477Ssam * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 47112124Ssam * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 48104477Ssam * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 49104477Ssam * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 50104477Ssam * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 51104477Ssam * SUCH DAMAGE. 52104477Ssam * 53104477Ssam * The licence and distribution terms for any publically available version or 54104477Ssam * derivative of this code cannot be changed. i.e. this code cannot simply be 55104477Ssam * copied and put under another distribution licence 56104477Ssam * [including the GNU Public Licence.] 57104477Ssam */ 58104477Ssam 59104477Ssam#ifndef HEADER_ASN1_H 60104477Ssam# define HEADER_ASN1_H 61104477Ssam 62104477Ssam# include <time.h> 63104477Ssam# include <openssl/e_os2.h> 64104477Ssam# ifndef OPENSSL_NO_BIO 65104477Ssam# include <openssl/bio.h> 66104477Ssam# endif 67104477Ssam# include <openssl/stack.h> 68104477Ssam# include <openssl/safestack.h> 69104477Ssam 70104477Ssam# include <openssl/symhacks.h> 71104477Ssam 72104477Ssam# include <openssl/ossl_typ.h> 73104477Ssam# ifndef OPENSSL_NO_DEPRECATED 74112124Ssam# include <openssl/bn.h> 75112124Ssam# endif 76112124Ssam 77112124Ssam# ifdef OPENSSL_BUILD_SHLIBCRYPTO 78104477Ssam# undef OPENSSL_EXTERN 79104477Ssam# define OPENSSL_EXTERN OPENSSL_EXPORT 80104477Ssam# endif 81104477Ssam 82104477Ssam#ifdef __cplusplus 83104477Ssamextern "C" { 84104477Ssam#endif 85104477Ssam 86104477Ssam# define V_ASN1_UNIVERSAL 0x00 87104477Ssam# define V_ASN1_APPLICATION 0x40 88104477Ssam# define V_ASN1_CONTEXT_SPECIFIC 0x80 89104477Ssam# define V_ASN1_PRIVATE 0xc0 90104477Ssam 91104477Ssam# define V_ASN1_CONSTRUCTED 0x20 92104477Ssam# define V_ASN1_PRIMITIVE_TAG 0x1f 93104477Ssam# define V_ASN1_PRIMATIVE_TAG 0x1f 94104477Ssam 95104477Ssam# define V_ASN1_APP_CHOOSE -2/* let the recipient choose */ 96104477Ssam# define V_ASN1_OTHER -3/* used in ASN1_TYPE */ 97104477Ssam# define V_ASN1_ANY -4/* used in ASN1 template code */ 98104477Ssam 99104477Ssam# define V_ASN1_NEG 0x100/* negative flag */ 100104477Ssam 101104477Ssam# define V_ASN1_UNDEF -1 102104477Ssam# define V_ASN1_EOC 0 103104477Ssam# define V_ASN1_BOOLEAN 1 /**/ 104104477Ssam# define V_ASN1_INTEGER 2 105104477Ssam# define V_ASN1_NEG_INTEGER (2 | V_ASN1_NEG) 106104477Ssam# define V_ASN1_BIT_STRING 3 107104477Ssam# define V_ASN1_OCTET_STRING 4 108104477Ssam# define V_ASN1_NULL 5 109104477Ssam# define V_ASN1_OBJECT 6 110104477Ssam# define V_ASN1_OBJECT_DESCRIPTOR 7 111104477Ssam# define V_ASN1_EXTERNAL 8 112104477Ssam# define V_ASN1_REAL 9 113104477Ssam# define V_ASN1_ENUMERATED 10 114105251Smarkm# define V_ASN1_NEG_ENUMERATED (10 | V_ASN1_NEG) 115112124Ssam# define V_ASN1_UTF8STRING 12 116112124Ssam# define V_ASN1_SEQUENCE 16 117112124Ssam# define V_ASN1_SET 17 118104477Ssam# define V_ASN1_NUMERICSTRING 18 /**/ 119104477Ssam# define V_ASN1_PRINTABLESTRING 19 120104477Ssam# define V_ASN1_T61STRING 20 121104477Ssam# define V_ASN1_TELETEXSTRING 20/* alias */ 122104477Ssam# define V_ASN1_VIDEOTEXSTRING 21 /**/ 123104477Ssam# define V_ASN1_IA5STRING 22 124104477Ssam# define V_ASN1_UTCTIME 23 125104477Ssam# define V_ASN1_GENERALIZEDTIME 24 /**/ 126104477Ssam# define V_ASN1_GRAPHICSTRING 25 /**/ 127104477Ssam# define V_ASN1_ISO64STRING 26 /**/ 128104477Ssam# define V_ASN1_VISIBLESTRING 26/* alias */ 129104477Ssam# define V_ASN1_GENERALSTRING 27 /**/ 130104477Ssam# define V_ASN1_UNIVERSALSTRING 28 /**/ 131104477Ssam# define V_ASN1_BMPSTRING 30 132104477Ssam/* For use with d2i_ASN1_type_bytes() */ 133104477Ssam# define B_ASN1_NUMERICSTRING 0x0001 134104477Ssam# define B_ASN1_PRINTABLESTRING 0x0002 135104477Ssam# define B_ASN1_T61STRING 0x0004 136104477Ssam# define B_ASN1_TELETEXSTRING 0x0004 137104477Ssam# define B_ASN1_VIDEOTEXSTRING 0x0008 138104477Ssam# define B_ASN1_IA5STRING 0x0010 139104477Ssam# define B_ASN1_GRAPHICSTRING 0x0020 140104477Ssam# define B_ASN1_ISO64STRING 0x0040 141104477Ssam# define B_ASN1_VISIBLESTRING 0x0040 142104477Ssam# define B_ASN1_GENERALSTRING 0x0080 143104477Ssam# define B_ASN1_UNIVERSALSTRING 0x0100 144104477Ssam# define B_ASN1_OCTET_STRING 0x0200 145104477Ssam# define B_ASN1_BIT_STRING 0x0400 146104477Ssam# define B_ASN1_BMPSTRING 0x0800 147104477Ssam# define B_ASN1_UNKNOWN 0x1000 148104477Ssam# define B_ASN1_UTF8STRING 0x2000 149104477Ssam# define B_ASN1_UTCTIME 0x4000 150104477Ssam# define B_ASN1_GENERALIZEDTIME 0x8000 151104477Ssam# define B_ASN1_SEQUENCE 0x10000 152104477Ssam/* For use with ASN1_mbstring_copy() */ 153104477Ssam# define MBSTRING_FLAG 0x1000 154104477Ssam# define MBSTRING_UTF8 (MBSTRING_FLAG) 155104477Ssam# define MBSTRING_ASC (MBSTRING_FLAG|1) 156104477Ssam# define MBSTRING_BMP (MBSTRING_FLAG|2) 157104477Ssam# define MBSTRING_UNIV (MBSTRING_FLAG|4) 158104477Ssam# define SMIME_OLDMIME 0x400 159104477Ssam# define SMIME_CRLFEOL 0x800 160104477Ssam# define SMIME_STREAM 0x1000 161104477Ssam struct X509_algor_st; 162104477SsamDECLARE_STACK_OF(X509_ALGOR) 163104477Ssam 164104477Ssam# define DECLARE_ASN1_SET_OF(type)/* filled in by mkstack.pl */ 165104477Ssam# define IMPLEMENT_ASN1_SET_OF(type)/* nothing, no longer needed */ 166104477Ssam 167104477Ssam/* 168104477Ssam * We MUST make sure that, except for constness, asn1_ctx_st and 169109596Ssam * asn1_const_ctx are exactly the same. Fortunately, as soon as the old ASN1 170109596Ssam * parsing macros are gone, we can throw this away as well... 171104477Ssam */ 172104477Ssamtypedef struct asn1_ctx_st { 173109596Ssam unsigned char *p; /* work char pointer */ 174109596Ssam int eos; /* end of sequence read for indefinite 175104477Ssam * encoding */ 176104477Ssam int error; /* error code to use when returning an error */ 177104477Ssam int inf; /* constructed if 0x20, indefinite is 0x21 */ 178109596Ssam int tag; /* tag from last 'get object' */ 179109596Ssam int xclass; /* class from last 'get object' */ 180112121Ssam long slen; /* length of last 'get object' */ 181109596Ssam unsigned char *max; /* largest value of p allowed */ 182109596Ssam unsigned char *q; /* temporary variable */ 183104477Ssam unsigned char **pp; /* variable */ 184104477Ssam int line; /* used in error processing */ 185104477Ssam} ASN1_CTX; 186104477Ssam 187104477Ssamtypedef struct asn1_const_ctx_st { 188104477Ssam const unsigned char *p; /* work char pointer */ 189104477Ssam int eos; /* end of sequence read for indefinite 190104477Ssam * encoding */ 191104477Ssam int error; /* error code to use when returning an error */ 192104477Ssam int inf; /* constructed if 0x20, indefinite is 0x21 */ 193104477Ssam int tag; /* tag from last 'get object' */ 194104477Ssam int xclass; /* class from last 'get object' */ 195104477Ssam long slen; /* length of last 'get object' */ 196104477Ssam const unsigned char *max; /* largest value of p allowed */ 197104477Ssam const unsigned char *q; /* temporary variable */ 198104477Ssam const unsigned char **pp; /* variable */ 199104477Ssam int line; /* used in error processing */ 200104477Ssam} ASN1_const_CTX; 201104477Ssam 202104477Ssam/* 203104477Ssam * These are used internally in the ASN1_OBJECT to keep track of whether the 204104477Ssam * names and data need to be free()ed 205104477Ssam */ 206104477Ssam# define ASN1_OBJECT_FLAG_DYNAMIC 0x01/* internal use */ 207104477Ssam# define ASN1_OBJECT_FLAG_CRITICAL 0x02/* critical x509v3 object id */ 208104477Ssam# define ASN1_OBJECT_FLAG_DYNAMIC_STRINGS 0x04/* internal use */ 209104477Ssam# define ASN1_OBJECT_FLAG_DYNAMIC_DATA 0x08/* internal use */ 210104477Ssamtypedef struct asn1_object_st { 211104477Ssam const char *sn, *ln; 212104477Ssam int nid; 213104477Ssam int length; 214104477Ssam const unsigned char *data; /* data remains const after init */ 215104477Ssam int flags; /* Should we free this one */ 216104477Ssam} ASN1_OBJECT; 217104477Ssam 218104477Ssam# define ASN1_STRING_FLAG_BITS_LEFT 0x08/* Set if 0x07 has bits left value */ 219104477Ssam/* 220104477Ssam * This indicates that the ASN1_STRING is not a real value but just a place 221104477Ssam * holder for the location where indefinite length constructed data should be 222104477Ssam * inserted in the memory buffer 223104477Ssam */ 224104477Ssam# define ASN1_STRING_FLAG_NDEF 0x010 225104477Ssam 226104477Ssam/* 227104477Ssam * This flag is used by the CMS code to indicate that a string is not 228104477Ssam * complete and is a place holder for content when it had all been accessed. 229104477Ssam * The flag will be reset when content has been written to it. 230104477Ssam */ 231104477Ssam 232104477Ssam# define ASN1_STRING_FLAG_CONT 0x020 233104477Ssam/* 234104477Ssam * This flag is used by ASN1 code to indicate an ASN1_STRING is an MSTRING 235104477Ssam * type. 236104477Ssam */ 237104477Ssam# define ASN1_STRING_FLAG_MSTRING 0x040 238104477Ssam/* This is the base type that holds just about everything :-) */ 239112124Ssamstruct asn1_string_st { 240112124Ssam int length; 241112124Ssam int type; 242112124Ssam unsigned char *data; 243112124Ssam /* 244112124Ssam * The value of the following field depends on the type being held. It 245104477Ssam * is mostly being used for BIT_STRING so if the input data has a 246104477Ssam * non-zero 'unused bits' value, it will be handled correctly 247104477Ssam */ 248104477Ssam long flags; 249104477Ssam}; 250104477Ssam 251104477Ssam/* 252104477Ssam * ASN1_ENCODING structure: this is used to save the received encoding of an 253104477Ssam * ASN1 type. This is useful to get round problems with invalid encodings 254104477Ssam * which can break signatures. 255104477Ssam */ 256104477Ssam 257104477Ssamtypedef struct ASN1_ENCODING_st { 258104477Ssam unsigned char *enc; /* DER encoding */ 259104477Ssam long len; /* Length of encoding */ 260104477Ssam int modified; /* set to 1 if 'enc' is invalid */ 261104477Ssam} ASN1_ENCODING; 262115748Ssam 263104477Ssam/* Used with ASN1 LONG type: if a long is set to this it is omitted */ 264104477Ssam# define ASN1_LONG_UNDEF 0x7fffffffL 265104477Ssam 266104477Ssam# define STABLE_FLAGS_MALLOC 0x01 267104477Ssam# define STABLE_NO_MASK 0x02 268104477Ssam# define DIRSTRING_TYPE \ 269104477Ssam (B_ASN1_PRINTABLESTRING|B_ASN1_T61STRING|B_ASN1_BMPSTRING|B_ASN1_UTF8STRING) 270104477Ssam# define PKCS9STRING_TYPE (DIRSTRING_TYPE|B_ASN1_IA5STRING) 271104477Ssam 272104477Ssamtypedef struct asn1_string_table_st { 273104477Ssam int nid; 274104477Ssam long minsize; 275104477Ssam long maxsize; 276104477Ssam unsigned long mask; 277104477Ssam unsigned long flags; 278104477Ssam} ASN1_STRING_TABLE; 279104477Ssam 280104477SsamDECLARE_STACK_OF(ASN1_STRING_TABLE) 281104477Ssam 282104477Ssam/* size limits: this stuff is taken straight from RFC2459 */ 283104477Ssam 284104477Ssam# define ub_name 32768 285104477Ssam# define ub_common_name 64 286104477Ssam# define ub_locality_name 128 287104477Ssam# define ub_state_name 128 288104477Ssam# define ub_organization_name 64 289104477Ssam# define ub_organization_unit_name 64 290104477Ssam# define ub_title 64 291104477Ssam# define ub_email_address 128 292104477Ssam 293104477Ssam/* 294104477Ssam * Declarations for template structures: for full definitions see asn1t.h 295104477Ssam */ 296104477Ssamtypedef struct ASN1_TEMPLATE_st ASN1_TEMPLATE; 297104477Ssamtypedef struct ASN1_TLC_st ASN1_TLC; 298104477Ssam/* This is just an opaque pointer */ 299104477Ssamtypedef struct ASN1_VALUE_st ASN1_VALUE; 300104477Ssam 301104477Ssam/* Declare ASN1 functions: the implement macro in in asn1t.h */ 302104477Ssam 303104477Ssam# define DECLARE_ASN1_FUNCTIONS(type) DECLARE_ASN1_FUNCTIONS_name(type, type) 304104477Ssam 305104477Ssam# define DECLARE_ASN1_ALLOC_FUNCTIONS(type) \ 306104477Ssam DECLARE_ASN1_ALLOC_FUNCTIONS_name(type, type) 307104477Ssam 308104477Ssam# define DECLARE_ASN1_FUNCTIONS_name(type, name) \ 309104477Ssam DECLARE_ASN1_ALLOC_FUNCTIONS_name(type, name) \ 310104477Ssam DECLARE_ASN1_ENCODE_FUNCTIONS(type, name, name) 311104477Ssam 312104477Ssam# define DECLARE_ASN1_FUNCTIONS_fname(type, itname, name) \ 313104477Ssam DECLARE_ASN1_ALLOC_FUNCTIONS_name(type, name) \ 314104477Ssam DECLARE_ASN1_ENCODE_FUNCTIONS(type, itname, name) 315104477Ssam 316104477Ssam# define DECLARE_ASN1_ENCODE_FUNCTIONS(type, itname, name) \ 317104477Ssam type *d2i_##name(type **a, const unsigned char **in, long len); \ 318104477Ssam int i2d_##name(type *a, unsigned char **out); \ 319104477Ssam DECLARE_ASN1_ITEM(itname) 320104477Ssam 321104477Ssam# define DECLARE_ASN1_ENCODE_FUNCTIONS_const(type, name) \ 322104477Ssam type *d2i_##name(type **a, const unsigned char **in, long len); \ 323104477Ssam int i2d_##name(const type *a, unsigned char **out); \ 324104477Ssam DECLARE_ASN1_ITEM(name) 325104477Ssam 326104477Ssam# define DECLARE_ASN1_NDEF_FUNCTION(name) \ 327104477Ssam int i2d_##name##_NDEF(name *a, unsigned char **out); 328104477Ssam 329104477Ssam# define DECLARE_ASN1_FUNCTIONS_const(name) \ 330104477Ssam DECLARE_ASN1_ALLOC_FUNCTIONS(name) \ 331104477Ssam DECLARE_ASN1_ENCODE_FUNCTIONS_const(name, name) 332104477Ssam 333104477Ssam# define DECLARE_ASN1_ALLOC_FUNCTIONS_name(type, name) \ 334104477Ssam type *name##_new(void); \ 335104477Ssam void name##_free(type *a); 336104477Ssam 337104477Ssam# define DECLARE_ASN1_PRINT_FUNCTION(stname) \ 338104477Ssam DECLARE_ASN1_PRINT_FUNCTION_fname(stname, stname) 339104477Ssam 340104477Ssam# define DECLARE_ASN1_PRINT_FUNCTION_fname(stname, fname) \ 341104477Ssam int fname##_print_ctx(BIO *out, stname *x, int indent, \ 342104477Ssam const ASN1_PCTX *pctx); 343117126Sscottl 344117126Sscottl# define D2I_OF(type) type *(*)(type **,const unsigned char **,long) 345104477Ssam# define I2D_OF(type) int (*)(type *,unsigned char **) 346104477Ssam# define I2D_OF_const(type) int (*)(const type *,unsigned char **) 347104477Ssam 348104477Ssam# define CHECKED_D2I_OF(type, d2i) \ 349104477Ssam ((d2i_of_void*) (1 ? d2i : ((D2I_OF(type))0))) 350104477Ssam# define CHECKED_I2D_OF(type, i2d) \ 351104477Ssam ((i2d_of_void*) (1 ? i2d : ((I2D_OF(type))0))) 352104477Ssam# define CHECKED_NEW_OF(type, xnew) \ 353104477Ssam ((void *(*)(void)) (1 ? xnew : ((type *(*)(void))0))) 354104477Ssam# define CHECKED_PTR_OF(type, p) \ 355104477Ssam ((void*) (1 ? p : (type*)0)) 356104477Ssam# define CHECKED_PPTR_OF(type, p) \ 357104477Ssam ((void**) (1 ? p : (type**)0)) 358104477Ssam 359104477Ssam# define TYPEDEF_D2I_OF(type) typedef type *d2i_of_##type(type **,const unsigned char **,long) 360104477Ssam# define TYPEDEF_I2D_OF(type) typedef int i2d_of_##type(type *,unsigned char **) 361104477Ssam# define TYPEDEF_D2I2D_OF(type) TYPEDEF_D2I_OF(type); TYPEDEF_I2D_OF(type) 362104477Ssam 363104477SsamTYPEDEF_D2I2D_OF(void); 364104477Ssam 365104477Ssam/*- 366104477Ssam * The following macros and typedefs allow an ASN1_ITEM 367104477Ssam * to be embedded in a structure and referenced. Since 368104477Ssam * the ASN1_ITEM pointers need to be globally accessible 369104477Ssam * (possibly from shared libraries) they may exist in 370104477Ssam * different forms. On platforms that support it the 371104477Ssam * ASN1_ITEM structure itself will be globally exported. 372104477Ssam * Other platforms will export a function that returns 373104477Ssam * an ASN1_ITEM pointer. 374104477Ssam * 375104477Ssam * To handle both cases transparently the macros below 376104477Ssam * should be used instead of hard coding an ASN1_ITEM 377104477Ssam * pointer in a structure. 378104477Ssam * 379104477Ssam * The structure will look like this: 380104477Ssam * 381104477Ssam * typedef struct SOMETHING_st { 382104477Ssam * ... 383104477Ssam * ASN1_ITEM_EXP *iptr; 384104477Ssam * ... 385104477Ssam * } SOMETHING; 386104477Ssam * 387104477Ssam * It would be initialised as e.g.: 388104477Ssam * 389104477Ssam * SOMETHING somevar = {...,ASN1_ITEM_ref(X509),...}; 390104477Ssam * 391104477Ssam * and the actual pointer extracted with: 392104477Ssam * 393104477Ssam * const ASN1_ITEM *it = ASN1_ITEM_ptr(somevar.iptr); 394104477Ssam * 395104477Ssam * Finally an ASN1_ITEM pointer can be extracted from an 396104477Ssam * appropriate reference with: ASN1_ITEM_rptr(X509). This 397104477Ssam * would be used when a function takes an ASN1_ITEM * argument. 398104477Ssam * 399104477Ssam */ 400104477Ssam 401104477Ssam# ifndef OPENSSL_EXPORT_VAR_AS_FUNCTION 402104477Ssam 403104477Ssam/* ASN1_ITEM pointer exported type */ 404104477Ssamtypedef const ASN1_ITEM ASN1_ITEM_EXP; 405104477Ssam 406104477Ssam/* Macro to obtain ASN1_ITEM pointer from exported type */ 407104477Ssam# define ASN1_ITEM_ptr(iptr) (iptr) 408104477Ssam 409104477Ssam/* Macro to include ASN1_ITEM pointer from base type */ 410104477Ssam# define ASN1_ITEM_ref(iptr) (&(iptr##_it)) 411104477Ssam 412104477Ssam# define ASN1_ITEM_rptr(ref) (&(ref##_it)) 413104477Ssam 414104477Ssam# define DECLARE_ASN1_ITEM(name) \ 415104477Ssam OPENSSL_EXTERN const ASN1_ITEM name##_it; 416104477Ssam 417104477Ssam# else 418104477Ssam 419104477Ssam/* 420104477Ssam * Platforms that can't easily handle shared global variables are declared as 421104477Ssam * functions returning ASN1_ITEM pointers. 422104477Ssam */ 423104477Ssam 424104477Ssam/* ASN1_ITEM pointer exported type */ 425104477Ssamtypedef const ASN1_ITEM *ASN1_ITEM_EXP (void); 426104477Ssam 427104477Ssam/* Macro to obtain ASN1_ITEM pointer from exported type */ 428115748Ssam# define ASN1_ITEM_ptr(iptr) (iptr()) 429104477Ssam 430104477Ssam/* Macro to include ASN1_ITEM pointer from base type */ 431104477Ssam# define ASN1_ITEM_ref(iptr) (iptr##_it) 432104477Ssam 433104477Ssam# define ASN1_ITEM_rptr(ref) (ref##_it()) 434104477Ssam 435104477Ssam# define DECLARE_ASN1_ITEM(name) \ 436104477Ssam const ASN1_ITEM * name##_it(void); 437104477Ssam 438104477Ssam# endif 439104477Ssam 440104477Ssam/* Parameters used by ASN1_STRING_print_ex() */ 441104477Ssam 442104477Ssam/* 443104477Ssam * These determine which characters to escape: RFC2253 special characters, 444104477Ssam * control characters and MSB set characters 445104477Ssam */ 446104477Ssam 447104477Ssam# define ASN1_STRFLGS_ESC_2253 1 448104477Ssam# define ASN1_STRFLGS_ESC_CTRL 2 449104477Ssam# define ASN1_STRFLGS_ESC_MSB 4 450104477Ssam 451104477Ssam/* 452104477Ssam * This flag determines how we do escaping: normally RC2253 backslash only, 453104477Ssam * set this to use backslash and quote. 454104477Ssam */ 455104477Ssam 456104477Ssam# define ASN1_STRFLGS_ESC_QUOTE 8 457104477Ssam 458104477Ssam/* These three flags are internal use only. */ 459104477Ssam 460104477Ssam/* Character is a valid PrintableString character */ 461104477Ssam# define CHARTYPE_PRINTABLESTRING 0x10 462104477Ssam/* Character needs escaping if it is the first character */ 463104477Ssam# define CHARTYPE_FIRST_ESC_2253 0x20 464104477Ssam/* Character needs escaping if it is the last character */ 465104477Ssam# define CHARTYPE_LAST_ESC_2253 0x40 466104477Ssam 467104477Ssam/* 468104477Ssam * NB the internal flags are safely reused below by flags handled at the top 469104477Ssam * level. 470104477Ssam */ 471104477Ssam 472104477Ssam/* 473104477Ssam * If this is set we convert all character strings to UTF8 first 474104477Ssam */ 475104477Ssam 476104477Ssam# define ASN1_STRFLGS_UTF8_CONVERT 0x10 477104477Ssam 478104477Ssam/* 479104477Ssam * If this is set we don't attempt to interpret content: just assume all 480104477Ssam * strings are 1 byte per character. This will produce some pretty odd 481104477Ssam * looking output! 482104477Ssam */ 483104477Ssam 484104477Ssam# define ASN1_STRFLGS_IGNORE_TYPE 0x20 485104477Ssam 486104477Ssam/* If this is set we include the string type in the output */ 487104477Ssam# define ASN1_STRFLGS_SHOW_TYPE 0x40 488104477Ssam 489104477Ssam/* 490119137Ssam * This determines which strings to display and which to 'dump' (hex dump of 491104477Ssam * content octets or DER encoding). We can only dump non character strings or 492104477Ssam * everything. If we don't dump 'unknown' they are interpreted as character 493104477Ssam * strings with 1 octet per character and are subject to the usual escaping 494104477Ssam * options. 495104477Ssam */ 496104477Ssam 497104477Ssam# define ASN1_STRFLGS_DUMP_ALL 0x80 498104477Ssam# define ASN1_STRFLGS_DUMP_UNKNOWN 0x100 499104477Ssam 500104477Ssam/* 501104477Ssam * These determine what 'dumping' does, we can dump the content octets or the 502104477Ssam * DER encoding: both use the RFC2253 #XXXXX notation. 503104477Ssam */ 504104477Ssam 505104477Ssam# define ASN1_STRFLGS_DUMP_DER 0x200 506104477Ssam 507104477Ssam/* 508104477Ssam * All the string flags consistent with RFC2253, escaping control characters 509104477Ssam * isn't essential in RFC2253 but it is advisable anyway. 510104477Ssam */ 511104477Ssam 512104477Ssam# define ASN1_STRFLGS_RFC2253 (ASN1_STRFLGS_ESC_2253 | \ 513104477Ssam ASN1_STRFLGS_ESC_CTRL | \ 514104477Ssam ASN1_STRFLGS_ESC_MSB | \ 515104477Ssam ASN1_STRFLGS_UTF8_CONVERT | \ 516104477Ssam ASN1_STRFLGS_DUMP_UNKNOWN | \ 517104477Ssam ASN1_STRFLGS_DUMP_DER) 518104477Ssam 519104477SsamDECLARE_STACK_OF(ASN1_INTEGER) 520104477SsamDECLARE_ASN1_SET_OF(ASN1_INTEGER) 521104477Ssam 522104477SsamDECLARE_STACK_OF(ASN1_GENERALSTRING) 523104477Ssam 524104477Ssamtypedef struct asn1_type_st { 525104477Ssam int type; 526104477Ssam union { 527104477Ssam char *ptr; 528115748Ssam ASN1_BOOLEAN boolean; 529115748Ssam ASN1_STRING *asn1_string; 530104477Ssam ASN1_OBJECT *object; 531104477Ssam ASN1_INTEGER *integer; 532104477Ssam ASN1_ENUMERATED *enumerated; 533104477Ssam ASN1_BIT_STRING *bit_string; 534115848Ssam ASN1_OCTET_STRING *octet_string; 535115848Ssam ASN1_PRINTABLESTRING *printablestring; 536115862Ssam ASN1_T61STRING *t61string; 537115848Ssam ASN1_IA5STRING *ia5string; 538104477Ssam ASN1_GENERALSTRING *generalstring; 539104477Ssam ASN1_BMPSTRING *bmpstring; 540104477Ssam ASN1_UNIVERSALSTRING *universalstring; 541104477Ssam ASN1_UTCTIME *utctime; 542104477Ssam ASN1_GENERALIZEDTIME *generalizedtime; 543104477Ssam ASN1_VISIBLESTRING *visiblestring; 544104477Ssam ASN1_UTF8STRING *utf8string; 545104477Ssam /* 546104477Ssam * set and sequence are left complete and still contain the set or 547104477Ssam * sequence bytes 548104477Ssam */ 549104477Ssam ASN1_STRING *set; 550104477Ssam ASN1_STRING *sequence; 551104477Ssam ASN1_VALUE *asn1_value; 552104477Ssam } value; 553104477Ssam} ASN1_TYPE; 554104477Ssam 555104477SsamDECLARE_STACK_OF(ASN1_TYPE) 556104477SsamDECLARE_ASN1_SET_OF(ASN1_TYPE) 557104477Ssam 558104477Ssamtypedef STACK_OF(ASN1_TYPE) ASN1_SEQUENCE_ANY; 559104477Ssam 560104477SsamDECLARE_ASN1_ENCODE_FUNCTIONS_const(ASN1_SEQUENCE_ANY, ASN1_SEQUENCE_ANY) 561104477SsamDECLARE_ASN1_ENCODE_FUNCTIONS_const(ASN1_SEQUENCE_ANY, ASN1_SET_ANY) 562104477Ssam 563104477Ssamtypedef struct NETSCAPE_X509_st { 564104477Ssam ASN1_OCTET_STRING *header; 565104477Ssam X509 *cert; 566104477Ssam} NETSCAPE_X509; 567104477Ssam 568104477Ssam/* This is used to contain a list of bit names */ 569104477Ssamtypedef struct BIT_STRING_BITNAME_st { 570104477Ssam int bitnum; 571104477Ssam const char *lname; 572104477Ssam const char *sname; 573104477Ssam} BIT_STRING_BITNAME; 574104477Ssam 575104477Ssam# define M_ASN1_STRING_length(x) ((x)->length) 576104477Ssam# define M_ASN1_STRING_length_set(x, n) ((x)->length = (n)) 577104477Ssam# define M_ASN1_STRING_type(x) ((x)->type) 578104477Ssam# define M_ASN1_STRING_data(x) ((x)->data) 579104477Ssam 580104477Ssam/* Macros for string operations */ 581104477Ssam# define M_ASN1_BIT_STRING_new() (ASN1_BIT_STRING *)\ 582104477Ssam ASN1_STRING_type_new(V_ASN1_BIT_STRING) 583104477Ssam# define M_ASN1_BIT_STRING_free(a) ASN1_STRING_free((ASN1_STRING *)a) 584104477Ssam# define M_ASN1_BIT_STRING_dup(a) (ASN1_BIT_STRING *)\ 585104477Ssam ASN1_STRING_dup((const ASN1_STRING *)a) 586104477Ssam# define M_ASN1_BIT_STRING_cmp(a,b) ASN1_STRING_cmp(\ 587104477Ssam (const ASN1_STRING *)a,(const ASN1_STRING *)b) 588104477Ssam# define M_ASN1_BIT_STRING_set(a,b,c) ASN1_STRING_set((ASN1_STRING *)a,b,c) 589104477Ssam 590104477Ssam# define M_ASN1_INTEGER_new() (ASN1_INTEGER *)\ 591104477Ssam ASN1_STRING_type_new(V_ASN1_INTEGER) 592104477Ssam# define M_ASN1_INTEGER_free(a) ASN1_STRING_free((ASN1_STRING *)a) 593104477Ssam# define M_ASN1_INTEGER_dup(a) (ASN1_INTEGER *)\ 594104477Ssam ASN1_STRING_dup((const ASN1_STRING *)a) 595104477Ssam# define M_ASN1_INTEGER_cmp(a,b) ASN1_STRING_cmp(\ 596104477Ssam (const ASN1_STRING *)a,(const ASN1_STRING *)b) 597104477Ssam 598104477Ssam# define M_ASN1_ENUMERATED_new() (ASN1_ENUMERATED *)\ 599104477Ssam ASN1_STRING_type_new(V_ASN1_ENUMERATED) 600104477Ssam# define M_ASN1_ENUMERATED_free(a) ASN1_STRING_free((ASN1_STRING *)a) 601104477Ssam# define M_ASN1_ENUMERATED_dup(a) (ASN1_ENUMERATED *)\ 602104477Ssam ASN1_STRING_dup((const ASN1_STRING *)a) 603104477Ssam# define M_ASN1_ENUMERATED_cmp(a,b) ASN1_STRING_cmp(\ 604104477Ssam (const ASN1_STRING *)a,(const ASN1_STRING *)b) 605104477Ssam 606104477Ssam# define M_ASN1_OCTET_STRING_new() (ASN1_OCTET_STRING *)\ 607104477Ssam ASN1_STRING_type_new(V_ASN1_OCTET_STRING) 608104477Ssam# define M_ASN1_OCTET_STRING_free(a) ASN1_STRING_free((ASN1_STRING *)a) 609104477Ssam# define M_ASN1_OCTET_STRING_dup(a) (ASN1_OCTET_STRING *)\ 610104477Ssam ASN1_STRING_dup((const ASN1_STRING *)a) 611104477Ssam# define M_ASN1_OCTET_STRING_cmp(a,b) ASN1_STRING_cmp(\ 612104477Ssam (const ASN1_STRING *)a,(const ASN1_STRING *)b) 613104477Ssam# define M_ASN1_OCTET_STRING_set(a,b,c) ASN1_STRING_set((ASN1_STRING *)a,b,c) 614104477Ssam# define M_ASN1_OCTET_STRING_print(a,b) ASN1_STRING_print(a,(ASN1_STRING *)b) 615104477Ssam# define M_i2d_ASN1_OCTET_STRING(a,pp) \ 616104477Ssam i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_OCTET_STRING,\ 617104477Ssam V_ASN1_UNIVERSAL) 618104477Ssam 619104477Ssam# define B_ASN1_TIME \ 620104477Ssam B_ASN1_UTCTIME | \ 621104477Ssam B_ASN1_GENERALIZEDTIME 622104477Ssam 623104477Ssam# define B_ASN1_PRINTABLE \ 624104477Ssam B_ASN1_NUMERICSTRING| \ 625104477Ssam B_ASN1_PRINTABLESTRING| \ 626104477Ssam B_ASN1_T61STRING| \ 627104477Ssam B_ASN1_IA5STRING| \ 628104477Ssam B_ASN1_BIT_STRING| \ 629104477Ssam B_ASN1_UNIVERSALSTRING|\ 630104477Ssam B_ASN1_BMPSTRING|\ 631104477Ssam B_ASN1_UTF8STRING|\ 632104477Ssam B_ASN1_SEQUENCE|\ 633104477Ssam B_ASN1_UNKNOWN 634104477Ssam 635104477Ssam# define B_ASN1_DIRECTORYSTRING \ 636104477Ssam B_ASN1_PRINTABLESTRING| \ 637104477Ssam B_ASN1_TELETEXSTRING|\ 638104477Ssam B_ASN1_BMPSTRING|\ 639104477Ssam B_ASN1_UNIVERSALSTRING|\ 640112124Ssam B_ASN1_UTF8STRING 641112124Ssam 642112124Ssam# define B_ASN1_DISPLAYTEXT \ 643112124Ssam B_ASN1_IA5STRING| \ 644112124Ssam B_ASN1_VISIBLESTRING| \ 645112124Ssam B_ASN1_BMPSTRING|\ 646112124Ssam B_ASN1_UTF8STRING 647112124Ssam 648112124Ssam# define M_ASN1_PRINTABLE_new() ASN1_STRING_type_new(V_ASN1_T61STRING) 649104477Ssam# define M_ASN1_PRINTABLE_free(a) ASN1_STRING_free((ASN1_STRING *)a) 650104477Ssam# define M_i2d_ASN1_PRINTABLE(a,pp) i2d_ASN1_bytes((ASN1_STRING *)a,\ 651104477Ssam pp,a->type,V_ASN1_UNIVERSAL) 652104477Ssam# define M_d2i_ASN1_PRINTABLE(a,pp,l) \ 653104477Ssam d2i_ASN1_type_bytes((ASN1_STRING **)a,pp,l, \ 654104477Ssam B_ASN1_PRINTABLE) 655104477Ssam 656104477Ssam# define M_DIRECTORYSTRING_new() ASN1_STRING_type_new(V_ASN1_PRINTABLESTRING) 657104477Ssam# define M_DIRECTORYSTRING_free(a) ASN1_STRING_free((ASN1_STRING *)a) 658104477Ssam# define M_i2d_DIRECTORYSTRING(a,pp) i2d_ASN1_bytes((ASN1_STRING *)a,\ 659104477Ssam pp,a->type,V_ASN1_UNIVERSAL) 660104477Ssam# define M_d2i_DIRECTORYSTRING(a,pp,l) \ 661104477Ssam d2i_ASN1_type_bytes((ASN1_STRING **)a,pp,l, \ 662104477Ssam B_ASN1_DIRECTORYSTRING) 663104477Ssam 664104477Ssam# define M_DISPLAYTEXT_new() ASN1_STRING_type_new(V_ASN1_VISIBLESTRING) 665104477Ssam# define M_DISPLAYTEXT_free(a) ASN1_STRING_free((ASN1_STRING *)a) 666104477Ssam# define M_i2d_DISPLAYTEXT(a,pp) i2d_ASN1_bytes((ASN1_STRING *)a,\ 667104477Ssam pp,a->type,V_ASN1_UNIVERSAL) 668104477Ssam# define M_d2i_DISPLAYTEXT(a,pp,l) \ 669104477Ssam d2i_ASN1_type_bytes((ASN1_STRING **)a,pp,l, \ 670104477Ssam B_ASN1_DISPLAYTEXT) 671104477Ssam 672104477Ssam# define M_ASN1_PRINTABLESTRING_new() (ASN1_PRINTABLESTRING *)\ 673104477Ssam ASN1_STRING_type_new(V_ASN1_PRINTABLESTRING) 674104477Ssam# define M_ASN1_PRINTABLESTRING_free(a) ASN1_STRING_free((ASN1_STRING *)a) 675104477Ssam# define M_i2d_ASN1_PRINTABLESTRING(a,pp) \ 676104477Ssam i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_PRINTABLESTRING,\ 677104477Ssam V_ASN1_UNIVERSAL) 678104477Ssam# define M_d2i_ASN1_PRINTABLESTRING(a,pp,l) \ 679104477Ssam (ASN1_PRINTABLESTRING *)d2i_ASN1_type_bytes\ 680104477Ssam ((ASN1_STRING **)a,pp,l,B_ASN1_PRINTABLESTRING) 681104477Ssam 682104477Ssam# define M_ASN1_T61STRING_new() (ASN1_T61STRING *)\ 683104477Ssam ASN1_STRING_type_new(V_ASN1_T61STRING) 684104477Ssam# define M_ASN1_T61STRING_free(a) ASN1_STRING_free((ASN1_STRING *)a) 685104477Ssam# define M_i2d_ASN1_T61STRING(a,pp) \ 686104477Ssam i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_T61STRING,\ 687104477Ssam V_ASN1_UNIVERSAL) 688104477Ssam# define M_d2i_ASN1_T61STRING(a,pp,l) \ 689119137Ssam (ASN1_T61STRING *)d2i_ASN1_type_bytes\ 690104477Ssam ((ASN1_STRING **)a,pp,l,B_ASN1_T61STRING) 691104477Ssam 692104477Ssam# define M_ASN1_IA5STRING_new() (ASN1_IA5STRING *)\ 693104477Ssam ASN1_STRING_type_new(V_ASN1_IA5STRING) 694104477Ssam# define M_ASN1_IA5STRING_free(a) ASN1_STRING_free((ASN1_STRING *)a) 695104477Ssam# define M_ASN1_IA5STRING_dup(a) \ 696104477Ssam (ASN1_IA5STRING *)ASN1_STRING_dup((const ASN1_STRING *)a) 697104477Ssam# define M_i2d_ASN1_IA5STRING(a,pp) \ 698104477Ssam i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_IA5STRING,\ 699104477Ssam V_ASN1_UNIVERSAL) 700104477Ssam# define M_d2i_ASN1_IA5STRING(a,pp,l) \ 701104477Ssam (ASN1_IA5STRING *)d2i_ASN1_type_bytes((ASN1_STRING **)a,pp,l,\ 702104477Ssam B_ASN1_IA5STRING) 703104477Ssam 704104477Ssam# define M_ASN1_UTCTIME_new() (ASN1_UTCTIME *)\ 705104477Ssam ASN1_STRING_type_new(V_ASN1_UTCTIME) 706104477Ssam# define M_ASN1_UTCTIME_free(a) ASN1_STRING_free((ASN1_STRING *)a) 707104477Ssam# define M_ASN1_UTCTIME_dup(a) (ASN1_UTCTIME *)\ 708104477Ssam ASN1_STRING_dup((const ASN1_STRING *)a) 709104477Ssam 710104477Ssam# define M_ASN1_GENERALIZEDTIME_new() (ASN1_GENERALIZEDTIME *)\ 711104477Ssam ASN1_STRING_type_new(V_ASN1_GENERALIZEDTIME) 712104477Ssam# define M_ASN1_GENERALIZEDTIME_free(a) ASN1_STRING_free((ASN1_STRING *)a) 713104477Ssam# define M_ASN1_GENERALIZEDTIME_dup(a) (ASN1_GENERALIZEDTIME *)ASN1_STRING_dup(\ 714104477Ssam (const ASN1_STRING *)a) 715104477Ssam 716104477Ssam# define M_ASN1_TIME_new() (ASN1_TIME *)\ 717104477Ssam ASN1_STRING_type_new(V_ASN1_UTCTIME) 718104477Ssam# define M_ASN1_TIME_free(a) ASN1_STRING_free((ASN1_STRING *)a) 719104477Ssam# define M_ASN1_TIME_dup(a) (ASN1_TIME *)\ 720104477Ssam ASN1_STRING_dup((const ASN1_STRING *)a) 721104477Ssam 722104477Ssam# define M_ASN1_GENERALSTRING_new() (ASN1_GENERALSTRING *)\ 723104477Ssam ASN1_STRING_type_new(V_ASN1_GENERALSTRING) 724104477Ssam# define M_ASN1_GENERALSTRING_free(a) ASN1_STRING_free((ASN1_STRING *)a) 725104477Ssam# define M_i2d_ASN1_GENERALSTRING(a,pp) \ 726104477Ssam i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_GENERALSTRING,\ 727104477Ssam V_ASN1_UNIVERSAL) 728104477Ssam# define M_d2i_ASN1_GENERALSTRING(a,pp,l) \ 729104477Ssam (ASN1_GENERALSTRING *)d2i_ASN1_type_bytes\ 730104477Ssam ((ASN1_STRING **)a,pp,l,B_ASN1_GENERALSTRING) 731104477Ssam 732112124Ssam# define M_ASN1_UNIVERSALSTRING_new() (ASN1_UNIVERSALSTRING *)\ 733112124Ssam ASN1_STRING_type_new(V_ASN1_UNIVERSALSTRING) 734104477Ssam# define M_ASN1_UNIVERSALSTRING_free(a) ASN1_STRING_free((ASN1_STRING *)a) 735104477Ssam# define M_i2d_ASN1_UNIVERSALSTRING(a,pp) \ 736104477Ssam i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_UNIVERSALSTRING,\ 737104477Ssam V_ASN1_UNIVERSAL) 738104477Ssam# define M_d2i_ASN1_UNIVERSALSTRING(a,pp,l) \ 739104477Ssam (ASN1_UNIVERSALSTRING *)d2i_ASN1_type_bytes\ 740104477Ssam ((ASN1_STRING **)a,pp,l,B_ASN1_UNIVERSALSTRING) 741104477Ssam 742112124Ssam# define M_ASN1_BMPSTRING_new() (ASN1_BMPSTRING *)\ 743112124Ssam ASN1_STRING_type_new(V_ASN1_BMPSTRING) 744104477Ssam# define M_ASN1_BMPSTRING_free(a) ASN1_STRING_free((ASN1_STRING *)a) 745104477Ssam# define M_i2d_ASN1_BMPSTRING(a,pp) \ 746104477Ssam i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_BMPSTRING,\ 747104477Ssam V_ASN1_UNIVERSAL) 748104477Ssam# define M_d2i_ASN1_BMPSTRING(a,pp,l) \ 749104477Ssam (ASN1_BMPSTRING *)d2i_ASN1_type_bytes\ 750104477Ssam ((ASN1_STRING **)a,pp,l,B_ASN1_BMPSTRING) 751104477Ssam 752104477Ssam# define M_ASN1_VISIBLESTRING_new() (ASN1_VISIBLESTRING *)\ 753104477Ssam ASN1_STRING_type_new(V_ASN1_VISIBLESTRING) 754104477Ssam# define M_ASN1_VISIBLESTRING_free(a) ASN1_STRING_free((ASN1_STRING *)a) 755104477Ssam# define M_i2d_ASN1_VISIBLESTRING(a,pp) \ 756104477Ssam i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_VISIBLESTRING,\ 757104477Ssam V_ASN1_UNIVERSAL) 758104477Ssam# define M_d2i_ASN1_VISIBLESTRING(a,pp,l) \ 759104477Ssam (ASN1_VISIBLESTRING *)d2i_ASN1_type_bytes\ 760104477Ssam ((ASN1_STRING **)a,pp,l,B_ASN1_VISIBLESTRING) 761104477Ssam 762104477Ssam# define M_ASN1_UTF8STRING_new() (ASN1_UTF8STRING *)\ 763104477Ssam ASN1_STRING_type_new(V_ASN1_UTF8STRING) 764104477Ssam# define M_ASN1_UTF8STRING_free(a) ASN1_STRING_free((ASN1_STRING *)a) 765104477Ssam# define M_i2d_ASN1_UTF8STRING(a,pp) \ 766104477Ssam i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_UTF8STRING,\ 767104477Ssam V_ASN1_UNIVERSAL) 768104477Ssam# define M_d2i_ASN1_UTF8STRING(a,pp,l) \ 769104477Ssam (ASN1_UTF8STRING *)d2i_ASN1_type_bytes\ 770104477Ssam ((ASN1_STRING **)a,pp,l,B_ASN1_UTF8STRING) 771104477Ssam 772104477Ssam /* for the is_set parameter to i2d_ASN1_SET */ 773104477Ssam# define IS_SEQUENCE 0 774104477Ssam# define IS_SET 1 775104477Ssam 776104477SsamDECLARE_ASN1_FUNCTIONS_fname(ASN1_TYPE, ASN1_ANY, ASN1_TYPE) 777104477Ssam 778104477Ssamint ASN1_TYPE_get(ASN1_TYPE *a); 779104477Ssamvoid ASN1_TYPE_set(ASN1_TYPE *a, int type, void *value); 780104477Ssamint ASN1_TYPE_set1(ASN1_TYPE *a, int type, const void *value); 781104477Ssamint ASN1_TYPE_cmp(const ASN1_TYPE *a, const ASN1_TYPE *b); 782104477Ssam 783104477SsamASN1_OBJECT *ASN1_OBJECT_new(void); 784104477Ssamvoid ASN1_OBJECT_free(ASN1_OBJECT *a); 785104477Ssamint i2d_ASN1_OBJECT(ASN1_OBJECT *a, unsigned char **pp); 786104477SsamASN1_OBJECT *c2i_ASN1_OBJECT(ASN1_OBJECT **a, const unsigned char **pp, 787104477Ssam long length); 788104477SsamASN1_OBJECT *d2i_ASN1_OBJECT(ASN1_OBJECT **a, const unsigned char **pp, 789104477Ssam long length); 790104477Ssam 791104477SsamDECLARE_ASN1_ITEM(ASN1_OBJECT) 792104477Ssam 793104477SsamDECLARE_STACK_OF(ASN1_OBJECT) 794104477SsamDECLARE_ASN1_SET_OF(ASN1_OBJECT) 795104477Ssam 796104477SsamASN1_STRING *ASN1_STRING_new(void); 797104477Ssamvoid ASN1_STRING_free(ASN1_STRING *a); 798104477Ssamvoid ASN1_STRING_clear_free(ASN1_STRING *a); 799104477Ssamint ASN1_STRING_copy(ASN1_STRING *dst, const ASN1_STRING *str); 800104477SsamASN1_STRING *ASN1_STRING_dup(const ASN1_STRING *a); 801104477SsamASN1_STRING *ASN1_STRING_type_new(int type); 802104477Ssamint ASN1_STRING_cmp(const ASN1_STRING *a, const ASN1_STRING *b); 803104477Ssam /* 804104477Ssam * Since this is used to store all sorts of things, via macros, for now, 805104477Ssam * make its data void * 806104477Ssam */ 807104477Ssamint ASN1_STRING_set(ASN1_STRING *str, const void *data, int len); 808104477Ssamvoid ASN1_STRING_set0(ASN1_STRING *str, void *data, int len); 809104477Ssamint ASN1_STRING_length(const ASN1_STRING *x); 810104477Ssamvoid ASN1_STRING_length_set(ASN1_STRING *x, int n); 811104477Ssamint ASN1_STRING_type(ASN1_STRING *x); 812104477Ssamunsigned char *ASN1_STRING_data(ASN1_STRING *x); 813104477Ssam 814104477SsamDECLARE_ASN1_FUNCTIONS(ASN1_BIT_STRING) 815104477Ssamint i2c_ASN1_BIT_STRING(ASN1_BIT_STRING *a, unsigned char **pp); 816104477SsamASN1_BIT_STRING *c2i_ASN1_BIT_STRING(ASN1_BIT_STRING **a, 817104477Ssam const unsigned char **pp, long length); 818104477Ssamint ASN1_BIT_STRING_set(ASN1_BIT_STRING *a, unsigned char *d, int length); 819104477Ssamint ASN1_BIT_STRING_set_bit(ASN1_BIT_STRING *a, int n, int value); 820104477Ssamint ASN1_BIT_STRING_get_bit(ASN1_BIT_STRING *a, int n); 821104477Ssamint ASN1_BIT_STRING_check(ASN1_BIT_STRING *a, 822104477Ssam unsigned char *flags, int flags_len); 823104477Ssam 824104477Ssam# ifndef OPENSSL_NO_BIO 825104477Ssamint ASN1_BIT_STRING_name_print(BIO *out, ASN1_BIT_STRING *bs, 826104477Ssam BIT_STRING_BITNAME *tbl, int indent); 827104477Ssam# endif 828104477Ssamint ASN1_BIT_STRING_num_asc(char *name, BIT_STRING_BITNAME *tbl); 829104477Ssamint ASN1_BIT_STRING_set_asc(ASN1_BIT_STRING *bs, char *name, int value, 830104477Ssam BIT_STRING_BITNAME *tbl); 831104477Ssam 832104477Ssamint i2d_ASN1_BOOLEAN(int a, unsigned char **pp); 833104477Ssamint d2i_ASN1_BOOLEAN(int *a, const unsigned char **pp, long length); 834104477Ssam 835104477SsamDECLARE_ASN1_FUNCTIONS(ASN1_INTEGER) 836104477Ssamint i2c_ASN1_INTEGER(ASN1_INTEGER *a, unsigned char **pp); 837104477SsamASN1_INTEGER *c2i_ASN1_INTEGER(ASN1_INTEGER **a, const unsigned char **pp, 838104477Ssam long length); 839104477SsamASN1_INTEGER *d2i_ASN1_UINTEGER(ASN1_INTEGER **a, const unsigned char **pp, 840104477Ssam long length); 841104477SsamASN1_INTEGER *ASN1_INTEGER_dup(const ASN1_INTEGER *x); 842104477Ssamint ASN1_INTEGER_cmp(const ASN1_INTEGER *x, const ASN1_INTEGER *y); 843104477Ssam 844104477SsamDECLARE_ASN1_FUNCTIONS(ASN1_ENUMERATED) 845104477Ssam 846104477Ssamint ASN1_UTCTIME_check(ASN1_UTCTIME *a); 847104477SsamASN1_UTCTIME *ASN1_UTCTIME_set(ASN1_UTCTIME *s, time_t t); 848104477SsamASN1_UTCTIME *ASN1_UTCTIME_adj(ASN1_UTCTIME *s, time_t t, 849104477Ssam int offset_day, long offset_sec); 850104477Ssamint ASN1_UTCTIME_set_string(ASN1_UTCTIME *s, const char *str); 851104477Ssamint ASN1_UTCTIME_cmp_time_t(const ASN1_UTCTIME *s, time_t t); 852104477Ssam# if 0 853104477Ssamtime_t ASN1_UTCTIME_get(const ASN1_UTCTIME *s); 854104477Ssam# endif 855104477Ssam 856104477Ssamint ASN1_GENERALIZEDTIME_check(ASN1_GENERALIZEDTIME *a); 857104477SsamASN1_GENERALIZEDTIME *ASN1_GENERALIZEDTIME_set(ASN1_GENERALIZEDTIME *s, 858104477Ssam time_t t); 859104477SsamASN1_GENERALIZEDTIME *ASN1_GENERALIZEDTIME_adj(ASN1_GENERALIZEDTIME *s, 860104477Ssam time_t t, int offset_day, 861104477Ssam long offset_sec); 862104477Ssamint ASN1_GENERALIZEDTIME_set_string(ASN1_GENERALIZEDTIME *s, const char *str); 863104477Ssam 864104477SsamDECLARE_ASN1_FUNCTIONS(ASN1_OCTET_STRING) 865104477SsamASN1_OCTET_STRING *ASN1_OCTET_STRING_dup(const ASN1_OCTET_STRING *a); 866104477Ssamint ASN1_OCTET_STRING_cmp(const ASN1_OCTET_STRING *a, 867104477Ssam const ASN1_OCTET_STRING *b); 868104477Ssamint ASN1_OCTET_STRING_set(ASN1_OCTET_STRING *str, const unsigned char *data, 869104477Ssam int len); 870104477Ssam 871104477SsamDECLARE_ASN1_FUNCTIONS(ASN1_VISIBLESTRING) 872104477SsamDECLARE_ASN1_FUNCTIONS(ASN1_UNIVERSALSTRING) 873104477SsamDECLARE_ASN1_FUNCTIONS(ASN1_UTF8STRING) 874104477SsamDECLARE_ASN1_FUNCTIONS(ASN1_NULL) 875104477SsamDECLARE_ASN1_FUNCTIONS(ASN1_BMPSTRING) 876104477Ssam 877104477Ssamint UTF8_getc(const unsigned char *str, int len, unsigned long *val); 878104477Ssamint UTF8_putc(unsigned char *str, int len, unsigned long value); 879104477Ssam 880104477SsamDECLARE_ASN1_FUNCTIONS_name(ASN1_STRING, ASN1_PRINTABLE) 881104477Ssam 882104477SsamDECLARE_ASN1_FUNCTIONS_name(ASN1_STRING, DIRECTORYSTRING) 883104477SsamDECLARE_ASN1_FUNCTIONS_name(ASN1_STRING, DISPLAYTEXT) 884104477SsamDECLARE_ASN1_FUNCTIONS(ASN1_PRINTABLESTRING) 885104477SsamDECLARE_ASN1_FUNCTIONS(ASN1_T61STRING) 886104477SsamDECLARE_ASN1_FUNCTIONS(ASN1_IA5STRING) 887104477SsamDECLARE_ASN1_FUNCTIONS(ASN1_GENERALSTRING) 888104477SsamDECLARE_ASN1_FUNCTIONS(ASN1_UTCTIME) 889104477SsamDECLARE_ASN1_FUNCTIONS(ASN1_GENERALIZEDTIME) 890104477SsamDECLARE_ASN1_FUNCTIONS(ASN1_TIME) 891104477Ssam 892104477SsamDECLARE_ASN1_ITEM(ASN1_OCTET_STRING_NDEF) 893104477Ssam 894104477SsamASN1_TIME *ASN1_TIME_set(ASN1_TIME *s, time_t t); 895104477SsamASN1_TIME *ASN1_TIME_adj(ASN1_TIME *s, time_t t, 896104477Ssam int offset_day, long offset_sec); 897104477Ssamint ASN1_TIME_check(ASN1_TIME *t); 898104477SsamASN1_GENERALIZEDTIME *ASN1_TIME_to_generalizedtime(ASN1_TIME *t, ASN1_GENERALIZEDTIME 899104477Ssam **out); 900104477Ssamint ASN1_TIME_set_string(ASN1_TIME *s, const char *str); 901104477Ssam 902104477Ssamint i2d_ASN1_SET(STACK_OF(OPENSSL_BLOCK) *a, unsigned char **pp, 903104477Ssam i2d_of_void *i2d, int ex_tag, int ex_class, int is_set); 904104477SsamSTACK_OF(OPENSSL_BLOCK) *d2i_ASN1_SET(STACK_OF(OPENSSL_BLOCK) **a, 905104477Ssam const unsigned char **pp, 906104477Ssam long length, d2i_of_void *d2i, 907104477Ssam void (*free_func) (OPENSSL_BLOCK), 908104477Ssam int ex_tag, int ex_class); 909104477Ssam 910104477Ssam# ifndef OPENSSL_NO_BIO 911104477Ssamint i2a_ASN1_INTEGER(BIO *bp, ASN1_INTEGER *a); 912104477Ssamint a2i_ASN1_INTEGER(BIO *bp, ASN1_INTEGER *bs, char *buf, int size); 913104477Ssamint i2a_ASN1_ENUMERATED(BIO *bp, ASN1_ENUMERATED *a); 914104477Ssamint a2i_ASN1_ENUMERATED(BIO *bp, ASN1_ENUMERATED *bs, char *buf, int size); 915104477Ssamint i2a_ASN1_OBJECT(BIO *bp, ASN1_OBJECT *a); 916104477Ssamint a2i_ASN1_STRING(BIO *bp, ASN1_STRING *bs, char *buf, int size); 917104477Ssamint i2a_ASN1_STRING(BIO *bp, ASN1_STRING *a, int type); 918104477Ssam# endif 919104477Ssamint i2t_ASN1_OBJECT(char *buf, int buf_len, ASN1_OBJECT *a); 920104477Ssam 921104477Ssamint a2d_ASN1_OBJECT(unsigned char *out, int olen, const char *buf, int num); 922104477SsamASN1_OBJECT *ASN1_OBJECT_create(int nid, unsigned char *data, int len, 923104477Ssam const char *sn, const char *ln); 924104477Ssam 925104477Ssamint ASN1_INTEGER_set(ASN1_INTEGER *a, long v); 926104477Ssamlong ASN1_INTEGER_get(const ASN1_INTEGER *a); 927104477SsamASN1_INTEGER *BN_to_ASN1_INTEGER(const BIGNUM *bn, ASN1_INTEGER *ai); 928104477SsamBIGNUM *ASN1_INTEGER_to_BN(const ASN1_INTEGER *ai, BIGNUM *bn); 929104477Ssam 930104477Ssamint ASN1_ENUMERATED_set(ASN1_ENUMERATED *a, long v); 931104477Ssamlong ASN1_ENUMERATED_get(ASN1_ENUMERATED *a); 932104477SsamASN1_ENUMERATED *BN_to_ASN1_ENUMERATED(BIGNUM *bn, ASN1_ENUMERATED *ai); 933104477SsamBIGNUM *ASN1_ENUMERATED_to_BN(ASN1_ENUMERATED *ai, BIGNUM *bn); 934104477Ssam 935104477Ssam/* General */ 936104477Ssam/* given a string, return the correct type, max is the maximum length */ 937104477Ssamint ASN1_PRINTABLE_type(const unsigned char *s, int max); 938104477Ssam 939104477Ssamint i2d_ASN1_bytes(ASN1_STRING *a, unsigned char **pp, int tag, int xclass); 940104477SsamASN1_STRING *d2i_ASN1_bytes(ASN1_STRING **a, const unsigned char **pp, 941104477Ssam long length, int Ptag, int Pclass); 942104477Ssamunsigned long ASN1_tag2bit(int tag); 943104477Ssam/* type is one or more of the B_ASN1_ values. */ 944104477SsamASN1_STRING *d2i_ASN1_type_bytes(ASN1_STRING **a, const unsigned char **pp, 945104477Ssam long length, int type); 946104477Ssam 947104477Ssam/* PARSING */ 948104477Ssamint asn1_Finish(ASN1_CTX *c); 949104477Ssamint asn1_const_Finish(ASN1_const_CTX *c); 950104477Ssam 951104477Ssam/* SPECIALS */ 952104477Ssamint ASN1_get_object(const unsigned char **pp, long *plength, int *ptag, 953104477Ssam int *pclass, long omax); 954104477Ssamint ASN1_check_infinite_end(unsigned char **p, long len); 955104477Ssamint ASN1_const_check_infinite_end(const unsigned char **p, long len); 956104477Ssamvoid ASN1_put_object(unsigned char **pp, int constructed, int length, 957104477Ssam int tag, int xclass); 958104477Ssamint ASN1_put_eoc(unsigned char **pp); 959104477Ssamint ASN1_object_size(int constructed, int length, int tag); 960104477Ssam 961104477Ssam/* Used to implement other functions */ 962104477Ssamvoid *ASN1_dup(i2d_of_void *i2d, d2i_of_void *d2i, void *x); 963104477Ssam 964104477Ssam# define ASN1_dup_of(type,i2d,d2i,x) \ 965104477Ssam ((type*)ASN1_dup(CHECKED_I2D_OF(type, i2d), \ 966104477Ssam CHECKED_D2I_OF(type, d2i), \ 967104477Ssam CHECKED_PTR_OF(type, x))) 968104477Ssam 969104477Ssam# define ASN1_dup_of_const(type,i2d,d2i,x) \ 970104477Ssam ((type*)ASN1_dup(CHECKED_I2D_OF(const type, i2d), \ 971104477Ssam CHECKED_D2I_OF(type, d2i), \ 972104477Ssam CHECKED_PTR_OF(const type, x))) 973104477Ssam 974104477Ssamvoid *ASN1_item_dup(const ASN1_ITEM *it, void *x); 975104477Ssam 976104477Ssam/* ASN1 alloc/free macros for when a type is only used internally */ 977104477Ssam 978104477Ssam# define M_ASN1_new_of(type) (type *)ASN1_item_new(ASN1_ITEM_rptr(type)) 979104477Ssam# define M_ASN1_free_of(x, type) \ 980104477Ssam ASN1_item_free(CHECKED_PTR_OF(type, x), ASN1_ITEM_rptr(type)) 981104477Ssam 982104477Ssam# ifndef OPENSSL_NO_FP_API 983104477Ssamvoid *ASN1_d2i_fp(void *(*xnew) (void), d2i_of_void *d2i, FILE *in, void **x); 984104477Ssam 985104477Ssam# define ASN1_d2i_fp_of(type,xnew,d2i,in,x) \ 986104477Ssam ((type*)ASN1_d2i_fp(CHECKED_NEW_OF(type, xnew), \ 987104477Ssam CHECKED_D2I_OF(type, d2i), \ 988104477Ssam in, \ 989104477Ssam CHECKED_PPTR_OF(type, x))) 990104477Ssam 991104477Ssamvoid *ASN1_item_d2i_fp(const ASN1_ITEM *it, FILE *in, void *x); 992104477Ssamint ASN1_i2d_fp(i2d_of_void *i2d, FILE *out, void *x); 993104477Ssam 994104477Ssam# define ASN1_i2d_fp_of(type,i2d,out,x) \ 995104477Ssam (ASN1_i2d_fp(CHECKED_I2D_OF(type, i2d), \ 996104477Ssam out, \ 997104477Ssam CHECKED_PTR_OF(type, x))) 998104477Ssam 999104477Ssam# define ASN1_i2d_fp_of_const(type,i2d,out,x) \ 1000104477Ssam (ASN1_i2d_fp(CHECKED_I2D_OF(const type, i2d), \ 1001104477Ssam out, \ 1002104477Ssam CHECKED_PTR_OF(const type, x))) 1003104477Ssam 1004104477Ssamint ASN1_item_i2d_fp(const ASN1_ITEM *it, FILE *out, void *x); 1005104477Ssamint ASN1_STRING_print_ex_fp(FILE *fp, ASN1_STRING *str, unsigned long flags); 1006104477Ssam# endif 1007104477Ssam 1008104477Ssamint ASN1_STRING_to_UTF8(unsigned char **out, ASN1_STRING *in); 1009104477Ssam 1010104477Ssam# ifndef OPENSSL_NO_BIO 1011104477Ssamvoid *ASN1_d2i_bio(void *(*xnew) (void), d2i_of_void *d2i, BIO *in, void **x); 1012104477Ssam 1013104477Ssam# define ASN1_d2i_bio_of(type,xnew,d2i,in,x) \ 1014104477Ssam ((type*)ASN1_d2i_bio( CHECKED_NEW_OF(type, xnew), \ 1015104477Ssam CHECKED_D2I_OF(type, d2i), \ 1016104477Ssam in, \ 1017104477Ssam CHECKED_PPTR_OF(type, x))) 1018104477Ssam 1019104477Ssamvoid *ASN1_item_d2i_bio(const ASN1_ITEM *it, BIO *in, void *x); 1020104477Ssamint ASN1_i2d_bio(i2d_of_void *i2d, BIO *out, unsigned char *x); 1021104477Ssam 1022104477Ssam# define ASN1_i2d_bio_of(type,i2d,out,x) \ 1023104477Ssam (ASN1_i2d_bio(CHECKED_I2D_OF(type, i2d), \ 1024104477Ssam out, \ 1025104477Ssam CHECKED_PTR_OF(type, x))) 1026104477Ssam 1027104477Ssam# define ASN1_i2d_bio_of_const(type,i2d,out,x) \ 1028104477Ssam (ASN1_i2d_bio(CHECKED_I2D_OF(const type, i2d), \ 1029104477Ssam out, \ 1030104477Ssam CHECKED_PTR_OF(const type, x))) 1031104477Ssam 1032104477Ssamint ASN1_item_i2d_bio(const ASN1_ITEM *it, BIO *out, void *x); 1033104477Ssamint ASN1_UTCTIME_print(BIO *fp, const ASN1_UTCTIME *a); 1034104477Ssamint ASN1_GENERALIZEDTIME_print(BIO *fp, const ASN1_GENERALIZEDTIME *a); 1035104477Ssamint ASN1_TIME_print(BIO *fp, const ASN1_TIME *a); 1036104477Ssamint ASN1_STRING_print(BIO *bp, const ASN1_STRING *v); 1037104477Ssamint ASN1_STRING_print_ex(BIO *out, ASN1_STRING *str, unsigned long flags); 1038104477Ssamint ASN1_bn_print(BIO *bp, const char *number, const BIGNUM *num, 1039104477Ssam unsigned char *buf, int off); 1040104477Ssamint ASN1_parse(BIO *bp, const unsigned char *pp, long len, int indent); 1041104477Ssamint ASN1_parse_dump(BIO *bp, const unsigned char *pp, long len, int indent, 1042104477Ssam int dump); 1043104477Ssam# endif 1044104477Ssamconst char *ASN1_tag2str(int tag); 1045104477Ssam 1046104477Ssam/* Used to load and write netscape format cert */ 1047104477Ssam 1048104477SsamDECLARE_ASN1_FUNCTIONS(NETSCAPE_X509) 1049104477Ssam 1050104477Ssamint ASN1_UNIVERSALSTRING_to_string(ASN1_UNIVERSALSTRING *s); 1051104477Ssam 1052104477Ssamint ASN1_TYPE_set_octetstring(ASN1_TYPE *a, unsigned char *data, int len); 1053104477Ssamint ASN1_TYPE_get_octetstring(ASN1_TYPE *a, unsigned char *data, int max_len); 1054104477Ssamint ASN1_TYPE_set_int_octetstring(ASN1_TYPE *a, long num, 1055104477Ssam unsigned char *data, int len); 1056104477Ssamint ASN1_TYPE_get_int_octetstring(ASN1_TYPE *a, long *num, 1057104477Ssam unsigned char *data, int max_len); 1058104477Ssam 1059104477SsamSTACK_OF(OPENSSL_BLOCK) *ASN1_seq_unpack(const unsigned char *buf, int len, 1060104477Ssam d2i_of_void *d2i, 1061104477Ssam void (*free_func) (OPENSSL_BLOCK)); 1062104477Ssamunsigned char *ASN1_seq_pack(STACK_OF(OPENSSL_BLOCK) *safes, i2d_of_void *i2d, 1063104477Ssam unsigned char **buf, int *len); 1064104477Ssamvoid *ASN1_unpack_string(ASN1_STRING *oct, d2i_of_void *d2i); 1065104477Ssamvoid *ASN1_item_unpack(ASN1_STRING *oct, const ASN1_ITEM *it); 1066104477SsamASN1_STRING *ASN1_pack_string(void *obj, i2d_of_void *i2d, 1067104477Ssam ASN1_OCTET_STRING **oct); 1068104477Ssam 1069104477Ssam# define ASN1_pack_string_of(type,obj,i2d,oct) \ 1070104477Ssam (ASN1_pack_string(CHECKED_PTR_OF(type, obj), \ 1071104477Ssam CHECKED_I2D_OF(type, i2d), \ 1072104477Ssam oct)) 1073104477Ssam 1074104477SsamASN1_STRING *ASN1_item_pack(void *obj, const ASN1_ITEM *it, 1075104477Ssam ASN1_OCTET_STRING **oct); 1076104477Ssam 1077104477Ssamvoid ASN1_STRING_set_default_mask(unsigned long mask); 1078104477Ssamint ASN1_STRING_set_default_mask_asc(const char *p); 1079104477Ssamunsigned long ASN1_STRING_get_default_mask(void); 1080104477Ssamint ASN1_mbstring_copy(ASN1_STRING **out, const unsigned char *in, int len, 1081104477Ssam int inform, unsigned long mask); 1082104477Ssamint ASN1_mbstring_ncopy(ASN1_STRING **out, const unsigned char *in, int len, 1083104477Ssam int inform, unsigned long mask, 1084104477Ssam long minsize, long maxsize); 1085104477Ssam 1086104477SsamASN1_STRING *ASN1_STRING_set_by_NID(ASN1_STRING **out, 1087104477Ssam const unsigned char *in, int inlen, 1088104477Ssam int inform, int nid); 1089104477SsamASN1_STRING_TABLE *ASN1_STRING_TABLE_get(int nid); 1090104477Ssamint ASN1_STRING_TABLE_add(int, long, long, unsigned long, unsigned long); 1091104477Ssamvoid ASN1_STRING_TABLE_cleanup(void); 1092104477Ssam 1093104477Ssam/* ASN1 template functions */ 1094104477Ssam 1095104477Ssam/* Old API compatible functions */ 1096104477SsamASN1_VALUE *ASN1_item_new(const ASN1_ITEM *it); 1097104477Ssamvoid ASN1_item_free(ASN1_VALUE *val, const ASN1_ITEM *it); 1098104477SsamASN1_VALUE *ASN1_item_d2i(ASN1_VALUE **val, const unsigned char **in, 1099104477Ssam long len, const ASN1_ITEM *it); 1100104477Ssamint ASN1_item_i2d(ASN1_VALUE *val, unsigned char **out, const ASN1_ITEM *it); 1101104477Ssamint ASN1_item_ndef_i2d(ASN1_VALUE *val, unsigned char **out, 1102104477Ssam const ASN1_ITEM *it); 1103104477Ssam 1104104477Ssamvoid ASN1_add_oid_module(void); 1105104477Ssam 1106104477SsamASN1_TYPE *ASN1_generate_nconf(char *str, CONF *nconf); 1107104477SsamASN1_TYPE *ASN1_generate_v3(char *str, X509V3_CTX *cnf); 1108104477Ssam 1109104477Ssam/* ASN1 Print flags */ 1110104477Ssam 1111104477Ssam/* Indicate missing OPTIONAL fields */ 1112104477Ssam# define ASN1_PCTX_FLAGS_SHOW_ABSENT 0x001 1113104477Ssam/* Mark start and end of SEQUENCE */ 1114104477Ssam# define ASN1_PCTX_FLAGS_SHOW_SEQUENCE 0x002 1115104477Ssam/* Mark start and end of SEQUENCE/SET OF */ 1116104477Ssam# define ASN1_PCTX_FLAGS_SHOW_SSOF 0x004 1117104477Ssam/* Show the ASN1 type of primitives */ 1118104477Ssam# define ASN1_PCTX_FLAGS_SHOW_TYPE 0x008 1119104477Ssam/* Don't show ASN1 type of ANY */ 1120104477Ssam# define ASN1_PCTX_FLAGS_NO_ANY_TYPE 0x010 1121104477Ssam/* Don't show ASN1 type of MSTRINGs */ 1122104477Ssam# define ASN1_PCTX_FLAGS_NO_MSTRING_TYPE 0x020 1123104477Ssam/* Don't show field names in SEQUENCE */ 1124104477Ssam# define ASN1_PCTX_FLAGS_NO_FIELD_NAME 0x040 1125104477Ssam/* Show structure names of each SEQUENCE field */ 1126104477Ssam# define ASN1_PCTX_FLAGS_SHOW_FIELD_STRUCT_NAME 0x080 1127104477Ssam/* Don't show structure name even at top level */ 1128104477Ssam# define ASN1_PCTX_FLAGS_NO_STRUCT_NAME 0x100 1129104477Ssam 1130104477Ssamint ASN1_item_print(BIO *out, ASN1_VALUE *ifld, int indent, 1131104477Ssam const ASN1_ITEM *it, const ASN1_PCTX *pctx); 1132104477SsamASN1_PCTX *ASN1_PCTX_new(void); 1133104477Ssamvoid ASN1_PCTX_free(ASN1_PCTX *p); 1134104477Ssamunsigned long ASN1_PCTX_get_flags(ASN1_PCTX *p); 1135104477Ssamvoid ASN1_PCTX_set_flags(ASN1_PCTX *p, unsigned long flags); 1136104477Ssamunsigned long ASN1_PCTX_get_nm_flags(ASN1_PCTX *p); 1137104477Ssamvoid ASN1_PCTX_set_nm_flags(ASN1_PCTX *p, unsigned long flags); 1138104477Ssamunsigned long ASN1_PCTX_get_cert_flags(ASN1_PCTX *p); 1139104477Ssamvoid ASN1_PCTX_set_cert_flags(ASN1_PCTX *p, unsigned long flags); 1140104477Ssamunsigned long ASN1_PCTX_get_oid_flags(ASN1_PCTX *p); 1141104477Ssamvoid ASN1_PCTX_set_oid_flags(ASN1_PCTX *p, unsigned long flags); 1142104477Ssamunsigned long ASN1_PCTX_get_str_flags(ASN1_PCTX *p); 1143104477Ssamvoid ASN1_PCTX_set_str_flags(ASN1_PCTX *p, unsigned long flags); 1144104477Ssam 1145104477SsamBIO_METHOD *BIO_f_asn1(void); 1146104477Ssam 1147104477SsamBIO *BIO_new_NDEF(BIO *out, ASN1_VALUE *val, const ASN1_ITEM *it); 1148104477Ssam 1149104477Ssamint i2d_ASN1_bio_stream(BIO *out, ASN1_VALUE *val, BIO *in, int flags, 1150104477Ssam const ASN1_ITEM *it); 1151104477Ssamint PEM_write_bio_ASN1_stream(BIO *out, ASN1_VALUE *val, BIO *in, int flags, 1152104477Ssam const char *hdr, const ASN1_ITEM *it); 1153104477Ssamint SMIME_write_ASN1(BIO *bio, ASN1_VALUE *val, BIO *data, int flags, 1154104477Ssam int ctype_nid, int econt_nid, 1155104477Ssam STACK_OF(X509_ALGOR) *mdalgs, const ASN1_ITEM *it); 1156104477SsamASN1_VALUE *SMIME_read_ASN1(BIO *bio, BIO **bcont, const ASN1_ITEM *it); 1157104477Ssamint SMIME_crlf_copy(BIO *in, BIO *out, int flags); 1158104477Ssamint SMIME_text(BIO *in, BIO *out); 1159104477Ssam 1160104477Ssam/* BEGIN ERROR CODES */ 1161104477Ssam/* 1162104477Ssam * The following lines are auto generated by the script mkerr.pl. Any changes 1163104477Ssam * made after this point may be overwritten when the script is next run. 1164104477Ssam */ 1165104477Ssamvoid ERR_load_ASN1_strings(void); 1166104477Ssam 1167104477Ssam/* Error codes for the ASN1 functions. */ 1168104477Ssam 1169104477Ssam/* Function codes. */ 1170104477Ssam# define ASN1_F_A2D_ASN1_OBJECT 100 1171104477Ssam# define ASN1_F_A2I_ASN1_ENUMERATED 101 1172104477Ssam# define ASN1_F_A2I_ASN1_INTEGER 102 1173104477Ssam# define ASN1_F_A2I_ASN1_STRING 103 1174104477Ssam# define ASN1_F_APPEND_EXP 176 1175104477Ssam# define ASN1_F_ASN1_BIT_STRING_SET_BIT 183 1176104477Ssam# define ASN1_F_ASN1_CB 177 1177104477Ssam# define ASN1_F_ASN1_CHECK_TLEN 104 1178104477Ssam# define ASN1_F_ASN1_COLLATE_PRIMITIVE 105 1179104477Ssam# define ASN1_F_ASN1_COLLECT 106 1180104477Ssam# define ASN1_F_ASN1_D2I_EX_PRIMITIVE 108 1181104477Ssam# define ASN1_F_ASN1_D2I_FP 109 1182104477Ssam# define ASN1_F_ASN1_D2I_READ_BIO 107 1183104477Ssam# define ASN1_F_ASN1_DIGEST 184 1184104477Ssam# define ASN1_F_ASN1_DO_ADB 110 1185104477Ssam# define ASN1_F_ASN1_DUP 111 1186104477Ssam# define ASN1_F_ASN1_ENUMERATED_SET 112 1187104477Ssam# define ASN1_F_ASN1_ENUMERATED_TO_BN 113 1188104477Ssam# define ASN1_F_ASN1_EX_C2I 204 1189104477Ssam# define ASN1_F_ASN1_FIND_END 190 1190104477Ssam# define ASN1_F_ASN1_GENERALIZEDTIME_ADJ 216 1191104477Ssam# define ASN1_F_ASN1_GENERALIZEDTIME_SET 185 1192104477Ssam# define ASN1_F_ASN1_GENERATE_V3 178 1193104477Ssam# define ASN1_F_ASN1_GET_OBJECT 114 1194104477Ssam# define ASN1_F_ASN1_HEADER_NEW 115 1195104477Ssam# define ASN1_F_ASN1_I2D_BIO 116 1196104477Ssam# define ASN1_F_ASN1_I2D_FP 117 1197104477Ssam# define ASN1_F_ASN1_INTEGER_SET 118 1198104477Ssam# define ASN1_F_ASN1_INTEGER_TO_BN 119 1199104477Ssam# define ASN1_F_ASN1_ITEM_D2I_FP 206 1200104477Ssam# define ASN1_F_ASN1_ITEM_DUP 191 1201104477Ssam# define ASN1_F_ASN1_ITEM_EX_COMBINE_NEW 121 1202104477Ssam# define ASN1_F_ASN1_ITEM_EX_D2I 120 1203104477Ssam# define ASN1_F_ASN1_ITEM_I2D_BIO 192 1204104477Ssam# define ASN1_F_ASN1_ITEM_I2D_FP 193 1205104477Ssam# define ASN1_F_ASN1_ITEM_PACK 198 1206104477Ssam# define ASN1_F_ASN1_ITEM_SIGN 195 1207104477Ssam# define ASN1_F_ASN1_ITEM_SIGN_CTX 220 1208104477Ssam# define ASN1_F_ASN1_ITEM_UNPACK 199 1209104477Ssam# define ASN1_F_ASN1_ITEM_VERIFY 197 1210104477Ssam# define ASN1_F_ASN1_MBSTRING_NCOPY 122 1211104477Ssam# define ASN1_F_ASN1_OBJECT_NEW 123 1212104477Ssam# define ASN1_F_ASN1_OUTPUT_DATA 214 1213104477Ssam# define ASN1_F_ASN1_PACK_STRING 124 1214104477Ssam# define ASN1_F_ASN1_PCTX_NEW 205 1215104477Ssam# define ASN1_F_ASN1_PKCS5_PBE_SET 125 1216104477Ssam# define ASN1_F_ASN1_SEQ_PACK 126 1217104477Ssam# define ASN1_F_ASN1_SEQ_UNPACK 127 1218104477Ssam# define ASN1_F_ASN1_SIGN 128 1219104477Ssam# define ASN1_F_ASN1_STR2TYPE 179 1220104477Ssam# define ASN1_F_ASN1_STRING_SET 186 1221104477Ssam# define ASN1_F_ASN1_STRING_TABLE_ADD 129 1222104477Ssam# define ASN1_F_ASN1_STRING_TYPE_NEW 130 1223104477Ssam# define ASN1_F_ASN1_TEMPLATE_EX_D2I 132 1224104477Ssam# define ASN1_F_ASN1_TEMPLATE_NEW 133 1225104477Ssam# define ASN1_F_ASN1_TEMPLATE_NOEXP_D2I 131 1226104477Ssam# define ASN1_F_ASN1_TIME_ADJ 217 1227104477Ssam# define ASN1_F_ASN1_TIME_SET 175 1228104477Ssam# define ASN1_F_ASN1_TYPE_GET_INT_OCTETSTRING 134 1229104477Ssam# define ASN1_F_ASN1_TYPE_GET_OCTETSTRING 135 1230104477Ssam# define ASN1_F_ASN1_UNPACK_STRING 136 1231104477Ssam# define ASN1_F_ASN1_UTCTIME_ADJ 218 1232104477Ssam# define ASN1_F_ASN1_UTCTIME_SET 187 1233104477Ssam# define ASN1_F_ASN1_VERIFY 137 1234104477Ssam# define ASN1_F_B64_READ_ASN1 209 1235104477Ssam# define ASN1_F_B64_WRITE_ASN1 210 1236104477Ssam# define ASN1_F_BIO_NEW_NDEF 208 1237104477Ssam# define ASN1_F_BITSTR_CB 180 1238104477Ssam# define ASN1_F_BN_TO_ASN1_ENUMERATED 138 1239104477Ssam# define ASN1_F_BN_TO_ASN1_INTEGER 139 1240104477Ssam# define ASN1_F_C2I_ASN1_BIT_STRING 189 1241104477Ssam# define ASN1_F_C2I_ASN1_INTEGER 194 1242104477Ssam# define ASN1_F_C2I_ASN1_OBJECT 196 1243104477Ssam# define ASN1_F_COLLECT_DATA 140 1244104477Ssam# define ASN1_F_D2I_ASN1_BIT_STRING 141 1245104477Ssam# define ASN1_F_D2I_ASN1_BOOLEAN 142 1246104477Ssam# define ASN1_F_D2I_ASN1_BYTES 143 1247104477Ssam# define ASN1_F_D2I_ASN1_GENERALIZEDTIME 144 1248104477Ssam# define ASN1_F_D2I_ASN1_HEADER 145 1249104477Ssam# define ASN1_F_D2I_ASN1_INTEGER 146 1250104477Ssam# define ASN1_F_D2I_ASN1_OBJECT 147 1251104477Ssam# define ASN1_F_D2I_ASN1_SET 148 1252104477Ssam# define ASN1_F_D2I_ASN1_TYPE_BYTES 149 1253104477Ssam# define ASN1_F_D2I_ASN1_UINTEGER 150 1254104477Ssam# define ASN1_F_D2I_ASN1_UTCTIME 151 1255104477Ssam# define ASN1_F_D2I_AUTOPRIVATEKEY 207 1256104477Ssam# define ASN1_F_D2I_NETSCAPE_RSA 152 1257104477Ssam# define ASN1_F_D2I_NETSCAPE_RSA_2 153 1258104477Ssam# define ASN1_F_D2I_PRIVATEKEY 154 1259104477Ssam# define ASN1_F_D2I_PUBLICKEY 155 1260104477Ssam# define ASN1_F_D2I_RSA_NET 200 1261104477Ssam# define ASN1_F_D2I_RSA_NET_2 201 1262104477Ssam# define ASN1_F_D2I_X509 156 1263104477Ssam# define ASN1_F_D2I_X509_CINF 157 1264104477Ssam# define ASN1_F_D2I_X509_PKEY 159 1265104477Ssam# define ASN1_F_I2D_ASN1_BIO_STREAM 211 1266104477Ssam# define ASN1_F_I2D_ASN1_SET 188 1267104477Ssam# define ASN1_F_I2D_ASN1_TIME 160 1268104477Ssam# define ASN1_F_I2D_DSA_PUBKEY 161 1269104477Ssam# define ASN1_F_I2D_EC_PUBKEY 181 1270104477Ssam# define ASN1_F_I2D_PRIVATEKEY 163 1271104477Ssam# define ASN1_F_I2D_PUBLICKEY 164 1272104477Ssam# define ASN1_F_I2D_RSA_NET 162 1273104477Ssam# define ASN1_F_I2D_RSA_PUBKEY 165 1274104477Ssam# define ASN1_F_LONG_C2I 166 1275104477Ssam# define ASN1_F_OID_MODULE_INIT 174 1276104477Ssam# define ASN1_F_PARSE_TAGGING 182 1277104477Ssam# define ASN1_F_PKCS5_PBE2_SET_IV 167 1278104477Ssam# define ASN1_F_PKCS5_PBE_SET 202 1279104477Ssam# define ASN1_F_PKCS5_PBE_SET0_ALGOR 215 1280104477Ssam# define ASN1_F_PKCS5_PBKDF2_SET 219 1281104477Ssam# define ASN1_F_SMIME_READ_ASN1 212 1282104477Ssam# define ASN1_F_SMIME_TEXT 213 1283104477Ssam# define ASN1_F_X509_CINF_NEW 168 1284104477Ssam# define ASN1_F_X509_CRL_ADD0_REVOKED 169 1285104477Ssam# define ASN1_F_X509_INFO_NEW 170 1286104477Ssam# define ASN1_F_X509_NAME_ENCODE 203 1287104477Ssam# define ASN1_F_X509_NAME_EX_D2I 158 1288104477Ssam# define ASN1_F_X509_NAME_EX_NEW 171 1289104477Ssam# define ASN1_F_X509_NEW 172 1290104477Ssam# define ASN1_F_X509_PKEY_NEW 173 1291104477Ssam 1292104477Ssam/* Reason codes. */ 1293104477Ssam# define ASN1_R_ADDING_OBJECT 171 1294104477Ssam# define ASN1_R_ASN1_PARSE_ERROR 203 1295104477Ssam# define ASN1_R_ASN1_SIG_PARSE_ERROR 204 1296104477Ssam# define ASN1_R_AUX_ERROR 100 1297104477Ssam# define ASN1_R_BAD_CLASS 101 1298104477Ssam# define ASN1_R_BAD_OBJECT_HEADER 102 1299104477Ssam# define ASN1_R_BAD_PASSWORD_READ 103 1300104477Ssam# define ASN1_R_BAD_TAG 104 1301104477Ssam# define ASN1_R_BMPSTRING_IS_WRONG_LENGTH 214 1302104477Ssam# define ASN1_R_BN_LIB 105 1303104477Ssam# define ASN1_R_BOOLEAN_IS_WRONG_LENGTH 106 1304104477Ssam# define ASN1_R_BUFFER_TOO_SMALL 107 1305104477Ssam# define ASN1_R_CIPHER_HAS_NO_OBJECT_IDENTIFIER 108 1306104477Ssam# define ASN1_R_CONTEXT_NOT_INITIALISED 217 1307104477Ssam# define ASN1_R_DATA_IS_WRONG 109 1308104477Ssam# define ASN1_R_DECODE_ERROR 110 1309104477Ssam# define ASN1_R_DECODING_ERROR 111 1310104477Ssam# define ASN1_R_DEPTH_EXCEEDED 174 1311104477Ssam# define ASN1_R_DIGEST_AND_KEY_TYPE_NOT_SUPPORTED 198 1312104477Ssam# define ASN1_R_ENCODE_ERROR 112 1313104477Ssam# define ASN1_R_ERROR_GETTING_TIME 173 1314104477Ssam# define ASN1_R_ERROR_LOADING_SECTION 172 1315104477Ssam# define ASN1_R_ERROR_PARSING_SET_ELEMENT 113 1316104477Ssam# define ASN1_R_ERROR_SETTING_CIPHER_PARAMS 114 1317104477Ssam# define ASN1_R_EXPECTING_AN_INTEGER 115 1318104477Ssam# define ASN1_R_EXPECTING_AN_OBJECT 116 1319104477Ssam# define ASN1_R_EXPECTING_A_BOOLEAN 117 1320104477Ssam# define ASN1_R_EXPECTING_A_TIME 118 1321104477Ssam# define ASN1_R_EXPLICIT_LENGTH_MISMATCH 119 1322104477Ssam# define ASN1_R_EXPLICIT_TAG_NOT_CONSTRUCTED 120 1323104477Ssam# define ASN1_R_FIELD_MISSING 121 1324104477Ssam# define ASN1_R_FIRST_NUM_TOO_LARGE 122 1325104477Ssam# define ASN1_R_HEADER_TOO_LONG 123 1326104477Ssam# define ASN1_R_ILLEGAL_BITSTRING_FORMAT 175 1327104477Ssam# define ASN1_R_ILLEGAL_BOOLEAN 176 1328104477Ssam# define ASN1_R_ILLEGAL_CHARACTERS 124 1329104477Ssam# define ASN1_R_ILLEGAL_FORMAT 177 1330104477Ssam# define ASN1_R_ILLEGAL_HEX 178 1331104477Ssam# define ASN1_R_ILLEGAL_IMPLICIT_TAG 179 1332104477Ssam# define ASN1_R_ILLEGAL_INTEGER 180 1333104477Ssam# define ASN1_R_ILLEGAL_NESTED_TAGGING 181 1334104477Ssam# define ASN1_R_ILLEGAL_NULL 125 1335104477Ssam# define ASN1_R_ILLEGAL_NULL_VALUE 182 1336104477Ssam# define ASN1_R_ILLEGAL_OBJECT 183 1337104477Ssam# define ASN1_R_ILLEGAL_OPTIONAL_ANY 126 1338104477Ssam# define ASN1_R_ILLEGAL_OPTIONS_ON_ITEM_TEMPLATE 170 1339104477Ssam# define ASN1_R_ILLEGAL_TAGGED_ANY 127 1340104477Ssam# define ASN1_R_ILLEGAL_TIME_VALUE 184 1341104477Ssam# define ASN1_R_INTEGER_NOT_ASCII_FORMAT 185 1342104477Ssam# define ASN1_R_INTEGER_TOO_LARGE_FOR_LONG 128 1343104477Ssam# define ASN1_R_INVALID_BIT_STRING_BITS_LEFT 220 1344104477Ssam# define ASN1_R_INVALID_BMPSTRING_LENGTH 129 1345104477Ssam# define ASN1_R_INVALID_DIGIT 130 1346104477Ssam# define ASN1_R_INVALID_MIME_TYPE 205 1347104477Ssam# define ASN1_R_INVALID_MODIFIER 186 1348104477Ssam# define ASN1_R_INVALID_NUMBER 187 1349104477Ssam# define ASN1_R_INVALID_OBJECT_ENCODING 216 1350104477Ssam# define ASN1_R_INVALID_SEPARATOR 131 1351104477Ssam# define ASN1_R_INVALID_TIME_FORMAT 132 1352104477Ssam# define ASN1_R_INVALID_UNIVERSALSTRING_LENGTH 133 1353104477Ssam# define ASN1_R_INVALID_UTF8STRING 134 1354104477Ssam# define ASN1_R_IV_TOO_LARGE 135 1355104477Ssam# define ASN1_R_LENGTH_ERROR 136 1356104477Ssam# define ASN1_R_LIST_ERROR 188 1357104477Ssam# define ASN1_R_MIME_NO_CONTENT_TYPE 206 1358104477Ssam# define ASN1_R_MIME_PARSE_ERROR 207 1359104477Ssam# define ASN1_R_MIME_SIG_PARSE_ERROR 208 1360104477Ssam# define ASN1_R_MISSING_EOC 137 1361104477Ssam# define ASN1_R_MISSING_SECOND_NUMBER 138 1362104477Ssam# define ASN1_R_MISSING_VALUE 189 1363104477Ssam# define ASN1_R_MSTRING_NOT_UNIVERSAL 139 1364104477Ssam# define ASN1_R_MSTRING_WRONG_TAG 140 1365104477Ssam# define ASN1_R_NESTED_ASN1_STRING 197 1366104477Ssam# define ASN1_R_NON_HEX_CHARACTERS 141 1367104477Ssam# define ASN1_R_NOT_ASCII_FORMAT 190 1368104477Ssam# define ASN1_R_NOT_ENOUGH_DATA 142 1369104477Ssam# define ASN1_R_NO_CONTENT_TYPE 209 1370104477Ssam# define ASN1_R_NO_DEFAULT_DIGEST 201 1371104477Ssam# define ASN1_R_NO_MATCHING_CHOICE_TYPE 143 1372104477Ssam# define ASN1_R_NO_MULTIPART_BODY_FAILURE 210 1373104477Ssam# define ASN1_R_NO_MULTIPART_BOUNDARY 211 1374104477Ssam# define ASN1_R_NO_SIG_CONTENT_TYPE 212 1375104477Ssam# define ASN1_R_NULL_IS_WRONG_LENGTH 144 1376104477Ssam# define ASN1_R_OBJECT_NOT_ASCII_FORMAT 191 1377104477Ssam# define ASN1_R_ODD_NUMBER_OF_CHARS 145 1378104477Ssam# define ASN1_R_PRIVATE_KEY_HEADER_MISSING 146 1379104477Ssam# define ASN1_R_SECOND_NUMBER_TOO_LARGE 147 1380104477Ssam# define ASN1_R_SEQUENCE_LENGTH_MISMATCH 148 1381104477Ssam# define ASN1_R_SEQUENCE_NOT_CONSTRUCTED 149 1382104477Ssam# define ASN1_R_SEQUENCE_OR_SET_NEEDS_CONFIG 192 1383104477Ssam# define ASN1_R_SHORT_LINE 150 1384104477Ssam# define ASN1_R_SIG_INVALID_MIME_TYPE 213 1385104477Ssam# define ASN1_R_STREAMING_NOT_SUPPORTED 202 1386104477Ssam# define ASN1_R_STRING_TOO_LONG 151 1387104477Ssam# define ASN1_R_STRING_TOO_SHORT 152 1388104477Ssam# define ASN1_R_TAG_VALUE_TOO_HIGH 153 1389104477Ssam# define ASN1_R_THE_ASN1_OBJECT_IDENTIFIER_IS_NOT_KNOWN_FOR_THIS_MD 154 1390104477Ssam# define ASN1_R_TIME_NOT_ASCII_FORMAT 193 1391104477Ssam# define ASN1_R_TOO_LONG 155 1392104477Ssam# define ASN1_R_TYPE_NOT_CONSTRUCTED 156 1393104477Ssam# define ASN1_R_TYPE_NOT_PRIMITIVE 218 1394104477Ssam# define ASN1_R_UNABLE_TO_DECODE_RSA_KEY 157 1395104477Ssam# define ASN1_R_UNABLE_TO_DECODE_RSA_PRIVATE_KEY 158 1396104477Ssam# define ASN1_R_UNEXPECTED_EOC 159 1397104477Ssam# define ASN1_R_UNIVERSALSTRING_IS_WRONG_LENGTH 215 1398104477Ssam# define ASN1_R_UNKNOWN_FORMAT 160 1399104477Ssam# define ASN1_R_UNKNOWN_MESSAGE_DIGEST_ALGORITHM 161 1400104477Ssam# define ASN1_R_UNKNOWN_OBJECT_TYPE 162 1401104477Ssam# define ASN1_R_UNKNOWN_PUBLIC_KEY_TYPE 163 1402104477Ssam# define ASN1_R_UNKNOWN_SIGNATURE_ALGORITHM 199 1403104477Ssam# define ASN1_R_UNKNOWN_TAG 194 1404104477Ssam# define ASN1_R_UNKOWN_FORMAT 195 1405104477Ssam# define ASN1_R_UNSUPPORTED_ANY_DEFINED_BY_TYPE 164 1406104477Ssam# define ASN1_R_UNSUPPORTED_CIPHER 165 1407104477Ssam# define ASN1_R_UNSUPPORTED_ENCRYPTION_ALGORITHM 166 1408104477Ssam# define ASN1_R_UNSUPPORTED_PUBLIC_KEY_TYPE 167 1409104477Ssam# define ASN1_R_UNSUPPORTED_TYPE 196 1410104477Ssam# define ASN1_R_WRONG_PUBLIC_KEY_TYPE 200 1411104477Ssam# define ASN1_R_WRONG_TAG 168 1412104477Ssam# define ASN1_R_WRONG_TYPE 169 1413104477Ssam 1414104477Ssam#ifdef __cplusplus 1415104477Ssam} 1416104477Ssam#endif 1417104477Ssam#endif 1418104477Ssam