Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

修正asn1的tag掩码。完善asn1的tag测试,使其覆盖所有可能值。 #1752

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/asn1.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const char *asn1_tag_name(int tag)
}

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_PRIVATE: return "Private";
}
Expand Down
22 changes: 12 additions & 10 deletions tests/asn1test.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,16 +59,18 @@ static void print_octets(const uint8_t *o, size_t olen)

static int test_asn1_tag(void)
{
int i;
format_print(stderr, 0, 0, "Tags:\n");
for (i = 1; i <= 13; i++) {
format_print(stderr, 0, 4, "%s (0x%02x)\n", asn1_tag_name(i), i);
}
for (i = 18; i <= 30; i++) {
format_print(stderr, 0, 4, "%s (0x%02x)\n", asn1_tag_name(i), i);
}
printf("%s() ok\n", __FUNCTION__);
return 1;
int tag;
format_print(stderr, 0, 0, "Testing all tag values from 0 to 255:\n");
for (tag = 0; tag <= 255; tag++) {
const char *name = asn1_tag_name(tag);
if (name) {
format_print(stderr, 0, 4, "%s (0x%02x)\n", name, tag);
} else {
format_print(stderr, 0, 4, "Unknown Tag (0x%02x)\n", tag);
}
}
printf("%s() ok\n", __FUNCTION__);
return 1;
}

static int test_asn1_length(void)
Expand Down