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