aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorlloyd <[email protected]>2010-09-20 22:19:33 +0000
committerlloyd <[email protected]>2010-09-20 22:19:33 +0000
commit911c0f587ba21c944cb420f9953ffc5e2bac7fb2 (patch)
treefdb3c081fc4dc9ac12841759e866be6c83940e4a /src
parent7e0f39425ef8194ed9cc5b90943b5665a60ae437 (diff)
Remove searching with an arbitrary predicate from X509_Store
Diffstat (limited to 'src')
-rw-r--r--src/cert/x509store/x509find.cpp111
-rw-r--r--src/cert/x509store/x509find.h60
-rw-r--r--src/cert/x509store/x509stor.cpp15
-rw-r--r--src/cert/x509store/x509stor.h11
4 files changed, 0 insertions, 197 deletions
diff --git a/src/cert/x509store/x509find.cpp b/src/cert/x509store/x509find.cpp
deleted file mode 100644
index 257367da9..000000000
--- a/src/cert/x509store/x509find.cpp
+++ /dev/null
@@ -1,111 +0,0 @@
-/*
-* X.509 Certificate Store Searching
-* (C) 1999-2007 Jack Lloyd
-*
-* Distributed under the terms of the Botan license
-*/
-
-#include <botan/x509find.h>
-#include <botan/charset.h>
-#include <algorithm>
-
-namespace Botan {
-
-namespace {
-
-/*
-* Compare based on case-insensive substrings
-*/
-bool substring_match(const std::string& searching_for,
- const std::string& found)
- {
- if(std::search(found.begin(), found.end(), searching_for.begin(),
- searching_for.end(), Charset::caseless_cmp) != found.end())
- return true;
- return false;
- }
-
-/*
-* Compare based on case-insensive match
-*/
-bool ignore_case(const std::string& searching_for, const std::string& found)
- {
- if(searching_for.size() != found.size())
- return false;
-
- return std::equal(found.begin(), found.end(),
- searching_for.begin(), Charset::caseless_cmp);
- }
-
-}
-
-/*
-* Search based on the contents of a DN entry
-*/
-bool DN_Check::match(const X509_Certificate& cert) const
- {
- std::vector<std::string> info = cert.subject_info(dn_entry);
-
- for(u32bit j = 0; j != info.size(); ++j)
- if(compare(info[j], looking_for))
- return true;
- return false;
- }
-
-/*
-* DN_Check Constructor
-*/
-DN_Check::DN_Check(const std::string& dn_entry, const std::string& looking_for,
- compare_fn func)
- {
- this->dn_entry = dn_entry;
- this->looking_for = looking_for;
- compare = func;
- }
-
-/*
-* DN_Check Constructor
-*/
-DN_Check::DN_Check(const std::string& dn_entry, const std::string& looking_for,
- Search_Type method)
- {
- this->dn_entry = dn_entry;
- this->looking_for = looking_for;
-
- if(method == SUBSTRING_MATCHING)
- compare = &substring_match;
- else if(method == IGNORE_CASE)
- compare = &ignore_case;
- else
- throw Invalid_Argument("Unknown method argument to DN_Check()");
- }
-
-/*
-* Match by issuer and serial number
-*/
-bool IandS_Match::match(const X509_Certificate& cert) const
- {
- if(cert.serial_number() != serial)
- return false;
- return (cert.issuer_dn() == issuer);
- }
-
-/*
-* IandS_Match Constructor
-*/
-IandS_Match::IandS_Match(const X509_DN& issuer,
- const MemoryRegion<byte>& serial)
- {
- this->issuer = issuer;
- this->serial = serial;
- }
-
-/*
-* Match by subject key identifier
-*/
-bool SKID_Match::match(const X509_Certificate& cert) const
- {
- return (cert.subject_key_id() == skid);
- }
-
-}
diff --git a/src/cert/x509store/x509find.h b/src/cert/x509store/x509find.h
deleted file mode 100644
index 5624b717b..000000000
--- a/src/cert/x509store/x509find.h
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
-* X.509 Certificate Store Searching
-* (C) 1999-2007 Jack Lloyd
-*
-* Distributed under the terms of the Botan license
-*/
-
-#ifndef BOTAN_X509_CERT_STORE_SEARCH_H__
-#define BOTAN_X509_CERT_STORE_SEARCH_H__
-
-#include <botan/x509stor.h>
-
-namespace Botan {
-
-/**
-* Search based on the contents of a DN entry
-*/
-class BOTAN_DLL DN_Check : public X509_Store::Search_Func
- {
- public:
- typedef bool (*compare_fn)(const std::string&, const std::string&);
- enum Search_Type { SUBSTRING_MATCHING, IGNORE_CASE };
-
- bool match(const X509_Certificate& cert) const;
-
- DN_Check(const std::string&, const std::string&, compare_fn);
- DN_Check(const std::string&, const std::string&, Search_Type);
- private:
- std::string dn_entry, looking_for;
- compare_fn compare;
- };
-
-/**
-* Search for a certificate by issuer/serial
-*/
-class BOTAN_DLL IandS_Match : public X509_Store::Search_Func
- {
- public:
- bool match(const X509_Certificate& cert) const;
- IandS_Match(const X509_DN&, const MemoryRegion<byte>&);
- private:
- X509_DN issuer;
- MemoryVector<byte> serial;
- };
-
-/**
-* Search for a certificate by subject keyid
-*/
-class BOTAN_DLL SKID_Match : public X509_Store::Search_Func
- {
- public:
- bool match(const X509_Certificate& cert) const;
- SKID_Match(const MemoryRegion<byte>& s) : skid(s) {}
- private:
- MemoryVector<byte> skid;
- };
-
-}
-
-#endif
diff --git a/src/cert/x509store/x509stor.cpp b/src/cert/x509store/x509stor.cpp
index 6ae473aaa..f96ba99dc 100644
--- a/src/cert/x509store/x509stor.cpp
+++ b/src/cert/x509store/x509stor.cpp
@@ -441,21 +441,6 @@ bool X509_Store::is_revoked(const X509_Certificate& cert) const
}
/*
-* Retrieve all the certificates in the store
-*/
-std::vector<X509_Certificate>
-X509_Store::get_certs(const Search_Func& search) const
- {
- std::vector<X509_Certificate> found_certs;
- for(u32bit j = 0; j != certs.size(); ++j)
- {
- if(search.match(certs[j].cert))
- found_certs.push_back(certs[j].cert);
- }
- return found_certs;
- }
-
-/*
* Construct a path back to a root for this cert
*/
std::vector<X509_Certificate>
diff --git a/src/cert/x509store/x509stor.h b/src/cert/x509store/x509stor.h
index c5445f808..186c59b4b 100644
--- a/src/cert/x509store/x509stor.h
+++ b/src/cert/x509store/x509stor.h
@@ -48,16 +48,6 @@ enum X509_Code {
class BOTAN_DLL X509_Store
{
public:
- /**
- * A callback for searching the store
- */
- class BOTAN_DLL Search_Func
- {
- public:
- virtual bool match(const X509_Certificate&) const = 0;
- virtual ~Search_Func() {}
- };
-
enum Cert_Usage {
ANY = 0x00,
TLS_SERVER = 0x01,
@@ -70,7 +60,6 @@ class BOTAN_DLL X509_Store
X509_Code validate_cert(const X509_Certificate&, Cert_Usage = ANY);
- std::vector<X509_Certificate> get_certs(const Search_Func&) const;
std::vector<X509_Certificate> get_cert_chain(const X509_Certificate&);
std::string PEM_encode() const;