wintrust: Use the return value of CryptRegisterOIDFunction.
[wine] / dlls / wintrust / register.c
1 /*
2  * Register related wintrust functions
3  *
4  * Copyright 2006 Paul Vriens
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19  */
20
21 #include <stdarg.h>
22
23 #include "windef.h"
24 #include "winbase.h"
25 #include "winerror.h"
26 #include "winuser.h"
27 #include "winreg.h"
28 #include "winnls.h"
29
30 #include "guiddef.h"
31 #include "wintrust.h"
32 #include "softpub.h"
33
34 #include "wine/debug.h"
35
36 WINE_DEFAULT_DEBUG_CHANNEL(wintrust);
37
38 static CRYPT_TRUST_REG_ENTRY SoftpubInitialization;
39 static CRYPT_TRUST_REG_ENTRY SoftpubMessage;
40 static CRYPT_TRUST_REG_ENTRY SoftpubSignature;
41 static CRYPT_TRUST_REG_ENTRY SoftpubCertficate;
42 static CRYPT_TRUST_REG_ENTRY SoftpubCertCheck;
43 static CRYPT_TRUST_REG_ENTRY SoftpubFinalPolicy;
44 static CRYPT_TRUST_REG_ENTRY SoftpubCleanup;
45
46 static CRYPT_TRUST_REG_ENTRY SoftpubDefCertInit;
47
48 static CRYPT_TRUST_REG_ENTRY SoftpubDumpStructure;
49
50 static CRYPT_TRUST_REG_ENTRY HTTPSCertificateTrust;
51 static CRYPT_TRUST_REG_ENTRY HTTPSFinalProv;
52
53 static CRYPT_TRUST_REG_ENTRY OfficeInitializePolicy;
54 static CRYPT_TRUST_REG_ENTRY OfficeCleanupPolicy;
55
56 static CRYPT_TRUST_REG_ENTRY DriverInitializePolicy;
57 static CRYPT_TRUST_REG_ENTRY DriverFinalPolicy;
58 static CRYPT_TRUST_REG_ENTRY DriverCleanupPolicy;
59
60 static CRYPT_TRUST_REG_ENTRY GenericChainCertificateTrust;
61 static CRYPT_TRUST_REG_ENTRY GenericChainFinalProv;
62
63 static const WCHAR Trust[]            = {'S','o','f','t','w','a','r','e','\\',
64                                          'M','i','c','r','o','s','o','f','t','\\',
65                                          'C','r','y','p','t','o','g','r','a','p','h','y','\\',
66                                          'P','r','o','v','i','d','e','r','s','\\',
67                                          'T','r','u','s','t','\\', 0 };
68
69 static const WCHAR Initialization[]   = {'I','n','i','t','i','a','l','i','z','a','t','i','o','n','\\', 0};
70 static const WCHAR Message[]          = {'M','e','s','s','a','g','e','\\', 0};
71 static const WCHAR Signature[]        = {'S','i','g','n','a','t','u','r','e','\\', 0};
72 static const WCHAR Certificate[]      = {'C','e','r','t','i','f','i','c','a','t','e','\\', 0};
73 static const WCHAR CertCheck[]        = {'C','e','r','t','C','h','e','c','k','\\', 0};
74 static const WCHAR FinalPolicy[]      = {'F','i','n','a','l','P','o','l','i','c','y','\\', 0};
75 static const WCHAR DiagnosticPolicy[] = {'D','i','a','g','n','o','s','t','i','c','P','o','l','i','c','y','\\', 0};
76 static const WCHAR Cleanup[]          = {'C','l','e','a','n','u','p','\\', 0};
77
78 static const WCHAR DefaultId[]        = {'D','e','f','a','u','l','t','I','d', 0};
79 static const WCHAR Dll[]              = {'$','D','L','L', 0};
80
81 /***********************************************************************
82  *              WINTRUST_InitRegStructs
83  *
84  * Helper function to allocate and initialize the members of the
85  * CRYPT_TRUST_REG_ENTRY structs.
86  */
87 static void WINTRUST_InitRegStructs(void)
88 {
89 #define WINTRUST_INITREGENTRY( action, dllname, functionname ) \
90     action.cbStruct = sizeof(CRYPT_TRUST_REG_ENTRY); \
91     action.pwszDLLName = HeapAlloc(GetProcessHeap(), 0, sizeof(dllname)); \
92     lstrcpyW(action.pwszDLLName, dllname); \
93     action.pwszFunctionName = HeapAlloc(GetProcessHeap(), 0, sizeof(functionname)); \
94     lstrcpyW(action.pwszFunctionName, functionname);
95
96     WINTRUST_INITREGENTRY(SoftpubInitialization, SP_POLICY_PROVIDER_DLL_NAME, SP_INIT_FUNCTION)
97     WINTRUST_INITREGENTRY(SoftpubMessage, SP_POLICY_PROVIDER_DLL_NAME, SP_OBJTRUST_FUNCTION)
98     WINTRUST_INITREGENTRY(SoftpubSignature, SP_POLICY_PROVIDER_DLL_NAME, SP_SIGTRUST_FUNCTION)
99     WINTRUST_INITREGENTRY(SoftpubCertficate, SP_POLICY_PROVIDER_DLL_NAME, WT_PROVIDER_CERTTRUST_FUNCTION)
100     WINTRUST_INITREGENTRY(SoftpubCertCheck, SP_POLICY_PROVIDER_DLL_NAME, SP_CHKCERT_FUNCTION)
101     WINTRUST_INITREGENTRY(SoftpubFinalPolicy, SP_POLICY_PROVIDER_DLL_NAME, SP_FINALPOLICY_FUNCTION)
102     WINTRUST_INITREGENTRY(SoftpubCleanup, SP_POLICY_PROVIDER_DLL_NAME, SP_CLEANUPPOLICY_FUNCTION)
103     WINTRUST_INITREGENTRY(SoftpubDefCertInit, SP_POLICY_PROVIDER_DLL_NAME, SP_GENERIC_CERT_INIT_FUNCTION)
104     WINTRUST_INITREGENTRY(SoftpubDumpStructure, SP_POLICY_PROVIDER_DLL_NAME, SP_TESTDUMPPOLICY_FUNCTION_TEST)
105     WINTRUST_INITREGENTRY(HTTPSCertificateTrust, SP_POLICY_PROVIDER_DLL_NAME, HTTPS_CERTTRUST_FUNCTION)
106     WINTRUST_INITREGENTRY(HTTPSFinalProv, SP_POLICY_PROVIDER_DLL_NAME, HTTPS_FINALPOLICY_FUNCTION)
107     WINTRUST_INITREGENTRY(OfficeInitializePolicy, OFFICE_POLICY_PROVIDER_DLL_NAME, OFFICE_INITPROV_FUNCTION)
108     WINTRUST_INITREGENTRY(OfficeCleanupPolicy, OFFICE_POLICY_PROVIDER_DLL_NAME, OFFICE_CLEANUPPOLICY_FUNCTION)
109     WINTRUST_INITREGENTRY(DriverInitializePolicy, SP_POLICY_PROVIDER_DLL_NAME, DRIVER_INITPROV_FUNCTION)
110     WINTRUST_INITREGENTRY(DriverFinalPolicy, SP_POLICY_PROVIDER_DLL_NAME, DRIVER_FINALPOLPROV_FUNCTION)
111     WINTRUST_INITREGENTRY(DriverCleanupPolicy, SP_POLICY_PROVIDER_DLL_NAME, DRIVER_CLEANUPPOLICY_FUNCTION)
112     WINTRUST_INITREGENTRY(GenericChainCertificateTrust, SP_POLICY_PROVIDER_DLL_NAME, GENERIC_CHAIN_CERTTRUST_FUNCTION)
113     WINTRUST_INITREGENTRY(GenericChainFinalProv, SP_POLICY_PROVIDER_DLL_NAME, GENERIC_CHAIN_FINALPOLICY_FUNCTION)
114
115 #undef WINTRUST_INITREGENTRY
116 }
117
118 /***********************************************************************
119  *              WINTRUST_FreeRegStructs
120  *
121  * Helper function to free 2 members of the CRYPT_TRUST_REG_ENTRY
122  * structs.
123  */
124 static void WINTRUST_FreeRegStructs(void)
125 {
126 #define WINTRUST_FREEREGENTRY( action ) \
127     HeapFree(GetProcessHeap(), 0, action.pwszDLLName); \
128     HeapFree(GetProcessHeap(), 0, action.pwszFunctionName);
129
130     WINTRUST_FREEREGENTRY(SoftpubInitialization);
131     WINTRUST_FREEREGENTRY(SoftpubMessage);
132     WINTRUST_FREEREGENTRY(SoftpubSignature);
133     WINTRUST_FREEREGENTRY(SoftpubCertficate);
134     WINTRUST_FREEREGENTRY(SoftpubCertCheck);
135     WINTRUST_FREEREGENTRY(SoftpubFinalPolicy);
136     WINTRUST_FREEREGENTRY(SoftpubCleanup);
137     WINTRUST_FREEREGENTRY(SoftpubDefCertInit);
138     WINTRUST_FREEREGENTRY(SoftpubDumpStructure);
139     WINTRUST_FREEREGENTRY(HTTPSCertificateTrust);
140     WINTRUST_FREEREGENTRY(HTTPSFinalProv);
141     WINTRUST_FREEREGENTRY(OfficeInitializePolicy);
142     WINTRUST_FREEREGENTRY(OfficeCleanupPolicy);
143     WINTRUST_FREEREGENTRY(DriverInitializePolicy);
144     WINTRUST_FREEREGENTRY(DriverFinalPolicy);
145     WINTRUST_FREEREGENTRY(DriverCleanupPolicy);
146     WINTRUST_FREEREGENTRY(GenericChainCertificateTrust);
147     WINTRUST_FREEREGENTRY(GenericChainFinalProv);
148
149 #undef WINTRUST_FREEREGENTRY
150 }
151
152 /***********************************************************************
153  *              WINTRUST_guid2wstr
154  *
155  * Create a wide-string from a GUID
156  *
157  */
158 static void WINTRUST_Guid2Wstr(const GUID* pgActionID, WCHAR* GuidString)
159
160     static const WCHAR wszFormat[] = {'{','%','0','8','l','X','-','%','0','4','X','-','%','0','4','X','-',
161                                       '%','0','2','X','%','0','2','X','-','%','0','2','X','%','0','2','X','%','0','2','X','%','0','2',
162                                       'X','%','0','2','X','%','0','2','X','}', 0};
163
164     wsprintfW(GuidString, wszFormat, pgActionID->Data1, pgActionID->Data2, pgActionID->Data3,
165         pgActionID->Data4[0], pgActionID->Data4[1], pgActionID->Data4[2], pgActionID->Data4[3],
166         pgActionID->Data4[4], pgActionID->Data4[5], pgActionID->Data4[6], pgActionID->Data4[7]);
167 }
168
169 /***********************************************************************
170  *              WINTRUST_WriteProviderToReg
171  *
172  * Helper function for WintrustAddActionID
173  *
174  */
175 static LONG WINTRUST_WriteProviderToReg(WCHAR* GuidString,
176                                         const WCHAR* FunctionType,
177                                         CRYPT_TRUST_REG_ENTRY RegEntry)
178 {
179     static const WCHAR Function[] = {'$','F','u','n','c','t','i','o','n', 0};
180     WCHAR ProvKey[MAX_PATH];
181     HKEY Key;
182     LONG Res = ERROR_SUCCESS;
183
184     /* Create the needed key string */
185     ProvKey[0]='\0';
186     lstrcatW(ProvKey, Trust);
187     lstrcatW(ProvKey, FunctionType);
188     lstrcatW(ProvKey, GuidString);
189
190     if (!RegEntry.pwszDLLName || !RegEntry.pwszFunctionName)
191         return ERROR_INVALID_PARAMETER;
192
193     Res = RegCreateKeyExW(HKEY_LOCAL_MACHINE, ProvKey, 0, NULL, 0, KEY_WRITE, NULL, &Key, NULL);
194     if (Res != ERROR_SUCCESS) goto error_close_key;
195
196     /* Create the $DLL entry */
197     Res = RegSetValueExW(Key, Dll, 0, REG_SZ, (BYTE*)RegEntry.pwszDLLName,
198         (lstrlenW(RegEntry.pwszDLLName) + 1)*sizeof(WCHAR));
199     if (Res != ERROR_SUCCESS) goto error_close_key;
200
201     /* Create the $Function entry */
202     Res = RegSetValueExW(Key, Function, 0, REG_SZ, (BYTE*)RegEntry.pwszFunctionName,
203         (lstrlenW(RegEntry.pwszFunctionName) + 1)*sizeof(WCHAR));
204
205 error_close_key:
206     RegCloseKey(Key);
207
208     return Res;
209 }
210
211 /***********************************************************************
212  *              WintrustAddActionID (WINTRUST.@)
213  *
214  * Add the definitions of the actions a Trust provider can perform to
215  * the registry.
216  *
217  * PARAMS
218  *   pgActionID [I] Pointer to a GUID for the Trust provider.
219  *   fdwFlags   [I] Flag to indicate whether registry errors are passed on.
220  *   psProvInfo [I] Pointer to a structure with information about DLL
221  *                  name and functions.
222  *
223  * RETURNS
224  *   Success: TRUE.
225  *   Failure: FALSE. (Use GetLastError() for more information)
226  *
227  * NOTES
228  *   Adding definitions is basically only adding relevant information
229  *   to the registry. No verification takes place whether a DLL or it's
230  *   entrypoints exist.
231  *   Information in the registry will always be overwritten.
232  *
233  */
234 BOOL WINAPI WintrustAddActionID( GUID* pgActionID, DWORD fdwFlags,
235                                  CRYPT_REGISTER_ACTIONID* psProvInfo)
236 {
237     WCHAR GuidString[39];
238     LONG Res;
239     LONG WriteActionError = ERROR_SUCCESS;
240
241     TRACE("%p %lx %p\n", debugstr_guid(pgActionID), fdwFlags, psProvInfo);
242
243     /* Some sanity checks.
244      * We use the W2K3 last error as it makes more sense (W2K leaves the last error
245      * as is).
246      */
247     if (!pgActionID ||
248         !psProvInfo ||
249         (psProvInfo->cbStruct != sizeof(CRYPT_REGISTER_ACTIONID)))
250     {
251         SetLastError(ERROR_INVALID_PARAMETER);
252         return FALSE;
253     }
254
255     /* Create this string only once, instead of in the helper function */
256     WINTRUST_Guid2Wstr( pgActionID, GuidString);
257
258     /* Write the information to the registry */
259     Res = WINTRUST_WriteProviderToReg(GuidString, Initialization  , psProvInfo->sInitProvider);
260     if (Res != ERROR_SUCCESS) WriteActionError = Res;
261     Res = WINTRUST_WriteProviderToReg(GuidString, Message         , psProvInfo->sObjectProvider);
262     if (Res != ERROR_SUCCESS) WriteActionError = Res;
263     Res = WINTRUST_WriteProviderToReg(GuidString, Signature       , psProvInfo->sSignatureProvider);
264     if (Res != ERROR_SUCCESS) WriteActionError = Res;
265     Res = WINTRUST_WriteProviderToReg(GuidString, Certificate     , psProvInfo->sCertificateProvider);
266     if (Res != ERROR_SUCCESS) WriteActionError = Res;
267     Res = WINTRUST_WriteProviderToReg(GuidString, CertCheck       , psProvInfo->sCertificatePolicyProvider);
268     if (Res != ERROR_SUCCESS) WriteActionError = Res;
269     Res = WINTRUST_WriteProviderToReg(GuidString, FinalPolicy     , psProvInfo->sFinalPolicyProvider);
270     if (Res != ERROR_SUCCESS) WriteActionError = Res;
271     Res = WINTRUST_WriteProviderToReg(GuidString, DiagnosticPolicy, psProvInfo->sTestPolicyProvider);
272     if (Res != ERROR_SUCCESS) WriteActionError = Res;
273     Res = WINTRUST_WriteProviderToReg(GuidString, Cleanup         , psProvInfo->sCleanupProvider);
274     if (Res != ERROR_SUCCESS) WriteActionError = Res;
275
276     /* Testing (by restricting access to the registry for some keys) shows that the last failing function
277      * will be used for last error.
278      * If the flag WT_ADD_ACTION_ID_RET_RESULT_FLAG is set and there are errors when adding the action
279      * we have to return FALSE. Errors includes both invalid entries as well as registry errors.
280      * Testing also showed that one error doesn't stop the registry writes. Every action will be dealt with.
281      */
282
283     if (WriteActionError != ERROR_SUCCESS)
284     {
285         SetLastError(WriteActionError);
286
287         if (fdwFlags == WT_ADD_ACTION_ID_RET_RESULT_FLAG)
288             return FALSE;
289     }
290
291     return TRUE;
292 }
293
294 /***********************************************************************
295  *              WINTRUST_RemoveProviderFromReg
296  *
297  * Helper function for WintrustRemoveActionID
298  *
299  */
300 static void WINTRUST_RemoveProviderFromReg(WCHAR* GuidString,
301                                            const WCHAR* FunctionType)
302 {
303     WCHAR ProvKey[MAX_PATH];
304
305     /* Create the needed key string */
306     ProvKey[0]='\0';
307     lstrcatW(ProvKey, Trust);
308     lstrcatW(ProvKey, FunctionType);
309     lstrcatW(ProvKey, GuidString);
310
311     /* We don't care about success or failure */
312     RegDeleteKeyW(HKEY_LOCAL_MACHINE, ProvKey);
313 }
314
315 /***********************************************************************
316  *              WintrustRemoveActionID (WINTRUST.@)
317  *
318  * Remove the definitions of the actions a Trust provider can perform
319  * from the registry.
320  *
321  * PARAMS
322  *   pgActionID [I] Pointer to a GUID for the Trust provider.
323  *
324  * RETURNS
325  *   Success: TRUE. (Use GetLastError() for more information)
326  *   Failure: FALSE. (Use GetLastError() for more information)
327  *
328  * NOTES
329  *   Testing shows that WintrustRemoveActionID always returns TRUE and
330  *   that a possible error should be retrieved via GetLastError().
331  *   There are no checks if the definitions are in the registry.
332  */
333 BOOL WINAPI WintrustRemoveActionID( GUID* pgActionID )
334 {
335     WCHAR GuidString[39];
336
337     TRACE("(%s)\n", debugstr_guid(pgActionID));
338  
339     if (!pgActionID)
340     {
341         SetLastError(ERROR_INVALID_PARAMETER);
342         return TRUE;
343     }
344
345     /* Create this string only once, instead of in the helper function */
346     WINTRUST_Guid2Wstr( pgActionID, GuidString);
347
348     /* We don't care about success or failure */
349     WINTRUST_RemoveProviderFromReg(GuidString, Initialization);
350     WINTRUST_RemoveProviderFromReg(GuidString, Message);
351     WINTRUST_RemoveProviderFromReg(GuidString, Signature);
352     WINTRUST_RemoveProviderFromReg(GuidString, Certificate);
353     WINTRUST_RemoveProviderFromReg(GuidString, CertCheck);
354     WINTRUST_RemoveProviderFromReg(GuidString, FinalPolicy);
355     WINTRUST_RemoveProviderFromReg(GuidString, DiagnosticPolicy);
356     WINTRUST_RemoveProviderFromReg(GuidString, Cleanup);
357
358     return TRUE;
359 }
360
361 /***********************************************************************
362  *              WINTRUST_WriteSingleUsageEntry
363  *
364  * Write a single value and its data to:
365  *
366  * HKLM\Software\Microsoft\Cryptography\Trust\Usages\<OID>
367  */
368 static LONG WINTRUST_WriteSingleUsageEntry(LPCSTR OID,
369                                            const WCHAR* Value,
370                                            WCHAR* Data)
371 {
372     static const WCHAR Usages[] = {'U','s','a','g','e','s','\\', 0};
373     WCHAR* UsageKey;
374     HKEY Key;
375     LONG Res = ERROR_SUCCESS;
376     WCHAR* OIDW;
377     DWORD Len;
378
379     /* Turn OID into a wide-character string */
380     Len = MultiByteToWideChar( CP_ACP, 0, OID, -1, NULL, 0 );
381     OIDW = HeapAlloc( GetProcessHeap(), 0, Len * sizeof(WCHAR) );
382     MultiByteToWideChar( CP_ACP, 0, OID, -1, OIDW, Len );
383
384     /* Allocate the needed space for UsageKey */
385     UsageKey = HeapAlloc(GetProcessHeap(), 0, (lstrlenW(Trust) + lstrlenW(Usages) + Len) * sizeof(WCHAR));
386     /* Create the key string */
387     lstrcpyW(UsageKey, Trust);
388     lstrcatW(UsageKey, Usages);
389     lstrcatW(UsageKey, OIDW);
390
391     Res = RegCreateKeyExW(HKEY_LOCAL_MACHINE, UsageKey, 0, NULL, 0, KEY_WRITE, NULL, &Key, NULL);
392     if (Res == ERROR_SUCCESS)
393     {
394         /* Create the Value entry */
395         Res = RegSetValueExW(Key, Value, 0, REG_SZ, (BYTE*)Data,
396                              (lstrlenW(Data) + 1)*sizeof(WCHAR));
397     }
398     RegCloseKey(Key);
399
400     HeapFree(GetProcessHeap(), 0, OIDW);
401     HeapFree(GetProcessHeap(), 0, UsageKey);
402
403     return Res;
404 }
405
406 /***************************************************************************
407  *              WINTRUST_RegisterGenVerifyV2
408  *
409  * Register WINTRUST_ACTION_GENERIC_VERIFY_V2 actions and usages.
410  *
411  * NOTES
412  *   WINTRUST_ACTION_GENERIC_VERIFY_V2 ({00AAC56B-CD44-11D0-8CC2-00C04FC295EE}
413  *   is defined in softpub.h
414  *   We don't care about failures (see comments in DllRegisterServer)
415  */
416 static void WINTRUST_RegisterGenVerifyV2(void)
417 {
418     static const GUID ProvGUID = WINTRUST_ACTION_GENERIC_VERIFY_V2;
419     WCHAR GuidString[39];
420
421     WINTRUST_Guid2Wstr(&ProvGUID , GuidString);
422
423     TRACE("Going to register WINTRUST_ACTION_GENERIC_VERIFY_V2 : %s\n", wine_dbgstr_w(GuidString));
424
425     /* HKLM\Software\Microsoft\Cryptography\Trust\Usages\1.3.6.1.5.5.7.3.3 */
426     WINTRUST_WriteSingleUsageEntry(szOID_PKIX_KP_CODE_SIGNING, DefaultId, GuidString);
427
428     /* HKLM\Software\Microsoft\Cryptography\Trust\Provider\*\{00AAC56B-CD44-11D0-8CC2-00C04FC295EE} */
429     WINTRUST_WriteProviderToReg(GuidString, Initialization, SoftpubInitialization);
430     WINTRUST_WriteProviderToReg(GuidString, Message       , SoftpubMessage);
431     WINTRUST_WriteProviderToReg(GuidString, Signature     , SoftpubSignature);
432     WINTRUST_WriteProviderToReg(GuidString, Certificate   , SoftpubCertficate);
433     WINTRUST_WriteProviderToReg(GuidString, CertCheck     , SoftpubCertCheck);
434     WINTRUST_WriteProviderToReg(GuidString, FinalPolicy   , SoftpubFinalPolicy);
435     WINTRUST_WriteProviderToReg(GuidString, Cleanup       , SoftpubCleanup);
436 }
437
438 /***************************************************************************
439  *              WINTRUST_RegisterPublishedSoftware
440  *
441  * Register WIN_SPUB_ACTION_PUBLISHED_SOFTWARE actions and usages.
442  *
443  * NOTES
444  *   WIN_SPUB_ACTION_PUBLISHED_SOFTWARE ({64B9D180-8DA2-11CF-8736-00AA00A485EB})
445  *   is defined in wintrust.h
446  *   We don't care about failures (see comments in DllRegisterServer)
447  */
448 static void WINTRUST_RegisterPublishedSoftware(void)
449 {
450     static const GUID ProvGUID = WIN_SPUB_ACTION_PUBLISHED_SOFTWARE;
451     WCHAR GuidString[39];
452
453     WINTRUST_Guid2Wstr(&ProvGUID , GuidString);
454
455     TRACE("Going to register WIN_SPUB_ACTION_PUBLISHED_SOFTWARE : %s\n", wine_dbgstr_w(GuidString));
456
457     /* HKLM\Software\Microsoft\Cryptography\Trust\Provider\*\{64B9D180-8DA2-11CF-8736-00AA00A485EB} */
458     WINTRUST_WriteProviderToReg(GuidString, Initialization, SoftpubInitialization);
459     WINTRUST_WriteProviderToReg(GuidString, Message       , SoftpubMessage);
460     WINTRUST_WriteProviderToReg(GuidString, Signature     , SoftpubSignature);
461     WINTRUST_WriteProviderToReg(GuidString, Certificate   , SoftpubCertficate);
462     WINTRUST_WriteProviderToReg(GuidString, CertCheck     , SoftpubCertCheck);
463     WINTRUST_WriteProviderToReg(GuidString, FinalPolicy   , SoftpubFinalPolicy);
464     WINTRUST_WriteProviderToReg(GuidString, Cleanup       , SoftpubCleanup);
465 }
466
467 #define WIN_SPUB_ACTION_PUBLISHED_SOFTWARE_NOBADUI { 0xc6b2e8d0, 0xe005, 0x11cf, { 0xa1,0x34,0x00,0xc0,0x4f,0xd7,0xbf,0x43 }}
468
469 /***************************************************************************
470  *              WINTRUST_RegisterPublishedSoftwareNoBadUi
471  *
472  * Register WIN_SPUB_ACTION_PUBLISHED_SOFTWARE_NOBADUI actions and usages.
473  *
474  * NOTES
475  *   WIN_SPUB_ACTION_PUBLISHED_SOFTWARE_NOBADUI ({C6B2E8D0-E005-11CF-A134-00C04FD7BF43})
476  *   is not defined in any include file. (FIXME: Find out if the name is correct).
477  *   We don't care about failures (see comments in DllRegisterServer)
478  */
479 static void WINTRUST_RegisterPublishedSoftwareNoBadUi(void)
480 {
481     static const GUID ProvGUID = WIN_SPUB_ACTION_PUBLISHED_SOFTWARE_NOBADUI;
482     WCHAR GuidString[39];
483
484     WINTRUST_Guid2Wstr(&ProvGUID , GuidString);
485
486     TRACE("Going to register WIN_SPUB_ACTION_PUBLISHED_SOFTWARE_NOBADUI : %s\n", wine_dbgstr_w(GuidString));
487
488     /* HKLM\Software\Microsoft\Cryptography\Trust\Provider\*\{C6B2E8D0-E005-11CF-A134-00C04FD7BF43} */
489     WINTRUST_WriteProviderToReg(GuidString, Initialization, SoftpubInitialization);
490     WINTRUST_WriteProviderToReg(GuidString, Message       , SoftpubMessage);
491     WINTRUST_WriteProviderToReg(GuidString, Signature     , SoftpubSignature);
492     WINTRUST_WriteProviderToReg(GuidString, Certificate   , SoftpubCertficate);
493     WINTRUST_WriteProviderToReg(GuidString, CertCheck     , SoftpubCertCheck);
494     WINTRUST_WriteProviderToReg(GuidString, FinalPolicy   , SoftpubFinalPolicy);
495     WINTRUST_WriteProviderToReg(GuidString, Cleanup       , SoftpubCleanup);
496 }
497
498 /***************************************************************************
499  *              WINTRUST_RegisterGenCertVerify
500  *
501  * Register WINTRUST_ACTION_GENERIC_CERT_VERIFY actions and usages.
502  *
503  * NOTES
504  *   WINTRUST_ACTION_GENERIC_CERT_VERIFY ({189A3842-3041-11D1-85E1-00C04FC295EE})
505  *   is defined in softpub.h
506  *   We don't care about failures (see comments in DllRegisterServer)
507  */
508 static void WINTRUST_RegisterGenCertVerify(void)
509 {
510     static const GUID ProvGUID = WINTRUST_ACTION_GENERIC_CERT_VERIFY;
511     WCHAR GuidString[39];
512
513     WINTRUST_Guid2Wstr(&ProvGUID , GuidString);
514
515     TRACE("Going to register WINTRUST_ACTION_GENERIC_CERT_VERIFY : %s\n", wine_dbgstr_w(GuidString));
516
517     /* HKLM\Software\Microsoft\Cryptography\Trust\Provider\*\{189A3842-3041-11D1-85E1-00C04FC295EE} */
518     WINTRUST_WriteProviderToReg(GuidString, Initialization, SoftpubDefCertInit);
519     WINTRUST_WriteProviderToReg(GuidString, Message       , SoftpubMessage);
520     WINTRUST_WriteProviderToReg(GuidString, Signature     , SoftpubSignature);
521     WINTRUST_WriteProviderToReg(GuidString, Certificate   , SoftpubCertficate);
522     WINTRUST_WriteProviderToReg(GuidString, CertCheck     , SoftpubCertCheck);
523     WINTRUST_WriteProviderToReg(GuidString, FinalPolicy   , SoftpubFinalPolicy);
524     WINTRUST_WriteProviderToReg(GuidString, Cleanup       , SoftpubCleanup);
525 }
526
527 /***************************************************************************
528  *              WINTRUST_RegisterTrustProviderTest
529  *
530  * Register WINTRUST_ACTION_TRUSTPROVIDER_TEST actions and usages.
531  *
532  * NOTES
533  *   WINTRUST_ACTION_TRUSTPROVIDER_TEST ({573E31F8-DDBA-11D0-8CCB-00C04FC295EE})
534  *   is defined in softpub.h
535  *   We don't care about failures (see comments in DllRegisterServer)
536  */
537 static void WINTRUST_RegisterTrustProviderTest(void)
538 {
539     static const GUID ProvGUID = WINTRUST_ACTION_TRUSTPROVIDER_TEST;
540     WCHAR GuidString[39];
541
542     WINTRUST_Guid2Wstr(&ProvGUID , GuidString);
543
544     TRACE("Going to register WINTRUST_ACTION_TRUSTPROVIDER_TEST : %s\n", wine_dbgstr_w(GuidString));
545
546     /* HKLM\Software\Microsoft\Cryptography\Trust\Provider\*\{573E31F8-DDBA-11D0-8CCB-00C04FC295EE} */
547     WINTRUST_WriteProviderToReg(GuidString, Initialization  , SoftpubInitialization);
548     WINTRUST_WriteProviderToReg(GuidString, Message         , SoftpubMessage);
549     WINTRUST_WriteProviderToReg(GuidString, Signature       , SoftpubSignature);
550     WINTRUST_WriteProviderToReg(GuidString, Certificate     , SoftpubCertficate);
551     WINTRUST_WriteProviderToReg(GuidString, CertCheck       , SoftpubCertCheck);
552     WINTRUST_WriteProviderToReg(GuidString, FinalPolicy     , SoftpubFinalPolicy);
553     WINTRUST_WriteProviderToReg(GuidString, DiagnosticPolicy, SoftpubDumpStructure);
554     WINTRUST_WriteProviderToReg(GuidString, Cleanup         , SoftpubCleanup);
555 }
556
557 /***************************************************************************
558  *              WINTRUST_RegisterHttpsProv
559  *
560  * Register HTTPSPROV_ACTION actions and usages.
561  *
562  * NOTES
563  *   HTTPSPROV_ACTION ({573E31F8-AABA-11D0-8CCB-00C04FC295EE})
564  *   is defined in softpub.h
565  *   We don't care about failures (see comments in DllRegisterServer)
566  */
567 static void WINTRUST_RegisterHttpsProv(void)
568 {
569     static WCHAR SoftpubLoadUsage[] = {'S','o','f','t','p','u','b','L','o','a','d','D','e','f','U','s','a','g','e','C','a','l','l','D','a','t','a', 0};
570     static WCHAR SoftpubFreeUsage[] = {'S','o','f','t','p','u','b','F','r','e','e','D','e','f','U','s','a','g','e','C','a','l','l','D','a','t','a', 0};
571     static const WCHAR CBAlloc[]    = {'C','a','l','l','b','a','c','k','A','l','l','o','c','F','u','n','c','t','i','o','n', 0};
572     static const WCHAR CBFree[]     = {'C','a','l','l','b','a','c','k','F','r','e','e','F','u','n','c','t','i','o','n', 0};
573     static const GUID ProvGUID = HTTPSPROV_ACTION;
574     WCHAR GuidString[39];
575     WCHAR ProvDllName[sizeof(SP_POLICY_PROVIDER_DLL_NAME)];
576
577     WINTRUST_Guid2Wstr(&ProvGUID , GuidString);
578
579     TRACE("Going to register HTTPSPROV_ACTION : %s\n", wine_dbgstr_w(GuidString));
580
581     lstrcpyW(ProvDllName, SP_POLICY_PROVIDER_DLL_NAME); \
582
583     /* HKLM\Software\Microsoft\Cryptography\Trust\Usages\1.3.6.1.5.5.7.3.1 */
584     WINTRUST_WriteSingleUsageEntry(szOID_PKIX_KP_SERVER_AUTH, Dll, ProvDllName);
585     WINTRUST_WriteSingleUsageEntry(szOID_PKIX_KP_SERVER_AUTH, CBAlloc, SoftpubLoadUsage );
586     WINTRUST_WriteSingleUsageEntry(szOID_PKIX_KP_SERVER_AUTH, CBFree, SoftpubFreeUsage );
587     WINTRUST_WriteSingleUsageEntry(szOID_PKIX_KP_SERVER_AUTH, DefaultId, GuidString );
588     /* HKLM\Software\Microsoft\Cryptography\Trust\Usages\1.3.6.1.5.5.7.3.2 */
589     WINTRUST_WriteSingleUsageEntry(szOID_PKIX_KP_CLIENT_AUTH, Dll, ProvDllName);
590     WINTRUST_WriteSingleUsageEntry(szOID_PKIX_KP_CLIENT_AUTH, CBAlloc, SoftpubLoadUsage );
591     WINTRUST_WriteSingleUsageEntry(szOID_PKIX_KP_CLIENT_AUTH, CBFree, SoftpubFreeUsage );
592     WINTRUST_WriteSingleUsageEntry(szOID_PKIX_KP_CLIENT_AUTH, DefaultId, GuidString );
593     /* HKLM\Software\Microsoft\Cryptography\Trust\Usages\1.3.6.1.4.1.311.10.3.3 */
594     WINTRUST_WriteSingleUsageEntry(szOID_SERVER_GATED_CRYPTO, Dll, ProvDllName);
595     WINTRUST_WriteSingleUsageEntry(szOID_SERVER_GATED_CRYPTO, CBAlloc, SoftpubLoadUsage );
596     WINTRUST_WriteSingleUsageEntry(szOID_SERVER_GATED_CRYPTO, CBFree, SoftpubFreeUsage );
597     WINTRUST_WriteSingleUsageEntry(szOID_SERVER_GATED_CRYPTO, DefaultId, GuidString );
598     /* HKLM\Software\Microsoft\Cryptography\Trust\Usages\2.16.840.1.113730.4.1 */
599     WINTRUST_WriteSingleUsageEntry(szOID_SGC_NETSCAPE, Dll, ProvDllName);
600     WINTRUST_WriteSingleUsageEntry(szOID_SGC_NETSCAPE, CBAlloc, SoftpubLoadUsage );
601     WINTRUST_WriteSingleUsageEntry(szOID_SGC_NETSCAPE, CBFree, SoftpubFreeUsage );
602     WINTRUST_WriteSingleUsageEntry(szOID_SGC_NETSCAPE, DefaultId, GuidString );
603
604     /* HKLM\Software\Microsoft\Cryptography\Trust\Provider\*\{573E31F8-AABA-11D0-8CCB-00C04FC295EE} */
605     WINTRUST_WriteProviderToReg(GuidString, Initialization, SoftpubInitialization);
606     WINTRUST_WriteProviderToReg(GuidString, Message       , SoftpubMessage);
607     WINTRUST_WriteProviderToReg(GuidString, Signature     , SoftpubSignature);
608     WINTRUST_WriteProviderToReg(GuidString, Certificate   , HTTPSCertificateTrust);
609     WINTRUST_WriteProviderToReg(GuidString, CertCheck     , SoftpubCertCheck);
610     WINTRUST_WriteProviderToReg(GuidString, FinalPolicy   , HTTPSFinalProv);
611     WINTRUST_WriteProviderToReg(GuidString, Cleanup       , SoftpubCleanup);
612 }
613
614 /***************************************************************************
615  *              WINTRUST_RegisterOfficeSignVerify
616  *
617  * Register OFFICESIGN_ACTION_VERIFY actions and usages.
618  *
619  * NOTES
620  *   OFFICESIGN_ACTION_VERIFY ({5555C2CD-17FB-11D1-85C4-00C04FC295EE})
621  *   is defined in softpub.h
622  *   We don't care about failures (see comments in DllRegisterServer)
623  */
624 static void WINTRUST_RegisterOfficeSignVerify(void)
625 {
626     static const GUID ProvGUID = OFFICESIGN_ACTION_VERIFY;
627     WCHAR GuidString[39];
628
629     WINTRUST_Guid2Wstr(&ProvGUID , GuidString);
630
631     TRACE("Going to register OFFICESIGN_ACTION_VERIFY : %s\n", wine_dbgstr_w(GuidString));
632
633     /* HKLM\Software\Microsoft\Cryptography\Trust\Provider\*\{5555C2CD-17FB-11D1-85C4-00C04FC295EE} */
634     WINTRUST_WriteProviderToReg(GuidString, Initialization, OfficeInitializePolicy);
635     WINTRUST_WriteProviderToReg(GuidString, Message       , SoftpubMessage);
636     WINTRUST_WriteProviderToReg(GuidString, Signature     , SoftpubSignature);
637     WINTRUST_WriteProviderToReg(GuidString, Certificate   , SoftpubCertficate);
638     WINTRUST_WriteProviderToReg(GuidString, CertCheck     , SoftpubCertCheck);
639     WINTRUST_WriteProviderToReg(GuidString, FinalPolicy   , SoftpubFinalPolicy);
640     WINTRUST_WriteProviderToReg(GuidString, Cleanup       , OfficeCleanupPolicy);
641 }
642
643 /***************************************************************************
644  *              WINTRUST_RegisterDriverVerify
645  *
646  * Register DRIVER_ACTION_VERIFY actions and usages.
647  *
648  * NOTES
649  *   DRIVER_ACTION_VERIFY ({F750E6C3-38EE-11D1-85E5-00C04FC295EE})
650  *   is defined in softpub.h
651  *   We don't care about failures (see comments in DllRegisterServer)
652  */
653 static void WINTRUST_RegisterDriverVerify(void)
654 {
655     static const GUID ProvGUID = DRIVER_ACTION_VERIFY;
656     WCHAR GuidString[39];
657
658     WINTRUST_Guid2Wstr(&ProvGUID , GuidString);
659
660     TRACE("Going to register DRIVER_ACTION_VERIFY : %s\n", wine_dbgstr_w(GuidString));
661
662     /* HKLM\Software\Microsoft\Cryptography\Trust\Provider\*\{F750E6C3-38EE-11D1-85E5-00C04FC295EE} */
663     WINTRUST_WriteProviderToReg(GuidString, Initialization, DriverInitializePolicy);
664     WINTRUST_WriteProviderToReg(GuidString, Message       , SoftpubMessage);
665     WINTRUST_WriteProviderToReg(GuidString, Signature     , SoftpubSignature);
666     WINTRUST_WriteProviderToReg(GuidString, Certificate   , SoftpubCertficate);
667     WINTRUST_WriteProviderToReg(GuidString, CertCheck     , SoftpubCertCheck);
668     WINTRUST_WriteProviderToReg(GuidString, FinalPolicy   , DriverFinalPolicy);
669     WINTRUST_WriteProviderToReg(GuidString, Cleanup       , DriverCleanupPolicy);
670 }
671
672 /***************************************************************************
673  *              WINTRUST_RegisterGenChainVerify
674  *
675  * Register WINTRUST_ACTION_GENERIC_CHAIN_VERIFY actions and usages.
676  *
677  * NOTES
678  *   WINTRUST_ACTION_GENERIC_CHAIN_VERIFY ({FC451C16-AC75-11D1-B4B8-00C04FB66EA0})
679  *   is defined in softpub.h
680  *   We don't care about failures (see comments in DllRegisterServer)
681  */
682 static void WINTRUST_RegisterGenChainVerify(void)
683 {
684     static const GUID ProvGUID = WINTRUST_ACTION_GENERIC_CHAIN_VERIFY;
685     WCHAR GuidString[39];
686
687     WINTRUST_Guid2Wstr(&ProvGUID , GuidString);
688
689     TRACE("Going to register WINTRUST_ACTION_GENERIC_CHAIN_VERIFY : %s\n", wine_dbgstr_w(GuidString));
690
691     /* HKLM\Software\Microsoft\Cryptography\Trust\Provider\*\{FC451C16-AC75-11D1-B4B8-00C04FB66EA0} */
692     WINTRUST_WriteProviderToReg(GuidString, Initialization, SoftpubInitialization);
693     WINTRUST_WriteProviderToReg(GuidString, Message       , SoftpubMessage);
694     WINTRUST_WriteProviderToReg(GuidString, Signature     , SoftpubSignature);
695     WINTRUST_WriteProviderToReg(GuidString, Certificate   , GenericChainCertificateTrust);
696     WINTRUST_WriteProviderToReg(GuidString, CertCheck     , SoftpubCertCheck);
697     WINTRUST_WriteProviderToReg(GuidString, FinalPolicy   , GenericChainFinalProv);
698     WINTRUST_WriteProviderToReg(GuidString, Cleanup       , SoftpubCleanup);
699 }
700
701 /***********************************************************************
702  *              DllRegisterServer (WINTRUST.@)
703  */
704 HRESULT WINAPI DllRegisterServer(void)
705 {
706     static const CHAR WVTAsn1SpcPeImageDataEncode[]           = "WVTAsn1SpcPeImageDataEncode";
707     static const CHAR WVTAsn1SpcPeImageDataDecode[]           = "WVTAsn1SpcPeImageDataDecode";
708     static const CHAR WVTAsn1SpcLinkEncode[]                  = "WVTAsn1SpcLinkEncode";
709     static const CHAR WVTAsn1SpcLinkDecode[]                  = "WVTAsn1SpcLinkDecode";
710     static const CHAR WVTAsn1SpcSigInfoEncode[]               = "WVTAsn1SpcSigInfoEncode";
711     static const CHAR WVTAsn1SpcSigInfoDecode[]               = "WVTAsn1SpcSigInfoDecode";
712     static const CHAR WVTAsn1SpcIndirectDataContentEncode[]   = "WVTAsn1SpcIndirectDataContentEncode";
713     static const CHAR WVTAsn1SpcIndirectDataContentDecode[]   = "WVTAsn1SpcIndirectDataContentDecode";
714     static const CHAR WVTAsn1SpcSpAgencyInfoEncode[]          = "WVTAsn1SpcSpAgencyInfoEncode";
715     static const CHAR WVTAsn1SpcSpAgencyInfoDecode[]          = "WVTAsn1SpcSpAgencyInfoDecode";
716     static const CHAR WVTAsn1SpcMinimalCriteriaInfoEncode[]   = "WVTAsn1SpcMinimalCriteriaInfoEncode";
717     static const CHAR WVTAsn1SpcMinimalCriteriaInfoDecode[]   = "WVTAsn1SpcMinimalCriteriaInfoDecode";
718     static const CHAR WVTAsn1SpcFinancialCriteriaInfoEncode[] = "WVTAsn1SpcFinancialCriteriaInfoEncode";
719     static const CHAR WVTAsn1SpcFinancialCriteriaInfoDecode[] = "WVTAsn1SpcFinancialCriteriaInfoDecode";
720     static const CHAR WVTAsn1SpcStatementTypeEncode[]         = "WVTAsn1SpcStatementTypeEncode";
721     static const CHAR WVTAsn1SpcStatementTypeDecode[]         = "WVTAsn1SpcStatementTypeDecode";
722     static const CHAR WVTAsn1CatNameValueEncode[]             = "WVTAsn1CatNameValueEncode";
723     static const CHAR WVTAsn1CatNameValueDecode[]             = "WVTAsn1CatNameValueDecode";
724     static const CHAR WVTAsn1CatMemberInfoEncode[]            = "WVTAsn1CatMemberInfoEncode";
725     static const CHAR WVTAsn1CatMemberInfoDecode[]            = "WVTAsn1CatMemberInfoDecode";
726     static const CHAR WVTAsn1SpcSpOpusInfoEncode[]            = "WVTAsn1SpcSpOpusInfoEncode";
727     static const CHAR WVTAsn1SpcSpOpusInfoDecode[]            = "WVTAsn1SpcSpOpusInfoDecode";
728     HRESULT Res = S_OK;
729     HKEY Key;
730
731     TRACE("\n");
732
733     /* FIXME:
734      * 
735      * A short list of stuff that should be done here:
736      *
737      * - Several calls to CryptRegisterOIDFunction
738      * - Several action registrations (NOT through WintrustAddActionID)
739      * - Several calls to CryptSIPAddProvider
740      * - One call to CryptSIPRemoveProvider (do we need that?)
741      */
742
743     /* Testing on native shows that when an error is encountered in one of the CryptRegisterOIDFunction calls
744      * the rest of these calls is skipped. Registering is however continued for the trust providers.
745      *
746      * We are not totally in line with native as there all decoding functions are registered after all encoding
747      * functions.
748      */
749 #define WINTRUST_REGISTEROID( oid, encode_funcname, decode_funcname ) \
750     do { \
751         if (!CryptRegisterOIDFunction(X509_ASN_ENCODING, CRYPT_OID_ENCODE_OBJECT_FUNC, oid, SP_POLICY_PROVIDER_DLL_NAME, encode_funcname)) \
752         {                                                               \
753             Res = HRESULT_FROM_WIN32(GetLastError());                   \
754             goto add_trust_providers;                                   \
755         }                                                               \
756         if (!CryptRegisterOIDFunction(X509_ASN_ENCODING, CRYPT_OID_DECODE_OBJECT_FUNC, oid, SP_POLICY_PROVIDER_DLL_NAME, decode_funcname)) \
757         {                                                               \
758             Res = HRESULT_FROM_WIN32(GetLastError());                   \
759             goto add_trust_providers;                                   \
760         }                                                               \
761     } while (0)
762
763     WINTRUST_REGISTEROID(SPC_PE_IMAGE_DATA_OBJID, WVTAsn1SpcPeImageDataEncode, WVTAsn1SpcPeImageDataDecode);
764     WINTRUST_REGISTEROID(SPC_PE_IMAGE_DATA_STRUCT, WVTAsn1SpcPeImageDataEncode, WVTAsn1SpcPeImageDataDecode);
765     WINTRUST_REGISTEROID(SPC_CAB_DATA_OBJID, WVTAsn1SpcLinkEncode, WVTAsn1SpcLinkDecode);
766     WINTRUST_REGISTEROID(SPC_CAB_DATA_STRUCT, WVTAsn1SpcLinkEncode, WVTAsn1SpcLinkDecode);
767     WINTRUST_REGISTEROID(SPC_JAVA_CLASS_DATA_OBJID, WVTAsn1SpcLinkEncode, WVTAsn1SpcLinkDecode);
768     WINTRUST_REGISTEROID(SPC_JAVA_CLASS_DATA_STRUCT, WVTAsn1SpcLinkEncode, WVTAsn1SpcLinkDecode);
769     WINTRUST_REGISTEROID(SPC_LINK_OBJID, WVTAsn1SpcLinkEncode, WVTAsn1SpcLinkDecode);
770     WINTRUST_REGISTEROID(SPC_LINK_STRUCT, WVTAsn1SpcLinkEncode, WVTAsn1SpcLinkDecode);
771     WINTRUST_REGISTEROID(SPC_SIGINFO_OBJID, WVTAsn1SpcSigInfoEncode, WVTAsn1SpcSigInfoDecode);
772     WINTRUST_REGISTEROID(SPC_SIGINFO_STRUCT, WVTAsn1SpcSigInfoEncode, WVTAsn1SpcSigInfoDecode);
773     WINTRUST_REGISTEROID(SPC_INDIRECT_DATA_OBJID, WVTAsn1SpcIndirectDataContentEncode, WVTAsn1SpcIndirectDataContentDecode);
774     WINTRUST_REGISTEROID(SPC_INDIRECT_DATA_CONTENT_STRUCT, WVTAsn1SpcIndirectDataContentEncode, WVTAsn1SpcIndirectDataContentDecode);
775     WINTRUST_REGISTEROID(SPC_SP_AGENCY_INFO_OBJID, WVTAsn1SpcSpAgencyInfoEncode, WVTAsn1SpcSpAgencyInfoDecode);
776     WINTRUST_REGISTEROID(SPC_SP_AGENCY_INFO_STRUCT, WVTAsn1SpcSpAgencyInfoEncode, WVTAsn1SpcSpAgencyInfoDecode);
777     WINTRUST_REGISTEROID(SPC_MINIMAL_CRITERIA_OBJID, WVTAsn1SpcMinimalCriteriaInfoEncode, WVTAsn1SpcMinimalCriteriaInfoDecode);
778     WINTRUST_REGISTEROID(SPC_MINIMAL_CRITERIA_STRUCT, WVTAsn1SpcMinimalCriteriaInfoEncode, WVTAsn1SpcMinimalCriteriaInfoDecode);
779     WINTRUST_REGISTEROID(SPC_FINANCIAL_CRITERIA_OBJID, WVTAsn1SpcFinancialCriteriaInfoEncode, WVTAsn1SpcFinancialCriteriaInfoDecode);
780     WINTRUST_REGISTEROID(SPC_FINANCIAL_CRITERIA_STRUCT, WVTAsn1SpcFinancialCriteriaInfoEncode, WVTAsn1SpcFinancialCriteriaInfoDecode);
781     WINTRUST_REGISTEROID(SPC_STATEMENT_TYPE_OBJID, WVTAsn1SpcStatementTypeEncode, WVTAsn1SpcStatementTypeDecode);
782     WINTRUST_REGISTEROID(SPC_STATEMENT_TYPE_STRUCT, WVTAsn1SpcStatementTypeEncode, WVTAsn1SpcStatementTypeDecode);
783     WINTRUST_REGISTEROID(CAT_NAMEVALUE_OBJID, WVTAsn1CatNameValueEncode, WVTAsn1CatNameValueDecode);
784     WINTRUST_REGISTEROID(CAT_NAMEVALUE_STRUCT, WVTAsn1CatNameValueEncode, WVTAsn1CatNameValueDecode);
785     WINTRUST_REGISTEROID(CAT_MEMBERINFO_OBJID, WVTAsn1CatMemberInfoEncode, WVTAsn1CatMemberInfoDecode);
786     WINTRUST_REGISTEROID(CAT_MEMBERINFO_STRUCT, WVTAsn1CatMemberInfoEncode, WVTAsn1CatMemberInfoDecode);
787     WINTRUST_REGISTEROID(SPC_SP_OPUS_INFO_OBJID, WVTAsn1SpcSpOpusInfoEncode, WVTAsn1SpcSpOpusInfoDecode);
788     WINTRUST_REGISTEROID(SPC_SP_OPUS_INFO_STRUCT, WVTAsn1SpcSpOpusInfoEncode, WVTAsn1SpcSpOpusInfoDecode);
789
790 #undef WINTRUST_REGISTEROID
791
792 add_trust_providers:
793
794     /* Testing on W2K3 shows:
795      * If we cannot open HKLM\Software\Microsoft\Cryptography\Providers\Trust
796      * for writing, DllRegisterServer returns S_FALSE. If the key can be opened 
797      * there is no check whether the actions can be written in the registry.
798      * As the previous list shows, there are several calls after these registrations.
799      * If they fail they will overwrite the returnvalue of DllRegisterServer.
800      */
801
802     /* Check if we can open/create HKLM\Software\Microsoft\Cryptography\Providers\Trust */
803     if (RegCreateKeyExW(HKEY_LOCAL_MACHINE, Trust, 0, NULL, 0, KEY_WRITE, NULL, &Key, NULL) != ERROR_SUCCESS)
804     {
805         /* If the opening/creation of the key fails, there is no need to do the action registrations as they
806          * will fail as well.
807          */
808         Res = S_FALSE;
809     }
810     else
811     {
812         RegCloseKey(Key);
813
814         /* Create the necessary action registry structures */
815         WINTRUST_InitRegStructs();
816
817         /* Register several Trust Provider actions */
818         WINTRUST_RegisterGenVerifyV2();
819         WINTRUST_RegisterPublishedSoftware();
820         WINTRUST_RegisterPublishedSoftwareNoBadUi();
821         WINTRUST_RegisterGenCertVerify();
822         WINTRUST_RegisterTrustProviderTest();
823         WINTRUST_RegisterHttpsProv();
824         WINTRUST_RegisterOfficeSignVerify();
825         WINTRUST_RegisterDriverVerify();
826         WINTRUST_RegisterGenChainVerify();
827
828         /* Free the registry structures */
829         WINTRUST_FreeRegStructs();
830     }
831
832     return Res;
833 }
834
835 /***********************************************************************
836  *              DllUnregisterServer (WINTRUST.@)
837  */
838 HRESULT WINAPI DllUnregisterServer(void)
839 {
840      FIXME("stub\n");
841      return S_OK;
842 }
843
844 /***********************************************************************
845  *              SoftpubDllRegisterServer (WINTRUST.@)
846  */
847 HRESULT WINAPI SoftpubDllRegisterServer(void)
848 {
849      FIXME("stub\n");
850      return S_OK;
851 }
852
853 /***********************************************************************
854  *              SoftpubDllUnregisterServer (WINTRUST.@)
855  */
856 HRESULT WINAPI SoftpubDllUnregisterServer(void)
857 {
858      FIXME("stub\n");
859      return S_OK;
860 }
861
862 /***********************************************************************
863  *              mscat32DllRegisterServer (WINTRUST.@)
864  */
865 HRESULT WINAPI mscat32DllRegisterServer(void)
866 {
867      FIXME("stub\n");
868      return S_OK;
869 }
870
871 /***********************************************************************
872  *              mscat32DllUnregisterServer (WINTRUST.@)
873  */
874 HRESULT WINAPI mscat32DllUnregisterServer(void)
875 {
876      FIXME("stub\n");
877      return S_OK;
878 }
879
880 /***********************************************************************
881  *              mssip32DllRegisterServer (WINTRUST.@)
882  */
883 HRESULT WINAPI mssip32DllRegisterServer(void)
884 {
885      FIXME("stub\n");
886      return S_OK;
887 }
888
889 /***********************************************************************
890  *              mssip32DllUnregisterServer (WINTRUST.@)
891  */
892 HRESULT WINAPI mssip32DllUnregisterServer(void)
893 {
894      FIXME("stub\n");
895      return S_OK;
896 }