Index: net/base/x509_cert_types.h |
=================================================================== |
--- net/base/x509_cert_types.h (revision 164213) |
+++ net/base/x509_cert_types.h (working copy) |
@@ -75,6 +75,11 @@ |
HashValue() : tag(HASH_VALUE_SHA1) {} |
bool Equals(const HashValue& other) const; |
+ |
+ // Parse/write in this format: "sha1/Guzek9lMwR3KeIS8wwS9gBvVtIg=" |
+ bool ParseBase64String(const std::string& input); |
+ std::string WriteBase64String() const; |
+ |
size_t size() const; |
unsigned char* data(); |
const unsigned char* data() const; |
@@ -88,18 +93,16 @@ |
} fingerprint; |
}; |
-class NET_EXPORT HashValueLessThan { |
- public: |
- bool operator()(const HashValue& lhs, |
- const HashValue& rhs) const { |
- size_t lhs_size = lhs.size(); |
- size_t rhs_size = rhs.size(); |
+class NET_EXPORT HashValuesEqual { |
+ public: |
+ explicit HashValuesEqual(const HashValue& fingerprint) : |
+ fingerprint_(fingerprint) {} |
- if (lhs_size != rhs_size) |
- return lhs_size < rhs_size; |
+ bool operator()(const HashValue& other) const { |
+ return fingerprint_.Equals(other); |
+ } |
- return memcmp(lhs.data(), rhs.data(), lhs_size) < 0; |
- } |
+ const HashValue& fingerprint_; |
}; |
typedef std::vector<HashValue> HashValueVector; |
@@ -110,6 +113,20 @@ |
const uint8* array, |
size_t array_byte_len); |
+// Returns true if the intersection of |a| and |b| is not empty. If either |
+// |a| or |b| is empty, returns false. |
+bool NET_EXPORT HashesIntersect(const HashValueVector& a, |
+ const HashValueVector& b); |
+ |
+// Convert between HashValueVector and comma-separated string format: |
+// "sha1/Guzek9lMwR3KeIS8wwS9gBvVtIg=,sha256/U8Sg... |
+// A correct input string returns true, with hashes populated |
+// An empty input string returns true, with hashes cleared |
+// An incorrect input string returns false, with hashes cleared |
+std::string NET_EXPORT HashesToBase64String(const HashValueVector& hashes); |
+bool NET_EXPORT Base64StringToHashes(const std::string& hashes_str, |
+ HashValueVector* hashes); |
+ |
// CertPrincipal represents the issuer or subject field of an X.509 certificate. |
struct NET_EXPORT CertPrincipal { |
CertPrincipal(); |