I'm trying to use SHA2-512 on Windows 7 with CryptoAPI, however, calling
CryptCreateHash
GetLastError()
HCRYPTPROV hCryptProv;
CryptAcquireContext(&hCryptProv, nullptr, nullptr, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT);
HCRYPTHASH hHash;
if (!CryptCreateHash(hCryptProv, CALG_SHA_512, 0, 0, &hHash)) {
DWORD err = GetLastError(); // -> 2148073480=0x80090008
}
CALG_SHA1
CALG_SHA512
The reason for this is, that the SHA2 algorithms are not supported by the "Microsoft Base Cryptography Provider" (PROV_RSA_FULL
or PROV_RSA_SIG
).
One needs to use the "Microsoft Enhanced RSA and AES Cryptographic Provider" (PROV_RSA_AES
) in CryptAcquireContext
.