diff options
-rw-r--r-- | include/oids.h | 13 | ||||
-rw-r--r-- | src/if_algo.cpp | 3 | ||||
-rw-r--r-- | src/oids.cpp | 8 | ||||
-rw-r--r-- | src/x509cert.cpp | 14 | ||||
-rw-r--r-- | src/x509stat.cpp | 26 |
5 files changed, 40 insertions, 24 deletions
diff --git a/include/oids.h b/include/oids.h index edb3b2bd4..7b5f775c6 100644 --- a/include/oids.h +++ b/include/oids.h @@ -18,19 +18,16 @@ namespace OIDS { void add_oid(const OID&, const std::string&); /************************************************* -* Do an OID to string lookup * +* See if an OID exists in the internal table * *************************************************/ -std::string lookup(const OID&); +bool have_oid(const std::string&); /************************************************* -* Do a string to OID lookup * +* Perform OID<->string mappings * *************************************************/ +std::string lookup(const OID&); OID lookup(const std::string&); - -/************************************************* -* See if an OID exists in the internal table * -*************************************************/ -bool have_oid(const std::string&); +bool name_of(const OID&, const std::string&); } diff --git a/src/if_algo.cpp b/src/if_algo.cpp index afa428fde..5af691aa2 100644 --- a/src/if_algo.cpp +++ b/src/if_algo.cpp @@ -139,8 +139,7 @@ PKCS8_Decoder* IF_Scheme_PrivateKey::pkcs8_decoder() .end_cons(); if(version != 0) - throw Decoding_Error(key->algo_name() + - ": Unknown PKCS #1 key version"); + throw Decoding_Error("Unknown PKCS #1 key format version"); key->PKCS8_load_hook(); } diff --git a/src/oids.cpp b/src/oids.cpp index 6b96b3656..92a89bbb6 100644 --- a/src/oids.cpp +++ b/src/oids.cpp @@ -53,6 +53,14 @@ bool have_oid(const std::string& name) return global_config().is_set("str2oid", name); } +/************************************************* +* Check to see if an OID exists in the table * +*************************************************/ +bool name_of(const OID& oid, const std::string& name) + { + return (oid == lookup(name)); + } + } } diff --git a/src/x509cert.cpp b/src/x509cert.cpp index 4a1152cf5..8696404fa 100644 --- a/src/x509cert.cpp +++ b/src/x509cert.cpp @@ -335,14 +335,22 @@ AlternativeName create_alt_name(const Data_Store& info) public: bool operator()(const std::string& key, const std::string&) const { - if(key == "RFC882" || key == "DNS" || key == "URI") - return true; + for(u32bit j = 0; j != matches.size(); j++) + if(key.compare(matches[j]) == 0) + return true; return false; } + + AltName_Matcher(const std::string& match_any_of) + { + matches = split_on(match_any_of, '/'); + } + private: + std::vector<std::string> matches; }; std::multimap<std::string, std::string> names - = info.search_with(AltName_Matcher()); + = info.search_with(AltName_Matcher("RFC882/DNS/URI")); AlternativeName alt_name; diff --git a/src/x509stat.cpp b/src/x509stat.cpp index 3ea431962..059e43414 100644 --- a/src/x509stat.cpp +++ b/src/x509stat.cpp @@ -34,17 +34,21 @@ Certificate_Extension* X509_GlobalState::get_extension(const OID& oid) const *************************************************/ X509_GlobalState::X509_GlobalState() { -#define CREATE_PROTOTYPE(NAME, TYPE) \ - struct TYPE ## _Prototype : public Extension_Prototype \ - { \ - Certificate_Extension* make(const OID& oid) \ - { \ - if(oid == OIDS::lookup(NAME)) \ - return new Cert_Extension::TYPE(); \ - return 0; \ - } \ - }; \ - add(new TYPE ## _Prototype); + +#define CREATE_PROTOTYPE(NAME, TYPE) \ + do { \ + struct TYPE ## _Prototype : public Extension_Prototype \ + { \ + Certificate_Extension* make(const OID& oid) \ + { \ + if(OIDS::name_of(oid, NAME)) \ + return new Cert_Extension::TYPE(); \ + return 0; \ + } \ + }; \ + \ + add(new TYPE ## _Prototype); \ + } while(0); CREATE_PROTOTYPE("X509v3.KeyUsage", Key_Usage); CREATE_PROTOTYPE("X509v3.BasicConstraints", Basic_Constraints); |