Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1610)

Unified Diff: net/base/x509_cert_types.h

Issue 11274032: Separate http_security_headers from transport_security_state (Closed) Base URL: https://src.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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();

Powered by Google App Engine
This is Rietveld 408576698