Signed-off-by: Sven Baars sbaars@codeweavers.com --- dlls/crypt32/cert.c | 44 +++++++++++++++++++------------------------- 1 file changed, 19 insertions(+), 25 deletions(-)
diff --git a/dlls/crypt32/cert.c b/dlls/crypt32/cert.c index c651dd18512..687b60bac54 100644 --- a/dlls/crypt32/cert.c +++ b/dlls/crypt32/cert.c @@ -2249,7 +2249,7 @@ BOOL WINAPI CryptHashCertificate(HCRYPTPROV_LEGACY hCryptProv, ALG_ID Algid, DWORD dwFlags, const BYTE *pbEncoded, DWORD cbEncoded, BYTE *pbComputedHash, DWORD *pcbComputedHash) { - BOOL ret = TRUE; + BOOL ret; HCRYPTHASH hHash = 0;
TRACE("(%08Ix, %d, %08lx, %p, %ld, %p, %p)\n", hCryptProv, Algid, dwFlags, @@ -2261,17 +2261,14 @@ BOOL WINAPI CryptHashCertificate(HCRYPTPROV_LEGACY hCryptProv, ALG_ID Algid, if (!hCryptProv) hCryptProv = I_CryptGetDefaultCryptProv(Algid);
+ ret = CryptCreateHash(hCryptProv, Algid, 0, 0, &hHash); if (ret) { - ret = CryptCreateHash(hCryptProv, Algid, 0, 0, &hHash); + ret = CryptHashData(hHash, pbEncoded, cbEncoded, 0); if (ret) - { - ret = CryptHashData(hHash, pbEncoded, cbEncoded, 0); - if (ret) - ret = CryptGetHashParam(hHash, HP_HASHVAL, pbComputedHash, - pcbComputedHash, 0); - CryptDestroyHash(hHash); - } + ret = CryptGetHashParam(hHash, HP_HASHVAL, pbComputedHash, + pcbComputedHash, 0); + CryptDestroyHash(hHash); } return ret; } @@ -2333,8 +2330,10 @@ BOOL WINAPI CryptHashPublicKeyInfo(HCRYPTPROV_LEGACY hCryptProv, ALG_ID Algid, DWORD dwFlags, DWORD dwCertEncodingType, PCERT_PUBLIC_KEY_INFO pInfo, BYTE *pbComputedHash, DWORD *pcbComputedHash) { - BOOL ret = TRUE; HCRYPTHASH hHash = 0; + DWORD size = 0; + BYTE *buf; + BOOL ret;
TRACE("(%08Ix, %d, %08lx, %ld, %p, %p, %p)\n", hCryptProv, Algid, dwFlags, dwCertEncodingType, pInfo, pbComputedHash, pcbComputedHash); @@ -2350,27 +2349,22 @@ BOOL WINAPI CryptHashPublicKeyInfo(HCRYPTPROV_LEGACY hCryptProv, ALG_ID Algid, SetLastError(ERROR_FILE_NOT_FOUND); return FALSE; } + + ret = CRYPT_AsnEncodePubKeyInfoNoNull(dwCertEncodingType, + X509_PUBLIC_KEY_INFO, pInfo, CRYPT_ENCODE_ALLOC_FLAG, NULL, + (LPBYTE)&buf, &size); if (ret) { - BYTE *buf; - DWORD size = 0; - - ret = CRYPT_AsnEncodePubKeyInfoNoNull(dwCertEncodingType, - X509_PUBLIC_KEY_INFO, pInfo, CRYPT_ENCODE_ALLOC_FLAG, NULL, - (LPBYTE)&buf, &size); + ret = CryptCreateHash(hCryptProv, Algid, 0, 0, &hHash); if (ret) { - ret = CryptCreateHash(hCryptProv, Algid, 0, 0, &hHash); + ret = CryptHashData(hHash, buf, size, 0); if (ret) - { - ret = CryptHashData(hHash, buf, size, 0); - if (ret) - ret = CryptGetHashParam(hHash, HP_HASHVAL, pbComputedHash, - pcbComputedHash, 0); - CryptDestroyHash(hHash); - } - LocalFree(buf); + ret = CryptGetHashParam(hHash, HP_HASHVAL, pbComputedHash, + pcbComputedHash, 0); + CryptDestroyHash(hHash); } + LocalFree(buf); } return ret; }