Signed-off-by: Sven Baars sbaars@codeweavers.com --- dlls/crypt32/cert.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-)
diff --git a/dlls/crypt32/cert.c b/dlls/crypt32/cert.c index 5fc76c9556f..c651dd18512 100644 --- a/dlls/crypt32/cert.c +++ b/dlls/crypt32/cert.c @@ -2255,10 +2255,12 @@ BOOL WINAPI CryptHashCertificate(HCRYPTPROV_LEGACY hCryptProv, ALG_ID Algid, TRACE("(%08Ix, %d, %08lx, %p, %ld, %p, %p)\n", hCryptProv, Algid, dwFlags, pbEncoded, cbEncoded, pbComputedHash, pcbComputedHash);
- if (!hCryptProv) - hCryptProv = I_CryptGetDefaultCryptProv(Algid); if (!Algid) Algid = CALG_SHA1; + + if (!hCryptProv) + hCryptProv = I_CryptGetDefaultCryptProv(Algid); + if (ret) { ret = CryptCreateHash(hCryptProv, Algid, 0, 0, &hHash); @@ -2337,10 +2339,12 @@ BOOL WINAPI CryptHashPublicKeyInfo(HCRYPTPROV_LEGACY hCryptProv, ALG_ID Algid, TRACE("(%08Ix, %d, %08lx, %ld, %p, %p, %p)\n", hCryptProv, Algid, dwFlags, dwCertEncodingType, pInfo, pbComputedHash, pcbComputedHash);
- if (!hCryptProv) - hCryptProv = I_CryptGetDefaultCryptProv(0); if (!Algid) Algid = CALG_MD5; + + if (!hCryptProv) + hCryptProv = I_CryptGetDefaultCryptProv(Algid); + if ((dwCertEncodingType & CERT_ENCODING_TYPE_MASK) != X509_ASN_ENCODING) { SetLastError(ERROR_FILE_NOT_FOUND); @@ -2389,8 +2393,6 @@ BOOL WINAPI CryptHashToBeSigned(HCRYPTPROV_LEGACY hCryptProv, PCCRYPT_OID_INFO oidInfo; HCRYPTHASH hHash;
- if (!hCryptProv) - hCryptProv = I_CryptGetDefaultCryptProv(0); oidInfo = CryptFindOIDInfo(CRYPT_OID_INFO_OID_KEY, info->SignatureAlgorithm.pszObjId, 0); if (!oidInfo) @@ -2400,6 +2402,9 @@ BOOL WINAPI CryptHashToBeSigned(HCRYPTPROV_LEGACY hCryptProv, } else { + if (!hCryptProv) + hCryptProv = I_CryptGetDefaultCryptProv(oidInfo->u.Algid); + ret = CryptCreateHash(hCryptProv, oidInfo->u.Algid, 0, 0, &hHash); if (ret) { @@ -2439,7 +2444,8 @@ BOOL WINAPI CryptSignCertificate(HCRYPTPROV_OR_NCRYPT_KEY_HANDLE hCryptProv, if (info->dwGroupId == CRYPT_HASH_ALG_OID_GROUP_ID) { if (!hCryptProv) - hCryptProv = I_CryptGetDefaultCryptProv(0); + hCryptProv = I_CryptGetDefaultCryptProv(info->u.Algid); + ret = CryptCreateHash(hCryptProv, info->u.Algid, 0, 0, &hHash); if (ret) {