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

Unified Diff: net/base/x509_cert_types.cc

Issue 10826257: Implement SHA-256 fingerprint support (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 3 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
« no previous file with comments | « net/base/x509_cert_types.h ('k') | net/base/x509_certificate.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/base/x509_cert_types.cc
===================================================================
--- net/base/x509_cert_types.cc (revision 155029)
+++ net/base/x509_cert_types.cc (working copy)
@@ -38,7 +38,7 @@
} // namespace
// static
-bool IsSHA1HashInSortedArray(const SHA1Fingerprint& hash,
+bool IsSHA1HashInSortedArray(const SHA1HashValue& hash,
const uint8* array,
size_t array_byte_len) {
DCHECK_EQ(0u, array_byte_len % base::kSHA1Length);
@@ -143,4 +143,52 @@
return true;
}
+bool HashValue::Equals(const HashValue& other) const {
+ if (tag != other.tag)
+ return false;
+ switch (tag) {
+ case HASH_VALUE_SHA1:
+ return fingerprint.sha1.Equals(other.fingerprint.sha1);
+ case HASH_VALUE_SHA256:
+ return fingerprint.sha256.Equals(other.fingerprint.sha256);
+ default:
+ NOTREACHED() << "Unknown HashValueTag " << tag;
+ return false;
+ }
+}
+
+size_t HashValue::size() const {
+ switch (tag) {
+ case HASH_VALUE_SHA1:
+ return sizeof(fingerprint.sha1.data);
+ case HASH_VALUE_SHA256:
+ return sizeof(fingerprint.sha256.data);
+ default:
+ NOTREACHED() << "Unknown HashValueTag " << tag;
+ // Although this is NOTREACHED, this function might be inlined and its
+ // return value can be passed to memset as the length argument. If we
+ // returned 0 here, it might result in what appears (in some stages of
+ // compilation) to be a call to to memset with a length argument of 0,
+ // which results in a warning. Therefore, we return a dummy value
+ // here.
+ return sizeof(fingerprint.sha1.data);
+ }
+}
+
+unsigned char* HashValue::data() {
+ return const_cast<unsigned char*>(const_cast<const HashValue*>(this)->data());
+}
+
+const unsigned char* HashValue::data() const {
+ switch (tag) {
+ case HASH_VALUE_SHA1:
+ return fingerprint.sha1.data;
+ case HASH_VALUE_SHA256:
+ return fingerprint.sha256.data;
+ default:
+ NOTREACHED() << "Unknown HashValueTag " << tag;
+ return NULL;
+ }
+}
+
} // namespace net
« no previous file with comments | « net/base/x509_cert_types.h ('k') | net/base/x509_certificate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698