LTKCPP-- LLRP Toolkit C Plus Plus Library
|
00001 /* crypto/asn1/asn1.h */ 00002 /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 00003 * All rights reserved. 00004 * 00005 * This package is an SSL implementation written 00006 * by Eric Young (eay@cryptsoft.com). 00007 * The implementation was written so as to conform with Netscapes SSL. 00008 * 00009 * This library is free for commercial and non-commercial use as long as 00010 * the following conditions are aheared to. The following conditions 00011 * apply to all code found in this distribution, be it the RC4, RSA, 00012 * lhash, DES, etc., code; not just the SSL code. The SSL documentation 00013 * included with this distribution is covered by the same copyright terms 00014 * except that the holder is Tim Hudson (tjh@cryptsoft.com). 00015 * 00016 * Copyright remains Eric Young's, and as such any Copyright notices in 00017 * the code are not to be removed. 00018 * If this package is used in a product, Eric Young should be given attribution 00019 * as the author of the parts of the library used. 00020 * This can be in the form of a textual message at program startup or 00021 * in documentation (online or textual) provided with the package. 00022 * 00023 * Redistribution and use in source and binary forms, with or without 00024 * modification, are permitted provided that the following conditions 00025 * are met: 00026 * 1. Redistributions of source code must retain the copyright 00027 * notice, this list of conditions and the following disclaimer. 00028 * 2. Redistributions in binary form must reproduce the above copyright 00029 * notice, this list of conditions and the following disclaimer in the 00030 * documentation and/or other materials provided with the distribution. 00031 * 3. All advertising materials mentioning features or use of this software 00032 * must display the following acknowledgement: 00033 * "This product includes cryptographic software written by 00034 * Eric Young (eay@cryptsoft.com)" 00035 * The word 'cryptographic' can be left out if the rouines from the library 00036 * being used are not cryptographic related :-). 00037 * 4. If you include any Windows specific code (or a derivative thereof) from 00038 * the apps directory (application code) you must include an acknowledgement: 00039 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" 00040 * 00041 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND 00042 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00043 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 00044 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 00045 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 00046 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 00047 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 00048 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 00049 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 00050 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 00051 * SUCH DAMAGE. 00052 * 00053 * The licence and distribution terms for any publically available version or 00054 * derivative of this code cannot be changed. i.e. this code cannot simply be 00055 * copied and put under another distribution licence 00056 * [including the GNU Public Licence.] 00057 */ 00058 00059 #ifndef HEADER_ASN1_H 00060 # define HEADER_ASN1_H 00061 00062 # include <time.h> 00063 # include <openssl/e_os2.h> 00064 # ifndef OPENSSL_NO_BIO 00065 # include <openssl/bio.h> 00066 # endif 00067 # include <openssl/stack.h> 00068 # include <openssl/safestack.h> 00069 00070 # include <openssl/symhacks.h> 00071 00072 # include <openssl/ossl_typ.h> 00073 # ifndef OPENSSL_NO_DEPRECATED 00074 # include <openssl/bn.h> 00075 # endif 00076 00077 # ifdef OPENSSL_BUILD_SHLIBCRYPTO 00078 # undef OPENSSL_EXTERN 00079 # define OPENSSL_EXTERN OPENSSL_EXPORT 00080 # endif 00081 00082 #ifdef __cplusplus 00083 extern "C" { 00084 #endif 00085 00086 # define V_ASN1_UNIVERSAL 0x00 00087 # define V_ASN1_APPLICATION 0x40 00088 # define V_ASN1_CONTEXT_SPECIFIC 0x80 00089 # define V_ASN1_PRIVATE 0xc0 00090 00091 # define V_ASN1_CONSTRUCTED 0x20 00092 # define V_ASN1_PRIMITIVE_TAG 0x1f 00093 # define V_ASN1_PRIMATIVE_TAG 0x1f 00094 00095 # define V_ASN1_APP_CHOOSE -2/* let the recipient choose */ 00096 # define V_ASN1_OTHER -3/* used in ASN1_TYPE */ 00097 # define V_ASN1_ANY -4/* used in ASN1 template code */ 00098 00099 # define V_ASN1_NEG 0x100/* negative flag */ 00100 00101 # define V_ASN1_UNDEF -1 00102 # define V_ASN1_EOC 0 00103 # define V_ASN1_BOOLEAN 1 00104 # define V_ASN1_INTEGER 2 00105 # define V_ASN1_NEG_INTEGER (2 | V_ASN1_NEG) 00106 # define V_ASN1_BIT_STRING 3 00107 # define V_ASN1_OCTET_STRING 4 00108 # define V_ASN1_NULL 5 00109 # define V_ASN1_OBJECT 6 00110 # define V_ASN1_OBJECT_DESCRIPTOR 7 00111 # define V_ASN1_EXTERNAL 8 00112 # define V_ASN1_REAL 9 00113 # define V_ASN1_ENUMERATED 10 00114 # define V_ASN1_NEG_ENUMERATED (10 | V_ASN1_NEG) 00115 # define V_ASN1_UTF8STRING 12 00116 # define V_ASN1_SEQUENCE 16 00117 # define V_ASN1_SET 17 00118 # define V_ASN1_NUMERICSTRING 18 00119 # define V_ASN1_PRINTABLESTRING 19 00120 # define V_ASN1_T61STRING 20 00121 # define V_ASN1_TELETEXSTRING 20/* alias */ 00122 # define V_ASN1_VIDEOTEXSTRING 21 00123 # define V_ASN1_IA5STRING 22 00124 # define V_ASN1_UTCTIME 23 00125 # define V_ASN1_GENERALIZEDTIME 24 00126 # define V_ASN1_GRAPHICSTRING 25 00127 # define V_ASN1_ISO64STRING 26 00128 # define V_ASN1_VISIBLESTRING 26/* alias */ 00129 # define V_ASN1_GENERALSTRING 27 00130 # define V_ASN1_UNIVERSALSTRING 28 00131 # define V_ASN1_BMPSTRING 30 00132 /* For use with d2i_ASN1_type_bytes() */ 00133 # define B_ASN1_NUMERICSTRING 0x0001 00134 # define B_ASN1_PRINTABLESTRING 0x0002 00135 # define B_ASN1_T61STRING 0x0004 00136 # define B_ASN1_TELETEXSTRING 0x0004 00137 # define B_ASN1_VIDEOTEXSTRING 0x0008 00138 # define B_ASN1_IA5STRING 0x0010 00139 # define B_ASN1_GRAPHICSTRING 0x0020 00140 # define B_ASN1_ISO64STRING 0x0040 00141 # define B_ASN1_VISIBLESTRING 0x0040 00142 # define B_ASN1_GENERALSTRING 0x0080 00143 # define B_ASN1_UNIVERSALSTRING 0x0100 00144 # define B_ASN1_OCTET_STRING 0x0200 00145 # define B_ASN1_BIT_STRING 0x0400 00146 # define B_ASN1_BMPSTRING 0x0800 00147 # define B_ASN1_UNKNOWN 0x1000 00148 # define B_ASN1_UTF8STRING 0x2000 00149 # define B_ASN1_UTCTIME 0x4000 00150 # define B_ASN1_GENERALIZEDTIME 0x8000 00151 # define B_ASN1_SEQUENCE 0x10000 00152 /* For use with ASN1_mbstring_copy() */ 00153 # define MBSTRING_FLAG 0x1000 00154 # define MBSTRING_UTF8 (MBSTRING_FLAG) 00155 # define MBSTRING_ASC (MBSTRING_FLAG|1) 00156 # define MBSTRING_BMP (MBSTRING_FLAG|2) 00157 # define MBSTRING_UNIV (MBSTRING_FLAG|4) 00158 # define SMIME_OLDMIME 0x400 00159 # define SMIME_CRLFEOL 0x800 00160 # define SMIME_STREAM 0x1000 00161 struct X509_algor_st; 00162 DECLARE_STACK_OF(X509_ALGOR) 00163 00164 # define DECLARE_ASN1_SET_OF(type)/* filled in by mkstack.pl */ 00165 # define IMPLEMENT_ASN1_SET_OF(type)/* nothing, no longer needed */ 00166 00167 /* 00168 * We MUST make sure that, except for constness, asn1_ctx_st and 00169 * asn1_const_ctx are exactly the same. Fortunately, as soon as the old ASN1 00170 * parsing macros are gone, we can throw this away as well... 00171 */ 00172 typedef struct asn1_ctx_st { 00173 unsigned char *p; /* work char pointer */ 00174 int eos; /* end of sequence read for indefinite 00175 * encoding */ 00176 int error; /* error code to use when returning an error */ 00177 int inf; /* constructed if 0x20, indefinite is 0x21 */ 00178 int tag; /* tag from last 'get object' */ 00179 int xclass; /* class from last 'get object' */ 00180 long slen; /* length of last 'get object' */ 00181 unsigned char *max; /* largest value of p allowed */ 00182 unsigned char *q; /* temporary variable */ 00183 unsigned char **pp; /* variable */ 00184 int line; /* used in error processing */ 00185 } ASN1_CTX; 00186 00187 typedef struct asn1_const_ctx_st { 00188 const unsigned char *p; /* work char pointer */ 00189 int eos; /* end of sequence read for indefinite 00190 * encoding */ 00191 int error; /* error code to use when returning an error */ 00192 int inf; /* constructed if 0x20, indefinite is 0x21 */ 00193 int tag; /* tag from last 'get object' */ 00194 int xclass; /* class from last 'get object' */ 00195 long slen; /* length of last 'get object' */ 00196 const unsigned char *max; /* largest value of p allowed */ 00197 const unsigned char *q; /* temporary variable */ 00198 const unsigned char **pp; /* variable */ 00199 int line; /* used in error processing */ 00200 } ASN1_const_CTX; 00201 00202 /* 00203 * These are used internally in the ASN1_OBJECT to keep track of whether the 00204 * names and data need to be free()ed 00205 */ 00206 # define ASN1_OBJECT_FLAG_DYNAMIC 0x01/* internal use */ 00207 # define ASN1_OBJECT_FLAG_CRITICAL 0x02/* critical x509v3 object id */ 00208 # define ASN1_OBJECT_FLAG_DYNAMIC_STRINGS 0x04/* internal use */ 00209 # define ASN1_OBJECT_FLAG_DYNAMIC_DATA 0x08/* internal use */ 00210 struct asn1_object_st { 00211 const char *sn, *ln; 00212 int nid; 00213 int length; 00214 const unsigned char *data; /* data remains const after init */ 00215 int flags; /* Should we free this one */ 00216 }; 00217 00218 # define ASN1_STRING_FLAG_BITS_LEFT 0x08/* Set if 0x07 has bits left value */ 00219 /* 00220 * This indicates that the ASN1_STRING is not a real value but just a place 00221 * holder for the location where indefinite length constructed data should be 00222 * inserted in the memory buffer 00223 */ 00224 # define ASN1_STRING_FLAG_NDEF 0x010 00225 00226 /* 00227 * This flag is used by the CMS code to indicate that a string is not 00228 * complete and is a place holder for content when it had all been accessed. 00229 * The flag will be reset when content has been written to it. 00230 */ 00231 00232 # define ASN1_STRING_FLAG_CONT 0x020 00233 /* 00234 * This flag is used by ASN1 code to indicate an ASN1_STRING is an MSTRING 00235 * type. 00236 */ 00237 # define ASN1_STRING_FLAG_MSTRING 0x040 00238 /* This is the base type that holds just about everything :-) */ 00239 struct asn1_string_st { 00240 int length; 00241 int type; 00242 unsigned char *data; 00243 /* 00244 * The value of the following field depends on the type being held. It 00245 * is mostly being used for BIT_STRING so if the input data has a 00246 * non-zero 'unused bits' value, it will be handled correctly 00247 */ 00248 long flags; 00249 }; 00250 00251 /* 00252 * ASN1_ENCODING structure: this is used to save the received encoding of an 00253 * ASN1 type. This is useful to get round problems with invalid encodings 00254 * which can break signatures. 00255 */ 00256 00257 typedef struct ASN1_ENCODING_st { 00258 unsigned char *enc; /* DER encoding */ 00259 long len; /* Length of encoding */ 00260 int modified; /* set to 1 if 'enc' is invalid */ 00261 } ASN1_ENCODING; 00262 00263 /* Used with ASN1 LONG type: if a long is set to this it is omitted */ 00264 # define ASN1_LONG_UNDEF 0x7fffffffL 00265 00266 # define STABLE_FLAGS_MALLOC 0x01 00267 # define STABLE_NO_MASK 0x02 00268 # define DIRSTRING_TYPE \ 00269 (B_ASN1_PRINTABLESTRING|B_ASN1_T61STRING|B_ASN1_BMPSTRING|B_ASN1_UTF8STRING) 00270 # define PKCS9STRING_TYPE (DIRSTRING_TYPE|B_ASN1_IA5STRING) 00271 00272 typedef struct asn1_string_table_st { 00273 int nid; 00274 long minsize; 00275 long maxsize; 00276 unsigned long mask; 00277 unsigned long flags; 00278 } ASN1_STRING_TABLE; 00279 00280 DECLARE_STACK_OF(ASN1_STRING_TABLE) 00281 00282 /* size limits: this stuff is taken straight from RFC2459 */ 00283 00284 # define ub_name 32768 00285 # define ub_common_name 64 00286 # define ub_locality_name 128 00287 # define ub_state_name 128 00288 # define ub_organization_name 64 00289 # define ub_organization_unit_name 64 00290 # define ub_title 64 00291 # define ub_email_address 128 00292 00293 /* 00294 * Declarations for template structures: for full definitions see asn1t.h 00295 */ 00296 typedef struct ASN1_TEMPLATE_st ASN1_TEMPLATE; 00297 typedef struct ASN1_TLC_st ASN1_TLC; 00298 /* This is just an opaque pointer */ 00299 typedef struct ASN1_VALUE_st ASN1_VALUE; 00300 00301 /* Declare ASN1 functions: the implement macro in in asn1t.h */ 00302 00303 # define DECLARE_ASN1_FUNCTIONS(type) DECLARE_ASN1_FUNCTIONS_name(type, type) 00304 00305 # define DECLARE_ASN1_ALLOC_FUNCTIONS(type) \ 00306 DECLARE_ASN1_ALLOC_FUNCTIONS_name(type, type) 00307 00308 # define DECLARE_ASN1_FUNCTIONS_name(type, name) \ 00309 DECLARE_ASN1_ALLOC_FUNCTIONS_name(type, name) \ 00310 DECLARE_ASN1_ENCODE_FUNCTIONS(type, name, name) 00311 00312 # define DECLARE_ASN1_FUNCTIONS_fname(type, itname, name) \ 00313 DECLARE_ASN1_ALLOC_FUNCTIONS_name(type, name) \ 00314 DECLARE_ASN1_ENCODE_FUNCTIONS(type, itname, name) 00315 00316 # define DECLARE_ASN1_ENCODE_FUNCTIONS(type, itname, name) \ 00317 type *d2i_##name(type **a, const unsigned char **in, long len); \ 00318 int i2d_##name(type *a, unsigned char **out); \ 00319 DECLARE_ASN1_ITEM(itname) 00320 00321 # define DECLARE_ASN1_ENCODE_FUNCTIONS_const(type, name) \ 00322 type *d2i_##name(type **a, const unsigned char **in, long len); \ 00323 int i2d_##name(const type *a, unsigned char **out); \ 00324 DECLARE_ASN1_ITEM(name) 00325 00326 # define DECLARE_ASN1_NDEF_FUNCTION(name) \ 00327 int i2d_##name##_NDEF(name *a, unsigned char **out); 00328 00329 # define DECLARE_ASN1_FUNCTIONS_const(name) \ 00330 DECLARE_ASN1_ALLOC_FUNCTIONS(name) \ 00331 DECLARE_ASN1_ENCODE_FUNCTIONS_const(name, name) 00332 00333 # define DECLARE_ASN1_ALLOC_FUNCTIONS_name(type, name) \ 00334 type *name##_new(void); \ 00335 void name##_free(type *a); 00336 00337 # define DECLARE_ASN1_PRINT_FUNCTION(stname) \ 00338 DECLARE_ASN1_PRINT_FUNCTION_fname(stname, stname) 00339 00340 # define DECLARE_ASN1_PRINT_FUNCTION_fname(stname, fname) \ 00341 int fname##_print_ctx(BIO *out, stname *x, int indent, \ 00342 const ASN1_PCTX *pctx); 00343 00344 # define D2I_OF(type) type *(*)(type **,const unsigned char **,long) 00345 # define I2D_OF(type) int (*)(type *,unsigned char **) 00346 # define I2D_OF_const(type) int (*)(const type *,unsigned char **) 00347 00348 # define CHECKED_D2I_OF(type, d2i) \ 00349 ((d2i_of_void*) (1 ? d2i : ((D2I_OF(type))0))) 00350 # define CHECKED_I2D_OF(type, i2d) \ 00351 ((i2d_of_void*) (1 ? i2d : ((I2D_OF(type))0))) 00352 # define CHECKED_NEW_OF(type, xnew) \ 00353 ((void *(*)(void)) (1 ? xnew : ((type *(*)(void))0))) 00354 # define CHECKED_PTR_OF(type, p) \ 00355 ((void*) (1 ? p : (type*)0)) 00356 # define CHECKED_PPTR_OF(type, p) \ 00357 ((void**) (1 ? p : (type**)0)) 00358 00359 # define TYPEDEF_D2I_OF(type) typedef type *d2i_of_##type(type **,const unsigned char **,long) 00360 # define TYPEDEF_I2D_OF(type) typedef int i2d_of_##type(type *,unsigned char **) 00361 # define TYPEDEF_D2I2D_OF(type) TYPEDEF_D2I_OF(type); TYPEDEF_I2D_OF(type) 00362 00363 TYPEDEF_D2I2D_OF(void); 00364 00365 /*- 00366 * The following macros and typedefs allow an ASN1_ITEM 00367 * to be embedded in a structure and referenced. Since 00368 * the ASN1_ITEM pointers need to be globally accessible 00369 * (possibly from shared libraries) they may exist in 00370 * different forms. On platforms that support it the 00371 * ASN1_ITEM structure itself will be globally exported. 00372 * Other platforms will export a function that returns 00373 * an ASN1_ITEM pointer. 00374 * 00375 * To handle both cases transparently the macros below 00376 * should be used instead of hard coding an ASN1_ITEM 00377 * pointer in a structure. 00378 * 00379 * The structure will look like this: 00380 * 00381 * typedef struct SOMETHING_st { 00382 * ... 00383 * ASN1_ITEM_EXP *iptr; 00384 * ... 00385 * } SOMETHING; 00386 * 00387 * It would be initialised as e.g.: 00388 * 00389 * SOMETHING somevar = {...,ASN1_ITEM_ref(X509),...}; 00390 * 00391 * and the actual pointer extracted with: 00392 * 00393 * const ASN1_ITEM *it = ASN1_ITEM_ptr(somevar.iptr); 00394 * 00395 * Finally an ASN1_ITEM pointer can be extracted from an 00396 * appropriate reference with: ASN1_ITEM_rptr(X509). This 00397 * would be used when a function takes an ASN1_ITEM * argument. 00398 * 00399 */ 00400 00401 # ifndef OPENSSL_EXPORT_VAR_AS_FUNCTION 00402 00403 /* ASN1_ITEM pointer exported type */ 00404 typedef const ASN1_ITEM ASN1_ITEM_EXP; 00405 00406 /* Macro to obtain ASN1_ITEM pointer from exported type */ 00407 # define ASN1_ITEM_ptr(iptr) (iptr) 00408 00409 /* Macro to include ASN1_ITEM pointer from base type */ 00410 # define ASN1_ITEM_ref(iptr) (&(iptr##_it)) 00411 00412 # define ASN1_ITEM_rptr(ref) (&(ref##_it)) 00413 00414 # define DECLARE_ASN1_ITEM(name) \ 00415 OPENSSL_EXTERN const ASN1_ITEM name##_it; 00416 00417 # else 00418 00419 /* 00420 * Platforms that can't easily handle shared global variables are declared as 00421 * functions returning ASN1_ITEM pointers. 00422 */ 00423 00424 /* ASN1_ITEM pointer exported type */ 00425 typedef const ASN1_ITEM *ASN1_ITEM_EXP (void); 00426 00427 /* Macro to obtain ASN1_ITEM pointer from exported type */ 00428 # define ASN1_ITEM_ptr(iptr) (iptr()) 00429 00430 /* Macro to include ASN1_ITEM pointer from base type */ 00431 # define ASN1_ITEM_ref(iptr) (iptr##_it) 00432 00433 # define ASN1_ITEM_rptr(ref) (ref##_it()) 00434 00435 # define DECLARE_ASN1_ITEM(name) \ 00436 const ASN1_ITEM * name##_it(void); 00437 00438 # endif 00439 00440 /* Parameters used by ASN1_STRING_print_ex() */ 00441 00442 /* 00443 * These determine which characters to escape: RFC2253 special characters, 00444 * control characters and MSB set characters 00445 */ 00446 00447 # define ASN1_STRFLGS_ESC_2253 1 00448 # define ASN1_STRFLGS_ESC_CTRL 2 00449 # define ASN1_STRFLGS_ESC_MSB 4 00450 00451 /* 00452 * This flag determines how we do escaping: normally RC2253 backslash only, 00453 * set this to use backslash and quote. 00454 */ 00455 00456 # define ASN1_STRFLGS_ESC_QUOTE 8 00457 00458 /* These three flags are internal use only. */ 00459 00460 /* Character is a valid PrintableString character */ 00461 # define CHARTYPE_PRINTABLESTRING 0x10 00462 /* Character needs escaping if it is the first character */ 00463 # define CHARTYPE_FIRST_ESC_2253 0x20 00464 /* Character needs escaping if it is the last character */ 00465 # define CHARTYPE_LAST_ESC_2253 0x40 00466 00467 /* 00468 * NB the internal flags are safely reused below by flags handled at the top 00469 * level. 00470 */ 00471 00472 /* 00473 * If this is set we convert all character strings to UTF8 first 00474 */ 00475 00476 # define ASN1_STRFLGS_UTF8_CONVERT 0x10 00477 00478 /* 00479 * If this is set we don't attempt to interpret content: just assume all 00480 * strings are 1 byte per character. This will produce some pretty odd 00481 * looking output! 00482 */ 00483 00484 # define ASN1_STRFLGS_IGNORE_TYPE 0x20 00485 00486 /* If this is set we include the string type in the output */ 00487 # define ASN1_STRFLGS_SHOW_TYPE 0x40 00488 00489 /* 00490 * This determines which strings to display and which to 'dump' (hex dump of 00491 * content octets or DER encoding). We can only dump non character strings or 00492 * everything. If we don't dump 'unknown' they are interpreted as character 00493 * strings with 1 octet per character and are subject to the usual escaping 00494 * options. 00495 */ 00496 00497 # define ASN1_STRFLGS_DUMP_ALL 0x80 00498 # define ASN1_STRFLGS_DUMP_UNKNOWN 0x100 00499 00500 /* 00501 * These determine what 'dumping' does, we can dump the content octets or the 00502 * DER encoding: both use the RFC2253 #XXXXX notation. 00503 */ 00504 00505 # define ASN1_STRFLGS_DUMP_DER 0x200 00506 00507 /* 00508 * All the string flags consistent with RFC2253, escaping control characters 00509 * isn't essential in RFC2253 but it is advisable anyway. 00510 */ 00511 00512 # define ASN1_STRFLGS_RFC2253 (ASN1_STRFLGS_ESC_2253 | \ 00513 ASN1_STRFLGS_ESC_CTRL | \ 00514 ASN1_STRFLGS_ESC_MSB | \ 00515 ASN1_STRFLGS_UTF8_CONVERT | \ 00516 ASN1_STRFLGS_DUMP_UNKNOWN | \ 00517 ASN1_STRFLGS_DUMP_DER) 00518 00519 DECLARE_STACK_OF(ASN1_INTEGER) 00520 DECLARE_ASN1_SET_OF(ASN1_INTEGER) 00521 00522 DECLARE_STACK_OF(ASN1_GENERALSTRING) 00523 00524 typedef struct asn1_type_st { 00525 int type; 00526 union { 00527 char *ptr; 00528 ASN1_BOOLEAN boolean; 00529 ASN1_STRING *asn1_string; 00530 ASN1_OBJECT *object; 00531 ASN1_INTEGER *integer; 00532 ASN1_ENUMERATED *enumerated; 00533 ASN1_BIT_STRING *bit_string; 00534 ASN1_OCTET_STRING *octet_string; 00535 ASN1_PRINTABLESTRING *printablestring; 00536 ASN1_T61STRING *t61string; 00537 ASN1_IA5STRING *ia5string; 00538 ASN1_GENERALSTRING *generalstring; 00539 ASN1_BMPSTRING *bmpstring; 00540 ASN1_UNIVERSALSTRING *universalstring; 00541 ASN1_UTCTIME *utctime; 00542 ASN1_GENERALIZEDTIME *generalizedtime; 00543 ASN1_VISIBLESTRING *visiblestring; 00544 ASN1_UTF8STRING *utf8string; 00545 /* 00546 * set and sequence are left complete and still contain the set or 00547 * sequence bytes 00548 */ 00549 ASN1_STRING *set; 00550 ASN1_STRING *sequence; 00551 ASN1_VALUE *asn1_value; 00552 } value; 00553 } ASN1_TYPE; 00554 00555 DECLARE_STACK_OF(ASN1_TYPE) 00556 DECLARE_ASN1_SET_OF(ASN1_TYPE) 00557 00558 typedef STACK_OF(ASN1_TYPE) ASN1_SEQUENCE_ANY; 00559 00560 DECLARE_ASN1_ENCODE_FUNCTIONS_const(ASN1_SEQUENCE_ANY, ASN1_SEQUENCE_ANY) 00561 DECLARE_ASN1_ENCODE_FUNCTIONS_const(ASN1_SEQUENCE_ANY, ASN1_SET_ANY) 00562 00563 typedef struct NETSCAPE_X509_st { 00564 ASN1_OCTET_STRING *header; 00565 X509 *cert; 00566 } NETSCAPE_X509; 00567 00568 /* This is used to contain a list of bit names */ 00569 typedef struct BIT_STRING_BITNAME_st { 00570 int bitnum; 00571 const char *lname; 00572 const char *sname; 00573 } BIT_STRING_BITNAME; 00574 00575 # define M_ASN1_STRING_length(x) ((x)->length) 00576 # define M_ASN1_STRING_length_set(x, n) ((x)->length = (n)) 00577 # define M_ASN1_STRING_type(x) ((x)->type) 00578 # define M_ASN1_STRING_data(x) ((x)->data) 00579 00580 /* Macros for string operations */ 00581 # define M_ASN1_BIT_STRING_new() (ASN1_BIT_STRING *)\ 00582 ASN1_STRING_type_new(V_ASN1_BIT_STRING) 00583 # define M_ASN1_BIT_STRING_free(a) ASN1_STRING_free((ASN1_STRING *)a) 00584 # define M_ASN1_BIT_STRING_dup(a) (ASN1_BIT_STRING *)\ 00585 ASN1_STRING_dup((const ASN1_STRING *)a) 00586 # define M_ASN1_BIT_STRING_cmp(a,b) ASN1_STRING_cmp(\ 00587 (const ASN1_STRING *)a,(const ASN1_STRING *)b) 00588 # define M_ASN1_BIT_STRING_set(a,b,c) ASN1_STRING_set((ASN1_STRING *)a,b,c) 00589 00590 # define M_ASN1_INTEGER_new() (ASN1_INTEGER *)\ 00591 ASN1_STRING_type_new(V_ASN1_INTEGER) 00592 # define M_ASN1_INTEGER_free(a) ASN1_STRING_free((ASN1_STRING *)a) 00593 # define M_ASN1_INTEGER_dup(a) (ASN1_INTEGER *)\ 00594 ASN1_STRING_dup((const ASN1_STRING *)a) 00595 # define M_ASN1_INTEGER_cmp(a,b) ASN1_STRING_cmp(\ 00596 (const ASN1_STRING *)a,(const ASN1_STRING *)b) 00597 00598 # define M_ASN1_ENUMERATED_new() (ASN1_ENUMERATED *)\ 00599 ASN1_STRING_type_new(V_ASN1_ENUMERATED) 00600 # define M_ASN1_ENUMERATED_free(a) ASN1_STRING_free((ASN1_STRING *)a) 00601 # define M_ASN1_ENUMERATED_dup(a) (ASN1_ENUMERATED *)\ 00602 ASN1_STRING_dup((const ASN1_STRING *)a) 00603 # define M_ASN1_ENUMERATED_cmp(a,b) ASN1_STRING_cmp(\ 00604 (const ASN1_STRING *)a,(const ASN1_STRING *)b) 00605 00606 # define M_ASN1_OCTET_STRING_new() (ASN1_OCTET_STRING *)\ 00607 ASN1_STRING_type_new(V_ASN1_OCTET_STRING) 00608 # define M_ASN1_OCTET_STRING_free(a) ASN1_STRING_free((ASN1_STRING *)a) 00609 # define M_ASN1_OCTET_STRING_dup(a) (ASN1_OCTET_STRING *)\ 00610 ASN1_STRING_dup((const ASN1_STRING *)a) 00611 # define M_ASN1_OCTET_STRING_cmp(a,b) ASN1_STRING_cmp(\ 00612 (const ASN1_STRING *)a,(const ASN1_STRING *)b) 00613 # define M_ASN1_OCTET_STRING_set(a,b,c) ASN1_STRING_set((ASN1_STRING *)a,b,c) 00614 # define M_ASN1_OCTET_STRING_print(a,b) ASN1_STRING_print(a,(ASN1_STRING *)b) 00615 # define M_i2d_ASN1_OCTET_STRING(a,pp) \ 00616 i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_OCTET_STRING,\ 00617 V_ASN1_UNIVERSAL) 00618 00619 # define B_ASN1_TIME \ 00620 B_ASN1_UTCTIME | \ 00621 B_ASN1_GENERALIZEDTIME 00622 00623 # define B_ASN1_PRINTABLE \ 00624 B_ASN1_NUMERICSTRING| \ 00625 B_ASN1_PRINTABLESTRING| \ 00626 B_ASN1_T61STRING| \ 00627 B_ASN1_IA5STRING| \ 00628 B_ASN1_BIT_STRING| \ 00629 B_ASN1_UNIVERSALSTRING|\ 00630 B_ASN1_BMPSTRING|\ 00631 B_ASN1_UTF8STRING|\ 00632 B_ASN1_SEQUENCE|\ 00633 B_ASN1_UNKNOWN 00634 00635 # define B_ASN1_DIRECTORYSTRING \ 00636 B_ASN1_PRINTABLESTRING| \ 00637 B_ASN1_TELETEXSTRING|\ 00638 B_ASN1_BMPSTRING|\ 00639 B_ASN1_UNIVERSALSTRING|\ 00640 B_ASN1_UTF8STRING 00641 00642 # define B_ASN1_DISPLAYTEXT \ 00643 B_ASN1_IA5STRING| \ 00644 B_ASN1_VISIBLESTRING| \ 00645 B_ASN1_BMPSTRING|\ 00646 B_ASN1_UTF8STRING 00647 00648 # define M_ASN1_PRINTABLE_new() ASN1_STRING_type_new(V_ASN1_T61STRING) 00649 # define M_ASN1_PRINTABLE_free(a) ASN1_STRING_free((ASN1_STRING *)a) 00650 # define M_i2d_ASN1_PRINTABLE(a,pp) i2d_ASN1_bytes((ASN1_STRING *)a,\ 00651 pp,a->type,V_ASN1_UNIVERSAL) 00652 # define M_d2i_ASN1_PRINTABLE(a,pp,l) \ 00653 d2i_ASN1_type_bytes((ASN1_STRING **)a,pp,l, \ 00654 B_ASN1_PRINTABLE) 00655 00656 # define M_DIRECTORYSTRING_new() ASN1_STRING_type_new(V_ASN1_PRINTABLESTRING) 00657 # define M_DIRECTORYSTRING_free(a) ASN1_STRING_free((ASN1_STRING *)a) 00658 # define M_i2d_DIRECTORYSTRING(a,pp) i2d_ASN1_bytes((ASN1_STRING *)a,\ 00659 pp,a->type,V_ASN1_UNIVERSAL) 00660 # define M_d2i_DIRECTORYSTRING(a,pp,l) \ 00661 d2i_ASN1_type_bytes((ASN1_STRING **)a,pp,l, \ 00662 B_ASN1_DIRECTORYSTRING) 00663 00664 # define M_DISPLAYTEXT_new() ASN1_STRING_type_new(V_ASN1_VISIBLESTRING) 00665 # define M_DISPLAYTEXT_free(a) ASN1_STRING_free((ASN1_STRING *)a) 00666 # define M_i2d_DISPLAYTEXT(a,pp) i2d_ASN1_bytes((ASN1_STRING *)a,\ 00667 pp,a->type,V_ASN1_UNIVERSAL) 00668 # define M_d2i_DISPLAYTEXT(a,pp,l) \ 00669 d2i_ASN1_type_bytes((ASN1_STRING **)a,pp,l, \ 00670 B_ASN1_DISPLAYTEXT) 00671 00672 # define M_ASN1_PRINTABLESTRING_new() (ASN1_PRINTABLESTRING *)\ 00673 ASN1_STRING_type_new(V_ASN1_PRINTABLESTRING) 00674 # define M_ASN1_PRINTABLESTRING_free(a) ASN1_STRING_free((ASN1_STRING *)a) 00675 # define M_i2d_ASN1_PRINTABLESTRING(a,pp) \ 00676 i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_PRINTABLESTRING,\ 00677 V_ASN1_UNIVERSAL) 00678 # define M_d2i_ASN1_PRINTABLESTRING(a,pp,l) \ 00679 (ASN1_PRINTABLESTRING *)d2i_ASN1_type_bytes\ 00680 ((ASN1_STRING **)a,pp,l,B_ASN1_PRINTABLESTRING) 00681 00682 # define M_ASN1_T61STRING_new() (ASN1_T61STRING *)\ 00683 ASN1_STRING_type_new(V_ASN1_T61STRING) 00684 # define M_ASN1_T61STRING_free(a) ASN1_STRING_free((ASN1_STRING *)a) 00685 # define M_i2d_ASN1_T61STRING(a,pp) \ 00686 i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_T61STRING,\ 00687 V_ASN1_UNIVERSAL) 00688 # define M_d2i_ASN1_T61STRING(a,pp,l) \ 00689 (ASN1_T61STRING *)d2i_ASN1_type_bytes\ 00690 ((ASN1_STRING **)a,pp,l,B_ASN1_T61STRING) 00691 00692 # define M_ASN1_IA5STRING_new() (ASN1_IA5STRING *)\ 00693 ASN1_STRING_type_new(V_ASN1_IA5STRING) 00694 # define M_ASN1_IA5STRING_free(a) ASN1_STRING_free((ASN1_STRING *)a) 00695 # define M_ASN1_IA5STRING_dup(a) \ 00696 (ASN1_IA5STRING *)ASN1_STRING_dup((const ASN1_STRING *)a) 00697 # define M_i2d_ASN1_IA5STRING(a,pp) \ 00698 i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_IA5STRING,\ 00699 V_ASN1_UNIVERSAL) 00700 # define M_d2i_ASN1_IA5STRING(a,pp,l) \ 00701 (ASN1_IA5STRING *)d2i_ASN1_type_bytes((ASN1_STRING **)a,pp,l,\ 00702 B_ASN1_IA5STRING) 00703 00704 # define M_ASN1_UTCTIME_new() (ASN1_UTCTIME *)\ 00705 ASN1_STRING_type_new(V_ASN1_UTCTIME) 00706 # define M_ASN1_UTCTIME_free(a) ASN1_STRING_free((ASN1_STRING *)a) 00707 # define M_ASN1_UTCTIME_dup(a) (ASN1_UTCTIME *)\ 00708 ASN1_STRING_dup((const ASN1_STRING *)a) 00709 00710 # define M_ASN1_GENERALIZEDTIME_new() (ASN1_GENERALIZEDTIME *)\ 00711 ASN1_STRING_type_new(V_ASN1_GENERALIZEDTIME) 00712 # define M_ASN1_GENERALIZEDTIME_free(a) ASN1_STRING_free((ASN1_STRING *)a) 00713 # define M_ASN1_GENERALIZEDTIME_dup(a) (ASN1_GENERALIZEDTIME *)ASN1_STRING_dup(\ 00714 (const ASN1_STRING *)a) 00715 00716 # define M_ASN1_TIME_new() (ASN1_TIME *)\ 00717 ASN1_STRING_type_new(V_ASN1_UTCTIME) 00718 # define M_ASN1_TIME_free(a) ASN1_STRING_free((ASN1_STRING *)a) 00719 # define M_ASN1_TIME_dup(a) (ASN1_TIME *)\ 00720 ASN1_STRING_dup((const ASN1_STRING *)a) 00721 00722 # define M_ASN1_GENERALSTRING_new() (ASN1_GENERALSTRING *)\ 00723 ASN1_STRING_type_new(V_ASN1_GENERALSTRING) 00724 # define M_ASN1_GENERALSTRING_free(a) ASN1_STRING_free((ASN1_STRING *)a) 00725 # define M_i2d_ASN1_GENERALSTRING(a,pp) \ 00726 i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_GENERALSTRING,\ 00727 V_ASN1_UNIVERSAL) 00728 # define M_d2i_ASN1_GENERALSTRING(a,pp,l) \ 00729 (ASN1_GENERALSTRING *)d2i_ASN1_type_bytes\ 00730 ((ASN1_STRING **)a,pp,l,B_ASN1_GENERALSTRING) 00731 00732 # define M_ASN1_UNIVERSALSTRING_new() (ASN1_UNIVERSALSTRING *)\ 00733 ASN1_STRING_type_new(V_ASN1_UNIVERSALSTRING) 00734 # define M_ASN1_UNIVERSALSTRING_free(a) ASN1_STRING_free((ASN1_STRING *)a) 00735 # define M_i2d_ASN1_UNIVERSALSTRING(a,pp) \ 00736 i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_UNIVERSALSTRING,\ 00737 V_ASN1_UNIVERSAL) 00738 # define M_d2i_ASN1_UNIVERSALSTRING(a,pp,l) \ 00739 (ASN1_UNIVERSALSTRING *)d2i_ASN1_type_bytes\ 00740 ((ASN1_STRING **)a,pp,l,B_ASN1_UNIVERSALSTRING) 00741 00742 # define M_ASN1_BMPSTRING_new() (ASN1_BMPSTRING *)\ 00743 ASN1_STRING_type_new(V_ASN1_BMPSTRING) 00744 # define M_ASN1_BMPSTRING_free(a) ASN1_STRING_free((ASN1_STRING *)a) 00745 # define M_i2d_ASN1_BMPSTRING(a,pp) \ 00746 i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_BMPSTRING,\ 00747 V_ASN1_UNIVERSAL) 00748 # define M_d2i_ASN1_BMPSTRING(a,pp,l) \ 00749 (ASN1_BMPSTRING *)d2i_ASN1_type_bytes\ 00750 ((ASN1_STRING **)a,pp,l,B_ASN1_BMPSTRING) 00751 00752 # define M_ASN1_VISIBLESTRING_new() (ASN1_VISIBLESTRING *)\ 00753 ASN1_STRING_type_new(V_ASN1_VISIBLESTRING) 00754 # define M_ASN1_VISIBLESTRING_free(a) ASN1_STRING_free((ASN1_STRING *)a) 00755 # define M_i2d_ASN1_VISIBLESTRING(a,pp) \ 00756 i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_VISIBLESTRING,\ 00757 V_ASN1_UNIVERSAL) 00758 # define M_d2i_ASN1_VISIBLESTRING(a,pp,l) \ 00759 (ASN1_VISIBLESTRING *)d2i_ASN1_type_bytes\ 00760 ((ASN1_STRING **)a,pp,l,B_ASN1_VISIBLESTRING) 00761 00762 # define M_ASN1_UTF8STRING_new() (ASN1_UTF8STRING *)\ 00763 ASN1_STRING_type_new(V_ASN1_UTF8STRING) 00764 # define M_ASN1_UTF8STRING_free(a) ASN1_STRING_free((ASN1_STRING *)a) 00765 # define M_i2d_ASN1_UTF8STRING(a,pp) \ 00766 i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_UTF8STRING,\ 00767 V_ASN1_UNIVERSAL) 00768 # define M_d2i_ASN1_UTF8STRING(a,pp,l) \ 00769 (ASN1_UTF8STRING *)d2i_ASN1_type_bytes\ 00770 ((ASN1_STRING **)a,pp,l,B_ASN1_UTF8STRING) 00771 00772 /* for the is_set parameter to i2d_ASN1_SET */ 00773 # define IS_SEQUENCE 0 00774 # define IS_SET 1 00775 00776 DECLARE_ASN1_FUNCTIONS_fname(ASN1_TYPE, ASN1_ANY, ASN1_TYPE) 00777 00778 int ASN1_TYPE_get(ASN1_TYPE *a); 00779 void ASN1_TYPE_set(ASN1_TYPE *a, int type, void *value); 00780 int ASN1_TYPE_set1(ASN1_TYPE *a, int type, const void *value); 00781 int ASN1_TYPE_cmp(const ASN1_TYPE *a, const ASN1_TYPE *b); 00782 00783 ASN1_OBJECT *ASN1_OBJECT_new(void); 00784 void ASN1_OBJECT_free(ASN1_OBJECT *a); 00785 int i2d_ASN1_OBJECT(ASN1_OBJECT *a, unsigned char **pp); 00786 ASN1_OBJECT *c2i_ASN1_OBJECT(ASN1_OBJECT **a, const unsigned char **pp, 00787 long length); 00788 ASN1_OBJECT *d2i_ASN1_OBJECT(ASN1_OBJECT **a, const unsigned char **pp, 00789 long length); 00790 00791 DECLARE_ASN1_ITEM(ASN1_OBJECT) 00792 00793 DECLARE_STACK_OF(ASN1_OBJECT) 00794 DECLARE_ASN1_SET_OF(ASN1_OBJECT) 00795 00796 ASN1_STRING *ASN1_STRING_new(void); 00797 void ASN1_STRING_free(ASN1_STRING *a); 00798 void ASN1_STRING_clear_free(ASN1_STRING *a); 00799 int ASN1_STRING_copy(ASN1_STRING *dst, const ASN1_STRING *str); 00800 ASN1_STRING *ASN1_STRING_dup(const ASN1_STRING *a); 00801 ASN1_STRING *ASN1_STRING_type_new(int type); 00802 int ASN1_STRING_cmp(const ASN1_STRING *a, const ASN1_STRING *b); 00803 /* 00804 * Since this is used to store all sorts of things, via macros, for now, 00805 * make its data void * 00806 */ 00807 int ASN1_STRING_set(ASN1_STRING *str, const void *data, int len); 00808 void ASN1_STRING_set0(ASN1_STRING *str, void *data, int len); 00809 int ASN1_STRING_length(const ASN1_STRING *x); 00810 void ASN1_STRING_length_set(ASN1_STRING *x, int n); 00811 int ASN1_STRING_type(ASN1_STRING *x); 00812 unsigned char *ASN1_STRING_data(ASN1_STRING *x); 00813 00814 DECLARE_ASN1_FUNCTIONS(ASN1_BIT_STRING) 00815 int i2c_ASN1_BIT_STRING(ASN1_BIT_STRING *a, unsigned char **pp); 00816 ASN1_BIT_STRING *c2i_ASN1_BIT_STRING(ASN1_BIT_STRING **a, 00817 const unsigned char **pp, long length); 00818 int ASN1_BIT_STRING_set(ASN1_BIT_STRING *a, unsigned char *d, int length); 00819 int ASN1_BIT_STRING_set_bit(ASN1_BIT_STRING *a, int n, int value); 00820 int ASN1_BIT_STRING_get_bit(ASN1_BIT_STRING *a, int n); 00821 int ASN1_BIT_STRING_check(ASN1_BIT_STRING *a, 00822 unsigned char *flags, int flags_len); 00823 00824 # ifndef OPENSSL_NO_BIO 00825 int ASN1_BIT_STRING_name_print(BIO *out, ASN1_BIT_STRING *bs, 00826 BIT_STRING_BITNAME *tbl, int indent); 00827 # endif 00828 int ASN1_BIT_STRING_num_asc(char *name, BIT_STRING_BITNAME *tbl); 00829 int ASN1_BIT_STRING_set_asc(ASN1_BIT_STRING *bs, char *name, int value, 00830 BIT_STRING_BITNAME *tbl); 00831 00832 int i2d_ASN1_BOOLEAN(int a, unsigned char **pp); 00833 int d2i_ASN1_BOOLEAN(int *a, const unsigned char **pp, long length); 00834 00835 DECLARE_ASN1_FUNCTIONS(ASN1_INTEGER) 00836 int i2c_ASN1_INTEGER(ASN1_INTEGER *a, unsigned char **pp); 00837 ASN1_INTEGER *c2i_ASN1_INTEGER(ASN1_INTEGER **a, const unsigned char **pp, 00838 long length); 00839 ASN1_INTEGER *d2i_ASN1_UINTEGER(ASN1_INTEGER **a, const unsigned char **pp, 00840 long length); 00841 ASN1_INTEGER *ASN1_INTEGER_dup(const ASN1_INTEGER *x); 00842 int ASN1_INTEGER_cmp(const ASN1_INTEGER *x, const ASN1_INTEGER *y); 00843 00844 DECLARE_ASN1_FUNCTIONS(ASN1_ENUMERATED) 00845 00846 int ASN1_UTCTIME_check(const ASN1_UTCTIME *a); 00847 ASN1_UTCTIME *ASN1_UTCTIME_set(ASN1_UTCTIME *s, time_t t); 00848 ASN1_UTCTIME *ASN1_UTCTIME_adj(ASN1_UTCTIME *s, time_t t, 00849 int offset_day, long offset_sec); 00850 int ASN1_UTCTIME_set_string(ASN1_UTCTIME *s, const char *str); 00851 int ASN1_UTCTIME_cmp_time_t(const ASN1_UTCTIME *s, time_t t); 00852 # if 0 00853 time_t ASN1_UTCTIME_get(const ASN1_UTCTIME *s); 00854 # endif 00855 00856 int ASN1_GENERALIZEDTIME_check(const ASN1_GENERALIZEDTIME *a); 00857 ASN1_GENERALIZEDTIME *ASN1_GENERALIZEDTIME_set(ASN1_GENERALIZEDTIME *s, 00858 time_t t); 00859 ASN1_GENERALIZEDTIME *ASN1_GENERALIZEDTIME_adj(ASN1_GENERALIZEDTIME *s, 00860 time_t t, int offset_day, 00861 long offset_sec); 00862 int ASN1_GENERALIZEDTIME_set_string(ASN1_GENERALIZEDTIME *s, const char *str); 00863 int ASN1_TIME_diff(int *pday, int *psec, 00864 const ASN1_TIME *from, const ASN1_TIME *to); 00865 00866 DECLARE_ASN1_FUNCTIONS(ASN1_OCTET_STRING) 00867 ASN1_OCTET_STRING *ASN1_OCTET_STRING_dup(const ASN1_OCTET_STRING *a); 00868 int ASN1_OCTET_STRING_cmp(const ASN1_OCTET_STRING *a, 00869 const ASN1_OCTET_STRING *b); 00870 int ASN1_OCTET_STRING_set(ASN1_OCTET_STRING *str, const unsigned char *data, 00871 int len); 00872 00873 DECLARE_ASN1_FUNCTIONS(ASN1_VISIBLESTRING) 00874 DECLARE_ASN1_FUNCTIONS(ASN1_UNIVERSALSTRING) 00875 DECLARE_ASN1_FUNCTIONS(ASN1_UTF8STRING) 00876 DECLARE_ASN1_FUNCTIONS(ASN1_NULL) 00877 DECLARE_ASN1_FUNCTIONS(ASN1_BMPSTRING) 00878 00879 int UTF8_getc(const unsigned char *str, int len, unsigned long *val); 00880 int UTF8_putc(unsigned char *str, int len, unsigned long value); 00881 00882 DECLARE_ASN1_FUNCTIONS_name(ASN1_STRING, ASN1_PRINTABLE) 00883 00884 DECLARE_ASN1_FUNCTIONS_name(ASN1_STRING, DIRECTORYSTRING) 00885 DECLARE_ASN1_FUNCTIONS_name(ASN1_STRING, DISPLAYTEXT) 00886 DECLARE_ASN1_FUNCTIONS(ASN1_PRINTABLESTRING) 00887 DECLARE_ASN1_FUNCTIONS(ASN1_T61STRING) 00888 DECLARE_ASN1_FUNCTIONS(ASN1_IA5STRING) 00889 DECLARE_ASN1_FUNCTIONS(ASN1_GENERALSTRING) 00890 DECLARE_ASN1_FUNCTIONS(ASN1_UTCTIME) 00891 DECLARE_ASN1_FUNCTIONS(ASN1_GENERALIZEDTIME) 00892 DECLARE_ASN1_FUNCTIONS(ASN1_TIME) 00893 00894 DECLARE_ASN1_ITEM(ASN1_OCTET_STRING_NDEF) 00895 00896 ASN1_TIME *ASN1_TIME_set(ASN1_TIME *s, time_t t); 00897 ASN1_TIME *ASN1_TIME_adj(ASN1_TIME *s, time_t t, 00898 int offset_day, long offset_sec); 00899 int ASN1_TIME_check(ASN1_TIME *t); 00900 ASN1_GENERALIZEDTIME *ASN1_TIME_to_generalizedtime(ASN1_TIME *t, ASN1_GENERALIZEDTIME 00901 **out); 00902 int ASN1_TIME_set_string(ASN1_TIME *s, const char *str); 00903 00904 int i2d_ASN1_SET(STACK_OF(OPENSSL_BLOCK) *a, unsigned char **pp, 00905 i2d_of_void *i2d, int ex_tag, int ex_class, int is_set); 00906 STACK_OF(OPENSSL_BLOCK) *d2i_ASN1_SET(STACK_OF(OPENSSL_BLOCK) **a, 00907 const unsigned char **pp, 00908 long length, d2i_of_void *d2i, 00909 void (*free_func) (OPENSSL_BLOCK), 00910 int ex_tag, int ex_class); 00911 00912 # ifndef OPENSSL_NO_BIO 00913 int i2a_ASN1_INTEGER(BIO *bp, ASN1_INTEGER *a); 00914 int a2i_ASN1_INTEGER(BIO *bp, ASN1_INTEGER *bs, char *buf, int size); 00915 int i2a_ASN1_ENUMERATED(BIO *bp, ASN1_ENUMERATED *a); 00916 int a2i_ASN1_ENUMERATED(BIO *bp, ASN1_ENUMERATED *bs, char *buf, int size); 00917 int i2a_ASN1_OBJECT(BIO *bp, ASN1_OBJECT *a); 00918 int a2i_ASN1_STRING(BIO *bp, ASN1_STRING *bs, char *buf, int size); 00919 int i2a_ASN1_STRING(BIO *bp, ASN1_STRING *a, int type); 00920 # endif 00921 int i2t_ASN1_OBJECT(char *buf, int buf_len, ASN1_OBJECT *a); 00922 00923 int a2d_ASN1_OBJECT(unsigned char *out, int olen, const char *buf, int num); 00924 ASN1_OBJECT *ASN1_OBJECT_create(int nid, unsigned char *data, int len, 00925 const char *sn, const char *ln); 00926 00927 int ASN1_INTEGER_set(ASN1_INTEGER *a, long v); 00928 long ASN1_INTEGER_get(const ASN1_INTEGER *a); 00929 ASN1_INTEGER *BN_to_ASN1_INTEGER(const BIGNUM *bn, ASN1_INTEGER *ai); 00930 BIGNUM *ASN1_INTEGER_to_BN(const ASN1_INTEGER *ai, BIGNUM *bn); 00931 00932 int ASN1_ENUMERATED_set(ASN1_ENUMERATED *a, long v); 00933 long ASN1_ENUMERATED_get(ASN1_ENUMERATED *a); 00934 ASN1_ENUMERATED *BN_to_ASN1_ENUMERATED(BIGNUM *bn, ASN1_ENUMERATED *ai); 00935 BIGNUM *ASN1_ENUMERATED_to_BN(ASN1_ENUMERATED *ai, BIGNUM *bn); 00936 00937 /* General */ 00938 /* given a string, return the correct type, max is the maximum length */ 00939 int ASN1_PRINTABLE_type(const unsigned char *s, int max); 00940 00941 int i2d_ASN1_bytes(ASN1_STRING *a, unsigned char **pp, int tag, int xclass); 00942 ASN1_STRING *d2i_ASN1_bytes(ASN1_STRING **a, const unsigned char **pp, 00943 long length, int Ptag, int Pclass); 00944 unsigned long ASN1_tag2bit(int tag); 00945 /* type is one or more of the B_ASN1_ values. */ 00946 ASN1_STRING *d2i_ASN1_type_bytes(ASN1_STRING **a, const unsigned char **pp, 00947 long length, int type); 00948 00949 /* PARSING */ 00950 int asn1_Finish(ASN1_CTX *c); 00951 int asn1_const_Finish(ASN1_const_CTX *c); 00952 00953 /* SPECIALS */ 00954 int ASN1_get_object(const unsigned char **pp, long *plength, int *ptag, 00955 int *pclass, long omax); 00956 int ASN1_check_infinite_end(unsigned char **p, long len); 00957 int ASN1_const_check_infinite_end(const unsigned char **p, long len); 00958 void ASN1_put_object(unsigned char **pp, int constructed, int length, 00959 int tag, int xclass); 00960 int ASN1_put_eoc(unsigned char **pp); 00961 int ASN1_object_size(int constructed, int length, int tag); 00962 00963 /* Used to implement other functions */ 00964 void *ASN1_dup(i2d_of_void *i2d, d2i_of_void *d2i, void *x); 00965 00966 # define ASN1_dup_of(type,i2d,d2i,x) \ 00967 ((type*)ASN1_dup(CHECKED_I2D_OF(type, i2d), \ 00968 CHECKED_D2I_OF(type, d2i), \ 00969 CHECKED_PTR_OF(type, x))) 00970 00971 # define ASN1_dup_of_const(type,i2d,d2i,x) \ 00972 ((type*)ASN1_dup(CHECKED_I2D_OF(const type, i2d), \ 00973 CHECKED_D2I_OF(type, d2i), \ 00974 CHECKED_PTR_OF(const type, x))) 00975 00976 void *ASN1_item_dup(const ASN1_ITEM *it, void *x); 00977 00978 /* ASN1 alloc/free macros for when a type is only used internally */ 00979 00980 # define M_ASN1_new_of(type) (type *)ASN1_item_new(ASN1_ITEM_rptr(type)) 00981 # define M_ASN1_free_of(x, type) \ 00982 ASN1_item_free(CHECKED_PTR_OF(type, x), ASN1_ITEM_rptr(type)) 00983 00984 # ifndef OPENSSL_NO_FP_API 00985 void *ASN1_d2i_fp(void *(*xnew) (void), d2i_of_void *d2i, FILE *in, void **x); 00986 00987 # define ASN1_d2i_fp_of(type,xnew,d2i,in,x) \ 00988 ((type*)ASN1_d2i_fp(CHECKED_NEW_OF(type, xnew), \ 00989 CHECKED_D2I_OF(type, d2i), \ 00990 in, \ 00991 CHECKED_PPTR_OF(type, x))) 00992 00993 void *ASN1_item_d2i_fp(const ASN1_ITEM *it, FILE *in, void *x); 00994 int ASN1_i2d_fp(i2d_of_void *i2d, FILE *out, void *x); 00995 00996 # define ASN1_i2d_fp_of(type,i2d,out,x) \ 00997 (ASN1_i2d_fp(CHECKED_I2D_OF(type, i2d), \ 00998 out, \ 00999 CHECKED_PTR_OF(type, x))) 01000 01001 # define ASN1_i2d_fp_of_const(type,i2d,out,x) \ 01002 (ASN1_i2d_fp(CHECKED_I2D_OF(const type, i2d), \ 01003 out, \ 01004 CHECKED_PTR_OF(const type, x))) 01005 01006 int ASN1_item_i2d_fp(const ASN1_ITEM *it, FILE *out, void *x); 01007 int ASN1_STRING_print_ex_fp(FILE *fp, ASN1_STRING *str, unsigned long flags); 01008 # endif 01009 01010 int ASN1_STRING_to_UTF8(unsigned char **out, ASN1_STRING *in); 01011 01012 # ifndef OPENSSL_NO_BIO 01013 void *ASN1_d2i_bio(void *(*xnew) (void), d2i_of_void *d2i, BIO *in, void **x); 01014 01015 # define ASN1_d2i_bio_of(type,xnew,d2i,in,x) \ 01016 ((type*)ASN1_d2i_bio( CHECKED_NEW_OF(type, xnew), \ 01017 CHECKED_D2I_OF(type, d2i), \ 01018 in, \ 01019 CHECKED_PPTR_OF(type, x))) 01020 01021 void *ASN1_item_d2i_bio(const ASN1_ITEM *it, BIO *in, void *x); 01022 int ASN1_i2d_bio(i2d_of_void *i2d, BIO *out, unsigned char *x); 01023 01024 # define ASN1_i2d_bio_of(type,i2d,out,x) \ 01025 (ASN1_i2d_bio(CHECKED_I2D_OF(type, i2d), \ 01026 out, \ 01027 CHECKED_PTR_OF(type, x))) 01028 01029 # define ASN1_i2d_bio_of_const(type,i2d,out,x) \ 01030 (ASN1_i2d_bio(CHECKED_I2D_OF(const type, i2d), \ 01031 out, \ 01032 CHECKED_PTR_OF(const type, x))) 01033 01034 int ASN1_item_i2d_bio(const ASN1_ITEM *it, BIO *out, void *x); 01035 int ASN1_UTCTIME_print(BIO *fp, const ASN1_UTCTIME *a); 01036 int ASN1_GENERALIZEDTIME_print(BIO *fp, const ASN1_GENERALIZEDTIME *a); 01037 int ASN1_TIME_print(BIO *fp, const ASN1_TIME *a); 01038 int ASN1_STRING_print(BIO *bp, const ASN1_STRING *v); 01039 int ASN1_STRING_print_ex(BIO *out, ASN1_STRING *str, unsigned long flags); 01040 int ASN1_bn_print(BIO *bp, const char *number, const BIGNUM *num, 01041 unsigned char *buf, int off); 01042 int ASN1_parse(BIO *bp, const unsigned char *pp, long len, int indent); 01043 int ASN1_parse_dump(BIO *bp, const unsigned char *pp, long len, int indent, 01044 int dump); 01045 # endif 01046 const char *ASN1_tag2str(int tag); 01047 01048 /* Used to load and write netscape format cert */ 01049 01050 DECLARE_ASN1_FUNCTIONS(NETSCAPE_X509) 01051 01052 int ASN1_UNIVERSALSTRING_to_string(ASN1_UNIVERSALSTRING *s); 01053 01054 int ASN1_TYPE_set_octetstring(ASN1_TYPE *a, unsigned char *data, int len); 01055 int ASN1_TYPE_get_octetstring(ASN1_TYPE *a, unsigned char *data, int max_len); 01056 int ASN1_TYPE_set_int_octetstring(ASN1_TYPE *a, long num, 01057 unsigned char *data, int len); 01058 int ASN1_TYPE_get_int_octetstring(ASN1_TYPE *a, long *num, 01059 unsigned char *data, int max_len); 01060 01061 STACK_OF(OPENSSL_BLOCK) *ASN1_seq_unpack(const unsigned char *buf, int len, 01062 d2i_of_void *d2i, 01063 void (*free_func) (OPENSSL_BLOCK)); 01064 unsigned char *ASN1_seq_pack(STACK_OF(OPENSSL_BLOCK) *safes, i2d_of_void *i2d, 01065 unsigned char **buf, int *len); 01066 void *ASN1_unpack_string(ASN1_STRING *oct, d2i_of_void *d2i); 01067 void *ASN1_item_unpack(ASN1_STRING *oct, const ASN1_ITEM *it); 01068 ASN1_STRING *ASN1_pack_string(void *obj, i2d_of_void *i2d, 01069 ASN1_OCTET_STRING **oct); 01070 01071 # define ASN1_pack_string_of(type,obj,i2d,oct) \ 01072 (ASN1_pack_string(CHECKED_PTR_OF(type, obj), \ 01073 CHECKED_I2D_OF(type, i2d), \ 01074 oct)) 01075 01076 ASN1_STRING *ASN1_item_pack(void *obj, const ASN1_ITEM *it, 01077 ASN1_OCTET_STRING **oct); 01078 01079 void ASN1_STRING_set_default_mask(unsigned long mask); 01080 int ASN1_STRING_set_default_mask_asc(const char *p); 01081 unsigned long ASN1_STRING_get_default_mask(void); 01082 int ASN1_mbstring_copy(ASN1_STRING **out, const unsigned char *in, int len, 01083 int inform, unsigned long mask); 01084 int ASN1_mbstring_ncopy(ASN1_STRING **out, const unsigned char *in, int len, 01085 int inform, unsigned long mask, 01086 long minsize, long maxsize); 01087 01088 ASN1_STRING *ASN1_STRING_set_by_NID(ASN1_STRING **out, 01089 const unsigned char *in, int inlen, 01090 int inform, int nid); 01091 ASN1_STRING_TABLE *ASN1_STRING_TABLE_get(int nid); 01092 int ASN1_STRING_TABLE_add(int, long, long, unsigned long, unsigned long); 01093 void ASN1_STRING_TABLE_cleanup(void); 01094 01095 /* ASN1 template functions */ 01096 01097 /* Old API compatible functions */ 01098 ASN1_VALUE *ASN1_item_new(const ASN1_ITEM *it); 01099 void ASN1_item_free(ASN1_VALUE *val, const ASN1_ITEM *it); 01100 ASN1_VALUE *ASN1_item_d2i(ASN1_VALUE **val, const unsigned char **in, 01101 long len, const ASN1_ITEM *it); 01102 int ASN1_item_i2d(ASN1_VALUE *val, unsigned char **out, const ASN1_ITEM *it); 01103 int ASN1_item_ndef_i2d(ASN1_VALUE *val, unsigned char **out, 01104 const ASN1_ITEM *it); 01105 01106 void ASN1_add_oid_module(void); 01107 01108 ASN1_TYPE *ASN1_generate_nconf(char *str, CONF *nconf); 01109 ASN1_TYPE *ASN1_generate_v3(char *str, X509V3_CTX *cnf); 01110 01111 /* ASN1 Print flags */ 01112 01113 /* Indicate missing OPTIONAL fields */ 01114 # define ASN1_PCTX_FLAGS_SHOW_ABSENT 0x001 01115 /* Mark start and end of SEQUENCE */ 01116 # define ASN1_PCTX_FLAGS_SHOW_SEQUENCE 0x002 01117 /* Mark start and end of SEQUENCE/SET OF */ 01118 # define ASN1_PCTX_FLAGS_SHOW_SSOF 0x004 01119 /* Show the ASN1 type of primitives */ 01120 # define ASN1_PCTX_FLAGS_SHOW_TYPE 0x008 01121 /* Don't show ASN1 type of ANY */ 01122 # define ASN1_PCTX_FLAGS_NO_ANY_TYPE 0x010 01123 /* Don't show ASN1 type of MSTRINGs */ 01124 # define ASN1_PCTX_FLAGS_NO_MSTRING_TYPE 0x020 01125 /* Don't show field names in SEQUENCE */ 01126 # define ASN1_PCTX_FLAGS_NO_FIELD_NAME 0x040 01127 /* Show structure names of each SEQUENCE field */ 01128 # define ASN1_PCTX_FLAGS_SHOW_FIELD_STRUCT_NAME 0x080 01129 /* Don't show structure name even at top level */ 01130 # define ASN1_PCTX_FLAGS_NO_STRUCT_NAME 0x100 01131 01132 int ASN1_item_print(BIO *out, ASN1_VALUE *ifld, int indent, 01133 const ASN1_ITEM *it, const ASN1_PCTX *pctx); 01134 ASN1_PCTX *ASN1_PCTX_new(void); 01135 void ASN1_PCTX_free(ASN1_PCTX *p); 01136 unsigned long ASN1_PCTX_get_flags(ASN1_PCTX *p); 01137 void ASN1_PCTX_set_flags(ASN1_PCTX *p, unsigned long flags); 01138 unsigned long ASN1_PCTX_get_nm_flags(ASN1_PCTX *p); 01139 void ASN1_PCTX_set_nm_flags(ASN1_PCTX *p, unsigned long flags); 01140 unsigned long ASN1_PCTX_get_cert_flags(ASN1_PCTX *p); 01141 void ASN1_PCTX_set_cert_flags(ASN1_PCTX *p, unsigned long flags); 01142 unsigned long ASN1_PCTX_get_oid_flags(ASN1_PCTX *p); 01143 void ASN1_PCTX_set_oid_flags(ASN1_PCTX *p, unsigned long flags); 01144 unsigned long ASN1_PCTX_get_str_flags(ASN1_PCTX *p); 01145 void ASN1_PCTX_set_str_flags(ASN1_PCTX *p, unsigned long flags); 01146 01147 BIO_METHOD *BIO_f_asn1(void); 01148 01149 BIO *BIO_new_NDEF(BIO *out, ASN1_VALUE *val, const ASN1_ITEM *it); 01150 01151 int i2d_ASN1_bio_stream(BIO *out, ASN1_VALUE *val, BIO *in, int flags, 01152 const ASN1_ITEM *it); 01153 int PEM_write_bio_ASN1_stream(BIO *out, ASN1_VALUE *val, BIO *in, int flags, 01154 const char *hdr, const ASN1_ITEM *it); 01155 int SMIME_write_ASN1(BIO *bio, ASN1_VALUE *val, BIO *data, int flags, 01156 int ctype_nid, int econt_nid, 01157 STACK_OF(X509_ALGOR) *mdalgs, const ASN1_ITEM *it); 01158 ASN1_VALUE *SMIME_read_ASN1(BIO *bio, BIO **bcont, const ASN1_ITEM *it); 01159 int SMIME_crlf_copy(BIO *in, BIO *out, int flags); 01160 int SMIME_text(BIO *in, BIO *out); 01161 01162 /* BEGIN ERROR CODES */ 01163 /* 01164 * The following lines are auto generated by the script mkerr.pl. Any changes 01165 * made after this point may be overwritten when the script is next run. 01166 */ 01167 void ERR_load_ASN1_strings(void); 01168 01169 /* Error codes for the ASN1 functions. */ 01170 01171 /* Function codes. */ 01172 # define ASN1_F_A2D_ASN1_OBJECT 100 01173 # define ASN1_F_A2I_ASN1_ENUMERATED 101 01174 # define ASN1_F_A2I_ASN1_INTEGER 102 01175 # define ASN1_F_A2I_ASN1_STRING 103 01176 # define ASN1_F_APPEND_EXP 176 01177 # define ASN1_F_ASN1_BIT_STRING_SET_BIT 183 01178 # define ASN1_F_ASN1_CB 177 01179 # define ASN1_F_ASN1_CHECK_TLEN 104 01180 # define ASN1_F_ASN1_COLLATE_PRIMITIVE 105 01181 # define ASN1_F_ASN1_COLLECT 106 01182 # define ASN1_F_ASN1_D2I_EX_PRIMITIVE 108 01183 # define ASN1_F_ASN1_D2I_FP 109 01184 # define ASN1_F_ASN1_D2I_READ_BIO 107 01185 # define ASN1_F_ASN1_DIGEST 184 01186 # define ASN1_F_ASN1_DO_ADB 110 01187 # define ASN1_F_ASN1_DUP 111 01188 # define ASN1_F_ASN1_ENUMERATED_SET 112 01189 # define ASN1_F_ASN1_ENUMERATED_TO_BN 113 01190 # define ASN1_F_ASN1_EX_C2I 204 01191 # define ASN1_F_ASN1_FIND_END 190 01192 # define ASN1_F_ASN1_GENERALIZEDTIME_ADJ 216 01193 # define ASN1_F_ASN1_GENERALIZEDTIME_SET 185 01194 # define ASN1_F_ASN1_GENERATE_V3 178 01195 # define ASN1_F_ASN1_GET_OBJECT 114 01196 # define ASN1_F_ASN1_HEADER_NEW 115 01197 # define ASN1_F_ASN1_I2D_BIO 116 01198 # define ASN1_F_ASN1_I2D_FP 117 01199 # define ASN1_F_ASN1_INTEGER_SET 118 01200 # define ASN1_F_ASN1_INTEGER_TO_BN 119 01201 # define ASN1_F_ASN1_ITEM_D2I_FP 206 01202 # define ASN1_F_ASN1_ITEM_DUP 191 01203 # define ASN1_F_ASN1_ITEM_EX_COMBINE_NEW 121 01204 # define ASN1_F_ASN1_ITEM_EX_D2I 120 01205 # define ASN1_F_ASN1_ITEM_I2D_BIO 192 01206 # define ASN1_F_ASN1_ITEM_I2D_FP 193 01207 # define ASN1_F_ASN1_ITEM_PACK 198 01208 # define ASN1_F_ASN1_ITEM_SIGN 195 01209 # define ASN1_F_ASN1_ITEM_SIGN_CTX 220 01210 # define ASN1_F_ASN1_ITEM_UNPACK 199 01211 # define ASN1_F_ASN1_ITEM_VERIFY 197 01212 # define ASN1_F_ASN1_MBSTRING_NCOPY 122 01213 # define ASN1_F_ASN1_OBJECT_NEW 123 01214 # define ASN1_F_ASN1_OUTPUT_DATA 214 01215 # define ASN1_F_ASN1_PACK_STRING 124 01216 # define ASN1_F_ASN1_PCTX_NEW 205 01217 # define ASN1_F_ASN1_PKCS5_PBE_SET 125 01218 # define ASN1_F_ASN1_SEQ_PACK 126 01219 # define ASN1_F_ASN1_SEQ_UNPACK 127 01220 # define ASN1_F_ASN1_SIGN 128 01221 # define ASN1_F_ASN1_STR2TYPE 179 01222 # define ASN1_F_ASN1_STRING_SET 186 01223 # define ASN1_F_ASN1_STRING_TABLE_ADD 129 01224 # define ASN1_F_ASN1_STRING_TYPE_NEW 130 01225 # define ASN1_F_ASN1_TEMPLATE_EX_D2I 132 01226 # define ASN1_F_ASN1_TEMPLATE_NEW 133 01227 # define ASN1_F_ASN1_TEMPLATE_NOEXP_D2I 131 01228 # define ASN1_F_ASN1_TIME_ADJ 217 01229 # define ASN1_F_ASN1_TIME_SET 175 01230 # define ASN1_F_ASN1_TYPE_GET_INT_OCTETSTRING 134 01231 # define ASN1_F_ASN1_TYPE_GET_OCTETSTRING 135 01232 # define ASN1_F_ASN1_UNPACK_STRING 136 01233 # define ASN1_F_ASN1_UTCTIME_ADJ 218 01234 # define ASN1_F_ASN1_UTCTIME_SET 187 01235 # define ASN1_F_ASN1_VERIFY 137 01236 # define ASN1_F_B64_READ_ASN1 209 01237 # define ASN1_F_B64_WRITE_ASN1 210 01238 # define ASN1_F_BIO_NEW_NDEF 208 01239 # define ASN1_F_BITSTR_CB 180 01240 # define ASN1_F_BN_TO_ASN1_ENUMERATED 138 01241 # define ASN1_F_BN_TO_ASN1_INTEGER 139 01242 # define ASN1_F_C2I_ASN1_BIT_STRING 189 01243 # define ASN1_F_C2I_ASN1_INTEGER 194 01244 # define ASN1_F_C2I_ASN1_OBJECT 196 01245 # define ASN1_F_COLLECT_DATA 140 01246 # define ASN1_F_D2I_ASN1_BIT_STRING 141 01247 # define ASN1_F_D2I_ASN1_BOOLEAN 142 01248 # define ASN1_F_D2I_ASN1_BYTES 143 01249 # define ASN1_F_D2I_ASN1_GENERALIZEDTIME 144 01250 # define ASN1_F_D2I_ASN1_HEADER 145 01251 # define ASN1_F_D2I_ASN1_INTEGER 146 01252 # define ASN1_F_D2I_ASN1_OBJECT 147 01253 # define ASN1_F_D2I_ASN1_SET 148 01254 # define ASN1_F_D2I_ASN1_TYPE_BYTES 149 01255 # define ASN1_F_D2I_ASN1_UINTEGER 150 01256 # define ASN1_F_D2I_ASN1_UTCTIME 151 01257 # define ASN1_F_D2I_AUTOPRIVATEKEY 207 01258 # define ASN1_F_D2I_NETSCAPE_RSA 152 01259 # define ASN1_F_D2I_NETSCAPE_RSA_2 153 01260 # define ASN1_F_D2I_PRIVATEKEY 154 01261 # define ASN1_F_D2I_PUBLICKEY 155 01262 # define ASN1_F_D2I_RSA_NET 200 01263 # define ASN1_F_D2I_RSA_NET_2 201 01264 # define ASN1_F_D2I_X509 156 01265 # define ASN1_F_D2I_X509_CINF 157 01266 # define ASN1_F_D2I_X509_PKEY 159 01267 # define ASN1_F_I2D_ASN1_BIO_STREAM 211 01268 # define ASN1_F_I2D_ASN1_SET 188 01269 # define ASN1_F_I2D_ASN1_TIME 160 01270 # define ASN1_F_I2D_DSA_PUBKEY 161 01271 # define ASN1_F_I2D_EC_PUBKEY 181 01272 # define ASN1_F_I2D_PRIVATEKEY 163 01273 # define ASN1_F_I2D_PUBLICKEY 164 01274 # define ASN1_F_I2D_RSA_NET 162 01275 # define ASN1_F_I2D_RSA_PUBKEY 165 01276 # define ASN1_F_LONG_C2I 166 01277 # define ASN1_F_OID_MODULE_INIT 174 01278 # define ASN1_F_PARSE_TAGGING 182 01279 # define ASN1_F_PKCS5_PBE2_SET_IV 167 01280 # define ASN1_F_PKCS5_PBE_SET 202 01281 # define ASN1_F_PKCS5_PBE_SET0_ALGOR 215 01282 # define ASN1_F_PKCS5_PBKDF2_SET 219 01283 # define ASN1_F_SMIME_READ_ASN1 212 01284 # define ASN1_F_SMIME_TEXT 213 01285 # define ASN1_F_X509_CINF_NEW 168 01286 # define ASN1_F_X509_CRL_ADD0_REVOKED 169 01287 # define ASN1_F_X509_INFO_NEW 170 01288 # define ASN1_F_X509_NAME_ENCODE 203 01289 # define ASN1_F_X509_NAME_EX_D2I 158 01290 # define ASN1_F_X509_NAME_EX_NEW 171 01291 # define ASN1_F_X509_NEW 172 01292 # define ASN1_F_X509_PKEY_NEW 173 01293 01294 /* Reason codes. */ 01295 # define ASN1_R_ADDING_OBJECT 171 01296 # define ASN1_R_ASN1_PARSE_ERROR 203 01297 # define ASN1_R_ASN1_SIG_PARSE_ERROR 204 01298 # define ASN1_R_AUX_ERROR 100 01299 # define ASN1_R_BAD_CLASS 101 01300 # define ASN1_R_BAD_OBJECT_HEADER 102 01301 # define ASN1_R_BAD_PASSWORD_READ 103 01302 # define ASN1_R_BAD_TAG 104 01303 # define ASN1_R_BMPSTRING_IS_WRONG_LENGTH 214 01304 # define ASN1_R_BN_LIB 105 01305 # define ASN1_R_BOOLEAN_IS_WRONG_LENGTH 106 01306 # define ASN1_R_BUFFER_TOO_SMALL 107 01307 # define ASN1_R_CIPHER_HAS_NO_OBJECT_IDENTIFIER 108 01308 # define ASN1_R_CONTEXT_NOT_INITIALISED 217 01309 # define ASN1_R_DATA_IS_WRONG 109 01310 # define ASN1_R_DECODE_ERROR 110 01311 # define ASN1_R_DECODING_ERROR 111 01312 # define ASN1_R_DEPTH_EXCEEDED 174 01313 # define ASN1_R_DIGEST_AND_KEY_TYPE_NOT_SUPPORTED 198 01314 # define ASN1_R_ENCODE_ERROR 112 01315 # define ASN1_R_ERROR_GETTING_TIME 173 01316 # define ASN1_R_ERROR_LOADING_SECTION 172 01317 # define ASN1_R_ERROR_PARSING_SET_ELEMENT 113 01318 # define ASN1_R_ERROR_SETTING_CIPHER_PARAMS 114 01319 # define ASN1_R_EXPECTING_AN_INTEGER 115 01320 # define ASN1_R_EXPECTING_AN_OBJECT 116 01321 # define ASN1_R_EXPECTING_A_BOOLEAN 117 01322 # define ASN1_R_EXPECTING_A_TIME 118 01323 # define ASN1_R_EXPLICIT_LENGTH_MISMATCH 119 01324 # define ASN1_R_EXPLICIT_TAG_NOT_CONSTRUCTED 120 01325 # define ASN1_R_FIELD_MISSING 121 01326 # define ASN1_R_FIRST_NUM_TOO_LARGE 122 01327 # define ASN1_R_HEADER_TOO_LONG 123 01328 # define ASN1_R_ILLEGAL_BITSTRING_FORMAT 175 01329 # define ASN1_R_ILLEGAL_BOOLEAN 176 01330 # define ASN1_R_ILLEGAL_CHARACTERS 124 01331 # define ASN1_R_ILLEGAL_FORMAT 177 01332 # define ASN1_R_ILLEGAL_HEX 178 01333 # define ASN1_R_ILLEGAL_IMPLICIT_TAG 179 01334 # define ASN1_R_ILLEGAL_INTEGER 180 01335 # define ASN1_R_ILLEGAL_NESTED_TAGGING 181 01336 # define ASN1_R_ILLEGAL_NULL 125 01337 # define ASN1_R_ILLEGAL_NULL_VALUE 182 01338 # define ASN1_R_ILLEGAL_OBJECT 183 01339 # define ASN1_R_ILLEGAL_OPTIONAL_ANY 126 01340 # define ASN1_R_ILLEGAL_OPTIONS_ON_ITEM_TEMPLATE 170 01341 # define ASN1_R_ILLEGAL_TAGGED_ANY 127 01342 # define ASN1_R_ILLEGAL_TIME_VALUE 184 01343 # define ASN1_R_INTEGER_NOT_ASCII_FORMAT 185 01344 # define ASN1_R_INTEGER_TOO_LARGE_FOR_LONG 128 01345 # define ASN1_R_INVALID_BIT_STRING_BITS_LEFT 220 01346 # define ASN1_R_INVALID_BMPSTRING_LENGTH 129 01347 # define ASN1_R_INVALID_DIGIT 130 01348 # define ASN1_R_INVALID_MIME_TYPE 205 01349 # define ASN1_R_INVALID_MODIFIER 186 01350 # define ASN1_R_INVALID_NUMBER 187 01351 # define ASN1_R_INVALID_OBJECT_ENCODING 216 01352 # define ASN1_R_INVALID_SEPARATOR 131 01353 # define ASN1_R_INVALID_TIME_FORMAT 132 01354 # define ASN1_R_INVALID_UNIVERSALSTRING_LENGTH 133 01355 # define ASN1_R_INVALID_UTF8STRING 134 01356 # define ASN1_R_IV_TOO_LARGE 135 01357 # define ASN1_R_LENGTH_ERROR 136 01358 # define ASN1_R_LIST_ERROR 188 01359 # define ASN1_R_MIME_NO_CONTENT_TYPE 206 01360 # define ASN1_R_MIME_PARSE_ERROR 207 01361 # define ASN1_R_MIME_SIG_PARSE_ERROR 208 01362 # define ASN1_R_MISSING_EOC 137 01363 # define ASN1_R_MISSING_SECOND_NUMBER 138 01364 # define ASN1_R_MISSING_VALUE 189 01365 # define ASN1_R_MSTRING_NOT_UNIVERSAL 139 01366 # define ASN1_R_MSTRING_WRONG_TAG 140 01367 # define ASN1_R_NESTED_ASN1_STRING 197 01368 # define ASN1_R_NON_HEX_CHARACTERS 141 01369 # define ASN1_R_NOT_ASCII_FORMAT 190 01370 # define ASN1_R_NOT_ENOUGH_DATA 142 01371 # define ASN1_R_NO_CONTENT_TYPE 209 01372 # define ASN1_R_NO_DEFAULT_DIGEST 201 01373 # define ASN1_R_NO_MATCHING_CHOICE_TYPE 143 01374 # define ASN1_R_NO_MULTIPART_BODY_FAILURE 210 01375 # define ASN1_R_NO_MULTIPART_BOUNDARY 211 01376 # define ASN1_R_NO_SIG_CONTENT_TYPE 212 01377 # define ASN1_R_NULL_IS_WRONG_LENGTH 144 01378 # define ASN1_R_OBJECT_NOT_ASCII_FORMAT 191 01379 # define ASN1_R_ODD_NUMBER_OF_CHARS 145 01380 # define ASN1_R_PRIVATE_KEY_HEADER_MISSING 146 01381 # define ASN1_R_SECOND_NUMBER_TOO_LARGE 147 01382 # define ASN1_R_SEQUENCE_LENGTH_MISMATCH 148 01383 # define ASN1_R_SEQUENCE_NOT_CONSTRUCTED 149 01384 # define ASN1_R_SEQUENCE_OR_SET_NEEDS_CONFIG 192 01385 # define ASN1_R_SHORT_LINE 150 01386 # define ASN1_R_SIG_INVALID_MIME_TYPE 213 01387 # define ASN1_R_STREAMING_NOT_SUPPORTED 202 01388 # define ASN1_R_STRING_TOO_LONG 151 01389 # define ASN1_R_STRING_TOO_SHORT 152 01390 # define ASN1_R_TAG_VALUE_TOO_HIGH 153 01391 # define ASN1_R_THE_ASN1_OBJECT_IDENTIFIER_IS_NOT_KNOWN_FOR_THIS_MD 154 01392 # define ASN1_R_TIME_NOT_ASCII_FORMAT 193 01393 # define ASN1_R_TOO_LONG 155 01394 # define ASN1_R_TYPE_NOT_CONSTRUCTED 156 01395 # define ASN1_R_TYPE_NOT_PRIMITIVE 218 01396 # define ASN1_R_UNABLE_TO_DECODE_RSA_KEY 157 01397 # define ASN1_R_UNABLE_TO_DECODE_RSA_PRIVATE_KEY 158 01398 # define ASN1_R_UNEXPECTED_EOC 159 01399 # define ASN1_R_UNIVERSALSTRING_IS_WRONG_LENGTH 215 01400 # define ASN1_R_UNKNOWN_FORMAT 160 01401 # define ASN1_R_UNKNOWN_MESSAGE_DIGEST_ALGORITHM 161 01402 # define ASN1_R_UNKNOWN_OBJECT_TYPE 162 01403 # define ASN1_R_UNKNOWN_PUBLIC_KEY_TYPE 163 01404 # define ASN1_R_UNKNOWN_SIGNATURE_ALGORITHM 199 01405 # define ASN1_R_UNKNOWN_TAG 194 01406 # define ASN1_R_UNKOWN_FORMAT 195 01407 # define ASN1_R_UNSUPPORTED_ANY_DEFINED_BY_TYPE 164 01408 # define ASN1_R_UNSUPPORTED_CIPHER 165 01409 # define ASN1_R_UNSUPPORTED_ENCRYPTION_ALGORITHM 166 01410 # define ASN1_R_UNSUPPORTED_PUBLIC_KEY_TYPE 167 01411 # define ASN1_R_UNSUPPORTED_TYPE 196 01412 # define ASN1_R_WRONG_PUBLIC_KEY_TYPE 200 01413 # define ASN1_R_WRONG_TAG 168 01414 # define ASN1_R_WRONG_TYPE 169 01415 01416 #ifdef __cplusplus 01417 } 01418 #endif 01419 #endif