From: Jouni Malinen Date: Sat, 13 Mar 2021 21:02:44 +0000 (+0200) Subject: ASN.1: Add helper functions for debug printing identifier/length info X-Git-Tag: hostap_2_10~424 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f629bfe2253eb2fb944677926c59ee596e94c6fb;p=thirdparty%2Fhostap.git ASN.1: Add helper functions for debug printing identifier/length info These can be helpful in cleaning up implementation of more or less identical debug printing operations. Signed-off-by: Jouni Malinen --- diff --git a/src/tls/asn1.c b/src/tls/asn1.c index 2da7b4a33..ee9a3afdf 100644 --- a/src/tls/asn1.c +++ b/src/tls/asn1.c @@ -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; diff --git a/src/tls/asn1.h b/src/tls/asn1.h index 3d291617a..de3430adb 100644 --- a/src/tls/asn1.h +++ b/src/tls/asn1.h @@ -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);