1 /* crypto/asn1/asn1.h */ 2 /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 3 * All rights reserved. 4 * 5 * This package is an SSL implementation written 6 * by Eric Young (eay@cryptsoft.com). 7 * The implementation was written so as to conform with Netscapes SSL. 8 * 9 * This library is free for commercial and non-commercial use as long as 10 * the following conditions are aheared to. The following conditions 11 * apply to all code found in this distribution, be it the RC4, RSA, 12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation 13 * included with this distribution is covered by the same copyright terms 14 * except that the holder is Tim Hudson (tjh@cryptsoft.com). 15 * 16 * Copyright remains Eric Young's, and as such any Copyright notices in 17 * the code are not to be removed. 18 * If this package is used in a product, Eric Young should be given attribution 19 * as the author of the parts of the library used. 20 * This can be in the form of a textual message at program startup or 21 * in documentation (online or textual) provided with the package. 22 * 23 * Redistribution and use in source and binary forms, with or without 24 * modification, are permitted provided that the following conditions 25 * are met: 26 * 1. Redistributions of source code must retain the copyright 27 * notice, this list of conditions and the following disclaimer. 28 * 2. Redistributions in binary form must reproduce the above copyright 29 * notice, this list of conditions and the following disclaimer in the 30 * documentation and/or other materials provided with the distribution. 31 * 3. All advertising materials mentioning features or use of this software 32 * must display the following acknowledgement: 33 * "This product includes cryptographic software written by 34 * Eric Young (eay@cryptsoft.com)" 35 * The word 'cryptographic' can be left out if the rouines from the library 36 * being used are not cryptographic related :-). 37 * 4. If you include any Windows specific code (or a derivative thereof) from 38 * the apps directory (application code) you must include an acknowledgement: 39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" 40 * 41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND 42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 51 * SUCH DAMAGE. 52 * 53 * The licence and distribution terms for any publically available version or 54 * derivative of this code cannot be changed. i.e. this code cannot simply be 55 * copied and put under another distribution licence 56 * [including the GNU Public Licence.] 57 */ 58 59 module deimos.openssl.asn1; 60 61 import deimos.openssl._d_util; 62 63 import deimos.openssl.asn1t; // Needed for ASN1_ITEM_st. 64 65 import core.stdc.time; 66 public import deimos.openssl.e_os2; 67 version(OPENSSL_NO_BIO) {} else { 68 public import deimos.openssl.bio; 69 } 70 public import deimos.openssl.stack; 71 public import deimos.openssl.safestack; 72 73 public import deimos.openssl.symhacks; 74 75 public import deimos.openssl.ossl_typ; 76 version(OPENSSL_NO_DEPRECATED) {} else { 77 public import deimos.openssl.bn; 78 } 79 80 81 extern (C): 82 nothrow: 83 84 enum V_ASN1_UNIVERSAL = 0x00; 85 enum V_ASN1_APPLICATION = 0x40; 86 enum V_ASN1_CONTEXT_SPECIFIC = 0x80; 87 enum V_ASN1_PRIVATE = 0xc0; 88 89 enum V_ASN1_CONSTRUCTED = 0x20; 90 enum V_ASN1_PRIMITIVE_TAG = 0x1f; 91 enum V_ASN1_PRIMATIVE_TAG = 0x1f; 92 93 enum V_ASN1_APP_CHOOSE = -2; /* let the recipient choose */ 94 enum V_ASN1_OTHER = -3; /* used in ASN1_TYPE */ 95 enum V_ASN1_ANY = -4; /* used in ASN1 template code */ 96 97 enum V_ASN1_NEG = 0x100; /* negative flag */ 98 99 enum V_ASN1_UNDEF = -1; 100 enum V_ASN1_EOC = 0; 101 enum V_ASN1_BOOLEAN = 1; /**/ 102 enum V_ASN1_INTEGER = 2; 103 enum V_ASN1_NEG_INTEGER = (2 | V_ASN1_NEG); 104 enum V_ASN1_BIT_STRING = 3; 105 enum V_ASN1_OCTET_STRING = 4; 106 enum V_ASN1_NULL = 5; 107 enum V_ASN1_OBJECT = 6; 108 enum V_ASN1_OBJECT_DESCRIPTOR = 7; 109 enum V_ASN1_EXTERNAL = 8; 110 enum V_ASN1_REAL = 9; 111 enum V_ASN1_ENUMERATED = 10; 112 enum V_ASN1_NEG_ENUMERATED = (10 | V_ASN1_NEG); 113 enum V_ASN1_UTF8STRING = 12; 114 enum V_ASN1_SEQUENCE = 16; 115 enum V_ASN1_SET = 17; 116 enum V_ASN1_NUMERICSTRING = 18; /**/ 117 enum V_ASN1_PRINTABLESTRING = 19; 118 enum V_ASN1_T61STRING = 20; 119 enum V_ASN1_TELETEXSTRING = 20; /* alias */ 120 enum V_ASN1_VIDEOTEXSTRING = 21; /**/ 121 enum V_ASN1_IA5STRING = 22; 122 enum V_ASN1_UTCTIME = 23; 123 enum V_ASN1_GENERALIZEDTIME = 24; /**/ 124 enum V_ASN1_GRAPHICSTRING = 25; /**/ 125 enum V_ASN1_ISO64STRING = 26; /**/ 126 enum V_ASN1_VISIBLESTRING = 26; /* alias */ 127 enum V_ASN1_GENERALSTRING = 27; /**/ 128 enum V_ASN1_UNIVERSALSTRING = 28; /**/ 129 enum V_ASN1_BMPSTRING = 30; 130 131 /* For use with d2i_ASN1_type_bytes() */ 132 enum B_ASN1_NUMERICSTRING = 0x0001; 133 enum B_ASN1_PRINTABLESTRING = 0x0002; 134 enum B_ASN1_T61STRING = 0x0004; 135 enum B_ASN1_TELETEXSTRING = 0x0004; 136 enum B_ASN1_VIDEOTEXSTRING = 0x0008; 137 enum B_ASN1_IA5STRING = 0x0010; 138 enum B_ASN1_GRAPHICSTRING = 0x0020; 139 enum B_ASN1_ISO64STRING = 0x0040; 140 enum B_ASN1_VISIBLESTRING = 0x0040; 141 enum B_ASN1_GENERALSTRING = 0x0080; 142 enum B_ASN1_UNIVERSALSTRING = 0x0100; 143 enum B_ASN1_OCTET_STRING = 0x0200; 144 enum B_ASN1_BIT_STRING = 0x0400; 145 enum B_ASN1_BMPSTRING = 0x0800; 146 enum B_ASN1_UNKNOWN = 0x1000; 147 enum B_ASN1_UTF8STRING = 0x2000; 148 enum B_ASN1_UTCTIME = 0x4000; 149 enum B_ASN1_GENERALIZEDTIME = 0x8000; 150 enum B_ASN1_SEQUENCE = 0x10000; 151 152 /* For use with ASN1_mbstring_copy() */ 153 enum MBSTRING_FLAG = 0x1000; 154 enum MBSTRING_UTF8 = (MBSTRING_FLAG); 155 enum MBSTRING_ASC = (MBSTRING_FLAG|1); 156 enum MBSTRING_BMP = (MBSTRING_FLAG|2); 157 enum MBSTRING_UNIV = (MBSTRING_FLAG|4); 158 159 enum SMIME_OLDMIME = 0x400; 160 enum SMIME_CRLFEOL = 0x800; 161 enum SMIME_STREAM = 0x1000; 162 163 /+mixin DECLARE_STACK_OF!(X509_ALGOR);+/ 164 165 mixin template DECLARE_ASN1_SET_OF(type) {} /* filled in by mkstack.pl */ 166 mixin template IMPLEMENT_ASN1_SET_OF(type) {} /* nothing, no longer needed */ 167 168 /* We MUST make sure that, except for constness, asn1_ctx_st and 169 asn1_const_ctx are exactly the same. Fortunately, as soon as 170 the old ASN1 parsing macros are gone, we can throw this away 171 as well... */ 172 struct asn1_ctx_st { 173 ubyte* p;/* work char pointer */ 174 int eos; /* end of sequence read for indefinite encoding */ 175 int error; /* error code to use when returning an error */ 176 int inf; /* constructed if 0x20, indefinite is 0x21 */ 177 int tag; /* tag from last 'get object' */ 178 int xclass; /* class from last 'get object' */ 179 c_long slen; /* length of last 'get object' */ 180 ubyte* max; /* largest value of p allowed */ 181 ubyte* q;/* temporary variable */ 182 ubyte** pp;/* variable */ 183 int line; /* used in error processing */ 184 } 185 alias asn1_ctx_st ASN1_CTX; 186 187 struct asn1_const_ctx_st { 188 const(ubyte)* p;/* work char pointer */ 189 int eos; /* end of sequence read for indefinite encoding */ 190 int error; /* error code to use when returning an error */ 191 int inf; /* constructed if 0x20, indefinite is 0x21 */ 192 int tag; /* tag from last 'get object' */ 193 int xclass; /* class from last 'get object' */ 194 c_long slen; /* length of last 'get object' */ 195 const(ubyte)* max; /* largest value of p allowed */ 196 const(ubyte)* q;/* temporary variable */ 197 const(ubyte)** pp;/* variable */ 198 int line; /* used in error processing */ 199 } 200 alias asn1_const_ctx_st ASN1_const_CTX; 201 202 /* These are used internally in the ASN1_OBJECT to keep track of 203 * whether the names and data need to be free()ed */ 204 enum ASN1_OBJECT_FLAG_DYNAMIC = 0x01; /* internal use */ 205 enum ASN1_OBJECT_FLAG_CRITICAL = 0x02; /* critical x509v3 object id */ 206 enum ASN1_OBJECT_FLAG_DYNAMIC_STRINGS = 0x04; /* internal use */ 207 enum ASN1_OBJECT_FLAG_DYNAMIC_DATA = 0x08; /* internal use */ 208 struct asn1_object_st { 209 const(char)* sn,ln; 210 int nid; 211 int length; 212 const(ubyte)* data; /* data remains const after init */ 213 int flags; /* Should we free this one */ 214 } 215 alias asn1_object_st ASN1_OBJECT; 216 217 enum ASN1_STRING_FLAG_BITS_LEFT = 0x08; /* Set if 0x07 has bits left value */ 218 /* This indicates that the ASN1_STRING is not a real value but just a place 219 * holder for the location where indefinite length constructed data should 220 * be inserted in the memory buffer 221 */ 222 enum ASN1_STRING_FLAG_NDEF = 0x010; 223 224 /* This flag is used by the CMS code to indicate that a string is not 225 * complete and is a place holder for content when it had all been 226 * accessed. The flag will be reset when content has been written to it. 227 */ 228 229 enum ASN1_STRING_FLAG_CONT = 0x020; 230 /* This flag is used by ASN1 code to indicate an ASN1_STRING is an MSTRING 231 * type. 232 */ 233 enum ASN1_STRING_FLAG_MSTRING = 0x040; 234 /* This is the base type that holds just about everything :-) */ 235 struct asn1_string_st { 236 int length; 237 int type; 238 ubyte* data; 239 /* The value of the following field depends on the type being 240 * held. It is mostly being used for BIT_STRING so if the 241 * input data has a non-zero 'unused bits' value, it will be 242 * handled correctly */ 243 c_long flags; 244 } 245 246 /* ASN1_ENCODING structure: this is used to save the received 247 * encoding of an ASN1 type. This is useful to get round 248 * problems with invalid encodings which can break signatures. 249 */ 250 251 struct ASN1_ENCODING_st { 252 ubyte* enc; /* DER encoding */ 253 c_long len; /* Length of encoding */ 254 int modified; /* set to 1 if 'enc' is invalid */ 255 } 256 alias ASN1_ENCODING_st ASN1_ENCODING; 257 258 /* Used with ASN1 LONG type: if a c_long is set to this it is omitted */ 259 enum ASN1_LONG_UNDEF = 0x7fffffff; 260 261 enum STABLE_FLAGS_MALLOC = 0x01; 262 enum STABLE_NO_MASK = 0x02; 263 enum DIRSTRING_TYPE = (B_ASN1_PRINTABLESTRING|B_ASN1_T61STRING|B_ASN1_BMPSTRING|B_ASN1_UTF8STRING); 264 enum PKCS9STRING_TYPE = (DIRSTRING_TYPE|B_ASN1_IA5STRING); 265 266 struct asn1_string_table_st { 267 int nid; 268 c_long minsize; 269 c_long maxsize; 270 c_ulong mask; 271 c_ulong flags; 272 } 273 alias asn1_string_table_st ASN1_STRING_TABLE; 274 275 /+mixin DECLARE_STACK_OF!(ASN1_STRING_TABLE);+/ 276 277 /* size limits: this stuff is taken straight from RFC2459 */ 278 279 enum ub_name = 32768; 280 enum ub_common_name = 64; 281 enum ub_locality_name = 128; 282 enum ub_state_name = 128; 283 enum ub_organization_name = 64; 284 enum ub_organization_unit_name = 64; 285 enum ub_title = 64; 286 enum ub_email_address = 128; 287 288 /* Declarations for template structures: for full definitions 289 * see asn1t.h 290 */ 291 alias ASN1_TEMPLATE_st ASN1_TEMPLATE; 292 import deimos.openssl.asn1t; /*struct ASN1_TLC_st;*/ 293 alias ASN1_TLC_st ASN1_TLC; 294 /* This is just an opaque pointer */ 295 struct ASN1_VALUE_st; 296 alias ASN1_VALUE_st ASN1_VALUE; 297 298 /* Declare ASN1 functions: the implement macro in in asn1t.h */ 299 // Need to use string mixins here to avoid DMD mangling extern(C) symbol names. 300 301 template DECLARE_ASN1_FUNCTIONS(string type) { 302 enum DECLARE_ASN1_FUNCTIONS = DECLARE_ASN1_FUNCTIONS_name!(type, type); 303 } 304 305 template DECLARE_ASN1_ALLOC_FUNCTIONS(string type) { 306 enum DECLARE_ASN1_ALLOC_FUNCTIONS = 307 DECLARE_ASN1_ALLOC_FUNCTIONS_name!(type, type); 308 } 309 310 template DECLARE_ASN1_FUNCTIONS_name(string type, string name) { 311 enum DECLARE_ASN1_FUNCTIONS_name = 312 DECLARE_ASN1_ALLOC_FUNCTIONS_name!(type, name) ~ 313 DECLARE_ASN1_ENCODE_FUNCTIONS!(type, name, name); 314 } 315 316 template DECLARE_ASN1_FUNCTIONS_fname(string type, string itname, string name) { 317 enum DECLARE_ASN1_FUNCTIONS_fname = 318 DECLARE_ASN1_ALLOC_FUNCTIONS_name!(type, name) ~ 319 DECLARE_ASN1_ENCODE_FUNCTIONS!(type, itname, name); 320 } 321 322 template DECLARE_ASN1_ENCODE_FUNCTIONS(string type, string itname, string name) { 323 enum DECLARE_ASN1_ENCODE_FUNCTIONS = " 324 " ~ type ~ "* d2i_" ~ name ~ "(" ~ type ~ "** a, const(ubyte)** in_, c_long len); 325 int i2d_" ~ name ~ "(" ~ type ~ "* a, ubyte** out_); 326 " ~ DECLARE_ASN1_ITEM!itname; 327 } 328 329 template DECLARE_ASN1_ENCODE_FUNCTIONS_const(string type, string name) { 330 enum DECLARE_ASN1_ENCODE_FUNCTIONS_const = " 331 " ~ type ~ "* d2i_" ~ name ~ "(" ~ type ~ "** a, const(ubyte)** in_, c_long len); 332 int i2d_" ~ name ~ "(const(" ~ type ~ ")* a, ubyte** out_); 333 " ~ DECLARE_ASN1_ITEM!name; 334 } 335 336 template DECLARE_ASN1_NDEF_FUNCTION(string name) { 337 enum DECLARE_ASN1_NDEF_FUNCTION = " 338 int i2d_" ~ name ~ "_NDEF(" ~ name ~ "* a, ubyte** out_); 339 "; 340 } 341 342 template DECLARE_ASN1_FUNCTIONS_const(string name) { 343 enum DECLARE_ASN1_FUNCTIONS_const = 344 DECLARE_ASN1_ALLOC_FUNCTIONS!name ~ 345 DECLARE_ASN1_ENCODE_FUNCTIONS_const!(name, name); 346 } 347 348 template DECLARE_ASN1_ALLOC_FUNCTIONS_name(string type, string name) { 349 enum DECLARE_ASN1_ALLOC_FUNCTIONS_name = " 350 extern(C) " ~ type ~ "* " ~ name ~ "_new(); 351 extern(C) void " ~ name ~ "_free(" ~ type ~ "* a); 352 "; 353 } 354 355 template DECLARE_ASN1_PRINT_FUNCTION(string stname) { 356 enum DECLARE_ASN1_PRINT_FUNCTION = 357 DECLARE_ASN1_PRINT_FUNCTION_fname!(stname, stname); 358 } 359 360 template DECLARE_ASN1_PRINT_FUNCTION_fname(string stname, string fname) { 361 enum DECLARE_ASN1_PRINT_FUNCTION_fname = " 362 int " ~ fname ~ "_print_ctx(BIO* out_, " ~ stname ~ "* x, int indent, 363 const(ASN1_PCTX)* pctx); 364 "; 365 } 366 367 template D2I_OF(type) { 368 alias ExternC!(type* function(type**, const(ubyte)**, c_long)) D2I_OF; 369 } 370 template I2D_OF(type) { 371 alias ExternC!(int function(type*, ubyte**)) I2D_OF; 372 } 373 template I2D_OF_const(type) { 374 alias ExternC!(int function(const(type)*, ubyte**)) I2D_OF_const; 375 } 376 377 d2i_of_void* CHECKED_D2I_OF(type)(D2I_OF!type d2i) { 378 return cast(d2i_of_void*) (1 ? d2i : null); 379 } 380 i2d_of_void* CHECKED_I2D_OF(type)(I2D_OF!type i2d) { 381 return cast(i2d_of_void*) (1 ? i2d : null); 382 } 383 ExternC!(type* function()) CHECKED_NEW_OF(type)(ExternC!(type* function()) xnew) { 384 return typeof(return)(1 ? xnew : null); 385 } 386 void* CHECKED_PTR_OF(type)(type* p) { 387 return cast(void*)(1 ? p : null); 388 } 389 void* CHECKED_PPTR_OF(type)(type** p) { 390 return cast(void**)(1 ? p : null); 391 } 392 393 template TYPEDEF_D2I_OF(string type) { 394 enum TYPEDEF_D2I_OF = "alias typeof(D2I_OF!(" ~ type ~ ").init) d2i_of_" ~ type ~ ";"; 395 } 396 template TYPEDEF_I2D_OF(string type) { 397 enum TYPEDEF_I2D_OF = "alias typeof(I2D_OF!(" ~ type ~ ").init) i2d_of_" ~ type ~ ";"; 398 } 399 template TYPEDEF_D2I2D_OF(string type) { 400 enum TYPEDEF_D2I2D_OF = TYPEDEF_D2I_OF!type ~ TYPEDEF_I2D_OF!type; 401 } 402 403 // Probably due to a DMD @@BUG@@, the types are not available to all modules 404 // if the mixin is used. 405 // mixin(TYPEDEF_D2I2D_OF!"void"); 406 alias typeof(*(D2I_OF!void).init) d2i_of_void; 407 alias typeof(*(I2D_OF!void).init) i2d_of_void; 408 409 /* The following macros and typedefs allow an ASN1_ITEM 410 * to be embedded in a structure and referenced. Since 411 * the ASN1_ITEM pointers need to be globally accessible 412 * (possibly from shared libraries) they may exist in 413 * different forms. On platforms that support it the 414 * ASN1_ITEM structure itself will be globally exported. 415 * Other platforms will export a function that returns 416 * an ASN1_ITEM pointer. 417 * 418 * To handle both cases transparently the macros below 419 * should be used instead of hard coding an ASN1_ITEM 420 * pointer in a structure. 421 * 422 * The structure will look like this: 423 * 424 * struct SOMETHING_st { 425 * ... 426 * ASN1_ITEM_EXP* iptr; 427 * ... 428 * } 429 alias SOMETHING_st SOMETHING; 430 * 431 * It would be initialised as e.g.: 432 * 433 * SOMETHING somevar = {...,ASN1_ITEM_ref(X509),...}; 434 * 435 * and the actual pointer extracted with: 436 * 437 * const(ASN1_ITEM)* it = ASN1_ITEM_ptr(somevar.iptr); 438 * 439 * Finally an ASN1_ITEM pointer can be extracted from an 440 * appropriate reference with: ASN1_ITEM_rptr(X509). This 441 * would be used when a function takes an ASN1_ITEM* argument. 442 * 443 */ 444 445 version (OPENSSL_EXPORT_VAR_AS_FUNCTION) { 446 /* Platforms that can't easily handle shared global variables are declared 447 * as functions returning ASN1_ITEM pointers. 448 */ 449 450 /* ASN1_ITEM pointer exported type */ 451 alias const(ASN1_ITEM)* ASN1_ITEM_EXP; 452 453 /* Macro to obtain ASN1_ITEM pointer from exported type */ 454 template ASN1_ITEM_ptr(string iptr) { 455 enum ASN1_ITEM_ptr = "(" ~ iptr ~ ")()"; 456 } 457 458 /* Macro to include ASN1_ITEM pointer from base type */ 459 template ASN1_ITEM_ref(string iptr) { 460 enum ASN1_ITEM_ref = "(" ~ iptr ~ "_it)"; 461 } 462 463 template ASN1_ITEM_rptr(string ref_) { 464 enum ASN1_ITEM_rptr = "(" ~ ref_ ~ "_it())"; 465 } 466 467 template DECLARE_ASN1_ITEM(string name) { 468 enum DECLARE_ASN1_ITEM = "extern(C) const(ASN1_ITEM)* " ~ name ~ "_it();"; 469 } 470 } else { 471 /* ASN1_ITEM pointer exported type */ 472 alias const(ASN1_ITEM) ASN1_ITEM_EXP; 473 474 /* Macro to obtain ASN1_ITEM pointer from exported type */ 475 template ASN1_ITEM_ptr(string iptr) { 476 enum ASN1_ITEM_ptr = iptr; 477 } 478 479 /* Macro to include ASN1_ITEM pointer from base type */ 480 template ASN1_ITEM_ref(string iptr) { 481 enum ASN1_ITEM_ref = "(&(" ~ iptr ~ "_it))"; 482 } 483 484 template ASN1_ITEM_rptr(string ref_) { 485 enum ASN1_ITEM_rptr = "(&(" ~ ref_ ~ "_it))"; 486 } 487 488 template DECLARE_ASN1_ITEM(string name) { 489 enum DECLARE_ASN1_ITEM = "extern const(ASN1_ITEM) " ~ name ~ "_it;"; 490 } 491 } 492 493 /* Parameters used by ASN1_STRING_print_ex() */ 494 495 /* These determine which characters to escape: 496 * RFC2253 special characters, control characters and 497 * MSB set characters 498 */ 499 500 enum ASN1_STRFLGS_ESC_2253 = 1; 501 enum ASN1_STRFLGS_ESC_CTRL = 2; 502 enum ASN1_STRFLGS_ESC_MSB = 4; 503 504 505 /* This flag determines how we do escaping: normally 506 * RC2253 backslash only, set this to use backslash and 507 * quote. 508 */ 509 510 enum ASN1_STRFLGS_ESC_QUOTE = 8; 511 512 513 /* These three flags are internal use only. */ 514 515 /* Character is a valid PrintableString character */ 516 enum CHARTYPE_PRINTABLESTRING = 0x10; 517 /* Character needs escaping if it is the first character */ 518 enum CHARTYPE_FIRST_ESC_2253 = 0x20; 519 /* Character needs escaping if it is the last character */ 520 enum CHARTYPE_LAST_ESC_2253 = 0x40; 521 522 /* NB the internal flags are safely reused below by flags 523 * handled at the top level. 524 */ 525 526 /* If this is set we convert all character strings 527 * to UTF8 first 528 */ 529 530 enum ASN1_STRFLGS_UTF8_CONVERT = 0x10; 531 532 /* If this is set we don't attempt to interpret content: 533 * just assume all strings are 1 byte per character. This 534 * will produce some pretty odd looking output! 535 */ 536 537 enum ASN1_STRFLGS_IGNORE_TYPE = 0x20; 538 539 /* If this is set we include the string type in the output */ 540 enum ASN1_STRFLGS_SHOW_TYPE = 0x40; 541 542 /* This determines which strings to display and which to 543 * 'dump' (hex dump of content octets or DER encoding). We can 544 * only dump non character strings or everything. If we 545 * don't dump 'unknown' they are interpreted as character 546 * strings with 1 octet per character and are subject to 547 * the usual escaping options. 548 */ 549 550 enum ASN1_STRFLGS_DUMP_ALL = 0x80; 551 enum ASN1_STRFLGS_DUMP_UNKNOWN = 0x100; 552 553 /* These determine what 'dumping' does, we can dump the 554 * content octets or the DER encoding: both use the 555 * RFC2253 #XXXXX notation. 556 */ 557 558 enum ASN1_STRFLGS_DUMP_DER = 0x200; 559 560 /* All the string flags consistent with RFC2253, 561 * escaping control characters isn't essential in 562 * RFC2253 but it is advisable anyway. 563 */ 564 565 enum ASN1_STRFLGS_RFC2253 = (ASN1_STRFLGS_ESC_2253 | 566 ASN1_STRFLGS_ESC_CTRL | 567 ASN1_STRFLGS_ESC_MSB | 568 ASN1_STRFLGS_UTF8_CONVERT | 569 ASN1_STRFLGS_DUMP_UNKNOWN | 570 ASN1_STRFLGS_DUMP_DER); 571 572 /+mixin DECLARE_STACK_OF!(ASN1_INTEGER);+/ 573 mixin DECLARE_ASN1_SET_OF!(ASN1_INTEGER); 574 575 /+mixin DECLARE_STACK_OF!(ASN1_GENERALSTRING);+/ 576 577 struct asn1_type_st 578 { 579 int type; 580 union value_ { 581 char* ptr; 582 ASN1_BOOLEAN boolean; 583 ASN1_STRING* asn1_string; 584 ASN1_OBJECT* object; 585 ASN1_INTEGER* integer; 586 ASN1_ENUMERATED* enumerated; 587 ASN1_BIT_STRING* bit_string; 588 ASN1_OCTET_STRING* octet_string; 589 ASN1_PRINTABLESTRING* printablestring; 590 ASN1_T61STRING* t61string; 591 ASN1_IA5STRING* ia5string; 592 ASN1_GENERALSTRING* generalstring; 593 ASN1_BMPSTRING* bmpstring; 594 ASN1_UNIVERSALSTRING* universalstring; 595 ASN1_UTCTIME* utctime; 596 ASN1_GENERALIZEDTIME* generalizedtime; 597 ASN1_VISIBLESTRING* visiblestring; 598 ASN1_UTF8STRING* utf8string; 599 /* set and sequence are left complete and still 600 * contain the set or sequence bytes */ 601 ASN1_STRING* set; 602 ASN1_STRING* sequence; 603 ASN1_VALUE* asn1_value; 604 } 605 value_ value; 606 } 607 alias asn1_type_st ASN1_TYPE; 608 609 /+mixin DECLARE_STACK_OF!(ASN1_TYPE);+/ 610 mixin DECLARE_ASN1_SET_OF!(ASN1_TYPE); 611 612 alias STACK_OF!(ASN1_TYPE) ASN1_SEQUENCE_ANY; 613 614 mixin(DECLARE_ASN1_ENCODE_FUNCTIONS_const!("ASN1_SEQUENCE_ANY", "ASN1_SEQUENCE_ANY")); 615 mixin(DECLARE_ASN1_ENCODE_FUNCTIONS_const!("ASN1_SEQUENCE_ANY", "ASN1_SET_ANY")); 616 617 struct NETSCAPE_X509_st { 618 ASN1_OCTET_STRING* header; 619 X509* cert; 620 } 621 alias NETSCAPE_X509_st NETSCAPE_X509; 622 623 /* This is used to contain a list of bit names */ 624 struct BIT_STRING_BITNAME_st { 625 int bitnum; 626 const(char)* lname; 627 const(char)* sname; 628 } 629 alias BIT_STRING_BITNAME_st BIT_STRING_BITNAME; 630 631 632 auto M_ASN1_STRING_length()(ASN1_STRING* x) { return x.length; } 633 void M_ASN1_STRING_length_set()(ASN1_STRING* x, int n) { x.length = n; } 634 auto M_ASN1_STRING_type()(ASN1_STRING* x) { return x.type; } 635 auto M_ASN1_STRING_data()(ASN1_STRING* x) { return x.data; } 636 637 /* Macros for string operations */ 638 ASN1_BIT_STRING* M_ASN1_BIT_STRING_new()() { return cast(ASN1_BIT_STRING*)ASN1_STRING_type_new(V_ASN1_BIT_STRING); } 639 void M_ASN1_BIT_STRING_free()(ASN1_BIT_STRING* a) { ASN1_STRING_free(cast(ASN1_STRING*)a); } 640 ASN1_BIT_STRING* M_ASN1_BIT_STRING_dup()(ASN1_BIT_STRING* a) { return cast(ASN1_BIT_STRING*)ASN1_STRING_dup(cast(ASN1_STRING*)a); } 641 auto M_ASN1_BIT_STRING_cmp()(const(ASN1_BIT_STRING)* a, const(ASN1_BIT_STRING)* b) { return ASN1_STRING_cmp(cast(const(ASN1_STRING)*)a, cast(const(ASN1_STRING)*)b); } 642 auto M_ASN1_BIT_STRING_set()(ASN1_BIT_STRING* a,const(void)* b, int c){ return ASN1_STRING_set(cast(ASN1_STRING*)a, b, c); } 643 644 ASN1_INTEGER* M_ASN1_INTEGER_new()() { return cast(ASN1_INTEGER*)ASN1_STRING_type_new(V_ASN1_INTEGER); } 645 void M_ASN1_INTEGER_free()(ASN1_INTEGER* a) { ASN1_STRING_free(cast(ASN1_STRING*)a); } 646 ASN1_INTEGER* M_ASN1_INTEGER_dup()(ASN1_INTEGER* a) { return cast(ASN1_INTEGER*)ASN1_STRING_dup(cast(ASN1_STRING*)a); } 647 auto M_ASN1_INTEGER_cmp()(const(ASN1_INTEGER)* a, const(ASN1_INTEGER)* b) { return ASN1_STRING_cmp(cast(const(ASN1_STRING)*)a, cast(const(ASN1_STRING)*)b); } 648 649 ASN1_ENUMERATED* M_ASN1_ENUMERATED_new()() { return cast(ASN1_ENUMERATED*)ASN1_STRING_type_new(V_ASN1_ENUMERATED); } 650 void M_ASN1_ENUMERATED_free()(ASN1_ENUMERATED* a) { ASN1_STRING_free(cast(ASN1_STRING*)a); } 651 ASN1_ENUMERATED* M_ASN1_ENUMERATED_dup()(ASN1_ENUMERATED* a) { return cast(ASN1_ENUMERATED*)ASN1_STRING_dup(cast(ASN1_STRING*)a); } 652 auto M_ASN1_ENUMERATED_cmp()(const(ASN1_ENUMERATED)* a, const(ASN1_ENUMERATED)* b) { return ASN1_STRING_cmp(cast(const(ASN1_STRING)*)a, cast(const(ASN1_STRING)*)b); } 653 654 ASN1_OCTET_STRING* M_ASN1_OCTET_STRING_new()() { return cast(ASN1_OCTET_STRING*)ASN1_STRING_type_new(V_ASN1_OCTET_STRING); } 655 void M_ASN1_OCTET_STRING_free()(ASN1_OCTET_STRING* a) { ASN1_STRING_free(cast(ASN1_STRING*)a); } 656 ASN1_OCTET_STRING* M_ASN1_OCTET_STRING_dup()(ASN1_OCTET_STRING* a) { return cast(ASN1_OCTET_STRING*)ASN1_STRING_dup(cast(ASN1_STRING*)a); } 657 auto M_ASN1_OCTET_STRING_cmp()(const(ASN1_OCTET_STRING)* a, const(ASN1_OCTET_STRING)* b) { return ASN1_STRING_cmp(cast(const(ASN1_STRING)*)a, cast(const(ASN1_STRING)*)b); } 658 auto M_ASN1_OCTET_STRING_set()(ASN1_OCTET_STRING* a,const(void)* b, int c){ return ASN1_STRING_set(cast(ASN1_STRING*)a, b, c); } 659 auto M_ASN1_OCTET_STRING_print()(BIO* a,const(ASN1_OCTET_STRING)* b) { return ASN1_STRING_print(a,cast(ASN1_STRING*)b); } 660 auto M_i2d_ASN1_OCTET_STRING()(const(ASN1_OCTET_STRING)* a, ubyte** pp) { return i2d_ASN1_bytes(cast(ASN1_STRING*)a,pp,V_ASN1_OCTET_STRING,V_ASN1_UNIVERSAL); } 661 662 enum B_ASN1_TIME = 663 B_ASN1_UTCTIME | 664 B_ASN1_GENERALIZEDTIME; 665 666 enum B_ASN1_PRINTABLE = 667 B_ASN1_NUMERICSTRING| 668 B_ASN1_PRINTABLESTRING| 669 B_ASN1_T61STRING| 670 B_ASN1_IA5STRING| 671 B_ASN1_BIT_STRING| 672 B_ASN1_UNIVERSALSTRING| 673 B_ASN1_BMPSTRING| 674 B_ASN1_UTF8STRING| 675 B_ASN1_SEQUENCE| 676 B_ASN1_UNKNOWN; 677 678 enum B_ASN1_DIRECTORYSTRING = 679 B_ASN1_PRINTABLESTRING| 680 B_ASN1_TELETEXSTRING| 681 B_ASN1_BMPSTRING| 682 B_ASN1_UNIVERSALSTRING| 683 B_ASN1_UTF8STRING; 684 685 enum B_ASN1_DISPLAYTEXT = 686 B_ASN1_IA5STRING| 687 B_ASN1_VISIBLESTRING| 688 B_ASN1_BMPSTRING| 689 B_ASN1_UTF8STRING; 690 /+ 691 auto M_ASN1_PRINTABLE_new()() { return ASN1_STRING_type_new(V_ASN1_T61STRING); } 692 void M_ASN1_PRINTABLE_free()(ASN1_PRINTABLE* a) { ASN1_STRING_free(cast(ASN1_STRING*)a); } 693 #define M_i2d_ASN1_PRINTABLE(a,pp) i2d_ASN1_bytes((ASN1_STRING*)a,\ 694 pp,a->type,V_ASN1_UNIVERSAL) 695 #define M_d2i_ASN1_PRINTABLE(a,pp,l) \ 696 d2i_ASN1_type_bytes((ASN1_STRING**)a,pp,l, \ 697 B_ASN1_PRINTABLE) 698 699 auto M_DIRECTORYSTRING_new()() { return ASN1_STRING_type_new(V_ASN1_PRINTABLESTRING); } 700 void M_DIRECTORYSTRING_free()(DIRECTORYSTRING* a) { ASN1_STRING_free(cast(ASN1_STRING*)a); } 701 #define M_i2d_DIRECTORYSTRING(a,pp) i2d_ASN1_bytes((ASN1_STRING*)a,\ 702 pp,a->type,V_ASN1_UNIVERSAL) 703 #define M_d2i_DIRECTORYSTRING(a,pp,l) \ 704 d2i_ASN1_type_bytes((ASN1_STRING**)a,pp,l, \ 705 B_ASN1_DIRECTORYSTRING) 706 707 auto M_DISPLAYTEXT_new()() { return ASN1_STRING_type_new(V_ASN1_VISIBLESTRING); } 708 void M_DISPLAYTEXT_free()(DISPLAYTEXT* a) { ASN1_STRING_free(cast(ASN1_STRING*)a); } 709 #define M_i2d_DISPLAYTEXT(a,pp) i2d_ASN1_bytes((ASN1_STRING*)a,\ 710 pp,a->type,V_ASN1_UNIVERSAL) 711 #define M_d2i_DISPLAYTEXT(a,pp,l) \ 712 d2i_ASN1_type_bytes((ASN1_STRING**)a,pp,l, \ 713 B_ASN1_DISPLAYTEXT) 714 715 ASN1_PRINTABLESTRING* M_ASN1_PRINTABLESTRING_new()() { return cast(ASN1_PRINTABLESTRING*)ASN1_STRING_type_new(V_ASN1_PRINTABLESTRING); } 716 void M_ASN1_PRINTABLESTRING_free()(ASN1_PRINTABLESTRING* a) { ASN1_STRING_free(cast(ASN1_STRING*)a); } 717 #define M_i2d_ASN1_PRINTABLESTRING(a,pp) \ 718 i2d_ASN1_bytes((ASN1_STRING*)a,pp,V_ASN1_PRINTABLESTRING,\ 719 V_ASN1_UNIVERSAL) 720 #define M_d2i_ASN1_PRINTABLESTRING(a,pp,l) \ 721 (ASN1_PRINTABLESTRING*)d2i_ASN1_type_bytes\ 722 ((ASN1_STRING**)a,pp,l,B_ASN1_PRINTABLESTRING) 723 724 ASN1_T61STRING* M_ASN1_T61STRING_new()() { return cast(ASN1_T61STRING*)ASN1_STRING_type_new(V_ASN1_T61STRING); } 725 void M_ASN1_T61STRING_free()(ASN1_T61STRING* a) { ASN1_STRING_free(cast(ASN1_STRING*)a); } 726 #define M_i2d_ASN1_T61STRING(a,pp) \ 727 i2d_ASN1_bytes((ASN1_STRING*)a,pp,V_ASN1_T61STRING,\ 728 V_ASN1_UNIVERSAL) 729 #define M_d2i_ASN1_T61STRING(a,pp,l) \ 730 (ASN1_T61STRING*)d2i_ASN1_type_bytes\ 731 ((ASN1_STRING**)a,pp,l,B_ASN1_T61STRING) 732 733 ASN1_IA5STRING* M_ASN1_IA5STRING_new()() { return cast(ASN1_IA5STRING*)ASN1_STRING_type_new(V_ASN1_IA5STRING); } 734 void M_ASN1_IA5STRING_free()(ASN1_IA5STRING* a) { ASN1_STRING_free(cast(ASN1_STRING*)a); } 735 #define M_ASN1_IA5STRING_dup(a) \ 736 (ASN1_IA5STRING*)ASN1_STRING_dup((const(ASN1_STRING)*)a) 737 #define M_i2d_ASN1_IA5STRING(a,pp) \ 738 i2d_ASN1_bytes((ASN1_STRING*)a,pp,V_ASN1_IA5STRING,\ 739 V_ASN1_UNIVERSAL) 740 #define M_d2i_ASN1_IA5STRING(a,pp,l) \ 741 (ASN1_IA5STRING*)d2i_ASN1_type_bytes((ASN1_STRING**)a,pp,l,\ 742 B_ASN1_IA5STRING) 743 744 ASN1_UTCTIME* M_ASN1_UTCTIME_new()() { return cast(ASN1_UTCTIME*)ASN1_STRING_type_new(V_ASN1_UTCTIME); } 745 void M_ASN1_UTCTIME_free()(ASN1_UTCTIME* a) { ASN1_STRING_free(cast(ASN1_STRING*)a); } 746 ASN1_UTCTIME* M_ASN1_UTCTIME_dup()(ASN1_UTCTIME* a) { return cast(ASN1_UTCTIME*)ASN1_STRING_dup(cast(ASN1_STRING*)a); } 747 748 ASN1_GENERALIZEDTIME* M_ASN1_GENERALIZEDTIME_new()() { return cast(ASN1_GENERALIZEDTIME*)ASN1_STRING_type_new(V_ASN1_GENERALIZEDTIME); } 749 void M_ASN1_GENERALIZEDTIME_free()(ASN1_GENERALIZEDTIME* a) { ASN1_STRING_free(cast(ASN1_STRING*)a); } 750 ASN1_GENERALIZEDTIME* M_ASN1_GENERALIZEDTIME_dup()(ASN1_GENERALIZEDTIME* a) { return cast(ASN1_GENERALIZEDTIME*)ASN1_STRING_dup(cast(ASN1_STRING*)a); } 751 752 ASN1_TIME* M_ASN1_TIME_new()() { return cast(ASN1_TIME*)ASN1_STRING_type_new(V_ASN1_UTCTIME); } 753 void M_ASN1_TIME_free()(ASN1_TIME* a) { ASN1_STRING_free(cast(ASN1_STRING*)a); } 754 ASN1_TIME* M_ASN1_TIME_dup()(ASN1_TIME* a) { return cast(ASN1_TIME*)ASN1_STRING_dup(cast(ASN1_STRING*)a); } 755 756 ASN1_GENERALSTRING* M_ASN1_GENERALSTRING_new()() { return cast(ASN1_GENERALSTRING*)ASN1_STRING_type_new(V_ASN1_GENERALSTRING); } 757 void M_ASN1_GENERALSTRING_free()(ASN1_GENERALSTRING* a) { ASN1_STRING_free(cast(ASN1_STRING*)a); } 758 #define M_i2d_ASN1_GENERALSTRING(a,pp) \ 759 i2d_ASN1_bytes((ASN1_STRING*)a,pp,V_ASN1_GENERALSTRING,\ 760 V_ASN1_UNIVERSAL) 761 #define M_d2i_ASN1_GENERALSTRING(a,pp,l) \ 762 (ASN1_GENERALSTRING*)d2i_ASN1_type_bytes\ 763 ((ASN1_STRING**)a,pp,l,B_ASN1_GENERALSTRING) 764 765 ASN1_UNIVERSALSTRING* M_ASN1_UNIVERSALSTRING_new()() { return cast(ASN1_UNIVERSALSTRING*)ASN1_STRING_type_new(V_ASN1_UNIVERSALSTRING); } 766 void M_ASN1_UNIVERSALSTRING_free()(ASN1_UNIVERSALSTRING* a) { ASN1_STRING_free(cast(ASN1_STRING*)a); } 767 #define M_i2d_ASN1_UNIVERSALSTRING(a,pp) \ 768 i2d_ASN1_bytes((ASN1_STRING*)a,pp,V_ASN1_UNIVERSALSTRING,\ 769 V_ASN1_UNIVERSAL) 770 #define M_d2i_ASN1_UNIVERSALSTRING(a,pp,l) \ 771 (ASN1_UNIVERSALSTRING*)d2i_ASN1_type_bytes\ 772 ((ASN1_STRING**)a,pp,l,B_ASN1_UNIVERSALSTRING) 773 774 ASN1_BMPSTRING* M_ASN1_BMPSTRING_new()() { return cast(ASN1_BMPSTRING*)ASN1_STRING_type_new(V_ASN1_BMPSTRING); } 775 void M_ASN1_BMPSTRING_free()(ASN1_BMPSTRING* a) { ASN1_STRING_free(cast(ASN1_STRING*)a); } 776 #define M_i2d_ASN1_BMPSTRING(a,pp) \ 777 i2d_ASN1_bytes((ASN1_STRING*)a,pp,V_ASN1_BMPSTRING,\ 778 V_ASN1_UNIVERSAL) 779 #define M_d2i_ASN1_BMPSTRING(a,pp,l) \ 780 (ASN1_BMPSTRING*)d2i_ASN1_type_bytes\ 781 ((ASN1_STRING**)a,pp,l,B_ASN1_BMPSTRING) 782 783 ASN1_VISIBLESTRING* M_ASN1_VISIBLESTRING_new()() { return cast(ASN1_VISIBLESTRING*)ASN1_STRING_type_new(V_ASN1_VISIBLESTRING); } 784 void M_ASN1_VISIBLESTRING_free()(ASN1_VISIBLESTRING* a) { ASN1_STRING_free(cast(ASN1_STRING*)a); } 785 #define M_i2d_ASN1_VISIBLESTRING(a,pp) \ 786 i2d_ASN1_bytes((ASN1_STRING*)a,pp,V_ASN1_VISIBLESTRING,\ 787 V_ASN1_UNIVERSAL) 788 #define M_d2i_ASN1_VISIBLESTRING(a,pp,l) \ 789 (ASN1_VISIBLESTRING*)d2i_ASN1_type_bytes\ 790 ((ASN1_STRING**)a,pp,l,B_ASN1_VISIBLESTRING) 791 792 ASN1_UTF8STRING* M_ASN1_UTF8STRING_new()() { return cast(ASN1_UTF8STRING*)ASN1_STRING_type_new(V_ASN1_UTF8STRING); } 793 void M_ASN1_UTF8STRING_free()(ASN1_UTF8STRING* a) { ASN1_STRING_free(cast(ASN1_STRING*)a); } 794 #define M_i2d_ASN1_UTF8STRING(a,pp) \ 795 i2d_ASN1_bytes((ASN1_STRING*)a,pp,V_ASN1_UTF8STRING,\ 796 V_ASN1_UNIVERSAL) 797 #define M_d2i_ASN1_UTF8STRING(a,pp,l) \ 798 (ASN1_UTF8STRING*)d2i_ASN1_type_bytes\ 799 ((ASN1_STRING**)a,pp,l,B_ASN1_UTF8STRING) 800 +/ 801 /* for the is_set parameter to i2d_ASN1_SET */ 802 enum IS_SEQUENCE = 0; 803 enum IS_SET = 1; 804 805 mixin(DECLARE_ASN1_FUNCTIONS_fname!("ASN1_TYPE", "ASN1_ANY", "ASN1_TYPE")); 806 807 int ASN1_TYPE_get(ASN1_TYPE* a); 808 void ASN1_TYPE_set(ASN1_TYPE* a, int type, void* value); 809 int ASN1_TYPE_set1(ASN1_TYPE* a, int type, const(void)* value); 810 int ASN1_TYPE_cmp(ASN1_TYPE* a, ASN1_TYPE* b); 811 812 ASN1_OBJECT* ASN1_OBJECT_new(); 813 void ASN1_OBJECT_free(ASN1_OBJECT* a); 814 int i2d_ASN1_OBJECT(ASN1_OBJECT* a,ubyte** pp); 815 ASN1_OBJECT* c2i_ASN1_OBJECT(ASN1_OBJECT** a,const(ubyte)** pp, 816 c_long length); 817 ASN1_OBJECT* d2i_ASN1_OBJECT(ASN1_OBJECT** a,const(ubyte)** pp, 818 c_long length); 819 820 mixin(DECLARE_ASN1_ITEM!"ASN1_OBJECT"); 821 822 /+mixin DECLARE_STACK_OF!(ASN1_OBJECT);+/ 823 struct stack_st_ASN1_OBJECT; // define type to make it compile, needed until this module and safestack.d is converted and supports "DEFINE_STACK_OF" 824 825 mixin DECLARE_ASN1_SET_OF!(ASN1_OBJECT); 826 827 ASN1_STRING* ASN1_STRING_new(); 828 void ASN1_STRING_free(ASN1_STRING* a); 829 int ASN1_STRING_copy(ASN1_STRING* dst, const(ASN1_STRING)* str); 830 ASN1_STRING* ASN1_STRING_dup(const(ASN1_STRING)* a); 831 ASN1_STRING* ASN1_STRING_type_new(int type ); 832 int ASN1_STRING_cmp(const(ASN1_STRING)* a, const(ASN1_STRING)* b); 833 /* Since this is used to store all sorts of things, via macros, for now, make 834 its data void* */ 835 int ASN1_STRING_set(ASN1_STRING* str, const(void)* data, int len); 836 void ASN1_STRING_set0(ASN1_STRING* str, void* data, int len); 837 int ASN1_STRING_length(const(ASN1_STRING)* x); 838 void ASN1_STRING_length_set(ASN1_STRING* x, int n); 839 int ASN1_STRING_type(ASN1_STRING* x); 840 ubyte* ASN1_STRING_data(ASN1_STRING* x); 841 842 mixin(DECLARE_ASN1_FUNCTIONS!"ASN1_BIT_STRING"); 843 int i2c_ASN1_BIT_STRING(ASN1_BIT_STRING* a,ubyte** pp); 844 ASN1_BIT_STRING* c2i_ASN1_BIT_STRING(ASN1_BIT_STRING** a,const(ubyte)** pp, 845 c_long length); 846 int ASN1_BIT_STRING_set(ASN1_BIT_STRING* a, ubyte* d, 847 int length ); 848 int ASN1_BIT_STRING_set_bit(ASN1_BIT_STRING* a, int n, int value); 849 int ASN1_BIT_STRING_get_bit(ASN1_BIT_STRING* a, int n); 850 int ASN1_BIT_STRING_check(ASN1_BIT_STRING* a, 851 ubyte* flags, int flags_len); 852 853 version(OPENSSL_NO_BIO) {} else { 854 int ASN1_BIT_STRING_name_print(BIO* out_, ASN1_BIT_STRING* bs, 855 BIT_STRING_BITNAME* tbl, int indent); 856 } 857 int ASN1_BIT_STRING_num_asc(char* name, BIT_STRING_BITNAME* tbl); 858 int ASN1_BIT_STRING_set_asc(ASN1_BIT_STRING* bs, char* name, int value, 859 BIT_STRING_BITNAME* tbl); 860 861 int i2d_ASN1_BOOLEAN(int a,ubyte** pp); 862 int d2i_ASN1_BOOLEAN(int* a,const(ubyte)** pp,c_long length); 863 864 mixin(DECLARE_ASN1_FUNCTIONS!"ASN1_INTEGER"); 865 int i2c_ASN1_INTEGER(ASN1_INTEGER* a,ubyte** pp); 866 ASN1_INTEGER* c2i_ASN1_INTEGER(ASN1_INTEGER** a,const(ubyte)** pp, 867 c_long length); 868 ASN1_INTEGER* d2i_ASN1_UINTEGER(ASN1_INTEGER** a,const(ubyte)** pp, 869 c_long length); 870 ASN1_INTEGER* ASN1_INTEGER_dup(const(ASN1_INTEGER)* x); 871 int ASN1_INTEGER_cmp(const(ASN1_INTEGER)* x, const(ASN1_INTEGER)* y); 872 873 mixin(DECLARE_ASN1_FUNCTIONS!"ASN1_ENUMERATED"); 874 875 int ASN1_UTCTIME_check(ASN1_UTCTIME* a); 876 ASN1_UTCTIME* ASN1_UTCTIME_set(ASN1_UTCTIME* s,time_t t); 877 ASN1_UTCTIME* ASN1_UTCTIME_adj(ASN1_UTCTIME* s, time_t t, 878 int offset_day, c_long offset_sec); 879 int ASN1_UTCTIME_set_string(ASN1_UTCTIME* s, const(char)* str); 880 int ASN1_UTCTIME_cmp_time_t(const(ASN1_UTCTIME)* s, time_t t); 881 version (none) { 882 time_t ASN1_UTCTIME_get(const(ASN1_UTCTIME)* s); 883 } 884 885 int ASN1_GENERALIZEDTIME_check(ASN1_GENERALIZEDTIME* a); 886 ASN1_GENERALIZEDTIME* ASN1_GENERALIZEDTIME_set(ASN1_GENERALIZEDTIME* s,time_t t); 887 ASN1_GENERALIZEDTIME* ASN1_GENERALIZEDTIME_adj(ASN1_GENERALIZEDTIME* s, 888 time_t t, int offset_day, c_long offset_sec); 889 int ASN1_GENERALIZEDTIME_set_string(ASN1_GENERALIZEDTIME* s, const(char)* str); 890 891 mixin(DECLARE_ASN1_FUNCTIONS!"ASN1_OCTET_STRING"); 892 ASN1_OCTET_STRING* ASN1_OCTET_STRING_dup(const(ASN1_OCTET_STRING)* a); 893 int ASN1_OCTET_STRING_cmp(const(ASN1_OCTET_STRING)* a, const(ASN1_OCTET_STRING)* b); 894 int ASN1_OCTET_STRING_set(ASN1_OCTET_STRING* str, const(ubyte)* data, int len); 895 896 mixin(DECLARE_ASN1_FUNCTIONS!"ASN1_VISIBLESTRING"); 897 mixin(DECLARE_ASN1_FUNCTIONS!"ASN1_UNIVERSALSTRING"); 898 mixin(DECLARE_ASN1_FUNCTIONS!"ASN1_UTF8STRING"); 899 mixin(DECLARE_ASN1_FUNCTIONS!"ASN1_NULL"); 900 mixin(DECLARE_ASN1_FUNCTIONS!"ASN1_BMPSTRING"); 901 902 int UTF8_getc(const(char)* str, int len, c_ulong* val); 903 int UTF8_putc(char* str, int len, c_ulong value); 904 905 mixin(DECLARE_ASN1_FUNCTIONS_name!("ASN1_STRING", "ASN1_PRINTABLE")); 906 907 mixin(DECLARE_ASN1_FUNCTIONS_name!("ASN1_STRING", "DIRECTORYSTRING")); 908 mixin(DECLARE_ASN1_FUNCTIONS_name!("ASN1_STRING", "DISPLAYTEXT")); 909 mixin(DECLARE_ASN1_FUNCTIONS!"ASN1_PRINTABLESTRING"); 910 mixin(DECLARE_ASN1_FUNCTIONS!"ASN1_T61STRING"); 911 mixin(DECLARE_ASN1_FUNCTIONS!"ASN1_IA5STRING"); 912 mixin(DECLARE_ASN1_FUNCTIONS!"ASN1_GENERALSTRING"); 913 mixin(DECLARE_ASN1_FUNCTIONS!"ASN1_UTCTIME"); 914 mixin(DECLARE_ASN1_FUNCTIONS!"ASN1_GENERALIZEDTIME"); 915 mixin(DECLARE_ASN1_FUNCTIONS!"ASN1_TIME"); 916 917 mixin(DECLARE_ASN1_ITEM!"ASN1_OCTET_STRING_NDEF"); 918 919 ASN1_TIME* ASN1_TIME_set(ASN1_TIME* s,time_t t); 920 ASN1_TIME* ASN1_TIME_adj(ASN1_TIME* s,time_t t, 921 int offset_day, c_long offset_sec); 922 int ASN1_TIME_check(ASN1_TIME* t); 923 ASN1_GENERALIZEDTIME* ASN1_TIME_to_generalizedtime(ASN1_TIME* t, ASN1_GENERALIZEDTIME** out_); 924 int ASN1_TIME_set_string(ASN1_TIME* s, const(char)* str); 925 926 int i2d_ASN1_SET(STACK_OF!(OPENSSL_BLOCK) *a, ubyte** pp, 927 i2d_of_void* i2d, int ex_tag, int ex_class, 928 int is_set); 929 STACK_OF!(OPENSSL_BLOCK) *d2i_ASN1_SET(STACK_OF!(OPENSSL_BLOCK) **a, 930 const(ubyte)** pp, 931 c_long length, d2i_of_void* d2i, 932 ExternC!(void function(OPENSSL_BLOCK)) free_func, int ex_tag, 933 int ex_class); 934 935 version(OPENSSL_NO_BIO) {} else { 936 int i2a_ASN1_INTEGER(BIO* bp, ASN1_INTEGER* a); 937 int a2i_ASN1_INTEGER(BIO* bp,ASN1_INTEGER* bs,char* buf,int size); 938 int i2a_ASN1_ENUMERATED(BIO* bp, ASN1_ENUMERATED* a); 939 int a2i_ASN1_ENUMERATED(BIO* bp,ASN1_ENUMERATED* bs,char* buf,int size); 940 int i2a_ASN1_OBJECT(BIO* bp,ASN1_OBJECT* a); 941 int a2i_ASN1_STRING(BIO* bp,ASN1_STRING* bs,char* buf,int size); 942 int i2a_ASN1_STRING(BIO* bp, ASN1_STRING* a, int type); 943 } 944 int i2t_ASN1_OBJECT(char* buf,int buf_len,ASN1_OBJECT* a); 945 946 int a2d_ASN1_OBJECT(ubyte* out_,int olen, const(char)* buf, int num); 947 ASN1_OBJECT* ASN1_OBJECT_create(int nid, ubyte* data,int len, 948 const(char)* sn, const(char)* ln); 949 950 int ASN1_INTEGER_set(ASN1_INTEGER* a, c_long v); 951 c_long ASN1_INTEGER_get(const(ASN1_INTEGER)* a); 952 ASN1_INTEGER* BN_to_ASN1_INTEGER(const(BIGNUM)* bn, ASN1_INTEGER* ai); 953 BIGNUM* ASN1_INTEGER_to_BN(const(ASN1_INTEGER)* ai,BIGNUM* bn); 954 955 int ASN1_ENUMERATED_set(ASN1_ENUMERATED* a, c_long v); 956 c_long ASN1_ENUMERATED_get(ASN1_ENUMERATED* a); 957 ASN1_ENUMERATED* BN_to_ASN1_ENUMERATED(BIGNUM* bn, ASN1_ENUMERATED* ai); 958 BIGNUM* ASN1_ENUMERATED_to_BN(ASN1_ENUMERATED* ai,BIGNUM* bn); 959 960 /* General */ 961 /* given a string, return the correct type, max is the maximum length */ 962 int ASN1_PRINTABLE_type(const(ubyte)* s, int max); 963 964 int i2d_ASN1_bytes(ASN1_STRING* a, ubyte** pp, int tag, int xclass); 965 ASN1_STRING* d2i_ASN1_bytes(ASN1_STRING** a, const(ubyte)** pp, 966 c_long length, int Ptag, int Pclass); 967 c_ulong ASN1_tag2bit(int tag); 968 /* type is one or more of the B_ASN1_ values. */ 969 ASN1_STRING* d2i_ASN1_type_bytes(ASN1_STRING** a,const(ubyte)** pp, 970 c_long length,int type); 971 972 /* PARSING */ 973 int asn1_Finish(ASN1_CTX* c); 974 int asn1_const_Finish(ASN1_const_CTX* c); 975 976 /* SPECIALS */ 977 int ASN1_get_object(const(ubyte)** pp, c_long* plength, int* ptag, 978 int* pclass, c_long omax); 979 int ASN1_check_infinite_end(ubyte** p,c_long len); 980 int ASN1_const_check_infinite_end(const(ubyte)** p,c_long len); 981 void ASN1_put_object(ubyte** pp, int constructed, int length, 982 int tag, int xclass); 983 int ASN1_put_eoc(ubyte** pp); 984 int ASN1_object_size(int constructed, int length, int tag); 985 986 /* Used to implement other functions */ 987 void* ASN1_dup(i2d_of_void* i2d, d2i_of_void* d2i, void* x); 988 989 auto ASN1_dup_of(type)(I2D_OF!type* i2d, D2I_OF!type* d2i, type* x) { 990 return cast(type*)(ASN1_dup(CHECKED_I2D_OF!type(i2d), 991 CHECKED_D2I_OF!type(d2i), 992 CHECKED_PTR_OF!type(x))); 993 } 994 995 auto ASN1_dup_of_const(type)(I2D_OF!(const(type))* i2d, D2I_OF!type* d2i, const(type)* x) { 996 return cast(type*)(ASN1_dup(CHECKED_I2D_OF!(const(type))(i2d), 997 CHECKED_D2I_OF!type(d2i), 998 CHECKED_PTR_OF!(const(type))(x))); 999 } 1000 1001 void* ASN1_item_dup(const(ASN1_ITEM)* it, void* x); 1002 1003 /* ASN1 alloc/free macros for when a type is only used internally */ 1004 1005 template M_ASN1_new_of(string type) { 1006 enum M_ASN1_new_of = "(cast(" ~ type ~ "*)ASN1_item_new(ASN1_ITEM_rptr!`" ~ type ~ "`))"; 1007 } 1008 template M_ASN1_free_of(string x, string type) { 1009 enum M_ASN1_free_of = "ASN1_item_free(CHECKED_PTR_OF!(" ~ type ~ ")(" ~ x ~ "), ASN1_ITEM_rptr!`" ~ type ~ "`))"; 1010 } 1011 1012 version (OPENSSL_NO_FP_API) {} else { 1013 void* ASN1_d2i_fp(ExternC!(void* function()) xnew, d2i_of_void* d2i, FILE* in_, void** x); 1014 1015 type* ASN1_d2i_fp_of(type)(ExternC!(type* function()) xnew, d2i,in_,x) { 1016 return cast(type*)(ASN1_d2i_fp(CHECKED_NEW_OF!type(xnew), 1017 CHECKED_D2I_OF!type(d2i), 1018 in_, 1019 CHECKED_PPTR_OF!type(x))); 1020 } 1021 1022 void* ASN1_item_d2i_fp(const(ASN1_ITEM)* it, FILE* in_, void* x); 1023 int ASN1_i2d_fp(i2d_of_void* i2d,FILE* out_,void* x); 1024 1025 auto ASN1_i2d_fp_of(type)(I2D_OF!(type) i2d, FILE* out_, const(type)* x) { 1026 return ASN1_i2d_fp(CHECKED_I2D_OF!(type)(i2d), out_, CHECKED_PTR_OF!(type)(x)); 1027 } 1028 1029 auto ASN1_i2d_fp_of_const(type)(I2D_OF!(const(type)) i2d, FILE* out_, const(type)* x) { 1030 return ASN1_i2d_fp(CHECKED_I2D_OF!(const(type))(i2d), out_, CHECKED_PTR_OF!(const(type))(x)); 1031 } 1032 1033 int ASN1_item_i2d_fp(const(ASN1_ITEM)* it, FILE* out_, void* x); 1034 int ASN1_STRING_print_ex_fp(FILE* fp, ASN1_STRING* str, c_ulong flags); 1035 } 1036 1037 int ASN1_STRING_to_UTF8(char** out_, ASN1_STRING* in_); 1038 1039 version(OPENSSL_NO_BIO) {} else { 1040 void* ASN1_d2i_bio(ExternC!(void* function()) xnew, d2i_of_void* d2i, BIO* in_, void** x); 1041 1042 type* ASN1_d2i_bio_of(type)(ExternC!(type* function()) xnew, D2I_OF!type d2i, BIO* in_, type** x) { 1043 return cast(type*)ASN1_d2i_bio(CHECKED_NEW_OF!type(xnew), 1044 CHECKED_D2I_OF!type(d2i), in_, CHECKED_PPTR_OF!type(x)); 1045 } 1046 1047 void* ASN1_item_d2i_bio(const(ASN1_ITEM)* it, BIO* in_, void* x); 1048 int ASN1_i2d_bio(i2d_of_void* i2d,BIO* out_, ubyte* x); 1049 1050 int ASN1_i2d_bio_of(type)(I2D_OF!type* i2d,BIO* out_,type* x) { 1051 return ASN1_i2d_bio(CHECKED_I2D_OF!type(i2d), out_, CHECKED_PTR_OF!type(x)); 1052 } 1053 1054 int ASN1_i2d_bio_of_const(type)(I2D_OF!(const(type))* i2d,BIO* out_,type* x) { 1055 return ASN1_i2d_bio(CHECKED_I2D_OF!type(i2d), out_, CHECKED_PTR_OF!(const(type))(x)); 1056 } 1057 1058 int ASN1_item_i2d_bio(const(ASN1_ITEM)* it, BIO* out_, void* x); 1059 int ASN1_UTCTIME_print(BIO* fp, const(ASN1_UTCTIME)* a); 1060 int ASN1_GENERALIZEDTIME_print(BIO* fp, const(ASN1_GENERALIZEDTIME)* a); 1061 int ASN1_TIME_print(BIO* fp, const(ASN1_TIME)* a); 1062 int ASN1_STRING_print(BIO* bp, const(ASN1_STRING)* v); 1063 int ASN1_STRING_print_ex(BIO* out_, ASN1_STRING* str, c_ulong flags); 1064 int ASN1_bn_print(BIO* bp, const(char)* number, const(BIGNUM)* num, 1065 ubyte* buf, int off); 1066 int ASN1_parse(BIO* bp,const(ubyte)* pp,c_long len,int indent); 1067 int ASN1_parse_dump(BIO* bp,const(ubyte)* pp,c_long len,int indent,int dump); 1068 } 1069 const(char)* ASN1_tag2str(int tag); 1070 1071 /* Used to load and write netscape format cert */ 1072 1073 mixin(DECLARE_ASN1_FUNCTIONS!"NETSCAPE_X509"); 1074 1075 int ASN1_UNIVERSALSTRING_to_string(ASN1_UNIVERSALSTRING* s); 1076 1077 int ASN1_TYPE_set_octetstring(ASN1_TYPE* a, 1078 ubyte* data, int len); 1079 int ASN1_TYPE_get_octetstring(ASN1_TYPE* a, 1080 ubyte* data, int max_len); 1081 int ASN1_TYPE_set_int_octetstring(ASN1_TYPE* a, c_long num, 1082 ubyte* data, int len); 1083 int ASN1_TYPE_get_int_octetstring(ASN1_TYPE* a,c_long* num, 1084 ubyte* data, int max_len); 1085 1086 STACK_OF!(OPENSSL_BLOCK) *ASN1_seq_unpack(const(ubyte)* buf, int len, 1087 d2i_of_void* d2i, ExternC!(void function(OPENSSL_BLOCK)) free_func); 1088 ubyte* ASN1_seq_pack(STACK_OF!(OPENSSL_BLOCK) *safes, i2d_of_void* i2d, 1089 ubyte** buf, int* len ); 1090 void* ASN1_unpack_string(ASN1_STRING* oct, d2i_of_void* d2i); 1091 void* ASN1_item_unpack(ASN1_STRING* oct, const(ASN1_ITEM)* it); 1092 ASN1_STRING* ASN1_pack_string(void* obj, i2d_of_void* i2d, 1093 ASN1_OCTET_STRING** oct); 1094 1095 auto ASN1_pack_string_of(type)(type* obj, I2D_OF!type* i2d, ASN1_OCTET_STRING** oct) { 1096 return ASN1_pack_string(CHECKED_PTR_OF!type(obj), CHECKED_I2D_OF!type(i2d), oct); 1097 } 1098 1099 ASN1_STRING* ASN1_item_pack(void* obj, const(ASN1_ITEM)* it, ASN1_OCTET_STRING** oct); 1100 1101 void ASN1_STRING_set_default_mask(c_ulong mask); 1102 int ASN1_STRING_set_default_mask_asc(const(char)* p); 1103 c_ulong ASN1_STRING_get_default_mask(); 1104 int ASN1_mbstring_copy(ASN1_STRING** out_, const(ubyte)* in_, int len, 1105 int inform, c_ulong mask); 1106 int ASN1_mbstring_ncopy(ASN1_STRING** out_, const(ubyte)* in_, int len, 1107 int inform, c_ulong mask, 1108 c_long minsize, c_long maxsize); 1109 1110 ASN1_STRING* ASN1_STRING_set_by_NID(ASN1_STRING** out_, 1111 const(ubyte)* in_, int inlen, int inform, int nid); 1112 ASN1_STRING_TABLE* ASN1_STRING_TABLE_get(int nid); 1113 int ASN1_STRING_TABLE_add(int, c_long, c_long, c_ulong, c_ulong); 1114 void ASN1_STRING_TABLE_cleanup(); 1115 1116 /* ASN1 template functions */ 1117 1118 /* Old API compatible functions */ 1119 ASN1_VALUE* ASN1_item_new(const(ASN1_ITEM)* it); 1120 void ASN1_item_free(ASN1_VALUE* val, const(ASN1_ITEM)* it); 1121 ASN1_VALUE* ASN1_item_d2i(ASN1_VALUE** val, const(ubyte)** in_, c_long len, const(ASN1_ITEM)* it); 1122 int ASN1_item_i2d(ASN1_VALUE* val, ubyte** out_, const(ASN1_ITEM)* it); 1123 int ASN1_item_ndef_i2d(ASN1_VALUE* val, ubyte** out_, const(ASN1_ITEM)* it); 1124 1125 void ASN1_add_oid_module(); 1126 1127 ASN1_TYPE* ASN1_generate_nconf(char* str, CONF* nconf); 1128 ASN1_TYPE* ASN1_generate_v3(char* str, X509V3_CTX* cnf); 1129 1130 /* ASN1 Print flags */ 1131 1132 /* Indicate missing OPTIONAL fields */ 1133 enum ASN1_PCTX_FLAGS_SHOW_ABSENT = 0x001; 1134 /* Mark start and end of SEQUENCE */ 1135 enum ASN1_PCTX_FLAGS_SHOW_SEQUENCE = 0x002; 1136 /* Mark start and end of SEQUENCE/SET OF */ 1137 enum ASN1_PCTX_FLAGS_SHOW_SSOF = 0x004; 1138 /* Show the ASN1 type of primitives */ 1139 enum ASN1_PCTX_FLAGS_SHOW_TYPE = 0x008; 1140 /* Don't show ASN1 type of ANY */ 1141 enum ASN1_PCTX_FLAGS_NO_ANY_TYPE = 0x010; 1142 /* Don't show ASN1 type of MSTRINGs */ 1143 enum ASN1_PCTX_FLAGS_NO_MSTRING_TYPE = 0x020; 1144 /* Don't show field names in SEQUENCE */ 1145 enum ASN1_PCTX_FLAGS_NO_FIELD_NAME = 0x040; 1146 /* Show structure names of each SEQUENCE field */ 1147 enum ASN1_PCTX_FLAGS_SHOW_FIELD_STRUCT_NAME = 0x080; 1148 /* Don't show structure name even at top level */ 1149 enum ASN1_PCTX_FLAGS_NO_STRUCT_NAME = 0x100; 1150 1151 int ASN1_item_print(BIO* out_, ASN1_VALUE* ifld, int indent, 1152 const(ASN1_ITEM)* it, const(ASN1_PCTX)* pctx); 1153 ASN1_PCTX* ASN1_PCTX_new(); 1154 void ASN1_PCTX_free(ASN1_PCTX* p); 1155 c_ulong ASN1_PCTX_get_flags(ASN1_PCTX* p); 1156 void ASN1_PCTX_set_flags(ASN1_PCTX* p, c_ulong flags); 1157 c_ulong ASN1_PCTX_get_nm_flags(ASN1_PCTX* p); 1158 void ASN1_PCTX_set_nm_flags(ASN1_PCTX* p, c_ulong flags); 1159 c_ulong ASN1_PCTX_get_cert_flags(ASN1_PCTX* p); 1160 void ASN1_PCTX_set_cert_flags(ASN1_PCTX* p, c_ulong flags); 1161 c_ulong ASN1_PCTX_get_oid_flags(ASN1_PCTX* p); 1162 void ASN1_PCTX_set_oid_flags(ASN1_PCTX* p, c_ulong flags); 1163 c_ulong ASN1_PCTX_get_str_flags(ASN1_PCTX* p); 1164 void ASN1_PCTX_set_str_flags(ASN1_PCTX* p, c_ulong flags); 1165 1166 BIO_METHOD* BIO_f_asn1(); 1167 1168 BIO* BIO_new_NDEF(BIO* out_, ASN1_VALUE* val, const(ASN1_ITEM)* it); 1169 1170 int i2d_ASN1_bio_stream(BIO* out_, ASN1_VALUE* val, BIO* in_, int flags, 1171 const(ASN1_ITEM)* it); 1172 int PEM_write_bio_ASN1_stream(BIO* out_, ASN1_VALUE* val, BIO* in_, int flags, 1173 const(char)* hdr, 1174 const(ASN1_ITEM)* it); 1175 int SMIME_write_ASN1(BIO* bio, ASN1_VALUE* val, BIO* data, int flags, 1176 int ctype_nid, int econt_nid, 1177 STACK_OF!(X509_ALGOR) *mdalgs, 1178 const(ASN1_ITEM)* it); 1179 ASN1_VALUE* SMIME_read_ASN1(BIO* bio, BIO** bcont, const(ASN1_ITEM)* it); 1180 int SMIME_crlf_copy(BIO* in_, BIO* out_, int flags); 1181 int SMIME_text(BIO* in_, BIO* out_); 1182 1183 /* BEGIN ERROR CODES */ 1184 /* The following lines are auto generated by the script mkerr.pl. Any changes 1185 * made after this point may be overwritten when the script is next run. 1186 */ 1187 void ERR_load_ASN1_strings(); 1188 1189 /* Error codes for the ASN1 functions. */ 1190 1191 /* Function codes. */ 1192 enum ASN1_F_A2D_ASN1_OBJECT = 100; 1193 enum ASN1_F_A2I_ASN1_ENUMERATED = 101; 1194 enum ASN1_F_A2I_ASN1_INTEGER = 102; 1195 enum ASN1_F_A2I_ASN1_STRING = 103; 1196 enum ASN1_F_APPEND_EXP = 176; 1197 enum ASN1_F_ASN1_BIT_STRING_SET_BIT = 183; 1198 enum ASN1_F_ASN1_CB = 177; 1199 enum ASN1_F_ASN1_CHECK_TLEN = 104; 1200 enum ASN1_F_ASN1_COLLATE_PRIMITIVE = 105; 1201 enum ASN1_F_ASN1_COLLECT = 106; 1202 enum ASN1_F_ASN1_D2I_EX_PRIMITIVE = 108; 1203 enum ASN1_F_ASN1_D2I_FP = 109; 1204 enum ASN1_F_ASN1_D2I_READ_BIO = 107; 1205 enum ASN1_F_ASN1_DIGEST = 184; 1206 enum ASN1_F_ASN1_DO_ADB = 110; 1207 enum ASN1_F_ASN1_DUP = 111; 1208 enum ASN1_F_ASN1_ENUMERATED_SET = 112; 1209 enum ASN1_F_ASN1_ENUMERATED_TO_BN = 113; 1210 enum ASN1_F_ASN1_EX_C2I = 204; 1211 enum ASN1_F_ASN1_FIND_END = 190; 1212 enum ASN1_F_ASN1_GENERALIZEDTIME_ADJ = 216; 1213 enum ASN1_F_ASN1_GENERALIZEDTIME_SET = 185; 1214 enum ASN1_F_ASN1_GENERATE_V3 = 178; 1215 enum ASN1_F_ASN1_GET_OBJECT = 114; 1216 enum ASN1_F_ASN1_HEADER_NEW = 115; 1217 enum ASN1_F_ASN1_I2D_BIO = 116; 1218 enum ASN1_F_ASN1_I2D_FP = 117; 1219 enum ASN1_F_ASN1_INTEGER_SET = 118; 1220 enum ASN1_F_ASN1_INTEGER_TO_BN = 119; 1221 enum ASN1_F_ASN1_ITEM_D2I_FP = 206; 1222 enum ASN1_F_ASN1_ITEM_DUP = 191; 1223 enum ASN1_F_ASN1_ITEM_EX_COMBINE_NEW = 121; 1224 enum ASN1_F_ASN1_ITEM_EX_D2I = 120; 1225 enum ASN1_F_ASN1_ITEM_I2D_BIO = 192; 1226 enum ASN1_F_ASN1_ITEM_I2D_FP = 193; 1227 enum ASN1_F_ASN1_ITEM_PACK = 198; 1228 enum ASN1_F_ASN1_ITEM_SIGN = 195; 1229 enum ASN1_F_ASN1_ITEM_SIGN_CTX = 220; 1230 enum ASN1_F_ASN1_ITEM_UNPACK = 199; 1231 enum ASN1_F_ASN1_ITEM_VERIFY = 197; 1232 enum ASN1_F_ASN1_MBSTRING_NCOPY = 122; 1233 enum ASN1_F_ASN1_OBJECT_NEW = 123; 1234 enum ASN1_F_ASN1_OUTPUT_DATA = 214; 1235 enum ASN1_F_ASN1_PACK_STRING = 124; 1236 enum ASN1_F_ASN1_PCTX_NEW = 205; 1237 enum ASN1_F_ASN1_PKCS5_PBE_SET = 125; 1238 enum ASN1_F_ASN1_SEQ_PACK = 126; 1239 enum ASN1_F_ASN1_SEQ_UNPACK = 127; 1240 enum ASN1_F_ASN1_SIGN = 128; 1241 enum ASN1_F_ASN1_STR2TYPE = 179; 1242 enum ASN1_F_ASN1_STRING_SET = 186; 1243 enum ASN1_F_ASN1_STRING_TABLE_ADD = 129; 1244 enum ASN1_F_ASN1_STRING_TYPE_NEW = 130; 1245 enum ASN1_F_ASN1_TEMPLATE_EX_D2I = 132; 1246 enum ASN1_F_ASN1_TEMPLATE_NEW = 133; 1247 enum ASN1_F_ASN1_TEMPLATE_NOEXP_D2I = 131; 1248 enum ASN1_F_ASN1_TIME_ADJ = 217; 1249 enum ASN1_F_ASN1_TIME_SET = 175; 1250 enum ASN1_F_ASN1_TYPE_GET_INT_OCTETSTRING = 134; 1251 enum ASN1_F_ASN1_TYPE_GET_OCTETSTRING = 135; 1252 enum ASN1_F_ASN1_UNPACK_STRING = 136; 1253 enum ASN1_F_ASN1_UTCTIME_ADJ = 218; 1254 enum ASN1_F_ASN1_UTCTIME_SET = 187; 1255 enum ASN1_F_ASN1_VERIFY = 137; 1256 enum ASN1_F_B64_READ_ASN1 = 209; 1257 enum ASN1_F_B64_WRITE_ASN1 = 210; 1258 enum ASN1_F_BIO_NEW_NDEF = 208; 1259 enum ASN1_F_BITSTR_CB = 180; 1260 enum ASN1_F_BN_TO_ASN1_ENUMERATED = 138; 1261 enum ASN1_F_BN_TO_ASN1_INTEGER = 139; 1262 enum ASN1_F_C2I_ASN1_BIT_STRING = 189; 1263 enum ASN1_F_C2I_ASN1_INTEGER = 194; 1264 enum ASN1_F_C2I_ASN1_OBJECT = 196; 1265 enum ASN1_F_COLLECT_DATA = 140; 1266 enum ASN1_F_D2I_ASN1_BIT_STRING = 141; 1267 enum ASN1_F_D2I_ASN1_BOOLEAN = 142; 1268 enum ASN1_F_D2I_ASN1_BYTES = 143; 1269 enum ASN1_F_D2I_ASN1_GENERALIZEDTIME = 144; 1270 enum ASN1_F_D2I_ASN1_HEADER = 145; 1271 enum ASN1_F_D2I_ASN1_INTEGER = 146; 1272 enum ASN1_F_D2I_ASN1_OBJECT = 147; 1273 enum ASN1_F_D2I_ASN1_SET = 148; 1274 enum ASN1_F_D2I_ASN1_TYPE_BYTES = 149; 1275 enum ASN1_F_D2I_ASN1_UINTEGER = 150; 1276 enum ASN1_F_D2I_ASN1_UTCTIME = 151; 1277 enum ASN1_F_D2I_AUTOPRIVATEKEY = 207; 1278 enum ASN1_F_D2I_NETSCAPE_RSA = 152; 1279 enum ASN1_F_D2I_NETSCAPE_RSA_2 = 153; 1280 enum ASN1_F_D2I_PRIVATEKEY = 154; 1281 enum ASN1_F_D2I_PUBLICKEY = 155; 1282 enum ASN1_F_D2I_RSA_NET = 200; 1283 enum ASN1_F_D2I_RSA_NET_2 = 201; 1284 enum ASN1_F_D2I_X509 = 156; 1285 enum ASN1_F_D2I_X509_CINF = 157; 1286 enum ASN1_F_D2I_X509_PKEY = 159; 1287 enum ASN1_F_I2D_ASN1_BIO_STREAM = 211; 1288 enum ASN1_F_I2D_ASN1_SET = 188; 1289 enum ASN1_F_I2D_ASN1_TIME = 160; 1290 enum ASN1_F_I2D_DSA_PUBKEY = 161; 1291 enum ASN1_F_I2D_EC_PUBKEY = 181; 1292 enum ASN1_F_I2D_PRIVATEKEY = 163; 1293 enum ASN1_F_I2D_PUBLICKEY = 164; 1294 enum ASN1_F_I2D_RSA_NET = 162; 1295 enum ASN1_F_I2D_RSA_PUBKEY = 165; 1296 enum ASN1_F_LONG_C2I = 166; 1297 enum ASN1_F_OID_MODULE_INIT = 174; 1298 enum ASN1_F_PARSE_TAGGING = 182; 1299 enum ASN1_F_PKCS5_PBE2_SET_IV = 167; 1300 enum ASN1_F_PKCS5_PBE_SET = 202; 1301 enum ASN1_F_PKCS5_PBE_SET0_ALGOR = 215; 1302 enum ASN1_F_PKCS5_PBKDF2_SET = 219; 1303 enum ASN1_F_SMIME_READ_ASN1 = 212; 1304 enum ASN1_F_SMIME_TEXT = 213; 1305 enum ASN1_F_X509_CINF_NEW = 168; 1306 enum ASN1_F_X509_CRL_ADD0_REVOKED = 169; 1307 enum ASN1_F_X509_INFO_NEW = 170; 1308 enum ASN1_F_X509_NAME_ENCODE = 203; 1309 enum ASN1_F_X509_NAME_EX_D2I = 158; 1310 enum ASN1_F_X509_NAME_EX_NEW = 171; 1311 enum ASN1_F_X509_NEW = 172; 1312 enum ASN1_F_X509_PKEY_NEW = 173; 1313 1314 /* Reason codes. */ 1315 enum ASN1_R_ADDING_OBJECT = 171; 1316 enum ASN1_R_ASN1_PARSE_ERROR = 203; 1317 enum ASN1_R_ASN1_SIG_PARSE_ERROR = 204; 1318 enum ASN1_R_AUX_ERROR = 100; 1319 enum ASN1_R_BAD_CLASS = 101; 1320 enum ASN1_R_BAD_OBJECT_HEADER = 102; 1321 enum ASN1_R_BAD_PASSWORD_READ = 103; 1322 enum ASN1_R_BAD_TAG = 104; 1323 enum ASN1_R_BMPSTRING_IS_WRONG_LENGTH = 214; 1324 enum ASN1_R_BN_LIB = 105; 1325 enum ASN1_R_BOOLEAN_IS_WRONG_LENGTH = 106; 1326 enum ASN1_R_BUFFER_TOO_SMALL = 107; 1327 enum ASN1_R_CIPHER_HAS_NO_OBJECT_IDENTIFIER = 108; 1328 enum ASN1_R_CONTEXT_NOT_INITIALISED = 217; 1329 enum ASN1_R_DATA_IS_WRONG = 109; 1330 enum ASN1_R_DECODE_ERROR = 110; 1331 enum ASN1_R_DECODING_ERROR = 111; 1332 enum ASN1_R_DEPTH_EXCEEDED = 174; 1333 enum ASN1_R_DIGEST_AND_KEY_TYPE_NOT_SUPPORTED = 198; 1334 enum ASN1_R_ENCODE_ERROR = 112; 1335 enum ASN1_R_ERROR_GETTING_TIME = 173; 1336 enum ASN1_R_ERROR_LOADING_SECTION = 172; 1337 enum ASN1_R_ERROR_PARSING_SET_ELEMENT = 113; 1338 enum ASN1_R_ERROR_SETTING_CIPHER_PARAMS = 114; 1339 enum ASN1_R_EXPECTING_AN_INTEGER = 115; 1340 enum ASN1_R_EXPECTING_AN_OBJECT = 116; 1341 enum ASN1_R_EXPECTING_A_BOOLEAN = 117; 1342 enum ASN1_R_EXPECTING_A_TIME = 118; 1343 enum ASN1_R_EXPLICIT_LENGTH_MISMATCH = 119; 1344 enum ASN1_R_EXPLICIT_TAG_NOT_CONSTRUCTED = 120; 1345 enum ASN1_R_FIELD_MISSING = 121; 1346 enum ASN1_R_FIRST_NUM_TOO_LARGE = 122; 1347 enum ASN1_R_HEADER_TOO_LONG = 123; 1348 enum ASN1_R_ILLEGAL_BITSTRING_FORMAT = 175; 1349 enum ASN1_R_ILLEGAL_BOOLEAN = 176; 1350 enum ASN1_R_ILLEGAL_CHARACTERS = 124; 1351 enum ASN1_R_ILLEGAL_FORMAT = 177; 1352 enum ASN1_R_ILLEGAL_HEX = 178; 1353 enum ASN1_R_ILLEGAL_IMPLICIT_TAG = 179; 1354 enum ASN1_R_ILLEGAL_INTEGER = 180; 1355 enum ASN1_R_ILLEGAL_NESTED_TAGGING = 181; 1356 enum ASN1_R_ILLEGAL_NULL = 125; 1357 enum ASN1_R_ILLEGAL_NULL_VALUE = 182; 1358 enum ASN1_R_ILLEGAL_OBJECT = 183; 1359 enum ASN1_R_ILLEGAL_OPTIONAL_ANY = 126; 1360 enum ASN1_R_ILLEGAL_OPTIONS_ON_ITEM_TEMPLATE = 170; 1361 enum ASN1_R_ILLEGAL_TAGGED_ANY = 127; 1362 enum ASN1_R_ILLEGAL_TIME_VALUE = 184; 1363 enum ASN1_R_INTEGER_NOT_ASCII_FORMAT = 185; 1364 enum ASN1_R_INTEGER_TOO_LARGE_FOR_LONG = 128; 1365 enum ASN1_R_INVALID_BMPSTRING_LENGTH = 129; 1366 enum ASN1_R_INVALID_DIGIT = 130; 1367 enum ASN1_R_INVALID_MIME_TYPE = 205; 1368 enum ASN1_R_INVALID_MODIFIER = 186; 1369 enum ASN1_R_INVALID_NUMBER = 187; 1370 enum ASN1_R_INVALID_OBJECT_ENCODING = 216; 1371 enum ASN1_R_INVALID_SEPARATOR = 131; 1372 enum ASN1_R_INVALID_TIME_FORMAT = 132; 1373 enum ASN1_R_INVALID_UNIVERSALSTRING_LENGTH = 133; 1374 enum ASN1_R_INVALID_UTF8STRING = 134; 1375 enum ASN1_R_IV_TOO_LARGE = 135; 1376 enum ASN1_R_LENGTH_ERROR = 136; 1377 enum ASN1_R_LIST_ERROR = 188; 1378 enum ASN1_R_MIME_NO_CONTENT_TYPE = 206; 1379 enum ASN1_R_MIME_PARSE_ERROR = 207; 1380 enum ASN1_R_MIME_SIG_PARSE_ERROR = 208; 1381 enum ASN1_R_MISSING_EOC = 137; 1382 enum ASN1_R_MISSING_SECOND_NUMBER = 138; 1383 enum ASN1_R_MISSING_VALUE = 189; 1384 enum ASN1_R_MSTRING_NOT_UNIVERSAL = 139; 1385 enum ASN1_R_MSTRING_WRONG_TAG = 140; 1386 enum ASN1_R_NESTED_ASN1_STRING = 197; 1387 enum ASN1_R_NON_HEX_CHARACTERS = 141; 1388 enum ASN1_R_NOT_ASCII_FORMAT = 190; 1389 enum ASN1_R_NOT_ENOUGH_DATA = 142; 1390 enum ASN1_R_NO_CONTENT_TYPE = 209; 1391 enum ASN1_R_NO_DEFAULT_DIGEST = 201; 1392 enum ASN1_R_NO_MATCHING_CHOICE_TYPE = 143; 1393 enum ASN1_R_NO_MULTIPART_BODY_FAILURE = 210; 1394 enum ASN1_R_NO_MULTIPART_BOUNDARY = 211; 1395 enum ASN1_R_NO_SIG_CONTENT_TYPE = 212; 1396 enum ASN1_R_NULL_IS_WRONG_LENGTH = 144; 1397 enum ASN1_R_OBJECT_NOT_ASCII_FORMAT = 191; 1398 enum ASN1_R_ODD_NUMBER_OF_CHARS = 145; 1399 enum ASN1_R_PRIVATE_KEY_HEADER_MISSING = 146; 1400 enum ASN1_R_SECOND_NUMBER_TOO_LARGE = 147; 1401 enum ASN1_R_SEQUENCE_LENGTH_MISMATCH = 148; 1402 enum ASN1_R_SEQUENCE_NOT_CONSTRUCTED = 149; 1403 enum ASN1_R_SEQUENCE_OR_SET_NEEDS_CONFIG = 192; 1404 enum ASN1_R_SHORT_LINE = 150; 1405 enum ASN1_R_SIG_INVALID_MIME_TYPE = 213; 1406 enum ASN1_R_STREAMING_NOT_SUPPORTED = 202; 1407 enum ASN1_R_STRING_TOO_LONG = 151; 1408 enum ASN1_R_STRING_TOO_SHORT = 152; 1409 enum ASN1_R_TAG_VALUE_TOO_HIGH = 153; 1410 enum ASN1_R_THE_ASN1_OBJECT_IDENTIFIER_IS_NOT_KNOWN_FOR_THIS_MD = 154; 1411 enum ASN1_R_TIME_NOT_ASCII_FORMAT = 193; 1412 enum ASN1_R_TOO_LONG = 155; 1413 enum ASN1_R_TYPE_NOT_CONSTRUCTED = 156; 1414 enum ASN1_R_UNABLE_TO_DECODE_RSA_KEY = 157; 1415 enum ASN1_R_UNABLE_TO_DECODE_RSA_PRIVATE_KEY = 158; 1416 enum ASN1_R_UNEXPECTED_EOC = 159; 1417 enum ASN1_R_UNIVERSALSTRING_IS_WRONG_LENGTH = 215; 1418 enum ASN1_R_UNKNOWN_FORMAT = 160; 1419 enum ASN1_R_UNKNOWN_MESSAGE_DIGEST_ALGORITHM = 161; 1420 enum ASN1_R_UNKNOWN_OBJECT_TYPE = 162; 1421 enum ASN1_R_UNKNOWN_PUBLIC_KEY_TYPE = 163; 1422 enum ASN1_R_UNKNOWN_SIGNATURE_ALGORITHM = 199; 1423 enum ASN1_R_UNKNOWN_TAG = 194; 1424 enum ASN1_R_UNKOWN_FORMAT = 195; 1425 enum ASN1_R_UNSUPPORTED_ANY_DEFINED_BY_TYPE = 164; 1426 enum ASN1_R_UNSUPPORTED_CIPHER = 165; 1427 enum ASN1_R_UNSUPPORTED_ENCRYPTION_ALGORITHM = 166; 1428 enum ASN1_R_UNSUPPORTED_PUBLIC_KEY_TYPE = 167; 1429 enum ASN1_R_UNSUPPORTED_TYPE = 196; 1430 enum ASN1_R_WRONG_PUBLIC_KEY_TYPE = 200; 1431 enum ASN1_R_WRONG_TAG = 168; 1432 enum ASN1_R_WRONG_TYPE = 169;