2 * Copyright 2002 Mike McCormack for CodeWeavers
3 * Copyright 2005 Juan Lang
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
29 #include "crypt32_private.h"
30 #include "wine/debug.h"
32 WINE_DEFAULT_DEBUG_CHANNEL(crypt);
34 static HCRYPTPROV hDefProv;
36 BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD fdwReason, PVOID pvReserved)
40 case DLL_PROCESS_ATTACH:
41 DisableThreadLibraryCalls(hInstance);
42 crypt_oid_init(hInstance);
44 case DLL_PROCESS_DETACH:
46 if (hDefProv) CryptReleaseContext(hDefProv, 0);
52 HCRYPTPROV CRYPT_GetDefaultProvider(void)
55 CryptAcquireContextW(&hDefProv, NULL, MS_ENHANCED_PROV_W,
56 PROV_RSA_FULL, CRYPT_VERIFYCONTEXT);
60 typedef void * HLRUCACHE;
62 /* this function is called by Internet Explorer when it is about to verify a
63 * downloaded component. The first parameter appears to be a pointer to an
64 * unknown type, native fails unless it points to a buffer of at least 20 bytes.
65 * The second parameter appears to be an out parameter, whatever it's set to is
66 * passed (by cryptnet.dll) to I_CryptFlushLruCache.
68 BOOL WINAPI I_CryptCreateLruCache(void *unknown, HLRUCACHE *out)
70 FIXME("(%p, %p): stub!\n", unknown, out);
71 *out = (void *)0xbaadf00d;
75 BOOL WINAPI I_CryptFindLruEntryData(DWORD unk0, DWORD unk1, DWORD unk2)
77 FIXME("(%08x, %08x, %08x): stub!\n", unk0, unk1, unk2);
81 DWORD WINAPI I_CryptFlushLruCache(HLRUCACHE h, DWORD unk0, DWORD unk1)
83 FIXME("(%p, %08x, %08x): stub!\n", h, unk0, unk1);
87 HLRUCACHE WINAPI I_CryptFreeLruCache(HLRUCACHE h, DWORD unk0, DWORD unk1)
89 FIXME("(%p, %08x, %08x): stub!\n", h, unk0, unk1);
93 LPVOID WINAPI CryptMemAlloc(ULONG cbSize)
95 return HeapAlloc(GetProcessHeap(), 0, cbSize);
98 LPVOID WINAPI CryptMemRealloc(LPVOID pv, ULONG cbSize)
100 return HeapReAlloc(GetProcessHeap(), 0, pv, cbSize);
103 VOID WINAPI CryptMemFree(LPVOID pv)
105 HeapFree(GetProcessHeap(), 0, pv);
108 DWORD WINAPI I_CryptAllocTls(void)
113 LPVOID WINAPI I_CryptDetachTls(DWORD dwTlsIndex)
117 ret = TlsGetValue(dwTlsIndex);
118 TlsSetValue(dwTlsIndex, NULL);
122 LPVOID WINAPI I_CryptGetTls(DWORD dwTlsIndex)
124 return TlsGetValue(dwTlsIndex);
127 BOOL WINAPI I_CryptSetTls(DWORD dwTlsIndex, LPVOID lpTlsValue)
129 return TlsSetValue(dwTlsIndex, lpTlsValue);
132 BOOL WINAPI I_CryptFreeTls(DWORD dwTlsIndex, DWORD unknown)
134 TRACE("(%d, %d)\n", dwTlsIndex, unknown);
135 return TlsFree(dwTlsIndex);
138 BOOL WINAPI I_CryptGetOssGlobal(DWORD x)
144 HCRYPTPROV WINAPI I_CryptGetDefaultCryptProv(DWORD reserved)
148 TRACE("(%08x)\n", reserved);
152 SetLastError(E_INVALIDARG);
153 return (HCRYPTPROV)0;
155 ret = CRYPT_GetDefaultProvider();
156 CryptContextAddRef(ret, NULL, 0);
160 BOOL WINAPI I_CryptReadTrustedPublisherDWORDValueFromRegistry(LPCWSTR name,
163 static const WCHAR safer[] = {
164 'S','o','f','t','w','a','r','e','\\','P','o','l','i','c','i','e','s','\\',
165 'M','i','c','r','o','s','o','f','t','\\','S','y','s','t','e','m',
166 'C','e','r','t','i','f','i','c','a','t','e','s','\\',
167 'T','r','u','s','t','e','d','P','u','b','l','i','s','h','e','r','\\',
168 'S','a','f','e','r',0 };
173 TRACE("(%s, %p)\n", debugstr_w(name), value);
176 rc = RegCreateKeyW(HKEY_LOCAL_MACHINE, safer, &key);
177 if (rc == ERROR_SUCCESS)
179 DWORD size = sizeof(DWORD);
181 if (!RegQueryValueExW(key, name, NULL, NULL, (LPBYTE)value, &size))
188 int WINAPI I_CryptInstallOssGlobal(DWORD x, DWORD y, DWORD z)
192 FIXME("%08x %08x %08x, return value %d\n", x, y, z,ret);
196 BOOL WINAPI I_CryptInstallAsn1Module(void *x, DWORD y, DWORD z)
198 FIXME("%p %08x %08x\n", x, y, z);
202 BOOL WINAPI I_CryptUninstallAsn1Module(void *x)
208 BOOL WINAPI CryptFormatObject(DWORD dwCertEncodingType, DWORD dwFormatType,
209 DWORD dwFormatStrType, void *pFormatStruct, LPCSTR lpszStructType,
210 const BYTE *pbEncoded, DWORD cbEncoded, void *pbFormat, DWORD *pcbFormat)
212 FIXME("(%08x, %d, %d, %p, %s, %p, %d, %p, %p): stub\n",
213 dwCertEncodingType, dwFormatType, dwFormatStrType, pFormatStruct,
214 debugstr_a(lpszStructType), pbEncoded, cbEncoded, pbFormat, pcbFormat);
218 BOOL WINAPI CryptQueryObject(DWORD dwObjectType, const void* pvObject,
219 DWORD dwExpectedContentTypeFlags, DWORD dwExpectedFormatTypeFlags,
220 DWORD dwFlags, DWORD* pdwMsgAndCertEncodingType, DWORD* pdwContentType,
221 DWORD* pdwFormatType, HCERTSTORE* phCertStore, HCRYPTMSG* phMsg,
222 const void** ppvContext)
224 FIXME( "%08x %p %08x %08x %08x %p %p %p %p %p %p\n", dwObjectType,
225 pvObject, dwExpectedContentTypeFlags, dwExpectedFormatTypeFlags,
226 dwFlags, pdwMsgAndCertEncodingType, pdwContentType, pdwFormatType,
227 phCertStore, phMsg, ppvContext);
231 BOOL WINAPI CryptVerifyMessageSignature(PCRYPT_VERIFY_MESSAGE_PARA pVerifyPara,
232 DWORD dwSignerIndex, const BYTE* pbSignedBlob, DWORD cbSignedBlob,
233 BYTE* pbDecoded, DWORD* pcbDecoded, PCCERT_CONTEXT* ppSignerCert)
235 FIXME("stub: %p, %d, %p, %d, %p, %p, %p\n",
236 pVerifyPara, dwSignerIndex, pbSignedBlob, cbSignedBlob,
237 pbDecoded, pcbDecoded, ppSignerCert);
239 *ppSignerCert = NULL;