widl: Generate helper macros for WinRT implementation.
[wine/zf.git] / dlls / wintrust / tests / softpub.c
blob25d458faad7e17a06f89fa0a29aa5cc72a3c0131
1 /*
2 * wintrust softpub functions tests
4 * Copyright 2007,2010 Juan Lang
5 * Copyright 2010 Andrey Turkin
6 * Copyright 2016 Mark Jansen
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.
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.
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
23 #include <stdio.h>
24 #include <stdarg.h>
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"
35 #include "wine/test.h"
37 /* Just in case we're being built with borked headers, redefine function
38 * pointers to have the correct calling convention.
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);
61 typedef struct _SAFE_PROVIDER_FUNCTIONS
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;
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);
85 static void InitFunctionPtrs(void)
87 HMODULE hWintrust = GetModuleHandleA("wintrust.dll");
88 HMODULE hCrypt32 = GetModuleHandleA("crypt32.dll");
90 #define WINTRUST_GET_PROC(func) \
91 p ## func = (void*)GetProcAddress(hWintrust, #func); \
92 if(!p ## func) { \
93 trace("GetProcAddress(%s) failed\n", #func); \
96 WINTRUST_GET_PROC(WTHelperGetKnownUsages)
98 #undef WINTRUST_GET_PROC
100 #define CRYPT32_GET_PROC(func) \
101 func ## _p = (void*)GetProcAddress(hCrypt32, #func); \
102 if(!func ## _p) { \
103 trace("GetProcAddress(%s) failed\n", #func); \
106 CRYPT32_GET_PROC(CryptSIPCreateIndirectData)
107 CRYPT32_GET_PROC(CertFreeCertificateChain)
109 #undef CRYPT32_GET_PROC
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 };
125 static void test_utils(SAFE_PROVIDER_FUNCTIONS *funcs)
127 CRYPT_PROVIDER_DATA data = { 0 };
128 HCERTSTORE store;
129 CRYPT_PROVIDER_SGNR sgnr = { 0 };
130 BOOL ret;
132 /* Crash
133 ret = funcs->pfnAddStore2Chain(NULL, NULL);
134 ret = funcs->pfnAddStore2Chain(&data, NULL);
136 store = CertOpenStore(CERT_STORE_PROV_MEMORY, X509_ASN_ENCODING, 0,
137 CERT_STORE_CREATE_NEW_FLAG, NULL);
138 if (store)
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)
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;
155 else
156 skip("CertOpenStore failed: %08x\n", GetLastError());
158 /* Crash
159 ret = funcs->pfnAddSgnr2Chain(NULL, FALSE, 0, NULL);
160 ret = funcs->pfnAddSgnr2Chain(&data, FALSE, 0, NULL);
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)
168 PCCERT_CONTEXT cert;
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 index is ignored */
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 sgnr.sftVerifyAsOf.dwLowDateTime = 0;
186 todo_wine
187 ok(!memcmp(&data.pasSigners[2], &sgnr, sizeof(sgnr)),
188 "Unexpected data in signer\n");
189 /* But too large a thing isn't added */
190 sgnr.cbStruct = sizeof(sgnr) + sizeof(DWORD);
191 SetLastError(0xdeadbeef);
192 ret = funcs->pfnAddSgnr2Chain(&data, FALSE, 0, &sgnr);
193 ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER,
194 "Expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
196 /* Crash
197 ret = funcs->pfnAddCert2Chain(NULL, 0, FALSE, 0, NULL);
198 ret = funcs->pfnAddCert2Chain(&data, 0, FALSE, 0, NULL);
200 cert = CertCreateCertificateContext(X509_ASN_ENCODING, v1CertWithPubKey,
201 sizeof(v1CertWithPubKey));
202 if (cert)
204 /* Notes on behavior that are hard to test:
205 * 1. If pasSigners is invalid, pfnAddCert2Chain crashes
206 * 2. An invalid signer index isn't checked.
208 ret = funcs->pfnAddCert2Chain(&data, 0, FALSE, 0, cert);
209 ok(ret, "pfnAddCert2Chain failed: %08x\n", GetLastError());
210 ok(data.pasSigners[0].csCertChain == 1, "Expected 1 cert, got %d\n",
211 data.pasSigners[0].csCertChain);
212 ok(data.pasSigners[0].pasCertChain != NULL,
213 "Expected pasCertChain to be allocated\n");
214 if (data.pasSigners[0].pasCertChain)
216 ok(data.pasSigners[0].pasCertChain[0].pCert == cert,
217 "Unexpected cert\n");
218 CertFreeCertificateContext(
219 data.pasSigners[0].pasCertChain[0].pCert);
221 CertFreeCertificateContext(cert);
223 else
224 skip("CertCreateCertificateContext failed: %08x\n", GetLastError());
225 funcs->pfnFree(data.pasSigners);
229 static void testInitialize(SAFE_PROVIDER_FUNCTIONS *funcs, GUID *actionID)
231 HRESULT ret;
232 CRYPT_PROVIDER_DATA data = { 0 };
233 WINTRUST_DATA wintrust_data = { 0 };
235 if (!funcs->pfnInitialize)
237 skip("missing pfnInitialize\n");
238 return;
241 /* Crashes
242 ret = funcs->pfnInitialize(NULL);
244 memset(&data, 0, sizeof(data));
245 ret = funcs->pfnInitialize(&data);
246 ok(ret == S_FALSE, "Expected S_FALSE, got %08x\n", ret);
247 data.padwTrustStepErrors =
248 funcs->pfnAlloc(TRUSTERROR_MAX_STEPS * sizeof(DWORD));
249 /* Without wintrust data set, crashes when padwTrustStepErrors is set */
250 data.pWintrustData = &wintrust_data;
251 if (data.padwTrustStepErrors)
253 /* Apparently, cdwTrustStepErrors does not need to be set. */
254 memset(data.padwTrustStepErrors, 0,
255 TRUSTERROR_MAX_STEPS * sizeof(DWORD));
256 ret = funcs->pfnInitialize(&data);
257 ok(ret == S_OK, "Expected S_OK, got %08x\n", ret);
258 data.cdwTrustStepErrors = 1;
259 ret = funcs->pfnInitialize(&data);
260 ok(ret == S_OK, "Expected S_OK, got %08x\n", ret);
261 memset(data.padwTrustStepErrors, 0xba,
262 TRUSTERROR_MAX_STEPS * sizeof(DWORD));
263 ret = funcs->pfnInitialize(&data);
264 ok(ret == S_FALSE, "Expected S_FALSE, got %08x\n", ret);
265 data.padwTrustStepErrors[TRUSTERROR_STEP_FINAL_WVTINIT] = 0;
266 ret = funcs->pfnInitialize(&data);
267 ok(ret == S_OK, "Expected S_OK, got %08x\n", ret);
268 funcs->pfnFree(data.padwTrustStepErrors);
272 static void getNotepadPath(WCHAR *notepadPathW, DWORD size)
274 static const CHAR notepad[] = "\\notepad.exe";
275 CHAR notepadPath[MAX_PATH];
277 /* Workaround missing W-functions for win9x */
278 GetWindowsDirectoryA(notepadPath, MAX_PATH);
279 lstrcatA(notepadPath, notepad);
280 MultiByteToWideChar(CP_ACP, 0, notepadPath, -1, notepadPathW, size);
283 /* Creates a test file and returns a handle to it. The file's path is returned
284 * in temp_file, which must be at least MAX_PATH characters in length.
286 static HANDLE create_temp_file(WCHAR *temp_file)
288 HANDLE file = INVALID_HANDLE_VALUE;
289 WCHAR temp_path[MAX_PATH];
291 if (GetTempPathW(ARRAY_SIZE(temp_path), temp_path))
293 static const WCHAR img[] = { 'i','m','g',0 };
295 if (GetTempFileNameW(temp_path, img, 0, temp_file))
296 file = CreateFileW(temp_file, GENERIC_READ | GENERIC_WRITE, 0, NULL,
297 CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
299 return file;
302 static void testObjTrust(SAFE_PROVIDER_FUNCTIONS *funcs, GUID *actionID)
304 HRESULT ret;
305 CRYPT_PROVIDER_DATA data = { 0 };
306 CRYPT_PROVIDER_SIGSTATE sig_state = { 0 };
307 WINTRUST_DATA wintrust_data = { 0 };
308 WINTRUST_CERT_INFO certInfo = { sizeof(WINTRUST_CERT_INFO), 0 };
309 WINTRUST_FILE_INFO fileInfo = { sizeof(WINTRUST_FILE_INFO), 0 };
311 if (!funcs->pfnObjectTrust)
313 skip("missing pfnObjectTrust\n");
314 return;
317 /* Crashes
318 ret = funcs->pfnObjectTrust(NULL);
321 data.cbStruct = sizeof(data);
322 data.pSigState = &sig_state;
323 data.pWintrustData = &wintrust_data;
324 data.padwTrustStepErrors =
325 funcs->pfnAlloc(TRUSTERROR_MAX_STEPS * sizeof(DWORD));
326 if (data.padwTrustStepErrors)
328 WCHAR pathW[MAX_PATH];
329 PROVDATA_SIP provDataSIP = { 0 };
330 static const GUID unknown = { 0xC689AAB8, 0x8E78, 0x11D0, { 0x8C,0x47,
331 0x00,0xC0,0x4F,0xC2,0x95,0xEE } };
332 static GUID bogusGuid = { 0xdeadbeef, 0xbaad, 0xf00d, { 0x00,0x00,0x00,
333 0x00,0x00,0x00,0x00,0x00 } };
335 ret = funcs->pfnObjectTrust(&data);
336 ok(ret == S_FALSE, "Expected S_FALSE, got %08x\n", ret);
337 ok(data.padwTrustStepErrors[TRUSTERROR_STEP_FINAL_OBJPROV] ==
338 ERROR_INVALID_PARAMETER,
339 "Expected ERROR_INVALID_PARAMETER, got %08x\n",
340 data.padwTrustStepErrors[TRUSTERROR_STEP_FINAL_OBJPROV]);
341 U(wintrust_data).pCert = &certInfo;
342 wintrust_data.dwUnionChoice = WTD_CHOICE_CERT;
343 ret = funcs->pfnObjectTrust(&data);
344 ok(ret == S_OK, "Expected S_OK, got %08x\n", ret);
345 certInfo.psCertContext = (PCERT_CONTEXT)CertCreateCertificateContext(
346 X509_ASN_ENCODING, v1CertWithPubKey, sizeof(v1CertWithPubKey));
347 ret = funcs->pfnObjectTrust(&data);
348 ok(ret == S_OK, "Expected S_OK, got %08x\n", ret);
349 CertFreeCertificateContext(certInfo.psCertContext);
350 certInfo.psCertContext = NULL;
351 wintrust_data.dwUnionChoice = WTD_CHOICE_FILE;
352 U(wintrust_data).pFile = NULL;
353 ret = funcs->pfnObjectTrust(&data);
354 ok(ret == S_FALSE, "Expected S_FALSE, got %08x\n", ret);
355 ok(data.padwTrustStepErrors[TRUSTERROR_STEP_FINAL_OBJPROV] ==
356 ERROR_INVALID_PARAMETER,
357 "Expected ERROR_INVALID_PARAMETER, got %08x\n",
358 data.padwTrustStepErrors[TRUSTERROR_STEP_FINAL_OBJPROV]);
359 U(wintrust_data).pFile = &fileInfo;
360 /* Crashes
361 ret = funcs->pfnObjectTrust(&data);
363 /* Create and test with an empty file */
364 fileInfo.hFile = create_temp_file(pathW);
365 /* pfnObjectTrust now crashes unless both pPDSip and psPfns are set */
366 U(data).pPDSip = &provDataSIP;
367 data.psPfns = (CRYPT_PROVIDER_FUNCTIONS *)funcs;
368 ret = funcs->pfnObjectTrust(&data);
369 ok(ret == S_FALSE, "Expected S_FALSE, got %08x\n", ret);
370 ok(data.padwTrustStepErrors[TRUSTERROR_STEP_FINAL_OBJPROV] ==
371 TRUST_E_SUBJECT_FORM_UNKNOWN,
372 "expected TRUST_E_SUBJECT_FORM_UNKNOWN, got %08x\n",
373 data.padwTrustStepErrors[TRUSTERROR_STEP_FINAL_OBJPROV]);
374 CloseHandle(fileInfo.hFile);
375 fileInfo.hFile = NULL;
376 fileInfo.pcwszFilePath = pathW;
377 ret = funcs->pfnObjectTrust(&data);
378 ok(ret == S_FALSE, "Expected S_FALSE, got %08x\n", ret);
379 ok(data.padwTrustStepErrors[TRUSTERROR_STEP_FINAL_OBJPROV] ==
380 TRUST_E_SUBJECT_FORM_UNKNOWN,
381 "expected TRUST_E_SUBJECT_FORM_UNKNOWN, got %08x\n",
382 data.padwTrustStepErrors[TRUSTERROR_STEP_FINAL_OBJPROV]);
383 DeleteFileW(pathW);
384 /* Test again with a file we expect to exist, and to contain no
385 * signature.
387 getNotepadPath(pathW, MAX_PATH);
388 ret = funcs->pfnObjectTrust(&data);
389 ok(ret == S_FALSE, "Expected S_FALSE, got %08x\n", ret);
390 ok(data.padwTrustStepErrors[TRUSTERROR_STEP_FINAL_OBJPROV] ==
391 TRUST_E_NOSIGNATURE ||
392 data.padwTrustStepErrors[TRUSTERROR_STEP_FINAL_OBJPROV] ==
393 TRUST_E_SUBJECT_FORM_UNKNOWN,
394 "Expected TRUST_E_NOSIGNATURE or TRUST_E_SUBJECT_FORM_UNKNOWN, got %08x\n",
395 data.padwTrustStepErrors[TRUSTERROR_STEP_FINAL_OBJPROV]);
396 if (data.padwTrustStepErrors[TRUSTERROR_STEP_FINAL_OBJPROV] ==
397 TRUST_E_NOSIGNATURE)
399 ok(!memcmp(&provDataSIP.gSubject, &unknown, sizeof(unknown)),
400 "Unexpected subject GUID\n");
401 ok(provDataSIP.pSip != NULL, "Expected a SIP\n");
402 ok(provDataSIP.psSipSubjectInfo != NULL,
403 "Expected a subject info\n");
405 /* Specifying the GUID results in that GUID being the subject GUID */
406 fileInfo.pgKnownSubject = &bogusGuid;
407 ret = funcs->pfnObjectTrust(&data);
408 ok(ret == S_FALSE, "Expected S_FALSE, got %08x\n", ret);
409 ok(data.padwTrustStepErrors[TRUSTERROR_STEP_FINAL_OBJPROV] ==
410 TRUST_E_NOSIGNATURE ||
411 data.padwTrustStepErrors[TRUSTERROR_STEP_FINAL_OBJPROV] ==
412 TRUST_E_SUBJECT_FORM_UNKNOWN ||
413 data.padwTrustStepErrors[TRUSTERROR_STEP_FINAL_OBJPROV] ==
414 TRUST_E_PROVIDER_UNKNOWN,
415 "Expected TRUST_E_NOSIGNATURE or TRUST_E_SUBJECT_FORM_UNKNOWN or TRUST_E_PROVIDER_UNKNOWN, got %08x\n",
416 data.padwTrustStepErrors[TRUSTERROR_STEP_FINAL_OBJPROV]);
417 if (data.padwTrustStepErrors[TRUSTERROR_STEP_FINAL_OBJPROV] ==
418 TRUST_E_NOSIGNATURE)
420 ok(!memcmp(&provDataSIP.gSubject, &bogusGuid, sizeof(bogusGuid)),
421 "unexpected subject GUID\n");
423 /* Specifying a bogus GUID pointer crashes */
424 if (0)
426 fileInfo.pgKnownSubject = (GUID *)0xdeadbeef;
427 ret = funcs->pfnObjectTrust(&data);
428 ok(ret == S_FALSE, "Expected S_FALSE, got %08x\n", ret);
430 funcs->pfnFree(data.padwTrustStepErrors);
434 static const BYTE selfSignedCert[] = {
435 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x42, 0x45, 0x47, 0x49, 0x4e, 0x20, 0x43,
436 0x45, 0x52, 0x54, 0x49, 0x46, 0x49, 0x43, 0x41, 0x54, 0x45, 0x2d, 0x2d,
437 0x2d, 0x2d, 0x2d, 0x0a, 0x4d, 0x49, 0x49, 0x44, 0x70, 0x7a, 0x43, 0x43,
438 0x41, 0x6f, 0x2b, 0x67, 0x41, 0x77, 0x49, 0x42, 0x41, 0x67, 0x49, 0x4a,
439 0x41, 0x4c, 0x59, 0x51, 0x67, 0x65, 0x66, 0x7a, 0x51, 0x41, 0x61, 0x43,
440 0x4d, 0x41, 0x30, 0x47, 0x43, 0x53, 0x71, 0x47, 0x53, 0x49, 0x62, 0x33,
441 0x44, 0x51, 0x45, 0x42, 0x42, 0x51, 0x55, 0x41, 0x4d, 0x47, 0x6f, 0x78,
442 0x43, 0x7a, 0x41, 0x4a, 0x42, 0x67, 0x4e, 0x56, 0x0a, 0x42, 0x41, 0x59,
443 0x54, 0x41, 0x6b, 0x46, 0x56, 0x4d, 0x52, 0x4d, 0x77, 0x45, 0x51, 0x59,
444 0x44, 0x56, 0x51, 0x51, 0x49, 0x44, 0x41, 0x70, 0x54, 0x62, 0x32, 0x31,
445 0x6c, 0x4c, 0x56, 0x4e, 0x30, 0x59, 0x58, 0x52, 0x6c, 0x4d, 0x53, 0x45,
446 0x77, 0x48, 0x77, 0x59, 0x44, 0x56, 0x51, 0x51, 0x4b, 0x44, 0x42, 0x68,
447 0x4a, 0x62, 0x6e, 0x52, 0x6c, 0x63, 0x6d, 0x35, 0x6c, 0x64, 0x43, 0x42,
448 0x58, 0x0a, 0x61, 0x57, 0x52, 0x6e, 0x61, 0x58, 0x52, 0x7a, 0x49, 0x46,
449 0x42, 0x30, 0x65, 0x53, 0x42, 0x4d, 0x64, 0x47, 0x51, 0x78, 0x49, 0x7a,
450 0x41, 0x68, 0x42, 0x67, 0x4e, 0x56, 0x42, 0x41, 0x4d, 0x4d, 0x47, 0x6e,
451 0x4e, 0x6c, 0x62, 0x47, 0x5a, 0x7a, 0x61, 0x57, 0x64, 0x75, 0x5a, 0x57,
452 0x51, 0x75, 0x64, 0x47, 0x56, 0x7a, 0x64, 0x43, 0x35, 0x33, 0x61, 0x57,
453 0x35, 0x6c, 0x61, 0x48, 0x45, 0x75, 0x0a, 0x62, 0x33, 0x4a, 0x6e, 0x4d,
454 0x42, 0x34, 0x58, 0x44, 0x54, 0x45, 0x7a, 0x4d, 0x44, 0x59, 0x79, 0x4d,
455 0x54, 0x45, 0x78, 0x4d, 0x6a, 0x55, 0x78, 0x4d, 0x46, 0x6f, 0x58, 0x44,
456 0x54, 0x49, 0x7a, 0x4d, 0x44, 0x59, 0x78, 0x4f, 0x54, 0x45, 0x78, 0x4d,
457 0x6a, 0x55, 0x78, 0x4d, 0x46, 0x6f, 0x77, 0x61, 0x6a, 0x45, 0x4c, 0x4d,
458 0x41, 0x6b, 0x47, 0x41, 0x31, 0x55, 0x45, 0x42, 0x68, 0x4d, 0x43, 0x0a,
459 0x51, 0x56, 0x55, 0x78, 0x45, 0x7a, 0x41, 0x52, 0x42, 0x67, 0x4e, 0x56,
460 0x42, 0x41, 0x67, 0x4d, 0x43, 0x6c, 0x4e, 0x76, 0x62, 0x57, 0x55, 0x74,
461 0x55, 0x33, 0x52, 0x68, 0x64, 0x47, 0x55, 0x78, 0x49, 0x54, 0x41, 0x66,
462 0x42, 0x67, 0x4e, 0x56, 0x42, 0x41, 0x6f, 0x4d, 0x47, 0x45, 0x6c, 0x75,
463 0x64, 0x47, 0x56, 0x79, 0x62, 0x6d, 0x56, 0x30, 0x49, 0x46, 0x64, 0x70,
464 0x5a, 0x47, 0x64, 0x70, 0x0a, 0x64, 0x48, 0x4d, 0x67, 0x55, 0x48, 0x52,
465 0x35, 0x49, 0x45, 0x78, 0x30, 0x5a, 0x44, 0x45, 0x6a, 0x4d, 0x43, 0x45,
466 0x47, 0x41, 0x31, 0x55, 0x45, 0x41, 0x77, 0x77, 0x61, 0x63, 0x32, 0x56,
467 0x73, 0x5a, 0x6e, 0x4e, 0x70, 0x5a, 0x32, 0x35, 0x6c, 0x5a, 0x43, 0x35,
468 0x30, 0x5a, 0x58, 0x4e, 0x30, 0x4c, 0x6e, 0x64, 0x70, 0x62, 0x6d, 0x56,
469 0x6f, 0x63, 0x53, 0x35, 0x76, 0x63, 0x6d, 0x63, 0x77, 0x0a, 0x67, 0x67,
470 0x45, 0x69, 0x4d, 0x41, 0x30, 0x47, 0x43, 0x53, 0x71, 0x47, 0x53, 0x49,
471 0x62, 0x33, 0x44, 0x51, 0x45, 0x42, 0x41, 0x51, 0x55, 0x41, 0x41, 0x34,
472 0x49, 0x42, 0x44, 0x77, 0x41, 0x77, 0x67, 0x67, 0x45, 0x4b, 0x41, 0x6f,
473 0x49, 0x42, 0x41, 0x51, 0x44, 0x77, 0x4e, 0x6d, 0x2b, 0x46, 0x7a, 0x78,
474 0x6e, 0x6b, 0x48, 0x57, 0x2f, 0x4e, 0x70, 0x37, 0x59, 0x48, 0x34, 0x4d,
475 0x79, 0x45, 0x0a, 0x77, 0x4d, 0x6c, 0x49, 0x67, 0x71, 0x30, 0x66, 0x45,
476 0x77, 0x70, 0x47, 0x6f, 0x41, 0x75, 0x78, 0x44, 0x64, 0x61, 0x46, 0x55,
477 0x32, 0x6f, 0x70, 0x76, 0x41, 0x51, 0x56, 0x61, 0x2b, 0x41, 0x43, 0x46,
478 0x38, 0x63, 0x6f, 0x38, 0x4d, 0x4a, 0x6c, 0x33, 0x78, 0x77, 0x76, 0x46,
479 0x44, 0x2b, 0x67, 0x61, 0x46, 0x45, 0x7a, 0x59, 0x78, 0x53, 0x58, 0x30,
480 0x43, 0x47, 0x72, 0x4a, 0x45, 0x4c, 0x63, 0x0a, 0x74, 0x34, 0x4d, 0x69,
481 0x30, 0x68, 0x4b, 0x50, 0x76, 0x42, 0x70, 0x65, 0x73, 0x59, 0x6c, 0x46,
482 0x4d, 0x51, 0x65, 0x6b, 0x2b, 0x63, 0x70, 0x51, 0x50, 0x33, 0x4b, 0x35,
483 0x75, 0x36, 0x71, 0x58, 0x5a, 0x52, 0x49, 0x67, 0x48, 0x75, 0x59, 0x45,
484 0x4c, 0x2f, 0x73, 0x55, 0x6f, 0x39, 0x32, 0x70, 0x44, 0x30, 0x7a, 0x4a,
485 0x65, 0x4c, 0x47, 0x41, 0x31, 0x49, 0x30, 0x4b, 0x5a, 0x34, 0x73, 0x2f,
486 0x0a, 0x51, 0x7a, 0x77, 0x61, 0x4f, 0x38, 0x62, 0x62, 0x4b, 0x6d, 0x37,
487 0x42, 0x72, 0x6e, 0x56, 0x77, 0x30, 0x6e, 0x5a, 0x2f, 0x4b, 0x41, 0x5a,
488 0x6a, 0x75, 0x78, 0x75, 0x6f, 0x4e, 0x33, 0x52, 0x64, 0x72, 0x69, 0x30,
489 0x4a, 0x48, 0x77, 0x7a, 0x6a, 0x41, 0x55, 0x34, 0x2b, 0x71, 0x57, 0x65,
490 0x55, 0x63, 0x2f, 0x64, 0x33, 0x45, 0x70, 0x4f, 0x47, 0x78, 0x69, 0x42,
491 0x77, 0x5a, 0x4e, 0x61, 0x7a, 0x0a, 0x39, 0x6f, 0x4a, 0x41, 0x37, 0x54,
492 0x2f, 0x51, 0x6f, 0x62, 0x75, 0x61, 0x4e, 0x53, 0x6b, 0x65, 0x55, 0x48,
493 0x43, 0x61, 0x50, 0x53, 0x6a, 0x44, 0x37, 0x71, 0x7a, 0x6c, 0x43, 0x4f,
494 0x52, 0x48, 0x47, 0x68, 0x75, 0x31, 0x76, 0x79, 0x79, 0x35, 0x31, 0x45,
495 0x36, 0x79, 0x46, 0x43, 0x4e, 0x47, 0x66, 0x65, 0x7a, 0x71, 0x2f, 0x4d,
496 0x59, 0x34, 0x4e, 0x4b, 0x68, 0x77, 0x72, 0x61, 0x59, 0x64, 0x0a, 0x62,
497 0x79, 0x49, 0x2f, 0x6c, 0x42, 0x46, 0x62, 0x36, 0x35, 0x6b, 0x5a, 0x45,
498 0x66, 0x49, 0x4b, 0x4b, 0x54, 0x7a, 0x79, 0x36, 0x76, 0x30, 0x44, 0x65,
499 0x79, 0x50, 0x37, 0x52, 0x6b, 0x34, 0x75, 0x48, 0x44, 0x38, 0x77, 0x62,
500 0x49, 0x79, 0x50, 0x32, 0x47, 0x6c, 0x42, 0x30, 0x67, 0x37, 0x2f, 0x69,
501 0x79, 0x33, 0x4c, 0x61, 0x74, 0x49, 0x74, 0x49, 0x70, 0x2b, 0x49, 0x35,
502 0x53, 0x50, 0x56, 0x0a, 0x41, 0x67, 0x4d, 0x42, 0x41, 0x41, 0x47, 0x6a,
503 0x55, 0x44, 0x42, 0x4f, 0x4d, 0x42, 0x30, 0x47, 0x41, 0x31, 0x55, 0x64,
504 0x44, 0x67, 0x51, 0x57, 0x42, 0x42, 0x53, 0x36, 0x49, 0x4c, 0x5a, 0x2f,
505 0x71, 0x38, 0x66, 0x2f, 0x4b, 0x45, 0x68, 0x4b, 0x76, 0x68, 0x69, 0x2b,
506 0x73, 0x6b, 0x59, 0x45, 0x31, 0x79, 0x48, 0x71, 0x39, 0x7a, 0x41, 0x66,
507 0x42, 0x67, 0x4e, 0x56, 0x48, 0x53, 0x4d, 0x45, 0x0a, 0x47, 0x44, 0x41,
508 0x57, 0x67, 0x42, 0x53, 0x36, 0x49, 0x4c, 0x5a, 0x2f, 0x71, 0x38, 0x66,
509 0x2f, 0x4b, 0x45, 0x68, 0x4b, 0x76, 0x68, 0x69, 0x2b, 0x73, 0x6b, 0x59,
510 0x45, 0x31, 0x79, 0x48, 0x71, 0x39, 0x7a, 0x41, 0x4d, 0x42, 0x67, 0x4e,
511 0x56, 0x48, 0x52, 0x4d, 0x45, 0x42, 0x54, 0x41, 0x44, 0x41, 0x51, 0x48,
512 0x2f, 0x4d, 0x41, 0x30, 0x47, 0x43, 0x53, 0x71, 0x47, 0x53, 0x49, 0x62,
513 0x33, 0x0a, 0x44, 0x51, 0x45, 0x42, 0x42, 0x51, 0x55, 0x41, 0x41, 0x34,
514 0x49, 0x42, 0x41, 0x51, 0x41, 0x79, 0x5a, 0x59, 0x77, 0x47, 0x4b, 0x46,
515 0x34, 0x34, 0x43, 0x68, 0x47, 0x51, 0x72, 0x6e, 0x74, 0x57, 0x6c, 0x38,
516 0x48, 0x53, 0x4a, 0x30, 0x63, 0x69, 0x55, 0x58, 0x4d, 0x44, 0x4b, 0x32,
517 0x46, 0x6c, 0x6f, 0x74, 0x47, 0x49, 0x6a, 0x30, 0x32, 0x6c, 0x4d, 0x39,
518 0x38, 0x71, 0x45, 0x49, 0x65, 0x68, 0x0a, 0x56, 0x67, 0x66, 0x41, 0x34,
519 0x7a, 0x69, 0x37, 0x4d, 0x45, 0x6c, 0x51, 0x61, 0x76, 0x6b, 0x52, 0x76,
520 0x32, 0x54, 0x43, 0x50, 0x50, 0x55, 0x51, 0x62, 0x35, 0x51, 0x64, 0x61,
521 0x6f, 0x37, 0x57, 0x78, 0x37, 0x6c, 0x66, 0x61, 0x54, 0x6f, 0x5a, 0x68,
522 0x4f, 0x54, 0x2b, 0x4e, 0x52, 0x68, 0x32, 0x6b, 0x35, 0x78, 0x2b, 0x6b,
523 0x6a, 0x5a, 0x46, 0x77, 0x38, 0x70, 0x45, 0x48, 0x74, 0x35, 0x51, 0x0a,
524 0x69, 0x68, 0x62, 0x46, 0x4c, 0x35, 0x58, 0x2b, 0x57, 0x7a, 0x6f, 0x2b,
525 0x42, 0x36, 0x36, 0x59, 0x79, 0x49, 0x76, 0x68, 0x77, 0x54, 0x63, 0x48,
526 0x30, 0x46, 0x2b, 0x6e, 0x66, 0x55, 0x71, 0x66, 0x74, 0x38, 0x59, 0x74,
527 0x72, 0x2f, 0x38, 0x37, 0x47, 0x45, 0x62, 0x73, 0x41, 0x48, 0x6a, 0x48,
528 0x43, 0x36, 0x4c, 0x2b, 0x77, 0x6b, 0x31, 0x76, 0x4e, 0x6e, 0x64, 0x49,
529 0x59, 0x47, 0x30, 0x51, 0x0a, 0x79, 0x62, 0x73, 0x7a, 0x78, 0x49, 0x72,
530 0x32, 0x6d, 0x46, 0x45, 0x49, 0x4a, 0x6f, 0x69, 0x51, 0x44, 0x44, 0x67,
531 0x66, 0x6c, 0x71, 0x67, 0x64, 0x76, 0x4c, 0x54, 0x32, 0x79, 0x64, 0x46,
532 0x6d, 0x79, 0x33, 0x73, 0x32, 0x68, 0x49, 0x74, 0x51, 0x6c, 0x49, 0x71,
533 0x4b, 0x4c, 0x42, 0x36, 0x49, 0x4a, 0x51, 0x49, 0x75, 0x69, 0x37, 0x72,
534 0x37, 0x34, 0x76, 0x64, 0x72, 0x63, 0x58, 0x71, 0x58, 0x0a, 0x44, 0x7a,
535 0x68, 0x6d, 0x4c, 0x66, 0x67, 0x6a, 0x67, 0x4c, 0x77, 0x33, 0x2b, 0x55,
536 0x79, 0x69, 0x59, 0x74, 0x44, 0x54, 0x76, 0x63, 0x78, 0x65, 0x7a, 0x62,
537 0x4c, 0x73, 0x76, 0x51, 0x6f, 0x52, 0x6b, 0x74, 0x77, 0x4b, 0x5a, 0x4c,
538 0x44, 0x54, 0x42, 0x42, 0x35, 0x76, 0x59, 0x32, 0x78, 0x4b, 0x36, 0x6b,
539 0x4f, 0x4f, 0x44, 0x70, 0x7a, 0x50, 0x48, 0x73, 0x4b, 0x67, 0x30, 0x42,
540 0x59, 0x77, 0x0a, 0x4d, 0x6b, 0x48, 0x56, 0x56, 0x54, 0x34, 0x79, 0x2f,
541 0x4d, 0x59, 0x36, 0x63, 0x63, 0x4b, 0x51, 0x2f, 0x4c, 0x56, 0x74, 0x32,
542 0x66, 0x4a, 0x49, 0x74, 0x69, 0x41, 0x71, 0x49, 0x47, 0x32, 0x38, 0x64,
543 0x37, 0x31, 0x53, 0x0a, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x45, 0x4e, 0x44,
544 0x20, 0x43, 0x45, 0x52, 0x54, 0x49, 0x46, 0x49, 0x43, 0x41, 0x54, 0x45,
545 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x0a
548 static void testCertTrust(SAFE_PROVIDER_FUNCTIONS *funcs, GUID *actionID)
550 CRYPT_PROVIDER_DATA data = { 0 };
551 CRYPT_PROVIDER_SIGSTATE sig_state = { 0 };
552 CRYPT_PROVIDER_SGNR sgnr = { sizeof(sgnr), { 0 } };
553 HRESULT ret;
554 BOOL b;
556 if (!CertFreeCertificateChain_p)
558 win_skip("CertFreeCertificateChain not found\n");
559 return;
562 data.pSigState = &sig_state;
563 data.padwTrustStepErrors =
564 funcs->pfnAlloc(TRUSTERROR_MAX_STEPS * sizeof(DWORD));
565 if (!data.padwTrustStepErrors)
567 skip("pfnAlloc failed\n");
568 return;
570 ret = funcs->pfnCertificateTrust(&data);
571 ok(ret == S_FALSE, "Expected S_FALSE, got %08x\n", ret);
572 ok(data.padwTrustStepErrors[TRUSTERROR_STEP_FINAL_CERTPROV] ==
573 TRUST_E_NOSIGNATURE, "Expected TRUST_E_NOSIGNATURE, got %08x\n",
574 data.padwTrustStepErrors[TRUSTERROR_STEP_FINAL_CERTPROV]);
575 b = funcs->pfnAddSgnr2Chain(&data, FALSE, 0, &sgnr);
576 if (b)
578 PCCERT_CONTEXT cert;
580 /* An empty signer "succeeds," even though there's no cert */
581 ret = funcs->pfnCertificateTrust(&data);
582 ok(ret == S_OK, "Expected S_OK, got %08x\n", ret);
583 cert = CertCreateCertificateContext(X509_ASN_ENCODING, selfSignedCert,
584 sizeof(selfSignedCert));
585 if (cert)
587 WINTRUST_DATA wintrust_data = { 0 };
589 b = funcs->pfnAddCert2Chain(&data, 0, FALSE, 0, cert);
590 ok(b == TRUE, "Expected TRUE, got %d\n", b);
592 /* If pWintrustData isn't set, crashes attempting to access
593 * pWintrustData->fdwRevocationChecks
595 data.pWintrustData = &wintrust_data;
596 /* If psPfns isn't set, crashes attempting to access
597 * psPfns->pfnCertCheckPolicy
599 data.psPfns = (CRYPT_PROVIDER_FUNCTIONS *)funcs;
600 ret = funcs->pfnCertificateTrust(&data);
601 ok(ret == S_OK, "Expected S_OK, got %08x\n", ret);
602 ok(data.csSigners == 1, "Unexpected number of signers %d\n",
603 data.csSigners);
604 ok(data.pasSigners[0].pChainContext != NULL,
605 "Expected a certificate chain\n");
606 ok(data.pasSigners[0].csCertChain == 1,
607 "Unexpected number of chain elements %d\n",
608 data.pasSigners[0].csCertChain);
609 /* pasSigners and pasSigners[0].pasCertChain are guaranteed to be
610 * initialized, see tests for pfnAddSgnr2Chain and pfnAddCert2Chain
612 ok(!data.pasSigners[0].pasCertChain[0].fTrustedRoot,
613 "Didn't expect cert to be trusted\n");
614 ok(data.pasSigners[0].pasCertChain[0].fSelfSigned,
615 "Expected cert to be self-signed\n");
616 ok(data.pasSigners[0].pasCertChain[0].dwConfidence ==
617 (CERT_CONFIDENCE_SIG | CERT_CONFIDENCE_TIMENEST),
618 "Expected CERT_CONFIDENCE_SIG | CERT_CONFIDENCE_TIMENEST, got %08x\n",
619 data.pasSigners[0].pasCertChain[0].dwConfidence);
620 CertFreeCertificateContext(
621 data.pasSigners[0].pasCertChain[0].pCert);
622 CertFreeCertificateChain_p(data.pasSigners[0].pChainContext);
623 CertFreeCertificateContext(cert);
626 funcs->pfnFree(data.padwTrustStepErrors);
629 static void test_provider_funcs(void)
631 static GUID generic_verify_v2 = WINTRUST_ACTION_GENERIC_VERIFY_V2;
632 SAFE_PROVIDER_FUNCTIONS funcs = { sizeof(SAFE_PROVIDER_FUNCTIONS), 0 };
633 BOOL ret;
635 ret = WintrustLoadFunctionPointers(&generic_verify_v2,
636 (CRYPT_PROVIDER_FUNCTIONS *)&funcs);
637 if (!ret)
638 skip("WintrustLoadFunctionPointers failed\n");
639 else
641 test_utils(&funcs);
642 testInitialize(&funcs, &generic_verify_v2);
643 testObjTrust(&funcs, &generic_verify_v2);
644 testCertTrust(&funcs, &generic_verify_v2);
648 /* minimal PE file image */
649 #define VA_START 0x400000
650 #define FILE_PE_START 0x50
651 #define NUM_SECTIONS 3
652 #define FILE_TEXT 0x200
653 #define RVA_TEXT 0x1000
654 #define RVA_BSS 0x2000
655 #define FILE_IDATA 0x400
656 #define RVA_IDATA 0x3000
657 #define FILE_TOTAL 0x600
658 #define RVA_TOTAL 0x4000
659 #include <pshpack1.h>
660 struct Imports {
661 IMAGE_IMPORT_DESCRIPTOR descriptors[2];
662 IMAGE_THUNK_DATA32 original_thunks[2];
663 IMAGE_THUNK_DATA32 thunks[2];
664 struct __IMPORT_BY_NAME {
665 WORD hint;
666 char funcname[0x20];
667 } ibn;
668 char dllname[0x10];
670 #define EXIT_PROCESS (VA_START+RVA_IDATA+FIELD_OFFSET(struct Imports, thunks))
672 static struct _PeImage {
673 IMAGE_DOS_HEADER dos_header;
674 char __alignment1[FILE_PE_START - sizeof(IMAGE_DOS_HEADER)];
675 IMAGE_NT_HEADERS32 nt_headers;
676 IMAGE_SECTION_HEADER sections[NUM_SECTIONS];
677 char __alignment2[FILE_TEXT - FILE_PE_START - sizeof(IMAGE_NT_HEADERS32) -
678 NUM_SECTIONS * sizeof(IMAGE_SECTION_HEADER)];
679 unsigned char text_section[FILE_IDATA-FILE_TEXT];
680 struct Imports idata_section;
681 char __alignment3[FILE_TOTAL-FILE_IDATA-sizeof(struct Imports)];
682 } bin = {
683 /* dos header */
684 {IMAGE_DOS_SIGNATURE, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, {0}, 0, 0, {0}, FILE_PE_START},
685 /* alignment before PE header */
686 {0},
687 /* nt headers */
688 {IMAGE_NT_SIGNATURE,
689 /* basic headers - 3 sections, no symbols, EXE file */
690 {IMAGE_FILE_MACHINE_I386, NUM_SECTIONS, 0, 0, 0, sizeof(IMAGE_OPTIONAL_HEADER32),
691 IMAGE_FILE_32BIT_MACHINE | IMAGE_FILE_EXECUTABLE_IMAGE},
692 /* optional header */
693 {IMAGE_NT_OPTIONAL_HDR32_MAGIC, 4, 0, FILE_IDATA-FILE_TEXT,
694 FILE_TOTAL-FILE_IDATA + FILE_IDATA-FILE_TEXT, 0x400,
695 RVA_TEXT, RVA_TEXT, RVA_BSS, VA_START, 0x1000, 0x200, 4, 0, 1, 0, 4, 0, 0,
696 RVA_TOTAL, FILE_TEXT, 0, IMAGE_SUBSYSTEM_WINDOWS_GUI, 0,
697 0x200000, 0x1000, 0x100000, 0x1000, 0, 0x10,
698 {{0, 0},
699 {RVA_IDATA, sizeof(struct Imports)}
703 /* sections */
705 {".text", {0x100}, RVA_TEXT, FILE_IDATA-FILE_TEXT, FILE_TEXT,
706 0, 0, 0, 0, IMAGE_SCN_CNT_CODE | IMAGE_SCN_MEM_EXECUTE | IMAGE_SCN_MEM_READ},
707 {".bss", {0x400}, RVA_BSS, 0, 0, 0, 0, 0, 0,
708 IMAGE_SCN_CNT_UNINITIALIZED_DATA | IMAGE_SCN_MEM_READ | IMAGE_SCN_MEM_WRITE},
709 {".idata", {sizeof(struct Imports)}, RVA_IDATA, FILE_TOTAL-FILE_IDATA, FILE_IDATA, 0,
710 0, 0, 0, IMAGE_SCN_CNT_INITIALIZED_DATA | IMAGE_SCN_MEM_READ | IMAGE_SCN_MEM_WRITE}
712 /* alignment before first section */
713 {0},
714 /* .text section */
716 0x31, 0xC0, /* xor eax, eax */
717 0xFF, 0x25, EXIT_PROCESS&0xFF, (EXIT_PROCESS>>8)&0xFF, (EXIT_PROCESS>>16)&0xFF,
718 (EXIT_PROCESS>>24)&0xFF, /* jmp ExitProcess */
721 /* .idata section */
724 {{RVA_IDATA + FIELD_OFFSET(struct Imports, original_thunks)}, 0, 0,
725 RVA_IDATA + FIELD_OFFSET(struct Imports, dllname),
726 RVA_IDATA + FIELD_OFFSET(struct Imports, thunks)
728 {{0}, 0, 0, 0, 0}
730 {{{RVA_IDATA+FIELD_OFFSET(struct Imports, ibn)}}, {{0}}},
731 {{{RVA_IDATA+FIELD_OFFSET(struct Imports, ibn)}}, {{0}}},
732 {0,"ExitProcess"},
733 "KERNEL32.DLL"
735 /* final alignment */
738 #include <poppack.h>
740 static void test_sip_create_indirect_data(void)
742 static GUID unknown = { 0xC689AAB8, 0x8E78, 0x11D0, { 0x8C,0x47,
743 0x00,0xC0,0x4F,0xC2,0x95,0xEE } };
744 static char oid_sha1[] = szOID_OIWSEC_sha1;
745 BOOL ret;
746 SIP_SUBJECTINFO subjinfo = { 0 };
747 WCHAR temp_file[MAX_PATH];
748 HANDLE file;
749 DWORD count;
751 if (!CryptSIPCreateIndirectData_p)
753 skip("Missing CryptSIPCreateIndirectData\n");
754 return;
756 SetLastError(0xdeadbeef);
757 ret = CryptSIPCreateIndirectData_p(NULL, NULL, NULL);
758 ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER,
759 "expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
760 SetLastError(0xdeadbeef);
761 ret = CryptSIPCreateIndirectData_p(&subjinfo, NULL, NULL);
762 ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER,
763 "expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
764 subjinfo.cbSize = sizeof(subjinfo);
765 SetLastError(0xdeadbeef);
766 ret = CryptSIPCreateIndirectData_p(&subjinfo, NULL, NULL);
767 ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER,
768 "expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
769 file = create_temp_file(temp_file);
770 if (file == INVALID_HANDLE_VALUE)
772 skip("couldn't create temp file\n");
773 return;
775 WriteFile(file, &bin, sizeof(bin), &count, NULL);
776 FlushFileBuffers(file);
778 subjinfo.hFile = file;
779 SetLastError(0xdeadbeef);
780 ret = CryptSIPCreateIndirectData_p(&subjinfo, NULL, NULL);
781 ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER,
782 "expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
783 subjinfo.pgSubjectType = &unknown;
784 SetLastError(0xdeadbeef);
785 ret = CryptSIPCreateIndirectData_p(&subjinfo, NULL, NULL);
786 ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER,
787 "expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
788 subjinfo.DigestAlgorithm.pszObjId = oid_sha1;
789 count = 0xdeadbeef;
790 ret = CryptSIPCreateIndirectData_p(&subjinfo, &count, NULL);
791 todo_wine
792 ok(ret, "CryptSIPCreateIndirectData failed: %d\n", GetLastError());
793 ok(count, "expected a positive count\n");
794 if (ret)
796 SIP_INDIRECT_DATA *indirect = HeapAlloc(GetProcessHeap(), 0, count);
798 count = 256;
799 ret = CryptSIPCreateIndirectData_p(&subjinfo, &count, indirect);
800 ok(ret, "CryptSIPCreateIndirectData failed: %d\n", GetLastError());
801 /* If the count is larger than needed, it's unmodified */
802 ok(count == 256, "unexpected count %d\n", count);
803 ok(!strcmp(indirect->Data.pszObjId, SPC_PE_IMAGE_DATA_OBJID),
804 "unexpected data oid %s\n",
805 indirect->Data.pszObjId);
806 ok(!strcmp(indirect->DigestAlgorithm.pszObjId, oid_sha1),
807 "unexpected digest algorithm oid %s\n",
808 indirect->DigestAlgorithm.pszObjId);
809 ok(indirect->Digest.cbData == 20, "unexpected hash size %d\n",
810 indirect->Digest.cbData);
811 if (indirect->Digest.cbData == 20)
813 const BYTE hash[20] = {
814 0x8a,0xd5,0x45,0x53,0x3d,0x67,0xdf,0x2f,0x78,0xe0,
815 0x55,0x0a,0xe0,0xd9,0x7a,0x28,0x3e,0xbf,0x45,0x2b };
817 ok(!memcmp(indirect->Digest.pbData, hash, 20),
818 "unexpected value\n");
821 HeapFree(GetProcessHeap(), 0, indirect);
823 CloseHandle(file);
824 DeleteFileW(temp_file);
827 static void test_wintrust(void)
829 static GUID generic_action_v2 = WINTRUST_ACTION_GENERIC_VERIFY_V2;
830 WINTRUST_DATA wtd;
831 WINTRUST_FILE_INFO file;
832 LONG r;
833 HRESULT hr;
834 WCHAR pathW[MAX_PATH];
836 memset(&wtd, 0, sizeof(wtd));
837 wtd.cbStruct = sizeof(wtd);
838 wtd.dwUIChoice = WTD_UI_NONE;
839 wtd.fdwRevocationChecks = WTD_REVOKE_WHOLECHAIN;
840 wtd.dwUnionChoice = WTD_CHOICE_FILE;
841 U(wtd).pFile = &file;
842 wtd.dwStateAction = WTD_STATEACTION_VERIFY;
843 memset(&file, 0, sizeof(file));
844 file.cbStruct = sizeof(file);
845 file.pcwszFilePath = pathW;
846 /* Test with an empty file */
847 file.hFile = create_temp_file(pathW);
848 SetLastError(0xdeadbeef);
849 r = WinVerifyTrust(INVALID_HANDLE_VALUE, &generic_action_v2, &wtd);
850 ok(r == GetLastError(), "expected %08x, got %08x\n", GetLastError(), r);
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 SetLastError(0xdeadbeef);
859 r = WinVerifyTrust(INVALID_HANDLE_VALUE, &generic_action_v2, &wtd);
860 ok(r == GetLastError(), "expected %08x, got %08x\n", GetLastError(), r);
861 ok(r == TRUST_E_NOSIGNATURE || r == CRYPT_E_FILE_ERROR,
862 "expected TRUST_E_NOSIGNATURE or CRYPT_E_FILE_ERROR, got %08x\n", r);
863 wtd.dwStateAction = WTD_STATEACTION_CLOSE;
864 SetLastError(0xdeadbeef);
865 r = WinVerifyTrust(INVALID_HANDLE_VALUE, &generic_action_v2, &wtd);
866 ok(GetLastError() == 0xdeadbeef, "expected 0xdeadbeef, got %08x\n", GetLastError());
867 ok(r == S_OK, "WinVerifyTrust failed: %08x\n", r);
868 wtd.dwStateAction = WTD_STATEACTION_VERIFY;
869 SetLastError(0xdeadbeef);
870 hr = WinVerifyTrustEx(INVALID_HANDLE_VALUE, &generic_action_v2, &wtd);
871 ok(hr == GetLastError(), "expected %08x, got %08x\n", GetLastError(), hr);
872 ok(hr == TRUST_E_NOSIGNATURE || hr == CRYPT_E_FILE_ERROR,
873 "expected TRUST_E_NOSIGNATURE or CRYPT_E_FILE_ERROR, got %08x\n", hr);
874 wtd.dwStateAction = WTD_STATEACTION_CLOSE;
875 SetLastError(0xdeadbeef);
876 r = WinVerifyTrust(INVALID_HANDLE_VALUE, &generic_action_v2, &wtd);
877 ok(GetLastError() == 0xdeadbeef, "expected 0xdeadbeef, got %08x\n", GetLastError());
878 ok(r == S_OK, "WinVerifyTrust failed: %08x\n", r);
881 /* Self-signed .exe, built with tcc, signed with signtool
882 * (and a certificate generated on a self-signed CA).
884 * small.c:
885 * int _start()
887 * return 0;
890 * tcc -nostdlib small.c
891 * signtool sign /v /f codesign.pfx small.exe
893 static const BYTE SelfSignedFile32[] =
895 0x4D,0x5A,0x90,0x00,0x03,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0xFF,0xFF,0x00,0x00,0xB8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
896 0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
897 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x00,0x00,0x00,0x0E,0x1F,0xBA,0x0E,0x00,0xB4,0x09,0xCD,
898 0x21,0xB8,0x01,0x4C,0xCD,0x21,0x54,0x68,0x69,0x73,0x20,0x70,0x72,0x6F,0x67,0x72,0x61,0x6D,0x20,0x63,0x61,0x6E,0x6E,0x6F,
899 0x74,0x20,0x62,0x65,0x20,0x72,0x75,0x6E,0x20,0x69,0x6E,0x20,0x44,0x4F,0x53,0x20,0x6D,0x6F,0x64,0x65,0x2E,0x0D,0x0D,0x0A,
900 0x24,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x50,0x45,0x00,0x00,0x4C,0x01,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
901 0x00,0x00,0x00,0x00,0xE0,0x00,0x0F,0x03,0x0B,0x01,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
902 0x00,0x10,0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x40,0x00,0x00,0x10,0x00,0x00,0x00,0x02,0x00,0x00,
903 0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x00,0x00,0x00,0x02,0x00,0x00,
904 0xE7,0x0C,0x00,0x00,0x03,0x00,0x00,0x00,0x00,0x00,0x10,0x00,0x00,0x10,0x00,0x00,0x00,0x00,0x10,0x00,0x00,0x10,0x00,0x00,
905 0x00,0x00,0x00,0x00,0x10,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,0x04,0x00,0x00,0x68,0x05,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,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
909 0x00,0x00,0x00,0x00,0x00,0x00,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,0x2E,0x74,0x65,0x78,0x74,0x00,0x00,0x00,
911 0x18,0x00,0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
912 0x00,0x00,0x00,0x00,0x20,0x00,0x00,0x60,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,0x55,0x89,0xE5,0x81,0xEC,0x00,0x00,0x00,0x00,0x90,0xB8,0x00,0x00,0x00,0x00,0xE9,
917 0x00,0x00,0x00,0x00,0xC9,0xC3,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,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
930 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
931 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
932 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
933 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
934 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
935 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
936 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
937 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x68,0x05,0x00,0x00,0x00,0x02,0x02,0x00,
938 /* Start of the signature overlay */
939 0x30,0x82,0x05,0x5A,0x06,0x09,0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x07,0x02,0xA0,0x82,0x05,0x4B,0x30,0x82,0x05,0x47,0x02,
940 0x01,0x01,0x31,0x0B,0x30,0x09,0x06,0x05,0x2B,0x0E,0x03,0x02,0x1A,0x05,0x00,0x30,0x4C,0x06,0x0A,0x2B,0x06,0x01,0x04,0x01,
941 0x82,0x37,0x02,0x01,0x04,0xA0,0x3E,0x30,0x3C,0x30,0x17,0x06,0x0A,0x2B,0x06,0x01,0x04,0x01,0x82,0x37,0x02,0x01,0x0F,0x30,
942 0x09,0x03,0x01,0x00,0xA0,0x04,0xA2,0x02,0x80,0x00,0x30,0x21,0x30,0x09,0x06,0x05,0x2B,0x0E,0x03,0x02,0x1A,0x05,0x00,0x04,
943 0x14,0xA0,0x95,0xDE,0xBD,0x1A,0xB7,0x86,0xAF,0x50,0x63,0xD8,0x8F,0x90,0xD5,0x49,0x96,0x4E,0x44,0xF0,0x71,0xA0,0x82,0x03,
944 0x1D,0x30,0x82,0x03,0x19,0x30,0x82,0x02,0x01,0xA0,0x03,0x02,0x01,0x02,0x02,0x10,0x96,0x53,0x2C,0xC9,0x23,0x56,0x8A,0x87,
945 0x42,0x30,0x3E,0xD5,0x8D,0x72,0xD5,0x25,0x30,0x0D,0x06,0x09,0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x01,0x0B,0x05,0x00,0x30,
946 0x17,0x31,0x15,0x30,0x13,0x06,0x03,0x55,0x04,0x03,0x13,0x0C,0x54,0x65,0x73,0x74,0x20,0x43,0x41,0x20,0x52,0x6F,0x6F,0x74,
947 0x30,0x1E,0x17,0x0D,0x31,0x36,0x30,0x33,0x30,0x33,0x32,0x30,0x32,0x37,0x30,0x37,0x5A,0x17,0x0D,0x34,0x39,0x31,0x32,0x33,
948 0x31,0x32,0x33,0x30,0x30,0x30,0x30,0x5A,0x30,0x17,0x31,0x15,0x30,0x13,0x06,0x03,0x55,0x04,0x03,0x13,0x0C,0x43,0x6F,0x64,
949 0x65,0x53,0x69,0x67,0x6E,0x54,0x65,0x73,0x74,0x30,0x82,0x01,0x22,0x30,0x0D,0x06,0x09,0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,
950 0x01,0x01,0x05,0x00,0x03,0x82,0x01,0x0F,0x00,0x30,0x82,0x01,0x0A,0x02,0x82,0x01,0x01,0x00,0xB2,0xC9,0x91,0x98,0x8C,0xDC,
951 0x80,0xBC,0x16,0xBF,0xC1,0x04,0x77,0x90,0xC0,0xFD,0x8C,0xBA,0x68,0x26,0xAC,0xB7,0x20,0x68,0x41,0xED,0xC3,0x9C,0x47,0x7C,
952 0x36,0xC2,0x7B,0xE1,0x5E,0xFD,0xA9,0x99,0xF4,0x29,0x36,0x86,0x93,0x40,0x55,0x53,0x65,0x79,0xBC,0x9F,0x8F,0x6E,0x2B,0x05,
953 0x84,0xE1,0xFD,0xD2,0xEF,0xEA,0x89,0x8C,0xEC,0xF9,0x55,0xF0,0x2C,0xE5,0xA7,0x29,0xF9,0x7E,0x50,0xDC,0x9C,0xA1,0x23,0xA5,
954 0xD9,0x78,0xA1,0xE7,0x7C,0xD7,0x04,0x4F,0x11,0xAC,0x9F,0x4A,0x47,0xA1,0x1E,0xD5,0x9E,0xE7,0x5B,0xB5,0x8C,0x9C,0x67,0x7A,
955 0xD0,0xF8,0x54,0xD1,0x64,0x7F,0x39,0x48,0xB6,0xCF,0x2F,0x26,0x7D,0x7B,0x13,0x2B,0xC2,0x8F,0xA6,0x3F,0x42,0x71,0x95,0x3E,
956 0x59,0x0F,0x12,0xFA,0xC2,0x70,0x89,0xB7,0xB6,0x10,0x49,0xE0,0x7D,0x4D,0xFC,0x80,0x61,0x53,0x50,0x72,0xFD,0x46,0x35,0x51,
957 0x36,0xE6,0x06,0xA9,0x4C,0x0D,0x82,0x15,0xF6,0x5D,0xDE,0xD4,0xDB,0xE7,0x82,0x10,0x40,0xA1,0x47,0x68,0x88,0x0C,0x0A,0x80,
958 0xD1,0xE5,0x9A,0x35,0x28,0x82,0x1F,0x0F,0x80,0x5A,0x6E,0x1D,0x22,0x22,0xB3,0xA7,0xA2,0x9E,0x82,0x2D,0xC0,0x7F,0x5A,0xD0,
959 0xBA,0xB2,0xCA,0x20,0xE2,0x97,0xE9,0x72,0x41,0xB7,0xD6,0x1A,0x93,0x23,0x97,0xF0,0xA9,0x61,0xD2,0x91,0xBD,0xB6,0x6B,0x95,
960 0x12,0x67,0x16,0xAC,0x0A,0xB7,0x55,0x02,0x0D,0xA5,0xAD,0x17,0x95,0x77,0xF9,0x96,0x03,0x41,0xD3,0xE1,0x61,0x68,0xBB,0x0A,
961 0xB5,0xC4,0xEE,0x70,0x40,0x08,0x05,0xC4,0xF1,0x5D,0x02,0x03,0x01,0x00,0x01,0xA3,0x61,0x30,0x5F,0x30,0x13,0x06,0x03,0x55,
962 0x1D,0x25,0x04,0x0C,0x30,0x0A,0x06,0x08,0x2B,0x06,0x01,0x05,0x05,0x07,0x03,0x03,0x30,0x48,0x06,0x03,0x55,0x1D,0x01,0x04,
963 0x41,0x30,0x3F,0x80,0x10,0x35,0x40,0x67,0x8F,0x7D,0x03,0x1B,0x76,0x52,0x62,0x2D,0xF5,0x21,0xF6,0x7C,0xBC,0xA1,0x19,0x30,
964 0x17,0x31,0x15,0x30,0x13,0x06,0x03,0x55,0x04,0x03,0x13,0x0C,0x54,0x65,0x73,0x74,0x20,0x43,0x41,0x20,0x52,0x6F,0x6F,0x74,
965 0x82,0x10,0xA0,0x4B,0xEB,0xAC,0xFA,0x08,0xF2,0x8B,0x47,0xD2,0xB3,0x54,0x60,0x6C,0xE6,0x29,0x30,0x0D,0x06,0x09,0x2A,0x86,
966 0x48,0x86,0xF7,0x0D,0x01,0x01,0x0B,0x05,0x00,0x03,0x82,0x01,0x01,0x00,0x5F,0x8C,0x7F,0xDA,0x1D,0x21,0x7A,0x15,0xD8,0x20,
967 0x04,0x53,0x7F,0x44,0x6D,0x7B,0x57,0xBE,0x7F,0x86,0x77,0x58,0xC4,0xD4,0x80,0xC7,0x2E,0x64,0x9B,0x44,0xC5,0x2D,0x6D,0xDB,
968 0x35,0x5A,0xFE,0xA4,0xD8,0x66,0x9B,0xF7,0x6E,0xFC,0xEF,0x52,0x7B,0xC5,0x16,0xE6,0xA3,0x7D,0x59,0xB7,0x31,0x28,0xEB,0xB5,
969 0x45,0xC9,0xB1,0xD1,0x08,0x67,0xC6,0x37,0xE7,0xD7,0x2A,0xE6,0x1F,0xD9,0x6A,0xE5,0x04,0xDF,0x6A,0x9D,0x91,0xFA,0x41,0xBD,
970 0x2A,0x50,0xEA,0x99,0x24,0xA9,0x0F,0x2B,0x50,0x51,0x5F,0xD9,0x0B,0x89,0x1B,0xCB,0xDB,0x88,0xE8,0xEC,0x87,0xB0,0x16,0xCC,
971 0x43,0xEE,0x5A,0xBD,0x57,0xE2,0x46,0xA7,0x56,0x54,0x23,0x32,0x8A,0xFB,0x25,0x51,0x39,0x38,0xE6,0x87,0xF5,0x73,0x63,0xD0,
972 0x5B,0xC7,0x3F,0xFD,0x04,0x75,0x74,0x4C,0x3D,0xB5,0x31,0x22,0x7D,0xF1,0x8D,0xB4,0xE0,0xAA,0xE1,0xFF,0x8F,0xDD,0xB8,0x04,
973 0x6A,0x31,0xEE,0x30,0x2D,0x6E,0x74,0x0F,0x37,0x71,0x77,0x2B,0xB8,0x9E,0x62,0x47,0x00,0x9C,0xA5,0x82,0x2B,0x9F,0x24,0x67,
974 0x50,0x86,0x8B,0xC9,0x36,0x81,0xEB,0x44,0xC2,0xF1,0x91,0xA6,0x84,0x75,0x15,0x8F,0x22,0xDE,0xAC,0xB5,0x16,0xE3,0x96,0x74,
975 0x72,0x2F,0x15,0xD5,0xFB,0x01,0x22,0xC4,0x24,0xEE,0x3D,0xDF,0x9E,0xA9,0x0A,0x5B,0x16,0x21,0xE8,0x4A,0x8C,0x7E,0x3A,0x9C,
976 0x22,0xA0,0x49,0x60,0x97,0x1B,0x3E,0x2D,0x80,0x91,0xDB,0xF7,0x78,0x38,0x76,0x78,0x0C,0xE3,0xD4,0x27,0x77,0x69,0x96,0xE6,
977 0x41,0xC7,0x2E,0xE9,0x61,0xD6,0x31,0x82,0x01,0xC4,0x30,0x82,0x01,0xC0,0x02,0x01,0x01,0x30,0x2B,0x30,0x17,0x31,0x15,0x30,
978 0x13,0x06,0x03,0x55,0x04,0x03,0x13,0x0C,0x54,0x65,0x73,0x74,0x20,0x43,0x41,0x20,0x52,0x6F,0x6F,0x74,0x02,0x10,0x96,0x53,
979 0x2C,0xC9,0x23,0x56,0x8A,0x87,0x42,0x30,0x3E,0xD5,0x8D,0x72,0xD5,0x25,0x30,0x09,0x06,0x05,0x2B,0x0E,0x03,0x02,0x1A,0x05,
980 0x00,0xA0,0x70,0x30,0x10,0x06,0x0A,0x2B,0x06,0x01,0x04,0x01,0x82,0x37,0x02,0x01,0x0C,0x31,0x02,0x30,0x00,0x30,0x19,0x06,
981 0x09,0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x03,0x31,0x0C,0x06,0x0A,0x2B,0x06,0x01,0x04,0x01,0x82,0x37,0x02,0x01,0x04,
982 0x30,0x1C,0x06,0x0A,0x2B,0x06,0x01,0x04,0x01,0x82,0x37,0x02,0x01,0x0B,0x31,0x0E,0x30,0x0C,0x06,0x0A,0x2B,0x06,0x01,0x04,
983 0x01,0x82,0x37,0x02,0x01,0x15,0x30,0x23,0x06,0x09,0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x04,0x31,0x16,0x04,0x14,0x3D,
984 0x08,0xC8,0xA3,0xEE,0x05,0x1A,0x61,0xD9,0xFE,0x1A,0x63,0xC0,0x8A,0x6E,0x9D,0xF9,0xC3,0x13,0x98,0x30,0x0D,0x06,0x09,0x2A,
985 0x86,0x48,0x86,0xF7,0x0D,0x01,0x01,0x01,0x05,0x00,0x04,0x82,0x01,0x00,0x90,0xF9,0xC0,0x7F,0x1D,0x70,0x8C,0x04,0x22,0x82,
986 0xB6,0x2D,0x48,0xBF,0x30,0x51,0x29,0xF8,0xE3,0x11,0x39,0xE0,0x64,0x23,0x72,0xE2,0x4C,0x09,0x9F,0x39,0xF2,0x6F,0xDD,0xB9,
987 0x5A,0x3D,0xEF,0xEB,0xBE,0xEC,0x3B,0xE6,0x58,0x4C,0xC9,0x4F,0xED,0xCB,0x6E,0x9D,0x67,0x8E,0x89,0x92,0x40,0x39,0xA2,0x5F,
988 0xF9,0xEF,0xD3,0xF5,0x24,0x27,0x8D,0xF7,0x3C,0x92,0x66,0x56,0xC8,0x2B,0xEA,0x04,0xA1,0x0E,0xDA,0x89,0x30,0xA7,0x01,0xD8,
989 0x0B,0xF8,0xFD,0x99,0xB6,0xC0,0x38,0xB0,0x21,0x50,0x3A,0x86,0x01,0xD0,0xF3,0x86,0x72,0xE3,0x5A,0xBB,0x2A,0x6E,0xBD,0xFB,
990 0x22,0xF9,0x42,0xD3,0x04,0xFE,0x8D,0xD8,0x79,0xD1,0xEE,0x61,0xC6,0x48,0x04,0x99,0x9A,0xA2,0x73,0xE5,0xFB,0x24,0x10,0xD5,
991 0x6B,0x71,0x80,0x0E,0x09,0xEA,0x85,0x9A,0xBD,0xBB,0xDE,0x99,0x5D,0xA3,0x18,0x4D,0xED,0x20,0x73,0x3E,0x32,0xEF,0x2C,0xAC,
992 0x5A,0x83,0x87,0x1F,0x7F,0x19,0x61,0x35,0x53,0xC1,0xAA,0x89,0x97,0xB3,0xDD,0x8D,0xA8,0x67,0x5B,0xC2,0xE2,0x09,0xB7,0xDD,
993 0x6A,0xCB,0xD5,0xBF,0xD6,0x08,0xE2,0x23,0x1A,0x41,0x9D,0xD5,0x6A,0x6B,0x8D,0x3C,0x29,0x1B,0xF1,0x3F,0x4E,0x4A,0x8F,0x29,
994 0x33,0xF9,0x1C,0x60,0xA0,0x92,0x7E,0x4F,0x35,0xB8,0xDD,0xEB,0xD1,0x68,0x1A,0x9D,0xA2,0xA6,0x97,0x1F,0x5F,0xC6,0x2C,0xFB,
995 0xCA,0xDF,0xF7,0x95,0x33,0x95,0xD4,0x79,0x5C,0x73,0x87,0x49,0x1F,0x8C,0x6E,0xCE,0x3E,0x6D,0x3D,0x2B,0x6B,0xD7,0x66,0xE9,
996 0x88,0x6F,0xF2,0x83,0xB9,0x9B,0x00,0x00
999 static const BYTE SelfSignedFile64[] =
1001 0x4D,0x5A,0x90,0x00,0x03,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0xFF,0xFF,0x00,0x00,0xB8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
1002 0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
1003 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x00,0x00,0x00,0x0E,0x1F,0xBA,0x0E,0x00,0xB4,0x09,0xCD,
1004 0x21,0xB8,0x01,0x4C,0xCD,0x21,0x54,0x68,0x69,0x73,0x20,0x70,0x72,0x6F,0x67,0x72,0x61,0x6D,0x20,0x63,0x61,0x6E,0x6E,0x6F,
1005 0x74,0x20,0x62,0x65,0x20,0x72,0x75,0x6E,0x20,0x69,0x6E,0x20,0x44,0x4F,0x53,0x20,0x6D,0x6F,0x64,0x65,0x2E,0x0D,0x0D,0x0A,
1006 0x24,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x50,0x45,0x00,0x00,0x64,0x86,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
1007 0x00,0x00,0x00,0x00,0xF0,0x00,0x2F,0x02,0x0B,0x02,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
1008 0x00,0x10,0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x00,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x02,0x00,0x00,
1009 0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x00,0x00,0x00,0x02,0x00,0x00,
1010 0x02,0xB9,0x00,0x00,0x03,0x00,0x00,0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x00,0x00,0x00,
1011 0x00,0x00,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x00,0x00,0x00,
1012 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
1013 0x00,0x20,0x00,0x00,0x0C,0x00,0x00,0x00,0x00,0x06,0x00,0x00,0x68,0x05,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
1014 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
1015 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,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,0x2E,0x74,0x65,0x78,0x74,0x00,0x00,0x00,0x20,0x00,0x00,0x00,0x00,0x10,0x00,0x00,
1018 0x00,0x02,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x00,0x00,0x60,
1019 0x2E,0x70,0x64,0x61,0x74,0x61,0x00,0x00,0x0C,0x00,0x00,0x00,0x00,0x20,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x04,0x00,0x00,
1020 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x40,0x00,0x00,0x40,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,0x55,0x48,0x89,0xE5,0x48,0x81,0xEC,0x00,0x00,0x00,0x00,0xB8,0x00,0x00,0x00,0x00,
1023 0xE9,0x00,0x00,0x00,0x00,0xC9,0xC3,0x00,0x01,0x04,0x02,0x05,0x04,0x03,0x01,0x50,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,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
1036 0x00,0x00,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,0x0B,0x10,0x00,0x00,0x17,0x10,0x00,0x00,
1044 0x18,0x10,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 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
1058 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
1059 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
1060 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
1061 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
1062 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
1063 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
1064 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
1065 /* Start of the signature overlay */
1066 0x68,0x05,0x00,0x00,0x00,0x02,0x02,0x00,0x30,0x82,0x05,0x5A,0x06,0x09,0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x07,0x02,0xA0,
1067 0x82,0x05,0x4B,0x30,0x82,0x05,0x47,0x02,0x01,0x01,0x31,0x0B,0x30,0x09,0x06,0x05,0x2B,0x0E,0x03,0x02,0x1A,0x05,0x00,0x30,
1068 0x4C,0x06,0x0A,0x2B,0x06,0x01,0x04,0x01,0x82,0x37,0x02,0x01,0x04,0xA0,0x3E,0x30,0x3C,0x30,0x17,0x06,0x0A,0x2B,0x06,0x01,
1069 0x04,0x01,0x82,0x37,0x02,0x01,0x0F,0x30,0x09,0x03,0x01,0x00,0xA0,0x04,0xA2,0x02,0x80,0x00,0x30,0x21,0x30,0x09,0x06,0x05,
1070 0x2B,0x0E,0x03,0x02,0x1A,0x05,0x00,0x04,0x14,0xCA,0x7C,0x10,0xFB,0x5A,0x96,0x6D,0x69,0xEF,0x26,0x30,0x1A,0xE9,0xC7,0x22,
1071 0x19,0xEB,0x6E,0x17,0x07,0xA0,0x82,0x03,0x1D,0x30,0x82,0x03,0x19,0x30,0x82,0x02,0x01,0xA0,0x03,0x02,0x01,0x02,0x02,0x10,
1072 0x96,0x53,0x2C,0xC9,0x23,0x56,0x8A,0x87,0x42,0x30,0x3E,0xD5,0x8D,0x72,0xD5,0x25,0x30,0x0D,0x06,0x09,0x2A,0x86,0x48,0x86,
1073 0xF7,0x0D,0x01,0x01,0x0B,0x05,0x00,0x30,0x17,0x31,0x15,0x30,0x13,0x06,0x03,0x55,0x04,0x03,0x13,0x0C,0x54,0x65,0x73,0x74,
1074 0x20,0x43,0x41,0x20,0x52,0x6F,0x6F,0x74,0x30,0x1E,0x17,0x0D,0x31,0x36,0x30,0x33,0x30,0x33,0x32,0x30,0x32,0x37,0x30,0x37,
1075 0x5A,0x17,0x0D,0x34,0x39,0x31,0x32,0x33,0x31,0x32,0x33,0x30,0x30,0x30,0x30,0x5A,0x30,0x17,0x31,0x15,0x30,0x13,0x06,0x03,
1076 0x55,0x04,0x03,0x13,0x0C,0x43,0x6F,0x64,0x65,0x53,0x69,0x67,0x6E,0x54,0x65,0x73,0x74,0x30,0x82,0x01,0x22,0x30,0x0D,0x06,
1077 0x09,0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x01,0x01,0x05,0x00,0x03,0x82,0x01,0x0F,0x00,0x30,0x82,0x01,0x0A,0x02,0x82,0x01,
1078 0x01,0x00,0xB2,0xC9,0x91,0x98,0x8C,0xDC,0x80,0xBC,0x16,0xBF,0xC1,0x04,0x77,0x90,0xC0,0xFD,0x8C,0xBA,0x68,0x26,0xAC,0xB7,
1079 0x20,0x68,0x41,0xED,0xC3,0x9C,0x47,0x7C,0x36,0xC2,0x7B,0xE1,0x5E,0xFD,0xA9,0x99,0xF4,0x29,0x36,0x86,0x93,0x40,0x55,0x53,
1080 0x65,0x79,0xBC,0x9F,0x8F,0x6E,0x2B,0x05,0x84,0xE1,0xFD,0xD2,0xEF,0xEA,0x89,0x8C,0xEC,0xF9,0x55,0xF0,0x2C,0xE5,0xA7,0x29,
1081 0xF9,0x7E,0x50,0xDC,0x9C,0xA1,0x23,0xA5,0xD9,0x78,0xA1,0xE7,0x7C,0xD7,0x04,0x4F,0x11,0xAC,0x9F,0x4A,0x47,0xA1,0x1E,0xD5,
1082 0x9E,0xE7,0x5B,0xB5,0x8C,0x9C,0x67,0x7A,0xD0,0xF8,0x54,0xD1,0x64,0x7F,0x39,0x48,0xB6,0xCF,0x2F,0x26,0x7D,0x7B,0x13,0x2B,
1083 0xC2,0x8F,0xA6,0x3F,0x42,0x71,0x95,0x3E,0x59,0x0F,0x12,0xFA,0xC2,0x70,0x89,0xB7,0xB6,0x10,0x49,0xE0,0x7D,0x4D,0xFC,0x80,
1084 0x61,0x53,0x50,0x72,0xFD,0x46,0x35,0x51,0x36,0xE6,0x06,0xA9,0x4C,0x0D,0x82,0x15,0xF6,0x5D,0xDE,0xD4,0xDB,0xE7,0x82,0x10,
1085 0x40,0xA1,0x47,0x68,0x88,0x0C,0x0A,0x80,0xD1,0xE5,0x9A,0x35,0x28,0x82,0x1F,0x0F,0x80,0x5A,0x6E,0x1D,0x22,0x22,0xB3,0xA7,
1086 0xA2,0x9E,0x82,0x2D,0xC0,0x7F,0x5A,0xD0,0xBA,0xB2,0xCA,0x20,0xE2,0x97,0xE9,0x72,0x41,0xB7,0xD6,0x1A,0x93,0x23,0x97,0xF0,
1087 0xA9,0x61,0xD2,0x91,0xBD,0xB6,0x6B,0x95,0x12,0x67,0x16,0xAC,0x0A,0xB7,0x55,0x02,0x0D,0xA5,0xAD,0x17,0x95,0x77,0xF9,0x96,
1088 0x03,0x41,0xD3,0xE1,0x61,0x68,0xBB,0x0A,0xB5,0xC4,0xEE,0x70,0x40,0x08,0x05,0xC4,0xF1,0x5D,0x02,0x03,0x01,0x00,0x01,0xA3,
1089 0x61,0x30,0x5F,0x30,0x13,0x06,0x03,0x55,0x1D,0x25,0x04,0x0C,0x30,0x0A,0x06,0x08,0x2B,0x06,0x01,0x05,0x05,0x07,0x03,0x03,
1090 0x30,0x48,0x06,0x03,0x55,0x1D,0x01,0x04,0x41,0x30,0x3F,0x80,0x10,0x35,0x40,0x67,0x8F,0x7D,0x03,0x1B,0x76,0x52,0x62,0x2D,
1091 0xF5,0x21,0xF6,0x7C,0xBC,0xA1,0x19,0x30,0x17,0x31,0x15,0x30,0x13,0x06,0x03,0x55,0x04,0x03,0x13,0x0C,0x54,0x65,0x73,0x74,
1092 0x20,0x43,0x41,0x20,0x52,0x6F,0x6F,0x74,0x82,0x10,0xA0,0x4B,0xEB,0xAC,0xFA,0x08,0xF2,0x8B,0x47,0xD2,0xB3,0x54,0x60,0x6C,
1093 0xE6,0x29,0x30,0x0D,0x06,0x09,0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x01,0x0B,0x05,0x00,0x03,0x82,0x01,0x01,0x00,0x5F,0x8C,
1094 0x7F,0xDA,0x1D,0x21,0x7A,0x15,0xD8,0x20,0x04,0x53,0x7F,0x44,0x6D,0x7B,0x57,0xBE,0x7F,0x86,0x77,0x58,0xC4,0xD4,0x80,0xC7,
1095 0x2E,0x64,0x9B,0x44,0xC5,0x2D,0x6D,0xDB,0x35,0x5A,0xFE,0xA4,0xD8,0x66,0x9B,0xF7,0x6E,0xFC,0xEF,0x52,0x7B,0xC5,0x16,0xE6,
1096 0xA3,0x7D,0x59,0xB7,0x31,0x28,0xEB,0xB5,0x45,0xC9,0xB1,0xD1,0x08,0x67,0xC6,0x37,0xE7,0xD7,0x2A,0xE6,0x1F,0xD9,0x6A,0xE5,
1097 0x04,0xDF,0x6A,0x9D,0x91,0xFA,0x41,0xBD,0x2A,0x50,0xEA,0x99,0x24,0xA9,0x0F,0x2B,0x50,0x51,0x5F,0xD9,0x0B,0x89,0x1B,0xCB,
1098 0xDB,0x88,0xE8,0xEC,0x87,0xB0,0x16,0xCC,0x43,0xEE,0x5A,0xBD,0x57,0xE2,0x46,0xA7,0x56,0x54,0x23,0x32,0x8A,0xFB,0x25,0x51,
1099 0x39,0x38,0xE6,0x87,0xF5,0x73,0x63,0xD0,0x5B,0xC7,0x3F,0xFD,0x04,0x75,0x74,0x4C,0x3D,0xB5,0x31,0x22,0x7D,0xF1,0x8D,0xB4,
1100 0xE0,0xAA,0xE1,0xFF,0x8F,0xDD,0xB8,0x04,0x6A,0x31,0xEE,0x30,0x2D,0x6E,0x74,0x0F,0x37,0x71,0x77,0x2B,0xB8,0x9E,0x62,0x47,
1101 0x00,0x9C,0xA5,0x82,0x2B,0x9F,0x24,0x67,0x50,0x86,0x8B,0xC9,0x36,0x81,0xEB,0x44,0xC2,0xF1,0x91,0xA6,0x84,0x75,0x15,0x8F,
1102 0x22,0xDE,0xAC,0xB5,0x16,0xE3,0x96,0x74,0x72,0x2F,0x15,0xD5,0xFB,0x01,0x22,0xC4,0x24,0xEE,0x3D,0xDF,0x9E,0xA9,0x0A,0x5B,
1103 0x16,0x21,0xE8,0x4A,0x8C,0x7E,0x3A,0x9C,0x22,0xA0,0x49,0x60,0x97,0x1B,0x3E,0x2D,0x80,0x91,0xDB,0xF7,0x78,0x38,0x76,0x78,
1104 0x0C,0xE3,0xD4,0x27,0x77,0x69,0x96,0xE6,0x41,0xC7,0x2E,0xE9,0x61,0xD6,0x31,0x82,0x01,0xC4,0x30,0x82,0x01,0xC0,0x02,0x01,
1105 0x01,0x30,0x2B,0x30,0x17,0x31,0x15,0x30,0x13,0x06,0x03,0x55,0x04,0x03,0x13,0x0C,0x54,0x65,0x73,0x74,0x20,0x43,0x41,0x20,
1106 0x52,0x6F,0x6F,0x74,0x02,0x10,0x96,0x53,0x2C,0xC9,0x23,0x56,0x8A,0x87,0x42,0x30,0x3E,0xD5,0x8D,0x72,0xD5,0x25,0x30,0x09,
1107 0x06,0x05,0x2B,0x0E,0x03,0x02,0x1A,0x05,0x00,0xA0,0x70,0x30,0x10,0x06,0x0A,0x2B,0x06,0x01,0x04,0x01,0x82,0x37,0x02,0x01,
1108 0x0C,0x31,0x02,0x30,0x00,0x30,0x19,0x06,0x09,0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x03,0x31,0x0C,0x06,0x0A,0x2B,0x06,
1109 0x01,0x04,0x01,0x82,0x37,0x02,0x01,0x04,0x30,0x1C,0x06,0x0A,0x2B,0x06,0x01,0x04,0x01,0x82,0x37,0x02,0x01,0x0B,0x31,0x0E,
1110 0x30,0x0C,0x06,0x0A,0x2B,0x06,0x01,0x04,0x01,0x82,0x37,0x02,0x01,0x15,0x30,0x23,0x06,0x09,0x2A,0x86,0x48,0x86,0xF7,0x0D,
1111 0x01,0x09,0x04,0x31,0x16,0x04,0x14,0x0C,0xEC,0x76,0xF2,0x3F,0xE4,0x6F,0xEB,0xFF,0x00,0xDA,0x95,0xE7,0x8B,0x64,0xBC,0x55,
1112 0xBA,0xF0,0xEA,0x30,0x0D,0x06,0x09,0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x01,0x01,0x05,0x00,0x04,0x82,0x01,0x00,0x05,0x22,
1113 0xD1,0xB3,0x85,0x09,0x46,0x99,0x77,0x69,0xC8,0xD2,0x0C,0xFC,0x8D,0xF4,0x01,0xD4,0x5B,0xF0,0xB4,0x13,0x63,0xAF,0x24,0x0E,
1114 0x6C,0x1B,0x14,0xCF,0xA8,0x9A,0xEC,0x7E,0xF2,0x60,0xED,0x6C,0x39,0x4D,0x7A,0x73,0x9C,0x9F,0x24,0x46,0xE2,0xEA,0xFA,0x70,
1115 0xB4,0xAC,0xFC,0x38,0x90,0xF2,0x4F,0x70,0xCC,0x00,0xD1,0x2B,0xB6,0xFB,0xCD,0x7F,0xFC,0xCB,0x35,0xA9,0xA6,0x76,0x37,0xD6,
1116 0x08,0x82,0x99,0x4C,0x47,0xD7,0x4E,0xB5,0xDE,0xCA,0x4E,0xED,0x71,0x48,0xD4,0x84,0xE1,0x30,0x10,0x33,0x7F,0x84,0xEE,0x2F,
1117 0x44,0x99,0xE4,0x26,0x27,0xB5,0xB8,0xC1,0xA1,0x40,0x6B,0x87,0x04,0x95,0xC3,0xF0,0xFF,0x25,0x97,0xFD,0xDB,0x9C,0x67,0x80,
1118 0x39,0x97,0x72,0x75,0x07,0x92,0xA5,0x08,0x19,0x5B,0xD3,0xC9,0x5E,0xC4,0x7B,0xA9,0x04,0x02,0x63,0xCC,0xC5,0x92,0xF6,0xE9,
1119 0xD6,0xB0,0xA8,0xF9,0xD0,0x9F,0x3F,0xBC,0x86,0x77,0x1E,0x12,0x9A,0x9A,0x9B,0x05,0x77,0x39,0x42,0x01,0xB7,0x23,0xF0,0x78,
1120 0x4F,0x52,0x6D,0x1B,0x9F,0xBA,0x29,0xEC,0x90,0xA9,0x1E,0x1E,0x5C,0xA9,0x28,0xA0,0x0B,0x09,0xDC,0x99,0x82,0xE3,0x34,0xBB,
1121 0x5C,0x66,0x8E,0x54,0x95,0x4B,0x65,0x95,0xCD,0x87,0x72,0x74,0xCD,0x3B,0x5C,0x72,0xBB,0x61,0x6A,0x98,0x44,0x9C,0xB0,0x2A,
1122 0xE7,0xB0,0xA6,0x2B,0xDA,0x47,0x5C,0x75,0x36,0xB5,0x90,0x8E,0x82,0x47,0xCD,0x3F,0x4B,0xD0,0xFB,0x8E,0x17,0x6B,0x40,0x57,
1123 0x9C,0x68,0x1A,0x5D,0x92,0xCD,0xD0,0x5F,0x02,0xA1,0x2C,0xD9,0x56,0x20,0x00,0x00
1126 static void call_winverify(WCHAR *pathW, LONG *status, BOOL hash_only)
1128 static GUID WVTPolicyGUID = WINTRUST_ACTION_GENERIC_VERIFY_V2;
1129 WINTRUST_FILE_INFO file_info = { sizeof(file_info), 0 };
1130 WINTRUST_DATA data = { sizeof(data), 0 };
1131 LONG ret;
1133 file_info.pcwszFilePath = pathW;
1135 data.dwUIChoice = WTD_UI_NONE;
1136 data.fdwRevocationChecks = WTD_REVOKE_NONE;
1137 data.dwUnionChoice = WTD_CHOICE_FILE;
1138 data.pFile = &file_info;
1139 data.dwStateAction = WTD_STATEACTION_VERIFY;
1140 data.dwProvFlags = hash_only ? WTD_HASH_ONLY_FLAG : 0;
1141 *status = WinVerifyTrust(NULL, &WVTPolicyGUID, &data);
1143 data.dwStateAction = WTD_STATEACTION_CLOSE;
1144 ret = WinVerifyTrust(NULL, &WVTPolicyGUID, &data);
1145 ok(ret == S_OK, "WinVerifyTrust failed: %08x\n", ret);
1148 static void test_wintrust_digest(void)
1150 static const BYTE Dummy[] = { 0x11,0x22,0x33,0x44 };
1151 static const struct
1153 struct { const BYTE *data; DWORD length; } blocks[5];
1154 struct { LONG status; BOOL todo; } t1;
1155 struct { LONG status; BOOL todo; } t2;
1157 tests[] =
1159 /* 32-bit tests */
1161 {{ SelfSignedFile32, sizeof(SelfSignedFile32) }},
1162 { CERT_E_CHAINING, TRUE }, { S_OK, FALSE }
1165 {{ SelfSignedFile32, sizeof(SelfSignedFile32) },
1166 { Dummy, sizeof(Dummy) }},
1167 { TRUST_E_NOSIGNATURE, FALSE }, { TRUST_E_NOSIGNATURE, FALSE }
1170 {{ Dummy, sizeof(Dummy) },
1171 { SelfSignedFile32 + sizeof(Dummy), sizeof(SelfSignedFile32) - sizeof(Dummy) }},
1172 { TRUST_E_SUBJECT_FORM_UNKNOWN, FALSE }, { TRUST_E_NOSIGNATURE, TRUE }
1175 {{ SelfSignedFile32, 19 },
1176 { Dummy, sizeof(Dummy) },
1177 { SelfSignedFile32 + 19 + sizeof(Dummy), sizeof(SelfSignedFile32) - 19 - sizeof(Dummy) }},
1178 { TRUST_E_BAD_DIGEST, FALSE }, { TRUST_E_NOSIGNATURE, TRUE }
1181 {{ SelfSignedFile32, sizeof(IMAGE_DOS_HEADER) }},
1182 { TRUST_E_SUBJECT_FORM_UNKNOWN, TRUE }, { TRUST_E_NOSIGNATURE, FALSE }
1185 {{ SelfSignedFile32, sizeof(IMAGE_DOS_HEADER) + sizeof(IMAGE_NT_HEADERS32) * 2 }},
1186 { TRUST_E_NOSIGNATURE, FALSE }, { TRUST_E_NOSIGNATURE, FALSE }
1189 /* 64-bit tests */
1191 {{ SelfSignedFile64, sizeof(SelfSignedFile64) }},
1192 { CERT_E_CHAINING, TRUE }, { S_OK, FALSE }
1195 {{ SelfSignedFile64, sizeof(SelfSignedFile64) },
1196 { Dummy, sizeof(Dummy) }},
1197 { TRUST_E_NOSIGNATURE, FALSE }, { TRUST_E_NOSIGNATURE, FALSE }
1200 {{ Dummy, sizeof(Dummy) },
1201 { SelfSignedFile64 + sizeof(Dummy), sizeof(SelfSignedFile64) - sizeof(Dummy) }},
1202 { TRUST_E_SUBJECT_FORM_UNKNOWN, FALSE }, { TRUST_E_NOSIGNATURE, TRUE }
1205 {{ SelfSignedFile64, 19 },
1206 { Dummy, sizeof(Dummy) },
1207 { SelfSignedFile64 + 19 + sizeof(Dummy), sizeof(SelfSignedFile64) - 19 - sizeof(Dummy) }},
1208 { TRUST_E_BAD_DIGEST, FALSE }, { TRUST_E_NOSIGNATURE, TRUE }
1211 {{ SelfSignedFile64, sizeof(IMAGE_DOS_HEADER) }},
1212 { TRUST_E_SUBJECT_FORM_UNKNOWN, TRUE }, { TRUST_E_NOSIGNATURE, FALSE }
1215 {{ SelfSignedFile64, sizeof(IMAGE_DOS_HEADER) + sizeof(IMAGE_NT_HEADERS64) * 2 }},
1216 { TRUST_E_NOSIGNATURE, FALSE }, { TRUST_E_NOSIGNATURE, FALSE }
1219 WCHAR pathW[MAX_PATH];
1220 DWORD written;
1221 HANDLE file;
1222 LONG status;
1223 BOOL ret;
1224 int i, j;
1226 for (i = 0; i < ARRAY_SIZE(tests); i++)
1228 file = create_temp_file(pathW);
1229 ok(file != INVALID_HANDLE_VALUE, "failed to create temporary file\n");
1231 for (j = 0; tests[i].blocks[j].data; j++)
1233 ret = WriteFile(file, tests[i].blocks[j].data, tests[i].blocks[j].length, &written, NULL);
1234 ok(ret && written == tests[i].blocks[j].length, "WriteFile failed with %u\n", GetLastError());
1237 CloseHandle(file);
1239 call_winverify(pathW, &status, FALSE);
1240 todo_wine_if(tests[i].t1.todo)
1241 ok(status == tests[i].t1.status, "test %d/1: expected %08x, got %08x\n", i, tests[i].t1.status, status);
1243 call_winverify(pathW, &status, TRUE);
1244 todo_wine_if(tests[i].t2.todo)
1245 ok(status == tests[i].t2.status, "test %d/2: expected %08x, got %08x\n", i, tests[i].t2.status, status);
1247 DeleteFileW(pathW);
1251 static void test_get_known_usages(void)
1253 BOOL ret;
1254 PCCRYPT_OID_INFO *usages;
1256 if (!pWTHelperGetKnownUsages)
1258 skip("missing WTHelperGetKnownUsages\n");
1259 return;
1261 SetLastError(0xdeadbeef);
1262 ret = pWTHelperGetKnownUsages(0, NULL);
1263 ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER,
1264 "expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
1265 SetLastError(0xdeadbeef);
1266 ret = pWTHelperGetKnownUsages(1, NULL);
1267 ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER,
1268 "expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
1269 SetLastError(0xdeadbeef);
1270 ret = pWTHelperGetKnownUsages(0, &usages);
1271 ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER,
1272 "expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
1273 /* A value of 1 for the first parameter seems to imply the value is
1274 * allocated
1276 SetLastError(0xdeadbeef);
1277 usages = NULL;
1278 ret = pWTHelperGetKnownUsages(1, &usages);
1279 ok(ret, "WTHelperGetKnownUsages failed: %d\n", GetLastError());
1280 ok(usages != NULL, "expected a pointer\n");
1281 if (ret && usages)
1283 PCCRYPT_OID_INFO *ptr;
1285 /* The returned usages are an array of PCCRYPT_OID_INFOs, terminated with a
1286 * NULL pointer.
1288 for (ptr = usages; *ptr; ptr++)
1290 ok((*ptr)->cbSize == sizeof(CRYPT_OID_INFO) ||
1291 (*ptr)->cbSize == (sizeof(CRYPT_OID_INFO) + 2 * sizeof(LPCWSTR)), /* Vista */
1292 "unexpected size %d\n", (*ptr)->cbSize);
1293 /* Each returned usage is in the CRYPT_ENHKEY_USAGE_OID_GROUP_ID group */
1294 ok((*ptr)->dwGroupId == CRYPT_ENHKEY_USAGE_OID_GROUP_ID,
1295 "expected group CRYPT_ENHKEY_USAGE_OID_GROUP_ID, got %d\n",
1296 (*ptr)->dwGroupId);
1299 /* A value of 2 for the second parameter seems to imply the value is freed
1301 SetLastError(0xdeadbeef);
1302 ret = pWTHelperGetKnownUsages(2, &usages);
1303 ok(ret, "WTHelperGetKnownUsages failed: %d\n", GetLastError());
1304 ok(usages == NULL, "expected pointer to be cleared\n");
1305 SetLastError(0xdeadbeef);
1306 usages = NULL;
1307 ret = pWTHelperGetKnownUsages(2, &usages);
1308 ok(ret, "WTHelperGetKnownUsages failed: %d\n", GetLastError());
1309 SetLastError(0xdeadbeef);
1310 ret = pWTHelperGetKnownUsages(2, NULL);
1311 ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER,
1312 "expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
1315 START_TEST(softpub)
1317 InitFunctionPtrs();
1318 test_provider_funcs();
1319 test_sip_create_indirect_data();
1320 test_wintrust();
1321 test_wintrust_digest();
1322 test_get_known_usages();