mirror of
git://source.winehq.org/git/wine.git
synced 2024-09-01 12:23:39 +00:00
rsaenh: Use BCrypt algorithm pseudo-handles.
This commit is contained in:
parent
4918be2c59
commit
6db0fc5ce8
|
@ -36,48 +36,32 @@ BOOL WINAPI SystemFunction036(PVOID pbBuffer, ULONG dwLen);
|
||||||
|
|
||||||
BOOL init_hash_impl(ALG_ID aiAlgid, BCRYPT_HASH_HANDLE *hash_handle)
|
BOOL init_hash_impl(ALG_ID aiAlgid, BCRYPT_HASH_HANDLE *hash_handle)
|
||||||
{
|
{
|
||||||
BCRYPT_ALG_HANDLE provider;
|
switch (aiAlgid)
|
||||||
NTSTATUS status;
|
|
||||||
|
|
||||||
switch (aiAlgid)
|
|
||||||
{
|
{
|
||||||
case CALG_MD2:
|
case CALG_MD2:
|
||||||
status = BCryptOpenAlgorithmProvider(&provider, BCRYPT_MD2_ALGORITHM, MS_PRIMITIVE_PROVIDER, 0);
|
return !BCryptCreateHash(BCRYPT_MD2_ALG_HANDLE, hash_handle, NULL, 0, NULL, 0, 0);
|
||||||
break;
|
|
||||||
|
|
||||||
case CALG_MD4:
|
|
||||||
status = BCryptOpenAlgorithmProvider(&provider, BCRYPT_MD4_ALGORITHM, MS_PRIMITIVE_PROVIDER, 0);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case CALG_MD5:
|
|
||||||
status = BCryptOpenAlgorithmProvider(&provider, BCRYPT_MD5_ALGORITHM, MS_PRIMITIVE_PROVIDER, 0);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case CALG_SHA:
|
|
||||||
status = BCryptOpenAlgorithmProvider(&provider, BCRYPT_SHA1_ALGORITHM, MS_PRIMITIVE_PROVIDER, 0);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case CALG_SHA_256:
|
case CALG_MD4:
|
||||||
status = BCryptOpenAlgorithmProvider(&provider, BCRYPT_SHA256_ALGORITHM, MS_PRIMITIVE_PROVIDER, 0);
|
return !BCryptCreateHash(BCRYPT_MD4_ALG_HANDLE, hash_handle, NULL, 0, NULL, 0, 0);
|
||||||
break;
|
|
||||||
|
|
||||||
case CALG_SHA_384:
|
case CALG_MD5:
|
||||||
status = BCryptOpenAlgorithmProvider(&provider, BCRYPT_SHA384_ALGORITHM, MS_PRIMITIVE_PROVIDER, 0);
|
return !BCryptCreateHash(BCRYPT_MD5_ALG_HANDLE, hash_handle, NULL, 0, NULL, 0, 0);
|
||||||
break;
|
|
||||||
|
|
||||||
case CALG_SHA_512:
|
case CALG_SHA:
|
||||||
status = BCryptOpenAlgorithmProvider(&provider, BCRYPT_SHA512_ALGORITHM, MS_PRIMITIVE_PROVIDER, 0);
|
return !BCryptCreateHash(BCRYPT_SHA1_ALG_HANDLE, hash_handle, NULL, 0, NULL, 0, 0);
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
case CALG_SHA_256:
|
||||||
return TRUE;
|
return !BCryptCreateHash(BCRYPT_SHA256_ALG_HANDLE, hash_handle, NULL, 0, NULL, 0, 0);
|
||||||
|
|
||||||
|
case CALG_SHA_384:
|
||||||
|
return !BCryptCreateHash(BCRYPT_SHA384_ALG_HANDLE, hash_handle, NULL, 0, NULL, 0, 0);
|
||||||
|
|
||||||
|
case CALG_SHA_512:
|
||||||
|
return !BCryptCreateHash(BCRYPT_SHA512_ALG_HANDLE, hash_handle, NULL, 0, NULL, 0, 0);
|
||||||
|
|
||||||
|
default:
|
||||||
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (status) return FALSE;
|
|
||||||
|
|
||||||
status = BCryptCreateHash(provider, hash_handle, NULL, 0, NULL, 0, 0);
|
|
||||||
BCryptCloseAlgorithmProvider(provider, 0);
|
|
||||||
return !status;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL update_hash_impl(BCRYPT_HASH_HANDLE hash_handle, const BYTE *pbData, DWORD dwDataLen)
|
BOOL update_hash_impl(BCRYPT_HASH_HANDLE hash_handle, const BYTE *pbData, DWORD dwDataLen)
|
||||||
|
|
Loading…
Reference in a new issue