From 6ed72be9850bc59df02b0ec19ce44cfabc805656 Mon Sep 17 00:00:00 2001 From: "unsafe@trevp.net" Date: Tue, 8 Jan 2013 22:07:33 +0000 Subject: This is the first in an intended sequence of CLs to refactor TransportSecurityState, fix some book-keeping bugs, and hopefully add TACK. This sequence of CLs will be derived from the original, overly-large CL #11191005. This CL does a few things: - Adds a high-level API for processing HSTS/HPKP - Move the code for handling HSTS/HPKP headers out of transport_security_state - Move HashValue out of x509_cert_types - Addresses several HSTS/HPKP parsing bugs identified during review of the cleanup - Ignore unknown HSTS/HPKP directives - Ignore unknown hash algorithms - Handle overly-large (> int64) expirations without parsing issues - Reject invalid pins entered by users Review URL: https://chromiumcodereview.appspot.com/11274032 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@175595 0039d316-1c4b-4281-b951-d872f2087c98 --- chrome/browser/net/transport_security_persister.cc | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) (limited to 'chrome/browser/net/transport_security_persister.cc') diff --git a/chrome/browser/net/transport_security_persister.cc b/chrome/browser/net/transport_security_persister.cc index 7e80742..b288e21 100644 --- a/chrome/browser/net/transport_security_persister.cc +++ b/chrome/browser/net/transport_security_persister.cc @@ -29,16 +29,8 @@ namespace { ListValue* SPKIHashesToListValue(const HashValueVector& hashes) { ListValue* pins = new ListValue; - - for (HashValueVector::const_iterator i = hashes.begin(); - i != hashes.end(); ++i) { - std::string hash_str(reinterpret_cast(i->data()), i->size()); - std::string b64; - if (base::Base64Encode(hash_str, &b64)) - pins->Append(new StringValue(TransportSecurityState::HashValueLabel(*i) + - b64)); - } - + for (size_t i = 0; i != hashes.size(); i++) + pins->Append(new StringValue(hashes[i].ToString())); return pins; } @@ -48,7 +40,7 @@ void SPKIHashesFromListValue(const ListValue& pins, HashValueVector* hashes) { std::string type_and_base64; HashValue fingerprint; if (pins.GetString(i, &type_and_base64) && - TransportSecurityState::ParsePin(type_and_base64, &fingerprint)) { + fingerprint.FromString(type_and_base64)) { hashes->push_back(fingerprint); } } -- cgit v1.1