Manually fix a few tables in advance of clang-format.

clang-format gets very confused by the comments in these tables. (The
comments seem to have already gotten a little messed up from upstream's
reformatted.) Reformat them ahead of time. I removed the tag2str number
comments as they aren't really doing much good at this point.

Also remove the last entry in tag2bits because it's not actually used.
ASN1_tag2bit only reads the first 31 entries.

Change-Id: If50770fd79b9d6ccab5558d24b0ee3a27c81a452
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/52731
Reviewed-by: Bob Beck <bbe@google.com>
Commit-Queue: Bob Beck <bbe@google.com>
chromium-5359
David Benjamin 3 years ago committed by Boringssl LUCI CQ
parent 1f7525e991
commit 67d4f28357
  1. 40
      crypto/asn1/asn1_par.c
  2. 52
      crypto/asn1/tasn_dec.c

@ -60,15 +60,37 @@
const char *ASN1_tag2str(int tag) const char *ASN1_tag2str(int tag)
{ {
static const char *const tag2str[] = { static const char *const tag2str[] = {
"EOC", "BOOLEAN", "INTEGER", "BIT STRING", "OCTET STRING", /* 0-4 */ "EOC",
"NULL", "OBJECT", "OBJECT DESCRIPTOR", "EXTERNAL", "REAL", /* 5-9 */ "BOOLEAN",
"ENUMERATED", "<ASN1 11>", "UTF8STRING", "<ASN1 13>", /* 10-13 */ "INTEGER",
"<ASN1 14>", "<ASN1 15>", "SEQUENCE", "SET", /* 15-17 */ "BIT STRING",
"NUMERICSTRING", "PRINTABLESTRING", "T61STRING", /* 18-20 */ "OCTET STRING",
"VIDEOTEXSTRING", "IA5STRING", "UTCTIME", "GENERALIZEDTIME", /* 21-24 "NULL",
*/ "OBJECT",
"GRAPHICSTRING", "VISIBLESTRING", "GENERALSTRING", /* 25-27 */ "OBJECT DESCRIPTOR",
"UNIVERSALSTRING", "<ASN1 29>", "BMPSTRING" /* 28-30 */ "EXTERNAL",
"REAL",
"ENUMERATED",
"<ASN1 11>",
"UTF8STRING",
"<ASN1 13>",
"<ASN1 14>",
"<ASN1 15>",
"SEQUENCE",
"SET",
"NUMERICSTRING",
"PRINTABLESTRING",
"T61STRING",
"VIDEOTEXSTRING",
"IA5STRING",
"UTCTIME",
"GENERALIZEDTIME",
"GRAPHICSTRING",
"VISIBLESTRING",
"GENERALSTRING",
"UNIVERSALSTRING",
"<ASN1 29>",
"BMPSTRING",
}; };
if ((tag == V_ASN1_NEG_INTEGER) || (tag == V_ASN1_NEG_ENUMERATED)) if ((tag == V_ASN1_NEG_INTEGER) || (tag == V_ASN1_NEG_ENUMERATED))

@ -97,29 +97,43 @@ static int asn1_item_ex_d2i(ASN1_VALUE **pval, const unsigned char **in,
char opt, int depth); char opt, int depth);
/* Table to convert tags to bit values, used for MSTRING type */ /* Table to convert tags to bit values, used for MSTRING type */
static const unsigned long tag2bit[32] = { static const unsigned long tag2bit[31] = {
0, 0, 0, B_ASN1_BIT_STRING, /* tags 0 - 3 */ 0, /* (reserved) */
B_ASN1_OCTET_STRING, 0, 0, B_ASN1_UNKNOWN, /* tags 4- 7 */ 0, /* BOOLEAN */
B_ASN1_UNKNOWN, B_ASN1_UNKNOWN, B_ASN1_UNKNOWN, B_ASN1_UNKNOWN, /* tags 0, /* INTEGER */
* 8-11 */ B_ASN1_BIT_STRING,
B_ASN1_UTF8STRING, B_ASN1_UNKNOWN, B_ASN1_UNKNOWN, B_ASN1_UNKNOWN, /* tags B_ASN1_OCTET_STRING,
* 12-15 0, /* NULL */
*/ 0, /* OBJECT IDENTIFIER */
B_ASN1_SEQUENCE, 0, B_ASN1_NUMERICSTRING, B_ASN1_PRINTABLESTRING, /* tags B_ASN1_UNKNOWN, /* ObjectDescriptor */
* 16-19 B_ASN1_UNKNOWN, /* EXTERNAL */
*/ B_ASN1_UNKNOWN, /* REAL */
B_ASN1_T61STRING, B_ASN1_VIDEOTEXSTRING, B_ASN1_IA5STRING, /* tags 20-22 */ B_ASN1_UNKNOWN, /* ENUMERATED */
B_ASN1_UTCTIME, B_ASN1_GENERALIZEDTIME, /* tags 23-24 */ B_ASN1_UNKNOWN, /* EMBEDDED PDV */
B_ASN1_GRAPHICSTRING, B_ASN1_ISO64STRING, B_ASN1_GENERALSTRING, /* tags B_ASN1_UTF8STRING,
* 25-27 */ B_ASN1_UNKNOWN, /* RELATIVE-OID */
B_ASN1_UNIVERSALSTRING, B_ASN1_UNKNOWN, B_ASN1_BMPSTRING, B_ASN1_UNKNOWN, /* tags B_ASN1_UNKNOWN, /* TIME */
* 28-31 B_ASN1_UNKNOWN, /* (reserved) */
*/ B_ASN1_SEQUENCE,
0, /* SET */
B_ASN1_NUMERICSTRING,
B_ASN1_PRINTABLESTRING,
B_ASN1_T61STRING,
B_ASN1_VIDEOTEXSTRING,
B_ASN1_IA5STRING,
B_ASN1_UTCTIME,
B_ASN1_GENERALIZEDTIME,
B_ASN1_GRAPHICSTRING,
B_ASN1_ISO64STRING,
B_ASN1_GENERALSTRING,
B_ASN1_UNIVERSALSTRING,
B_ASN1_UNKNOWN, /* CHARACTER STRING */
B_ASN1_BMPSTRING,
}; };
unsigned long ASN1_tag2bit(int tag) unsigned long ASN1_tag2bit(int tag)
{ {
if ((tag < 0) || (tag > 30)) if (tag < 0 || tag > 30)
return 0; return 0;
return tag2bit[tag]; return tag2bit[tag];
} }

Loading…
Cancel
Save