ReactOS 0.4.17-dev-357-ga8f14ff
cryptnet.c
Go to the documentation of this file.
1/*
2 * Unit test suite for cryptnet.dll
3 *
4 * Copyright 2007 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#include <stdarg.h>
21#include <stdio.h>
22
23#include <windef.h>
24#include <winbase.h>
25#include <winerror.h>
26#include <wincrypt.h>
27#include "wine/test.h"
28
29static const BYTE bigCert[] = {
300x30,0x78,0x02,0x01,0x01,0x30,0x02,0x06,0x00,0x30,0x14,0x31,0x12,0x30,0x10,
310x06,0x03,0x55,0x04,0x03,0x13,0x09,0x4a,0x75,0x61,0x6e,0x20,0x4c,0x61,0x6e,
320x67,0x30,0x22,0x18,0x0f,0x31,0x36,0x30,0x31,0x30,0x31,0x30,0x31,0x30,0x30,
330x30,0x30,0x30,0x30,0x5a,0x18,0x0f,0x31,0x36,0x30,0x31,0x30,0x31,0x30,0x31,
340x30,0x30,0x30,0x30,0x30,0x30,0x5a,0x30,0x14,0x31,0x12,0x30,0x10,0x06,0x03,
350x55,0x04,0x03,0x13,0x09,0x4a,0x75,0x61,0x6e,0x20,0x4c,0x61,0x6e,0x67,0x30,
360x07,0x30,0x02,0x06,0x00,0x03,0x01,0x00,0xa3,0x16,0x30,0x14,0x30,0x12,0x06,
370x03,0x55,0x1d,0x13,0x01,0x01,0xff,0x04,0x08,0x30,0x06,0x01,0x01,0xff,0x02,
380x01,0x01};
400x30,0x81,0x99,0xa0,0x03,0x02,0x01,0x02,0x02,0x01,0x01,0x30,0x0d,0x06,0x09,
410x2a,0x86,0x48,0x86,0xf7,0x0d,0x01,0x01,0x05,0x05,0x00,0x30,0x14,0x31,0x12,
420x30,0x10,0x06,0x03,0x55,0x04,0x03,0x13,0x09,0x4a,0x75,0x61,0x6e,0x20,0x4c,
430x61,0x6e,0x67,0x30,0x22,0x18,0x0f,0x31,0x36,0x30,0x31,0x30,0x31,0x30,0x31,
440x30,0x30,0x30,0x30,0x30,0x30,0x5a,0x18,0x0f,0x31,0x36,0x30,0x31,0x30,0x31,
450x30,0x31,0x30,0x30,0x30,0x30,0x30,0x30,0x5a,0x30,0x14,0x31,0x12,0x30,0x10,
460x06,0x03,0x55,0x04,0x03,0x13,0x09,0x4a,0x75,0x61,0x6e,0x20,0x4c,0x61,0x6e,
470x67,0x30,0x07,0x30,0x02,0x06,0x00,0x03,0x01,0x00,0xa3,0x27,0x30,0x25,0x30,
480x23,0x06,0x03,0x55,0x1d,0x1c,0x01,0x01,0xff,0x04,0x19,0x30,0x17,0xa0,0x15,
490xa0,0x13,0x86,0x11,0x68,0x74,0x74,0x70,0x3a,0x2f,0x2f,0x77,0x69,0x6e,0x65,
500x68,0x71,0x2e,0x6f,0x72,0x67, };
51static const BYTE certWithCRLDistPoint[] = {
520x30,0x81,0x9b,0xa0,0x03,0x02,0x01,0x02,0x02,0x01,0x01,0x30,0x0d,0x06,0x09,
530x2a,0x86,0x48,0x86,0xf7,0x0d,0x01,0x01,0x05,0x05,0x00,0x30,0x14,0x31,0x12,
540x30,0x10,0x06,0x03,0x55,0x04,0x03,0x13,0x09,0x4a,0x75,0x61,0x6e,0x20,0x4c,
550x61,0x6e,0x67,0x30,0x22,0x18,0x0f,0x31,0x36,0x30,0x31,0x30,0x31,0x30,0x31,
560x30,0x30,0x30,0x30,0x30,0x30,0x5a,0x18,0x0f,0x31,0x36,0x30,0x31,0x30,0x31,
570x30,0x31,0x30,0x30,0x30,0x30,0x30,0x30,0x5a,0x30,0x14,0x31,0x12,0x30,0x10,
580x06,0x03,0x55,0x04,0x03,0x13,0x09,0x4a,0x75,0x61,0x6e,0x20,0x4c,0x61,0x6e,
590x67,0x30,0x07,0x30,0x02,0x06,0x00,0x03,0x01,0x00,0xa3,0x29,0x30,0x27,0x30,
600x25,0x06,0x03,0x55,0x1d,0x1f,0x01,0x01,0xff,0x04,0x1b,0x30,0x19,0x30,0x17,
610xa0,0x15,0xa0,0x13,0x86,0x11,0x68,0x74,0x74,0x70,0x3a,0x2f,0x2f,0x77,0x69,
620x6e,0x65,0x68,0x71,0x2e,0x6f,0x72,0x67, };
640x30,0x82,0x01,0x3c,0xa0,0x03,0x02,0x01,0x02,0x02,0x01,0x01,0x30,0x0b,0x06,
650x09,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x01,0x01,0x05,0x30,0x14,0x31,0x12,0x30,
660x10,0x06,0x03,0x55,0x04,0x03,0x13,0x09,0x4a,0x75,0x61,0x6e,0x20,0x4c,0x61,
670x6e,0x67,0x30,0x1e,0x17,0x0d,0x30,0x39,0x31,0x30,0x32,0x38,0x30,0x30,0x30,
680x30,0x30,0x30,0x5a,0x17,0x0d,0x32,0x30,0x31,0x31,0x32,0x37,0x30,0x30,0x30,
690x30,0x30,0x30,0x5a,0x30,0x14,0x31,0x12,0x30,0x10,0x06,0x03,0x55,0x04,0x03,
700x13,0x09,0x4a,0x75,0x61,0x6e,0x20,0x4c,0x61,0x6e,0x67,0x30,0x81,0xa5,0x30,
710x0b,0x06,0x09,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x01,0x01,0x01,0x03,0x81,0x95,
720x00,0x06,0x02,0x00,0x00,0x00,0x24,0x00,0x00,0x52,0x53,0x41,0x31,0x00,0x04,
730x00,0x00,0x01,0x00,0x01,0x00,0x2f,0xb2,0x8c,0xff,0x6c,0xf1,0xb1,0x61,0x9c,
740x3a,0x8f,0x5e,0x35,0x2f,0x1f,0xd5,0xcf,0x2a,0xf6,0x9e,0x37,0xe8,0x89,0xa2,
750xb1,0x1c,0xc0,0x1c,0xb6,0x72,0x45,0x97,0xe5,0x88,0x3d,0xfe,0xa6,0x27,0xea,
760xd6,0x07,0x0f,0xcd,0xba,0x49,0x06,0x16,0xdb,0xad,0x06,0x76,0x39,0x4c,0x15,
770xdf,0xe2,0x07,0xc5,0x99,0x1b,0x98,0x4b,0xc3,0x8e,0x89,0x12,0x95,0x9e,0x3b,
780xb9,0x59,0xfe,0x91,0x33,0xc1,0x1f,0xce,0x8f,0xab,0x93,0x25,0x01,0x3e,0xde,
790xf1,0x58,0x3b,0xe7,0x7a,0x03,0x14,0x07,0x09,0x0a,0x21,0x2d,0x12,0x11,0x08,
800x78,0x07,0x9e,0x34,0xc3,0xc5,0xde,0xb2,0xd8,0xd7,0x86,0x0d,0x0d,0xcd,0x81,
810xa4,0x2d,0x7c,0x82,0x50,0xca,0x2a,0xc2,0x99,0xe5,0xf3,0xca,0x7e,0xad,0xa3,
820x31,0x30,0x2f,0x30,0x2d,0x06,0x08,0x2b,0x06,0x01,0x05,0x05,0x07,0x01,0x01,
830x04,0x21,0x30,0x1f,0x30,0x1d,0x06,0x08,0x2b,0x06,0x01,0x05,0x05,0x07,0x30,
840x02,0x86,0x11,0x68,0x74,0x74,0x70,0x3a,0x2f,0x2f,0x77,0x69,0x6e,0x65,0x68,
850x71,0x2e,0x6f,0x72,0x67 };
86
88 const CRYPT_URL_ARRAY *got)
89{
90 ok(expected->cUrl == got->cUrl, "Expected %ld URLs, got %ld\n",
91 expected->cUrl, got->cUrl);
92 if (expected->cUrl == got->cUrl)
93 {
94 DWORD i;
95
96 for (i = 0; i < got->cUrl; i++)
97 ok(!lstrcmpiW(expected->rgwszUrl[i], got->rgwszUrl[i]),
98 "%ld: unexpected URL\n", i);
99 }
100}
101
102
103static void test_getObjectUrl(void)
104{
105 static WCHAR url[] = L"http://winehq.org";
106 BOOL ret;
107 DWORD urlArraySize = 0, infoSize = 0;
109
110 SetLastError(0xdeadbeef);
113 "Expected ERROR_FILE_NOT_FOUND, got %ld\n", GetLastError());
114 /* Crash
115 ret = CryptGetObjectUrl(URL_OID_CERTIFICATE_ISSUER, NULL, 0, NULL, NULL,
116 NULL, NULL, NULL);
117 ret = CryptGetObjectUrl(URL_OID_CERTIFICATE_ISSUER, NULL, 0, NULL, NULL,
118 NULL, &infoSize, NULL);
119 ret = CryptGetObjectUrl(URL_OID_CERTIFICATE_ISSUER, NULL, 0, NULL,
120 &urlArraySize, NULL, &infoSize, NULL);
121 */
122 /* A cert with no CRL dist point extension fails.. */
124 sizeof(bigCert));
125 SetLastError(0xdeadbeef);
127 NULL, NULL, NULL, NULL);
129 "Expected CRYPT_E_NOT_FOUND, got %08lx\n", GetLastError());
131
134 if (cert)
135 {
136 /* This cert has no AIA extension, so expect this to fail */
137 SetLastError(0xdeadbeef);
139 NULL, NULL, NULL, NULL, NULL);
141 "Expected CRYPT_E_NOT_FOUND, got %08lx\n", GetLastError());
142 SetLastError(0xdeadbeef);
146 "Expected CRYPT_E_NOT_FOUND, got %08lx\n", GetLastError());
147 SetLastError(0xdeadbeef);
151 "Expected CRYPT_E_NOT_FOUND, got %08lx\n", GetLastError());
152 /* It does have an issuing dist point extension, but that's not what
153 * this is looking for (it wants a CRL dist points extension)
154 */
155 SetLastError(0xdeadbeef);
157 (void *)cert, 0, NULL, NULL, NULL, NULL, NULL);
159 "Expected CRYPT_E_NOT_FOUND, got %08lx\n", GetLastError());
160 SetLastError(0xdeadbeef);
163 NULL);
165 "Expected CRYPT_E_NOT_FOUND, got %08lx\n", GetLastError());
166 SetLastError(0xdeadbeef);
169 NULL);
171 "Expected CRYPT_E_NOT_FOUND, got %08lx\n", GetLastError());
173 }
176 if (cert)
177 {
178 PCRYPT_URL_ARRAY urlArray;
179
180 /* This cert has no AIA extension, so expect this to fail */
181 SetLastError(0xdeadbeef);
183 NULL, NULL, NULL, NULL, NULL);
185 "Expected CRYPT_E_NOT_FOUND, got %08lx\n", GetLastError());
186 SetLastError(0xdeadbeef);
190 "Expected CRYPT_E_NOT_FOUND, got %08lx\n", GetLastError());
191 SetLastError(0xdeadbeef);
195 "Expected CRYPT_E_NOT_FOUND, got %08lx\n", GetLastError());
196 /* It does have a CRL dist points extension */
197 SetLastError(0xdeadbeef);
199 (void *)cert, 0, NULL, NULL, NULL, NULL, NULL);
201 "Expected E_INVALIDARG, got %08lx\n", GetLastError());
202 SetLastError(0xdeadbeef);
204 (void *)cert, 0, NULL, NULL, NULL, &infoSize, NULL);
206 "Expected E_INVALIDARG, got %08lx\n", GetLastError());
207 /* Can get it without specifying the location: */
209 (void *)cert, 0, NULL, &urlArraySize, NULL, NULL, NULL);
210 ok(ret, "CryptGetObjectUrl failed: %08lx\n", GetLastError());
211 urlArray = HeapAlloc(GetProcessHeap(), 0, urlArraySize);
212 if (urlArray)
213 {
215 (void *)cert, 0, urlArray, &urlArraySize, NULL, NULL, NULL);
216 ok(ret, "CryptGetObjectUrl failed: %08lx\n", GetLastError());
217 if (ret)
218 {
219 LPWSTR pUrl = url;
220 CRYPT_URL_ARRAY expectedUrl = { 1, &pUrl };
221
222 compareUrlArray(&expectedUrl, urlArray);
223 }
224 HeapFree(GetProcessHeap(), 0, urlArray);
225 }
226 /* or by specifying it's an extension: */
228 (void *)cert, CRYPT_GET_URL_FROM_EXTENSION, NULL, &urlArraySize, NULL,
229 NULL, NULL);
230 ok(ret, "CryptGetObjectUrl failed: %08lx\n", GetLastError());
231 urlArray = HeapAlloc(GetProcessHeap(), 0, urlArraySize);
232 if (urlArray)
233 {
235 (void *)cert, CRYPT_GET_URL_FROM_EXTENSION, urlArray,
236 &urlArraySize, NULL, NULL, NULL);
237 ok(ret, "CryptGetObjectUrl failed: %08lx\n", GetLastError());
238 if (ret)
239 {
240 LPWSTR pUrl = url;
241 CRYPT_URL_ARRAY expectedUrl = { 1, &pUrl };
242
243 compareUrlArray(&expectedUrl, urlArray);
244 }
245 HeapFree(GetProcessHeap(), 0, urlArray);
246 }
247 /* but it isn't contained in a property: */
248 SetLastError(0xdeadbeef);
250 (void *)cert, CRYPT_GET_URL_FROM_PROPERTY, NULL, &urlArraySize, NULL,
251 NULL, NULL);
253 "Expected CRYPT_E_NOT_FOUND, got %08lx\n", GetLastError());
255 }
258 if (cert)
259 {
260 PCRYPT_URL_ARRAY urlArray;
261
262 /* This has an AIA extension with the CA Issuers set, so expect it
263 * to succeed:
264 */
266 (void *)cert, 0, NULL, &urlArraySize, NULL, NULL, NULL);
267 ok(ret, "CryptGetObjectUrl failed: %08lx\n", GetLastError());
268 if (ret)
269 {
270 urlArray = HeapAlloc(GetProcessHeap(), 0, urlArraySize);
271 if (urlArray)
272 {
274 (void *)cert, CRYPT_GET_URL_FROM_EXTENSION, urlArray,
275 &urlArraySize, NULL, NULL, NULL);
276 ok(ret, "CryptGetObjectUrl failed: %08lx\n", GetLastError());
277 if (ret)
278 {
279 LPWSTR pUrl = url;
280 CRYPT_URL_ARRAY expectedUrl = { 1, &pUrl };
281
282 compareUrlArray(&expectedUrl, urlArray);
283 }
284 HeapFree(GetProcessHeap(), 0, urlArray);
285 }
286 }
287 /* It doesn't have a CRL dist points extension, so this should fail */
288 SetLastError(0xdeadbeef);
290 (void *)cert, 0, NULL, &urlArraySize, NULL, NULL, NULL);
292 "expected CRYPT_E_NOT_FOUND, got %08lx\n", GetLastError());
294 }
295}
296
298{
299 static char curr[MAX_PATH] = { 0 };
300 char temp[MAX_PATH];
301 DWORD dwNumberOfBytesWritten;
302 HANDLE hf;
303
304 if (!*curr)
306 GetTempFileNameA(curr, "net", 0, temp);
311 &dwNumberOfBytesWritten, NULL);
312 CloseHandle(hf);
313}
314
316{
317 BOOL ret;
318 char tmpfile[MAX_PATH], url[MAX_PATH + 8];
319 CRYPT_BLOB_ARRAY *pBlobArray;
322 HCERTSTORE store;
323 CRYPT_RETRIEVE_AUX_INFO aux = { 0 };
324 FILETIME ft = { 0 };
325
326 SetLastError(0xdeadbeef);
330 "got 0x%lx/%lu (expected ERROR_INVALID_PARAMETER or E_INVALIDARG)\n",
332
334 sprintf(url, "file://%s", tmpfile);
335
336 pBlobArray = (CRYPT_BLOB_ARRAY *)0xdeadbeef;
337 ret = CryptRetrieveObjectByUrlA(url, NULL, 0, 0, (void **)&pBlobArray,
338 NULL, NULL, NULL, NULL);
339 if (!ret)
340 {
341 /* File URL support was apparently removed in Vista/Windows 2008 */
342 win_skip("File URLs not supported\n");
343 return;
344 }
345 ok(ret, "CryptRetrieveObjectByUrlA failed: %ld\n", GetLastError());
346 ok(pBlobArray && pBlobArray != (CRYPT_BLOB_ARRAY *)0xdeadbeef,
347 "Expected a valid pointer\n");
348 if (pBlobArray && pBlobArray != (CRYPT_BLOB_ARRAY *)0xdeadbeef)
349 {
350 ok(pBlobArray->cBlob == 1, "Expected 1 blob, got %ld\n",
351 pBlobArray->cBlob);
352 ok(pBlobArray->rgBlob[0].cbData == sizeof(certWithCRLDistPoint),
353 "Unexpected size %ld\n", pBlobArray->rgBlob[0].cbData);
354 CryptMemFree(pBlobArray);
355 }
356 cert = (PCCERT_CONTEXT)0xdeadbeef;
358 (void **)&cert, NULL, NULL, NULL, NULL);
359 ok(ret, "CryptRetrieveObjectByUrlA failed: %ld\n", GetLastError());
360 ok(cert && cert != (PCCERT_CONTEXT)0xdeadbeef, "Expected a cert\n");
361 if (cert && cert != (PCCERT_CONTEXT)0xdeadbeef)
363 crl = (PCCRL_CONTEXT)0xdeadbeef;
364 SetLastError(0xdeadbeef);
366 NULL, NULL, NULL, NULL);
367 /* w2k3,XP, newer w2k: CRYPT_E_NO_MATCH, older w2k: CRYPT_E_ASN1_BADTAG
368 * or OSS_DATA_ERROR.
369 */
373 "got 0x%lx/%lu (expected CRYPT_E_NO_MATCH)\n", GetLastError(), GetLastError());
374
375 /* only newer versions of cryptnet do the cleanup */
378 ok(crl == NULL, "Expected CRL to be NULL\n");
379 }
380
381 if (crl && crl != (PCCRL_CONTEXT)0xdeadbeef)
383 store = (HCERTSTORE)0xdeadbeef;
385 &store, NULL, NULL, NULL, NULL);
386 ok(ret, "CryptRetrieveObjectByUrlA failed: %ld\n", GetLastError());
387 if (store && store != (HCERTSTORE)0xdeadbeef)
388 {
389 DWORD certs = 0;
390
391 cert = NULL;
392 do {
394 if (cert)
395 certs++;
396 } while (cert);
397 ok(certs == 1, "Expected 1 cert, got %ld\n", certs);
398 CertCloseStore(store, 0);
399 }
400 /* Are file URLs cached? */
401 cert = (PCCERT_CONTEXT)0xdeadbeef;
404 ok(ret, "CryptRetrieveObjectByUrlA failed: %08lx\n", GetLastError());
405 if (cert && cert != (PCCERT_CONTEXT)0xdeadbeef)
407
408 cert = (PCCERT_CONTEXT)0xdeadbeef;
410 (void **)&cert, NULL, NULL, NULL, &aux);
411 /* w2k: failure with E_INVALIDARG */
413 "got %u with 0x%lx/%lu (expected '!=0' or '0' with E_INVALIDARG)\n",
415 if (cert && cert != (PCCERT_CONTEXT)0xdeadbeef)
417
418 cert = (PCCERT_CONTEXT)0xdeadbeef;
419 aux.cbSize = sizeof(aux);
421 (void **)&cert, NULL, NULL, NULL, &aux);
422 /* w2k: failure with E_INVALIDARG */
424 "got %u with 0x%lx/%lu (expected '!=0' or '0' with E_INVALIDARG)\n",
426 if (!ret) {
427 /* no more tests useful */
429 skip("no usable CertificateContext\n");
430 return;
431 }
433
434 aux.pLastSyncTime = &ft;
436 (void **)&cert, NULL, NULL, NULL, &aux);
437 ok(ret, "CryptRetrieveObjectByUrlA failed: %08lx\n", GetLastError());
440 "Expected last sync time to be set\n");
442 /* Okay, after being deleted, are file URLs still cached? */
443 SetLastError(0xdeadbeef);
448 "Expected ERROR_FILE_NOT_FOUND or ERROR_PATH_NOT_FOUND, got %ld\n",
449 GetLastError());
450}
451
4530x30,0x82,0x01,0xdf,0x30,0x82,0x01,0x4c,0xa0,0x03,0x02,0x01,0x02,0x02,0x10,
4540x5b,0xc7,0x0b,0x27,0x99,0xbb,0x2e,0x99,0x47,0x9d,0x45,0x4e,0x7c,0x1a,0xca,
4550xe8,0x30,0x09,0x06,0x05,0x2b,0x0e,0x03,0x02,0x1d,0x05,0x00,0x30,0x10,0x31,
4560x0e,0x30,0x0c,0x06,0x03,0x55,0x04,0x03,0x13,0x05,0x43,0x65,0x72,0x74,0x31,
4570x30,0x1e,0x17,0x0d,0x30,0x37,0x30,0x31,0x30,0x31,0x30,0x30,0x30,0x30,0x30,
4580x30,0x5a,0x17,0x0d,0x30,0x37,0x31,0x32,0x33,0x31,0x32,0x33,0x35,0x39,0x35,
4590x39,0x5a,0x30,0x10,0x31,0x0e,0x30,0x0c,0x06,0x03,0x55,0x04,0x03,0x13,0x05,
4600x43,0x65,0x72,0x74,0x31,0x30,0x81,0x9f,0x30,0x0d,0x06,0x09,0x2a,0x86,0x48,
4610x86,0xf7,0x0d,0x01,0x01,0x01,0x05,0x00,0x03,0x81,0x8d,0x00,0x30,0x81,0x89,
4620x02,0x81,0x81,0x00,0xad,0x7e,0xca,0xf3,0xe5,0x99,0xc2,0x2a,0xca,0x50,0x82,
4630x7c,0x2d,0xa4,0x81,0xcd,0x0d,0x0d,0x86,0xd7,0xd8,0xb2,0xde,0xc5,0xc3,0x34,
4640x9e,0x07,0x78,0x08,0x11,0x12,0x2d,0x21,0x0a,0x09,0x07,0x14,0x03,0x7a,0xe7,
4650x3b,0x58,0xf1,0xde,0x3e,0x01,0x25,0x93,0xab,0x8f,0xce,0x1f,0xc1,0x33,0x91,
4660xfe,0x59,0xb9,0x3b,0x9e,0x95,0x12,0x89,0x8e,0xc3,0x4b,0x98,0x1b,0x99,0xc5,
4670x07,0xe2,0xdf,0x15,0x4c,0x39,0x76,0x06,0xad,0xdb,0x16,0x06,0x49,0xba,0xcd,
4680x0f,0x07,0xd6,0xea,0x27,0xa6,0xfe,0x3d,0x88,0xe5,0x97,0x45,0x72,0xb6,0x1c,
4690xc0,0x1c,0xb1,0xa2,0x89,0xe8,0x37,0x9e,0xf6,0x2a,0xcf,0xd5,0x1f,0x2f,0x35,
4700x5e,0x8f,0x3a,0x9c,0x61,0xb1,0xf1,0x6c,0xff,0x8c,0xb2,0x2f,0x02,0x03,0x01,
4710x00,0x01,0xa3,0x42,0x30,0x40,0x30,0x0e,0x06,0x03,0x55,0x1d,0x0f,0x01,0x01,
4720xff,0x04,0x04,0x03,0x02,0x00,0x06,0x30,0x0f,0x06,0x03,0x55,0x1d,0x13,0x01,
4730x01,0xff,0x04,0x05,0x30,0x03,0x01,0x01,0xff,0x30,0x1d,0x06,0x03,0x55,0x1d,
4740x0e,0x04,0x16,0x04,0x14,0x14,0x8c,0x16,0xbb,0xbe,0x70,0xa2,0x28,0x89,0xa0,
4750x58,0xff,0x98,0xbd,0xa8,0x24,0x2b,0x8a,0xe9,0x9a,0x30,0x09,0x06,0x05,0x2b,
4760x0e,0x03,0x02,0x1d,0x05,0x00,0x03,0x81,0x81,0x00,0x74,0xcb,0x21,0xfd,0x2d,
4770x25,0xdc,0xa5,0xaa,0xa1,0x26,0xdc,0x8b,0x40,0x11,0x64,0xae,0x5c,0x71,0x3c,
4780x28,0xbc,0xf9,0xb3,0xcb,0xa5,0x94,0xb2,0x8d,0x4c,0x23,0x2b,0x9b,0xde,0x2c,
4790x4c,0x30,0x04,0xc6,0x88,0x10,0x2f,0x53,0xfd,0x6c,0x82,0xf1,0x13,0xfb,0xda,
4800x27,0x75,0x25,0x48,0xe4,0x72,0x09,0x2a,0xee,0xb4,0x1e,0xc9,0x55,0xf5,0xf7,
4810x82,0x91,0xd8,0x4b,0xe4,0x3a,0xfe,0x97,0x87,0xdf,0xfb,0x15,0x5a,0x12,0x3e,
4820x12,0xe6,0xad,0x40,0x0b,0xcf,0xee,0x1a,0x44,0xe0,0x83,0xb2,0x67,0x94,0xd4,
4830x2e,0x7c,0xf2,0x06,0x9d,0xb3,0x3b,0x7e,0x2f,0xda,0x25,0x66,0x7e,0xa7,0x1f,
4840x45,0xd4,0xf5,0xe3,0xdf,0x2a,0xf1,0x18,0x28,0x20,0xb5,0xf8,0xf5,0x8d,0x7a,
4850x2e,0x84,0xee };
486static const BYTE revokedCert[] = {
4870x30,0x82,0x01,0xb9,0x30,0x82,0x01,0x22,0xa0,0x03,0x02,0x01,0x02,0x02,0x01,
4880x01,0x30,0x0d,0x06,0x09,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x01,0x01,0x05,0x05,
4890x00,0x30,0x10,0x31,0x0e,0x30,0x0c,0x06,0x03,0x55,0x04,0x03,0x13,0x05,0x43,
4900x65,0x72,0x74,0x31,0x30,0x1e,0x17,0x0d,0x30,0x37,0x30,0x35,0x30,0x31,0x30,
4910x30,0x30,0x30,0x30,0x30,0x5a,0x17,0x0d,0x30,0x37,0x31,0x30,0x30,0x31,0x30,
4920x30,0x30,0x30,0x30,0x30,0x5a,0x30,0x10,0x31,0x0e,0x30,0x0c,0x06,0x03,0x55,
4930x04,0x03,0x13,0x05,0x43,0x65,0x72,0x74,0x32,0x30,0x81,0x9f,0x30,0x0d,0x06,
4940x09,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x01,0x01,0x01,0x05,0x00,0x03,0x81,0x8d,
4950x00,0x30,0x81,0x89,0x02,0x81,0x81,0x00,0xb8,0x52,0xda,0xc5,0x4b,0x3f,0xe5,
4960x33,0x0e,0x67,0x5f,0x48,0x21,0xdc,0x7e,0xef,0x37,0x33,0xba,0xff,0xb4,0xc6,
4970xdc,0xb6,0x17,0x8e,0x20,0x55,0x07,0x12,0xd2,0x7b,0x3c,0xce,0x30,0xc5,0xa7,
4980x48,0x9f,0x6e,0xfe,0xb8,0xbe,0xdb,0x9f,0x9b,0x17,0x60,0x16,0xde,0xc6,0x8b,
4990x47,0xd1,0x57,0x71,0x3c,0x93,0xfc,0xbd,0xec,0x44,0x32,0x3b,0xb9,0xcf,0x6b,
5000x05,0x72,0xa7,0x87,0x8e,0x7e,0xd4,0x9a,0x87,0x1c,0x2f,0xb7,0x82,0x40,0xfc,
5010x6a,0x80,0x83,0x68,0x28,0xce,0x84,0xf4,0x0b,0x2e,0x44,0xcb,0x53,0xac,0x85,
5020x85,0xb5,0x46,0x36,0x98,0x3c,0x10,0x02,0xaa,0x02,0xbc,0x8b,0xa2,0x23,0xb2,
5030xd3,0x51,0x9a,0x22,0x4a,0xe3,0xaa,0x4e,0x7c,0xda,0x38,0xcf,0x49,0x98,0x72,
5040xa3,0x02,0x03,0x01,0x00,0x01,0xa3,0x23,0x30,0x21,0x30,0x1f,0x06,0x03,0x55,
5050x1d,0x23,0x04,0x18,0x30,0x18,0x80,0x14,0x14,0x8c,0x16,0xbb,0xbe,0x70,0xa2,
5060x28,0x89,0xa0,0x58,0xff,0x98,0xbd,0xa8,0x24,0x2b,0x8a,0xe9,0x9a,0x30,0x0d,
5070x06,0x09,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x01,0x01,0x05,0x05,0x00,0x03,0x81,
5080x81,0x00,0x8a,0x49,0xa9,0x86,0x5e,0xc9,0x33,0x7e,0xfd,0xab,0x64,0x1f,0x6d,
5090x00,0xd7,0x9b,0xec,0xd1,0x5b,0x38,0xcc,0xd6,0xf3,0xf2,0xb4,0x75,0x70,0x00,
5100x82,0x9d,0x37,0x58,0xe1,0xcd,0x2c,0x61,0xb3,0x28,0xe7,0x8a,0x00,0xbe,0x6e,
5110xca,0xe8,0x55,0xd5,0xad,0x3a,0xea,0xaf,0x13,0x20,0x1c,0x44,0xfc,0xb4,0xf9,
5120x29,0x2b,0xdc,0x8a,0x2d,0x1b,0x27,0x9e,0xb9,0x3b,0x4a,0x71,0x9d,0x47,0x7d,
5130xf7,0x92,0x6b,0x21,0x7f,0xfa,0x88,0x79,0x94,0x33,0xf6,0xdd,0x92,0x04,0x92,
5140xd6,0x5e,0x0a,0x74,0xf2,0x85,0xa6,0xd5,0x3c,0x28,0xc0,0x89,0x5d,0xda,0xf3,
5150xa6,0x01,0xc2,0xe9,0xa3,0xc1,0xb7,0x21,0x08,0xba,0x18,0x07,0x45,0xeb,0x77,
5160x7d,0xcd,0xc6,0xe7,0x2a,0x7b,0x46,0xd2,0x3d,0xb5 };
517static const BYTE unRevokedCert[] = {
5180x30,0x82,0x01,0xa2,0x30,0x82,0x01,0x0d,0xa0,0x03,0x02,0x01,0x02,0x02,0x01,
5190x02,0x30,0x0b,0x06,0x09,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x01,0x01,0x05,0x30,
5200x10,0x31,0x0e,0x30,0x0c,0x06,0x03,0x55,0x04,0x03,0x13,0x05,0x43,0x65,0x72,
5210x74,0x31,0x30,0x1e,0x17,0x0d,0x30,0x37,0x30,0x35,0x30,0x31,0x30,0x30,0x30,
5220x30,0x30,0x30,0x5a,0x17,0x0d,0x30,0x37,0x31,0x30,0x30,0x31,0x30,0x30,0x30,
5230x30,0x30,0x30,0x5a,0x30,0x24,0x31,0x22,0x30,0x0e,0x06,0x03,0x55,0x04,0x03,
5240x13,0x07,0x66,0x6f,0x6f,0x2e,0x63,0x6f,0x6d,0x30,0x10,0x06,0x03,0x55,0x04,
5250x03,0x13,0x09,0x2a,0x2e,0x66,0x6f,0x6f,0x2e,0x63,0x6f,0x6d,0x30,0x81,0x9d,
5260x30,0x0b,0x06,0x09,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x01,0x01,0x01,0x03,0x81,
5270x8d,0x00,0x30,0x81,0x89,0x02,0x81,0x81,0x00,0xb8,0x52,0xda,0xc5,0x4b,0x3f,
5280xe5,0x33,0x0e,0x67,0x5f,0x48,0x21,0xdc,0x7e,0xef,0x37,0x33,0xba,0xff,0xb4,
5290xc6,0xdc,0xb6,0x17,0x8e,0x20,0x55,0x07,0x12,0xd2,0x7b,0x3c,0xce,0x30,0xc5,
5300xa7,0x48,0x9f,0x6e,0xfe,0xb8,0xbe,0xdb,0x9f,0x9b,0x17,0x60,0x16,0xde,0xc6,
5310x8b,0x47,0xd1,0x57,0x71,0x3c,0x93,0xfc,0xbd,0xec,0x44,0x32,0x3b,0xb9,0xcf,
5320x6b,0x05,0x72,0xa7,0x87,0x8e,0x7e,0xd4,0x9a,0x87,0x1c,0x2f,0xb7,0x82,0x40,
5330xfc,0x6a,0x80,0x83,0x68,0x28,0xce,0x84,0xf4,0x0b,0x2e,0x44,0xcb,0x53,0xac,
5340x85,0x85,0xb5,0x46,0x36,0x98,0x3c,0x10,0x02,0xaa,0x02,0xbc,0x8b,0xa2,0x23,
5350xb2,0xd3,0x51,0x9a,0x22,0x4a,0xe3,0xaa,0x4e,0x7c,0xda,0x38,0xcf,0x49,0x98,
5360x72,0xa3,0x02,0x03,0x01,0x00,0x01,0x30,0x0b,0x06,0x09,0x2a,0x86,0x48,0x86,
5370xf7,0x0d,0x01,0x01,0x05,0x03,0x81,0x81,0x00,0x9f,0x11,0x8a,0x0a,0x6e,0xb0,
5380x73,0xcc,0x48,0xf1,0x92,0xca,0xaf,0x9a,0x3d,0xb9,0xcf,0xbe,0x84,0xd0,0xa8,
5390x34,0x25,0x27,0x9d,0x28,0x68,0xc5,0x35,0x2b,0x84,0xff,0xdb,0xd0,0x1f,0x0d,
5400xd7,0xd6,0x8c,0x1b,0x33,0x52,0x7d,0x19,0xd0,0xc2,0xf3,0x63,0xd6,0x55,0x45,
5410xf9,0x46,0xa0,0xb7,0xb3,0x94,0xbb,0x25,0x9b,0x29,0x76,0x7c,0x11,0xc7,0x7b,
5420xcc,0xcb,0x99,0x3c,0xae,0xe7,0x16,0xb5,0xa7,0x6a,0x1f,0x75,0x4a,0x58,0x65,
5430xb1,0x5b,0x91,0x29,0x20,0x81,0x51,0x64,0x05,0x24,0xa5,0x77,0xb7,0x8e,0xc8,
5440x32,0x0f,0x0d,0x4f,0xf9,0x78,0x0f,0xc4,0xef,0xd6,0x25,0x5a,0xa4,0x9b,0x07,
5450x17,0xea,0x56,0xe2,0x7b,0x61,0x1c,0x2d,0x40,0x38,0x9a,0x24,0x64,0x4b,0x6d,
5460x08,0x96 };
5480x30,0x82,0x01,0x1f,0x30,0x81,0x89,0x02,0x01,0x01,0x30,0x0d,0x06,0x09,0x2a,
5490x86,0x48,0x86,0xf7,0x0d,0x01,0x01,0x05,0x05,0x00,0x30,0x10,0x31,0x0e,0x30,
5500x0c,0x06,0x03,0x55,0x04,0x03,0x13,0x05,0x43,0x65,0x72,0x74,0x31,0x17,0x0d,
5510x30,0x37,0x30,0x39,0x30,0x31,0x30,0x30,0x30,0x30,0x30,0x30,0x5a,0x17,0x0d,
5520x30,0x37,0x31,0x32,0x33,0x31,0x32,0x33,0x35,0x39,0x35,0x39,0x5a,0x30,0x14,
5530x30,0x12,0x02,0x01,0x01,0x17,0x0d,0x30,0x37,0x30,0x39,0x30,0x31,0x30,0x30,
5540x30,0x30,0x30,0x30,0x5a,0xa0,0x2f,0x30,0x2d,0x30,0x0a,0x06,0x03,0x55,0x1d,
5550x14,0x04,0x03,0x02,0x01,0x01,0x30,0x1f,0x06,0x03,0x55,0x1d,0x23,0x04,0x18,
5560x30,0x18,0x80,0x14,0x14,0x8c,0x16,0xbb,0xbe,0x70,0xa2,0x28,0x89,0xa0,0x58,
5570xff,0x98,0xbd,0xa8,0x24,0x2b,0x8a,0xe9,0x9a,0x30,0x0d,0x06,0x09,0x2a,0x86,
5580x48,0x86,0xf7,0x0d,0x01,0x01,0x05,0x05,0x00,0x03,0x81,0x81,0x00,0xa3,0xcf,
5590x17,0x5d,0x7a,0x08,0xab,0x11,0x1a,0xbd,0x5c,0xde,0x9a,0x22,0x92,0x38,0xe6,
5600x96,0xcc,0xb1,0xc5,0x42,0x86,0xa6,0xae,0xad,0xa3,0x1a,0x2b,0xa0,0xb0,0x65,
5610xaa,0x9c,0xd7,0x2d,0x44,0x8c,0xae,0x61,0xc7,0x30,0x17,0x89,0x84,0x3b,0x4a,
5620x8f,0x17,0x08,0x06,0x37,0x1c,0xf7,0x2d,0x4e,0x47,0x07,0x61,0x50,0xd9,0x06,
5630xd1,0x46,0xed,0x0a,0xbb,0xc3,0x9b,0x36,0x0b,0xa7,0x27,0x2f,0x2b,0x55,0xce,
5640x2a,0xa5,0x60,0xc6,0x53,0x28,0xe8,0xee,0xad,0x0e,0x2b,0xe8,0xd7,0x5f,0xc9,
5650xa5,0xed,0xf9,0x77,0xb0,0x3c,0x81,0xcf,0xcc,0x49,0xb2,0x1a,0xc3,0xfd,0x34,
5660xd5,0xbc,0xb0,0xd5,0xa5,0x9c,0x1b,0x72,0xc3,0x0f,0xa3,0xe3,0x3c,0xf0,0xc3,
5670x91,0xe8,0x93,0x4f,0xd4,0x2f };
568static const BYTE rootSignedCRL[] = {
5690x30,0x81,0xe6,0x30,0x53,0x30,0x0b,0x06,0x09,0x2a,0x86,0x48,0x86,0xf7,0x0d,
5700x01,0x01,0x05,0x30,0x10,0x31,0x0e,0x30,0x0c,0x06,0x03,0x55,0x04,0x03,0x13,
5710x05,0x43,0x65,0x72,0x74,0x31,0x17,0x0d,0x30,0x37,0x30,0x35,0x30,0x31,0x30,
5720x30,0x30,0x30,0x30,0x30,0x5a,0x17,0x0d,0x30,0x37,0x31,0x32,0x33,0x31,0x32,
5730x33,0x35,0x39,0x35,0x39,0x5a,0x30,0x14,0x30,0x12,0x02,0x01,0x01,0x17,0x0d,
5740x30,0x37,0x31,0x30,0x30,0x31,0x30,0x30,0x30,0x30,0x30,0x30,0x5a,0x30,0x0b,
5750x06,0x09,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x01,0x01,0x05,0x03,0x81,0x81,0x00,
5760x94,0x84,0x0a,0xad,0x63,0xe3,0x05,0xc1,0xd8,0x94,0x44,0xeb,0x30,0x03,0xa1,
5770xb4,0x7b,0x09,0x2f,0xf6,0xef,0x0f,0xe5,0x58,0x70,0x67,0xac,0x32,0x91,0xc0,
5780x9d,0xf1,0x2b,0xf4,0xb3,0xcf,0xdd,0x1d,0x74,0x7b,0x6f,0x59,0x36,0x73,0xca,
5790xcd,0x9c,0xb6,0xd9,0x35,0x39,0x45,0x8d,0xfd,0xf9,0x65,0xf3,0x42,0x2c,0x2c,
5800xa6,0xfc,0xd2,0x23,0x6c,0x73,0x28,0x21,0x47,0x22,0x88,0x36,0x7d,0xd8,0xf0,
5810xd0,0xca,0x11,0x20,0x50,0x6b,0x1e,0xb1,0x16,0x16,0xde,0xa6,0xc1,0x8d,0x18,
5820xf1,0x42,0x22,0x1d,0x95,0x11,0xd7,0xa9,0x8f,0x90,0xe5,0x2f,0x71,0x52,0x47,
5830xe0,0x45,0xb1,0x5a,0x2c,0x72,0x8a,0x25,0xca,0xd6,0x96,0xa2,0x7b,0x83,0x4c,
5840xa3,0x24,0x7e,0xdd,0x45,0xa1,0x38,0xf8 };
585
586static BOOL (WINAPI *pCertVerifyRevocation)(DWORD, DWORD, DWORD, void **, DWORD,
588
589/* Wednesday, Oct 1, 2007 */
590static SYSTEMTIME oct2007 = { 2007, 10, 1, 1, 0, 0, 0, 0 };
591/* Tuesday, May 1, 2007 */
592static SYSTEMTIME may2007 = { 2007, 5, 2, 1, 0, 0, 0, 0 };
593
594static void test_verifyRevocation(void)
595{
598 const CERT_CONTEXT *certs[2];
600 BOOL ret;
601
602 pCertVerifyRevocation = (void *)GetProcAddress(GetModuleHandleA("cryptnet.dll"), "CertDllVerifyRevocation");
603
604 if (0)
605 {
606 /* Crash */
607 pCertVerifyRevocation(0, 0, 0, NULL, 0, NULL, NULL);
608 }
609
610 SetLastError(0xdeadbeef);
611 memset(&status, 0xcc, sizeof(status));
612 status.cbSize = sizeof(status);
613 ret = pCertVerifyRevocation(0, 0, 0, NULL, 0, NULL, &status);
614 ok(!ret, "expected failure\n");
615 ok(GetLastError() == E_INVALIDARG, "got error %#lx\n", GetLastError());
616 todo_wine ok(!status.dwIndex, "got index %lu\n", status.dwIndex);
617 todo_wine ok(status.dwError == E_INVALIDARG, "got error %#lx\n", status.dwError);
618 todo_wine ok(!status.dwReason, "got reason %lu\n", status.dwReason);
619
620 SetLastError(0xdeadbeef);
621 memset(&status, 0xcc, sizeof(status));
622 status.cbSize = sizeof(status);
623 ret = pCertVerifyRevocation(X509_ASN_ENCODING, 0, 0, NULL, 0, NULL, &status);
624 ok(!ret, "expected failure\n");
625 ok(GetLastError() == E_INVALIDARG, "got error %#lx\n", GetLastError());
626 todo_wine ok(!status.dwIndex, "got index %lu\n", status.dwIndex);
627 todo_wine ok(status.dwError == E_INVALIDARG, "got error %#lx\n", status.dwError);
628 todo_wine ok(!status.dwReason, "got reason %lu\n", status.dwReason);
629
630 SetLastError(0xdeadbeef);
631 memset(&status, 0xcc, sizeof(status));
632 status.cbSize = sizeof(status);
633 ret = pCertVerifyRevocation(0, CERT_CONTEXT_REVOCATION_TYPE, 0, NULL, 0, NULL, &status);
634 ok(!ret, "expected failure\n");
635 ok(GetLastError() == E_INVALIDARG, "got error %#lx\n", GetLastError());
636 todo_wine ok(!status.dwIndex, "got index %lu\n", status.dwIndex);
637 todo_wine ok(status.dwError == E_INVALIDARG, "got error %#lx\n", status.dwError);
638 todo_wine ok(!status.dwReason, "got reason %lu\n", status.dwReason);
639
641
642 SetLastError(0xdeadbeef);
643 memset(&status, 0xcc, sizeof(status));
644 status.cbSize = sizeof(status);
645 ret = pCertVerifyRevocation(0, CERT_CONTEXT_REVOCATION_TYPE, 1, (void **)certs, 0, NULL, &status);
646 ok(!ret, "expected failure\n");
647 ok(GetLastError() == CRYPT_E_NO_REVOCATION_CHECK, "got error %#lx\n", GetLastError());
648 ok(!status.dwIndex, "got index %lu\n", status.dwIndex);
649 ok(status.dwError == CRYPT_E_NO_REVOCATION_CHECK, "got error %#lx\n", status.dwError);
650 ok(!status.dwReason, "got reason %lu\n", status.dwReason);
651
653
656
657 /* The root cert itself can't be checked for revocation */
658 SetLastError(0xdeadbeef);
659 memset(&status, 0xcc, sizeof(status));
660 status.cbSize = sizeof(status);
661 ret = pCertVerifyRevocation(0, CERT_CONTEXT_REVOCATION_TYPE, 1, (void **)&certs[0], 0, NULL, &status);
662 ok(!ret, "expected failure\n");
663 ok(GetLastError() == CRYPT_E_NO_REVOCATION_CHECK, "got error %#lx\n", GetLastError());
664 ok(!status.dwIndex, "got index %lu\n", status.dwIndex);
665 ok(status.dwError == CRYPT_E_NO_REVOCATION_CHECK, "got error %#lx\n", status.dwError);
666 ok(!status.dwReason, "got reason %lu\n", status.dwReason);
667
668 /* Neither can the end cert */
669 SetLastError(0xdeadbeef);
670 memset(&status, 0xcc, sizeof(status));
671 status.cbSize = sizeof(status);
672 ret = pCertVerifyRevocation(0, CERT_CONTEXT_REVOCATION_TYPE, 1, (void **)&certs[1], 0, NULL, &status);
673 ok(!ret, "expected failure\n");
674 ok(GetLastError() == CRYPT_E_NO_REVOCATION_CHECK, "got error %#lx\n", GetLastError());
675 ok(!status.dwIndex, "got index %lu\n", status.dwIndex);
676 ok(status.dwError == CRYPT_E_NO_REVOCATION_CHECK, "got error %#lx\n", status.dwError);
677 ok(!status.dwReason, "got reason %lu\n", status.dwReason);
678
679 /* Both certs together can't, either (they're not CRLs) */
680 SetLastError(0xdeadbeef);
681 memset(&status, 0xcc, sizeof(status));
682 status.cbSize = sizeof(status);
683 ret = pCertVerifyRevocation(0, CERT_CONTEXT_REVOCATION_TYPE, 2, (void **)certs, 0, NULL, &status);
684 ok(!ret, "expected failure\n");
685 ok(GetLastError() == CRYPT_E_NO_REVOCATION_CHECK, "got error %#lx\n", GetLastError());
686 ok(!status.dwIndex, "got index %lu\n", status.dwIndex);
687 ok(status.dwError == CRYPT_E_NO_REVOCATION_CHECK, "got error %#lx\n", status.dwError);
688 ok(!status.dwReason, "got reason %lu\n", status.dwReason);
689
690 /* Test with an invalid CRL */
691
695 ok(ret, "failed to add CRL, error %lu\n", GetLastError());
696
697 SetLastError(0xdeadbeef);
698 memset(&status, 0xcc, sizeof(status));
699 status.cbSize = sizeof(status);
700 ret = pCertVerifyRevocation(X509_ASN_ENCODING, CERT_CONTEXT_REVOCATION_TYPE,
701 2, (void **)certs, 0, &params, &status);
702 ok(!ret, "expected failure\n");
703 ok(GetLastError() == CRYPT_E_NO_REVOCATION_CHECK, "got error %#lx\n", GetLastError());
704 ok(!status.dwIndex, "got index %lu\n", status.dwIndex);
705 ok(status.dwError == CRYPT_E_NO_REVOCATION_CHECK, "got error %#lx\n", status.dwError);
706 ok(!status.dwReason, "got reason %lu\n", status.dwReason);
707
708 /* Specifying CERT_VERIFY_REV_CHAIN_FLAG doesn't change things either */
709 SetLastError(0xdeadbeef);
710 memset(&status, 0xcc, sizeof(status));
711 status.cbSize = sizeof(status);
712 ret = pCertVerifyRevocation(X509_ASN_ENCODING, CERT_CONTEXT_REVOCATION_TYPE,
713 2, (void **)certs, CERT_VERIFY_REV_CHAIN_FLAG, &params, &status);
714 ok(!ret, "expected failure\n");
715 ok(GetLastError() == CRYPT_E_NO_REVOCATION_CHECK, "got error %#lx\n", GetLastError());
716 ok(!status.dwIndex, "got index %lu\n", status.dwIndex);
717 ok(status.dwError == CRYPT_E_NO_REVOCATION_CHECK, "got error %#lx\n", status.dwError);
718 ok(!status.dwReason, "got reason %lu\n", status.dwReason);
719
720 /* Again, specifying the issuer cert: no change */
721 params.pIssuerCert = certs[0];
722 SetLastError(0xdeadbeef);
723 memset(&status, 0xcc, sizeof(status));
724 status.cbSize = sizeof(status);
725 ret = pCertVerifyRevocation(X509_ASN_ENCODING, CERT_CONTEXT_REVOCATION_TYPE,
726 1, (void **)&certs[1], 0, &params, &status);
727 ok(!ret, "expected failure\n");
728 ok(GetLastError() == CRYPT_E_NO_REVOCATION_CHECK, "got error %#lx\n", GetLastError());
729 ok(!status.dwIndex, "got index %lu\n", status.dwIndex);
730 ok(status.dwError == CRYPT_E_NO_REVOCATION_CHECK, "got error %#lx\n", status.dwError);
731 ok(!status.dwReason, "got reason %lu\n", status.dwReason);
732
733 /* Specifying the time to check: still no change */
735 params.pftTimeToUse = &time;
736
737 SetLastError(0xdeadbeef);
738 memset(&status, 0xcc, sizeof(status));
739 status.cbSize = sizeof(status);
740 ret = pCertVerifyRevocation(X509_ASN_ENCODING, CERT_CONTEXT_REVOCATION_TYPE,
741 1, (void **)&certs[1], 0, &params, &status);
742 ok(!ret, "expected failure\n");
743 ok(GetLastError() == CRYPT_E_NO_REVOCATION_CHECK, "got error %#lx\n", GetLastError());
744 ok(!status.dwIndex, "got index %lu\n", status.dwIndex);
745 ok(status.dwError == CRYPT_E_NO_REVOCATION_CHECK, "got error %#lx\n", status.dwError);
746 ok(!status.dwReason, "got reason %lu\n", status.dwReason);
747
748 CertCloseStore(params.hCrlStore, 0);
749
750 /* Test again with a valid CRL. This time, the cert should be revoked when
751 * the time is after the validity period of the CRL, or considered
752 * "revocation offline" when the checked time precedes the validity
753 * period of the CRL.
754 */
758 ok(ret, "failed to add CRL, error %lu\n", GetLastError());
759
760 params.pftTimeToUse = NULL;
761
762 SetLastError(0xdeadbeef);
763 memset(&status, 0xcc, sizeof(status));
764 status.cbSize = sizeof(status);
765 ret = pCertVerifyRevocation(X509_ASN_ENCODING, CERT_CONTEXT_REVOCATION_TYPE,
766 1, (void **)&certs[1], 0, &params, &status);
767 ok(!ret, "expected failure\n");
768 ok(GetLastError() == CRYPT_E_REVOKED, "got error %#lx\n", GetLastError());
769 ok(!status.dwIndex, "got index %lu\n", status.dwIndex);
770 ok(status.dwError == CRYPT_E_REVOKED, "got error %#lx\n", status.dwError);
771 ok(!status.dwReason, "got reason %lu\n", status.dwReason);
772
774 params.pftTimeToUse = &time;
775 SetLastError(0xdeadbeef);
776 memset(&status, 0xcc, sizeof(status));
777 status.cbSize = sizeof(status);
778 ret = pCertVerifyRevocation(X509_ASN_ENCODING, CERT_CONTEXT_REVOCATION_TYPE,
779 1, (void **)&certs[1], 0, &params, &status);
780 ok(!ret, "expected failure\n");
781 ok(GetLastError() == CRYPT_E_REVOKED, "got error %#lx\n", GetLastError());
782 ok(!status.dwIndex, "got index %lu\n", status.dwIndex);
783 ok(status.dwError == CRYPT_E_REVOKED, "got error %#lx\n", status.dwError);
784 ok(!status.dwReason, "got reason %lu\n", status.dwReason);
785
787 SetLastError(0xdeadbeef);
788 memset(&status, 0xcc, sizeof(status));
789 status.cbSize = sizeof(status);
790 ret = pCertVerifyRevocation(X509_ASN_ENCODING, CERT_CONTEXT_REVOCATION_TYPE,
791 1, (void **)&certs[1], 0, &params, &status);
792 ok(!ret, "expected failure\n");
793 ok(GetLastError() == CRYPT_E_REVOCATION_OFFLINE, "got error %#lx\n", GetLastError());
794 ok(!status.dwIndex, "got index %lu\n", status.dwIndex);
795 ok(status.dwError == CRYPT_E_REVOCATION_OFFLINE, "got error %#lx\n", status.dwError);
796 ok(!status.dwReason, "got reason %lu\n", status.dwReason);
797
799
800 /* Test again with a valid CRL and an un-revoked cert. No matter the
801 * time checked, it's reported as revocation offline.
802 */
804
805 params.pftTimeToUse = NULL;
806 SetLastError(0xdeadbeef);
807 memset(&status, 0xcc, sizeof(status));
808 status.cbSize = sizeof(status);
809 ret = pCertVerifyRevocation(X509_ASN_ENCODING, CERT_CONTEXT_REVOCATION_TYPE,
810 1, (void **)&certs[1], 0, &params, &status);
811 ok(!ret, "expected failure\n");
812 ok(GetLastError() == CRYPT_E_REVOCATION_OFFLINE, "got error %#lx\n", GetLastError());
813 ok(!status.dwIndex, "got index %lu\n", status.dwIndex);
814 ok(status.dwError == CRYPT_E_REVOCATION_OFFLINE, "got error %#lx\n", status.dwError);
815 ok(!status.dwReason, "got reason %lu\n", status.dwReason);
816
818 params.pftTimeToUse = &time;
819 SetLastError(0xdeadbeef);
820 memset(&status, 0xcc, sizeof(status));
821 status.cbSize = sizeof(status);
822 ret = pCertVerifyRevocation(X509_ASN_ENCODING, CERT_CONTEXT_REVOCATION_TYPE,
823 1, (void **)&certs[1], 0, &params, &status);
824 ok(!ret, "expected failure\n");
825 ok(GetLastError() == CRYPT_E_REVOCATION_OFFLINE, "got error %#lx\n", GetLastError());
826 ok(!status.dwIndex, "got index %lu\n", status.dwIndex);
827 ok(status.dwError == CRYPT_E_REVOCATION_OFFLINE, "got error %#lx\n", status.dwError);
828 ok(!status.dwReason, "got reason %lu\n", status.dwReason);
829
831 SetLastError(0xdeadbeef);
832 memset(&status, 0xcc, sizeof(status));
833 status.cbSize = sizeof(status);
834 ret = pCertVerifyRevocation(X509_ASN_ENCODING, CERT_CONTEXT_REVOCATION_TYPE,
835 1, (void **)&certs[1], 0, &params, &status);
836 ok(!ret, "expected failure\n");
837 ok(GetLastError() == CRYPT_E_REVOCATION_OFFLINE, "got error %#lx\n", GetLastError());
838 ok(!status.dwIndex, "got index %lu\n", status.dwIndex);
839 ok(status.dwError == CRYPT_E_REVOCATION_OFFLINE, "got error %#lx\n", status.dwError);
840 ok(!status.dwReason, "got reason %lu\n", status.dwReason);
841
842 params.pftTimeToUse = NULL;
843
844 /* Test with the wrong encoding type. */
845 SetLastError(0xdeadbeef);
846 memset(&status, 0xcc, sizeof(status));
847 status.cbSize = sizeof(status);
848 ret = pCertVerifyRevocation(0, CERT_CONTEXT_REVOCATION_TYPE,
849 1, (void **)&certs[1], 0, &params, &status);
850 ok(!ret, "expected failure\n");
852 ok(!status.dwIndex, "got index %lu\n", status.dwIndex);
853 todo_wine ok(status.dwError == CRYPT_E_NO_REVOCATION_CHECK, "got error %#lx\n", status.dwError);
854 ok(!status.dwReason, "got reason %lu\n", status.dwReason);
855
856 /* Test with the wrong context type. */
857 SetLastError(0xdeadbeef);
858 memset(&status, 0xcc, sizeof(status));
859 status.cbSize = sizeof(status);
860 ret = pCertVerifyRevocation(X509_ASN_ENCODING, 0xdeadbeef,
861 1, (void **)&certs[1], 0, &params, &status);
862 ok(!ret, "expected failure\n");
863 ok(GetLastError() == CRYPT_E_NO_REVOCATION_CHECK, "got error %#lx\n", GetLastError());
864 ok(!status.dwIndex, "got index %lu\n", status.dwIndex);
865 ok(status.dwError == CRYPT_E_NO_REVOCATION_CHECK, "got error %#lx\n", status.dwError);
866 ok(!status.dwReason, "got reason %lu\n", status.dwReason);
867
868 CertCloseStore(params.hCrlStore, 0);
871}
872
873START_TEST(cryptnet)
874{
878}
#define ok(value,...)
Definition: atltest.h:57
#define skip(...)
Definition: atltest.h:64
#define broken(x)
Definition: atltest.h:178
#define START_TEST(x)
Definition: atltest.h:75
static const BYTE rootSignedCRLWithBadAKI[]
Definition: cryptnet.c:547
static void test_getObjectUrl(void)
Definition: cryptnet.c:103
static SYSTEMTIME may2007
Definition: cryptnet.c:592
static const BYTE certWithCRLDistPoint[]
Definition: cryptnet.c:51
static SYSTEMTIME oct2007
Definition: cryptnet.c:590
static void test_retrieveObjectByUrl(void)
Definition: cryptnet.c:315
static void make_tmp_file(LPSTR path)
Definition: cryptnet.c:297
static const BYTE bigCert[]
Definition: cryptnet.c:29
static const BYTE certWithAIAWithCAIssuers[]
Definition: cryptnet.c:63
static const BYTE rootSignedCRL[]
Definition: cryptnet.c:568
static void test_verifyRevocation(void)
Definition: cryptnet.c:594
static const BYTE rootWithKeySignAndCRLSign[]
Definition: cryptnet.c:452
static const BYTE revokedCert[]
Definition: cryptnet.c:486
static void PCERT_REVOCATION_PARA
Definition: cryptnet.c:587
static const BYTE unRevokedCert[]
Definition: cryptnet.c:517
static const BYTE certWithIssuingDistPoint[]
Definition: cryptnet.c:39
static void compareUrlArray(const CRYPT_URL_ARRAY *expected, const CRYPT_URL_ARRAY *got)
Definition: cryptnet.c:87
static DWORD
Definition: cryptnet.c:586
static void PCERT_REVOCATION_STATUS
Definition: cryptnet.c:587
BOOL WINAPI CryptRetrieveObjectByUrlA(LPCSTR pszURL, LPCSTR pszObjectOid, DWORD dwRetrievalFlags, DWORD dwTimeout, LPVOID *ppvObject, HCRYPTASYNC hAsyncRetrieve, PCRYPT_CREDENTIALS pCredentials, LPVOID pvVerify, PCRYPT_RETRIEVE_AUX_INFO pAuxInfo)
BOOL WINAPI CryptGetObjectUrl(LPCSTR pszUrlOid, LPVOID pvPara, DWORD dwFlags, PCRYPT_URL_ARRAY pUrlArray, DWORD *pcbUrlArray, PCRYPT_URL_INFO pUrlInfo, DWORD *pcbUrlInfo, LPVOID pvReserved)
#define E_INVALIDARG
Definition: ddrawi.h:101
#define NULL
Definition: types.h:112
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
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
VOID WINAPI CryptMemFree(LPVOID pv)
Definition: main.c:141
HCERTSTORE WINAPI CertOpenStore(LPCSTR lpszStoreProvider, DWORD dwMsgAndCertEncodingType, HCRYPTPROV_LEGACY hCryptProv, DWORD dwFlags, const void *pvPara)
Definition: store.c:815
PCCERT_CONTEXT WINAPI CertEnumCertificatesInStore(HCERTSTORE hCertStore, PCCERT_CONTEXT pPrev)
Definition: store.c:928
BOOL WINAPI CertCloseStore(HCERTSTORE hCertStore, DWORD dwFlags)
Definition: store.c:1127
#define CloseHandle
Definition: compat.h:739
#define GetProcessHeap()
Definition: compat.h:736
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
#define SetLastError(x)
Definition: compat.h:752
#define GetProcAddress(x, y)
Definition: compat.h:753
#define HeapAlloc
Definition: compat.h:733
#define CreateFileA(a, b, c, d, e, f, g)
Definition: compat.h:740
#define MAX_PATH
Definition: compat.h:34
#define HeapFree(x, y, z)
Definition: compat.h:735
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:137
BOOL WINAPI DeleteFileA(IN LPCSTR lpFileName)
Definition: delete.c:24
BOOL WINAPI WriteFile(_In_ HANDLE hFile, _In_reads_bytes_opt_(nNumberOfBytesToWrite) LPCVOID lpBuffer, _In_ DWORD nNumberOfBytesToWrite, _Out_opt_ LPDWORD lpNumberOfBytesWritten, _Inout_opt_ LPOVERLAPPED lpOverlapped)
Definition: rw.c:25
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:812
DWORD WINAPI GetCurrentDirectoryA(IN DWORD nBufferLength, OUT LPSTR lpBuffer)
Definition: path.c:2065
BOOL WINAPI SystemTimeToFileTime(IN CONST SYSTEMTIME *lpSystemTime, OUT LPFILETIME lpFileTime)
Definition: time.c:153
int WINAPI lstrcmpiW(LPCWSTR str1, LPCWSTR str2)
Definition: locale.c:4171
FILE *CDECL tmpfile(void)
Definition: file.c:5199
return ret
Definition: mutex.c:146
#define L(x)
Definition: resources.c:13
UINT WINAPI GetTempFileNameA(IN LPCSTR lpPathName, IN LPCSTR lpPrefixString, IN UINT uUnique, OUT LPSTR lpTempFileName)
Definition: filename.c:26
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
GLenum const GLfloat * params
Definition: glext.h:5645
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
LPSTR WINAPI lstrcpyA(LPSTR lpString1, LPCSTR lpString2)
Definition: lstring.c:100
#define win_skip
Definition: minitest.h:67
#define todo_wine
Definition: minitest.h:80
__u16 time
Definition: mkdosfs.c:8
#define CREATE_ALWAYS
Definition: disk.h:72
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
#define sprintf
Definition: sprintf.c:45
static const WCHAR url[]
Definition: encode.c:1384
static const BYTE crl[]
Definition: message.c:817
static BYTE cert[]
Definition: msg.c:1374
BOOL expected
Definition: store.c:2000
#define BOOL
Definition: nt_native.h:43
#define GENERIC_WRITE
Definition: nt_native.h:90
short WCHAR
Definition: pedump.c:58
static calc_node_t temp
Definition: rpn_ieee.c:38
#define memset(x, y, z)
Definition: compat.h:39
PCRYPT_DATA_BLOB rgBlob
Definition: wincrypt.h:1813
FILETIME * pLastSyncTime
Definition: wincrypt.h:1843
LPWSTR * rgwszUrl
Definition: wincrypt.h:1738
DWORD dwHighDateTime
Definition: mapidefs.h:66
DWORD dwLowDateTime
Definition: mapidefs.h:65
Definition: ps.c:97
uint16_t * LPWSTR
Definition: typedefs.h:56
char * LPSTR
Definition: typedefs.h:51
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define CONTEXT_OID_CERTIFICATE
Definition: wincrypt.h:1876
#define CONTEXT_OID_CRL
Definition: wincrypt.h:1877
#define URL_OID_CERTIFICATE_ISSUER
Definition: wincrypt.h:1748
#define CONTEXT_OID_CAPI2_ANY
Definition: wincrypt.h:1880
void * HCERTSTORE
Definition: wincrypt.h:60
#define CRYPT_GET_URL_FROM_EXTENSION
Definition: wincrypt.h:3637
#define CERT_STORE_CREATE_NEW_FLAG
Definition: wincrypt.h:2633
#define X509_ASN_ENCODING
Definition: wincrypt.h:2501
#define CERT_STORE_PROV_MEMORY
Definition: wincrypt.h:2455
#define CRYPT_GET_URL_FROM_PROPERTY
Definition: wincrypt.h:3636
const CERT_CONTEXT * PCCERT_CONTEXT
Definition: wincrypt.h:494
#define CERT_CONTEXT_REVOCATION_TYPE
Definition: wincrypt.h:930
#define URL_OID_CERTIFICATE_CRL_DIST_POINT
Definition: wincrypt.h:1749
#define CERT_STORE_ADD_ALWAYS
Definition: wincrypt.h:2654
const CRL_CONTEXT * PCCRL_CONTEXT
Definition: wincrypt.h:737
#define CERT_VERIFY_REV_CHAIN_FLAG
Definition: wincrypt.h:931
#define CRYPT_CACHE_ONLY_RETRIEVAL
Definition: wincrypt.h:1883
#define WINAPI
Definition: msvc.h:6
#define CRYPT_E_REVOKED
Definition: winerror.h:4433
#define CRYPT_E_NO_MATCH
Definition: winerror.h:4426
#define CRYPT_E_NOT_FOUND
Definition: winerror.h:4421
#define ERROR_PATH_NOT_FOUND
Definition: winerror.h:228
#define CRYPT_E_NO_REVOCATION_CHECK
Definition: winerror.h:4435
#define CRYPT_E_REVOCATION_OFFLINE
Definition: winerror.h:4436
#define OSS_DATA_ERROR
Definition: winerror.h:4457
#define CRYPT_E_ASN1_BADTAG
Definition: winerror.h:4510
unsigned char BYTE
Definition: xxhash.c:193