Commit ba1631ad authored by Hans Leidekker's avatar Hans Leidekker Committed by Alexandre Julliard

fusion: Use BCrypt algorithm pseudo-handles.

parent c7e0f923
...@@ -809,10 +809,8 @@ HRESULT assembly_get_pubkey_token(ASSEMBLY *assembly, LPWSTR *token) ...@@ -809,10 +809,8 @@ HRESULT assembly_get_pubkey_token(ASSEMBLY *assembly, LPWSTR *token)
ULONG i, size; ULONG i, size;
LONG offset; LONG offset;
BYTE hashdata[20], *pubkey, *ptr; BYTE hashdata[20], *pubkey, *ptr;
BCRYPT_ALG_HANDLE alg;
BYTE tokbytes[BYTES_PER_TOKEN]; BYTE tokbytes[BYTES_PER_TOKEN];
HRESULT hr = E_FAIL; WCHAR *tok;
LPWSTR tok;
DWORD idx; DWORD idx;
*token = NULL; *token = NULL;
...@@ -833,33 +831,20 @@ HRESULT assembly_get_pubkey_token(ASSEMBLY *assembly, LPWSTR *token) ...@@ -833,33 +831,20 @@ HRESULT assembly_get_pubkey_token(ASSEMBLY *assembly, LPWSTR *token)
pubkey = assembly_get_blob(assembly, idx, &size); pubkey = assembly_get_blob(assembly, idx, &size);
if (BCryptOpenAlgorithmProvider(&alg, BCRYPT_SHA1_ALGORITHM, MS_PRIMITIVE_PROVIDER, 0) != STATUS_SUCCESS) if (BCryptHash(BCRYPT_SHA1_ALG_HANDLE, NULL, 0, pubkey, size, hashdata, sizeof(hashdata)) != STATUS_SUCCESS)
return E_FAIL; return E_FAIL;
if (BCryptHash(alg, NULL, 0, pubkey, size, hashdata, sizeof(hashdata)) != STATUS_SUCCESS)
{
hr = E_FAIL;
goto done;
}
size = sizeof(hashdata); size = sizeof(hashdata);
for (i = size - 1; i >= size - 8; i--) for (i = size - 1; i >= size - 8; i--)
tokbytes[size - i - 1] = hashdata[i]; tokbytes[size - i - 1] = hashdata[i];
if (!(tok = malloc((TOKEN_LENGTH + 1) * sizeof(WCHAR)))) if (!(tok = malloc((TOKEN_LENGTH + 1) * sizeof(WCHAR))))
{ return E_OUTOFMEMORY;
hr = E_OUTOFMEMORY;
goto done;
}
token_to_str(tokbytes, tok); token_to_str(tokbytes, tok);
*token = tok; *token = tok;
hr = S_OK; return S_OK;
done:
BCryptCloseAlgorithmProvider(alg, 0);
return hr;
} }
HRESULT assembly_get_runtime_version(ASSEMBLY *assembly, LPSTR *version) HRESULT assembly_get_runtime_version(ASSEMBLY *assembly, LPSTR *version)
......
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