2 * Register related wintrust functions
4 * Copyright 2006 Paul Vriens
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.
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.
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
34 #include "wine/debug.h"
36 WINE_DEFAULT_DEBUG_CHANNEL(wintrust);
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;
46 static CRYPT_TRUST_REG_ENTRY SoftpubDefCertInit;
48 static CRYPT_TRUST_REG_ENTRY SoftpubDumpStructure;
50 static CRYPT_TRUST_REG_ENTRY HTTPSCertificateTrust;
51 static CRYPT_TRUST_REG_ENTRY HTTPSFinalProv;
53 static const WCHAR Trust[] = {'S','o','f','t','w','a','r','e','\\',
54 'M','i','c','r','o','s','o','f','t','\\',
55 'C','r','y','p','t','o','g','r','a','p','h','y','\\',
56 'P','r','o','v','i','d','e','r','s','\\',
57 'T','r','u','s','t','\\', 0 };
59 static const WCHAR Initialization[] = {'I','n','i','t','i','a','l','i','z','a','t','i','o','n','\\', 0};
60 static const WCHAR Message[] = {'M','e','s','s','a','g','e','\\', 0};
61 static const WCHAR Signature[] = {'S','i','g','n','a','t','u','r','e','\\', 0};
62 static const WCHAR Certificate[] = {'C','e','r','t','i','f','i','c','a','t','e','\\', 0};
63 static const WCHAR CertCheck[] = {'C','e','r','t','C','h','e','c','k','\\', 0};
64 static const WCHAR FinalPolicy[] = {'F','i','n','a','l','P','o','l','i','c','y','\\', 0};
65 static const WCHAR DiagnosticPolicy[] = {'D','i','a','g','n','o','s','t','i','c','P','o','l','i','c','y','\\', 0};
66 static const WCHAR Cleanup[] = {'C','l','e','a','n','u','p','\\', 0};
68 static const WCHAR DefaultId[] = {'D','e','f','a','u','l','t','I','d', 0};
69 static const WCHAR Dll[] = {'$','D','L','L', 0};
71 /***********************************************************************
72 * WINTRUST_InitRegStructs
74 * Helper function to allocate and initialize the members of the
75 * CRYPT_TRUST_REG_ENTRY structs.
77 static void WINTRUST_InitRegStructs(void)
79 #define WINTRUST_INITREGENTRY( action, dllname, functionname ) \
80 action.cbStruct = sizeof(CRYPT_TRUST_REG_ENTRY); \
81 action.pwszDLLName = HeapAlloc(GetProcessHeap(), 0, sizeof(dllname)); \
82 lstrcpyW(action.pwszDLLName, dllname); \
83 action.pwszFunctionName = HeapAlloc(GetProcessHeap(), 0, sizeof(functionname)); \
84 lstrcpyW(action.pwszFunctionName, functionname);
86 WINTRUST_INITREGENTRY(SoftpubInitialization, SP_POLICY_PROVIDER_DLL_NAME, SP_INIT_FUNCTION)
87 WINTRUST_INITREGENTRY(SoftpubMessage, SP_POLICY_PROVIDER_DLL_NAME, SP_OBJTRUST_FUNCTION)
88 WINTRUST_INITREGENTRY(SoftpubSignature, SP_POLICY_PROVIDER_DLL_NAME, SP_SIGTRUST_FUNCTION)
89 WINTRUST_INITREGENTRY(SoftpubCertficate, SP_POLICY_PROVIDER_DLL_NAME, WT_PROVIDER_CERTTRUST_FUNCTION)
90 WINTRUST_INITREGENTRY(SoftpubCertCheck, SP_POLICY_PROVIDER_DLL_NAME, SP_CHKCERT_FUNCTION)
91 WINTRUST_INITREGENTRY(SoftpubFinalPolicy, SP_POLICY_PROVIDER_DLL_NAME, SP_FINALPOLICY_FUNCTION)
92 WINTRUST_INITREGENTRY(SoftpubCleanup, SP_POLICY_PROVIDER_DLL_NAME, SP_CLEANUPPOLICY_FUNCTION)
93 WINTRUST_INITREGENTRY(SoftpubDefCertInit, SP_POLICY_PROVIDER_DLL_NAME, SP_GENERIC_CERT_INIT_FUNCTION)
94 WINTRUST_INITREGENTRY(SoftpubDumpStructure, SP_POLICY_PROVIDER_DLL_NAME, SP_TESTDUMPPOLICY_FUNCTION_TEST)
95 WINTRUST_INITREGENTRY(HTTPSCertificateTrust, SP_POLICY_PROVIDER_DLL_NAME, HTTPS_CERTTRUST_FUNCTION)
96 WINTRUST_INITREGENTRY(HTTPSFinalProv, SP_POLICY_PROVIDER_DLL_NAME, HTTPS_FINALPOLICY_FUNCTION)
98 #undef WINTRUST_INITREGENTRY
101 /***********************************************************************
102 * WINTRUST_FreeRegStructs
104 * Helper function to free 2 members of the CRYPT_TRUST_REG_ENTRY
107 static void WINTRUST_FreeRegStructs(void)
109 #define WINTRUST_FREEREGENTRY( action ) \
110 HeapFree(GetProcessHeap(), 0, action.pwszDLLName); \
111 HeapFree(GetProcessHeap(), 0, action.pwszFunctionName);
113 WINTRUST_FREEREGENTRY(SoftpubInitialization);
114 WINTRUST_FREEREGENTRY(SoftpubMessage);
115 WINTRUST_FREEREGENTRY(SoftpubSignature);
116 WINTRUST_FREEREGENTRY(SoftpubCertficate);
117 WINTRUST_FREEREGENTRY(SoftpubCertCheck);
118 WINTRUST_FREEREGENTRY(SoftpubFinalPolicy);
119 WINTRUST_FREEREGENTRY(SoftpubCleanup);
120 WINTRUST_FREEREGENTRY(SoftpubDefCertInit);
121 WINTRUST_FREEREGENTRY(SoftpubDumpStructure);
122 WINTRUST_FREEREGENTRY(HTTPSCertificateTrust);
123 WINTRUST_FREEREGENTRY(HTTPSFinalProv);
125 #undef WINTRUST_FREEREGENTRY
128 /***********************************************************************
131 * Create a wide-string from a GUID
134 static void WINTRUST_Guid2Wstr(const GUID* pgActionID, WCHAR* GuidString)
136 static const WCHAR wszFormat[] = {'{','%','0','8','l','X','-','%','0','4','X','-','%','0','4','X','-',
137 '%','0','2','X','%','0','2','X','-','%','0','2','X','%','0','2','X','%','0','2','X','%','0','2',
138 'X','%','0','2','X','%','0','2','X','}', 0};
140 wsprintfW(GuidString, wszFormat, pgActionID->Data1, pgActionID->Data2, pgActionID->Data3,
141 pgActionID->Data4[0], pgActionID->Data4[1], pgActionID->Data4[2], pgActionID->Data4[3],
142 pgActionID->Data4[4], pgActionID->Data4[5], pgActionID->Data4[6], pgActionID->Data4[7]);
145 /***********************************************************************
146 * WINTRUST_WriteProviderToReg
148 * Helper function for WintrustAddActionID
151 static LONG WINTRUST_WriteProviderToReg(WCHAR* GuidString,
152 const WCHAR* FunctionType,
153 CRYPT_TRUST_REG_ENTRY RegEntry)
155 static const WCHAR Function[] = {'$','F','u','n','c','t','i','o','n', 0};
156 WCHAR ProvKey[MAX_PATH];
158 LONG Res = ERROR_SUCCESS;
160 /* Create the needed key string */
162 lstrcatW(ProvKey, Trust);
163 lstrcatW(ProvKey, FunctionType);
164 lstrcatW(ProvKey, GuidString);
166 if (!RegEntry.pwszDLLName || !RegEntry.pwszFunctionName)
167 return ERROR_INVALID_PARAMETER;
169 Res = RegCreateKeyExW(HKEY_LOCAL_MACHINE, ProvKey, 0, NULL, 0, KEY_WRITE, NULL, &Key, NULL);
170 if (Res != ERROR_SUCCESS) goto error_close_key;
172 /* Create the $DLL entry */
173 Res = RegSetValueExW(Key, Dll, 0, REG_SZ, (BYTE*)RegEntry.pwszDLLName,
174 (lstrlenW(RegEntry.pwszDLLName) + 1)*sizeof(WCHAR));
175 if (Res != ERROR_SUCCESS) goto error_close_key;
177 /* Create the $Function entry */
178 Res = RegSetValueExW(Key, Function, 0, REG_SZ, (BYTE*)RegEntry.pwszFunctionName,
179 (lstrlenW(RegEntry.pwszFunctionName) + 1)*sizeof(WCHAR));
187 /***********************************************************************
188 * WintrustAddActionID (WINTRUST.@)
190 * Add the definitions of the actions a Trust provider can perform to
194 * pgActionID [I] Pointer to a GUID for the Trust provider.
195 * fdwFlags [I] Flag to indicate whether registry errors are passed on.
196 * psProvInfo [I] Pointer to a structure with information about DLL
197 * name and functions.
201 * Failure: FALSE. (Use GetLastError() for more information)
204 * Adding definitions is basically only adding relevant information
205 * to the registry. No verification takes place whether a DLL or it's
207 * Information in the registry will always be overwritten.
210 BOOL WINAPI WintrustAddActionID( GUID* pgActionID, DWORD fdwFlags,
211 CRYPT_REGISTER_ACTIONID* psProvInfo)
213 WCHAR GuidString[39];
215 LONG WriteActionError = ERROR_SUCCESS;
217 TRACE("%p %lx %p\n", debugstr_guid(pgActionID), fdwFlags, psProvInfo);
219 /* Some sanity checks.
220 * We use the W2K3 last error as it makes more sense (W2K leaves the last error
225 (psProvInfo->cbStruct != sizeof(CRYPT_REGISTER_ACTIONID)))
227 SetLastError(ERROR_INVALID_PARAMETER);
231 /* Create this string only once, instead of in the helper function */
232 WINTRUST_Guid2Wstr( pgActionID, GuidString);
234 /* Write the information to the registry */
235 Res = WINTRUST_WriteProviderToReg(GuidString, Initialization , psProvInfo->sInitProvider);
236 if (Res != ERROR_SUCCESS) WriteActionError = Res;
237 Res = WINTRUST_WriteProviderToReg(GuidString, Message , psProvInfo->sObjectProvider);
238 if (Res != ERROR_SUCCESS) WriteActionError = Res;
239 Res = WINTRUST_WriteProviderToReg(GuidString, Signature , psProvInfo->sSignatureProvider);
240 if (Res != ERROR_SUCCESS) WriteActionError = Res;
241 Res = WINTRUST_WriteProviderToReg(GuidString, Certificate , psProvInfo->sCertificateProvider);
242 if (Res != ERROR_SUCCESS) WriteActionError = Res;
243 Res = WINTRUST_WriteProviderToReg(GuidString, CertCheck , psProvInfo->sCertificatePolicyProvider);
244 if (Res != ERROR_SUCCESS) WriteActionError = Res;
245 Res = WINTRUST_WriteProviderToReg(GuidString, FinalPolicy , psProvInfo->sFinalPolicyProvider);
246 if (Res != ERROR_SUCCESS) WriteActionError = Res;
247 Res = WINTRUST_WriteProviderToReg(GuidString, DiagnosticPolicy, psProvInfo->sTestPolicyProvider);
248 if (Res != ERROR_SUCCESS) WriteActionError = Res;
249 Res = WINTRUST_WriteProviderToReg(GuidString, Cleanup , psProvInfo->sCleanupProvider);
250 if (Res != ERROR_SUCCESS) WriteActionError = Res;
252 /* Testing (by restricting access to the registry for some keys) shows that the last failing function
253 * will be used for last error.
254 * If the flag WT_ADD_ACTION_ID_RET_RESULT_FLAG is set and there are errors when adding the action
255 * we have to return FALSE. Errors includes both invalid entries as well as registry errors.
256 * Testing also showed that one error doesn't stop the registry writes. Every action will be dealt with.
259 if (WriteActionError != ERROR_SUCCESS)
261 SetLastError(WriteActionError);
263 if (fdwFlags == WT_ADD_ACTION_ID_RET_RESULT_FLAG)
270 /***********************************************************************
271 * WINTRUST_RemoveProviderFromReg
273 * Helper function for WintrustRemoveActionID
276 static void WINTRUST_RemoveProviderFromReg(WCHAR* GuidString,
277 const WCHAR* FunctionType)
279 WCHAR ProvKey[MAX_PATH];
281 /* Create the needed key string */
283 lstrcatW(ProvKey, Trust);
284 lstrcatW(ProvKey, FunctionType);
285 lstrcatW(ProvKey, GuidString);
287 /* We don't care about success or failure */
288 RegDeleteKeyW(HKEY_LOCAL_MACHINE, ProvKey);
291 /***********************************************************************
292 * WintrustRemoveActionID (WINTRUST.@)
294 * Remove the definitions of the actions a Trust provider can perform
298 * pgActionID [I] Pointer to a GUID for the Trust provider.
301 * Success: TRUE. (Use GetLastError() for more information)
302 * Failure: FALSE. (Use GetLastError() for more information)
305 * Testing shows that WintrustRemoveActionID always returns TRUE and
306 * that a possible error should be retrieved via GetLastError().
307 * There are no checks if the definitions are in the registry.
309 BOOL WINAPI WintrustRemoveActionID( GUID* pgActionID )
311 WCHAR GuidString[39];
313 TRACE("(%s)\n", debugstr_guid(pgActionID));
317 SetLastError(ERROR_INVALID_PARAMETER);
321 /* Create this string only once, instead of in the helper function */
322 WINTRUST_Guid2Wstr( pgActionID, GuidString);
324 /* We don't care about success or failure */
325 WINTRUST_RemoveProviderFromReg(GuidString, Initialization);
326 WINTRUST_RemoveProviderFromReg(GuidString, Message);
327 WINTRUST_RemoveProviderFromReg(GuidString, Signature);
328 WINTRUST_RemoveProviderFromReg(GuidString, Certificate);
329 WINTRUST_RemoveProviderFromReg(GuidString, CertCheck);
330 WINTRUST_RemoveProviderFromReg(GuidString, FinalPolicy);
331 WINTRUST_RemoveProviderFromReg(GuidString, DiagnosticPolicy);
332 WINTRUST_RemoveProviderFromReg(GuidString, Cleanup);
337 /***********************************************************************
338 * WINTRUST_WriteSingleUsageEntry
340 * Write a single value and its data to:
342 * HKLM\Software\Microsoft\Cryptography\Trust\Usages\<OID>
344 static LONG WINTRUST_WriteSingleUsageEntry(LPCSTR OID,
348 static const WCHAR Usages[] = {'U','s','a','g','e','s','\\', 0};
351 LONG Res = ERROR_SUCCESS;
355 /* Turn OID into a wide-character string */
356 Len = MultiByteToWideChar( CP_ACP, 0, OID, -1, NULL, 0 );
357 OIDW = HeapAlloc( GetProcessHeap(), 0, Len * sizeof(WCHAR) );
358 MultiByteToWideChar( CP_ACP, 0, OID, -1, OIDW, Len );
360 /* Allocate the needed space for UsageKey */
361 UsageKey = HeapAlloc(GetProcessHeap(), 0, (lstrlenW(Trust) + lstrlenW(Usages) + Len) * sizeof(WCHAR));
362 /* Create the key string */
363 lstrcpyW(UsageKey, Trust);
364 lstrcatW(UsageKey, Usages);
365 lstrcatW(UsageKey, OIDW);
367 Res = RegCreateKeyExW(HKEY_LOCAL_MACHINE, UsageKey, 0, NULL, 0, KEY_WRITE, NULL, &Key, NULL);
368 if (Res == ERROR_SUCCESS)
370 /* Create the Value entry */
371 Res = RegSetValueExW(Key, Value, 0, REG_SZ, (BYTE*)Data,
372 (lstrlenW(Data) + 1)*sizeof(WCHAR));
376 HeapFree(GetProcessHeap(), 0, OIDW);
377 HeapFree(GetProcessHeap(), 0, UsageKey);
382 /***************************************************************************
383 * WINTRUST_RegisterGenVerifyV2
385 * Register WINTRUST_ACTION_GENERIC_VERIFY_V2 actions and usages.
388 * WINTRUST_ACTION_GENERIC_VERIFY_V2 ({00AAC56B-CD44-11D0-8CC2-00C04FC295EE}
389 * is defined in softpub.h
390 * We don't care about failures (see comments in DllRegisterServer)
392 static void WINTRUST_RegisterGenVerifyV2(void)
394 static const GUID ProvGUID = WINTRUST_ACTION_GENERIC_VERIFY_V2;
395 WCHAR GuidString[39];
397 WINTRUST_Guid2Wstr(&ProvGUID , GuidString);
399 TRACE("Going to register WINTRUST_ACTION_GENERIC_VERIFY_V2 : %s\n", wine_dbgstr_w(GuidString));
401 /* HKLM\Software\Microsoft\Cryptography\Trust\Usages\1.3.6.1.5.5.7.3.3 */
402 WINTRUST_WriteSingleUsageEntry(szOID_PKIX_KP_CODE_SIGNING, DefaultId, GuidString);
404 /* HKLM\Software\Microsoft\Cryptography\Trust\Provider\*\{00AAC56B-CD44-11D0-8CC2-00C04FC295EE} */
405 WINTRUST_WriteProviderToReg(GuidString, Initialization, SoftpubInitialization);
406 WINTRUST_WriteProviderToReg(GuidString, Message , SoftpubMessage);
407 WINTRUST_WriteProviderToReg(GuidString, Signature , SoftpubSignature);
408 WINTRUST_WriteProviderToReg(GuidString, Certificate , SoftpubCertficate);
409 WINTRUST_WriteProviderToReg(GuidString, CertCheck , SoftpubCertCheck);
410 WINTRUST_WriteProviderToReg(GuidString, FinalPolicy , SoftpubFinalPolicy);
411 WINTRUST_WriteProviderToReg(GuidString, Cleanup , SoftpubCleanup);
414 /***************************************************************************
415 * WINTRUST_RegisterPublishedSoftware
417 * Register WIN_SPUB_ACTION_PUBLISHED_SOFTWARE actions and usages.
420 * WIN_SPUB_ACTION_PUBLISHED_SOFTWARE ({64B9D180-8DA2-11CF-8736-00AA00A485EB})
421 * is defined in wintrust.h
422 * We don't care about failures (see comments in DllRegisterServer)
424 static void WINTRUST_RegisterPublishedSoftware(void)
426 static const GUID ProvGUID = WIN_SPUB_ACTION_PUBLISHED_SOFTWARE;
427 WCHAR GuidString[39];
429 WINTRUST_Guid2Wstr(&ProvGUID , GuidString);
431 TRACE("Going to register WIN_SPUB_ACTION_PUBLISHED_SOFTWARE : %s\n", wine_dbgstr_w(GuidString));
433 /* HKLM\Software\Microsoft\Cryptography\Trust\Provider\*\{64B9D180-8DA2-11CF-8736-00AA00A485EB} */
434 WINTRUST_WriteProviderToReg(GuidString, Initialization, SoftpubInitialization);
435 WINTRUST_WriteProviderToReg(GuidString, Message , SoftpubMessage);
436 WINTRUST_WriteProviderToReg(GuidString, Signature , SoftpubSignature);
437 WINTRUST_WriteProviderToReg(GuidString, Certificate , SoftpubCertficate);
438 WINTRUST_WriteProviderToReg(GuidString, CertCheck , SoftpubCertCheck);
439 WINTRUST_WriteProviderToReg(GuidString, FinalPolicy , SoftpubFinalPolicy);
440 WINTRUST_WriteProviderToReg(GuidString, Cleanup , SoftpubCleanup);
443 #define WIN_SPUB_ACTION_PUBLISHED_SOFTWARE_NOBADUI { 0xc6b2e8d0, 0xe005, 0x11cf, { 0xa1,0x34,0x00,0xc0,0x4f,0xd7,0xbf,0x43 }}
445 /***************************************************************************
446 * WINTRUST_RegisterPublishedSoftwareNoBadUi
448 * Register WIN_SPUB_ACTION_PUBLISHED_SOFTWARE_NOBADUI actions and usages.
451 * WIN_SPUB_ACTION_PUBLISHED_SOFTWARE_NOBADUI ({C6B2E8D0-E005-11CF-A134-00C04FD7BF43})
452 * is not defined in any include file. (FIXME: Find out if the name is correct).
453 * We don't care about failures (see comments in DllRegisterServer)
455 static void WINTRUST_RegisterPublishedSoftwareNoBadUi(void)
457 static const GUID ProvGUID = WIN_SPUB_ACTION_PUBLISHED_SOFTWARE_NOBADUI;
458 WCHAR GuidString[39];
460 WINTRUST_Guid2Wstr(&ProvGUID , GuidString);
462 TRACE("Going to register WIN_SPUB_ACTION_PUBLISHED_SOFTWARE_NOBADUI : %s\n", wine_dbgstr_w(GuidString));
464 /* HKLM\Software\Microsoft\Cryptography\Trust\Provider\*\{C6B2E8D0-E005-11CF-A134-00C04FD7BF43} */
465 WINTRUST_WriteProviderToReg(GuidString, Initialization, SoftpubInitialization);
466 WINTRUST_WriteProviderToReg(GuidString, Message , SoftpubMessage);
467 WINTRUST_WriteProviderToReg(GuidString, Signature , SoftpubSignature);
468 WINTRUST_WriteProviderToReg(GuidString, Certificate , SoftpubCertficate);
469 WINTRUST_WriteProviderToReg(GuidString, CertCheck , SoftpubCertCheck);
470 WINTRUST_WriteProviderToReg(GuidString, FinalPolicy , SoftpubFinalPolicy);
471 WINTRUST_WriteProviderToReg(GuidString, Cleanup , SoftpubCleanup);
474 /***************************************************************************
475 * WINTRUST_RegisterGenCertVerify
477 * Register WINTRUST_ACTION_GENERIC_CERT_VERIFY actions and usages.
480 * WINTRUST_ACTION_GENERIC_CERT_VERIFY ({189A3842-3041-11D1-85E1-00C04FC295EE})
481 * is defined in softpub.h
482 * We don't care about failures (see comments in DllRegisterServer)
484 static void WINTRUST_RegisterGenCertVerify(void)
486 static const GUID ProvGUID = WINTRUST_ACTION_GENERIC_CERT_VERIFY;
487 WCHAR GuidString[39];
489 WINTRUST_Guid2Wstr(&ProvGUID , GuidString);
491 TRACE("Going to register WINTRUST_ACTION_GENERIC_CERT_VERIFY : %s\n", wine_dbgstr_w(GuidString));
493 /* HKLM\Software\Microsoft\Cryptography\Trust\Provider\*\{189A3842-3041-11D1-85E1-00C04FC295EE} */
494 WINTRUST_WriteProviderToReg(GuidString, Initialization, SoftpubDefCertInit);
495 WINTRUST_WriteProviderToReg(GuidString, Message , SoftpubMessage);
496 WINTRUST_WriteProviderToReg(GuidString, Signature , SoftpubSignature);
497 WINTRUST_WriteProviderToReg(GuidString, Certificate , SoftpubCertficate);
498 WINTRUST_WriteProviderToReg(GuidString, CertCheck , SoftpubCertCheck);
499 WINTRUST_WriteProviderToReg(GuidString, FinalPolicy , SoftpubFinalPolicy);
500 WINTRUST_WriteProviderToReg(GuidString, Cleanup , SoftpubCleanup);
503 /***************************************************************************
504 * WINTRUST_RegisterTrustProviderTest
506 * Register WINTRUST_ACTION_TRUSTPROVIDER_TEST actions and usages.
509 * WINTRUST_ACTION_TRUSTPROVIDER_TEST ({573E31F8-DDBA-11D0-8CCB-00C04FC295EE})
510 * is defined in softpub.h
511 * We don't care about failures (see comments in DllRegisterServer)
513 static void WINTRUST_RegisterTrustProviderTest(void)
515 static const GUID ProvGUID = WINTRUST_ACTION_TRUSTPROVIDER_TEST;
516 WCHAR GuidString[39];
518 WINTRUST_Guid2Wstr(&ProvGUID , GuidString);
520 TRACE("Going to register WINTRUST_ACTION_TRUSTPROVIDER_TEST : %s\n", wine_dbgstr_w(GuidString));
522 /* HKLM\Software\Microsoft\Cryptography\Trust\Provider\*\{573E31F8-DDBA-11D0-8CCB-00C04FC295EE} */
523 WINTRUST_WriteProviderToReg(GuidString, Initialization , SoftpubInitialization);
524 WINTRUST_WriteProviderToReg(GuidString, Message , SoftpubMessage);
525 WINTRUST_WriteProviderToReg(GuidString, Signature , SoftpubSignature);
526 WINTRUST_WriteProviderToReg(GuidString, Certificate , SoftpubCertficate);
527 WINTRUST_WriteProviderToReg(GuidString, CertCheck , SoftpubCertCheck);
528 WINTRUST_WriteProviderToReg(GuidString, FinalPolicy , SoftpubFinalPolicy);
529 WINTRUST_WriteProviderToReg(GuidString, DiagnosticPolicy, SoftpubDumpStructure);
530 WINTRUST_WriteProviderToReg(GuidString, Cleanup , SoftpubCleanup);
533 /***************************************************************************
534 * WINTRUST_RegisterHttpsProv
536 * Register HTTPSPROV_ACTION actions and usages.
539 * HTTPSPROV_ACTION ({573E31F8-AABA-11D0-8CCB-00C04FC295EE})
540 * is defined in softpub.h
541 * We don't care about failures (see comments in DllRegisterServer)
543 static void WINTRUST_RegisterHttpsProv(void)
545 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};
546 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};
547 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};
548 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};
549 static const GUID ProvGUID = HTTPSPROV_ACTION;
550 WCHAR GuidString[39];
551 WCHAR ProvDllName[sizeof(SP_POLICY_PROVIDER_DLL_NAME)];
553 WINTRUST_Guid2Wstr(&ProvGUID , GuidString);
555 TRACE("Going to register HTTPSPROV_ACTION : %s\n", wine_dbgstr_w(GuidString));
557 lstrcpyW(ProvDllName, SP_POLICY_PROVIDER_DLL_NAME); \
559 /* HKLM\Software\Microsoft\Cryptography\Trust\Usages\1.3.6.1.5.5.7.3.1 */
560 WINTRUST_WriteSingleUsageEntry(szOID_PKIX_KP_SERVER_AUTH, Dll, ProvDllName);
561 WINTRUST_WriteSingleUsageEntry(szOID_PKIX_KP_SERVER_AUTH, CBAlloc, SoftpubLoadUsage );
562 WINTRUST_WriteSingleUsageEntry(szOID_PKIX_KP_SERVER_AUTH, CBFree, SoftpubFreeUsage );
563 WINTRUST_WriteSingleUsageEntry(szOID_PKIX_KP_SERVER_AUTH, DefaultId, GuidString );
564 /* HKLM\Software\Microsoft\Cryptography\Trust\Usages\1.3.6.1.5.5.7.3.2 */
565 WINTRUST_WriteSingleUsageEntry(szOID_PKIX_KP_CLIENT_AUTH, Dll, ProvDllName);
566 WINTRUST_WriteSingleUsageEntry(szOID_PKIX_KP_CLIENT_AUTH, CBAlloc, SoftpubLoadUsage );
567 WINTRUST_WriteSingleUsageEntry(szOID_PKIX_KP_CLIENT_AUTH, CBFree, SoftpubFreeUsage );
568 WINTRUST_WriteSingleUsageEntry(szOID_PKIX_KP_CLIENT_AUTH, DefaultId, GuidString );
569 /* HKLM\Software\Microsoft\Cryptography\Trust\Usages\1.3.6.1.4.1.311.10.3.3 */
570 WINTRUST_WriteSingleUsageEntry(szOID_SERVER_GATED_CRYPTO, Dll, ProvDllName);
571 WINTRUST_WriteSingleUsageEntry(szOID_SERVER_GATED_CRYPTO, CBAlloc, SoftpubLoadUsage );
572 WINTRUST_WriteSingleUsageEntry(szOID_SERVER_GATED_CRYPTO, CBFree, SoftpubFreeUsage );
573 WINTRUST_WriteSingleUsageEntry(szOID_SERVER_GATED_CRYPTO, DefaultId, GuidString );
574 /* HKLM\Software\Microsoft\Cryptography\Trust\Usages\2.16.840.1.113730.4.1 */
575 WINTRUST_WriteSingleUsageEntry(szOID_SGC_NETSCAPE, Dll, ProvDllName);
576 WINTRUST_WriteSingleUsageEntry(szOID_SGC_NETSCAPE, CBAlloc, SoftpubLoadUsage );
577 WINTRUST_WriteSingleUsageEntry(szOID_SGC_NETSCAPE, CBFree, SoftpubFreeUsage );
578 WINTRUST_WriteSingleUsageEntry(szOID_SGC_NETSCAPE, DefaultId, GuidString );
580 /* HKLM\Software\Microsoft\Cryptography\Trust\Provider\*\{573E31F8-AABA-11D0-8CCB-00C04FC295EE} */
581 WINTRUST_WriteProviderToReg(GuidString, Initialization, SoftpubInitialization);
582 WINTRUST_WriteProviderToReg(GuidString, Message , SoftpubMessage);
583 WINTRUST_WriteProviderToReg(GuidString, Signature , SoftpubSignature);
584 WINTRUST_WriteProviderToReg(GuidString, Certificate , HTTPSCertificateTrust);
585 WINTRUST_WriteProviderToReg(GuidString, CertCheck , SoftpubCertCheck);
586 WINTRUST_WriteProviderToReg(GuidString, FinalPolicy , HTTPSFinalProv);
587 WINTRUST_WriteProviderToReg(GuidString, Cleanup , SoftpubCleanup);
591 /***********************************************************************
592 * DllRegisterServer (WINTRUST.@)
594 HRESULT WINAPI DllRegisterServer(void)
601 /* Create the necessary action registry structures */
602 WINTRUST_InitRegStructs();
606 * A short list of stuff that should be done here:
608 * - Several calls to CryptRegisterOIDFunction
609 * - Several action registrations (NOT through WintrustAddActionID)
610 * - Several calls to CryptSIPAddProvider
611 * - One call to CryptSIPRemoveProvider (do we need that?)
614 /* Testing on W2K3 shows:
615 * If we cannot open HKLM\Software\Microsoft\Cryptography\Providers\Trust
616 * for writing, DllRegisterServer returns S_FALSE. If the key can be opened
617 * there is no check whether the actions can be written in the registry.
618 * As the previous list shows, there are several calls after these registrations.
619 * If they fail they will overwrite the returnvalue of DllRegisterServer.
622 /* Check if we can open/create HKLM\Software\Microsoft\Cryptography\Providers\Trust */
623 if (RegCreateKeyExW(HKEY_LOCAL_MACHINE, Trust, 0, NULL, 0, KEY_WRITE, NULL, &Key, NULL) != ERROR_SUCCESS)
627 /* Register several Trust Provider actions */
628 WINTRUST_RegisterGenVerifyV2();
629 WINTRUST_RegisterPublishedSoftware();
630 WINTRUST_RegisterPublishedSoftwareNoBadUi();
631 WINTRUST_RegisterGenCertVerify();
632 WINTRUST_RegisterTrustProviderTest();
633 WINTRUST_RegisterHttpsProv();
635 /* Free the registry structures */
636 WINTRUST_FreeRegStructs();
641 /***********************************************************************
642 * DllUnregisterServer (WINTRUST.@)
644 HRESULT WINAPI DllUnregisterServer(void)
650 /***********************************************************************
651 * SoftpubDllRegisterServer (WINTRUST.@)
653 HRESULT WINAPI SoftpubDllRegisterServer(void)
659 /***********************************************************************
660 * SoftpubDllUnregisterServer (WINTRUST.@)
662 HRESULT WINAPI SoftpubDllUnregisterServer(void)
668 /***********************************************************************
669 * mscat32DllRegisterServer (WINTRUST.@)
671 HRESULT WINAPI mscat32DllRegisterServer(void)
677 /***********************************************************************
678 * mscat32DllUnregisterServer (WINTRUST.@)
680 HRESULT WINAPI mscat32DllUnregisterServer(void)
686 /***********************************************************************
687 * mssip32DllRegisterServer (WINTRUST.@)
689 HRESULT WINAPI mssip32DllRegisterServer(void)
695 /***********************************************************************
696 * mssip32DllUnregisterServer (WINTRUST.@)
698 HRESULT WINAPI mssip32DllUnregisterServer(void)