Skip to content

Commit

Permalink
fix: workaround missing SHA256 macros in MinGW-w64
Browse files Browse the repository at this point in the history
  • Loading branch information
coryan committed Jul 4, 2024
1 parent f54ba19 commit c801913
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
5 changes: 5 additions & 0 deletions google/cloud/internal/sha256_hash.cc
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ namespace {
Sha256Type Sha256Hash(void const* data, std::size_t count) {
Sha256Type hash;
#ifdef _WIN32
// Workaround missing macros in MinGW-w64:
// https://github.com/mingw-w64/mingw-w64/issues/49
#ifndef BCRYPT_SHA256_ALG_HANDLE
#define BCRYPT_SHA256_ALG_HANDLE ((BCRYPT_ALG_HANDLE)0x00000041)
#endif
BCryptHash(BCRYPT_SHA256_ALG_HANDLE, nullptr, 0,
static_cast<PUCHAR>(const_cast<void*>(data)),
static_cast<ULONG>(count), hash.data(),
Expand Down
5 changes: 5 additions & 0 deletions google/cloud/internal/sha256_hmac.cc
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ Sha256Type Sha256HmacImpl(absl::Span<T const> key, unsigned char const* data,
std::size_t count) {
Sha256Type hash;
#ifdef _WIN32
// Workaround missing macros in MinGW-w64:
// https://github.com/mingw-w64/mingw-w64/issues/49
#ifndef BCRYPT_HMAC_SHA256_ALG_HANDLE
#define BCRYPT_HMAC_SHA256_ALG_HANDLE ((BCRYPT_ALG_HANDLE)0x000000b1)
#endif
BCryptHash(BCRYPT_HMAC_SHA256_ALG_HANDLE,
reinterpret_cast<PUCHAR>(const_cast<T*>(key.data())),
static_cast<ULONG>(key.size()), const_cast<PUCHAR>(data),
Expand Down

0 comments on commit c801913

Please sign in to comment.