aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/asn1/asn1_str.cpp
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2017-11-14 17:30:05 -0500
committerJack Lloyd <[email protected]>2017-11-14 17:30:05 -0500
commit76fd273cadcdeebd6f9e0f79f47c21971088a37a (patch)
treee651320011374ba723e9983cc646e3ba21c09e7e /src/lib/asn1/asn1_str.cpp
parent6ff498730653d9837af32efaa5d4298d302cec73 (diff)
Consolidate function for testing for ASN.1 string types
Diffstat (limited to 'src/lib/asn1/asn1_str.cpp')
-rw-r--r--src/lib/asn1/asn1_str.cpp23
1 files changed, 15 insertions, 8 deletions
diff --git a/src/lib/asn1/asn1_str.cpp b/src/lib/asn1/asn1_str.cpp
index d90aa215b..8b9524de2 100644
--- a/src/lib/asn1/asn1_str.cpp
+++ b/src/lib/asn1/asn1_str.cpp
@@ -55,14 +55,7 @@ ASN1_Tag choose_encoding(const std::string& str)
void assert_is_string_type(ASN1_Tag tag)
{
- if(tag != NUMERIC_STRING &&
- tag != PRINTABLE_STRING &&
- tag != VISIBLE_STRING &&
- tag != T61_STRING &&
- tag != IA5_STRING &&
- tag != UTF8_STRING &&
- tag != BMP_STRING &&
- tag != UNIVERSAL_STRING)
+ if(!ASN1_String::is_string_type(tag))
{
throw Invalid_Argument("ASN1_String: Unknown string type " +
std::to_string(tag));
@@ -71,6 +64,20 @@ void assert_is_string_type(ASN1_Tag tag)
}
+//static
+bool ASN1_String::is_string_type(ASN1_Tag tag)
+ {
+ return (tag == NUMERIC_STRING ||
+ tag == PRINTABLE_STRING ||
+ tag == VISIBLE_STRING ||
+ tag == T61_STRING ||
+ tag == IA5_STRING ||
+ tag == UTF8_STRING ||
+ tag == BMP_STRING ||
+ tag == UNIVERSAL_STRING);
+ }
+
+
/*
* Create an ASN1_String
*/