From c96c10ea2ac82d8255b8cb5ed9a8cd56117927c4 Mon Sep 17 00:00:00 2001 From: Dihambo <35786546+dihambo@users.noreply.github.com> Date: Fri, 27 Sep 2024 12:48:55 +0000 Subject: [PATCH 1/2] =?UTF-8?q?fix:=20tag=20mask=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/asn1.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/asn1.c b/src/asn1.c index affaee4e..e7453e14 100644 --- a/src/asn1.c +++ b/src/asn1.c @@ -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"; } From c0b0dfc855fece996ce4820e81347e98f3734c0c Mon Sep 17 00:00:00 2001 From: Dihambo <35786546+dihambo@users.noreply.github.com> Date: Fri, 27 Sep 2024 12:53:45 +0000 Subject: [PATCH 2/2] =?UTF-8?q?fix:=20=E8=A6=86=E7=9B=96=E6=89=80=E6=9C=89?= =?UTF-8?q?tag=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/asn1test.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/tests/asn1test.c b/tests/asn1test.c index 8bd69705..f1ca6b41 100644 --- a/tests/asn1test.c +++ b/tests/asn1test.c @@ -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)