aboutsummaryrefslogtreecommitdiff
path: root/src/dutil/cryputil.cpp
diff options
context:
space:
mode:
authorSean Hall <r.sean.hall@gmail.com>2021-04-28 16:36:56 -0500
committerSean Hall <r.sean.hall@gmail.com>2021-04-29 13:58:14 -0500
commitbcd3ee7ab858d62beb36af9f5986544b68a3dd35 (patch)
tree424c4e61a580b7c4b7481712f69ab0193d76b9c4 /src/dutil/cryputil.cpp
parentd73c29407fe5ec6a0207af7d9c2547457ae0854c (diff)
downloadwix-bcd3ee7ab858d62beb36af9f5986544b68a3dd35.tar.gz
wix-bcd3ee7ab858d62beb36af9f5986544b68a3dd35.tar.bz2
wix-bcd3ee7ab858d62beb36af9f5986544b68a3dd35.zip
Clean up more 32-bit assumptions.
Diffstat (limited to 'src/dutil/cryputil.cpp')
-rw-r--r--src/dutil/cryputil.cpp16
1 files changed, 13 insertions, 3 deletions
diff --git a/src/dutil/cryputil.cpp b/src/dutil/cryputil.cpp
index c5c1b221..24bb83f1 100644
--- a/src/dutil/cryputil.cpp
+++ b/src/dutil/cryputil.cpp
@@ -291,6 +291,9 @@ HRESULT DAPI CrypHashBuffer(
291 HRESULT hr = S_OK; 291 HRESULT hr = S_OK;
292 HCRYPTPROV hProv = NULL; 292 HCRYPTPROV hProv = NULL;
293 HCRYPTHASH hHash = NULL; 293 HCRYPTHASH hHash = NULL;
294 DWORD cbDataHashed = 0;
295 SIZE_T cbTotal = 0;
296 SIZE_T cbRemaining = 0;
294 297
295 // get handle to the crypto provider 298 // get handle to the crypto provider
296 if (!::CryptAcquireContextW(&hProv, NULL, NULL, dwProvType, CRYPT_VERIFYCONTEXT | CRYPT_SILENT)) 299 if (!::CryptAcquireContextW(&hProv, NULL, NULL, dwProvType, CRYPT_VERIFYCONTEXT | CRYPT_SILENT))
@@ -304,10 +307,17 @@ HRESULT DAPI CrypHashBuffer(
304 CrypExitWithLastError(hr, "Failed to initiate hash."); 307 CrypExitWithLastError(hr, "Failed to initiate hash.");
305 } 308 }
306 309
307 if (!::CryptHashData(hHash, pbBuffer, static_cast<DWORD>(cbBuffer), 0)) 310 do
308 { 311 {
309 CrypExitWithLastError(hr, "Failed to hash data."); 312 cbRemaining = cbBuffer - cbTotal;
310 } 313 cbDataHashed = (DWORD)min(DWORD_MAX, cbRemaining);
314 if (!::CryptHashData(hHash, pbBuffer + cbTotal, cbDataHashed, 0))
315 {
316 CrypExitWithLastError(hr, "Failed to hash data.");
317 }
318
319 cbTotal += cbDataHashed;
320 } while (cbTotal < cbBuffer);
311 321
312 // get hash value 322 // get hash value
313 if (!::CryptGetHashParam(hHash, HP_HASHVAL, pbHash, &cbHash, 0)) 323 if (!::CryptGetHashParam(hHash, HP_HASHVAL, pbHash, &cbHash, 0))