ReactOS 0.4.15-dev-7842-g558ab78
crypt.c
Go to the documentation of this file.
1/* Unit test suite for wintrust crypt functions
2 *
3 * Copyright 2007 Paul Vriens
4 * Copyright 2008 Hans Leidekker for CodeWeavers
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 *
20 */
21
22#include <stdarg.h>
23#include <stdio.h>
24
25#include "windows.h"
26#include "wincrypt.h"
27#include "mscat.h"
28
29#include "wine/test.h"
30
31static char selfname[MAX_PATH];
35
36static const WCHAR hashmeW[] = {'h','a','s','h','m','e',0};
37static const WCHAR attr1W[] = {'a','t','t','r','1',0};
38static const WCHAR attr2W[] = {'a','t','t','r','2',0};
39
40/*
41 * Minimalistic catalog file. To reconstruct, save text below as winetest.cdf,
42 * convert to DOS line endings and run 'makecat /cat winetest.cdf'
43 */
44
45/*
46[CatalogHeader]
47Name=winetest.cat
48ResultDir=.\
49PublicVersion=0x00000001
50EncodingType=
51CATATTR1=0x10010001:attr1:value1
52CATATTR2=0x10010001:attr2:value2
53
54[CatalogFiles]
55hashme=.\winetest.cdf
56*/
57
58static const CHAR test_cdf[] =
59 "[CatalogHeader]\r\n"
60 "Name=winetest.cat\r\n"
61 "ResultDir=.\\\r\n"
62 "PublicVersion=0x00000001\r\n"
63 "EncodingType=\r\n"
64 "CATATTR1=0x10010001:attr1:value1\r\n"
65 "CATATTR2=0x10010001:attr2:value2\r\n"
66 "\r\n"
67 "[CatalogFiles]\r\n"
68 "hashme=.\\winetest.cdf\r\n";
69
70static const BYTE test_catalog[] = {
71 0x30, 0x82, 0x01, 0xbc, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x07, 0x02, 0xa0,
72 0x82, 0x01, 0xad, 0x30, 0x82, 0x01, 0xa9, 0x02, 0x01, 0x01, 0x31, 0x00, 0x30, 0x82, 0x01, 0x9e,
73 0x06, 0x09, 0x2b, 0x06, 0x01, 0x04, 0x01, 0x82, 0x37, 0x0a, 0x01, 0xa0, 0x82, 0x01, 0x8f, 0x30,
74 0x82, 0x01, 0x8b, 0x30, 0x0c, 0x06, 0x0a, 0x2b, 0x06, 0x01, 0x04, 0x01, 0x82, 0x37, 0x0c, 0x01,
75 0x01, 0x04, 0x10, 0xfa, 0x55, 0x2c, 0xc2, 0xf6, 0xcc, 0xdd, 0x11, 0x2a, 0x9c, 0x00, 0x14, 0x22,
76 0xec, 0x8f, 0x3b, 0x17, 0x0d, 0x30, 0x38, 0x31, 0x32, 0x31, 0x38, 0x31, 0x31, 0x32, 0x36, 0x34,
77 0x38, 0x5a, 0x30, 0x0e, 0x06, 0x0a, 0x2b, 0x06, 0x01, 0x04, 0x01, 0x82, 0x37, 0x0c, 0x01, 0x02,
78 0x05, 0x00, 0x30, 0x81, 0xdd, 0x30, 0x81, 0xda, 0x04, 0x0e, 0x68, 0x00, 0x61, 0x00, 0x73, 0x00,
79 0x68, 0x00, 0x6d, 0x00, 0x65, 0x00, 0x00, 0x00, 0x31, 0x81, 0xc7, 0x30, 0x61, 0x06, 0x0a, 0x2b,
80 0x06, 0x01, 0x04, 0x01, 0x82, 0x37, 0x02, 0x01, 0x04, 0x31, 0x53, 0x30, 0x51, 0x30, 0x2c, 0x06,
81 0x0a, 0x2b, 0x06, 0x01, 0x04, 0x01, 0x82, 0x37, 0x02, 0x01, 0x19, 0xa2, 0x1e, 0x80, 0x1c, 0x00,
82 0x3c, 0x00, 0x3c, 0x00, 0x3c, 0x00, 0x4f, 0x00, 0x62, 0x00, 0x73, 0x00, 0x6f, 0x00, 0x6c, 0x00,
83 0x65, 0x00, 0x74, 0x00, 0x65, 0x00, 0x3e, 0x00, 0x3e, 0x00, 0x3e, 0x30, 0x21, 0x30, 0x09, 0x06,
84 0x05, 0x2b, 0x0e, 0x03, 0x02, 0x1a, 0x05, 0x00, 0x04, 0x14, 0xed, 0xd6, 0x9c, 0x9c, 0xb2, 0xfc,
85 0xaa, 0x03, 0xe8, 0xd3, 0x20, 0xf6, 0xab, 0x28, 0xc3, 0xff, 0xbd, 0x07, 0x36, 0xf5, 0x30, 0x62,
86 0x06, 0x0a, 0x2b, 0x06, 0x01, 0x04, 0x01, 0x82, 0x37, 0x0c, 0x02, 0x02, 0x31, 0x54, 0x30, 0x52,
87 0x1e, 0x4c, 0x00, 0x7b, 0x00, 0x44, 0x00, 0x45, 0x00, 0x33, 0x00, 0x35, 0x00, 0x31, 0x00, 0x41,
88 0x00, 0x34, 0x00, 0x32, 0x00, 0x2d, 0x00, 0x38, 0x00, 0x45, 0x00, 0x35, 0x00, 0x39, 0x00, 0x2d,
89 0x00, 0x31, 0x00, 0x31, 0x00, 0x44, 0x00, 0x30, 0x00, 0x2d, 0x00, 0x38, 0x00, 0x43, 0x00, 0x34,
90 0x00, 0x37, 0x00, 0x2d, 0x00, 0x30, 0x00, 0x30, 0x00, 0x43, 0x00, 0x30, 0x00, 0x34, 0x00, 0x46,
91 0x00, 0x43, 0x00, 0x32, 0x00, 0x39, 0x00, 0x35, 0x00, 0x45, 0x00, 0x45, 0x00, 0x7d, 0x02, 0x02,
92 0x02, 0x00, 0xa0, 0x6a, 0x30, 0x68, 0x30, 0x32, 0x06, 0x0a, 0x2b, 0x06, 0x01, 0x04, 0x01, 0x82,
93 0x37, 0x0c, 0x02, 0x01, 0x04, 0x24, 0x30, 0x22, 0x1e, 0x0a, 0x00, 0x61, 0x00, 0x74, 0x00, 0x74,
94 0x00, 0x72, 0x00, 0x32, 0x02, 0x04, 0x10, 0x01, 0x00, 0x01, 0x04, 0x0e, 0x76, 0x00, 0x61, 0x00,
95 0x6c, 0x00, 0x75, 0x00, 0x65, 0x00, 0x32, 0x00, 0x00, 0x00, 0x30, 0x32, 0x06, 0x0a, 0x2b, 0x06,
96 0x01, 0x04, 0x01, 0x82, 0x37, 0x0c, 0x02, 0x01, 0x04, 0x24, 0x30, 0x22, 0x1e, 0x0a, 0x00, 0x61,
97 0x00, 0x74, 0x00, 0x74, 0x00, 0x72, 0x00, 0x31, 0x02, 0x04, 0x10, 0x01, 0x00, 0x01, 0x04, 0x0e,
98 0x76, 0x00, 0x61, 0x00, 0x6c, 0x00, 0x75, 0x00, 0x65, 0x00, 0x31, 0x00, 0x00, 0x00, 0x31, 0x00,
99};
100
101static BOOL (WINAPI * pCryptCATAdminAcquireContext)(HCATADMIN*, const GUID*, DWORD);
102static BOOL (WINAPI * pCryptCATAdminReleaseContext)(HCATADMIN, DWORD);
103static BOOL (WINAPI * pCryptCATAdminCalcHashFromFileHandle)(HANDLE hFile, DWORD*, BYTE*, DWORD);
104static HCATINFO (WINAPI * pCryptCATAdminAddCatalog)(HCATADMIN, PWSTR, PWSTR, DWORD);
105static BOOL (WINAPI * pCryptCATAdminRemoveCatalog)(HCATADMIN, LPCWSTR, DWORD);
106static BOOL (WINAPI * pCryptCATAdminReleaseCatalogContext)(HCATADMIN, HCATINFO, DWORD);
107static HANDLE (WINAPI * pCryptCATOpen)(LPWSTR, DWORD, HCRYPTPROV, DWORD, DWORD);
108static BOOL (WINAPI * pCryptCATCatalogInfoFromContext)(HCATINFO, CATALOG_INFO *, DWORD);
109static BOOL (WINAPI * pCryptCATCDFClose)(CRYPTCATCDF *);
112static LPWSTR (WINAPI * pCryptCATCDFEnumMembersByCDFTagEx)(CRYPTCATCDF *, LPWSTR, PFN_CDF_PARSE_ERROR_CALLBACK,
118static BOOL (WINAPI * pCryptCATClose)(HANDLE);
121
122static void InitFunctionPtrs(void)
123{
124 HMODULE hWintrust = GetModuleHandleA("wintrust.dll");
125
126#define WINTRUST_GET_PROC(func) \
127 p ## func = (void*)GetProcAddress(hWintrust, #func); \
128 if(!p ## func) { \
129 trace("GetProcAddress(%s) failed\n", #func); \
130 }
131
148
149#undef WINTRUST_GET_PROC
150
151 pGetSignedDataMsg = (void*)GetProcAddress(hWintrust, "CryptSIPGetSignedDataMsg");
153 trace("GetProcAddress(CryptSIPGetSignedDataMsg) failed\n");
154
155 pPutSignedDataMsg = (void*)GetProcAddress(hWintrust, "CryptSIPPutSignedDataMsg");
157 trace("GetProcAddress(CryptSIPPutSignedDataMsg) failed\n");
158}
159
160static GUID dummy = {0xdeadbeef,0xdead,0xbeef,{0xde,0xad,0xbe,0xef,0xde,0xad,0xbe,0xef}};
161
162static void test_context(void)
163{
164 BOOL ret;
165 HCATADMIN hca;
166 static GUID unknown = { 0xC689AABA, 0x8E78, 0x11D0, { 0x8C,0x47,0x00,0xC0,0x4F,0xC2,0x95,0xEE }}; /* WINTRUST.DLL */
167 CHAR dummydir[MAX_PATH];
168 DWORD attrs;
169
170 /* When CryptCATAdminAcquireContext is successful it will create
171 * several directories if they don't exist:
172 *
173 * ...\system32\CatRoot\{GUID}, this directory holds the .cat files
174 * ...\system32\CatRoot2\{GUID} (WinXP and up), here we find the catalog database for that GUID
175 *
176 * Windows Vista uses lowercase catroot and catroot2.
177 *
178 * When passed a NULL GUID it will create the following directories although on
179 * WinXP and up these directories are already present when Windows is installed:
180 *
181 * ...\system32\CatRoot\{127D0A1D-4EF2-11D1-8608-00C04FC295EE}
182 * ...\system32\CatRoot2\{127D0A1D-4EF2-11D1-8608-00C04FC295EE} (WinXP up)
183 *
184 * TODO: Find out what this GUID is/does.
185 *
186 * On WinXP and up there is also a TimeStamp file in some of directories that
187 * seem to indicate the last change to the catalog database for that GUID.
188 *
189 * On Windows 2000 some files are created/updated:
190 *
191 * ...\system32\CatRoot\SYSMAST.cbk
192 * ...\system32\CatRoot\SYSMAST.cbd
193 * ...\system32\CatRoot\{GUID}\CATMAST.cbk
194 * ...\system32\CatRoot\{GUID}\CATMAST.cbd
195 *
196 */
197
198 /* All NULL */
199 SetLastError(0xdeadbeef);
200 ret = pCryptCATAdminAcquireContext(NULL, NULL, 0);
201 ok(!ret, "Expected failure\n");
203 "Expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
204
205 /* NULL GUID */
206 if (0) { /* crashes on 64-bit win10 */
207 ret = pCryptCATAdminAcquireContext(&hca, NULL, 0);
208 ok(ret, "Expected success, got FALSE with %d\n", GetLastError());
209 ok(hca != NULL, "Expected a context handle, got NULL\n");
210
211 /* Proper release */
212 SetLastError(0xdeadbeef);
213 ret = pCryptCATAdminReleaseContext(hca, 0);
214 ok(ret, "Expected success, got FALSE with %d\n", GetLastError());
215
216 /* Try to release a second time */
217 SetLastError(0xdeadbeef);
218 ret = pCryptCATAdminReleaseContext(hca, 0);
219 ok(!ret, "Expected failure\n");
221 "Expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
222 }
223
224 /* All NULL */
225 SetLastError(0xdeadbeef);
226 ret = pCryptCATAdminReleaseContext(NULL, 0);
227 ok(!ret, "Expected failure\n");
229 "Expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
230
231 /* NULL context handle and dummy GUID */
232 SetLastError(0xdeadbeef);
233 ret = pCryptCATAdminAcquireContext(NULL, &dummy, 0);
234 ok(!ret, "Expected failure\n");
236 "Expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
237
238 /* Correct context handle and dummy GUID
239 *
240 * The tests run in the past unfortunately made sure that some directories were created.
241 *
242 * FIXME:
243 * We don't want to mess too much with these for now so we should delete only the ones
244 * that shouldn't be there like the deadbeef ones. We first have to figure out if it's
245 * safe to remove files and directories from CatRoot/CatRoot2.
246 */
247
248 ret = pCryptCATAdminAcquireContext(&hca, &dummy, 0);
249 ok(ret || GetLastError() == ERROR_ACCESS_DENIED, "CryptCATAdminAcquireContext failed %u\n", GetLastError());
251 {
252 win_skip("Not running as administrator\n");
253 return;
254 }
255 ok(hca != NULL, "Expected a context handle, got NULL\n");
256
258 ok(attrs != INVALID_FILE_ATTRIBUTES, "Expected the CatRoot directory to exist\n");
259
260 /* Windows creates the GUID directory in capitals */
261 lstrcpyA(dummydir, catroot);
262 lstrcatA(dummydir, "\\{DEADBEEF-DEAD-BEEF-DEAD-BEEFDEADBEEF}");
263 attrs = GetFileAttributesA(dummydir);
265 "Expected CatRoot\\{DEADBEEF-DEAD-BEEF-DEAD-BEEFDEADBEEF} directory to exist\n");
266
267 /* Only present on XP or higher. */
269 if (attrs != INVALID_FILE_ATTRIBUTES)
270 {
271 lstrcpyA(dummydir, catroot2);
272 lstrcatA(dummydir, "\\{DEADBEEF-DEAD-BEEF-DEAD-BEEFDEADBEEF}");
273 attrs = GetFileAttributesA(dummydir);
275 "Expected CatRoot2\\{DEADBEEF-DEAD-BEEF-DEAD-BEEFDEADBEEF} directory to exist\n");
276 }
277
278 ret = pCryptCATAdminReleaseContext(hca, 0);
279 ok(ret, "Expected success, got FALSE with %d\n", GetLastError());
280
281 /* Correct context handle and GUID */
282 ret = pCryptCATAdminAcquireContext(&hca, &unknown, 0);
283 ok(ret, "Expected success, got FALSE with %d\n", GetLastError());
284 ok(hca != NULL, "Expected a context handle, got NULL\n");
285
286 ret = pCryptCATAdminReleaseContext(hca, 0);
287 ok(ret, "Expected success, got FALSE with %d\n", GetLastError());
288
289 hca = (void *) 0xdeadbeef;
290 SetLastError(0xdeadbeef);
291 /* Flags is documented as unused, but the parameter is checked since win8 */
292 ret = pCryptCATAdminAcquireContext(&hca, &unknown, 1);
293 ok((!ret && (GetLastError() == ERROR_INVALID_PARAMETER) && (hca == (void *) 0xdeadbeef)) ||
294 broken(ret && hca != NULL && hca != (void *) 0xdeadbeef),
295 "Expected FALSE and ERROR_INVALID_PARAMETER with untouched handle, got %d and %u with %p\n",
296 ret, GetLastError(), hca);
297
298 if (ret && hca)
299 {
300 SetLastError(0xdeadbeef);
301 ret = pCryptCATAdminReleaseContext(hca, 0);
302 ok(ret, "Expected success, got FALSE with %d\n", GetLastError());
303 }
304}
305
306/* TODO: Check whether SHA-1 is the algorithm that's always used */
307static void test_calchash(void)
308{
309 BOOL ret;
310 HANDLE file;
311 DWORD hashsize = 0;
312 BYTE* hash;
313 BYTE expectedhash[20] = {0x3a,0xa1,0x19,0x08,0xec,0xa6,0x0d,0x2e,0x7e,0xcc,0x7a,0xca,0xf5,0xb8,0x2e,0x62,0x6a,0xda,0xf0,0x19};
315 DWORD written;
316
317 /* All NULL */
318 SetLastError(0xdeadbeef);
319 ret = pCryptCATAdminCalcHashFromFileHandle(NULL, NULL, NULL, 0);
320 ok(!ret, "Expected failure\n");
322 "Expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
323
324 /* NULL filehandle, rest is legal */
325 SetLastError(0xdeadbeef);
326 ret = pCryptCATAdminCalcHashFromFileHandle(NULL, &hashsize, NULL, 0);
327 ok(!ret, "Expected failure\n");
329 "Expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
330
331 /* Correct filehandle, rest is NULL */
333 SetLastError(0xdeadbeef);
334 ret = pCryptCATAdminCalcHashFromFileHandle(file, NULL, NULL, 0);
335 ok(!ret, "Expected failure\n");
337 "Expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
339
340 /* All OK, but dwFlags set to 1 */
342 SetLastError(0xdeadbeef);
343 ret = pCryptCATAdminCalcHashFromFileHandle(file, &hashsize, NULL, 1);
344 ok(!ret, "Expected failure\n");
346 "Expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
348
349 /* All OK, requesting the size of the hash */
351 ok(file != INVALID_HANDLE_VALUE, "CreateFile failed %u\n", GetLastError());
352 SetLastError(0xdeadbeef);
353 ret = pCryptCATAdminCalcHashFromFileHandle(file, &hashsize, NULL, 0);
354 ok(ret, "Expected success, got FALSE with %d\n", GetLastError());
355 ok(hashsize == 20," Expected a hash size of 20, got %d\n", hashsize);
357 "Expected ERROR_INSUFFICIENT_BUFFER, got %d\n", GetLastError());
359
360 /* All OK, retrieve the hash
361 * Double the hash buffer to see what happens to the size parameter
362 */
364 hashsize *= 2;
365 hash = HeapAlloc(GetProcessHeap(), 0, hashsize);
366 SetLastError(0xdeadbeef);
367 ret = pCryptCATAdminCalcHashFromFileHandle(file, &hashsize, hash, 0);
368 ok(ret, "Expected success, got FALSE with %d\n", GetLastError());
369 ok(hashsize == 20," Expected a hash size of 20, got %d\n", hashsize);
371 "Expected ERROR_SUCCESS, got %d\n", GetLastError());
374
375 /* Do the same test with a file created and filled by ourselves (and we thus
376 * have a known hash for).
377 */
378 GetTempFileNameA(CURR_DIR, "hsh", 0, temp);
380 WriteFile(file, "Text in this file is needed to create a know hash", 49, &written, NULL);
382
383 /* All OK, first request the size and then retrieve the hash */
385 hashsize = 0;
386 pCryptCATAdminCalcHashFromFileHandle(file, &hashsize, NULL, 0);
387 hash = HeapAlloc(GetProcessHeap(), 0, hashsize);
388 SetLastError(0xdeadbeef);
389 ret = pCryptCATAdminCalcHashFromFileHandle(file, &hashsize, hash, 0);
390 ok(ret, "Expected success, got FALSE with %d\n", GetLastError());
392 "Expected ERROR_SUCCESS, got %d\n", GetLastError());
393 ok(hashsize == sizeof(expectedhash) &&
394 !memcmp(hash, expectedhash, sizeof(expectedhash)),
395 "Hashes didn't match\n");
397
400}
401
402static void test_CryptCATOpen(void)
403{
404 HANDLE hcat;
405 char empty[MAX_PATH];
407 HANDLE file;
408 BOOL ret;
409
410 SetLastError(0xdeadbeef);
411 hcat = pCryptCATOpen(NULL, 0, 0, 0, 0);
412 ok(hcat == INVALID_HANDLE_VALUE, "CryptCATOpen succeeded\n");
414 "Expected ERROR_INVALID_PARAMETER, got %08x\n", GetLastError());
415
416 if (!GetTempFileNameA(CURR_DIR, "cat", 0, empty)) return;
417
419 ok(file != INVALID_HANDLE_VALUE, "CreateFileA failed %u\n", GetLastError());
422
423 hcat = pCryptCATOpen(emptyW, 0, 0, 0, 0);
425 ok(hcat != INVALID_HANDLE_VALUE, "Expected a correct handle\n");
426
427 ret = pCryptCATClose(hcat);
429 ok(ret, "CryptCATClose failed\n");
431}
432
435
437{
438 ok(error_area != -2, "Didn't expect cdf_callback() to be called (%08x, %08x)\n",
439 area, error);
440
443}
444
445static void test_CryptCATCDF_params(void)
446{
447 static WCHAR nonexistent[] = {'d','e','a','d','b','e','e','f','.','c','d','f',0};
448 CRYPTCATCDF *catcdf;
449 BOOL ret;
450
451 if (!pCryptCATCDFOpen)
452 {
453 win_skip("CryptCATCDFOpen is not available\n");
454 return;
455 }
456
457 SetLastError(0xdeadbeef);
458 catcdf = pCryptCATCDFOpen(NULL, NULL);
459 ok(catcdf == NULL, "CryptCATCDFOpen succeeded\n");
461 ok(GetLastError() == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
462
463 SetLastError(0xdeadbeef);
465 ok(catcdf == NULL, "CryptCATCDFOpen succeeded\n");
467 ok(GetLastError() == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
468
469 /* File doesn't exist */
470 SetLastError(0xdeadbeef);
472 ok(catcdf == NULL, "CryptCATCDFOpen succeeded\n");
474 ok(GetLastError() == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", GetLastError());
475
476 SetLastError(0xdeadbeef);
477 ret = pCryptCATCDFClose(NULL);
478 ok(!ret, "Expected failure\n");
480 ok(GetLastError() == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
481
482 catcdf = NULL;
483 SetLastError(0xdeadbeef);
484 ret = pCryptCATCDFClose(catcdf);
485 ok(!ret, "Expected failure\n");
487 ok(GetLastError() == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
488}
489
490/* FIXME: Once Wine can create catalog files we should use the created catalog file in this test */
492{
493 static WCHAR basenameW[] = {'w','i','n','e','t','e','s','t','.','c','a','t',0};
494 static const char basename[] = "winetest.cat";
495 HCATADMIN hcatadmin;
496 HCATINFO hcatinfo;
498 WCHAR tmpfileW[MAX_PATH];
499 char tmpfile[MAX_PATH];
500 char catfile[MAX_PATH], catfilepath[MAX_PATH], *p;
501 WCHAR catfileW[MAX_PATH];
502 HANDLE file;
503 DWORD error, written;
504 BOOL ret;
505 DWORD attrs;
506
507 if (!pCryptCATAdminRemoveCatalog)
508 {
509 /* NT4 and W2K do have CryptCATAdminAddCatalog !! */
510 win_skip("CryptCATAdminRemoveCatalog is not available\n");
511 return;
512 }
513
514 if (!GetTempFileNameA(CURR_DIR, "cat", 0, tmpfile)) return;
517 ok(file != INVALID_HANDLE_VALUE, "CreateFileA failed %u\n", GetLastError());
519
520 ret = pCryptCATAdminAcquireContext(&hcatadmin, &dummy, 0);
521 ok(ret || GetLastError() == ERROR_ACCESS_DENIED, "CryptCATAdminAcquireContext failed %u\n", GetLastError());
523 {
524 win_skip("Not running as administrator\n");
525 return;
526 }
527
528 SetLastError(0xdeadbeef);
529 hcatinfo = pCryptCATAdminAddCatalog(NULL, NULL, NULL, 0);
531 ok(hcatinfo == NULL, "CryptCATAdminAddCatalog succeeded\n");
532 ok(error == ERROR_INVALID_PARAMETER, "got %u expected ERROR_INVALID_PARAMETER\n", GetLastError());
533
534 SetLastError(0xdeadbeef);
535 hcatinfo = pCryptCATAdminAddCatalog(hcatadmin, NULL, NULL, 0);
537 ok(hcatinfo == NULL, "CryptCATAdminAddCatalog succeeded\n");
538 ok(error == ERROR_INVALID_PARAMETER, "got %u expected ERROR_INVALID_PARAMETER\n", GetLastError());
539
540 MultiByteToWideChar(CP_ACP, 0, tmpfile, -1, tmpfileW, MAX_PATH);
541
542 SetLastError(0xdeadbeef);
543 hcatinfo = pCryptCATAdminAddCatalog(hcatadmin, tmpfileW, basenameW, 0);
545 todo_wine {
546 ok(hcatinfo == NULL, "CryptCATAdminAddCatalog succeeded\n");
547 ok(error == ERROR_BAD_FORMAT, "got %u expected ERROR_BAD_FORMAT\n", GetLastError());
548 }
549 if (hcatinfo != NULL)
550 pCryptCATAdminReleaseCatalogContext(hcatadmin, hcatinfo, 0);
551
552 SetLastError(0xdeadbeef);
553 hcatinfo = pCryptCATAdminAddCatalog(hcatadmin, tmpfileW, basenameW, 1);
555 ok(hcatinfo == NULL, "CryptCATAdminAddCatalog succeeded\n");
557 error == ERROR_BAD_FORMAT, /* win 8 */
558 "got %u\n", GetLastError());
559
560 SetLastError(0xdeadbeef);
561 hcatinfo = pCryptCATAdminAddCatalog(hcatadmin, tmpfileW, NULL, 0);
563 ok(hcatinfo == NULL, "CryptCATAdminAddCatalog succeeded\n");
564 todo_wine ok(error == ERROR_BAD_FORMAT, "got %u expected ERROR_BAD_FORMAT\n", GetLastError());
565
568 ok(file != INVALID_HANDLE_VALUE, "CreateFileA failed %u\n", GetLastError());
569 WriteFile(file, test_catalog, sizeof(test_catalog), &written, NULL);
571
572 /* Unique name will be created */
573 hcatinfo = pCryptCATAdminAddCatalog(hcatadmin, tmpfileW, NULL, 0);
574 if (!hcatinfo && (GetLastError() == ERROR_ACCESS_DENIED))
575 {
576 win_skip("Not enough rights\n");
577 goto cleanup;
578 }
579 todo_wine ok(hcatinfo != NULL, "CryptCATAdminAddCatalog failed %u\n", GetLastError());
580
581 info.cbStruct = sizeof(info);
582 info.wszCatalogFile[0] = 0;
583 ret = pCryptCATCatalogInfoFromContext(hcatinfo, &info, 0);
585 {
586 ok(ret, "CryptCATCatalogInfoFromContext failed %u\n", GetLastError());
587 ok(info.wszCatalogFile[0] != 0, "Expected a filename\n");
588 }
589 WideCharToMultiByte(CP_ACP, 0, info.wszCatalogFile, -1, catfile, MAX_PATH, NULL, NULL);
590 if ((p = strrchr(catfile, '\\'))) p++;
591 memset(catfileW, 0, sizeof(catfileW));
592 MultiByteToWideChar(CP_ACP, 0, p, -1, catfileW, MAX_PATH);
593
594 /* Set the file attributes so we can check what happens with them during the 'copy' */
597 ok(ret, "SetFileAttributesA failed : %u\n", GetLastError());
598
599 /* winetest.cat will be created */
600 hcatinfo = pCryptCATAdminAddCatalog(hcatadmin, tmpfileW, basenameW, 0);
601 ok(hcatinfo != NULL, "CryptCATAdminAddCatalog failed %u\n", GetLastError());
602
603 lstrcpyA(catfilepath, catroot);
604 lstrcatA(catfilepath, "\\{DEADBEEF-DEAD-BEEF-DEAD-BEEFDEADBEEF}\\winetest.cat");
605 attrs = GetFileAttributesA(catfilepath);
606 ok(attrs != INVALID_FILE_ATTRIBUTES, "Expected %s to exist\n", catfilepath);
608 ok(attrs == FILE_ATTRIBUTE_SYSTEM ||
610 "File has wrong attributes : %08x\n", attrs);
611
612 info.cbStruct = sizeof(info);
613 info.wszCatalogFile[0] = 0;
614 ret = pCryptCATCatalogInfoFromContext(hcatinfo, &info, 0);
615 ok(ret, "CryptCATCatalogInfoFromContext failed %u\n", GetLastError());
616 ok(info.wszCatalogFile[0] != 0, "Expected a filename\n");
617 WideCharToMultiByte(CP_ACP, 0, info.wszCatalogFile, -1, catfile, MAX_PATH, NULL, NULL);
618 if ((p = strrchr(catfile, '\\'))) p++;
619 ok(!lstrcmpA(basename, p), "Expected %s, got %s\n", basename, p);
620
621 ret = pCryptCATAdminReleaseCatalogContext(hcatadmin, hcatinfo, 0);
622 ok(ret, "CryptCATAdminReleaseCatalogContext failed %u\n", GetLastError());
623
624 /* Remove the catalog file with the unique name */
625 ret = pCryptCATAdminRemoveCatalog(hcatadmin, catfileW, 0);
626 ok(ret, "CryptCATAdminRemoveCatalog failed %u\n", GetLastError());
627
628 /* Remove the winetest.cat catalog file, first with the full path. This should not succeed
629 * according to MSDN */
630 ret = pCryptCATAdminRemoveCatalog(hcatadmin, info.wszCatalogFile, 0);
631 ok(ret, "CryptCATAdminRemoveCatalog failed %u\n", GetLastError());
632 /* The call succeeded with the full path but the file is not removed */
633 attrs = GetFileAttributesA(catfilepath);
634 ok(attrs != INVALID_FILE_ATTRIBUTES, "Expected %s to exist\n", catfilepath);
635 /* Given only the filename the file is removed */
636 ret = pCryptCATAdminRemoveCatalog(hcatadmin, basenameW, 0);
637 ok(ret, "CryptCATAdminRemoveCatalog failed %u\n", GetLastError());
638 attrs = GetFileAttributesA(catfilepath);
639 ok(attrs == INVALID_FILE_ATTRIBUTES, "Expected %s to be removed\n", catfilepath);
640
641cleanup:
642 ret = pCryptCATAdminReleaseContext(hcatadmin, 0);
643 ok(ret, "CryptCATAdminReleaseContext failed %u\n", GetLastError());
644
645 /* Set the attributes so we can delete the file */
646 attrs = FILE_ATTRIBUTE_NORMAL;
648 ok(ret, "SetFileAttributesA failed %u\n", GetLastError());
650}
651
652static void test_catalog_properties(const char *catfile, int attributes, int members)
653{
654 static const GUID subject = {0xde351a42,0x8e59,0x11d0,{0x8c,0x47,0x00,0xc0,0x4f,0xc2,0x95,0xee}};
655
656 HANDLE hcat;
659 char catalog[MAX_PATH];
660 WCHAR catalogW[MAX_PATH];
661 DWORD attrs;
662 BOOL ret;
663 int attrcount = 0, membercount = 0;
664
665 /* FIXME: Wine can't create catalog files out of catalog definition files yet. Remove this piece
666 * once wine is fixed
667 */
668 attrs = GetFileAttributesA(catfile);
669 if (attrs == INVALID_FILE_ATTRIBUTES)
670 {
671 HANDLE file;
672 DWORD written;
673
674 trace("Creating the catalog file\n");
675 if (!GetTempFileNameA(CURR_DIR, "cat", 0, catalog)) return;
677 ok(file != INVALID_HANDLE_VALUE, "CreateFileA failed %u\n", GetLastError());
678 WriteFile(file, test_catalog, sizeof(test_catalog), &written, NULL);
680
681 attributes = 2;
682 members = 1;
683 MultiByteToWideChar(CP_ACP, 0, catalog, -1, catalogW, MAX_PATH);
684 }
685 else
686 {
687 MultiByteToWideChar(CP_ACP, 0, catfile, -1, catalogW, MAX_PATH);
688 catalog[0] = 0;
689 }
690
691 hcat = pCryptCATOpen(catalogW, 0, 0, 0, 0);
692 if (hcat == INVALID_HANDLE_VALUE && members == 0)
693 {
694 win_skip("CryptCATOpen on W2K can't handle catalog files with no members\n");
695 return;
696 }
697 ok(hcat != INVALID_HANDLE_VALUE, "CryptCATOpen failed %u\n", GetLastError());
698
700 ok(m == NULL, "CryptCATEnumerateMember succeeded\n");
701
702 m = NULL;
703 while ((m = pCryptCATEnumerateMember(hcat, m)))
704 {
705 ok(m->cbStruct == sizeof(CRYPTCATMEMBER), "unexpected size %u\n", m->cbStruct);
706 todo_wine ok(!lstrcmpW(m->pwszReferenceTag, hashmeW), "unexpected tag\n");
707 ok(!memcmp(&m->gSubjectType, &subject, sizeof(subject)), "guid differs\n");
708 ok(!m->fdwMemberFlags, "got %x expected 0\n", m->fdwMemberFlags);
709 ok(m->dwCertVersion == 0x200, "got %x expected 0x200\n", m->dwCertVersion);
710 ok(!m->dwReserved, "got %x expected 0\n", m->dwReserved);
711 ok(m->hReserved == NULL, "got %p expected NULL\n", m->hReserved);
712
714 ok(attr == NULL, "CryptCATEnumerateAttr succeeded\n");
715
716 membercount++;
717 }
718 ok(membercount == members, "Expected %d members, got %d\n", members, membercount);
719
721 ok(attr == NULL, "CryptCATEnumerateAttr succeeded\n");
722
724 ok(attr == NULL, "CryptCATEnumerateAttr succeeded\n");
725
726 attr = NULL;
727 while ((attr = pCryptCATEnumerateCatAttr(hcat, attr)))
728 {
729 ok(!lstrcmpW(attr->pwszReferenceTag, attr1W) ||
730 !lstrcmpW(attr->pwszReferenceTag, attr2W),
731 "Expected 'attr1' or 'attr2'\n");
732
733 attrcount++;
734 }
736 ok(attrcount == attributes, "Expected %d catalog attributes, got %d\n", attributes, attrcount);
737
738 ret = pCryptCATClose(hcat);
739 ok(ret, "CryptCATClose failed\n");
740 if (catalog[0]) DeleteFileA( catalog );
741}
742
744{
745 static const char catfileA[] = "winetest.cat";
746 static const char cdffileA[] = "winetest.cdf";
747 static WCHAR cdffileW[] = {'w','i','n','e','t','e','s','t','.','c','d','f',0};
748 CRYPTCATCDF *catcdf;
749 CRYPTCATATTRIBUTE *catattr;
750 CRYPTCATMEMBER *catmember;
751 WCHAR *catmembertag;
752 DWORD written, attrs;
753 HANDLE file;
754 BOOL ret;
755 int attrcount, membercount;
756
757 if (!pCryptCATCDFOpen)
758 {
759 win_skip("CryptCATCDFOpen is not available\n");
760 return;
761 }
762
763 /* Create the cdf file */
765 ok(file != INVALID_HANDLE_VALUE, "CreateFileA failed %u\n", GetLastError());
766 WriteFile(file, test_cdf, sizeof(test_cdf) - 1, &written, NULL);
768
769 /* Don't enumerate attributes and members */
770 trace("No attribs and members\n");
771 SetLastError(0xdeadbeef);
772 catcdf = pCryptCATCDFOpen(cdffileW, NULL);
774 {
775 ok(catcdf != NULL, "CryptCATCDFOpen failed\n");
776 ok(GetLastError() == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", GetLastError());
777 }
778
779 ret = pCryptCATCDFClose(catcdf);
781 {
782 ok(ret, "Expected success, got FALSE with %d\n", GetLastError());
783 ok(GetLastError() == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", GetLastError());
784 }
785
786 attrs = GetFileAttributesA(catfileA);
788 ok(attrs != INVALID_FILE_ATTRIBUTES, "Expected the catalog file to exist\n");
789
790 test_catalog_properties(catfileA, 0, 0);
791 DeleteFileA(catfileA);
792
793 /* Only enumerate the attributes */
794 trace("Only attributes\n");
795 attrcount = 0;
796 catcdf = pCryptCATCDFOpen(cdffileW, NULL);
797
798 catattr = NULL;
799 while ((catattr = pCryptCATCDFEnumCatAttributes(catcdf, catattr, NULL)))
800 {
801 ok(!lstrcmpW(catattr->pwszReferenceTag, attr1W) ||
802 !lstrcmpW(catattr->pwszReferenceTag, attr2W),
803 "Expected 'attr1' or 'attr2'\n");
804
805 attrcount++;
806 }
808 ok(attrcount == 2, "Expected 2 attributes, got %d\n", attrcount);
809
810 pCryptCATCDFClose(catcdf);
811 /* Even though the resulting catalog file shows the attributes, they will not be enumerated */
812 test_catalog_properties(catfileA, 0, 0);
813 DeleteFileA(catfileA);
814
815 /* Only enumerate the members */
816 trace("Only members\n");
817 membercount = 0;
818 catcdf = pCryptCATCDFOpen(cdffileW, NULL);
819
820 catmember = NULL;
821 catmembertag = NULL;
822 while ((catmembertag = pCryptCATCDFEnumMembersByCDFTagEx(catcdf, catmembertag, NULL, &catmember, FALSE, NULL)))
823 {
824 ok(!lstrcmpW(catmembertag, hashmeW), "Expected 'hashme'\n");
825 membercount++;
826 }
828 ok(membercount == 1, "Expected 1 member, got %d\n", membercount);
829
830 pCryptCATCDFClose(catcdf);
831 test_catalog_properties(catfileA, 0, 1);
832 DeleteFileA(catfileA);
833
834 /* Enumerate members and attributes */
835 trace("Attributes and members\n");
836 attrcount = membercount = 0;
837 catcdf = pCryptCATCDFOpen(cdffileW, NULL);
838
839 catattr = NULL;
840 while ((catattr = pCryptCATCDFEnumCatAttributes(catcdf, catattr, NULL)))
841 attrcount++;
843 ok(attrcount == 2, "Expected 2 attributes, got %d\n", attrcount);
844
845 catmember = NULL;
846 catmembertag = NULL;
847 while ((catmembertag = pCryptCATCDFEnumMembersByCDFTagEx(catcdf, catmembertag, NULL, &catmember, FALSE, NULL)))
848 membercount++;
850 ok(membercount == 1, "Expected 1 member, got %d\n", membercount);
851
852 pCryptCATCDFClose(catcdf);
853 test_catalog_properties(catfileA, 2, 1);
854 DeleteFileA(catfileA);
855
856 DeleteFileA(cdffileA);
857}
858
859static void create_cdf_file(const CHAR *filename, const CHAR *contents)
860{
861 HANDLE file;
862 DWORD written;
863
865 ok(file != INVALID_HANDLE_VALUE, "CreateFileA failed %u\n", GetLastError());
868}
869
870#define CHECK_EXPECT(a, b) \
871 do { \
872 ok(a == error_area, "Expected %08x, got %08x\n", a, error_area); \
873 ok(b == local_error, "Expected %08x, got %08x\n", b, local_error); \
874 } while (0)
875
876/* Clear the variables (can't use 0) */
877#define CLEAR_EXPECT \
878 error_area = local_error = -1
879
880/* Set both variables so the callback routine can check if a call to it was unexpected */
881#define SET_UNEXPECTED \
882 error_area = local_error = -2
883
884static void test_cdf_parsing(void)
885{
886 static const char catfileA[] = "tempfile.cat";
887 static const char cdffileA[] = "tempfile.cdf";
888 static WCHAR cdffileW[] = {'t','e','m','p','f','i','l','e','.','c','d','f',0};
889 CHAR cdf_contents[4096];
890 CRYPTCATCDF *catcdf;
891 CRYPTCATATTRIBUTE *catattr;
892 CRYPTCATMEMBER *catmember;
893 WCHAR *catmembertag;
894
895 if (!pCryptCATCDFOpen)
896 {
897 win_skip("CryptCATCDFOpen is not available\n");
898 return;
899 }
900
901 /* Empty file */
902 DeleteFileA(cdffileA);
903 create_cdf_file(cdffileA, "");
904
906 SetLastError(0xdeadbeef);
907 catcdf = pCryptCATCDFOpen(cdffileW, cdf_callback);
910 ok(catcdf == NULL, "CryptCATCDFOpen succeeded\n");
912 ok(GetLastError() == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", GetLastError());
913 DeleteFileA(cdffileA);
914 ok(!DeleteFileA(catfileA), "Didn't expect a catalog file to be created\n");
915
916 /* Just the header */
917 lstrcpyA(cdf_contents, "[CatalogHeader]\r\n");
918 create_cdf_file(cdffileA, cdf_contents);
919
921 SetLastError(0xdeadbeef);
922 catcdf = pCryptCATCDFOpen(cdffileW, cdf_callback);
923 ok(catcdf == NULL, "CryptCATCDFOpen succeeded\n");
926 "Expected ERROR_SHARING_VIOLATION, got %d\n", GetLastError());
927 DeleteFileA(cdffileA);
928
929 /* Header and member only */
930 lstrcpyA(cdf_contents, "[CatalogHeader]\r\n");
931 lstrcatA(cdf_contents, "[CatalogFiles]\r\n");
932 lstrcatA(cdf_contents, "hashme=.\\tempfile.cdf\r\n");
933 create_cdf_file(cdffileA, cdf_contents);
934
936 SetLastError(0xdeadbeef);
937 catcdf = pCryptCATCDFOpen(cdffileW, cdf_callback);
938 ok(catcdf == NULL, "CryptCATCDFOpen succeeded\n");
941 "Expected ERROR_SHARING_VIOLATION, got %d\n", GetLastError());
942 DeleteFileA(cdffileA);
943 ok(!DeleteFileA(catfileA), "Didn't expect a catalog file to be created\n");
944
945 /* Header and Name (no value) */
946 lstrcpyA(cdf_contents, "[CatalogHeader]\r\n");
947 lstrcatA(cdf_contents, "Name=\r\n");
948 create_cdf_file(cdffileA, cdf_contents);
949
951 SetLastError(0xdeadbeef);
952 catcdf = pCryptCATCDFOpen(cdffileW, cdf_callback);
953 ok(catcdf == NULL, "CryptCATCDFOpen succeeded\n");
956 "Expected ERROR_SHARING_VIOLATION, got %d\n", GetLastError());
957 DeleteFileA(cdffileA);
958 ok(!DeleteFileA(catfileA), "Didn't expect a catalog file to be created\n");
959
960 /* Header and Name */
961 lstrcpyA(cdf_contents, "[CatalogHeader]\r\n");
962 lstrcatA(cdf_contents, "Name=tempfile.cat\r\n");
963 create_cdf_file(cdffileA, cdf_contents);
964
966 SetLastError(0xdeadbeef);
967 catcdf = pCryptCATCDFOpen(cdffileW, cdf_callback);
969 {
970 ok(catcdf != NULL, "CryptCATCDFOpen failed\n");
971 ok(GetLastError() == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", GetLastError());
972 }
973 pCryptCATCDFClose(catcdf);
974 DeleteFileA(cdffileA);
976 ok(DeleteFileA(catfileA), "Expected a catalog file to be created\n");
977
978 /* Header and nonexistent member */
979 lstrcpyA(cdf_contents, "[CatalogHeader]\r\n");
980 lstrcatA(cdf_contents, "Name=tempfile.cat\r\n");
981 lstrcatA(cdf_contents, "[CatalogFiles]\r\n");
982 lstrcatA(cdf_contents, "hashme=.\\deadbeef.cdf\r\n");
983 create_cdf_file(cdffileA, cdf_contents);
984
986 SetLastError(0xdeadbeef);
987 catcdf = pCryptCATCDFOpen(cdffileW, cdf_callback);
989 {
990 ok(catcdf != NULL, "CryptCATCDFOpen failed\n");
991 ok(GetLastError() == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", GetLastError());
992 }
993 /* Loop through the members */
995 catmember = NULL;
996 catmembertag = NULL;
997 while ((catmembertag = pCryptCATCDFEnumMembersByCDFTagEx(catcdf, catmembertag, cdf_callback, &catmember, FALSE, NULL))) ;
1000 pCryptCATCDFClose(catcdf);
1001 DeleteFileA(cdffileA);
1002 todo_wine
1003 ok(DeleteFileA(catfileA), "Expected a catalog file to be created\n");
1004
1005 /* Header, correct member but no explicit newline */
1006 lstrcpyA(cdf_contents, "[CatalogHeader]\r\n");
1007 lstrcatA(cdf_contents, "Name=tempfile.cat\r\n");
1008 lstrcatA(cdf_contents, "[CatalogFiles]\r\n");
1009 lstrcatA(cdf_contents, "hashme=.\\tempfile.cdf\r");
1010 create_cdf_file(cdffileA, cdf_contents);
1011
1013 SetLastError(0xdeadbeef);
1014 catcdf = pCryptCATCDFOpen(cdffileW, cdf_callback);
1015 todo_wine
1016 {
1017 ok(catcdf != NULL, "CryptCATCDFOpen failed\n");
1018 ok(GetLastError() == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", GetLastError());
1019 }
1020 /* Loop through the members */
1022 catmember = NULL;
1023 catmembertag = NULL;
1024 while ((catmembertag = pCryptCATCDFEnumMembersByCDFTagEx(catcdf, catmembertag, cdf_callback, &catmember, FALSE, NULL))) ;
1025 ok(error_area == 0xffffffff || broken(error_area == CRYPTCAT_E_AREA_MEMBER) /* < win81 */,
1026 "Expected area 0xffffffff, got %08x\n", error_area);
1027 ok(local_error == 0xffffffff || broken(local_error == CRYPTCAT_E_CDF_MEMBER_FILE_PATH) /* < win81 */,
1028 "Expected error 0xffffffff, got %08x\n", local_error);
1029
1030 pCryptCATCDFClose(catcdf);
1031 DeleteFileA(cdffileA);
1032 todo_wine
1033 ok(DeleteFileA(catfileA), "Expected a catalog file to be created\n");
1034
1035 /* Header and 2 duplicate members */
1036 lstrcpyA(cdf_contents, "[CatalogHeader]\r\n");
1037 lstrcatA(cdf_contents, "Name=tempfile.cat\r\n");
1038 lstrcatA(cdf_contents, "[CatalogFiles]\r\n");
1039 lstrcatA(cdf_contents, "hashme=.\\tempfile.cdf\r\n");
1040 lstrcatA(cdf_contents, "hashme=.\\tempfile.cdf\r\n");
1041 create_cdf_file(cdffileA, cdf_contents);
1042
1044 SetLastError(0xdeadbeef);
1045 catcdf = pCryptCATCDFOpen(cdffileW, cdf_callback);
1046 todo_wine
1047 {
1048 ok(catcdf != NULL, "CryptCATCDFOpen failed\n");
1049 ok(GetLastError() == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", GetLastError());
1050 }
1051 /* Loop through the members */
1053 catmember = NULL;
1054 catmembertag = NULL;
1055 while ((catmembertag = pCryptCATCDFEnumMembersByCDFTagEx(catcdf, catmembertag, cdf_callback, &catmember, FALSE, NULL))) ;
1056 pCryptCATCDFClose(catcdf);
1057 test_catalog_properties(catfileA, 0, 1);
1058 DeleteFileA(cdffileA);
1059 todo_wine
1060 ok(DeleteFileA(catfileA), "Expected a catalog file to be created\n");
1061
1062 /* Wrong attribute */
1063 lstrcpyA(cdf_contents, "[CatalogHeader]\r\n");
1064 lstrcatA(cdf_contents, "Name=tempfile.cat\r\n");
1065 lstrcatA(cdf_contents, "CATATTR1=0x10010001:attr1\r\n");
1066 create_cdf_file(cdffileA, cdf_contents);
1067
1069 SetLastError(0xdeadbeef);
1070 catcdf = pCryptCATCDFOpen(cdffileW, cdf_callback);
1071 todo_wine
1072 {
1073 ok(catcdf != NULL, "CryptCATCDFOpen failed\n");
1074 ok(GetLastError() == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", GetLastError());
1075 }
1076 /* Loop through the attributes */
1078 catattr = NULL;
1079 while ((catattr = pCryptCATCDFEnumCatAttributes(catcdf, catattr, cdf_callback))) ;
1080 todo_wine
1082 pCryptCATCDFClose(catcdf);
1083 DeleteFileA(cdffileA);
1084 todo_wine
1085 ok(DeleteFileA(catfileA), "Expected a catalog file to be created\n");
1086
1087 /* Two identical attributes */
1088 lstrcpyA(cdf_contents, "[CatalogHeader]\r\n");
1089 lstrcatA(cdf_contents, "Name=tempfile.cat\r\n");
1090 lstrcatA(cdf_contents, "CATATTR1=0x10010001:attr1:value1\r\n");
1091 lstrcatA(cdf_contents, "CATATTR1=0x10010001:attr1:value1\r\n");
1092 lstrcatA(cdf_contents, "[CatalogFiles]\r\n");
1093 lstrcatA(cdf_contents, "hashme=.\\tempfile.cdf\r\n");
1094 create_cdf_file(cdffileA, cdf_contents);
1095
1097 SetLastError(0xdeadbeef);
1098 catcdf = pCryptCATCDFOpen(cdffileW, cdf_callback);
1099 todo_wine
1100 {
1101 ok(catcdf != NULL, "CryptCATCDFOpen failed\n");
1102 ok(GetLastError() == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", GetLastError());
1103 }
1104 /* Loop through the members */
1106 catmember = NULL;
1107 catmembertag = NULL;
1108 while ((catmembertag = pCryptCATCDFEnumMembersByCDFTagEx(catcdf, catmembertag, cdf_callback, &catmember, FALSE, NULL))) ;
1109 /* Loop through the attributes */
1111 catattr = NULL;
1112 while ((catattr = pCryptCATCDFEnumCatAttributes(catcdf, catattr, cdf_callback))) ;
1113 pCryptCATCDFClose(catcdf);
1114 test_catalog_properties(catfileA, 1, 1);
1115 DeleteFileA(cdffileA);
1116 todo_wine
1117 ok(DeleteFileA(catfileA), "Expected a catalog file to be created\n");
1118
1119 /* Two different attribute values with the same tag */
1120 lstrcpyA(cdf_contents, "[CatalogHeader]\r\n");
1121 lstrcatA(cdf_contents, "Name=tempfile.cat\r\n");
1122 lstrcatA(cdf_contents, "CATATTR1=0x10010001:attr1:value1\r\n");
1123 lstrcatA(cdf_contents, "CATATTR1=0x10010001:attr2:value2\r\n");
1124 lstrcatA(cdf_contents, "[CatalogFiles]\r\n");
1125 lstrcatA(cdf_contents, "hashme=.\\tempfile.cdf\r\n");
1126 create_cdf_file(cdffileA, cdf_contents);
1127
1129 SetLastError(0xdeadbeef);
1130 catcdf = pCryptCATCDFOpen(cdffileW, cdf_callback);
1131 todo_wine
1132 {
1133 ok(catcdf != NULL, "CryptCATCDFOpen failed\n");
1134 ok(GetLastError() == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", GetLastError());
1135 }
1136 /* Loop through the members */
1138 catmember = NULL;
1139 catmembertag = NULL;
1140 while ((catmembertag = pCryptCATCDFEnumMembersByCDFTagEx(catcdf, catmembertag, cdf_callback, &catmember, FALSE, NULL))) ;
1141 /* Loop through the attributes */
1143 catattr = NULL;
1144 while ((catattr = pCryptCATCDFEnumCatAttributes(catcdf, catattr, cdf_callback))) ;
1145 pCryptCATCDFClose(catcdf);
1146 test_catalog_properties(catfileA, 1, 1);
1147 DeleteFileA(cdffileA);
1148 todo_wine
1149 ok(DeleteFileA(catfileA), "Expected a catalog file to be created\n");
1150}
1151
1152static const struct
1153{
1154 WORD e_magic; /* 00: MZ Header signature */
1156 DWORD e_lfanew; /* 3c: Offset to extended header */
1157} dos_header =
1158{
1159 IMAGE_DOS_SIGNATURE, { 0 }, sizeof(dos_header)
1161
1163{
1164 IMAGE_NT_SIGNATURE, /* Signature */
1165 {
1166 IMAGE_FILE_MACHINE_I386, /* Machine */
1167 1, /* NumberOfSections */
1168 0, /* TimeDateStamp */
1169 0, /* PointerToSymbolTable */
1170 0, /* NumberOfSymbols */
1171 sizeof(IMAGE_OPTIONAL_HEADER), /* SizeOfOptionalHeader */
1172 IMAGE_FILE_EXECUTABLE_IMAGE /* Characteristics */
1173 },
1174 {
1175 IMAGE_NT_OPTIONAL_HDR_MAGIC, /* Magic */
1176 2, /* MajorLinkerVersion */
1177 15, /* MinorLinkerVersion */
1178 0, /* SizeOfCode */
1179 0, /* SizeOfInitializedData */
1180 0, /* SizeOfUninitializedData */
1181 0, /* AddressOfEntryPoint */
1182 0x10, /* BaseOfCode, also serves as e_lfanew in the truncated MZ header */
1183#ifndef _WIN64
1184 0, /* BaseOfData */
1185#endif
1186 0x10000000, /* ImageBase */
1187 0, /* SectionAlignment */
1188 0, /* FileAlignment */
1189 4, /* MajorOperatingSystemVersion */
1190 0, /* MinorOperatingSystemVersion */
1191 1, /* MajorImageVersion */
1192 0, /* MinorImageVersion */
1193 4, /* MajorSubsystemVersion */
1194 0, /* MinorSubsystemVersion */
1195 0, /* Win32VersionValue */
1196 0x200, /* SizeOfImage */
1197 sizeof(dos_header) + sizeof(nt_header), /* SizeOfHeaders */
1198 0, /* CheckSum */
1199 IMAGE_SUBSYSTEM_WINDOWS_CUI, /* Subsystem */
1200 0, /* DllCharacteristics */
1201 0, /* SizeOfStackReserve */
1202 0, /* SizeOfStackCommit */
1203 0, /* SizeOfHeapReserve */
1204 3, /* SizeOfHeapCommit */
1205 2, /* LoaderFlags */
1206 1, /* NumberOfRvaAndSizes */
1207 { { 0 } } /* DataDirectory[IMAGE_NUMBEROF_DIRECTORY_ENTRIES] */
1208 }
1209};
1210
1211static void test_sip(void)
1212{
1213 static const WCHAR nameW[] = {'t','e','s','t','.','e','x','e',0};
1216 HANDLE file;
1217 GUID guid;
1218 BOOL ret;
1219 char buf[1024];
1220
1222 ok(file != INVALID_HANDLE_VALUE, "can't create file\n");
1224 return;
1226 WriteFile(file, &nt_header, sizeof(nt_header), &size, NULL);
1227 memset(buf, 0, sizeof(buf));
1228 WriteFile(file, buf, 0x200 - sizeof(dos_header) - sizeof(nt_header), &size, NULL);
1230
1232 ok(file != INVALID_HANDLE_VALUE, "can't open file\n");
1233
1234 memset(&info, 0, sizeof(SIP_SUBJECTINFO));
1235 info.cbSize = sizeof(SIP_SUBJECTINFO);
1236 info.pgSubjectType = &guid;
1237 ret = CryptSIPRetrieveSubjectGuid(NULL, file, info.pgSubjectType);
1238 ok(ret, "CryptSIPRetrieveSubjectGuid failed (%x)\n", GetLastError());
1239
1241 ok(!ret, "CryptSIPPutSignedDataMsg succeeded\n");
1242 index = GetLastError();
1243 ok(index == ERROR_PATH_NOT_FOUND, "GetLastError returned %x\n", index);
1244
1245 info.hFile = file;
1246 info.pwsFileName = nameW;
1248 ok(!ret, "CryptSIPPutSignedDataMsg succeeded\n");
1249 index = GetLastError();
1250 todo_wine ok(index == ERROR_INVALID_PARAMETER, "GetLastError returned %x\n", index);
1251
1252 info.hFile = INVALID_HANDLE_VALUE;
1253 info.pwsFileName = nameW;
1255 ok(!ret, "CryptSIPPutSignedDataMsg succeeded\n");
1256 index = GetLastError();
1257 ok(index == ERROR_SHARING_VIOLATION, "GetLastError returned %x\n", index);
1258
1261
1262 info.hFile = file;
1263 info.pwsFileName = (void*)0xdeadbeef;
1265 ok(ret, "CryptSIPPutSignedDataMsg failed (%x)\n", GetLastError());
1266 ok(index == 0, "index = %x\n", index);
1267
1270
1271 info.hFile = INVALID_HANDLE_VALUE;
1272 info.pwsFileName = nameW;
1273 ret = pPutSignedDataMsg(&info, X509_ASN_ENCODING, &index, 14, (BYTE*)"longer message");
1274 ok(ret, "CryptSIPPutSignedDataMsg failed (%x)\n", GetLastError());
1275 ok(index == 1, "index = %x\n", index);
1276
1277 size = 0;
1278 encoding = 0xdeadbeef;
1280 ok(ret, "CryptSIPGetSignedDataMsg failed (%x)\n", GetLastError());
1281 ok(encoding == 0xdeadbeef, "encoding = %x\n", encoding);
1282 ok(size == 16, "size = %d\n", size);
1283
1285 ok(ret, "CryptSIPGetSignedDataMsg failed (%x)\n", GetLastError());
1286 ok(encoding == (X509_ASN_ENCODING|PKCS_7_ASN_ENCODING), "encoding = %x\n", encoding);
1287 ok(size == 8, "size = %d\n", size);
1288 ok(!memcmp(buf, "test\0\0\0\0", 8), "buf = %s\n", buf);
1289
1290 size = 0;
1291 encoding = 0xdeadbeef;
1293 ok(ret, "CryptSIPGetSignedDataMsg failed (%x)\n", GetLastError());
1294 ok(encoding == 0xdeadbeef, "encoding = %x\n", encoding);
1295 ok(size == 24, "size = %d\n", size);
1296
1298 ok(ret, "CryptSIPGetSignedDataMsg failed (%x)\n", GetLastError());
1299 ok(encoding == (X509_ASN_ENCODING|PKCS_7_ASN_ENCODING), "encoding = %x\n", encoding);
1300 ok(size == 16, "size = %d\n", size);
1301 ok(!strcmp(buf, "longer message"), "buf = %s\n", buf);
1302
1303 CryptReleaseContext(info.hProv, 0);
1306}
1307
1309{
1310 char** myARGV;
1311 char sysdir[MAX_PATH];
1312
1314
1315 if (!pCryptCATAdminAcquireContext)
1316 {
1317 win_skip("CryptCATAdmin functions are not available\n");
1318 return;
1319 }
1320
1322 lstrcpyA(catroot, sysdir);
1323 lstrcatA(catroot, "\\CatRoot");
1324 lstrcpyA(catroot2, sysdir);
1325 lstrcatA(catroot2, "\\CatRoot2");
1326
1328 strcpy(selfname, myARGV[0]);
1329
1331
1332 test_context();
1333 test_calchash();
1335 /* Parameter checking only */
1337 /* Test the parsing of a cdf file */
1339 /* Create a catalog file out of our own catalog definition file */
1342 test_sip();
1343}
static LPSTR * myARGV
Definition: FindFiles.c:30
#define broken(x)
Definition: _sntprintf.h:21
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
#define trace
Definition: atltest.h:70
#define ok(value,...)
Definition: atltest.h:57
#define START_TEST(x)
Definition: atltest.h:75
static const WCHAR nameW[]
Definition: main.c:46
#define index(s, c)
Definition: various.h:29
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10
#define ERROR_SUCCESS
Definition: deptool.c:10
#define NULL
Definition: types.h:112
#define FALSE
Definition: types.h:117
BOOL WINAPI CryptReleaseContext(HCRYPTPROV hProv, DWORD dwFlags)
Definition: crypt.c:648
BOOL WINAPI CryptSIPRetrieveSubjectGuid(LPCWSTR FileName, HANDLE hFileIn, GUID *pgSubject)
Definition: sip.c:310
static const WCHAR empty[]
Definition: main.c:47
#define CloseHandle
Definition: compat.h:739
#define GetProcessHeap()
Definition: compat.h:736
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
#define CP_ACP
Definition: compat.h:109
#define OPEN_EXISTING
Definition: compat.h:775
#define SetLastError(x)
Definition: compat.h:752
#define GetProcAddress(x, y)
Definition: compat.h:753
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
#define HeapAlloc
Definition: compat.h:733
#define CreateFileA(a, b, c, d, e, f, g)
Definition: compat.h:740
#define GENERIC_READ
Definition: compat.h:135
#define MAX_PATH
Definition: compat.h:34
#define HeapFree(x, y, z)
Definition: compat.h:735
#define CreateFileW
Definition: compat.h:741
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:137
#define WideCharToMultiByte
Definition: compat.h:111
#define MultiByteToWideChar
Definition: compat.h:110
#define ERROR_ACCESS_DENIED
Definition: compat.h:97
#define FILE_SHARE_READ
Definition: compat.h:136
static void cleanup(void)
Definition: main.c:1335
BOOL WINAPI DeleteFileA(IN LPCSTR lpFileName)
Definition: delete.c:24
BOOL WINAPI DeleteFileW(IN LPCWSTR lpFileName)
Definition: delete.c:39
BOOL WINAPI SetFileAttributesA(LPCSTR lpFileName, DWORD dwFileAttributes)
Definition: fileinfo.c:776
DWORD WINAPI GetFileAttributesA(LPCSTR lpFileName)
Definition: fileinfo.c:636
BOOL WINAPI WriteFile(IN HANDLE hFile, IN LPCVOID lpBuffer, IN DWORD nNumberOfBytesToWrite OPTIONAL, OUT LPDWORD lpNumberOfBytesWritten, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: rw.c:24
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:812
DWORD WINAPI GetCurrentDirectoryA(IN DWORD nBufferLength, OUT LPSTR lpBuffer)
Definition: path.c:2146
UINT WINAPI GetSystemDirectoryA(OUT LPSTR lpBuffer, IN UINT uSize)
Definition: path.c:2283
static void basename(LPCWSTR path, LPWSTR name)
Definition: profile.c:38
BOOL WINAPI CryptCATAdminReleaseContext(HCATADMIN hCatAdmin, DWORD dwFlags)
Definition: crypt.c:444
CRYPTCATCDF *WINAPI CryptCATCDFOpen(LPWSTR pwszFilePath, PFN_CDF_PARSE_ERROR_CALLBACK pfnParseError)
Definition: crypt.c:1020
CRYPTCATATTRIBUTE *WINAPI CryptCATCDFEnumCatAttributes(CRYPTCATCDF *pCDF, CRYPTCATATTRIBUTE *pPrevAttr, PFN_CDF_PARSE_ERROR_CALLBACK pfnParseError)
Definition: crypt.c:994
BOOL WINAPI CryptCATClose(HANDLE hCatalog)
Definition: crypt.c:540
HANDLE WINAPI CryptCATOpen(LPWSTR pwszFileName, DWORD fdwOpenFlags, HCRYPTPROV hProv, DWORD dwPublicVersion, DWORD dwEncodingType)
Definition: crypt.c:854
CRYPTCATMEMBER *WINAPI CryptCATEnumerateMember(HANDLE hCatalog, CRYPTCATMEMBER *prev)
Definition: crypt.c:650
BOOL WINAPI CryptCATCatalogInfoFromContext(HCATINFO hcatinfo, CATALOG_INFO *info, DWORD flags)
Definition: crypt.c:835
BOOL WINAPI CryptCATAdminCalcHashFromFileHandle(HANDLE hFile, DWORD *pcbHash, BYTE *pbHash, DWORD dwFlags)
Definition: crypt.c:219
static const GUID unknown
Definition: crypt.c:1365
BOOL WINAPI CryptCATCDFClose(CRYPTCATCDF *pCDF)
Definition: crypt.c:984
LPWSTR WINAPI CryptCATCDFEnumMembersByCDFTagEx(CRYPTCATCDF *pCDF, LPWSTR pwszPrevCDFTag, PFN_CDF_PARSE_ERROR_CALLBACK pfnParseError, CRYPTCATMEMBER **ppMember, BOOL fContinueOnError, LPVOID pvReserved)
Definition: crypt.c:1006
HCATINFO WINAPI CryptCATAdminAddCatalog(HCATADMIN catAdmin, PWSTR catalogFile, PWSTR selectBaseName, DWORD flags)
Definition: crypt.c:162
BOOL WINAPI CryptCATAdminReleaseCatalogContext(HCATADMIN hCatAdmin, HCATINFO hCatInfo, DWORD dwFlags)
Definition: crypt.c:412
BOOL WINAPI CryptCATAdminRemoveCatalog(HCATADMIN hCatAdmin, LPCWSTR pwszCatalogFile, DWORD dwFlags)
Definition: crypt.c:475
CRYPTCATATTRIBUTE *WINAPI CryptCATEnumerateCatAttr(HANDLE hCatalog, CRYPTCATATTRIBUTE *prev)
Definition: crypt.c:632
BOOL WINAPI CryptCATAdminAcquireContext(HCATADMIN *catAdmin, const GUID *sys, DWORD dwFlags)
Definition: crypt.c:97
CRYPTCATATTRIBUTE *WINAPI CryptCATEnumerateAttr(HANDLE hCatalog, CRYPTCATMEMBER *member, CRYPTCATATTRIBUTE *prev)
Definition: crypt.c:614
UINT WINAPI GetTempFileNameA(IN LPCSTR lpPathName, IN LPCSTR lpPrefixString, IN UINT uUnique, OUT LPSTR lpTempFileName)
Definition: filename.c:26
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
unsigned short WORD
Definition: ntddk_ex.h:93
GLsizeiptr size
Definition: glext.h:5919
GLuint index
Definition: glext.h:6031
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
GLfloat GLfloat p
Definition: glext.h:8902
const GLfloat * m
Definition: glext.h:10848
static const WCHAR emptyW[]
Definition: navigate.c:40
_Check_return_ _CRTIMP FILE *__cdecl tmpfile(void)
Definition: file.c:3914
const char * filename
Definition: ioapi.h:137
LPSTR WINAPI lstrcpyA(LPSTR lpString1, LPCSTR lpString2)
Definition: lstring.c:100
int WINAPI lstrcmpW(LPCWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:170
int WINAPI lstrcmpA(LPCSTR lpString1, LPCSTR lpString2)
Definition: lstring.c:18
LPSTR WINAPI lstrcatA(LPSTR lpString1, LPCSTR lpString2)
Definition: lstring.c:123
int WINAPI lstrlenA(LPCSTR lpString)
Definition: lstring.c:145
const GUID * guid
#define error(str)
Definition: mkdosfs.c:1605
#define CREATE_ALWAYS
Definition: disk.h:72
#define CREATE_NEW
Definition: disk.h:69
#define OPEN_ALWAYS
Definition: disk.h:70
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
static BYTE HCRYPTKEY *static LPCWSTR
Definition: crypt.c:70
static BOOL
Definition: crypt.c:57
static const WCHAR nonexistent[]
Definition: font.c:33
#define todo_wine
Definition: custom.c:79
static const char * contents
Definition: parser.c:511
static CHAR CURR_DIR[MAX_PATH]
Definition: crypt.c:32
static const struct @1728 dos_header
DWORD e_lfanew
Definition: crypt.c:1156
WORD unused[29]
Definition: crypt.c:1155
static void test_CryptCATAdminAddRemoveCatalog(void)
Definition: crypt.c:491
static CHAR catroot2[MAX_PATH]
Definition: crypt.c:34
static pCryptSIPPutSignedDataMsg pPutSignedDataMsg
Definition: crypt.c:120
static void test_cdf_parsing(void)
Definition: crypt.c:884
static DWORD local_error
Definition: crypt.c:434
static void test_catalog_properties(const char *catfile, int attributes, int members)
Definition: crypt.c:652
static const BYTE test_catalog[]
Definition: crypt.c:70
static IMAGE_NT_HEADERS nt_header
Definition: crypt.c:1162
static CHAR catroot[MAX_PATH]
Definition: crypt.c:33
static LPWSTR
Definition: crypt.c:112
static HCATINFO
Definition: crypt.c:106
#define WINTRUST_GET_PROC(func)
static CRYPTCATATTRIBUTE *WINAPI * pCryptCATEnumerateAttr(HANDLE, CRYPTCATMEMBER *, CRYPTCATATTRIBUTE *)
static DWORD error_area
Definition: crypt.c:433
static CRYPTCATMEMBER *WINAPI * pCryptCATEnumerateMember(HANDLE, CRYPTCATMEMBER *)
static void test_calchash(void)
Definition: crypt.c:307
static void test_context(void)
Definition: crypt.c:162
static pCryptSIPGetSignedDataMsg pGetSignedDataMsg
Definition: crypt.c:119
static const WCHAR attr2W[]
Definition: crypt.c:38
static void InitFunctionPtrs(void)
Definition: crypt.c:122
static const WCHAR attr1W[]
Definition: crypt.c:37
static void WINAPI cdf_callback(DWORD area, DWORD error, WCHAR *line)
Definition: crypt.c:436
static void test_CryptCATCDF_params(void)
Definition: crypt.c:445
static const WCHAR hashmeW[]
Definition: crypt.c:36
WORD e_magic
Definition: crypt.c:1154
static void test_CryptCATOpen(void)
Definition: crypt.c:402
static CRYPTCATCDF *WINAPI * pCryptCATCDFOpen(LPWSTR, PFN_CDF_PARSE_ERROR_CALLBACK)
static PWSTR
Definition: crypt.c:104
static const CHAR test_cdf[]
Definition: crypt.c:58
static CRYPTCATATTRIBUTE *WINAPI * pCryptCATCDFEnumCatAttributes(CRYPTCATCDF *, CRYPTCATATTRIBUTE *, PFN_CDF_PARSE_ERROR_CALLBACK)
#define CHECK_EXPECT(a, b)
Definition: crypt.c:870
#define SET_UNEXPECTED
Definition: crypt.c:881
static CRYPTCATATTRIBUTE *WINAPI * pCryptCATEnumerateCatAttr(HANDLE, CRYPTCATATTRIBUTE *)
static CRYPTCATMEMBER LPVOID
Definition: crypt.c:113
static void test_sip(void)
Definition: crypt.c:1211
static char selfname[MAX_PATH]
Definition: crypt.c:31
#define CLEAR_EXPECT
Definition: crypt.c:877
static void create_cdf_file(const CHAR *filename, const CHAR *contents)
Definition: crypt.c:859
static void test_create_catalog_file(void)
Definition: crypt.c:743
#define CRYPTCAT_E_CDF_TAGNOTFOUND
Definition: mscat.h:47
#define CRYPTCAT_E_AREA_ATTRIBUTE
Definition: mscat.h:43
#define CRYPTCAT_E_CDF_MEMBER_FILENOTFOUND
Definition: mscat.h:51
#define CRYPTCAT_E_AREA_MEMBER
Definition: mscat.h:42
#define CRYPTCAT_E_AREA_HEADER
Definition: mscat.h:41
#define CRYPTCAT_E_CDF_MEMBER_FILE_PATH
Definition: mscat.h:49
#define CRYPTCAT_E_CDF_ATTR_TOOFEWVALUES
Definition: mscat.h:54
void(WINAPI * PFN_CDF_PARSE_ERROR_CALLBACK)(DWORD, DWORD, WCHAR *)
Definition: mscat.h:103
HANDLE HCATADMIN
Definition: mscat.h:24
BOOL(WINAPI * pCryptSIPGetSignedDataMsg)(SIP_SUBJECTINFO *, DWORD *, DWORD, DWORD *, BYTE *)
Definition: mssip.h:117
BOOL(WINAPI * pCryptSIPPutSignedDataMsg)(SIP_SUBJECTINFO *, DWORD, DWORD *, DWORD, BYTE *)
Definition: mssip.h:118
struct SIP_SUBJECTINFO_ SIP_SUBJECTINFO
_In_ HANDLE hFile
Definition: mswsock.h:90
#define FILE_SHARE_WRITE
Definition: nt_native.h:681
#define FILE_ATTRIBUTE_READONLY
Definition: nt_native.h:702
#define FILE_ATTRIBUTE_SYSTEM
Definition: nt_native.h:704
#define DWORD
Definition: nt_native.h:44
#define GENERIC_WRITE
Definition: nt_native.h:90
#define FILE_ATTRIBUTE_NOT_CONTENT_INDEXED
Definition: ntifs_ex.h:384
#define IMAGE_SUBSYSTEM_WINDOWS_CUI
Definition: ntimage.h:438
#define IMAGE_NT_OPTIONAL_HDR_MAGIC
Definition: ntimage.h:387
#define IMAGE_FILE_EXECUTABLE_IMAGE
Definition: pedump.c:160
#define IMAGE_FILE_MACHINE_I386
Definition: pedump.c:174
struct _IMAGE_OPTIONAL_HEADER IMAGE_OPTIONAL_HEADER
#define IMAGE_NT_SIGNATURE
Definition: pedump.c:93
#define IMAGE_DOS_SIGNATURE
Definition: pedump.c:89
static Real area(Real A[2], Real B[2], Real C[2])
Definition: polyDBG.cc:50
static calc_node_t temp
Definition: rpn_ieee.c:38
_Check_return_ _CRTIMP _CONST_RETURN char *__cdecl strrchr(_In_z_ const char *_Str, _In_ int _Ch)
#define win_skip
Definition: test.h:160
int winetest_get_mainargs(char ***pargv)
#define memset(x, y, z)
Definition: compat.h:39
LPWSTR pwszReferenceTag
Definition: mscat.h:62
Definition: cookie.c:202
Definition: fci.c:127
Definition: _hash_fun.h:40
Definition: parser.c:49
PVOID HANDLE
Definition: typedefs.h:73
#define INVALID_FILE_ATTRIBUTES
Definition: vfdcmd.c:23
int ret
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
ULONG_PTR HCRYPTPROV
Definition: wincrypt.h:46
#define X509_ASN_ENCODING
Definition: wincrypt.h:2297
#define PKCS_7_ASN_ENCODING
Definition: wincrypt.h:2299
#define WINAPI
Definition: msvc.h:6
#define ERROR_SHARING_VIOLATION
Definition: winerror.h:135
#define ERROR_PATH_NOT_FOUND
Definition: winerror.h:106
#define ERROR_BAD_FORMAT
Definition: winerror.h:114
static char * encoding
Definition: xmllint.c:155
__wchar_t WCHAR
Definition: xmlstorage.h:180
WCHAR * LPWSTR
Definition: xmlstorage.h:184
char CHAR
Definition: xmlstorage.h:175
unsigned char BYTE
Definition: xxhash.c:193