[WINTRUST_WINETEST] Import Wine Staging commit bdb15cf (WinVerifyTrust tests), by...
[reactos.git] / rostests / winetests / wintrust / softpub.c
1 /*
2 * wintrust softpub functions tests
3 *
4 * Copyright 2007,2010 Juan Lang
5 * Copyright 2010 Andrey Turkin
6 * Copyright 2016 Mark Jansen
7 *
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
12 *
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 */
22
23 #include <stdio.h>
24 #include <stdarg.h>
25
26 #include <windef.h>
27 #include <winbase.h>
28 #include <winerror.h>
29 #include <wintrust.h>
30 #include <softpub.h>
31 #include <mssip.h>
32 #include <winuser.h>
33 #include "winnls.h"
34
35 #include "wine/test.h"
36
37 /* Just in case we're being built with borked headers, redefine function
38 * pointers to have the correct calling convention.
39 */
40 typedef void *(WINAPI *SAFE_MEM_ALLOC)(DWORD);
41 typedef void (WINAPI *SAFE_MEM_FREE)(void *);
42 typedef BOOL (WINAPI *SAFE_ADD_STORE)(CRYPT_PROVIDER_DATA *,
43 HCERTSTORE);
44 typedef BOOL (WINAPI *SAFE_ADD_SGNR)(CRYPT_PROVIDER_DATA *,
45 BOOL, DWORD, struct _CRYPT_PROVIDER_SGNR *);
46 typedef BOOL (WINAPI *SAFE_ADD_CERT)(CRYPT_PROVIDER_DATA *,
47 DWORD, BOOL, DWORD, PCCERT_CONTEXT);
48 typedef BOOL (WINAPI *SAFE_ADD_PRIVDATA)(CRYPT_PROVIDER_DATA *,
49 CRYPT_PROVIDER_PRIVDATA *);
50 typedef HRESULT (WINAPI *SAFE_PROVIDER_INIT_CALL)(CRYPT_PROVIDER_DATA *);
51 typedef HRESULT (WINAPI *SAFE_PROVIDER_OBJTRUST_CALL)(CRYPT_PROVIDER_DATA *);
52 typedef HRESULT (WINAPI *SAFE_PROVIDER_SIGTRUST_CALL)(CRYPT_PROVIDER_DATA *);
53 typedef HRESULT (WINAPI *SAFE_PROVIDER_CERTTRUST_CALL)(CRYPT_PROVIDER_DATA *);
54 typedef HRESULT (WINAPI *SAFE_PROVIDER_FINALPOLICY_CALL)(CRYPT_PROVIDER_DATA *);
55 typedef HRESULT (WINAPI *SAFE_PROVIDER_TESTFINALPOLICY_CALL)(
56 CRYPT_PROVIDER_DATA *);
57 typedef HRESULT (WINAPI *SAFE_PROVIDER_CLEANUP_CALL)(CRYPT_PROVIDER_DATA *);
58 typedef BOOL (WINAPI *SAFE_PROVIDER_CERTCHKPOLICY_CALL)(
59 CRYPT_PROVIDER_DATA *, DWORD, BOOL, DWORD);
60
61 typedef struct _SAFE_PROVIDER_FUNCTIONS
62 {
63 DWORD cbStruct;
64 SAFE_MEM_ALLOC pfnAlloc;
65 SAFE_MEM_FREE pfnFree;
66 SAFE_ADD_STORE pfnAddStore2Chain;
67 SAFE_ADD_SGNR pfnAddSgnr2Chain;
68 SAFE_ADD_CERT pfnAddCert2Chain;
69 SAFE_ADD_PRIVDATA pfnAddPrivData2Chain;
70 SAFE_PROVIDER_INIT_CALL pfnInitialize;
71 SAFE_PROVIDER_OBJTRUST_CALL pfnObjectTrust;
72 SAFE_PROVIDER_SIGTRUST_CALL pfnSignatureTrust;
73 SAFE_PROVIDER_CERTTRUST_CALL pfnCertificateTrust;
74 SAFE_PROVIDER_FINALPOLICY_CALL pfnFinalPolicy;
75 SAFE_PROVIDER_CERTCHKPOLICY_CALL pfnCertCheckPolicy;
76 SAFE_PROVIDER_TESTFINALPOLICY_CALL pfnTestFinalPolicy;
77 struct _CRYPT_PROVUI_FUNCS *psUIpfns;
78 SAFE_PROVIDER_CLEANUP_CALL pfnCleanupPolicy;
79 } SAFE_PROVIDER_FUNCTIONS;
80
81 static BOOL (WINAPI * pWTHelperGetKnownUsages)(DWORD action, PCCRYPT_OID_INFO **usages);
82 static BOOL (WINAPI * CryptSIPCreateIndirectData_p)(SIP_SUBJECTINFO *, DWORD *, SIP_INDIRECT_DATA *);
83 static VOID (WINAPI * CertFreeCertificateChain_p)(PCCERT_CHAIN_CONTEXT);
84
85 static void InitFunctionPtrs(void)
86 {
87 HMODULE hWintrust = GetModuleHandleA("wintrust.dll");
88 HMODULE hCrypt32 = GetModuleHandleA("crypt32.dll");
89
90 #define WINTRUST_GET_PROC(func) \
91 p ## func = (void*)GetProcAddress(hWintrust, #func); \
92 if(!p ## func) { \
93 trace("GetProcAddress(%s) failed\n", #func); \
94 }
95
96 WINTRUST_GET_PROC(WTHelperGetKnownUsages)
97
98 #undef WINTRUST_GET_PROC
99
100 #define CRYPT32_GET_PROC(func) \
101 func ## _p = (void*)GetProcAddress(hCrypt32, #func); \
102 if(!func ## _p) { \
103 trace("GetProcAddress(%s) failed\n", #func); \
104 }
105
106 CRYPT32_GET_PROC(CryptSIPCreateIndirectData)
107 CRYPT32_GET_PROC(CertFreeCertificateChain)
108
109 #undef CRYPT32_GET_PROC
110 }
111
112 static const BYTE v1CertWithPubKey[] = {
113 0x30,0x81,0x95,0x02,0x01,0x01,0x30,0x02,0x06,0x00,0x30,0x15,0x31,0x13,0x30,
114 0x11,0x06,0x03,0x55,0x04,0x03,0x13,0x0a,0x4a,0x75,0x61,0x6e,0x20,0x4c,0x61,
115 0x6e,0x67,0x00,0x30,0x22,0x18,0x0f,0x31,0x36,0x30,0x31,0x30,0x31,0x30,0x31,
116 0x30,0x30,0x30,0x30,0x30,0x30,0x5a,0x18,0x0f,0x31,0x36,0x30,0x31,0x30,0x31,
117 0x30,0x31,0x30,0x30,0x30,0x30,0x30,0x30,0x5a,0x30,0x15,0x31,0x13,0x30,0x11,
118 0x06,0x03,0x55,0x04,0x03,0x13,0x0a,0x4a,0x75,0x61,0x6e,0x20,0x4c,0x61,0x6e,
119 0x67,0x00,0x30,0x22,0x30,0x0d,0x06,0x09,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x01,
120 0x01,0x01,0x05,0x00,0x03,0x11,0x00,0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,
121 0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f,0xa3,0x16,0x30,0x14,0x30,0x12,0x06,
122 0x03,0x55,0x1d,0x13,0x01,0x01,0xff,0x04,0x08,0x30,0x06,0x01,0x01,0xff,0x02,
123 0x01,0x01 };
124
125 static void test_utils(SAFE_PROVIDER_FUNCTIONS *funcs)
126 {
127 CRYPT_PROVIDER_DATA data = { 0 };
128 HCERTSTORE store;
129 CRYPT_PROVIDER_SGNR sgnr = { 0 };
130 BOOL ret;
131
132 /* Crash
133 ret = funcs->pfnAddStore2Chain(NULL, NULL);
134 ret = funcs->pfnAddStore2Chain(&data, NULL);
135 */
136 store = CertOpenStore(CERT_STORE_PROV_MEMORY, X509_ASN_ENCODING, 0,
137 CERT_STORE_CREATE_NEW_FLAG, NULL);
138 if (store)
139 {
140 ret = funcs->pfnAddStore2Chain(&data, store);
141 ok(ret, "pfnAddStore2Chain failed: %08x\n", GetLastError());
142 ok(data.chStores == 1, "Expected 1 store, got %d\n", data.chStores);
143 ok(data.pahStores != NULL, "Expected pahStores to be allocated\n");
144 if (data.pahStores)
145 {
146 ok(data.pahStores[0] == store, "Unexpected store\n");
147 CertCloseStore(data.pahStores[0], 0);
148 funcs->pfnFree(data.pahStores);
149 data.pahStores = NULL;
150 data.chStores = 0;
151 CertCloseStore(store, 0);
152 store = NULL;
153 }
154 }
155 else
156 skip("CertOpenStore failed: %08x\n", GetLastError());
157
158 /* Crash
159 ret = funcs->pfnAddSgnr2Chain(NULL, FALSE, 0, NULL);
160 ret = funcs->pfnAddSgnr2Chain(&data, FALSE, 0, NULL);
161 */
162 ret = funcs->pfnAddSgnr2Chain(&data, FALSE, 0, &sgnr);
163 ok(ret, "pfnAddSgnr2Chain failed: %08x\n", GetLastError());
164 ok(data.csSigners == 1, "Expected 1 signer, got %d\n", data.csSigners);
165 ok(data.pasSigners != NULL, "Expected pasSigners to be allocated\n");
166 if (data.pasSigners)
167 {
168 PCCERT_CONTEXT cert;
169
170 ok(!memcmp(&data.pasSigners[0], &sgnr, sizeof(sgnr)),
171 "Unexpected data in signer\n");
172 /* Adds into the location specified by the index */
173 sgnr.cbStruct = sizeof(CRYPT_PROVIDER_SGNR);
174 sgnr.sftVerifyAsOf.dwLowDateTime = 0xdeadbeef;
175 ret = funcs->pfnAddSgnr2Chain(&data, FALSE, 1, &sgnr);
176 ok(ret, "pfnAddSgnr2Chain failed: %08x\n", GetLastError());
177 ok(data.csSigners == 2, "Expected 2 signers, got %d\n", data.csSigners);
178 ok(!memcmp(&data.pasSigners[1], &sgnr, sizeof(sgnr)),
179 "Unexpected data in signer\n");
180 /* This also adds, but the data aren't copied */
181 sgnr.cbStruct = sizeof(DWORD);
182 ret = funcs->pfnAddSgnr2Chain(&data, FALSE, 0, &sgnr);
183 ok(ret, "pfnAddSgnr2Chain failed: %08x\n", GetLastError());
184 ok(data.csSigners == 3, "Expected 3 signers, got %d\n", data.csSigners);
185 ok(data.pasSigners[0].cbStruct == 0, "Unexpected data size %d\n",
186 data.pasSigners[0].cbStruct);
187 ok(data.pasSigners[0].sftVerifyAsOf.dwLowDateTime == 0,
188 "Unexpected verify time %d\n",
189 data.pasSigners[0].sftVerifyAsOf.dwLowDateTime);
190 /* But too large a thing isn't added */
191 sgnr.cbStruct = sizeof(sgnr) + sizeof(DWORD);
192 SetLastError(0xdeadbeef);
193 ret = funcs->pfnAddSgnr2Chain(&data, FALSE, 0, &sgnr);
194 ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER,
195 "Expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
196
197 /* Crash
198 ret = funcs->pfnAddCert2Chain(NULL, 0, FALSE, 0, NULL);
199 ret = funcs->pfnAddCert2Chain(&data, 0, FALSE, 0, NULL);
200 */
201 cert = CertCreateCertificateContext(X509_ASN_ENCODING, v1CertWithPubKey,
202 sizeof(v1CertWithPubKey));
203 if (cert)
204 {
205 /* Notes on behavior that are hard to test:
206 * 1. If pasSigners is invalid, pfnAddCert2Chain crashes
207 * 2. An invalid signer index isn't checked.
208 */
209 ret = funcs->pfnAddCert2Chain(&data, 0, FALSE, 0, cert);
210 ok(ret, "pfnAddCert2Chain failed: %08x\n", GetLastError());
211 ok(data.pasSigners[0].csCertChain == 1, "Expected 1 cert, got %d\n",
212 data.pasSigners[0].csCertChain);
213 ok(data.pasSigners[0].pasCertChain != NULL,
214 "Expected pasCertChain to be allocated\n");
215 if (data.pasSigners[0].pasCertChain)
216 {
217 ok(data.pasSigners[0].pasCertChain[0].pCert == cert,
218 "Unexpected cert\n");
219 CertFreeCertificateContext(
220 data.pasSigners[0].pasCertChain[0].pCert);
221 }
222 CertFreeCertificateContext(cert);
223 }
224 else
225 skip("CertCreateCertificateContext failed: %08x\n", GetLastError());
226 funcs->pfnFree(data.pasSigners);
227 }
228 }
229
230 static void testInitialize(SAFE_PROVIDER_FUNCTIONS *funcs, GUID *actionID)
231 {
232 HRESULT ret;
233 CRYPT_PROVIDER_DATA data = { 0 };
234 WINTRUST_DATA wintrust_data = { 0 };
235
236 if (!funcs->pfnInitialize)
237 {
238 skip("missing pfnInitialize\n");
239 return;
240 }
241
242 /* Crashes
243 ret = funcs->pfnInitialize(NULL);
244 */
245 memset(&data, 0, sizeof(data));
246 ret = funcs->pfnInitialize(&data);
247 ok(ret == S_FALSE, "Expected S_FALSE, got %08x\n", ret);
248 data.padwTrustStepErrors =
249 funcs->pfnAlloc(TRUSTERROR_MAX_STEPS * sizeof(DWORD));
250 /* Without wintrust data set, crashes when padwTrustStepErrors is set */
251 data.pWintrustData = &wintrust_data;
252 if (data.padwTrustStepErrors)
253 {
254 /* Apparently, cdwTrustStepErrors does not need to be set. */
255 ret = funcs->pfnInitialize(&data);
256 ok(ret == S_OK, "Expected S_OK, got %08x\n", ret);
257 data.cdwTrustStepErrors = 1;
258 ret = funcs->pfnInitialize(&data);
259 ok(ret == S_OK, "Expected S_OK, got %08x\n", ret);
260 memset(data.padwTrustStepErrors, 0xba,
261 TRUSTERROR_MAX_STEPS * sizeof(DWORD));
262 ret = funcs->pfnInitialize(&data);
263 ok(ret == S_FALSE, "Expected S_FALSE, got %08x\n", ret);
264 data.padwTrustStepErrors[TRUSTERROR_STEP_FINAL_WVTINIT] = 0;
265 ret = funcs->pfnInitialize(&data);
266 ok(ret == S_OK, "Expected S_OK, got %08x\n", ret);
267 funcs->pfnFree(data.padwTrustStepErrors);
268 }
269 }
270
271 static void getNotepadPath(WCHAR *notepadPathW, DWORD size)
272 {
273 static const CHAR notepad[] = "\\notepad.exe";
274 CHAR notepadPath[MAX_PATH];
275
276 /* Workaround missing W-functions for win9x */
277 GetWindowsDirectoryA(notepadPath, MAX_PATH);
278 lstrcatA(notepadPath, notepad);
279 MultiByteToWideChar(CP_ACP, 0, notepadPath, -1, notepadPathW, size);
280 }
281
282 /* Creates a test file and returns a handle to it. The file's path is returned
283 * in temp_file, which must be at least MAX_PATH characters in length.
284 */
285 static HANDLE create_temp_file(WCHAR *temp_file)
286 {
287 HANDLE file = INVALID_HANDLE_VALUE;
288 WCHAR temp_path[MAX_PATH];
289
290 if (GetTempPathW(sizeof(temp_path) / sizeof(temp_path[0]), temp_path))
291 {
292 static const WCHAR img[] = { 'i','m','g',0 };
293
294 if (GetTempFileNameW(temp_path, img, 0, temp_file))
295 file = CreateFileW(temp_file, GENERIC_READ | GENERIC_WRITE, 0, NULL,
296 CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
297 }
298 return file;
299 }
300
301 static void testObjTrust(SAFE_PROVIDER_FUNCTIONS *funcs, GUID *actionID)
302 {
303 HRESULT ret;
304 CRYPT_PROVIDER_DATA data = { 0 };
305 WINTRUST_DATA wintrust_data = { 0 };
306 WINTRUST_CERT_INFO certInfo = { sizeof(WINTRUST_CERT_INFO), 0 };
307 WINTRUST_FILE_INFO fileInfo = { sizeof(WINTRUST_FILE_INFO), 0 };
308
309 if (!funcs->pfnObjectTrust)
310 {
311 skip("missing pfnObjectTrust\n");
312 return;
313 }
314
315 /* Crashes
316 ret = funcs->pfnObjectTrust(NULL);
317 */
318 data.pWintrustData = &wintrust_data;
319 data.padwTrustStepErrors =
320 funcs->pfnAlloc(TRUSTERROR_MAX_STEPS * sizeof(DWORD));
321 if (data.padwTrustStepErrors)
322 {
323 WCHAR pathW[MAX_PATH];
324 PROVDATA_SIP provDataSIP = { 0 };
325 static const GUID unknown = { 0xC689AAB8, 0x8E78, 0x11D0, { 0x8C,0x47,
326 0x00,0xC0,0x4F,0xC2,0x95,0xEE } };
327 static GUID bogusGuid = { 0xdeadbeef, 0xbaad, 0xf00d, { 0x00,0x00,0x00,
328 0x00,0x00,0x00,0x00,0x00 } };
329
330 ret = funcs->pfnObjectTrust(&data);
331 ok(ret == S_FALSE, "Expected S_FALSE, got %08x\n", ret);
332 ok(data.padwTrustStepErrors[TRUSTERROR_STEP_FINAL_OBJPROV] ==
333 ERROR_INVALID_PARAMETER,
334 "Expected ERROR_INVALID_PARAMETER, got %08x\n",
335 data.padwTrustStepErrors[TRUSTERROR_STEP_FINAL_OBJPROV]);
336 U(wintrust_data).pCert = &certInfo;
337 wintrust_data.dwUnionChoice = WTD_CHOICE_CERT;
338 ret = funcs->pfnObjectTrust(&data);
339 ok(ret == S_OK, "Expected S_OK, got %08x\n", ret);
340 certInfo.psCertContext = (PCERT_CONTEXT)CertCreateCertificateContext(
341 X509_ASN_ENCODING, v1CertWithPubKey, sizeof(v1CertWithPubKey));
342 ret = funcs->pfnObjectTrust(&data);
343 ok(ret == S_OK, "Expected S_OK, got %08x\n", ret);
344 CertFreeCertificateContext(certInfo.psCertContext);
345 certInfo.psCertContext = NULL;
346 wintrust_data.dwUnionChoice = WTD_CHOICE_FILE;
347 U(wintrust_data).pFile = NULL;
348 ret = funcs->pfnObjectTrust(&data);
349 ok(ret == S_FALSE, "Expected S_FALSE, got %08x\n", ret);
350 ok(data.padwTrustStepErrors[TRUSTERROR_STEP_FINAL_OBJPROV] ==
351 ERROR_INVALID_PARAMETER,
352 "Expected ERROR_INVALID_PARAMETER, got %08x\n",
353 data.padwTrustStepErrors[TRUSTERROR_STEP_FINAL_OBJPROV]);
354 U(wintrust_data).pFile = &fileInfo;
355 /* Crashes
356 ret = funcs->pfnObjectTrust(&data);
357 */
358 /* Create and test with an empty file */
359 fileInfo.hFile = create_temp_file(pathW);
360 /* pfnObjectTrust now crashes unless both pPDSip and psPfns are set */
361 U(data).pPDSip = &provDataSIP;
362 data.psPfns = (CRYPT_PROVIDER_FUNCTIONS *)funcs;
363 ret = funcs->pfnObjectTrust(&data);
364 ok(ret == S_FALSE, "Expected S_FALSE, got %08x\n", ret);
365 ok(data.padwTrustStepErrors[TRUSTERROR_STEP_FINAL_OBJPROV] ==
366 TRUST_E_SUBJECT_FORM_UNKNOWN,
367 "expected TRUST_E_SUBJECT_FORM_UNKNOWN, got %08x\n",
368 data.padwTrustStepErrors[TRUSTERROR_STEP_FINAL_OBJPROV]);
369 CloseHandle(fileInfo.hFile);
370 fileInfo.hFile = NULL;
371 fileInfo.pcwszFilePath = pathW;
372 ret = funcs->pfnObjectTrust(&data);
373 ok(ret == S_FALSE, "Expected S_FALSE, got %08x\n", ret);
374 ok(data.padwTrustStepErrors[TRUSTERROR_STEP_FINAL_OBJPROV] ==
375 TRUST_E_SUBJECT_FORM_UNKNOWN,
376 "expected TRUST_E_SUBJECT_FORM_UNKNOWN, got %08x\n",
377 data.padwTrustStepErrors[TRUSTERROR_STEP_FINAL_OBJPROV]);
378 DeleteFileW(pathW);
379 /* Test again with a file we expect to exist, and to contain no
380 * signature.
381 */
382 getNotepadPath(pathW, MAX_PATH);
383 ret = funcs->pfnObjectTrust(&data);
384 ok(ret == S_FALSE, "Expected S_FALSE, got %08x\n", ret);
385 ok(data.padwTrustStepErrors[TRUSTERROR_STEP_FINAL_OBJPROV] ==
386 TRUST_E_NOSIGNATURE ||
387 data.padwTrustStepErrors[TRUSTERROR_STEP_FINAL_OBJPROV] ==
388 TRUST_E_SUBJECT_FORM_UNKNOWN,
389 "Expected TRUST_E_NOSIGNATURE or TRUST_E_SUBJECT_FORM_UNKNOWN, got %08x\n",
390 data.padwTrustStepErrors[TRUSTERROR_STEP_FINAL_OBJPROV]);
391 if (data.padwTrustStepErrors[TRUSTERROR_STEP_FINAL_OBJPROV] ==
392 TRUST_E_NOSIGNATURE)
393 {
394 ok(!memcmp(&provDataSIP.gSubject, &unknown, sizeof(unknown)),
395 "Unexpected subject GUID\n");
396 ok(provDataSIP.pSip != NULL, "Expected a SIP\n");
397 ok(provDataSIP.psSipSubjectInfo != NULL,
398 "Expected a subject info\n");
399 }
400 /* Specifying the GUID results in that GUID being the subject GUID */
401 fileInfo.pgKnownSubject = &bogusGuid;
402 ret = funcs->pfnObjectTrust(&data);
403 ok(ret == S_FALSE, "Expected S_FALSE, got %08x\n", ret);
404 ok(data.padwTrustStepErrors[TRUSTERROR_STEP_FINAL_OBJPROV] ==
405 TRUST_E_NOSIGNATURE ||
406 data.padwTrustStepErrors[TRUSTERROR_STEP_FINAL_OBJPROV] ==
407 TRUST_E_SUBJECT_FORM_UNKNOWN ||
408 data.padwTrustStepErrors[TRUSTERROR_STEP_FINAL_OBJPROV] ==
409 TRUST_E_PROVIDER_UNKNOWN,
410 "Expected TRUST_E_NOSIGNATURE or TRUST_E_SUBJECT_FORM_UNKNOWN or TRUST_E_PROVIDER_UNKNOWN, got %08x\n",
411 data.padwTrustStepErrors[TRUSTERROR_STEP_FINAL_OBJPROV]);
412 if (data.padwTrustStepErrors[TRUSTERROR_STEP_FINAL_OBJPROV] ==
413 TRUST_E_NOSIGNATURE)
414 {
415 ok(!memcmp(&provDataSIP.gSubject, &bogusGuid, sizeof(bogusGuid)),
416 "unexpected subject GUID\n");
417 }
418 /* Specifying a bogus GUID pointer crashes */
419 if (0)
420 {
421 fileInfo.pgKnownSubject = (GUID *)0xdeadbeef;
422 ret = funcs->pfnObjectTrust(&data);
423 ok(ret == S_FALSE, "Expected S_FALSE, got %08x\n", ret);
424 }
425 funcs->pfnFree(data.padwTrustStepErrors);
426 }
427 }
428
429 static const BYTE selfSignedCert[] = {
430 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x42, 0x45, 0x47, 0x49, 0x4e, 0x20, 0x43,
431 0x45, 0x52, 0x54, 0x49, 0x46, 0x49, 0x43, 0x41, 0x54, 0x45, 0x2d, 0x2d,
432 0x2d, 0x2d, 0x2d, 0x0a, 0x4d, 0x49, 0x49, 0x44, 0x70, 0x7a, 0x43, 0x43,
433 0x41, 0x6f, 0x2b, 0x67, 0x41, 0x77, 0x49, 0x42, 0x41, 0x67, 0x49, 0x4a,
434 0x41, 0x4c, 0x59, 0x51, 0x67, 0x65, 0x66, 0x7a, 0x51, 0x41, 0x61, 0x43,
435 0x4d, 0x41, 0x30, 0x47, 0x43, 0x53, 0x71, 0x47, 0x53, 0x49, 0x62, 0x33,
436 0x44, 0x51, 0x45, 0x42, 0x42, 0x51, 0x55, 0x41, 0x4d, 0x47, 0x6f, 0x78,
437 0x43, 0x7a, 0x41, 0x4a, 0x42, 0x67, 0x4e, 0x56, 0x0a, 0x42, 0x41, 0x59,
438 0x54, 0x41, 0x6b, 0x46, 0x56, 0x4d, 0x52, 0x4d, 0x77, 0x45, 0x51, 0x59,
439 0x44, 0x56, 0x51, 0x51, 0x49, 0x44, 0x41, 0x70, 0x54, 0x62, 0x32, 0x31,
440 0x6c, 0x4c, 0x56, 0x4e, 0x30, 0x59, 0x58, 0x52, 0x6c, 0x4d, 0x53, 0x45,
441 0x77, 0x48, 0x77, 0x59, 0x44, 0x56, 0x51, 0x51, 0x4b, 0x44, 0x42, 0x68,
442 0x4a, 0x62, 0x6e, 0x52, 0x6c, 0x63, 0x6d, 0x35, 0x6c, 0x64, 0x43, 0x42,
443 0x58, 0x0a, 0x61, 0x57, 0x52, 0x6e, 0x61, 0x58, 0x52, 0x7a, 0x49, 0x46,
444 0x42, 0x30, 0x65, 0x53, 0x42, 0x4d, 0x64, 0x47, 0x51, 0x78, 0x49, 0x7a,
445 0x41, 0x68, 0x42, 0x67, 0x4e, 0x56, 0x42, 0x41, 0x4d, 0x4d, 0x47, 0x6e,
446 0x4e, 0x6c, 0x62, 0x47, 0x5a, 0x7a, 0x61, 0x57, 0x64, 0x75, 0x5a, 0x57,
447 0x51, 0x75, 0x64, 0x47, 0x56, 0x7a, 0x64, 0x43, 0x35, 0x33, 0x61, 0x57,
448 0x35, 0x6c, 0x61, 0x48, 0x45, 0x75, 0x0a, 0x62, 0x33, 0x4a, 0x6e, 0x4d,
449 0x42, 0x34, 0x58, 0x44, 0x54, 0x45, 0x7a, 0x4d, 0x44, 0x59, 0x79, 0x4d,
450 0x54, 0x45, 0x78, 0x4d, 0x6a, 0x55, 0x78, 0x4d, 0x46, 0x6f, 0x58, 0x44,
451 0x54, 0x49, 0x7a, 0x4d, 0x44, 0x59, 0x78, 0x4f, 0x54, 0x45, 0x78, 0x4d,
452 0x6a, 0x55, 0x78, 0x4d, 0x46, 0x6f, 0x77, 0x61, 0x6a, 0x45, 0x4c, 0x4d,
453 0x41, 0x6b, 0x47, 0x41, 0x31, 0x55, 0x45, 0x42, 0x68, 0x4d, 0x43, 0x0a,
454 0x51, 0x56, 0x55, 0x78, 0x45, 0x7a, 0x41, 0x52, 0x42, 0x67, 0x4e, 0x56,
455 0x42, 0x41, 0x67, 0x4d, 0x43, 0x6c, 0x4e, 0x76, 0x62, 0x57, 0x55, 0x74,
456 0x55, 0x33, 0x52, 0x68, 0x64, 0x47, 0x55, 0x78, 0x49, 0x54, 0x41, 0x66,
457 0x42, 0x67, 0x4e, 0x56, 0x42, 0x41, 0x6f, 0x4d, 0x47, 0x45, 0x6c, 0x75,
458 0x64, 0x47, 0x56, 0x79, 0x62, 0x6d, 0x56, 0x30, 0x49, 0x46, 0x64, 0x70,
459 0x5a, 0x47, 0x64, 0x70, 0x0a, 0x64, 0x48, 0x4d, 0x67, 0x55, 0x48, 0x52,
460 0x35, 0x49, 0x45, 0x78, 0x30, 0x5a, 0x44, 0x45, 0x6a, 0x4d, 0x43, 0x45,
461 0x47, 0x41, 0x31, 0x55, 0x45, 0x41, 0x77, 0x77, 0x61, 0x63, 0x32, 0x56,
462 0x73, 0x5a, 0x6e, 0x4e, 0x70, 0x5a, 0x32, 0x35, 0x6c, 0x5a, 0x43, 0x35,
463 0x30, 0x5a, 0x58, 0x4e, 0x30, 0x4c, 0x6e, 0x64, 0x70, 0x62, 0x6d, 0x56,
464 0x6f, 0x63, 0x53, 0x35, 0x76, 0x63, 0x6d, 0x63, 0x77, 0x0a, 0x67, 0x67,
465 0x45, 0x69, 0x4d, 0x41, 0x30, 0x47, 0x43, 0x53, 0x71, 0x47, 0x53, 0x49,
466 0x62, 0x33, 0x44, 0x51, 0x45, 0x42, 0x41, 0x51, 0x55, 0x41, 0x41, 0x34,
467 0x49, 0x42, 0x44, 0x77, 0x41, 0x77, 0x67, 0x67, 0x45, 0x4b, 0x41, 0x6f,
468 0x49, 0x42, 0x41, 0x51, 0x44, 0x77, 0x4e, 0x6d, 0x2b, 0x46, 0x7a, 0x78,
469 0x6e, 0x6b, 0x48, 0x57, 0x2f, 0x4e, 0x70, 0x37, 0x59, 0x48, 0x34, 0x4d,
470 0x79, 0x45, 0x0a, 0x77, 0x4d, 0x6c, 0x49, 0x67, 0x71, 0x30, 0x66, 0x45,
471 0x77, 0x70, 0x47, 0x6f, 0x41, 0x75, 0x78, 0x44, 0x64, 0x61, 0x46, 0x55,
472 0x32, 0x6f, 0x70, 0x76, 0x41, 0x51, 0x56, 0x61, 0x2b, 0x41, 0x43, 0x46,
473 0x38, 0x63, 0x6f, 0x38, 0x4d, 0x4a, 0x6c, 0x33, 0x78, 0x77, 0x76, 0x46,
474 0x44, 0x2b, 0x67, 0x61, 0x46, 0x45, 0x7a, 0x59, 0x78, 0x53, 0x58, 0x30,
475 0x43, 0x47, 0x72, 0x4a, 0x45, 0x4c, 0x63, 0x0a, 0x74, 0x34, 0x4d, 0x69,
476 0x30, 0x68, 0x4b, 0x50, 0x76, 0x42, 0x70, 0x65, 0x73, 0x59, 0x6c, 0x46,
477 0x4d, 0x51, 0x65, 0x6b, 0x2b, 0x63, 0x70, 0x51, 0x50, 0x33, 0x4b, 0x35,
478 0x75, 0x36, 0x71, 0x58, 0x5a, 0x52, 0x49, 0x67, 0x48, 0x75, 0x59, 0x45,
479 0x4c, 0x2f, 0x73, 0x55, 0x6f, 0x39, 0x32, 0x70, 0x44, 0x30, 0x7a, 0x4a,
480 0x65, 0x4c, 0x47, 0x41, 0x31, 0x49, 0x30, 0x4b, 0x5a, 0x34, 0x73, 0x2f,
481 0x0a, 0x51, 0x7a, 0x77, 0x61, 0x4f, 0x38, 0x62, 0x62, 0x4b, 0x6d, 0x37,
482 0x42, 0x72, 0x6e, 0x56, 0x77, 0x30, 0x6e, 0x5a, 0x2f, 0x4b, 0x41, 0x5a,
483 0x6a, 0x75, 0x78, 0x75, 0x6f, 0x4e, 0x33, 0x52, 0x64, 0x72, 0x69, 0x30,
484 0x4a, 0x48, 0x77, 0x7a, 0x6a, 0x41, 0x55, 0x34, 0x2b, 0x71, 0x57, 0x65,
485 0x55, 0x63, 0x2f, 0x64, 0x33, 0x45, 0x70, 0x4f, 0x47, 0x78, 0x69, 0x42,
486 0x77, 0x5a, 0x4e, 0x61, 0x7a, 0x0a, 0x39, 0x6f, 0x4a, 0x41, 0x37, 0x54,
487 0x2f, 0x51, 0x6f, 0x62, 0x75, 0x61, 0x4e, 0x53, 0x6b, 0x65, 0x55, 0x48,
488 0x43, 0x61, 0x50, 0x53, 0x6a, 0x44, 0x37, 0x71, 0x7a, 0x6c, 0x43, 0x4f,
489 0x52, 0x48, 0x47, 0x68, 0x75, 0x31, 0x76, 0x79, 0x79, 0x35, 0x31, 0x45,
490 0x36, 0x79, 0x46, 0x43, 0x4e, 0x47, 0x66, 0x65, 0x7a, 0x71, 0x2f, 0x4d,
491 0x59, 0x34, 0x4e, 0x4b, 0x68, 0x77, 0x72, 0x61, 0x59, 0x64, 0x0a, 0x62,
492 0x79, 0x49, 0x2f, 0x6c, 0x42, 0x46, 0x62, 0x36, 0x35, 0x6b, 0x5a, 0x45,
493 0x66, 0x49, 0x4b, 0x4b, 0x54, 0x7a, 0x79, 0x36, 0x76, 0x30, 0x44, 0x65,
494 0x79, 0x50, 0x37, 0x52, 0x6b, 0x34, 0x75, 0x48, 0x44, 0x38, 0x77, 0x62,
495 0x49, 0x79, 0x50, 0x32, 0x47, 0x6c, 0x42, 0x30, 0x67, 0x37, 0x2f, 0x69,
496 0x79, 0x33, 0x4c, 0x61, 0x74, 0x49, 0x74, 0x49, 0x70, 0x2b, 0x49, 0x35,
497 0x53, 0x50, 0x56, 0x0a, 0x41, 0x67, 0x4d, 0x42, 0x41, 0x41, 0x47, 0x6a,
498 0x55, 0x44, 0x42, 0x4f, 0x4d, 0x42, 0x30, 0x47, 0x41, 0x31, 0x55, 0x64,
499 0x44, 0x67, 0x51, 0x57, 0x42, 0x42, 0x53, 0x36, 0x49, 0x4c, 0x5a, 0x2f,
500 0x71, 0x38, 0x66, 0x2f, 0x4b, 0x45, 0x68, 0x4b, 0x76, 0x68, 0x69, 0x2b,
501 0x73, 0x6b, 0x59, 0x45, 0x31, 0x79, 0x48, 0x71, 0x39, 0x7a, 0x41, 0x66,
502 0x42, 0x67, 0x4e, 0x56, 0x48, 0x53, 0x4d, 0x45, 0x0a, 0x47, 0x44, 0x41,
503 0x57, 0x67, 0x42, 0x53, 0x36, 0x49, 0x4c, 0x5a, 0x2f, 0x71, 0x38, 0x66,
504 0x2f, 0x4b, 0x45, 0x68, 0x4b, 0x76, 0x68, 0x69, 0x2b, 0x73, 0x6b, 0x59,
505 0x45, 0x31, 0x79, 0x48, 0x71, 0x39, 0x7a, 0x41, 0x4d, 0x42, 0x67, 0x4e,
506 0x56, 0x48, 0x52, 0x4d, 0x45, 0x42, 0x54, 0x41, 0x44, 0x41, 0x51, 0x48,
507 0x2f, 0x4d, 0x41, 0x30, 0x47, 0x43, 0x53, 0x71, 0x47, 0x53, 0x49, 0x62,
508 0x33, 0x0a, 0x44, 0x51, 0x45, 0x42, 0x42, 0x51, 0x55, 0x41, 0x41, 0x34,
509 0x49, 0x42, 0x41, 0x51, 0x41, 0x79, 0x5a, 0x59, 0x77, 0x47, 0x4b, 0x46,
510 0x34, 0x34, 0x43, 0x68, 0x47, 0x51, 0x72, 0x6e, 0x74, 0x57, 0x6c, 0x38,
511 0x48, 0x53, 0x4a, 0x30, 0x63, 0x69, 0x55, 0x58, 0x4d, 0x44, 0x4b, 0x32,
512 0x46, 0x6c, 0x6f, 0x74, 0x47, 0x49, 0x6a, 0x30, 0x32, 0x6c, 0x4d, 0x39,
513 0x38, 0x71, 0x45, 0x49, 0x65, 0x68, 0x0a, 0x56, 0x67, 0x66, 0x41, 0x34,
514 0x7a, 0x69, 0x37, 0x4d, 0x45, 0x6c, 0x51, 0x61, 0x76, 0x6b, 0x52, 0x76,
515 0x32, 0x54, 0x43, 0x50, 0x50, 0x55, 0x51, 0x62, 0x35, 0x51, 0x64, 0x61,
516 0x6f, 0x37, 0x57, 0x78, 0x37, 0x6c, 0x66, 0x61, 0x54, 0x6f, 0x5a, 0x68,
517 0x4f, 0x54, 0x2b, 0x4e, 0x52, 0x68, 0x32, 0x6b, 0x35, 0x78, 0x2b, 0x6b,
518 0x6a, 0x5a, 0x46, 0x77, 0x38, 0x70, 0x45, 0x48, 0x74, 0x35, 0x51, 0x0a,
519 0x69, 0x68, 0x62, 0x46, 0x4c, 0x35, 0x58, 0x2b, 0x57, 0x7a, 0x6f, 0x2b,
520 0x42, 0x36, 0x36, 0x59, 0x79, 0x49, 0x76, 0x68, 0x77, 0x54, 0x63, 0x48,
521 0x30, 0x46, 0x2b, 0x6e, 0x66, 0x55, 0x71, 0x66, 0x74, 0x38, 0x59, 0x74,
522 0x72, 0x2f, 0x38, 0x37, 0x47, 0x45, 0x62, 0x73, 0x41, 0x48, 0x6a, 0x48,
523 0x43, 0x36, 0x4c, 0x2b, 0x77, 0x6b, 0x31, 0x76, 0x4e, 0x6e, 0x64, 0x49,
524 0x59, 0x47, 0x30, 0x51, 0x0a, 0x79, 0x62, 0x73, 0x7a, 0x78, 0x49, 0x72,
525 0x32, 0x6d, 0x46, 0x45, 0x49, 0x4a, 0x6f, 0x69, 0x51, 0x44, 0x44, 0x67,
526 0x66, 0x6c, 0x71, 0x67, 0x64, 0x76, 0x4c, 0x54, 0x32, 0x79, 0x64, 0x46,
527 0x6d, 0x79, 0x33, 0x73, 0x32, 0x68, 0x49, 0x74, 0x51, 0x6c, 0x49, 0x71,
528 0x4b, 0x4c, 0x42, 0x36, 0x49, 0x4a, 0x51, 0x49, 0x75, 0x69, 0x37, 0x72,
529 0x37, 0x34, 0x76, 0x64, 0x72, 0x63, 0x58, 0x71, 0x58, 0x0a, 0x44, 0x7a,
530 0x68, 0x6d, 0x4c, 0x66, 0x67, 0x6a, 0x67, 0x4c, 0x77, 0x33, 0x2b, 0x55,
531 0x79, 0x69, 0x59, 0x74, 0x44, 0x54, 0x76, 0x63, 0x78, 0x65, 0x7a, 0x62,
532 0x4c, 0x73, 0x76, 0x51, 0x6f, 0x52, 0x6b, 0x74, 0x77, 0x4b, 0x5a, 0x4c,
533 0x44, 0x54, 0x42, 0x42, 0x35, 0x76, 0x59, 0x32, 0x78, 0x4b, 0x36, 0x6b,
534 0x4f, 0x4f, 0x44, 0x70, 0x7a, 0x50, 0x48, 0x73, 0x4b, 0x67, 0x30, 0x42,
535 0x59, 0x77, 0x0a, 0x4d, 0x6b, 0x48, 0x56, 0x56, 0x54, 0x34, 0x79, 0x2f,
536 0x4d, 0x59, 0x36, 0x63, 0x63, 0x4b, 0x51, 0x2f, 0x4c, 0x56, 0x74, 0x32,
537 0x66, 0x4a, 0x49, 0x74, 0x69, 0x41, 0x71, 0x49, 0x47, 0x32, 0x38, 0x64,
538 0x37, 0x31, 0x53, 0x0a, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x45, 0x4e, 0x44,
539 0x20, 0x43, 0x45, 0x52, 0x54, 0x49, 0x46, 0x49, 0x43, 0x41, 0x54, 0x45,
540 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x0a
541 };
542
543 static void testCertTrust(SAFE_PROVIDER_FUNCTIONS *funcs, GUID *actionID)
544 {
545 CRYPT_PROVIDER_DATA data = { 0 };
546 CRYPT_PROVIDER_SGNR sgnr = { sizeof(sgnr), { 0 } };
547 HRESULT ret;
548 BOOL b;
549
550 if (!CertFreeCertificateChain_p)
551 {
552 win_skip("CertFreeCertificateChain not found\n");
553 return;
554 }
555
556 data.padwTrustStepErrors =
557 funcs->pfnAlloc(TRUSTERROR_MAX_STEPS * sizeof(DWORD));
558 if (!data.padwTrustStepErrors)
559 {
560 skip("pfnAlloc failed\n");
561 return;
562 }
563 ret = funcs->pfnCertificateTrust(&data);
564 ok(ret == S_FALSE, "Expected S_FALSE, got %08x\n", ret);
565 ok(data.padwTrustStepErrors[TRUSTERROR_STEP_FINAL_CERTPROV] ==
566 TRUST_E_NOSIGNATURE, "Expected TRUST_E_NOSIGNATURE, got %08x\n",
567 data.padwTrustStepErrors[TRUSTERROR_STEP_FINAL_CERTPROV]);
568 b = funcs->pfnAddSgnr2Chain(&data, FALSE, 0, &sgnr);
569 if (b)
570 {
571 PCCERT_CONTEXT cert;
572
573 /* An empty signer "succeeds," even though there's no cert */
574 ret = funcs->pfnCertificateTrust(&data);
575 ok(ret == S_OK, "Expected S_OK, got %08x\n", ret);
576 cert = CertCreateCertificateContext(X509_ASN_ENCODING, selfSignedCert,
577 sizeof(selfSignedCert));
578 if (cert)
579 {
580 WINTRUST_DATA wintrust_data = { 0 };
581
582 b = funcs->pfnAddCert2Chain(&data, 0, FALSE, 0, cert);
583 ok(b == TRUE, "Expected TRUE, got %d\n", b);
584
585 /* If pWintrustData isn't set, crashes attempting to access
586 * pWintrustData->fdwRevocationChecks
587 */
588 data.pWintrustData = &wintrust_data;
589 /* If psPfns isn't set, crashes attempting to access
590 * psPfns->pfnCertCheckPolicy
591 */
592 data.psPfns = (CRYPT_PROVIDER_FUNCTIONS *)funcs;
593 ret = funcs->pfnCertificateTrust(&data);
594 ok(ret == S_OK, "Expected S_OK, got %08x\n", ret);
595 ok(data.csSigners == 1, "Unexpected number of signers %d\n",
596 data.csSigners);
597 ok(data.pasSigners[0].pChainContext != NULL,
598 "Expected a certificate chain\n");
599 ok(data.pasSigners[0].csCertChain == 1,
600 "Unexpected number of chain elements %d\n",
601 data.pasSigners[0].csCertChain);
602 /* pasSigners and pasSigners[0].pasCertChain are guaranteed to be
603 * initialized, see tests for pfnAddSgnr2Chain and pfnAddCert2Chain
604 */
605 ok(!data.pasSigners[0].pasCertChain[0].fTrustedRoot,
606 "Didn't expect cert to be trusted\n");
607 ok(data.pasSigners[0].pasCertChain[0].fSelfSigned,
608 "Expected cert to be self-signed\n");
609 ok(data.pasSigners[0].pasCertChain[0].dwConfidence ==
610 (CERT_CONFIDENCE_SIG | CERT_CONFIDENCE_TIMENEST),
611 "Expected CERT_CONFIDENCE_SIG | CERT_CONFIDENCE_TIMENEST, got %08x\n",
612 data.pasSigners[0].pasCertChain[0].dwConfidence);
613 CertFreeCertificateContext(
614 data.pasSigners[0].pasCertChain[0].pCert);
615 CertFreeCertificateChain_p(data.pasSigners[0].pChainContext);
616 CertFreeCertificateContext(cert);
617 }
618 }
619 funcs->pfnFree(data.padwTrustStepErrors);
620 }
621
622 static void test_provider_funcs(void)
623 {
624 static GUID generic_verify_v2 = WINTRUST_ACTION_GENERIC_VERIFY_V2;
625 SAFE_PROVIDER_FUNCTIONS funcs = { sizeof(SAFE_PROVIDER_FUNCTIONS), 0 };
626 BOOL ret;
627
628 ret = WintrustLoadFunctionPointers(&generic_verify_v2,
629 (CRYPT_PROVIDER_FUNCTIONS *)&funcs);
630 if (!ret)
631 skip("WintrustLoadFunctionPointers failed\n");
632 else
633 {
634 test_utils(&funcs);
635 testInitialize(&funcs, &generic_verify_v2);
636 testObjTrust(&funcs, &generic_verify_v2);
637 testCertTrust(&funcs, &generic_verify_v2);
638 }
639 }
640
641 /* minimal PE file image */
642 #define VA_START 0x400000
643 #define FILE_PE_START 0x50
644 #define NUM_SECTIONS 3
645 #define FILE_TEXT 0x200
646 #define RVA_TEXT 0x1000
647 #define RVA_BSS 0x2000
648 #define FILE_IDATA 0x400
649 #define RVA_IDATA 0x3000
650 #define FILE_TOTAL 0x600
651 #define RVA_TOTAL 0x4000
652 #include <pshpack1.h>
653 struct Imports {
654 IMAGE_IMPORT_DESCRIPTOR descriptors[2];
655 IMAGE_THUNK_DATA32 original_thunks[2];
656 IMAGE_THUNK_DATA32 thunks[2];
657 struct __IMPORT_BY_NAME {
658 WORD hint;
659 char funcname[0x20];
660 } ibn;
661 char dllname[0x10];
662 };
663 #define EXIT_PROCESS (VA_START+RVA_IDATA+FIELD_OFFSET(struct Imports, thunks))
664
665 static struct _PeImage {
666 IMAGE_DOS_HEADER dos_header;
667 char __alignment1[FILE_PE_START - sizeof(IMAGE_DOS_HEADER)];
668 IMAGE_NT_HEADERS32 nt_headers;
669 IMAGE_SECTION_HEADER sections[NUM_SECTIONS];
670 char __alignment2[FILE_TEXT - FILE_PE_START - sizeof(IMAGE_NT_HEADERS32) -
671 NUM_SECTIONS * sizeof(IMAGE_SECTION_HEADER)];
672 unsigned char text_section[FILE_IDATA-FILE_TEXT];
673 struct Imports idata_section;
674 char __alignment3[FILE_TOTAL-FILE_IDATA-sizeof(struct Imports)];
675 } bin = {
676 /* dos header */
677 {IMAGE_DOS_SIGNATURE, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, {0}, 0, 0, {0}, FILE_PE_START},
678 /* alignment before PE header */
679 {0},
680 /* nt headers */
681 {IMAGE_NT_SIGNATURE,
682 /* basic headers - 3 sections, no symbols, EXE file */
683 {IMAGE_FILE_MACHINE_I386, NUM_SECTIONS, 0, 0, 0, sizeof(IMAGE_OPTIONAL_HEADER32),
684 IMAGE_FILE_32BIT_MACHINE | IMAGE_FILE_EXECUTABLE_IMAGE},
685 /* optional header */
686 {IMAGE_NT_OPTIONAL_HDR32_MAGIC, 4, 0, FILE_IDATA-FILE_TEXT,
687 FILE_TOTAL-FILE_IDATA + FILE_IDATA-FILE_TEXT, 0x400,
688 RVA_TEXT, RVA_TEXT, RVA_BSS, VA_START, 0x1000, 0x200, 4, 0, 1, 0, 4, 0, 0,
689 RVA_TOTAL, FILE_TEXT, 0, IMAGE_SUBSYSTEM_WINDOWS_GUI, 0,
690 0x200000, 0x1000, 0x100000, 0x1000, 0, 0x10,
691 {{0, 0},
692 {RVA_IDATA, sizeof(struct Imports)}
693 }
694 }
695 },
696 /* sections */
697 {
698 {".text", {0x100}, RVA_TEXT, FILE_IDATA-FILE_TEXT, FILE_TEXT,
699 0, 0, 0, 0, IMAGE_SCN_CNT_CODE | IMAGE_SCN_MEM_EXECUTE | IMAGE_SCN_MEM_READ},
700 {".bss", {0x400}, RVA_BSS, 0, 0, 0, 0, 0, 0,
701 IMAGE_SCN_CNT_UNINITIALIZED_DATA | IMAGE_SCN_MEM_READ | IMAGE_SCN_MEM_WRITE},
702 {".idata", {sizeof(struct Imports)}, RVA_IDATA, FILE_TOTAL-FILE_IDATA, FILE_IDATA, 0,
703 0, 0, 0, IMAGE_SCN_CNT_INITIALIZED_DATA | IMAGE_SCN_MEM_READ | IMAGE_SCN_MEM_WRITE}
704 },
705 /* alignment before first section */
706 {0},
707 /* .text section */
708 {
709 0x31, 0xC0, /* xor eax, eax */
710 0xFF, 0x25, EXIT_PROCESS&0xFF, (EXIT_PROCESS>>8)&0xFF, (EXIT_PROCESS>>16)&0xFF,
711 (EXIT_PROCESS>>24)&0xFF, /* jmp ExitProcess */
712 0
713 },
714 /* .idata section */
715 {
716 {
717 {{RVA_IDATA + FIELD_OFFSET(struct Imports, original_thunks)}, 0, 0,
718 RVA_IDATA + FIELD_OFFSET(struct Imports, dllname),
719 RVA_IDATA + FIELD_OFFSET(struct Imports, thunks)
720 },
721 {{0}, 0, 0, 0, 0}
722 },
723 {{{RVA_IDATA+FIELD_OFFSET(struct Imports, ibn)}}, {{0}}},
724 {{{RVA_IDATA+FIELD_OFFSET(struct Imports, ibn)}}, {{0}}},
725 {0,"ExitProcess"},
726 "KERNEL32.DLL"
727 },
728 /* final alignment */
729 {0}
730 };
731 #include <poppack.h>
732
733 static void test_sip_create_indirect_data(void)
734 {
735 static GUID unknown = { 0xC689AAB8, 0x8E78, 0x11D0, { 0x8C,0x47,
736 0x00,0xC0,0x4F,0xC2,0x95,0xEE } };
737 static char oid_sha1[] = szOID_OIWSEC_sha1;
738 BOOL ret;
739 SIP_SUBJECTINFO subjinfo = { 0 };
740 WCHAR temp_file[MAX_PATH];
741 HANDLE file;
742 DWORD count;
743
744 if (!CryptSIPCreateIndirectData_p)
745 {
746 skip("Missing CryptSIPCreateIndirectData\n");
747 return;
748 }
749 SetLastError(0xdeadbeef);
750 ret = CryptSIPCreateIndirectData_p(NULL, NULL, NULL);
751 ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER,
752 "expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
753 SetLastError(0xdeadbeef);
754 ret = CryptSIPCreateIndirectData_p(&subjinfo, NULL, NULL);
755 ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER,
756 "expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
757 subjinfo.cbSize = sizeof(subjinfo);
758 SetLastError(0xdeadbeef);
759 ret = CryptSIPCreateIndirectData_p(&subjinfo, NULL, NULL);
760 ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER,
761 "expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
762 file = create_temp_file(temp_file);
763 if (file == INVALID_HANDLE_VALUE)
764 {
765 skip("couldn't create temp file\n");
766 return;
767 }
768 WriteFile(file, &bin, sizeof(bin), &count, NULL);
769 FlushFileBuffers(file);
770
771 subjinfo.hFile = file;
772 SetLastError(0xdeadbeef);
773 ret = CryptSIPCreateIndirectData_p(&subjinfo, NULL, NULL);
774 ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER,
775 "expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
776 subjinfo.pgSubjectType = &unknown;
777 SetLastError(0xdeadbeef);
778 ret = CryptSIPCreateIndirectData_p(&subjinfo, NULL, NULL);
779 ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER,
780 "expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
781 count = 0xdeadbeef;
782 SetLastError(0xdeadbeef);
783 ret = CryptSIPCreateIndirectData_p(&subjinfo, &count, NULL);
784 todo_wine
785 ok(!ret && (GetLastError() == NTE_BAD_ALGID ||
786 GetLastError() == ERROR_INVALID_PARAMETER /* Win7 */),
787 "expected NTE_BAD_ALGID or ERROR_INVALID_PARAMETER, got %08x\n",
788 GetLastError());
789 ok(count == 0xdeadbeef, "expected count to be unmodified, got %d\n", count);
790 subjinfo.DigestAlgorithm.pszObjId = oid_sha1;
791 count = 0xdeadbeef;
792 ret = CryptSIPCreateIndirectData_p(&subjinfo, &count, NULL);
793 todo_wine
794 ok(ret, "CryptSIPCreateIndirectData failed: %d\n", GetLastError());
795 ok(count, "expected a positive count\n");
796 if (ret)
797 {
798 SIP_INDIRECT_DATA *indirect = HeapAlloc(GetProcessHeap(), 0, count);
799
800 count = 256;
801 ret = CryptSIPCreateIndirectData_p(&subjinfo, &count, indirect);
802 ok(ret, "CryptSIPCreateIndirectData failed: %d\n", GetLastError());
803 /* If the count is larger than needed, it's unmodified */
804 ok(count == 256, "unexpected count %d\n", count);
805 ok(!strcmp(indirect->Data.pszObjId, SPC_PE_IMAGE_DATA_OBJID),
806 "unexpected data oid %s\n",
807 indirect->Data.pszObjId);
808 ok(!strcmp(indirect->DigestAlgorithm.pszObjId, oid_sha1),
809 "unexpected digest algorithm oid %s\n",
810 indirect->DigestAlgorithm.pszObjId);
811 ok(indirect->Digest.cbData == 20, "unexpected hash size %d\n",
812 indirect->Digest.cbData);
813 if (indirect->Digest.cbData == 20)
814 {
815 const BYTE hash[20] = {
816 0x8a,0xd5,0x45,0x53,0x3d,0x67,0xdf,0x2f,0x78,0xe0,
817 0x55,0x0a,0xe0,0xd9,0x7a,0x28,0x3e,0xbf,0x45,0x2b };
818
819 ok(!memcmp(indirect->Digest.pbData, hash, 20),
820 "unexpected value\n");
821 }
822
823 HeapFree(GetProcessHeap(), 0, indirect);
824 }
825 CloseHandle(file);
826 DeleteFileW(temp_file);
827 }
828
829 static void test_wintrust(void)
830 {
831 static GUID generic_action_v2 = WINTRUST_ACTION_GENERIC_VERIFY_V2;
832 WINTRUST_DATA wtd;
833 WINTRUST_FILE_INFO file;
834 LONG r;
835 HRESULT hr;
836 WCHAR pathW[MAX_PATH];
837
838 memset(&wtd, 0, sizeof(wtd));
839 wtd.cbStruct = sizeof(wtd);
840 wtd.dwUIChoice = WTD_UI_NONE;
841 wtd.fdwRevocationChecks = WTD_REVOKE_WHOLECHAIN;
842 wtd.dwUnionChoice = WTD_CHOICE_FILE;
843 U(wtd).pFile = &file;
844 wtd.dwStateAction = WTD_STATEACTION_VERIFY;
845 memset(&file, 0, sizeof(file));
846 file.cbStruct = sizeof(file);
847 file.pcwszFilePath = pathW;
848 /* Test with an empty file */
849 file.hFile = create_temp_file(pathW);
850 r = WinVerifyTrust(INVALID_HANDLE_VALUE, &generic_action_v2, &wtd);
851 ok(r == TRUST_E_SUBJECT_FORM_UNKNOWN,
852 "expected TRUST_E_SUBJECT_FORM_UNKNOWN, got %08x\n", r);
853 CloseHandle(file.hFile);
854 DeleteFileW(pathW);
855 file.hFile = NULL;
856 /* Test with a known file path, which we expect not have a signature */
857 getNotepadPath(pathW, MAX_PATH);
858 r = WinVerifyTrust(INVALID_HANDLE_VALUE, &generic_action_v2, &wtd);
859 ok(r == TRUST_E_NOSIGNATURE || r == CRYPT_E_FILE_ERROR,
860 "expected TRUST_E_NOSIGNATURE or CRYPT_E_FILE_ERROR, got %08x\n", r);
861 wtd.dwStateAction = WTD_STATEACTION_CLOSE;
862 r = WinVerifyTrust(INVALID_HANDLE_VALUE, &generic_action_v2, &wtd);
863 ok(r == S_OK, "WinVerifyTrust failed: %08x\n", r);
864 wtd.dwStateAction = WTD_STATEACTION_VERIFY;
865 hr = WinVerifyTrustEx(INVALID_HANDLE_VALUE, &generic_action_v2, &wtd);
866 ok(hr == TRUST_E_NOSIGNATURE || hr == CRYPT_E_FILE_ERROR,
867 "expected TRUST_E_NOSIGNATURE or CRYPT_E_FILE_ERROR, got %08x\n", hr);
868 wtd.dwStateAction = WTD_STATEACTION_CLOSE;
869 r = WinVerifyTrust(INVALID_HANDLE_VALUE, &generic_action_v2, &wtd);
870 ok(r == S_OK, "WinVerifyTrust failed: %08x\n", r);
871 }
872
873 /* Self-signed .exe, built with tcc, signed with signtool
874 * (and a certificate generated on a self-signed CA).
875 *
876 * small.c:
877 * int _start()
878 * {
879 * return 0;
880 * }
881 *
882 * tcc -nostdlib small.c
883 * signtool sign /v /f codesign.pfx small.exe
884 */
885 static const BYTE SelfSignedFile32[] =
886 {
887 0x4D,0x5A,0x90,0x00,0x03,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0xFF,0xFF,0x00,0x00,0xB8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
888 0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
889 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x00,0x00,0x00,0x0E,0x1F,0xBA,0x0E,0x00,0xB4,0x09,0xCD,
890 0x21,0xB8,0x01,0x4C,0xCD,0x21,0x54,0x68,0x69,0x73,0x20,0x70,0x72,0x6F,0x67,0x72,0x61,0x6D,0x20,0x63,0x61,0x6E,0x6E,0x6F,
891 0x74,0x20,0x62,0x65,0x20,0x72,0x75,0x6E,0x20,0x69,0x6E,0x20,0x44,0x4F,0x53,0x20,0x6D,0x6F,0x64,0x65,0x2E,0x0D,0x0D,0x0A,
892 0x24,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x50,0x45,0x00,0x00,0x4C,0x01,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
893 0x00,0x00,0x00,0x00,0xE0,0x00,0x0F,0x03,0x0B,0x01,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
894 0x00,0x10,0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x40,0x00,0x00,0x10,0x00,0x00,0x00,0x02,0x00,0x00,
895 0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x00,0x00,0x00,0x02,0x00,0x00,
896 0xE7,0x0C,0x00,0x00,0x03,0x00,0x00,0x00,0x00,0x00,0x10,0x00,0x00,0x10,0x00,0x00,0x00,0x00,0x10,0x00,0x00,0x10,0x00,0x00,
897 0x00,0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
898 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x68,0x05,0x00,0x00,
899 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
900 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
901 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
902 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x2E,0x74,0x65,0x78,0x74,0x00,0x00,0x00,
903 0x18,0x00,0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
904 0x00,0x00,0x00,0x00,0x20,0x00,0x00,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
905 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
906 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
907 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
908 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x55,0x89,0xE5,0x81,0xEC,0x00,0x00,0x00,0x00,0x90,0xB8,0x00,0x00,0x00,0x00,0xE9,
909 0x00,0x00,0x00,0x00,0xC9,0xC3,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
910 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
911 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
912 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
913 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
914 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
915 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
916 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
917 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
918 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
919 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
920 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
921 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
922 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
923 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
924 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
925 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
926 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
927 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
928 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
929 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x68,0x05,0x00,0x00,0x00,0x02,0x02,0x00,
930 /* Start of the signature overlay */
931 0x30,0x82,0x05,0x5A,0x06,0x09,0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x07,0x02,0xA0,0x82,0x05,0x4B,0x30,0x82,0x05,0x47,0x02,
932 0x01,0x01,0x31,0x0B,0x30,0x09,0x06,0x05,0x2B,0x0E,0x03,0x02,0x1A,0x05,0x00,0x30,0x4C,0x06,0x0A,0x2B,0x06,0x01,0x04,0x01,
933 0x82,0x37,0x02,0x01,0x04,0xA0,0x3E,0x30,0x3C,0x30,0x17,0x06,0x0A,0x2B,0x06,0x01,0x04,0x01,0x82,0x37,0x02,0x01,0x0F,0x30,
934 0x09,0x03,0x01,0x00,0xA0,0x04,0xA2,0x02,0x80,0x00,0x30,0x21,0x30,0x09,0x06,0x05,0x2B,0x0E,0x03,0x02,0x1A,0x05,0x00,0x04,
935 0x14,0xA0,0x95,0xDE,0xBD,0x1A,0xB7,0x86,0xAF,0x50,0x63,0xD8,0x8F,0x90,0xD5,0x49,0x96,0x4E,0x44,0xF0,0x71,0xA0,0x82,0x03,
936 0x1D,0x30,0x82,0x03,0x19,0x30,0x82,0x02,0x01,0xA0,0x03,0x02,0x01,0x02,0x02,0x10,0x96,0x53,0x2C,0xC9,0x23,0x56,0x8A,0x87,
937 0x42,0x30,0x3E,0xD5,0x8D,0x72,0xD5,0x25,0x30,0x0D,0x06,0x09,0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x01,0x0B,0x05,0x00,0x30,
938 0x17,0x31,0x15,0x30,0x13,0x06,0x03,0x55,0x04,0x03,0x13,0x0C,0x54,0x65,0x73,0x74,0x20,0x43,0x41,0x20,0x52,0x6F,0x6F,0x74,
939 0x30,0x1E,0x17,0x0D,0x31,0x36,0x30,0x33,0x30,0x33,0x32,0x30,0x32,0x37,0x30,0x37,0x5A,0x17,0x0D,0x34,0x39,0x31,0x32,0x33,
940 0x31,0x32,0x33,0x30,0x30,0x30,0x30,0x5A,0x30,0x17,0x31,0x15,0x30,0x13,0x06,0x03,0x55,0x04,0x03,0x13,0x0C,0x43,0x6F,0x64,
941 0x65,0x53,0x69,0x67,0x6E,0x54,0x65,0x73,0x74,0x30,0x82,0x01,0x22,0x30,0x0D,0x06,0x09,0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,
942 0x01,0x01,0x05,0x00,0x03,0x82,0x01,0x0F,0x00,0x30,0x82,0x01,0x0A,0x02,0x82,0x01,0x01,0x00,0xB2,0xC9,0x91,0x98,0x8C,0xDC,
943 0x80,0xBC,0x16,0xBF,0xC1,0x04,0x77,0x90,0xC0,0xFD,0x8C,0xBA,0x68,0x26,0xAC,0xB7,0x20,0x68,0x41,0xED,0xC3,0x9C,0x47,0x7C,
944 0x36,0xC2,0x7B,0xE1,0x5E,0xFD,0xA9,0x99,0xF4,0x29,0x36,0x86,0x93,0x40,0x55,0x53,0x65,0x79,0xBC,0x9F,0x8F,0x6E,0x2B,0x05,
945 0x84,0xE1,0xFD,0xD2,0xEF,0xEA,0x89,0x8C,0xEC,0xF9,0x55,0xF0,0x2C,0xE5,0xA7,0x29,0xF9,0x7E,0x50,0xDC,0x9C,0xA1,0x23,0xA5,
946 0xD9,0x78,0xA1,0xE7,0x7C,0xD7,0x04,0x4F,0x11,0xAC,0x9F,0x4A,0x47,0xA1,0x1E,0xD5,0x9E,0xE7,0x5B,0xB5,0x8C,0x9C,0x67,0x7A,
947 0xD0,0xF8,0x54,0xD1,0x64,0x7F,0x39,0x48,0xB6,0xCF,0x2F,0x26,0x7D,0x7B,0x13,0x2B,0xC2,0x8F,0xA6,0x3F,0x42,0x71,0x95,0x3E,
948 0x59,0x0F,0x12,0xFA,0xC2,0x70,0x89,0xB7,0xB6,0x10,0x49,0xE0,0x7D,0x4D,0xFC,0x80,0x61,0x53,0x50,0x72,0xFD,0x46,0x35,0x51,
949 0x36,0xE6,0x06,0xA9,0x4C,0x0D,0x82,0x15,0xF6,0x5D,0xDE,0xD4,0xDB,0xE7,0x82,0x10,0x40,0xA1,0x47,0x68,0x88,0x0C,0x0A,0x80,
950 0xD1,0xE5,0x9A,0x35,0x28,0x82,0x1F,0x0F,0x80,0x5A,0x6E,0x1D,0x22,0x22,0xB3,0xA7,0xA2,0x9E,0x82,0x2D,0xC0,0x7F,0x5A,0xD0,
951 0xBA,0xB2,0xCA,0x20,0xE2,0x97,0xE9,0x72,0x41,0xB7,0xD6,0x1A,0x93,0x23,0x97,0xF0,0xA9,0x61,0xD2,0x91,0xBD,0xB6,0x6B,0x95,
952 0x12,0x67,0x16,0xAC,0x0A,0xB7,0x55,0x02,0x0D,0xA5,0xAD,0x17,0x95,0x77,0xF9,0x96,0x03,0x41,0xD3,0xE1,0x61,0x68,0xBB,0x0A,
953 0xB5,0xC4,0xEE,0x70,0x40,0x08,0x05,0xC4,0xF1,0x5D,0x02,0x03,0x01,0x00,0x01,0xA3,0x61,0x30,0x5F,0x30,0x13,0x06,0x03,0x55,
954 0x1D,0x25,0x04,0x0C,0x30,0x0A,0x06,0x08,0x2B,0x06,0x01,0x05,0x05,0x07,0x03,0x03,0x30,0x48,0x06,0x03,0x55,0x1D,0x01,0x04,
955 0x41,0x30,0x3F,0x80,0x10,0x35,0x40,0x67,0x8F,0x7D,0x03,0x1B,0x76,0x52,0x62,0x2D,0xF5,0x21,0xF6,0x7C,0xBC,0xA1,0x19,0x30,
956 0x17,0x31,0x15,0x30,0x13,0x06,0x03,0x55,0x04,0x03,0x13,0x0C,0x54,0x65,0x73,0x74,0x20,0x43,0x41,0x20,0x52,0x6F,0x6F,0x74,
957 0x82,0x10,0xA0,0x4B,0xEB,0xAC,0xFA,0x08,0xF2,0x8B,0x47,0xD2,0xB3,0x54,0x60,0x6C,0xE6,0x29,0x30,0x0D,0x06,0x09,0x2A,0x86,
958 0x48,0x86,0xF7,0x0D,0x01,0x01,0x0B,0x05,0x00,0x03,0x82,0x01,0x01,0x00,0x5F,0x8C,0x7F,0xDA,0x1D,0x21,0x7A,0x15,0xD8,0x20,
959 0x04,0x53,0x7F,0x44,0x6D,0x7B,0x57,0xBE,0x7F,0x86,0x77,0x58,0xC4,0xD4,0x80,0xC7,0x2E,0x64,0x9B,0x44,0xC5,0x2D,0x6D,0xDB,
960 0x35,0x5A,0xFE,0xA4,0xD8,0x66,0x9B,0xF7,0x6E,0xFC,0xEF,0x52,0x7B,0xC5,0x16,0xE6,0xA3,0x7D,0x59,0xB7,0x31,0x28,0xEB,0xB5,
961 0x45,0xC9,0xB1,0xD1,0x08,0x67,0xC6,0x37,0xE7,0xD7,0x2A,0xE6,0x1F,0xD9,0x6A,0xE5,0x04,0xDF,0x6A,0x9D,0x91,0xFA,0x41,0xBD,
962 0x2A,0x50,0xEA,0x99,0x24,0xA9,0x0F,0x2B,0x50,0x51,0x5F,0xD9,0x0B,0x89,0x1B,0xCB,0xDB,0x88,0xE8,0xEC,0x87,0xB0,0x16,0xCC,
963 0x43,0xEE,0x5A,0xBD,0x57,0xE2,0x46,0xA7,0x56,0x54,0x23,0x32,0x8A,0xFB,0x25,0x51,0x39,0x38,0xE6,0x87,0xF5,0x73,0x63,0xD0,
964 0x5B,0xC7,0x3F,0xFD,0x04,0x75,0x74,0x4C,0x3D,0xB5,0x31,0x22,0x7D,0xF1,0x8D,0xB4,0xE0,0xAA,0xE1,0xFF,0x8F,0xDD,0xB8,0x04,
965 0x6A,0x31,0xEE,0x30,0x2D,0x6E,0x74,0x0F,0x37,0x71,0x77,0x2B,0xB8,0x9E,0x62,0x47,0x00,0x9C,0xA5,0x82,0x2B,0x9F,0x24,0x67,
966 0x50,0x86,0x8B,0xC9,0x36,0x81,0xEB,0x44,0xC2,0xF1,0x91,0xA6,0x84,0x75,0x15,0x8F,0x22,0xDE,0xAC,0xB5,0x16,0xE3,0x96,0x74,
967 0x72,0x2F,0x15,0xD5,0xFB,0x01,0x22,0xC4,0x24,0xEE,0x3D,0xDF,0x9E,0xA9,0x0A,0x5B,0x16,0x21,0xE8,0x4A,0x8C,0x7E,0x3A,0x9C,
968 0x22,0xA0,0x49,0x60,0x97,0x1B,0x3E,0x2D,0x80,0x91,0xDB,0xF7,0x78,0x38,0x76,0x78,0x0C,0xE3,0xD4,0x27,0x77,0x69,0x96,0xE6,
969 0x41,0xC7,0x2E,0xE9,0x61,0xD6,0x31,0x82,0x01,0xC4,0x30,0x82,0x01,0xC0,0x02,0x01,0x01,0x30,0x2B,0x30,0x17,0x31,0x15,0x30,
970 0x13,0x06,0x03,0x55,0x04,0x03,0x13,0x0C,0x54,0x65,0x73,0x74,0x20,0x43,0x41,0x20,0x52,0x6F,0x6F,0x74,0x02,0x10,0x96,0x53,
971 0x2C,0xC9,0x23,0x56,0x8A,0x87,0x42,0x30,0x3E,0xD5,0x8D,0x72,0xD5,0x25,0x30,0x09,0x06,0x05,0x2B,0x0E,0x03,0x02,0x1A,0x05,
972 0x00,0xA0,0x70,0x30,0x10,0x06,0x0A,0x2B,0x06,0x01,0x04,0x01,0x82,0x37,0x02,0x01,0x0C,0x31,0x02,0x30,0x00,0x30,0x19,0x06,
973 0x09,0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x03,0x31,0x0C,0x06,0x0A,0x2B,0x06,0x01,0x04,0x01,0x82,0x37,0x02,0x01,0x04,
974 0x30,0x1C,0x06,0x0A,0x2B,0x06,0x01,0x04,0x01,0x82,0x37,0x02,0x01,0x0B,0x31,0x0E,0x30,0x0C,0x06,0x0A,0x2B,0x06,0x01,0x04,
975 0x01,0x82,0x37,0x02,0x01,0x15,0x30,0x23,0x06,0x09,0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x04,0x31,0x16,0x04,0x14,0x3D,
976 0x08,0xC8,0xA3,0xEE,0x05,0x1A,0x61,0xD9,0xFE,0x1A,0x63,0xC0,0x8A,0x6E,0x9D,0xF9,0xC3,0x13,0x98,0x30,0x0D,0x06,0x09,0x2A,
977 0x86,0x48,0x86,0xF7,0x0D,0x01,0x01,0x01,0x05,0x00,0x04,0x82,0x01,0x00,0x90,0xF9,0xC0,0x7F,0x1D,0x70,0x8C,0x04,0x22,0x82,
978 0xB6,0x2D,0x48,0xBF,0x30,0x51,0x29,0xF8,0xE3,0x11,0x39,0xE0,0x64,0x23,0x72,0xE2,0x4C,0x09,0x9F,0x39,0xF2,0x6F,0xDD,0xB9,
979 0x5A,0x3D,0xEF,0xEB,0xBE,0xEC,0x3B,0xE6,0x58,0x4C,0xC9,0x4F,0xED,0xCB,0x6E,0x9D,0x67,0x8E,0x89,0x92,0x40,0x39,0xA2,0x5F,
980 0xF9,0xEF,0xD3,0xF5,0x24,0x27,0x8D,0xF7,0x3C,0x92,0x66,0x56,0xC8,0x2B,0xEA,0x04,0xA1,0x0E,0xDA,0x89,0x30,0xA7,0x01,0xD8,
981 0x0B,0xF8,0xFD,0x99,0xB6,0xC0,0x38,0xB0,0x21,0x50,0x3A,0x86,0x01,0xD0,0xF3,0x86,0x72,0xE3,0x5A,0xBB,0x2A,0x6E,0xBD,0xFB,
982 0x22,0xF9,0x42,0xD3,0x04,0xFE,0x8D,0xD8,0x79,0xD1,0xEE,0x61,0xC6,0x48,0x04,0x99,0x9A,0xA2,0x73,0xE5,0xFB,0x24,0x10,0xD5,
983 0x6B,0x71,0x80,0x0E,0x09,0xEA,0x85,0x9A,0xBD,0xBB,0xDE,0x99,0x5D,0xA3,0x18,0x4D,0xED,0x20,0x73,0x3E,0x32,0xEF,0x2C,0xAC,
984 0x5A,0x83,0x87,0x1F,0x7F,0x19,0x61,0x35,0x53,0xC1,0xAA,0x89,0x97,0xB3,0xDD,0x8D,0xA8,0x67,0x5B,0xC2,0xE2,0x09,0xB7,0xDD,
985 0x6A,0xCB,0xD5,0xBF,0xD6,0x08,0xE2,0x23,0x1A,0x41,0x9D,0xD5,0x6A,0x6B,0x8D,0x3C,0x29,0x1B,0xF1,0x3F,0x4E,0x4A,0x8F,0x29,
986 0x33,0xF9,0x1C,0x60,0xA0,0x92,0x7E,0x4F,0x35,0xB8,0xDD,0xEB,0xD1,0x68,0x1A,0x9D,0xA2,0xA6,0x97,0x1F,0x5F,0xC6,0x2C,0xFB,
987 0xCA,0xDF,0xF7,0x95,0x33,0x95,0xD4,0x79,0x5C,0x73,0x87,0x49,0x1F,0x8C,0x6E,0xCE,0x3E,0x6D,0x3D,0x2B,0x6B,0xD7,0x66,0xE9,
988 0x88,0x6F,0xF2,0x83,0xB9,0x9B,0x00,0x00
989 };
990
991 static const BYTE SelfSignedFile64[] =
992 {
993 0x4D,0x5A,0x90,0x00,0x03,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0xFF,0xFF,0x00,0x00,0xB8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
994 0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
995 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x00,0x00,0x00,0x0E,0x1F,0xBA,0x0E,0x00,0xB4,0x09,0xCD,
996 0x21,0xB8,0x01,0x4C,0xCD,0x21,0x54,0x68,0x69,0x73,0x20,0x70,0x72,0x6F,0x67,0x72,0x61,0x6D,0x20,0x63,0x61,0x6E,0x6E,0x6F,
997 0x74,0x20,0x62,0x65,0x20,0x72,0x75,0x6E,0x20,0x69,0x6E,0x20,0x44,0x4F,0x53,0x20,0x6D,0x6F,0x64,0x65,0x2E,0x0D,0x0D,0x0A,
998 0x24,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x50,0x45,0x00,0x00,0x64,0x86,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
999 0x00,0x00,0x00,0x00,0xF0,0x00,0x2F,0x02,0x0B,0x02,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
1000 0x00,0x10,0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x00,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x02,0x00,0x00,
1001 0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x00,0x00,0x00,0x02,0x00,0x00,
1002 0x02,0xB9,0x00,0x00,0x03,0x00,0x00,0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x00,0x00,0x00,
1003 0x00,0x00,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x00,0x00,0x00,
1004 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
1005 0x00,0x20,0x00,0x00,0x0C,0x00,0x00,0x00,0x00,0x06,0x00,0x00,0x68,0x05,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
1006 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
1007 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
1008 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
1009 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x2E,0x74,0x65,0x78,0x74,0x00,0x00,0x00,0x20,0x00,0x00,0x00,0x00,0x10,0x00,0x00,
1010 0x00,0x02,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x00,0x00,0x60,
1011 0x2E,0x70,0x64,0x61,0x74,0x61,0x00,0x00,0x0C,0x00,0x00,0x00,0x00,0x20,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x04,0x00,0x00,
1012 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x40,0x00,0x00,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
1013 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
1014 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x55,0x48,0x89,0xE5,0x48,0x81,0xEC,0x00,0x00,0x00,0x00,0xB8,0x00,0x00,0x00,0x00,
1015 0xE9,0x00,0x00,0x00,0x00,0xC9,0xC3,0x00,0x01,0x04,0x02,0x05,0x04,0x03,0x01,0x50,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
1016 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
1017 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
1018 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
1019 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
1020 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
1021 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
1022 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
1023 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
1024 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
1025 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
1026 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
1027 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
1028 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
1029 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
1030 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
1031 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
1032 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
1033 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
1034 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
1035 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0B,0x10,0x00,0x00,0x17,0x10,0x00,0x00,
1036 0x18,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
1037 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
1038 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
1039 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
1040 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
1041 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
1042 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
1043 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
1044 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
1045 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
1046 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
1047 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
1048 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
1049 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
1050 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
1051 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
1052 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
1053 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
1054 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
1055 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
1056 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
1057 /* Start of the signature overlay */
1058 0x68,0x05,0x00,0x00,0x00,0x02,0x02,0x00,0x30,0x82,0x05,0x5A,0x06,0x09,0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x07,0x02,0xA0,
1059 0x82,0x05,0x4B,0x30,0x82,0x05,0x47,0x02,0x01,0x01,0x31,0x0B,0x30,0x09,0x06,0x05,0x2B,0x0E,0x03,0x02,0x1A,0x05,0x00,0x30,
1060 0x4C,0x06,0x0A,0x2B,0x06,0x01,0x04,0x01,0x82,0x37,0x02,0x01,0x04,0xA0,0x3E,0x30,0x3C,0x30,0x17,0x06,0x0A,0x2B,0x06,0x01,
1061 0x04,0x01,0x82,0x37,0x02,0x01,0x0F,0x30,0x09,0x03,0x01,0x00,0xA0,0x04,0xA2,0x02,0x80,0x00,0x30,0x21,0x30,0x09,0x06,0x05,
1062 0x2B,0x0E,0x03,0x02,0x1A,0x05,0x00,0x04,0x14,0xCA,0x7C,0x10,0xFB,0x5A,0x96,0x6D,0x69,0xEF,0x26,0x30,0x1A,0xE9,0xC7,0x22,
1063 0x19,0xEB,0x6E,0x17,0x07,0xA0,0x82,0x03,0x1D,0x30,0x82,0x03,0x19,0x30,0x82,0x02,0x01,0xA0,0x03,0x02,0x01,0x02,0x02,0x10,
1064 0x96,0x53,0x2C,0xC9,0x23,0x56,0x8A,0x87,0x42,0x30,0x3E,0xD5,0x8D,0x72,0xD5,0x25,0x30,0x0D,0x06,0x09,0x2A,0x86,0x48,0x86,
1065 0xF7,0x0D,0x01,0x01,0x0B,0x05,0x00,0x30,0x17,0x31,0x15,0x30,0x13,0x06,0x03,0x55,0x04,0x03,0x13,0x0C,0x54,0x65,0x73,0x74,
1066 0x20,0x43,0x41,0x20,0x52,0x6F,0x6F,0x74,0x30,0x1E,0x17,0x0D,0x31,0x36,0x30,0x33,0x30,0x33,0x32,0x30,0x32,0x37,0x30,0x37,
1067 0x5A,0x17,0x0D,0x34,0x39,0x31,0x32,0x33,0x31,0x32,0x33,0x30,0x30,0x30,0x30,0x5A,0x30,0x17,0x31,0x15,0x30,0x13,0x06,0x03,
1068 0x55,0x04,0x03,0x13,0x0C,0x43,0x6F,0x64,0x65,0x53,0x69,0x67,0x6E,0x54,0x65,0x73,0x74,0x30,0x82,0x01,0x22,0x30,0x0D,0x06,
1069 0x09,0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x01,0x01,0x05,0x00,0x03,0x82,0x01,0x0F,0x00,0x30,0x82,0x01,0x0A,0x02,0x82,0x01,
1070 0x01,0x00,0xB2,0xC9,0x91,0x98,0x8C,0xDC,0x80,0xBC,0x16,0xBF,0xC1,0x04,0x77,0x90,0xC0,0xFD,0x8C,0xBA,0x68,0x26,0xAC,0xB7,
1071 0x20,0x68,0x41,0xED,0xC3,0x9C,0x47,0x7C,0x36,0xC2,0x7B,0xE1,0x5E,0xFD,0xA9,0x99,0xF4,0x29,0x36,0x86,0x93,0x40,0x55,0x53,
1072 0x65,0x79,0xBC,0x9F,0x8F,0x6E,0x2B,0x05,0x84,0xE1,0xFD,0xD2,0xEF,0xEA,0x89,0x8C,0xEC,0xF9,0x55,0xF0,0x2C,0xE5,0xA7,0x29,
1073 0xF9,0x7E,0x50,0xDC,0x9C,0xA1,0x23,0xA5,0xD9,0x78,0xA1,0xE7,0x7C,0xD7,0x04,0x4F,0x11,0xAC,0x9F,0x4A,0x47,0xA1,0x1E,0xD5,
1074 0x9E,0xE7,0x5B,0xB5,0x8C,0x9C,0x67,0x7A,0xD0,0xF8,0x54,0xD1,0x64,0x7F,0x39,0x48,0xB6,0xCF,0x2F,0x26,0x7D,0x7B,0x13,0x2B,
1075 0xC2,0x8F,0xA6,0x3F,0x42,0x71,0x95,0x3E,0x59,0x0F,0x12,0xFA,0xC2,0x70,0x89,0xB7,0xB6,0x10,0x49,0xE0,0x7D,0x4D,0xFC,0x80,
1076 0x61,0x53,0x50,0x72,0xFD,0x46,0x35,0x51,0x36,0xE6,0x06,0xA9,0x4C,0x0D,0x82,0x15,0xF6,0x5D,0xDE,0xD4,0xDB,0xE7,0x82,0x10,
1077 0x40,0xA1,0x47,0x68,0x88,0x0C,0x0A,0x80,0xD1,0xE5,0x9A,0x35,0x28,0x82,0x1F,0x0F,0x80,0x5A,0x6E,0x1D,0x22,0x22,0xB3,0xA7,
1078 0xA2,0x9E,0x82,0x2D,0xC0,0x7F,0x5A,0xD0,0xBA,0xB2,0xCA,0x20,0xE2,0x97,0xE9,0x72,0x41,0xB7,0xD6,0x1A,0x93,0x23,0x97,0xF0,
1079 0xA9,0x61,0xD2,0x91,0xBD,0xB6,0x6B,0x95,0x12,0x67,0x16,0xAC,0x0A,0xB7,0x55,0x02,0x0D,0xA5,0xAD,0x17,0x95,0x77,0xF9,0x96,
1080 0x03,0x41,0xD3,0xE1,0x61,0x68,0xBB,0x0A,0xB5,0xC4,0xEE,0x70,0x40,0x08,0x05,0xC4,0xF1,0x5D,0x02,0x03,0x01,0x00,0x01,0xA3,
1081 0x61,0x30,0x5F,0x30,0x13,0x06,0x03,0x55,0x1D,0x25,0x04,0x0C,0x30,0x0A,0x06,0x08,0x2B,0x06,0x01,0x05,0x05,0x07,0x03,0x03,
1082 0x30,0x48,0x06,0x03,0x55,0x1D,0x01,0x04,0x41,0x30,0x3F,0x80,0x10,0x35,0x40,0x67,0x8F,0x7D,0x03,0x1B,0x76,0x52,0x62,0x2D,
1083 0xF5,0x21,0xF6,0x7C,0xBC,0xA1,0x19,0x30,0x17,0x31,0x15,0x30,0x13,0x06,0x03,0x55,0x04,0x03,0x13,0x0C,0x54,0x65,0x73,0x74,
1084 0x20,0x43,0x41,0x20,0x52,0x6F,0x6F,0x74,0x82,0x10,0xA0,0x4B,0xEB,0xAC,0xFA,0x08,0xF2,0x8B,0x47,0xD2,0xB3,0x54,0x60,0x6C,
1085 0xE6,0x29,0x30,0x0D,0x06,0x09,0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x01,0x0B,0x05,0x00,0x03,0x82,0x01,0x01,0x00,0x5F,0x8C,
1086 0x7F,0xDA,0x1D,0x21,0x7A,0x15,0xD8,0x20,0x04,0x53,0x7F,0x44,0x6D,0x7B,0x57,0xBE,0x7F,0x86,0x77,0x58,0xC4,0xD4,0x80,0xC7,
1087 0x2E,0x64,0x9B,0x44,0xC5,0x2D,0x6D,0xDB,0x35,0x5A,0xFE,0xA4,0xD8,0x66,0x9B,0xF7,0x6E,0xFC,0xEF,0x52,0x7B,0xC5,0x16,0xE6,
1088 0xA3,0x7D,0x59,0xB7,0x31,0x28,0xEB,0xB5,0x45,0xC9,0xB1,0xD1,0x08,0x67,0xC6,0x37,0xE7,0xD7,0x2A,0xE6,0x1F,0xD9,0x6A,0xE5,
1089 0x04,0xDF,0x6A,0x9D,0x91,0xFA,0x41,0xBD,0x2A,0x50,0xEA,0x99,0x24,0xA9,0x0F,0x2B,0x50,0x51,0x5F,0xD9,0x0B,0x89,0x1B,0xCB,
1090 0xDB,0x88,0xE8,0xEC,0x87,0xB0,0x16,0xCC,0x43,0xEE,0x5A,0xBD,0x57,0xE2,0x46,0xA7,0x56,0x54,0x23,0x32,0x8A,0xFB,0x25,0x51,
1091 0x39,0x38,0xE6,0x87,0xF5,0x73,0x63,0xD0,0x5B,0xC7,0x3F,0xFD,0x04,0x75,0x74,0x4C,0x3D,0xB5,0x31,0x22,0x7D,0xF1,0x8D,0xB4,
1092 0xE0,0xAA,0xE1,0xFF,0x8F,0xDD,0xB8,0x04,0x6A,0x31,0xEE,0x30,0x2D,0x6E,0x74,0x0F,0x37,0x71,0x77,0x2B,0xB8,0x9E,0x62,0x47,
1093 0x00,0x9C,0xA5,0x82,0x2B,0x9F,0x24,0x67,0x50,0x86,0x8B,0xC9,0x36,0x81,0xEB,0x44,0xC2,0xF1,0x91,0xA6,0x84,0x75,0x15,0x8F,
1094 0x22,0xDE,0xAC,0xB5,0x16,0xE3,0x96,0x74,0x72,0x2F,0x15,0xD5,0xFB,0x01,0x22,0xC4,0x24,0xEE,0x3D,0xDF,0x9E,0xA9,0x0A,0x5B,
1095 0x16,0x21,0xE8,0x4A,0x8C,0x7E,0x3A,0x9C,0x22,0xA0,0x49,0x60,0x97,0x1B,0x3E,0x2D,0x80,0x91,0xDB,0xF7,0x78,0x38,0x76,0x78,
1096 0x0C,0xE3,0xD4,0x27,0x77,0x69,0x96,0xE6,0x41,0xC7,0x2E,0xE9,0x61,0xD6,0x31,0x82,0x01,0xC4,0x30,0x82,0x01,0xC0,0x02,0x01,
1097 0x01,0x30,0x2B,0x30,0x17,0x31,0x15,0x30,0x13,0x06,0x03,0x55,0x04,0x03,0x13,0x0C,0x54,0x65,0x73,0x74,0x20,0x43,0x41,0x20,
1098 0x52,0x6F,0x6F,0x74,0x02,0x10,0x96,0x53,0x2C,0xC9,0x23,0x56,0x8A,0x87,0x42,0x30,0x3E,0xD5,0x8D,0x72,0xD5,0x25,0x30,0x09,
1099 0x06,0x05,0x2B,0x0E,0x03,0x02,0x1A,0x05,0x00,0xA0,0x70,0x30,0x10,0x06,0x0A,0x2B,0x06,0x01,0x04,0x01,0x82,0x37,0x02,0x01,
1100 0x0C,0x31,0x02,0x30,0x00,0x30,0x19,0x06,0x09,0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x03,0x31,0x0C,0x06,0x0A,0x2B,0x06,
1101 0x01,0x04,0x01,0x82,0x37,0x02,0x01,0x04,0x30,0x1C,0x06,0x0A,0x2B,0x06,0x01,0x04,0x01,0x82,0x37,0x02,0x01,0x0B,0x31,0x0E,
1102 0x30,0x0C,0x06,0x0A,0x2B,0x06,0x01,0x04,0x01,0x82,0x37,0x02,0x01,0x15,0x30,0x23,0x06,0x09,0x2A,0x86,0x48,0x86,0xF7,0x0D,
1103 0x01,0x09,0x04,0x31,0x16,0x04,0x14,0x0C,0xEC,0x76,0xF2,0x3F,0xE4,0x6F,0xEB,0xFF,0x00,0xDA,0x95,0xE7,0x8B,0x64,0xBC,0x55,
1104 0xBA,0xF0,0xEA,0x30,0x0D,0x06,0x09,0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x01,0x01,0x05,0x00,0x04,0x82,0x01,0x00,0x05,0x22,
1105 0xD1,0xB3,0x85,0x09,0x46,0x99,0x77,0x69,0xC8,0xD2,0x0C,0xFC,0x8D,0xF4,0x01,0xD4,0x5B,0xF0,0xB4,0x13,0x63,0xAF,0x24,0x0E,
1106 0x6C,0x1B,0x14,0xCF,0xA8,0x9A,0xEC,0x7E,0xF2,0x60,0xED,0x6C,0x39,0x4D,0x7A,0x73,0x9C,0x9F,0x24,0x46,0xE2,0xEA,0xFA,0x70,
1107 0xB4,0xAC,0xFC,0x38,0x90,0xF2,0x4F,0x70,0xCC,0x00,0xD1,0x2B,0xB6,0xFB,0xCD,0x7F,0xFC,0xCB,0x35,0xA9,0xA6,0x76,0x37,0xD6,
1108 0x08,0x82,0x99,0x4C,0x47,0xD7,0x4E,0xB5,0xDE,0xCA,0x4E,0xED,0x71,0x48,0xD4,0x84,0xE1,0x30,0x10,0x33,0x7F,0x84,0xEE,0x2F,
1109 0x44,0x99,0xE4,0x26,0x27,0xB5,0xB8,0xC1,0xA1,0x40,0x6B,0x87,0x04,0x95,0xC3,0xF0,0xFF,0x25,0x97,0xFD,0xDB,0x9C,0x67,0x80,
1110 0x39,0x97,0x72,0x75,0x07,0x92,0xA5,0x08,0x19,0x5B,0xD3,0xC9,0x5E,0xC4,0x7B,0xA9,0x04,0x02,0x63,0xCC,0xC5,0x92,0xF6,0xE9,
1111 0xD6,0xB0,0xA8,0xF9,0xD0,0x9F,0x3F,0xBC,0x86,0x77,0x1E,0x12,0x9A,0x9A,0x9B,0x05,0x77,0x39,0x42,0x01,0xB7,0x23,0xF0,0x78,
1112 0x4F,0x52,0x6D,0x1B,0x9F,0xBA,0x29,0xEC,0x90,0xA9,0x1E,0x1E,0x5C,0xA9,0x28,0xA0,0x0B,0x09,0xDC,0x99,0x82,0xE3,0x34,0xBB,
1113 0x5C,0x66,0x8E,0x54,0x95,0x4B,0x65,0x95,0xCD,0x87,0x72,0x74,0xCD,0x3B,0x5C,0x72,0xBB,0x61,0x6A,0x98,0x44,0x9C,0xB0,0x2A,
1114 0xE7,0xB0,0xA6,0x2B,0xDA,0x47,0x5C,0x75,0x36,0xB5,0x90,0x8E,0x82,0x47,0xCD,0x3F,0x4B,0xD0,0xFB,0x8E,0x17,0x6B,0x40,0x57,
1115 0x9C,0x68,0x1A,0x5D,0x92,0xCD,0xD0,0x5F,0x02,0xA1,0x2C,0xD9,0x56,0x20,0x00,0x00
1116 };
1117
1118 static void call_winverify(WCHAR *pathW, LONG *status, BOOL hash_only)
1119 {
1120 static GUID WVTPolicyGUID = WINTRUST_ACTION_GENERIC_VERIFY_V2;
1121 WINTRUST_FILE_INFO file_info = { sizeof(file_info), 0 };
1122 WINTRUST_DATA data = { sizeof(data), 0 };
1123 LONG ret;
1124
1125 file_info.pcwszFilePath = pathW;
1126
1127 data.dwUIChoice = WTD_UI_NONE;
1128 data.fdwRevocationChecks = WTD_REVOKE_NONE;
1129 data.dwUnionChoice = WTD_CHOICE_FILE;
1130 data.pFile = &file_info;
1131 data.dwStateAction = WTD_STATEACTION_VERIFY;
1132 data.dwProvFlags = hash_only ? WTD_HASH_ONLY_FLAG : 0;
1133 *status = WinVerifyTrust(NULL, &WVTPolicyGUID, &data);
1134
1135 data.dwStateAction = WTD_STATEACTION_CLOSE;
1136 ret = WinVerifyTrust(NULL, &WVTPolicyGUID, &data);
1137 ok(ret == S_OK, "WinVerifyTrust failed: %08x\n", ret);
1138 }
1139
1140 static void test_wintrust_digest(void)
1141 {
1142 static const BYTE Dummy[] = { 0x11,0x22,0x33,0x44 };
1143 static const struct
1144 {
1145 struct { const BYTE *data; DWORD length; } blocks[5];
1146 struct { LONG status; BOOL todo; } t1;
1147 struct { LONG status; BOOL todo; } t2;
1148 }
1149 tests[] =
1150 {
1151 /* 32-bit tests */
1152 {
1153 {{ SelfSignedFile32, sizeof(SelfSignedFile32) }},
1154 { CERT_E_CHAINING, TRUE }, { S_OK, FALSE }
1155 },
1156 {
1157 {{ SelfSignedFile32, sizeof(SelfSignedFile32) },
1158 { Dummy, sizeof(Dummy) }},
1159 { TRUST_E_NOSIGNATURE, FALSE }, { TRUST_E_NOSIGNATURE, FALSE }
1160 },
1161 {
1162 {{ Dummy, sizeof(Dummy) },
1163 { SelfSignedFile32 + sizeof(Dummy), sizeof(SelfSignedFile32) - sizeof(Dummy) }},
1164 { TRUST_E_SUBJECT_FORM_UNKNOWN, FALSE }, { TRUST_E_NOSIGNATURE, TRUE }
1165 },
1166 {
1167 {{ SelfSignedFile32, 19 },
1168 { Dummy, sizeof(Dummy) },
1169 { SelfSignedFile32 + 19 + sizeof(Dummy), sizeof(SelfSignedFile32) - 19 - sizeof(Dummy) }},
1170 { TRUST_E_BAD_DIGEST, FALSE }, { TRUST_E_NOSIGNATURE, TRUE }
1171 },
1172 {
1173 {{ SelfSignedFile32, sizeof(IMAGE_DOS_HEADER) }},
1174 { TRUST_E_SUBJECT_FORM_UNKNOWN, TRUE }, { TRUST_E_NOSIGNATURE, FALSE }
1175 },
1176 {
1177 {{ SelfSignedFile32, sizeof(IMAGE_DOS_HEADER) + sizeof(IMAGE_NT_HEADERS32) * 2 }},
1178 { TRUST_E_NOSIGNATURE, FALSE }, { TRUST_E_NOSIGNATURE, FALSE }
1179 },
1180
1181 /* 64-bit tests */
1182 {
1183 {{ SelfSignedFile64, sizeof(SelfSignedFile64) }},
1184 { CERT_E_CHAINING, TRUE }, { S_OK, FALSE }
1185 },
1186 {
1187 {{ SelfSignedFile64, sizeof(SelfSignedFile64) },
1188 { Dummy, sizeof(Dummy) }},
1189 { TRUST_E_NOSIGNATURE, FALSE }, { TRUST_E_NOSIGNATURE, FALSE }
1190 },
1191 {
1192 {{ Dummy, sizeof(Dummy) },
1193 { SelfSignedFile64 + sizeof(Dummy), sizeof(SelfSignedFile64) - sizeof(Dummy) }},
1194 { TRUST_E_SUBJECT_FORM_UNKNOWN, FALSE }, { TRUST_E_NOSIGNATURE, TRUE }
1195 },
1196 {
1197 {{ SelfSignedFile64, 19 },
1198 { Dummy, sizeof(Dummy) },
1199 { SelfSignedFile64 + 19 + sizeof(Dummy), sizeof(SelfSignedFile64) - 19 - sizeof(Dummy) }},
1200 { TRUST_E_BAD_DIGEST, FALSE }, { TRUST_E_NOSIGNATURE, TRUE }
1201 },
1202 {
1203 {{ SelfSignedFile64, sizeof(IMAGE_DOS_HEADER) }},
1204 { TRUST_E_SUBJECT_FORM_UNKNOWN, TRUE }, { TRUST_E_NOSIGNATURE, FALSE }
1205 },
1206 {
1207 {{ SelfSignedFile64, sizeof(IMAGE_DOS_HEADER) + sizeof(IMAGE_NT_HEADERS64) * 2 }},
1208 { TRUST_E_NOSIGNATURE, FALSE }, { TRUST_E_NOSIGNATURE, FALSE }
1209 },
1210 };
1211 WCHAR pathW[MAX_PATH];
1212 DWORD written;
1213 HANDLE file;
1214 LONG status;
1215 BOOL ret;
1216 int i, j;
1217
1218 for (i = 0; i < sizeof(tests)/sizeof(tests[0]); i++)
1219 {
1220 file = create_temp_file(pathW);
1221 ok(file != INVALID_HANDLE_VALUE, "failed to create temporary file\n");
1222
1223 for (j = 0; tests[i].blocks[j].data; j++)
1224 {
1225 ret = WriteFile(file, tests[i].blocks[j].data, tests[i].blocks[j].length, &written, NULL);
1226 ok(ret && written == tests[i].blocks[j].length, "WriteFile failed with %u\n", GetLastError());
1227 }
1228
1229 CloseHandle(file);
1230
1231 call_winverify(pathW, &status, FALSE);
1232 todo_wine_if(tests[i].t1.todo)
1233 ok(status == tests[i].t1.status, "test %d/1: expected %08x, got %08x\n", i, tests[i].t1.status, status);
1234
1235 call_winverify(pathW, &status, TRUE);
1236 todo_wine_if(tests[i].t2.todo)
1237 ok(status == tests[i].t2.status, "test %d/2: expected %08x, got %08x\n", i, tests[i].t2.status, status);
1238
1239 DeleteFileW(pathW);
1240 }
1241 }
1242
1243 static void test_get_known_usages(void)
1244 {
1245 BOOL ret;
1246 PCCRYPT_OID_INFO *usages;
1247
1248 if (!pWTHelperGetKnownUsages)
1249 {
1250 skip("missing WTHelperGetKnownUsages\n");
1251 return;
1252 }
1253 SetLastError(0xdeadbeef);
1254 ret = pWTHelperGetKnownUsages(0, NULL);
1255 ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER,
1256 "expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
1257 SetLastError(0xdeadbeef);
1258 ret = pWTHelperGetKnownUsages(1, NULL);
1259 ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER,
1260 "expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
1261 SetLastError(0xdeadbeef);
1262 ret = pWTHelperGetKnownUsages(0, &usages);
1263 ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER,
1264 "expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
1265 /* A value of 1 for the first parameter seems to imply the value is
1266 * allocated
1267 */
1268 SetLastError(0xdeadbeef);
1269 usages = NULL;
1270 ret = pWTHelperGetKnownUsages(1, &usages);
1271 ok(ret, "WTHelperGetKnownUsages failed: %d\n", GetLastError());
1272 ok(usages != NULL, "expected a pointer\n");
1273 if (ret && usages)
1274 {
1275 PCCRYPT_OID_INFO *ptr;
1276
1277 /* The returned usages are an array of PCCRYPT_OID_INFOs, terminated with a
1278 * NULL pointer.
1279 */
1280 for (ptr = usages; *ptr; ptr++)
1281 {
1282 ok((*ptr)->cbSize == sizeof(CRYPT_OID_INFO) ||
1283 (*ptr)->cbSize == (sizeof(CRYPT_OID_INFO) + 2 * sizeof(LPCWSTR)), /* Vista */
1284 "unexpected size %d\n", (*ptr)->cbSize);
1285 /* Each returned usage is in the CRYPT_ENHKEY_USAGE_OID_GROUP_ID group */
1286 ok((*ptr)->dwGroupId == CRYPT_ENHKEY_USAGE_OID_GROUP_ID,
1287 "expected group CRYPT_ENHKEY_USAGE_OID_GROUP_ID, got %d\n",
1288 (*ptr)->dwGroupId);
1289 }
1290 }
1291 /* A value of 2 for the second parameter seems to imply the value is freed
1292 */
1293 SetLastError(0xdeadbeef);
1294 ret = pWTHelperGetKnownUsages(2, &usages);
1295 ok(ret, "WTHelperGetKnownUsages failed: %d\n", GetLastError());
1296 ok(usages == NULL, "expected pointer to be cleared\n");
1297 SetLastError(0xdeadbeef);
1298 usages = NULL;
1299 ret = pWTHelperGetKnownUsages(2, &usages);
1300 ok(ret, "WTHelperGetKnownUsages failed: %d\n", GetLastError());
1301 SetLastError(0xdeadbeef);
1302 ret = pWTHelperGetKnownUsages(2, NULL);
1303 ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER,
1304 "expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
1305 }
1306
1307 START_TEST(softpub)
1308 {
1309 InitFunctionPtrs();
1310 test_provider_funcs();
1311 test_sip_create_indirect_data();
1312 test_wintrust();
1313 test_wintrust_digest();
1314 test_get_known_usages();
1315 }