2 * Copyright 2002-2020 The OpenSSL Project Authors. All Rights Reserved.
4 * Licensed under the Apache License 2.0 (the "License"). You may not use
5 * this file except in compliance with the License. You can obtain a copy
6 * in the file LICENSE in the source distribution or at
7 * https://www.openssl.org/source/license.html
10 #include "internal/cryptlib.h"
11 #include <openssl/asn1.h>
12 #include <openssl/x509v3.h>
14 #define ASN1_GEN_FLAG 0x10000
15 #define ASN1_GEN_FLAG_IMP (ASN1_GEN_FLAG|1)
16 #define ASN1_GEN_FLAG_EXP (ASN1_GEN_FLAG|2)
17 #define ASN1_GEN_FLAG_TAG (ASN1_GEN_FLAG|3)
18 #define ASN1_GEN_FLAG_BITWRAP (ASN1_GEN_FLAG|4)
19 #define ASN1_GEN_FLAG_OCTWRAP (ASN1_GEN_FLAG|5)
20 #define ASN1_GEN_FLAG_SEQWRAP (ASN1_GEN_FLAG|6)
21 #define ASN1_GEN_FLAG_SETWRAP (ASN1_GEN_FLAG|7)
22 #define ASN1_GEN_FLAG_FORMAT (ASN1_GEN_FLAG|8)
24 #define ASN1_GEN_STR(str,val) {str, sizeof(str) - 1, val}
26 DEFINE_STACK_OF(CONF_VALUE)
28 #define ASN1_FLAG_EXP_MAX 20
29 /* Maximum number of nested sequences */
30 #define ASN1_GEN_SEQ_MAX_DEPTH 50
35 #define ASN1_GEN_FORMAT_ASCII 1
37 #define ASN1_GEN_FORMAT_UTF8 2
39 #define ASN1_GEN_FORMAT_HEX 3
41 #define ASN1_GEN_FORMAT_BITLIST 4
63 tag_exp_type exp_list[ASN1_FLAG_EXP_MAX];
67 static ASN1_TYPE *generate_v3(const char *str, X509V3_CTX *cnf, int depth,
69 static int bitstr_cb(const char *elem, int len, void *bitstr);
70 static int asn1_cb(const char *elem, int len, void *bitstr);
71 static int append_exp(tag_exp_arg *arg, int exp_tag, int exp_class,
72 int exp_constructed, int exp_pad, int imp_ok);
73 static int parse_tagging(const char *vstart, int vlen, int *ptag,
75 static ASN1_TYPE *asn1_multi(int utype, const char *section, X509V3_CTX *cnf,
76 int depth, int *perr);
77 static ASN1_TYPE *asn1_str2type(const char *str, int format, int utype);
78 static int asn1_str2tag(const char *tagstr, int len);
80 ASN1_TYPE *ASN1_generate_nconf(const char *str, CONF *nconf)
85 return ASN1_generate_v3(str, NULL);
87 X509V3_set_nconf(&cnf, nconf);
88 return ASN1_generate_v3(str, &cnf);
91 ASN1_TYPE *ASN1_generate_v3(const char *str, X509V3_CTX *cnf)
94 ASN1_TYPE *ret = generate_v3(str, cnf, 0, &err);
96 ASN1err(ASN1_F_ASN1_GENERATE_V3, err);
100 static ASN1_TYPE *generate_v3(const char *str, X509V3_CTX *cnf, int depth,
104 tag_exp_arg asn1_tags;
109 unsigned char *orig_der = NULL, *new_der = NULL;
110 const unsigned char *cpy_start;
112 const unsigned char *cp;
115 int hdr_constructed = 0, hdr_tag, hdr_class;
118 asn1_tags.imp_tag = -1;
119 asn1_tags.imp_class = -1;
120 asn1_tags.format = ASN1_GEN_FORMAT_ASCII;
121 asn1_tags.exp_count = 0;
122 if (CONF_parse_list(str, ',', 1, asn1_cb, &asn1_tags) != 0) {
123 *perr = ASN1_R_UNKNOWN_TAG;
127 if ((asn1_tags.utype == V_ASN1_SEQUENCE)
128 || (asn1_tags.utype == V_ASN1_SET)) {
130 *perr = ASN1_R_SEQUENCE_OR_SET_NEEDS_CONFIG;
133 if (depth >= ASN1_GEN_SEQ_MAX_DEPTH) {
134 *perr = ASN1_R_ILLEGAL_NESTED_TAGGING;
137 ret = asn1_multi(asn1_tags.utype, asn1_tags.str, cnf, depth, perr);
139 ret = asn1_str2type(asn1_tags.str, asn1_tags.format, asn1_tags.utype);
144 /* If no tagging return base type */
145 if ((asn1_tags.imp_tag == -1) && (asn1_tags.exp_count == 0))
148 /* Generate the encoding */
149 cpy_len = i2d_ASN1_TYPE(ret, &orig_der);
152 /* Set point to start copying for modified encoding */
153 cpy_start = orig_der;
155 /* Do we need IMPLICIT tagging? */
156 if (asn1_tags.imp_tag != -1) {
157 /* If IMPLICIT we will replace the underlying tag */
158 /* Skip existing tag+len */
159 r = ASN1_get_object(&cpy_start, &hdr_len, &hdr_tag, &hdr_class,
163 /* Update copy length */
164 cpy_len -= cpy_start - orig_der;
166 * For IMPLICIT tagging the length should match the original length
167 * and constructed flag should be consistent.
170 /* Indefinite length constructed */
174 /* Just retain constructed flag */
175 hdr_constructed = r & V_ASN1_CONSTRUCTED;
177 * Work out new length with IMPLICIT tag: ignore constructed because
178 * it will mess up if indefinite length
180 len = ASN1_object_size(0, hdr_len, asn1_tags.imp_tag);
184 /* Work out length in any EXPLICIT, starting from end */
186 for (i = 0, etmp = asn1_tags.exp_list + asn1_tags.exp_count - 1;
187 i < asn1_tags.exp_count; i++, etmp--) {
188 /* Content length: number of content octets + any padding */
189 len += etmp->exp_pad;
191 /* Total object length: length including new header */
192 len = ASN1_object_size(0, len, etmp->exp_tag);
195 /* Allocate buffer for new encoding */
197 new_der = OPENSSL_malloc(len);
201 /* Generate tagged encoding */
205 /* Output explicit tags first */
207 for (i = 0, etmp = asn1_tags.exp_list; i < asn1_tags.exp_count;
209 ASN1_put_object(&p, etmp->exp_constructed, etmp->exp_len,
210 etmp->exp_tag, etmp->exp_class);
215 /* If IMPLICIT, output tag */
217 if (asn1_tags.imp_tag != -1) {
218 if (asn1_tags.imp_class == V_ASN1_UNIVERSAL
219 && (asn1_tags.imp_tag == V_ASN1_SEQUENCE
220 || asn1_tags.imp_tag == V_ASN1_SET))
221 hdr_constructed = V_ASN1_CONSTRUCTED;
222 ASN1_put_object(&p, hdr_constructed, hdr_len,
223 asn1_tags.imp_tag, asn1_tags.imp_class);
226 /* Copy across original encoding */
227 memcpy(p, cpy_start, cpy_len);
231 /* Obtain new ASN1_TYPE structure */
232 ret = d2i_ASN1_TYPE(NULL, &cp, len);
235 OPENSSL_free(orig_der);
236 OPENSSL_free(new_der);
242 static int asn1_cb(const char *elem, int len, void *bitstr)
244 tag_exp_arg *arg = bitstr;
248 const char *p, *vstart = NULL;
250 int tmp_tag, tmp_class;
255 for (i = 0, p = elem; i < len; p++, i++) {
256 /* Look for the ':' in name value pairs */
259 vlen = len - (vstart - elem);
265 utype = asn1_str2tag(elem, len);
268 ASN1err(ASN1_F_ASN1_CB, ASN1_R_UNKNOWN_TAG);
269 ERR_add_error_data(2, "tag=", elem);
273 /* If this is not a modifier mark end of string and exit */
274 if (!(utype & ASN1_GEN_FLAG)) {
277 /* If no value and not end of string, error */
278 if (!vstart && elem[len]) {
279 ASN1err(ASN1_F_ASN1_CB, ASN1_R_MISSING_VALUE);
287 case ASN1_GEN_FLAG_IMP:
288 /* Check for illegal multiple IMPLICIT tagging */
289 if (arg->imp_tag != -1) {
290 ASN1err(ASN1_F_ASN1_CB, ASN1_R_ILLEGAL_NESTED_TAGGING);
293 if (!parse_tagging(vstart, vlen, &arg->imp_tag, &arg->imp_class))
297 case ASN1_GEN_FLAG_EXP:
299 if (!parse_tagging(vstart, vlen, &tmp_tag, &tmp_class))
301 if (!append_exp(arg, tmp_tag, tmp_class, 1, 0, 0))
305 case ASN1_GEN_FLAG_SEQWRAP:
306 if (!append_exp(arg, V_ASN1_SEQUENCE, V_ASN1_UNIVERSAL, 1, 0, 1))
310 case ASN1_GEN_FLAG_SETWRAP:
311 if (!append_exp(arg, V_ASN1_SET, V_ASN1_UNIVERSAL, 1, 0, 1))
315 case ASN1_GEN_FLAG_BITWRAP:
316 if (!append_exp(arg, V_ASN1_BIT_STRING, V_ASN1_UNIVERSAL, 0, 1, 1))
320 case ASN1_GEN_FLAG_OCTWRAP:
321 if (!append_exp(arg, V_ASN1_OCTET_STRING, V_ASN1_UNIVERSAL, 0, 0, 1))
325 case ASN1_GEN_FLAG_FORMAT:
327 ASN1err(ASN1_F_ASN1_CB, ASN1_R_UNKNOWN_FORMAT);
330 if (strncmp(vstart, "ASCII", 5) == 0)
331 arg->format = ASN1_GEN_FORMAT_ASCII;
332 else if (strncmp(vstart, "UTF8", 4) == 0)
333 arg->format = ASN1_GEN_FORMAT_UTF8;
334 else if (strncmp(vstart, "HEX", 3) == 0)
335 arg->format = ASN1_GEN_FORMAT_HEX;
336 else if (strncmp(vstart, "BITLIST", 7) == 0)
337 arg->format = ASN1_GEN_FORMAT_BITLIST;
339 ASN1err(ASN1_F_ASN1_CB, ASN1_R_UNKNOWN_FORMAT);
350 static int parse_tagging(const char *vstart, int vlen, int *ptag, int *pclass)
357 tag_num = strtoul(vstart, &eptr, 10);
358 /* Check we haven't gone past max length: should be impossible */
359 if (eptr && *eptr && (eptr > vstart + vlen))
362 ASN1err(ASN1_F_PARSE_TAGGING, ASN1_R_INVALID_NUMBER);
366 /* If we have non numeric characters, parse them */
368 vlen -= eptr - vstart;
375 *pclass = V_ASN1_UNIVERSAL;
379 *pclass = V_ASN1_APPLICATION;
383 *pclass = V_ASN1_PRIVATE;
387 *pclass = V_ASN1_CONTEXT_SPECIFIC;
393 ASN1err(ASN1_F_PARSE_TAGGING, ASN1_R_INVALID_MODIFIER);
394 ERR_add_error_data(2, "Char=", erch);
399 *pclass = V_ASN1_CONTEXT_SPECIFIC;
405 /* Handle multiple types: SET and SEQUENCE */
407 static ASN1_TYPE *asn1_multi(int utype, const char *section, X509V3_CTX *cnf,
408 int depth, int *perr)
410 ASN1_TYPE *ret = NULL;
411 STACK_OF(ASN1_TYPE) *sk = NULL;
412 STACK_OF(CONF_VALUE) *sect = NULL;
413 unsigned char *der = NULL;
416 sk = sk_ASN1_TYPE_new_null();
422 sect = X509V3_get_section(cnf, (char *)section);
425 for (i = 0; i < sk_CONF_VALUE_num(sect); i++) {
427 generate_v3(sk_CONF_VALUE_value(sect, i)->value, cnf,
431 if (!sk_ASN1_TYPE_push(sk, typ))
437 * Now we has a STACK of the components, convert to the correct form
440 if (utype == V_ASN1_SET)
441 derlen = i2d_ASN1_SET_ANY(sk, &der);
443 derlen = i2d_ASN1_SEQUENCE_ANY(sk, &der);
447 if ((ret = ASN1_TYPE_new()) == NULL)
449 if ((ret->value.asn1_string = ASN1_STRING_type_new(utype)) == NULL)
453 ret->value.asn1_string->data = der;
454 ret->value.asn1_string->length = derlen;
462 sk_ASN1_TYPE_pop_free(sk, ASN1_TYPE_free);
463 X509V3_section_free(cnf, sect);
468 static int append_exp(tag_exp_arg *arg, int exp_tag, int exp_class,
469 int exp_constructed, int exp_pad, int imp_ok)
471 tag_exp_type *exp_tmp;
472 /* Can only have IMPLICIT if permitted */
473 if ((arg->imp_tag != -1) && !imp_ok) {
474 ASN1err(ASN1_F_APPEND_EXP, ASN1_R_ILLEGAL_IMPLICIT_TAG);
478 if (arg->exp_count == ASN1_FLAG_EXP_MAX) {
479 ASN1err(ASN1_F_APPEND_EXP, ASN1_R_DEPTH_EXCEEDED);
483 exp_tmp = &arg->exp_list[arg->exp_count++];
486 * If IMPLICIT set tag to implicit value then reset implicit tag since it
489 if (arg->imp_tag != -1) {
490 exp_tmp->exp_tag = arg->imp_tag;
491 exp_tmp->exp_class = arg->imp_class;
495 exp_tmp->exp_tag = exp_tag;
496 exp_tmp->exp_class = exp_class;
498 exp_tmp->exp_constructed = exp_constructed;
499 exp_tmp->exp_pad = exp_pad;
504 static int asn1_str2tag(const char *tagstr, int len)
507 static const struct tag_name_st *tntmp, tnst[] = {
508 ASN1_GEN_STR("BOOL", V_ASN1_BOOLEAN),
509 ASN1_GEN_STR("BOOLEAN", V_ASN1_BOOLEAN),
510 ASN1_GEN_STR("NULL", V_ASN1_NULL),
511 ASN1_GEN_STR("INT", V_ASN1_INTEGER),
512 ASN1_GEN_STR("INTEGER", V_ASN1_INTEGER),
513 ASN1_GEN_STR("ENUM", V_ASN1_ENUMERATED),
514 ASN1_GEN_STR("ENUMERATED", V_ASN1_ENUMERATED),
515 ASN1_GEN_STR("OID", V_ASN1_OBJECT),
516 ASN1_GEN_STR("OBJECT", V_ASN1_OBJECT),
517 ASN1_GEN_STR("UTCTIME", V_ASN1_UTCTIME),
518 ASN1_GEN_STR("UTC", V_ASN1_UTCTIME),
519 ASN1_GEN_STR("GENERALIZEDTIME", V_ASN1_GENERALIZEDTIME),
520 ASN1_GEN_STR("GENTIME", V_ASN1_GENERALIZEDTIME),
521 ASN1_GEN_STR("OCT", V_ASN1_OCTET_STRING),
522 ASN1_GEN_STR("OCTETSTRING", V_ASN1_OCTET_STRING),
523 ASN1_GEN_STR("BITSTR", V_ASN1_BIT_STRING),
524 ASN1_GEN_STR("BITSTRING", V_ASN1_BIT_STRING),
525 ASN1_GEN_STR("UNIVERSALSTRING", V_ASN1_UNIVERSALSTRING),
526 ASN1_GEN_STR("UNIV", V_ASN1_UNIVERSALSTRING),
527 ASN1_GEN_STR("IA5", V_ASN1_IA5STRING),
528 ASN1_GEN_STR("IA5STRING", V_ASN1_IA5STRING),
529 ASN1_GEN_STR("UTF8", V_ASN1_UTF8STRING),
530 ASN1_GEN_STR("UTF8String", V_ASN1_UTF8STRING),
531 ASN1_GEN_STR("BMP", V_ASN1_BMPSTRING),
532 ASN1_GEN_STR("BMPSTRING", V_ASN1_BMPSTRING),
533 ASN1_GEN_STR("VISIBLESTRING", V_ASN1_VISIBLESTRING),
534 ASN1_GEN_STR("VISIBLE", V_ASN1_VISIBLESTRING),
535 ASN1_GEN_STR("PRINTABLESTRING", V_ASN1_PRINTABLESTRING),
536 ASN1_GEN_STR("PRINTABLE", V_ASN1_PRINTABLESTRING),
537 ASN1_GEN_STR("T61", V_ASN1_T61STRING),
538 ASN1_GEN_STR("T61STRING", V_ASN1_T61STRING),
539 ASN1_GEN_STR("TELETEXSTRING", V_ASN1_T61STRING),
540 ASN1_GEN_STR("GeneralString", V_ASN1_GENERALSTRING),
541 ASN1_GEN_STR("GENSTR", V_ASN1_GENERALSTRING),
542 ASN1_GEN_STR("NUMERIC", V_ASN1_NUMERICSTRING),
543 ASN1_GEN_STR("NUMERICSTRING", V_ASN1_NUMERICSTRING),
546 ASN1_GEN_STR("SEQUENCE", V_ASN1_SEQUENCE),
547 ASN1_GEN_STR("SEQ", V_ASN1_SEQUENCE),
548 ASN1_GEN_STR("SET", V_ASN1_SET),
551 ASN1_GEN_STR("EXP", ASN1_GEN_FLAG_EXP),
552 ASN1_GEN_STR("EXPLICIT", ASN1_GEN_FLAG_EXP),
554 ASN1_GEN_STR("IMP", ASN1_GEN_FLAG_IMP),
555 ASN1_GEN_STR("IMPLICIT", ASN1_GEN_FLAG_IMP),
556 /* OCTET STRING wrapper */
557 ASN1_GEN_STR("OCTWRAP", ASN1_GEN_FLAG_OCTWRAP),
558 /* SEQUENCE wrapper */
559 ASN1_GEN_STR("SEQWRAP", ASN1_GEN_FLAG_SEQWRAP),
561 ASN1_GEN_STR("SETWRAP", ASN1_GEN_FLAG_SETWRAP),
562 /* BIT STRING wrapper */
563 ASN1_GEN_STR("BITWRAP", ASN1_GEN_FLAG_BITWRAP),
564 ASN1_GEN_STR("FORM", ASN1_GEN_FLAG_FORMAT),
565 ASN1_GEN_STR("FORMAT", ASN1_GEN_FLAG_FORMAT),
569 len = strlen(tagstr);
572 for (i = 0; i < OSSL_NELEM(tnst); i++, tntmp++) {
573 if ((len == tntmp->len) && (strncmp(tntmp->strnam, tagstr, len) == 0))
580 static ASN1_TYPE *asn1_str2type(const char *str, int format, int utype)
582 ASN1_TYPE *atmp = NULL;
584 unsigned char *rdata;
588 if ((atmp = ASN1_TYPE_new()) == NULL) {
589 ASN1err(ASN1_F_ASN1_STR2TYPE, ERR_R_MALLOC_FAILURE);
600 ASN1err(ASN1_F_ASN1_STR2TYPE, ASN1_R_ILLEGAL_NULL_VALUE);
606 if (format != ASN1_GEN_FORMAT_ASCII) {
607 ASN1err(ASN1_F_ASN1_STR2TYPE, ASN1_R_NOT_ASCII_FORMAT);
612 vtmp.value = (char *)str;
613 if (!X509V3_get_value_bool(&vtmp, &atmp->value.boolean)) {
614 ASN1err(ASN1_F_ASN1_STR2TYPE, ASN1_R_ILLEGAL_BOOLEAN);
620 case V_ASN1_ENUMERATED:
621 if (format != ASN1_GEN_FORMAT_ASCII) {
622 ASN1err(ASN1_F_ASN1_STR2TYPE, ASN1_R_INTEGER_NOT_ASCII_FORMAT);
625 if ((atmp->value.integer
626 = s2i_ASN1_INTEGER(NULL, str)) == NULL) {
627 ASN1err(ASN1_F_ASN1_STR2TYPE, ASN1_R_ILLEGAL_INTEGER);
633 if (format != ASN1_GEN_FORMAT_ASCII) {
634 ASN1err(ASN1_F_ASN1_STR2TYPE, ASN1_R_OBJECT_NOT_ASCII_FORMAT);
637 if ((atmp->value.object = OBJ_txt2obj(str, 0)) == NULL) {
638 ASN1err(ASN1_F_ASN1_STR2TYPE, ASN1_R_ILLEGAL_OBJECT);
644 case V_ASN1_GENERALIZEDTIME:
645 if (format != ASN1_GEN_FORMAT_ASCII) {
646 ASN1err(ASN1_F_ASN1_STR2TYPE, ASN1_R_TIME_NOT_ASCII_FORMAT);
649 if ((atmp->value.asn1_string = ASN1_STRING_new()) == NULL) {
650 ASN1err(ASN1_F_ASN1_STR2TYPE, ERR_R_MALLOC_FAILURE);
653 if (!ASN1_STRING_set(atmp->value.asn1_string, str, -1)) {
654 ASN1err(ASN1_F_ASN1_STR2TYPE, ERR_R_MALLOC_FAILURE);
657 atmp->value.asn1_string->type = utype;
658 if (!ASN1_TIME_check(atmp->value.asn1_string)) {
659 ASN1err(ASN1_F_ASN1_STR2TYPE, ASN1_R_ILLEGAL_TIME_VALUE);
665 case V_ASN1_BMPSTRING:
666 case V_ASN1_PRINTABLESTRING:
667 case V_ASN1_IA5STRING:
668 case V_ASN1_T61STRING:
669 case V_ASN1_UTF8STRING:
670 case V_ASN1_VISIBLESTRING:
671 case V_ASN1_UNIVERSALSTRING:
672 case V_ASN1_GENERALSTRING:
673 case V_ASN1_NUMERICSTRING:
674 if (format == ASN1_GEN_FORMAT_ASCII)
675 format = MBSTRING_ASC;
676 else if (format == ASN1_GEN_FORMAT_UTF8)
677 format = MBSTRING_UTF8;
679 ASN1err(ASN1_F_ASN1_STR2TYPE, ASN1_R_ILLEGAL_FORMAT);
683 if (ASN1_mbstring_copy(&atmp->value.asn1_string, (unsigned char *)str,
684 -1, format, ASN1_tag2bit(utype)) <= 0) {
685 ASN1err(ASN1_F_ASN1_STR2TYPE, ERR_R_MALLOC_FAILURE);
691 case V_ASN1_BIT_STRING:
692 case V_ASN1_OCTET_STRING:
693 if ((atmp->value.asn1_string = ASN1_STRING_new()) == NULL) {
694 ASN1err(ASN1_F_ASN1_STR2TYPE, ERR_R_MALLOC_FAILURE);
698 if (format == ASN1_GEN_FORMAT_HEX) {
699 if ((rdata = OPENSSL_hexstr2buf(str, &rdlen)) == NULL) {
700 ASN1err(ASN1_F_ASN1_STR2TYPE, ASN1_R_ILLEGAL_HEX);
703 atmp->value.asn1_string->data = rdata;
704 atmp->value.asn1_string->length = rdlen;
705 atmp->value.asn1_string->type = utype;
706 } else if (format == ASN1_GEN_FORMAT_ASCII)
707 ASN1_STRING_set(atmp->value.asn1_string, str, -1);
708 else if ((format == ASN1_GEN_FORMAT_BITLIST)
709 && (utype == V_ASN1_BIT_STRING)) {
711 (str, ',', 1, bitstr_cb, atmp->value.bit_string)) {
712 ASN1err(ASN1_F_ASN1_STR2TYPE, ASN1_R_LIST_ERROR);
718 ASN1err(ASN1_F_ASN1_STR2TYPE, ASN1_R_ILLEGAL_BITSTRING_FORMAT);
722 if ((utype == V_ASN1_BIT_STRING) && no_unused) {
723 atmp->value.asn1_string->flags
724 &= ~(ASN1_STRING_FLAG_BITS_LEFT | 0x07);
725 atmp->value.asn1_string->flags |= ASN1_STRING_FLAG_BITS_LEFT;
731 ASN1err(ASN1_F_ASN1_STR2TYPE, ASN1_R_UNSUPPORTED_TYPE);
739 ERR_add_error_data(2, "string=", str);
742 ASN1_TYPE_free(atmp);
747 static int bitstr_cb(const char *elem, int len, void *bitstr)
753 bitnum = strtoul(elem, &eptr, 10);
754 if (eptr && *eptr && (eptr != elem + len))
757 ASN1err(ASN1_F_BITSTR_CB, ASN1_R_INVALID_NUMBER);
760 if (!ASN1_BIT_STRING_set_bit(bitstr, bitnum, 1)) {
761 ASN1err(ASN1_F_BITSTR_CB, ERR_R_MALLOC_FAILURE);
767 static int mask_cb(const char *elem, int len, void *arg)
769 unsigned long *pmask = arg, tmpmask;
773 if ((len == 3) && (strncmp(elem, "DIR", 3) == 0)) {
774 *pmask |= B_ASN1_DIRECTORYSTRING;
777 tag = asn1_str2tag(elem, len);
778 if (!tag || (tag & ASN1_GEN_FLAG))
780 tmpmask = ASN1_tag2bit(tag);
787 int ASN1_str2mask(const char *str, unsigned long *pmask)
790 return CONF_parse_list(str, '|', 1, mask_cb, pmask);