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

Unified Diff: net/cert/x509_certificate_win.cc

Issue 687833002: Get net_unittests working on Windows BoringSSL port. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@wincrypt
Patch Set: Created 6 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
« no previous file with comments | « net/cert/sha256_legacy_support_win.cc ('k') | net/net.gyp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/cert/x509_certificate_win.cc
diff --git a/net/cert/x509_certificate_win.cc b/net/cert/x509_certificate_win.cc
index df263d8fa90838d9af5fb7db8e72b0eed0ee8f30..949f9c2e9d42c88f416280ce7c3100dfe55c2859 100644
--- a/net/cert/x509_certificate_win.cc
+++ b/net/cert/x509_certificate_win.cc
@@ -4,8 +4,6 @@
#include "net/cert/x509_certificate.h"
-#include <blapi.h> // Implement CalculateChainFingerprint() with NSS.
-
#include "base/logging.h"
#include "base/memory/scoped_ptr.h"
#include "base/pickle.h"
@@ -17,6 +15,13 @@
#include "crypto/sha2.h"
#include "net/base/net_errors.h"
+// Implement CalculateChainFingerprint() with our native crypto library.
+#if defined(USE_OPENSSL)
+#include <openssl/sha.h>
+#else
+#include <blapi.h>
+#endif
+
#pragma comment(lib, "crypt32.lib")
using base::Time;
@@ -334,8 +339,8 @@ SHA256HashValue X509Certificate::CalculateFingerprint256(OSCertHandle cert) {
return sha256;
}
-// TODO(wtc): This function is implemented with NSS low-level hash
-// functions to ensure it is fast. Reimplement this function with
+// TODO(wtc): This function is implemented with low-level NSS and BoringSSL
+// hash functions to ensure it is fast. Reimplement this function with
// CryptoAPI. May need to cache the HCRYPTPROV to reduce the overhead.
// static
Ryan Sleevi 2014/10/29 20:47:59 Remove this comment entirely. Not gonna happen.
davidben 2014/10/29 23:04:58 Done.
SHA1HashValue X509Certificate::CalculateCAFingerprint(
@@ -343,6 +348,17 @@ SHA1HashValue X509Certificate::CalculateCAFingerprint(
SHA1HashValue sha1;
memset(sha1.data, 0, sizeof(sha1.data));
+#if defined(USE_OPENSSL)
+ SHA_CTX ctx;
+ if (!SHA1_Init(&ctx))
+ return sha1;
+ for (size_t i = 0; i < intermediates.size(); ++i) {
+ PCCERT_CONTEXT ca_cert = intermediates[i];
+ if (!SHA1_Update(&ctx, ca_cert->pbCertEncoded, ca_cert->cbCertEncoded))
+ return sha1;
+ }
+ SHA1_Final(sha1.data, &ctx);
+#else // !USE_OPENSSL
SHA1Context* sha1_ctx = SHA1_NewContext();
if (!sha1_ctx)
return sha1;
@@ -354,6 +370,7 @@ SHA1HashValue X509Certificate::CalculateCAFingerprint(
unsigned int result_len;
SHA1_End(sha1_ctx, sha1.data, &result_len, SHA1_LENGTH);
SHA1_DestroyContext(sha1_ctx, PR_TRUE);
+#endif // USE_OPENSSL
return sha1;
}
« no previous file with comments | « net/cert/sha256_legacy_support_win.cc ('k') | net/net.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698