1 /* $OpenBSD: asn1t.h,v 1.15 2019/08/20 13:10:09 inoguchi Exp $ */ 2 /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL 3 * project 2000. 4 */ 5 /* ==================================================================== 6 * Copyright (c) 2000-2005 The OpenSSL Project. All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without 9 * modification, are permitted provided that the following conditions 10 * are met: 11 * 12 * 1. Redistributions of source code must retain the above copyright 13 * notice, this list of conditions and the following disclaimer. 14 * 15 * 2. Redistributions in binary form must reproduce the above copyright 16 * notice, this list of conditions and the following disclaimer in 17 * the documentation and/or other materials provided with the 18 * distribution. 19 * 20 * 3. All advertising materials mentioning features or use of this 21 * software must display the following acknowledgment: 22 * "This product includes software developed by the OpenSSL Project 23 * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" 24 * 25 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to 26 * endorse or promote products derived from this software without 27 * prior written permission. For written permission, please contact 28 * licensing@OpenSSL.org. 29 * 30 * 5. Products derived from this software may not be called "OpenSSL" 31 * nor may "OpenSSL" appear in their names without prior written 32 * permission of the OpenSSL Project. 33 * 34 * 6. Redistributions of any form whatsoever must retain the following 35 * acknowledgment: 36 * "This product includes software developed by the OpenSSL Project 37 * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" 38 * 39 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY 40 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 41 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 42 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR 43 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 44 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 45 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 46 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 47 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 48 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 49 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 50 * OF THE POSSIBILITY OF SUCH DAMAGE. 51 * ==================================================================== 52 * 53 * This product includes cryptographic software written by Eric Young 54 * (eay@cryptsoft.com). This product includes software written by Tim 55 * Hudson (tjh@cryptsoft.com). 56 * 57 */ 58 module libressl_d.openssl.asn1t; 59 60 61 private static import core.stdc.config; 62 private static import libressl_d.openssl.stack; 63 private static import libressl_d.openssl.ossl_typ; 64 private static import libressl_d.openssl.bio; 65 public import libressl_d.openssl.opensslconf; 66 public import libressl_d.openssl.asn1; 67 public import core.stdc.stddef; 68 69 /* ASN1 template defines, structures and functions */ 70 71 extern (C): 72 nothrow @nogc: 73 74 version (LIBRESSL_INTERNAL) { 75 } else { 76 /* 77 * Macro to obtain ASN1_ADB pointer from a type (only used internally) 78 */ 79 //#define ASN1_ADB_ptr(iptr) ((const (.ASN1_ADB)*) (iptr)) 80 81 /* Macros for start and end of ASN1_ITEM definition */ 82 83 //#define ASN1_ITEM_start(itname) const libressl_d.openssl.ossl_typ.ASN1_ITEM itname##_it = { 84 //#define static_ASN1_ITEM_start(itname) static const libressl_d.openssl.ossl_typ.ASN1_ITEM itname##_it = { 85 //#define ASN1_ITEM_end(itname) } ; 86 87 /* Macros to aid ASN1 template writing */ 88 89 //#define ASN1_ITEM_TEMPLATE(tname) static const libressl_d.openssl.asn1.ASN1_TEMPLATE tname##_item_tt 90 91 //#define ASN1_ITEM_TEMPLATE_END(tname) ; .ASN1_ITEM_start(tname) .ASN1_ITYPE_PRIMITIVE, -1, &tname##_item_tt, 0, null, 0, #tname .ASN1_ITEM_end(tname) 92 93 //#define static_ASN1_ITEM_TEMPLATE_END(tname) ; .static_ASN1_ITEM_start(tname) .ASN1_ITYPE_PRIMITIVE, -1, &tname##_item_tt, 0, null, 0, #tname .ASN1_ITEM_end(tname) 94 95 /* This is a ASN1 type which just embeds a template */ 96 97 /* 98 * This pair helps declare a SEQUENCE. We can do: 99 * 100 * ASN1_SEQUENCE(stname) = { 101 * ... SEQUENCE components ... 102 * } ASN1_SEQUENCE_END(stname) 103 * 104 * This will produce an ASN1_ITEM called stname_it 105 * for a structure called stname. 106 * 107 * If you want the same structure but a different 108 * name then use: 109 * 110 * ASN1_SEQUENCE(itname) = { 111 * ... SEQUENCE components ... 112 * } ASN1_SEQUENCE_END_name(stname, itname) 113 * 114 * This will create an item called itname_it using 115 * a structure called stname. 116 */ 117 118 //#define ASN1_SEQUENCE(tname) static const libressl_d.openssl.asn1.ASN1_TEMPLATE tname##_seq_tt[] 119 120 //#define ASN1_SEQUENCE_END(stname) .ASN1_SEQUENCE_END_name(stname, stname) 121 122 //#define static_ASN1_SEQUENCE_END(stname) .static_ASN1_SEQUENCE_END_name(stname, stname) 123 124 //#define ASN1_SEQUENCE_END_name(stname, tname) ; .ASN1_ITEM_start(tname) .ASN1_ITYPE_SEQUENCE, libressl_d.openssl.asn1.V_ASN1_SEQUENCE, tname##_seq_tt, (tname##_seq_tt).sizeof / libressl_d.openssl.asn1.ASN1_TEMPLATE.sizeof, null, stname.sizeof, #stname .ASN1_ITEM_end(tname) 125 126 //#define static_ASN1_SEQUENCE_END_name(stname, tname) ; .static_ASN1_ITEM_start(tname) .ASN1_ITYPE_SEQUENCE, libressl_d.openssl.asn1.V_ASN1_SEQUENCE, tname##_seq_tt, (tname##_seq_tt).sizeof / libressl_d.openssl.asn1.ASN1_TEMPLATE.sizeof, null, stname.sizeof, #stname .ASN1_ITEM_end(tname) 127 128 //#define ASN1_NDEF_SEQUENCE(tname) .ASN1_SEQUENCE(tname) 129 130 //#define ASN1_NDEF_SEQUENCE_cb(tname, cb) .ASN1_SEQUENCE_cb(tname, cb) 131 132 //#define ASN1_SEQUENCE_cb(tname, cb) static const .ASN1_AUX tname##_aux = {null, 0, 0, 0, cb, 0}; .ASN1_SEQUENCE(tname) 133 134 //#define ASN1_BROKEN_SEQUENCE(tname) static const .ASN1_AUX tname##_aux = {null, .ASN1_AFLG_BROKEN, 0, 0, 0, 0}; .ASN1_SEQUENCE(tname) 135 136 //#define ASN1_SEQUENCE_ref(tname, cb, lck) static const .ASN1_AUX tname##_aux = {null, .ASN1_AFLG_REFCOUNT, offsetof(tname, references), lck, cb, 0}; .ASN1_SEQUENCE(tname) 137 138 //#define ASN1_SEQUENCE_enc(tname, enc, cb) static const .ASN1_AUX tname##_aux = {null, .ASN1_AFLG_ENCODING, 0, 0, cb, offsetof(tname, enc)}; .ASN1_SEQUENCE(tname) 139 140 //#define ASN1_NDEF_SEQUENCE_END(tname) ; .ASN1_ITEM_start(tname) .ASN1_ITYPE_NDEF_SEQUENCE, libressl_d.openssl.asn1.V_ASN1_SEQUENCE, tname##_seq_tt, (tname##_seq_tt).sizeof / libressl_d.openssl.asn1.ASN1_TEMPLATE.sizeof, null, tname.sizeof, #tname .ASN1_ITEM_end(tname) 141 142 //#define static_ASN1_NDEF_SEQUENCE_END(tname) ; .static_ASN1_ITEM_start(tname) .ASN1_ITYPE_NDEF_SEQUENCE, libressl_d.openssl.asn1.V_ASN1_SEQUENCE, tname##_seq_tt, (tname##_seq_tt).sizeof / libressl_d.openssl.asn1.ASN1_TEMPLATE.sizeof, null, tname.sizeof, #tname .ASN1_ITEM_end(tname) 143 144 //#define ASN1_BROKEN_SEQUENCE_END(stname) .ASN1_SEQUENCE_END_ref(stname, stname) 145 146 //#define ASN1_SEQUENCE_END_enc(stname, tname) .ASN1_SEQUENCE_END_ref(stname, tname) 147 148 //#define ASN1_SEQUENCE_END_cb(stname, tname) .ASN1_SEQUENCE_END_ref(stname, tname) 149 150 //#define static_ASN1_SEQUENCE_END_cb(stname, tname) .static_ASN1_SEQUENCE_END_ref(stname, tname) 151 152 //#define ASN1_SEQUENCE_END_ref(stname, tname) ; .ASN1_ITEM_start(tname) .ASN1_ITYPE_SEQUENCE, libressl_d.openssl.asn1.V_ASN1_SEQUENCE, tname##_seq_tt, (tname##_seq_tt).sizeof / libressl_d.openssl.asn1.ASN1_TEMPLATE.sizeof, &tname##_aux, stname.sizeof, #stname .ASN1_ITEM_end(tname) 153 154 //#define static_ASN1_SEQUENCE_END_ref(stname, tname) ; .static_ASN1_ITEM_start(tname) .ASN1_ITYPE_SEQUENCE, libressl_d.openssl.asn1.V_ASN1_SEQUENCE, tname##_seq_tt, (tname##_seq_tt).sizeof / libressl_d.openssl.asn1.ASN1_TEMPLATE.sizeof, &tname##_aux, stname.sizeof, #stname .ASN1_ITEM_end(tname) 155 156 //#define ASN1_NDEF_SEQUENCE_END_cb(stname, tname) ; .ASN1_ITEM_start(tname) .ASN1_ITYPE_NDEF_SEQUENCE, libressl_d.openssl.asn1.V_ASN1_SEQUENCE, tname##_seq_tt, (tname##_seq_tt).sizeof / libressl_d.openssl.asn1.ASN1_TEMPLATE.sizeof, &tname##_aux, stname.sizeof, #stname .ASN1_ITEM_end(tname) 157 158 /* 159 * This pair helps declare a CHOICE type. We can do: 160 * 161 * ASN1_CHOICE(chname) = { 162 * ... CHOICE options ... 163 * ASN1_CHOICE_END(chname) 164 * 165 * This will produce an ASN1_ITEM called chname_it 166 * for a structure called chname. The structure 167 * definition must look like this: 168 * typedef struct { 169 * int type; 170 * 171 * union value 172 * { 173 * ASN1_SOMETHING* pt1; 174 * ASN1_SOMEOTHER* pt2; 175 * } 176 * } chname; 177 * 178 * the name of the selector must be 'type'. 179 * to use an alternative selector name use the 180 * ASN1_CHOICE_END_selector() version. 181 */ 182 183 //#define ASN1_CHOICE(tname) static const libressl_d.openssl.asn1.ASN1_TEMPLATE tname##_ch_tt[] 184 185 //#define ASN1_CHOICE_cb(tname, cb) static const .ASN1_AUX tname##_aux = {null, 0, 0, 0, cb, 0}; .ASN1_CHOICE(tname) 186 187 //#define ASN1_CHOICE_END(stname) .ASN1_CHOICE_END_name(stname, stname) 188 189 //#define static_ASN1_CHOICE_END(stname) .static_ASN1_CHOICE_END_name(stname, stname) 190 191 //#define ASN1_CHOICE_END_name(stname, tname) .ASN1_CHOICE_END_selector(stname, tname, type) 192 193 //#define static_ASN1_CHOICE_END_name(stname, tname) .static_ASN1_CHOICE_END_selector(stname, tname, type) 194 195 //#define ASN1_CHOICE_END_selector(stname, tname, selname) ; .ASN1_ITEM_start(tname) .ASN1_ITYPE_CHOICE, offsetof(stname, selname), tname##_ch_tt, (tname##_ch_tt).sizeof / libressl_d.openssl.asn1.ASN1_TEMPLATE.sizeof, null, stname.sizeof, #stname .ASN1_ITEM_end(tname) 196 197 //#define static_ASN1_CHOICE_END_selector(stname, tname, selname) ; .static_ASN1_ITEM_start(tname) .ASN1_ITYPE_CHOICE, offsetof(stname, selname), tname##_ch_tt, (tname##_ch_tt).sizeof / libressl_d.openssl.asn1.ASN1_TEMPLATE.sizeof, null, stname.sizeof, #stname .ASN1_ITEM_end(tname) 198 199 //#define ASN1_CHOICE_END_cb(stname, tname, selname) ; .ASN1_ITEM_start(tname) .ASN1_ITYPE_CHOICE, offsetof(stname, selname), tname##_ch_tt, (tname##_ch_tt).sizeof / libressl_d.openssl.asn1.ASN1_TEMPLATE.sizeof, &tname##_aux, stname.sizeof, #stname .ASN1_ITEM_end(tname) 200 201 /* This helps with the template wrapper form of ASN1_ITEM */ 202 203 //#define ASN1_EX_TEMPLATE_TYPE(flags, tag, name, type) { (flags), (tag), 0, #name, libressl_d.openssl.asn1.ASN1_ITEM_ref(type) } 204 205 /* These help with SEQUENCE or CHOICE components */ 206 207 /* used to declare other types */ 208 209 //#define ASN1_EX_TYPE(flags, tag, stname, field, type) { (flags), (tag), offsetof(stname, field), #field, libressl_d.openssl.asn1.ASN1_ITEM_ref(type) } 210 211 /* used when the structure is combined with the parent */ 212 213 //#define ASN1_EX_COMBINE(flags, tag, type) { (flags) | .ASN1_TFLG_COMBINE, (tag), 0, null, libressl_d.openssl.asn1.ASN1_ITEM_ref(type) } 214 215 /* implicit and explicit helper macros */ 216 217 //#define ASN1_IMP_EX(stname, field, type, tag, ex) .ASN1_EX_TYPE(.ASN1_TFLG_IMPLICIT | ex, tag, stname, field, type) 218 219 //#define ASN1_EXP_EX(stname, field, type, tag, ex) .ASN1_EX_TYPE(.ASN1_TFLG_EXPLICIT | ex, tag, stname, field, type) 220 221 /* Any defined by macros: the field used is in the table itself */ 222 223 //#define ASN1_ADB_OBJECT(tblname) { .ASN1_TFLG_ADB_OID, -1, 0, #tblname, (const (libressl_d.openssl.ossl_typ.ASN1_ITEM)*) &(tblname##_adb) } 224 //#define ASN1_ADB_INTEGER(tblname) { .ASN1_TFLG_ADB_INT, -1, 0, #tblname, (const (libressl_d.openssl.ossl_typ.ASN1_ITEM)*) &(tblname##_adb) } 225 /* Plain simple type */ 226 //#define ASN1_SIMPLE(stname, field, type) .ASN1_EX_TYPE(0, 0, stname, field, type) 227 228 /* OPTIONAL simple type */ 229 //#define ASN1_OPT(stname, field, type) .ASN1_EX_TYPE(.ASN1_TFLG_OPTIONAL, 0, stname, field, type) 230 231 /* IMPLICIT tagged simple type */ 232 //#define ASN1_IMP(stname, field, type, tag) .ASN1_IMP_EX(stname, field, type, tag, 0) 233 234 /* IMPLICIT tagged OPTIONAL simple type */ 235 //#define ASN1_IMP_OPT(stname, field, type, tag) .ASN1_IMP_EX(stname, field, type, tag, .ASN1_TFLG_OPTIONAL) 236 237 /* Same as above but EXPLICIT */ 238 239 //#define ASN1_EXP(stname, field, type, tag) .ASN1_EXP_EX(stname, field, type, tag, 0) 240 //#define ASN1_EXP_OPT(stname, field, type, tag) .ASN1_EXP_EX(stname, field, type, tag, .ASN1_TFLG_OPTIONAL) 241 242 /* SEQUENCE OF type */ 243 //#define ASN1_SEQUENCE_OF(stname, field, type) .ASN1_EX_TYPE(.ASN1_TFLG_SEQUENCE_OF, 0, stname, field, type) 244 245 /* OPTIONAL SEQUENCE OF */ 246 //#define ASN1_SEQUENCE_OF_OPT(stname, field, type) .ASN1_EX_TYPE(.ASN1_TFLG_SEQUENCE_OF | .ASN1_TFLG_OPTIONAL, 0, stname, field, type) 247 248 /* Same as above but for SET OF */ 249 250 //#define ASN1_SET_OF(stname, field, type) .ASN1_EX_TYPE(.ASN1_TFLG_SET_OF, 0, stname, field, type) 251 252 //#define ASN1_SET_OF_OPT(stname, field, type) .ASN1_EX_TYPE(.ASN1_TFLG_SET_OF | .ASN1_TFLG_OPTIONAL, 0, stname, field, type) 253 254 /* Finally compound types of SEQUENCE, SET, IMPLICIT, EXPLICIT and OPTIONAL */ 255 256 //#define ASN1_IMP_SET_OF(stname, field, type, tag) .ASN1_IMP_EX(stname, field, type, tag, .ASN1_TFLG_SET_OF) 257 258 //#define ASN1_EXP_SET_OF(stname, field, type, tag) .ASN1_EXP_EX(stname, field, type, tag, .ASN1_TFLG_SET_OF) 259 260 //#define ASN1_IMP_SET_OF_OPT(stname, field, type, tag) .ASN1_IMP_EX(stname, field, type, tag, .ASN1_TFLG_SET_OF | .ASN1_TFLG_OPTIONAL) 261 262 //#define ASN1_EXP_SET_OF_OPT(stname, field, type, tag) .ASN1_EXP_EX(stname, field, type, tag, .ASN1_TFLG_SET_OF | .ASN1_TFLG_OPTIONAL) 263 264 //#define ASN1_IMP_SEQUENCE_OF(stname, field, type, tag) .ASN1_IMP_EX(stname, field, type, tag, .ASN1_TFLG_SEQUENCE_OF) 265 266 //#define ASN1_IMP_SEQUENCE_OF_OPT(stname, field, type, tag) .ASN1_IMP_EX(stname, field, type, tag, .ASN1_TFLG_SEQUENCE_OF | .ASN1_TFLG_OPTIONAL) 267 268 //#define ASN1_EXP_SEQUENCE_OF(stname, field, type, tag) .ASN1_EXP_EX(stname, field, type, tag, .ASN1_TFLG_SEQUENCE_OF) 269 270 //#define ASN1_EXP_SEQUENCE_OF_OPT(stname, field, type, tag) .ASN1_EXP_EX(stname, field, type, tag, .ASN1_TFLG_SEQUENCE_OF | .ASN1_TFLG_OPTIONAL) 271 272 /* EXPLICIT using indefinite length constructed form */ 273 //#define ASN1_NDEF_EXP(stname, field, type, tag) .ASN1_EXP_EX(stname, field, type, tag, .ASN1_TFLG_NDEF) 274 275 /* EXPLICIT OPTIONAL using indefinite length constructed form */ 276 //#define ASN1_NDEF_EXP_OPT(stname, field, type, tag) .ASN1_EXP_EX(stname, field, type, tag, .ASN1_TFLG_OPTIONAL | .ASN1_TFLG_NDEF) 277 278 /* Macros for the ASN1_ADB structure */ 279 280 //#define ASN1_ADB(name) static const .ASN1_ADB_TABLE name##_adbtbl[] 281 282 //#define ASN1_ADB_END(name, flags, field, app_table, def, none) ; static const .ASN1_ADB name##_adb = {flags, offsetof(name, field), app_table, name##_adbtbl, (name##_adbtbl).sizeof / .ASN1_ADB_TABLE.sizeof, def, none} 283 284 //#define ADB_ENTRY(val, template) { val, template } 285 286 //#define ASN1_ADB_TEMPLATE(name) static const libressl_d.openssl.asn1.ASN1_TEMPLATE name##_tt 287 } 288 289 /** 290 * This is the ASN1 template structure that defines 291 * a wrapper round the actual type. It determines the 292 * actual position of the field in the value structure, 293 * various flags such as OPTIONAL and the field name. 294 */ 295 struct ASN1_TEMPLATE_st 296 { 297 /** 298 * Various flags 299 */ 300 core.stdc.config.c_ulong flags; 301 302 /** 303 * tag, not used if no tagging 304 */ 305 core.stdc.config.c_long tag; 306 307 /** 308 * Offset of this field in structure 309 */ 310 core.stdc.config.c_ulong offset; 311 312 version (NO_ASN1_FIELD_NAMES) { 313 } else { 314 /** 315 * Field name 316 */ 317 const (char)* field_name; 318 } 319 320 /** 321 * Relevant ASN1_ITEM or ASN1_ADB 322 */ 323 libressl_d.openssl.asn1.ASN1_ITEM_EXP* item; 324 } 325 326 /* Macro to extract ASN1_ITEM and ASN1_ADB pointer from ASN1_TEMPLATE */ 327 328 //#define ASN1_TEMPLATE_item(t) (t.item_ptr) 329 //#define ASN1_TEMPLATE_adb(t) (t.item_ptr) 330 331 alias ASN1_ADB_TABLE = .ASN1_ADB_TABLE_st; 332 alias ASN1_ADB = .ASN1_ADB_st; 333 334 struct stack_st_ASN1_ADB_TABLE; 335 336 struct ASN1_ADB_st 337 { 338 /** 339 * Various flags 340 */ 341 core.stdc.config.c_ulong flags; 342 343 /** 344 * Offset of selector field 345 */ 346 core.stdc.config.c_ulong offset; 347 348 /** 349 * Application defined items 350 */ 351 .stack_st_ASN1_ADB_TABLE** app_items; 352 353 /** 354 * Table of possible types 355 */ 356 const (.ASN1_ADB_TABLE)* tbl; 357 358 /** 359 * Number of entries in tbl 360 */ 361 core.stdc.config.c_long tblcount; 362 363 /** 364 * Type to use if no match 365 */ 366 const (libressl_d.openssl.asn1.ASN1_TEMPLATE)* default_tt; 367 368 /** 369 * Type to use if selector is null 370 */ 371 const (libressl_d.openssl.asn1.ASN1_TEMPLATE)* null_tt; 372 } 373 374 struct ASN1_ADB_TABLE_st 375 { 376 /** 377 * NID for an object or value for an int 378 */ 379 core.stdc.config.c_long value; 380 381 /** 382 * item for this value 383 */ 384 const libressl_d.openssl.asn1.ASN1_TEMPLATE tt; 385 } 386 387 /* template flags */ 388 389 /** 390 * Field is optional 391 */ 392 enum ASN1_TFLG_OPTIONAL = 0x01; 393 394 /** 395 * Field is a SET OF 396 */ 397 enum ASN1_TFLG_SET_OF = 0x01 << 1; 398 399 /** 400 * Field is a SEQUENCE OF 401 */ 402 enum ASN1_TFLG_SEQUENCE_OF = 0x02 << 1; 403 404 /** 405 * Special case: this refers to a SET OF that 406 * will be sorted into DER order when encoded *and* 407 * the corresponding STACK will be modified to match 408 * the new order. 409 */ 410 enum ASN1_TFLG_SET_ORDER = 0x03 << 1; 411 412 /* Mask for SET OF or SEQUENCE OF */ 413 enum ASN1_TFLG_SK_MASK = 0x03 << 1; 414 415 /* 416 * These flags mean the tag should be taken from the 417 * tag field. If EXPLICIT then the underlying type 418 * is used for the inner tag. 419 */ 420 421 /** 422 * IMPLICIT tagging 423 */ 424 enum ASN1_TFLG_IMPTAG = 0x01 << 3; 425 426 /** 427 * EXPLICIT tagging, inner tag from underlying type 428 */ 429 enum ASN1_TFLG_EXPTAG = 0x02 << 3; 430 431 enum ASN1_TFLG_TAG_MASK = 0x03 << 3; 432 433 /** 434 * context specific IMPLICIT 435 */ 436 enum ASN1_TFLG_IMPLICIT = .ASN1_TFLG_IMPTAG | .ASN1_TFLG_CONTEXT; 437 438 /** 439 * context specific EXPLICIT 440 */ 441 enum ASN1_TFLG_EXPLICIT = .ASN1_TFLG_EXPTAG | .ASN1_TFLG_CONTEXT; 442 443 /* 444 * If tagging is in force these determine the 445 * type of tag to use. Otherwise the tag is 446 * determined by the underlying type. These 447 * values reflect the actual octet format. 448 */ 449 450 /** 451 * Universal tag 452 */ 453 enum ASN1_TFLG_UNIVERSAL = 0x00 << 6; 454 455 /** 456 * Application tag 457 */ 458 enum ASN1_TFLG_APPLICATION = 0x01 << 6; 459 460 /** 461 * Context specific tag 462 */ 463 enum ASN1_TFLG_CONTEXT = 0x02 << 6; 464 465 /** 466 * Private tag 467 */ 468 enum ASN1_TFLG_PRIVATE = 0x03 << 6; 469 470 enum ASN1_TFLG_TAG_CLASS = 0x03 << 6; 471 472 /* 473 * These are for ANY DEFINED BY type. In this case 474 * the 'item' field points to an ASN1_ADB structure 475 * which contains a table of values to decode the 476 * relevant type 477 */ 478 479 enum ASN1_TFLG_ADB_MASK = 0x03 << 8; 480 481 enum ASN1_TFLG_ADB_OID = 0x01 << 8; 482 483 enum ASN1_TFLG_ADB_INT = 0x01 << 9; 484 485 /** 486 * This flag means a parent structure is passed 487 * instead of the field: this is useful is a 488 * SEQUENCE is being combined with a CHOICE for 489 * example. Since this means the structure and 490 * item name will differ we need to use the 491 * ASN1_CHOICE_END_name() macro for example. 492 */ 493 enum ASN1_TFLG_COMBINE = 0x01 << 10; 494 495 /** 496 * This flag when present in a SEQUENCE OF, SET OF 497 * or EXPLICIT causes indefinite length constructed 498 * encoding to be used if required. 499 */ 500 enum ASN1_TFLG_NDEF = 0x01 << 11; 501 502 /** 503 * This is the actual ASN1 item itself 504 */ 505 struct ASN1_ITEM_st 506 { 507 /** 508 * The item type, primitive, SEQUENCE, CHOICE or extern 509 */ 510 char itype; 511 512 /** 513 * underlying type 514 */ 515 core.stdc.config.c_long utype; 516 517 /** 518 * If SEQUENCE or CHOICE this contains the contents 519 */ 520 const (libressl_d.openssl.asn1.ASN1_TEMPLATE)* templates; 521 522 /** 523 * Number of templates if SEQUENCE or CHOICE 524 */ 525 core.stdc.config.c_long tcount; 526 527 /** 528 * functions that handle this type 529 */ 530 const (void)* funcs; 531 532 /** 533 * Structure size (usually) 534 */ 535 core.stdc.config.c_long size; 536 537 version (NO_ASN1_FIELD_NAMES) { 538 } else { 539 /** 540 * Structure name 541 */ 542 const (char)* sname; 543 } 544 } 545 546 /* 547 * These are values for the itype field and 548 * determine how the type is interpreted. 549 * 550 * For PRIMITIVE types the underlying type 551 * determines the behaviour if items is null. 552 * 553 * Otherwise templates must contain a single 554 * template and the type is treated in the 555 * same way as the type specified in the template. 556 * 557 * For SEQUENCE types the templates field points 558 * to the members, the size field is the 559 * structure size. 560 * 561 * For CHOICE types the templates field points 562 * to each possible member (typically a union) 563 * and the 'size' field is the offset of the 564 * selector. 565 * 566 * The 'funcs' field is used for application 567 * specific functions. 568 * 569 * The EXTERN type uses a new style d2i/i2d. 570 * The new style should be used where possible 571 * because it avoids things like the d2i IMPLICIT 572 * hack. 573 * 574 * MSTRING is a multiple string type, it is used 575 * for a CHOICE of character strings where the 576 * actual strings all occupy an ASN1_STRING 577 * structure. In this case the 'utype' field 578 * has a special meaning, it is used as a mask 579 * of acceptable types using the B_ASN1 constants. 580 * 581 * NDEF_SEQUENCE is the same as SEQUENCE except 582 * that it will use indefinite length constructed 583 * encoding if requested. 584 * 585 */ 586 587 enum ASN1_ITYPE_PRIMITIVE = 0x00; 588 589 enum ASN1_ITYPE_SEQUENCE = 0x01; 590 591 enum ASN1_ITYPE_CHOICE = 0x02; 592 593 enum ASN1_ITYPE_EXTERN = 0x04; 594 595 enum ASN1_ITYPE_MSTRING = 0x05; 596 597 enum ASN1_ITYPE_NDEF_SEQUENCE = 0x06; 598 599 /** 600 * Cache for ASN1 tag and length, so we 601 * don't keep re-reading it for things 602 * like CHOICE 603 */ 604 struct ASN1_TLC_st 605 { 606 /** 607 * Values below are valid 608 */ 609 char valid; 610 611 /** 612 * return value 613 */ 614 int ret; 615 616 /** 617 * length 618 */ 619 core.stdc.config.c_long plen; 620 621 /** 622 * class value 623 */ 624 int ptag; 625 626 ///Ditto 627 int pclass; 628 629 /** 630 * header length 631 */ 632 int hdrlen; 633 } 634 635 /* Typedefs for ASN1 function pointers */ 636 637 alias ASN1_new_func = extern (C) nothrow @nogc libressl_d.openssl.asn1.ASN1_VALUE* function(); 638 alias ASN1_free_func = extern (C) nothrow @nogc void function(libressl_d.openssl.asn1.ASN1_VALUE* a); 639 alias ASN1_d2i_func = extern (C) nothrow @nogc libressl_d.openssl.asn1.ASN1_VALUE* function(libressl_d.openssl.asn1.ASN1_VALUE** a, const (ubyte)** in_, core.stdc.config.c_long length_); 640 alias ASN1_i2d_func = extern (C) nothrow @nogc int function(libressl_d.openssl.asn1.ASN1_VALUE* a, ubyte** in_); 641 642 alias ASN1_ex_d2i = extern (C) nothrow @nogc int function(libressl_d.openssl.asn1.ASN1_VALUE** pval, const (ubyte)** in_, core.stdc.config.c_long len, const (libressl_d.openssl.ossl_typ.ASN1_ITEM)* it, int tag, int aclass, char opt, libressl_d.openssl.asn1.ASN1_TLC* ctx); 643 644 alias ASN1_ex_i2d = extern (C) nothrow @nogc int function(libressl_d.openssl.asn1.ASN1_VALUE** pval, ubyte** out_, const (libressl_d.openssl.ossl_typ.ASN1_ITEM)* it, int tag, int aclass); 645 alias ASN1_ex_new_func = extern (C) nothrow @nogc int function(libressl_d.openssl.asn1.ASN1_VALUE** pval, const (libressl_d.openssl.ossl_typ.ASN1_ITEM)* it); 646 alias ASN1_ex_free_func = extern (C) nothrow @nogc void function(libressl_d.openssl.asn1.ASN1_VALUE** pval, const (libressl_d.openssl.ossl_typ.ASN1_ITEM)* it); 647 648 alias ASN1_ex_print_func = extern (C) nothrow @nogc int function(libressl_d.openssl.bio.BIO* out_, libressl_d.openssl.asn1.ASN1_VALUE** pval, int indent, const (char)* fname, const (libressl_d.openssl.ossl_typ.ASN1_PCTX)* pctx); 649 650 alias ASN1_primitive_i2c = extern (C) nothrow @nogc int function(libressl_d.openssl.asn1.ASN1_VALUE** pval, ubyte* cont, int* putype, const (libressl_d.openssl.ossl_typ.ASN1_ITEM)* it); 651 alias ASN1_primitive_c2i = extern (C) nothrow @nogc int function(libressl_d.openssl.asn1.ASN1_VALUE** pval, const (ubyte)* cont, int len, int utype, char* free_cont, const (libressl_d.openssl.ossl_typ.ASN1_ITEM)* it); 652 alias ASN1_primitive_print = extern (C) nothrow @nogc int function(libressl_d.openssl.bio.BIO* out_, libressl_d.openssl.asn1.ASN1_VALUE** pval, const (libressl_d.openssl.ossl_typ.ASN1_ITEM)* it, int indent, const (libressl_d.openssl.ossl_typ.ASN1_PCTX)* pctx); 653 654 struct ASN1_EXTERN_FUNCS_st 655 { 656 void* app_data; 657 .ASN1_ex_new_func* asn1_ex_new; 658 .ASN1_ex_free_func* asn1_ex_free; 659 .ASN1_ex_free_func* asn1_ex_clear; 660 .ASN1_ex_d2i* asn1_ex_d2i; 661 .ASN1_ex_i2d* asn1_ex_i2d; 662 .ASN1_ex_print_func* asn1_ex_print; 663 } 664 665 alias ASN1_EXTERN_FUNCS = .ASN1_EXTERN_FUNCS_st; 666 667 struct ASN1_PRIMITIVE_FUNCS_st 668 { 669 void* app_data; 670 core.stdc.config.c_ulong flags; 671 .ASN1_ex_new_func* prim_new; 672 .ASN1_ex_free_func* prim_free; 673 .ASN1_ex_free_func* prim_clear; 674 .ASN1_primitive_c2i* prim_c2i; 675 .ASN1_primitive_i2c* prim_i2c; 676 .ASN1_primitive_print* prim_print; 677 } 678 679 alias ASN1_PRIMITIVE_FUNCS = .ASN1_PRIMITIVE_FUNCS_st; 680 681 /* 682 * This is the ASN1_AUX structure: it handles various 683 * miscellaneous requirements. For example the use of 684 * reference counts and an informational callback. 685 * 686 * The "informational callback" is called at various 687 * points during the ASN1 encoding and decoding. It can 688 * be used to provide minor customisation of the structures 689 * used. This is most useful where the supplied routines 690 * *almost* do the right thing but need some extra help 691 * at a few points. If the callback returns zero then 692 * it is assumed a fatal error has occurred and the 693 * main operation should be abandoned. 694 * 695 * If major changes in the default behaviour are required 696 * then an external type is more appropriate. 697 */ 698 699 alias ASN1_aux_cb = extern (C) nothrow @nogc int function(int operation, libressl_d.openssl.asn1.ASN1_VALUE** in_, const (libressl_d.openssl.ossl_typ.ASN1_ITEM)* it, void* exarg); 700 701 struct ASN1_AUX_st 702 { 703 void* app_data; 704 int flags; 705 706 /** 707 * Offset of reference value 708 */ 709 int ref_offset; 710 711 /** 712 * Lock type to use 713 */ 714 int ref_lock; 715 716 .ASN1_aux_cb* asn1_cb; 717 718 /** 719 * Offset of ASN1_ENCODING structure 720 */ 721 int enc_offset; 722 } 723 724 alias ASN1_AUX = .ASN1_AUX_st; 725 726 /** 727 * For print related callbacks exarg points to this structure 728 */ 729 struct ASN1_PRINT_ARG_st 730 { 731 libressl_d.openssl.bio.BIO* out_; 732 int indent; 733 const (libressl_d.openssl.ossl_typ.ASN1_PCTX)* pctx; 734 } 735 736 alias ASN1_PRINT_ARG = .ASN1_PRINT_ARG_st; 737 738 /** 739 * For streaming related callbacks exarg points to this structure 740 */ 741 struct ASN1_STREAM_ARG_st 742 { 743 /** 744 * BIO to stream through 745 */ 746 libressl_d.openssl.bio.BIO* out_; 747 748 /** 749 * BIO with filters appended 750 */ 751 libressl_d.openssl.bio.BIO* ndef_bio; 752 753 /** 754 * Streaming I/O boundary 755 */ 756 ubyte** boundary; 757 } 758 759 alias ASN1_STREAM_ARG = .ASN1_STREAM_ARG_st; 760 761 /* Flags in ASN1_AUX */ 762 763 /** 764 * Use a reference count 765 */ 766 enum ASN1_AFLG_REFCOUNT = 1; 767 768 /** 769 * Save the encoding of structure (useful for signatures) 770 */ 771 enum ASN1_AFLG_ENCODING = 2; 772 773 /** 774 * The Sequence length is invalid 775 */ 776 enum ASN1_AFLG_BROKEN = 4; 777 778 /* operation values for asn1_cb */ 779 780 enum ASN1_OP_NEW_PRE = 0; 781 enum ASN1_OP_NEW_POST = 1; 782 enum ASN1_OP_FREE_PRE = 2; 783 enum ASN1_OP_FREE_POST = 3; 784 enum ASN1_OP_D2I_PRE = 4; 785 enum ASN1_OP_D2I_POST = 5; 786 enum ASN1_OP_I2D_PRE = 6; 787 enum ASN1_OP_I2D_POST = 7; 788 enum ASN1_OP_PRINT_PRE = 8; 789 enum ASN1_OP_PRINT_POST = 9; 790 enum ASN1_OP_STREAM_PRE = 10; 791 enum ASN1_OP_STREAM_POST = 11; 792 enum ASN1_OP_DETACHED_PRE = 12; 793 enum ASN1_OP_DETACHED_POST = 13; 794 795 version (LIBRESSL_INTERNAL) { 796 } else { 797 /* Macro to implement a primitive type */ 798 //#define IMPLEMENT_ASN1_TYPE(stname) .IMPLEMENT_ASN1_TYPE_ex(stname, stname, 0) 799 //#define IMPLEMENT_ASN1_TYPE_ex(itname, vname, ex) .ASN1_ITEM_start(itname) .ASN1_ITYPE_PRIMITIVE, V_##vname, null, 0, null, ex, #itname .ASN1_ITEM_end(itname) 800 801 /* Macro to implement a multi string type */ 802 //#define IMPLEMENT_ASN1_MSTRING(itname, mask) .ASN1_ITEM_start(itname) .ASN1_ITYPE_MSTRING, mask, null, 0, null, libressl_d.openssl.ossl_typ.ASN1_STRING.sizeof, #itname .ASN1_ITEM_end(itname) 803 //#define IMPLEMENT_EXTERN_ASN1(sname, tag, fptrs) .ASN1_ITEM_start(sname) .ASN1_ITYPE_EXTERN, tag, null, 0, &fptrs, 0, #sname .ASN1_ITEM_end(sname) 804 805 /* Macro to implement standard functions in terms of ASN1_ITEM structures */ 806 807 //#define IMPLEMENT_ASN1_FUNCTIONS(stname) .IMPLEMENT_ASN1_FUNCTIONS_fname(stname, stname, stname) 808 809 //#define IMPLEMENT_ASN1_FUNCTIONS_name(stname, itname) .IMPLEMENT_ASN1_FUNCTIONS_fname(stname, itname, itname) 810 811 //#define IMPLEMENT_ASN1_FUNCTIONS_ENCODE_name(stname, itname) IMPLEMENT_ASN1_FUNCTIONS_ENCODE_fname(stname, itname, itname) 812 813 //#define IMPLEMENT_STATIC_ASN1_ALLOC_FUNCTIONS(stname) .IMPLEMENT_ASN1_ALLOC_FUNCTIONS_pfname(static, stname, stname, stname) 814 815 //#define IMPLEMENT_ASN1_ALLOC_FUNCTIONS(stname) .IMPLEMENT_ASN1_ALLOC_FUNCTIONS_fname(stname, stname, stname) 816 817 //#define IMPLEMENT_ASN1_ALLOC_FUNCTIONS_pfname(pre, stname, itname, fname) pre stname* fname##_new(void) { return (stname*) libressl_d.openssl.asn1.ASN1_item_new(libressl_d.openssl.asn1.ASN1_ITEM_rptr(itname)); } pre void fname##_free(stname* a) { libressl_d.openssl.asn1.ASN1_item_free(cast(libressl_d.openssl.asn1.ASN1_VALUE*)(a), libressl_d.openssl.asn1.ASN1_ITEM_rptr(itname)); } 818 819 //#define IMPLEMENT_ASN1_ALLOC_FUNCTIONS_fname(stname, itname, fname) stname* fname##_new(void) { return (stname*) libressl_d.openssl.asn1.ASN1_item_new(libressl_d.openssl.asn1.ASN1_ITEM_rptr(itname)); } void fname##_free(stname* a) { libressl_d.openssl.asn1.ASN1_item_free(cast(libressl_d.openssl.asn1.ASN1_VALUE*)(a), libressl_d.openssl.asn1.ASN1_ITEM_rptr(itname)); } 820 821 //#define IMPLEMENT_ASN1_FUNCTIONS_fname(stname, itname, fname) .IMPLEMENT_ASN1_ENCODE_FUNCTIONS_fname(stname, itname, fname) .IMPLEMENT_ASN1_ALLOC_FUNCTIONS_fname(stname, itname, fname) 822 823 //#define IMPLEMENT_ASN1_ENCODE_FUNCTIONS_fname(stname, itname, fname) stname* d2i_##fname(stname** a, const (ubyte)** in_, core.stdc.config.c_long len) { return (stname*) libressl_d.openssl.asn1.ASN1_item_d2i(cast(libressl_d.openssl.asn1.ASN1_VALUE**)(a), in_, len, libressl_d.openssl.asn1.ASN1_ITEM_rptr(itname)); } int i2d_##fname(stname* a, ubyte** out_) { return libressl_d.openssl.asn1.ASN1_item_i2d(cast(libressl_d.openssl.asn1.ASN1_VALUE*)(a), out_, libressl_d.openssl.asn1.ASN1_ITEM_rptr(itname)); } 824 825 //#define IMPLEMENT_ASN1_NDEF_FUNCTION(stname) int i2d_##stname##_NDEF(stname* a, ubyte** out_) { return libressl_d.openssl.asn1.ASN1_item_ndef_i2d(cast(libressl_d.openssl.asn1.ASN1_VALUE*)(a), out_, libressl_d.openssl.asn1.ASN1_ITEM_rptr(stname)); } 826 827 /* 828 * This includes evil casts to remove const: they will go away when full 829 * ASN1 constification is done. 830 */ 831 //#define IMPLEMENT_ASN1_ENCODE_FUNCTIONS_const_fname(stname, itname, fname) stname* d2i_##fname(stname** a, const (ubyte)** in_, core.stdc.config.c_long len) { return (stname*) libressl_d.openssl.asn1.ASN1_item_d2i(cast(libressl_d.openssl.asn1.ASN1_VALUE**)(a), in_, len, libressl_d.openssl.asn1.ASN1_ITEM_rptr(itname)); } int i2d_##fname(const (stname)* a, ubyte** out_) { return libressl_d.openssl.asn1.ASN1_item_i2d(cast(libressl_d.openssl.asn1.ASN1_VALUE*)(a), out_, libressl_d.openssl.asn1.ASN1_ITEM_rptr(itname)); } 832 833 //#define IMPLEMENT_ASN1_DUP_FUNCTION(stname) stname* stname##_dup(stname* x) { return libressl_d.openssl.asn1.ASN1_item_dup(libressl_d.openssl.asn1.ASN1_ITEM_rptr(stname), x); } 834 835 //#define IMPLEMENT_ASN1_PRINT_FUNCTION(stname) .IMPLEMENT_ASN1_PRINT_FUNCTION_fname(stname, stname, stname) 836 837 //#define IMPLEMENT_ASN1_PRINT_FUNCTION_fname(stname, itname, fname) int fname##_print_ctx(libressl_d.openssl.bio.BIO* out_, stname* x, int indent, const (libressl_d.openssl.ossl_typ.ASN1_PCTX)* pctx) { return libressl_d.openssl.asn1.ASN1_item_print(out_, cast(libressl_d.openssl.asn1.ASN1_VALUE*)(x), indent, libressl_d.openssl.asn1.ASN1_ITEM_rptr(itname), pctx); } 838 839 //#define IMPLEMENT_ASN1_FUNCTIONS_const(name) .IMPLEMENT_ASN1_FUNCTIONS_const_fname(name, name, name) 840 841 //#define IMPLEMENT_ASN1_FUNCTIONS_const_fname(stname, itname, fname) .IMPLEMENT_ASN1_ENCODE_FUNCTIONS_const_fname(stname, itname, fname) .IMPLEMENT_ASN1_ALLOC_FUNCTIONS_fname(stname, itname, fname) 842 } 843 844 /* external definitions for primitive types */ 845 846 extern __gshared const libressl_d.openssl.ossl_typ.ASN1_ITEM ASN1_BOOLEAN_it; 847 extern __gshared const libressl_d.openssl.ossl_typ.ASN1_ITEM ASN1_TBOOLEAN_it; 848 extern __gshared const libressl_d.openssl.ossl_typ.ASN1_ITEM ASN1_FBOOLEAN_it; 849 extern __gshared const libressl_d.openssl.ossl_typ.ASN1_ITEM ASN1_SEQUENCE_it; 850 extern __gshared const libressl_d.openssl.ossl_typ.ASN1_ITEM CBIGNUM_it; 851 extern __gshared const libressl_d.openssl.ossl_typ.ASN1_ITEM BIGNUM_it; 852 extern __gshared const libressl_d.openssl.ossl_typ.ASN1_ITEM LONG_it; 853 extern __gshared const libressl_d.openssl.ossl_typ.ASN1_ITEM ZLONG_it; 854 855 //DECLARE_STACK_OF(ASN1_VALUE) 856 struct stack_st_ASN1_VALUE 857 { 858 libressl_d.openssl.stack._STACK stack; 859 } 860 861 /* Functions used internally by the ASN1 code */ 862 863 int ASN1_item_ex_new(libressl_d.openssl.asn1.ASN1_VALUE** pval, const (libressl_d.openssl.ossl_typ.ASN1_ITEM)* it); 864 void ASN1_item_ex_free(libressl_d.openssl.asn1.ASN1_VALUE** pval, const (libressl_d.openssl.ossl_typ.ASN1_ITEM)* it); 865 int ASN1_template_new(libressl_d.openssl.asn1.ASN1_VALUE** pval, const (libressl_d.openssl.asn1.ASN1_TEMPLATE)* tt); 866 int ASN1_primitive_new(libressl_d.openssl.asn1.ASN1_VALUE** pval, const (libressl_d.openssl.ossl_typ.ASN1_ITEM)* it); 867 868 void ASN1_template_free(libressl_d.openssl.asn1.ASN1_VALUE** pval, const (libressl_d.openssl.asn1.ASN1_TEMPLATE)* tt); 869 int ASN1_template_d2i(libressl_d.openssl.asn1.ASN1_VALUE** pval, const (ubyte)** in_, core.stdc.config.c_long len, const (libressl_d.openssl.asn1.ASN1_TEMPLATE)* tt); 870 int ASN1_item_ex_d2i(libressl_d.openssl.asn1.ASN1_VALUE** pval, const (ubyte)** in_, core.stdc.config.c_long len, const (libressl_d.openssl.ossl_typ.ASN1_ITEM)* it, int tag, int aclass, char opt, libressl_d.openssl.asn1.ASN1_TLC* ctx); 871 872 int ASN1_item_ex_i2d(libressl_d.openssl.asn1.ASN1_VALUE** pval, ubyte** out_, const (libressl_d.openssl.ossl_typ.ASN1_ITEM)* it, int tag, int aclass); 873 int ASN1_template_i2d(libressl_d.openssl.asn1.ASN1_VALUE** pval, ubyte** out_, const (libressl_d.openssl.asn1.ASN1_TEMPLATE)* tt); 874 void ASN1_primitive_free(libressl_d.openssl.asn1.ASN1_VALUE** pval, const (libressl_d.openssl.ossl_typ.ASN1_ITEM)* it); 875 876 int asn1_ex_c2i(libressl_d.openssl.asn1.ASN1_VALUE** pval, const (ubyte)* cont, int len, int utype, char* free_cont, const (libressl_d.openssl.ossl_typ.ASN1_ITEM)* it); 877 878 int asn1_get_choice_selector(libressl_d.openssl.asn1.ASN1_VALUE** pval, const (libressl_d.openssl.ossl_typ.ASN1_ITEM)* it); 879 int asn1_set_choice_selector(libressl_d.openssl.asn1.ASN1_VALUE** pval, int value, const (libressl_d.openssl.ossl_typ.ASN1_ITEM)* it); 880 881 libressl_d.openssl.asn1.ASN1_VALUE** asn1_get_field_ptr(libressl_d.openssl.asn1.ASN1_VALUE** pval, const (libressl_d.openssl.asn1.ASN1_TEMPLATE)* tt); 882 883 const (libressl_d.openssl.asn1.ASN1_TEMPLATE)* asn1_do_adb(libressl_d.openssl.asn1.ASN1_VALUE** pval, const (libressl_d.openssl.asn1.ASN1_TEMPLATE)* tt, int nullerr); 884 885 int asn1_do_lock(libressl_d.openssl.asn1.ASN1_VALUE** pval, int op, const (libressl_d.openssl.ossl_typ.ASN1_ITEM)* it); 886 887 void asn1_enc_init(libressl_d.openssl.asn1.ASN1_VALUE** pval, const (libressl_d.openssl.ossl_typ.ASN1_ITEM)* it); 888 void asn1_enc_free(libressl_d.openssl.asn1.ASN1_VALUE** pval, const (libressl_d.openssl.ossl_typ.ASN1_ITEM)* it); 889 int asn1_enc_restore(int* len, ubyte** out_, libressl_d.openssl.asn1.ASN1_VALUE** pval, const (libressl_d.openssl.ossl_typ.ASN1_ITEM)* it); 890 int asn1_enc_save(libressl_d.openssl.asn1.ASN1_VALUE** pval, const (ubyte)* in_, int inlen, const (libressl_d.openssl.ossl_typ.ASN1_ITEM)* it);