rsaenh: Pass exact size to BCryptFinishHash().

This commit is contained in:
Hans Leidekker 2022-11-01 15:08:30 +01:00 committed by Alexandre Julliard
parent 6705a71045
commit 4e3b287093
3 changed files with 6 additions and 6 deletions

View file

@ -70,9 +70,9 @@ BOOL update_hash_impl(BCRYPT_HASH_HANDLE hash_handle, const BYTE *pbData, DWORD
return TRUE; return TRUE;
} }
BOOL finalize_hash_impl(BCRYPT_HASH_HANDLE hash_handle, BYTE *pbHashValue) BOOL finalize_hash_impl(BCRYPT_HASH_HANDLE hash_handle, BYTE *hash_value, DWORD hash_size)
{ {
BCryptFinishHash(hash_handle, pbHashValue, RSAENH_MAX_HASH_SIZE, 0); BCryptFinishHash(hash_handle, hash_value, hash_size, 0);
BCryptDestroyHash(hash_handle); BCryptDestroyHash(hash_handle);
return TRUE; return TRUE;
} }

View file

@ -41,7 +41,7 @@ typedef union tagKEY_CONTEXT {
BOOL init_hash_impl(ALG_ID aiAlgid, BCRYPT_HASH_HANDLE *hash_handle) DECLSPEC_HIDDEN; BOOL init_hash_impl(ALG_ID aiAlgid, BCRYPT_HASH_HANDLE *hash_handle) DECLSPEC_HIDDEN;
BOOL update_hash_impl(BCRYPT_HASH_HANDLE hash_handle, const BYTE *pbData, BOOL update_hash_impl(BCRYPT_HASH_HANDLE hash_handle, const BYTE *pbData,
DWORD dwDataLen) DECLSPEC_HIDDEN; DWORD dwDataLen) DECLSPEC_HIDDEN;
BOOL finalize_hash_impl(BCRYPT_HASH_HANDLE hash_handle, BYTE *pbHashValue) DECLSPEC_HIDDEN; BOOL finalize_hash_impl(BCRYPT_HASH_HANDLE hash_handle, BYTE *hash_value, DWORD hash_size) DECLSPEC_HIDDEN;
BOOL duplicate_hash_impl(BCRYPT_HASH_HANDLE src_hash_handle, BOOL duplicate_hash_impl(BCRYPT_HASH_HANDLE src_hash_handle,
BCRYPT_HASH_HANDLE *dest_hash_handle) DECLSPEC_HIDDEN; BCRYPT_HASH_HANDLE *dest_hash_handle) DECLSPEC_HIDDEN;

View file

@ -816,7 +816,7 @@ static inline void finalize_hash(CRYPTHASH *pCryptHash)
if (pCryptHash->pHMACInfo) { if (pCryptHash->pHMACInfo) {
BYTE abHashValue[RSAENH_MAX_HASH_SIZE]; BYTE abHashValue[RSAENH_MAX_HASH_SIZE];
finalize_hash_impl(pCryptHash->hash_handle, pCryptHash->abHashValue); finalize_hash_impl(pCryptHash->hash_handle, pCryptHash->abHashValue, pCryptHash->dwHashSize);
memcpy(abHashValue, pCryptHash->abHashValue, pCryptHash->dwHashSize); memcpy(abHashValue, pCryptHash->abHashValue, pCryptHash->dwHashSize);
init_hash_impl(pCryptHash->pHMACInfo->HashAlgid, &pCryptHash->hash_handle); init_hash_impl(pCryptHash->pHMACInfo->HashAlgid, &pCryptHash->hash_handle);
update_hash_impl(pCryptHash->hash_handle, update_hash_impl(pCryptHash->hash_handle,
@ -824,7 +824,7 @@ static inline void finalize_hash(CRYPTHASH *pCryptHash)
pCryptHash->pHMACInfo->cbOuterString); pCryptHash->pHMACInfo->cbOuterString);
update_hash_impl(pCryptHash->hash_handle, update_hash_impl(pCryptHash->hash_handle,
abHashValue, pCryptHash->dwHashSize); abHashValue, pCryptHash->dwHashSize);
finalize_hash_impl(pCryptHash->hash_handle, pCryptHash->abHashValue); finalize_hash_impl(pCryptHash->hash_handle, pCryptHash->abHashValue, pCryptHash->dwHashSize);
pCryptHash->hash_handle = NULL; pCryptHash->hash_handle = NULL;
} }
break; break;
@ -842,7 +842,7 @@ static inline void finalize_hash(CRYPTHASH *pCryptHash)
break; break;
default: default:
finalize_hash_impl(pCryptHash->hash_handle, pCryptHash->abHashValue); finalize_hash_impl(pCryptHash->hash_handle, pCryptHash->abHashValue, pCryptHash->dwHashSize);
pCryptHash->hash_handle = NULL; pCryptHash->hash_handle = NULL;
} }
} }