mirror of
https://github.com/guanzhi/GmSSL.git
synced 2026-05-06 16:36:16 +08:00
Merge pull request #1752 from dihambo/master
修正asn1的tag掩码。完善asn1的tag测试,使其覆盖所有可能值。
This commit is contained in:
@@ -38,7 +38,7 @@ const char *asn1_tag_name(int tag)
|
|||||||
}
|
}
|
||||||
|
|
||||||
switch (tag & 0xc0) {
|
switch (tag & 0xc0) {
|
||||||
case ASN1_TAG_CONTENT_SPECIFIC: return asn1_tag_index[tag & 0xe0];
|
case ASN1_TAG_CONTENT_SPECIFIC: return asn1_tag_index[tag & 0x1f];
|
||||||
case ASN1_TAG_APPLICATION: return "Application";
|
case ASN1_TAG_APPLICATION: return "Application";
|
||||||
case ASN1_TAG_PRIVATE: return "Private";
|
case ASN1_TAG_PRIVATE: return "Private";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -59,16 +59,18 @@ static void print_octets(const uint8_t *o, size_t olen)
|
|||||||
|
|
||||||
static int test_asn1_tag(void)
|
static int test_asn1_tag(void)
|
||||||
{
|
{
|
||||||
int i;
|
int tag;
|
||||||
format_print(stderr, 0, 0, "Tags:\n");
|
format_print(stderr, 0, 0, "Testing all tag values from 0 to 255:\n");
|
||||||
for (i = 1; i <= 13; i++) {
|
for (tag = 0; tag <= 255; tag++) {
|
||||||
format_print(stderr, 0, 4, "%s (0x%02x)\n", asn1_tag_name(i), i);
|
const char *name = asn1_tag_name(tag);
|
||||||
}
|
if (name) {
|
||||||
for (i = 18; i <= 30; i++) {
|
format_print(stderr, 0, 4, "%s (0x%02x)\n", name, tag);
|
||||||
format_print(stderr, 0, 4, "%s (0x%02x)\n", asn1_tag_name(i), i);
|
} else {
|
||||||
}
|
format_print(stderr, 0, 4, "Unknown Tag (0x%02x)\n", tag);
|
||||||
printf("%s() ok\n", __FUNCTION__);
|
}
|
||||||
return 1;
|
}
|
||||||
|
printf("%s() ok\n", __FUNCTION__);
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int test_asn1_length(void)
|
static int test_asn1_length(void)
|
||||||
|
|||||||
Reference in New Issue
Block a user