2 * Copyright (C) 2004 Francois Gouget
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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 #ifndef __WINE_WINTRUST_H
20 #define __WINE_WINTRUST_H
27 typedef struct WINTRUST_FILE_INFO_
30 LPCWSTR pcwszFilePath
;
33 } WINTRUST_FILE_INFO
, *PWINTRUST_FILE_INFO
;
35 typedef struct WINTRUST_CATALOG_INFO_
38 DWORD dwCatalogVersion
;
39 LPCWSTR pcwszCatalogFilePath
;
40 LPCWSTR pcwszMemberTag
;
41 LPCWSTR pcwszMemberFilePath
;
43 BYTE
* pbCalculatedFileHash
;
44 DWORD cbCalculatedFileHash
;
45 PCCTL_CONTEXT pcCatalogContext
;
46 } WINTRUST_CATALOG_INFO
, *PWINTRUST_CATALOG_INFO
;
48 typedef struct WINTRUST_BLOB_INFO_
52 LPCWSTR pcwszDisplayName
;
57 } WINTRUST_BLOB_INFO
, *PWINTRUST_BLOB_INFO
;
59 typedef struct WINTRUST_SGNR_INFO_
62 LPCWSTR pcwszDisplayName
;
63 CMSG_SIGNER_INFO
* psSignerInfo
;
65 HCERTSTORE
* pahStores
;
66 } WINTRUST_SGNR_INFO
, *PWINTRUST_SGNR_INFO
;
68 typedef struct WINTRUST_CERT_INFO_
71 LPCWSTR pcwszDisplayName
;
72 CERT_CONTEXT
* psCertContext
;
74 HCERTSTORE
* pahStores
;
76 FILETIME
* psftVerifyAsOf
;
77 } WINTRUST_CERT_INFO
, *PWINTRUST_CERT_INFO
;
79 #define WTCI_DONT_OPEN_STORES 0x00000001
80 #define WTCI_OPEN_ONLY_ROOT 0x00000002
85 #define WTD_UI_NOBAD 3
86 #define WTD_UI_NOGOOD 4
87 /* fdwRevocationChecks */
88 #define WTD_REVOKE_NONE 0
89 #define WTD_REVOKE_WHOLECHAIN 1
91 #define WTD_CHOICE_FILE 1
92 #define WTD_CHOICE_CATALOG 2
93 #define WTD_CHOICE_BLOB 3
94 #define WTD_CHOICE_SIGNER 4
95 #define WTD_CHOICE_CERT 5
97 typedef struct _WINTRUST_DATA
100 LPVOID pPolicyCallbackData
;
101 LPVOID pSIPClientData
;
103 DWORD fdwRevocationChecks
;
107 struct WINTRUST_FILE_INFO_
* pFile
;
108 struct WINTRUST_CATALOG_INFO_
* pCatalog
;
109 struct WINTRUST_BLOB_INFO_
* pBlob
;
110 struct WINTRUST_SGNR_INFO_
* pSgnr
;
111 struct WINTRUST_CERT_INFO_
* pCert
;
115 HANDLE hWVTStateData
;
116 WCHAR
* pwszURLReference
;
119 } WINTRUST_DATA
, *PWINTRUST_DATA
;
121 #define WTD_STATEACTION_IGNORE 0
122 #define WTD_STATEACTION_VERIFY 1
123 #define WTD_STATEACTION_CLOSE 2
124 #define WTD_STATEACTION_AUTO_CACHE 3
125 #define WTD_STATEACTION_AUTO_CACHE_FLUSH 4
127 #define WTD_PROV_FLAGS_MASK 0x0000ffff
128 #define WTD_USE_IE4_TRUST_FLAG 0x00000001
129 #define WTD_NO_IE4_CHAIN_FLAG 0x00000002
130 #define WTD_NO_POLICY_USAGE_FLAG 0x00000004
131 #define WTD_REVOCATION_CHECK_NONE 0x00000010
132 #define WTD_REVOCATION_CHECK_END_CERT 0x00000020
133 #define WTD_REVOCATION_CHECK_CHAIN 0x00000040
134 #define WTD_REVOCATION_CHECK_CHAIN_EXCLUDE_ROOT 0x00000080
135 #define WTD_SAFER_FLAG 0x00000100
136 #define WTD_HASH_ONLY_FLAG 0x00000200
137 #define WTD_USE_DEFAULT_OSVER_CHECK 0x00000400
138 #define WTD_LIFETIME_SIGNING_FLAG 0x00000800
140 #define WTD_UICONTEXT_EXECUTE 0
141 #define WTD_UICONTEXT_INSTALL 1
143 typedef struct _CRYPT_TRUST_REG_ENTRY
147 WCHAR
*pwszFunctionName
;
148 } CRYPT_TRUST_REG_ENTRY
, *PCRYPT_TRUST_REG_ENTRY
;
150 typedef struct _CRYPT_REGISTER_ACTIONID
153 CRYPT_TRUST_REG_ENTRY sInitProvider
;
154 CRYPT_TRUST_REG_ENTRY sObjectProvider
;
155 CRYPT_TRUST_REG_ENTRY sSignatureProvider
;
156 CRYPT_TRUST_REG_ENTRY sCertificateProvider
;
157 CRYPT_TRUST_REG_ENTRY sCertificatePolicyProvider
;
158 CRYPT_TRUST_REG_ENTRY sFinalPolicyProvider
;
159 CRYPT_TRUST_REG_ENTRY sTestPolicyProvider
;
160 CRYPT_TRUST_REG_ENTRY sCleanupProvider
;
161 } CRYPT_REGISTER_ACTIONID
, *PCRYPT_REGISTER_ACTIONID
;
163 typedef struct _CRYPT_PROVIDER_REGDEFUSAGE
168 char *pwszLoadCallbackDataFunctionName
;
169 char *pwszFreeCallbackDataFunctionName
;
170 } CRYPT_PROVIDER_REGDEFUSAGE
, *PCRYPT_PROVIDER_REGDEFUSAGE
;
172 typedef struct _CRYPT_PROVUI_DATA
{
175 WCHAR
*pYesButtonText
;
176 WCHAR
*pNoButtonText
;
177 WCHAR
*pMoreInfoButtonText
;
178 WCHAR
*pAdvancedLinkText
;
179 WCHAR
*pCopyActionText
;
180 WCHAR
*pCopyActionTextNoTS
;
181 WCHAR
*pCopyActionTextNotSigned
;
182 } CRYPT_PROVUI_DATA
, *PCRYPT_PROVUI_DATA
;
184 typedef struct _CRYPT_PROVIDER_CERT
{
186 PCCERT_CONTEXT pCert
;
191 DWORD dwRevokedReason
;
194 CTL_CONTEXT
*pTrustListContext
;
195 BOOL fTrustListSignerCert
;
196 PCCTL_CONTEXT pCtlContext
;
199 PCERT_CHAIN_ELEMENT pChainElement
;
200 } CRYPT_PROVIDER_CERT
, *PCRYPT_PROVIDER_CERT
;
202 typedef struct _CRYPT_PROVIDER_SGNR
{
204 FILETIME sftVerifyAsOf
;
206 CRYPT_PROVIDER_CERT
*pasCertChain
;
208 CMSG_SIGNER_INFO
*psSigner
;
210 DWORD csCounterSigners
;
211 struct _CRYPT_PROVIDER_SGNR
*pasCounterSigners
;
212 PCCERT_CHAIN_CONTEXT pChainContext
;
213 } CRYPT_PROVIDER_SGNR
, *PCRYPT_PROVIDER_SGNR
;
215 typedef struct _CRYPT_PROVIDER_PRIVDATA
{
220 } CRYPT_PROVIDER_PRIVDATA
, *PCRYPT_PROVIDER_PRIVDATA
;
222 struct _CRYPT_PROVIDER_DATA
;
224 typedef void * (*PFN_CPD_MEM_ALLOC
)(DWORD cbSize
);
225 typedef void (*PFN_CPD_MEM_FREE
)(void *pvMem2Free
);
226 typedef BOOL (*PFN_CPD_ADD_STORE
)(struct _CRYPT_PROVIDER_DATA
*pProvData
,
227 HCERTSTORE hStore2Add
);
228 typedef BOOL (*PFN_CPD_ADD_SGNR
)(struct _CRYPT_PROVIDER_DATA
*pProvData
,
229 BOOL fCounterSigner
, DWORD idxSigner
, struct _CRYPT_PROVIDER_SGNR
*pSgnr2Add
);
230 typedef BOOL (*PFN_CPD_ADD_CERT
)(struct _CRYPT_PROVIDER_DATA
*pProvData
,
231 DWORD idxSigner
, BOOL fCounterSigner
, DWORD idxCounterSigner
,
232 PCCERT_CONTEXT pCert2Add
);
233 typedef BOOL (*PFN_CPD_ADD_PRIVDATA
)(struct _CRYPT_PROVIDER_DATA
*pProvData
,
234 struct _CRYPT_PROVIDER_PRIVDATA
*pPrivData2Add
);
235 typedef HRESULT (*PFN_PROVIDER_INIT_CALL
)(
236 struct _CRYPT_PROVIDER_DATA
*pProvData
);
237 typedef HRESULT (*PFN_PROVIDER_OBJTRUST_CALL
)(
238 struct _CRYPT_PROVIDER_DATA
*pProvData
);
239 typedef HRESULT (*PFN_PROVIDER_SIGTRUST_CALL
)(
240 struct _CRYPT_PROVIDER_DATA
*pProvData
);
241 typedef HRESULT (*PFN_PROVIDER_CERTTRUST_CALL
)(
242 struct _CRYPT_PROVIDER_DATA
*pProvData
);
243 typedef HRESULT (*PFN_PROVIDER_FINALPOLICY_CALL
)(
244 struct _CRYPT_PROVIDER_DATA
*pProvData
);
245 typedef HRESULT (*PFN_PROVIDER_TESTFINALPOLICY_CALL
)(
246 struct _CRYPT_PROVIDER_DATA
*pProvData
);
247 typedef HRESULT (*PFN_PROVIDER_CLEANUP_CALL
)(
248 struct _CRYPT_PROVIDER_DATA
*pProvData
);
249 typedef BOOL (*PFN_PROVIDER_CERTCHKPOLICY_CALL
)(
250 struct _CRYPT_PROVIDER_DATA
*pProvData
, DWORD idxSigner
,
251 BOOL fCounterSignerChain
, DWORD idxCounterSigner
);
253 typedef struct _CRYPT_PROVIDER_FUNCTIONS
{
255 PFN_CPD_MEM_ALLOC pfnAlloc
;
256 PFN_CPD_MEM_FREE pfnFree
;
257 PFN_CPD_ADD_STORE pfnAddStore2Chain
;
258 PFN_CPD_ADD_SGNR pfnAddSgnr2Chain
;
259 PFN_CPD_ADD_CERT pfnAddCert2Chain
;
260 PFN_CPD_ADD_PRIVDATA pfnAddPrivData2Chain
;
261 PFN_PROVIDER_INIT_CALL pfnInitialize
;
262 PFN_PROVIDER_OBJTRUST_CALL pfnObjectTrust
;
263 PFN_PROVIDER_SIGTRUST_CALL pfnSignatureTrust
;
264 PFN_PROVIDER_CERTTRUST_CALL pfnCertificateTrust
;
265 PFN_PROVIDER_FINALPOLICY_CALL pfnFinalPolicy
;
266 PFN_PROVIDER_CERTCHKPOLICY_CALL pfnCertCheckPolicy
;
267 PFN_PROVIDER_TESTFINALPOLICY_CALL pfnTestFinalPolicy
;
268 struct _CRYPT_PROVUI_FUNCS
*psUIpfns
;
269 PFN_PROVIDER_CLEANUP_CALL pfnCleanupPolicy
;
270 } CRYPT_PROVIDER_FUNCTIONS
, *PCRYPT_PROVIDER_FUNCTIONS
;
272 struct SIP_DISPATCH_INFO_
;
273 struct SIP_SUBJECTINFO_
;
274 struct SIP_INDIRECT_DATA_
;
276 typedef struct _PROVDATA_SIP
{
279 struct SIP_DISPATCH_INFO_
*pSip
;
280 struct SIP_DISPATCH_INFO_
*pCATSip
;
281 struct SIP_SUBJECTINFO_
*psSipSubjectInfo
;
282 struct SIP_SUBJECTINFO_
*psSipCATSubjectInfo
;
283 struct SIP_INDIRECT_DATA_
*psIndirectData
;
284 } PROVDATA_SIP
, *PPROVDATA_SIP
;
286 typedef struct _CRYPT_PROVIDER_DATA
{
288 WINTRUST_DATA
*pWintrustData
;
294 DWORD dwRegSecuritySettings
;
295 DWORD dwRegPolicySettings
;
296 CRYPT_PROVIDER_FUNCTIONS
*psPfns
;
297 DWORD cdwTrustStepErrors
;
298 DWORD
*padwTrustStepErrors
;
300 HCERTSTORE
*pahStores
;
304 CRYPT_PROVIDER_SGNR
*pasSigners
;
305 DWORD dwSubjectChoice
;
307 struct _PROVDATA_SIP
*pPDSip
;
310 BOOL fRecallWithState
;
311 FILETIME sftSystemTime
;
312 char *pszCTLSignerUsageOID
;
315 PCERT_USAGE_MATCH pRequestUsage
;
316 DWORD dwTrustPubSettings
;
317 DWORD dwUIStateFlags
;
318 } CRYPT_PROVIDER_DATA
, *PCRYPT_PROVIDER_DATA
;
320 typedef BOOL (*PFN_PROVUI_CALL
)(HWND hWndSecurityDialog
,
321 struct _CRYPT_PROVIDER_DATA
*pProvData
);
323 typedef struct _CRYPT_PROVUI_FUNCS
{
325 CRYPT_PROVUI_DATA psUIData
;
326 PFN_PROVUI_CALL pfnOnMoreInfoClick
;
327 PFN_PROVUI_CALL pfnOnMoreInfoClickDefault
;
328 PFN_PROVUI_CALL pfnOnAdvancedClick
;
329 PFN_PROVUI_CALL pfnOnAdvancedClickDefault
;
330 } CRYPT_PROVUI_FUNCS
, *PCRYPT_PROVUI_FUNCS
;
334 #define WTPF_TRUSTTEST 0x00000020
335 #define WTPF_TESTCANBEVALID 0x00000080
336 #define WTPF_IGNOREEXPIRATION 0x00000100
337 #define WTPF_IGNOREREVOKATION 0x00000200
338 #define WTPF_OFFLINEOK_IND 0x00000400
339 #define WTPF_OFFLINEOK_COM 0x00000800
340 #define WTPF_OFFLINEOKNBU_IND 0x00001000
341 #define WTPF_OFFLINEOKNBU_COM 0x00002000
342 #define WTPF_VERIFY_V1_OFF 0x00010000
343 #define WTPF_IGNOREREVOCATIONONTS 0x00020000
344 #define WTPF_ALLOWONLYPERTRUST 0x00040000
346 #define WT_ADD_ACTION_ID_RET_RESULT_FLAG 1
352 #if defined(__GNUC__)
353 #define WT_PROVIDER_CERTTRUST_FUNCTION (const WCHAR []) \
354 {'W','i','n','t','r','u','s','t','C','e','r','t','i','f','i','c','a','t','e','T','r','u','s','t', 0}
355 #elif defined(_MSC_VER)
356 #define WT_PROVIDER_CERTTRUST_FUNCTION L"WintrustCertificateTrust"
358 static const WCHAR WT_PROVIDER_CERTTRUST_FUNCTION
[] =
359 {'W','i','n','t','r','u','s','t','C','e','r','t','i','f','i','c','a','t','e','T','r','u','s','t', 0};
362 BOOL WINAPI
WintrustAddActionID(GUID
*,DWORD
,CRYPT_REGISTER_ACTIONID
*);
363 BOOL WINAPI
WintrustRemoveActionID(GUID
*);
364 BOOL WINAPI
WintrustLoadFunctionPointers(GUID
*,CRYPT_PROVIDER_FUNCTIONS
*);
365 BOOL WINAPI
WintrustAddDefaultForUsage(const char*,CRYPT_PROVIDER_REGDEFUSAGE
*);
366 void WINAPI
WintrustGetRegPolicyFlags(DWORD
*);
367 BOOL WINAPI
WintrustSetRegPolicyFlags(DWORD
);
368 LONG WINAPI
WinVerifyTrust(HWND
,GUID
*,LPVOID
);
369 HRESULT WINAPI
WinVerifyTrustEx(HWND
,GUID
*,WINTRUST_DATA
*);
371 CRYPT_PROVIDER_SGNR
* WINAPI
WTHelperGetProvSignerFromChain(
372 CRYPT_PROVIDER_DATA
*pProvData
, DWORD idxSigner
, BOOL fCounterSigner
,
373 DWORD idxCounterSigner
);
374 CRYPT_PROVIDER_DATA
* WINAPI
WTHelperProvDataFromStateData(HANDLE hStateData
);
376 #define SPC_INDIRECT_DATA_OBJID "1.3.6.1.4.1.311.2.1.4"
377 #define SPC_SP_AGENCY_INFO_OBJID "1.3.6.1.4.1.311.2.1.10"
378 #define SPC_STATEMENT_TYPE_OBJID "1.3.6.1.4.1.311.2.1.11"
379 #define SPC_SP_OPUS_INFO_OBJID "1.3.6.1.4.1.311.2.1.12"
380 #define SPC_PE_IMAGE_DATA_OBJID "1.3.6.1.4.1.311.2.1.15"
381 #define SPC_JAVA_CLASS_DATA_OBJID "1.3.6.1.4.1.311.2.1.20"
382 #define SPC_CAB_DATA_OBJID "1.3.6.1.4.1.311.2.1.25"
383 #define SPC_MINIMAL_CRITERIA_OBJID "1.3.6.1.4.1.311.2.1.26"
384 #define SPC_FINANCIAL_CRITERIA_OBJID "1.3.6.1.4.1.311.2.1.27"
385 #define SPC_LINK_OBJID "1.3.6.1.4.1.311.2.1.28"
386 #define SPC_SIGINFO_OBJID "1.3.6.1.4.1.311.2.1.30"
387 #define CAT_NAMEVALUE_OBJID "1.3.6.1.4.1.311.12.2.1"
388 #define CAT_MEMBERINFO_OBJID "1.3.6.1.4.1.311.12.2.2"
390 #define SPC_SP_AGENCY_INFO_STRUCT ((LPCSTR) 2000)
391 #define SPC_MINIMAL_CRITERIA_STRUCT ((LPCSTR) 2001)
392 #define SPC_FINANCIAL_CRITERIA_STRUCT ((LPCSTR) 2002)
393 #define SPC_INDIRECT_DATA_CONTENT_STRUCT ((LPCSTR) 2003)
394 #define SPC_PE_IMAGE_DATA_STRUCT ((LPCSTR) 2004)
395 #define SPC_LINK_STRUCT ((LPCSTR) 2005)
396 #define SPC_STATEMENT_TYPE_STRUCT ((LPCSTR) 2006)
397 #define SPC_SP_OPUS_INFO_STRUCT ((LPCSTR) 2007)
398 #define SPC_CAB_DATA_STRUCT ((LPCSTR) 2008)
399 #define SPC_JAVA_CLASS_DATA_STRUCT ((LPCSTR) 2009)
400 #define SPC_SIGINFO_STRUCT ((LPCSTR) 2130)
401 #define CAT_NAMEVALUE_STRUCT ((LPCSTR) 2221)
402 #define CAT_MEMBERINFO_STRUCT ((LPCSTR) 2222)
404 #define WIN_SPUB_ACTION_PUBLISHED_SOFTWARE \
405 { 0x64b9d180, 0x8da2, 0x11cf, { 0x87,0x36,0x00,0xaa,0x00,0xa4,0x85,0xeb }}