user: Add some missing messages to the message spy.
[wine] / include / wintrust.h
1 /*
2  * Copyright (C) 2004 Francois Gouget
3  *
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.
8  *
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.
13  *
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
17  */
18
19 #ifndef __WINE_WINTRUST_H
20 #define __WINE_WINTRUST_H
21
22 #include <wincrypt.h>
23
24
25 #include <pshpack8.h>
26
27 typedef struct WINTRUST_FILE_INFO_
28 {
29     DWORD   cbStruct;
30     LPCWSTR pcwszFilePath;
31     HANDLE  hFile;
32     GUID*   pgKnownSubject;
33 } WINTRUST_FILE_INFO, *PWINTRUST_FILE_INFO;
34
35 typedef struct WINTRUST_CATALOG_INFO_
36 {
37     DWORD         cbStruct;
38     DWORD         dwCatalogVersion;
39     LPCWSTR       pcwszCatalogFilePath;
40     LPCWSTR       pcwszMemberTag;
41     LPCWSTR       pcwszMemberFilePath;
42     HANDLE        hMemberFile;
43     BYTE*         pbCalculatedFileHash;
44     DWORD         cbCalculatedFileHash;
45     PCCTL_CONTEXT pcCatalogContext;
46 } WINTRUST_CATALOG_INFO, *PWINTRUST_CATALOG_INFO;
47
48 typedef struct WINTRUST_BLOB_INFO_
49 {
50     DWORD   cbStruct;
51     GUID    gSubject;
52     LPCWSTR pcwszDisplayName;
53     DWORD   cbMemObject;
54     BYTE*   pbMemObject;
55     DWORD   cbMemSignedMsg;
56     BYTE*   pbMemSignedMsg;
57 } WINTRUST_BLOB_INFO, *PWINTRUST_BLOB_INFO;
58
59 typedef struct WINTRUST_SGNR_INFO_
60 {
61     DWORD             cbStruct;
62     LPCWSTR           pcwszDisplayName;
63     CMSG_SIGNER_INFO* psSignerInfo;
64     DWORD             chStores;
65     HCERTSTORE*       pahStores;
66 } WINTRUST_SGNR_INFO, *PWINTRUST_SGNR_INFO;
67
68 typedef struct WINTRUST_CERT_INFO_
69 {
70     DWORD         cbStruct;
71     LPCWSTR       pcwszDisplayName;
72     CERT_CONTEXT* psCertContext;
73     DWORD         chStores;
74     HCERTSTORE*   pahStores;
75     DWORD         dwFlags;
76     FILETIME*     psftVerifyAsOf;
77 } WINTRUST_CERT_INFO, *PWINTRUST_CERT_INFO;
78
79 #define WTCI_DONT_OPEN_STORES 0x00000001
80 #define WTCI_OPEN_ONLY_ROOT   0x00000002
81
82 /* dwUIChoice */
83 #define WTD_UI_ALL                1
84 #define WTD_UI_NONE               2
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
90 /* dwUnionChoice */
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
96
97 typedef struct _WINTRUST_DATA
98 {
99     DWORD  cbStruct;
100     LPVOID pPolicyCallbackData;
101     LPVOID pSIPClientData;
102     DWORD  dwUIChoice;
103     DWORD  fdwRevocationChecks;
104     DWORD  dwUnionChoice;
105     union
106     {
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;
112     } DUMMYUNIONNAME;
113
114     DWORD  dwStateAction;
115     HANDLE hWVTStateData;
116     WCHAR* pwszURLReference;
117     DWORD  dwProvFlags;
118     DWORD  dwUIContext;
119 } WINTRUST_DATA, *PWINTRUST_DATA;
120
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
126
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
139
140 #define WTD_UICONTEXT_EXECUTE 0
141 #define WTD_UICONTEXT_INSTALL 1
142
143 typedef struct _CRYPT_TRUST_REG_ENTRY
144 {
145     DWORD cbStruct;
146     WCHAR *pwszDLLName;
147     WCHAR *pwszFunctionName;
148 } CRYPT_TRUST_REG_ENTRY, *PCRYPT_TRUST_REG_ENTRY;
149
150 typedef struct _CRYPT_REGISTER_ACTIONID
151 {
152     DWORD cbStruct;
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;
162
163 typedef struct _CRYPT_PROVIDER_REGDEFUSAGE
164 {
165     DWORD cbStruct;
166     GUID  *pgActionID;
167     WCHAR *pwszDllName;
168     char  *pwszLoadCallbackDataFunctionName;
169     char  *pwszFreeCallbackDataFunctionName;
170 } CRYPT_PROVIDER_REGDEFUSAGE, *PCRYPT_PROVIDER_REGDEFUSAGE;
171
172 typedef struct _CRYPT_PROVUI_DATA {
173     DWORD cbStruct;
174     DWORD dwFinalError;
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;
183
184 typedef struct _CRYPT_PROVIDER_CERT {
185     DWORD               cbStruct;
186     PCCERT_CONTEXT      pCert;
187     BOOL                fCommercial;
188     BOOL                fTrustedRoot;
189     BOOL                fSelfSigned;
190     BOOL                fTestCert;
191     DWORD               dwRevokedReason;
192     DWORD               dwConfidence;
193     DWORD               dwError;
194     CTL_CONTEXT        *pTrustListContext;
195     BOOL                fTrustListSignerCert;
196     PCCTL_CONTEXT       pCtlContext;
197     DWORD               dwCtlError;
198     BOOL                fIsCyclic;
199     PCERT_CHAIN_ELEMENT pChainElement;
200 } CRYPT_PROVIDER_CERT, *PCRYPT_PROVIDER_CERT;
201
202 typedef struct _CRYPT_PROVIDER_SGNR {
203     DWORD                cbStruct;
204     FILETIME             sftVerifyAsOf;
205     DWORD                csCertChain;
206     CRYPT_PROVIDER_CERT *pasCertChain;
207     DWORD                dwSignerType;
208     CMSG_SIGNER_INFO    *psSigner;
209     DWORD                dwError;
210     DWORD                csCounterSigners;
211     struct _CRYPT_PROVIDER_SGNR *pasCounterSigners;
212     PCCERT_CHAIN_CONTEXT pChainContext;
213 } CRYPT_PROVIDER_SGNR, *PCRYPT_PROVIDER_SGNR;
214
215 typedef struct _CRYPT_PROVIDER_PRIVDATA {
216     DWORD cbStruct;
217     GUID  gProviderID;
218     DWORD cbProvData;
219     void *pvProvData;
220 } CRYPT_PROVIDER_PRIVDATA, *PCRYPT_PROVIDER_PRIVDATA;
221
222 struct _CRYPT_PROVIDER_DATA;
223
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_CERTTTRUST_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);
252
253 typedef struct _CRYPT_PROVIDER_FUNCTIONS {
254     DWORD cbStruct;
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_CERTTTRUST_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;
271
272 struct SIP_DISPATCH_INFO_;
273 struct SIP_SUBJECTINFO_;
274 struct SIP_INDIRECT_DATA_;
275
276 typedef struct _PROVDATA_SIP {
277     DWORD cbStruct;
278     GUID  gSubject;
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;
285
286 typedef struct _CRYPT_PROVIDER_DATA {
287     DWORD                     cbStruct;
288     WINTRUST_DATA            *pWintrustData;
289     BOOL                      fOpenedFile;
290     HWND                      hWndParent;
291     GUID                     *pgActionID;
292     HCRYPTPROV                hProv;
293     DWORD                     dwError;
294     DWORD                     dwRegSecuritySettings;
295     DWORD                     dwRegPolicySettings;
296     CRYPT_PROVIDER_FUNCTIONS *psPfns;
297     DWORD                     cdwTrustStepErrors;
298     DWORD                    *padwTrustStepErrors;
299     DWORD                     chStores;
300     HCERTSTORE               *pahStores;
301     DWORD                     dwEncoding;
302     HCRYPTMSG                 hMsg;
303     DWORD                     csSigners;
304     CRYPT_PROVIDER_SGNR      *pasSigners;
305     DWORD                     dwSubjectChoice;
306     union {
307         struct _PROVDATA_SIP        *pPDSip;
308     } DUMMYUNIONNAME;
309     char                     *pszUsageOID;
310     BOOL                      fRecallWithState;
311     FILETIME                  sftSystemTime;
312     char                      *pszCTLSignerUsageOID;
313     DWORD                     dwProvFlags;
314     DWORD                     dwFinalError;
315     PCERT_USAGE_MATCH         pRequestUsage;
316     DWORD                     dwTrustPubSettings;
317     DWORD                     dwUIStateFlags;
318 } CRYPT_PROVIDER_DATA, *PCRYPT_PROVIDER_DATA;
319
320 typedef BOOL (*PFN_PROVUI_CALL)(HWND hWndSecurityDialog,
321  struct _CRYPT_PROVIDER_DATA *pProvData);
322
323 typedef struct _CRYPT_PROVUI_FUNCS {
324     DWORD cbStruct;
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;
331
332 #include <poppack.h>
333
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
345
346 #define WT_ADD_ACTION_ID_RET_RESULT_FLAG 1
347
348 #ifdef __cplusplus
349 extern "C" {
350 #endif
351
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"
357 #else
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};
360 #endif
361
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 LONG      WINAPI WinVerifyTrust(HWND,GUID*,LPVOID);
368 HRESULT   WINAPI WinVerifyTrustEx(HWND,GUID*,WINTRUST_DATA*);
369
370 CRYPT_PROVIDER_SGNR * WINAPI WTHelperGetProvSignerFromChain(
371  CRYPT_PROVIDER_DATA *pProvData, DWORD idxSigner, BOOL fCounterSigner,
372  DWORD idxCounterSigner);
373 CRYPT_PROVIDER_DATA * WINAPI WTHelperProvDataFromStateData(HANDLE hStateData);
374
375 #define SPC_INDIRECT_DATA_OBJID      "1.3.6.1.4.1.311.2.1.4"
376 #define SPC_SP_AGENCY_INFO_OBJID     "1.3.6.1.4.1.311.2.1.10"
377 #define SPC_STATEMENT_TYPE_OBJID     "1.3.6.1.4.1.311.2.1.11"
378 #define SPC_SP_OPUS_INFO_OBJID       "1.3.6.1.4.1.311.2.1.12"
379 #define SPC_PE_IMAGE_DATA_OBJID      "1.3.6.1.4.1.311.2.1.15"
380 #define SPC_JAVA_CLASS_DATA_OBJID    "1.3.6.1.4.1.311.2.1.20"
381 #define SPC_CAB_DATA_OBJID           "1.3.6.1.4.1.311.2.1.25"
382 #define SPC_MINIMAL_CRITERIA_OBJID   "1.3.6.1.4.1.311.2.1.26"
383 #define SPC_FINANCIAL_CRITERIA_OBJID "1.3.6.1.4.1.311.2.1.27"
384 #define SPC_LINK_OBJID               "1.3.6.1.4.1.311.2.1.28"
385 #define SPC_SIGINFO_OBJID            "1.3.6.1.4.1.311.2.1.30"
386 #define CAT_NAMEVALUE_OBJID          "1.3.6.1.4.1.311.12.2.1"
387 #define CAT_MEMBERINFO_OBJID         "1.3.6.1.4.1.311.12.2.2"
388
389 #define SPC_SP_AGENCY_INFO_STRUCT        ((LPCSTR) 2000)
390 #define SPC_MINIMAL_CRITERIA_STRUCT      ((LPCSTR) 2001)
391 #define SPC_FINANCIAL_CRITERIA_STRUCT    ((LPCSTR) 2002)
392 #define SPC_INDIRECT_DATA_CONTENT_STRUCT ((LPCSTR) 2003)
393 #define SPC_PE_IMAGE_DATA_STRUCT         ((LPCSTR) 2004)
394 #define SPC_LINK_STRUCT                  ((LPCSTR) 2005)
395 #define SPC_STATEMENT_TYPE_STRUCT        ((LPCSTR) 2006)
396 #define SPC_SP_OPUS_INFO_STRUCT          ((LPCSTR) 2007)
397 #define SPC_CAB_DATA_STRUCT              ((LPCSTR) 2008)
398 #define SPC_JAVA_CLASS_DATA_STRUCT       ((LPCSTR) 2009)
399 #define SPC_SIGINFO_STRUCT               ((LPCSTR) 2130)
400 #define CAT_NAMEVALUE_STRUCT             ((LPCSTR) 2221)
401 #define CAT_MEMBERINFO_STRUCT            ((LPCSTR) 2222)
402
403 #define WIN_SPUB_ACTION_PUBLISHED_SOFTWARE \
404      { 0x64b9d180, 0x8da2, 0x11cf, { 0x87,0x36,0x00,0xaa,0x00,0xa4,0x85,0xeb }}
405
406 #ifdef __cplusplus
407 }
408 #endif
409
410 #endif