IsdialogMessage16 must not process messages that are not intended for
[wine.git] / dlls / crypt32 / main.c
blob19bd29668a586f5f79a6624bef287b11fbc9c729
1 /*
2 * Copyright 2002 Mike McCormack for CodeWeavers
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 #include "config.h"
20 #include <stdarg.h>
21 #include <stdio.h>
23 #include "windef.h"
24 #include "winbase.h"
25 #include "wincrypt.h"
26 #include "winreg.h"
27 #include "winnls.h"
28 #include "mssip.h"
29 #include "wine/debug.h"
31 WINE_DEFAULT_DEBUG_CHANNEL(crypt);
33 /* this function is called by Internet Explorer when it is about to verify a downloaded component */
34 BOOL WINAPI I_CryptCreateLruCache(DWORD x, DWORD y)
36 FIXME("stub!\n");
37 return FALSE;
40 /* these functions all have an unknown number of args */
41 BOOL WINAPI I_CryptFindLruEntryData(DWORD x)
43 FIXME("stub!\n");
44 return FALSE;
47 BOOL WINAPI I_CryptFlushLruCache(DWORD x)
49 FIXME("stub!\n");
50 return FALSE;
53 BOOL WINAPI I_CryptFreeLruCache(DWORD x)
55 FIXME("stub!\n");
56 return FALSE;
59 BOOL WINAPI CryptProtectData(DATA_BLOB* pDataIn, LPCWSTR szDataDescr, DATA_BLOB* pOptionalEntropy,
60 PVOID pvReserved, CRYPTPROTECT_PROMPTSTRUCT* pPromptStruct,
61 DWORD dwFlags, DATA_BLOB* pDataOut)
63 FIXME("stub!\n");
64 return FALSE;
68 * (0x1001350, %eax, 0, 0, 9);
71 BOOL WINAPI CertOpenStore(LPSTR dw1, DWORD dw2, DWORD dw3, DWORD dw4, DWORD dw5)
73 FIXME("(%s, %ld, %ld, %ld, %ld), stub.\n", debugstr_a(dw1), dw2, dw3, dw4, dw5);
74 return TRUE;
77 BOOL WINAPI CryptSIPRemoveProvider(GUID *pgProv)
79 FIXME("stub!\n");
80 return FALSE;
83 /* convert a guid to a wide character string */
84 static void CRYPT_guid2wstr( LPGUID guid, LPWSTR wstr )
86 char str[40];
88 sprintf(str, "{%08lX-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}",
89 guid->Data1, guid->Data2, guid->Data3,
90 guid->Data4[0], guid->Data4[1], guid->Data4[2], guid->Data4[3],
91 guid->Data4[4], guid->Data4[5], guid->Data4[6], guid->Data4[7] );
92 MultiByteToWideChar( CP_ACP, 0, str, -1, wstr, 40 );
96 * Helper for CryptSIPAddProvider
98 * Add a registry key containing a dll name and function under
99 * "Software\\Microsoft\\Cryptography\\OID\\EncodingType 0\\<func>\\<guid>"
101 static LONG CRYPT_SIPWriteFunction( LPGUID guid, LPCWSTR szKey,
102 LPCWSTR szDll, LPCWSTR szFunction )
104 const WCHAR szOID[] = {
105 'S','o','f','t','w','a','r','e','\\',
106 'M','i','c','r','o','s','o','f','t','\\',
107 'C','r','y','p','t','o','g','r','a','p','h','y','\\',
108 'O','I','D','\\',
109 'E','n','c','o','d','i','n','g','T','y','p','e',' ','0','\\',
110 'C','r','y','p','t','S','I','P','D','l','l', 0 };
111 const WCHAR szBackSlash[] = { '\\', 0 };
112 const WCHAR szDllName[] = { 'D','l','l',0 };
113 const WCHAR szFuncName[] = { 'F','u','n','c','N','a','m','e',0 };
114 WCHAR szFullKey[ 0x100 ];
115 LONG r;
116 HKEY hKey;
118 if( !szFunction )
119 return ERROR_SUCCESS;
121 /* max length of szFullKey depends on our code only, so we won't overrun */
122 lstrcpyW( szFullKey, szOID );
123 lstrcatW( szFullKey, szKey );
124 lstrcatW( szFullKey, szBackSlash );
125 CRYPT_guid2wstr( guid, &szFullKey[ lstrlenW( szFullKey ) ] );
126 lstrcatW( szFullKey, szBackSlash );
128 TRACE("key is %s\n", debugstr_w( szFullKey ) );
130 r = RegCreateKeyW( HKEY_LOCAL_MACHINE, szFullKey, &hKey );
131 if( r != ERROR_SUCCESS )
132 return r;
134 /* write the values */
135 RegSetValueExW( hKey, szFuncName, 0, REG_SZ, (LPBYTE) szFunction,
136 ( lstrlenW( szFunction ) + 1 ) * sizeof (WCHAR) );
137 RegSetValueExW( hKey, szDllName, 0, REG_SZ, (LPBYTE) szDll,
138 ( lstrlenW( szDll ) + 1) * sizeof (WCHAR) );
140 RegCloseKey( hKey );
142 return ERROR_SUCCESS;
145 BOOL WINAPI CryptSIPAddProvider(SIP_ADD_NEWPROVIDER *psNewProv)
147 const WCHAR szCreate[] = {
148 'C','r','e','a','t','e',
149 'I','n','d','i','r','e','c','t','D','a','t','a',0};
150 const WCHAR szGetSigned[] = {
151 'G','e','t','S','i','g','n','e','d','D','a','t','a','M','s','g',0};
152 const WCHAR szIsMyFile[] = {
153 'I','s','M','y','F','i','l','e','T','y','p','e', 0 };
154 const WCHAR szPutSigned[] = {
155 'P','u','t','S','i','g','n','e','d','D','a','t','a','M','s','g',0};
156 const WCHAR szRemoveSigned[] = {
157 'R','e','m','o','v','e',
158 'S','i','g','n','e','d','D','a','t','a','M','s','g',0};
159 const WCHAR szVerify[] = {
160 'V','e','r','i','f','y',
161 'I','n','d','i','r','e','c','t','D','a','t','a',0};
163 TRACE("%p\n", psNewProv);
165 if( !psNewProv )
166 return FALSE;
168 TRACE("%s %s %s %s\n",
169 debugstr_guid( psNewProv->pgSubject ),
170 debugstr_w( psNewProv->pwszDLLFileName ),
171 debugstr_w( psNewProv->pwszMagicNumber ),
172 debugstr_w( psNewProv->pwszIsFunctionName ) );
174 #define CRYPT_SIPADDPROV( key, field ) \
175 CRYPT_SIPWriteFunction( psNewProv->pgSubject, key, \
176 psNewProv->pwszDLLFileName, psNewProv->field)
178 CRYPT_SIPADDPROV( szGetSigned, pwszGetFuncName );
179 CRYPT_SIPADDPROV( szPutSigned, pwszPutFuncName );
180 CRYPT_SIPADDPROV( szCreate, pwszCreateFuncName );
181 CRYPT_SIPADDPROV( szVerify, pwszVerifyFuncName );
182 CRYPT_SIPADDPROV( szRemoveSigned, pwszRemoveFuncName );
183 CRYPT_SIPADDPROV( szIsMyFile, pwszIsFunctionNameFmt2 );
185 #undef CRYPT_SIPADDPROV
187 return TRUE;
190 BOOL WINAPI CryptSIPRetrieveSubjectGuid
191 (LPCWSTR FileName, HANDLE hFileIn, GUID *pgSubject)
193 FIXME("stub!\n");
194 return FALSE;
197 BOOL WINAPI CryptSIPLoad
198 (const GUID *pgSubject, DWORD dwFlags, SIP_DISPATCH_INFO *pSipDispatch)
200 FIXME("stub!\n");
201 return FALSE;
204 BOOL WINAPI CryptGetOIDFunctionValue(DWORD dwEncodingType, LPCSTR pszFuncName,
205 LPCSTR pszOID, LPCWSTR pwszValueName,
206 DWORD *pdwValueType, BYTE *pbValueData,
207 DWORD *pcbValueData)
209 FIXME("(%lx,%s,%s,%s,%p,%p,%p) stub!\n", dwEncodingType, pszFuncName, pszOID,
210 debugstr_w(pwszValueName), pdwValueType, pbValueData, pcbValueData);
211 return FALSE;
214 BOOL WINAPI CryptRegisterDefaultOIDFunction(DWORD dwEncodingType,
215 LPCSTR pszFuncName, DWORD dwIndex,
216 LPCWSTR pwszDll)
218 FIXME("(%lx,%s,%lx,%s) stub!\n", dwEncodingType, pszFuncName, dwIndex,
219 debugstr_w(pwszDll));
220 return FALSE;
223 BOOL WINAPI CryptRegisterOIDFunction(DWORD dwEncodingType, LPCSTR pszFuncName,
224 LPCSTR pszOID, LPCWSTR pwszDll, LPCSTR pszOverrideFuncName)
226 LONG r;
227 const char szOID[] = "Software\\Microsoft\\Cryptography\\OID";
228 const char szType1[] = "EncodingType 1";
229 const WCHAR szDllName[] = { 'D','l','l',0 };
230 HKEY hKey;
231 LPSTR szKey;
232 UINT len;
234 TRACE("%lx %s %s %s %s\n", dwEncodingType, pszFuncName, pszOID,
235 debugstr_w(pwszDll), pszOverrideFuncName);
237 if( dwEncodingType & PKCS_7_ASN_ENCODING )
238 FIXME("PKCS_7_ASN_ENCODING not implemented\n");
240 if( dwEncodingType & X509_ASN_ENCODING )
242 /* construct the name of the key */
243 len = sizeof szOID + sizeof szType1 + 2 +
244 lstrlenA( pszFuncName ) + lstrlenA( pszOID );
245 szKey = HeapAlloc( GetProcessHeap(), 0, len );
246 if( !szKey )
247 return FALSE;
248 sprintf( szKey, "%s\\%s\\%s\\%s",
249 szOID, szType1, pszFuncName, pszOID );
251 TRACE("Key name is %s\n", debugstr_a( szKey ) );
253 r = RegCreateKeyA( HKEY_LOCAL_MACHINE, szKey, &hKey );
254 HeapFree( GetProcessHeap(), 0, szKey );
255 if( r != ERROR_SUCCESS )
256 return FALSE;
258 /* write the values */
259 RegSetValueExA( hKey, "FuncName", 0, REG_SZ, pszOverrideFuncName,
260 lstrlenA( pszOverrideFuncName ) + 1 );
261 RegSetValueExW( hKey, szDllName, 0, REG_SZ, (LPBYTE) pwszDll,
262 (lstrlenW( pwszDll ) + 1) * sizeof (WCHAR) );
264 RegCloseKey( hKey );
267 return TRUE;
270 PCCERT_CONTEXT WINAPI CertEnumCertificatesInStore(HCERTSTORE hCertStore, PCCERT_CONTEXT pPrev)
272 FIXME("(%p,%p)\n", hCertStore, pPrev);
273 return NULL;
276 BOOL WINAPI CertSaveStore(HCERTSTORE hCertStore, DWORD dwMsgAndCertEncodingType,
277 DWORD dwSaveAs, DWORD dwSaveTo, void* pvSaveToPara, DWORD dwFlags)
279 FIXME("(%p,%ld,%ld,%ld,%p,%08lx) stub!\n", hCertStore,
280 dwMsgAndCertEncodingType, dwSaveAs, dwSaveTo, pvSaveToPara, dwFlags);
281 return TRUE;
284 PCCRL_CONTEXT WINAPI CertCreateCRLContext( DWORD dwCertEncodingType,
285 const BYTE* pbCrlEncoded, DWORD cbCrlEncoded)
287 FIXME("%08lx %p %08lx\n", dwCertEncodingType, pbCrlEncoded, cbCrlEncoded);
288 return NULL;
291 BOOL WINAPI CertCloseStore( HCERTSTORE hCertStore, DWORD dwFlags )
293 FIXME("%p %08lx\n", hCertStore, dwFlags );
294 return TRUE;