Commit 5bc1b8ac authored by Juan Lang's avatar Juan Lang Committed by Alexandre Julliard

crypt32: Improve undocumented functions.

- Test and implement I_CryptGetDefaultCryptProv (and correct its parameter list) - I_CryptReadTrustedPublisherDWORDValueFromRegistry always initializes its out parameter, correct and show with a test.
parent 5c850c6a
......@@ -186,7 +186,7 @@
@ stdcall I_CryptFlushLruCache(ptr long long)
@ stdcall I_CryptFreeLruCache(ptr long long)
@ stdcall I_CryptFreeTls(long long)
@ stdcall I_CryptGetDefaultCryptProv(long long long)
@ stdcall I_CryptGetDefaultCryptProv(long)
@ stub I_CryptGetDefaultCryptProvForEncrypt
@ stdcall I_CryptGetOssGlobal(long)
@ stdcall I_CryptGetTls(long)
......
......@@ -271,10 +271,20 @@ BOOL WINAPI I_CryptGetOssGlobal(DWORD x)
return FALSE;
}
BOOL WINAPI I_CryptGetDefaultCryptProv(DWORD x, DWORD y, DWORD z)
HCRYPTPROV WINAPI I_CryptGetDefaultCryptProv(DWORD reserved)
{
FIXME("%08lx %08lx %08lx\n", x, y, z);
return FALSE;
HCRYPTPROV ret;
TRACE("(%08lx)\n", reserved);
if (reserved)
{
SetLastError(E_INVALIDARG);
return (HCRYPTPROV)0;
}
ret = CRYPT_GetDefaultProvider();
CryptContextAddRef(ret, NULL, 0);
return ret;
}
BOOL WINAPI I_CryptReadTrustedPublisherDWORDValueFromRegistry(LPCWSTR name,
......@@ -292,6 +302,7 @@ BOOL WINAPI I_CryptReadTrustedPublisherDWORDValueFromRegistry(LPCWSTR name,
TRACE("(%s, %p)\n", debugstr_w(name), value);
*value = 0;
rc = RegCreateKeyW(HKEY_LOCAL_MACHINE, safer, &key);
if (rc == ERROR_SUCCESS)
{
......
......@@ -295,7 +295,7 @@ static void test_readTrustedPublisherDWORD(void)
static const WCHAR authenticodeFlags[] = { 'A','u','t','h','e','n',
't','i','c','o','d','e','F','l','a','g','s',0 };
BOOL ret, exists = FALSE;
DWORD size, readFlags, returnedFlags;
DWORD size, readFlags = 0, returnedFlags;
HKEY key;
LONG rc;
......@@ -308,14 +308,41 @@ static void test_readTrustedPublisherDWORD(void)
if (rc == ERROR_SUCCESS)
exists = TRUE;
}
returnedFlags = 0xdeadbeef;
ret = pReadDWORD(authenticodeFlags, &returnedFlags);
ok(ret == exists, "Unexpected return value\n");
if (exists)
ok(readFlags == returnedFlags,
"Expected flags %08lx, got %08lx\n", readFlags, returnedFlags);
ok(readFlags == returnedFlags,
"Expected flags %08lx, got %08lx\n", readFlags, returnedFlags);
}
}
typedef HCRYPTPROV (WINAPI *I_CryptGetDefaultCryptProvFunc)(DWORD w);
static void test_getDefaultCryptProv(void)
{
I_CryptGetDefaultCryptProvFunc pI_CryptGetDefaultCryptProv;
HCRYPTPROV prov;
if (!hCrypt) return;
pI_CryptGetDefaultCryptProv = (I_CryptGetDefaultCryptProvFunc)
GetProcAddress(hCrypt, "I_CryptGetDefaultCryptProv");
if (!pI_CryptGetDefaultCryptProv) return;
prov = pI_CryptGetDefaultCryptProv(0xdeadbeef);
ok(prov == 0 && GetLastError() == E_INVALIDARG,
"Expected E_INVALIDARG, got %08lx\n", GetLastError());
prov = pI_CryptGetDefaultCryptProv(PROV_RSA_FULL);
ok(prov == 0 && GetLastError() == E_INVALIDARG,
"Expected E_INVALIDARG, got %08lx\n", GetLastError());
prov = pI_CryptGetDefaultCryptProv(1);
ok(prov == 0 && GetLastError() == E_INVALIDARG,
"Expected E_INVALIDARG, got %08lx\n", GetLastError());
prov = pI_CryptGetDefaultCryptProv(0);
ok(prov != 0, "I_CryptGetDefaultCryptProv failed: %08lx\n", GetLastError());
CryptReleaseContext(prov, 0);
}
START_TEST(main)
{
hCrypt = LoadLibraryA("crypt32.dll");
......@@ -326,4 +353,5 @@ START_TEST(main)
test_cryptAllocate();
test_cryptTls();
test_readTrustedPublisherDWORD();
test_getDefaultCryptProv();
}
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