2002-03-10 00:29:33 +01:00
|
|
|
/*
|
|
|
|
* Copyright 2001 Rein Klazes
|
|
|
|
*
|
|
|
|
* 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 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2002-03-10 00:29:33 +01:00
|
|
|
*/
|
|
|
|
|
2001-04-16 21:36:12 +02:00
|
|
|
#include "config.h"
|
|
|
|
|
2003-09-06 01:08:26 +02:00
|
|
|
#include <stdarg.h>
|
|
|
|
|
2001-04-16 21:36:12 +02:00
|
|
|
#include "windef.h"
|
2003-09-06 01:08:26 +02:00
|
|
|
#include "winbase.h"
|
2001-04-16 21:36:12 +02:00
|
|
|
#include "winerror.h"
|
2007-05-15 03:15:09 +02:00
|
|
|
#include "winreg.h"
|
2001-04-16 21:36:12 +02:00
|
|
|
#include "guiddef.h"
|
2004-10-21 23:00:29 +02:00
|
|
|
#include "wintrust.h"
|
2006-03-22 05:46:02 +01:00
|
|
|
#include "softpub.h"
|
2004-10-21 23:00:29 +02:00
|
|
|
#include "mscat.h"
|
2005-12-07 12:51:39 +01:00
|
|
|
#include "objbase.h"
|
2001-04-16 21:36:12 +02:00
|
|
|
|
2002-03-10 00:29:33 +01:00
|
|
|
#include "wine/debug.h"
|
2001-04-16 21:36:12 +02:00
|
|
|
|
2004-02-26 06:30:54 +01:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(wintrust);
|
2001-04-16 21:36:12 +02:00
|
|
|
|
2006-03-21 16:18:24 +01:00
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* DllMain (WINTRUST.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI DllMain( HINSTANCE inst, DWORD reason, LPVOID reserved )
|
|
|
|
{
|
|
|
|
switch(reason)
|
|
|
|
{
|
|
|
|
case DLL_WINE_PREATTACH:
|
|
|
|
return FALSE; /* prefer native version */
|
|
|
|
case DLL_PROCESS_ATTACH:
|
|
|
|
DisableThreadLibraryCalls( inst );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2006-08-02 02:20:33 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* TrustIsCertificateSelfSigned (WINTRUST.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI TrustIsCertificateSelfSigned( PCCERT_CONTEXT cert )
|
|
|
|
{
|
|
|
|
BOOL ret;
|
|
|
|
|
|
|
|
TRACE("%p\n", cert);
|
|
|
|
ret = CertCompareCertificateName(cert->dwCertEncodingType,
|
|
|
|
&cert->pCertInfo->Subject, &cert->pCertInfo->Issuer);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2001-04-25 21:54:21 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* WinVerifyTrust (WINTRUST.@)
|
2006-08-23 10:40:06 +02:00
|
|
|
*
|
|
|
|
* Verifies an object by calling the specified trust provider.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* hwnd [I] Handle to a caller window.
|
|
|
|
* ActionID [I] Pointer to a GUID that identifies the action to perform.
|
|
|
|
* ActionData [I] Information used by the trust provider to verify the object.
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: Zero.
|
|
|
|
* Failure: A TRUST_E_* error code.
|
|
|
|
*
|
|
|
|
* NOTES
|
|
|
|
* Trust providers can be found at:
|
|
|
|
* HKLM\SOFTWARE\Microsoft\Cryptography\Providers\Trust\
|
2001-04-25 21:54:21 +02:00
|
|
|
*/
|
2006-09-07 20:02:35 +02:00
|
|
|
LONG WINAPI WinVerifyTrust( HWND hwnd, GUID *ActionID, LPVOID ActionData )
|
2001-04-16 21:36:12 +02:00
|
|
|
{
|
2005-07-15 11:54:34 +02:00
|
|
|
FIXME("%p %s %p\n", hwnd, debugstr_guid(ActionID), ActionData);
|
2005-09-12 12:10:36 +02:00
|
|
|
return ERROR_SUCCESS;
|
2001-04-16 21:36:12 +02:00
|
|
|
}
|
2005-06-01 21:49:41 +02:00
|
|
|
|
2006-02-18 15:50:01 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* WinVerifyTrustEx (WINTRUST.@)
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI WinVerifyTrustEx( HWND hwnd, GUID *ActionID,
|
|
|
|
WINTRUST_DATA* ActionData )
|
|
|
|
{
|
2007-08-14 19:17:41 +02:00
|
|
|
return WinVerifyTrust(hwnd, ActionID, ActionData);
|
2006-02-18 15:50:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* WTHelperGetProvSignerFromChain (WINTRUST.@)
|
|
|
|
*/
|
|
|
|
CRYPT_PROVIDER_SGNR * WINAPI WTHelperGetProvSignerFromChain(
|
|
|
|
CRYPT_PROVIDER_DATA *pProvData, DWORD idxSigner, BOOL fCounterSigner,
|
|
|
|
DWORD idxCounterSigner)
|
|
|
|
{
|
2007-08-14 19:14:54 +02:00
|
|
|
CRYPT_PROVIDER_SGNR *sgnr;
|
|
|
|
|
|
|
|
TRACE("(%p %d %d %d)\n", pProvData, idxSigner, fCounterSigner,
|
2006-02-18 15:50:01 +01:00
|
|
|
idxCounterSigner);
|
2007-08-14 19:14:54 +02:00
|
|
|
|
|
|
|
if (idxSigner >= pProvData->csSigners || !pProvData->pasSigners)
|
|
|
|
return NULL;
|
|
|
|
sgnr = &pProvData->pasSigners[idxSigner];
|
|
|
|
if (fCounterSigner)
|
|
|
|
{
|
|
|
|
if (idxCounterSigner >= sgnr->csCounterSigners ||
|
|
|
|
!sgnr->pasCounterSigners)
|
|
|
|
return NULL;
|
|
|
|
sgnr = &sgnr->pasCounterSigners[idxCounterSigner];
|
|
|
|
}
|
|
|
|
TRACE("returning %p\n", sgnr);
|
|
|
|
return sgnr;
|
2006-02-18 15:50:01 +01:00
|
|
|
}
|
|
|
|
|
2007-08-14 19:16:10 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* WTHelperGetProvCertFromChain (WINTRUST.@)
|
|
|
|
*/
|
|
|
|
CRYPT_PROVIDER_CERT * WINAPI WTHelperGetProvCertFromChain(
|
|
|
|
CRYPT_PROVIDER_SGNR *pSgnr, DWORD idxCert)
|
|
|
|
{
|
|
|
|
CRYPT_PROVIDER_CERT *cert;
|
|
|
|
|
|
|
|
TRACE("(%p %d)\n", pSgnr, idxCert);
|
|
|
|
|
|
|
|
if (idxCert >= pSgnr->csCertChain || !pSgnr->pasCertChain)
|
|
|
|
return NULL;
|
|
|
|
cert = &pSgnr->pasCertChain[idxCert];
|
|
|
|
TRACE("returning %p\n", cert);
|
|
|
|
return cert;
|
|
|
|
}
|
|
|
|
|
2006-02-18 15:50:01 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* WTHelperProvDataFromStateData (WINTRUST.@)
|
|
|
|
*/
|
|
|
|
CRYPT_PROVIDER_DATA * WINAPI WTHelperProvDataFromStateData(HANDLE hStateData)
|
|
|
|
{
|
2007-08-14 19:16:43 +02:00
|
|
|
TRACE("%p\n", hStateData);
|
|
|
|
return (CRYPT_PROVIDER_DATA *)hStateData;
|
2006-02-18 15:50:01 +01:00
|
|
|
}
|
|
|
|
|
2007-05-15 03:15:09 +02:00
|
|
|
static const WCHAR Software_Publishing[] = {
|
|
|
|
'S','o','f','t','w','a','r','e','\\',
|
|
|
|
'M','i','c','r','o','s','o','f','t','\\',
|
|
|
|
'W','i','n','d','o','w','s','\\',
|
|
|
|
'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
|
|
|
|
'W','i','n','t','r','u','s','t','\\',
|
|
|
|
'T','r','u','s','t',' ','P','r','o','v','i','d','e','r','s','\\',
|
|
|
|
'S','o','f','t','w','a','r','e',' ',
|
|
|
|
'P','u','b','l','i','s','h','i','n','g',0 };
|
|
|
|
static const WCHAR State[] = { 'S','t','a','t','e',0 };
|
|
|
|
|
2005-06-01 21:49:41 +02:00
|
|
|
/***********************************************************************
|
2005-09-16 20:44:26 +02:00
|
|
|
* WintrustGetRegPolicyFlags (WINTRUST.@)
|
2005-06-01 21:49:41 +02:00
|
|
|
*/
|
|
|
|
void WINAPI WintrustGetRegPolicyFlags( DWORD* pdwPolicyFlags )
|
|
|
|
{
|
2007-05-15 03:15:09 +02:00
|
|
|
HKEY key;
|
|
|
|
LONG r;
|
|
|
|
|
|
|
|
TRACE("%p\n", pdwPolicyFlags);
|
|
|
|
|
2005-06-01 21:49:41 +02:00
|
|
|
*pdwPolicyFlags = 0;
|
2007-05-15 03:15:09 +02:00
|
|
|
r = RegCreateKeyExW(HKEY_CURRENT_USER, Software_Publishing, 0, NULL, 0,
|
|
|
|
KEY_READ, NULL, &key, NULL);
|
|
|
|
if (!r)
|
|
|
|
{
|
|
|
|
DWORD size = sizeof(DWORD);
|
|
|
|
|
|
|
|
r = RegQueryValueExW(key, State, NULL, NULL, (LPBYTE)pdwPolicyFlags,
|
|
|
|
&size);
|
|
|
|
RegCloseKey(key);
|
|
|
|
if (r)
|
|
|
|
{
|
|
|
|
/* Failed to query, create and return default value */
|
|
|
|
*pdwPolicyFlags = WTPF_IGNOREREVOCATIONONTS |
|
|
|
|
WTPF_OFFLINEOKNBU_COM |
|
|
|
|
WTPF_OFFLINEOKNBU_IND |
|
|
|
|
WTPF_OFFLINEOK_COM |
|
|
|
|
WTPF_OFFLINEOK_IND;
|
|
|
|
WintrustSetRegPolicyFlags(*pdwPolicyFlags);
|
|
|
|
}
|
|
|
|
}
|
2005-06-01 21:49:41 +02:00
|
|
|
}
|
2005-09-16 20:44:26 +02:00
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* WintrustSetRegPolicyFlags (WINTRUST.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI WintrustSetRegPolicyFlags( DWORD dwPolicyFlags)
|
|
|
|
{
|
2007-05-15 03:15:09 +02:00
|
|
|
HKEY key;
|
|
|
|
LONG r;
|
|
|
|
|
|
|
|
TRACE("%x\n", dwPolicyFlags);
|
|
|
|
|
|
|
|
r = RegCreateKeyExW(HKEY_CURRENT_USER, Software_Publishing, 0,
|
|
|
|
NULL, 0, KEY_WRITE, NULL, &key, NULL);
|
|
|
|
if (!r)
|
|
|
|
{
|
|
|
|
r = RegSetValueExW(key, State, 0, REG_DWORD, (LPBYTE)&dwPolicyFlags,
|
|
|
|
sizeof(DWORD));
|
|
|
|
RegCloseKey(key);
|
|
|
|
}
|
|
|
|
if (r) SetLastError(r);
|
|
|
|
return r == ERROR_SUCCESS;
|
2005-09-16 20:44:26 +02:00
|
|
|
}
|