Skip to content

Commit cba7122

Browse files
author
Hanno Becker
committed
ASN.1: Add helper macro to detect string types
1 parent 819799c commit cba7122

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

include/mbedtls/asn1.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,18 @@
9090
#define MBEDTLS_ASN1_CONSTRUCTED 0x20
9191
#define MBEDTLS_ASN1_CONTEXT_SPECIFIC 0x80
9292

93+
/* Slightly smaller way to check if tag is a string tag
94+
* compared to canonical implementation. */
95+
#define MBEDTLS_ASN1_IS_STRING_TAG( tag ) \
96+
( ( tag ) < 32u && ( \
97+
( ( 1u << ( tag ) ) & ( ( 1u << MBEDTLS_ASN1_BMP_STRING ) | \
98+
( 1u << MBEDTLS_ASN1_UTF8_STRING ) | \
99+
( 1u << MBEDTLS_ASN1_T61_STRING ) | \
100+
( 1u << MBEDTLS_ASN1_IA5_STRING ) | \
101+
( 1u << MBEDTLS_ASN1_UNIVERSAL_STRING ) | \
102+
( 1u << MBEDTLS_ASN1_PRINTABLE_STRING ) | \
103+
( 1u << MBEDTLS_ASN1_BIT_STRING ) ) ) != 0 ) )
104+
93105
/*
94106
* Bit masks for each of the components of an ASN.1 tag as specified in
95107
* ITU X.690 (08/2015), section 8.1 "General rules for encoding",

0 commit comments

Comments
 (0)