0

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}
This commit is contained in:
davidben
2014-10-29 17:39:38 -07:00
committed by Commit bot
parent 6fdf39c8fc
commit c6ac2609dd
21 changed files with 48 additions and 30 deletions

@ -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 {

@ -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"

@ -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"

@ -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 {

@ -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")

@ -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 {

@ -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)' ],

@ -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 {

@ -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 {

25
crypto/wincrypt_shim.h Normal file

@ -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_

@ -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 {

@ -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()

@ -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,

@ -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>

@ -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 {

@ -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>

@ -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"

@ -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,

@ -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;

@ -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 {

@ -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.