blob: af8afe8157c22505e1685fc4a54b0dbb2778c8a3 [file]
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
diff --git a/google/cloud/internal/win32/sign_using_sha256.cc b/google/cloud/internal/win32/sign_using_sha256.cc
index 15ecc6e6f9..9595ed9eb3 100644
--- a/google/cloud/internal/win32/sign_using_sha256.cc
+++ b/google/cloud/internal/win32/sign_using_sha256.cc
@@ -99,6 +99,11 @@ StatusOr<std::unique_ptr<std::remove_pointer_t<BCRYPT_KEY_HANDLE>,
decltype(&BCryptDestroyKey)>>
CreateRsaBCryptKey(std::vector<BYTE> buffer) {
BCRYPT_KEY_HANDLE key_handle;
+ // Workaround missing macros in MinGW-w64:
+ // https://github.com/mingw-w64/mingw-w64/issues/49
+ #ifndef BCRYPT_RSA_ALG_HANDLE
+ #define BCRYPT_RSA_ALG_HANDLE ((BCRYPT_ALG_HANDLE)0x000000e1)
+ #endif
if (BCryptImportKeyPair(BCRYPT_RSA_ALG_HANDLE, nullptr,
BCRYPT_RSAPRIVATE_BLOB, &key_handle, buffer.data(),
static_cast<DWORD>(buffer.size()),
diff --git a/google/cloud/storage/internal/md5hash.cc b/google/cloud/storage/internal/md5hash.cc
index 00c72e0e5d..7fbd04507f 100644
--- a/google/cloud/storage/internal/md5hash.cc
+++ b/google/cloud/storage/internal/md5hash.cc
@@ -31,6 +31,11 @@ GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN
std::vector<std::uint8_t> MD5Hash(absl::string_view payload) {
#ifdef _WIN32
std::vector<unsigned char> digest(16);
+ // Workaround missing macros in MinGW-w64:
+ // https://github.com/mingw-w64/mingw-w64/issues/49
+ #ifndef BCRYPT_MD5_ALG_HANDLE
+ #define BCRYPT_MD5_ALG_HANDLE ((BCRYPT_ALG_HANDLE)0x00000021)
+ #endif
BCryptHash(BCRYPT_MD5_ALG_HANDLE, nullptr, 0,
reinterpret_cast<PUCHAR>(const_cast<char*>(payload.data())),
static_cast<ULONG>(payload.size()), digest.data(),
diff --git a/google/cloud/storage/internal/win32/hash_function_impl.cc b/google/cloud/storage/internal/win32/hash_function_impl.cc
index 655c9f0991..07b2937c94 100644
--- a/google/cloud/storage/internal/win32/hash_function_impl.cc
+++ b/google/cloud/storage/internal/win32/hash_function_impl.cc
@@ -33,6 +33,11 @@ using ContextPtr =
ContextPtr CreateMD5HashCtx() {
BCRYPT_HASH_HANDLE hHash = nullptr;
+ // Workaround missing macros in MinGW-w64:
+ // https://github.com/mingw-w64/mingw-w64/issues/49
+ #ifndef BCRYPT_MD5_ALG_HANDLE
+ #define BCRYPT_MD5_ALG_HANDLE ((BCRYPT_ALG_HANDLE)0x00000021)
+ #endif
BCryptCreateHash(BCRYPT_MD5_ALG_HANDLE, &hHash, nullptr, 0, nullptr, 0, 0);
return ContextPtr(hHash);
}