From df31111d6db8f7a2a494511036701b583d2c8340 Mon Sep 17 00:00:00 2001 From: Jack Lloyd Date: Sun, 4 Aug 2019 08:34:34 -0400 Subject: Remove unnecessary functions --- src/lib/asn1/asn1_oid.cpp | 12 +++++++++--- src/lib/asn1/oids.cpp | 16 ---------------- src/lib/asn1/oids.h | 9 +++------ src/tests/test_oid.cpp | 2 ++ 4 files changed, 14 insertions(+), 25 deletions(-) (limited to 'src') diff --git a/src/lib/asn1/asn1_oid.cpp b/src/lib/asn1/asn1_oid.cpp index bf3e2515b..ca5006232 100644 --- a/src/lib/asn1/asn1_oid.cpp +++ b/src/lib/asn1/asn1_oid.cpp @@ -67,10 +67,13 @@ OID OID::from_string(const std::string& str) // first try as a dotted decimal OID string: std::vector raw = parse_oid_str(str); - if(raw.empty() == false) + if(raw.size() > 0) return OID(std::move(raw)); - return OIDS::str2oid_or_throw(str); + const OID o = OIDS::str2oid_or_empty(name); + if(o.empty()) + throw Lookup_Error("No OID associated with name " + name); + return o; } /* @@ -106,7 +109,10 @@ std::string OID::to_string() const std::string OID::to_formatted_string() const { - return OIDS::oid2str_or_raw(*this); + const std::string s = OIDS::oid2str_or_empty(oid); + if(!s.empty()) + return s; + return this->to_string(); } /* diff --git a/src/lib/asn1/oids.cpp b/src/lib/asn1/oids.cpp index 8eae538a1..bece7a9b4 100644 --- a/src/lib/asn1/oids.cpp +++ b/src/lib/asn1/oids.cpp @@ -126,22 +126,6 @@ std::string OIDS::oid2str_or_throw(const OID& oid) return s; } -std::string OIDS::oid2str_or_raw(const OID& oid) - { - const std::string s = OIDS::oid2str_or_empty(oid); - if(s.empty()) - return oid.to_string(); - return s; - } - -OID OIDS::str2oid_or_throw(const std::string& name) - { - const OID o = OIDS::str2oid_or_empty(name); - if(o.empty()) - throw Lookup_Error("No OID associated with name " + name); - return o; - } - bool OIDS::have_oid(const std::string& name) { return OID_Map::global_registry().have_oid(name); diff --git a/src/lib/asn1/oids.h b/src/lib/asn1/oids.h index 167d9ade7..480e4f982 100644 --- a/src/lib/asn1/oids.h +++ b/src/lib/asn1/oids.h @@ -46,16 +46,13 @@ BOTAN_UNSTABLE_API std::string oid2str_or_empty(const OID& oid); BOTAN_UNSTABLE_API OID str2oid_or_empty(const std::string& name); BOTAN_UNSTABLE_API std::string oid2str_or_throw(const OID& oid); -BOTAN_UNSTABLE_API OID str2oid_or_throw(const std::string& name); - -BOTAN_UNSTABLE_API std::string oid2str_or_raw(const OID& oid); /** * See if an OID exists in the internal table. * @param oid the oid to check for * @return true if the oid is registered */ -BOTAN_UNSTABLE_API bool have_oid(const std::string& oid); +BOTAN_UNSTABLE_API bool BOTAN_DEPRECATED("Just lookup the value instead") have_oid(const std::string& oid); /** * Tests whether the specified OID stands for the specified name. @@ -63,9 +60,9 @@ BOTAN_UNSTABLE_API bool have_oid(const std::string& oid); * @param name the name to check * @return true if the specified OID stands for the specified name */ -inline bool BOTAN_DEPRECATED("Use oid == str2oid_or_throw(name)") name_of(const OID& oid, const std::string& name) +inline bool BOTAN_DEPRECATED("Use oid == OID::from_string(name)") name_of(const OID& oid, const std::string& name) { - return (oid == str2oid_or_throw(name)); + return (oid == str2oid_or_empty(name)); } inline std::string BOTAN_DEPRECATED("Use oid2str_or_empty") lookup(const OID& oid) diff --git a/src/tests/test_oid.cpp b/src/tests/test_oid.cpp index b8c6d5d7f..9ab1ad440 100644 --- a/src/tests/test_oid.cpp +++ b/src/tests/test_oid.cpp @@ -4,6 +4,8 @@ * Botan is released under the Simplified BSD License (see license.txt) */ +#define BOTAN_NO_DEPRECATED_WARNINGS + #include "tests.h" #if defined(BOTAN_HAS_ASN1) -- cgit v1.2.3