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

Unified Diff: net/cert/x509_certificate_win.cc

Issue 547603002: Certificate Transparency: Code for unpacking EV cert hashes whitelist (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Avoiding globals in favour of passing the SSLConfigService around Created 6 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
Index: net/cert/x509_certificate_win.cc
diff --git a/net/cert/x509_certificate_win.cc b/net/cert/x509_certificate_win.cc
index ab92b6f2a628fcc10185274291d2f9c353ae346f..44d8b222db31381549a6c963387e73eb4b53abe9 100644
--- a/net/cert/x509_certificate_win.cc
+++ b/net/cert/x509_certificate_win.cc
@@ -14,6 +14,7 @@
#include "base/strings/utf_string_conversions.h"
#include "crypto/capi_util.h"
#include "crypto/scoped_capi_types.h"
+#include "crypto/sha2.h"
#include "net/base/net_errors.h"
#pragma comment(lib, "crypt32.lib")
@@ -315,6 +316,24 @@ SHA1HashValue X509Certificate::CalculateFingerprint(
return sha1;
}
+// static
+SHA256HashValue X509Certificate::CalculateFingerprint256(OSCertHandle cert) {
+ DCHECK(NULL != cert->pbCertEncoded);
+ DCHECK_NE(static_cast<DWORD>(0), cert->cbCertEncoded);
Ryan Sleevi 2014/10/01 20:15:43 just use 0u ?
Eran Messeri 2014/10/03 12:00:11 Done.
+
+ SHA256HashValue sha256;
+ DWORD sha256_size = sizeof(sha256.data);
Ryan Sleevi 2014/10/01 20:15:43 No longer the correct type now, is it?
Eran Messeri 2014/10/03 12:00:11 Done.
+
+ // Use crypto::SHA256HashString for two reasons:
+ // * < Windows Vista does not have universal SHA-256 support.
+ // * More efficient on Windows > Vista (less overhead since non-default CSP
+ // is not needed).
+ base::StringPiece der_cert(reinterpret_cast<const char*>(cert->pbCertEncoded),
+ cert->cbCertEncoded);
+ crypto::SHA256HashString(der_cert, sha256.data, sha256_size);
+ return sha256;
+}
+
// TODO(wtc): This function is implemented with NSS low-level hash
// functions to ensure it is fast. Reimplement this function with
// CryptoAPI. May need to cache the HCRYPTPROV to reduce the overhead.

Powered by Google App Engine
This is Rietveld 408576698