diff options
Diffstat (limited to 'src/dutil/cryputil.cpp')
-rw-r--r-- | src/dutil/cryputil.cpp | 16 |
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)) |