]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
ASN.1: Add helper functions for debug printing identifier/length info
authorJouni Malinen <j@w1.fi>
Sat, 13 Mar 2021 21:02:44 +0000 (23:02 +0200)
committerJouni Malinen <j@w1.fi>
Sat, 13 Mar 2021 21:15:55 +0000 (23:15 +0200)
These can be helpful in cleaning up implementation of more or less
identical debug printing operations.

Signed-off-by: Jouni Malinen <j@w1.fi>
src/tls/asn1.c
src/tls/asn1.h

index 2da7b4a3339c8f98b7679876a4c41e2019b41fab..ee9a3afdf00afc24303893da1ffffc70e02db848 100644 (file)
@@ -207,6 +207,20 @@ int asn1_get_next(const u8 *buf, size_t len, struct asn1_hdr *hdr)
 }
 
 
+void asn1_print_hdr(const struct asn1_hdr *hdr, const char *title)
+{
+       wpa_printf(MSG_DEBUG, "%sclass %d constructed %d tag 0x%x",
+                  title, hdr->class, hdr->constructed, hdr->tag);
+}
+
+
+void asn1_unexpected(const struct asn1_hdr *hdr, const char *title)
+{
+       wpa_printf(MSG_DEBUG, "%s - found class %d constructed %d tag 0x%x",
+                  title, hdr->class, hdr->constructed, hdr->tag);
+}
+
+
 int asn1_parse_oid(const u8 *buf, size_t len, struct asn1_oid *oid)
 {
        const u8 *pos, *end;
index 3d291617af6be36f2d8ba084723b109fbebefd3c..de3430adbad92446936e4a6ecb289e92a61a74a5 100644 (file)
@@ -60,6 +60,8 @@ struct asn1_oid {
 
 
 int asn1_get_next(const u8 *buf, size_t len, struct asn1_hdr *hdr);
+void asn1_print_hdr(const struct asn1_hdr *hdr, const char *title);
+void asn1_unexpected(const struct asn1_hdr *hdr, const char *title);
 int asn1_parse_oid(const u8 *buf, size_t len, struct asn1_oid *oid);
 int asn1_get_oid(const u8 *buf, size_t len, struct asn1_oid *oid,
                 const u8 **next);