ReactOS 0.4.16-dev-1946-g52006dd
store.c
Go to the documentation of this file.
1/*
2 * crypt32 cert store function tests
3 *
4 * Copyright 2005-2006 Juan Lang
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#include <stdio.h>
22#include <stdarg.h>
23
24#include <windef.h>
25#include <winbase.h>
26#include <winuser.h>
27#include <shlobj.h>
28#include <shlwapi.h>
29#include <winreg.h>
30#include <winerror.h>
31#include <wincrypt.h>
32
33#include "wine/test.h"
34
35/* The following aren't defined in wincrypt.h, as they're "reserved" */
36#define CERT_CERT_PROP_ID 32
37#define CERT_CRL_PROP_ID 33
38#define CERT_CTL_PROP_ID 34
39
41{
45};
46
47static const BYTE emptyCert[] = { 0x30, 0x00 };
48static const BYTE bigCert[] = { 0x30, 0x7a, 0x02, 0x01, 0x01, 0x30, 0x02, 0x06,
49 0x00, 0x30, 0x15, 0x31, 0x13, 0x30, 0x11, 0x06, 0x03, 0x55, 0x04, 0x03, 0x13,
50 0x0a, 0x4a, 0x75, 0x61, 0x6e, 0x20, 0x4c, 0x61, 0x6e, 0x67, 0x00, 0x30, 0x22,
51 0x18, 0x0f, 0x31, 0x36, 0x30, 0x31, 0x30, 0x31, 0x30, 0x31, 0x30, 0x30, 0x30,
52 0x30, 0x30, 0x30, 0x5a, 0x18, 0x0f, 0x31, 0x36, 0x30, 0x31, 0x30, 0x31, 0x30,
53 0x31, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x5a, 0x30, 0x15, 0x31, 0x13, 0x30,
54 0x11, 0x06, 0x03, 0x55, 0x04, 0x03, 0x13, 0x0a, 0x4a, 0x75, 0x61, 0x6e, 0x20,
55 0x4c, 0x61, 0x6e, 0x67, 0x00, 0x30, 0x07, 0x30, 0x02, 0x06, 0x00, 0x03, 0x01,
56 0x00, 0xa3, 0x16, 0x30, 0x14, 0x30, 0x12, 0x06, 0x03, 0x55, 0x1d, 0x13, 0x01,
57 0x01, 0xff, 0x04, 0x08, 0x30, 0x06, 0x01, 0x01, 0xff, 0x02, 0x01, 0x01 };
58static const BYTE signedBigCert[] = {
59 0x30, 0x81, 0x93, 0x30, 0x7a, 0x02, 0x01, 0x01, 0x30, 0x02, 0x06, 0x00, 0x30,
60 0x15, 0x31, 0x13, 0x30, 0x11, 0x06, 0x03, 0x55, 0x04, 0x03, 0x13, 0x0a, 0x4a,
61 0x75, 0x61, 0x6e, 0x20, 0x4c, 0x61, 0x6e, 0x67, 0x00, 0x30, 0x22, 0x18, 0x0f,
62 0x31, 0x36, 0x30, 0x31, 0x30, 0x31, 0x30, 0x31, 0x30, 0x30, 0x30, 0x30, 0x30,
63 0x30, 0x5a, 0x18, 0x0f, 0x31, 0x36, 0x30, 0x31, 0x30, 0x31, 0x30, 0x31, 0x30,
64 0x30, 0x30, 0x30, 0x30, 0x30, 0x5a, 0x30, 0x15, 0x31, 0x13, 0x30, 0x11, 0x06,
65 0x03, 0x55, 0x04, 0x03, 0x13, 0x0a, 0x4a, 0x75, 0x61, 0x6e, 0x20, 0x4c, 0x61,
66 0x6e, 0x67, 0x00, 0x30, 0x07, 0x30, 0x02, 0x06, 0x00, 0x03, 0x01, 0x00, 0xa3,
67 0x16, 0x30, 0x14, 0x30, 0x12, 0x06, 0x03, 0x55, 0x1d, 0x13, 0x01, 0x01, 0xff,
68 0x04, 0x08, 0x30, 0x06, 0x01, 0x01, 0xff, 0x02, 0x01, 0x01, 0x30, 0x02, 0x06,
69 0x00, 0x03, 0x11, 0x00, 0x0f, 0x0e, 0x0d, 0x0c, 0x0b, 0x0a, 0x09, 0x08, 0x07,
70 0x06, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00 };
71static const BYTE serializedCert[] = { 0x20, 0x00, 0x00, 0x00,
72 0x01, 0x00, 0x00, 0x00, 0x7c, 0x00, 0x00, 0x00, 0x30, 0x7a, 0x02, 0x01, 0x01,
73 0x30, 0x02, 0x06, 0x00, 0x30, 0x15, 0x31, 0x13, 0x30, 0x11, 0x06, 0x03, 0x55,
74 0x04, 0x03, 0x13, 0x0a, 0x4a, 0x75, 0x61, 0x6e, 0x20, 0x4c, 0x61, 0x6e, 0x67,
75 0x00, 0x30, 0x22, 0x18, 0x0f, 0x31, 0x36, 0x30, 0x31, 0x30, 0x31, 0x30, 0x31,
76 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x5a, 0x18, 0x0f, 0x31, 0x36, 0x30, 0x31,
77 0x30, 0x31, 0x30, 0x31, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x5a, 0x30, 0x15,
78 0x31, 0x13, 0x30, 0x11, 0x06, 0x03, 0x55, 0x04, 0x03, 0x13, 0x0a, 0x4a, 0x75,
79 0x61, 0x6e, 0x20, 0x4c, 0x61, 0x6e, 0x67, 0x00, 0x30, 0x07, 0x30, 0x02, 0x06,
80 0x00, 0x03, 0x01, 0x00, 0xa3, 0x16, 0x30, 0x14, 0x30, 0x12, 0x06, 0x03, 0x55,
81 0x1d, 0x13, 0x01, 0x01, 0xff, 0x04, 0x08, 0x30, 0x06, 0x01, 0x01, 0xff, 0x02,
82 0x01, 0x01 };
83static const BYTE signedCRL[] = { 0x30, 0x45, 0x30, 0x2c, 0x30, 0x02, 0x06,
84 0x00, 0x30, 0x15, 0x31, 0x13, 0x30, 0x11, 0x06, 0x03, 0x55, 0x04, 0x03, 0x13,
85 0x0a, 0x4a, 0x75, 0x61, 0x6e, 0x20, 0x4c, 0x61, 0x6e, 0x67, 0x00, 0x18, 0x0f,
86 0x31, 0x36, 0x30, 0x31, 0x30, 0x31, 0x30, 0x31, 0x30, 0x30, 0x30, 0x30, 0x30,
87 0x30, 0x5a, 0x30, 0x02, 0x06, 0x00, 0x03, 0x11, 0x00, 0x0f, 0x0e, 0x0d, 0x0c,
88 0x0b, 0x0a, 0x09, 0x08, 0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00 };
89static const BYTE bigCert2[] = { 0x30, 0x7a, 0x02, 0x01, 0x01, 0x30, 0x02, 0x06,
90 0x00, 0x30, 0x15, 0x31, 0x13, 0x30, 0x11, 0x06, 0x03, 0x55, 0x04, 0x03, 0x13,
91 0x0a, 0x41, 0x6c, 0x65, 0x78, 0x20, 0x4c, 0x61, 0x6e, 0x67, 0x00, 0x30, 0x22,
92 0x18, 0x0f, 0x31, 0x36, 0x30, 0x31, 0x30, 0x31, 0x30, 0x31, 0x30, 0x30, 0x30,
93 0x30, 0x30, 0x30, 0x5a, 0x18, 0x0f, 0x31, 0x36, 0x30, 0x31, 0x30, 0x31, 0x30,
94 0x31, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x5a, 0x30, 0x15, 0x31, 0x13, 0x30,
95 0x11, 0x06, 0x03, 0x55, 0x04, 0x03, 0x13, 0x0a, 0x41, 0x6c, 0x65, 0x78, 0x20,
96 0x4c, 0x61, 0x6e, 0x67, 0x00, 0x30, 0x07, 0x30, 0x02, 0x06, 0x00, 0x03, 0x01,
97 0x00, 0xa3, 0x16, 0x30, 0x14, 0x30, 0x12, 0x06, 0x03, 0x55, 0x1d, 0x13, 0x01,
98 0x01, 0xff, 0x04, 0x08, 0x30, 0x06, 0x01, 0x01, 0xff, 0x02, 0x01, 0x01 };
1000x30,0x82,0x01,0x0f,0x06,0x09,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x01,0x07,0x02,
1010xa0,0x82,0x01,0x00,0x30,0x81,0xfd,0x02,0x01,0x01,0x31,0x0e,0x30,0x0c,0x06,
1020x08,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x02,0x05,0x05,0x00,0x30,0x30,0x06,0x09,
1030x2b,0x06,0x01,0x04,0x01,0x82,0x37,0x0a,0x01,0xa0,0x23,0x30,0x21,0x30,0x00,
1040x18,0x0f,0x31,0x36,0x30,0x31,0x30,0x31,0x30,0x31,0x30,0x30,0x30,0x30,0x30,
1050x30,0x5a,0x30,0x0c,0x06,0x08,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x02,0x05,0x05,
1060x00,0x31,0x81,0xb5,0x30,0x81,0xb2,0x02,0x01,0x01,0x30,0x1a,0x30,0x15,0x31,
1070x13,0x30,0x11,0x06,0x03,0x55,0x04,0x03,0x13,0x0a,0x4a,0x75,0x61,0x6e,0x20,
1080x4c,0x61,0x6e,0x67,0x00,0x02,0x01,0x01,0x30,0x0c,0x06,0x08,0x2a,0x86,0x48,
1090x86,0xf7,0x0d,0x02,0x05,0x05,0x00,0xa0,0x3b,0x30,0x18,0x06,0x09,0x2a,0x86,
1100x48,0x86,0xf7,0x0d,0x01,0x09,0x03,0x31,0x0b,0x06,0x09,0x2b,0x06,0x01,0x04,
1110x01,0x82,0x37,0x0a,0x01,0x30,0x1f,0x06,0x09,0x2a,0x86,0x48,0x86,0xf7,0x0d,
1120x01,0x09,0x04,0x31,0x12,0x04,0x10,0x54,0x71,0xbc,0xe1,0x56,0x31,0xa2,0xf9,
1130x65,0x70,0x34,0xf8,0xe2,0xe9,0xb4,0xf4,0x30,0x04,0x06,0x00,0x05,0x00,0x04,
1140x40,0x2f,0x1b,0x9f,0x5a,0x4a,0x15,0x73,0xfa,0xb1,0x93,0x3d,0x09,0x52,0xdf,
1150x6b,0x98,0x4b,0x13,0x5e,0xe7,0xbf,0x65,0xf4,0x9c,0xc2,0xb1,0x77,0x09,0xb1,
1160x66,0x4d,0x72,0x0d,0xb1,0x1a,0x50,0x20,0xe0,0x57,0xa2,0x39,0xc7,0xcd,0x7f,
1170x8e,0xe7,0x5f,0x76,0x2b,0xd1,0x6a,0x82,0xb3,0x30,0x25,0x61,0xf6,0x25,0x23,
1180x57,0x6c,0x0b,0x47,0xb8 };
119
120#define test_store_is_empty(store) _test_store_is_empty(__LINE__,store)
121static void _test_store_is_empty(unsigned line, HCERTSTORE store)
122{
123 const CERT_CONTEXT *cert;
124
126 ok_(__FILE__,line)(!cert && GetLastError() == CRYPT_E_NOT_FOUND, "store is not empty\n");
127}
128
129static void testMemStore(void)
130{
131 HCERTSTORE store1, store2;
133 BOOL ret;
134 DWORD GLE;
135
136 /* NULL provider */
137 store1 = CertOpenStore(0, 0, 0, 0, NULL);
138 ok(!store1 && GetLastError() == ERROR_FILE_NOT_FOUND,
139 "Expected ERROR_FILE_NOT_FOUND, got %ld\n", GetLastError());
140 /* weird flags */
144 "Expected ERROR_CALL_NOT_IMPLEMENTED, got %ld\n", GetLastError());
145
146 /* normal */
149 ok(store1 != NULL, "CertOpenStore failed: %ld\n", GetLastError());
150 /* open existing doesn't */
153 ok(store2 != NULL, "CertOpenStore failed: %ld\n", GetLastError());
154 ok(store1 != store2, "Expected different stores\n");
155
156 /* add a bogus (empty) cert */
157 context = NULL;
160 /* Windows returns CRYPT_E_ASN1_EOD, but accept
161 * CRYPT_E_ASN1_CORRUPT as well (because matching errors is tough in this
162 * case)
163 */
164 GLE = GetLastError();
166 "Expected CRYPT_E_ASN1_EOD or CRYPT_E_ASN1_CORRUPT, got %08lx\n",
167 GLE);
168 /* add a "signed" cert--the signature isn't a real signature, so this adds
169 * without any check of the signature's validity
170 */
173 ok(ret, "CertAddEncodedCertificateToStore failed: %08lx\n", GetLastError());
174 ok(context != NULL, "Expected a valid cert context\n");
175 if (context)
176 {
177 ok(context->cbCertEncoded == sizeof(signedBigCert),
178 "Wrong cert size %ld\n", context->cbCertEncoded);
179 ok(!memcmp(context->pbCertEncoded, signedBigCert,
180 sizeof(signedBigCert)), "Unexpected encoded cert in context\n");
181 /* remove it, the rest of the tests will work on an unsigned cert */
183 ok(ret, "CertDeleteCertificateFromStore failed: %08lx\n",
184 GetLastError());
185 }
186 /* try adding a "signed" CRL as a cert */
189 GLE = GetLastError();
191 "Expected CRYPT_E_ASN1_BADTAG or CRYPT_E_ASN1_CORRUPT, got %08lx\n",
192 GLE);
193 /* add a cert to store1 */
196 ok(ret, "CertAddEncodedCertificateToStore failed: %08lx\n", GetLastError());
197 ok(context != NULL, "Expected a valid cert context\n");
198 if (context)
199 {
200 DWORD size;
201 BYTE *buf;
202
203 ok(context->cbCertEncoded == sizeof(bigCert),
204 "Wrong cert size %ld\n", context->cbCertEncoded);
205 ok(!memcmp(context->pbCertEncoded, bigCert, sizeof(bigCert)),
206 "Unexpected encoded cert in context\n");
207 ok(context->hCertStore == store1, "Unexpected store\n");
208
209 /* check serializing this element */
210 /* These crash
211 ret = CertSerializeCertificateStoreElement(NULL, 0, NULL, NULL);
212 ret = CertSerializeCertificateStoreElement(context, 0, NULL, NULL);
213 ret = CertSerializeCertificateStoreElement(NULL, 0, NULL, &size);
214 */
215 /* apparently flags are ignored */
217 ok(ret, "CertSerializeCertificateStoreElement failed: %08lx\n",
218 GetLastError());
219 buf = malloc(size);
220 if (buf)
221 {
223 ok(ret, "CertSerializeCertificateStoreElement failed: %08lx\n", GetLastError());
224 ok(size == sizeof(serializedCert), "Wrong size %ld\n", size);
226 "Unexpected serialized cert\n");
227 free(buf);
228 }
229
231 ok(ret, "CertFreeCertificateContext failed: %08lx\n", GetLastError());
232 }
233 /* verify the cert's in store1 */
235 ok(context != NULL, "Expected a valid context\n");
238 "Expected CRYPT_E_NOT_FOUND, got %08lx\n", GetLastError());
239 /* verify store2 (the "open existing" mem store) is still empty */
241 ok(!context, "Expected an empty store\n");
242 /* delete the cert from store1, and check it's empty */
244 if (context)
245 {
246 /* Deleting a bitwise copy crashes with an access to an uninitialized
247 * pointer, so a cert context has some special data out there in memory
248 * someplace
249 CERT_CONTEXT copy;
250 memcpy(&copy, context, sizeof(copy));
251 ret = CertDeleteCertificateFromStore(&copy);
252 */
254
255 ok(copy != NULL, "CertDuplicateCertificateContext failed: %08lx\n",
256 GetLastError());
258 ok(ret, "CertDeleteCertificateFromStore failed: %08lx\n",
259 GetLastError());
260 /* try deleting a copy */
262 ok(ret, "CertDeleteCertificateFromStore failed: %08lx\n",
263 GetLastError());
264 /* check that the store is empty */
266 ok(!context, "Expected an empty store\n");
267 }
268
269 /* close an empty store */
270 ret = CertCloseStore(NULL, 0);
271 ok(ret, "CertCloseStore failed: %ld\n", GetLastError());
272 ret = CertCloseStore(store1, 0);
273 ok(ret, "CertCloseStore failed: %ld\n", GetLastError());
274 ret = CertCloseStore(store2, 0);
275 ok(ret, "CertCloseStore failed: %ld\n", GetLastError());
276
277 /* This seems nonsensical, but you can open a read-only mem store, only
278 * it isn't read-only
279 */
282 ok(store1 != NULL, "CertOpenStore failed: %ld\n", GetLastError());
283 /* yep, this succeeds */
286 ok(ret, "CertAddEncodedCertificateToStore failed: %08lx\n", GetLastError());
287 ok(context != NULL, "Expected a valid cert context\n");
288 if (context)
289 {
290 ok(context->cbCertEncoded == sizeof(bigCert),
291 "Wrong cert size %ld\n", context->cbCertEncoded);
292 ok(!memcmp(context->pbCertEncoded, bigCert, sizeof(bigCert)),
293 "Unexpected encoded cert in context\n");
294 ok(context->hCertStore == store1, "Unexpected store\n");
296 ok(ret, "CertDeleteCertificateFromStore failed: %08lx\n",
297 GetLastError());
298 }
299 CertCloseStore(store1, 0);
300}
301
302static void compareStore(HCERTSTORE store, LPCSTR name, const BYTE *pb,
303 DWORD cb, BOOL todo)
304{
305 BOOL ret;
306 CRYPT_DATA_BLOB blob = { 0, NULL };
307
310 ok(ret, "CertSaveStore failed: %08lx\n", GetLastError());
312 ok(blob.cbData == cb, "%s: expected size %ld, got %ld\n", name, cb,
313 blob.cbData);
314 blob.pbData = malloc(blob.cbData);
315 if (blob.pbData)
316 {
319 ok(ret, "CertSaveStore failed: %08lx\n", GetLastError());
321 ok(!memcmp(pb, blob.pbData, cb), "%s: unexpected value\n", name);
322 free(blob.pbData);
323 }
324}
325
327 0x00,0x00,0x00,0x00,0x43,0x45,0x52,0x54,0x20,0x00,0x00,0x00,0x01,0x00,0x00,
328 0x00,0x7c,0x00,0x00,0x00,0x30,0x7a,0x02,0x01,0x01,0x30,0x02,0x06,0x00,0x30,
329 0x15,0x31,0x13,0x30,0x11,0x06,0x03,0x55,0x04,0x03,0x13,0x0a,0x4a,0x75,0x61,
330 0x6e,0x20,0x4c,0x61,0x6e,0x67,0x00,0x30,0x22,0x18,0x0f,0x31,0x36,0x30,0x31,
331 0x30,0x31,0x30,0x31,0x30,0x30,0x30,0x30,0x30,0x30,0x5a,0x18,0x0f,0x31,0x36,
332 0x30,0x31,0x30,0x31,0x30,0x31,0x30,0x30,0x30,0x30,0x30,0x30,0x5a,0x30,0x15,
333 0x31,0x13,0x30,0x11,0x06,0x03,0x55,0x04,0x03,0x13,0x0a,0x4a,0x75,0x61,0x6e,
334 0x20,0x4c,0x61,0x6e,0x67,0x00,0x30,0x07,0x30,0x02,0x06,0x00,0x03,0x01,0x00,
335 0xa3,0x16,0x30,0x14,0x30,0x12,0x06,0x03,0x55,0x1d,0x13,0x01,0x01,0xff,0x04,
336 0x08,0x30,0x06,0x01,0x01,0xff,0x02,0x01,0x01,0x00,0x00,0x00,0x00,0x00,0x00,
337 0x00,0x00,0x00,0x00,0x00,0x00 };
338
339static const struct
340{
348 {'R','O','O','T',0}, CERT_LOCAL_MACHINE_SYSTEM_STORE_REGPATH },
353 /* Adding to HKCU\Root triggers safety warning. */
359
360/* Testing whether system stores are available for adding new certs
361 * and checking directly in the registry whether they are actually saved or deleted.
362 * Windows treats HKCU\My (at least) as a special case and uses AppData directory
363 * for storing certs, not registry.
364 */
365static void testRegStoreSavedCerts(void)
366{
368 HCERTSTORE store;
369 HANDLE cert_file;
370 HRESULT pathres;
371 WCHAR key_name[MAX_PATH], appdata_path[MAX_PATH];
372 HKEY key;
373 BOOL ret;
374 DWORD res,i;
375
376 for (i = 0; i < ARRAY_SIZE(reg_store_saved_certs); i++)
377 {
378 DWORD err;
379
382
383 err = GetLastError();
384 if (!store)
385 {
386 ok (err == ERROR_ACCESS_DENIED, "Failed to create store at %ld (%08lx)\n", i, err);
387 skip("Insufficient privileges for the test %ld\n", i);
388 continue;
389 }
390 ok (store!=NULL, "Failed to open the store at %ld, %lx\n", i, GetLastError());
392 ok (cert1 != NULL, "Create cert context failed at %ld, %lx\n", i, GetLastError());
394 /* Additional skip per Win7, it allows opening HKLM store, but disallows adding certs */
395 err = GetLastError();
396 if (!ret)
397 {
398 ok (err == ERROR_ACCESS_DENIED, "Failed to add certificate to store at %ld (%08lx)\n", i, err);
399 skip("Insufficient privileges for the test %ld\n", i);
400 continue;
401 }
402 ok (ret, "Adding to the store failed at %ld, %lx\n", i, err);
404 CertCloseStore(store, 0);
405
407 reg_store_saved_certs[i].store_name, L"Certificates", L"6E3090715FD92356EBAE2540E622DA192602A608");
408
410 {
412 ok (!res, "The cert hasn't been saved at %ld, %lx\n", i, GetLastError());
413 if (!res) RegCloseKey(key);
414 } else
415 {
416 pathres = SHGetFolderPathW(NULL, CSIDL_APPDATA, NULL, 0, appdata_path);
417 ok (pathres == S_OK,
418 "Failed to get app data path at %ld (%lx)\n", pathres, GetLastError());
419 if (pathres == S_OK)
420 {
421 PathAppendW(appdata_path, L"Microsoft\\SystemCertificates");
423 PathAppendW(appdata_path, L"Certificates");
424 PathAppendW(appdata_path, L"6E3090715FD92356EBAE2540E622DA192602A608");
425
426 cert_file = CreateFileW(appdata_path, GENERIC_READ, 0, NULL,
428 todo_wine ok (cert_file != INVALID_HANDLE_VALUE,
429 "Cert was not saved in AppData at %ld (%lx)\n", i, GetLastError());
430 CloseHandle(cert_file);
431 }
432 }
433
434 /* deleting cert from store */
437 ok (store!=NULL, "Failed to open the store at %ld, %lx\n", i, GetLastError());
438
440 ok (cert1 != NULL, "Create cert context failed at %ld, %lx\n", i, GetLastError());
441
444 ok (cert2 != NULL, "Failed to find cert in the store at %ld, %lx\n", i, GetLastError());
445
447 ok (ret, "Failed to delete certificate from store at %ld, %lx\n", i, GetLastError());
448
451 CertCloseStore(store, 0);
452
454 ok (res, "The cert's registry entry should be absent at %li, %lx\n", i, GetLastError());
455 if (!res) RegCloseKey(key);
456
458 {
459 cert_file = CreateFileW(appdata_path, GENERIC_READ, 0, NULL,
461 ok (cert_file == INVALID_HANDLE_VALUE,
462 "Cert should have been absent in AppData %ld\n", i);
463
464 CloseHandle(cert_file);
465 }
466 }
467}
468
473static void testStoresInCollection(void)
474{
475 PCCERT_CONTEXT cert1, cert2, tcert1;
476 HCERTSTORE collection, ro_store, rw_store, rw_store_2, tstore;
477 BOOL ret;
478
481 ok(collection != NULL, "Failed to init collection store, last error %lx\n", GetLastError());
482 /* Add read-only store to collection with very high priority*/
484 CERT_SYSTEM_STORE_CURRENT_USER, L"WineTest_RO");
485 ok(ro_store != NULL, "Failed to init ro store %lx\n", GetLastError());
486
487 ret = CertAddStoreToCollection(collection, ro_store, 0, 1000);
488 ok (ret, "Failed to add read-only store to collection %lx\n", GetLastError());
489
491 ok (cert1 != NULL, "Create cert context failed %lx\n", GetLastError());
493 ok (!ret, "Added cert to collection with single read-only store %lx\n", GetLastError());
494
495 /* Add read-write store to collection with the lowest priority*/
497 CERT_SYSTEM_STORE_CURRENT_USER, L"WineTest_RW");
498 ok (rw_store != NULL, "Failed to open rw store %lx\n", GetLastError());
500 ok (ret, "Failed to add rw store to collection %lx\n", GetLastError());
504 ok (ret, "Failed to add cert to the collection %lx\n", GetLastError());
505
506 tcert1 = CertEnumCertificatesInStore(ro_store, NULL);
507 ok (!tcert1, "Read-only ro_store contains cert\n");
508
509 tcert1 = CertEnumCertificatesInStore(rw_store, NULL);
510 ok (cert1 && tcert1->cbCertEncoded == cert1->cbCertEncoded,
511 "Unexpected cert in the rw store\n");
513
515 ok (tcert1 && tcert1->cbCertEncoded == cert1->cbCertEncoded,
516 "Unexpected cert in the collection\n");
518
521 CERT_SYSTEM_STORE_CURRENT_USER, L"WineTest_RW2");
522 ok (rw_store_2 != NULL, "Failed to init second rw store %lx\n", GetLastError());
524 ok (ret, "Failed to add rw_store_2 to collection %lx\n",GetLastError());
525
527 ok (cert2 != NULL, "Failed to create cert context %lx\n", GetLastError());
529 ok (ret, "Failed to add cert2 to the store %lx\n",GetLastError());
530
532 tcert1 = CertEnumCertificatesInStore(ro_store, 0);
533 ok (tcert1 == NULL, "Read-only store not empty\n");
534
535 tcert1 = CertEnumCertificatesInStore(rw_store, NULL);
536 ok (tcert1 && tcert1->cbCertEncoded == cert1->cbCertEncoded,
537 "Unexpected cert in the rw_store\n");
539
540 tcert1 = CertEnumCertificatesInStore(rw_store_2, NULL);
541 ok (tcert1 && tcert1->cbCertEncoded == cert2->cbCertEncoded,
542 "Unexpected cert in the rw_store_2\n");
544
547 ok (tcert1 && tcert1->cbCertEncoded == cert2->cbCertEncoded,
548 "cert2 expected in the collection got %p, %lx\n",tcert1, GetLastError());
549 tcert1 = CertEnumCertificatesInStore(collection, tcert1);
550 ok (tcert1 && tcert1->cbCertEncoded == cert1->cbCertEncoded,
551 "cert1 expected in the collection got %p, %lx\n",tcert1, GetLastError());
552 tcert1 = CertEnumCertificatesInStore(collection, tcert1);
553 ok (tcert1==NULL,"Unexpected cert in the collection %p %lx\n",tcert1, GetLastError());
554
555 /* checking whether certs had been saved */
558 ok (tstore!=NULL, "Failed to open existing rw store\n");
559 tcert1 = CertEnumCertificatesInStore(tstore, NULL);
561 ok(tcert1 && tcert1->cbCertEncoded == cert1->cbCertEncoded, "cert1 wasn't saved\n");
563 CertCloseStore(tstore,0);
564
567 ok (tstore!=NULL, "Failed to open existing rw2 store\n");
568 tcert1 = CertEnumCertificatesInStore(tstore, NULL);
570 ok (tcert1 && tcert1->cbCertEncoded == cert2->cbCertEncoded, "cert2 wasn't saved\n");
572 CertCloseStore(tstore,0);
573
575 CertCloseStore(ro_store,0);
576 CertCloseStore(rw_store,0);
577 CertCloseStore(rw_store_2,0);
578
579 /* reopening registry stores to check whether certs had been saved */
581 CERT_SYSTEM_STORE_CURRENT_USER, L"WineTest_RW");
582 tcert1 = CertEnumCertificatesInStore(rw_store, NULL);
583 ok (tcert1 && tcert1->cbCertEncoded == cert1->cbCertEncoded,
584 "Unexpected cert in store %p\n", tcert1);
586 CertCloseStore(rw_store,0);
587
589 CERT_SYSTEM_STORE_CURRENT_USER, L"WineTest_RW2");
590 tcert1 = CertEnumCertificatesInStore(rw_store_2, NULL);
591 ok (tcert1 && tcert1->cbCertEncoded == cert2->cbCertEncoded,
592 "Unexpected cert in store %p\n", tcert1);
594 CertCloseStore(rw_store_2,0);
595
604
605}
606
607static void testCollectionStore(void)
608{
609 HCERTSTORE store1, store2, collection, collection2;
611 BOOL ret;
613 HANDLE file;
614
617
618 /* Try adding a cert to any empty collection */
622 "Expected E_ACCESSDENIED, got %08lx\n", GetLastError());
623
624 /* Create and add a cert to a memory store */
629 ok(ret, "CertAddEncodedCertificateToStore failed: %08lx\n", GetLastError());
630 /* Add the memory store to the collection, without allowing adding */
631 ret = CertAddStoreToCollection(collection, store1, 0, 0);
632 ok(ret, "CertAddStoreToCollection failed: %08lx\n", GetLastError());
633 /* Verify the cert is in the collection */
635 ok(context != NULL, "Expected a valid context\n");
636 if (context)
637 {
638 ok(context->hCertStore == collection, "Unexpected store\n");
640 }
641 /* Check that adding to the collection isn't allowed */
645 "Expected E_ACCESSDENIED, got %08lx\n", GetLastError());
646
647 /* Create a new memory store */
650 /* Try adding a store to a non-collection store */
651 ret = CertAddStoreToCollection(store1, store2,
654 "Expected E_INVALIDARG, got %08lx\n", GetLastError());
655 /* Try adding some bogus stores */
656 /* This crashes in Windows
657 ret = pCertAddStoreToCollection(0, store2,
658 CERT_PHYSICAL_STORE_ADD_ENABLE_FLAG, 0);
659 */
660 /* This "succeeds"... */
663 ok(ret, "CertAddStoreToCollection failed: %08lx\n", GetLastError());
664 /* while this crashes.
665 ret = pCertAddStoreToCollection(collection, 1,
666 CERT_PHYSICAL_STORE_ADD_ENABLE_FLAG, 0);
667 */
668
669 /* Add it to the collection, this time allowing adding */
672 ok(ret, "CertAddStoreToCollection failed: %08lx\n", GetLastError());
673 /* Check that adding to the collection is allowed */
676 ok(ret, "CertAddEncodedCertificateToStore failed: %08lx\n", GetLastError());
677 /* Now check that it was actually added to store2 */
679 ok(context != NULL, "Expected a valid context\n");
680 if (context)
681 {
682 ok(context->hCertStore == store2, "Unexpected store\n");
684 }
685 /* Check that the collection has both bigCert and bigCert2. bigCert comes
686 * first because store1 was added first.
687 */
689 ok(context != NULL, "Expected a valid context\n");
690 if (context)
691 {
692 ok(context->hCertStore == collection, "Unexpected store\n");
693 ok(context->cbCertEncoded == sizeof(bigCert),
694 "Wrong size %ld\n", context->cbCertEncoded);
695 ok(!memcmp(context->pbCertEncoded, bigCert, context->cbCertEncoded),
696 "Unexpected cert\n");
698 ok(context != NULL, "Expected a valid context\n");
699 if (context)
700 {
701 ok(context->hCertStore == collection, "Unexpected store\n");
702 ok(context->cbCertEncoded == sizeof(bigCert2),
703 "Wrong size %ld\n", context->cbCertEncoded);
704 ok(!memcmp(context->pbCertEncoded, bigCert2,
705 context->cbCertEncoded), "Unexpected cert\n");
707 ok(!context, "Unexpected cert\n");
708 }
709 }
710 /* close store2, and check that the collection is unmodified */
711 CertCloseStore(store2, 0);
713 ok(context != NULL, "Expected a valid context\n");
714 if (context)
715 {
716 ok(context->hCertStore == collection, "Unexpected store\n");
717 ok(context->cbCertEncoded == sizeof(bigCert),
718 "Wrong size %ld\n", context->cbCertEncoded);
719 ok(!memcmp(context->pbCertEncoded, bigCert, context->cbCertEncoded),
720 "Unexpected cert\n");
722 ok(context != NULL, "Expected a valid context\n");
723 if (context)
724 {
725 ok(context->hCertStore == collection, "Unexpected store\n");
726 ok(context->cbCertEncoded == sizeof(bigCert2),
727 "Wrong size %ld\n", context->cbCertEncoded);
728 ok(!memcmp(context->pbCertEncoded, bigCert2,
729 context->cbCertEncoded), "Unexpected cert\n");
731 ok(!context, "Unexpected cert\n");
732 }
733 }
734
735 /* Adding a collection to a collection is legal */
736 collection2 = CertOpenStore(CERT_STORE_PROV_COLLECTION, 0, 0,
740 ok(ret, "CertAddStoreToCollection failed: %08lx\n", GetLastError());
741 /* check the contents of collection2 */
743 ok(context != NULL, "Expected a valid context\n");
744 if (context)
745 {
746 ok(context->hCertStore == collection2, "Unexpected store\n");
747 ok(context->cbCertEncoded == sizeof(bigCert),
748 "Wrong size %ld\n", context->cbCertEncoded);
749 ok(!memcmp(context->pbCertEncoded, bigCert, context->cbCertEncoded),
750 "Unexpected cert\n");
752 ok(context != NULL, "Expected a valid context\n");
753 if (context)
754 {
755 ok(context->hCertStore == collection2, "Unexpected store\n");
756 ok(context->cbCertEncoded == sizeof(bigCert2),
757 "Wrong size %ld\n", context->cbCertEncoded);
758 ok(!memcmp(context->pbCertEncoded, bigCert2,
759 context->cbCertEncoded), "Unexpected cert\n");
761 ok(!context, "Unexpected cert\n");
762 }
763 }
764
765 /* I'd like to test closing the collection in the middle of enumeration,
766 * but my tests have been inconsistent. The first time calling
767 * CertEnumCertificatesInStore on a closed collection succeeded, while the
768 * second crashed. So anything appears to be fair game.
769 * I'd also like to test removing a store from a collection in the middle
770 * of an enumeration, but my tests in Windows have been inconclusive.
771 * In one scenario it worked. In another scenario, about a third of the
772 * time this leads to "random" crashes elsewhere in the code. This
773 * probably means this is not allowed.
774 */
775
776 CertCloseStore(store1, 0);
778 CertCloseStore(collection2, 0);
779
780 /* Add the same cert to two memory stores, then put them in a collection */
783 ok(store1 != 0, "CertOpenStore failed: %08lx\n", GetLastError());
786 ok(store2 != 0, "CertOpenStore failed: %08lx\n", GetLastError());
787
790 ok(ret, "CertAddEncodedCertificateToStore failed: %08lx\n", GetLastError());
793 ok(ret, "CertAddEncodedCertificateToStore failed: %08lx\n", GetLastError());
796 ok(collection != 0, "CertOpenStore failed: %08lx\n", GetLastError());
797
799 ok(ret, "CertAddStoreToCollection failed: %08lx\n", GetLastError());
801 ok(ret, "CertAddStoreToCollection failed: %08lx\n", GetLastError());
802
803 /* Check that the collection has two copies of the same cert */
805 ok(context != NULL, "Expected a valid context\n");
806 if (context)
807 {
808 ok(context->hCertStore == collection, "Unexpected store\n");
809 ok(context->cbCertEncoded == sizeof(bigCert),
810 "Wrong size %ld\n", context->cbCertEncoded);
811 ok(!memcmp(context->pbCertEncoded, bigCert, context->cbCertEncoded),
812 "Unexpected cert\n");
814 ok(context != NULL, "Expected a valid context\n");
815 if (context)
816 {
817 ok(context->hCertStore == collection, "Unexpected store\n");
818 ok(context->cbCertEncoded == sizeof(bigCert),
819 "Wrong size %ld\n", context->cbCertEncoded);
820 ok(!memcmp(context->pbCertEncoded, bigCert, context->cbCertEncoded),
821 "Unexpected cert\n");
823 ok(context == NULL, "Unexpected cert\n");
824 }
825 }
826
827 /* The following would check whether I can delete an identical cert, rather
828 * than one enumerated from the store. It crashes, so that means I must
829 * only call CertDeleteCertificateFromStore with contexts enumerated from
830 * the store.
831 context = CertCreateCertificateContext(X509_ASN_ENCODING, bigCert,
832 sizeof(bigCert));
833 ok(context != NULL, "CertCreateCertificateContext failed: %08x\n",
834 GetLastError());
835 if (context)
836 {
837 ret = CertDeleteCertificateFromStore(collection, context);
838 printf("ret is %d, GetLastError is %08x\n", ret, GetLastError());
839 CertFreeCertificateContext(context);
840 }
841 */
842
843 /* Now check deleting from the collection. */
845 ok(context != NULL, "Expected a valid context\n");
846 if (context)
847 {
849 /* store1 should now be empty */
851 ok(!context, "Unexpected cert\n");
852 /* and there should be one certificate in the collection */
854 ok(context != NULL, "Expected a valid cert\n");
855 if (context)
856 {
857 ok(context->hCertStore == collection, "Unexpected store\n");
858 ok(context->cbCertEncoded == sizeof(bigCert),
859 "Wrong size %ld\n", context->cbCertEncoded);
860 ok(!memcmp(context->pbCertEncoded, bigCert, context->cbCertEncoded),
861 "Unexpected cert\n");
862 }
864 ok(context == NULL, "Unexpected cert\n");
865 }
866
867 /* Finally, test removing stores from the collection. No return
868 * value, so it's a bit funny to test.
869 */
870 /* This crashes
871 * CertRemoveStoreFromCollection(NULL, NULL);
872 */
873 /* This "succeeds," no crash, no last error set */
874 SetLastError(0xdeadbeef);
876 ok(GetLastError() == 0xdeadbeef,
877 "Didn't expect an error to be set: %08lx\n", GetLastError());
878
879 /* After removing store2, the collection should be empty */
880 SetLastError(0xdeadbeef);
882 ok(GetLastError() == 0xdeadbeef,
883 "Didn't expect an error to be set: %08lx\n", GetLastError());
885 ok(!context, "Unexpected cert\n");
886
888 CertCloseStore(store2, 0);
889 CertCloseStore(store1, 0);
890
891 /* Test adding certificates to and deleting certificates from collections.
892 */
893 store1 = CertOpenSystemStoreA(0, "My");
896
899 ok(ret, "CertAddEncodedCertificateToStore failed: %08lx\n", GetLastError());
901
903
906 ok(ret, "CertAddEncodedCertificateToStore failed: %08lx\n", GetLastError());
908
910 CertCloseStore(store1, 0);
911
912 /* Test whether a collection store can be committed */
915
916 SetLastError(0xdeadbeef);
918 ok(ret, "CertControlStore failed: %08lx\n", GetLastError());
919
920 /* Adding a mem store that can't be committed prevents a successful commit.
921 */
925 SetLastError(0xdeadbeef);
928 "expected ERROR_CALL_NOT_IMPLEMENTED, got %ld\n", GetLastError());
930 CertCloseStore(store1, 0);
931
932 /* Test adding a cert to a collection with a file store, committing the
933 * change to the collection, and comparing the resulting file.
934 */
935 if (!GetTempFileNameW(L".", L"cer", 0, filename))
936 return;
937
942 return;
943
944 store1 = CertOpenStore(CERT_STORE_PROV_FILE, 0, 0,
946 ok(store1 != NULL, "CertOpenStore failed: %08lx\n", GetLastError());
949 CertCloseStore(store1, 0);
950
953 ok(ret, "CertAddEncodedCertificateToStore failed: %08lx\n",
954 GetLastError());
956 ok(ret, "CertControlStore failed: %d\n", ret);
957 compareStore(collection, "serialized store with cert",
960
962}
963
964/* Looks for the property with ID propID in the buffer buf. Returns a pointer
965 * to its header if found, NULL if not.
966 */
967static const struct CertPropIDHeader *findPropID(const BYTE *buf, DWORD size,
969{
970 const struct CertPropIDHeader *ret = NULL;
971 BOOL failed = FALSE;
972
973 while (size && !ret && !failed)
974 {
975 if (size < sizeof(struct CertPropIDHeader))
976 failed = TRUE;
977 else
978 {
979 const struct CertPropIDHeader *hdr =
980 (const struct CertPropIDHeader *)buf;
981
982 size -= sizeof(struct CertPropIDHeader);
983 buf += sizeof(struct CertPropIDHeader);
984 if (size < hdr->cb)
985 failed = TRUE;
986 else if (hdr->propID == propID)
987 ret = hdr;
988 else
989 {
990 buf += hdr->cb;
991 size -= hdr->cb;
992 }
993 }
994 }
995 return ret;
996}
997
998static void testRegStore(void)
999{
1000 static const char tempKey[] = "Software\\Wine\\CryptTemp";
1001 HCERTSTORE store;
1002 LONG rc;
1003 HKEY key = NULL;
1004 DWORD disp, GLE;
1005
1006 store = CertOpenStore(CERT_STORE_PROV_REG, 0, 0, 0, NULL);
1007 GLE = GetLastError();
1008 ok(!store && (GLE == ERROR_INVALID_HANDLE || GLE == ERROR_BADKEY),
1009 "Expected ERROR_INVALID_HANDLE or ERROR_BADKEY, got %ld\n", GLE);
1010 store = CertOpenStore(CERT_STORE_PROV_REG, 0, 0, 0, key);
1011 GLE = GetLastError();
1012 ok(!store && (GLE == ERROR_INVALID_HANDLE || GLE == ERROR_BADKEY),
1013 "Expected ERROR_INVALID_HANDLE or ERROR_BADKEY, got %ld\n", GLE);
1014
1015 /* Opening up any old key works.. */
1017 store = CertOpenStore(CERT_STORE_PROV_REG, 0, 0, 0, key);
1018 /* Not sure if this is a bug in DuplicateHandle, marking todo_wine for now
1019 */
1020 todo_wine ok(store != 0, "CertOpenStore failed: %08lx\n", GetLastError());
1021 CertCloseStore(store, 0);
1022
1024 NULL, &key, NULL);
1025 ok(!rc, "RegCreateKeyExA failed: %ld\n", rc);
1026 if (key)
1027 {
1028 BOOL ret;
1029 BYTE hash[20];
1030 DWORD size, i;
1031 static const char certificates[] = "Certificates\\";
1032 char subKeyName[sizeof(certificates) + 20 * 2 + 1], *ptr;
1033 HKEY subKey;
1035
1036 store = CertOpenStore(CERT_STORE_PROV_REG, 0, 0, 0, key);
1037 ok(store != 0, "CertOpenStore failed: %08lx\n", GetLastError());
1038 /* Add a certificate. It isn't persisted right away, since it's only
1039 * added to the cache..
1040 */
1043 ok(ret, "CertAddEncodedCertificateToStore failed: %08lx\n",
1044 GetLastError());
1045 /* so flush the cache to force a commit.. */
1047 ok(ret, "CertControlStore failed: %08lx\n", GetLastError());
1048 /* and check that the expected subkey was written. */
1049 size = sizeof(hash);
1050 ret = CryptHashCertificate(0, 0, 0, bigCert2, sizeof(bigCert2),
1051 hash, &size);
1052 ok(ret, "CryptHashCertificate failed: %ld\n", GetLastError());
1053 strcpy(subKeyName, certificates);
1054 for (i = 0, ptr = subKeyName + sizeof(certificates) - 1; i < size;
1055 i++, ptr += 2)
1056 sprintf(ptr, "%02X", hash[i]);
1057 rc = RegCreateKeyExA(key, subKeyName, 0, NULL, 0, KEY_ALL_ACCESS, NULL,
1058 &subKey, NULL);
1059 ok(!rc, "RegCreateKeyExA failed: %ld\n", rc);
1060 if (subKey)
1061 {
1062 LPBYTE buf;
1063
1064 size = 0;
1065 RegQueryValueExA(subKey, "Blob", NULL, NULL, NULL, &size);
1066 buf = malloc(size);
1067 if (buf)
1068 {
1069 rc = RegQueryValueExA(subKey, "Blob", NULL, NULL, buf, &size);
1070 ok(!rc, "RegQueryValueExA failed: %ld\n", rc);
1071 if (!rc)
1072 {
1073 const struct CertPropIDHeader *hdr;
1074
1075 /* Both the hash and the cert should be present */
1077 ok(hdr != NULL, "Expected to find a cert property\n");
1078 if (hdr)
1079 {
1080 ok(hdr->cb == sizeof(bigCert2),
1081 "Wrong size %ld of cert property\n", hdr->cb);
1082 ok(!memcmp((const BYTE *)hdr + sizeof(*hdr), bigCert2,
1083 hdr->cb), "Unexpected cert in cert property\n");
1084 }
1086 ok(hdr != NULL, "Expected to find a hash property\n");
1087 if (hdr)
1088 {
1089 ok(hdr->cb == sizeof(hash),
1090 "Wrong size %ld of hash property\n", hdr->cb);
1091 ok(!memcmp((const BYTE *)hdr + sizeof(*hdr), hash,
1092 hdr->cb), "Unexpected hash in cert property\n");
1093 }
1094 }
1095 free(buf);
1096 }
1097 RegCloseKey(subKey);
1098 }
1099
1100 /* Remove the existing context */
1102 ok(context != NULL, "Expected a cert context\n");
1103 if (context)
1106 ok(ret, "CertControlStore failed: %08lx\n", GetLastError());
1107
1108 /* Add a serialized cert with a bogus hash directly to the registry */
1109 memset(hash, 0, sizeof(hash));
1110 strcpy(subKeyName, certificates);
1111 for (i = 0, ptr = subKeyName + sizeof(certificates) - 1;
1112 i < sizeof(hash); i++, ptr += 2)
1113 sprintf(ptr, "%02X", hash[i]);
1114 rc = RegCreateKeyExA(key, subKeyName, 0, NULL, 0, KEY_ALL_ACCESS, NULL,
1115 &subKey, NULL);
1116 ok(!rc, "RegCreateKeyExA failed: %ld\n", rc);
1117 if (subKey)
1118 {
1119 BYTE buf[sizeof(struct CertPropIDHeader) * 2 + sizeof(hash) +
1120 sizeof(bigCert)], *ptr;
1121 DWORD certCount = 0;
1122 struct CertPropIDHeader *hdr;
1123
1124 hdr = (struct CertPropIDHeader *)buf;
1125 hdr->propID = CERT_HASH_PROP_ID;
1126 hdr->unknown1 = 1;
1127 hdr->cb = sizeof(hash);
1128 ptr = buf + sizeof(*hdr);
1129 memcpy(ptr, hash, sizeof(hash));
1130 ptr += sizeof(hash);
1131 hdr = (struct CertPropIDHeader *)ptr;
1132 hdr->propID = CERT_CERT_PROP_ID;
1133 hdr->unknown1 = 1;
1134 hdr->cb = sizeof(bigCert);
1135 ptr += sizeof(*hdr);
1136 memcpy(ptr, bigCert, sizeof(bigCert));
1137
1138 rc = RegSetValueExA(subKey, "Blob", 0, REG_BINARY, buf,
1139 sizeof(buf));
1140 ok(!rc, "RegSetValueExA failed: %ld\n", rc);
1141
1143 ok(ret, "CertControlStore failed: %08lx\n", GetLastError());
1144
1145 /* Make sure the bogus hash cert gets loaded. */
1146 certCount = 0;
1147 context = NULL;
1148 do {
1150 if (context)
1151 certCount++;
1152 } while (context != NULL);
1153 ok(certCount == 1, "Expected 1 certificates, got %ld\n", certCount);
1154
1155 RegCloseKey(subKey);
1156 }
1157
1158 /* Add another serialized cert directly to the registry, this time
1159 * under the correct key name (named with the correct hash value).
1160 */
1161 size = sizeof(hash);
1163 sizeof(bigCert2), hash, &size);
1164 ok(ret, "CryptHashCertificate failed: %ld\n", GetLastError());
1165 strcpy(subKeyName, certificates);
1166 for (i = 0, ptr = subKeyName + sizeof(certificates) - 1;
1167 i < sizeof(hash); i++, ptr += 2)
1168 sprintf(ptr, "%02X", hash[i]);
1169 rc = RegCreateKeyExA(key, subKeyName, 0, NULL, 0, KEY_ALL_ACCESS, NULL,
1170 &subKey, NULL);
1171 ok(!rc, "RegCreateKeyExA failed: %ld\n", rc);
1172 if (subKey)
1173 {
1174 BYTE buf[sizeof(struct CertPropIDHeader) * 2 + sizeof(hash) +
1175 sizeof(bigCert2)], *ptr;
1176 DWORD certCount = 0;
1178 struct CertPropIDHeader *hdr;
1179
1180 /* First try with a bogus hash... */
1181 hdr = (struct CertPropIDHeader *)buf;
1182 hdr->propID = CERT_HASH_PROP_ID;
1183 hdr->unknown1 = 1;
1184 hdr->cb = sizeof(hash);
1185 ptr = buf + sizeof(*hdr);
1186 memset(ptr, 0, sizeof(hash));
1187 ptr += sizeof(hash);
1188 hdr = (struct CertPropIDHeader *)ptr;
1189 hdr->propID = CERT_CERT_PROP_ID;
1190 hdr->unknown1 = 1;
1191 hdr->cb = sizeof(bigCert2);
1192 ptr += sizeof(*hdr);
1193 memcpy(ptr, bigCert2, sizeof(bigCert2));
1194
1195 rc = RegSetValueExA(subKey, "Blob", 0, REG_BINARY, buf,
1196 sizeof(buf));
1197 ok(!rc, "RegSetValueExA failed: %ld\n", rc);
1198
1200 ok(ret, "CertControlStore failed: %08lx\n", GetLastError());
1201
1202 /* and make sure just one cert still gets loaded. */
1203 certCount = 0;
1204 context = NULL;
1205 do {
1207 if (context)
1208 certCount++;
1209 } while (context != NULL);
1210 ok(certCount == 1, "Expected 1 certificate, got %ld\n", certCount);
1211
1212 /* Try again with the correct hash... */
1213 ptr = buf + sizeof(*hdr);
1214 memcpy(ptr, hash, sizeof(hash));
1215
1216 rc = RegSetValueExA(subKey, "Blob", 0, REG_BINARY, buf,
1217 sizeof(buf));
1218 ok(!rc, "RegSetValueExA failed: %ld\n", rc);
1219
1221 ok(ret, "CertControlStore failed: %08lx\n", GetLastError());
1222
1223 /* and make sure two certs get loaded. */
1224 certCount = 0;
1225 context = NULL;
1226 do {
1228 if (context)
1229 certCount++;
1230 } while (context != NULL);
1231 ok(certCount == 2, "Expected 2 certificates, got %ld\n", certCount);
1232
1233 RegCloseKey(subKey);
1234 }
1235 CertCloseStore(store, 0);
1236 /* Is delete allowed on a reg store? */
1237 store = CertOpenStore(CERT_STORE_PROV_REG, 0, 0,
1239 ok(store == NULL, "Expected NULL return from CERT_STORE_DELETE_FLAG\n");
1240 ok(GetLastError() == 0, "CertOpenStore failed: %08lx\n",
1241 GetLastError());
1242
1244 }
1245 /* The CertOpenStore with CERT_STORE_DELETE_FLAG above will delete the
1246 * contents of the key, but not the key itself.
1247 */
1249 NULL, &key, &disp);
1250 ok(!rc, "RegCreateKeyExA failed: %ld\n", rc);
1252 "Expected REG_OPENED_EXISTING_KEY, got %ld\n", disp);
1253 if (!rc)
1254 {
1256 rc = RegDeleteKeyA(HKEY_CURRENT_USER, tempKey);
1257 if (rc)
1258 {
1259 /* Use shlwapi's SHDeleteKeyA to _really_ blow away the key,
1260 * otherwise subsequent tests will fail.
1261 */
1263 }
1264 }
1265}
1266
1267static void testSystemRegStore(void)
1268{
1269 HCERTSTORE store, memStore;
1270
1271 /* Check with a UNICODE name */
1274 /* Not all OSes support CERT_STORE_PROV_SYSTEM_REGISTRY, so don't continue
1275 * testing if they don't.
1276 */
1277 if (!store)
1278 return;
1279
1280 /* Check that it isn't a collection store */
1281 memStore = CertOpenStore(CERT_STORE_PROV_MEMORY, 0, 0,
1283 if (memStore)
1284 {
1285 BOOL ret = CertAddStoreToCollection(store, memStore, 0, 0);
1286 ok(!ret && GetLastError() == E_INVALIDARG, "Expected E_INVALIDARG, got %08lx\n", GetLastError());
1287 CertCloseStore(memStore, 0);
1288 }
1289 CertCloseStore(store, 0);
1290
1291 /* Check opening a bogus store */
1294 ok(!store && GetLastError() == ERROR_FILE_NOT_FOUND,
1295 "Expected ERROR_FILE_NOT_FOUND, got %08lx\n", GetLastError());
1298 ok(store != 0, "CertOpenStore failed: %08lx\n", GetLastError());
1299 if (store)
1300 CertCloseStore(store, 0);
1301 /* Now check whether deleting is allowed */
1304 ok(!store, "CertOpenStore failed: %08lx\n", GetLastError());
1305 RegDeleteKeyW(HKEY_CURRENT_USER, L"Software\\Microsoft\\SystemCertificates\\Bogus");
1306
1308 ok(!store && GetLastError() == E_INVALIDARG,
1309 "Expected E_INVALIDARG, got %08lx\n", GetLastError());
1312 ok(!store && GetLastError() == E_INVALIDARG,
1313 "Expected E_INVALIDARG, got %08lx\n", GetLastError());
1316 ok(!store && GetLastError() == E_INVALIDARG,
1317 "Expected E_INVALIDARG, got %08lx\n", GetLastError());
1318 /* The name is expected to be UNICODE, check with an ASCII name */
1321 ok(!store && GetLastError() == ERROR_FILE_NOT_FOUND,
1322 "Expected ERROR_FILE_NOT_FOUND, got %08lx\n", GetLastError());
1323}
1324
1325static void testSystemStore(void)
1326{
1327 HCERTSTORE store;
1328 WCHAR keyName[MAX_PATH];
1329 HKEY key;
1330 LONG rc;
1331
1332 store = CertOpenStore(CERT_STORE_PROV_SYSTEM, 0, 0, 0, NULL);
1333 ok(!store && GetLastError() == ERROR_FILE_NOT_FOUND,
1334 "Expected ERROR_FILE_NOT_FOUND, got %08lx\n", GetLastError());
1337 ok(!store && GetLastError() == ERROR_FILE_NOT_FOUND,
1338 "Expected ERROR_FILE_NOT_FOUND, got %08lx\n", GetLastError());
1341 ok(!store && GetLastError() == ERROR_FILE_NOT_FOUND,
1342 "Expected ERROR_FILE_NOT_FOUND, got %08lx\n", GetLastError());
1343 /* The name is expected to be UNICODE, first check with an ASCII name */
1346 ok(!store && GetLastError() == ERROR_FILE_NOT_FOUND,
1347 "Expected ERROR_FILE_NOT_FOUND, got %08lx\n", GetLastError());
1348 /* Create the expected key */
1350 lstrcatW(keyName, L"\\My");
1351 rc = RegCreateKeyExW(HKEY_CURRENT_USER, keyName, 0, NULL, 0, KEY_READ,
1352 NULL, &key, NULL);
1353 ok(!rc, "RegCreateKeyEx failed: %ld\n", rc);
1354 if (!rc)
1356 /* Check opening with a UNICODE name, specifying the create new flag */
1359 ok(!store && GetLastError() == ERROR_FILE_EXISTS,
1360 "Expected ERROR_FILE_EXISTS, got %08lx\n", GetLastError());
1361 /* Now check opening with a UNICODE name, this time opening existing */
1364 ok(store != 0, "CertOpenStore failed: %08lx\n", GetLastError());
1365 if (store)
1366 {
1369
1370 /* Check that it's a collection store */
1371 if (memStore)
1372 {
1373 BOOL ret = CertAddStoreToCollection(store, memStore, 0, 0);
1374 ok(ret, "CertAddStoreToCollection failed: %08lx\n", GetLastError());
1375 CertCloseStore(memStore, 0);
1376 }
1377 CertCloseStore(store, 0);
1378 }
1379
1380 /* Check opening a bogus store */
1383 ok(!store, "Expected ERROR_FILE_NOT_FOUND, got %08lx\n", GetLastError());
1386 ok(store != 0, "CertOpenStore failed: %08lx\n", GetLastError());
1387 if (store)
1388 CertCloseStore(store, 0);
1389 /* Now check whether deleting is allowed */
1392 ok(!store, "Didn't expect a store to be returned when deleting\n");
1393 RegDeleteKeyW(HKEY_CURRENT_USER, L"Software\\Microsoft\\SystemCertificates\\Bogus");
1394}
1395
1397 0x00,0x00,0x00,0x00,0x43,0x45,0x52,0x54,0x20,0x00,0x00,0x00,0x01,0x00,0x00,
1398 0x00,0x7c,0x00,0x00,0x00,0x30,0x7a,0x02,0x01,0x01,0x30,0x02,0x06,0x00,0x30,
1399 0x15,0x31,0x13,0x30,0x11,0x06,0x03,0x55,0x04,0x03,0x13,0x0a,0x4a,0x75,0x61,
1400 0x6e,0x20,0x4c,0x61,0x6e,0x67,0x00,0x30,0x22,0x18,0x0f,0x31,0x36,0x30,0x31,
1401 0x30,0x31,0x30,0x31,0x30,0x30,0x30,0x30,0x30,0x30,0x5a,0x18,0x0f,0x31,0x36,
1402 0x30,0x31,0x30,0x31,0x30,0x31,0x30,0x30,0x30,0x30,0x30,0x30,0x5a,0x30,0x15,
1403 0x31,0x13,0x30,0x11,0x06,0x03,0x55,0x04,0x03,0x13,0x0a,0x4a,0x75,0x61,0x6e,
1404 0x20,0x4c,0x61,0x6e,0x67,0x00,0x30,0x07,0x30,0x02,0x06,0x00,0x03,0x01,0x00,
1405 0xa3,0x16,0x30,0x14,0x30,0x12,0x06,0x03,0x55,0x1d,0x13,0x01,0x01,0xff,0x04,
1406 0x08,0x30,0x06,0x01,0x01,0xff,0x02,0x01,0x01,0x21,0x00,0x00,0x00,0x01,0x00,
1407 0x00,0x00,0x47,0x00,0x00,0x00,0x30,0x45,0x30,0x2c,0x30,0x02,0x06,0x00,0x30,
1408 0x15,0x31,0x13,0x30,0x11,0x06,0x03,0x55,0x04,0x03,0x13,0x0a,0x4a,0x75,0x61,
1409 0x6e,0x20,0x4c,0x61,0x6e,0x67,0x00,0x18,0x0f,0x31,0x36,0x30,0x31,0x30,0x31,
1410 0x30,0x31,0x30,0x30,0x30,0x30,0x30,0x30,0x5a,0x30,0x02,0x06,0x00,0x03,0x11,
1411 0x00,0x0f,0x0e,0x0d,0x0c,0x0b,0x0a,0x09,0x08,0x07,0x06,0x05,0x04,0x03,0x02,
1412 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 };
1413
1414static void testFileStore(void)
1415{
1417 HCERTSTORE store;
1418 BOOL ret;
1420 HANDLE file;
1421
1422 store = CertOpenStore(CERT_STORE_PROV_FILE, 0, 0, 0, NULL);
1423 ok(!store && GetLastError() == ERROR_INVALID_HANDLE,
1424 "Expected ERROR_INVALID_HANDLE, got %08lx\n", GetLastError());
1425
1426 if (!GetTempFileNameW(L".", L"cer", 0, filename))
1427 return;
1428
1433 return;
1434
1436 file);
1437 ok(!store && GetLastError() == E_INVALIDARG,
1438 "Expected E_INVALIDARG, got %08lx\n", GetLastError());
1439 store = CertOpenStore(CERT_STORE_PROV_FILE, 0, 0,
1441 ok(!store && GetLastError() == E_INVALIDARG,
1442 "Expected E_INVALIDARG, got %08lx\n", GetLastError());
1443
1444 /* A "read-only" file store.. */
1445 store = CertOpenStore(CERT_STORE_PROV_FILE, 0, 0,
1447 ok(store != NULL, "CertOpenStore failed: %08lx\n", GetLastError());
1448 if (store)
1449 {
1450 DWORD size;
1451
1454 /* apparently allows adding certificates.. */
1455 ok(ret, "CertAddEncodedCertificateToStore failed: %d\n", ret);
1456 /* but not commits.. */
1459 "Expected ERROR_CALL_NOT_IMPLEMENTED, got %08lx\n", GetLastError());
1460 /* It still has certs in memory.. */
1462 ok(cert != NULL, "CertEnumCertificatesInStore failed: %08lx\n",
1463 GetLastError());
1465 /* but the file size is still 0. */
1467 ok(size == 0, "Expected size 0, got %ld\n", size);
1468 CertCloseStore(store, 0);
1469 }
1470
1471 /* The create new flag is allowed.. */
1472 store = CertOpenStore(CERT_STORE_PROV_FILE, 0, 0,
1474 ok(store != NULL, "CertOpenStore failed: %08lx\n", GetLastError());
1475 if (store)
1476 {
1477 /* but without the commit enable flag, commits don't happen. */
1480 ok(ret, "CertAddEncodedCertificateToStore failed: %d\n", ret);
1483 "Expected ERROR_CALL_NOT_IMPLEMENTED, got %08lx\n", GetLastError());
1484 CertCloseStore(store, 0);
1485 }
1486 /* as is the open existing flag. */
1487 store = CertOpenStore(CERT_STORE_PROV_FILE, 0, 0,
1489 ok(store != NULL, "CertOpenStore failed: %08lx\n", GetLastError());
1490 if (store)
1491 {
1492 /* but without the commit enable flag, commits don't happen. */
1495 ok(ret, "CertAddEncodedCertificateToStore failed: %d\n", ret);
1498 "Expected ERROR_CALL_NOT_IMPLEMENTED, got %08lx\n", GetLastError());
1499 CertCloseStore(store, 0);
1500 }
1501 store = CertOpenStore(CERT_STORE_PROV_FILE, 0, 0,
1503 ok(store != NULL, "CertOpenStore failed: %08lx\n", GetLastError());
1504 if (store)
1505 {
1509 ok(ret, "CertAddEncodedCertificateToStore failed: %08lx\n",
1510 GetLastError());
1511 /* with commits enabled, commit is allowed */
1513 ok(ret, "CertControlStore failed: %d\n", ret);
1514 compareStore(store, "serialized store with cert",
1516 CertCloseStore(store, 0);
1517 }
1521 return;
1522 store = CertOpenStore(CERT_STORE_PROV_FILE, 0, 0,
1524 ok(store != NULL, "CertOpenStore failed: %08lx\n", GetLastError());
1525 if (store)
1526 {
1530 ok(ret, "CertAddEncodedCRLToStore failed: %08lx\n", GetLastError());
1531 compareStore(store, "serialized store with cert and CRL",
1533 FALSE);
1534 CertCloseStore(store, 0);
1535 }
1536
1538}
1539
1541{
1544 BOOL ret;
1545
1547 {
1548 DWORD written;
1549
1550 ret = WriteFile(file, pb, cb, &written, NULL);
1552 }
1553 else
1554 ret = FALSE;
1555 return ret;
1556}
1557
1558static const BYTE base64SPC[] =
1559"MIICJQYJKoZIhvcNAQcCoIICFjCCAhICAQExADALBgkqhkiG9w0BBwGgggH6MIIB"
1560"9jCCAV+gAwIBAgIQnP8+EF4opr9OxH7h4uBPWTANBgkqhkiG9w0BAQQFADAUMRIw"
1561"EAYDVQQDEwlKdWFuIExhbmcwHhcNMDgxMjEyMTcxMDE0WhcNMzkxMjMxMjM1OTU5"
1562"WjAUMRIwEAYDVQQDEwlKdWFuIExhbmcwgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJ"
1563"AoGBALCgNjyNvOic0FOfjxvi43HbM+D5joDkhiGSXe+gbZlf8f16k07kkObFEunz"
1564"mdB5coscmA7gyqiWNN4ZUyr2cA3lCbnpGPA/0IblyyOcuGIFmmCzeZaVa5ZG6xZP"
1565"K7L7o+73Qo6jXVbGhBGnMZ7Q9sAn6s2933olnStnejnqwV0NAgMBAAGjSTBHMEUG"
1566"A1UdAQQ+MDyAEFKbKEdXYyx+CWKcV6vxM6ShFjAUMRIwEAYDVQQDEwlKdWFuIExh"
1567"bmeCEJz/PhBeKKa/TsR+4eLgT1kwDQYJKoZIhvcNAQEEBQADgYEALpkgLgW3mEaK"
1568"idPQ3iPJYLG0Ub1wraqEl9bd42hrhzIdcDzlQgxnm8/5cHYVxIF/C20x/HJplb1R"
1569"G6U1ipFe/q8byWD/9JpiBKMGPi9YlUTgXHfS9d4S/QWO1h9Z7KeipBYhoslQpHXu"
1570"y9bUr8Adqi6SzgHpCnMu53dxgxUD1r4xAA==";
1571/* Same as base64SPC, but as a wide-char string */
1572static const WCHAR utf16Base64SPC[] =
1573L"MIICJQYJKoZIhvcNAQcCoIICFjCCAhICAQExADALBgkqhkiG9w0BBwGgggH6MIIB"
1574"9jCCAV+gAwIBAgIQnP8+EF4opr9OxH7h4uBPWTANBgkqhkiG9w0BAQQFADAUMRIw"
1575"EAYDVQQDEwlKdWFuIExhbmcwHhcNMDgxMjEyMTcxMDE0WhcNMzkxMjMxMjM1OTU5"
1576"WjAUMRIwEAYDVQQDEwlKdWFuIExhbmcwgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJ"
1577"AoGBALCgNjyNvOic0FOfjxvi43HbM+D5joDkhiGSXe+gbZlf8f16k07kkObFEunz"
1578"mdB5coscmA7gyqiWNN4ZUyr2cA3lCbnpGPA/0IblyyOcuGIFmmCzeZaVa5ZG6xZP"
1579"K7L7o+73Qo6jXVbGhBGnMZ7Q9sAn6s2933olnStnejnqwV0NAgMBAAGjSTBHMEUG"
1580"A1UdAQQ+MDyAEFKbKEdXYyx+CWKcV6vxM6ShFjAUMRIwEAYDVQQDEwlKdWFuIExh"
1581"bmeCEJz/PhBeKKa/TsR+4eLgT1kwDQYJKoZIhvcNAQEEBQADgYEALpkgLgW3mEaK"
1582"idPQ3iPJYLG0Ub1wraqEl9bd42hrhzIdcDzlQgxnm8/5cHYVxIF/C20x/HJplb1R"
1583"G6U1ipFe/q8byWD/9JpiBKMGPi9YlUTgXHfS9d4S/QWO1h9Z7KeipBYhoslQpHXu"
1584"y9bUr8Adqi6SzgHpCnMu53dxgxUD1r4xAA==";
1585
1586static void testFileNameStore(void)
1587{
1589 HCERTSTORE store;
1590 BOOL ret;
1591 DWORD GLE;
1592
1594 GLE = GetLastError();
1596 "Expected ERROR_PATH_NOT_FOUND or ERROR_INVALID_PARAMETER, got %08lx\n",
1597 GLE);
1598
1599 if (!GetTempFileNameW(L".", L"cer", 0, filename))
1600 return;
1602
1603 /* The two flags are mutually exclusive */
1606 ok(!store && GetLastError() == E_INVALIDARG,
1607 "Expected E_INVALIDARG, got %08lx\n", GetLastError());
1608
1609 /* In all of the following tests, the encoding type seems to be ignored */
1611 {
1614
1617 ok(store != NULL, "CertOpenStore failed: %08lx\n", GetLastError());
1618
1620 ok(cert != NULL, "CertEnumCertificatesInStore failed: %08lx\n",
1621 GetLastError());
1623 ok(!cert, "Expected only one cert\n");
1624 crl = CertEnumCRLsInStore(store, NULL);
1625 ok(!crl, "Expected no CRLs\n");
1626
1627 CertCloseStore(store, 0);
1629 }
1631 sizeof(serializedStoreWithCert)))
1632 {
1635
1638 ok(store != NULL, "CertOpenStore failed: %08lx\n", GetLastError());
1639
1641 ok(cert != NULL, "CertEnumCertificatesInStore failed: %08lx\n",
1642 GetLastError());
1644 ok(!cert, "Expected only one cert\n");
1645 crl = CertEnumCRLsInStore(store, NULL);
1646 ok(!crl, "Expected no CRLs\n");
1647
1648 CertCloseStore(store, 0);
1650 }
1653 {
1656
1659 ok(store != NULL, "CertOpenStore failed: %08lx\n", GetLastError());
1660
1662 ok(cert != NULL, "CertEnumCertificatesInStore failed: %08lx\n",
1663 GetLastError());
1665 ok(!cert, "Expected only one cert\n");
1666 crl = CertEnumCRLsInStore(store, NULL);
1667 ok(crl != NULL, "CertEnumCRLsInStore failed: %08lx\n", GetLastError());
1668 crl = CertEnumCRLsInStore(store, crl);
1669 ok(!crl, "Expected only one CRL\n");
1670
1671 CertCloseStore(store, 0);
1672 /* Don't delete it this time, the next test uses it */
1673 }
1674 /* Now that the file exists, we can open it read-only */
1677 ok(store != NULL, "CertOpenStore failed: %08lx\n", GetLastError());
1678 CertCloseStore(store, 0);
1680
1683 ok(store != NULL, "CertOpenStore failed: %08lx\n", GetLastError());
1684 if (store)
1685 {
1688 ok(ret, "CertAddEncodedCertificateToStore failed: %08lx\n",
1689 GetLastError());
1690 compareStore(store, "serialized store with cert",
1692 CertCloseStore(store, 0);
1693 }
1696 ok(store != NULL, "CertOpenStore failed: %08lx\n", GetLastError());
1697 if (store)
1698 {
1701 ok(ret, "CertAddEncodedCRLToStore failed: %08lx\n", GetLastError());
1702 compareStore(store, "serialized store with cert and CRL",
1704 FALSE);
1705 CertCloseStore(store, 0);
1706 }
1708
1709 if (!GetTempFileNameW(L".", L"spc", 0, filename))
1710 return;
1712
1714 {
1717
1720 ok(store != NULL, "CertOpenStore failed: %08lx\n", GetLastError());
1721
1723 ok(cert != NULL, "CertEnumCertificatesInStore failed: %08lx\n",
1724 GetLastError());
1726 ok(!cert, "Expected only one cert\n");
1727 crl = CertEnumCRLsInStore(store, NULL);
1728 ok(!crl, "Expected no CRLs\n");
1729
1730 CertCloseStore(store, 0);
1732 }
1734 sizeof(utf16Base64SPC)))
1735 {
1738
1741 ok(store != NULL, "CertOpenStore failed: %08lx\n", GetLastError());
1742
1744 ok(cert != NULL, "CertEnumCertificatesInStore failed: %08lx\n",
1745 GetLastError());
1747 ok(!cert, "Expected only one cert\n");
1748 crl = CertEnumCRLsInStore(store, NULL);
1749 ok(!crl, "Expected no CRLs\n");
1750
1751 CertCloseStore(store, 0);
1753 }
1754}
1755
1756static const BYTE signedContent[] = {
17570x30,0x81,0xb2,0x06,0x09,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x01,0x07,0x02,0xa0,
17580x81,0xa4,0x30,0x81,0xa1,0x02,0x01,0x01,0x31,0x0e,0x30,0x0c,0x06,0x08,0x2a,
17590x86,0x48,0x86,0xf7,0x0d,0x02,0x05,0x05,0x00,0x30,0x13,0x06,0x09,0x2a,0x86,
17600x48,0x86,0xf7,0x0d,0x01,0x07,0x01,0xa0,0x06,0x04,0x04,0x01,0x02,0x03,0x04,
17610x31,0x77,0x30,0x75,0x02,0x01,0x01,0x30,0x1a,0x30,0x15,0x31,0x13,0x30,0x11,
17620x06,0x03,0x55,0x04,0x03,0x13,0x0a,0x4a,0x75,0x61,0x6e,0x20,0x4c,0x61,0x6e,
17630x67,0x00,0x02,0x01,0x01,0x30,0x0c,0x06,0x08,0x2a,0x86,0x48,0x86,0xf7,0x0d,
17640x02,0x05,0x05,0x00,0x30,0x04,0x06,0x00,0x05,0x00,0x04,0x40,0x81,0xa6,0x70,
17650xb3,0xef,0x59,0xd1,0x66,0xd1,0x9b,0xc0,0x9a,0xb6,0x9a,0x5e,0x6d,0x6f,0x6d,
17660x0d,0x59,0xa9,0xaa,0x6e,0xe9,0x2c,0xa0,0x1e,0xee,0xc2,0x60,0xbc,0x59,0xbe,
17670x3f,0x63,0x06,0x8d,0xc9,0x11,0x1d,0x23,0x64,0x92,0xef,0x2e,0xfc,0x57,0x29,
17680xa4,0xaf,0xe0,0xee,0x93,0x19,0x39,0x51,0xe4,0x44,0xb8,0x0b,0x28,0xf4,0xa8,
17690x0d };
17710x30,0x82,0x01,0x4f,0x02,0x01,0x01,0x31,0x0e,0x30,0x0c,0x06,0x08,0x2a,0x86,
17720x48,0x86,0xf7,0x0d,0x02,0x05,0x05,0x00,0x30,0x13,0x06,0x09,0x2a,0x86,0x48,
17730x86,0xf7,0x0d,0x01,0x07,0x01,0xa0,0x06,0x04,0x04,0x01,0x02,0x03,0x04,0xa0,
17740x7c,0x30,0x7a,0x02,0x01,0x01,0x30,0x02,0x06,0x00,0x30,0x15,0x31,0x13,0x30,
17750x11,0x06,0x03,0x55,0x04,0x03,0x13,0x0a,0x4a,0x75,0x61,0x6e,0x20,0x4c,0x61,
17760x6e,0x67,0x00,0x30,0x22,0x18,0x0f,0x31,0x36,0x30,0x31,0x30,0x31,0x30,0x31,
17770x30,0x30,0x30,0x30,0x30,0x30,0x5a,0x18,0x0f,0x31,0x36,0x30,0x31,0x30,0x31,
17780x30,0x31,0x30,0x30,0x30,0x30,0x30,0x30,0x5a,0x30,0x15,0x31,0x13,0x30,0x11,
17790x06,0x03,0x55,0x04,0x03,0x13,0x0a,0x4a,0x75,0x61,0x6e,0x20,0x4c,0x61,0x6e,
17800x67,0x00,0x30,0x07,0x30,0x02,0x06,0x00,0x03,0x01,0x00,0xa3,0x16,0x30,0x14,
17810x30,0x12,0x06,0x03,0x55,0x1d,0x13,0x01,0x01,0xff,0x04,0x08,0x30,0x06,0x01,
17820x01,0xff,0x02,0x01,0x01,0xa1,0x2e,0x30,0x2c,0x30,0x02,0x06,0x00,0x30,0x15,
17830x31,0x13,0x30,0x11,0x06,0x03,0x55,0x04,0x03,0x13,0x0a,0x4a,0x75,0x61,0x6e,
17840x20,0x4c,0x61,0x6e,0x67,0x00,0x18,0x0f,0x31,0x36,0x30,0x31,0x30,0x31,0x30,
17850x31,0x30,0x30,0x30,0x30,0x30,0x30,0x5a,0x31,0x77,0x30,0x75,0x02,0x01,0x01,
17860x30,0x1a,0x30,0x15,0x31,0x13,0x30,0x11,0x06,0x03,0x55,0x04,0x03,0x13,0x0a,
17870x4a,0x75,0x61,0x6e,0x20,0x4c,0x61,0x6e,0x67,0x00,0x02,0x01,0x01,0x30,0x0c,
17880x06,0x08,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x02,0x05,0x05,0x00,0x30,0x04,0x06,
17890x00,0x05,0x00,0x04,0x40,0x81,0xa6,0x70,0xb3,0xef,0x59,0xd1,0x66,0xd1,0x9b,
17900xc0,0x9a,0xb6,0x9a,0x5e,0x6d,0x6f,0x6d,0x0d,0x59,0xa9,0xaa,0x6e,0xe9,0x2c,
17910xa0,0x1e,0xee,0xc2,0x60,0xbc,0x59,0xbe,0x3f,0x63,0x06,0x8d,0xc9,0x11,0x1d,
17920x23,0x64,0x92,0xef,0x2e,0xfc,0x57,0x29,0xa4,0xaf,0xe0,0xee,0x93,0x19,0x39,
17930x51,0xe4,0x44,0xb8,0x0b,0x28,0xf4,0xa8,0x0d };
1794static const BYTE hashContent[] = {
17950x30,0x47,0x06,0x09,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x01,0x07,0x05,0xa0,0x3a,
17960x30,0x38,0x02,0x01,0x00,0x30,0x0c,0x06,0x08,0x2a,0x86,0x48,0x86,0xf7,0x0d,
17970x02,0x05,0x05,0x00,0x30,0x13,0x06,0x09,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x01,
17980x07,0x01,0xa0,0x06,0x04,0x04,0x01,0x02,0x03,0x04,0x04,0x10,0x08,0xd6,0xc0,
17990x5a,0x21,0x51,0x2a,0x79,0xa1,0xdf,0xeb,0x9d,0x2a,0x8f,0x26,0x2f };
1800static const BYTE hashBareContent[] = {
18010x30,0x38,0x02,0x01,0x00,0x30,0x0c,0x06,0x08,0x2a,0x86,0x48,0x86,0xf7,0x0d,
18020x02,0x05,0x05,0x00,0x30,0x13,0x06,0x09,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x01,
18030x07,0x01,0xa0,0x06,0x04,0x04,0x01,0x02,0x03,0x04,0x04,0x10,0x08,0xd6,0xc0,
18040x5a,0x21,0x51,0x2a,0x79,0xa1,0xdf,0xeb,0x9d,0x2a,0x8f,0x26,0x2f };
1805
1806static void testMessageStore(void)
1807{
1808 HCERTSTORE store;
1810 NULL);
1813 DWORD count, size;
1814 BOOL ret;
1815
1816 /* Crashes
1817 store = CertOpenStore(CERT_STORE_PROV_MSG, 0, 0, 0, NULL);
1818 */
1819 SetLastError(0xdeadbeef);
1820 store = CertOpenStore(CERT_STORE_PROV_MSG, 0, 0, 0, msg);
1822 "Expected CRYPT_E_INVALID_MSG_TYPE, got %08lx\n", GetLastError());
1824 store = CertOpenStore(CERT_STORE_PROV_MSG, 0, 0, 0, msg);
1825 ok(store != NULL, "CertOpenStore failed: %08lx\n", GetLastError());
1826 if (store)
1827 {
1830
1831 count = 0;
1832 do {
1834 if (cert)
1835 count++;
1836 } while (cert);
1837 ok(count == 0, "Expected 0 certificates, got %ld\n", count);
1838
1839 count = 0;
1840 do {
1841 crl = CertEnumCRLsInStore(store, crl);
1842 if (crl)
1843 count++;
1844 } while (crl);
1845 ok(count == 0, "Expected 0 CRLs, got %ld\n", count);
1846
1847 /* Can add certs to a message store */
1850 ok(ret, "CertAddEncodedCertificateToStore failed: %08lx\n",
1851 GetLastError());
1852 count = 0;
1853 do {
1855 if (cert)
1856 count++;
1857 } while (cert);
1858 ok(count == 1, "Expected 1 certificate, got %ld\n", count);
1859
1860 CertCloseStore(store, 0);
1861 }
1862 /* but the added certs weren't actually added to the message */
1863 size = sizeof(count);
1865 ok(ret, "CryptMsgGetParam failed: %08lx\n", GetLastError());
1866 ok(count == 0, "Expected 0 certificates, got %ld\n", count);
1868
1869 /* Crashes
1870 store = CertOpenStore(CERT_STORE_PROV_PKCS7, 0, 0, 0, NULL);
1871 */
1872 store = CertOpenStore(CERT_STORE_PROV_PKCS7, 0, 0, 0, &blob);
1873 ok(store != NULL, "CertOpenStore failed: %08lx\n", GetLastError());
1874 if (store)
1875 {
1876 DWORD count = 0;
1879
1880 do {
1882 if (cert)
1883 count++;
1884 } while (cert);
1885 ok(count == 1, "Expected 1 certificate, got %ld\n", count);
1886
1887 count = 0;
1888 do {
1889 crl = CertEnumCRLsInStore(store, crl);
1890 if (crl)
1891 count++;
1892 } while (crl);
1893 ok(count == 1, "Expected 1 CRL, got %ld\n", count);
1894
1895 CertCloseStore(store, 0);
1896 }
1897 /* Encoding appears to be ignored */
1899 &blob);
1900 ok(store != NULL, "CertOpenStore failed: %08lx\n", GetLastError());
1901 if (store)
1902 CertCloseStore(store, 0);
1903 /* Messages other than signed messages aren't allowed */
1904 blob.cbData = sizeof(hashContent);
1905 blob.pbData = (LPBYTE)hashContent;
1906 SetLastError(0xdeadbeef);
1907 store = CertOpenStore(CERT_STORE_PROV_PKCS7, 0, 0, 0, &blob);
1909 "Expected CRYPT_E_INVALID_MSG_TYPE, got %08lx\n", GetLastError());
1910 blob.cbData = sizeof(hashBareContent);
1911 blob.pbData = (LPBYTE)hashBareContent;
1912 SetLastError(0xdeadbeef);
1913 store = CertOpenStore(CERT_STORE_PROV_PKCS7, 0, 0, 0, &blob);
1914 ok(!store && GetLastError() == CRYPT_E_ASN1_BADTAG,
1915 "Expected CRYPT_E_ASN1_BADTAG, got %08lx\n", GetLastError());
1916}
1917
1918static void testSerializedStore(void)
1919{
1920 HCERTSTORE store;
1922
1923 if (0)
1924 {
1925 /* Crash */
1929 }
1930 blob.cbData = sizeof(serializedStoreWithCert);
1931 blob.pbData = (BYTE *)serializedStoreWithCert;
1935 "Expected ERROR_CALL_NOT_IMPLEMENTED, got %08lx\n", GetLastError());
1936 store = CertOpenStore(CERT_STORE_PROV_SERIALIZED, 0, 0, 0, &blob);
1937 ok(store != NULL, "CertOpenStore failed: %08lx\n", GetLastError());
1938 if (store)
1939 {
1942
1944 ok(cert != NULL, "CertEnumCertificatesInStore failed: %08lx\n",
1945 GetLastError());
1947 ok(!cert, "Expected only one cert\n");
1948 crl = CertEnumCRLsInStore(store, NULL);
1949 ok(!crl, "Expected no CRLs\n");
1950
1951 CertCloseStore(store, 0);
1952 }
1953 blob.cbData = sizeof(serializedStoreWithCertAndCRL);
1955 store = CertOpenStore(CERT_STORE_PROV_SERIALIZED, 0, 0, 0, &blob);
1956 ok(store != NULL, "CertOpenStore failed: %08lx\n", GetLastError());
1957 if (store)
1958 {
1961
1963 ok(cert != NULL, "CertEnumCertificatesInStore failed: %08lx\n",
1964 GetLastError());
1966 ok(!cert, "Expected only one cert\n");
1967 crl = CertEnumCRLsInStore(store, NULL);
1968 ok(crl != NULL, "CertEnumCRLsInStore failed: %08lx\n",
1969 GetLastError());
1970 crl = CertEnumCRLsInStore(store, crl);
1971 ok(!crl, "Expected only one CRL\n");
1972
1973 CertCloseStore(store, 0);
1974 }
1975}
1976
1978{
1979 HCERTSTORE store;
1980
1981 store = CertOpenSystemStoreW(0, NULL);
1982 ok(!store && GetLastError() == E_INVALIDARG,
1983 "Expected E_INVALIDARG, got %08lx\n", GetLastError());
1984 /* This succeeds, and on WinXP at least, the Bogus key is created under
1985 * HKCU (but not under HKLM, even when run as an administrator.)
1986 */
1987 store = CertOpenSystemStoreW(0, L"Bogus");
1988 ok(store != 0, "CertOpenSystemStore failed: %08lx\n", GetLastError());
1989 if (store)
1990 CertCloseStore(store, 0);
1991 /* Delete it so other tests succeed next time around */
1994 RegDeleteKeyW(HKEY_CURRENT_USER, L"Software\\Microsoft\\SystemCertificates\\Bogus");
1995}
1996
1997static const struct
1998{
2004 /* Following tests could require administrator privileges and thus could be skipped */
2011
2013{
2014 BOOL ret, cur_flag;
2015 DWORD err = 0;
2016 HCERTSTORE hstore;
2017 const CERT_CONTEXT *cert, *cert2;
2018 unsigned int i;
2019
2020 for (i = 0; i < ARRAY_SIZE(reg_system_store_test_data); i++) {
2021 cur_flag = reg_system_store_test_data[i].cert_store;
2022 ret = CertRegisterSystemStore(L"WineTest", cur_flag, NULL, NULL);
2023 if (!ret)
2024 {
2025 err = GetLastError();
2026 if (err == ERROR_ACCESS_DENIED)
2027 {
2028 win_skip("Insufficient privileges for the flag %08x test\n", cur_flag);
2029 continue;
2030 }
2031 }
2034 "Store registration (dwFlags=%08x) failed, last error %lx\n", cur_flag, err);
2035 if (!ret)
2036 {
2037 skip("Nothing to test without registered store at %08x\n", cur_flag);
2038 continue;
2039 }
2040
2041 hstore = CertOpenStore(CERT_STORE_PROV_SYSTEM_W, 0, 0, CERT_STORE_OPEN_EXISTING_FLAG | cur_flag, L"WineTest");
2042 ok (hstore != NULL, "Opening just registered store at %08x failed, last error %lx\n", cur_flag, GetLastError());
2043
2045 ok (cert != NULL, "Failed creating cert at %08x, last error: %lx\n", cur_flag, GetLastError());
2046 if (cert)
2047 {
2049 ok (ret, "Failed to add cert at %08x, last error: %lx\n", cur_flag, GetLastError());
2050
2052 ok (cert2 != NULL && cert2->cbCertEncoded == cert->cbCertEncoded,
2053 "Unexpected cert encoded size at %08x, last error: %lx\n", cur_flag, GetLastError());
2054
2056 ok (ret, "Failed to delete certificate from the new store at %08x, last error: %lx\n", cur_flag, GetLastError());
2057
2059 }
2060
2061 ret = CertCloseStore(hstore, 0);
2062 ok (ret, "CertCloseStore failed at %08x, last error %lx\n", cur_flag, GetLastError());
2063
2064 ret = CertUnregisterSystemStore(L"WineTest", cur_flag );
2067 "Unregistering failed at %08x, last error %ld\n", cur_flag, GetLastError());
2068 }
2069
2070}
2071
2073{
2076};
2077
2078static BOOL CALLBACK enumSystemStoreCB(const void *systemStore, DWORD dwFlags,
2079 PCERT_SYSTEM_STORE_INFO pStoreInfo, void *pvReserved, void *pvArg)
2080{
2081 struct EnumSystemStoreInfo *info = pvArg;
2082
2083 info->storeCount++;
2084 return info->goOn;
2085}
2086
2088{
2089 BOOL ret;
2090 struct EnumSystemStoreInfo info = { FALSE, 0 };
2091
2092 SetLastError(0xdeadbeef);
2095 "Expected ERROR_FILE_NOT_FOUND, got %08lx\n", GetLastError());
2096 /* Crashes
2097 ret = CertEnumSystemStore(CERT_SYSTEM_STORE_LOCAL_MACHINE, NULL, NULL,
2098 NULL);
2099 */
2100
2101 SetLastError(0xdeadbeef);
2104 /* Callback returning FALSE stops enumeration */
2105 ok(!ret, "Expected CertEnumSystemStore to stop\n");
2106 ok(info.storeCount == 0 || info.storeCount == 1,
2107 "Expected 0 or 1 stores\n");
2108
2109 info.goOn = TRUE;
2110 info.storeCount = 0;
2113 ok(ret, "CertEnumSystemStore failed: %08lx\n", GetLastError());
2114 /* There should always be at least My, Root, and CA stores */
2115 ok(info.storeCount == 0 || info.storeCount >= 3,
2116 "Expected at least 3 stores\n");
2117}
2118
2119static void testStoreProperty(void)
2120{
2121 HCERTSTORE store;
2122 BOOL ret;
2123 DWORD propID, size = 0, state;
2125
2126 /* Crash
2127 ret = CertGetStoreProperty(NULL, 0, NULL, NULL);
2128 ret = CertGetStoreProperty(NULL, 0, NULL, &size);
2129 ret = CertGetStoreProperty(store, 0, NULL, NULL);
2130 */
2131
2134 /* Check a missing prop ID */
2135 SetLastError(0xdeadbeef);
2136 ret = CertGetStoreProperty(store, 0, NULL, &size);
2138 "Expected CRYPT_E_NOT_FOUND, got %08lx\n", GetLastError());
2139 /* Contrary to MSDN, CERT_ACCESS_STATE_PROP_ID is supported for stores.. */
2140 size = sizeof(state);
2142 ok(ret, "CertGetStoreProperty failed for CERT_ACCESS_STATE_PROP_ID: %08lx\n",
2143 GetLastError());
2144 ok(!state, "Expected a non-persisted store\n");
2145 /* and CERT_STORE_LOCALIZED_NAME_PROP_ID isn't supported by default. */
2146 size = 0;
2148 &size);
2150 "Expected CRYPT_E_NOT_FOUND, got %08lx\n", GetLastError());
2151 /* Delete an arbitrary property on a store */
2153 ok(ret, "CertSetStoreProperty failed: %08lx\n", GetLastError());
2154 /* Set an arbitrary property on a store */
2155 blob.pbData = (LPBYTE)&state;
2156 blob.cbData = sizeof(state);
2158 ok(ret, "CertSetStoreProperty failed: %08lx\n", GetLastError());
2159 /* Get an arbitrary property that's been set */
2161 ok(ret, "CertGetStoreProperty failed: %08lx\n", GetLastError());
2162 ok(size == sizeof(state), "Unexpected data size %ld\n", size);
2164 ok(ret, "CertGetStoreProperty failed: %08lx\n", GetLastError());
2165 ok(propID == state, "CertGetStoreProperty got the wrong value\n");
2166 /* Delete it again */
2168 ok(ret, "CertSetStoreProperty failed: %08lx\n", GetLastError());
2169 /* And check that it's missing */
2170 SetLastError(0xdeadbeef);
2173 "Expected CRYPT_E_NOT_FOUND, got %08lx\n", GetLastError());
2174 CertCloseStore(store, 0);
2175
2176 /* Recheck on the My store.. */
2177 store = CertOpenSystemStoreW(0, L"My");
2178 size = sizeof(state);
2180 ok(ret, "CertGetStoreProperty failed for CERT_ACCESS_STATE_PROP_ID: %08lx\n",
2181 GetLastError());
2182 ok(state, "Expected a persisted store\n");
2183 SetLastError(0xdeadbeef);
2184 size = 0;
2186 &size);
2188 "Expected CRYPT_E_NOT_FOUND, got %08lx\n", GetLastError());
2189 CertCloseStore(store, 0);
2190}
2191
2192static void testAddSerialized(void)
2193{
2194 BOOL ret;
2195 HCERTSTORE store;
2196 BYTE buf[sizeof(struct CertPropIDHeader) * 2 + 20 + sizeof(bigCert)] =
2197 { 0 };
2198 BYTE hash[20];
2199 struct CertPropIDHeader *hdr;
2201
2202 ret = CertAddSerializedElementToStore(0, NULL, 0, 0, 0, 0, NULL, NULL);
2204 "Expected ERROR_END_OF_MEDIA, got %08lx\n", GetLastError());
2205
2208 ok(store != 0, "CertOpenStore failed: %08lx\n", GetLastError());
2209
2210 ret = CertAddSerializedElementToStore(store, NULL, 0, 0, 0, 0, NULL, NULL);
2212 "Expected ERROR_END_OF_MEDIA, got %08lx\n", GetLastError());
2213
2214 /* Test with an empty property */
2215 hdr = (struct CertPropIDHeader *)buf;
2216 hdr->propID = CERT_CERT_PROP_ID;
2217 hdr->unknown1 = 1;
2218 hdr->cb = 0;
2219 ret = CertAddSerializedElementToStore(store, buf, sizeof(buf), 0, 0, 0,
2220 NULL, NULL);
2222 "Expected E_INVALIDARG, got %08lx\n", GetLastError());
2223 /* Test with a bad size in property header */
2224 hdr->cb = sizeof(bigCert) - 1;
2225 memcpy(buf + sizeof(struct CertPropIDHeader), bigCert, sizeof(bigCert));
2226 ret = CertAddSerializedElementToStore(store, buf, sizeof(buf), 0, 0, 0,
2227 NULL, NULL);
2229 "Expected E_INVALIDARG, got %08lx\n", GetLastError());
2231 sizeof(struct CertPropIDHeader) + sizeof(bigCert), 0, 0, 0, NULL,
2232 NULL);
2234 "Expected E_INVALIDARG, got %08lx\n", GetLastError());
2236 sizeof(struct CertPropIDHeader) + sizeof(bigCert), CERT_STORE_ADD_NEW,
2237 0, 0, NULL, NULL);
2239 "Expected E_INVALIDARG, got %08lx\n", GetLastError());
2240 /* Kosher size in property header, but no context type */
2241 hdr->cb = sizeof(bigCert);
2242 ret = CertAddSerializedElementToStore(store, buf, sizeof(buf), 0, 0, 0,
2243 NULL, NULL);
2245 "Expected E_INVALIDARG, got %08lx\n", GetLastError());
2247 sizeof(struct CertPropIDHeader) + sizeof(bigCert), 0, 0, 0, NULL,
2248 NULL);
2250 "Expected E_INVALIDARG, got %08lx\n", GetLastError());
2252 sizeof(struct CertPropIDHeader) + sizeof(bigCert), CERT_STORE_ADD_NEW,
2253 0, 0, NULL, NULL);
2255 "Expected E_INVALIDARG, got %08lx\n", GetLastError());
2256 /* With a bad context type */
2257 ret = CertAddSerializedElementToStore(store, buf, sizeof(buf), 0, 0,
2260 "Expected E_INVALIDARG, got %08lx\n", GetLastError());
2262 sizeof(struct CertPropIDHeader) + sizeof(bigCert), 0, 0,
2265 "Expected E_INVALIDARG, got %08lx\n", GetLastError());
2267 sizeof(struct CertPropIDHeader) + sizeof(bigCert), CERT_STORE_ADD_NEW,
2270 "Expected E_INVALIDARG, got %08lx\n", GetLastError());
2271 /* Bad unknown field, good type */
2272 hdr->unknown1 = 2;
2273 ret = CertAddSerializedElementToStore(store, buf, sizeof(buf), 0, 0,
2276 "Expected ERROR_FILE_NOT_FOUND got %08lx\n", GetLastError());
2278 sizeof(struct CertPropIDHeader) + sizeof(bigCert), 0, 0,
2281 "Expected ERROR_FILE_NOT_FOUND got %08lx\n", GetLastError());
2283 sizeof(struct CertPropIDHeader) + sizeof(bigCert), CERT_STORE_ADD_NEW,
2286 "Expected ERROR_FILE_NOT_FOUND got %08lx\n", GetLastError());
2287 /* Most everything okay, but bad add disposition */
2288 hdr->unknown1 = 1;
2289 /* This crashes
2290 ret = CertAddSerializedElementToStore(store, buf, sizeof(buf), 0, 0,
2291 CERT_STORE_CERTIFICATE_CONTEXT_FLAG, NULL, NULL);
2292 * as does this
2293 ret = CertAddSerializedElementToStore(store, buf,
2294 sizeof(struct CertPropIDHeader) + sizeof(bigCert), 0, 0,
2295 CERT_STORE_CERTIFICATE_CONTEXT_FLAG, NULL, NULL);
2296 */
2297 /* Everything okay, but buffer's too big */
2298 ret = CertAddSerializedElementToStore(store, buf, sizeof(buf),
2300 ok(ret, "CertAddSerializedElementToStore failed: %08lx\n", GetLastError());
2301 /* Everything okay, check it's not re-added */
2303 sizeof(struct CertPropIDHeader) + sizeof(bigCert), CERT_STORE_ADD_NEW,
2306 "Expected CRYPT_E_EXISTS, got %08lx\n", GetLastError());
2307
2309 ok(context != NULL, "Expected a cert\n");
2310 if (context)
2312
2313 /* Try adding with a bogus hash. Oddly enough, it succeeds, and the hash,
2314 * when queried, is the real hash rather than the bogus hash.
2315 */
2316 hdr = (struct CertPropIDHeader *)(buf + sizeof(struct CertPropIDHeader) +
2317 sizeof(bigCert));
2318 hdr->propID = CERT_HASH_PROP_ID;
2319 hdr->unknown1 = 1;
2320 hdr->cb = sizeof(hash);
2321 memset(hash, 0xc, sizeof(hash));
2322 memcpy((LPBYTE)hdr + sizeof(struct CertPropIDHeader), hash, sizeof(hash));
2323 ret = CertAddSerializedElementToStore(store, buf, sizeof(buf),
2325 (const void **)&context);
2326 ok(ret, "CertAddSerializedElementToStore failed: %08lx\n", GetLastError());
2327 if (context)
2328 {
2329 BYTE hashVal[20], realHash[20];
2330 DWORD size = sizeof(hashVal);
2331
2332 ret = CryptHashCertificate(0, 0, 0, bigCert, sizeof(bigCert),
2333 realHash, &size);
2334 ok(ret, "CryptHashCertificate failed: %08lx\n", GetLastError());
2336 hashVal, &size);
2337 ok(ret, "CertGetCertificateContextProperty failed: %08lx\n",
2338 GetLastError());
2339 ok(!memcmp(hashVal, realHash, size), "Unexpected hash\n");
2341 }
2342
2343 CertCloseStore(store, 0);
2344}
2345
23470x0b,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x12,0x00,0x00,0x00,0x57,0x00,0x69,
23480x00,0x6e,0x00,0x65,0x00,0x54,0x00,0x65,0x00,0x73,0x00,0x74,0x00,0x00,0x00,
23490x20,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x7c,0x00,0x00,0x00,0x30,0x7a,0x02,
23500x01,0x01,0x30,0x02,0x06,0x00,0x30,0x15,0x31,0x13,0x30,0x11,0x06,0x03,0x55,
23510x04,0x03,0x13,0x0a,0x4a,0x75,0x61,0x6e,0x20,0x4c,0x61,0x6e,0x67,0x00,0x30,
23520x22,0x18,0x0f,0x31,0x36,0x30,0x31,0x30,0x31,0x30,0x31,0x30,0x30,0x30,0x30,
23530x30,0x30,0x5a,0x18,0x0f,0x31,0x36,0x30,0x31,0x30,0x31,0x30,0x31,0x30,0x30,
23540x30,0x30,0x30,0x30,0x5a,0x30,0x15,0x31,0x13,0x30,0x11,0x06,0x03,0x55,0x04,
23550x03,0x13,0x0a,0x4a,0x75,0x61,0x6e,0x20,0x4c,0x61,0x6e,0x67,0x00,0x30,0x07,
23560x30,0x02,0x06,0x00,0x03,0x01,0x00,0xa3,0x16,0x30,0x14,0x30,0x12,0x06,0x03,
23570x55,0x1d,0x13,0x01,0x01,0xff,0x04,0x08,0x30,0x06,0x01,0x01,0xff,0x02,0x01,
23580x01 };
23600x00,0x00,0x00,0x00,0x43,0x45,0x52,0x54,0x0b,0x00,0x00,0x00,0x01,0x00,0x00,
23610x00,0x12,0x00,0x00,0x00,0x57,0x00,0x69,0x00,0x6e,0x00,0x65,0x00,0x54,0x00,
23620x65,0x00,0x73,0x00,0x74,0x00,0x00,0x00,0x20,0x00,0x00,0x00,0x01,0x00,0x00,
23630x00,0x7c,0x00,0x00,0x00,0x30,0x7a,0x02,0x01,0x01,0x30,0x02,0x06,0x00,0x30,
23640x15,0x31,0x13,0x30,0x11,0x06,0x03,0x55,0x04,0x03,0x13,0x0a,0x4a,0x75,0x61,
23650x6e,0x20,0x4c,0x61,0x6e,0x67,0x00,0x30,0x22,0x18,0x0f,0x31,0x36,0x30,0x31,
23660x30,0x31,0x30,0x31,0x30,0x30,0x30,0x30,0x30,0x30,0x5a,0x18,0x0f,0x31,0x36,
23670x30,0x31,0x30,0x31,0x30,0x31,0x30,0x30,0x30,0x30,0x30,0x30,0x5a,0x30,0x15,
23680x31,0x13,0x30,0x11,0x06,0x03,0x55,0x04,0x03,0x13,0x0a,0x4a,0x75,0x61,0x6e,
23690x20,0x4c,0x61,0x6e,0x67,0x00,0x30,0x07,0x30,0x02,0x06,0x00,0x03,0x01,0x00,
23700xa3,0x16,0x30,0x14,0x30,0x12,0x06,0x03,0x55,0x1d,0x13,0x01,0x01,0xff,0x04,
23710x08,0x30,0x06,0x01,0x01,0xff,0x02,0x01,0x01,0x00,0x00,0x00,0x00,0x00,0x00,
23720x00,0x00,0x00,0x00,0x00,0x00 };
23740x00,0x00,0x00,0x00,0x43,0x45,0x52,0x54,0x03,0x00,0x00,0x00,0x01,0x00,0x00,
23750x00,0x14,0x00,0x00,0x00,0x6e,0x30,0x90,0x71,0x5f,0xd9,0x23,0x56,0xeb,0xae,
23760x25,0x40,0xe6,0x22,0xda,0x19,0x26,0x02,0xa6,0x08,0x20,0x00,0x00,0x00,0x01,
23770x00,0x00,0x00,0x7c,0x00,0x00,0x00,0x30,0x7a,0x02,0x01,0x01,0x30,0x02,0x06,
23780x00,0x30,0x15,0x31,0x13,0x30,0x11,0x06,0x03,0x55,0x04,0x03,0x13,0x0a,0x4a,
23790x75,0x61,0x6e,0x20,0x4c,0x61,0x6e,0x67,0x00,0x30,0x22,0x18,0x0f,0x31,0x36,
23800x30,0x31,0x30,0x31,0x30,0x31,0x30,0x30,0x30,0x30,0x30,0x30,0x5a,0x18,0x0f,
23810x31,0x36,0x30,0x31,0x30,0x31,0x30,0x31,0x30,0x30,0x30,0x30,0x30,0x30,0x5a,
23820x30,0x15,0x31,0x13,0x30,0x11,0x06,0x03,0x55,0x04,0x03,0x13,0x0a,0x4a,0x75,
23830x61,0x6e,0x20,0x4c,0x61,0x6e,0x67,0x00,0x30,0x07,0x30,0x02,0x06,0x00,0x03,
23840x01,0x00,0xa3,0x16,0x30,0x14,0x30,0x12,0x06,0x03,0x55,0x1d,0x13,0x01,0x01,
23850xff,0x04,0x08,0x30,0x06,0x01,0x01,0xff,0x02,0x01,0x01,0x00,0x00,0x00,0x00,
23860x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 };
2387
2388static void delete_test_key(void)
2389{
2390 HKEY root_key, test_key;
2391 WCHAR subkey_name[32];
2392 DWORD num_subkeys, subkey_name_len;
2393 int idx;
2394
2395 if (RegOpenKeyExW(HKEY_CURRENT_USER, L"Software\\Microsoft\\SystemCertificates", 0, KEY_READ, &root_key))
2396 return;
2397 if (RegOpenKeyExW(root_key, L"WineTest", 0, KEY_READ, &test_key))
2398 {
2399 RegCloseKey(root_key);
2400 return;
2401 }
2402 RegQueryInfoKeyW(test_key, NULL, NULL, NULL, &num_subkeys, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
2403 for (idx = num_subkeys; idx-- > 0;)
2404 {
2405 subkey_name_len = ARRAY_SIZE(subkey_name);
2406 RegEnumKeyExW(test_key, idx, subkey_name, &subkey_name_len, NULL, NULL, NULL, NULL);
2407 RegDeleteKeyW(test_key, subkey_name);
2408 }
2409 RegCloseKey(test_key);
2410 RegDeleteKeyW(root_key, L"WineTest");
2411 RegCloseKey(root_key);
2412}
2413
2414static void testAddCertificateLink(void)
2415{
2416 BOOL ret;
2417 HCERTSTORE store1, store2;
2418 PCCERT_CONTEXT source, linked;
2419 DWORD size;
2420 LPBYTE buf;
2422 WCHAR filename1[MAX_PATH], filename2[MAX_PATH];
2423 HANDLE file;
2424
2425 if (0)
2426 {
2427 /* Crashes, i.e. the store is dereferenced without checking. */
2429 }
2430
2431 /* Adding a certificate link to a store requires a valid add disposition */
2434 SetLastError(0xdeadbeef);
2437 "expected E_INVALIDARG, got %08lx\n", GetLastError());
2439 sizeof(bigCert));
2440 SetLastError(0xdeadbeef);
2443 "expected E_INVALIDARG, got %08lx\n", GetLastError());
2445 NULL);
2446 ok(ret, "CertAddCertificateLinkToStore failed: %08lx\n", GetLastError());
2447 if (0)
2448 {
2449 /* Crashes, i.e. the source certificate is dereferenced without
2450 * checking when a valid add disposition is given.
2451 */
2453 NULL);
2454 }
2455 CertCloseStore(store1, 0);
2456
2460 &linked);
2461 ok(ret, "CertAddCertificateLinkToStore failed: %08lx\n", GetLastError());
2462 if (ret)
2463 {
2464 ok(linked->hCertStore == store1, "unexpected store\n");
2466 ok(ret, "CertSerializeCertificateStoreElement failed: %08lx\n",
2467 GetLastError());
2468 buf = malloc(size);
2469 if (buf)
2470 {
2472 ok(ret, "CertSerializeCertificateStoreElement failed: %08lx\n",
2473 GetLastError());
2474 /* The serialized linked certificate is identical to the serialized
2475 * original certificate.
2476 */
2477 ok(size == sizeof(serializedCert), "Wrong size %ld\n", size);
2479 "Unexpected serialized cert\n");
2480 free(buf);
2481 }
2482 /* Set a friendly name on the source certificate... */
2483 blob.pbData = (LPBYTE)L"WineTest";
2484 blob.cbData = sizeof(L"WineTest");
2487 ok(ret, "CertSetCertificateContextProperty failed: %08lx\n",
2488 GetLastError());
2489 /* and the linked certificate has the same friendly name. */
2492 ok(ret, "CertGetCertificateContextProperty failed: %08lx\n",
2493 GetLastError());
2494 buf = malloc(size);
2495 if (buf)
2496 {
2499 ok(ret, "CertGetCertificateContextProperty failed: %08lx\n",
2500 GetLastError());
2501 ok(!lstrcmpW((LPCWSTR)buf, L"WineTest"),
2502 "unexpected friendly name\n");
2503 free(buf);
2504 }
2506 }
2508 CertCloseStore(store1, 0);
2509
2510 /* Test adding a cert to a file store, committing the change to the store,
2511 * and creating a link to the resulting cert.
2512 */
2513 if (!GetTempFileNameW(L".", L"cer", 0, filename1))
2514 return;
2515
2516 DeleteFileW(filename1);
2517 file = CreateFileW(filename1, GENERIC_READ | GENERIC_WRITE, 0, NULL,
2520 return;
2521
2522 store1 = CertOpenStore(CERT_STORE_PROV_FILE, 0, 0,
2524 ok(store1 != NULL, "CertOpenStore failed: %08lx\n", GetLastError());
2526
2529 ok(ret, "CertAddEncodedCertificateToStore failed: %08lx\n",
2530 GetLastError());
2531
2532 /* Test adding a link to a memory store. */
2536 &linked);
2537 ok(ret, "CertAddCertificateLinkToStore failed: %08lx\n", GetLastError());
2538 if (ret)
2539 {
2540 ok(linked->hCertStore == store2, "unexpected store\n");
2542 ok(ret, "CertSerializeCertificateStoreElement failed: %08lx\n",
2543 GetLastError());
2544 buf = malloc(size);
2545 if (buf)
2546 {
2548 /* The serialized linked certificate is identical to the serialized
2549 * original certificate.
2550 */
2551 ok(ret, "CertSerializeCertificateStoreElement failed: %08lx\n", GetLastError());
2552 ok(size == sizeof(serializedCert), "Wrong size %ld\n", size);
2554 "Unexpected serialized cert\n");
2555 free(buf);
2556 }
2557 /* Set a friendly name on the source certificate... */
2558 blob.pbData = (LPBYTE)L"WineTest";
2559 blob.cbData = sizeof(L"WineTest");
2562 ok(ret, "CertSetCertificateContextProperty failed: %08lx\n",
2563 GetLastError());
2564 /* and the linked certificate has the same friendly name. */
2567 ok(ret, "CertGetCertificateContextProperty failed: %08lx\n",
2568 GetLastError());
2569 buf = malloc(size);
2570 if (buf)
2571 {
2574 ok(ret, "CertGetCertificateContextProperty failed: %08lx\n", GetLastError());
2575 ok(!lstrcmpW((LPCWSTR)buf, L"WineTest"),
2576 "unexpected friendly name\n");
2577 free(buf);
2578 }
2580 }
2581 CertCloseStore(store2, 0);
2582
2583 if (!GetTempFileNameW(L".", L"cer", 0, filename2))
2584 return;
2585
2590 return;
2591
2592 store2 = CertOpenStore(CERT_STORE_PROV_FILE, 0, 0,
2594 ok(store2 != NULL, "CertOpenStore failed: %08lx\n", GetLastError());
2596 /* Test adding a link to a file store. */
2598 &linked);
2599 ok(ret, "CertAddCertificateLinkToStore failed: %08lx\n", GetLastError());
2600 if (ret)
2601 {
2602 ok(linked->hCertStore == store2, "unexpected store\n");
2604 ok(ret, "CertSerializeCertificateStoreElement failed: %08lx\n",
2605 GetLastError());
2606 buf = malloc(size);
2607 if (buf)
2608 {
2610 ok(ret, "CertSerializeCertificateStoreElement failed: %08lx\n",
2611 GetLastError());
2612 /* The serialized linked certificate now contains the friendly
2613 * name property.
2614 */
2616 "Wrong size %ld\n", size);
2618 "Unexpected serialized cert\n");
2619 free(buf);
2620 }
2622 compareStore(store2, "file store -> file store",
2625 }
2626 CertCloseStore(store2, 0);
2628
2630
2631 CertCloseStore(store1, 0);
2632 DeleteFileW(filename1);
2633
2634 /* Test adding a link to a system store (which is a collection store.) */
2635 store1 = CertOpenSystemStoreA(0, "My");
2637 sizeof(bigCert));
2638 SetLastError(0xdeadbeef);
2640 &linked);
2642 "expected E_INVALIDARG, got %08lx\n", GetLastError());
2644
2645 /* Test adding a link to a file store, where the linked certificate is
2646 * in a system store.
2647 */
2650 ok(ret, "CertAddEncodedCertificateToStore failed: %08lx\n",
2651 GetLastError());
2652 if (!GetTempFileNameW(L".", L"cer", 0, filename1))
2653 return;
2654
2655 DeleteFileW(filename1);
2656 file = CreateFileW(filename1, GENERIC_READ | GENERIC_WRITE, 0, NULL,
2659 return;
2660
2661 store2 = CertOpenStore(CERT_STORE_PROV_FILE, 0, 0,
2663 ok(store2 != NULL, "CertOpenStore failed: %08lx\n", GetLastError());
2665
2667 &linked);
2668 ok(ret, "CertAddCertificateLinkToStore failed: %08lx\n", GetLastError());
2669 if (ret)
2670 {
2671 ok(linked->hCertStore == store2, "unexpected store\n");
2673 ok(ret, "CertControlStore failed: %d\n", ret);
2674 compareStore(store2, "file store -> system store",
2678 }
2679
2680 CertCloseStore(store2, 0);
2681 DeleteFileW(filename1);
2682
2683 /* Test adding a link to a registry store, where the linked certificate is
2684 * in a system store.
2685 */
2688 ok(store2 != NULL, "CertOpenStore failed: %08lx\n", GetLastError());
2690 &linked);
2691 ok(ret, "CertAddCertificateLinkToStore failed: %08lx\n", GetLastError());
2692 if (ret)
2693 {
2694 ok(linked->hCertStore == store2, "unexpected store\n");
2696 }
2697 CertCloseStore(store2, 0);
2698
2700 CertCloseStore(store1, 0);
2701
2703}
2704
2706{
2708 DWORD certs = 0;
2709
2710 do {
2712 if (cert)
2713 certs++;
2714 } while (cert);
2715 return certs;
2716}
2717
2719{
2721 DWORD crls = 0;
2722
2723 do {
2724 crl = CertEnumCRLsInStore(store, crl);
2725 if (crl)
2726 crls++;
2727 } while (crl);
2728 return crls;
2729}
2730
2731static void testEmptyStore(void)
2732{
2733 const CERT_CONTEXT *cert, *cert2, *cert3;
2734 const CRL_CONTEXT *crl;
2735 const CTL_CONTEXT *ctl;
2736 HCERTSTORE store;
2737 BOOL res;
2738
2740 ok(cert != NULL, "CertCreateCertificateContext failed\n");
2741 ok(cert->hCertStore != NULL, "cert->hCertStore == NULL\n");
2742 if(!cert->hCertStore) {
2744 return;
2745 }
2746
2747 test_store_is_empty(cert->hCertStore);
2748
2750 ok(cert2 != NULL, "CertCreateCertificateContext failed\n");
2751 ok(cert2->hCertStore == cert->hCertStore, "Unexpected hCertStore\n");
2752
2753 test_store_is_empty(cert2->hCertStore);
2754
2756 ok(res, "CertAddCertificateContextToStore failed\n");
2757 todo_wine
2758 ok(cert3 && cert3 != cert2, "Unexpected cert3\n");
2759 ok(cert3->hCertStore == cert->hCertStore, "Unexpected hCertStore\n");
2760
2761 test_store_is_empty(cert->hCertStore);
2762
2764 ok(res, "CertDeleteCertificateContextFromStore failed\n");
2765 ok(cert3->hCertStore == cert->hCertStore, "Unexpected hCertStore\n");
2766
2768
2770 ok(store != NULL, "CertOpenStore failed\n");
2771
2773 ok(res, "CertAddCertificateContextToStore failed\n");
2774 ok(cert3 && cert3 != cert2, "Unexpected cert3\n");
2775 ok(cert3->hCertStore == store, "Unexpected hCertStore\n");
2776
2778 ok(res, "CertDeleteCertificateContextFromStore failed\n");
2779 ok(cert3->hCertStore == store, "Unexpected hCertStore\n");
2780
2781 CertCloseStore(store, 0);
2783
2785 ok(!res && GetLastError() == E_UNEXPECTED, "CertCloseStore returned: %x(%lx)\n", res, GetLastError());
2786
2787 res = CertCloseStore(cert->hCertStore, 0);
2788 ok(!res && GetLastError() == E_UNEXPECTED, "CertCloseStore returned: %x(%lx)\n", res, GetLastError());
2789
2791
2793 ok(crl != NULL, "CertCreateCRLContext failed\n");
2794 ok(crl->hCertStore == cert->hCertStore, "unexpected hCertStore\n");
2795
2797
2799 ok(ctl != NULL, "CertCreateCTLContext failed\n");
2800 ok(ctl->hCertStore == cert->hCertStore, "unexpected hCertStore\n");
2801
2802 CertFreeCTLContext(ctl);
2803
2805}
2806
2807static void testCloseStore(void)
2808{
2809 const CERT_CONTEXT *cert;
2810 const CRL_CONTEXT *crl;
2811 const CTL_CONTEXT *ctl;
2812 HCERTSTORE store, store2;
2813 BOOL res;
2814
2816 ok(store != NULL, "CertOpenStore failed\n");
2817
2819 ok(res, "CertCloseStore failed\n");
2820
2822 ok(store != NULL, "CertOpenStore failed\n");
2823
2824 store2 = CertDuplicateStore(store);
2825 ok(store2 != NULL, "CertCloneStore failed\n");
2826 ok(store2 == store, "unexpected store2\n");
2827
2829 ok(!res && GetLastError() == CRYPT_E_PENDING_CLOSE, "CertCloseStore failed\n");
2830
2832 ok(res, "CertCloseStore failed\n");
2833
2835 ok(store != NULL, "CertOpenStore failed\n");
2836
2839 ok(res, "CertAddEncodedCertificateToStore failed\n");
2840
2841 /* There is still a reference from cert */
2843 ok(!res && GetLastError() == CRYPT_E_PENDING_CLOSE, "CertCloseStore failed\n");
2844
2846 ok(res, "CertFreeCertificateContext failed\n");
2847
2849 ok(store != NULL, "CertOpenStore failed\n");
2850
2853 ok(res, "CertAddEncodedCRLToStore failed\n");
2854
2855 /* There is still a reference from CRL */
2857 ok(!res && GetLastError() == CRYPT_E_PENDING_CLOSE, "CertCloseStore failed\n");
2858
2860 ok(res, "CertFreeCRLContext failed\n");
2861
2863 ok(store != NULL, "CertOpenStore failed\n");
2864
2867 ok(res, "CertAddEncodedCTLToStore failed\n");
2868
2869 /* There is still a reference from CTL */
2871 ok(!res && GetLastError() == CRYPT_E_PENDING_CLOSE, "CertCloseStore returned: %x(%lu)\n", res, GetLastError());
2872
2873 res = CertFreeCTLContext(ctl);
2874 ok(res, "CertFreeCTLContext failed\n");
2875
2876 /* Add all kinds of contexts, then release external references and make sure that store is properly closed. */
2878 ok(store != NULL, "CertOpenStore failed\n");
2879
2882 ok(res, "CertAddEncodedCertificateToStore failed\n");
2883
2886 ok(res, "CertAddEncodedCRLToStore failed\n");
2887
2890 ok(res, "CertAddEncodedCTLToStore failed\n");
2891
2894 CertFreeCTLContext(ctl);
2895
2897 ok(res, "CertCloseStore failed\n");
2898}
2899
2900static void test_I_UpdateStore(void)
2901{
2902 HMODULE lib = GetModuleHandleA("crypt32");
2903 BOOL (WINAPI *pI_CertUpdatestore)(HCERTSTORE, HCERTSTORE, DWORD, DWORD) =
2904 (void *)GetProcAddress(lib, "I_CertUpdateStore");
2905 BOOL ret;
2906 HCERTSTORE store1, store2;
2908 DWORD certs;
2909
2910 if (!pI_CertUpdatestore)
2911 {
2912 win_skip("No I_CertUpdateStore\n");
2913 return;
2914 }
2919
2920 /* Crash
2921 ret = pI_CertUpdatestore(NULL, NULL, 0, 0);
2922 ret = pI_CertUpdatestore(store1, NULL, 0, 0);
2923 ret = pI_CertUpdatestore(NULL, store2, 0, 0);
2924 */
2925 ret = pI_CertUpdatestore(store1, store2, 0, 0);
2926 ok(ret, "I_CertUpdateStore failed: %08lx\n", GetLastError());
2927
2930 /* I_CertUpdateStore adds the contexts from store2 to store1 */
2931 ret = pI_CertUpdatestore(store1, store2, 0, 0);
2932 ok(ret, "I_CertUpdateStore failed: %08lx\n", GetLastError());
2933 certs = countCertsInStore(store1);
2934 ok(certs == 1, "Expected 1 cert, got %ld\n", certs);
2935 /* Calling it a second time has no effect */
2936 ret = pI_CertUpdatestore(store1, store2, 0, 0);
2937 ok(ret, "I_CertUpdateStore failed: %08lx\n", GetLastError());
2938 certs = countCertsInStore(store1);
2939 ok(certs == 1, "Expected 1 cert, got %ld\n", certs);
2940
2941 /* The last parameters to I_CertUpdateStore appear to be ignored */
2942 ret = pI_CertUpdatestore(store1, store2, 1, 0);
2943 ok(ret, "I_CertUpdateStore failed: %08lx\n", GetLastError());
2944 ret = pI_CertUpdatestore(store1, store2, 0, 1);
2945 ok(ret, "I_CertUpdateStore failed: %08lx\n", GetLastError());
2946
2949
2950 /* I_CertUpdateStore also adds the CRLs from store2 to store1 */
2951 ret = pI_CertUpdatestore(store1, store2, 0, 0);
2952 ok(ret, "I_CertUpdateStore failed: %08lx\n", GetLastError());
2953 certs = countCertsInStore(store1);
2954 ok(certs == 1, "Expected 1 cert, got %ld\n", certs);
2955 certs = countCRLsInStore(store1);
2956 ok(certs == 1, "Expected 1 CRL, got %ld\n", certs);
2957
2959 /* If a context is deleted from store2, I_CertUpdateStore deletes it
2960 * from store1
2961 */
2962 ret = pI_CertUpdatestore(store1, store2, 0, 0);
2963 ok(ret, "I_CertUpdateStore failed: %08lx\n", GetLastError());
2964 certs = countCertsInStore(store1);
2965 ok(certs == 0, "Expected 0 certs, got %ld\n", certs);
2966
2967 CertCloseStore(store1, 0);
2968 CertCloseStore(store2, 0);
2969}
2970
2971static const BYTE pfxdata[] =
2972{
2973 0x30, 0x82, 0x0b, 0x1d, 0x02, 0x01, 0x03, 0x30, 0x82, 0x0a, 0xe3, 0x06,
2974 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x07, 0x01, 0xa0, 0x82,
2975 0x0a, 0xd4, 0x04, 0x82, 0x0a, 0xd0, 0x30, 0x82, 0x0a, 0xcc, 0x30, 0x82,
2976 0x05, 0x07, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x07,
2977 0x06, 0xa0, 0x82, 0x04, 0xf8, 0x30, 0x82, 0x04, 0xf4, 0x02, 0x01, 0x00,
2978 0x30, 0x82, 0x04, 0xed, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d,
2979 0x01, 0x07, 0x01, 0x30, 0x1c, 0x06, 0x0a, 0x2a, 0x86, 0x48, 0x86, 0xf7,
2980 0x0d, 0x01, 0x0c, 0x01, 0x06, 0x30, 0x0e, 0x04, 0x08, 0xac, 0x3e, 0x35,
2981 0xa8, 0xed, 0x0d, 0x50, 0x07, 0x02, 0x02, 0x08, 0x00, 0x80, 0x82, 0x04,
2982 0xc0, 0x5a, 0x62, 0x55, 0x25, 0xf6, 0x2c, 0xf1, 0x78, 0x6c, 0x63, 0x96,
2983 0x8a, 0xea, 0x04, 0x64, 0xb3, 0x99, 0x3b, 0x80, 0x50, 0x05, 0x37, 0x55,
2984 0xa3, 0x5e, 0x9f, 0x35, 0xc3, 0x3c, 0xdc, 0xf6, 0xc4, 0xc1, 0x39, 0xa2,
2985 0xd7, 0x50, 0xad, 0xf9, 0x29, 0x3c, 0x51, 0xea, 0x15, 0x20, 0x25, 0xd3,
2986 0x4d, 0x69, 0xdf, 0x10, 0xd8, 0x9d, 0x60, 0x78, 0x8a, 0x70, 0x44, 0x7f,
2987 0x01, 0x4f, 0x4a, 0xfa, 0xab, 0xfd, 0x46, 0x48, 0x96, 0x2b, 0x69, 0xfc,
2988 0x11, 0xf8, 0x3f, 0xd3, 0x79, 0x09, 0x75, 0x81, 0x47, 0xdf, 0xce, 0xfe,
2989 0x07, 0x2f, 0x0a, 0xd8, 0xac, 0x87, 0x14, 0x1f, 0x7b, 0x95, 0x70, 0xee,
2990 0x7e, 0x52, 0x90, 0x11, 0xd6, 0x69, 0xf4, 0xd5, 0x38, 0x85, 0xc9, 0xc1,
2991 0x07, 0x01, 0xe8, 0xbb, 0xfb, 0xe2, 0x08, 0xa8, 0xfa, 0xbf, 0xf0, 0x92,
2992 0x63, 0x1d, 0xbb, 0x2b, 0x45, 0x6f, 0xce, 0x97, 0x01, 0xd7, 0x95, 0xf0,
2993 0x9c, 0x9a, 0x6b, 0x73, 0x01, 0xbf, 0xf9, 0x3d, 0xc8, 0x2b, 0x86, 0x7a,
2994 0xd5, 0x65, 0x84, 0xd7, 0xff, 0xb2, 0xf9, 0x20, 0x52, 0x35, 0xc5, 0x60,
2995 0x33, 0x70, 0x1d, 0x2f, 0x26, 0x09, 0x1c, 0x22, 0x17, 0xd8, 0x08, 0x4e,
2996 0x69, 0x20, 0xe2, 0x71, 0xe4, 0x07, 0xb1, 0x48, 0x5f, 0x20, 0x08, 0x7a,
2997 0xbf, 0x65, 0x53, 0x23, 0x07, 0xf9, 0x6c, 0xde, 0x3e, 0x29, 0xbf, 0x6b,
2998 0xef, 0xbb, 0x6a, 0x5f, 0x79, 0xa1, 0x72, 0xa1, 0x10, 0x24, 0x80, 0xb4,
2999 0x44, 0xb8, 0xc9, 0xfc, 0xa3, 0x36, 0x7e, 0x23, 0x37, 0x58, 0xc6, 0x1e,
3000 0xe8, 0x42, 0x4d, 0xb5, 0xf5, 0x58, 0x93, 0x21, 0x38, 0xa2, 0xc4, 0xa9,
3001 0x01, 0x96, 0xf9, 0x61, 0xac, 0x55, 0xb3, 0x3d, 0xe4, 0x54, 0x8b, 0x6c,
3002 0xc3, 0x83, 0xff, 0x50, 0x87, 0x94, 0xe8, 0x35, 0x3c, 0x26, 0x0d, 0x20,
3003 0x8a, 0x25, 0x0e, 0xb6, 0x67, 0x78, 0x29, 0xc7, 0xbf, 0x76, 0x8e, 0x62,
3004 0x62, 0xc4, 0x50, 0xd6, 0xc5, 0x3c, 0xb4, 0x7a, 0x35, 0xbe, 0x53, 0x52,
3005 0xc4, 0xe4, 0x10, 0xb3, 0xe0, 0x73, 0xb0, 0xd1, 0xc1, 0x5a, 0x4f, 0x4e,
3006 0x64, 0x0d, 0x92, 0x51, 0x2d, 0x4d, 0xec, 0xb0, 0xc6, 0x40, 0x1b, 0x03,
3007 0x89, 0x7f, 0xc2, 0x2c, 0xe3, 0x2c, 0xbd, 0x8c, 0x9c, 0xd9, 0xe0, 0x08,
3008 0x59, 0xd3, 0xaf, 0x48, 0x56, 0x89, 0x60, 0x85, 0x76, 0xe0, 0xd8, 0x7c,
3009 0xcf, 0x02, 0x8f, 0xfd, 0xb2, 0x8f, 0x2b, 0x61, 0xcf, 0x28, 0x56, 0x8b,
3010 0x6b, 0x03, 0x2b, 0x2f, 0x83, 0x31, 0xa0, 0x1c, 0xd1, 0x6c, 0x87, 0x49,
3011 0xc4, 0x77, 0x55, 0x1f, 0x61, 0x45, 0x58, 0x88, 0x9f, 0x01, 0xc3, 0x63,
3012 0x62, 0x30, 0x35, 0xdf, 0x61, 0x74, 0x55, 0x63, 0x3f, 0xae, 0x41, 0xc1,
3013 0xb8, 0xf0, 0x9f, 0xab, 0x25, 0xad, 0x41, 0x5c, 0x1f, 0x00, 0x0d, 0xef,
3014 0xf0, 0xcf, 0xaf, 0x41, 0x23, 0xca, 0x8c, 0x38, 0xea, 0x5a, 0xe4, 0x8b,
3015 0xb4, 0x89, 0xd0, 0x76, 0x7f, 0x2b, 0x77, 0x8f, 0xe4, 0x44, 0xd5, 0x37,
3016 0xac, 0xc2, 0x09, 0x7e, 0x7e, 0x7e, 0x02, 0x5c, 0x27, 0x01, 0xcb, 0x4d,
3017 0xea, 0xb3, 0x97, 0x36, 0x35, 0xd2, 0x05, 0x3c, 0x4e, 0xb8, 0x04, 0x5c,
3018 0xb8, 0x95, 0x3f, 0xc6, 0xbf, 0xd4, 0x20, 0x01, 0xfb, 0xed, 0x37, 0x5a,
3019 0xad, 0x4c, 0x61, 0x93, 0xfe, 0x95, 0x7c, 0x34, 0x11, 0x15, 0x9d, 0x00,
3020 0x0b, 0x99, 0x69, 0xcb, 0x7e, 0xb9, 0x53, 0x46, 0x57, 0x39, 0x3f, 0x59,
3021 0x4b, 0x30, 0x8d, 0xfb, 0x84, 0x66, 0x2d, 0x06, 0xc9, 0x88, 0xa6, 0x18,
3022 0xd7, 0x36, 0xc6, 0xf6, 0xf7, 0x47, 0x85, 0x38, 0xc8, 0x3d, 0x37, 0xea,
3023 0x57, 0x4c, 0xb0, 0x7c, 0x95, 0x29, 0x84, 0xab, 0xbb, 0x19, 0x86, 0xc2,
3024 0xc5, 0x99, 0x01, 0x38, 0x6b, 0xf1, 0xd3, 0x1d, 0xa8, 0x02, 0xf9, 0x6f,
3025 0xaa, 0xf1, 0x57, 0xd0, 0x88, 0x68, 0x62, 0x5f, 0x9f, 0x7a, 0x63, 0xba,
3026 0x3a, 0xc9, 0x95, 0x11, 0x3c, 0xf9, 0xa1, 0xc1, 0x35, 0xfe, 0xd5, 0x12,
3027 0x49, 0x88, 0x0d, 0x5c, 0xe2, 0xd1, 0x15, 0x18, 0xfb, 0xd5, 0x7f, 0x19,
3028 0x3f, 0xaf, 0xa0, 0xcb, 0x31, 0x20, 0x9e, 0x03, 0x93, 0xa4, 0x66, 0xbd,
3029 0x83, 0xe8, 0x60, 0x34, 0x55, 0x0d, 0x97, 0x10, 0x23, 0x24, 0x7a, 0x45,
3030 0x36, 0xb4, 0xc4, 0xee, 0x60, 0x6f, 0xd8, 0x46, 0xc5, 0xac, 0x2b, 0xa9,
3031 0x18, 0x74, 0x83, 0x1e, 0xdf, 0x7c, 0x1a, 0x5a, 0xe8, 0x5f, 0x8b, 0x4f,
3032 0x9f, 0x40, 0x3e, 0x5e, 0xfb, 0xd3, 0x68, 0xac, 0x34, 0x62, 0x30, 0x23,
3033 0xb6, 0xbc, 0xdf, 0xbc, 0xc7, 0x25, 0xd2, 0x1b, 0x57, 0x33, 0xfb, 0x78,
3034 0x22, 0x21, 0x1e, 0x3a, 0xf6, 0x44, 0x18, 0x7e, 0x12, 0x36, 0x47, 0x58,
3035 0xd0, 0x59, 0x26, 0x98, 0x98, 0x95, 0xf4, 0xd1, 0xaa, 0x45, 0xaa, 0xe7,
3036 0xd1, 0xe6, 0x2d, 0x78, 0xf0, 0x8b, 0x1c, 0xfd, 0xf8, 0x50, 0x60, 0xa2,
3037 0x1e, 0x7f, 0xe3, 0x31, 0x77, 0x31, 0x58, 0x99, 0x0f, 0xda, 0x0e, 0xa3,
3038 0xc6, 0x7a, 0x30, 0x45, 0x55, 0x11, 0x91, 0x77, 0x41, 0x79, 0xd3, 0x56,
3039 0xb2, 0x07, 0x00, 0x61, 0xab, 0xec, 0x27, 0xc7, 0x9f, 0xfa, 0x89, 0x08,
3040 0xc2, 0x87, 0xcf, 0xe9, 0xdc, 0x9e, 0x29, 0x22, 0xfb, 0x23, 0x7f, 0x9d,
3041 0x89, 0xd5, 0x6e, 0x75, 0x20, 0xd8, 0x00, 0x5b, 0xc4, 0x94, 0xbb, 0xc5,
3042 0xb2, 0xba, 0x77, 0x2b, 0xf6, 0x3c, 0x88, 0xb0, 0x4c, 0x38, 0x46, 0x55,
3043 0xee, 0x8b, 0x03, 0x15, 0xbc, 0x0a, 0x1d, 0x47, 0x87, 0x44, 0xaf, 0xb1,
3044 0x2a, 0xa7, 0x4d, 0x08, 0xdf, 0x3b, 0x2d, 0x70, 0xa1, 0x67, 0x31, 0x76,
3045 0x6e, 0x6f, 0x40, 0x3b, 0x3b, 0xe8, 0xf9, 0xdf, 0x90, 0xa4, 0xce, 0x7f,
3046 0xb8, 0x2d, 0x69, 0xcb, 0x1c, 0x1e, 0x94, 0xcd, 0xb1, 0xd8, 0x43, 0x22,
3047 0xb8, 0x4f, 0x98, 0x92, 0x74, 0xb3, 0xde, 0xeb, 0x7a, 0xcb, 0xfa, 0xd0,
3048 0x36, 0xe4, 0x5d, 0xfa, 0xd3, 0xce, 0xf9, 0xba, 0x3e, 0x0f, 0x6c, 0xc3,
3049 0x5b, 0xb3, 0x81, 0x84, 0x6e, 0x5d, 0xc1, 0x21, 0x89, 0xec, 0x67, 0x9a,
3050 0xfd, 0x55, 0x20, 0xb0, 0x71, 0x53, 0xae, 0xf8, 0xa4, 0x8d, 0xd5, 0xe5,
3051 0x2d, 0x3a, 0xce, 0x89, 0x55, 0x8c, 0x4f, 0x3b, 0x37, 0x95, 0x4e, 0x15,
3052 0xbe, 0xe7, 0xd1, 0x7a, 0x36, 0x82, 0x45, 0x69, 0x7c, 0x27, 0x4f, 0xb9,
3053 0x4b, 0x7d, 0xcd, 0x59, 0xc8, 0xf4, 0x8b, 0x0f, 0x4f, 0x75, 0x23, 0xd3,
3054 0xd0, 0xc7, 0x10, 0x79, 0xc0, 0xf1, 0xac, 0x14, 0xf7, 0x0d, 0xc8, 0x5e,
3055 0xfc, 0xff, 0x1a, 0x2b, 0x10, 0x88, 0x7e, 0x7e, 0x2f, 0xfa, 0x7b, 0x9f,
3056 0x47, 0x23, 0x34, 0xfc, 0xf5, 0xde, 0xd9, 0xa3, 0x05, 0x99, 0x2a, 0x96,
3057 0x83, 0x3d, 0xa4, 0x7f, 0x6a, 0x66, 0x9b, 0xe7, 0xf1, 0x00, 0x4e, 0x9a,
3058 0xfc, 0x68, 0xd2, 0x74, 0x17, 0xba, 0xc9, 0xc8, 0x20, 0x39, 0xa1, 0xa8,
3059 0x85, 0xc6, 0x10, 0x2b, 0xab, 0x97, 0x34, 0x2d, 0x49, 0x68, 0x57, 0xb0,
3060 0x43, 0xee, 0x25, 0xbb, 0x35, 0x1b, 0x03, 0x99, 0xa3, 0x21, 0x68, 0x66,
3061 0x86, 0x3f, 0xc6, 0xfc, 0x49, 0xf0, 0xba, 0x5f, 0x00, 0xc6, 0xe3, 0x1c,
3062 0xb2, 0x9f, 0x16, 0x7f, 0xc7, 0x40, 0x4a, 0x9a, 0x39, 0xc1, 0x95, 0x69,
3063 0xa2, 0x87, 0xba, 0x58, 0xc6, 0xf2, 0xd6, 0x66, 0xa6, 0x4c, 0x6d, 0x29,
3064 0x9c, 0xa8, 0x6e, 0xa9, 0xd2, 0xe4, 0x54, 0x17, 0x89, 0xe2, 0x43, 0xf0,
3065 0xe1, 0x8b, 0x57, 0x84, 0x6c, 0x87, 0x63, 0x17, 0xbb, 0xf6, 0x33, 0x1b,
3066 0xe4, 0x34, 0x6a, 0x80, 0x70, 0x7b, 0x1b, 0xfd, 0xf8, 0x79, 0x28, 0xc8,
3067 0x3c, 0x8e, 0xa4, 0xd5, 0xb8, 0x96, 0x54, 0xd4, 0xec, 0x72, 0xe5, 0x40,
3068 0x8f, 0x56, 0xde, 0x82, 0x15, 0x72, 0x4d, 0xd8, 0x0c, 0x07, 0xea, 0xe6,
3069 0x44, 0xcd, 0x94, 0x73, 0x5c, 0x04, 0xe8, 0x8e, 0xb7, 0xc7, 0xc9, 0x29,
3070 0xdc, 0x04, 0xef, 0x7c, 0x31, 0x9b, 0x50, 0xbc, 0xea, 0x71, 0x1f, 0x28,
3071 0x22, 0xb6, 0x04, 0x53, 0x2e, 0x71, 0xc4, 0xf6, 0xbb, 0x88, 0x51, 0xee,
3072 0x3e, 0x76, 0x65, 0xb4, 0x4b, 0x1b, 0xa3, 0xec, 0x7b, 0xa7, 0x9d, 0x31,
3073 0x5d, 0xb8, 0x9f, 0xab, 0x6b, 0x54, 0x7d, 0xbd, 0xc1, 0x2c, 0x55, 0xb0,
3074 0x23, 0x8c, 0x06, 0x60, 0x01, 0x4f, 0x60, 0x85, 0x56, 0x7f, 0xfb, 0x99,
3075 0x0c, 0xdc, 0x8c, 0x09, 0x37, 0x46, 0x5b, 0x97, 0x5d, 0xe8, 0x31, 0x00,
3076 0x1b, 0x30, 0x9b, 0x02, 0x92, 0x29, 0xb5, 0x20, 0xce, 0x4b, 0x90, 0xfb,
3077 0x91, 0x07, 0x5a, 0xd3, 0xf5, 0xa0, 0xe6, 0x8f, 0xf8, 0x73, 0xc5, 0x4b,
3078 0xbb, 0xad, 0x2a, 0xeb, 0xa8, 0xb7, 0x68, 0x34, 0x36, 0x47, 0xd5, 0x4b,
3079 0x61, 0x89, 0x53, 0xe6, 0xb6, 0xb1, 0x07, 0xe4, 0x08, 0x2e, 0xed, 0x50,
3080 0xd4, 0x1e, 0xed, 0x7f, 0xbf, 0x35, 0x68, 0x04, 0x45, 0x72, 0x86, 0x71,
3081 0x15, 0x55, 0xdf, 0xe6, 0x30, 0xc0, 0x8b, 0x8a, 0xb0, 0x6c, 0xd0, 0x35,
3082 0x57, 0x8f, 0x04, 0x37, 0xbc, 0xe1, 0xb8, 0xbf, 0x27, 0x37, 0x3d, 0xd0,
3083 0xc8, 0x46, 0x67, 0x42, 0x51, 0x30, 0x82, 0x05, 0xbd, 0x06, 0x09, 0x2a,
3084 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x07, 0x01, 0xa0, 0x82, 0x05, 0xae,
3085 0x04, 0x82, 0x05, 0xaa, 0x30, 0x82, 0x05, 0xa6, 0x30, 0x82, 0x05, 0xa2,
3086 0x06, 0x0b, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x0c, 0x0a, 0x01,
3087 0x02, 0xa0, 0x82, 0x04, 0xee, 0x30, 0x82, 0x04, 0xea, 0x30, 0x1c, 0x06,
3088 0x0a, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x0c, 0x01, 0x03, 0x30,
3089 0x0e, 0x04, 0x08, 0x9f, 0xa4, 0x72, 0x2b, 0x6b, 0x0e, 0xcb, 0x9f, 0x02,
3090 0x02, 0x08, 0x00, 0x04, 0x82, 0x04, 0xc8, 0xe5, 0x35, 0xb9, 0x72, 0x28,
3091 0x20, 0x28, 0xad, 0xe3, 0x01, 0xd7, 0x0b, 0xe0, 0x4e, 0x36, 0xc3, 0x73,
3092 0x06, 0xd5, 0xf6, 0x75, 0x1a, 0x78, 0xb2, 0xd8, 0xf6, 0x5a, 0x85, 0x8e,
3093 0x50, 0xa3, 0x05, 0x49, 0x02, 0x2d, 0xf8, 0xa3, 0x2f, 0xe6, 0x02, 0x7a,
3094 0xd5, 0x0b, 0x1d, 0xf1, 0xd1, 0xe4, 0x16, 0xaa, 0x70, 0x2e, 0x34, 0xdb,
3095 0x56, 0xd9, 0x33, 0x94, 0x11, 0xaa, 0x60, 0xd4, 0xfa, 0x5b, 0xd1, 0xb3,
3096 0x2e, 0x86, 0x6a, 0x5a, 0x69, 0xdf, 0x11, 0x91, 0xb0, 0xca, 0x82, 0xff,
3097 0x63, 0xad, 0x6a, 0x0b, 0x90, 0xa6, 0xc7, 0x9b, 0xef, 0x9a, 0xf8, 0x96,
3098 0xec, 0xe4, 0xc4, 0xdf, 0x55, 0x4c, 0x12, 0x07, 0xab, 0x7c, 0x5c, 0x68,
3099 0x47, 0xf2, 0x92, 0xfb, 0x94, 0xab, 0xc3, 0x64, 0xd3, 0xfe, 0xb2, 0x16,
3100 0xb4, 0x78, 0x80, 0x52, 0xe9, 0x32, 0x39, 0x3b, 0x8d, 0x12, 0x91, 0x36,
3101 0xfd, 0xa1, 0x97, 0xc2, 0x0a, 0x4a, 0xf1, 0xb3, 0x8a, 0xe4, 0x01, 0xed,
3102 0x0a, 0xda, 0x2e, 0xa0, 0x38, 0xa9, 0x47, 0x3d, 0x3a, 0x64, 0x87, 0x06,
3103 0xc3, 0x83, 0x60, 0xaf, 0x84, 0xdb, 0x87, 0xff, 0x70, 0x61, 0x43, 0x7d,
3104 0x2d, 0x61, 0x9a, 0xf7, 0x0d, 0xca, 0x0c, 0x0f, 0xbe, 0x43, 0x5b, 0x99,
3105 0xe1, 0x90, 0x64, 0x1f, 0xa7, 0x1b, 0xa6, 0xa6, 0x5c, 0x13, 0x70, 0xa3,
3106 0xdb, 0xd7, 0xf0, 0xe8, 0x7a, 0xb0, 0xd1, 0x9b, 0x52, 0xa6, 0x4f, 0xd6,
3107 0xff, 0x54, 0x4d, 0xa6, 0x15, 0x05, 0x5c, 0xe9, 0x04, 0x6a, 0xc3, 0x49,
3108 0x12, 0x2f, 0x24, 0x03, 0xc3, 0x80, 0x06, 0xa6, 0x07, 0x8b, 0x96, 0xe7,
3109 0x39, 0x31, 0x6d, 0xd3, 0x1b, 0xa5, 0x45, 0x58, 0x04, 0xe7, 0x87, 0xdf,
3110 0x26, 0xfb, 0x1b, 0x9f, 0x92, 0x93, 0x32, 0x12, 0x9a, 0xc9, 0xe6, 0xcb,
3111 0x88, 0x14, 0x9f, 0x23, 0x0b, 0x52, 0xa2, 0xb8, 0x32, 0x6c, 0xa9, 0x33,
3112 0xa1, 0x17, 0xe8, 0x4a, 0xd4, 0x5c, 0x7d, 0xb3, 0xa3, 0x64, 0x86, 0x03,
3113 0x7c, 0x7c, 0x3f, 0x99, 0xdc, 0x21, 0x9f, 0x93, 0xc6, 0xb9, 0x1d, 0xe0,
3114 0x21, 0x79, 0x78, 0x35, 0xdc, 0x1e, 0x27, 0x3c, 0x73, 0x7f, 0x0f, 0xd6,
3115 0x4f, 0xde, 0xe9, 0xb4, 0xb7, 0xe3, 0xf5, 0x72, 0xce, 0x42, 0xf3, 0x91,
3116 0x5b, 0x84, 0xba, 0xbb, 0xae, 0xf0, 0x87, 0x0f, 0x50, 0xa4, 0x5e, 0x80,
3117 0x23, 0x57, 0x2b, 0xa0, 0xa3, 0xc3, 0x8a, 0x2f, 0xa8, 0x7a, 0x1a, 0x65,
3118 0x8f, 0x62, 0xf8, 0x3e, 0xe2, 0xcd, 0xbc, 0x63, 0x56, 0x8e, 0x77, 0xf3,
3119 0xf9, 0x69, 0x10, 0x57, 0xa8, 0xaf, 0x67, 0x2a, 0x9f, 0x7f, 0x7e, 0xeb,
3120 0x1d, 0x99, 0xa6, 0x67, 0xcd, 0x9e, 0x42, 0x2e, 0x5e, 0x4e, 0x61, 0x24,
3121 0xfa, 0xca, 0x2a, 0xeb, 0x62, 0x1f, 0xa3, 0x14, 0x0a, 0x06, 0x4b, 0x77,
3122 0x78, 0x77, 0x9b, 0xf1, 0x03, 0xcc, 0xb5, 0xfe, 0xfb, 0x7a, 0x77, 0xa6,
3123 0x82, 0x9f, 0xe5, 0xde, 0x9d, 0x0d, 0x4d, 0x37, 0xc6, 0x12, 0x73, 0x6d,
3124 0xea, 0xbb, 0x48, 0xf0, 0xd2, 0x81, 0xcc, 0x1a, 0x47, 0xfa, 0xa4, 0xd2,
3125 0xb2, 0x27, 0xa0, 0xfc, 0x30, 0x04, 0xdb, 0x05, 0xd3, 0x0b, 0xbc, 0x4d,
3126 0x7a, 0x99, 0xef, 0x7f, 0x26, 0x01, 0xd4, 0x07, 0x0b, 0x1e, 0x99, 0x06,
3127 0x3c, 0xde, 0x3d, 0x1c, 0x21, 0x82, 0x68, 0x46, 0x35, 0x38, 0x61, 0xea,
3128 0xd4, 0xc2, 0x65, 0x09, 0x39, 0x87, 0xb4, 0xd3, 0x5d, 0x3c, 0xa3, 0x79,
3129 0xe4, 0x01, 0x4e, 0xbf, 0x18, 0xba, 0x57, 0x3f, 0xdd, 0xea, 0x0a, 0x6b,
3130 0x99, 0xfb, 0x93, 0xfa, 0xab, 0xee, 0x08, 0xdf, 0x38, 0x23, 0xae, 0x8d,
3131 0xa8, 0x03, 0x13, 0xfe, 0x83, 0x88, 0xb0, 0xc2, 0xf9, 0x90, 0xa5, 0x1c,
3132 0x01, 0x6f, 0x71, 0x91, 0x42, 0x35, 0x81, 0x74, 0x71, 0x6c, 0xba, 0x86,
3133 0x48, 0xfe, 0x96, 0xd2, 0x88, 0x12, 0x36, 0x4e, 0xa6, 0x2f, 0xd1, 0xdb,
3134 0xfa, 0xbf, 0xdb, 0x84, 0x01, 0xfc, 0x7d, 0x7a, 0xac, 0x20, 0xae, 0xf5,
3135 0x95, 0xc9, 0xdc, 0x10, 0x5f, 0x4c, 0xae, 0x85, 0x01, 0x8b, 0xfe, 0x77,
3136 0x13, 0x01, 0xae, 0x39, 0x59, 0x7e, 0xbc, 0xfd, 0xc9, 0x42, 0xe4, 0x13,
3137 0x07, 0x3f, 0xa9, 0x74, 0xd9, 0xd5, 0xfc, 0xb9, 0x78, 0xbe, 0x97, 0xf5,
3138 0xe7, 0x36, 0x7f, 0xfa, 0x23, 0x30, 0xeb, 0xab, 0x92, 0xd3, 0xdc, 0x3f,
3139 0x7f, 0xc0, 0x77, 0x93, 0xf9, 0x88, 0xe3, 0x4e, 0x13, 0x53, 0x6d, 0x71,
3140 0x87, 0xe9, 0x24, 0x2b, 0xae, 0x26, 0xbf, 0x62, 0x51, 0x04, 0x42, 0xe1,
3141 0x13, 0x9d, 0xd8, 0x9f, 0x59, 0x87, 0x3f, 0xfc, 0x94, 0xff, 0xcf, 0x88,
3142 0x88, 0xe6, 0xeb, 0x6e, 0xc1, 0x96, 0x04, 0x27, 0xc8, 0xda, 0xfa, 0xe8,
3143 0x2e, 0xbb, 0x2c, 0x6e, 0xf4, 0xb4, 0x00, 0x7d, 0x8d, 0x3b, 0xef, 0x8b,
3144 0x18, 0xa9, 0x5f, 0x32, 0xa9, 0xf2, 0x3a, 0x7e, 0x65, 0x2d, 0x6e, 0x8d,
3145 0x75, 0x77, 0xf6, 0xa6, 0xd8, 0xf9, 0x6b, 0x51, 0xe6, 0x66, 0x52, 0x59,
3146 0x39, 0x97, 0x22, 0xda, 0xb2, 0xd6, 0x82, 0x5a, 0x6e, 0x61, 0x60, 0x16,
3147 0x48, 0x7b, 0xf1, 0xc3, 0x4d, 0x7f, 0x50, 0xfa, 0x4d, 0x58, 0x27, 0x30,
3148 0xc8, 0x96, 0xe0, 0x41, 0x4f, 0x6b, 0xeb, 0x88, 0xa2, 0x7a, 0xef, 0x8a,
3149 0x88, 0xc8, 0x50, 0x4b, 0x55, 0x66, 0xee, 0xbf, 0xc4, 0x01, 0x82, 0x4c,
3150 0xec, 0xde, 0x37, 0x64, 0xd6, 0x1e, 0xcf, 0x3e, 0x2e, 0xfe, 0x84, 0x68,
3151 0xbf, 0xa3, 0x68, 0x77, 0xa9, 0x03, 0xe4, 0xf8, 0xd7, 0xb2, 0x6e, 0xa3,
3152 0xc4, 0xc3, 0x36, 0x53, 0xf3, 0xdd, 0x7e, 0x4c, 0xf0, 0xe9, 0xb2, 0x44,
3153 0xe6, 0x60, 0x3d, 0x00, 0x9a, 0x08, 0xc3, 0x21, 0x17, 0x49, 0xda, 0x49,
3154 0xfb, 0x4c, 0x8b, 0xe9, 0x10, 0x66, 0xfe, 0xb7, 0xe0, 0xf9, 0xdd, 0xbf,
3155 0x41, 0xfe, 0x04, 0x9b, 0x7f, 0xe8, 0xd6, 0x2e, 0x4d, 0x0f, 0x7b, 0x10,
3156 0x73, 0x4c, 0xa1, 0x3e, 0x43, 0xb7, 0xcf, 0x94, 0x97, 0x7e, 0x24, 0xbb,
3157 0x87, 0xbf, 0x22, 0xb8, 0x3e, 0xeb, 0x9a, 0x3f, 0xe3, 0x86, 0xee, 0x21,
3158 0xbc, 0xf5, 0x44, 0xeb, 0x60, 0x2e, 0xe7, 0x8f, 0x89, 0xa4, 0x91, 0x61,
3159 0x28, 0x90, 0x85, 0x68, 0xe0, 0xa9, 0x62, 0x93, 0x86, 0x5a, 0x15, 0xbe,
3160 0xb2, 0x76, 0x83, 0xf2, 0x0f, 0x00, 0xc7, 0xb6, 0x57, 0xe9, 0x1f, 0x92,
3161 0x49, 0xfe, 0x50, 0x85, 0xbf, 0x39, 0x3d, 0xe4, 0x8b, 0x72, 0x2d, 0x49,
3162 0xbe, 0x05, 0x0a, 0x34, 0x56, 0x80, 0xc6, 0x1f, 0x46, 0x59, 0xc9, 0xfe,
3163 0x40, 0xfb, 0x78, 0x6d, 0x7a, 0xe5, 0x30, 0xe9, 0x81, 0x55, 0x75, 0x05,
3164 0x63, 0xd2, 0x22, 0xee, 0x2e, 0x6e, 0xb9, 0x18, 0xe5, 0x8a, 0x5a, 0x66,
3165 0xbd, 0x74, 0x30, 0xe3, 0x8b, 0x76, 0x22, 0x18, 0x1e, 0xef, 0x69, 0xe8,
3166 0x9d, 0x07, 0xa7, 0x9a, 0x87, 0x6c, 0x04, 0x4b, 0x74, 0x2b, 0xbe, 0x37,
3167 0x2f, 0x29, 0x9b, 0x60, 0x9d, 0x8b, 0x57, 0x55, 0x34, 0xca, 0x41, 0x25,
3168 0xae, 0x56, 0x92, 0x34, 0x1b, 0x9e, 0xbd, 0xfe, 0x74, 0xbd, 0x4e, 0x29,
3169 0xf0, 0x5e, 0x27, 0x94, 0xb0, 0x9e, 0x23, 0x9f, 0x4a, 0x0f, 0xa1, 0xdf,
3170 0xe7, 0xc4, 0xdb, 0xbe, 0x0f, 0x1a, 0x0b, 0x6c, 0xb0, 0xe1, 0x06, 0x7c,
3171 0x5a, 0x5b, 0x81, 0x1c, 0xb6, 0x12, 0xec, 0x6f, 0x3b, 0xbb, 0x84, 0x36,
3172 0xd5, 0x28, 0x16, 0xea, 0x51, 0xa8, 0x99, 0x24, 0x8f, 0xe7, 0xf8, 0xe9,
3173 0xce, 0xa1, 0x65, 0x96, 0x6f, 0x4e, 0x2f, 0xb7, 0x6f, 0x65, 0x39, 0xad,
3174 0xfd, 0x2e, 0xa0, 0x37, 0x32, 0x2f, 0xf3, 0x95, 0xa1, 0x3a, 0xa1, 0x9d,
3175 0x2c, 0x9e, 0xa1, 0x4b, 0x7e, 0xc9, 0x7e, 0x86, 0xaa, 0x16, 0x00, 0x82,
3176 0x1d, 0x36, 0xbf, 0x98, 0x0a, 0x82, 0x5b, 0xcc, 0xc4, 0x6a, 0xad, 0xa0,
3177 0x1f, 0x47, 0x98, 0xde, 0x8d, 0x68, 0x38, 0x3f, 0x33, 0xe2, 0x08, 0x3b,
3178 0x2a, 0x65, 0xd9, 0x2f, 0x53, 0x68, 0xb8, 0x78, 0xd0, 0x1d, 0xbb, 0x2a,
3179 0x73, 0x19, 0xba, 0x58, 0xea, 0xf1, 0x0a, 0xaa, 0xa6, 0xbe, 0x27, 0xd6,
3180 0x00, 0x6b, 0x4e, 0x43, 0x8e, 0x5b, 0x19, 0xc1, 0x37, 0x0f, 0xfb, 0x81,
3181 0x72, 0x10, 0xb6, 0x20, 0x32, 0xcd, 0xa2, 0x7c, 0x90, 0xd4, 0xf5, 0xcf,
3182 0x1c, 0xcb, 0x14, 0x24, 0x7a, 0x4d, 0xf5, 0xd5, 0xd9, 0xce, 0x6a, 0x64,
3183 0xc9, 0xd3, 0xa7, 0x36, 0x6f, 0x1d, 0xf1, 0xe9, 0x71, 0x6c, 0x3d, 0x02,
3184 0xa4, 0x62, 0xb1, 0x82, 0x5c, 0x13, 0x4b, 0x6b, 0x68, 0xe2, 0x31, 0xef,
3185 0xe4, 0x46, 0xfd, 0xe5, 0xa8, 0x29, 0xe9, 0x1e, 0xad, 0xff, 0x33, 0xdb,
3186 0x0b, 0xc0, 0x92, 0xb1, 0xef, 0xeb, 0xb3, 0x6f, 0x96, 0x7b, 0xdf, 0xcd,
3187 0x07, 0x19, 0x86, 0x60, 0x98, 0xcf, 0x95, 0xfe, 0x98, 0xdd, 0x29, 0xa6,
3188 0x35, 0x7b, 0x46, 0x13, 0x03, 0xa8, 0xd9, 0x7c, 0xb3, 0xdf, 0x9f, 0x14,
3189 0xb7, 0x34, 0x5a, 0xc4, 0x12, 0x81, 0xc5, 0x98, 0x25, 0x8d, 0x3e, 0xe3,
3190 0xd8, 0x2d, 0xe4, 0x54, 0xab, 0xb0, 0x13, 0xfd, 0xd1, 0x3f, 0x3b, 0xbf,
3191 0xa9, 0x45, 0x28, 0x8a, 0x2f, 0x9c, 0x1e, 0x2d, 0xe5, 0xab, 0x13, 0x95,
3192 0x97, 0xc3, 0x34, 0x37, 0x8d, 0x93, 0x66, 0x31, 0x81, 0xa0, 0x30, 0x23,
3193 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x09, 0x15, 0x31,
3194 0x16, 0x04, 0x14, 0xa5, 0x23, 0x9b, 0x7e, 0xe6, 0x45, 0x71, 0xbf, 0x48,
3195 0xc6, 0x27, 0x3c, 0x96, 0x87, 0x63, 0xbd, 0x1f, 0xde, 0x72, 0x12, 0x30,
3196 0x79, 0x06, 0x09, 0x2b, 0x06, 0x01, 0x04, 0x01, 0x82, 0x37, 0x11, 0x01,
3197 0x31, 0x6c, 0x1e, 0x6a, 0x00, 0x4d, 0x00, 0x69, 0x00, 0x63, 0x00, 0x72,
3198 0x00, 0x6f, 0x00, 0x73, 0x00, 0x6f, 0x00, 0x66, 0x00, 0x74, 0x00, 0x20,
3199 0x00, 0x45, 0x00, 0x6e, 0x00, 0x68, 0x00, 0x61, 0x00, 0x6e, 0x00, 0x63,
3200 0x00, 0x65, 0x00, 0x64, 0x00, 0x20, 0x00, 0x52, 0x00, 0x53, 0x00, 0x41,
3201 0x00, 0x20, 0x00, 0x61, 0x00, 0x6e, 0x00, 0x64, 0x00, 0x20, 0x00, 0x41,
3202 0x00, 0x45, 0x00, 0x53, 0x00, 0x20, 0x00, 0x43, 0x00, 0x72, 0x00, 0x79,
3203 0x00, 0x70, 0x00, 0x74, 0x00, 0x6f, 0x00, 0x67, 0x00, 0x72, 0x00, 0x61,
3204 0x00, 0x70, 0x00, 0x68, 0x00, 0x69, 0x00, 0x63, 0x00, 0x20, 0x00, 0x50,
3205 0x00, 0x72, 0x00, 0x6f, 0x00, 0x76, 0x00, 0x69, 0x00, 0x64, 0x00, 0x65,
3206 0x00, 0x72, 0x30, 0x31, 0x30, 0x21, 0x30, 0x09, 0x06, 0x05, 0x2b, 0x0e,
3207 0x03, 0x02, 0x1a, 0x05, 0x00, 0x04, 0x14, 0x93, 0xa8, 0xb2, 0x7e, 0xb7,
3208 0xab, 0xf1, 0x1c, 0x3c, 0x36, 0x58, 0xdc, 0x67, 0x6d, 0x42, 0xa6, 0xfc,
3209 0x53, 0x01, 0xe6, 0x04, 0x08, 0x77, 0x57, 0x22, 0xa1, 0x7d, 0xb9, 0xa2,
3210 0x69, 0x02, 0x02, 0x08, 0x00
3211};
3212
3214{
3215 HCERTSTORE store;
3216 CRYPT_DATA_BLOB pfx;
3217 const CERT_CONTEXT *cert;
3219 char buf[512];
3221 CERT_INFO *info;
3222 DWORD count, size;
3223 BOOL ret;
3224
3225 SetLastError( 0xdeadbeef );
3226 store = PFXImportCertStore( NULL, NULL, 0 );
3227 ok( store == NULL, "got %p\n", store );
3228 ok( GetLastError() == ERROR_INVALID_PARAMETER, "got %lu\n", GetLastError() );
3229
3230 pfx.pbData = (BYTE *)pfxdata;
3231 pfx.cbData = sizeof(pfxdata);
3233 ok( store != NULL, "got %lu\n", GetLastError() );
3234 count = countCertsInStore( store );
3235 ok( count == 1, "got %lu\n", count );
3236
3238 ok( cert != NULL, "got %lu\n", GetLastError() );
3239 ok( cert->dwCertEncodingType == X509_ASN_ENCODING, "got %lu\n", cert->dwCertEncodingType );
3240 ok( cert->pbCertEncoded != NULL, "pbCertEncoded not set\n" );
3241 ok( cert->cbCertEncoded == 1123, "got %lu\n", cert->cbCertEncoded );
3242 ok( cert->pCertInfo != NULL, "pCertInfo not set\n" );
3243 ok( cert->hCertStore == store, "got %p\n", cert->hCertStore );
3244
3245 info = cert->pCertInfo;
3246 ok( info->dwVersion == CERT_V1, "got %lu\n", info->dwVersion );
3247 ok( !strcmp(info->SignatureAlgorithm.pszObjId, szOID_RSA_SHA256RSA),
3248 "got \"%s\"\n", info->SignatureAlgorithm.pszObjId );
3249
3250 size = sizeof(key);
3252 ok( ret, "got %08lx\n", GetLastError() );
3253 ok( key.cbSize == sizeof(key), "got %lu\n", key.cbSize );
3254 ok( key.hCryptProv, "hCryptProv not set\n" );
3255 ok( key.dwKeySpec == AT_KEYEXCHANGE, "got %lu\n", key.dwKeySpec );
3256
3257 size = sizeof(buf);
3258 SetLastError( 0xdeadbeef );
3260 ok( !ret && GetLastError() == CRYPT_E_NOT_FOUND, "got %08lx\n", GetLastError() );
3262 CertCloseStore( store, 0 );
3263
3264 /* without PKCS12_NO_PERSIST_KEY */
3266 ok( store != NULL, "got %lu\n", GetLastError() );
3267
3269 ok( cert != NULL, "got %08lx\n", GetLastError() );
3270
3271 size = sizeof(key);
3273 ok( !ret && GetLastError() == CRYPT_E_NOT_FOUND, "got %08lx\n", GetLastError() );
3274
3275 size = sizeof(buf);
3277 ok(ret, "got %lu\n", GetLastError());
3279 CertCloseStore( store, 0 );
3280
3281 /* CRYPT_MACHINE_KEYSET */
3283 ok( store != NULL, "got %lu\n", GetLastError() );
3284
3286 ok( cert != NULL, "got %08lx\n", GetLastError() );
3287
3289 CertCloseStore( store, 0 );
3290}
3291
3292static void test_CryptQueryObject(void)
3293{
3294 CRYPT_DATA_BLOB pfx;
3295 DWORD encoding_type, content_type, format_type;
3296 HCERTSTORE store;
3297 HCRYPTMSG msg;
3298 const void *ctx;
3299 BOOL ret;
3300
3301 SetLastError( 0xdeadbeef );
3304 ok( !ret, "success\n" );
3305 ok( GetLastError() == E_INVALIDARG, "got %lu\n", GetLastError() );
3306
3307 pfx.pbData = (BYTE *)pfxdata;
3308 pfx.cbData = sizeof(pfxdata);
3309 encoding_type = content_type = format_type = 0xdeadbeef;
3310 store = (HCERTSTORE *)0xdeadbeef;
3311 msg = (HCRYPTMSG *)0xdeadbeef;
3312 ctx = (void *)0xdeadbeef;
3315 &store, &msg, &ctx );
3316 ok( ret, "got %lu\n", GetLastError() );
3317 ok( encoding_type == X509_ASN_ENCODING, "got %08lx\n", encoding_type );
3318 ok( content_type == CERT_QUERY_CONTENT_PFX, "got %08lx\n", content_type );
3319 ok( format_type == CERT_QUERY_FORMAT_BINARY, "got %08lx\n", format_type );
3320 ok( store == NULL, "got %p\n", store );
3321 ok( msg == NULL, "got %p\n", msg );
3322 ok( ctx == NULL, "got %p\n", ctx );
3323}
3324
3326{
3327 /* various combinations of CertOpenStore */
3328 testMemStore();
3331
3332 testRegStore();
3334
3337 testFileStore();
3342
3344
3348
3351
3353
3355#ifdef __REACTOS__
3356 if ((GetVersion() & 0xFF) > 5) // test_PFXImportCertStore() crashes on Server 2003
3357#endif
3360}
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
static int state
Definition: maze.c:121
#define ok(value,...)
Definition: atltest.h:57
#define skip(...)
Definition: atltest.h:64
#define START_TEST(x)
Definition: atltest.h:75
#define ok_(x1, x2)
Definition: atltest.h:61
#define msg(x)
Definition: auth_time.c:54
#define ARRAY_SIZE(A)
Definition: main.h:20
INT copy(TCHAR source[MAX_PATH], TCHAR dest[MAX_PATH], INT append, DWORD lpdwFlags, BOOL bTouch)
Definition: copy.c:51
#define RegCloseKey(hKey)
Definition: registry.h:49
BOOL WINAPI CertAddStoreToCollection(HCERTSTORE hCollectionStore, HCERTSTORE hSiblingStore, DWORD dwUpdateFlags, DWORD dwPriority)
void WINAPI CertRemoveStoreFromCollection(HCERTSTORE hCollectionStore, HCERTSTORE hSiblingStore)
HCERTSTORE WINAPI PFXImportCertStore(CRYPT_DATA_BLOB *pPFX, LPCWSTR szPassword, DWORD dwFlags)
Definition: decode.c:6400
format_type
Definition: d3dx9_private.h:49
#define E_INVALIDARG
Definition: ddrawi.h:101
#define free
Definition: debug_ros.c:5
#define malloc
Definition: debug_ros.c:4
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
unsigned int idx
Definition: utils.c:41
LONG WINAPI RegCreateKeyExW(_In_ HKEY hKey, _In_ LPCWSTR lpSubKey, _In_ DWORD Reserved, _In_opt_ LPWSTR lpClass, _In_ DWORD dwOptions, _In_ REGSAM samDesired, _In_opt_ LPSECURITY_ATTRIBUTES lpSecurityAttributes, _Out_ PHKEY phkResult, _Out_opt_ LPDWORD lpdwDisposition)
Definition: reg.c:1096
LONG WINAPI RegSetValueExA(HKEY hKey, LPCSTR lpValueName, DWORD Reserved, DWORD dwType, CONST BYTE *lpData, DWORD cbData)
Definition: reg.c:4799
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3333
LONG WINAPI RegEnumKeyExW(_In_ HKEY hKey, _In_ DWORD dwIndex, _Out_ LPWSTR lpName, _Inout_ LPDWORD lpcbName, _Reserved_ LPDWORD lpReserved, _Out_opt_ LPWSTR lpClass, _Inout_opt_ LPDWORD lpcbClass, _Out_opt_ PFILETIME lpftLastWriteTime)
Definition: reg.c:2504
LONG WINAPI RegDeleteKeyW(_In_ HKEY hKey, _In_ LPCWSTR lpSubKey)
Definition: reg.c:1239
LONG WINAPI RegQueryInfoKeyW(HKEY hKey, LPWSTR lpClass, LPDWORD lpcClass, LPDWORD lpReserved, LPDWORD lpcSubKeys, LPDWORD lpcMaxSubKeyLen, LPDWORD lpcMaxClassLen, LPDWORD lpcValues, LPDWORD lpcMaxValueNameLen, LPDWORD lpcMaxValueLen, LPDWORD lpcbSecurityDescriptor, PFILETIME lpftLastWriteTime)
Definition: reg.c:3662
LONG WINAPI RegQueryValueExA(_In_ HKEY hkeyorg, _In_ LPCSTR name, _In_ LPDWORD reserved, _Out_opt_ LPDWORD type, _Out_opt_ LPBYTE data, _Inout_opt_ LPDWORD count)
Definition: reg.c:4009
LONG WINAPI RegCreateKeyExA(_In_ HKEY hKey, _In_ LPCSTR lpSubKey, _In_ DWORD Reserved, _In_ LPSTR lpClass, _In_ DWORD dwOptions, _In_ REGSAM samDesired, _In_ LPSECURITY_ATTRIBUTES lpSecurityAttributes, _Out_ PHKEY phkResult, _Out_ LPDWORD lpdwDisposition)
Definition: reg.c:1034
LONG WINAPI RegDeleteKeyA(_In_ HKEY hKey, _In_ LPCSTR lpSubKey)
Definition: reg.c:1224
BOOL WINAPI CertAddCertificateContextToStore(HCERTSTORE hCertStore, PCCERT_CONTEXT pCertContext, DWORD dwAddDisposition, PCCERT_CONTEXT *ppStoreContext)
Definition: cert.c:286
BOOL WINAPI CertFreeCertificateContext(PCCERT_CONTEXT pCertContext)
Definition: cert.c:371
PCCERT_CONTEXT WINAPI CertCreateCertificateContext(DWORD dwCertEncodingType, const BYTE *pbCertEncoded, DWORD cbCertEncoded)
Definition: cert.c:316
PCCERT_CONTEXT WINAPI CertFindCertificateInStore(HCERTSTORE hCertStore, DWORD dwCertEncodingType, DWORD dwFlags, DWORD dwType, const void *pvPara, PCCERT_CONTEXT pPrevCertContext)
Definition: cert.c:1765
BOOL WINAPI CertAddCertificateLinkToStore(HCERTSTORE hCertStore, PCCERT_CONTEXT pCertContext, DWORD dwAddDisposition, PCCERT_CONTEXT *ppCertContext)
Definition: cert.c:296
BOOL WINAPI CertAddEncodedCertificateToStore(HCERTSTORE hCertStore, DWORD dwCertEncodingType, const BYTE *pbCertEncoded, DWORD cbCertEncoded, DWORD dwAddDisposition, PCCERT_CONTEXT *ppCertContext)
Definition: cert.c:58
BOOL WINAPI CertSetCertificateContextProperty(PCCERT_CONTEXT pCertContext, DWORD dwPropId, DWORD dwFlags, const void *pvData)
Definition: cert.c:799
BOOL WINAPI CertGetCertificateContextProperty(PCCERT_CONTEXT pCertContext, DWORD dwPropId, void *pvData, DWORD *pcbData)
Definition: cert.c:551
PCCERT_CONTEXT WINAPI CertDuplicateCertificateContext(PCCERT_CONTEXT pCertContext)
Definition: cert.c:360
BOOL WINAPI CryptHashCertificate(HCRYPTPROV_LEGACY hCryptProv, ALG_ID Algid, DWORD dwFlags, const BYTE *pbEncoded, DWORD cbEncoded, BYTE *pbComputedHash, DWORD *pcbComputedHash)
Definition: cert.c:2187
BOOL WINAPI CertFreeCRLContext(PCCRL_CONTEXT pCrlContext)
Definition: crl.c:386
BOOL WINAPI CertAddEncodedCRLToStore(HCERTSTORE hCertStore, DWORD dwCertEncodingType, const BYTE *pbCrlEncoded, DWORD cbCrlEncoded, DWORD dwAddDisposition, PCCRL_CONTEXT *ppCrlContext)
Definition: crl.c:129
PCCRL_CONTEXT WINAPI CertCreateCRLContext(DWORD dwCertEncodingType, const BYTE *pbCrlEncoded, DWORD cbCrlEncoded)
Definition: crl.c:85
BOOL WINAPI CertFreeCTLContext(PCCTL_CONTEXT pCTLContext)
Definition: ctl.c:499
PCCTL_CONTEXT WINAPI CertCreateCTLContext(DWORD dwMsgAndCertEncodingType, const BYTE *pbCtlEncoded, DWORD cbCtlEncoded)
Definition: ctl.c:363
BOOL WINAPI CertAddEncodedCTLToStore(HCERTSTORE hCertStore, DWORD dwMsgAndCertEncodingType, const BYTE *pbCtlEncoded, DWORD cbCtlEncoded, DWORD dwAddDisposition, PCCTL_CONTEXT *ppCtlContext)
Definition: ctl.c:177
HCRYPTMSG WINAPI CryptMsgOpenToDecode(DWORD dwMsgEncodingType, DWORD dwFlags, DWORD dwMsgType, HCRYPTPROV_LEGACY hCryptProv, PCERT_INFO pRecipientInfo, PCMSG_STREAM_INFO pStreamInfo)
Definition: msg.c:3552
BOOL WINAPI CryptMsgGetParam(HCRYPTMSG hCryptMsg, DWORD dwParamType, DWORD dwIndex, void *pvData, DWORD *pcbData)
Definition: msg.c:3626
BOOL WINAPI CryptMsgUpdate(HCRYPTMSG hCryptMsg, const BYTE *pbData, DWORD cbData, BOOL fFinal)
Definition: msg.c:3616
BOOL WINAPI CryptMsgClose(HCRYPTMSG hCryptMsg)
Definition: msg.c:3597
BOOL WINAPI CryptQueryObject(DWORD dwObjectType, const void *pvObject, DWORD dwExpectedContentTypeFlags, DWORD dwExpectedFormatTypeFlags, DWORD dwFlags, DWORD *pdwMsgAndCertEncodingType, DWORD *pdwContentType, DWORD *pdwFormatType, HCERTSTORE *phCertStore, HCRYPTMSG *phMsg, const void **ppvContext)
Definition: object.c:699
BOOL WINAPI CertRegisterSystemStore(const void *pvSystemStore, DWORD dwFlags, PCERT_SYSTEM_STORE_INFO pStoreInfo, void *pvReserved)
Definition: store.c:1448
HCERTSTORE WINAPI CertOpenStore(LPCSTR lpszStoreProvider, DWORD dwMsgAndCertEncodingType, HCRYPTPROV_LEGACY hCryptProv, DWORD dwFlags, const void *pvPara)
Definition: store.c:815
BOOL WINAPI CertSetStoreProperty(HCERTSTORE hCertStore, DWORD dwPropId, DWORD dwFlags, const void *pvData)
Definition: store.c:1236
BOOL WINAPI CertControlStore(HCERTSTORE hCertStore, DWORD dwFlags, DWORD dwCtrlType, void const *pvCtrlPara)
Definition: store.c:1149
HCERTSTORE WINAPI CertDuplicateStore(HCERTSTORE hCertStore)
Definition: store.c:1116
BOOL WINAPI CertEnumSystemStore(DWORD dwFlags, void *pvSystemStoreLocationPara, void *pvArg, PFN_CERT_ENUM_SYSTEM_STORE pfnEnum)
Definition: store.c:1321
BOOL WINAPI CertUnregisterSystemStore(const void *pvSystemStore, DWORD dwFlags)
Definition: store.c:1471
PCCRL_CONTEXT WINAPI CertEnumCRLsInStore(HCERTSTORE hCertStore, PCCRL_CONTEXT pPrev)
Definition: store.c:1101
PCCERT_CONTEXT WINAPI CertEnumCertificatesInStore(HCERTSTORE hCertStore, PCCERT_CONTEXT pPrev)
Definition: store.c:928
HCERTSTORE WINAPI CertOpenSystemStoreA(HCRYPTPROV_LEGACY hProv, LPCSTR szSubSystemProtocol)
Definition: store.c:904
BOOL WINAPI CertCloseStore(HCERTSTORE hCertStore, DWORD dwFlags)
Definition: store.c:1127
BOOL WINAPI CertGetStoreProperty(HCERTSTORE hCertStore, DWORD dwPropId, void *pvData, DWORD *pcbData)
Definition: store.c:1172
BOOL WINAPI CertDeleteCertificateFromStore(PCCERT_CONTEXT pCertContext)
Definition: store.c:943
HCERTSTORE WINAPI CertOpenSystemStoreW(HCRYPTPROV_LEGACY hProv, LPCWSTR szSubSystemProtocol)
Definition: store.c:916
#define CloseHandle
Definition: compat.h:739
#define ERROR_CALL_NOT_IMPLEMENTED
Definition: compat.h:102
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
#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 GENERIC_READ
Definition: compat.h:135
#define MAX_PATH
Definition: compat.h:34
#define ERROR_INVALID_HANDLE
Definition: compat.h:98
#define CreateFileW
Definition: compat.h:741
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:137
#define CALLBACK
Definition: compat.h:35
#define lstrcpyW
Definition: compat.h:749
#define ERROR_ACCESS_DENIED
Definition: compat.h:97
BOOL WINAPI DeleteFileW(IN LPCWSTR lpFileName)
Definition: delete.c:39
DWORD WINAPI GetFileSize(HANDLE hFile, LPDWORD lpFileSizeHigh)
Definition: fileinfo.c:331
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
int WINAPI lstrcmpW(LPCWSTR str1, LPCWSTR str2)
Definition: locale.c:4246
DWORD WINAPI GetVersion(void)
Definition: version.c:1458
HRESULT WINAPI SHGetFolderPathW(HWND hwndOwner, int nFolder, HANDLE hToken, DWORD dwFlags, LPWSTR pszPath)
Definition: shellpath.c:2716
DWORD WINAPI SHDeleteKeyA(HKEY hKey, LPCSTR lpszSubKey)
Definition: reg.c:1533
return ret
Definition: mutex.c:146
#define L(x)
Definition: resources.c:13
UINT WINAPI GetTempFileNameW(IN LPCWSTR lpPathName, IN LPCWSTR lpPrefixString, IN UINT uUnique, OUT LPWSTR lpTempFileName)
Definition: filename.c:84
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
GLuint GLuint GLsizei count
Definition: gl.h:1545
GLuint res
Definition: glext.h:9613
GLsizeiptr size
Definition: glext.h:5919
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define S_OK
Definition: intsafe.h:52
const char * filename
Definition: ioapi.h:137
char hdr[14]
Definition: iptest.cpp:33
LPWSTR WINAPI lstrcatW(LPWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:274
static char filename2[]
Definition: lzexpand_main.c:51
#define win_skip
Definition: minitest.h:67
#define todo_wine_if(is_todo)
Definition: minitest.h:81
#define todo_wine
Definition: minitest.h:80
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define CREATE_ALWAYS
Definition: disk.h:72
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
static PVOID ptr
Definition: dispmode.c:27
#define sprintf
Definition: sprintf.c:45
static DWORD GLE
Definition: registry.c:38
static const BYTE cert2[]
Definition: message.c:797
static const BYTE hashVal[]
Definition: message.c:603
static const BYTE crl[]
Definition: message.c:817
static const BYTE cert1[]
Definition: message.c:781
static BYTE cert[]
Definition: msg.c:1374
const WCHAR * base_reg_path
Definition: store.c:345
static void testAddSerialized(void)
Definition: store.c:2192
static void test_I_UpdateStore(void)
Definition: store.c:2900
static DWORD countCertsInStore(HCERTSTORE store)
Definition: store.c:2705
static void testSerializedStore(void)
Definition: store.c:1918
static const BYTE serializedStoreWithCertAndCRL[]
Definition: store.c:1396
static void testAddCertificateLink(void)
Definition: store.c:2414
static const BYTE pfxdata[]
Definition: store.c:2971
static const WCHAR utf16Base64SPC[]
Definition: store.c:1572
static void testCollectionStore(void)
Definition: store.c:607
static const BYTE signedCRL[]
Definition: store.c:83
static const struct @1783 reg_store_saved_certs[]
static void testFileStore(void)
Definition: store.c:1414
static const BYTE bigCert[]
Definition: store.c:48
HKEY key
Definition: store.c:341
static void test_CryptQueryObject(void)
Definition: store.c:3292
static void testMessageStore(void)
Definition: store.c:1806
static const BYTE hashContent[]
Definition: store.c:1794
static void testEmptyStore(void)
Definition: store.c:2731
static const struct CertPropIDHeader * findPropID(const BYTE *buf, DWORD size, DWORD propID)
Definition: store.c:967
static void testCertOpenSystemStore(void)
Definition: store.c:1977
static const BYTE emptyCert[]
Definition: store.c:47
static const BYTE signedWithCertAndCrlBareContent[]
Definition: store.c:1770
static void delete_test_key(void)
Definition: store.c:2388
static BOOL initFileFromData(LPCWSTR filename, const BYTE *pb, DWORD cb)
Definition: store.c:1540
#define CERT_CERT_PROP_ID
Definition: store.c:36
static const BYTE signedCTLWithCTLInnerContent[]
Definition: store.c:99
static DWORD countCRLsInStore(HCERTSTORE store)
Definition: store.c:2718
static void testStoreProperty(void)
Definition: store.c:2119
BOOL appdata_file
Definition: store.c:343
static void testCertEnumSystemStore(void)
Definition: store.c:2087
static const BYTE signedContent[]
Definition: store.c:1756
static const BYTE hashBareContent[]
Definition: store.c:1800
static const BYTE serializedStoreWithCert[]
Definition: store.c:326
static const BYTE serializedCert[]
Definition: store.c:71
static void testCertRegisterSystemStore(void)
Definition: store.c:2012
static void testRegStoreSavedCerts(void)
Definition: store.c:365
DWORD cert_store
Definition: store.c:342
static void testMemStore(void)
Definition: store.c:129
static void testCloseStore(void)
Definition: store.c:2807
static void _test_store_is_empty(unsigned line, HCERTSTORE store)
Definition: store.c:121
static void test_PFXImportCertStore(void)
Definition: store.c:3213
WCHAR store_name[16]
Definition: store.c:344
BOOL todo
Definition: store.c:2001
static void testFileNameStore(void)
Definition: store.c:1586
static const BYTE serializedStoreWithCertWithFriendlyName[]
Definition: store.c:2359
static BOOL CALLBACK enumSystemStoreCB(const void *systemStore, DWORD dwFlags, PCERT_SYSTEM_STORE_INFO pStoreInfo, void *pvReserved, void *pvArg)
Definition: store.c:2078
static const BYTE serializedStoreWithCertAndHash[]
Definition: store.c:2373
static const BYTE base64SPC[]
Definition: store.c:1558
static void testRegStore(void)
Definition: store.c:998
static const BYTE signedBigCert[]
Definition: store.c:58
static void compareStore(HCERTSTORE store, LPCSTR name, const BYTE *pb, DWORD cb, BOOL todo)
Definition: store.c:302
#define test_store_is_empty(store)
Definition: store.c:120
static const BYTE serializedCertWithFriendlyName[]
Definition: store.c:2346
static void testStoresInCollection(void)
Definition: store.c:473
static const struct @1784 reg_system_store_test_data[]
static void testSystemRegStore(void)
Definition: store.c:1267
static void testSystemStore(void)
Definition: store.c:1325
static const BYTE bigCert2[]
Definition: store.c:89
BOOL expected
Definition: store.c:2000
static LPCWSTR LPVOID pvReserved
Definition: asmcache.c:749
static HMODULE MODULEINFO DWORD cb
Definition: module.c:33
static BSTR content_type
static ICollection collection
Definition: typelib.c:184
_In_ LPWSTR _In_ DWORD _In_ DWORD _In_ DWORD dwFlags
Definition: netsh.h:141
#define REG_BINARY
Definition: nt_native.h:1499
#define KEY_ALL_ACCESS
Definition: nt_native.h:1044
#define KEY_READ
Definition: nt_native.h:1026
#define BOOL
Definition: nt_native.h:43
#define DWORD
Definition: nt_native.h:44
#define REG_OPENED_EXISTING_KEY
Definition: nt_native.h:1088
#define GENERIC_WRITE
Definition: nt_native.h:90
#define PathAppendW
Definition: pathcch.h:310
long LONG
Definition: pedump.c:60
#define err(...)
strcpy
Definition: string.h:131
#define memset(x, y, z)
Definition: compat.h:39
BOOL WINAPI CertSaveStore(HCERTSTORE hCertStore, DWORD dwMsgAndCertEncodingType, DWORD dwSaveAs, DWORD dwSaveTo, void *pvSaveToPara, DWORD dwFlags)
Definition: serialize.c:895
BOOL WINAPI CertAddSerializedElementToStore(HCERTSTORE hCertStore, const BYTE *pbElement, DWORD cbElement, DWORD dwAddDisposition, DWORD dwFlags, DWORD dwContextTypeFlags, DWORD *pdwContentType, const void **ppvContext)
Definition: serialize.c:953
BOOL WINAPI CertSerializeCertificateStoreElement(PCCERT_CONTEXT pCertContext, DWORD dwFlags, BYTE *pbElement, DWORD *pcbElement)
Definition: serialize.c:144
#define CSIDL_APPDATA
Definition: shlobj.h:2204
DWORD cb
Definition: store.c:44
DWORD propID
Definition: store.c:42
DWORD unknown1
Definition: store.c:43
HCERTSTORE hCertStore
Definition: wincrypt.h:492
DWORD cbCertEncoded
Definition: wincrypt.h:490
BYTE * pbData
Definition: wincrypt.h:112
HCERTSTORE hCertStore
Definition: wincrypt.h:860
Definition: image.c:134
Definition: http.c:7252
Definition: fci.c:127
Definition: _hash_fun.h:40
Definition: copy.c:22
Definition: parser.c:49
Definition: name.c:39
unsigned char * LPBYTE
Definition: typedefs.h:53
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define szOID_RSA_SHA256RSA
Definition: wincrypt.h:3177
#define CERT_STORE_PROV_PKCS7
Definition: wincrypt.h:2458
#define CERT_QUERY_CONTENT_FLAG_ALL
Definition: wincrypt.h:3724
#define CERT_KEY_CONTEXT_PROP_ID
Definition: wincrypt.h:2837
#define CERT_STORE_SAVE_AS_STORE
Definition: wincrypt.h:2793
#define CERT_STORE_PROV_COLLECTION
Definition: wincrypt.h:2465
#define CERT_PHYSICAL_STORE_ADD_ENABLE_FLAG
Definition: wincrypt.h:2743
#define CERT_STORE_ADD_REPLACE_EXISTING
Definition: wincrypt.h:2653
#define CERT_STORE_LOCALIZED_NAME_PROP_ID
Definition: wincrypt.h:2977
void * HCERTSTORE
Definition: wincrypt.h:60
#define CERT_QUERY_FORMAT_BINARY
Definition: wincrypt.h:3739
#define CRYPT_USER_KEYSET
Definition: wincrypt.h:4320
#define CERT_STORE_OPEN_EXISTING_FLAG
Definition: wincrypt.h:2634
#define CERT_KEY_PROV_INFO_PROP_ID
Definition: wincrypt.h:2833
#define CERT_FIRST_USER_PROP_ID
Definition: wincrypt.h:2895
#define CERT_STORE_CREATE_NEW_FLAG
Definition: wincrypt.h:2633
#define CERT_STORE_PROV_SYSTEM
Definition: wincrypt.h:2464
#define CERT_CLOSE_STORE_CHECK_FLAG
Definition: wincrypt.h:2648
#define CERT_QUERY_OBJECT_BLOB
Definition: wincrypt.h:3687
#define CERT_STORE_PROV_SERIALIZED
Definition: wincrypt.h:2459
#define CERT_QUERY_FORMAT_FLAG_BINARY
Definition: wincrypt.h:3743
#define CERT_STORE_PROV_SYSTEM_REGISTRY_W
Definition: wincrypt.h:2467
#define CERT_V1
Definition: wincrypt.h:2803
#define CERT_QUERY_CONTENT_PFX
Definition: wincrypt.h:3700
#define CERT_STORE_PROV_FILENAME_W
Definition: wincrypt.h:2461
#define AT_KEYEXCHANGE
Definition: wincrypt.h:2239
#define CERT_STORE_CTRL_RESYNC
Definition: wincrypt.h:2967
#define CERT_SYSTEM_STORE_CURRENT_SERVICE
Definition: wincrypt.h:2532
#define X509_ASN_ENCODING
Definition: wincrypt.h:2501
#define CERT_FILE_STORE_COMMIT_ENABLE_FLAG
Definition: wincrypt.h:2644
#define CERT_STORE_CRL_CONTEXT_FLAG
Definition: wincrypt.h:3127
#define CERT_STORE_PROV_MEMORY
Definition: wincrypt.h:2455
#define CERT_STORE_PROV_REG
Definition: wincrypt.h:2457
#define CERT_STORE_PROV_FILE
Definition: wincrypt.h:2456
#define CERT_SYSTEM_STORE_LOCAL_MACHINE_ENTERPRISE
Definition: wincrypt.h:2542
#define PKCS12_NO_PERSIST_KEY
Definition: wincrypt.h:4327
#define CERT_STORE_PROV_MSG
Definition: wincrypt.h:2454
#define CERT_FRIENDLY_NAME_PROP_ID
Definition: wincrypt.h:2844
#define CERT_ACCESS_STATE_PROP_ID
Definition: wincrypt.h:2847
static const WCHAR CERT_LOCAL_MACHINE_SYSTEM_STORE_REGPATH[]
Definition: wincrypt.h:2551
#define CERT_STORE_PROV_SYSTEM_REGISTRY
Definition: wincrypt.h:2468
#define CERT_SYSTEM_STORE_LOCAL_MACHINE
Definition: wincrypt.h:2530
#define CERT_STORE_ADD_NEW
Definition: wincrypt.h:2651
#define CERT_STORE_SAVE_TO_MEMORY
Definition: wincrypt.h:2797
#define CERT_HASH_PROP_ID
Definition: wincrypt.h:2835
#define CERT_STORE_ADD_ALWAYS
Definition: wincrypt.h:2654
#define CERT_STORE_PROV_SYSTEM_W
Definition: wincrypt.h:2463
#define CERT_STORE_CTRL_COMMIT
Definition: wincrypt.h:2969
#define CERT_SYSTEM_STORE_CURRENT_USER
Definition: wincrypt.h:2528
#define CERT_STORE_CERTIFICATE_CONTEXT_FLAG
Definition: wincrypt.h:3125
#define CERT_FIND_ANY
Definition: wincrypt.h:3010
#define CERT_FIND_EXISTING
Definition: wincrypt.h:3052
#define PKCS_7_ASN_ENCODING
Definition: wincrypt.h:2503
#define CERT_SYSTEM_STORE_CURRENT_USER_GROUP_POLICY
Definition: wincrypt.h:2538
#define CERT_STORE_DELETE_FLAG
Definition: wincrypt.h:2624
#define CERT_STORE_READONLY_FLAG
Definition: wincrypt.h:2635
#define CMSG_CERT_COUNT_PARAM
Definition: wincrypt.h:4100
#define CRYPT_EXPORTABLE
Definition: wincrypt.h:2410
#define CERT_SYSTEM_STORE_LOCAL_MACHINE_GROUP_POLICY
Definition: wincrypt.h:2540
#define CRYPT_MACHINE_KEYSET
Definition: wincrypt.h:2276
#define WINAPI
Definition: msvc.h:6
#define CRYPT_E_NOT_FOUND
Definition: winerror.h:4421
#define ERROR_BADKEY
Definition: winerror.h:913
#define ERROR_PATH_NOT_FOUND
Definition: winerror.h:228
#define E_ACCESSDENIED
Definition: winerror.h:4116
#define CRYPT_E_ASN1_CORRUPT
Definition: winerror.h:4502
#define ERROR_FILE_EXISTS
Definition: winerror.h:287
#define E_UNEXPECTED
Definition: winerror.h:3528
#define CRYPT_E_INVALID_MSG_TYPE
Definition: winerror.h:4402
#define CRYPT_E_PENDING_CLOSE
Definition: winerror.h:4432
#define CRYPT_E_EXISTS
Definition: winerror.h:4422
#define CRYPT_E_ASN1_EOD
Definition: winerror.h:4501
#define ERROR_END_OF_MEDIA
Definition: winerror.h:960
#define CRYPT_E_ASN1_BADTAG
Definition: winerror.h:4510
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12
#define HKEY_CURRENT_USER
Definition: winreg.h:11
int WINAPIV wsprintfW(_Out_ LPWSTR, _In_ _Printf_format_string_ LPCWSTR,...)
const char * LPCSTR
Definition: xmlstorage.h:183
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned char BYTE
Definition: xxhash.c:193