1515# specific language governing permissions and limitations
1616# under the License.
1717
18- a/google/cloud/internal/win32/sign_using_sha256.cc b/google/cloud/internal/win32/sign_using_sha256.cc
18+ diff --git a/google/cloud/internal/win32/sign_using_sha256.cc b/google/cloud/internal/win32/sign_using_sha256.cc
1919index 15ecc6e6f9..60b6b7057e 100644
2020--- a/google/cloud/internal/win32/sign_using_sha256.cc
2121+++ b/google/cloud/internal/win32/sign_using_sha256.cc
@@ -26,8 +26,40 @@ index 15ecc6e6f9..60b6b7057e 100644
2626+ // Workaround missing macros in MinGW-w64:
2727+ // https://github.com/mingw-w64/mingw-w64/issues/49
2828+ #ifndef BCRYPT_RSA_ALG_HANDLE
29- + #define BCRYPT_RSA_ALG_HANDLE ((BCRYPT_ALG_HANDLE)0x000000e1 )
29+ + #define BCRYPT_RSA_ALG_HANDLE ((BCRYPT_ALG_HANDLE)0x0000000A )
3030+ #endif
3131 if (BCryptImportKeyPair(BCRYPT_RSA_ALG_HANDLE, nullptr,
3232 BCRYPT_RSAPRIVATE_BLOB, &key_handle, buffer.data(),
3333 static_cast<DWORD>(buffer.size()),
34+ diff --git a/google/cloud/storage/internal/md5hash.cc b/google/cloud/storage/internal/md5hash.cc
35+ index 00c72e0e5d..7fbd04507f 100644
36+ --- a/google/cloud/storage/internal/md5hash.cc
37+ +++ b/google/cloud/storage/internal/md5hash.cc
38+ @@ -31,6 +31,11 @@ GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN
39+ std::vector<std::uint8_t> MD5Hash(absl::string_view payload) {
40+ #ifdef _WIN32
41+ std::vector<unsigned char> digest(16);
42+ + // Workaround missing macros in MinGW-w64:
43+ + // https://github.com/mingw-w64/mingw-w64/issues/49
44+ + #ifndef BCRYPT_MD5_ALG_HANDLE
45+ + #define BCRYPT_MD5_ALG_HANDLE ((BCRYPT_ALG_HANDLE)0x00000021)
46+ + #endif
47+ BCryptHash(BCRYPT_MD5_ALG_HANDLE, nullptr, 0,
48+ reinterpret_cast<PUCHAR>(const_cast<char*>(payload.data())),
49+ static_cast<ULONG>(payload.size()), digest.data(),
50+ diff --git a/google/cloud/storage/internal/win32/hash_function_impl.cc b/google/cloud/storage/internal/win32/hash_function_impl.cc
51+ index 655c9f0991..07b2937c94 100644
52+ --- a/google/cloud/storage/internal/win32/hash_function_impl.cc
53+ +++ b/google/cloud/storage/internal/win32/hash_function_impl.cc
54+ @@ -33,6 +33,11 @@ using ContextPtr =
55+
56+ ContextPtr CreateMD5HashCtx() {
57+ BCRYPT_HASH_HANDLE hHash = nullptr;
58+ + // Workaround missing macros in MinGW-w64:
59+ + // https://github.com/mingw-w64/mingw-w64/issues/49
60+ + #ifndef BCRYPT_MD5_ALG_HANDLE
61+ + #define BCRYPT_MD5_ALG_HANDLE ((BCRYPT_ALG_HANDLE)0x00000021)
62+ + #endif
63+ BCryptCreateHash(BCRYPT_MD5_ALG_HANDLE, &hHash, nullptr, 0, nullptr, 0, 0);
64+ return ContextPtr(hHash);
65+ }
0 commit comments