aboutsummaryrefslogtreecommitdiffstats
path: root/src/cert/x509cert
diff options
context:
space:
mode:
authorlloyd <[email protected]>2012-01-03 14:18:03 +0000
committerlloyd <[email protected]>2012-01-03 14:18:03 +0000
commit5c00cc7305718fe209757142f7a43b711cccd8f9 (patch)
tree560b225a66b06682d16182c5f0c57988242c8d48 /src/cert/x509cert
parent52868a93300a3b7e8666c49ccc786e6dba66438e (diff)
Add Credentials_Manager which is an interface to something that knows
what certs, keys, etc are available to the app. Needs polishing but it seems like it should be sound.
Diffstat (limited to 'src/cert/x509cert')
-rw-r--r--src/cert/x509cert/x509cert.cpp18
-rw-r--r--src/cert/x509cert/x509cert.h6
2 files changed, 24 insertions, 0 deletions
diff --git a/src/cert/x509cert/x509cert.cpp b/src/cert/x509cert/x509cert.cpp
index 7d9370f2a..88aeebd77 100644
--- a/src/cert/x509cert/x509cert.cpp
+++ b/src/cert/x509cert/x509cert.cpp
@@ -296,6 +296,24 @@ bool X509_Certificate::operator==(const X509_Certificate& other) const
subject == other.subject);
}
+bool X509_Certificate::operator<(const X509_Certificate& other) const
+ {
+ /* If signature values are not equal, sort by lexicographic ordering of that */
+ if(sig != other.sig)
+ {
+ if(sig < other.sig)
+ return true;
+ return false;
+ }
+
+ /*
+ * same signatures, highly unlikely case, revert to compare
+ * of entire contents
+ */
+
+ return to_string() < other.to_string();
+ }
+
/*
* X.509 Certificate Comparison
*/
diff --git a/src/cert/x509cert/x509cert.h b/src/cert/x509cert/x509cert.h
index 8798ef1c2..cd49aa02f 100644
--- a/src/cert/x509cert/x509cert.h
+++ b/src/cert/x509cert/x509cert.h
@@ -152,6 +152,12 @@ class BOTAN_DLL X509_Certificate : public X509_Object
bool operator==(const X509_Certificate& other) const;
/**
+ * Impose an arbitrary (but consistent) ordering
+ * @return true if this is less than other by some unspecified criteria
+ */
+ bool operator<(const X509_Certificate& other) const;
+
+ /**
* Create a certificate from a data source providing the DER or
* PEM encoded certificate.
* @param source the data source