Commit 6db0fc5c authored by Hans Leidekker's avatar Hans Leidekker Committed by Alexandre Julliard

rsaenh: Use BCrypt algorithm pseudo-handles.

parent 4918be2c
......@@ -36,48 +36,32 @@ BOOL WINAPI SystemFunction036(PVOID pbBuffer, ULONG dwLen);
BOOL init_hash_impl(ALG_ID aiAlgid, BCRYPT_HASH_HANDLE *hash_handle)
{
BCRYPT_ALG_HANDLE provider;
NTSTATUS status;
switch (aiAlgid)
switch (aiAlgid)
{
case CALG_MD2:
status = BCryptOpenAlgorithmProvider(&provider, BCRYPT_MD2_ALGORITHM, MS_PRIMITIVE_PROVIDER, 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_MD2:
return !BCryptCreateHash(BCRYPT_MD2_ALG_HANDLE, hash_handle, NULL, 0, NULL, 0, 0);
case CALG_SHA_256:
status = BCryptOpenAlgorithmProvider(&provider, BCRYPT_SHA256_ALGORITHM, MS_PRIMITIVE_PROVIDER, 0);
break;
case CALG_MD4:
return !BCryptCreateHash(BCRYPT_MD4_ALG_HANDLE, hash_handle, NULL, 0, NULL, 0, 0);
case CALG_SHA_384:
status = BCryptOpenAlgorithmProvider(&provider, BCRYPT_SHA384_ALGORITHM, MS_PRIMITIVE_PROVIDER, 0);
break;
case CALG_MD5:
return !BCryptCreateHash(BCRYPT_MD5_ALG_HANDLE, hash_handle, NULL, 0, NULL, 0, 0);
case CALG_SHA_512:
status = BCryptOpenAlgorithmProvider(&provider, BCRYPT_SHA512_ALGORITHM, MS_PRIMITIVE_PROVIDER, 0);
break;
case CALG_SHA:
return !BCryptCreateHash(BCRYPT_SHA1_ALG_HANDLE, hash_handle, NULL, 0, NULL, 0, 0);
default:
return TRUE;
}
case CALG_SHA_256:
return !BCryptCreateHash(BCRYPT_SHA256_ALG_HANDLE, hash_handle, NULL, 0, NULL, 0, 0);
if (status) return FALSE;
case CALG_SHA_384:
return !BCryptCreateHash(BCRYPT_SHA384_ALG_HANDLE, hash_handle, NULL, 0, NULL, 0, 0);
status = BCryptCreateHash(provider, hash_handle, NULL, 0, NULL, 0, 0);
BCryptCloseAlgorithmProvider(provider, 0);
return !status;
case CALG_SHA_512:
return !BCryptCreateHash(BCRYPT_SHA512_ALG_HANDLE, hash_handle, NULL, 0, NULL, 0, 0);
default:
return TRUE;
}
}
BOOL update_hash_impl(BCRYPT_HASH_HANDLE hash_handle, const BYTE *pbData, DWORD dwDataLen)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment