diff options
author | davidben <davidben@chromium.org> | 2014-10-29 17:39:38 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-10-30 00:40:05 +0000 |
commit | c6ac2609dd032e468440cd4f7f86770b4cb9774d (patch) | |
tree | 629420f416f2b4c183a5aa3048b040b5919c7ffc | |
parent | 6fdf39c8fcf627270840b321cf329d53ab7261d1 (diff) | |
download | chromium_src-c6ac2609dd032e468440cd4f7f86770b4cb9774d.zip chromium_src-c6ac2609dd032e468440cd4f7f86770b4cb9774d.tar.gz chromium_src-c6ac2609dd032e468440cd4f7f86770b4cb9774d.tar.bz2 |
Add crypto/wincrypt_shim.h wrapper header to resolve BoringSSL conflicts.
wincrypt.h defines macros that conflict with BoringSSL. Introduce a
crypto/wincrypt_shim.h wrapper header which #undefs those macros and
instead #defines replacement ones. All Chromium headers should
use this wrapper header.
BUG=338884
Review URL: https://codereview.chromium.org/686883002
Cr-Commit-Position: refs/heads/master@{#301994}
-rw-r--r-- | chrome/app/signature_validator_win.cc | 2 | ||||
-rw-r--r-- | chrome/app/signature_validator_win_unittest.cc | 2 | ||||
-rw-r--r-- | chrome/browser/password_manager/password_store_win_unittest.cc | 3 | ||||
-rw-r--r-- | components/os_crypt/ie7_password_win.cc | 2 | ||||
-rw-r--r-- | components/os_crypt/os_crypt_win.cc | 2 | ||||
-rw-r--r-- | crypto/capi_util.h | 2 | ||||
-rw-r--r-- | crypto/crypto.gypi | 1 | ||||
-rw-r--r-- | crypto/hmac_win.cc | 2 | ||||
-rw-r--r-- | crypto/scoped_capi_types.h | 2 | ||||
-rw-r--r-- | crypto/wincrypt_shim.h | 25 | ||||
-rw-r--r-- | net/base/keygen_handler_win.cc | 6 | ||||
-rw-r--r-- | net/cert/cert_database_win.cc | 5 | ||||
-rw-r--r-- | net/cert/cert_verify_proc_win.cc | 2 | ||||
-rw-r--r-- | net/cert/sha256_legacy_support_win.cc | 3 | ||||
-rw-r--r-- | net/cert/sha256_legacy_support_win.h | 2 | ||||
-rw-r--r-- | net/cert/test_root_certs.h | 2 | ||||
-rw-r--r-- | net/cert/test_root_certs_win.cc | 3 | ||||
-rw-r--r-- | net/cert/x509_cert_types_win.cc | 4 | ||||
-rw-r--r-- | net/cert/x509_certificate.h | 3 | ||||
-rw-r--r-- | net/ssl/client_cert_store_win.cc | 2 | ||||
-rw-r--r-- | net/test/spawned_test_server/local_test_server_win.cc | 3 |
21 files changed, 48 insertions, 30 deletions
diff --git a/chrome/app/signature_validator_win.cc b/chrome/app/signature_validator_win.cc index 75efe25..e64446d 100644 --- a/chrome/app/signature_validator_win.cc +++ b/chrome/app/signature_validator_win.cc @@ -6,7 +6,6 @@ #include <atlstr.h> #include <softpub.h> -#include <wincrypt.h> #include <windows.h> #include <wintrust.h> @@ -19,6 +18,7 @@ #include "base/time/time.h" #include "base/win/scoped_handle.h" #include "crypto/sha2.h" +#include "crypto/wincrypt_shim.h" namespace { diff --git a/chrome/app/signature_validator_win_unittest.cc b/chrome/app/signature_validator_win_unittest.cc index 7e0b961..89cbda4 100644 --- a/chrome/app/signature_validator_win_unittest.cc +++ b/chrome/app/signature_validator_win_unittest.cc @@ -4,7 +4,6 @@ #include <windows.h> #include <atlstr.h> -#include <wincrypt.h> #include <wintrust.h> #include "base/base_paths.h" @@ -19,6 +18,7 @@ #include "base/strings/string_util.h" #include "chrome/app/signature_validator_win.h" #include "crypto/sha2.h" +#include "crypto/wincrypt_shim.h" #include "net/cert/test_root_certs.h" #include "testing/gtest/include/gtest/gtest.h" diff --git a/chrome/browser/password_manager/password_store_win_unittest.cc b/chrome/browser/password_manager/password_store_win_unittest.cc index c4a4033..364f89b 100644 --- a/chrome/browser/password_manager/password_store_win_unittest.cc +++ b/chrome/browser/password_manager/password_store_win_unittest.cc @@ -3,7 +3,7 @@ // found in the LICENSE file. #include <windows.h> -#include <wincrypt.h> + #include <string> #include <vector> @@ -26,6 +26,7 @@ #include "components/password_manager/core/common/password_manager_pref_names.h" #include "components/webdata/common/web_database_service.h" #include "content/public/test/test_browser_thread.h" +#include "crypto/wincrypt_shim.h" #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h" diff --git a/components/os_crypt/ie7_password_win.cc b/components/os_crypt/ie7_password_win.cc index ef7fbd5..9bb3225 100644 --- a/components/os_crypt/ie7_password_win.cc +++ b/components/os_crypt/ie7_password_win.cc @@ -4,7 +4,6 @@ #include "components/os_crypt/ie7_password_win.h" -#include <wincrypt.h> #include <string> #include <vector> @@ -12,6 +11,7 @@ #include "base/sha1.h" #include "base/strings/string_util.h" #include "base/strings/stringprintf.h" +#include "crypto/wincrypt_shim.h" namespace { diff --git a/components/os_crypt/os_crypt_win.cc b/components/os_crypt/os_crypt_win.cc index 1f4e749..bbed441 100644 --- a/components/os_crypt/os_crypt_win.cc +++ b/components/os_crypt/os_crypt_win.cc @@ -5,9 +5,9 @@ #include "components/os_crypt/os_crypt.h" #include <windows.h> -#include <wincrypt.h> #include "base/strings/utf_string_conversions.h" +#include "crypto/wincrypt_shim.h" #pragma comment(lib, "crypt32.lib") diff --git a/crypto/capi_util.h b/crypto/capi_util.h index 09a44e7..9d43293 100644 --- a/crypto/capi_util.h +++ b/crypto/capi_util.h @@ -6,9 +6,9 @@ #define CRYPTO_CAPI_UTIL_H_ #include <windows.h> -#include <wincrypt.h> #include "crypto/crypto_export.h" +#include "crypto/wincrypt_shim.h" namespace crypto { diff --git a/crypto/crypto.gypi b/crypto/crypto.gypi index de65e19..82b5da5 100644 --- a/crypto/crypto.gypi +++ b/crypto/crypto.gypi @@ -20,6 +20,7 @@ 'third_party/nss/chromium-prtypes.h', 'third_party/nss/chromium-sha256.h', 'third_party/nss/sha512.cc', + 'wincrypt_shim.h', ], }, 'hmac_win64_related_sources': [ '<@(hmac_win64_related_sources)' ], diff --git a/crypto/hmac_win.cc b/crypto/hmac_win.cc index ba7d827..99b3a60 100644 --- a/crypto/hmac_win.cc +++ b/crypto/hmac_win.cc @@ -5,7 +5,6 @@ #include "crypto/hmac.h" #include <windows.h> -#include <wincrypt.h> #include <algorithm> #include <vector> @@ -14,6 +13,7 @@ #include "crypto/scoped_capi_types.h" #include "crypto/third_party/nss/chromium-blapi.h" #include "crypto/third_party/nss/chromium-sha256.h" +#include "crypto/wincrypt_shim.h" namespace crypto { diff --git a/crypto/scoped_capi_types.h b/crypto/scoped_capi_types.h index 9ab28d9..ac92e39 100644 --- a/crypto/scoped_capi_types.h +++ b/crypto/scoped_capi_types.h @@ -6,11 +6,11 @@ #define CRYPTO_SCOPED_CAPI_TYPES_H_ #include <windows.h> -#include <wincrypt.h> #include <algorithm> #include "base/logging.h" +#include "crypto/wincrypt_shim.h" namespace crypto { diff --git a/crypto/wincrypt_shim.h b/crypto/wincrypt_shim.h new file mode 100644 index 0000000..799ac49 --- /dev/null +++ b/crypto/wincrypt_shim.h @@ -0,0 +1,25 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef NET_CRYPTO_WINCRYPT_SHIM_H_ +#define NET_CRYPTO_WINCRYPT_SHIM_H_ + +// wincrypt.h defines macros which conflict with OpenSSL's types. This header +// includes wincrypt and undefines the OpenSSL macros which conflict. Any +// Chromium headers which include wincrypt should instead include this header. + +#include <windows.h> +#include <wincrypt.h> + +// Undefine the macros which conflict with OpenSSL and define replacements. See +// http://msdn.microsoft.com/en-us/library/windows/desktop/aa378145(v=vs.85).aspx +#undef X509_CERT_PAIR +#undef X509_EXTENSIONS +#undef X509_NAME + +#define WINCRYPT_X509_CERT_PAIR ((LPCSTR) 53) +#define WINCRYPT_X509_EXTENSIONS ((LPCSTR) 5) +#define WINCRYPT_X509_NAME ((LPCSTR) 7) + +#endif // NET_CRYPTO_WINCRYPT_SHIM_H_
\ No newline at end of file diff --git a/net/base/keygen_handler_win.cc b/net/base/keygen_handler_win.cc index f97ada7..ffa3b2e 100644 --- a/net/base/keygen_handler_win.cc +++ b/net/base/keygen_handler_win.cc @@ -5,10 +5,7 @@ #include "net/base/keygen_handler.h" #include <windows.h> -#include <wincrypt.h> -#pragma comment(lib, "crypt32.lib") #include <rpc.h> -#pragma comment(lib, "rpcrt4.lib") #include <list> #include <string> @@ -22,7 +19,10 @@ #include "base/strings/utf_string_conversions.h" #include "crypto/capi_util.h" #include "crypto/scoped_capi_types.h" +#include "crypto/wincrypt_shim.h" +#pragma comment(lib, "crypt32.lib") +#pragma comment(lib, "rpcrt4.lib") namespace net { diff --git a/net/cert/cert_database_win.cc b/net/cert/cert_database_win.cc index 9bf378c..fae3cbf 100644 --- a/net/cert/cert_database_win.cc +++ b/net/cert/cert_database_win.cc @@ -5,13 +5,14 @@ #include "net/cert/cert_database.h" #include <windows.h> -#include <wincrypt.h> -#pragma comment(lib, "crypt32.lib") #include "base/observer_list_threadsafe.h" +#include "crypto/wincrypt_shim.h" #include "net/base/net_errors.h" #include "net/cert/x509_certificate.h" +#pragma comment(lib, "crypt32.lib") + namespace net { CertDatabase::CertDatabase() diff --git a/net/cert/cert_verify_proc_win.cc b/net/cert/cert_verify_proc_win.cc index 6d841c4..60e2286 100644 --- a/net/cert/cert_verify_proc_win.cc +++ b/net/cert/cert_verify_proc_win.cc @@ -191,7 +191,7 @@ bool CertSubjectCommonNameHasNull(PCCERT_CONTEXT cert) { DWORD name_info_size = 0; BOOL rv; rv = CryptDecodeObjectEx(X509_ASN_ENCODING | PKCS_7_ASN_ENCODING, - X509_NAME, + WINCRYPT_X509_NAME, cert->pCertInfo->Subject.pbData, cert->pCertInfo->Subject.cbData, CRYPT_DECODE_ALLOC_FLAG | CRYPT_DECODE_NOCOPY_FLAG, diff --git a/net/cert/sha256_legacy_support_win.cc b/net/cert/sha256_legacy_support_win.cc index 656edd73..c27fc5a 100644 --- a/net/cert/sha256_legacy_support_win.cc +++ b/net/cert/sha256_legacy_support_win.cc @@ -4,9 +4,6 @@ #include "net/cert/sha256_legacy_support_win.h" -#include <windows.h> -#include <wincrypt.h> - #include <cert.h> #include <keyhi.h> #include <secoid.h> diff --git a/net/cert/sha256_legacy_support_win.h b/net/cert/sha256_legacy_support_win.h index c98414c..fce93dd 100644 --- a/net/cert/sha256_legacy_support_win.h +++ b/net/cert/sha256_legacy_support_win.h @@ -6,8 +6,8 @@ #define NET_CERT_SHA256_LEGACY_SUPPORT_WIN_H_ #include <windows.h> -#include <wincrypt.h> +#include "crypto/wincrypt_shim.h" #include "net/base/net_export.h" namespace net { diff --git a/net/cert/test_root_certs.h b/net/cert/test_root_certs.h index 84c163a..9d2cc2a 100644 --- a/net/cert/test_root_certs.h +++ b/net/cert/test_root_certs.h @@ -16,7 +16,7 @@ #include <vector> #elif defined(OS_WIN) #include <windows.h> -#include <wincrypt.h> +#include "crypto/wincrypt_shim.h" #elif defined(OS_MACOSX) #include <CoreFoundation/CFArray.h> #include <Security/SecTrust.h> diff --git a/net/cert/test_root_certs_win.cc b/net/cert/test_root_certs_win.cc index 8be0e3c..4e941e2 100644 --- a/net/cert/test_root_certs_win.cc +++ b/net/cert/test_root_certs_win.cc @@ -4,9 +4,6 @@ #include "net/cert/test_root_certs.h" -#include <windows.h> -#include <wincrypt.h> - #include "base/basictypes.h" #include "base/lazy_instance.h" #include "base/logging.h" diff --git a/net/cert/x509_cert_types_win.cc b/net/cert/x509_cert_types_win.cc index 570f5fc..8a456f3 100644 --- a/net/cert/x509_cert_types_win.cc +++ b/net/cert/x509_cert_types_win.cc @@ -5,13 +5,13 @@ #include "net/cert/x509_cert_types.h" #include <windows.h> -#include <wincrypt.h> #include "base/logging.h" #include "base/memory/scoped_ptr.h" #include "base/strings/string_util.h" #include "base/strings/utf_string_conversions.h" #include "crypto/capi_util.h" +#include "crypto/wincrypt_shim.h" #pragma comment(lib, "crypt32.lib") @@ -97,7 +97,7 @@ bool CertPrincipal::ParseDistinguishedName(const void* ber_name_data, DWORD name_info_size = 0; BOOL rv; rv = CryptDecodeObjectEx(X509_ASN_ENCODING | PKCS_7_ASN_ENCODING, - X509_NAME, + WINCRYPT_X509_NAME, reinterpret_cast<const BYTE*>(ber_name_data), length, CRYPT_DECODE_ALLOC_FLAG | CRYPT_DECODE_NOCOPY_FLAG, diff --git a/net/cert/x509_certificate.h b/net/cert/x509_certificate.h index 85b7c6f..5c64a44 100644 --- a/net/cert/x509_certificate.h +++ b/net/cert/x509_certificate.h @@ -20,11 +20,10 @@ #if defined(OS_WIN) #include <windows.h> -#include <wincrypt.h> +#include "crypto/wincrypt_shim.h" #elif defined(OS_MACOSX) #include <CoreFoundation/CFArray.h> #include <Security/SecBase.h> - #elif defined(USE_OPENSSL_CERTS) // Forward declaration; real one in <x509.h> typedef struct x509_st X509; diff --git a/net/ssl/client_cert_store_win.cc b/net/ssl/client_cert_store_win.cc index 24ae1aa..2e9763f 100644 --- a/net/ssl/client_cert_store_win.cc +++ b/net/ssl/client_cert_store_win.cc @@ -9,12 +9,12 @@ #define SECURITY_WIN32 // Needs to be defined before including security.h #include <windows.h> -#include <wincrypt.h> #include <security.h> #include "base/callback.h" #include "base/logging.h" #include "crypto/scoped_capi_types.h" +#include "crypto/wincrypt_shim.h" #include "net/cert/x509_util.h" namespace net { diff --git a/net/test/spawned_test_server/local_test_server_win.cc b/net/test/spawned_test_server/local_test_server_win.cc index 1454e85..401cfac 100644 --- a/net/test/spawned_test_server/local_test_server_win.cc +++ b/net/test/spawned_test_server/local_test_server_win.cc @@ -5,7 +5,6 @@ #include "net/test/spawned_test_server/local_test_server.h" #include <windows.h> -#include <wincrypt.h> #include "base/base_paths.h" #include "base/bind.h" @@ -23,8 +22,6 @@ #include "base/win/scoped_handle.h" #include "net/test/python_utils.h" -#pragma comment(lib, "crypt32.lib") - namespace { // Writes |size| bytes to |handle| and sets |*unblocked| to true. |