2002-04-03 19:55:13 +00:00
|
|
|
/*
|
2003-09-08 19:38:45 +00:00
|
|
|
* Copyright 2002 Mike McCormack for CodeWeavers
|
2005-06-14 11:38:36 +00:00
|
|
|
* Copyright 2005 Juan Lang
|
2002-04-03 19:55:13 +00:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2006-05-18 12:49:52 +00:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2002-04-03 19:55:13 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
2003-09-05 23:08:26 +00:00
|
|
|
#include <stdarg.h>
|
2003-12-11 04:26:05 +00:00
|
|
|
#include <stdio.h>
|
2003-09-05 23:08:26 +00:00
|
|
|
|
|
|
|
#include "windef.h"
|
2002-04-03 19:55:13 +00:00
|
|
|
#include "winbase.h"
|
2002-06-13 22:02:17 +00:00
|
|
|
#include "wincrypt.h"
|
2003-12-11 04:26:05 +00:00
|
|
|
#include "winreg.h"
|
2006-08-09 21:45:34 +00:00
|
|
|
#include "winuser.h"
|
2007-09-11 14:48:04 +00:00
|
|
|
#include "i_cryptasn1tls.h"
|
2005-08-25 09:51:59 +00:00
|
|
|
#include "crypt32_private.h"
|
2002-08-16 01:36:53 +00:00
|
|
|
#include "wine/debug.h"
|
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(crypt);
|
2002-06-13 22:02:17 +00:00
|
|
|
|
2005-08-25 09:51:59 +00:00
|
|
|
static HCRYPTPROV hDefProv;
|
|
|
|
|
|
|
|
BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD fdwReason, PVOID pvReserved)
|
|
|
|
{
|
|
|
|
switch (fdwReason)
|
|
|
|
{
|
2005-12-02 10:28:09 +00:00
|
|
|
case DLL_PROCESS_ATTACH:
|
2006-01-09 16:17:37 +00:00
|
|
|
DisableThreadLibraryCalls(hInstance);
|
2006-02-23 21:18:13 +00:00
|
|
|
crypt_oid_init(hInstance);
|
2005-12-02 10:28:09 +00:00
|
|
|
break;
|
2005-08-25 09:51:59 +00:00
|
|
|
case DLL_PROCESS_DETACH:
|
2006-02-23 21:18:13 +00:00
|
|
|
crypt_oid_free();
|
2007-07-10 00:07:54 +00:00
|
|
|
crypt_sip_free();
|
2007-08-15 23:22:43 +00:00
|
|
|
default_chain_engine_free();
|
2005-08-25 09:51:59 +00:00
|
|
|
if (hDefProv) CryptReleaseContext(hDefProv, 0);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
HCRYPTPROV CRYPT_GetDefaultProvider(void)
|
|
|
|
{
|
|
|
|
if (!hDefProv)
|
|
|
|
CryptAcquireContextW(&hDefProv, NULL, MS_ENHANCED_PROV_W,
|
|
|
|
PROV_RSA_FULL, CRYPT_VERIFYCONTEXT);
|
|
|
|
return hDefProv;
|
|
|
|
}
|
|
|
|
|
2005-11-28 19:52:13 +00:00
|
|
|
typedef void * HLRUCACHE;
|
|
|
|
|
|
|
|
/* this function is called by Internet Explorer when it is about to verify a
|
|
|
|
* downloaded component. The first parameter appears to be a pointer to an
|
|
|
|
* unknown type, native fails unless it points to a buffer of at least 20 bytes.
|
|
|
|
* The second parameter appears to be an out parameter, whatever it's set to is
|
|
|
|
* passed (by cryptnet.dll) to I_CryptFlushLruCache.
|
|
|
|
*/
|
|
|
|
BOOL WINAPI I_CryptCreateLruCache(void *unknown, HLRUCACHE *out)
|
2002-04-03 19:55:13 +00:00
|
|
|
{
|
2005-11-28 19:52:13 +00:00
|
|
|
FIXME("(%p, %p): stub!\n", unknown, out);
|
|
|
|
*out = (void *)0xbaadf00d;
|
|
|
|
return TRUE;
|
2002-04-03 19:55:13 +00:00
|
|
|
}
|
|
|
|
|
2005-11-28 19:52:13 +00:00
|
|
|
BOOL WINAPI I_CryptFindLruEntryData(DWORD unk0, DWORD unk1, DWORD unk2)
|
2002-04-03 19:55:13 +00:00
|
|
|
{
|
2006-10-04 04:58:09 +00:00
|
|
|
FIXME("(%08x, %08x, %08x): stub!\n", unk0, unk1, unk2);
|
2002-04-03 19:55:13 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2005-11-28 19:52:13 +00:00
|
|
|
DWORD WINAPI I_CryptFlushLruCache(HLRUCACHE h, DWORD unk0, DWORD unk1)
|
2002-04-03 19:55:13 +00:00
|
|
|
{
|
2006-10-04 04:58:09 +00:00
|
|
|
FIXME("(%p, %08x, %08x): stub!\n", h, unk0, unk1);
|
2005-11-28 19:52:13 +00:00
|
|
|
return 0;
|
2002-04-03 19:55:13 +00:00
|
|
|
}
|
|
|
|
|
2005-11-28 19:52:13 +00:00
|
|
|
HLRUCACHE WINAPI I_CryptFreeLruCache(HLRUCACHE h, DWORD unk0, DWORD unk1)
|
2002-04-03 19:55:13 +00:00
|
|
|
{
|
2006-10-04 04:58:09 +00:00
|
|
|
FIXME("(%p, %08x, %08x): stub!\n", h, unk0, unk1);
|
2005-11-28 19:52:13 +00:00
|
|
|
return h;
|
2002-04-03 19:55:13 +00:00
|
|
|
}
|
2002-06-13 22:02:17 +00:00
|
|
|
|
2005-10-27 10:24:20 +00:00
|
|
|
LPVOID WINAPI CryptMemAlloc(ULONG cbSize)
|
|
|
|
{
|
|
|
|
return HeapAlloc(GetProcessHeap(), 0, cbSize);
|
|
|
|
}
|
|
|
|
|
|
|
|
LPVOID WINAPI CryptMemRealloc(LPVOID pv, ULONG cbSize)
|
|
|
|
{
|
|
|
|
return HeapReAlloc(GetProcessHeap(), 0, pv, cbSize);
|
|
|
|
}
|
|
|
|
|
|
|
|
VOID WINAPI CryptMemFree(LPVOID pv)
|
|
|
|
{
|
|
|
|
HeapFree(GetProcessHeap(), 0, pv);
|
|
|
|
}
|
|
|
|
|
|
|
|
DWORD WINAPI I_CryptAllocTls(void)
|
|
|
|
{
|
|
|
|
return TlsAlloc();
|
|
|
|
}
|
|
|
|
|
|
|
|
LPVOID WINAPI I_CryptDetachTls(DWORD dwTlsIndex)
|
|
|
|
{
|
|
|
|
LPVOID ret;
|
|
|
|
|
|
|
|
ret = TlsGetValue(dwTlsIndex);
|
|
|
|
TlsSetValue(dwTlsIndex, NULL);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
LPVOID WINAPI I_CryptGetTls(DWORD dwTlsIndex)
|
|
|
|
{
|
|
|
|
return TlsGetValue(dwTlsIndex);
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOL WINAPI I_CryptSetTls(DWORD dwTlsIndex, LPVOID lpTlsValue)
|
|
|
|
{
|
|
|
|
return TlsSetValue(dwTlsIndex, lpTlsValue);
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOL WINAPI I_CryptFreeTls(DWORD dwTlsIndex, DWORD unknown)
|
|
|
|
{
|
2006-10-04 04:58:09 +00:00
|
|
|
TRACE("(%d, %d)\n", dwTlsIndex, unknown);
|
2005-10-27 10:24:20 +00:00
|
|
|
return TlsFree(dwTlsIndex);
|
|
|
|
}
|
2006-01-23 10:54:58 +00:00
|
|
|
|
|
|
|
BOOL WINAPI I_CryptGetOssGlobal(DWORD x)
|
|
|
|
{
|
2006-10-04 04:58:09 +00:00
|
|
|
FIXME("%08x\n", x);
|
2006-01-23 10:54:58 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2006-08-12 03:37:04 +00:00
|
|
|
HCRYPTPROV WINAPI I_CryptGetDefaultCryptProv(DWORD reserved)
|
2006-08-09 21:45:34 +00:00
|
|
|
{
|
2006-08-12 03:37:04 +00:00
|
|
|
HCRYPTPROV ret;
|
|
|
|
|
2006-10-04 04:58:09 +00:00
|
|
|
TRACE("(%08x)\n", reserved);
|
2006-08-12 03:37:04 +00:00
|
|
|
|
|
|
|
if (reserved)
|
|
|
|
{
|
|
|
|
SetLastError(E_INVALIDARG);
|
|
|
|
return (HCRYPTPROV)0;
|
|
|
|
}
|
|
|
|
ret = CRYPT_GetDefaultProvider();
|
|
|
|
CryptContextAddRef(ret, NULL, 0);
|
|
|
|
return ret;
|
2006-08-09 21:45:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
BOOL WINAPI I_CryptReadTrustedPublisherDWORDValueFromRegistry(LPCWSTR name,
|
|
|
|
DWORD *value)
|
|
|
|
{
|
|
|
|
static const WCHAR safer[] = {
|
|
|
|
'S','o','f','t','w','a','r','e','\\','P','o','l','i','c','i','e','s','\\',
|
|
|
|
'M','i','c','r','o','s','o','f','t','\\','S','y','s','t','e','m',
|
|
|
|
'C','e','r','t','i','f','i','c','a','t','e','s','\\',
|
|
|
|
'T','r','u','s','t','e','d','P','u','b','l','i','s','h','e','r','\\',
|
|
|
|
'S','a','f','e','r',0 };
|
|
|
|
HKEY key;
|
|
|
|
LONG rc;
|
|
|
|
BOOL ret = FALSE;
|
|
|
|
|
|
|
|
TRACE("(%s, %p)\n", debugstr_w(name), value);
|
|
|
|
|
2006-08-12 03:37:04 +00:00
|
|
|
*value = 0;
|
2006-08-09 21:45:34 +00:00
|
|
|
rc = RegCreateKeyW(HKEY_LOCAL_MACHINE, safer, &key);
|
|
|
|
if (rc == ERROR_SUCCESS)
|
|
|
|
{
|
|
|
|
DWORD size = sizeof(DWORD);
|
|
|
|
|
|
|
|
if (!RegQueryValueExW(key, name, NULL, NULL, (LPBYTE)value, &size))
|
|
|
|
ret = TRUE;
|
|
|
|
RegCloseKey(key);
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2007-08-04 01:13:39 +00:00
|
|
|
DWORD WINAPI I_CryptInstallOssGlobal(DWORD x, DWORD y, DWORD z)
|
2006-01-23 10:54:58 +00:00
|
|
|
{
|
2006-11-24 19:32:10 +00:00
|
|
|
static int ret = 8;
|
|
|
|
ret++;
|
|
|
|
FIXME("%08x %08x %08x, return value %d\n", x, y, z,ret);
|
|
|
|
return ret;
|
2006-01-23 10:54:58 +00:00
|
|
|
}
|
2006-02-13 12:22:25 +00:00
|
|
|
|
2007-09-11 14:48:04 +00:00
|
|
|
BOOL WINAPI I_CryptInstallAsn1Module(ASN1module_t x, DWORD y, void* z)
|
2006-02-22 15:37:24 +00:00
|
|
|
{
|
2007-09-11 14:48:04 +00:00
|
|
|
FIXME("(%p %08x %p): stub\n", x, y, z);
|
2006-02-22 15:37:24 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2007-09-11 14:48:04 +00:00
|
|
|
BOOL WINAPI I_CryptUninstallAsn1Module(HCRYPTASN1MODULE x)
|
2006-08-09 21:45:34 +00:00
|
|
|
{
|
2007-09-11 14:48:04 +00:00
|
|
|
FIXME("(%08x): stub\n", x);
|
2006-08-09 21:45:34 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2007-09-11 14:48:04 +00:00
|
|
|
ASN1decoding_t WINAPI I_CryptGetAsn1Decoder(HCRYPTASN1MODULE x)
|
2007-08-09 20:20:00 +00:00
|
|
|
{
|
2007-09-11 14:48:04 +00:00
|
|
|
FIXME("(%08x): stub\n", x);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
ASN1encoding_t WINAPI I_CryptGetAsn1Encoder(HCRYPTASN1MODULE x)
|
|
|
|
{
|
|
|
|
FIXME("(%08x): stub\n", x);
|
2007-08-09 20:20:00 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2006-08-22 15:10:17 +00:00
|
|
|
BOOL WINAPI CryptFormatObject(DWORD dwCertEncodingType, DWORD dwFormatType,
|
|
|
|
DWORD dwFormatStrType, void *pFormatStruct, LPCSTR lpszStructType,
|
|
|
|
const BYTE *pbEncoded, DWORD cbEncoded, void *pbFormat, DWORD *pcbFormat)
|
|
|
|
{
|
2006-10-04 04:58:09 +00:00
|
|
|
FIXME("(%08x, %d, %d, %p, %s, %p, %d, %p, %p): stub\n",
|
2006-08-22 15:10:17 +00:00
|
|
|
dwCertEncodingType, dwFormatType, dwFormatStrType, pFormatStruct,
|
|
|
|
debugstr_a(lpszStructType), pbEncoded, cbEncoded, pbFormat, pcbFormat);
|
|
|
|
return FALSE;
|
|
|
|
}
|