ReactOS 0.4.16-dev-1946-g52006dd
encode.c
Go to the documentation of this file.
1/*
2 * Unit test suite for crypt32.dll's CryptEncodeObjectEx/CryptDecodeObjectEx
3 *
4 * Copyright 2005 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 <stdio.h>
21#include <stdarg.h>
22#include <windef.h>
23#include <winbase.h>
24#include <winerror.h>
25#include <wincrypt.h>
26#include <snmp.h>
27
28#include "wine/test.h"
29
30void CRYPT_CopyReversed(BYTE *dst, const BYTE *src, size_t len)
31{
32 DWORD i;
33 for (i = 0; i < len; i++) {
34 dst[len - i - 1] = src[i];
35 }
36}
37
39{
40 int val;
41 const BYTE *encoded;
42};
43
44static const BYTE bin1[] = {0x02,0x01,0x01};
45static const BYTE bin2[] = {0x02,0x01,0x7f};
46static const BYTE bin3[] = {0x02,0x02,0x00,0x80};
47static const BYTE bin4[] = {0x02,0x02,0x01,0x00};
48static const BYTE bin5[] = {0x02,0x01,0x80};
49static const BYTE bin6[] = {0x02,0x02,0xff,0x7f};
50static const BYTE bin7[] = {0x02,0x04,0xba,0xdd,0xf0,0x0d};
51
52static const struct encodedInt ints[] = {
53 { 1, bin1 },
54 { 127, bin2 },
55 { 128, bin3 },
56 { 256, bin4 },
57 { -128, bin5 },
58 { -129, bin6 },
59 { 0xbaddf00d, bin7 },
60};
61
63{
64 const BYTE *val;
65 const BYTE *encoded;
66 const BYTE *decoded;
67};
68
69static const BYTE bin8[] = {0xff,0xff,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0};
70static const BYTE bin9[] = {0x02,0x0a,0x08,0x07,0x06,0x05,0x04,0x03,0x02,0x01,0xff,0xff,0};
71static const BYTE bin10[] = {0xff,0xff,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0};
72
73static const BYTE bin11[] = {0x08,0x07,0x06,0x05,0x04,0x03,0x02,0x01,0xff,0xff,0xff,0};
74static const BYTE bin12[] = {0x02,0x09,0xff,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0};
75static const BYTE bin13[] = {0x08,0x07,0x06,0x05,0x04,0x03,0x02,0x01,0xff,0};
76
77static const struct encodedBigInt bigInts[] = {
78 { bin8, bin9, bin10 },
79 { bin11, bin12, bin13 },
80};
81
82static const BYTE bin14[] = {0xff,0xff,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0};
83static const BYTE bin15[] = {0x02,0x0a,0x08,0x07,0x06,0x05,0x04,0x03,0x02,0x01,0xff,0xff,0};
84static const BYTE bin16[] = {0x08,0x07,0x06,0x05,0x04,0x03,0x02,0x01,0xff,0xff,0xff,0};
85static const BYTE bin17[] = {0x02,0x0c,0x00,0xff,0xff,0xff,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0};
86
87/* Decoded is the same as original, so don't bother storing a separate copy */
88static const struct encodedBigInt bigUInts[] = {
89 { bin14, bin15, NULL },
90 { bin16, bin17, NULL },
91};
92
93static void test_encodeInt(DWORD dwEncoding)
94{
95 DWORD bufSize = 0;
96 int i;
97 BOOL ret;
99 BYTE *buf = NULL;
100
101 /* CryptEncodeObjectEx with NULL bufSize crashes..
102 ret = CryptEncodeObjectEx(3, X509_INTEGER, &ints[0].val, 0, NULL, NULL,
103 NULL);
104 */
105 /* check bogus encoding */
107 &bufSize);
109 "Expected ERROR_FILE_NOT_FOUND, got %ld\n", GetLastError());
110
111 ret = CryptEncodeObjectEx(dwEncoding, X509_INTEGER, NULL, 0, NULL, NULL,
112 &bufSize);
114 "Expected STATUS_ACCESS_VIOLATION, got %08lx\n", GetLastError());
115
116 for (i = 0; i < ARRAY_SIZE(ints); i++)
117 {
118 /* encode as normal integer */
119 ret = CryptEncodeObjectEx(dwEncoding, X509_INTEGER, &ints[i].val, 0,
120 NULL, NULL, &bufSize);
121 ok(ret, "Expected success, got %ld\n", GetLastError());
122 ret = CryptEncodeObjectEx(dwEncoding, X509_INTEGER, &ints[i].val,
124 ok(ret, "CryptEncodeObjectEx failed: %ld\n", GetLastError());
125 if (ret)
126 {
127 ok(buf[0] == 2, "Got unexpected type %d for integer (expected 2)\n",
128 buf[0]);
129 ok(buf[1] == ints[i].encoded[1], "Got length %d, expected %d\n",
130 buf[1], ints[i].encoded[1]);
131 ok(!memcmp(buf + 1, ints[i].encoded + 1, ints[i].encoded[1] + 1),
132 "Encoded value of 0x%08x didn't match expected\n", ints[i].val);
133 LocalFree(buf);
134 }
135 /* encode as multibyte integer */
136 blob.cbData = sizeof(ints[i].val);
137 blob.pbData = (BYTE *)&ints[i].val;
139 0, NULL, NULL, &bufSize);
140 ok(ret, "Expected success, got %ld\n", GetLastError());
143 ok(ret, "CryptEncodeObjectEx failed: %ld\n", GetLastError());
144 if (ret)
145 {
146 ok(buf[0] == 2, "Got unexpected type %d for integer (expected 2)\n",
147 buf[0]);
148 ok(buf[1] == ints[i].encoded[1], "Got length %d, expected %d\n",
149 buf[1], ints[i].encoded[1]);
150 ok(!memcmp(buf + 1, ints[i].encoded + 1, ints[i].encoded[1] + 1),
151 "Encoded value of 0x%08x didn't match expected\n", ints[i].val);
152 LocalFree(buf);
153 }
154 }
155 /* encode a couple bigger ints, just to show it's little-endian and leading
156 * sign bytes are dropped
157 */
158 for (i = 0; i < ARRAY_SIZE(bigInts); i++)
159 {
160 blob.cbData = strlen((const char*)bigInts[i].val);
161 blob.pbData = (BYTE *)bigInts[i].val;
163 0, NULL, NULL, &bufSize);
164 ok(ret, "Expected success, got %ld\n", GetLastError());
167 ok(ret, "CryptEncodeObjectEx failed: %ld\n", GetLastError());
168 if (ret)
169 {
170 ok(buf[0] == 2, "Got unexpected type %d for integer (expected 2)\n",
171 buf[0]);
172 ok(buf[1] == bigInts[i].encoded[1], "Got length %d, expected %d\n",
173 buf[1], bigInts[i].encoded[1]);
174 ok(!memcmp(buf + 1, bigInts[i].encoded + 1,
175 bigInts[i].encoded[1] + 1),
176 "Encoded value didn't match expected\n");
177 LocalFree(buf);
178 }
179 }
180 /* and, encode some uints */
181 for (i = 0; i < ARRAY_SIZE(bigUInts); i++)
182 {
183 blob.cbData = strlen((const char*)bigUInts[i].val);
184 blob.pbData = (BYTE*)bigUInts[i].val;
186 0, NULL, NULL, &bufSize);
187 ok(ret, "Expected success, got %ld\n", GetLastError());
190 ok(ret, "CryptEncodeObjectEx failed: %ld\n", GetLastError());
191 if (ret)
192 {
193 ok(buf[0] == 2, "Got unexpected type %d for integer (expected 2)\n",
194 buf[0]);
195 ok(buf[1] == bigUInts[i].encoded[1], "Got length %d, expected %d\n",
196 buf[1], bigUInts[i].encoded[1]);
197 ok(!memcmp(buf + 1, bigUInts[i].encoded + 1,
198 bigUInts[i].encoded[1] + 1),
199 "Encoded value didn't match expected\n");
200 LocalFree(buf);
201 }
202 }
203}
204
205static void test_decodeInt(DWORD dwEncoding)
206{
207 static const BYTE bigInt[] = { 2, 5, 0xff, 0xfe, 0xff, 0xfe, 0xff };
208 static const BYTE testStr[] = { 0x16, 4, 't', 'e', 's', 't' };
209 static const BYTE longForm[] = { 2, 0x81, 0x01, 0x01 };
210 static const BYTE bigBogus[] = { 0x02, 0x84, 0x01, 0xff, 0xff, 0xf9 };
211 static const BYTE extraBytes[] = { 2, 1, 1, 0, 0, 0, 0 };
212 BYTE *buf = NULL;
213 DWORD bufSize = 0;
214 int i;
215 BOOL ret;
216
217 /* CryptDecodeObjectEx with NULL bufSize crashes..
218 ret = CryptDecodeObjectEx(3, X509_INTEGER, &ints[0].encoded,
219 ints[0].encoded[1] + 2, 0, NULL, NULL, NULL);
220 */
221 /* check bogus encoding */
223 ints[0].encoded[1] + 2, 0, NULL, NULL, &bufSize);
225 "Expected ERROR_FILE_NOT_FOUND, got %ld\n", GetLastError());
226 /* check with NULL integer buffer */
227 ret = CryptDecodeObjectEx(dwEncoding, X509_INTEGER, NULL, 0, 0, NULL, NULL,
228 &bufSize);
230 "Expected CRYPT_E_ASN1_EOD, got %08lx\n", GetLastError());
231 /* check with a valid, but too large, integer */
232 ret = CryptDecodeObjectEx(dwEncoding, X509_INTEGER, bigInt, bigInt[1] + 2,
235 "Expected CRYPT_E_ASN1_LARGE, got %ld\n", GetLastError());
236 /* check with a DER-encoded string */
237 ret = CryptDecodeObjectEx(dwEncoding, X509_INTEGER, testStr, testStr[1] + 2,
240 "Expected CRYPT_E_ASN1_BADTAG, got %08lx\n", GetLastError());
241 for (i = 0; i < ARRAY_SIZE(ints); i++)
242 {
243 /* When the output buffer is NULL, this always succeeds */
244 SetLastError(0xdeadbeef);
246 ints[i].encoded, ints[i].encoded[1] + 2, 0, NULL, NULL,
247 &bufSize);
248 ok(ret && GetLastError() == NOERROR,
249 "Expected success and NOERROR, got %ld\n", GetLastError());
251 ints[i].encoded, ints[i].encoded[1] + 2,
253 ok(ret, "CryptDecodeObjectEx failed: %ld\n", GetLastError());
254 ok(bufSize == sizeof(int), "Wrong size %ld\n", bufSize);
255 ok(buf != NULL, "Expected allocated buffer\n");
256 if (ret)
257 {
258 ok(!memcmp(buf, &ints[i].val, bufSize), "Expected %d, got %d\n",
259 ints[i].val, *(int *)buf);
260 LocalFree(buf);
261 }
262 }
263 for (i = 0; i < ARRAY_SIZE(bigInts); i++)
264 {
266 bigInts[i].encoded, bigInts[i].encoded[1] + 2, 0, NULL, NULL,
267 &bufSize);
268 ok(ret && GetLastError() == NOERROR,
269 "Expected success and NOERROR, got %ld\n", GetLastError());
271 bigInts[i].encoded, bigInts[i].encoded[1] + 2,
273 ok(ret, "CryptDecodeObjectEx failed: %ld\n", GetLastError());
274 ok(bufSize >= sizeof(CRYPT_INTEGER_BLOB), "Wrong size %ld\n", bufSize);
275 ok(buf != NULL, "Expected allocated buffer\n");
276 if (ret)
277 {
279
280 ok(blob->cbData == strlen((const char*)bigInts[i].decoded),
281 "Expected len %d, got %ld\n", lstrlenA((const char*)bigInts[i].decoded),
282 blob->cbData);
283 ok(!memcmp(blob->pbData, bigInts[i].decoded, blob->cbData),
284 "Unexpected value\n");
285 LocalFree(buf);
286 }
287 }
288 for (i = 0; i < ARRAY_SIZE(bigUInts); i++)
289 {
291 bigUInts[i].encoded, bigUInts[i].encoded[1] + 2, 0, NULL, NULL,
292 &bufSize);
293 ok(ret && GetLastError() == NOERROR,
294 "Expected success and NOERROR, got %ld\n", GetLastError());
298 ok(ret, "CryptDecodeObjectEx failed: %ld\n", GetLastError());
299 ok(bufSize >= sizeof(CRYPT_INTEGER_BLOB), "Wrong size %ld\n", bufSize);
300 ok(buf != NULL, "Expected allocated buffer\n");
301 if (ret)
302 {
304
305 ok(blob->cbData == strlen((const char*)bigUInts[i].val),
306 "Expected len %d, got %ld\n", lstrlenA((const char*)bigUInts[i].val),
307 blob->cbData);
308 ok(!memcmp(blob->pbData, bigUInts[i].val, blob->cbData),
309 "Unexpected value\n");
310 LocalFree(buf);
311 }
312 }
313 /* Decode the value 1 with long-form length */
314 ret = CryptDecodeObjectEx(dwEncoding, X509_MULTI_BYTE_INTEGER, longForm,
315 sizeof(longForm), CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &bufSize);
316 ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
317 if (ret)
318 {
319 ok(*(int *)buf == 1, "Expected 1, got %d\n", *(int *)buf);
320 LocalFree(buf);
321 }
322 /* check with extra bytes at the end */
323 ret = CryptDecodeObjectEx(dwEncoding, X509_INTEGER, extraBytes,
324 sizeof(extraBytes), CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &bufSize);
325 ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
326 if (ret)
327 {
328 ok(*(int *)buf == 1, "Expected 1, got %d\n", *(int *)buf);
329 LocalFree(buf);
330 }
331 /* Try to decode some bogus large items */
332 /* The buffer size is smaller than the encoded length, so this should fail
333 * with CRYPT_E_ASN1_EOD if it's being decoded.
334 * Under XP it fails with CRYPT_E_ASN1_LARGE, which means there's a limit
335 * on the size decoded, but in ME it fails with CRYPT_E_ASN1_EOD or crashes.
336 * So this test unfortunately isn't useful.
337 ret = CryptDecodeObjectEx(dwEncoding, X509_MULTI_BYTE_INTEGER, tooBig,
338 0x7fffffff, CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &bufSize);
339 ok(!ret && GetLastError() == CRYPT_E_ASN1_LARGE,
340 "Expected CRYPT_E_ASN1_LARGE, got %08x\n", GetLastError());
341 */
342 /* This will try to decode the buffer and overflow it, check that it's
343 * caught.
344 */
345 if (0)
346 {
347 /* a large buffer isn't guaranteed to crash, it depends on memory allocation order */
348 ret = CryptDecodeObjectEx(dwEncoding, X509_MULTI_BYTE_INTEGER, bigBogus,
349 0x01ffffff, CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &bufSize);
351 "Expected STATUS_ACCESS_VIOLATION, got %08lx\n", GetLastError());
352 }
353}
354
355static const BYTE bin18[] = {0x0a,0x01,0x01};
356static const BYTE bin19[] = {0x0a,0x05,0x00,0xff,0xff,0xff,0x80};
357
358/* These are always encoded unsigned, and aren't constrained to be any
359 * particular value
360 */
361static const struct encodedInt enums[] = {
362 { 1, bin18 },
363 { -128, bin19 },
364};
365
366/* X509_CRL_REASON_CODE is also an enumerated type, but it's #defined to
367 * X509_ENUMERATED.
368 */
371
372static void test_encodeEnumerated(DWORD dwEncoding)
373{
374 DWORD i, j;
375
376 for (i = 0; i < ARRAY_SIZE(enumeratedTypes); i++)
377 {
378 for (j = 0; j < ARRAY_SIZE(enums); j++)
379 {
380 BOOL ret;
381 BYTE *buf = NULL;
382 DWORD bufSize = 0;
383
386 &bufSize);
387 ok(ret, "CryptEncodeObjectEx failed: %ld\n", GetLastError());
388 if (ret)
389 {
390 ok(buf[0] == 0xa,
391 "Got unexpected type %d for enumerated (expected 0xa)\n",
392 buf[0]);
393 ok(buf[1] == enums[j].encoded[1],
394 "Got length %d, expected %d\n", buf[1], enums[j].encoded[1]);
395 ok(!memcmp(buf + 1, enums[j].encoded + 1,
396 enums[j].encoded[1] + 1),
397 "Encoded value of 0x%08x didn't match expected\n",
398 enums[j].val);
399 LocalFree(buf);
400 }
401 }
402 }
403}
404
405static void test_decodeEnumerated(DWORD dwEncoding)
406{
407 DWORD i, j;
408
409 for (i = 0; i < ARRAY_SIZE(enumeratedTypes); i++)
410 {
411 for (j = 0; j < ARRAY_SIZE(enums); j++)
412 {
413 BOOL ret;
414 DWORD bufSize = sizeof(int);
415 int val;
416
418 enums[j].encoded, enums[j].encoded[1] + 2, 0, NULL,
419 &val, &bufSize);
420 ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
421 ok(bufSize == sizeof(int),
422 "Got unexpected size %ld for enumerated\n", bufSize);
423 ok(val == enums[j].val, "Unexpected value %d, expected %d\n",
424 val, enums[j].val);
425 }
426 }
427}
428
430{
433};
434
435static void testTimeEncoding(DWORD dwEncoding, LPCSTR structType,
436 const struct encodedFiletime *time)
437{
438 FILETIME ft = { 0 };
439 BYTE *buf = NULL;
440 DWORD bufSize = 0;
441 BOOL ret;
442
443 ret = SystemTimeToFileTime(&time->sysTime, &ft);
444 ok(ret, "SystemTimeToFileTime failed: %ld\n", GetLastError());
445 ret = CryptEncodeObjectEx(dwEncoding, structType, &ft,
447 /* years other than 1950-2050 are not allowed for encodings other than
448 * X509_CHOICE_OF_TIME.
449 */
450 if (structType == X509_CHOICE_OF_TIME ||
451 (time->sysTime.wYear >= 1950 && time->sysTime.wYear <= 2050))
452 {
453 ok(ret, "CryptEncodeObjectEx failed: %ld (0x%08lx)\n", GetLastError(),
454 GetLastError());
455 ok(buf != NULL, "Expected an allocated buffer\n");
456 if (ret)
457 {
458 ok(buf[0] == time->encodedTime[0],
459 "Expected type 0x%02x, got 0x%02x\n", time->encodedTime[0],
460 buf[0]);
461 ok(buf[1] == time->encodedTime[1], "Expected %d bytes, got %ld\n",
462 time->encodedTime[1], bufSize);
463 ok(!memcmp(time->encodedTime + 2, buf + 2, time->encodedTime[1]),
464 "Got unexpected value for time encoding\n");
465 LocalFree(buf);
466 }
467 }
468 else
470 "Expected CRYPT_E_BAD_ENCODE, got 0x%08lx\n", GetLastError());
471}
472
473static const char *printSystemTime(const SYSTEMTIME *st)
474{
475 static char buf[64];
476
477 sprintf(buf, "%02d-%02d-%04d %02d:%02d:%02d.%03d", st->wMonth, st->wDay,
478 st->wYear, st->wHour, st->wMinute, st->wSecond, st->wMilliseconds);
479 return buf;
480}
481
482static const char *printFileTime(const FILETIME *ft)
483{
484 static char buf[64];
485 SYSTEMTIME st;
486
487 FileTimeToSystemTime(ft, &st);
488 sprintf(buf, "%02d-%02d-%04d %02d:%02d:%02d.%03d", st.wMonth, st.wDay,
489 st.wYear, st.wHour, st.wMinute, st.wSecond, st.wMilliseconds);
490 return buf;
491}
492
493static void compareTime(const SYSTEMTIME *expected, const FILETIME *got)
494{
495 SYSTEMTIME st;
496
497 FileTimeToSystemTime(got, &st);
498 ok(expected->wYear == st.wYear &&
499 expected->wMonth == st.wMonth &&
500 expected->wDay == st.wDay &&
501 expected->wHour == st.wHour &&
502 expected->wMinute == st.wMinute &&
503 expected->wSecond == st.wSecond &&
504 abs(expected->wMilliseconds - st.wMilliseconds) <= 1,
505 "Got unexpected value for time decoding:\nexpected %s, got %s\n",
507}
508
509static void testTimeDecoding(DWORD dwEncoding, LPCSTR structType,
510 const struct encodedFiletime *time)
511{
512 FILETIME ft = { 0 };
513 DWORD size = sizeof(ft);
514 BOOL ret;
515
516 ret = CryptDecodeObjectEx(dwEncoding, structType, time->encodedTime,
517 time->encodedTime[1] + 2, 0, NULL, &ft, &size);
518 /* years other than 1950-2050 are not allowed for encodings other than
519 * X509_CHOICE_OF_TIME.
520 */
521 if (structType == X509_CHOICE_OF_TIME ||
522 (time->sysTime.wYear >= 1950 && time->sysTime.wYear <= 2050))
523 {
524 ok(ret, "CryptDecodeObjectEx failed: %ld (0x%08lx)\n", GetLastError(),
525 GetLastError());
526 if (ret)
527 compareTime(&time->sysTime, &ft);
528 }
529 else
531 "Expected CRYPT_E_ASN1_BADTAG, got %08lx\n", GetLastError());
532}
533
534static const BYTE bin20[] = {
535 0x17,0x0d,'0','5','0','6','0','6','1','6','1','0','0','0','Z'};
536static const BYTE bin21[] = {
537 0x18,0x0f,'1','9','4','5','0','6','0','6','1','6','1','0','0','0','Z'};
538static const BYTE bin22[] = {
539 0x18,0x0f,'2','1','4','5','0','6','0','6','1','6','1','0','0','0','Z'};
540
541static const struct encodedFiletime times[] = {
542 { { 2005, 6, 1, 6, 16, 10, 0, 0 }, bin20 },
543 { { 1945, 6, 1, 6, 16, 10, 0, 0 }, bin21 },
544 { { 2145, 6, 1, 6, 16, 10, 0, 0 }, bin22 },
545};
546
547static void test_encodeFiletime(DWORD dwEncoding)
548{
549 DWORD i;
550
551 for (i = 0; i < ARRAY_SIZE(times); i++)
552 {
554 testTimeEncoding(dwEncoding, PKCS_UTC_TIME, &times[i]);
556 }
557}
558
559static const BYTE bin23[] = {
560 0x18,0x13,'1','9','4','5','0','6','0','6','1','6','1','0','0','0','.','0','0','0','Z'};
561static const BYTE bin24[] = {
562 0x18,0x13,'1','9','4','5','0','6','0','6','1','6','1','0','0','0','.','9','9','9','Z'};
563static const BYTE bin25[] = {
564 0x18,0x13,'1','9','4','5','0','6','0','6','1','6','1','0','0','0','+','0','1','0','0'};
565static const BYTE bin26[] = {
566 0x18,0x13,'1','9','4','5','0','6','0','6','1','6','1','0','0','0','-','0','1','0','0'};
567static const BYTE bin27[] = {
568 0x18,0x13,'1','9','4','5','0','6','0','6','1','6','1','0','0','0','-','0','1','1','5'};
569static const BYTE bin28[] = {
570 0x18,0x0a,'2','1','4','5','0','6','0','6','1','6'};
571static const BYTE bin29[] = {
572 0x17,0x0a,'4','5','0','6','0','6','1','6','1','0'};
573static const BYTE bin30[] = {
574 0x17,0x0b,'4','5','0','6','0','6','1','6','1','0','Z'};
575static const BYTE bin31[] = {
576 0x17,0x0d,'4','5','0','6','0','6','1','6','1','0','+','0','1'};
577static const BYTE bin32[] = {
578 0x17,0x0d,'4','5','0','6','0','6','1','6','1','0','-','0','1'};
579static const BYTE bin33[] = {
580 0x17,0x0f,'4','5','0','6','0','6','1','6','1','0','+','0','1','0','0'};
581static const BYTE bin34[] = {
582 0x17,0x0f,'4','5','0','6','0','6','1','6','1','0','-','0','1','0','0'};
583static const BYTE bin35[] = {
584 0x17,0x08, '4','5','0','6','0','6','1','6'};
585static const BYTE bin36[] = {
586 0x18,0x0f, 'a','a','a','a','a','a','a','a','a','a','a','a','a','a','Z'};
587static const BYTE bin37[] = {
588 0x18,0x04, '2','1','4','5'};
589static const BYTE bin38[] = {
590 0x18,0x08, '2','1','4','5','0','6','0','6'};
591
592static void test_decodeFiletime(DWORD dwEncoding)
593{
594 static const struct encodedFiletime otherTimes[] = {
595 { { 1945, 6, 1, 6, 16, 10, 0, 0 }, bin23 },
596 { { 1945, 6, 1, 6, 16, 10, 0, 999 }, bin24 },
597 { { 1945, 6, 1, 6, 17, 10, 0, 0 }, bin25 },
598 { { 1945, 6, 1, 6, 15, 10, 0, 0 }, bin26 },
599 { { 1945, 6, 1, 6, 14, 55, 0, 0 }, bin27 },
600 { { 2145, 6, 1, 6, 16, 0, 0, 0 }, bin28 },
601 { { 2045, 6, 1, 6, 16, 10, 0, 0 }, bin29 },
602 { { 2045, 6, 1, 6, 16, 10, 0, 0 }, bin30 },
603 { { 2045, 6, 1, 6, 17, 10, 0, 0 }, bin31 },
604 { { 2045, 6, 1, 6, 15, 10, 0, 0 }, bin32 },
605 { { 2045, 6, 1, 6, 17, 10, 0, 0 }, bin33 },
606 { { 2045, 6, 1, 6, 15, 10, 0, 0 }, bin34 },
607 };
608 /* An oddball case that succeeds in Windows, but doesn't seem correct
609 { { 2145, 6, 1, 2, 11, 31, 0, 0 }, "\x18" "\x13" "21450606161000-9999" },
610 */
611 static const unsigned char *bogusTimes[] = {
612 /* oddly, this succeeds on Windows, with year 2765
613 "\x18" "\x0f" "21r50606161000Z",
614 */
615 bin35,
616 bin36,
617 bin37,
618 bin38,
619 };
620 DWORD i, size;
621 FILETIME ft1 = { 0 }, ft2 = { 0 };
622 BOOL ret;
623
624 /* Check bogus length with non-NULL buffer */
626 ok(ret, "SystemTimeToFileTime failed: %ld\n", GetLastError());
627 size = 1;
629 times[0].encodedTime, times[0].encodedTime[1] + 2, 0, NULL, &ft2, &size);
631 "Expected ERROR_MORE_DATA, got %ld\n", GetLastError());
632 /* Normal tests */
633 for (i = 0; i < ARRAY_SIZE(times); i++)
634 {
636 testTimeDecoding(dwEncoding, PKCS_UTC_TIME, &times[i]);
638 }
639 for (i = 0; i < ARRAY_SIZE(otherTimes); i++)
640 {
641 testTimeDecoding(dwEncoding, X509_CHOICE_OF_TIME, &otherTimes[i]);
642 testTimeDecoding(dwEncoding, PKCS_UTC_TIME, &otherTimes[i]);
643 testTimeDecoding(dwEncoding, szOID_RSA_signingTime, &otherTimes[i]);
644 }
645 for (i = 0; i < ARRAY_SIZE(bogusTimes); i++)
646 {
647 size = sizeof(ft1);
649 bogusTimes[i], bogusTimes[i][1] + 2, 0, NULL, &ft1, &size);
651 "Expected CRYPT_E_ASN1_CORRUPT, got %08lx\n", GetLastError());
652 }
653}
654
655static const char commonName[] = "Juan Lang";
656static const char surName[] = "Lang";
657
658static const BYTE emptySequence[] = { 0x30, 0 };
659static const BYTE emptyRDNs[] = { 0x30, 0x02, 0x31, 0 };
660static const BYTE twoRDNs[] = {
661 0x30,0x23,0x31,0x21,0x30,0x0c,0x06,0x03,0x55,0x04,0x04,
662 0x13,0x05,0x4c,0x61,0x6e,0x67,0x00,0x30,0x11,0x06,0x03,0x55,0x04,0x03,
663 0x13,0x0a,0x4a,0x75,0x61,0x6e,0x20,0x4c,0x61,0x6e,0x67,0};
664static const BYTE encodedTwoRDNs[] = {
6650x30,0x2e,0x31,0x2c,0x30,0x2a,0x06,0x03,0x55,0x04,0x03,0x30,0x23,0x31,0x21,
6660x30,0x0c,0x06,0x03,0x55,0x04,0x04,0x13,0x05,0x4c,0x61,0x6e,0x67,0x00,0x30,
6670x11,0x06,0x03,0x55,0x04,0x03,0x13,0x0a,0x4a,0x75,0x61,0x6e,0x20,0x4c,0x61,
6680x6e,0x67,0x00,
669};
670
671static const BYTE us[] = { 0x55, 0x53 };
672static const BYTE minnesota[] = { 0x4d, 0x69, 0x6e, 0x6e, 0x65, 0x73, 0x6f,
673 0x74, 0x61 };
674static const BYTE minneapolis[] = { 0x4d, 0x69, 0x6e, 0x6e, 0x65, 0x61, 0x70,
675 0x6f, 0x6c, 0x69, 0x73 };
676static const BYTE codeweavers[] = { 0x43, 0x6f, 0x64, 0x65, 0x57, 0x65, 0x61,
677 0x76, 0x65, 0x72, 0x73 };
678static const BYTE wine[] = { 0x57, 0x69, 0x6e, 0x65, 0x20, 0x44, 0x65, 0x76,
679 0x65, 0x6c, 0x6f, 0x70, 0x6d, 0x65, 0x6e, 0x74 };
680static const BYTE localhostAttr[] = { 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x68, 0x6f,
681 0x73, 0x74 };
682static const BYTE aric[] = { 0x61, 0x72, 0x69, 0x63, 0x40, 0x63, 0x6f, 0x64,
683 0x65, 0x77, 0x65, 0x61, 0x76, 0x65, 0x72, 0x73, 0x2e, 0x63, 0x6f, 0x6d };
684
685#define RDNA(arr) oid_ ## arr, CERT_RDN_PRINTABLE_STRING, { sizeof(arr), (LPBYTE)arr }
686#define RDNIA5(arr) oid_ ## arr, CERT_RDN_IA5_STRING, { sizeof(arr), (LPBYTE)arr }
687
688static CHAR oid_us[] = "2.5.4.6",
689 oid_minnesota[] = "2.5.4.8",
690 oid_minneapolis[] = "2.5.4.7",
691 oid_codeweavers[] = "2.5.4.10",
692 oid_wine[] = "2.5.4.11",
693 oid_localhostAttr[] = "2.5.4.3",
694 oid_aric[] = "1.2.840.113549.1.9.1";
695static CERT_RDN_ATTR rdnAttrs[] = { { RDNA(us) },
696 { RDNA(minnesota) },
697 { RDNA(minneapolis) },
698 { RDNA(codeweavers) },
699 { RDNA(wine) },
700 { RDNA(localhostAttr) },
701 { RDNIA5(aric) } };
703 { RDNA(localhostAttr) },
704 { RDNA(minnesota) },
705 { RDNA(minneapolis) },
706 { RDNA(codeweavers) },
707 { RDNA(wine) },
708 { RDNIA5(aric) } };
709
710#undef RDNIA5
711#undef RDNA
712
713static const BYTE encodedRDNAttrs[] = {
7140x30,0x81,0x96,0x31,0x81,0x93,0x30,0x09,0x06,0x03,0x55,0x04,0x06,0x13,0x02,0x55,
7150x53,0x30,0x10,0x06,0x03,0x55,0x04,0x03,0x13,0x09,0x6c,0x6f,0x63,0x61,0x6c,0x68,
7160x6f,0x73,0x74,0x30,0x10,0x06,0x03,0x55,0x04,0x08,0x13,0x09,0x4d,0x69,0x6e,0x6e,
7170x65,0x73,0x6f,0x74,0x61,0x30,0x12,0x06,0x03,0x55,0x04,0x07,0x13,0x0b,0x4d,0x69,
7180x6e,0x6e,0x65,0x61,0x70,0x6f,0x6c,0x69,0x73,0x30,0x12,0x06,0x03,0x55,0x04,0x0a,
7190x13,0x0b,0x43,0x6f,0x64,0x65,0x57,0x65,0x61,0x76,0x65,0x72,0x73,0x30,0x17,0x06,
7200x03,0x55,0x04,0x0b,0x13,0x10,0x57,0x69,0x6e,0x65,0x20,0x44,0x65,0x76,0x65,0x6c,
7210x6f,0x70,0x6d,0x65,0x6e,0x74,0x30,0x21,0x06,0x09,0x2a,0x86,0x48,0x86,0xf7,0x0d,
7220x01,0x09,0x01,0x16,0x14,0x61,0x72,0x69,0x63,0x40,0x63,0x6f,0x64,0x65,0x77,0x65,
7230x61,0x76,0x65,0x72,0x73,0x2e,0x63,0x6f,0x6d
724};
725
726static void test_encodeName(DWORD dwEncoding)
727{
728 CERT_RDN_ATTR attrs[2];
729 CERT_RDN rdn;
731 static CHAR oid_common_name[] = szOID_COMMON_NAME,
732 oid_sur_name[] = szOID_SUR_NAME;
733 BYTE *buf = NULL;
734 DWORD size = 0;
735 BOOL ret;
736
737 /* Test with NULL pvStructInfo */
738 ret = CryptEncodeObjectEx(dwEncoding, X509_NAME, NULL,
741 "Expected STATUS_ACCESS_VIOLATION, got %08lx\n", GetLastError());
742
743 /* Test with empty CERT_NAME_INFO */
744 info.cRDN = 0;
745 info.rgRDN = NULL;
746 ret = CryptEncodeObjectEx(dwEncoding, X509_NAME, &info,
748 ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
749 if (ret)
750 {
752 "Got unexpected encoding for empty name\n");
753 LocalFree(buf);
754 }
755
756 /* Test with bogus CERT_RDN */
757 info.cRDN = 1;
758 ret = CryptEncodeObjectEx(dwEncoding, X509_NAME, &info,
761 "Expected STATUS_ACCESS_VIOLATION, got %08lx\n", GetLastError());
762
763 /* Test with empty CERT_RDN */
764 rdn.cRDNAttr = 0;
765 rdn.rgRDNAttr = NULL;
766 info.cRDN = 1;
767 info.rgRDN = &rdn;
768 ret = CryptEncodeObjectEx(dwEncoding, X509_NAME, &info,
770 ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
771 if (ret)
772 {
773 ok(!memcmp(buf, emptyRDNs, sizeof(emptyRDNs)),
774 "Got unexpected encoding for empty RDN array\n");
775 LocalFree(buf);
776 }
777
778 /* Test with bogus attr array */
779 rdn.cRDNAttr = 1;
780 rdn.rgRDNAttr = NULL;
781 ret = CryptEncodeObjectEx(dwEncoding, X509_NAME, &info,
784 "Expected STATUS_ACCESS_VIOLATION, got %08lx\n", GetLastError());
785
786 /* Check with two CERT_RDN_ATTRs. Note DER encoding forces the order of
787 * the encoded attributes to be swapped.
788 */
789 attrs[0].pszObjId = oid_common_name;
791 attrs[0].Value.cbData = sizeof(commonName);
792 attrs[0].Value.pbData = (BYTE *)commonName;
793 attrs[1].pszObjId = oid_sur_name;
795 attrs[1].Value.cbData = sizeof(surName);
796 attrs[1].Value.pbData = (BYTE *)surName;
797 rdn.cRDNAttr = 2;
798 rdn.rgRDNAttr = attrs;
799 ret = CryptEncodeObjectEx(dwEncoding, X509_NAME, &info,
801 ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
802 if (ret)
803 {
804 ok(!memcmp(buf, twoRDNs, sizeof(twoRDNs)),
805 "Got unexpected encoding for two RDN array\n");
806 LocalFree(buf);
807 }
808 /* A name can be "encoded" with previously encoded RDN attrs. */
810 attrs[0].Value.pbData = (LPBYTE)twoRDNs;
811 attrs[0].Value.cbData = sizeof(twoRDNs);
812 rdn.cRDNAttr = 1;
813 ret = CryptEncodeObjectEx(dwEncoding, X509_NAME, &info,
815 ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
816 if (ret)
817 {
818 ok(size == sizeof(encodedTwoRDNs), "Unexpected size %ld\n", size);
820 "Unexpected value for re-encoded two RDN array\n");
821 LocalFree(buf);
822 }
823 /* CERT_RDN_ANY_TYPE is too vague for X509_NAMEs, check the return */
824 rdn.cRDNAttr = 1;
826 ret = CryptEncodeObjectEx(dwEncoding, X509_NAME, &info,
829 "Expected E_INVALIDARG, got %08lx\n", GetLastError());
830 /* Test a more complex name */
832 rdn.rgRDNAttr = rdnAttrs;
833 info.cRDN = 1;
834 info.rgRDN = &rdn;
835 buf = NULL;
836 size = 0;
839 ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
840 if (ret)
841 {
842 ok(size == sizeof(encodedRDNAttrs), "Wrong size %ld\n", size);
843 ok(!memcmp(buf, encodedRDNAttrs, size), "Unexpected value\n");
844 LocalFree(buf);
845 }
846}
847
848static const BYTE twoRDNsNoNull[] = {
849 0x30,0x21,0x31,0x1f,0x30,0x0b,0x06,0x03,0x55,0x04,0x04,0x13,0x04,0x4c,0x61,
850 0x6e,0x67,0x30,0x10,0x06,0x03,0x55,0x04,0x03,0x13,0x09,0x4a,0x75,0x61,0x6e,
851 0x20,0x4c,0x61,0x6e,0x67 };
852static const BYTE anyType[] = {
853 0x30,0x2f,0x31,0x2d,0x30,0x2b,0x06,0x03,0x55,0x04,0x03,0x1e,0x24,0x23,0x30,
854 0x21,0x31,0x0c,0x30,0x03,0x06,0x04,0x55,0x13,0x04,0x4c,0x05,0x6e,0x61,0x00,
855 0x67,0x11,0x30,0x03,0x06,0x04,0x55,0x13,0x03,0x4a,0x0a,0x61,0x75,0x20,0x6e,
856 0x61,0x4c,0x67,0x6e };
857
858static void test_encodeUnicodeName(DWORD dwEncoding)
859{
860 CERT_RDN_ATTR attrs[2];
861 CERT_RDN rdn;
863 static CHAR oid_common_name[] = szOID_COMMON_NAME,
864 oid_sur_name[] = szOID_SUR_NAME;
865 BYTE *buf = NULL;
866 DWORD size = 0;
867 BOOL ret;
868
872 "Expected STATUS_ACCESS_VIOLATION, got %08lx\n", GetLastError());
873
874 /* Test with empty CERT_NAME_INFO */
875 info.cRDN = 0;
876 info.rgRDN = NULL;
879 ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
880 if (ret)
881 {
883 "Got unexpected encoding for empty name\n");
884 LocalFree(buf);
885 }
886 /* Check with one CERT_RDN_ATTR, that has an invalid character for the
887 * encoding (the NULL).
888 */
889 attrs[0].pszObjId = oid_common_name;
891 attrs[0].Value.cbData = sizeof(L"Juan Lang");
892 attrs[0].Value.pbData = (BYTE *)L"Juan Lang";
893 rdn.cRDNAttr = 1;
894 rdn.rgRDNAttr = attrs;
895 info.cRDN = 1;
896 info.rgRDN = &rdn;
900 "Expected CRYPT_E_INVALID_PRINTABLE_STRING, got %08lx\n", GetLastError());
901 ok(size == 9, "Unexpected error index %08lx\n", size);
902 /* Check with two NULL-terminated CERT_RDN_ATTRs. Note DER encoding
903 * forces the order of the encoded attributes to be swapped.
904 */
905 attrs[0].pszObjId = oid_common_name;
907 attrs[0].Value.cbData = 0;
908 attrs[0].Value.pbData = (BYTE *)L"Juan Lang";
909 attrs[1].pszObjId = oid_sur_name;
911 attrs[1].Value.cbData = 0;
912 attrs[1].Value.pbData = (BYTE *)L"Lang";
913 rdn.cRDNAttr = 2;
914 rdn.rgRDNAttr = attrs;
915 info.cRDN = 1;
916 info.rgRDN = &rdn;
919 ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
920 if (ret)
921 {
923 "Got unexpected encoding for two RDN array\n");
924 LocalFree(buf);
925 }
926 /* A name can be "encoded" with previously encoded RDN attrs. */
928 attrs[0].Value.pbData = (LPBYTE)twoRDNs;
929 attrs[0].Value.cbData = sizeof(twoRDNs);
930 rdn.cRDNAttr = 1;
933 ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
934 if (ret)
935 {
936 ok(size == sizeof(encodedTwoRDNs), "Unexpected size %ld\n", size);
938 "Unexpected value for re-encoded two RDN array\n");
939 LocalFree(buf);
940 }
941 /* Unicode names infer the type for CERT_RDN_ANY_TYPE */
942 rdn.cRDNAttr = 1;
946 todo_wine ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
947 if (ret)
948 {
949 ok(size == sizeof(anyType), "Unexpected size %ld\n", size);
950 ok(!memcmp(buf, anyType, size), "Unexpected value\n");
951 LocalFree(buf);
952 }
953}
954
956 const CERT_NAME_VALUE *got)
957{
958 ok(got->dwValueType == expected->dwValueType,
959 "Expected string type %ld, got %ld\n", expected->dwValueType,
960 got->dwValueType);
961 ok(got->Value.cbData == expected->Value.cbData ||
962 got->Value.cbData == expected->Value.cbData - sizeof(WCHAR) /* Win8 */,
963 "String type %ld: unexpected data size, got %ld, expected %ld\n",
964 expected->dwValueType, got->Value.cbData, expected->Value.cbData);
965 if (got->Value.cbData && got->Value.pbData)
966 ok(!memcmp(got->Value.pbData, expected->Value.pbData,
967 min(got->Value.cbData, expected->Value.cbData)),
968 "String type %ld: unexpected value\n", expected->dwValueType);
969}
970
972 const CERT_RDN_ATTR *got)
973{
974 if (expected->pszObjId && *expected->pszObjId)
975 {
976 ok(got->pszObjId != NULL, "Expected OID %s, got NULL\n",
977 expected->pszObjId);
978 if (got->pszObjId)
979 {
980 ok(!strcmp(got->pszObjId, expected->pszObjId),
981 "Got unexpected OID %s, expected %s\n", got->pszObjId,
982 expected->pszObjId);
983 }
984 }
985 compareNameValues((const CERT_NAME_VALUE *)&expected->dwValueType,
986 (const CERT_NAME_VALUE *)&got->dwValueType);
987}
988
989static void compareRDNs(const CERT_RDN *expected, const CERT_RDN *got)
990{
991 ok(got->cRDNAttr == expected->cRDNAttr,
992 "Expected %ld RDN attrs, got %ld\n", expected->cRDNAttr, got->cRDNAttr);
993 if (got->cRDNAttr)
994 {
995 DWORD i;
996
997 for (i = 0; i < got->cRDNAttr; i++)
998 compareRDNAttrs(&expected->rgRDNAttr[i], &got->rgRDNAttr[i]);
999 }
1000}
1001
1003 const CERT_NAME_INFO *got)
1004{
1005 ok(got->cRDN == expected->cRDN, "Expected %ld RDNs, got %ld\n",
1006 expected->cRDN, got->cRDN);
1007 if (got->cRDN)
1008 {
1009 DWORD i;
1010
1011 for (i = 0; i < got->cRDN; i++)
1012 compareRDNs(&expected->rgRDN[i], &got->rgRDN[i]);
1013 }
1014}
1015
1016static const BYTE emptyIndefiniteSequence[] = { 0x30,0x80,0x00,0x00 };
1017static const BYTE twoRDNsExtraBytes[] = {
1018 0x30,0x23,0x31,0x21,0x30,0x0c,0x06,0x03,0x55,0x04,0x04,
1019 0x13,0x05,0x4c,0x61,0x6e,0x67,0x00,0x30,0x11,0x06,0x03,0x55,0x04,0x03,
1020 0x13,0x0a,0x4a,0x75,0x61,0x6e,0x20,0x4c,0x61,0x6e,0x67,0,0,0,0,0,0};
1021
1022static void test_decodeName(DWORD dwEncoding)
1023{
1024 BYTE *buf = NULL;
1025 DWORD bufSize = 0;
1026 BOOL ret;
1027 CERT_RDN rdn;
1028 CERT_NAME_INFO info = { 1, &rdn };
1029
1030 /* test empty name */
1031 bufSize = 0;
1033 emptySequence[1] + 2,
1035 &buf, &bufSize);
1036 ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
1037 /* Interestingly, in Windows, if cRDN is 0, rgRGN may not be NULL. My
1038 * decoder works the same way, so only test the count.
1039 */
1040 if (ret)
1041 {
1042 ok(bufSize == sizeof(CERT_NAME_INFO), "Wrong bufSize %ld\n", bufSize);
1043 ok(((CERT_NAME_INFO *)buf)->cRDN == 0,
1044 "Expected 0 RDNs in empty info, got %ld\n",
1045 ((CERT_NAME_INFO *)buf)->cRDN);
1046 LocalFree(buf);
1047 }
1048 /* test empty name with indefinite-length encoding */
1051 &buf, &bufSize);
1052 ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
1053 if (ret)
1054 {
1055 ok(bufSize == sizeof(CERT_NAME_INFO), "Wrong bufSize %ld\n", bufSize);
1056 ok(((CERT_NAME_INFO *)buf)->cRDN == 0,
1057 "Expected 0 RDNs in empty info, got %ld\n",
1058 ((CERT_NAME_INFO *)buf)->cRDN);
1059 LocalFree(buf);
1060 }
1061 /* test empty RDN */
1062 bufSize = 0;
1064 emptyRDNs[1] + 2,
1066 &buf, &bufSize);
1067 ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
1068 if (ret)
1069 {
1071
1072 ok(bufSize == sizeof(CERT_NAME_INFO) + sizeof(CERT_RDN) &&
1073 info->cRDN == 1 && info->rgRDN && info->rgRDN[0].cRDNAttr == 0,
1074 "Got unexpected value for empty RDN\n");
1075 LocalFree(buf);
1076 }
1077 /* test two RDN attrs */
1078 bufSize = 0;
1080 twoRDNs[1] + 2,
1082 &buf, &bufSize);
1083 ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
1084 if (ret)
1085 {
1086 static CHAR oid_sur_name[] = szOID_SUR_NAME,
1087 oid_common_name[] = szOID_COMMON_NAME;
1088
1089 CERT_RDN_ATTR attrs[] = {
1090 { oid_sur_name, CERT_RDN_PRINTABLE_STRING, { sizeof(surName),
1091 (BYTE *)surName } },
1092 { oid_common_name, CERT_RDN_PRINTABLE_STRING, { sizeof(commonName),
1093 (BYTE *)commonName } },
1094 };
1095
1096 rdn.cRDNAttr = ARRAY_SIZE(attrs);
1097 rdn.rgRDNAttr = attrs;
1099 LocalFree(buf);
1100 }
1101 /* test that two RDN attrs with extra bytes succeeds */
1102 bufSize = 0;
1104 sizeof(twoRDNsExtraBytes), 0, NULL, NULL, &bufSize);
1105 ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
1106 /* And, a slightly more complicated name */
1107 buf = NULL;
1108 bufSize = 0;
1111 ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
1112 if (ret)
1113 {
1117 LocalFree(buf);
1118 }
1119}
1120
1121static void test_decodeUnicodeName(DWORD dwEncoding)
1122{
1123 BYTE *buf = NULL;
1124 DWORD bufSize = 0;
1125 BOOL ret;
1126 CERT_RDN rdn;
1127 CERT_NAME_INFO info = { 1, &rdn };
1128
1129 /* test empty name */
1130 bufSize = 0;
1132 emptySequence[1] + 2,
1134 &buf, &bufSize);
1135 ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
1136 if (ret)
1137 {
1138 ok(bufSize == sizeof(CERT_NAME_INFO),
1139 "Got wrong bufSize %ld\n", bufSize);
1140 ok(((CERT_NAME_INFO *)buf)->cRDN == 0,
1141 "Expected 0 RDNs in empty info, got %ld\n",
1142 ((CERT_NAME_INFO *)buf)->cRDN);
1143 LocalFree(buf);
1144 }
1145 /* test empty RDN */
1146 bufSize = 0;
1148 emptyRDNs[1] + 2,
1150 &buf, &bufSize);
1151 ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
1152 if (ret)
1153 {
1155
1156 ok(bufSize == sizeof(CERT_NAME_INFO) + sizeof(CERT_RDN) &&
1157 info->cRDN == 1 && info->rgRDN && info->rgRDN[0].cRDNAttr == 0,
1158 "Got unexpected value for empty RDN\n");
1159 LocalFree(buf);
1160 }
1161 /* test two RDN attrs */
1162 bufSize = 0;
1164 sizeof(twoRDNsNoNull),
1166 &buf, &bufSize);
1167 ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
1168 if (ret)
1169 {
1170 static CHAR oid_sur_name[] = szOID_SUR_NAME,
1171 oid_common_name[] = szOID_COMMON_NAME;
1172
1173 CERT_RDN_ATTR attrs[] = {
1174 { oid_sur_name, CERT_RDN_PRINTABLE_STRING,
1175 { lstrlenW(L"Lang") * sizeof(WCHAR), (BYTE *)L"Lang" } },
1176 { oid_common_name, CERT_RDN_PRINTABLE_STRING,
1177 { lstrlenW(L"Juan Lang") * sizeof(WCHAR), (BYTE *)L"Juan Lang" } },
1178 };
1179
1180 rdn.cRDNAttr = ARRAY_SIZE(attrs);
1181 rdn.rgRDNAttr = attrs;
1183 LocalFree(buf);
1184 }
1185}
1186
1188{
1192};
1193
1194static const char bogusIA5[] = "\x80";
1195static const char bogusPrintable[] = "~";
1196static const char bogusNumeric[] = "A";
1197static const BYTE bin42[] = { 0x16,0x02,0x80,0x00 };
1198static const BYTE bin43[] = { 0x13,0x02,0x7e,0x00 };
1199static const BYTE bin44[] = { 0x12,0x02,0x41,0x00 };
1201 0x04,0x0a,0x4a,0x75,0x61,0x6e,0x20,0x4c,0x61,0x6e,0x67,0x00 };
1203 0x12,0x0a,0x4a,0x75,0x61,0x6e,0x20,0x4c,0x61,0x6e,0x67,0x00 };
1205 0x13,0x0a,0x4a,0x75,0x61,0x6e,0x20,0x4c,0x61,0x6e,0x67,0x00 };
1207 0x14,0x0a,0x4a,0x75,0x61,0x6e,0x20,0x4c,0x61,0x6e,0x67,0x00 };
1209 0x15,0x0a,0x4a,0x75,0x61,0x6e,0x20,0x4c,0x61,0x6e,0x67,0x00 };
1211 0x16,0x0a,0x4a,0x75,0x61,0x6e,0x20,0x4c,0x61,0x6e,0x67,0x00 };
1213 0x19,0x0a,0x4a,0x75,0x61,0x6e,0x20,0x4c,0x61,0x6e,0x67,0x00 };
1215 0x1a,0x0a,0x4a,0x75,0x61,0x6e,0x20,0x4c,0x61,0x6e,0x67,0x00 };
1217 0x1b,0x0a,0x4a,0x75,0x61,0x6e,0x20,0x4c,0x61,0x6e,0x67,0x00 };
1219 0x1e,0x14,0x00,0x4a,0x00,0x75,0x00,0x61,0x00,0x6e,0x00,0x20,0x00,0x4c,0x00,
1220 0x61,0x00,0x6e,0x00,0x67,0x00,0x00 };
1222 0x0c,0x0a,0x4a,0x75,0x61,0x6e,0x20,0x4c,0x61,0x6e,0x67,0x00 };
1223static char embedded_null[] = "foo\0com";
1225 0x16,0x07,0x66,0x6f,0x6f,0x00,0x63,0x6f,0x6d };
1226
1227static struct EncodedNameValue nameValues[] = {
1228 { { CERT_RDN_OCTET_STRING, { sizeof(commonName), (BYTE *)commonName } },
1230 { { CERT_RDN_NUMERIC_STRING, { sizeof(commonName), (BYTE *)commonName } },
1232 { { CERT_RDN_PRINTABLE_STRING, { sizeof(commonName), (BYTE *)commonName } },
1234 { { CERT_RDN_T61_STRING, { sizeof(commonName), (BYTE *)commonName } },
1236 { { CERT_RDN_VIDEOTEX_STRING, { sizeof(commonName), (BYTE *)commonName } },
1238 { { CERT_RDN_IA5_STRING, { sizeof(commonName), (BYTE *)commonName } },
1240 { { CERT_RDN_GRAPHIC_STRING, { sizeof(commonName), (BYTE *)commonName } },
1242 { { CERT_RDN_VISIBLE_STRING, { sizeof(commonName), (BYTE *)commonName } },
1244 { { CERT_RDN_GENERAL_STRING, { sizeof(commonName), (BYTE *)commonName } },
1246 { { CERT_RDN_BMP_STRING, { sizeof(L"Juan Lang"), (BYTE *)L"Juan Lang" } },
1248 { { CERT_RDN_UTF8_STRING, { sizeof(L"Juan Lang"), (BYTE *)L"Juan Lang" } },
1250 /* The following tests succeed under Windows, but really should fail,
1251 * they contain characters that are illegal for the encoding. I'm
1252 * including them to justify my lazy encoding.
1253 */
1254 { { CERT_RDN_IA5_STRING, { sizeof(bogusIA5), (BYTE *)bogusIA5 } }, bin42,
1255 sizeof(bin42) },
1257 (BYTE *)bogusPrintable } }, bin43, sizeof(bin43) },
1259 bin44, sizeof(bin44) },
1260};
1261/* This is kept separate, because the decoding doesn't return to the original
1262 * value.
1263 */
1265 { CERT_RDN_IA5_STRING, { sizeof(embedded_null) - 1, (BYTE *)embedded_null } },
1267
1268static void test_encodeNameValue(DWORD dwEncoding)
1269{
1270 BYTE *buf = NULL;
1271 DWORD size = 0, i;
1272 BOOL ret;
1273 CERT_NAME_VALUE value = { 0, { 0, NULL } };
1274
1275 value.dwValueType = CERT_RDN_ENCODED_BLOB;
1276 value.Value.pbData = printableCommonNameValue;
1277 value.Value.cbData = sizeof(printableCommonNameValue);
1280 ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
1281 if (ret)
1282 {
1283 ok(size == sizeof(printableCommonNameValue), "Unexpected size %ld\n",
1284 size);
1286 "Unexpected encoding\n");
1287 LocalFree(buf);
1288 }
1289 for (i = 0; i < ARRAY_SIZE(nameValues); i++)
1290 {
1293 ok(ret, "Type %ld: CryptEncodeObjectEx failed: %08lx\n",
1294 nameValues[i].value.dwValueType, GetLastError());
1295 if (ret)
1296 {
1298 "Expected size %ld, got %ld\n", nameValues[i].encodedSize, size);
1300 "Got unexpected encoding\n");
1301 LocalFree(buf);
1302 }
1303 }
1306 ok(ret, "Type %ld: CryptEncodeObjectEx failed: %08lx\n",
1307 embeddedNullNameValue.value.dwValueType, GetLastError());
1308 if (ret)
1309 {
1310 ok(size == embeddedNullNameValue.encodedSize,
1311 "Expected size %ld, got %ld\n", embeddedNullNameValue.encodedSize, size);
1313 "Got unexpected encoding\n");
1314 LocalFree(buf);
1315 }
1316}
1317
1318static void test_decodeNameValue(DWORD dwEncoding)
1319{
1320 int i;
1321 BYTE *buf = NULL;
1322 DWORD bufSize = 0;
1323 BOOL ret;
1324
1325 for (i = 0; i < ARRAY_SIZE(nameValues); i++)
1326 {
1330 &buf, &bufSize);
1331 ok(ret, "Value type %ld: CryptDecodeObjectEx failed: %08lx\n",
1332 nameValues[i].value.dwValueType, GetLastError());
1333 if (ret)
1334 {
1336 (const CERT_NAME_VALUE *)buf);
1337 LocalFree(buf);
1338 }
1339 }
1341 embeddedNullNameValue.encoded, embeddedNullNameValue.encodedSize,
1343 &buf, &bufSize);
1344 /* Some Windows versions disallow name values with embedded NULLs, so
1345 * either success or failure is acceptable.
1346 */
1347 if (ret)
1348 {
1349 CERT_NAME_VALUE rdnEncodedValue = { CERT_RDN_ENCODED_BLOB,
1350 { sizeof(ia5EmbeddedNull), ia5EmbeddedNull } };
1351 CERT_NAME_VALUE embeddedNullValue = { CERT_RDN_IA5_STRING,
1352 { sizeof(embedded_null) - 1, (BYTE *)embedded_null } };
1353 const CERT_NAME_VALUE *got = (const CERT_NAME_VALUE *)buf,
1354 *expected = NULL;
1355
1356 /* Some Windows versions decode name values with embedded NULLs,
1357 * others leave them encoded, even with the same version of crypt32.
1358 * Accept either.
1359 */
1362 "Expected CERT_RDN_ENCODED_BLOB or CERT_RDN_IA5_STRING, got %ld\n",
1363 got->dwValueType);
1365 expected = &rdnEncodedValue;
1366 else if (got->dwValueType == CERT_RDN_IA5_STRING)
1367 expected = &embeddedNullValue;
1368 if (expected)
1369 {
1370 ok(got->Value.cbData == expected->Value.cbData,
1371 "String type %ld: unexpected data size, got %ld, expected %ld\n",
1372 got->dwValueType, got->Value.cbData, expected->Value.cbData);
1373 if (got->Value.cbData && got->Value.pbData)
1374 ok(!memcmp(got->Value.pbData, expected->Value.pbData,
1375 min(got->Value.cbData, expected->Value.cbData)),
1376 "String type %ld: unexpected value\n", expected->dwValueType);
1377 }
1378 LocalFree(buf);
1379 }
1380}
1381
1382static const BYTE emptyURL[] = { 0x30, 0x02, 0x86, 0x00 };
1383static const BYTE emptyURLExtraBytes[] = { 0x30, 0x02, 0x86, 0x00, 0, 0, 0 };
1384static const WCHAR url[] = L"http://winehq.org";
1385static const BYTE encodedURL[] = { 0x30, 0x13, 0x86, 0x11, 0x68, 0x74,
1386 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x77, 0x69, 0x6e, 0x65, 0x68, 0x71, 0x2e,
1387 0x6f, 0x72, 0x67 };
1388static const WCHAR dnsName[] = L"winehq.org";
1389static const BYTE encodedDnsName[] = { 0x30, 0x0c, 0x82, 0x0a, 0x77, 0x69,
1390 0x6e, 0x65, 0x68, 0x71, 0x2e, 0x6f, 0x72, 0x67 };
1391static const BYTE localhost[] = { 127, 0, 0, 1 };
1392static const BYTE encodedIPAddr[] = { 0x30, 0x06, 0x87, 0x04, 0x7f, 0x00, 0x00,
1393 0x01 };
1394static const unsigned char encodedCommonName[] = {
1395 0x30,0x15,0x31,0x13,0x30,0x11,0x06,0x03,0x55,0x04,0x03,0x13,0x0a,'J','u','a','n',' ','L','a','n','g',0};
1396static const BYTE encodedOidName[] = { 0x30,0x04,0x88,0x02,0x2a,0x03 };
1397static const BYTE encodedDirectoryName[] = {
13980x30,0x19,0xa4,0x17,0x30,0x15,0x31,0x13,0x30,0x11,0x06,0x03,0x55,0x04,0x03,
13990x13,0x0a,0x4a,0x75,0x61,0x6e,0x20,0x4c,0x61,0x6e,0x67,0x00 };
1400
1401static void test_encodeAltName(DWORD dwEncoding)
1402{
1403 CERT_ALT_NAME_INFO info = { 0 };
1404 CERT_ALT_NAME_ENTRY entry = { 0 };
1405 BYTE *buf = NULL;
1406 DWORD size = 0;
1407 BOOL ret;
1408 char oid[] = "1.2.3";
1409
1410 /* Test with empty info */
1413 if (ret)
1414 {
1415 ok(size == sizeof(emptySequence), "Wrong size %ld\n", size);
1416 ok(!memcmp(buf, emptySequence, size), "Unexpected value\n");
1417 LocalFree(buf);
1418 }
1419 /* Test with an empty entry */
1420 info.cAltEntry = 1;
1421 info.rgAltEntry = &entry;
1425 "Expected E_INVALIDARG, got %08lx\n", GetLastError());
1426 /* Test with an empty pointer */
1427 entry.dwAltNameChoice = CERT_ALT_NAME_URL;
1430 if (ret)
1431 {
1432 ok(size == sizeof(emptyURL), "Wrong size %ld\n", size);
1433 ok(!memcmp(buf, emptyURL, size), "Unexpected value\n");
1434 LocalFree(buf);
1435 }
1436 /* Test with a real URL */
1437 entry.pwszURL = (LPWSTR)url;
1440 if (ret)
1441 {
1442 ok(size == sizeof(encodedURL), "Wrong size %ld\n", size);
1443 ok(!memcmp(buf, encodedURL, size), "Unexpected value\n");
1444 LocalFree(buf);
1445 }
1446 /* Now with the URL containing an invalid IA5 char */
1447 entry.pwszURL = (WCHAR *)L"http://\x226f\x575b";
1451 "Expected CRYPT_E_INVALID_IA5_STRING, got %08lx\n", GetLastError());
1452 /* The first invalid character is at index 7 */
1454 "Expected invalid char at index 7, got %ld\n",
1456 /* Now with the URL missing a scheme */
1457 entry.pwszURL = (LPWSTR)dnsName;
1460 ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
1461 if (ret)
1462 {
1463 /* This succeeds, but it shouldn't, so don't worry about conforming */
1464 LocalFree(buf);
1465 }
1466 /* Now with a DNS name */
1467 entry.dwAltNameChoice = CERT_ALT_NAME_DNS_NAME;
1470 ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
1471 if (ret)
1472 {
1473 ok(size == sizeof(encodedDnsName), "Wrong size %ld\n", size);
1474 ok(!memcmp(buf, encodedDnsName, size), "Unexpected value\n");
1475 LocalFree(buf);
1476 }
1477 /* Test with an IP address */
1478 entry.dwAltNameChoice = CERT_ALT_NAME_IP_ADDRESS;
1479 entry.IPAddress.cbData = sizeof(localhost);
1480 entry.IPAddress.pbData = (LPBYTE)localhost;
1483 if (ret)
1484 {
1485 ok(size == sizeof(encodedIPAddr), "Wrong size %ld\n", size);
1486 ok(!memcmp(buf, encodedIPAddr, size), "Unexpected value\n");
1487 LocalFree(buf);
1488 }
1489 /* Test with OID */
1490 entry.dwAltNameChoice = CERT_ALT_NAME_REGISTERED_ID;
1491 entry.pszRegisteredID = oid;
1494 if (ret)
1495 {
1496 ok(size == sizeof(encodedOidName), "Wrong size %ld\n", size);
1497 ok(!memcmp(buf, encodedOidName, size), "Unexpected value\n");
1498 LocalFree(buf);
1499 }
1500 /* Test with directory name */
1501 entry.dwAltNameChoice = CERT_ALT_NAME_DIRECTORY_NAME;
1502 entry.DirectoryName.cbData = sizeof(encodedCommonName);
1503 entry.DirectoryName.pbData = (LPBYTE)encodedCommonName;
1506 if (ret)
1507 {
1508 ok(size == sizeof(encodedDirectoryName), "Wrong size %ld\n", size);
1509 ok(!memcmp(buf, encodedDirectoryName, size), "Unexpected value\n");
1510 LocalFree(buf);
1511 }
1512}
1513
1514static void test_decodeAltName(DWORD dwEncoding)
1515{
1516 static const BYTE unimplementedType[] = { 0x30, 0x06, 0x85, 0x04, 0x7f,
1517 0x00, 0x00, 0x01 };
1518 static const BYTE bogusType[] = { 0x30, 0x06, 0x89, 0x04, 0x7f, 0x00, 0x00,
1519 0x01 };
1520 static const BYTE dns_embedded_null[] = { 0x30,0x10,0x82,0x0e,0x66,0x6f,
1521 0x6f,0x2e,0x63,0x6f,0x6d,0x00,0x62,0x61,0x64,0x64,0x69,0x65 };
1522 static const BYTE dns_embedded_bell[] = { 0x30,0x10,0x82,0x0e,0x66,0x6f,
1523 0x6f,0x2e,0x63,0x6f,0x6d,0x07,0x62,0x61,0x64,0x64,0x69,0x65 };
1524 static const BYTE url_embedded_null[] = { 0x30,0x10,0x86,0x0e,0x66,0x6f,
1525 0x6f,0x2e,0x63,0x6f,0x6d,0x00,0x62,0x61,0x64,0x64,0x69,0x65 };
1526 BOOL ret;
1527 BYTE *buf = NULL;
1528 DWORD bufSize = 0;
1530
1531 /* Test some bogus ones first */
1533 unimplementedType, sizeof(unimplementedType), CRYPT_DECODE_ALLOC_FLAG,
1534 NULL, &buf, &bufSize);
1536 "Expected CRYPT_E_ASN1_BADTAG, got %08lx\n", GetLastError());
1538 bogusType, sizeof(bogusType), CRYPT_DECODE_ALLOC_FLAG, NULL, &buf,
1539 &bufSize);
1541 "Expected CRYPT_E_ASN1_CORRUPT, got %08lx\n", GetLastError());
1542 /* Now expected cases */
1545 ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
1546 if (ret)
1547 {
1549
1550 ok(info->cAltEntry == 0, "Expected 0 entries, got %ld\n",
1551 info->cAltEntry);
1552 LocalFree(buf);
1553 }
1556 ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
1557 if (ret)
1558 {
1560
1561 ok(info->cAltEntry == 1, "Expected 1 entries, got %ld\n",
1562 info->cAltEntry);
1563 ok(info->rgAltEntry[0].dwAltNameChoice == CERT_ALT_NAME_URL,
1564 "Expected CERT_ALT_NAME_URL, got %ld\n",
1565 info->rgAltEntry[0].dwAltNameChoice);
1566 ok(info->rgAltEntry[0].pwszURL == NULL || !*info->rgAltEntry[0].pwszURL,
1567 "Expected empty URL\n");
1568 LocalFree(buf);
1569 }
1572 ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
1575 ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
1576 if (ret)
1577 {
1579
1580 ok(info->cAltEntry == 1, "Expected 1 entries, got %ld\n",
1581 info->cAltEntry);
1582 ok(info->rgAltEntry[0].dwAltNameChoice == CERT_ALT_NAME_URL,
1583 "Expected CERT_ALT_NAME_URL, got %ld\n",
1584 info->rgAltEntry[0].dwAltNameChoice);
1585 ok(!lstrcmpW(info->rgAltEntry[0].pwszURL, url), "Unexpected URL\n");
1586 LocalFree(buf);
1587 }
1590 ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
1591 if (ret)
1592 {
1594
1595 ok(info->cAltEntry == 1, "Expected 1 entries, got %ld\n",
1596 info->cAltEntry);
1597 ok(info->rgAltEntry[0].dwAltNameChoice == CERT_ALT_NAME_DNS_NAME,
1598 "Expected CERT_ALT_NAME_DNS_NAME, got %ld\n",
1599 info->rgAltEntry[0].dwAltNameChoice);
1600 ok(!lstrcmpW(info->rgAltEntry[0].pwszDNSName, dnsName),
1601 "Unexpected DNS name\n");
1602 LocalFree(buf);
1603 }
1606 ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
1607 if (ret)
1608 {
1610
1611 ok(info->cAltEntry == 1, "Expected 1 entries, got %ld\n",
1612 info->cAltEntry);
1613 ok(info->rgAltEntry[0].dwAltNameChoice == CERT_ALT_NAME_IP_ADDRESS,
1614 "Expected CERT_ALT_NAME_IP_ADDRESS, got %ld\n",
1615 info->rgAltEntry[0].dwAltNameChoice);
1616 ok(info->rgAltEntry[0].IPAddress.cbData == sizeof(localhost),
1617 "Unexpected IP address length %ld\n",
1618 info->rgAltEntry[0].IPAddress.cbData);
1619 ok(!memcmp(info->rgAltEntry[0].IPAddress.pbData, localhost,
1620 sizeof(localhost)), "Unexpected IP address value\n");
1621 LocalFree(buf);
1622 }
1625 ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
1626 if (ret)
1627 {
1629
1630 ok(info->cAltEntry == 1, "Expected 1 entries, got %ld\n",
1631 info->cAltEntry);
1632 ok(info->rgAltEntry[0].dwAltNameChoice == CERT_ALT_NAME_REGISTERED_ID,
1633 "Expected CERT_ALT_NAME_REGISTERED_ID, got %ld\n",
1634 info->rgAltEntry[0].dwAltNameChoice);
1635 ok(!strcmp(info->rgAltEntry[0].pszRegisteredID, "1.2.3"),
1636 "Expected OID 1.2.3, got %s\n", info->rgAltEntry[0].pszRegisteredID);
1637 LocalFree(buf);
1638 }
1642 ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
1643 if (ret)
1644 {
1646
1647 ok(info->cAltEntry == 1, "Expected 1 entries, got %ld\n",
1648 info->cAltEntry);
1649 ok(info->rgAltEntry[0].dwAltNameChoice == CERT_ALT_NAME_DIRECTORY_NAME,
1650 "Expected CERT_ALT_NAME_DIRECTORY_NAME, got %ld\n",
1651 info->rgAltEntry[0].dwAltNameChoice);
1652 ok(info->rgAltEntry[0].DirectoryName.cbData ==
1653 sizeof(encodedCommonName), "Unexpected directory name length %ld\n",
1654 info->rgAltEntry[0].DirectoryName.cbData);
1655 ok(!memcmp(info->rgAltEntry[0].DirectoryName.pbData,
1657 "Unexpected directory name value\n");
1658 LocalFree(buf);
1659 }
1661 dns_embedded_null, sizeof(dns_embedded_null), CRYPT_DECODE_ALLOC_FLAG,
1662 NULL, &buf, &bufSize);
1663#if defined(__REACTOS__) && defined(_M_AMD64)
1664 if ((GetVersion() & 0xFFFF) != 0x0006) // Next test fails on Vista x64
1665#endif
1666 ok(!ret, "expected failure\n");
1667 /* An embedded bell character is allowed, however. */
1669 dns_embedded_bell, sizeof(dns_embedded_bell), CRYPT_DECODE_ALLOC_FLAG,
1670 NULL, &buf, &bufSize);
1671 ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
1672 if (ret)
1673 {
1675
1676 ok(info->cAltEntry == 1, "Expected 1 entries, got %ld\n",
1677 info->cAltEntry);
1678 ok(info->rgAltEntry[0].dwAltNameChoice == CERT_ALT_NAME_DNS_NAME,
1679 "Expected CERT_ALT_NAME_DNS_NAME, got %ld\n",
1680 info->rgAltEntry[0].dwAltNameChoice);
1681 LocalFree(buf);
1682 }
1684 url_embedded_null, sizeof(dns_embedded_null), CRYPT_DECODE_ALLOC_FLAG,
1685 NULL, &buf, &bufSize);
1686#if defined(__REACTOS__) && defined(_M_AMD64)
1687 if ((GetVersion() & 0xFFFF) != 0x0006) // Next test fails on Vista x64
1688#endif
1689 ok(!ret, "expected failure\n");
1690}
1691
1693{
1698};
1699
1706 { CERT_RDN_IA5_STRING, L"http://\x226f\x575b", 7, CRYPT_E_INVALID_IA5_STRING },
1707};
1708
1710{
1714};
1715
1716static BYTE oneNumeric[] = { 0x12, 0x01, 0x31 };
1717static BYTE onePrintable[] = { 0x13, 0x01, 0x31 };
1718static BYTE oneTeletex[] = { 0x14, 0x01, 0x31 };
1719static BYTE oneVideotex[] = { 0x15, 0x01, 0x31 };
1720static BYTE oneIA5[] = { 0x16, 0x01, 0x31 };
1721static BYTE oneGraphic[] = { 0x19, 0x01, 0x31 };
1722static BYTE oneVisible[] = { 0x1a, 0x01, 0x31 };
1723static BYTE oneUniversal[] = { 0x1c, 0x04, 0x00, 0x00, 0x00, 0x31 };
1724static BYTE oneGeneral[] = { 0x1b, 0x01, 0x31 };
1725static BYTE oneBMP[] = { 0x1e, 0x02, 0x00, 0x31 };
1726static BYTE oneUTF8[] = { 0x0c, 0x01, 0x31 };
1727static BYTE nihongoT61[] = { 0x14,0x09,0x68,0x74,0x74,0x70,0x3a,0x2f,0x2f,0x6f,
1728 0x5b };
1729static BYTE nihongoGeneral[] = { 0x1b,0x09,0x68,0x74,0x74,0x70,0x3a,0x2f,0x2f,
1730 0x6f,0x5b };
1731static BYTE nihongoBMP[] = { 0x1e,0x12,0x00,0x68,0x00,0x74,0x00,0x74,0x00,0x70,
1732 0x00,0x3a,0x00,0x2f,0x00,0x2f,0x22,0x6f,0x57,0x5b };
1733static BYTE nihongoUTF8[] = { 0x0c,0x0d,0x68,0x74,0x74,0x70,0x3a,0x2f,0x2f,
1734 0xe2,0x89,0xaf,0xe5,0x9d,0x9b };
1735
1737 { CERT_RDN_NUMERIC_STRING, L"1", { sizeof(oneNumeric), oneNumeric } },
1739 { CERT_RDN_TELETEX_STRING, L"1", { sizeof(oneTeletex), oneTeletex } },
1740 { CERT_RDN_VIDEOTEX_STRING, L"1", { sizeof(oneVideotex), oneVideotex } },
1741 { CERT_RDN_IA5_STRING, L"1", { sizeof(oneIA5), oneIA5 } },
1742 { CERT_RDN_GRAPHIC_STRING, L"1", { sizeof(oneGraphic), oneGraphic } },
1743 { CERT_RDN_VISIBLE_STRING, L"1", { sizeof(oneVisible), oneVisible } },
1745 { CERT_RDN_GENERAL_STRING, L"1", { sizeof(oneGeneral), oneGeneral } },
1746 { CERT_RDN_BMP_STRING, L"1", { sizeof(oneBMP), oneBMP } },
1747 { CERT_RDN_UTF8_STRING, L"1", { sizeof(oneUTF8), oneUTF8 } },
1748 { CERT_RDN_BMP_STRING, L"http://\x226f\x575b", { sizeof(nihongoBMP), nihongoBMP } },
1749 { CERT_RDN_UTF8_STRING, L"http://\x226f\x575b", { sizeof(nihongoUTF8), nihongoUTF8 } },
1750};
1751
1753 { CERT_RDN_TELETEX_STRING, L"http://\x226f\x575b", { sizeof(nihongoT61), nihongoT61 } },
1754 { CERT_RDN_GENERAL_STRING, L"http://\x226f\x575b", { sizeof(nihongoGeneral), nihongoGeneral } },
1755};
1756
1757static void test_encodeUnicodeNameValue(DWORD dwEncoding)
1758{
1759 BYTE *buf = NULL;
1760 DWORD size = 0, i;
1761 BOOL ret;
1763
1767 "Expected STATUS_ACCESS_VIOLATION, got %08lx\n", GetLastError());
1768
1769 /* Have to have a string of some sort */
1770 value.dwValueType = 0; /* aka CERT_RDN_ANY_TYPE */
1771 value.Value.pbData = NULL;
1772 value.Value.cbData = 0;
1776 "Expected CRYPT_E_NOT_CHAR_STRING, got %08lx\n", GetLastError());
1777 value.dwValueType = CERT_RDN_ENCODED_BLOB;
1781 "Expected CRYPT_E_NOT_CHAR_STRING, got %08lx\n", GetLastError());
1782 value.dwValueType = CERT_RDN_ANY_TYPE;
1783 value.Value.pbData = (LPBYTE)L"1";
1787 "Expected CRYPT_E_NOT_CHAR_STRING, got %08lx\n", GetLastError());
1788 value.Value.cbData = sizeof(L"1");
1792 "Expected CRYPT_E_NOT_CHAR_STRING, got %08lx\n", GetLastError());
1793 /* An encoded string with specified length isn't good enough either */
1794 value.dwValueType = CERT_RDN_ENCODED_BLOB;
1795 value.Value.pbData = oneUniversal;
1796 value.Value.cbData = sizeof(oneUniversal);
1800 "Expected CRYPT_E_NOT_CHAR_STRING, got %08lx\n", GetLastError());
1801 /* More failure checking */
1802 value.Value.cbData = 0;
1803 for (i = 0; i < ARRAY_SIZE(unicodeErrors); i++)
1804 {
1805 value.Value.pbData = (LPBYTE)unicodeErrors[i].str;
1806 value.dwValueType = unicodeErrors[i].valueType;
1810 "Value type %ld: expected %08lx, got %08lx\n", value.dwValueType,
1811 unicodeErrors[i].error, GetLastError());
1812 ok(size == unicodeErrors[i].errorIndex,
1813 "Expected error index %ld, got %ld\n", unicodeErrors[i].errorIndex,
1814 size);
1815 }
1816 /* cbData can be zero if the string is NULL-terminated */
1817 value.Value.cbData = 0;
1818 for (i = 0; i < ARRAY_SIZE(unicodeResults); i++)
1819 {
1820 value.Value.pbData = (LPBYTE)unicodeResults[i].str;
1821 value.dwValueType = unicodeResults[i].valueType;
1824 ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
1825 if (ret)
1826 {
1828 "Value type %ld: expected size %ld, got %ld\n",
1829 value.dwValueType, unicodeResults[i].encoded.cbData, size);
1831 "Value type %ld: unexpected value\n", value.dwValueType);
1832 LocalFree(buf);
1833 }
1834 }
1835 /* These "encode," but they do so by truncating each unicode character
1836 * rather than properly encoding it. Kept separate from the proper results,
1837 * because the encoded forms won't decode to their original strings.
1838 */
1839 for (i = 0; i < ARRAY_SIZE(unicodeWeirdness); i++)
1840 {
1841 value.Value.pbData = (LPBYTE)unicodeWeirdness[i].str;
1842 value.dwValueType = unicodeWeirdness[i].valueType;
1845 ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
1846 if (ret)
1847 {
1849 "Value type %ld: expected size %ld, got %ld\n",
1850 value.dwValueType, unicodeWeirdness[i].encoded.cbData, size);
1852 "Value type %ld: unexpected value\n", value.dwValueType);
1853 LocalFree(buf);
1854 }
1855 }
1856}
1857
1858static void test_decodeUnicodeNameValue(DWORD dwEncoding)
1859{
1860 DWORD i;
1861
1862 for (i = 0; i < ARRAY_SIZE(unicodeResults); i++)
1863 {
1864 BYTE *buf = NULL;
1865 BOOL ret;
1866 DWORD size = 0;
1867
1869 unicodeResults[i].encoded.pbData, unicodeResults[i].encoded.cbData,
1871 ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
1872 if (ret && buf)
1873 {
1875
1876 ok(value->dwValueType == unicodeResults[i].valueType,
1877 "Expected value type %ld, got %ld\n", unicodeResults[i].valueType,
1878 value->dwValueType);
1879 ok(!wcsncmp((LPWSTR)value->Value.pbData, unicodeResults[i].str,
1880 value->Value.cbData / sizeof(WCHAR)),
1881 "Unexpected decoded value for index %ld (value type %ld)\n", i,
1882 unicodeResults[i].valueType);
1883 LocalFree(buf);
1884 }
1885 }
1886}
1887
1888static const unsigned char decoded_hi_octet[] = { 'h','i' };
1889static const unsigned char encoded_hi_octet[] = { ASN_OCTETSTRING,2,'h','i' };
1890static const unsigned char decoded_something_long_octet[] = {
1891 's','o','m','e','l','o','n','g',0xff,'s','t','r','i','n','g' };
1892static const unsigned char encoded_something_long_octet[] = {
1893 ASN_OCTETSTRING,15,'s','o','m','e','l','o','n','g',0xff,'s','t','r','i','n','g' };
1894static const unsigned char encoded_empty_octet[] = { ASN_OCTETSTRING,0 };
1895
1896static void test_encodeOctets(DWORD dwEncoding)
1897{
1899 DWORD i;
1900
1901 static const struct {
1902 const BYTE *decoded;
1904 const BYTE *encoded;
1905 UINT encoded_size;
1906 } tests[] = {
1907 {
1910 },{
1913 },{
1916 }
1917 };
1918
1919 for (i = 0; i < ARRAY_SIZE(tests); i++)
1920 {
1921 BYTE *buf = NULL;
1922 BOOL ret;
1923 DWORD bufSize = 0;
1924
1925 blob.cbData = tests[i].decoded_size;
1926 blob.pbData = (BYTE*)tests[i].decoded;
1929 ok(ret, "CryptEncodeObjectEx failed: %ld\n", GetLastError());
1930 if (ret)
1931 {
1932 ok(bufSize == tests[i].encoded_size, "[%lu] buf size %lu expected %u\n",
1933 i, bufSize, tests[i].encoded_size);
1934 ok(buf[0] == 4, "Got unexpected type %d for octet string (expected 4)\n", buf[0]);
1935 ok(buf[1] == tests[i].decoded_size, "[%lu] Got length %d, expected %d\n",
1936 i, buf[1], tests[i].decoded_size);
1937 ok(!memcmp(buf, tests[i].encoded, tests[i].encoded_size), "[%lu] Got unexpected value\n", i);
1938 LocalFree(buf);
1939 }
1940 }
1941}
1942
1943static const unsigned char encoded_constructed_hi_octet[] =
1944 { ASN_CONSTRUCTOR|ASN_OCTETSTRING,0x80, ASN_OCTETSTRING,2,'h','i', 0,0 };
1945static const unsigned char encoded_constructed_hi_octet2[] =
1946 { ASN_CONSTRUCTOR|ASN_OCTETSTRING,4, ASN_OCTETSTRING,2,'h','i', 1,2,3 };
1947static const unsigned char encoded_constructed_hi_octet3[] =
1949static const unsigned char encoded_constructed_hi_octet_invalid_end[] =
1950 { ASN_CONSTRUCTOR|ASN_OCTETSTRING,0x80, ASN_OCTETSTRING,2,'h','i', 0,1 };
1951
1952static void test_decodeOctets(DWORD dwEncoding)
1953{
1954 DWORD i;
1955
1956 static const struct {
1957 const BYTE *encoded;
1958 UINT encoded_size;
1959 const BYTE *decoded;
1961 DWORD error;
1962 } tests[] = {
1963 {
1966 },{
1969 },{
1972 },{
1975 },{
1978 },{
1981 },{
1984 },{
1987 },{
1990 }
1991 };
1992
1993 for (i = 0; i < ARRAY_SIZE(tests); i++)
1994 {
1995 BYTE *buf = NULL;
1996 BOOL ret;
1997 DWORD bufSize = 0;
1998
2000 tests[i].encoded, tests[i].encoded_size,
2002 if (tests[i].error)
2003 {
2004 ok(!ret && GetLastError() == tests[i].error,
2005 "[%lu] CryptDecodeObjectEx returned %x(%lx)\n", i, ret, GetLastError());
2006 continue;
2007 }
2008 ok(ret, "[%lu] CryptDecodeObjectEx failed: %08lx\n", i, GetLastError());
2010 "[%lu] Expected size >= %d, got %ld\n", i,
2011 (int)sizeof(CRYPT_DATA_BLOB) + tests[i].decoded_size, bufSize);
2012 ok(buf != NULL, "Expected allocated buffer\n");
2013 if (ret)
2014 {
2016
2017 ok (blob->cbData == tests[i].decoded_size, "[%lu] cbData = %lu\n", i, blob->cbData);
2018 if (blob->cbData)
2019 ok(!memcmp(blob->pbData, tests[i].decoded, blob->cbData),
2020 "Unexpected value\n");
2021 LocalFree(buf);
2022 }
2023 }
2024}
2025
2026static const BYTE bytesToEncode[] = { 0xff, 0xff };
2027
2029{
2034};
2035
2036static const unsigned char bin52[] = { 0x03,0x03,0x00,0xff,0xff };
2037static const unsigned char bin53[] = { 0xff,0xff };
2038static const unsigned char bin54[] = { 0x03,0x03,0x01,0xff,0xfe };
2039static const unsigned char bin55[] = { 0xff,0xfe };
2040static const unsigned char bin56[] = { 0x03,0x02,0x01,0xfe };
2041static const unsigned char bin57[] = { 0xfe };
2042
2043static const struct encodedBits bits[] = {
2044 /* normal test cases */
2045 { 0, bin52, 2, bin53 },
2046 { 1, bin54, 2, bin55 },
2047 /* strange test case, showing cUnusedBits >= 8 is allowed */
2048 { 9, bin56, 1, bin57 },
2049};
2050
2051static void test_encodeBits(DWORD dwEncoding)
2052{
2053 DWORD i;
2054
2055 for (i = 0; i < ARRAY_SIZE(bits); i++)
2056 {
2058 BOOL ret;
2059 BYTE *buf = NULL;
2060 DWORD bufSize = 0;
2061
2062 blob.cbData = sizeof(bytesToEncode);
2063 blob.pbData = (BYTE *)bytesToEncode;
2064 blob.cUnusedBits = bits[i].cUnusedBits;
2065 ret = CryptEncodeObjectEx(dwEncoding, X509_BITS, &blob,
2067 ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
2068 if (ret)
2069 {
2070 ok(bufSize == bits[i].encoded[1] + 2,
2071 "%ld: Got unexpected size %ld, expected %d\n", i, bufSize,
2072 bits[i].encoded[1] + 2);
2073 ok(!memcmp(buf, bits[i].encoded, bits[i].encoded[1] + 2),
2074 "%ld: Unexpected value\n", i);
2075 LocalFree(buf);
2076 }
2077 }
2078}
2079
2080static void test_decodeBits(DWORD dwEncoding)
2081{
2082 static const BYTE ber[] = "\x03\x02\x01\xff";
2083 static const BYTE berDecoded = 0xfe;
2084 DWORD i;
2085 BOOL ret;
2086 BYTE *buf = NULL;
2087 DWORD bufSize = 0;
2088
2089 /* normal cases */
2090 for (i = 0; i < ARRAY_SIZE(bits); i++)
2091 {
2094 &bufSize);
2095 ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
2096 if (ret)
2097 {
2099
2100 ok(bufSize >= sizeof(CRYPT_BIT_BLOB) + bits[i].cbDecoded,
2101 "Got unexpected size %ld\n", bufSize);
2102 blob = (CRYPT_BIT_BLOB *)buf;
2103 ok(blob->cbData == bits[i].cbDecoded,
2104 "Got unexpected length %ld, expected %ld\n", blob->cbData,
2105 bits[i].cbDecoded);
2106 if (blob->cbData && bits[i].cbDecoded)
2107 ok(!memcmp(blob->pbData, bits[i].decoded, bits[i].cbDecoded),
2108 "Unexpected value\n");
2109 LocalFree(buf);
2110 }
2111 }
2112 /* special case: check that something that's valid in BER but not in DER
2113 * decodes successfully
2114 */
2115 ret = CryptDecodeObjectEx(dwEncoding, X509_BITS, ber, ber[1] + 2,
2117 ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
2118 if (ret)
2119 {
2121
2122 ok(bufSize >= sizeof(CRYPT_BIT_BLOB) + sizeof(berDecoded),
2123 "Got unexpected size %ld\n", bufSize);
2124 blob = (CRYPT_BIT_BLOB *)buf;
2125 ok(blob->cbData == sizeof(berDecoded),
2126 "Got unexpected length %ld\n", blob->cbData);
2127 if (blob->cbData)
2128 ok(*blob->pbData == berDecoded, "Unexpected value\n");
2129 LocalFree(buf);
2130 }
2131}
2132
2134{
2137};
2138
2139static const unsigned char bin59[] = { 0x30,0x00 };
2140static const unsigned char bin60[] = { 0x30,0x03,0x01,0x01,0xff };
2141static const unsigned char bin61[] = { 0x30,0x03,0x02,0x01,0x00 };
2142static const unsigned char bin62[] = { 0x30,0x06,0x01,0x01,0xff,0x02,0x01,0x01 };
2143static const struct Constraints2 constraints2[] = {
2144 /* empty constraints */
2145 { { FALSE, FALSE, 0}, bin59 },
2146 /* can be a CA */
2147 { { TRUE, FALSE, 0}, bin60 },
2148 /* has path length constraints set (MSDN implies fCA needs to be TRUE as well,
2149 * but that's not the case
2150 */
2151 { { FALSE, TRUE, 0}, bin61 },
2152 /* can be a CA and has path length constraints set */
2153 { { TRUE, TRUE, 1}, bin62 },
2154};
2155
2156static const BYTE emptyConstraint[] = { 0x30, 0x03, 0x03, 0x01, 0x00 };
2157static const BYTE encodedDomainName[] = { 0x30, 0x2b, 0x31, 0x29, 0x30, 0x11,
2158 0x06, 0x0a, 0x09, 0x92, 0x26, 0x89, 0x93, 0xf2, 0x2c, 0x64, 0x01, 0x19, 0x16,
2159 0x03, 0x6f, 0x72, 0x67, 0x30, 0x14, 0x06, 0x0a, 0x09, 0x92, 0x26, 0x89, 0x93,
2160 0xf2, 0x2c, 0x64, 0x01, 0x19, 0x16, 0x06, 0x77, 0x69, 0x6e, 0x65, 0x68, 0x71 };
2161static const BYTE constraintWithDomainName[] = { 0x30, 0x32, 0x03, 0x01, 0x00,
2162 0x30, 0x2d, 0x30, 0x2b, 0x31, 0x29, 0x30, 0x11, 0x06, 0x0a, 0x09, 0x92, 0x26,
2163 0x89, 0x93, 0xf2, 0x2c, 0x64, 0x01, 0x19, 0x16, 0x03, 0x6f, 0x72, 0x67, 0x30,
2164 0x14, 0x06, 0x0a, 0x09, 0x92, 0x26, 0x89, 0x93, 0xf2, 0x2c, 0x64, 0x01, 0x19,
2165 0x16, 0x06, 0x77, 0x69, 0x6e, 0x65, 0x68, 0x71 };
2166
2167static void test_encodeBasicConstraints(DWORD dwEncoding)
2168{
2169 DWORD i, bufSize = 0;
2171 CERT_NAME_BLOB nameBlob = { sizeof(encodedDomainName),
2173 BOOL ret;
2174 BYTE *buf = NULL;
2175
2176 /* First test with the simpler info2 */
2177 for (i = 0; i < ARRAY_SIZE(constraints2); i++)
2178 {
2181 &bufSize);
2182 ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
2183 if (ret)
2184 {
2185 ok(bufSize == constraints2[i].encoded[1] + 2,
2186 "Expected %d bytes, got %ld\n", constraints2[i].encoded[1] + 2,
2187 bufSize);
2189 constraints2[i].encoded[1] + 2), "Unexpected value\n");
2190 LocalFree(buf);
2191 }
2192 }
2193 /* Now test with more complex basic constraints */
2194 info.SubjectType.cbData = 0;
2195 info.fPathLenConstraint = FALSE;
2196 info.cSubtreesConstraint = 0;
2199 ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
2200 if (ret)
2201 {
2202 ok(bufSize == sizeof(emptyConstraint), "Wrong size %ld\n", bufSize);
2204 "Unexpected value\n");
2205 LocalFree(buf);
2206 }
2207 /* None of the certs I examined had any subtree constraint, but I test one
2208 * anyway just in case.
2209 */
2210 info.cSubtreesConstraint = 1;
2211 info.rgSubtreesConstraint = &nameBlob;
2214 ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
2215 if (ret)
2216 {
2217 ok(bufSize == sizeof(constraintWithDomainName), "Wrong size %ld\n", bufSize);
2219 sizeof(constraintWithDomainName)), "Unexpected value\n");
2220 LocalFree(buf);
2221 }
2222 /* FIXME: test encoding with subject type. */
2223}
2224
2225static const unsigned char bin63[] = { 0x30,0x06,0x01,0x01,0x01,0x02,0x01,0x01 };
2226
2227static void test_decodeBasicConstraints(DWORD dwEncoding)
2228{
2229 static const BYTE inverted[] = { 0x30, 0x06, 0x02, 0x01, 0x01, 0x01, 0x01,
2230 0xff };
2231 static const struct Constraints2 badBool = { { TRUE, TRUE, 1 }, bin63 };
2232 DWORD i;
2233 BOOL ret;
2234 BYTE *buf = NULL;
2235 DWORD bufSize = 0;
2236
2237 /* First test with simpler info2 */
2238 for (i = 0; i < ARRAY_SIZE(constraints2); i++)
2239 {
2243 ok(ret, "CryptDecodeObjectEx failed for item %ld: %08lx\n", i,
2244 GetLastError());
2245 if (ret)
2246 {
2249
2250 ok(!memcmp(info, &constraints2[i].info, sizeof(*info)),
2251 "Unexpected value for item %ld\n", i);
2252 LocalFree(buf);
2253 }
2254 }
2255 /* Check with the order of encoded elements inverted */
2256 buf = (PBYTE)1;
2258 inverted, inverted[1] + 2, CRYPT_DECODE_ALLOC_FLAG, NULL, &buf,
2259 &bufSize);
2261 "Expected CRYPT_E_ASN1_CORRUPT, got %08lx\n", GetLastError());
2262 ok(!buf, "Expected buf to be set to NULL\n");
2263 /* Check with a non-DER bool */
2265 badBool.encoded, badBool.encoded[1] + 2, CRYPT_DECODE_ALLOC_FLAG, NULL,
2266 &buf, &bufSize);
2267 ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
2268 if (ret)
2269 {
2272
2273 ok(!memcmp(info, &badBool.info, sizeof(*info)), "Unexpected value\n");
2274 LocalFree(buf);
2275 }
2276 /* Check with a non-basic constraints value */
2281 "Expected CRYPT_E_ASN1_CORRUPT, got %08lx\n", GetLastError());
2282 /* Now check with the more complex CERT_BASIC_CONSTRAINTS_INFO */
2285 &buf, &bufSize);
2286 ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
2287 if (ret)
2288 {
2290
2291 ok(info->SubjectType.cbData == 0, "Expected no subject type\n");
2292 ok(!info->fPathLenConstraint, "Expected no path length constraint\n");
2293 ok(info->cSubtreesConstraint == 0, "Expected no subtree constraints\n");
2294 LocalFree(buf);
2295 }
2299 ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
2300 if (ret)
2301 {
2303
2304 ok(info->SubjectType.cbData == 0, "Expected no subject type\n");
2305 ok(!info->fPathLenConstraint, "Expected no path length constraint\n");
2306 ok(info->cSubtreesConstraint == 1, "Expected a subtree constraint\n");
2307 if (info->cSubtreesConstraint && info->rgSubtreesConstraint)
2308 {
2309 ok(info->rgSubtreesConstraint[0].cbData ==
2310 sizeof(encodedDomainName), "Wrong size %ld\n",
2311 info->rgSubtreesConstraint[0].cbData);
2312 ok(!memcmp(info->rgSubtreesConstraint[0].pbData, encodedDomainName,
2313 sizeof(encodedDomainName)), "Unexpected value\n");
2314 }
2315 LocalFree(buf);
2316 }
2317}
2318
2319/* These are terrible public keys of course, I'm just testing encoding */
2320static const BYTE modulus1[] = { 0,0,0,1,1,1,1,1 };
2321static const BYTE modulus2[] = { 1,1,1,1,1,0,0,0 };
2322static const BYTE modulus3[] = { 0x80,1,1,1,1,0,0,0 };
2323static const BYTE modulus4[] = { 1,1,1,1,1,0,0,0x80 };
2324static const BYTE mod1_encoded[] = { 0x30,0x0f,0x02,0x08,0x01,0x01,0x01,0x01,0x01,0x00,0x00,0x00,0x02,0x03,0x02,0x00,0x01 };
2325static const BYTE mod2_encoded[] = { 0x30,0x0c,0x02,0x05,0x01,0x01,0x01,0x01,0x01,0x02,0x03,0x02,0x00,0x01 };
2326static const BYTE mod3_encoded[] = { 0x30,0x0c,0x02,0x05,0x01,0x01,0x01,0x01,0x80,0x02,0x03,0x02,0x00,0x01 };
2327static const BYTE mod4_encoded[] = { 0x30,0x10,0x02,0x09,0x00,0x80,0x00,0x00,0x01,0x01,0x01,0x01,0x01,0x02,0x03,0x02,0x00,0x01 };
2328
2330{
2335};
2336
2337static const struct EncodedRSAPubKey rsaPubKeys[] = {
2338 { modulus1, sizeof(modulus1), mod1_encoded, sizeof(modulus1) },
2339 { modulus2, sizeof(modulus2), mod2_encoded, 5 },
2340 { modulus3, sizeof(modulus3), mod3_encoded, 5 },
2341 { modulus4, sizeof(modulus4), mod4_encoded, 8 },
2342};
2343
2344static void test_encodeRsaPublicKey(DWORD dwEncoding)
2345{
2346 BYTE toEncode[sizeof(BLOBHEADER) + sizeof(RSAPUBKEY) + sizeof(modulus1)];
2347 BLOBHEADER *hdr = (BLOBHEADER *)toEncode;
2348 RSAPUBKEY *rsaPubKey = (RSAPUBKEY *)(toEncode + sizeof(BLOBHEADER));
2349 BOOL ret;
2350 BYTE *buf = NULL;
2351 DWORD bufSize = 0, i;
2352
2353 /* Try with a bogus blob type */
2354 hdr->bType = 2;
2355 hdr->bVersion = CUR_BLOB_VERSION;
2356 hdr->reserved = 0;
2357 hdr->aiKeyAlg = CALG_RSA_KEYX;
2358 rsaPubKey->magic = 0x31415352;
2359 rsaPubKey->bitlen = sizeof(modulus1) * 8;
2360 rsaPubKey->pubexp = 131073;
2361 memcpy(toEncode + sizeof(BLOBHEADER) + sizeof(RSAPUBKEY), modulus1,
2362 sizeof(modulus1));
2363
2365 toEncode, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &bufSize);
2367 "Expected E_INVALIDARG, got %08lx\n", GetLastError());
2368 /* Now with a bogus reserved field */
2369 hdr->bType = PUBLICKEYBLOB;
2370 hdr->reserved = 1;
2372 toEncode, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &bufSize);
2373 if (ret)
2374 {
2375 ok(bufSize == rsaPubKeys[0].encoded[1] + 2,
2376 "Expected size %d, got %ld\n", rsaPubKeys[0].encoded[1] + 2, bufSize);
2377 ok(!memcmp(buf, rsaPubKeys[0].encoded, bufSize), "Unexpected value\n");
2378 LocalFree(buf);
2379 }
2380 /* Now with a bogus blob version */
2381 hdr->reserved = 0;
2382 hdr->bVersion = 0;
2384 toEncode, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &bufSize);
2385 if (ret)
2386 {
2387 ok(bufSize == rsaPubKeys[0].encoded[1] + 2,
2388 "Expected size %d, got %ld\n", rsaPubKeys[0].encoded[1] + 2, bufSize);
2389 ok(!memcmp(buf, rsaPubKeys[0].encoded, bufSize), "Unexpected value\n");
2390 LocalFree(buf);
2391 }
2392 /* And with a bogus alg ID */
2393 hdr->bVersion = CUR_BLOB_VERSION;
2394 hdr->aiKeyAlg = CALG_DES;
2396 toEncode, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &bufSize);
2397 if (ret)
2398 {
2399 ok(bufSize == rsaPubKeys[0].encoded[1] + 2,
2400 "Expected size %d, got %ld\n", rsaPubKeys[0].encoded[1] + 2, bufSize);
2401 ok(!memcmp(buf, rsaPubKeys[0].encoded, bufSize), "Unexpected value\n");
2402 LocalFree(buf);
2403 }
2404 /* Check a couple of RSA-related OIDs */
2405 hdr->aiKeyAlg = CALG_RSA_KEYX;
2407 toEncode, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &bufSize);
2409 "Expected ERROR_FILE_NOT_FOUND, got %08lx\n", GetLastError());
2411 toEncode, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &bufSize);
2413 "Expected ERROR_FILE_NOT_FOUND, got %08lx\n", GetLastError());
2414 /* Finally, all valid */
2415 hdr->aiKeyAlg = CALG_RSA_KEYX;
2416 for (i = 0; i < ARRAY_SIZE(rsaPubKeys); i++)
2417 {
2418 memcpy(toEncode + sizeof(BLOBHEADER) + sizeof(RSAPUBKEY),
2421 toEncode, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &bufSize);
2422 ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
2423 if (ret)
2424 {
2425 ok(bufSize == rsaPubKeys[i].encoded[1] + 2,
2426 "Expected size %d, got %ld\n", rsaPubKeys[i].encoded[1] + 2,
2427 bufSize);
2429 "Unexpected value\n");
2430 LocalFree(buf);
2431 }
2432 }
2433}
2434
2435static void test_decodeRsaPublicKey(DWORD dwEncoding)
2436{
2437 DWORD i;
2438 LPBYTE buf = NULL;
2439 DWORD bufSize = 0;
2440 BOOL ret;
2441
2442 /* Try with a bad length */
2447 "Expected CRYPT_E_ASN1_EOD, got %08lx\n", GetLastError());
2448 /* Try with a couple of RSA-related OIDs */
2450 rsaPubKeys[0].encoded, rsaPubKeys[0].encoded[1] + 2,
2453 "Expected ERROR_FILE_NOT_FOUND, got %08lx\n", GetLastError());
2455 rsaPubKeys[0].encoded, rsaPubKeys[0].encoded[1] + 2,
2458 "Expected ERROR_FILE_NOT_FOUND, got %08lx\n", GetLastError());
2459 /* Now try success cases */
2460 for (i = 0; i < ARRAY_SIZE(rsaPubKeys); i++)
2461 {
2462 bufSize = 0;
2466 ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
2467 if (ret)
2468 {
2470 RSAPUBKEY *rsaPubKey = (RSAPUBKEY *)(buf + sizeof(BLOBHEADER));
2471
2472 ok(bufSize >= sizeof(BLOBHEADER) + sizeof(RSAPUBKEY) +
2474 "Wrong size %ld\n", bufSize);
2475 ok(hdr->bType == PUBLICKEYBLOB,
2476 "Expected type PUBLICKEYBLOB (%d), got %d\n", PUBLICKEYBLOB,
2477 hdr->bType);
2478 ok(hdr->bVersion == CUR_BLOB_VERSION,
2479 "Expected version CUR_BLOB_VERSION (%d), got %d\n",
2480 CUR_BLOB_VERSION, hdr->bVersion);
2481 ok(hdr->reserved == 0, "Expected reserved 0, got %d\n",
2482 hdr->reserved);
2483 ok(hdr->aiKeyAlg == CALG_RSA_KEYX,
2484 "Expected CALG_RSA_KEYX, got %08x\n", hdr->aiKeyAlg);
2485 ok(rsaPubKey->magic == 0x31415352,
2486 "Expected magic RSA1, got %08lx\n", rsaPubKey->magic);
2487 ok(rsaPubKey->bitlen == rsaPubKeys[i].decodedModulusLen * 8,
2488 "Wrong bit len %ld\n", rsaPubKey->bitlen);
2489 ok(rsaPubKey->pubexp == 131073, "Expected pubexp 131073, got %ld\n",
2490 rsaPubKey->pubexp);
2491 ok(!memcmp(buf + sizeof(BLOBHEADER) + sizeof(RSAPUBKEY),
2493 "Unexpected modulus\n");
2494 LocalFree(buf);
2495 }
2496 }
2497}
2498
2500{
2501 BYTE toEncode[sizeof(BCRYPT_RSAKEY_BLOB) + sizeof(DWORD) + sizeof(modulus1)];
2503 BOOL ret;
2504 BYTE *buf = NULL;
2505 DWORD bufSize = 0, i;
2506 BYTE pubexp[] = {0x01,0x00,0x02,0x00}; /* 131073 */
2507
2508 /* Verify that the Magic value doesn't matter */
2509 hdr->Magic = 1;
2510 hdr->BitLength = sizeof(modulus1) * 8;
2511 hdr->cbPublicExp = sizeof(pubexp);
2512 hdr->cbModulus = sizeof(modulus1);
2513 hdr->cbPrime1 = 0;
2514 hdr->cbPrime2 = 0;
2515
2516 /* CNG_RSA_PUBLIC_KEY_BLOB stores the exponent and modulus
2517 * in big-endian format, so we need convert them
2518 * from little-endian format before encoding
2519 */
2520 CRYPT_CopyReversed(toEncode + sizeof(BCRYPT_RSAKEY_BLOB), pubexp, sizeof(pubexp));
2521 CRYPT_CopyReversed(toEncode + sizeof(BCRYPT_RSAKEY_BLOB) + sizeof(pubexp), modulus1, sizeof(modulus1));
2522
2524 toEncode, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &bufSize);
2525 ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
2526
2527 /* Finally, all valid */
2528 hdr->Magic = BCRYPT_RSAPUBLIC_MAGIC;
2529 for (i = 0; i < ARRAY_SIZE(rsaPubKeys); i++)
2530 {
2531 hdr->BitLength = rsaPubKeys[i].modulusLen * 8;
2532 hdr->cbModulus = rsaPubKeys[i].modulusLen;
2533
2534 CRYPT_CopyReversed(toEncode + sizeof(BCRYPT_RSAKEY_BLOB) + sizeof(DWORD),
2536
2538 toEncode, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &bufSize);
2539 ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
2540 if (ret)
2541 {
2542 ok(bufSize == rsaPubKeys[i].encoded[1] + 2,
2543 "Expected size %d, got %ld\n", rsaPubKeys[i].encoded[1] + 2,
2544 bufSize);
2546 "Unexpected value\n");
2547 LocalFree(buf);
2548 }
2549 }
2550}
2551
2553{
2554 DWORD i;
2555 LPBYTE buf = NULL;
2556 LPBYTE leModulus = NULL;
2557 DWORD bufSize = 0;
2558 BOOL ret;
2559
2560 /* Try with a bad length */
2565 "Expected CRYPT_E_ASN1_EOD, got %08lx\n", GetLastError());
2566 /* Now try success cases */
2567 for (i = 0; i < ARRAY_SIZE(rsaPubKeys); i++)
2568 {
2569 bufSize = 0;
2573 ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
2574 if (ret)
2575 {
2577 BYTE pubexp[] = {0xff,0xff,0xff,0xcc}, pubexp_expected[] = {0x01,0x00,0x02};
2578 /* CNG_RSA_PUBLIC_KEY_BLOB stores the exponent
2579 * in big-endian format, so we need to convert it to little-endian
2580 */
2581 CRYPT_CopyReversed((BYTE *)&pubexp, buf + sizeof(BCRYPT_RSAKEY_BLOB), hdr->cbPublicExp);
2582 ok(bufSize >= sizeof(BCRYPT_RSAKEY_BLOB) +
2584 "Wrong size %ld\n", bufSize);
2585 ok(hdr->Magic == BCRYPT_RSAPUBLIC_MAGIC,
2586 "Expected magic BCRYPT_RSAPUBLIC_MAGIC (%d), got %ld\n", BCRYPT_RSAPUBLIC_MAGIC,
2587 hdr->Magic);
2588 ok(hdr->BitLength == rsaPubKeys[i].decodedModulusLen * 8,
2589 "Wrong bit len %ld\n", hdr->BitLength);
2590 /* Windows decodes the exponent to 3 bytes, since it will fit.
2591 * Our implementation currently unconditionally decodes to a DWORD (4 bytes)
2592 */
2593 ok(hdr->cbPublicExp == 3, "Expected cbPublicExp 3, got %ld\n", hdr->cbPublicExp);
2594 ok(hdr->cbModulus == rsaPubKeys[i].decodedModulusLen,
2595 "Wrong modulus len %ld\n", hdr->cbModulus);
2596 ok(hdr->cbPrime1 == 0,"Wrong cbPrime1 %ld\n", hdr->cbPrime1);
2597 ok(hdr->cbPrime2 == 0,"Wrong cbPrime2 %ld\n", hdr->cbPrime2);
2598 ok(!memcmp(pubexp, pubexp_expected, sizeof(pubexp_expected)), "Wrong exponent\n");
2599 ok(pubexp[3] == 0xcc, "Got %02x\n", pubexp[3]);
2600
2601 leModulus = malloc(hdr->cbModulus);
2602 /*
2603 * CNG_RSA_PUBLIC_KEY_BLOB stores the modulus in big-endian format,
2604 * so we need to convert it to little-endian
2605 */
2606 CRYPT_CopyReversed(leModulus, buf + sizeof(BCRYPT_RSAKEY_BLOB) + hdr->cbPublicExp,
2607 hdr->cbModulus);
2608 ok(!memcmp(leModulus,
2610 "Unexpected modulus\n");
2611 LocalFree(buf);
2612 free(leModulus);
2613 }
2614 }
2615}
2616
2617static const BYTE intSequence[] = { 0x30, 0x1b, 0x02, 0x01, 0x01, 0x02, 0x01,
2618 0x7f, 0x02, 0x02, 0x00, 0x80, 0x02, 0x02, 0x01, 0x00, 0x02, 0x01, 0x80, 0x02,
2619 0x02, 0xff, 0x7f, 0x02, 0x04, 0xba, 0xdd, 0xf0, 0x0d };
2620
2621static const BYTE mixedSequence[] = { 0x30, 0x27, 0x17, 0x0d, 0x30, 0x35, 0x30,
2622 0x36, 0x30, 0x36, 0x31, 0x36, 0x31, 0x30, 0x30, 0x30, 0x5a, 0x02, 0x01, 0x7f,
2623 0x02, 0x02, 0x00, 0x80, 0x02, 0x02, 0x01, 0x00, 0x02, 0x01, 0x80, 0x02, 0x02,
2624 0xff, 0x7f, 0x02, 0x04, 0xba, 0xdd, 0xf0, 0x0d };
2625
2626static void test_encodeSequenceOfAny(DWORD dwEncoding)
2627{
2630 DWORD i;
2631 BOOL ret;
2632 BYTE *buf = NULL;
2633 DWORD bufSize = 0;
2634
2635 /* Encode a homogeneous sequence */
2636 for (i = 0; i < ARRAY_SIZE(ints); i++)
2637 {
2638 blobs[i].cbData = ints[i].encoded[1] + 2;
2639 blobs[i].pbData = (BYTE *)ints[i].encoded;
2640 }
2641 seq.cValue = ARRAY_SIZE(ints);
2642 seq.rgValue = blobs;
2643
2644 ret = CryptEncodeObjectEx(dwEncoding, X509_SEQUENCE_OF_ANY, &seq,
2646 ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
2647 if (ret)
2648 {
2649 ok(bufSize == sizeof(intSequence), "Wrong size %ld\n", bufSize);
2650 ok(!memcmp(buf, intSequence, intSequence[1] + 2), "Unexpected value\n");
2651 LocalFree(buf);
2652 }
2653 /* Change the type of the first element in the sequence, and give it
2654 * another go
2655 */
2656 blobs[0].cbData = times[0].encodedTime[1] + 2;
2657 blobs[0].pbData = (BYTE *)times[0].encodedTime;
2658 ret = CryptEncodeObjectEx(dwEncoding, X509_SEQUENCE_OF_ANY, &seq,
2660 ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
2661 if (ret)
2662 {
2663 ok(bufSize == sizeof(mixedSequence), "Wrong size %ld\n", bufSize);
2665 "Unexpected value\n");
2666 LocalFree(buf);
2667 }
2668}
2669
2670static void test_decodeSequenceOfAny(DWORD dwEncoding)
2671{
2672 BOOL ret;
2673 BYTE *buf = NULL;
2674 DWORD bufSize = 0;
2675
2678 ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
2679 if (ret)
2680 {
2682 DWORD i;
2683
2684 ok(seq->cValue == ARRAY_SIZE(ints), "Wrong elements %ld\n", seq->cValue);
2685 for (i = 0; i < min(seq->cValue, ARRAY_SIZE(ints)); i++)
2686 {
2687 ok(seq->rgValue[i].cbData == ints[i].encoded[1] + 2,
2688 "Expected %d bytes, got %ld\n", ints[i].encoded[1] + 2,
2689 seq->rgValue[i].cbData);
2690 ok(!memcmp(seq->rgValue[i].pbData, ints[i].encoded,
2691 ints[i].encoded[1] + 2), "Unexpected value\n");
2692 }
2693 LocalFree(buf);
2694 }
2697 &bufSize);
2698 ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
2699 if (ret)
2700 {
2702
2703 ok(seq->cValue == ARRAY_SIZE(ints), "Wrong elements %ld\n", seq->cValue);
2704 /* Just check the first element since it's all that changed */
2705 ok(seq->rgValue[0].cbData == times[0].encodedTime[1] + 2,
2706 "Expected %d bytes, got %ld\n", times[0].encodedTime[1] + 2,
2707 seq->rgValue[0].cbData);
2708 ok(!memcmp(seq->rgValue[0].pbData, times[0].encodedTime,
2709 times[0].encodedTime[1] + 2), "Unexpected value\n");
2710 LocalFree(buf);
2711 }
2712}
2713
2715{
2718};
2719
2720static BYTE crit_ext_data[] = { 0x30,0x06,0x01,0x01,0xff,0x02,0x01,0x01 };
2721static BYTE noncrit_ext_data[] = { 0x30,0x06,0x01,0x01,0xff,0x02,0x01,0x01 };
2727static CHAR oid_short[] = "1.1";
2729 { oid_short, FALSE, { 0, NULL } };
2730
2731static const BYTE ext0[] = { 0x30,0x00 };
2732static const BYTE ext1[] = { 0x30,0x14,0x30,0x12,0x06,0x03,0x55,0x1d,0x13,0x01,0x01,
2733 0xff,0x04,0x08,0x30,0x06,0x01,0x01,0xff,0x02,0x01,0x01 };
2734static const BYTE ext2[] = { 0x30,0x11,0x30,0x0f,0x06,0x03,0x55,0x1d,0x13,0x04,
2735 0x08,0x30,0x06,0x01,0x01,0xff,0x02,0x01,0x01 };
2736static const BYTE ext3[] = { 0x30,0x07,0x30,0x05,0x06,0x01,0x29,0x04,0x00 };
2737
2738static const struct encodedExtensions exts[] = {
2739 { { 0, NULL }, ext0 },
2740 { { 1, &criticalExt }, ext1 },
2741 { { 1, &nonCriticalExt }, ext2 },
2742 { { 1, &extWithShortOid }, ext3 }
2743};
2744
2745static void test_encodeExtensions(DWORD dwEncoding)
2746{
2747 DWORD i;
2748
2749 for (i = 0; i < ARRAY_SIZE(exts); i++)
2750 {
2751 BOOL ret;
2752 BYTE *buf = NULL;
2753 DWORD bufSize = 0;
2754
2757 ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
2758 if (ret)
2759 {
2760 ok(bufSize == exts[i].encoded[1] + 2,
2761 "Expected %d bytes, got %ld\n", exts[i].encoded[1] + 2, bufSize);
2762 ok(!memcmp(buf, exts[i].encoded, exts[i].encoded[1] + 2),
2763 "Unexpected value\n");
2764 LocalFree(buf);
2765 }
2766 }
2767}
2768
2769static void test_decodeExtensions(DWORD dwEncoding)
2770{
2771 DWORD i;
2772
2773 for (i = 0; i < ARRAY_SIZE(exts); i++)
2774 {
2775 BOOL ret;
2776 BYTE *buf = NULL;
2777 DWORD bufSize = 0;
2778
2781 NULL, &buf, &bufSize);
2782 ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
2783 if (ret)
2784 {
2786 DWORD j;
2787
2788 ok(ext->cExtension == exts[i].exts.cExtension,
2789 "Expected %ld extensions, see %ld\n", exts[i].exts.cExtension,
2790 ext->cExtension);
2791 for (j = 0; j < min(ext->cExtension, exts[i].exts.cExtension); j++)
2792 {
2793 ok(!strcmp(ext->rgExtension[j].pszObjId,
2794 exts[i].exts.rgExtension[j].pszObjId),
2795 "Expected OID %s, got %s\n",
2796 exts[i].exts.rgExtension[j].pszObjId,
2797 ext->rgExtension[j].pszObjId);
2798 ok(!memcmp(ext->rgExtension[j].Value.pbData,
2799 exts[i].exts.rgExtension[j].Value.pbData,
2800 exts[i].exts.rgExtension[j].Value.cbData),
2801 "Unexpected value\n");
2802 }
2803 LocalFree(buf);
2804 }
2806 exts[i].encoded, exts[i].encoded[1] + 2, 0, NULL, NULL, &bufSize);
2807 ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
2808 buf = calloc(1, bufSize);
2809 if (buf)
2810 {
2812 exts[i].encoded, exts[i].encoded[1] + 2, 0, NULL, buf, &bufSize);
2813 ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
2814 free(buf);
2815 }
2816 }
2817}
2818
2819/* MS encodes public key info with a NULL if the algorithm identifier's
2820 * parameters are empty. However, when encoding an algorithm in a CERT_INFO,
2821 * it encodes them by omitting the algorithm parameters. It accepts either
2822 * form for decoding.
2823 */
2825{
2830};
2831
2832static const BYTE aKey[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0xa, 0xb, 0xc, 0xd,
2833 0xe, 0xf };
2834static const BYTE params[] = { 0x02, 0x01, 0x01 };
2835
2836static const unsigned char bin64[] = {
2837 0x30,0x0b,0x30,0x06,0x06,0x02,0x2a,0x03,0x05,0x00,0x03,0x01,0x00};
2838static const unsigned char bin65[] = {
2839 0x30,0x09,0x30,0x04,0x06,0x02,0x2a,0x03,0x03,0x01,0x00};
2840static const unsigned char bin66[] = {
2841 0x30,0x0f,0x30,0x0a,0x06,0x06,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x05,0x00,0x03,0x01,0x00};
2842static const unsigned char bin67[] = {
2843 0x30,0x0d,0x30,0x08,0x06,0x06,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x03,0x01,0x00};
2844static const unsigned char bin68[] = {
2845 0x30,0x1f,0x30,0x0a,0x06,0x06,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x05,0x00,0x03,0x11,0x00,0x00,0x01,
2846 0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f};
2847static const unsigned char bin69[] = {
2848 0x30,0x1d,0x30,0x08,0x06,0x06,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x03,0x11,0x00,0x00,0x01,
2849 0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f};
2850static const unsigned char bin70[] = {
2851 0x30,0x20,0x30,0x0b,0x06,0x06,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x02,0x01,0x01,
2852 0x03,0x11,0x00,0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,
2853 0x0f};
2854static const unsigned char bin71[] = {
2855 0x30,0x20,0x30,0x0b,0x06,0x06,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x02,0x01,0x01,
2856 0x03,0x11,0x00,0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,
2857 0x0f};
2858static unsigned char bin72[] = { 0x05,0x00};
2859
2860static CHAR oid_bogus[] = "1.2.3",
2862
2863static const struct encodedPublicKey pubKeys[] = {
2864 /* with a bogus OID */
2865 { { { oid_bogus, { 0, NULL } }, { 0, NULL, 0 } },
2866 bin64, bin65,
2867 { { oid_bogus, { 2, bin72 } }, { 0, NULL, 0 } } },
2868 /* some normal keys */
2869 { { { oid_rsa, { 0, NULL } }, { 0, NULL, 0} },
2870 bin66, bin67,
2871 { { oid_rsa, { 2, bin72 } }, { 0, NULL, 0 } } },
2872 { { { oid_rsa, { 0, NULL } }, { sizeof(aKey), (BYTE *)aKey, 0} },
2873 bin68, bin69,
2874 { { oid_rsa, { 2, bin72 } }, { sizeof(aKey), (BYTE *)aKey, 0} } },
2875 /* with add'l parameters--note they must be DER-encoded */
2876 { { { oid_rsa, { sizeof(params), (BYTE *)params } }, { sizeof(aKey),
2877 (BYTE *)aKey, 0 } },
2878 bin70, bin71,
2879 { { oid_rsa, { sizeof(params), (BYTE *)params } }, { sizeof(aKey),
2880 (BYTE *)aKey, 0 } } },
2881};
2882
2883static void test_encodePublicKeyInfo(DWORD dwEncoding)
2884{
2885 DWORD i;
2886
2887 for (i = 0; i < ARRAY_SIZE(pubKeys); i++)
2888 {
2889 BOOL ret;
2890 BYTE *buf = NULL;
2891 DWORD bufSize = 0;
2892
2895 &bufSize);
2896 ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
2897 if (ret)
2898 {
2899 ok(bufSize == pubKeys[i].encoded[1] + 2,
2900 "Expected %d bytes, got %ld\n", pubKeys[i].encoded[1] + 2, bufSize);
2901 if (bufSize == pubKeys[i].encoded[1] + 2)
2902 ok(!memcmp(buf, pubKeys[i].encoded, pubKeys[i].encoded[1] + 2),
2903 "Unexpected value\n");
2904 LocalFree(buf);
2905 }
2906 }
2907}
2908
2910 const CERT_PUBLIC_KEY_INFO *got)
2911{
2912 ok(!strcmp(expected->Algorithm.pszObjId, got->Algorithm.pszObjId),
2913 "Expected OID %s, got %s\n", expected->Algorithm.pszObjId,
2914 got->Algorithm.pszObjId);
2915 ok(expected->Algorithm.Parameters.cbData ==
2917 "Expected parameters of %ld bytes, got %ld\n",
2918 expected->Algorithm.Parameters.cbData, got->Algorithm.Parameters.cbData);
2919 if (expected->Algorithm.Parameters.cbData)
2920 ok(!memcmp(expected->Algorithm.Parameters.pbData,
2922 "Unexpected algorithm parameters\n");
2923 ok(expected->PublicKey.cbData == got->PublicKey.cbData,
2924 "Expected public key of %ld bytes, got %ld\n",
2925 expected->PublicKey.cbData, got->PublicKey.cbData);
2926 if (expected->PublicKey.cbData)
2927 ok(!memcmp(expected->PublicKey.pbData, got->PublicKey.pbData,
2928 got->PublicKey.cbData), "Unexpected public key value\n");
2929}
2930
2931static void test_decodePublicKeyInfo(DWORD dwEncoding)
2932{
2933 static const BYTE bogusPubKeyInfo[] = { 0x30, 0x22, 0x30, 0x0d, 0x06, 0x06,
2934 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x01, 0x01, 0x01, 0x03,
2935 0x11, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09,
2936 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f };
2937 DWORD i;
2938 BOOL ret;
2939 BYTE *buf = NULL;
2940 DWORD bufSize = 0;
2941
2942 for (i = 0; i < ARRAY_SIZE(pubKeys); i++)
2943 {
2944 /* The NULL form decodes to the decoded member */
2947 NULL, &buf, &bufSize);
2948 ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
2949 if (ret)
2950 {
2953 LocalFree(buf);
2954 }
2955 /* The non-NULL form decodes to the original */
2959 ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
2960 if (ret)
2961 {
2963 LocalFree(buf);
2964 }
2965 }
2966 /* Test with bogus (not valid DER) parameters */
2968 bogusPubKeyInfo, bogusPubKeyInfo[1] + 2, CRYPT_DECODE_ALLOC_FLAG,
2969 NULL, &buf, &bufSize);
2971 "Expected CRYPT_E_ASN1_CORRUPT, got %08lx\n", GetLastError());
2972}
2973
2974static const BYTE v1Cert[] = { 0x30, 0x33, 0x02, 0x00, 0x30, 0x02, 0x06, 0x00,
2975 0x30, 0x22, 0x18, 0x0f, 0x31, 0x36, 0x30, 0x31, 0x30, 0x31, 0x30, 0x31, 0x30,
2976 0x30, 0x30, 0x30, 0x30, 0x30, 0x5a, 0x18, 0x0f, 0x31, 0x36, 0x30, 0x31, 0x30,
2977 0x31, 0x30, 0x31, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x5a, 0x30, 0x07, 0x30,
2978 0x02, 0x06, 0x00, 0x03, 0x01, 0x00 };
2979static const BYTE v2Cert[] = { 0x30, 0x38, 0xa0, 0x03, 0x02, 0x01, 0x01, 0x02,
2980 0x00, 0x30, 0x02, 0x06, 0x00, 0x30, 0x22, 0x18, 0x0f, 0x31, 0x36, 0x30, 0x31,
2981 0x30, 0x31, 0x30, 0x31, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x5a, 0x18, 0x0f,
2982 0x31, 0x36, 0x30, 0x31, 0x30, 0x31, 0x30, 0x31, 0x30, 0x30, 0x30, 0x30, 0x30,
2983 0x30, 0x5a, 0x30, 0x07, 0x30, 0x02, 0x06, 0x00, 0x03, 0x01, 0x00 };
2984static const BYTE v3Cert[] = { 0x30, 0x38, 0xa0, 0x03, 0x02, 0x01, 0x02, 0x02,
2985 0x00, 0x30, 0x02, 0x06, 0x00, 0x30, 0x22, 0x18, 0x0f, 0x31, 0x36, 0x30, 0x31,
2986 0x30, 0x31, 0x30, 0x31, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x5a, 0x18, 0x0f,
2987 0x31, 0x36, 0x30, 0x31, 0x30, 0x31, 0x30, 0x31, 0x30, 0x30, 0x30, 0x30, 0x30,
2988 0x30, 0x5a, 0x30, 0x07, 0x30, 0x02, 0x06, 0x00, 0x03, 0x01, 0x00 };
2989static const BYTE v4Cert[] = {
29900x30,0x38,0xa0,0x03,0x02,0x01,0x03,0x02,0x00,0x30,0x02,0x06,0x00,0x30,0x22,
29910x18,0x0f,0x31,0x36,0x30,0x31,0x30,0x31,0x30,0x31,0x30,0x30,0x30,0x30,0x30,
29920x30,0x5a,0x18,0x0f,0x31,0x36,0x30,0x31,0x30,0x31,0x30,0x31,0x30,0x30,0x30,
29930x30,0x30,0x30,0x5a,0x30,0x07,0x30,0x02,0x06,0x00,0x03,0x01,0x00 };
2994static const BYTE v1CertWithConstraints[] = { 0x30, 0x4b, 0x02, 0x00, 0x30,
2995 0x02, 0x06, 0x00, 0x30, 0x22, 0x18, 0x0f, 0x31, 0x36, 0x30, 0x31, 0x30, 0x31,
2996 0x30, 0x31, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x5a, 0x18, 0x0f, 0x31, 0x36,
2997 0x30, 0x31, 0x30, 0x31, 0x30, 0x31, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x5a,
2998 0x30, 0x07, 0x30, 0x02, 0x06, 0x00, 0x03, 0x01, 0x00, 0xa3, 0x16, 0x30, 0x14,
2999 0x30, 0x12, 0x06, 0x03, 0x55, 0x1d, 0x13, 0x01, 0x01, 0xff, 0x04, 0x08, 0x30,
3000 0x06, 0x01, 0x01, 0xff, 0x02, 0x01, 0x01 };
3001static const BYTE v1CertWithSerial[] = { 0x30, 0x4c, 0x02, 0x01, 0x01, 0x30,
3002 0x02, 0x06, 0x00, 0x30, 0x22, 0x18, 0x0f, 0x31, 0x36, 0x30, 0x31, 0x30, 0x31,
3003 0x30, 0x31, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x5a, 0x18, 0x0f, 0x31, 0x36,
3004 0x30, 0x31, 0x30, 0x31, 0x30, 0x31, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x5a,
3005 0x30, 0x07, 0x30, 0x02, 0x06, 0x00, 0x03, 0x01, 0x00, 0xa3, 0x16, 0x30, 0x14,
3006 0x30, 0x12, 0x06, 0x03, 0x55, 0x1d, 0x13, 0x01, 0x01, 0xff, 0x04, 0x08, 0x30,
3007 0x06, 0x01, 0x01, 0xff, 0x02, 0x01, 0x01 };
3008static const BYTE bigCert[] = { 0x30, 0x7a, 0x02, 0x01, 0x01, 0x30, 0x02, 0x06,
3009 0x00, 0x30, 0x15, 0x31, 0x13, 0x30, 0x11, 0x06, 0x03, 0x55, 0x04, 0x03, 0x13,
3010 0x0a, 0x4a, 0x75, 0x61, 0x6e, 0x20, 0x4c, 0x61, 0x6e, 0x67, 0x00, 0x30, 0x22,
3011 0x18, 0x0f, 0x31, 0x36, 0x30, 0x31, 0x30, 0x31, 0x30, 0x31, 0x30, 0x30, 0x30,
3012 0x30, 0x30, 0x30, 0x5a, 0x18, 0x0f, 0x31, 0x36, 0x30, 0x31, 0x30, 0x31, 0x30,
3013 0x31, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x5a, 0x30, 0x15, 0x31, 0x13, 0x30,
3014 0x11, 0x06, 0x03, 0x55, 0x04, 0x03, 0x13, 0x0a, 0x4a, 0x75, 0x61, 0x6e, 0x20,
3015 0x4c, 0x61, 0x6e, 0x67, 0x00, 0x30, 0x07, 0x30, 0x02, 0x06, 0x00, 0x03, 0x01,
3016 0x00, 0xa3, 0x16, 0x30, 0x14, 0x30, 0x12, 0x06, 0x03, 0x55, 0x1d, 0x13, 0x01,
3017 0x01, 0xff, 0x04, 0x08, 0x30, 0x06, 0x01, 0x01, 0xff, 0x02, 0x01, 0x01 };
3018static const BYTE v1CertWithPubKey[] = {
30190x30,0x81,0x95,0x02,0x01,0x01,0x30,0x02,0x06,0x00,0x30,0x15,0x31,0x13,0x30,
30200x11,0x06,0x03,0x55,0x04,0x03,0x13,0x0a,0x4a,0x75,0x61,0x6e,0x20,0x4c,0x61,
30210x6e,0x67,0x00,0x30,0x22,0x18,0x0f,0x31,0x36,0x30,0x31,0x30,0x31,0x30,0x31,
30220x30,0x30,0x30,0x30,0x30,0x30,0x5a,0x18,0x0f,0x31,0x36,0x30,0x31,0x30,0x31,
30230x30,0x31,0x30,0x30,0x30,0x30,0x30,0x30,0x5a,0x30,0x15,0x31,0x13,0x30,0x11,
30240x06,0x03,0x55,0x04,0x03,0x13,0x0a,0x4a,0x75,0x61,0x6e,0x20,0x4c,0x61,0x6e,
30250x67,0x00,0x30,0x22,0x30,0x0d,0x06,0x09,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x01,
30260x01,0x01,0x05,0x00,0x03,0x11,0x00,0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,
30270x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f,0xa3,0x16,0x30,0x14,0x30,0x12,0x06,
30280x03,0x55,0x1d,0x13,0x01,0x01,0xff,0x04,0x08,0x30,0x06,0x01,0x01,0xff,0x02,
30290x01,0x01 };
30310x30,0x81,0x93,0x02,0x01,0x01,0x30,0x02,0x06,0x00,0x30,0x15,0x31,0x13,0x30,
30320x11,0x06,0x03,0x55,0x04,0x03,0x13,0x0a,0x4a,0x75,0x61,0x6e,0x20,0x4c,0x61,
30330x6e,0x67,0x00,0x30,0x22,0x18,0x0f,0x31,0x36,0x30,0x31,0x30,0x31,0x30,0x31,
30340x30,0x30,0x30,0x30,0x30,0x30,0x5a,0x18,0x0f,0x31,0x36,0x30,0x31,0x30,0x31,
30350x30,0x31,0x30,0x30,0x30,0x30,0x30,0x30,0x5a,0x30,0x15,0x31,0x13,0x30,0x11,
30360x06,0x03,0x55,0x04,0x03,0x13,0x0a,0x4a,0x75,0x61,0x6e,0x20,0x4c,0x61,0x6e,
30370x67,0x00,0x30,0x20,0x30,0x0b,0x06,0x09,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x01,
30380x01,0x01,0x03,0x11,0x00,0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,
30390x0a,0x0b,0x0c,0x0d,0x0e,0x0f,0xa3,0x16,0x30,0x14,0x30,0x12,0x06,0x03,0x55,
30400x1d,0x13,0x01,0x01,0xff,0x04,0x08,0x30,0x06,0x01,0x01,0xff,0x02,0x01,0x01 };
30420x30,0x7b,0x02,0x01,0x01,0x30,0x02,0x06,0x00,0x30,0x15,0x31,0x13,0x30,0x11,
30430x06,0x03,0x55,0x04,0x03,0x13,0x0a,0x4a,0x75,0x61,0x6e,0x20,0x4c,0x61,0x6e,
30440x67,0x00,0x30,0x22,0x18,0x0f,0x31,0x36,0x30,0x31,0x30,0x31,0x30,0x31,0x30,
30450x30,0x30,0x30,0x30,0x30,0x5a,0x18,0x0f,0x31,0x36,0x30,0x31,0x30,0x31,0x30,
30460x31,0x30,0x30,0x30,0x30,0x30,0x30,0x5a,0x30,0x15,0x31,0x13,0x30,0x11,0x06,
30470x03,0x55,0x04,0x03,0x13,0x0a,0x4a,0x75,0x61,0x6e,0x20,0x4c,0x61,0x6e,0x67,
30480x00,0x30,0x07,0x30,0x02,0x06,0x00,0x03,0x01,0x00,0xa3,0x17,0x30,0x15,0x30,
30490x13,0x06,0x03,0x55,0x1d,0x0e,0x04,0x0c,0x04,0x0a,0x4a,0x75,0x61,0x6e,0x20,
30500x4c,0x61,0x6e,0x67,0x00 };
30520x30,0x38,0x02,0x01,0x01,0x30,0x02,0x06,0x00,0x30,0x22,0x18,0x0f,0x31,0x36,
30530x30,0x31,0x30,0x31,0x30,0x31,0x30,0x30,0x30,0x30,0x30,0x30,0x5a,0x18,0x0f,
30540x31,0x36,0x30,0x31,0x30,0x31,0x30,0x31,0x30,0x30,0x30,0x30,0x30,0x30,0x5a,
30550x30,0x07,0x30,0x02,0x06,0x00,0x03,0x01,0x00,0x81,0x02,0x00,0x01 };
30570x30,0x81,0x99,0x02,0x01,0x01,0x30,0x02,0x06,0x00,0x30,0x15,0x31,0x13,0x30,
30580x11,0x06,0x03,0x55,0x04,0x03,0x13,0x0a,0x4a,0x75,0x61,0x6e,0x20,0x4c,0x61,
30590x6e,0x67,0x00,0x30,0x22,0x18,0x0f,0x31,0x36,0x30,0x31,0x30,0x31,0x30,0x31,
30600x30,0x30,0x30,0x30,0x30,0x30,0x5a,0x18,0x0f,0x31,0x36,0x30,0x31,0x30,0x31,
30610x30,0x31,0x30,0x30,0x30,0x30,0x30,0x30,0x5a,0x30,0x15,0x31,0x13,0x30,0x11,
30620x06,0x03,0x55,0x04,0x03,0x13,0x0a,0x4a,0x75,0x61,0x6e,0x20,0x4c,0x61,0x6e,
30630x67,0x00,0x30,0x22,0x30,0x0d,0x06,0x09,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x01,
30640x01,0x01,0x05,0x00,0x03,0x11,0x00,0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,
30650x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f,0x81,0x02,0x00,0x01,0xa3,0x16,0x30,
30660x14,0x30,0x12,0x06,0x03,0x55,0x1d,0x13,0x01,0x01,0xff,0x04,0x08,0x30,0x06,
30670x01,0x01,0xff,0x02,0x01,0x01 };
30690x30,0x81,0x97,0x02,0x01,0x01,0x30,0x02,0x06,0x00,0x30,0x15,0x31,0x13,0x30,
30700x11,0x06,0x03,0x55,0x04,0x03,0x13,0x0a,0x4a,0x75,0x61,0x6e,0x20,0x4c,0x61,
30710x6e,0x67,0x00,0x30,0x22,0x18,0x0f,0x31,0x36,0x30,0x31,0x30,0x31,0x30,0x31,
30720x30,0x30,0x30,0x30,0x30,0x30,0x5a,0x18,0x0f,0x31,0x36,0x30,0x31,0x30,0x31,
30730x30,0x31,0x30,0x30,0x30,0x30,0x30,0x30,0x5a,0x30,0x15,0x31,0x13,0x30,0x11,
30740x06,0x03,0x55,0x04,0x03,0x13,0x0a,0x4a,0x75,0x61,0x6e,0x20,0x4c,0x61,0x6e,
30750x67,0x00,0x30,0x20,0x30,0x0b,0x06,0x09,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x01,
30760x01,0x01,0x03,0x11,0x00,0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,
30770x0a,0x0b,0x0c,0x0d,0x0e,0x0f,0x81,0x02,0x00,0x01,0xa3,0x16,0x30,0x14,0x30,
30780x12,0x06,0x03,0x55,0x1d,0x13,0x01,0x01,0xff,0x04,0x08,0x30,0x06,0x01,0x01,
30790xff,0x02,0x01,0x01 };
3080
3081static const BYTE serialNum[] = { 0x01 };
3082
3083static void test_encodeCertToBeSigned(DWORD dwEncoding)
3084{
3085 BOOL ret;
3086 BYTE *buf = NULL;
3087 DWORD size = 0;
3088 CERT_INFO info = { 0 };
3089 static char oid_rsa_rsa[] = szOID_RSA_RSA;
3090 static char oid_subject_key_identifier[] = szOID_SUBJECT_KEY_IDENTIFIER;
3092
3093 /* Test with NULL pvStructInfo */
3097 "Expected STATUS_ACCESS_VIOLATION, got %08lx\n", GetLastError());
3098
3099 /* Test with a V1 cert */
3102 ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
3103 if (ret)
3104 {
3105 ok(size == v1Cert[1] + 2, "Expected size %d, got %ld\n",
3106 v1Cert[1] + 2, size);
3107 ok(!memcmp(buf, v1Cert, size), "Got unexpected value\n");
3108 LocalFree(buf);
3109 }
3110 /* Test v2 cert */
3111 info.dwVersion = CERT_V2;
3114 ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
3115 if (ret)
3116 {
3117 ok(size == sizeof(v2Cert), "Wrong size %ld\n", size);
3118 ok(!memcmp(buf, v2Cert, size), "Got unexpected value\n");
3119 LocalFree(buf);
3120 }
3121 /* Test v3 cert */
3122 info.dwVersion = CERT_V3;
3125 ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
3126 if (ret)
3127 {
3128 ok(size == sizeof(v3Cert), "Wrong size %ld\n", size);
3129 ok(!memcmp(buf, v3Cert, size), "Got unexpected value\n");
3130 LocalFree(buf);
3131 }
3132 /* A v4 cert? */
3133 info.dwVersion = 3; /* Not a typo, CERT_V3 is 2 */
3136 if (ret)
3137 {
3138 ok(size == sizeof(v4Cert), "Wrong size %ld\n", size);
3139 ok(!memcmp(buf, v4Cert, size), "Unexpected value\n");
3140 LocalFree(buf);
3141 }
3142 /* see if a V1 cert can have basic constraints set (RFC3280 says no, but
3143 * API doesn't prevent it)
3144 */
3145 info.dwVersion = CERT_V1;
3146 info.cExtension = 1;
3147 info.rgExtension = &criticalExt;
3150 ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
3151 if (ret)
3152 {
3153 ok(size == sizeof(v1CertWithConstraints), "Wrong size %ld\n", size);
3154 ok(!memcmp(buf, v1CertWithConstraints, size), "Got unexpected value\n");
3155 LocalFree(buf);
3156 }
3157 /* test v1 cert with a serial number */
3158 info.SerialNumber.cbData = sizeof(serialNum);
3159 info.SerialNumber.pbData = (BYTE *)serialNum;
3162 if (ret)
3163 {
3164 ok(size == sizeof(v1CertWithSerial), "Wrong size %ld\n", size);
3165 ok(!memcmp(buf, v1CertWithSerial, size), "Got unexpected value\n");
3166 LocalFree(buf);
3167 }
3168 /* Test v1 cert with an issuer name, serial number, and issuer unique id */
3169 info.dwVersion = CERT_V1;
3170 info.cExtension = 0;
3171 info.IssuerUniqueId.cbData = sizeof(serialNum);
3172 info.IssuerUniqueId.pbData = (BYTE *)serialNum;
3175 ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
3176 if (ret)
3177 {
3178 ok(size == sizeof(v1CertWithIssuerUniqueId), "Wrong size %ld\n", size);
3180 "Got unexpected value\n");
3181 LocalFree(buf);
3182 }
3183 /* Test v1 cert with an issuer name, a subject name, and a serial number */
3184 info.IssuerUniqueId.cbData = 0;
3185 info.IssuerUniqueId.pbData = NULL;
3186 info.cExtension = 1;
3187 info.rgExtension = &criticalExt;
3188 info.Issuer.cbData = sizeof(encodedCommonName);
3189 info.Issuer.pbData = (BYTE *)encodedCommonName;
3190 info.Subject.cbData = sizeof(encodedCommonName);
3191 info.Subject.pbData = (BYTE *)encodedCommonName;
3194 if (ret)
3195 {
3196 ok(size == sizeof(bigCert), "Wrong size %ld\n", size);
3197 ok(!memcmp(buf, bigCert, size), "Got unexpected value\n");
3198 LocalFree(buf);
3199 }
3200 /* Add a public key */
3201 info.SubjectPublicKeyInfo.Algorithm.pszObjId = oid_rsa_rsa;
3202 info.SubjectPublicKeyInfo.PublicKey.cbData = sizeof(aKey);
3203 info.SubjectPublicKeyInfo.PublicKey.pbData = (LPBYTE)aKey;
3206 if (ret)
3207 {
3208 ok(size == sizeof(v1CertWithPubKey) ||
3209 size == sizeof(v1CertWithPubKeyNoNull), "Wrong size %ld\n", size);
3210 if (size == sizeof(v1CertWithPubKey))
3211 ok(!memcmp(buf, v1CertWithPubKey, size), "Got unexpected value\n");
3212 else if (size == sizeof(v1CertWithPubKeyNoNull))
3214 "Got unexpected value\n");
3215 LocalFree(buf);
3216 }
3217 /* Again add an issuer unique id */
3218 info.IssuerUniqueId.cbData = sizeof(serialNum);
3219 info.IssuerUniqueId.pbData = (BYTE *)serialNum;
3222 ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
3223 if (ret)
3224 {
3227 "Wrong size %ld\n", size);
3230 size), "unexpected value\n");
3231 else if (size ==
3233 ok(!memcmp(buf,
3235 "unexpected value\n");
3236 LocalFree(buf);
3237 }
3238 /* Remove the public key, and add a subject key identifier extension */
3239 info.IssuerUniqueId.cbData = 0;
3240 info.IssuerUniqueId.pbData = NULL;
3241 info.SubjectPublicKeyInfo.Algorithm.pszObjId = NULL;
3242 info.SubjectPublicKeyInfo.PublicKey.cbData = 0;
3243 info.SubjectPublicKeyInfo.PublicKey.pbData = NULL;
3244 ext.pszObjId = oid_subject_key_identifier;
3245 ext.fCritical = FALSE;
3246 ext.Value.cbData = sizeof(octetCommonNameValue);
3247 ext.Value.pbData = octetCommonNameValue;
3248 info.cExtension = 1;
3249 info.rgExtension = &ext;
3252 if (ret)
3253 {
3254 ok(size == sizeof(v1CertWithSubjectKeyId), "Wrong size %ld\n", size);
3255 ok(!memcmp(buf, v1CertWithSubjectKeyId, size), "Unexpected value\n");
3256 LocalFree(buf);
3257 }
3258}
3259
3260static void test_decodeCertToBeSigned(DWORD dwEncoding)
3261{
3262 static const BYTE *corruptCerts[] = { v1Cert, v2Cert, v3Cert, v4Cert,
3264 BOOL ret;
3265 BYTE *buf = NULL;
3266 DWORD size = 0, i;
3267
3268 /* Test with NULL pbEncoded */
3272 "Expected CRYPT_E_ASN1_EOD, got %08lx\n", GetLastError());
3273
3277 "Expected STATUS_ACCESS_VIOLATION, got %08lx\n", GetLastError());
3278
3279 /* The following certs all fail with CRYPT_E_ASN1_CORRUPT or
3280 * CRYPT_E_ASN1_BADTAG, because at a minimum a cert must have a non-zero
3281 * serial number, an issuer, a subject, and a public key.
3282 */
3283 for (i = 0; i < ARRAY_SIZE(corruptCerts); i++)
3284 {
3286 corruptCerts[i], corruptCerts[i][1] + 2, CRYPT_DECODE_ALLOC_FLAG, NULL,
3287 &buf, &size);
3288 ok(!ret, "Expected failure\n");
3289 }
3290 /* The following succeeds, even though v1 certs are not allowed to have
3291 * extensions.
3292 */
3296 ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
3297 if (ret)
3298 {
3300
3301 ok(size >= sizeof(CERT_INFO), "Wrong size %ld\n", size);
3302 ok(info->dwVersion == CERT_V1, "expected CERT_V1, got %ld\n",
3303 info->dwVersion);
3304 ok(info->cExtension == 1, "expected 1 extension, got %ld\n",
3305 info->cExtension);
3306 LocalFree(buf);
3307 }
3308 /* The following also succeeds, even though V1 certs are not allowed to
3309 * have issuer unique ids.
3310 */
3315 ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
3316 if (ret)
3317 {
3319
3320 ok(size >= sizeof(CERT_INFO), "Wrong size %ld\n", size);
3321 ok(info->dwVersion == CERT_V1, "expected CERT_V1, got %ld\n",
3322 info->dwVersion);
3323 ok(info->IssuerUniqueId.cbData == sizeof(serialNum),
3324 "unexpected issuer unique id size %ld\n", info->IssuerUniqueId.cbData);
3325 ok(!memcmp(info->IssuerUniqueId.pbData, serialNum, sizeof(serialNum)),
3326 "unexpected issuer unique id value\n");
3327 LocalFree(buf);
3328 }
3329 /* Now check with serial number, subject and issuer specified */
3332 ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
3333 if (ret)
3334 {
3336
3337 ok(size >= sizeof(CERT_INFO), "Wrong size %ld\n", size);
3338 ok(info->SerialNumber.cbData == 1,
3339 "Expected serial number size 1, got %ld\n", info->SerialNumber.cbData);
3340 ok(*info->SerialNumber.pbData == *serialNum,
3341 "Expected serial number %d, got %d\n", *serialNum,
3342 *info->SerialNumber.pbData);
3343 ok(info->Issuer.cbData == sizeof(encodedCommonName),
3344 "Wrong size %ld\n", info->Issuer.cbData);
3345 ok(!memcmp(info->Issuer.pbData, encodedCommonName, info->Issuer.cbData),
3346 "Unexpected issuer\n");
3347 ok(info->Subject.cbData == sizeof(encodedCommonName),
3348 "Wrong size %ld\n", info->Subject.cbData);
3349 ok(!memcmp(info->Subject.pbData, encodedCommonName,
3350 info->Subject.cbData), "Unexpected subject\n");
3351 LocalFree(buf);
3352 }
3353 /* Check again with pub key specified */
3356 &buf, &size);
3357 ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
3358 if (ret)
3359 {
3361
3362 ok(size >= sizeof(CERT_INFO), "Wrong size %ld\n", size);
3363 ok(info->SerialNumber.cbData == 1,
3364 "Expected serial number size 1, got %ld\n", info->SerialNumber.cbData);
3365 ok(*info->SerialNumber.pbData == *serialNum,
3366 "Expected serial number %d, got %d\n", *serialNum,
3367 *info->SerialNumber.pbData);
3368 ok(info->Issuer.cbData == sizeof(encodedCommonName),
3369 "Wrong size %ld\n", info->Issuer.cbData);
3370 ok(!memcmp(info->Issuer.pbData, encodedCommonName, info->Issuer.cbData),
3371 "Unexpected issuer\n");
3372 ok(info->Subject.cbData == sizeof(encodedCommonName),
3373 "Wrong size %ld\n", info->Subject.cbData);
3374 ok(!memcmp(info->Subject.pbData, encodedCommonName,
3375 info->Subject.cbData), "Unexpected subject\n");
3376 ok(!strcmp(info->SubjectPublicKeyInfo.Algorithm.pszObjId,
3377 szOID_RSA_RSA), "Expected szOID_RSA_RSA, got %s\n",
3378 info->SubjectPublicKeyInfo.Algorithm.pszObjId);
3379 ok(info->SubjectPublicKeyInfo.PublicKey.cbData == sizeof(aKey),
3380 "Wrong size %ld\n", info->SubjectPublicKeyInfo.PublicKey.cbData);
3381 ok(!memcmp(info->SubjectPublicKeyInfo.PublicKey.pbData, aKey,
3382 sizeof(aKey)), "Unexpected public key\n");
3383 LocalFree(buf);
3384 }
3385}
3386
3387static const BYTE hash[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0xa, 0xb, 0xc, 0xd,
3388 0xe, 0xf };
3389
3390static const BYTE signedBigCert[] = {
3391 ASN_SEQUENCE,0x81,147,
3392 ASN_SEQUENCE,122,
3393 ASN_INTEGER,1, 0x01,
3394 ASN_SEQUENCE,2,
3396 ASN_SEQUENCE,21,
3397 0x31,19,
3398 ASN_SEQUENCE,17,
3399 ASN_OBJECTIDENTIFIER,3, 0x55,0x04,0x03,
3400 0x13,10, 0x4a,0x75,0x61,0x6e,0x20,0x4c,0x61,0x6e,0x67,0x00,
3401 ASN_SEQUENCE,34,
3402 0x18,15, 0x31,0x36,0x30,0x31,0x30,0x31,0x30,0x31,0x30,0x30,0x30,0x30,0x30,0x30,0x5a,
3403 0x18,15, 0x31,0x36,0x30,0x31,0x30,0x31,0x30,0x31,0x30,0x30,0x30,0x30,0x30,0x30,0x5a,
3404 ASN_SEQUENCE,21,
3405 0x31,19,
3406 ASN_SEQUENCE,17,
3407 ASN_OBJECTIDENTIFIER,3, 0x55,0x04,0x03,
3408 0x13,10, 0x4a,0x75,0x61,0x6e,0x20,0x4c,0x61,0x6e,0x67,0x00,
3409 ASN_SEQUENCE,7,
3410 ASN_SEQUENCE,2,
3412 ASN_BITS,1, 0x00,
3413 0xa3,22,
3414 ASN_SEQUENCE,20,
3415 ASN_SEQUENCE,18,
3416 ASN_OBJECTIDENTIFIER,3, 0x55,0x1d,0x13,
3417 0x01,1, 0xff,
3418 ASN_OCTETSTRING,8, 0x30,0x06,0x01,0x01,0xff,0x02,0x01,0x01,
3419 ASN_SEQUENCE,2,
3421 ASN_BITS,17, 0x00,0x0f,0x0e,0x0d,0x0c,0x0b,0x0a,0x09,0x08,
3422 0x07,0x06,0x05,0x04,0x03,0x02,0x01,0x00
3423};
3424
3426 ASN_SEQUENCE,0x81,151,
3427 ASN_SEQUENCE,126,
3428 ASN_INTEGER,1, 0x01,
3429 ASN_SEQUENCE,2,
3431 ASN_SEQUENCE,21,
3432 0x31,19,
3433 ASN_SEQUENCE,17,
3434 ASN_OBJECTIDENTIFIER,3, 0x55,0x04,0x03,
3435 0x13,10, 0x4a,0x75,0x61,0x6e,0x20,0x4c,0x61,0x6e,0x67,0x00,
3436 ASN_SEQUENCE,0x80,
3437 0x18,15, 0x31,0x36,0x30,0x31,0x30,0x31,0x30,0x31,0x30,0x30,0x30,0x30,0x30,0x30,0x5a,
3438 0x18,15, 0x31,0x36,0x30,0x31,0x30,0x31,0x30,0x31,0x30,0x30,0x30,0x30,0x30,0x30,0x5a,
3439 0,0,
3440 ASN_SEQUENCE,21,
3441 0x31,19,
3442 ASN_SEQUENCE,17,
3443 ASN_OBJECTIDENTIFIER,3, 0x55,0x04,0x03,
3444 0x13,10, 0x4a,0x75,0x61,0x6e,0x20,0x4c,0x61,0x6e,0x67,0x00,
3445 ASN_SEQUENCE,0x80,
3446 ASN_SEQUENCE,2,
3448 ASN_BITS,1, 0x00,
3449 0,0,
3450 0xa3,22,
3451 ASN_SEQUENCE,20,
3452 ASN_SEQUENCE,18,
3453 ASN_OBJECTIDENTIFIER,3, 0x55,0x1d,0x13,
3454 0x01,1, 0xff,
3455 ASN_OCTETSTRING,8, 0x30,0x06,0x01,0x01,0xff,0x02,0x01,0x01,
3456 ASN_SEQUENCE,2,
3458 ASN_BITS,17, 0x00,0x0f,0x0e,0x0d,0x0c,0x0b,0x0a,0x09,0x08,
3459 0x07,0x06,0x05,0x04,0x03,0x02,0x01,0x00
3460};
3461
3462static void test_encodeCert(DWORD dwEncoding)
3463{
3464 /* Note the SignatureAlgorithm must match that in the encoded cert. Note
3465 * also that bigCert is a NULL-terminated string, so don't count its
3466 * last byte (otherwise the signed cert won't decode.)
3467 */
3468 CERT_SIGNED_CONTENT_INFO info = { { sizeof(bigCert), (BYTE *)bigCert },
3469 { NULL, { 0, NULL } }, { sizeof(hash), (BYTE *)hash, 0 } };
3470 BOOL ret;
3471 BYTE *buf = NULL;
3472 DWORD bufSize = 0;
3473
3474 ret = CryptEncodeObjectEx(dwEncoding, X509_CERT, &info,
3476 ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
3477 if (ret)
3478 {
3479 ok(bufSize == sizeof(signedBigCert), "Wrong size %ld\n", bufSize);
3480 ok(!memcmp(buf, signedBigCert, bufSize), "Unexpected cert\n");
3481 LocalFree(buf);
3482 }
3483}
3484
3485static void test_decodeCert(DWORD dwEncoding)
3486{
3487 BOOL ret;
3488 BYTE *buf = NULL;
3489 DWORD size = 0;
3490
3493 ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
3494 if (ret)
3495 {
3497
3498 ok(info->ToBeSigned.cbData == sizeof(bigCert),
3499 "Wrong cert size %ld\n", info->ToBeSigned.cbData);
3500 ok(!memcmp(info->ToBeSigned.pbData, bigCert, info->ToBeSigned.cbData),
3501 "Unexpected cert\n");
3502 ok(info->Signature.cbData == sizeof(hash),
3503 "Wrong signature size %ld\n", info->Signature.cbData);
3504 ok(!memcmp(info->Signature.pbData, hash, info->Signature.cbData),
3505 "Unexpected signature\n");
3506 LocalFree(buf);
3507 }
3508 /* A signed cert decodes as a CERT_INFO too */
3511 ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
3512 if (ret)
3513 {
3515
3516 ok(size >= sizeof(CERT_INFO), "Wrong size %ld\n", size);
3517 ok(info->SerialNumber.cbData == 1,
3518 "Expected serial number size 1, got %ld\n", info->SerialNumber.cbData);
3519 ok(*info->SerialNumber.pbData == *serialNum,
3520 "Expected serial number %d, got %d\n", *serialNum,
3521 *info->SerialNumber.pbData);
3522 ok(info->Issuer.cbData == sizeof(encodedCommonName),
3523 "Wrong size %ld\n", info->Issuer.cbData);
3524 ok(!memcmp(info->Issuer.pbData, encodedCommonName, info->Issuer.cbData),
3525 "Unexpected issuer\n");
3526 ok(info->Subject.cbData == sizeof(encodedCommonName),
3527 "Wrong size %ld\n", info->Subject.cbData);
3528 ok(!memcmp(info->Subject.pbData, encodedCommonName,
3529 info->Subject.cbData), "Unexpected subject\n");
3530 LocalFree(buf);
3531 }
3534 ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
3535 if (ret)
3536 {
3538
3539 ok(size >= sizeof(CERT_INFO), "Wrong size %ld\n", size);
3540 ok(info->SerialNumber.cbData == 1,
3541 "Expected serial number size 1, got %ld\n", info->SerialNumber.cbData);
3542 ok(*info->SerialNumber.pbData == *serialNum,
3543 "Expected serial number %d, got %d\n", *serialNum,
3544 *info->SerialNumber.pbData);
3545 ok(info->Issuer.cbData == sizeof(encodedCommonName),
3546 "Wrong size %ld\n", info->Issuer.cbData);
3547 ok(!memcmp(info->Issuer.pbData, encodedCommonName, info->Issuer.cbData),
3548 "Unexpected issuer\n");
3549 ok(info->Subject.cbData == sizeof(encodedCommonName),
3550 "Wrong size %ld\n", info->Subject.cbData);
3551 ok(!memcmp(info->Subject.pbData, encodedCommonName,
3552 info->Subject.cbData), "Unexpected subject\n");
3553 LocalFree(buf);
3554 }
3555}
3556
3557static const BYTE emptyDistPoint[] = { 0x30, 0x02, 0x30, 0x00 };
3558static const BYTE distPointWithUrl[] = { 0x30, 0x19, 0x30, 0x17, 0xa0, 0x15,
3559 0xa0, 0x13, 0x86, 0x11, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x77, 0x69,
3560 0x6e, 0x65, 0x68, 0x71, 0x2e, 0x6f, 0x72, 0x67 };
3561static const BYTE distPointWithReason[] = { 0x30, 0x06, 0x30, 0x04, 0x81, 0x02,
3562 0x00, 0x03 };
3563static const BYTE distPointWithIssuer[] = { 0x30, 0x17, 0x30, 0x15, 0xa2, 0x13,
3564 0x86, 0x11, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x77, 0x69, 0x6e, 0x65,
3565 0x68, 0x71, 0x2e, 0x6f, 0x72, 0x67 };
3566static const BYTE distPointWithUrlAndIssuer[] = { 0x30, 0x2e, 0x30, 0x2c, 0xa0,
3567 0x15, 0xa0, 0x13, 0x86, 0x11, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x77,
3568 0x69, 0x6e, 0x65, 0x68, 0x71, 0x2e, 0x6f, 0x72, 0x67, 0xa2, 0x13, 0x86, 0x11,
3569 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x77, 0x69, 0x6e, 0x65, 0x68, 0x71,
3570 0x2e, 0x6f, 0x72, 0x67 };
3573
3574static void test_encodeCRLDistPoints(DWORD dwEncoding)
3575{
3576 CRL_DIST_POINTS_INFO info = { 0 };
3577 CRL_DIST_POINT point = { { 0 } };
3578 CERT_ALT_NAME_ENTRY entry = { 0 };
3579 BOOL ret;
3580 BYTE *buf = NULL;
3581 DWORD size = 0;
3582
3583 /* Test with an empty info */
3587 "Expected E_INVALIDARG, got %08lx\n", GetLastError());
3588 /* Test with one empty dist point */
3589 info.cDistPoint = 1;
3590 info.rgDistPoint = &point;
3593 ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
3594 if (ret)
3595 {
3596 ok(size == sizeof(emptyDistPoint), "Wrong size %ld\n", size);
3597 ok(!memcmp(buf, emptyDistPoint, size), "Unexpected value\n");
3598 LocalFree(buf);
3599 }
3600 /* A dist point with an invalid name */
3601 point.DistPointName.dwDistPointNameChoice = CRL_DIST_POINT_FULL_NAME;
3602 entry.dwAltNameChoice = CERT_ALT_NAME_URL;
3603 entry.pwszURL = (WCHAR *)L"http://\x226f\x575b";
3604 point.DistPointName.FullName.cAltEntry = 1;
3605 point.DistPointName.FullName.rgAltEntry = &entry;
3609 "Expected CRYPT_E_INVALID_IA5_STRING, got %08lx\n", GetLastError());
3610 /* The first invalid character is at index 7 */
3612 "Expected invalid char at index 7, got %ld\n",
3614 /* A dist point with (just) a valid name */
3615 entry.pwszURL = (LPWSTR)url;
3618 ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
3619 if (ret)
3620 {
3621 ok(size == sizeof(distPointWithUrl), "Wrong size %ld\n", size);
3622 ok(!memcmp(buf, distPointWithUrl, size), "Unexpected value\n");
3623 LocalFree(buf);
3624 }
3625 /* A dist point with (just) reason flags */
3626 point.DistPointName.dwDistPointNameChoice = CRL_DIST_POINT_NO_NAME;
3627 point.ReasonFlags.cbData = sizeof(crlReason);
3628 point.ReasonFlags.pbData = (LPBYTE)&crlReason;
3631 ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
3632 if (ret)
3633 {
3634 ok(size == sizeof(distPointWithReason), "Wrong size %ld\n", size);
3635 ok(!memcmp(buf, distPointWithReason, size), "Unexpected value\n");
3636 LocalFree(buf);
3637 }
3638 /* A dist point with just an issuer */
3639 point.ReasonFlags.cbData = 0;
3640 point.CRLIssuer.cAltEntry = 1;
3641 point.CRLIssuer.rgAltEntry = &entry;
3644 ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
3645 if (ret)
3646 {
3647 ok(size == sizeof(distPointWithIssuer), "Wrong size %ld\n", size);
3648 ok(!memcmp(buf, distPointWithIssuer, size), "Unexpected value\n");
3649 LocalFree(buf);
3650 }
3651 /* A dist point with both a name and an issuer */
3652 point.DistPointName.dwDistPointNameChoice = CRL_DIST_POINT_FULL_NAME;
3655 ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
3656 if (ret)
3657 {
3659 "Wrong size %ld\n", size);
3660 ok(!memcmp(buf, distPointWithUrlAndIssuer, size), "Unexpected value\n");
3661 LocalFree(buf);
3662 }
3663}
3664
3665static void test_decodeCRLDistPoints(DWORD dwEncoding)
3666{
3667 BOOL ret;
3668 BYTE *buf = NULL;
3669 DWORD size = 0;
3673
3676 &buf, &size);
3677 ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
3678 if (ret)
3679 {
3681 ok(size >= sizeof(CRL_DIST_POINTS_INFO) + sizeof(CRL_DIST_POINT),
3682 "Wrong size %ld\n", size);
3683 ok(info->cDistPoint == 1, "Expected 1 dist points, got %ld\n",
3684 info->cDistPoint);
3685 point = info->rgDistPoint;
3686 ok(point->DistPointName.dwDistPointNameChoice == CRL_DIST_POINT_NO_NAME,
3687 "Expected CRL_DIST_POINT_NO_NAME, got %ld\n",
3688 point->DistPointName.dwDistPointNameChoice);
3689 ok(point->ReasonFlags.cbData == 0, "Expected no reason\n");
3690 ok(point->CRLIssuer.cAltEntry == 0, "Expected no issuer\n");
3691 LocalFree(buf);
3692 }
3695 &buf, &size);
3696 ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
3697 if (ret)
3698 {
3700 ok(size >= sizeof(CRL_DIST_POINTS_INFO) + sizeof(CRL_DIST_POINT),
3701 "Wrong size %ld\n", size);
3702 ok(info->cDistPoint == 1, "Expected 1 dist points, got %ld\n",
3703 info->cDistPoint);
3704 point = info->rgDistPoint;
3705 ok(point->DistPointName.dwDistPointNameChoice ==
3707 "Expected CRL_DIST_POINT_FULL_NAME, got %ld\n",
3708 point->DistPointName.dwDistPointNameChoice);
3709 ok(point->DistPointName.FullName.cAltEntry == 1,
3710 "Expected 1 name entry, got %ld\n",
3711 point->DistPointName.FullName.cAltEntry);
3712 entry = point->DistPointName.FullName.rgAltEntry;
3713 ok(entry->dwAltNameChoice == CERT_ALT_NAME_URL,
3714 "Expected CERT_ALT_NAME_URL, got %ld\n", entry->dwAltNameChoice);
3715 ok(!lstrcmpW(entry->pwszURL, url), "Unexpected name\n");
3716 ok(point->ReasonFlags.cbData == 0, "Expected no reason\n");
3717 ok(point->CRLIssuer.cAltEntry == 0, "Expected no issuer\n");
3718 LocalFree(buf);
3719 }
3722 NULL, &buf, &size);
3723 ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
3724 if (ret)
3725 {
3727 ok(size >= sizeof(CRL_DIST_POINTS_INFO) + sizeof(CRL_DIST_POINT),
3728 "Wrong size %ld\n", size);
3729 ok(info->cDistPoint == 1, "Expected 1 dist points, got %ld\n",
3730 info->cDistPoint);
3731 point = info->rgDistPoint;
3732 ok(point->DistPointName.dwDistPointNameChoice ==
3734 "Expected CRL_DIST_POINT_NO_NAME, got %ld\n",
3735 point->DistPointName.dwDistPointNameChoice);
3736 ok(point->ReasonFlags.cbData == sizeof(crlReason),
3737 "Expected reason length\n");
3738 ok(!memcmp(point->ReasonFlags.pbData, &crlReason, sizeof(crlReason)),
3739 "Unexpected reason\n");
3740 ok(point->CRLIssuer.cAltEntry == 0, "Expected no issuer\n");
3741 LocalFree(buf);
3742 }
3746 ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
3747 if (ret)
3748 {
3750 ok(size >= sizeof(CRL_DIST_POINTS_INFO) + sizeof(CRL_DIST_POINT),
3751 "Wrong size %ld\n", size);
3752 ok(info->cDistPoint == 1, "Expected 1 dist points, got %ld\n",
3753 info->cDistPoint);
3754 point = info->rgDistPoint;
3755 ok(point->DistPointName.dwDistPointNameChoice ==
3757 "Expected CRL_DIST_POINT_FULL_NAME, got %ld\n",
3758 point->DistPointName.dwDistPointNameChoice);
3759 ok(point->DistPointName.FullName.cAltEntry == 1,
3760 "Expected 1 name entry, got %ld\n",
3761 point->DistPointName.FullName.cAltEntry);
3762 entry = point->DistPointName.FullName.rgAltEntry;
3763 ok(entry->dwAltNameChoice == CERT_ALT_NAME_URL,
3764 "Expected CERT_ALT_NAME_URL, got %ld\n", entry->dwAltNameChoice);
3765 ok(!lstrcmpW(entry->pwszURL, url), "Unexpected name\n");
3766 ok(point->ReasonFlags.cbData == 0, "Expected no reason\n");
3767 ok(point->CRLIssuer.cAltEntry == 1,
3768 "Expected 1 issuer entry, got %ld\n", point->CRLIssuer.cAltEntry);
3769 entry = point->CRLIssuer.rgAltEntry;
3770 ok(entry->dwAltNameChoice == CERT_ALT_NAME_URL,
3771 "Expected CERT_ALT_NAME_URL, got %ld\n", entry->dwAltNameChoice);
3772 ok(!lstrcmpW(entry->pwszURL, url), "Unexpected name\n");
3773 LocalFree(buf);
3774 }
3777 NULL, NULL, &size);
3778 ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
3779 buf = calloc(1, size);
3780 if (buf)
3781 {
3784 NULL, buf, &size);
3785 ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
3786 free(buf);
3787 }
3788}
3789
3790static const BYTE badFlagsIDP[] = { 0x30,0x06,0x81,0x01,0xff,0x82,0x01,0xff };
3791static const BYTE emptyNameIDP[] = { 0x30,0x04,0xa0,0x02,0xa0,0x00 };
3792static const BYTE urlIDP[] = { 0x30,0x17,0xa0,0x15,0xa0,0x13,0x86,0x11,0x68,
3793 0x74,0x74,0x70,0x3a,0x2f,0x2f,0x77,0x69,0x6e,0x65,0x68,0x71,0x2e,0x6f,0x72,
3794 0x67 };
3795
3797{
3798 BOOL ret;
3799 BYTE *buf = NULL;
3800 DWORD size = 0;
3801 CRL_ISSUING_DIST_POINT point = { { 0 } };
3803
3807 "Expected STATUS_ACCESS_VIOLATION, got %08lx\n", GetLastError());
3810 ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
3811 if (ret)
3812 {
3813 ok(size == sizeof(emptySequence), "Unexpected size %ld\n", size);
3814 ok(!memcmp(buf, emptySequence, size), "Unexpected value\n");
3815 LocalFree(buf);
3816 }
3817 /* nonsensical flags */
3818 point.fOnlyContainsUserCerts = TRUE;
3819 point.fOnlyContainsCACerts = TRUE;
3822 ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
3823 if (ret)
3824 {
3825 ok(size == sizeof(badFlagsIDP), "Unexpected size %ld\n", size);
3826 ok(!memcmp(buf, badFlagsIDP, size), "Unexpected value\n");
3827 LocalFree(buf);
3828 }
3829 /* unimplemented name type */
3830 point.fOnlyContainsCACerts = point.fOnlyContainsUserCerts = FALSE;
3831 point.DistPointName.dwDistPointNameChoice = CRL_DIST_POINT_ISSUER_RDN_NAME;
3835 "Expected E_INVALIDARG, got %08lx\n", GetLastError());
3836 /* empty name */
3837 point.DistPointName.dwDistPointNameChoice = CRL_DIST_POINT_FULL_NAME;
3838 point.DistPointName.FullName.cAltEntry = 0;
3841 ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
3842 if (ret)
3843 {
3844 ok(size == sizeof(emptyNameIDP), "Unexpected size %ld\n", size);
3845 ok(!memcmp(buf, emptyNameIDP, size), "Unexpected value\n");
3846 LocalFree(buf);
3847 }
3848 /* name with URL entry */
3849 entry.dwAltNameChoice = CERT_ALT_NAME_URL;
3850 entry.pwszURL = (LPWSTR)url;
3851 point.DistPointName.FullName.cAltEntry = 1;
3852 point.DistPointName.FullName.rgAltEntry = &entry;
3855 ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
3856 if (ret)
3857 {
3858 ok(size == sizeof(urlIDP), "Unexpected size %ld\n", size);
3859 ok(!memcmp(buf, urlIDP, size), "Unexpected value\n");
3860 LocalFree(buf);
3861 }
3862}
3863
3865 const CERT_ALT_NAME_ENTRY *got)
3866{
3867 ok(expected->dwAltNameChoice == got->dwAltNameChoice,
3868 "Expected name choice %ld, got %ld\n", expected->dwAltNameChoice,
3869 got->dwAltNameChoice);
3870 if (expected->dwAltNameChoice == got->dwAltNameChoice)
3871 {
3872 switch (got->dwAltNameChoice)
3873 {
3877 case CERT_ALT_NAME_URL:
3879 ok((!expected->pwszURL && !got->pwszURL) ||
3880 (!expected->pwszURL && !lstrlenW(got->pwszURL)) ||
3881 (!got->pwszURL && !lstrlenW(expected->pwszURL)) ||
3882 !lstrcmpW(expected->pwszURL, got->pwszURL),
3883 "Unexpected name\n");
3884 break;
3888 ok(got->IPAddress.cbData == expected->IPAddress.cbData,
3889 "Unexpected IP address length %ld\n", got->IPAddress.cbData);
3890 ok(!memcmp(got->IPAddress.pbData, expected->IPAddress.pbData,
3891 got->IPAddress.cbData), "Unexpected value\n");
3892 break;
3893 }
3894 }
3895}
3896
3898 const CERT_ALT_NAME_INFO *got)
3899{
3900 DWORD i;
3901
3902 ok(expected->cAltEntry == got->cAltEntry, "Expected %ld entries, got %ld\n",
3903 expected->cAltEntry, got->cAltEntry);
3904 for (i = 0; i < min(expected->cAltEntry, got->cAltEntry); i++)
3905 compareAltNameEntry(&expected->rgAltEntry[i], &got->rgAltEntry[i]);
3906}
3907
3909 const CRL_DIST_POINT_NAME *got)
3910{
3911 ok(got->dwDistPointNameChoice == expected->dwDistPointNameChoice,
3912 "Unexpected name choice %ld\n", got->dwDistPointNameChoice);
3914 compareAltNameInfo(&(expected->FullName), &(got->FullName));
3915}
3916
3918 const CRL_ISSUING_DIST_POINT *got)
3919{
3920 compareDistPointName(&expected->DistPointName, &got->DistPointName);
3921 ok(got->fOnlyContainsUserCerts == expected->fOnlyContainsUserCerts,
3922 "Unexpected fOnlyContainsUserCerts\n");
3923 ok(got->fOnlyContainsCACerts == expected->fOnlyContainsCACerts,
3924 "Unexpected fOnlyContainsCACerts\n");
3925 ok(got->OnlySomeReasonFlags.cbData == expected->OnlySomeReasonFlags.cbData,
3926 "Unexpected reason flags\n");
3927 ok(got->fIndirectCRL == expected->fIndirectCRL,
3928 "Unexpected fIndirectCRL\n");
3929}
3930
3932{
3933 BOOL ret;
3934 BYTE *buf = NULL;
3935 DWORD size = 0;
3936 CRL_ISSUING_DIST_POINT point = { { 0 } };
3937
3940 &buf, &size);
3941 ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
3942 if (ret)
3943 {
3945 LocalFree(buf);
3946 }
3949 &buf, &size);
3950 ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
3951 if (ret)
3952 {
3953 point.fOnlyContainsUserCerts = point.fOnlyContainsCACerts = TRUE;
3955 LocalFree(buf);
3956 }
3959 &buf, &size);
3960 ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
3961 if (ret)
3962 {
3963 point.fOnlyContainsCACerts = point.fOnlyContainsUserCerts = FALSE;
3964 point.DistPointName.dwDistPointNameChoice = CRL_DIST_POINT_FULL_NAME;
3965 point.DistPointName.FullName.cAltEntry = 0;
3967 LocalFree(buf);
3968 }
3971 ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
3972 if (ret)
3973 {
3975
3976 entry.dwAltNameChoice = CERT_ALT_NAME_URL;
3977 entry.pwszURL = (LPWSTR)url;
3978 point.DistPointName.FullName.cAltEntry = 1;
3979 point.DistPointName.FullName.rgAltEntry = &entry;
3981 LocalFree(buf);
3982 }
3983}
3984
3985static const BYTE v1CRL[] = { 0x30, 0x15, 0x30, 0x02, 0x06, 0x00, 0x18, 0x0f,
3986 0x31, 0x36, 0x30, 0x31, 0x30, 0x31, 0x30, 0x31, 0x30, 0x30, 0x30, 0x30, 0x30,
3987 0x30, 0x5a };
3988static const BYTE v2CRL[] = { 0x30, 0x18, 0x02, 0x01, 0x01, 0x30, 0x02, 0x06,
3989 0x00, 0x18, 0x0f, 0x31, 0x36, 0x30, 0x31, 0x30, 0x31, 0x30, 0x31, 0x30, 0x30,
3990 0x30, 0x30, 0x30, 0x30, 0x5a };
3991static const BYTE v1CRLWithIssuer[] = { 0x30, 0x2c, 0x30, 0x02, 0x06, 0x00,
3992 0x30, 0x15, 0x31, 0x13, 0x30, 0x11, 0x06, 0x03, 0x55, 0x04, 0x03, 0x13, 0x0a,
3993 0x4a, 0x75, 0x61, 0x6e, 0x20, 0x4c, 0x61, 0x6e, 0x67, 0x00, 0x18, 0x0f, 0x31,
3994 0x36, 0x30, 0x31, 0x30, 0x31, 0x30, 0x31, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30,
3995 0x5a };
3996static const BYTE v1CRLWithIssuerAndEmptyEntry[] = { 0x30, 0x43, 0x30, 0x02,
3997 0x06, 0x00, 0x30, 0x15, 0x31, 0x13, 0x30, 0x11, 0x06, 0x03, 0x55, 0x04, 0x03,
3998 0x13, 0x0a, 0x4a, 0x75, 0x61, 0x6e, 0x20, 0x4c, 0x61, 0x6e, 0x67, 0x00, 0x18,
3999 0x0f, 0x31, 0x36, 0x30, 0x31, 0x30, 0x31, 0x30, 0x31, 0x30, 0x30, 0x30, 0x30,
4000 0x30, 0x30, 0x5a, 0x30, 0x15, 0x30, 0x13, 0x02, 0x00, 0x18, 0x0f, 0x31, 0x36,
4001 0x30, 0x31, 0x30, 0x31, 0x30, 0x31, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x5a };
4002static const BYTE v1CRLWithIssuerAndEntry[] = { 0x30, 0x44, 0x30, 0x02, 0x06,
4003 0x00, 0x30, 0x15, 0x31, 0x13, 0x30, 0x11, 0x06, 0x03, 0x55, 0x04, 0x03, 0x13,
4004 0x0a, 0x4a, 0x75, 0x61, 0x6e, 0x20, 0x4c, 0x61, 0x6e, 0x67, 0x00, 0x18, 0x0f,
4005 0x31, 0x36, 0x30, 0x31, 0x30, 0x31, 0x30, 0x31, 0x30, 0x30, 0x30, 0x30, 0x30,
4006 0x30, 0x5a, 0x30, 0x16, 0x30, 0x14, 0x02, 0x01, 0x01, 0x18, 0x0f, 0x31, 0x36,
4007 0x30, 0x31, 0x30, 0x31, 0x30, 0x31, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x5a };
4008static const BYTE v1CRLWithEntryExt[] = { 0x30,0x5a,0x30,0x02,0x06,0x00,0x30,
4009 0x15,0x31,0x13,0x30,0x11,0x06,0x03,0x55,0x04,0x03,0x13,0x0a,0x4a,0x75,0x61,
4010 0x6e,0x20,0x4c,0x61,0x6e,0x67,0x00,0x18,0x0f,0x31,0x36,0x30,0x31,0x30,0x31,
4011 0x30,0x31,0x30,0x30,0x30,0x30,0x30,0x30,0x5a,0x30,0x2c,0x30,0x2a,0x02,0x01,
4012 0x01,0x18,0x0f,0x31,0x36,0x30,0x31,0x30,0x31,0x30,0x31,0x30,0x30,0x30,0x30,
4013 0x30,0x30,0x5a,0x30,0x14,0x30,0x12,0x06,0x03,0x55,0x1d,0x13,0x01,0x01,0xff,
4014 0x04,0x08,0x30,0x06,0x01,0x01,0xff,0x02,0x01,0x01 };
4015static const BYTE v1CRLWithExt[] = { 0x30,0x5c,0x30,0x02,0x06,0x00,0x30,0x15,
4016 0x31,0x13,0x30,0x11,0x06,0x03,0x55,0x04,0x03,0x13,0x0a,0x4a,0x75,0x61,0x6e,
4017 0x20,0x4c,0x61,0x6e,0x67,0x00,0x18,0x0f,0x31,0x36,0x30,0x31,0x30,0x31,0x30,
4018 0x31,0x30,0x30,0x30,0x30,0x30,0x30,0x5a,0x30,0x16,0x30,0x14,0x02,0x01,0x01,
4019 0x18,0x0f,0x31,0x36,0x30,0x31,0x30,0x31,0x30,0x31,0x30,0x30,0x30,0x30,0x30,
4020 0x30,0x5a,0xa0,0x16,0x30,0x14,0x30,0x12,0x06,0x03,0x55,0x1d,0x13,0x01,0x01,
4021 0xff,0x04,0x08,0x30,0x06,0x01,0x01,0xff,0x02,0x01,0x01 };
4022static const BYTE v2CRLWithExt[] = { 0x30,0x5c,0x02,0x01,0x01,0x30,0x02,0x06,
4023 0x00,0x30,0x15,0x31,0x13,0x30,0x11,0x06,0x03,0x55,0x04,0x03,0x13,0x0a,0x4a,
4024 0x75,0x61,0x6e,0x20,0x4c,0x61,0x6e,0x67,0x00,0x18,0x0f,0x31,0x36,0x30,0x31,
4025 0x30,0x31,0x30,0x31,0x30,0x30,0x30,0x30,0x30,0x30,0x5a,0x30,0x16,0x30,0x14,
4026 0x02,0x01,0x01,0x18,0x0f,0x31,0x36,0x30,0x31,0x30,0x31,0x30,0x31,0x30,0x30,
4027 0x30,0x30,0x30,0x30,0x5a,0xa0,0x13,0x30,0x11,0x30,0x0f,0x06,0x03,0x55,0x1d,
4028 0x13,0x04,0x08,0x30,0x06,0x01,0x01,0xff,0x02,0x01,0x01 };
4029
4030static void test_encodeCRLToBeSigned(DWORD dwEncoding)
4031{
4032 BOOL ret;
4033 BYTE *buf = NULL;
4034 DWORD size = 0;
4035 CRL_INFO info = { 0 };
4036 CRL_ENTRY entry = { { 0 }, { 0 }, 0, 0 };
4037
4038 /* Test with a V1 CRL */
4041 ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
4042 if (ret)
4043 {
4044 ok(size == sizeof(v1CRL), "Wrong size %ld\n", size);
4045 ok(!memcmp(buf, v1CRL, size), "Got unexpected value\n");
4046 LocalFree(buf);
4047 }
4048 /* Test v2 CRL */
4049 info.dwVersion = CRL_V2;
4052 ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
4053 if (ret)
4054 {
4055 ok(size == v2CRL[1] + 2, "Expected size %d, got %ld\n",
4056 v2CRL[1] + 2, size);
4057 ok(!memcmp(buf, v2CRL, size), "Got unexpected value\n");
4058 LocalFree(buf);
4059 }
4060 /* v1 CRL with a name */
4061 info.dwVersion = CRL_V1;
4062 info.Issuer.cbData = sizeof(encodedCommonName);
4063 info.Issuer.pbData = (BYTE *)encodedCommonName;
4066 ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
4067 if (ret)
4068 {
4069 ok(size == sizeof(v1CRLWithIssuer), "Wrong size %ld\n", size);
4070 ok(!memcmp(buf, v1CRLWithIssuer, size), "Got unexpected value\n");
4071 LocalFree(buf);
4072 }
4073
4074 /* v1 CRL with a name and a NULL entry pointer */
4075 info.cCRLEntry = 1;
4079 "Expected STATUS_ACCESS_VIOLATION, got %08lx\n", GetLastError());
4080
4081 /* now set an empty entry */
4082 info.cCRLEntry = 1;
4083 info.rgCRLEntry = &entry;
4086 if (ret)
4087 {
4089 "Wrong size %ld\n", size);
4091 "Got unexpected value\n");
4092 LocalFree(buf);
4093 }
4094 /* an entry with a serial number */
4095 entry.SerialNumber.cbData = sizeof(serialNum);
4096 entry.SerialNumber.pbData = (BYTE *)serialNum;
4099 if (ret)
4100 {
4101 ok(size == sizeof(v1CRLWithIssuerAndEntry),
4102 "Wrong size %ld\n", size);
4104 "Got unexpected value\n");
4105 LocalFree(buf);
4106 }
4107 /* an entry with an extension */
4108 entry.cExtension = 1;
4109 entry.rgExtension = &criticalExt;
4112 ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
4113 if (ret)
4114 {
4115 ok(size == sizeof(v1CRLWithEntryExt), "Wrong size %ld\n", size);
4116 ok(!memcmp(buf, v1CRLWithEntryExt, size), "Got unexpected value\n");
4117 LocalFree(buf);
4118 }
4119 /* a CRL with an extension */
4120 entry.cExtension = 0;
4121 info.cExtension = 1;
4122 info.rgExtension = &criticalExt;
4125 ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
4126 if (ret)
4127 {
4128 ok(size == sizeof(v1CRLWithExt), "Wrong size %ld\n", size);
4129 ok(!memcmp(buf, v1CRLWithExt, size), "Got unexpected value\n");
4130 LocalFree(buf);
4131 }
4132 /* a v2 CRL with an extension, this time non-critical */
4133 info.dwVersion = CRL_V2;
4134 info.rgExtension = &nonCriticalExt;
4137 ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
4138 if (ret)
4139 {
4140 ok(size == sizeof(v2CRLWithExt), "Wrong size %ld\n", size);
4141 ok(!memcmp(buf, v2CRLWithExt, size), "Got unexpected value\n");
4142 LocalFree(buf);
4143 }
4144}
4145
4146static const BYTE verisignCRL[] = { 0x30, 0x82, 0x01, 0xb1, 0x30, 0x82, 0x01,
4147 0x1a, 0x02, 0x01, 0x01, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7,
4148 0x0d, 0x01, 0x01, 0x02, 0x05, 0x00, 0x30, 0x61, 0x31, 0x11, 0x30, 0x0f, 0x06,
4149 0x03, 0x55, 0x04, 0x07, 0x13, 0x08, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65,
4150 0x74, 0x31, 0x17, 0x30, 0x15, 0x06, 0x03, 0x55, 0x04, 0x0a, 0x13, 0x0e, 0x56,
4151 0x65, 0x72, 0x69, 0x53, 0x69, 0x67, 0x6e, 0x2c, 0x20, 0x49, 0x6e, 0x63, 0x2e,
4152 0x31, 0x33, 0x30, 0x31, 0x06, 0x03, 0x55, 0x04, 0x0b, 0x13, 0x2a, 0x56, 0x65,
4153 0x72, 0x69, 0x53, 0x69, 0x67, 0x6e, 0x20, 0x43, 0x6f, 0x6d, 0x6d, 0x65, 0x72,
4154 0x63, 0x69, 0x61, 0x6c, 0x20, 0x53, 0x6f, 0x66, 0x74, 0x77, 0x61, 0x72, 0x65,
4155 0x20, 0x50, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x65, 0x72, 0x73, 0x20, 0x43,
4156 0x41, 0x17, 0x0d, 0x30, 0x31, 0x30, 0x33, 0x32, 0x34, 0x30, 0x30, 0x30, 0x30,
4157 0x30, 0x30, 0x5a, 0x17, 0x0d, 0x30, 0x34, 0x30, 0x31, 0x30, 0x37, 0x32, 0x33,
4158 0x35, 0x39, 0x35, 0x39, 0x5a, 0x30, 0x69, 0x30, 0x21, 0x02, 0x10, 0x1b, 0x51,
4159 0x90, 0xf7, 0x37, 0x24, 0x39, 0x9c, 0x92, 0x54, 0xcd, 0x42, 0x46, 0x37, 0x99,
4160 0x6a, 0x17, 0x0d, 0x30, 0x31, 0x30, 0x31, 0x33, 0x30, 0x30, 0x30, 0x30, 0x31,
4161 0x32, 0x34, 0x5a, 0x30, 0x21, 0x02, 0x10, 0x75, 0x0e, 0x40, 0xff, 0x97, 0xf0,
4162 0x47, 0xed, 0xf5, 0x56, 0xc7, 0x08, 0x4e, 0xb1, 0xab, 0xfd, 0x17, 0x0d, 0x30,
4163 0x31, 0x30, 0x31, 0x33, 0x31, 0x30, 0x30, 0x30, 0x30, 0x34, 0x39, 0x5a, 0x30,
4164 0x21, 0x02, 0x10, 0x77, 0xe6, 0x5a, 0x43, 0x59, 0x93, 0x5d, 0x5f, 0x7a, 0x75,
4165 0x80, 0x1a, 0xcd, 0xad, 0xc2, 0x22, 0x17, 0x0d, 0x30, 0x30, 0x30, 0x38, 0x33,
4166 0x31, 0x30, 0x30, 0x30, 0x30, 0x35, 0x36, 0x5a, 0xa0, 0x1a, 0x30, 0x18, 0x30,
4167 0x09, 0x06, 0x03, 0x55, 0x1d, 0x13, 0x04, 0x02, 0x30, 0x00, 0x30, 0x0b, 0x06,
4168 0x03, 0x55, 0x1d, 0x0f, 0x04, 0x04, 0x03, 0x02, 0x05, 0xa0, 0x30, 0x0d, 0x06,
4169 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x02, 0x05, 0x00, 0x03,
4170 0x81, 0x81, 0x00, 0x18, 0x2c, 0xe8, 0xfc, 0x16, 0x6d, 0x91, 0x4a, 0x3d, 0x88,
4171 0x54, 0x48, 0x5d, 0xb8, 0x11, 0xbf, 0x64, 0xbb, 0xf9, 0xda, 0x59, 0x19, 0xdd,
4172 0x0e, 0x65, 0xab, 0xc0, 0x0c, 0xfa, 0x67, 0x7e, 0x21, 0x1e, 0x83, 0x0e, 0xcf,
4173 0x9b, 0x89, 0x8a, 0xcf, 0x0c, 0x4b, 0xc1, 0x39, 0x9d, 0xe7, 0x6a, 0xac, 0x46,
4174 0x74, 0x6a, 0x91, 0x62, 0x22, 0x0d, 0xc4, 0x08, 0xbd, 0xf5, 0x0a, 0x90, 0x7f,
4175 0x06, 0x21, 0x3d, 0x7e, 0xa7, 0xaa, 0x5e, 0xcd, 0x22, 0x15, 0xe6, 0x0c, 0x75,
4176 0x8e, 0x6e, 0xad, 0xf1, 0x84, 0xe4, 0x22, 0xb4, 0x30, 0x6f, 0xfb, 0x64, 0x8f,
4177 0xd7, 0x80, 0x43, 0xf5, 0x19, 0x18, 0x66, 0x1d, 0x72, 0xa3, 0xe3, 0x94, 0x82,
4178 0x28, 0x52, 0xa0, 0x06, 0x4e, 0xb1, 0xc8, 0x92, 0x0c, 0x97, 0xbe, 0x15, 0x07,
4179 0xab, 0x7a, 0xc9, 0xea, 0x08, 0x67, 0x43, 0x4d, 0x51, 0x63, 0x3b, 0x9c, 0x9c,
4180 0xcd };
41820x30,0x82,0x1d,0xbd,0x30,0x82,0x1d,0x26,0x30,0x0d,0x06,0x09,0x2a,0x86,0x48,
41830x86,0xf7,0x0d,0x01,0x01,0x04,0x05,0x00,0x30,0x61,0x31,0x11,0x30,0x0f,0x06,
41840x03,0x55,0x04,0x07,0x13,0x08,0x49,0x6e,0x74,0x65,0x72,0x6e,0x65,0x74,0x31,
41850x17,0x30,0x15,0x06,0x03,0x55,0x04,0x0a,0x13,0x0e,0x56,0x65,0x72,0x69,0x53,
41860x69,0x67,0x6e,0x2c,0x20,0x49,0x6e,0x63,0x2e,0x31,0x33,0x30,0x31,0x06,0x03,
41870x55,0x04,0x0b,0x13,0x2a,0x56,0x65,0x72,0x69,0x53,0x69,0x67,0x6e,0x20,0x43,
41880x6f,0x6d,0x6d,0x65,0x72,0x63,0x69,0x61,0x6c,0x20,0x53,0x6f,0x66,0x74,0x77,
41890x61,0x72,0x65,0x20,0x50,0x75,0x62,0x6c,0x69,0x73,0x68,0x65,0x72,0x73,0x20,
41900x43,0x41,0x17,0x0d,0x30,0x34,0x30,0x33,0x33,0x31,0x30,0x30,0x30,0x30,0x30,
41910x30,0x5a,0x17,0x0d,0x30,0x34,0x30,0x35,0x33,0x31,0x32,0x33,0x35,0x39,0x35,
41920x39,0x5a,0x30,0x82,0x1c,0x92,0x30,0x21,0x02,0x10,0x01,0x22,0xb8,0xb2,0xf3,
41930x76,0x42,0xcc,0x48,0x71,0xb6,0x11,0xbf,0xd1,0xcf,0xda,0x17,0x0d,0x30,0x32,
41940x30,0x34,0x31,0x35,0x31,0x35,0x34,0x30,0x32,0x34,0x5a,0x30,0x21,0x02,0x10,
41950x01,0x83,0x93,0xfb,0x96,0xde,0x1d,0x89,0x4e,0xc3,0x47,0x9c,0xe1,0x60,0x13,
41960x63,0x17,0x0d,0x30,0x32,0x30,0x35,0x30,0x39,0x31,0x33,0x35,0x37,0x35,0x38,
41970x5a,0x30,0x21,0x02,0x10,0x01,0xdc,0xdb,0x63,0xd4,0xc9,0x9f,0x31,0xb8,0x16,
41980xf9,0x2c,0xf5,0xb1,0x08,0x8e,0x17,0x0d,0x30,0x32,0x30,0x34,0x31,0x38,0x31,
41990x37,0x34,0x36,0x31,0x34,0x5a,0x30,0x21,0x02,0x10,0x02,0x1a,0xa6,0xaf,0x94,
42000x71,0xf0,0x07,0x6e,0xf1,0x17,0xe4,0xd4,0x17,0x82,0xdb,0x17,0x0d,0x30,0x32,
42010x30,0x37,0x31,0x39,0x32,0x31,0x32,0x38,0x33,0x31,0x5a,0x30,0x21,0x02,0x10,
42020x02,0x4c,0xe8,0x9d,0xfd,0x5f,0x77,0x4d,0x4b,0xf5,0x79,0x8b,0xb1,0x08,0x67,
42030xac,0x17,0x0d,0x30,0x32,0x30,0x32,0x31,0x32,0x30,0x36,0x31,0x36,0x35,0x30,
42040x5a,0x30,0x21,0x02,0x10,0x02,0x59,0xae,0x6c,0x4c,0x21,0xf1,0x59,0x49,0x87,
42050xb0,0x95,0xf9,0x65,0xf3,0x20,0x17,0x0d,0x30,0x33,0x30,0x36,0x31,0x39,0x30,
42060x38,0x30,0x34,0x34,0x37,0x5a,0x30,0x21,0x02,0x10,0x03,0x3c,0x41,0x0e,0x2f,
42070x42,0x5c,0x32,0x2c,0xb1,0x35,0xfe,0xe7,0x61,0x97,0xa5,0x17,0x0d,0x30,0x32,
42080x30,0x34,0x32,0x34,0x31,0x39,0x34,0x37,0x30,0x32,0x5a,0x30,0x21,0x02,0x10,
42090x03,0x4e,0x68,0xfa,0x8b,0xb2,0x8e,0xb9,0x72,0xea,0x72,0xe5,0x3b,0x15,0xac,
42100x8b,0x17,0x0d,0x30,0x32,0x30,0x39,0x32,0x36,0x32,0x31,0x35,0x31,0x35,0x31,
42110x5a,0x30,0x21,0x02,0x10,0x03,0xc9,0xa8,0xe3,0x48,0xb0,0x5f,0xcf,0x08,0xee,
42120xb9,0x93,0xf9,0xe9,0xaf,0x0c,0x17,0x0d,0x30,0x32,0x30,0x34,0x31,0x38,0x31,
42130x33,0x34,0x39,0x32,0x32,0x5a,0x30,0x21,0x02,0x10,0x04,0x9b,0x23,0x6a,0x37,
42140x5c,0x06,0x98,0x0a,0x31,0xc8,0x86,0xdc,0x3a,0x95,0xcc,0x17,0x0d,0x30,0x32,
42150x31,0x30,0x30,0x31,0x32,0x32,0x31,0x30,0x35,0x36,0x5a,0x30,0x21,0x02,0x10,
42160x06,0x08,0xba,0xc7,0xac,0xf8,0x5a,0x7c,0xa1,0xf4,0x25,0x85,0xbb,0x4e,0x8c,
42170x4f,0x17,0x0d,0x30,0x33,0x30,0x31,0x30,0x33,0x30,0x37,0x35,0x37,0x31,0x34,
42180x5a,0x30,0x21,0x02,0x10,0x07,0x66,0x22,0x4a,0x4a,0x9d,0xff,0x6e,0xb5,0x11,
42190x0b,0xa9,0x94,0xfc,0x68,0x20,0x17,0x0d,0x30,0x32,0x30,0x38,0x32,0x32,0x30,
42200x31,0x34,0x30,0x31,0x32,0x5a,0x30,0x21,0x02,0x10,0x07,0x8f,0xa1,0x4d,0xb5,
42210xfc,0x0c,0xc6,0x42,0x72,0x88,0x37,0x76,0x29,0x44,0x31,0x17,0x0d,0x30,0x32,
42220x30,0x33,0x31,0x35,0x32,0x30,0x31,0x39,0x34,0x39,0x5a,0x30,0x21,0x02,0x10,
42230x07,0xb9,0xd9,0x42,0x19,0x81,0xc4,0xfd,0x49,0x4f,0x72,0xce,0xf2,0xf8,0x6d,
42240x76,0x17,0x0d,0x30,0x32,0x30,0x32,0x31,0x35,0x31,0x35,0x33,0x37,0x31,0x39,
42250x5a,0x30,0x21,0x02,0x10,0x08,0x6e,0xf9,0x6c,0x7f,0xbf,0xbc,0xc8,0x86,0x70,
42260x62,0x3f,0xe9,0xc4,0x2f,0x2b,0x17,0x0d,0x30,0x32,0x31,0x31,0x32,0x38,0x30,
42270x30,0x32,0x38,0x31,0x34,0x5a,0x30,0x21,0x02,0x10,0x09,0x08,0xe4,0xaa,0xf5,
42280x2d,0x2b,0xc0,0x15,0x9e,0x00,0x8b,0x3f,0x97,0x93,0xf9,0x17,0x0d,0x30,0x33,
42290x30,0x32,0x31,0x32,0x32,0x32,0x30,0x30,0x32,0x33,0x5a,0x30,0x21,0x02,0x10,
42300x09,0x13,0x0a,0x4f,0x0f,0x88,0xe5,0x50,0x05,0xc3,0x5f,0xf4,0xff,0x15,0x39,
42310xdd,0x17,0x0d,0x30,0x32,0x30,0x33,0x30,0x36,0x30,0x38,0x31,0x31,0x33,0x30,
42320x5a,0x30,0x21,0x02,0x10,0x09,0x8d,0xdd,0x37,0xda,0xe7,0x84,0x03,0x9d,0x98,
42330x96,0xf8,0x88,0x3a,0x55,0xca,0x17,0x0d,0x30,0x32,0x30,0x32,0x32,0x31,0x32,
42340x33,0x33,0x35,0x32,0x36,0x5a,0x30,0x21,0x02,0x10,0x0a,0x35,0x0c,0xd7,0xf4,
42350x53,0xe6,0xc1,0x4e,0xf2,0x2a,0xd3,0xce,0xf8,0x7c,0xe7,0x17,0x0d,0x30,0x32,
42360x30,0x38,0x30,0x32,0x32,0x32,0x32,0x34,0x32,0x38,0x5a,0x30,0x21,0x02,0x10,
42370x0b,0x9c,0xb8,0xf8,0xfb,0x35,0x38,0xf2,0x91,0xfd,0xa1,0xe9,0x69,0x4a,0xb1,
42380x24,0x17,0x0d,0x30,0x33,0x30,0x34,0x30,0x38,0x30,0x31,0x30,0x32,0x32,0x32,
42390x5a,0x30,0x21,0x02,0x10,0x0c,0x2f,0x7f,0x32,0x15,0xe0,0x2f,0x74,0xfa,0x05,
42400x22,0x67,0xbc,0x8a,0x2d,0xd0,0x17,0x0d,0x30,0x32,0x30,0x32,0x32,0x36,0x31,
42410x39,0x30,0x37,0x35,0x34,0x5a,0x30,0x21,0x02,0x10,0x0c,0x32,0x5b,0x78,0x32,
42420xc6,0x7c,0xd8,0xdd,0x25,0x91,0x22,0x4d,0x84,0x0a,0x94,0x17,0x0d,0x30,0x32,
42430x30,0x33,0x31,0x38,0x31,0x32,0x33,0x39,0x30,0x33,0x5a,0x30,0x21,0x02,0x10,
42440x0d,0x76,0x36,0xb9,0x1c,0x72,0xb7,0x9d,0xdf,0xa5,0x35,0x82,0xc5,0xa8,0xf7,
42450xbb,0x17,0x0d,0x30,0x32,0x30,0x38,0x32,0x37,0x32,0x31,0x34,0x32,0x31,0x31,
42460x5a,0x30,0x21,0x02,0x10,0x0f,0x28,0x79,0x98,0x56,0xb8,0xa5,0x5e,0xeb,0x79,
42470x5f,0x1b,0xed,0x0b,0x86,0x76,0x17,0x0d,0x30,0x32,0x30,0x33,0x31,0x33,0x30,
42480x31,0x31,0x30,0x34,0x37,0x5a,0x30,0x21,0x02,0x10,0x0f,0x80,0x3c,0x24,0xf4,
42490x62,0x27,0x24,0xbe,0x6a,0x74,0x9c,0x18,0x8e,0x4b,0x3b,0x17,0x0d,0x30,0x32,
42500x31,0x31,0x32,0x30,0x31,0x37,0x31,0x31,0x33,0x35,0x5a,0x30,0x21,0x02,0x10,
42510x0f,0xf2,0xa7,0x8c,0x80,0x9c,0xbe,0x2f,0xc8,0xa9,0xeb,0xfe,0x94,0x86,0x5a,
42520x5c,0x17,0x0d,0x30,0x32,0x30,0x36,0x32,0x30,0x31,0x39,0x35,0x38,0x34,0x35,
42530x5a,0x30,0x21,0x02,0x10,0x10,0x45,0x13,0x35,0x45,0xf3,0xc6,0x02,0x8d,0x8d,
42540x18,0xb1,0xc4,0x0a,0x7a,0x18,0x17,0x0d,0x30,0x32,0x30,0x34,0x32,0x36,0x31,
42550x37,0x33,0x32,0x35,0x39,0x5a,0x30,0x21,0x02,0x10,0x10,0x79,0xb1,0x71,0x1b,
42560x26,0x98,0x92,0x08,0x1e,0x3c,0xe4,0x8b,0x29,0x37,0xf9,0x17,0x0d,0x30,0x32,
42570x30,0x33,0x32,0x38,0x31,0x36,0x33,0x32,0x35,0x35,0x5a,0x30,0x21,0x02,0x10,
42580x11,0x38,0x80,0x77,0xcb,0x6b,0xe5,0xd6,0xa7,0xf2,0x99,0xa1,0xc8,0xe9,0x40,
42590x25,0x17,0x0d,0x30,0x32,0x30,0x34,0x31,0x39,0x31,0x32,0x32,0x34,0x31,0x37,
42600x5a,0x30,0x21,0x02,0x10,0x11,0x7a,0xc3,0x82,0xfe,0x74,0x36,0x11,0x21,0xd6,
42610x92,0x86,0x09,0xdf,0xe6,0xf3,0x17,0x0d,0x30,0x32,0x30,0x32,0x31,0x39,0x31,
42620x35,0x31,0x31,0x33,0x36,0x5a,0x30,0x21,0x02,0x10,0x11,0xab,0x8e,0x21,0x28,
42630x7f,0x6d,0xf2,0xc1,0xc8,0x40,0x3e,0xa5,0xde,0x98,0xd3,0x17,0x0d,0x30,0x32,
42640x30,0x35,0x30,0x32,0x31,0x38,0x34,0x34,0x33,0x31,0x5a,0x30,0x21,0x02,0x10,
42650x12,0x3c,0x38,0xae,0x3f,0x64,0x53,0x3a,0xf7,0xbc,0x6c,0x27,0xe2,0x9c,0x65,
42660x75,0x17,0x0d,0x30,0x32,0x30,0x32,0x31,0x33,0x32,0x33,0x30,0x38,0x35,0x39,
42670x5a,0x30,0x21,0x02,0x10,0x12,0x88,0xb6,0x6c,0x9b,0xcf,0xe7,0x50,0x92,0xd2,
42680x87,0x63,0x8f,0xb7,0xa6,0xe3,0x17,0x0d,0x30,0x32,0x30,0x37,0x30,0x32,0x32,
42690x30,0x35,0x35,0x30,0x33,0x5a,0x30,0x21,0x02,0x10,0x12,0x95,0x4e,0xb6,0x8f,
42700x3a,0x19,0x6a,0x16,0x73,0x4f,0x6e,0x15,0xba,0xa5,0xe7,0x17,0x0d,0x30,0x32,
42710x30,0x36,0x31,0x37,0x31,0x38,0x35,0x36,0x30,0x31,0x5a,0x30,0x21,0x02,0x10,
42720x13,0x37,0x0b,0x41,0x8c,0x31,0x43,0x1c,0x27,0xaa,0xe1,0x83,0x0f,0x99,0x21,
42730xcd,0x17,0x0d,0x30,0x32,0x30,0x37,0x32,0x32,0x31,0x32,0x31,0x37,0x31,0x36,
42740x5a,0x30,0x21,0x02,0x10,0x14,0x7a,0x29,0x0a,0x09,0x38,0xf4,0x53,0x28,0x33,
42750x6f,0x37,0x07,0x23,0x12,0x10,0x17,0x0d,0x30,0x32,0x30,0x32,0x32,0x32,0x30,
42760x32,0x30,0x30,0x31,0x34,0x5a,0x30,0x21,0x02,0x10,0x15,0x04,0x81,0x1e,0xe2,
42770x6f,0xf0,0xd8,0xdd,0x12,0x55,0x05,0x66,0x51,0x6e,0x1a,0x17,0x0d,0x30,0x32,
42780x30,0x33,0x31,0x33,0x31,0x30,0x35,0x33,0x30,0x38,0x5a,0x30,0x21,0x02,0x10,
42790x15,0x30,0x0d,0x8a,0xbd,0x0e,0x89,0x0e,0x66,0x4f,0x49,0x93,0xa2,0x8f,0xbc,
42800x2e,0x17,0x0d,0x30,0x32,0x30,0x34,0x30,0x34,0x30,0x36,0x34,0x32,0x32,0x33,
42810x5a,0x30,0x21,0x02,0x10,0x16,0xbe,0x64,0xd6,0x4f,0x90,0xf4,0xf7,0x2b,0xc8,
42820xca,0x67,0x5c,0x82,0x13,0xe8,0x17,0x0d,0x30,0x32,0x30,0x36,0x30,0x36,0x31,
42830x39,0x30,0x39,0x30,0x37,0x5a,0x30,0x21,0x02,0x10,0x18,0x51,0x9c,0xe4,0x48,
42840x62,0x06,0xfe,0xb8,0x2d,0x93,0xb7,0xc9,0xc9,0x1b,0x4e,0x17,0x0d,0x30,0x32,
42850x30,0x34,0x31,0x37,0x30,0x35,0x30,0x30,0x34,0x34,0x5a,0x30,0x21,0x02,0x10,
42860x19,0x82,0xdb,0x39,0x74,0x00,0x38,0x36,0x59,0xf6,0xcc,0xc1,0x23,0x8d,0x40,
42870xe9,0x17,0x0d,0x30,0x32,0x30,0x33,0x30,0x36,0x30,0x37,0x35,0x34,0x35,0x34,
42880x5a,0x30,0x21,0x02,0x10,0x1b,0x51,0x90,0xf7,0x37,0x24,0x39,0x9c,0x92,0x54,
42890xcd,0x42,0x46,0x37,0x99,0x6a,0x17,0x0d,0x30,0x31,0x30,0x31,0x33,0x30,0x30,
42900x30,0x30,0x30,0x30,0x30,0x5a,0x30,0x21,0x02,0x10,0x1b,0xe4,0xb2,0xbb,0xb6,
42910x74,0x5d,0x6b,0x8b,0x04,0xb6,0xa0,0x1b,0x35,0xeb,0x29,0x17,0x0d,0x30,0x32,
42920x30,0x39,0x32,0x35,0x32,0x30,0x31,0x34,0x35,0x36,0x5a,0x30,0x21,0x02,0x10,
42930x1c,0x1d,0xd5,0x2a,0xf6,0xaa,0xfd,0xbb,0x47,0xc2,0x73,0x36,0xcf,0x53,0xbd,
42940x81,0x17,0x0d,0x30,0x32,0x30,0x32,0x31,0x33,0x31,0x39,0x30,0x33,0x34,0x32,
42950x5a,0x30,0x21,0x02,0x10,0x1c,0xb0,0x5a,0x1f,0xfd,0xa6,0x98,0xf6,0x46,0xf9,
42960x32,0x10,0x9e,0xef,0x52,0x8e,0x17,0x0d,0x30,0x32,0x30,0x36,0x32,0x37,0x31,
42970x33,0x30,0x33,0x32,0x32,0x5a,0x30,0x21,0x02,0x10,0x1d,0x01,0xfc,0xa7,0xdd,
42980xb4,0x0c,0x64,0xbd,0x65,0x45,0xe6,0xbf,0x1c,0x7e,0x90,0x17,0x0d,0x30,0x32,
42990x30,0x32,0x32,0x31,0x30,0x34,0x32,0x30,0x30,0x36,0x5a,0x30,0x21,0x02,0x10,
43000x1e,0x4d,0xc9,0xc6,0x6e,0x57,0xda,0x8a,0x07,0x97,0x70,0xfa,0xee,0x9c,0xc5,
43010x58,0x17,0x0d,0x30,0x32,0x30,0x32,0x31,0x39,0x32,0x32,0x33,0x34,0x32,0x31,
43020x5a,0x30,0x21,0x02,0x10,0x1e,0xbb,0x9b,0x28,0x61,0x50,0x7f,0x12,0x30,0xfb,
43030x02,0xb5,0xe1,0xb0,0x7e,0x9d,0x17,0x0d,0x30,0x32,0x30,0x33,0x30,0x36,0x30,
43040x30,0x30,0x34,0x32,0x30,0x5a,0x30,0x21,0x02,0x10,0x1f,0x5a,0x64,0xc9,0xa5,
43050x51,0x8c,0xe2,0x2d,0x50,0x83,0xc2,0x4c,0x7c,0xe7,0x85,0x17,0x0d,0x30,0x32,
43060x30,0x38,0x32,0x34,0x30,0x36,0x33,0x31,0x32,0x38,0x5a,0x30,0x21,0x02,0x10,
43070x1f,0xc2,0x4e,0xd0,0xac,0x52,0xd3,0x39,0x18,0x6d,0xd0,0x0f,0x23,0xd7,0x45,
43080x72,0x17,0x0d,0x30,0x32,0x30,0x32,0x32,0x38,0x31,0x39,0x31,0x35,0x34,0x32,
43090x5a,0x30,0x20,0x02,0x0f,0x24,0x60,0x7a,0x8e,0x0e,0x86,0xa4,0x88,0x68,0xaf,
43100xd9,0x0c,0x6b,0xba,0xff,0x17,0x0d,0x30,0x32,0x30,0x32,0x32,0x38,0x30,0x35,
43110x31,0x38,0x32,0x34,0x5a,0x30,0x21,0x02,0x10,0x20,0x41,0x73,0xbb,0x72,0x88,
43120x6e,0x4b,0x1c,0xb6,0x70,0x02,0x67,0xaa,0x3b,0x3d,0x17,0x0d,0x30,0x32,0x30,
43130x39,0x30,0x33,0x31,0x37,0x30,0x36,0x32,0x31,0x5a,0x30,0x21,0x02,0x10,0x20,
43140x6e,0x0d,0xdc,0x8c,0xa4,0xac,0xf7,0x08,0x77,0x5c,0x80,0xf9,0xa3,0x68,0x92,
43150x17,0x0d,0x30,0x32,0x30,0x34,0x31,0x30,0x32,0x30,0x35,0x37,0x31,0x36,0x5a,
43160x30,0x21,0x02,0x10,0x21,0xe4,0x6b,0x98,0x47,0x91,0xe6,0x02,0xdf,0xb2,0x45,
43170xbc,0x31,0x37,0xa0,0x7c,0x17,0x0d,0x30,0x32,0x30,0x33,0x30,0x38,0x32,0x33,
43180x32,0x33,0x31,0x33,0x5a,0x30,0x21,0x02,0x10,0x22,0x00,0x95,0x70,0x79,0xf9,
43190x9c,0x34,0x91,0xbb,0x84,0xb9,0x91,0xde,0x22,0x55,0x17,0x0d,0x30,0x32,0x30,
43200x32,0x31,0x33,0x30,0x36,0x35,0x39,0x33,0x39,0x5a,0x30,0x21,0x02,0x10,0x22,
43210xf9,0x67,0x4f,0xcd,0x29,0xc6,0xdc,0xc8,0x22,0x6e,0xe9,0x0a,0xa1,0x48,0x5a,
43220x17,0x0d,0x30,0x32,0x30,0x34,0x30,0x33,0x30,0x30,0x34,0x33,0x32,0x36,0x5a,
43230x30,0x21,0x02,0x10,0x24,0xa3,0xa7,0xd0,0xb8,0x1d,0x1c,0xf7,0xe6,0x1f,0x6e,
43240xba,0xc9,0x98,0x59,0xed,0x17,0x0d,0x30,0x33,0x30,0x37,0x32,0x34,0x32,0x30,
43250x35,0x38,0x30,0x32,0x5a,0x30,0x21,0x02,0x10,0x24,0xef,0x89,0xa1,0x30,0x4f,
43260x51,0x63,0xfe,0xdb,0xdb,0x64,0x6e,0x4c,0x5a,0x81,0x17,0x0d,0x30,0x32,0x30,
43270x37,0x30,0x33,0x30,0x39,0x32,0x31,0x31,0x37,0x5a,0x30,0x21,0x02,0x10,0x25,
43280x08,0xe5,0xac,0xdd,0x6f,0x74,0x44,0x51,0x1a,0xf5,0xdb,0xf8,0xba,0x25,0xe0,
43290x17,0x0d,0x30,0x32,0x30,0x34,0x30,0x39,0x30,0x34,0x31,0x36,0x32,0x32,0x5a,
43300x30,0x21,0x02,0x10,0x25,0x81,0xe8,0x18,0x60,0x88,0xbc,0x1a,0xe9,0x14,0x84,
43310xed,0xd4,0x62,0xf5,0x47,0x17,0x0d,0x30,0x32,0x30,0x38,0x32,0x33,0x30,0x31,
43320x35,0x37,0x31,0x39,0x5a,0x30,0x21,0x02,0x10,0x26,0xe5,0x5c,0xab,0x16,0xec,
43330x61,0x38,0x49,0x2c,0xd2,0xb1,0x48,0x89,0xd5,0x47,0x17,0x0d,0x30,0x32,0x30,
43340x33,0x31,0x33,0x31,0x38,0x30,0x30,0x33,0x38,0x5a,0x30,0x21,0x02,0x10,0x27,
43350xbe,0xda,0x7f,0x4f,0x1f,0x6c,0x76,0x09,0xc0,0x9a,0xaf,0xd4,0x68,0xe2,0x16,
43360x17,0x0d,0x30,0x32,0x30,0x35,0x31,0x30,0x31,0x38,0x33,0x32,0x33,0x30,0x5a,
43370x30,0x21,0x02,0x10,0x28,0x89,0xd0,0xb3,0xb5,0xc4,0x56,0x36,0x9b,0x3e,0x81,
43380x1a,0x21,0x56,0xaa,0x42,0x17,0x0d,0x30,0x32,0x31,0x31,0x30,0x34,0x31,0x31,
43390x30,0x33,0x30,0x38,0x5a,0x30,0x21,0x02,0x10,0x28,0xab,0x93,0x06,0xb1,0x1e,
43400x05,0xe0,0xe1,0x25,0x75,0xc7,0x74,0xcb,0x55,0xa6,0x17,0x0d,0x30,0x33,0x30,
43410x31,0x32,0x34,0x31,0x39,0x34,0x38,0x32,0x33,0x5a,0x30,0x21,0x02,0x10,0x29,
43420xe9,0x3b,0x44,0x8d,0xc3,0x4b,0x80,0x17,0xda,0xe4,0x1c,0x43,0x96,0x83,0x59,
43430x17,0x0d,0x30,0x32,0x30,0x36,0x30,0x37,0x32,0x31,0x34,0x33,0x33,0x39,0x5a,
43440x30,0x21,0x02,0x10,0x2a,0x08,0x64,0x2b,0x48,0xe2,0x17,0x89,0x6a,0x0c,0xf9,
43450x7e,0x10,0x66,0x8f,0xe7,0x17,0x0d,0x30,0x32,0x30,0x38,0x31,0x39,0x31,0x38,
43460x33,0x35,0x32,0x39,0x5a,0x30,0x21,0x02,0x10,0x2a,0x44,0xee,0x91,0x5d,0xe3,
43470xa5,0x2b,0x09,0xf3,0x56,0x59,0xe0,0x8f,0x25,0x22,0x17,0x0d,0x30,0x32,0x30,
43480x32,0x32,0x31,0x31,0x39,0x33,0x31,0x32,0x34,0x5a,0x30,0x21,0x02,0x10,0x2a,
43490x8b,0x4e,0xa5,0xb6,0x06,0xc8,0x48,0x3b,0x0e,0x71,0x1e,0x6b,0xf4,0x16,0xc1,
43500x17,0x0d,0x30,0x32,0x30,0x34,0x33,0x30,0x30,0x39,0x32,0x31,0x31,0x38,0x5a,
43510x30,0x21,0x02,0x10,0x2b,0x03,0xfc,0x2f,0xc2,0x8e,0x38,0x29,0x6f,0xa1,0x0f,
43520xe9,0x47,0x1b,0x35,0xd7,0x17,0x0d,0x30,0x32,0x31,0x31,0x31,0x34,0x32,0x30,
43530x31,0x38,0x33,0x33,0x5a,0x30,0x21,0x02,0x10,0x2c,0x48,0xf7,0xd6,0xd5,0x71,
43540xc0,0xd1,0xbd,0x6a,0x00,0x65,0x1d,0x2d,0xa9,0xdd,0x17,0x0d,0x30,0x32,0x30,
43550x33,0x30,0x36,0x31,0x37,0x32,0x30,0x34,0x33,0x5a,0x30,0x21,0x02,0x10,0x2c,
43560xbf,0x84,0x1d,0xe4,0x58,0x32,0x79,0x32,0x10,0x37,0xde,0xd7,0x94,0xff,0x85,
43570x17,0x0d,0x30,0x32,0x30,0x32,0x32,0x32,0x31,0x39,0x30,0x32,0x32,0x35,0x5a,
43580x30,0x21,0x02,0x10,0x2d,0x03,0x54,0x35,0x54,0x45,0x2c,0x6d,0x39,0xf0,0x1b,
43590x74,0x68,0xde,0xcf,0x93,0x17,0x0d,0x30,0x32,0x30,0x39,0x32,0x33,0x31,0x33,
43600x32,0x33,0x33,0x37,0x5a,0x30,0x21,0x02,0x10,0x2d,0x24,0x94,0x34,0x19,0x92,
43610xb1,0xf2,0x37,0x9d,0x6e,0xc5,0x35,0x93,0xdd,0xf0,0x17,0x0d,0x30,0x32,0x30,
43620x33,0x31,0x35,0x31,0x37,0x31,0x37,0x32,0x37,0x5a,0x30,0x21,0x02,0x10,0x2d,
43630x47,0x24,0x61,0x87,0x91,0xba,0x2e,0xf2,0xf7,0x92,0x21,0xf3,0x1b,0x8b,0x1e,
43640x17,0x0d,0x30,0x32,0x30,0x35,0x31,0x34,0x32,0x33,0x30,0x38,0x32,0x32,0x5a,
43650x30,0x21,0x02,0x10,0x2d,0x84,0xc2,0xb1,0x01,0xa1,0x3a,0x6f,0xb0,0x30,0x13,
43660x76,0x5a,0x69,0xec,0x41,0x17,0x0d,0x30,0x32,0x30,0x37,0x31,0x35,0x31,0x37,
43670x32,0x39,0x32,0x33,0x5a,0x30,0x21,0x02,0x10,0x2d,0xd5,0x26,0xc3,0xcd,0x01,
43680xce,0xfd,0x67,0xb8,0x08,0xac,0x5a,0x70,0xc4,0x34,0x17,0x0d,0x30,0x32,0x30,
43690x32,0x32,0x37,0x30,0x34,0x34,0x36,0x31,0x34,0x5a,0x30,0x21,0x02,0x10,0x2e,
43700x2b,0x0a,0x94,0x4d,0xf1,0xa4,0x37,0xb7,0xa3,0x9b,0x4b,0x96,0x26,0xa8,0xe3,
43710x17,0x0d,0x30,0x33,0x30,0x31,0x30,0x39,0x30,0x36,0x32,0x38,0x32,0x38,0x5a,
43720x30,0x21,0x02,0x10,0x2e,0x31,0x30,0xc1,0x2e,0x16,0x31,0xd9,0x2b,0x0a,0x70,
43730xca,0x3f,0x31,0x73,0x62,0x17,0x0d,0x30,0x33,0x30,0x31,0x32,0x39,0x30,0x31,
43740x34,0x39,0x32,0x37,0x5a,0x30,0x21,0x02,0x10,0x2e,0xbd,0x6d,0xdf,0xce,0x20,
43750x6f,0xe7,0xa8,0xf4,0xf3,0x25,0x9c,0xc3,0xc1,0x12,0x17,0x0d,0x30,0x32,0x30,
43760x39,0x32,0x30,0x31,0x33,0x35,0x34,0x34,0x32,0x5a,0x30,0x21,0x02,0x10,0x2f,
43770x56,0x16,0x22,0xba,0x87,0xd5,0xfd,0xff,0xe6,0xb0,0xdd,0x3c,0x08,0x26,0x2c,
43780x17,0x0d,0x30,0x32,0x30,0x33,0x31,0x33,0x31,0x37,0x35,0x33,0x31,0x31,0x5a,
43790x30,0x21,0x02,0x10,0x30,0x3e,0x77,0x7b,0xec,0xcb,0x89,0x2c,0x15,0x55,0x7f,
43800x20,0xf2,0x33,0xc1,0x1e,0x17,0x0d,0x30,0x32,0x30,0x32,0x32,0x31,0x32,0x33,
43810x35,0x30,0x34,0x39,0x5a,0x30,0x21,0x02,0x10,0x30,0x59,0x6c,0xaa,0x5f,0xd3,
43820xac,0x50,0x86,0x2c,0xc4,0xfa,0x3c,0x48,0x50,0xd1,0x17,0x0d,0x30,0x32,0x30,
43830x32,0x32,0x31,0x30,0x34,0x31,0x39,0x33,0x35,0x5a,0x30,0x21,0x02,0x10,0x30,
43840xce,0x9a,0xf1,0xfa,0x17,0xfa,0xf5,0x4c,0xbc,0x52,0x8a,0xf4,0x26,0x2b,0x7b,
43850x17,0x0d,0x30,0x32,0x30,0x33,0x30,0x31,0x31,0x39,0x31,0x32,0x33,0x39,0x5a,
43860x30,0x21,0x02,0x10,0x31,0x16,0x4a,0x6a,0x2e,0x6d,0x34,0x4d,0xd2,0x40,0xf0,
43870x5f,0x47,0xe6,0x5b,0x47,0x17,0x0d,0x30,0x32,0x30,0x32,0x31,0x32,0x31,0x37,
43880x33,0x38,0x35,0x32,0x5a,0x30,0x21,0x02,0x10,0x31,0xdb,0x97,0x5b,0x06,0x63,
43890x0b,0xd8,0xfe,0x06,0xb3,0xf5,0xf9,0x64,0x0a,0x59,0x17,0x0d,0x30,0x32,0x30,
43900x32,0x31,0x32,0x31,0x35,0x35,0x39,0x32,0x33,0x5a,0x30,0x21,0x02,0x10,0x32,
43910xbc,0xeb,0x0c,0xca,0x65,0x06,0x3f,0xa4,0xd5,0x4a,0x56,0x46,0x7c,0x22,0x09,
43920x17,0x0d,0x30,0x32,0x30,0x38,0x31,0x36,0x30,0x37,0x33,0x33,0x35,0x35,0x5a,
43930x30,0x21,0x02,0x10,0x33,0x17,0xef,0xe1,0x89,0xec,0x11,0x25,0x15,0x8f,0x3b,
43940x67,0x7a,0x64,0x0b,0x50,0x17,0x0d,0x30,0x32,0x30,0x39,0x31,0x38,0x31,0x37,
43950x30,0x33,0x34,0x36,0x5a,0x30,0x21,0x02,0x10,0x34,0x24,0xa0,0xd2,0x00,0x61,
43960xeb,0xd3,0x9a,0xa7,0x2a,0x66,0xb4,0x82,0x23,0x77,0x17,0x0d,0x30,0x32,0x30,
43970x33,0x31,0x35,0x32,0x32,0x34,0x33,0x33,0x39,0x5a,0x30,0x21,0x02,0x10,0x34,
43980xa8,0x16,0x67,0xa5,0x1b,0xa3,0x31,0x11,0x5e,0x26,0xc8,0x3f,0x21,0x38,0xbe,
43990x17,0x0d,0x30,0x32,0x30,0x33,0x32,0x31,0x32,0x31,0x31,0x36,0x32,0x31,0x5a,
44000x30,0x21,0x02,0x10,0x36,0x3a,0xbe,0x05,0x55,0x52,0x93,0x4f,0x32,0x5f,0x30,
44010x63,0xc0,0xd4,0x50,0xdf,0x17,0x0d,0x30,0x32,0x30,0x33,0x30,0x38,0x31,0x31,
44020x34,0x36,0x31,0x34,0x5a,0x30,0x21,0x02,0x10,0x37,0x19,0xcc,0xa5,0x9d,0x85,
44030x05,0x56,0xe1,0x63,0x42,0x4b,0x0d,0x3c,0xbf,0xd6,0x17,0x0d,0x30,0x33,0x30,
44040x31,0x30,0x38,0x31,0x38,0x35,0x38,0x32,0x34,0x5a,0x30,0x21,0x02,0x10,0x37,
44050x2f,0xfd,0x2b,0xec,0x4d,0x94,0x35,0x51,0xf4,0x07,0x2a,0xf5,0x0b,0x97,0xc4,
44060x17,0x0d,0x30,0x32,0x30,0x32,0x31,0x33,0x31,0x39,0x31,0x38,0x30,0x31,0x5a,
44070x30,0x21,0x02,0x10,0x37,0x83,0xf5,0x1e,0x7e,0xf4,0x5f,0xad,0x1f,0x0c,0x55,
44080x86,0x30,0x02,0x54,0xc1,0x17,0x0d,0x30,0x33,0x30,0x31,0x30,0x38,0x32,0x30,
44090x30,0x33,0x34,0x34,0x5a,0x30,0x21,0x02,0x10,0x38,0x32,0x3e,0x50,0x2b,0x36,
44100x93,0x01,0x32,0x0a,0x59,0x8c,0xce,0xad,0xa0,0xeb,0x17,0x0d,0x30,0x32,0x30,
44110x34,0x33,0x30,0x32,0x31,0x32,0x34,0x30,0x38,0x5a,0x30,0x21,0x02,0x10,0x3a,
44120x62,0xd8,0x64,0xd3,0x85,0xd5,0x61,0x1d,0x9d,0x3f,0x61,0x25,0xe9,0x3a,0x1d,
44130x17,0x0d,0x30,0x32,0x30,0x36,0x31,0x37,0x31,0x35,0x31,0x39,0x31,0x36,0x5a,
44140x30,0x21,0x02,0x10,0x3a,0x97,0x36,0xb1,0x26,0x14,0x73,0x50,0xa3,0xcc,0x3f,
44150xd0,0x3b,0x83,0x99,0xc9,0x17,0x0d,0x30,0x32,0x30,0x39,0x31,0x31,0x30,0x33,
44160x32,0x39,0x33,0x30,0x5a,0x30,0x21,0x02,0x10,0x3b,0x87,0x3e,0x20,0xbe,0x97,
44170xff,0xa7,0x6b,0x2b,0x5f,0xff,0x9a,0x7f,0x4c,0x95,0x17,0x0d,0x30,0x32,0x30,
44180x37,0x30,0x33,0x30,0x30,0x33,0x31,0x34,0x37,0x5a,0x30,0x21,0x02,0x10,0x3b,
44190xba,0xe5,0xf2,0x23,0x99,0xc6,0xd7,0xae,0xe2,0x98,0x0d,0xa4,0x13,0x5c,0xd4,
44200x17,0x0d,0x30,0x32,0x30,0x35,0x32,0x34,0x31,0x39,0x32,0x38,0x34,0x35,0x5a,
44210x30,0x21,0x02,0x10,0x3b,0xc2,0x7c,0xf0,0xbd,0xd2,0x9a,0x6f,0x97,0xdd,0x76,
44220xbc,0xa9,0x6c,0x45,0x0d,0x17,0x0d,0x30,0x32,0x30,0x33,0x30,0x38,0x31,0x30,
44230x34,0x32,0x30,0x33,0x5a,0x30,0x21,0x02,0x10,0x3b,0xc5,0xda,0x41,0x64,0x7a,
44240x37,0x8e,0x9f,0x7f,0x1f,0x9b,0x25,0x0a,0xb4,0xda,0x17,0x0d,0x30,0x32,0x30,
44250x33,0x30,0x36,0x31,0x33,0x32,0x34,0x34,0x38,0x5a,0x30,0x21,0x02,0x10,0x3c,
44260x1b,0xf1,0x9a,0x48,0xb0,0xb8,0xa0,0x45,0xd5,0x8f,0x0f,0x57,0x90,0xc2,0xcd,
44270x17,0x0d,0x30,0x32,0x30,0x33,0x31,0x38,0x30,0x36,0x34,0x33,0x32,0x33,0x5a,
44280x30,0x21,0x02,0x10,0x3d,0x15,0x48,0x80,0xb4,0xfe,0x51,0x7e,0xed,0x46,0xae,
44290x51,0xfd,0x47,0x73,0xde,0x17,0x0d,0x30,0x32,0x30,0x38,0x32,0x37,0x30,0x39,
44300x32,0x30,0x30,0x38,0x5a,0x30,0x21,0x02,0x10,0x3d,0x61,0x4e,0x87,0xea,0x39,
44310x02,0xf3,0x1e,0x3e,0x56,0x5c,0x0e,0x3b,0xa7,0xe3,0x17,0x0d,0x30,0x32,0x31,
44320x30,0x32,0x39,0x31,0x39,0x35,0x34,0x31,0x32,0x5a,0x30,0x21,0x02,0x10,0x3d,
44330xdd,0x61,0x92,0x82,0x69,0x6b,0x01,0x79,0x0e,0xef,0x96,0x12,0xa3,0x76,0x80,
44340x17,0x0d,0x30,0x32,0x30,0x35,0x30,0x31,0x32,0x32,0x32,0x34,0x31,0x36,0x5a,
44350x30,0x21,0x02,0x10,0x3e,0x0e,0x14,0x71,0x55,0xf3,0x48,0x09,0x1b,0x56,0x3b,
44360x91,0x7a,0x7d,0xec,0xc9,0x17,0x0d,0x30,0x32,0x30,0x33,0x31,0x31,0x32,0x31,
44370x34,0x35,0x35,0x31,0x5a,0x30,0x21,0x02,0x10,0x3e,0x23,0x00,0x1f,0x9b,0xbd,
44380xe8,0xb1,0xf0,0x06,0x67,0xa6,0x70,0x42,0x2e,0xc3,0x17,0x0d,0x30,0x32,0x30,
44390x38,0x30,0x38,0x31,0x32,0x32,0x31,0x33,0x32,0x5a,0x30,0x21,0x02,0x10,0x41,
44400x91,0x1a,0x8c,0xde,0x2d,0xb3,0xeb,0x79,0x1d,0xc7,0x99,0x99,0xbe,0x0c,0x0e,
44410x17,0x0d,0x30,0x32,0x30,0x32,0x32,0x35,0x31,0x39,0x31,0x38,0x35,0x34,0x5a,
44420x30,0x21,0x02,0x10,0x41,0xa8,0xd7,0x9c,0x10,0x5e,0x5a,0xac,0x16,0x7f,0x93,
44430xaa,0xd1,0x83,0x34,0x55,0x17,0x0d,0x30,0x32,0x30,0x34,0x31,0x30,0x31,0x32,
44440x35,0x33,0x34,0x30,0x5a,0x30,0x21,0x02,0x10,0x42,0x88,0x96,0xb0,0x7b,0x28,
44450xa2,0xfa,0x2f,0x91,0x73,0x58,0xa7,0x1e,0x53,0x7c,0x17,0x0d,0x30,0x33,0x30,
44460x33,0x30,0x31,0x30,0x39,0x34,0x33,0x33,0x31,0x5a,0x30,0x21,0x02,0x10,0x42,
44470x93,0x2f,0xd2,0x54,0xd3,0x94,0xd0,0x41,0x6a,0x2e,0x33,0x8b,0x81,0xb4,0x3c,
44480x17,0x0d,0x30,0x32,0x30,0x38,0x30,0x38,0x30,0x30,0x34,0x38,0x34,0x36,0x5a,
44490x30,0x21,0x02,0x10,0x44,0x24,0xdd,0xba,0x85,0xfd,0x3e,0xb2,0xb8,0x17,0x74,
44500xfd,0x9d,0x5c,0x0c,0xbd,0x17,0x0d,0x30,0x32,0x30,0x39,0x32,0x31,0x31,0x36,
44510x30,0x39,0x31,0x32,0x5a,0x30,0x21,0x02,0x10,0x45,0x02,0x18,0x7d,0x39,0x9c,
44520xb9,0x14,0xfb,0x10,0x37,0x96,0xf4,0xc1,0xdd,0x2f,0x17,0x0d,0x30,0x32,0x30,
44530x32,0x31,0x31,0x31,0x31,0x31,0x31,0x30,0x36,0x5a,0x30,0x21,0x02,0x10,0x45,
44540x16,0xbc,0x31,0x0b,0x4e,0x87,0x0a,0xcc,0xe3,0xd5,0x14,0x16,0x33,0x11,0x83,
44550x17,0x0d,0x30,0x32,0x30,0x34,0x30,0x32,0x30,0x32,0x32,0x30,0x31,0x37,0x5a,
44560x30,0x21,0x02,0x10,0x46,0x16,0x36,0xde,0x3f,0xef,0x8c,0xfa,0x67,0x53,0x12,
44570xcc,0x76,0x63,0xd6,0xdd,0x17,0x0d,0x30,0x32,0x30,0x32,0x31,0x34,0x31,0x36,
44580x35,0x39,0x34,0x33,0x5a,0x30,0x21,0x02,0x10,0x46,0x5f,0x85,0xa3,0xa4,0x98,
44590x3c,0x40,0x63,0xf6,0x1c,0xf7,0xc2,0xbe,0xfd,0x0e,0x17,0x0d,0x30,0x32,0x30,
44600x34,0x30,0x39,0x31,0x35,0x33,0x30,0x30,0x35,0x5a,0x30,0x21,0x02,0x10,0x47,
44610x20,0xc2,0xd8,0x85,0x85,0x54,0x39,0xcd,0xf2,0x10,0xf0,0xa7,0x88,0x52,0x75,
44620x17,0x0d,0x30,0x32,0x30,0x39,0x31,0x30,0x32,0x32,0x32,0x35,0x32,0x37,0x5a,
44630x30,0x21,0x02,0x10,0x47,0x42,0x6e,0xa2,0xab,0xc5,0x33,0x5d,0x50,0x44,0x0b,
44640x88,0x97,0x84,0x59,0x4c,0x17,0x0d,0x30,0x32,0x30,0x33,0x30,0x35,0x31,0x34,
44650x30,0x35,0x31,0x39,0x5a,0x30,0x21,0x02,0x10,0x49,0x20,0x3f,0xa8,0x6e,0x81,
44660xc8,0x3b,0x26,0x05,0xf4,0xa7,0x9b,0x5a,0x81,0x60,0x17,0x0d,0x30,0x32,0x30,
44670x37,0x31,0x31,0x31,0x37,0x35,0x30,0x34,0x38,0x5a,0x30,0x21,0x02,0x10,0x49,
44680x8b,0x6f,0x05,0xfb,0xcb,0xf4,0x5a,0xaf,0x09,0x47,0xb1,0x04,0xc5,0xe3,0x51,
44690x17,0x0d,0x30,0x32,0x30,0x34,0x31,0x32,0x31,0x37,0x34,0x38,0x30,0x38,0x5a,
44700x30,0x21,0x02,0x10,0x49,0xb2,0xc3,0x7a,0xbf,0x75,0x2a,0xb3,0x13,0xae,0x53,
44710xc6,0xcb,0x45,0x5a,0x3e,0x17,0x0d,0x30,0x32,0x31,0x31,0x31,0x35,0x32,0x31,
44720x33,0x35,0x33,0x37,0x5a,0x30,0x21,0x02,0x10,0x4b,0xca,0xc3,0xab,0x0a,0xc5,
44730xcd,0x90,0xa2,0xbe,0x43,0xfe,0xdd,0x06,0xe1,0x45,0x17,0x0d,0x30,0x32,0x30,
44740x37,0x32,0x30,0x31,0x37,0x33,0x32,0x31,0x32,0x5a,0x30,0x21,0x02,0x10,0x4c,
44750x00,0xcc,0x73,0xd5,0x74,0x61,0x62,0x92,0x52,0xff,0xde,0x5b,0xc1,0x55,0xbd,
44760x17,0x0d,0x30,0x32,0x30,0x38,0x32,0x36,0x31,0x34,0x30,0x31,0x35,0x31,0x5a,
44770x30,0x21,0x02,0x10,0x4c,0x59,0xc1,0xc3,0x56,0x40,0x27,0xd4,0x22,0x0e,0x37,
44780xf6,0x5f,0x26,0x50,0xc5,0x17,0x0d,0x30,0x32,0x30,0x32,0x32,0x36,0x30,0x39,
44790x35,0x37,0x34,0x34,0x5a,0x30,0x21,0x02,0x10,0x4c,0xca,0x12,0x59,0x46,0xf9,
44800x2b,0xc6,0x7d,0x33,0x78,0x40,0x2c,0x3b,0x7a,0x0c,0x17,0x0d,0x30,0x32,0x30,
44810x35,0x33,0x30,0x32,0x30,0x32,0x34,0x35,0x38,0x5a,0x30,0x21,0x02,0x10,0x4d,
44820x57,0x51,0x35,0x9b,0xe5,0x41,0x2c,0x69,0x66,0xc7,0x21,0xec,0xc6,0x29,0x32,
44830x17,0x0d,0x30,0x32,0x30,0x39,0x32,0x36,0x30,0x34,0x33,0x35,0x35,0x36,0x5a,
44840x30,0x21,0x02,0x10,0x4e,0x85,0xab,0x9e,0x17,0x54,0xe7,0x42,0x0f,0x8c,0xa1,
44850x65,0x96,0x88,0x53,0x54,0x17,0x0d,0x30,0x32,0x30,0x33,0x32,0x38,0x30,0x30,
44860x31,0x38,0x35,0x33,0x5a,0x30,0x21,0x02,0x10,0x50,0x3d,0xed,0xac,0x21,0x86,
44870x66,0x5d,0xa5,0x1a,0x13,0xee,0xfc,0xa7,0x0b,0xc6,0x17,0x0d,0x30,0x32,0x30,
44880x32,0x31,0x38,0x31,0x33,0x35,0x35,0x34,0x39,0x5a,0x30,0x21,0x02,0x10,0x50,
44890xa3,0x81,0x9c,0xcb,0x22,0xe4,0x0f,0x80,0xcb,0x7a,0xec,0x35,0xf8,0x73,0x82,
44900x17,0x0d,0x30,0x32,0x31,0x30,0x30,0x35,0x31,0x36,0x35,0x39,0x35,0x39,0x5a,
44910x30,0x21,0x02,0x10,0x51,0x28,0x73,0x26,0x17,0xcf,0x10,0x6e,0xeb,0x4a,0x03,
44920x74,0xa3,0x35,0xe5,0x60,0x17,0x0d,0x30,0x33,0x30,0x36,0x31,0x33,0x31,0x30,
44930x30,0x39,0x32,0x39,0x5a,0x30,0x21,0x02,0x10,0x51,0x52,0xff,0xdc,0x69,0x6b,
44940x1f,0x1f,0xff,0x7c,0xb1,0x7f,0x03,0x90,0xa9,0x6b,0x17,0x0d,0x30,0x32,0x30,
44950x36,0x31,0x34,0x31,0x36,0x30,0x34,0x30,0x32,0x5a,0x30,0x21,0x02,0x10,0x52,
44960xd9,0x53,0x69,0x9f,0xec,0xab,0xdd,0x5d,0x2a,0x2f,0xaa,0x57,0x86,0xb9,0x1f,
44970x17,0x0d,0x30,0x32,0x30,0x38,0x33,0x30,0x32,0x33,0x34,0x36,0x34,0x33,0x5a,
44980x30,0x21,0x02,0x10,0x54,0x46,0xa8,0x8f,0x69,0x2e,0x02,0xf4,0xb4,0xb2,0x69,
44990xda,0xbd,0x40,0x02,0xe0,0x17,0x0d,0x30,0x32,0x30,0x33,0x32,0x36,0x30,0x31,
45000x35,0x36,0x35,0x38,0x5a,0x30,0x21,0x02,0x10,0x54,0xb5,0x81,0x73,0xb5,0x7c,
45010x6d,0xba,0x5c,0x99,0x0d,0xff,0x0a,0x4d,0xee,0xef,0x17,0x0d,0x30,0x32,0x30,
45020x37,0x32,0x34,0x31,0x36,0x33,0x39,0x35,0x31,0x5a,0x30,0x21,0x02,0x10,0x57,
45030x91,0x41,0x20,0x9f,0x57,0x6f,0x42,0x53,0x4e,0x19,0xcc,0xe4,0xc8,0x52,0x4a,
45040x17,0x0d,0x30,0x32,0x30,0x35,0x32,0x38,0x32,0x33,0x32,0x34,0x30,0x30,0x5a,
45050x30,0x21,0x02,0x10,0x57,0xc6,0xdc,0xa0,0xed,0xbf,0x77,0xdd,0x7e,0x18,0x68,
45060x83,0x57,0x0c,0x2a,0x4f,0x17,0x0d,0x30,0x32,0x30,0x35,0x32,0x31,0x31,0x34,
45070x30,0x36,0x31,0x31,0x5a,0x30,0x21,0x02,0x10,0x57,0xed,0xe2,0x5b,0xe2,0x62,
45080x3f,0x98,0xe1,0xf5,0x4d,0x30,0xa4,0x0e,0xdf,0xdf,0x17,0x0d,0x30,0x32,0x30,
45090x36,0x30,0x39,0x30,0x31,0x34,0x37,0x31,0x38,0x5a,0x30,0x21,0x02,0x10,0x58,
45100x47,0xd9,0xbd,0x83,0x1a,0x63,0x6f,0xb7,0x63,0x7f,0x4a,0x56,0x5e,0x8e,0x4d,
45110x17,0x0d,0x30,0x32,0x30,0x34,0x31,0x35,0x31,0x37,0x32,0x33,0x30,0x33,0x5a,
45120x30,0x21,0x02,0x10,0x58,0xc6,0x62,0x99,0x80,0xe6,0x0c,0x4f,0x00,0x8b,0x25,
45130x38,0x93,0xe6,0x18,0x10,0x17,0x0d,0x30,0x32,0x30,0x36,0x30,0x36,0x30,0x37,
45140x30,0x39,0x34,0x37,0x5a,0x30,0x21,0x02,0x10,0x59,0x52,0x09,0x0e,0x99,0xf3,
45150xa9,0xe5,0x2f,0xed,0xa9,0xb2,0xd8,0x61,0xe7,0xea,0x17,0x0d,0x30,0x32,0x30,
45160x36,0x32,0x36,0x31,0x34,0x31,0x38,0x33,0x36,0x5a,0x30,0x21,0x02,0x10,0x59,
45170x5c,0xaa,0xfb,0xbe,0xfb,0x73,0xd1,0xf4,0xab,0xc8,0xe3,0x3d,0x01,0x04,0xdd,
45180x17,0x0d,0x30,0x32,0x30,0x39,0x32,0x37,0x32,0x32,0x32,0x30,0x31,0x30,0x5a,
45190x30,0x21,0x02,0x10,0x59,0x97,0x59,0xa7,0x3d,0xb0,0xd9,0x7e,0xff,0x2a,0xcb,
45200x31,0xcc,0x66,0xf3,0x85,0x17,0x0d,0x30,0x32,0x30,0x38,0x32,0x32,0x30,0x30,
45210x35,0x35,0x35,0x38,0x5a,0x30,0x21,0x02,0x10,0x59,0xdd,0x45,0x36,0x61,0xd9,
45220x3e,0xe9,0xff,0xbd,0xad,0x2e,0xbf,0x9a,0x5d,0x98,0x17,0x0d,0x30,0x32,0x30,
45230x37,0x30,0x32,0x32,0x30,0x34,0x30,0x30,0x33,0x5a,0x30,0x21,0x02,0x10,0x5a,
45240x4b,0x48,0x18,0xa9,0x2a,0x9c,0xd5,0x91,0x2f,0x4f,0xa4,0xf8,0xb3,0x1b,0x4d,
45250x17,0x0d,0x30,0x32,0x30,0x34,0x30,0x34,0x32,0x33,0x33,0x33,0x31,0x32,0x5a,
45260x30,0x21,0x02,0x10,0x5a,0xdf,0x32,0x0d,0x64,0xeb,0x9b,0xd2,0x11,0xe2,0x58,
45270x50,0xbe,0x93,0x0c,0x65,0x17,0x0d,0x30,0x32,0x30,0x34,0x30,0x35,0x31,0x37,
45280x30,0x37,0x32,0x31,0x5a,0x30,0x21,0x02,0x10,0x5b,0x23,0xbf,0xbb,0xc4,0xb3,
45290xf4,0x02,0xe9,0xcb,0x10,0x9e,0xee,0xa5,0x3f,0xcd,0x17,0x0d,0x30,0x32,0x30,
45300x33,0x32,0x39,0x31,0x36,0x32,0x36,0x35,0x39,0x5a,0x30,0x21,0x02,0x10,0x5b,
45310x51,0xbc,0x38,0xbf,0xaf,0x9f,0x27,0xa9,0xc7,0xed,0x25,0xd0,0x8d,0xec,0x2e,
45320x17,0x0d,0x30,0x32,0x30,0x33,0x30,0x38,0x31,0x30,0x32,0x35,0x32,0x30,0x5a,
45330x30,0x21,0x02,0x10,0x5c,0x29,0x7f,0x46,0x61,0xdd,0x47,0x90,0x82,0x91,0xbd,
45340x79,0x22,0x6a,0x98,0x38,0x17,0x0d,0x30,0x32,0x31,0x31,0x30,0x38,0x31,0x35,
45350x35,0x34,0x32,0x36,0x5a,0x30,0x21,0x02,0x10,0x5e,0x38,0xf7,0x5b,0x00,0xf1,
45360xef,0x1c,0xb6,0xff,0xd5,0x5c,0x74,0xfb,0x95,0x5d,0x17,0x0d,0x30,0x32,0x31,
45370x31,0x32,0x33,0x30,0x31,0x34,0x39,0x32,0x39,0x5a,0x30,0x21,0x02,0x10,0x5e,
45380x88,0xbe,0xb6,0xb4,0xb2,0xaa,0xb0,0x92,0xf3,0xf6,0xc2,0xbc,0x72,0x21,0xca,
45390x17,0x0d,0x30,0x32,0x30,0x32,0x31,0x34,0x30,0x37,0x31,0x32,0x31,0x30,0x5a,
45400x30,0x21,0x02,0x10,0x5f,0x59,0xa0,0xbb,0xaf,0x26,0xc8,0xc1,0xb4,0x04,0x3a,
45410xbb,0xfc,0x4c,0x75,0xa5,0x17,0x0d,0x30,0x32,0x30,0x34,0x31,0x36,0x31,0x35,
45420x35,0x31,0x32,0x33,0x5a,0x30,0x21,0x02,0x10,0x5f,0x81,0x08,0x0f,0xa0,0xcd,
45430x44,0x73,0x23,0x58,0x8e,0x49,0x9f,0xb5,0x08,0x35,0x17,0x0d,0x30,0x32,0x30,
45440x36,0x31,0x39,0x31,0x34,0x31,0x37,0x34,0x33,0x5a,0x30,0x21,0x02,0x10,0x5f,
45450xba,0x1f,0x8f,0xb2,0x23,0x56,0xdd,0xbc,0xa6,0x72,0xb0,0x99,0x13,0xb5,0xb2,
45460x17,0x0d,0x30,0x32,0x30,0x35,0x30,0x36,0x30,0x38,0x34,0x37,0x31,0x30,0x5a,
45470x30,0x21,0x02,0x10,0x60,0x09,0xd5,0xb7,0x6b,0xf1,0x16,0x4a,0xfa,0xd0,0xa5,
45480x4c,0x8e,0xdd,0x02,0xcb,0x17,0x0d,0x30,0x32,0x30,0x36,0x31,0x37,0x31,0x36,
45490x31,0x32,0x32,0x39,0x5a,0x30,0x21,0x02,0x10,0x60,0x1d,0x19,0xd8,0x55,0xd5,
45500x14,0xd5,0xff,0x03,0x0d,0xad,0x5c,0x07,0x4c,0xe7,0x17,0x0d,0x30,0x32,0x30,
45510x37,0x31,0x35,0x32,0x33,0x30,0x31,0x31,0x31,0x5a,0x30,0x21,0x02,0x10,0x60,
45520x24,0x67,0xc3,0x0b,0xad,0x53,0x8f,0xce,0x89,0x05,0xb5,0x87,0xaf,0x7c,0xe4,
45530x17,0x0d,0x30,0x32,0x31,0x30,0x30,0x38,0x32,0x30,0x33,0x38,0x35,0x32,0x5a,
45540x30,0x21,0x02,0x10,0x60,0x5c,0xf3,0x3d,0x22,0x23,0x39,0x3f,0xe6,0x21,0x09,
45550xfd,0xdd,0x77,0xc2,0x8f,0x17,0x0d,0x30,0x32,0x30,0x37,0x30,0x32,0x31,0x37,
45560x32,0x37,0x35,0x38,0x5a,0x30,0x21,0x02,0x10,0x60,0xa2,0x5e,0xbf,0x07,0x83,
45570xa3,0x18,0x56,0x18,0x48,0x63,0xa7,0xfd,0xc7,0x63,0x17,0x0d,0x30,0x32,0x30,
45580x35,0x30,0x39,0x31,0x39,0x35,0x32,0x32,0x37,0x5a,0x30,0x21,0x02,0x10,0x60,
45590xc2,0xad,0xa8,0x0e,0xf9,0x9a,0x66,0x5d,0xa2,0x75,0x04,0x5e,0x5c,0x71,0xc2,
45600x17,0x0d,0x30,0x32,0x31,0x31,0x31,0x32,0x31,0x33,0x33,0x36,0x31,0x37,0x5a,
45610x30,0x21,0x02,0x10,0x60,0xdb,0x1d,0x37,0x34,0xf6,0x02,0x9d,0x68,0x1b,0x70,
45620xf1,0x13,0x00,0x2f,0x80,0x17,0x0d,0x30,0x32,0x30,0x32,0x32,0x38,0x30,0x39,
45630x35,0x35,0x33,0x33,0x5a,0x30,0x21,0x02,0x10,0x61,0xf0,0x38,0xea,0xbc,0x17,
45640x0d,0x11,0xd2,0x89,0xee,0x87,0x50,0x57,0xa0,0xed,0x17,0x0d,0x30,0x33,0x30,
45650x31,0x32,0x39,0x31,0x37,0x34,0x31,0x34,0x34,0x5a,0x30,0x21,0x02,0x10,0x61,
45660xfa,0x9b,0xeb,0x58,0xf9,0xe5,0xa5,0x9e,0x79,0xa8,0x3d,0x79,0xac,0x35,0x97,
45670x17,0x0d,0x30,0x32,0x31,0x30,0x31,0x30,0x32,0x30,0x31,0x36,0x33,0x37,0x5a,
45680x30,0x21,0x02,0x10,0x62,0x44,0x57,0x24,0x41,0xc0,0x89,0x3f,0x5b,0xd2,0xbd,
45690xe7,0x2f,0x75,0x41,0xfa,0x17,0x0d,0x30,0x32,0x30,0x38,0x30,0x38,0x31,0x38,
45700x33,0x30,0x31,0x35,0x5a,0x30,0x21,0x02,0x10,0x62,0x51,0x3a,0x2d,0x8d,0x82,
45710x39,0x65,0xfe,0xf6,0x8a,0xc8,0x4e,0x29,0x91,0xfd,0x17,0x0d,0x30,0x32,0x30,
45720x39,0x32,0x36,0x30,0x30,0x35,0x34,0x33,0x34,0x5a,0x30,0x21,0x02,0x10,0x62,
45730x52,0x49,0x49,0xf2,0x51,0x67,0x7a,0xe2,0xee,0xc9,0x0c,0x23,0x11,0x3d,0xb2,
45740x17,0x0d,0x30,0x32,0x30,0x34,0x31,0x37,0x31,0x38,0x30,0x36,0x35,0x35,0x5a,
45750x30,0x21,0x02,0x10,0x63,0x52,0xbd,0xdc,0xb7,0xbf,0xbb,0x90,0x6c,0x82,0xee,
45760xb5,0xa3,0x9f,0xd8,0xc9,0x17,0x0d,0x30,0x32,0x30,0x32,0x32,0x31,0x31,0x36,
45770x33,0x30,0x35,0x38,0x5a,0x30,0x21,0x02,0x10,0x63,0x5e,0x6b,0xe9,0xea,0x3d,
45780xd6,0x3b,0xc3,0x4d,0x09,0xc3,0x13,0xdb,0xdd,0xbc,0x17,0x0d,0x30,0x33,0x30,
45790x36,0x30,0x32,0x31,0x34,0x34,0x37,0x33,0x36,0x5a,0x30,0x21,0x02,0x10,0x63,
45800xda,0x0b,0xd5,0x13,0x1e,0x98,0x83,0x32,0xa2,0x3a,0x4b,0xdf,0x8c,0x89,0x86,
45810x17,0x0d,0x30,0x32,0x30,0x39,0x32,0x35,0x30,0x38,0x30,0x38,0x31,0x33,0x5a,
45820x30,0x21,0x02,0x10,0x64,0xfe,0xf0,0x1a,0x3a,0xed,0x89,0xf8,0xb5,0x34,0xd3,
45830x1e,0x0f,0xce,0x0d,0xce,0x17,0x0d,0x30,0x32,0x30,0x34,0x30,0x38,0x32,0x31,
45840x30,0x36,0x32,0x34,0x5a,0x30,0x21,0x02,0x10,0x65,0xa7,0x49,0xd8,0x37,0x22,
45850x4b,0x4a,0xe5,0xcf,0xa3,0xfe,0xd6,0x3b,0xc0,0x67,0x17,0x0d,0x30,0x32,0x31,
45860x32,0x30,0x34,0x31,0x37,0x31,0x34,0x31,0x36,0x5a,0x30,0x21,0x02,0x10,0x65,
45870xc9,0x9e,0x47,0x76,0x98,0x0d,0x9e,0x57,0xe4,0xae,0xc5,0x1c,0x3e,0xf2,0xe7,
45880x17,0x0d,0x30,0x32,0x30,0x39,0x32,0x33,0x31,0x34,0x30,0x38,0x31,0x38,0x5a,
45890x30,0x21,0x02,0x10,0x65,0xe0,0x7b,0xc5,0x74,0xe4,0xab,0x01,0x4f,0xa3,0x5e,
45900xd6,0xeb,0xcd,0xd5,0x69,0x17,0x0d,0x30,0x32,0x30,0x34,0x30,0x33,0x31,0x37,
45910x32,0x34,0x30,0x36,0x5a,0x30,0x21,0x02,0x10,0x66,0x51,0xb7,0xe5,0x62,0xb7,
45920xe3,0x31,0xc0,0xee,0xf2,0xe8,0xfe,0x84,0x6a,0x4e,0x17,0x0d,0x30,0x32,0x30,
45930x39,0x30,0x36,0x31,0x33,0x32,0x33,0x33,0x33,0x5a,0x30,0x21,0x02,0x10,0x67,
45940x7c,0x76,0xac,0x66,0x5a,0x6b,0x41,0x5c,0x07,0x83,0x02,0xd6,0xd9,0x63,0xc0,
45950x17,0x0d,0x30,0x32,0x30,0x32,0x31,0x38,0x31,0x33,0x35,0x35,0x31,0x30,0x5a,
45960x30,0x21,0x02,0x10,0x68,0x67,0xde,0xb3,0xaa,0x20,0xcf,0x4b,0x34,0xa5,0xe0,
45970xc8,0xc0,0xc5,0xc9,0xa4,0x17,0x0d,0x30,0x32,0x30,0x33,0x31,0x32,0x30,0x31,
45980x30,0x39,0x32,0x36,0x5a,0x30,0x21,0x02,0x10,0x69,0x23,0x34,0x5d,0x75,0x04,
45990xdc,0x99,0xbd,0xce,0x8d,0x21,0xb4,0x6b,0x10,0xfc,0x17,0x0d,0x30,0x32,0x30,
46000x39,0x30,0x33,0x31,0x33,0x31,0x39,0x32,0x30,0x5a,0x30,0x21,0x02,0x10,0x69,
46010x9f,0x20,0x31,0xd1,0x3f,0xfa,0x1e,0x70,0x2e,0x37,0xd5,0x9a,0x8c,0x0a,0x16,
46020x17,0x0d,0x30,0x32,0x30,0x32,0x32,0x30,0x30,0x39,0x30,0x31,0x33,0x35,0x5a,
46030x30,0x21,0x02,0x10,0x6a,0x94,0xd6,0x25,0xd0,0x67,0xe4,0x4d,0x79,0x2b,0xc6,
46040xd5,0xc9,0x4a,0x7f,0xc6,0x17,0x0d,0x30,0x32,0x30,0x32,0x31,0x31,0x31,0x39,
46050x31,0x35,0x34,0x30,0x5a,0x30,0x21,0x02,0x10,0x6b,0x5c,0xa4,0x45,0x5b,0xe9,
46060xcf,0xe7,0x3b,0x29,0xb1,0x32,0xd7,0xa1,0x04,0x3d,0x17,0x0d,0x30,0x32,0x31,
46070x30,0x31,0x38,0x31,0x35,0x34,0x33,0x34,0x38,0x5a,0x30,0x21,0x02,0x10,0x6b,
46080xc0,0x7d,0x4f,0x18,0xfe,0xb7,0x07,0xe8,0x56,0x9a,0x6c,0x40,0x0f,0x36,0x53,
46090x17,0x0d,0x30,0x32,0x30,0x39,0x32,0x36,0x32,0x31,0x30,0x31,0x32,0x36,0x5a,
46100x30,0x21,0x02,0x10,0x6b,0xe1,0xdd,0x36,0x3b,0xec,0xe0,0xa9,0xf5,0x92,0x7e,
46110x33,0xbf,0xed,0x48,0x46,0x17,0x0d,0x30,0x32,0x30,0x34,0x31,0x37,0x31,0x34,
46120x34,0x32,0x33,0x31,0x5a,0x30,0x21,0x02,0x10,0x6c,0xac,0xeb,0x37,0x2b,0x6a,
46130x42,0xe2,0xca,0xc8,0xd2,0xda,0xb8,0xb9,0x82,0x6a,0x17,0x0d,0x30,0x32,0x30,
46140x33,0x30,0x31,0x31,0x34,0x32,0x38,0x33,0x34,0x5a,0x30,0x21,0x02,0x10,0x6d,
46150x98,0x1b,0xb4,0x76,0xd1,0x62,0x59,0xa1,0x3c,0xee,0xd2,0x21,0xd8,0xdf,0x4c,
46160x17,0x0d,0x30,0x32,0x30,0x35,0x31,0x34,0x31,0x37,0x35,0x36,0x31,0x32,0x5a,
46170x30,0x21,0x02,0x10,0x6d,0xdd,0x0b,0x5a,0x3c,0x9c,0xab,0xd3,0x3b,0xd9,0x16,
46180xec,0x69,0x74,0xfb,0x9a,0x17,0x0d,0x30,0x32,0x30,0x32,0x32,0x32,0x31,0x32,
46190x32,0x36,0x33,0x38,0x5a,0x30,0x21,0x02,0x10,0x6e,0xde,0xfd,0x89,0x36,0xae,
46200xa0,0x41,0x8d,0x5c,0xec,0x2e,0x90,0x31,0xf8,0x9a,0x17,0x0d,0x30,0x32,0x30,
46210x34,0x30,0x38,0x32,0x32,0x33,0x36,0x31,0x32,0x5a,0x30,0x21,0x02,0x10,0x6f,
46220xb2,0x6b,0x4c,0x48,0xca,0xfe,0xe6,0x69,0x9a,0x06,0x63,0xc4,0x32,0x96,0xc1,
46230x17,0x0d,0x30,0x33,0x30,0x31,0x31,0x37,0x31,0x37,0x32,0x37,0x32,0x35,0x5a,
46240x30,0x21,0x02,0x10,0x70,0x0b,0xe1,0xee,0x44,0x89,0x51,0x52,0x65,0x27,0x2c,
46250x2d,0x34,0x7c,0xe0,0x8d,0x17,0x0d,0x30,0x32,0x30,0x39,0x31,0x38,0x30,0x30,
46260x33,0x36,0x30,0x30,0x5a,0x30,0x21,0x02,0x10,0x70,0x2d,0xc0,0xa6,0xb8,0xa5,
46270xa0,0xda,0x48,0x59,0xb3,0x96,0x34,0x80,0xc8,0x25,0x17,0x0d,0x30,0x32,0x30,
46280x38,0x33,0x30,0x31,0x34,0x30,0x31,0x30,0x31,0x5a,0x30,0x21,0x02,0x10,0x70,
46290xe1,0xd9,0x92,0xcd,0x76,0x42,0x63,0x51,0x6e,0xcd,0x8c,0x09,0x29,0x17,0x48,
46300x17,0x0d,0x30,0x32,0x30,0x35,0x31,0x37,0x31,0x31,0x31,0x30,0x34,0x31,0x5a,
46310x30,0x21,0x02,0x10,0x72,0x38,0xe4,0x91,0x6a,0x7a,0x8a,0xf3,0xbf,0xf0,0xd8,
46320xe0,0xa4,0x70,0x8d,0xa8,0x17,0x0d,0x30,0x32,0x30,0x33,0x30,0x34,0x31,0x39,
46330x30,0x36,0x34,0x30,0x5a,0x30,0x21,0x02,0x10,0x72,0x97,0xa1,0xd8,0x9c,0x3b,
46340x00,0xc2,0xc4,0x26,0x2d,0x06,0x2b,0x29,0x76,0x4e,0x17,0x0d,0x30,0x32,0x30,
46350x36,0x31,0x38,0x31,0x35,0x30,0x39,0x34,0x37,0x5a,0x30,0x21,0x02,0x10,0x72,
46360xd2,0x23,0x9b,0xf2,0x33,0xe9,0x7c,0xcf,0xb6,0xa9,0x41,0xd5,0x0e,0x5c,0x39,
46370x17,0x0d,0x30,0x33,0x30,0x34,0x30,0x39,0x31,0x37,0x30,0x32,0x32,0x39,0x5a,
46380x30,0x21,0x02,0x10,0x74,0x5c,0x9c,0xf9,0xaa,0xc3,0xfa,0x94,0x3c,0x25,0x39,
46390x65,0x44,0x95,0x13,0xf1,0x17,0x0d,0x30,0x32,0x30,0x37,0x30,0x39,0x32,0x33,
46400x35,0x33,0x32,0x30,0x5a,0x30,0x21,0x02,0x10,0x74,0x98,0x7f,0x68,0xad,0x17,
46410x92,0x93,0xf2,0x65,0x94,0x0c,0x33,0xe6,0xbd,0x49,0x17,0x0d,0x30,0x32,0x30,
46420x34,0x32,0x33,0x30,0x37,0x34,0x34,0x31,0x38,0x5a,0x30,0x21,0x02,0x10,0x75,
46430x0e,0x40,0xff,0x97,0xf0,0x47,0xed,0xf5,0x56,0xc7,0x08,0x4e,0xb1,0xab,0xfd,
46440x17,0x0d,0x30,0x31,0x30,0x31,0x33,0x31,0x30,0x30,0x30,0x30,0x30,0x30,0x5a,
46450x30,0x21,0x02,0x10,0x75,0x26,0x51,0x59,0x65,0xb7,0x33,0x32,0x5f,0xe6,0xcd,
46460xaa,0x30,0x65,0x78,0xe0,0x17,0x0d,0x30,0x32,0x30,0x35,0x31,0x36,0x31,0x38,
46470x32,0x34,0x35,0x36,0x5a,0x30,0x21,0x02,0x10,0x76,0x13,0x6f,0xbf,0xc8,0xde,
46480xd9,0x36,0x30,0x39,0xcc,0x85,0x8f,0x00,0x2f,0x19,0x17,0x0d,0x30,0x32,0x30,
46490x33,0x31,0x34,0x30,0x39,0x34,0x38,0x32,0x34,0x5a,0x30,0x21,0x02,0x10,0x76,
46500x52,0x78,0x89,0x44,0xfa,0xc1,0xb3,0xd7,0xc9,0x4c,0xb3,0x32,0x95,0xaf,0x03,
46510x17,0x0d,0x30,0x32,0x31,0x31,0x31,0x34,0x31,0x39,0x31,0x35,0x34,0x33,0x5a,
46520x30,0x21,0x02,0x10,0x77,0x5d,0x4c,0x40,0xd9,0x8d,0xfa,0xc8,0x9a,0x24,0x8d,
46530x47,0x10,0x90,0x4a,0x0a,0x17,0x0d,0x30,0x32,0x30,0x35,0x30,0x39,0x30,0x31,
46540x31,0x33,0x30,0x32,0x5a,0x30,0x21,0x02,0x10,0x77,0xe6,0x5a,0x43,0x59,0x93,
46550x5d,0x5f,0x7a,0x75,0x80,0x1a,0xcd,0xad,0xc2,0x22,0x17,0x0d,0x30,0x30,0x30,
46560x38,0x33,0x31,0x31,0x38,0x32,0x32,0x35,0x30,0x5a,0x30,0x21,0x02,0x10,0x78,
46570x19,0xf1,0xb6,0x87,0x83,0xaf,0xdf,0x60,0x8d,0x9a,0x64,0x0d,0xec,0xe0,0x51,
46580x17,0x0d,0x30,0x32,0x30,0x35,0x32,0x30,0x31,0x37,0x32,0x38,0x31,0x36,0x5a,
46590x30,0x21,0x02,0x10,0x78,0x64,0x65,0x8f,0x82,0x79,0xdb,0xa5,0x1c,0x47,0x10,
46600x1d,0x72,0x23,0x66,0x52,0x17,0x0d,0x30,0x33,0x30,0x31,0x32,0x34,0x31,0x38,
46610x34,0x35,0x34,0x37,0x5a,0x30,0x21,0x02,0x10,0x78,0x64,0xe1,0xc0,0x69,0x8f,
46620x3a,0xc7,0x8b,0x23,0xe3,0x29,0xb1,0xee,0xa9,0x41,0x17,0x0d,0x30,0x32,0x30,
46630x35,0x30,0x38,0x31,0x37,0x34,0x36,0x32,0x36,0x5a,0x30,0x21,0x02,0x10,0x78,
46640x79,0x89,0x61,0x12,0x67,0x64,0x14,0xfd,0x08,0xcc,0xb3,0x05,0x55,0xc0,0x67,
46650x17,0x0d,0x30,0x32,0x30,0x34,0x30,0x32,0x31,0x33,0x31,0x38,0x35,0x33,0x5a,
46660x30,0x21,0x02,0x10,0x78,0x8a,0x56,0x22,0x08,0xce,0x42,0xee,0xd1,0xa3,0x79,
46670x10,0x14,0xfd,0x3a,0x36,0x17,0x0d,0x30,0x33,0x30,0x32,0x30,0x35,0x31,0x36,
46680x35,0x33,0x32,0x39,0x5a,0x30,0x21,0x02,0x10,0x7a,0xa0,0x6c,0xba,0x33,0x02,
46690xac,0x5f,0xf5,0x0b,0xb6,0x77,0x61,0xef,0x77,0x09,0x17,0x0d,0x30,0x32,0x30,
46700x32,0x32,0x38,0x31,0x37,0x35,0x35,0x31,0x31,0x5a,0x30,0x21,0x02,0x10,0x7b,
46710x91,0x33,0x66,0x6c,0xf0,0xd4,0xe3,0x9d,0xf6,0x88,0x29,0x9b,0xf7,0xd0,0xea,
46720x17,0x0d,0x30,0x32,0x31,0x31,0x32,0x30,0x32,0x32,0x31,0x36,0x34,0x39,0x5a,
46730x30,0x21,0x02,0x10,0x7c,0xef,0xf2,0x0a,0x08,0xae,0x10,0x57,0x1e,0xde,0xdc,
46740xd6,0x63,0x76,0xb0,0x5d,0x17,0x0d,0x30,0x32,0x30,0x32,0x32,0x36,0x31,0x30,
46750x32,0x32,0x33,0x30,0x5a,0x30,0x21,0x02,0x10,0x7f,0x76,0xef,0x69,0xeb,0xf5,
46760x3f,0x53,0x2e,0xaa,0xa5,0xed,0xde,0xc0,0xb4,0x06,0x17,0x0d,0x30,0x32,0x30,
46770x35,0x30,0x31,0x30,0x33,0x33,0x33,0x30,0x37,0x5a,0x30,0x21,0x02,0x10,0x7f,
46780xcb,0x6b,0x99,0x91,0xd0,0x76,0xe1,0x3c,0x0e,0x67,0x15,0xc4,0xd4,0x4d,0x7b,
46790x17,0x0d,0x30,0x32,0x30,0x34,0x31,0x30,0x32,0x31,0x31,0x38,0x34,0x30,0x5a,
46800x30,0x0d,0x06,0x09,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x01,0x01,0x04,0x05,0x00,
46810x03,0x81,0x81,0x00,0x5c,0xb9,0xb3,0xbe,0xd3,0xd6,0x73,0xa3,0xfe,0x4a,0xb2,
46820x21,0x80,0xea,0xaa,0x05,0x61,0x14,0x1d,0x67,0xb1,0xdf,0xa6,0xf9,0x42,0x08,
46830x0d,0x59,0x62,0x9c,0x11,0x5f,0x0e,0x92,0xc5,0xc6,0xae,0x74,0x64,0xc7,0x84,
46840x3e,0x64,0x43,0xd2,0xec,0xbb,0xe1,0x9b,0x52,0x74,0x57,0xcf,0x96,0xef,0x68,
46850x02,0x7a,0x7b,0x36,0xb7,0xc6,0x9a,0x5f,0xca,0x9c,0x37,0x47,0xc8,0x3a,0x5c,
46860x34,0x35,0x3b,0x4b,0xca,0x20,0x77,0x44,0x68,0x07,0x02,0x34,0x46,0xaa,0x0f,
46870xd0,0x4d,0xd9,0x47,0xf4,0xb3,0x2d,0xb1,0x44,0xa5,0x69,0xa9,0x85,0x13,0x43,
46880xcd,0xcc,0x1d,0x9a,0xe6,0x2d,0xfd,0x9f,0xdc,0x2f,0x83,0xbb,0x8c,0xe2,0x8c,
46890x61,0xc0,0x99,0x16,0x71,0x05,0xb6,0x25,0x14,0x64,0x4f,0x30 };
4690
4691static void test_decodeCRLToBeSigned(DWORD dwEncoding)
4692{
4693 static const BYTE *corruptCRLs[] = { v1CRL, v2CRL };
4694 BOOL ret;
4695 BYTE *buf = NULL;
4696 DWORD size = 0, i;
4697
4698 for (i = 0; i < ARRAY_SIZE(corruptCRLs); i++)
4699 {
4701 corruptCRLs[i], corruptCRLs[i][1] + 2, CRYPT_DECODE_ALLOC_FLAG, NULL,
4702 &buf, &size);
4704 "Expected CRYPT_E_ASN1_CORRUPT, got %08lx\n", GetLastError());
4705 }
4706 /* at a minimum, a CRL must contain an issuer: */
4709 &buf, &size);
4710 ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
4711 if (ret)
4712 {
4713 CRL_INFO *info = (CRL_INFO *)buf;
4714
4715 ok(size >= sizeof(CRL_INFO), "Wrong size %ld\n", size);
4716 ok(info->cCRLEntry == 0, "Expected 0 CRL entries, got %ld\n",
4717 info->cCRLEntry);
4718 ok(info->Issuer.cbData == sizeof(encodedCommonName),
4719 "Wrong issuer size %ld\n", info->Issuer.cbData);
4720 ok(!memcmp(info->Issuer.pbData, encodedCommonName, info->Issuer.cbData),
4721 "Unexpected issuer\n");
4722 LocalFree(buf);
4723 }
4724 /* check decoding with an empty CRL entry */
4729 "Expected CRYPT_E_ASN1_CORRUPT or CRYPT_E_BAD_ENCODE, got %08lx\n",
4730 GetLastError());
4731 /* with a real CRL entry */
4735 ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
4736 if (ret)
4737 {
4738 CRL_INFO *info = (CRL_INFO *)buf;
4740
4741 ok(size >= sizeof(CRL_INFO), "Wrong size %ld\n", size);
4742 ok(info->cCRLEntry == 1, "Expected 1 CRL entries, got %ld\n",
4743 info->cCRLEntry);
4744 ok(info->rgCRLEntry != NULL, "Expected a valid CRL entry array\n");
4745 entry = info->rgCRLEntry;
4746 ok(entry->SerialNumber.cbData == 1,
4747 "Expected serial number size 1, got %ld\n",
4748 entry->SerialNumber.cbData);
4749 ok(*entry->SerialNumber.pbData == *serialNum,
4750 "Expected serial number %d, got %d\n", *serialNum,
4751 *entry->SerialNumber.pbData);
4752 ok(info->Issuer.cbData == sizeof(encodedCommonName),
4753 "Wrong issuer size %ld\n", info->Issuer.cbData);
4754 ok(!memcmp(info->Issuer.pbData, encodedCommonName, info->Issuer.cbData),
4755 "Unexpected issuer\n");
4756 LocalFree(buf);
4757 }
4758 /* a real CRL from verisign that has extensions */
4761 NULL, &buf, &size);
4762 ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
4763 if (ret)
4764 {
4765 CRL_INFO *info = (CRL_INFO *)buf;
4766
4767 ok(size >= sizeof(CRL_INFO), "Wrong size %ld\n", size);
4768 ok(info->cCRLEntry == 3, "Expected 3 CRL entries, got %ld\n",
4769 info->cCRLEntry);
4770 ok(info->rgCRLEntry != NULL, "Expected a valid CRL entry array\n");
4771 ok(info->cExtension == 2, "Expected 2 extensions, got %ld\n",
4772 info->cExtension);
4773 LocalFree(buf);
4774 }
4775 /* another real CRL from verisign that has lots of entries */
4779 ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
4780 if (ret)
4781 {
4782 CRL_INFO *info = (CRL_INFO *)buf;
4783
4784 ok(size >= sizeof(CRL_INFO), "Got size %ld\n", size);
4785 ok(info->cCRLEntry == 209, "Expected 209 CRL entries, got %ld\n",
4786 info->cCRLEntry);
4787 ok(info->cExtension == 0, "Expected 0 extensions, got %ld\n",
4788 info->cExtension);
4789 LocalFree(buf);
4790 }
4791 /* and finally, with an extension */
4794 NULL, &buf, &size);
4795 ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
4796 if (ret)
4797 {
4798 CRL_INFO *info = (CRL_INFO *)buf;
4800
4801 ok(size >= sizeof(CRL_INFO), "Wrong size %ld\n", size);
4802 ok(info->cCRLEntry == 1, "Expected 1 CRL entries, got %ld\n",
4803 info->cCRLEntry);
4804 ok(info->rgCRLEntry != NULL, "Expected a valid CRL entry array\n");
4805 entry = info->rgCRLEntry;
4806 ok(entry->SerialNumber.cbData == 1,
4807 "Expected serial number size 1, got %ld\n",
4808 entry->SerialNumber.cbData);
4809 ok(*entry->SerialNumber.pbData == *serialNum,
4810 "Expected serial number %d, got %d\n", *serialNum,
4811 *entry->SerialNumber.pbData);
4812 ok(info->Issuer.cbData == sizeof(encodedCommonName),
4813 "Wrong issuer size %ld\n", info->Issuer.cbData);
4814 ok(!memcmp(info->Issuer.pbData, encodedCommonName, info->Issuer.cbData),
4815 "Unexpected issuer\n");
4816 ok(info->cExtension == 1, "Expected 1 extensions, got %ld\n",
4817 info->cExtension);
4818 LocalFree(buf);
4819 }
4822 NULL, &buf, &size);
4823 ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
4824 if (ret)
4825 {
4826 CRL_INFO *info = (CRL_INFO *)buf;
4827
4828 ok(info->cExtension == 1, "Expected 1 extensions, got %ld\n",
4829 info->cExtension);
4830 LocalFree(buf);
4831 }
4832}
4833
4836static const BYTE encodedUsage[] = {
4837 0x30, 0x1f, 0x06, 0x08, 0x2b, 0x06, 0x01, 0x05, 0x05, 0x07, 0x03, 0x03,
4838 0x06, 0x08, 0x2b, 0x06, 0x01, 0x05, 0x05, 0x07, 0x03, 0x02, 0x06, 0x09,
4839 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x01 };
4840
4841static void test_encodeEnhancedKeyUsage(DWORD dwEncoding)
4842{
4843 BOOL ret;
4844 BYTE *buf = NULL;
4845 DWORD size = 0;
4847
4848 /* Test with empty usage */
4849 usage.cUsageIdentifier = 0;
4852 ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
4853 if (ret)
4854 {
4855 ok(size == sizeof(emptySequence), "Wrong size %ld\n", size);
4856 ok(!memcmp(buf, emptySequence, size), "Got unexpected value\n");
4857 LocalFree(buf);
4858 }
4859 /* Test with a few usages */
4860 usage.cUsageIdentifier = ARRAY_SIZE(keyUsages);
4861 usage.rgpszUsageIdentifier = (LPSTR *)keyUsages;
4864 ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
4865 if (ret)
4866 {
4867 ok(size == sizeof(encodedUsage), "Wrong size %ld\n", size);
4868 ok(!memcmp(buf, encodedUsage, size), "Got unexpected value\n");
4869 LocalFree(buf);
4870 }
4871}
4872
4873static void test_decodeEnhancedKeyUsage(DWORD dwEncoding)
4874{
4875 BOOL ret;
4876 LPBYTE buf = NULL;
4877 DWORD size = 0;
4878
4881 &buf, &size);
4882 ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
4883 if (ret)
4884 {
4886
4887 ok(size >= sizeof(CERT_ENHKEY_USAGE),
4888 "Wrong size %ld\n", size);
4889 ok(usage->cUsageIdentifier == 0, "Expected 0 CRL entries, got %ld\n",
4890 usage->cUsageIdentifier);
4891 LocalFree(buf);
4892 }
4895 &buf, &size);
4896 ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
4897 if (ret)
4898 {
4900 DWORD i;
4901
4902 ok(size >= sizeof(CERT_ENHKEY_USAGE),
4903 "Wrong size %ld\n", size);
4904 ok(usage->cUsageIdentifier == ARRAY_SIZE(keyUsages),
4905 "Wrong CRL entries count %ld\n", usage->cUsageIdentifier);
4906 for (i = 0; i < usage->cUsageIdentifier; i++)
4907 ok(!strcmp(usage->rgpszUsageIdentifier[i], keyUsages[i]),
4908 "Expected OID %s, got %s\n", keyUsages[i],
4909 usage->rgpszUsageIdentifier[i]);
4910 LocalFree(buf);
4911 }
4913 encodedUsage, sizeof(encodedUsage), 0, NULL, NULL, &size);
4914 ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
4915 buf = calloc(1, size);
4916 if (buf)
4917 {
4919 encodedUsage, sizeof(encodedUsage), 0, NULL, buf, &size);
4920 ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
4921 free(buf);
4922 }
4923}
4924
4925static BYTE keyId[] = { 1,2,3,4 };
4926static const BYTE authorityKeyIdWithId[] = {
4927 0x30,0x06,0x80,0x04,0x01,0x02,0x03,0x04 };
4928static const BYTE authorityKeyIdWithIssuer[] = { 0x30,0x19,0xa1,0x17,0x30,0x15,
4929 0x31,0x13,0x30,0x11,0x06,0x03,0x55,0x04,0x03,0x13,0x0a,0x4a,0x75,0x61,0x6e,
4930 0x20,0x4c,0x61,0x6e,0x67,0x00 };
4931static const BYTE authorityKeyIdWithSerial[] = { 0x30,0x03,0x82,0x01,0x01 };
4932
4933static void test_encodeAuthorityKeyId(DWORD dwEncoding)
4934{
4935 CERT_AUTHORITY_KEY_ID_INFO info = { { 0 } };
4936 BOOL ret;
4937 BYTE *buf = NULL;
4938 DWORD size = 0;
4939
4940 /* Test with empty id */
4943 ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
4944 if (ret)
4945 {
4946 ok(size == sizeof(emptySequence), "Unexpected size %ld\n", size);
4947 ok(!memcmp(buf, emptySequence, size), "Unexpected value\n");
4948 LocalFree(buf);
4949 }
4950 /* With just a key id */
4951 info.KeyId.cbData = sizeof(keyId);
4952 info.KeyId.pbData = keyId;
4955 ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
4956 if (ret)
4957 {
4958 ok(size == sizeof(authorityKeyIdWithId), "Unexpected size %ld\n", size);
4959 ok(!memcmp(buf, authorityKeyIdWithId, size), "Unexpected value\n");
4960 LocalFree(buf);
4961 }
4962 /* With just an issuer */
4963 info.KeyId.cbData = 0;
4964 info.CertIssuer.cbData = sizeof(encodedCommonName);
4965 info.CertIssuer.pbData = (BYTE *)encodedCommonName;
4968 ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
4969 if (ret)
4970 {
4971 ok(size == sizeof(authorityKeyIdWithIssuer), "Unexpected size %ld\n",
4972 size);
4973 ok(!memcmp(buf, authorityKeyIdWithIssuer, size), "Unexpected value\n");
4974 LocalFree(buf);
4975 }
4976 /* With just a serial number */
4977 info.CertIssuer.cbData = 0;
4978 info.CertSerialNumber.cbData = sizeof(serialNum);
4979 info.CertSerialNumber.pbData = (BYTE *)serialNum;
4982 ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
4983 if (ret)
4984 {
4985 ok(size == sizeof(authorityKeyIdWithSerial), "Unexpected size %ld\n",
4986 size);
4987 ok(!memcmp(buf, authorityKeyIdWithSerial, size), "Unexpected value\n");
4988 LocalFree(buf);
4989 }
4990}
4991
4992static void test_decodeAuthorityKeyId(DWORD dwEncoding)
4993{
4994 BOOL ret;
4995 LPBYTE buf = NULL;
4996 DWORD size = 0;
4997
5000 &buf, &size);
5001 ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
5002 if (ret)
5003 {
5005
5006 ok(size >= sizeof(CERT_AUTHORITY_KEY_ID_INFO), "Unexpected size %ld\n",
5007 size);
5008 ok(info->KeyId.cbData == 0, "Expected no key id\n");
5009 ok(info->CertIssuer.cbData == 0, "Expected no issuer name\n");
5010 ok(info->CertSerialNumber.cbData == 0, "Expected no serial number\n");
5011 LocalFree(buf);
5012 }
5016 ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
5017 if (ret)
5018 {
5020
5021 ok(size >= sizeof(CERT_AUTHORITY_KEY_ID_INFO), "Unexpected size %ld\n",
5022 size);
5023 ok(info->KeyId.cbData == sizeof(keyId), "Unexpected key id len\n");
5024 ok(!memcmp(info->KeyId.pbData, keyId, sizeof(keyId)),
5025 "Unexpected key id\n");
5026 ok(info->CertIssuer.cbData == 0, "Expected no issuer name\n");
5027 ok(info->CertSerialNumber.cbData == 0, "Expected no serial number\n");
5028 LocalFree(buf);
5029 }
5033 ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
5034 if (ret)
5035 {
5037
5038 ok(size >= sizeof(CERT_AUTHORITY_KEY_ID_INFO), "Unexpected size %ld\n",
5039 size);
5040 ok(info->KeyId.cbData == 0, "Expected no key id\n");
5041 ok(info->CertIssuer.cbData == sizeof(encodedCommonName),
5042 "Unexpected issuer len\n");
5043 ok(!memcmp(info->CertIssuer.pbData, encodedCommonName,
5044 sizeof(encodedCommonName)), "Unexpected issuer\n");
5045 ok(info->CertSerialNumber.cbData == 0, "Expected no serial number\n");
5046 LocalFree(buf);
5047 }
5051 ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
5052 if (ret)
5053 {
5055
5056 ok(size >= sizeof(CERT_AUTHORITY_KEY_ID_INFO), "Unexpected size %ld\n",
5057 size);
5058 ok(info->KeyId.cbData == 0, "Expected no key id\n");
5059 ok(info->CertIssuer.cbData == 0, "Expected no issuer name\n");
5060 ok(info->CertSerialNumber.cbData == sizeof(serialNum),
5061 "Unexpected serial number len\n");
5062 ok(!memcmp(info->CertSerialNumber.pbData, serialNum, sizeof(serialNum)),
5063 "Unexpected serial number\n");
5064 LocalFree(buf);
5065 }
5066}
5067
5068static const BYTE authorityKeyIdWithIssuerUrl[] = { 0x30,0x15,0xa1,0x13,0x86,
5069 0x11,0x68,0x74,0x74,0x70,0x3a,0x2f,0x2f,0x77,0x69,0x6e,0x65,0x68,0x71,0x2e,
5070 0x6f,0x72,0x67 };
5071
5072static void test_encodeAuthorityKeyId2(DWORD dwEncoding)
5073{
5075 CERT_ALT_NAME_ENTRY entry = { 0 };
5076 BOOL ret;
5077 BYTE *buf = NULL;
5078 DWORD size = 0;
5079
5080 /* Test with empty id */
5083 ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
5084 if (ret)
5085 {
5086 ok(size == sizeof(emptySequence), "Unexpected size %ld\n", size);
5087 ok(!memcmp(buf, emptySequence, size), "Unexpected value\n");
5088 LocalFree(buf);
5089 }
5090 /* With just a key id */
5091 info.KeyId.cbData = sizeof(keyId);
5092 info.KeyId.pbData = keyId;
5095 ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
5096 if (ret)
5097 {
5098 ok(size == sizeof(authorityKeyIdWithId), "Unexpected size %ld\n",
5099 size);
5100 ok(!memcmp(buf, authorityKeyIdWithId, size), "Unexpected value\n");
5101 LocalFree(buf);
5102 }
5103 /* With a bogus issuer name */
5104 info.KeyId.cbData = 0;
5105 info.AuthorityCertIssuer.cAltEntry = 1;
5106 info.AuthorityCertIssuer.rgAltEntry = &entry;
5110 "Expected E_INVALIDARG, got %08lx\n", GetLastError());
5111 /* With an issuer name */
5112 entry.dwAltNameChoice = CERT_ALT_NAME_URL;
5113 entry.pwszURL = (LPWSTR)url;
5116 ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
5117 if (ret)
5118 {
5119 ok(size == sizeof(authorityKeyIdWithIssuerUrl), "Unexpected size %ld\n",
5120 size);
5122 "Unexpected value\n");
5123 LocalFree(buf);
5124 }
5125 /* With just a serial number */
5126 info.AuthorityCertIssuer.cAltEntry = 0;
5127 info.AuthorityCertSerialNumber.cbData = sizeof(serialNum);
5128 info.AuthorityCertSerialNumber.pbData = (BYTE *)serialNum;
5131 ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
5132 if (ret)
5133 {
5134 ok(size == sizeof(authorityKeyIdWithSerial), "Unexpected size %ld\n",
5135 size);
5136 ok(!memcmp(buf, authorityKeyIdWithSerial, size), "Unexpected value\n");
5137 LocalFree(buf);
5138 }
5139}
5140
5141static void test_decodeAuthorityKeyId2(DWORD dwEncoding)
5142{
5143 BOOL ret;
5144 LPBYTE buf = NULL;
5145 DWORD size = 0;
5146
5149 &buf, &size);
5150 ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
5151 if (ret)
5152 {
5154
5155 ok(size >= sizeof(CERT_AUTHORITY_KEY_ID2_INFO), "Unexpected size %ld\n",
5156 size);
5157 ok(info->KeyId.cbData == 0, "Expected no key id\n");
5158 ok(info->AuthorityCertIssuer.cAltEntry == 0,
5159 "Expected no issuer name entries\n");
5160 ok(info->AuthorityCertSerialNumber.cbData == 0,
5161 "Expected no serial number\n");
5162 LocalFree(buf);
5163 }
5167 ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
5168 if (ret)
5169 {
5171
5172 ok(size >= sizeof(CERT_AUTHORITY_KEY_ID2_INFO), "Unexpected size %ld\n",
5173 size);
5174 ok(info->KeyId.cbData == sizeof(keyId), "Unexpected key id len\n");
5175 ok(!memcmp(info->KeyId.pbData, keyId, sizeof(keyId)),
5176 "Unexpected key id\n");
5177 ok(info->AuthorityCertIssuer.cAltEntry == 0,
5178 "Expected no issuer name entries\n");
5179 ok(info->AuthorityCertSerialNumber.cbData == 0,
5180 "Expected no serial number\n");
5181 LocalFree(buf);
5182 }
5186 ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
5187 if (ret)
5188 {
5190
5191 ok(size >= sizeof(CERT_AUTHORITY_KEY_ID2_INFO), "Unexpected size %ld\n",
5192 size);
5193 ok(info->KeyId.cbData == 0, "Expected no key id\n");
5194 ok(info->AuthorityCertIssuer.cAltEntry == 1,
5195 "Expected 1 issuer entry, got %ld\n",
5196 info->AuthorityCertIssuer.cAltEntry);
5197 ok(info->AuthorityCertIssuer.rgAltEntry[0].dwAltNameChoice ==
5198 CERT_ALT_NAME_URL, "Expected CERT_ALT_NAME_URL, got %ld\n",
5199 info->AuthorityCertIssuer.rgAltEntry[0].dwAltNameChoice);
5200 ok(!lstrcmpW(info->AuthorityCertIssuer.rgAltEntry[0].pwszURL,
5201 url), "Unexpected URL\n");
5202 ok(info->AuthorityCertSerialNumber.cbData == 0,
5203 "Expected no serial number\n");
5204 LocalFree(buf);
5205 }
5209 ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
5210 if (ret)
5211 {
5213
5214 ok(size >= sizeof(CERT_AUTHORITY_KEY_ID2_INFO), "Unexpected size %ld\n",
5215 size);
5216 ok(info->KeyId.cbData == 0, "Expected no key id\n");
5217 ok(info->AuthorityCertIssuer.cAltEntry == 0,
5218 "Expected no issuer name entries\n");
5219 ok(info->AuthorityCertSerialNumber.cbData == sizeof(serialNum),
5220 "Unexpected serial number len\n");
5221 ok(!memcmp(info->AuthorityCertSerialNumber.pbData, serialNum,
5222 sizeof(serialNum)), "Unexpected serial number\n");
5223 LocalFree(buf);
5224 }
5225}
5226
52280x30,0x19,0x30,0x17,0x06,0x02,0x2a,0x03,0x86,0x11,0x68,0x74,0x74,0x70,0x3a,
52290x2f,0x2f,0x77,0x69,0x6e,0x65,0x68,0x71,0x2e,0x6f,0x72,0x67 };
52310x30,0x29,0x30,0x17,0x06,0x02,0x2a,0x03,0x86,0x11,0x68,0x74,0x74,0x70,0x3a,
52320x2f,0x2f,0x77,0x69,0x6e,0x65,0x68,0x71,0x2e,0x6f,0x72,0x67,0x30,0x0e,0x06,
52330x02,0x2d,0x06,0x87,0x08,0x30,0x06,0x87,0x04,0x7f,0x00,0x00,0x01 };
5234
5236{
5237 static char oid1[] = "1.2.3";
5238 static char oid2[] = "1.5.6";
5239 BOOL ret;
5240 BYTE *buf = NULL;
5241 DWORD size = 0;
5242 CERT_ACCESS_DESCRIPTION accessDescription[2];
5244
5245 memset(accessDescription, 0, sizeof(accessDescription));
5246 aia.cAccDescr = 0;
5247 aia.rgAccDescr = NULL;
5248 /* Having no access descriptions is allowed */
5251 ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
5252 if (ret)
5253 {
5254 ok(size == sizeof(emptySequence), "unexpected size %ld\n", size);
5255 ok(!memcmp(buf, emptySequence, size), "unexpected value\n");
5256 LocalFree(buf);
5257 buf = NULL;
5258 }
5259 /* It can't have an empty access method */
5260 aia.cAccDescr = 1;
5261 aia.rgAccDescr = accessDescription;
5265 "expected E_INVALIDARG, got %08lx\n", GetLastError());
5266 /* It can't have an empty location */
5267 accessDescription[0].pszAccessMethod = oid1;
5268 SetLastError(0xdeadbeef);
5272 "expected E_INVALIDARG, got %08lx\n", GetLastError());
5273 accessDescription[0].AccessLocation.dwAltNameChoice = CERT_ALT_NAME_URL;
5274 accessDescription[0].AccessLocation.pwszURL = (LPWSTR)url;
5277 ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
5278 if (ret)
5279 {
5280 ok(size == sizeof(authorityInfoAccessWithUrl), "unexpected size %ld\n",
5281 size);
5283 "unexpected value\n");
5284 LocalFree(buf);
5285 buf = NULL;
5286 }
5287 accessDescription[1].pszAccessMethod = oid2;
5289 accessDescription[1].AccessLocation.IPAddress.cbData = sizeof(encodedIPAddr);
5290 accessDescription[1].AccessLocation.IPAddress.pbData = (LPBYTE)encodedIPAddr;
5291 aia.cAccDescr = 2;
5294 ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
5295 if (ret)
5296 {
5298 "unexpected size %ld\n", size);
5300 "unexpected value\n");
5301 LocalFree(buf);
5302 buf = NULL;
5303 }
5304}
5305
5308 const CERT_AUTHORITY_INFO_ACCESS *got)
5309{
5310 DWORD i;
5311
5312 ok(expected->cAccDescr == got->cAccDescr,
5313 "%s: expected %ld access descriptions, got %ld\n", header,
5314 expected->cAccDescr, got->cAccDescr);
5315 for (i = 0; i < expected->cAccDescr; i++)
5316 {
5317 ok(!strcmp(expected->rgAccDescr[i].pszAccessMethod,
5318 got->rgAccDescr[i].pszAccessMethod), "%s[%ld]: expected %s, got %s\n",
5319 header, i, expected->rgAccDescr[i].pszAccessMethod,
5321 compareAltNameEntry(&expected->rgAccDescr[i].AccessLocation,
5322 &got->rgAccDescr[i].AccessLocation);
5323 }
5324}
5325
5327{
5328 static char oid1[] = "1.2.3";
5329 static char oid2[] = "1.5.6";
5330 BOOL ret;
5331 LPBYTE buf = NULL;
5332 DWORD size = 0;
5333
5336 &buf, &size);
5337 ok(ret, "CryptDecodeObjectEx failed: %lx\n", GetLastError());
5338 if (ret)
5339 {
5341
5342 compareAuthorityInfoAccess("empty AIA", &aia,
5344 LocalFree(buf);
5345 buf = NULL;
5346 }
5350 ok(ret, "CryptDecodeObjectEx failed: %lx\n", GetLastError());
5351 if (ret)
5352 {
5353 CERT_ACCESS_DESCRIPTION accessDescription;
5355
5356 accessDescription.pszAccessMethod = oid1;
5358 accessDescription.AccessLocation.pwszURL = (LPWSTR)url;
5359 aia.cAccDescr = 1;
5360 aia.rgAccDescr = &accessDescription;
5361 compareAuthorityInfoAccess("AIA with URL", &aia,
5363 LocalFree(buf);
5364 buf = NULL;
5365 }
5369 NULL, &buf, &size);
5370 ok(ret, "CryptDecodeObjectEx failed: %lx\n", GetLastError());
5371 if (ret)
5372 {
5373 CERT_ACCESS_DESCRIPTION accessDescription[2];
5375
5376 accessDescription[0].pszAccessMethod = oid1;
5377 accessDescription[0].AccessLocation.dwAltNameChoice = CERT_ALT_NAME_URL;
5378 accessDescription[0].AccessLocation.pwszURL = (LPWSTR)url;
5379 accessDescription[1].pszAccessMethod = oid2;
5381 accessDescription[1].AccessLocation.IPAddress.cbData = sizeof(encodedIPAddr);
5382 accessDescription[1].AccessLocation.IPAddress.pbData = (LPBYTE)encodedIPAddr;
5383 aia.cAccDescr = 2;
5384 aia.rgAccDescr = accessDescription;
5385 compareAuthorityInfoAccess("AIA with URL and IP addr", &aia,
5387 LocalFree(buf);
5388 buf = NULL;
5389 }
5393 ok(ret, "CryptDecodeObjectEx failed: %lx\n", GetLastError());
5394 buf = calloc(1, size);
5395 if (buf)
5396 {
5400 ok(ret, "CryptDecodeObjectEx failed: %lx\n", GetLastError());
5401 free(buf);
5402 }
5403}
5404
5405static const BYTE emptyCTL[] = {
54060x30,0x17,0x30,0x00,0x18,0x0f,0x31,0x36,0x30,0x31,0x30,0x31,0x30,0x31,0x30,
54070x30,0x30,0x30,0x30,0x30,0x5a,0x30,0x02,0x06,0x00 };
5408static const BYTE emptyCTLWithVersion1[] = {
54090x30,0x1a,0x02,0x01,0x01,0x30,0x00,0x18,0x0f,0x31,0x36,0x30,0x31,0x30,0x31,
54100x30,0x31,0x30,0x30,0x30,0x30,0x30,0x30,0x5a,0x30,0x02,0x06,0x00 };
54120x30,0x1b,0x30,0x04,0x06,0x02,0x2a,0x03,0x18,0x0f,0x31,0x36,0x30,0x31,0x30,
54130x31,0x30,0x31,0x30,0x30,0x30,0x30,0x30,0x30,0x5a,0x30,0x02,0x06,0x00 };
5414static const BYTE ctlWithListIdentifier[] = {
54150x30,0x1a,0x30,0x00,0x04,0x01,0x01,0x18,0x0f,0x31,0x36,0x30,0x31,0x30,0x31,
54160x30,0x31,0x30,0x30,0x30,0x30,0x30,0x30,0x5a,0x30,0x02,0x06,0x00 };
5417static const BYTE ctlWithSequenceNumber[] = {
54180x30,0x1a,0x30,0x00,0x02,0x01,0x01,0x18,0x0f,0x31,0x36,0x30,0x31,0x30,0x31,
54190x30,0x31,0x30,0x30,0x30,0x30,0x30,0x30,0x5a,0x30,0x02,0x06,0x00 };
5420static const BYTE ctlWithThisUpdate[] = {
54210x30,0x15,0x30,0x00,0x17,0x0d,0x30,0x35,0x30,0x36,0x30,0x36,0x31,0x36,0x31,
54220x30,0x30,0x30,0x5a,0x30,0x02,0x06,0x00 };
54240x30,0x24,0x30,0x00,0x17,0x0d,0x30,0x35,0x30,0x36,0x30,0x36,0x31,0x36,0x31,
54250x30,0x30,0x30,0x5a,0x17,0x0d,0x30,0x35,0x30,0x36,0x30,0x36,0x31,0x36,0x31,
54260x30,0x30,0x30,0x5a,0x30,0x02,0x06,0x00 };
5427static const BYTE ctlWithAlgId[] = {
54280x30,0x1b,0x30,0x00,0x18,0x0f,0x31,0x36,0x30,0x31,0x30,0x31,0x30,0x31,0x30,
54290x30,0x30,0x30,0x30,0x30,0x5a,0x30,0x06,0x06,0x02,0x2d,0x06,0x05,0x00 };
5430static const BYTE ctlWithBogusEntry[] = {
54310x30,0x29,0x30,0x00,0x18,0x0f,0x31,0x36,0x30,0x31,0x30,0x31,0x30,0x31,0x30,
54320x30,0x30,0x30,0x30,0x30,0x5a,0x30,0x02,0x06,0x00,0x30,0x10,0x30,0x0e,0x04,
54330x01,0x01,0x31,0x09,0x30,0x07,0x06,0x02,0x2a,0x03,0x31,0x01,0x01 };
5434static const BYTE ctlWithOneEntry[] = {
54350x30,0x2a,0x30,0x00,0x18,0x0f,0x31,0x36,0x30,0x31,0x30,0x31,0x30,0x31,0x30,
54360x30,0x30,0x30,0x30,0x30,0x5a,0x30,0x02,0x06,0x00,0x30,0x11,0x30,0x0f,0x04,
54370x01,0x01,0x31,0x0a,0x30,0x08,0x06,0x02,0x2a,0x03,0x31,0x02,0x30,0x00 };
5438static const BYTE ctlWithTwoEntries[] = {
54390x30,0x41,0x30,0x00,0x18,0x0f,0x31,0x36,0x30,0x31,0x30,0x31,0x30,0x31,0x30,
54400x30,0x30,0x30,0x30,0x30,0x5a,0x30,0x02,0x06,0x00,0x30,0x28,0x30,0x0f,0x04,
54410x01,0x01,0x31,0x0a,0x30,0x08,0x06,0x02,0x2a,0x03,0x31,0x02,0x30,0x00,0x30,
54420x15,0x04,0x01,0x01,0x31,0x10,0x30,0x0e,0x06,0x02,0x2d,0x06,0x31,0x08,0x30,
54430x06,0x87,0x04,0x7f,0x00,0x00,0x01 };
5444
5445static void test_encodeCTL(DWORD dwEncoding)
5446{
5447 static char oid1[] = "1.2.3";
5448 static char oid2[] = "1.5.6";
5449 char *pOid1 = oid1;
5450 BOOL ret;
5451 BYTE *buf = NULL;
5452 DWORD size = 0;
5453 CTL_INFO info;
5454 SYSTEMTIME thisUpdate = { 2005, 6, 1, 6, 16, 10, 0, 0 };
5455 CTL_ENTRY ctlEntry[2];
5456 CRYPT_ATTRIBUTE attr1, attr2;
5457 CRYPT_ATTR_BLOB value1, value2;
5458
5459 memset(&info, 0, sizeof(info));
5460 ret = CryptEncodeObjectEx(dwEncoding, PKCS_CTL, &info,
5462 ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
5463 if (ret)
5464 {
5465 ok(size == sizeof(emptyCTL), "unexpected size %ld\n", size);
5466 ok(!memcmp(buf, emptyCTL, size), "unexpected value\n");
5467 LocalFree(buf);
5468 buf = NULL;
5469 }
5470 info.dwVersion = 1;
5471 ret = CryptEncodeObjectEx(dwEncoding, PKCS_CTL, &info,
5473 ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
5474 if (ret)
5475 {
5476 ok(size == sizeof(emptyCTLWithVersion1), "unexpected size %ld\n", size);
5477 ok(!memcmp(buf, emptyCTLWithVersion1, size), "unexpected value\n");
5478 LocalFree(buf);
5479 buf = NULL;
5480 }
5481 info.dwVersion = 0;
5482 info.SubjectUsage.cUsageIdentifier = 1;
5483 info.SubjectUsage.rgpszUsageIdentifier = &pOid1;
5484 ret = CryptEncodeObjectEx(dwEncoding, PKCS_CTL, &info,
5486 ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
5487 if (ret)
5488 {
5489 ok(size == sizeof(ctlWithUsageIdentifier), "unexpected size %ld\n",
5490 size);
5491 ok(!memcmp(buf, ctlWithUsageIdentifier, size), "unexpected value\n");
5492 LocalFree(buf);
5493 buf = NULL;
5494 }
5495 info.SubjectUsage.cUsageIdentifier = 0;
5496 info.ListIdentifier.cbData = sizeof(serialNum);
5497 info.ListIdentifier.pbData = (LPBYTE)serialNum;
5498 ret = CryptEncodeObjectEx(dwEncoding, PKCS_CTL, &info,
5500 ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
5501 if (ret)
5502 {
5503 ok(size == sizeof(ctlWithListIdentifier), "unexpected size %ld\n", size);
5504 ok(!memcmp(buf, ctlWithListIdentifier, size), "unexpected value\n");
5505 LocalFree(buf);
5506 buf = NULL;
5507 }
5508 info.ListIdentifier.cbData = 0;
5509 info.SequenceNumber.cbData = sizeof(serialNum);
5510 info.SequenceNumber.pbData = (LPBYTE)serialNum;
5511 ret = CryptEncodeObjectEx(dwEncoding, PKCS_CTL, &info,
5513 ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
5514 if (ret)
5515 {
5516 ok(size == sizeof(ctlWithSequenceNumber), "unexpected size %ld\n",
5517 size);
5518 ok(!memcmp(buf, ctlWithSequenceNumber, size), "unexpected value\n");
5519 LocalFree(buf);
5520 buf = NULL;
5521 }
5522 info.SequenceNumber.cbData = 0;
5523 SystemTimeToFileTime(&thisUpdate, &info.ThisUpdate);
5524 ret = CryptEncodeObjectEx(dwEncoding, PKCS_CTL, &info,
5526 ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
5527 if (ret)
5528 {
5529 ok(size == sizeof(ctlWithThisUpdate), "unexpected size %ld\n", size);
5530 ok(!memcmp(buf, ctlWithThisUpdate, size), "unexpected value\n");
5531 LocalFree(buf);
5532 buf = NULL;
5533 }
5534 SystemTimeToFileTime(&thisUpdate, &info.NextUpdate);
5535 ret = CryptEncodeObjectEx(dwEncoding, PKCS_CTL, &info,
5537 ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
5538 if (ret)
5539 {
5540 ok(size == sizeof(ctlWithThisAndNextUpdate), "unexpected size %ld\n",
5541 size);
5542 ok(!memcmp(buf, ctlWithThisAndNextUpdate, size), "unexpected value\n");
5543 LocalFree(buf);
5544 buf = NULL;
5545 }
5546 info.ThisUpdate.dwLowDateTime = info.ThisUpdate.dwHighDateTime = 0;
5547 info.NextUpdate.dwLowDateTime = info.NextUpdate.dwHighDateTime = 0;
5548 info.SubjectAlgorithm.pszObjId = oid2;
5549 ret = CryptEncodeObjectEx(dwEncoding, PKCS_CTL, &info,
5551 ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
5552 if (ret)
5553 {
5554 ok(size == sizeof(ctlWithAlgId), "unexpected size %ld\n", size);
5555 ok(!memcmp(buf, ctlWithAlgId, size), "unexpected value\n");
5556 LocalFree(buf);
5557 buf = NULL;
5558 }
5559 /* The value is supposed to be asn.1 encoded, so this'll fail to decode
5560 * (see tests below) but it'll encode fine.
5561 */
5562 info.SubjectAlgorithm.pszObjId = NULL;
5563 value1.cbData = sizeof(serialNum);
5564 value1.pbData = (LPBYTE)serialNum;
5565 attr1.pszObjId = oid1;
5566 attr1.cValue = 1;
5567 attr1.rgValue = &value1;
5568 ctlEntry[0].SubjectIdentifier.cbData = sizeof(serialNum);
5570 ctlEntry[0].cAttribute = 1;
5571 ctlEntry[0].rgAttribute = &attr1;
5572 info.cCTLEntry = 1;
5573 info.rgCTLEntry = ctlEntry;
5574 ret = CryptEncodeObjectEx(dwEncoding, PKCS_CTL, &info,
5576 ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
5577 if (ret)
5578 {
5579 ok(size == sizeof(ctlWithBogusEntry), "unexpected size %ld\n", size);
5580 ok(!memcmp(buf, ctlWithBogusEntry, size), "unexpected value\n");
5581 LocalFree(buf);
5582 buf = NULL;
5583 }
5584 value1.cbData = sizeof(emptySequence);
5585 value1.pbData = (LPBYTE)emptySequence;
5586 ret = CryptEncodeObjectEx(dwEncoding, PKCS_CTL, &info,
5588 ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
5589 if (ret)
5590 {
5591 ok(size == sizeof(ctlWithOneEntry), "unexpected size %ld\n", size);
5592 ok(!memcmp(buf, ctlWithOneEntry, size), "unexpected value\n");
5593 LocalFree(buf);
5594 buf = NULL;
5595 }
5596 value2.cbData = sizeof(encodedIPAddr);
5597 value2.pbData = (LPBYTE)encodedIPAddr;
5598 attr2.pszObjId = oid2;
5599 attr2.cValue = 1;
5600 attr2.rgValue = &value2;
5601 ctlEntry[1].SubjectIdentifier.cbData = sizeof(serialNum);
5603 ctlEntry[1].cAttribute = 1;
5604 ctlEntry[1].rgAttribute = &attr2;
5605 info.cCTLEntry = 2;
5606 ret = CryptEncodeObjectEx(dwEncoding, PKCS_CTL, &info,
5608 ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
5609 if (ret)
5610 {
5611 ok(size == sizeof(ctlWithTwoEntries), "unexpected size %ld\n", size);
5612 ok(!memcmp(buf, ctlWithTwoEntries, size), "unexpected value\n");
5613 LocalFree(buf);
5614 buf = NULL;
5615 }
5616}
5617
5619 const CTL_INFO *got)
5620{
5621 DWORD i, j, k;
5622
5623 ok(expected->dwVersion == got->dwVersion,
5624 "%s: expected version %ld, got %ld\n", header, expected->dwVersion,
5625 got->dwVersion);
5626 ok(expected->SubjectUsage.cUsageIdentifier ==
5628 "%s: expected %ld usage identifiers, got %ld\n", header,
5629 expected->SubjectUsage.cUsageIdentifier,
5631 for (i = 0; i < expected->SubjectUsage.cUsageIdentifier; i++)
5632 ok(!strcmp(expected->SubjectUsage.rgpszUsageIdentifier[i],
5634 "%s[%ld]: expected %s, got %s\n", header, i,
5635 expected->SubjectUsage.rgpszUsageIdentifier[i],
5637 ok(expected->ListIdentifier.cbData == got->ListIdentifier.cbData,
5638 "%s: expected list identifier of %ld bytes, got %ld\n", header,
5639 expected->ListIdentifier.cbData, got->ListIdentifier.cbData);
5640 if (expected->ListIdentifier.cbData)
5641 ok(!memcmp(expected->ListIdentifier.pbData, got->ListIdentifier.pbData,
5642 expected->ListIdentifier.cbData),
5643 "%s: unexpected list identifier value\n", header);
5644 ok(expected->SequenceNumber.cbData == got->SequenceNumber.cbData,
5645 "%s: expected sequence number of %ld bytes, got %ld\n", header,
5646 expected->SequenceNumber.cbData, got->SequenceNumber.cbData);
5647 if (expected->SequenceNumber.cbData)
5648 ok(!memcmp(expected->SequenceNumber.pbData, got->SequenceNumber.pbData,
5649 expected->SequenceNumber.cbData),
5650 "%s: unexpected sequence number value\n", header);
5651 ok(!memcmp(&expected->ThisUpdate, &got->ThisUpdate, sizeof(FILETIME)),
5652 "%s: expected this update = (%ld, %ld), got (%ld, %ld)\n", header,
5653 expected->ThisUpdate.dwLowDateTime, expected->ThisUpdate.dwHighDateTime,
5655 ok(!memcmp(&expected->NextUpdate, &got->NextUpdate, sizeof(FILETIME)),
5656 "%s: expected next update = (%ld, %ld), got (%ld, %ld)\n", header,
5657 expected->NextUpdate.dwLowDateTime, expected->NextUpdate.dwHighDateTime,
5659 if (expected->SubjectAlgorithm.pszObjId &&
5660 *expected->SubjectAlgorithm.pszObjId && !got->SubjectAlgorithm.pszObjId)
5661 ok(0, "%s: expected subject algorithm %s, got NULL\n", header,
5662 expected->SubjectAlgorithm.pszObjId);
5663 if (expected->SubjectAlgorithm.pszObjId && got->SubjectAlgorithm.pszObjId)
5664 ok(!strcmp(expected->SubjectAlgorithm.pszObjId,
5666 "%s: expected subject algorithm %s, got %s\n", header,
5667 expected->SubjectAlgorithm.pszObjId, got->SubjectAlgorithm.pszObjId);
5668 ok(expected->SubjectAlgorithm.Parameters.cbData ==
5670 "%s: expected subject algorithm parameters of %ld bytes, got %ld\n", header,
5671 expected->SubjectAlgorithm.Parameters.cbData,
5673 if (expected->SubjectAlgorithm.Parameters.cbData)
5674 ok(!memcmp(expected->SubjectAlgorithm.Parameters.pbData,
5676 expected->SubjectAlgorithm.Parameters.cbData),
5677 "%s: unexpected subject algorithm parameter value\n", header);
5678 ok(expected->cCTLEntry == got->cCTLEntry,
5679 "%s: expected %ld CTL entries, got %ld\n", header, expected->cCTLEntry,
5680 got->cCTLEntry);
5681 for (i = 0; i < expected->cCTLEntry; i++)
5682 {
5683 ok(expected->rgCTLEntry[i].SubjectIdentifier.cbData ==
5685 "%s[%ld]: expected subject identifier of %ld bytes, got %ld\n",
5686 header, i, expected->rgCTLEntry[i].SubjectIdentifier.cbData,
5688 if (expected->rgCTLEntry[i].SubjectIdentifier.cbData)
5689 ok(!memcmp(expected->rgCTLEntry[i].SubjectIdentifier.pbData,
5691 expected->rgCTLEntry[i].SubjectIdentifier.cbData),
5692 "%s[%ld]: unexpected subject identifier value\n",
5693 header, i);
5694 for (j = 0; j < expected->rgCTLEntry[i].cAttribute; j++)
5695 {
5696 ok(!strcmp(expected->rgCTLEntry[i].rgAttribute[j].pszObjId,
5698 "%s[%ld][%ld]: expected attribute OID %s, got %s\n", header, i, j,
5699 expected->rgCTLEntry[i].rgAttribute[j].pszObjId,
5701 for (k = 0; k < expected->rgCTLEntry[i].rgAttribute[j].cValue; k++)
5702 {
5703 ok(expected->rgCTLEntry[i].rgAttribute[j].rgValue[k].cbData ==
5705 "%s[%ld][%ld][%ld]: expected value of %ld bytes, got %ld\n",
5706 header, i, j, k,
5707 expected->rgCTLEntry[i].rgAttribute[j].rgValue[k].cbData,
5709 if (expected->rgCTLEntry[i].rgAttribute[j].rgValue[k].cbData)
5710 ok(!memcmp(
5711 expected->rgCTLEntry[i].rgAttribute[j].rgValue[k].pbData,
5713 expected->rgCTLEntry[i].rgAttribute[j].rgValue[k].cbData),
5714 "%s[%ld][%ld][%ld]: unexpected value\n",
5715 header, i, j, k);
5716 }
5717 }
5718 }
5719 ok(expected->cExtension == got->cExtension,
5720 "%s: expected %ld extensions, got %ld\n", header, expected->cExtension,
5721 got->cExtension);
5722 for (i = 0; i < expected->cExtension; i++)
5723 {
5724 ok(!strcmp(expected->rgExtension[i].pszObjId,
5725 got->rgExtension[i].pszObjId), "%s[%ld]: expected %s, got %s\n",
5726 header, i, expected->rgExtension[i].pszObjId,
5727 got->rgExtension[i].pszObjId);
5728 ok(expected->rgExtension[i].fCritical == got->rgExtension[i].fCritical,
5729 "%s[%ld]: expected fCritical = %d, got %d\n", header, i,
5730 expected->rgExtension[i].fCritical, got->rgExtension[i].fCritical);
5731 ok(expected->rgExtension[i].Value.cbData ==
5732 got->rgExtension[i].Value.cbData,
5733 "%s[%ld]: expected extension value to have %ld bytes, got %ld\n",
5734 header, i, expected->rgExtension[i].Value.cbData,
5735 got->rgExtension[i].Value.cbData);
5736 if (expected->rgExtension[i].Value.cbData)
5737 ok(!memcmp(expected->rgExtension[i].Value.pbData,
5738 got->rgExtension[i].Value.pbData,
5739 expected->rgExtension[i].Value.cbData),
5740 "%s[%ld]: unexpected extension value\n", header, i);
5741 }
5742}
5743
5744static const BYTE signedCTL[] = {
57450x30,0x81,0xc7,0x06,0x09,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x01,0x07,0x02,0xa0,
57460x81,0xb9,0x30,0x81,0xb6,0x02,0x01,0x01,0x31,0x0e,0x30,0x0c,0x06,0x08,0x2a,
57470x86,0x48,0x86,0xf7,0x0d,0x02,0x05,0x05,0x00,0x30,0x28,0x06,0x09,0x2a,0x86,
57480x48,0x86,0xf7,0x0d,0x01,0x07,0x01,0xa0,0x1b,0x04,0x19,0x30,0x17,0x30,0x00,
57490x18,0x0f,0x31,0x36,0x30,0x31,0x30,0x31,0x30,0x31,0x30,0x30,0x30,0x30,0x30,
57500x30,0x5a,0x30,0x02,0x06,0x00,0x31,0x77,0x30,0x75,0x02,0x01,0x01,0x30,0x1a,
57510x30,0x15,0x31,0x13,0x30,0x11,0x06,0x03,0x55,0x04,0x03,0x13,0x0a,0x4a,0x75,
57520x61,0x6e,0x20,0x4c,0x61,0x6e,0x67,0x00,0x02,0x01,0x01,0x30,0x0c,0x06,0x08,
57530x2a,0x86,0x48,0x86,0xf7,0x0d,0x02,0x05,0x05,0x00,0x30,0x04,0x06,0x00,0x05,
57540x00,0x04,0x40,0xca,0xd8,0x32,0xd1,0xbd,0x97,0x61,0x54,0xd6,0x80,0xcf,0x0d,
57550xbd,0xa2,0x42,0xc7,0xca,0x37,0x91,0x7d,0x9d,0xac,0x8c,0xdf,0x05,0x8a,0x39,
57560xc6,0x07,0xc1,0x37,0xe6,0xb9,0xd1,0x0d,0x26,0xec,0xa5,0xb0,0x8a,0x51,0x26,
57570x2b,0x4f,0x73,0x44,0x86,0x83,0x5e,0x2b,0x6e,0xcc,0xf8,0x1b,0x85,0x53,0xe9,
57580x7a,0x80,0x8f,0x6b,0x42,0x19,0x93 };
57600x30,0x82,0x01,0x0f,0x06,0x09,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x01,0x07,0x02,
57610xa0,0x82,0x01,0x00,0x30,0x81,0xfd,0x02,0x01,0x01,0x31,0x0e,0x30,0x0c,0x06,
57620x08,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x02,0x05,0x05,0x00,0x30,0x30,0x06,0x09,
57630x2b,0x06,0x01,0x04,0x01,0x82,0x37,0x0a,0x01,0xa0,0x23,0x30,0x21,0x30,0x00,
57640x18,0x0f,0x31,0x36,0x30,0x31,0x30,0x31,0x30,0x31,0x30,0x30,0x30,0x30,0x30,
57650x30,0x5a,0x30,0x0c,0x06,0x08,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x02,0x05,0x05,
57660x00,0x31,0x81,0xb5,0x30,0x81,0xb2,0x02,0x01,0x01,0x30,0x1a,0x30,0x15,0x31,
57670x13,0x30,0x11,0x06,0x03,0x55,0x04,0x03,0x13,0x0a,0x4a,0x75,0x61,0x6e,0x20,
57680x4c,0x61,0x6e,0x67,0x00,0x02,0x01,0x01,0x30,0x0c,0x06,0x08,0x2a,0x86,0x48,
57690x86,0xf7,0x0d,0x02,0x05,0x05,0x00,0xa0,0x3b,0x30,0x18,0x06,0x09,0x2a,0x86,
57700x48,0x86,0xf7,0x0d,0x01,0x09,0x03,0x31,0x0b,0x06,0x09,0x2b,0x06,0x01,0x04,
57710x01,0x82,0x37,0x0a,0x01,0x30,0x1f,0x06,0x09,0x2a,0x86,0x48,0x86,0xf7,0x0d,
57720x01,0x09,0x04,0x31,0x12,0x04,0x10,0x54,0x71,0xbc,0xe1,0x56,0x31,0xa2,0xf9,
57730x65,0x70,0x34,0xf8,0xe2,0xe9,0xb4,0xf4,0x30,0x04,0x06,0x00,0x05,0x00,0x04,
57740x40,0x2f,0x1b,0x9f,0x5a,0x4a,0x15,0x73,0xfa,0xb1,0x93,0x3d,0x09,0x52,0xdf,
57750x6b,0x98,0x4b,0x13,0x5e,0xe7,0xbf,0x65,0xf4,0x9c,0xc2,0xb1,0x77,0x09,0xb1,
57760x66,0x4d,0x72,0x0d,0xb1,0x1a,0x50,0x20,0xe0,0x57,0xa2,0x39,0xc7,0xcd,0x7f,
57770x8e,0xe7,0x5f,0x76,0x2b,0xd1,0x6a,0x82,0xb3,0x30,0x25,0x61,0xf6,0x25,0x23,
57780x57,0x6c,0x0b,0x47,0xb8 };
5779
5780static void test_decodeCTL(DWORD dwEncoding)
5781{
5782 static char oid1[] = "1.2.3";
5783 static char oid2[] = "1.5.6";
5784 static BYTE nullData[] = { 5,0 };
5785 char *pOid1 = oid1;
5786 BOOL ret;
5787 BYTE *buf = NULL;
5788 DWORD size = 0;
5789 CTL_INFO info;
5790 SYSTEMTIME thisUpdate = { 2005, 6, 1, 6, 16, 10, 0, 0 };
5791 CTL_ENTRY ctlEntry[2];
5792 CRYPT_ATTRIBUTE attr1, attr2;
5793 CRYPT_ATTR_BLOB value1, value2;
5794
5795 memset(&info, 0, sizeof(info));
5796 ret = CryptDecodeObjectEx(dwEncoding, PKCS_CTL, emptyCTL, sizeof(emptyCTL),
5798 ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
5799 if (ret)
5800 {
5801 compareCTLInfo("empty CTL", &info, (CTL_INFO *)buf);
5802 LocalFree(buf);
5803 buf = NULL;
5804 }
5805 info.dwVersion = 1;
5808 &size);
5809 ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
5810 if (ret)
5811 {
5812 compareCTLInfo("v1 CTL", &info, (CTL_INFO *)buf);
5813 LocalFree(buf);
5814 buf = NULL;
5815 }
5816 info.dwVersion = 0;
5817 info.SubjectUsage.cUsageIdentifier = 1;
5818 info.SubjectUsage.rgpszUsageIdentifier = &pOid1;
5821 &buf, &size);
5822 ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
5823 if (ret)
5824 {
5825 compareCTLInfo("CTL with usage identifier", &info, (CTL_INFO *)buf);
5826 LocalFree(buf);
5827 buf = NULL;
5828 }
5829 info.SubjectUsage.cUsageIdentifier = 0;
5830 info.ListIdentifier.cbData = sizeof(serialNum);
5831 info.ListIdentifier.pbData = (LPBYTE)serialNum;
5834 ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
5835 if (ret)
5836 {
5837 compareCTLInfo("CTL with list identifier", &info, (CTL_INFO *)buf);
5838 LocalFree(buf);
5839 buf = NULL;
5840 }
5841 info.ListIdentifier.cbData = 0;
5842 info.SequenceNumber.cbData = sizeof(serialNum);
5843 info.SequenceNumber.pbData = (LPBYTE)serialNum;
5846 ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
5847 if (ret)
5848 {
5849 compareCTLInfo("CTL with sequence number", &info, (CTL_INFO *)buf);
5850 LocalFree(buf);
5851 buf = NULL;
5852 }
5853 info.SequenceNumber.cbData = 0;
5854 SystemTimeToFileTime(&thisUpdate, &info.ThisUpdate);
5857 ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
5858 if (ret)
5859 {
5860 compareCTLInfo("CTL with this update", &info, (CTL_INFO *)buf);
5861 LocalFree(buf);
5862 buf = NULL;
5863 }
5864 SystemTimeToFileTime(&thisUpdate, &info.NextUpdate);
5867 &buf, &size);
5868 ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
5869 if (ret)
5870 {
5871 compareCTLInfo("CTL with this and next update", &info, (CTL_INFO *)buf);
5872 LocalFree(buf);
5873 buf = NULL;
5874 }
5875 info.ThisUpdate.dwLowDateTime = info.ThisUpdate.dwHighDateTime = 0;
5876 info.NextUpdate.dwLowDateTime = info.NextUpdate.dwHighDateTime = 0;
5877 info.SubjectAlgorithm.pszObjId = oid2;
5878 info.SubjectAlgorithm.Parameters.cbData = sizeof(nullData);
5879 info.SubjectAlgorithm.Parameters.pbData = nullData;
5882 ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
5883 if (ret)
5884 {
5885 compareCTLInfo("CTL with algorithm identifier", &info, (CTL_INFO *)buf);
5886 LocalFree(buf);
5887 buf = NULL;
5888 }
5889 SetLastError(0xdeadbeef);
5893 "expected CRYPT_E_ASN1_EOD or CRYPT_E_ASN1_CORRUPT, got %08lx\n",
5894 GetLastError());
5895 info.SubjectAlgorithm.Parameters.cbData = 0;
5896 info.ThisUpdate.dwLowDateTime = info.ThisUpdate.dwHighDateTime = 0;
5897 info.NextUpdate.dwLowDateTime = info.NextUpdate.dwHighDateTime = 0;
5898 info.SubjectAlgorithm.pszObjId = NULL;
5899 value1.cbData = sizeof(emptySequence);
5900 value1.pbData = (LPBYTE)emptySequence;
5901 attr1.pszObjId = oid1;
5902 attr1.cValue = 1;
5903 attr1.rgValue = &value1;
5904 ctlEntry[0].SubjectIdentifier.cbData = sizeof(serialNum);
5906 ctlEntry[0].cAttribute = 1;
5907 ctlEntry[0].rgAttribute = &attr1;
5908 info.cCTLEntry = 1;
5909 info.rgCTLEntry = ctlEntry;
5910 SetLastError(0xdeadbeef);
5913 ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
5914 if (ret)
5915 {
5916 compareCTLInfo("CTL with one entry", &info, (CTL_INFO *)buf);
5917 LocalFree(buf);
5918 buf = NULL;
5919 }
5920 value2.cbData = sizeof(encodedIPAddr);
5921 value2.pbData = (LPBYTE)encodedIPAddr;
5922 attr2.pszObjId = oid2;
5923 attr2.cValue = 1;
5924 attr2.rgValue = &value2;
5925 ctlEntry[1].SubjectIdentifier.cbData = sizeof(serialNum);
5927 ctlEntry[1].cAttribute = 1;
5928 ctlEntry[1].rgAttribute = &attr2;
5929 info.cCTLEntry = 2;
5932 ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
5933 if (ret)
5934 {
5935 compareCTLInfo("CTL with two entries", &info, (CTL_INFO *)buf);
5936 LocalFree(buf);
5937 buf = NULL;
5938 }
5939 /* A signed CTL isn't decodable, even if the inner content is a CTL */
5940 SetLastError(0xdeadbeef);
5944 "expected CRYPT_E_ASN1_BADTAG, got %08lx\n", GetLastError());
5945 SetLastError(0xdeadbeef);
5946 ret = CryptDecodeObjectEx(dwEncoding, PKCS_CTL,
5950 "expected CRYPT_E_ASN1_BADTAG, got %08lx\n", GetLastError());
5951}
5952
5953static const BYTE emptyPKCSContentInfo[] = { 0x30,0x04,0x06,0x02,0x2a,0x03 };
5954static const BYTE emptyPKCSContentInfoExtraBytes[] = { 0x30,0x04,0x06,0x02,0x2a,
5955 0x03,0,0,0,0,0,0 };
5956static const BYTE bogusPKCSContentInfo[] = { 0x30,0x07,0x06,0x02,0x2a,0x03,
5957 0xa0,0x01,0x01 };
5958static const BYTE intPKCSContentInfo[] = { 0x30,0x09,0x06,0x02,0x2a,0x03,0xa0,
5959 0x03,0x02,0x01,0x01 };
5960static BYTE bogusDER[] = { 1 };
5961
5962static void test_encodePKCSContentInfo(DWORD dwEncoding)
5963{
5964 BOOL ret;
5965 BYTE *buf = NULL;
5966 DWORD size = 0;
5967 CRYPT_CONTENT_INFO info = { 0 };
5968 char oid1[] = "1.2.3";
5969
5970 SetLastError(0xdeadbeef);
5974 "Expected STATUS_ACCESS_VIOLATION, got %lx\n", GetLastError());
5975
5976 SetLastError(0xdeadbeef);
5980 "Expected E_INVALIDARG, got %lx\n", GetLastError());
5981 info.pszObjId = oid1;
5984 ok(ret, "CryptEncodeObjectEx failed: %lx\n", GetLastError());
5985 if (ret)
5986 {
5987 ok(size == sizeof(emptyPKCSContentInfo), "Unexpected size %ld\n", size);
5988 ok(!memcmp(buf, emptyPKCSContentInfo, size), "Unexpected value\n");
5989 LocalFree(buf);
5990 }
5991 info.Content.pbData = bogusDER;
5992 info.Content.cbData = sizeof(bogusDER);
5995 ok(ret, "CryptEncodeObjectEx failed; %lx\n", GetLastError());
5996 if (ret)
5997 {
5998 ok(size == sizeof(bogusPKCSContentInfo), "Unexpected size %ld\n", size);
5999 ok(!memcmp(buf, bogusPKCSContentInfo, size), "Unexpected value\n");
6000 LocalFree(buf);
6001 }
6002 info.Content.pbData = (BYTE *)ints[0].encoded;
6003 info.Content.cbData = ints[0].encoded[1] + 2;
6006 if (ret)
6007 {
6008 ok(size == sizeof(intPKCSContentInfo), "Unexpected size %ld\n", size);
6009 ok(!memcmp(buf, intPKCSContentInfo, size), "Unexpected value\n");
6010 LocalFree(buf);
6011 }
6012}
6013
60150x30,0x80,0x06,0x09,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x01,0x07,0x02,0xa0,0x80,
60160x30,0x80,0x02,0x01,0x01,0x31,0x0e,0x30,0x0c,0x06,0x08,0x2a,0x86,0x48,0x86,
60170xf7,0x0d,0x02,0x05,0x05,0x00,0x30,0x80,0x06,0x09,0x2a,0x86,0x48,0x86,0xf7,
60180x0d,0x01,0x07,0x01,0xa0,0x80,0x24,0x80,0x04,0x04,0x01,0x02,0x03,0x04,0x04,
60190x04,0x01,0x02,0x03,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0xa0,0x81,0xd2,0x30,
60200x81,0xcf,0x02,0x01,0x01,0x30,0x02,0x06,0x00,0x30,0x15,0x31,0x13,0x30,0x11,
60210x06,0x03,0x55,0x04,0x03,0x13,0x0a,0x4a,0x75,0x61,0x6e,0x20,0x4c,0x61,0x6e,
60220x67,0x00,0x30,0x22,0x18,0x0f,0x31,0x36,0x30,0x31,0x30,0x31,0x30,0x31,0x30,
60230x30,0x30,0x30,0x30,0x30,0x5a,0x18,0x0f,0x31,0x36,0x30,0x31,0x30,0x31,0x30,
60240x31,0x30,0x30,0x30,0x30,0x30,0x30,0x5a,0x30,0x15,0x31,0x13,0x30,0x11,0x06,
60250x03,0x55,0x04,0x03,0x13,0x0a,0x4a,0x75,0x61,0x6e,0x20,0x4c,0x61,0x6e,0x67,
60260x00,0x30,0x5c,0x30,0x0d,0x06,0x09,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x01,0x01,
60270x01,0x05,0x00,0x03,0x4b,0x00,0x30,0x48,0x02,0x41,0x00,0xe2,0x54,0x3a,0xa7,
60280x83,0xb1,0x27,0x14,0x3e,0x59,0xbb,0xb4,0x53,0xe6,0x1f,0xe7,0x5d,0xf1,0x21,
60290x68,0xad,0x85,0x53,0xdb,0x6b,0x1e,0xeb,0x65,0x97,0x03,0x86,0x60,0xde,0xf3,
60300x6c,0x38,0x75,0xe0,0x4c,0x61,0xbb,0xbc,0x62,0x17,0xa9,0xcd,0x79,0x3f,0x21,
60310x4e,0x96,0xcb,0x0e,0xdc,0x61,0x94,0x30,0x18,0x10,0x6b,0xd0,0x1c,0x10,0x79,
60320x02,0x03,0x01,0x00,0x01,0xa3,0x16,0x30,0x14,0x30,0x12,0x06,0x03,0x55,0x1d,
60330x13,0x01,0x01,0xff,0x04,0x08,0x30,0x06,0x01,0x01,0xff,0x02,0x01,0x01,0x31,
60340x77,0x30,0x75,0x02,0x01,0x01,0x30,0x1a,0x30,0x15,0x31,0x13,0x30,0x11,0x06,
60350x03,0x55,0x04,0x03,0x13,0x0a,0x4a,0x75,0x61,0x6e,0x20,0x4c,0x61,0x6e,0x67,
60360x00,0x02,0x01,0x01,0x30,0x0c,0x06,0x08,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x02,
60370x05,0x05,0x00,0x30,0x04,0x06,0x00,0x05,0x00,0x04,0x40,0x57,0xba,0xe0,0xad,
60380xfe,0x36,0x8d,0xb3,0x88,0xa2,0x8d,0x84,0x82,0x52,0x09,0x09,0xd9,0xf0,0xb8,
60390x04,0xfa,0xb5,0x51,0x0b,0x2b,0x2e,0xd5,0x72,0x3e,0x3d,0x13,0x8a,0x51,0xc3,
60400x71,0x65,0x9a,0x52,0xf2,0x8f,0xb2,0x5b,0x39,0x28,0xb3,0x29,0x36,0xa5,0x8d,
60410xe3,0x55,0x71,0x91,0xf9,0x2a,0xd1,0xb8,0xaa,0x52,0xb8,0x22,0x3a,0xeb,0x61,
60420x00,0x00,0x00,0x00,0x00,0x00 };
6043
6044static const BYTE content_abcd[] = {
6045 ASN_SEQUENCE, 0x80,
6046 ASN_OBJECTIDENTIFIER, 2, 42,3,
6048 ASN_OCTETSTRING, 4, 'a','b','c','d',
6049 0,0,
6050 0,0,
6051};
6052
6053static const BYTE encoded_abcd[] = {
6054 ASN_OCTETSTRING, 4, 'a','b','c','d',
6055};
6056
6058 ASN_SEQUENCE, 0x80,
6059 ASN_OBJECTIDENTIFIER, 2, 42,3,
6062 ASN_OCTETSTRING, 4, 'a','b','0','0',
6063 0,0,
6064 0,0,
6065 0,0,
6066 1,2,3,4,5,6,7 /* extra garbage */
6067};
6068
6069static void test_decodePKCSContentInfo(DWORD dwEncoding)
6070{
6071 BOOL ret;
6072 LPBYTE buf = NULL;
6073 DWORD size = 0, i;
6075
6076 const struct {
6077 const BYTE *encoded;
6078 UINT encoded_size;
6079 const char *obj_id;
6080 const BYTE *content;
6081 UINT content_size;
6082 } tests[] = {
6084 "1.2.3", NULL, 0 },
6086 "1.2.3", NULL, 0 },
6088 "1.2.3", ints[0].encoded, ints[0].encoded[1] + 2 },
6090 "1.2.840.113549.1.7.2", NULL, 392 },
6091 { content_abcd, sizeof(content_abcd),
6092 "1.2.3", encoded_abcd, 6 },
6094 "1.2.3", content_constructed_abcd + 8, 10 }
6095 };
6096
6097 for (i = 0; i < ARRAY_SIZE(tests); i++)
6098 {
6099 ret = CryptDecodeObjectEx(dwEncoding, PKCS_CONTENT_INFO, tests[i].encoded,
6100 tests[i].encoded_size, CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size);
6101 ok(ret, "[%lu] CryptDecodeObjectEx failed: %lx\n", i, GetLastError());
6102 if (!ret) continue;
6103
6105
6106 ok(!strcmp(info->pszObjId, tests[i].obj_id), "[%lu] Expected %s, got %s\n",
6107 i, tests[i].obj_id, info->pszObjId);
6108 ok(info->Content.cbData == tests[i].content_size,
6109 "[%lu] Unexpected size %ld expected %d\n", i, info->Content.cbData,
6110 tests[i].content_size);
6111 if (tests[i].content)
6112 ok(!memcmp(info->Content.pbData, tests[i].content, tests[i].content_size),
6113 "[%lu] Unexpected value\n", i);
6114 LocalFree(buf);
6115 }
6116
6120 /* Native fails with CRYPT_E_ASN1_EOD, accept also CRYPT_E_ASN1_CORRUPT as
6121 * I doubt an app depends on that.
6122 */
6123 ok(!ret && (GetLastError() == CRYPT_E_ASN1_EOD ||
6125 "Expected CRYPT_E_ASN1_EOD or CRYPT_E_ASN1_CORRUPT, got %lx\n",
6126 GetLastError());
6127}
6128
6129static const BYTE emptyPKCSAttr[] = { 0x30,0x06,0x06,0x02,0x2a,0x03,0x31,
6130 0x00 };
6131static const BYTE bogusPKCSAttr[] = { 0x30,0x07,0x06,0x02,0x2a,0x03,0x31,0x01,
6132 0x01 };
6133static const BYTE intPKCSAttr[] = { 0x30,0x09,0x06,0x02,0x2a,0x03,0x31,0x03,
6134 0x02,0x01,0x01 };
6135
6136static void test_encodePKCSAttribute(DWORD dwEncoding)
6137{
6138 CRYPT_ATTRIBUTE attr = { 0 };
6139 BOOL ret;
6140 LPBYTE buf = NULL;
6141 DWORD size = 0;
6143 char oid[] = "1.2.3";
6144
6145 SetLastError(0xdeadbeef);
6149 "Expected STATUS_ACCESS_VIOLATION, got %lx\n", GetLastError());
6150
6151 SetLastError(0xdeadbeef);
6155 "Expected E_INVALIDARG, got %lx\n", GetLastError());
6156 attr.pszObjId = oid;
6159 ok(ret, "CryptEncodeObjectEx failed: %lx\n", GetLastError());
6160 if (ret)
6161 {
6162 ok(size == sizeof(emptyPKCSAttr), "Unexpected size %ld\n", size);
6163 ok(!memcmp(buf, emptyPKCSAttr, size), "Unexpected value\n");
6164 LocalFree(buf);
6165 }
6166 blob.cbData = sizeof(bogusDER);
6167 blob.pbData = bogusDER;
6168 attr.cValue = 1;
6169 attr.rgValue = &blob;
6172 ok(ret, "CryptEncodeObjectEx failed: %lx\n", GetLastError());
6173 if (ret)
6174 {
6175 ok(size == sizeof(bogusPKCSAttr), "Unexpected size %ld\n", size);
6176 ok(!memcmp(buf, bogusPKCSAttr, size), "Unexpected value\n");
6177 LocalFree(buf);
6178 }
6179 blob.pbData = (BYTE *)ints[0].encoded;
6180 blob.cbData = ints[0].encoded[1] + 2;
6183 if (ret)
6184 {
6185 ok(size == sizeof(intPKCSAttr), "Unexpected size %ld\n", size);
6186 ok(!memcmp(buf, intPKCSAttr, size), "Unexpected value\n");
6187 LocalFree(buf);
6188 }
6189}
6190
6191static void test_decodePKCSAttribute(DWORD dwEncoding)
6192{
6193 BOOL ret;
6194 LPBYTE buf = NULL;
6195 DWORD size = 0;
6197
6201 ok(ret, "CryptDecodeObjectEx failed: %lx\n", GetLastError());
6202 if (ret)
6203 {
6205
6206 ok(!strcmp(attr->pszObjId, "1.2.3"), "Expected 1.2.3, got %s\n",
6207 attr->pszObjId);
6208 ok(attr->cValue == 0, "Expected no value, got %ld\n", attr->cValue);
6209 LocalFree(buf);
6210 }
6211 SetLastError(0xdeadbeef);
6215 /* Native fails with CRYPT_E_ASN1_EOD, accept also CRYPT_E_ASN1_CORRUPT as
6216 * I doubt an app depends on that.
6217 */
6219 "Expected CRYPT_E_ASN1_EOD, CRYPT_E_ASN1_CORRUPT, got %lx\n",
6220 GetLastError());
6222 intPKCSAttr, sizeof(intPKCSAttr),
6224 ok(ret, "CryptDecodeObjectEx failed: %lx\n", GetLastError());
6225 if (ret)
6226 {
6228
6229 ok(!strcmp(attr->pszObjId, "1.2.3"), "Expected 1.2.3, got %s\n",
6230 attr->pszObjId);
6231 ok(attr->cValue == 1, "Expected 1 value, got %ld\n", attr->cValue);
6232 ok(attr->rgValue[0].cbData == ints[0].encoded[1] + 2,
6233 "Unexpected size %ld\n", attr->rgValue[0].cbData);
6234 ok(!memcmp(attr->rgValue[0].pbData, ints[0].encoded,
6235 attr->rgValue[0].cbData), "Unexpected value\n");
6236 LocalFree(buf);
6237 }
6238}
6239
6240static const BYTE emptyPKCSAttributes[] = { 0x31,0x00 };
6241static const BYTE singlePKCSAttributes[] = { 0x31,0x08,0x30,0x06,0x06,0x02,
6242 0x2a,0x03,0x31,0x00 };
6243static const BYTE doublePKCSAttributes[] = { 0x31,0x13,0x30,0x06,0x06,0x02,
6244 0x2a,0x03,0x31,0x00,0x30,0x09,0x06,0x02,0x2d,0x06,0x31,0x03,0x02,0x01,0x01 };
6245
6246static void test_encodePKCSAttributes(DWORD dwEncoding)
6247{
6248 CRYPT_ATTRIBUTES attributes = { 0 };
6249 CRYPT_ATTRIBUTE attr[2] = { { 0 } };
6251 BOOL ret;
6252 LPBYTE buf = NULL;
6253 DWORD size = 0;
6254 char oid1[] = "1.2.3", oid2[] = "1.5.6";
6255
6256 ret = CryptEncodeObjectEx(dwEncoding, PKCS_ATTRIBUTES, &attributes,
6258 ok(ret, "CryptEncodeObjectEx failed: %lx\n", GetLastError());
6259 if (ret)
6260 {
6261 ok(size == sizeof(emptyPKCSAttributes), "Unexpected size %ld\n", size);
6262 ok(!memcmp(buf, emptyPKCSAttributes, size), "Unexpected value\n");
6263 LocalFree(buf);
6264 }
6265 attributes.cAttr = 1;
6266 attributes.rgAttr = attr;
6267 SetLastError(0xdeadbeef);
6268 ret = CryptEncodeObjectEx(dwEncoding, PKCS_ATTRIBUTES, &attributes,
6271 "Expected E_INVALIDARG, got %08lx\n", GetLastError());
6272 attr[0].pszObjId = oid1;
6273 ret = CryptEncodeObjectEx(dwEncoding, PKCS_ATTRIBUTES, &attributes,
6275 if (ret)
6276 {
6277 ok(size == sizeof(singlePKCSAttributes), "Unexpected size %ld\n", size);
6278 ok(!memcmp(buf, singlePKCSAttributes, size), "Unexpected value\n");
6279 LocalFree(buf);
6280 }
6281 attr[1].pszObjId = oid2;
6282 attr[1].cValue = 1;
6283 attr[1].rgValue = &blob;
6284 blob.pbData = (BYTE *)ints[0].encoded;
6285 blob.cbData = ints[0].encoded[1] + 2;
6286 attributes.cAttr = 2;
6287 ret = CryptEncodeObjectEx(dwEncoding, PKCS_ATTRIBUTES, &attributes,
6289 ok(ret, "CryptEncodeObjectEx failed: %lx\n", GetLastError());
6290 if (ret)
6291 {
6292 ok(size == sizeof(doublePKCSAttributes), "Unexpected size %ld\n", size);
6293 ok(!memcmp(buf, doublePKCSAttributes, size), "Unexpected value\n");
6294 LocalFree(buf);
6295 }
6296}
6297
6298static void test_decodePKCSAttributes(DWORD dwEncoding)
6299{
6300 BOOL ret;
6301 LPBYTE buf = NULL;
6302 DWORD size = 0;
6303 CRYPT_ATTRIBUTES *attributes;
6304
6308 ok(ret, "CryptDecodeObjectEx failed: %lx\n", GetLastError());
6309 if (ret)
6310 {
6311 attributes = (CRYPT_ATTRIBUTES *)buf;
6312 ok(attributes->cAttr == 0, "Expected no attributes, got %ld\n",
6313 attributes->cAttr);
6314 LocalFree(buf);
6315 }
6319 ok(ret, "CryptDecodeObjectEx failed: %lx\n", GetLastError());
6320 if (ret)
6321 {
6322 attributes = (CRYPT_ATTRIBUTES *)buf;
6323 ok(attributes->cAttr == 1, "Expected 1 attribute, got %ld\n",
6324 attributes->cAttr);
6325 ok(!strcmp(attributes->rgAttr[0].pszObjId, "1.2.3"),
6326 "Expected 1.2.3, got %s\n", attributes->rgAttr[0].pszObjId);
6327 ok(attributes->rgAttr[0].cValue == 0,
6328 "Expected no attributes, got %ld\n", attributes->rgAttr[0].cValue);
6329 LocalFree(buf);
6330 }
6334 ok(ret, "CryptDecodeObjectEx failed: %lx\n", GetLastError());
6335 if (ret)
6336 {
6337 attributes = (CRYPT_ATTRIBUTES *)buf;
6338 ok(attributes->cAttr == 2, "Expected 2 attributes, got %ld\n",
6339 attributes->cAttr);
6340 ok(!strcmp(attributes->rgAttr[0].pszObjId, "1.2.3"),
6341 "Expected 1.2.3, got %s\n", attributes->rgAttr[0].pszObjId);
6342 ok(attributes->rgAttr[0].cValue == 0,
6343 "Expected no attributes, got %ld\n", attributes->rgAttr[0].cValue);
6344 ok(!strcmp(attributes->rgAttr[1].pszObjId, "1.5.6"),
6345 "Expected 1.5.6, got %s\n", attributes->rgAttr[1].pszObjId);
6346 ok(attributes->rgAttr[1].cValue == 1,
6347 "Expected 1 attribute, got %ld\n", attributes->rgAttr[1].cValue);
6348 ok(attributes->rgAttr[1].rgValue[0].cbData == ints[0].encoded[1] + 2,
6349 "Unexpected size %ld\n", attributes->rgAttr[1].rgValue[0].cbData);
6350 ok(!memcmp(attributes->rgAttr[1].rgValue[0].pbData, ints[0].encoded,
6351 attributes->rgAttr[1].rgValue[0].cbData), "Unexpected value\n");
6352 LocalFree(buf);
6353 }
6356 ok(ret, "CryptDecodeObjectEx failed: %lx\n", GetLastError());
6357 buf = calloc(1, size);
6358 if (buf)
6359 {
6362 ok(ret, "CryptDecodeObjectEx failed: %lx\n", GetLastError());
6363 free(buf);
6364 }
6365}
6366
6367static const BYTE singleCapability[] = {
63680x30,0x06,0x30,0x04,0x06,0x02,0x2d,0x06 };
6369static const BYTE twoCapabilities[] = {
63700x30,0x0c,0x30,0x04,0x06,0x02,0x2d,0x06,0x30,0x04,0x06,0x02,0x2a,0x03 };
63720x30,0x08,0x30,0x06,0x06,0x02,0x2d,0x06,0x05,0x00 };
6373
6375{
6376 static char oid1[] = "1.5.6", oid2[] = "1.2.3";
6377 BOOL ret;
6378 LPBYTE buf = NULL;
6379 DWORD size = 0;
6380 CRYPT_SMIME_CAPABILITY capability[2];
6381 CRYPT_SMIME_CAPABILITIES capabilities;
6382
6383 /* An empty capabilities is allowed */
6384 capabilities.cCapability = 0;
6386 &capabilities, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
6387 ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
6388 if (ret)
6389 {
6390 ok(size == sizeof(emptySequence), "unexpected size %ld\n", size);
6391 ok(!memcmp(buf, emptySequence, size), "unexpected value\n");
6392 LocalFree(buf);
6393 }
6394 /* A non-empty capabilities with an empty capability (lacking an OID) is
6395 * not allowed
6396 */
6397 capability[0].pszObjId = NULL;
6398 capability[0].Parameters.cbData = 0;
6399 capabilities.cCapability = 1;
6400 capabilities.rgCapability = capability;
6401 SetLastError(0xdeadbeef);
6403 &capabilities, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
6405 "Expected E_INVALIDARG, got %08lx\n", GetLastError());
6406 capability[0].pszObjId = oid1;
6408 &capabilities, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
6409 ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
6410 if (ret)
6411 {
6412 ok(size == sizeof(singleCapability), "unexpected size %ld\n", size);
6413 ok(!memcmp(buf, singleCapability, size), "unexpected value\n");
6414 LocalFree(buf);
6415 }
6416 capability[1].pszObjId = oid2;
6417 capability[1].Parameters.cbData = 0;
6418 capabilities.cCapability = 2;
6420 &capabilities, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
6421 ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
6422 if (ret)
6423 {
6424 ok(size == sizeof(twoCapabilities), "unexpected size %ld\n", size);
6425 ok(!memcmp(buf, twoCapabilities, size), "unexpected value\n");
6426 LocalFree(buf);
6427 }
6428}
6429
6432{
6433 DWORD i;
6434
6435 ok(got->cCapability == expected->cCapability,
6436 "%s: expected %ld capabilities, got %ld\n", header, expected->cCapability,
6437 got->cCapability);
6438 for (i = 0; i < expected->cCapability; i++)
6439 {
6440 ok(!strcmp(expected->rgCapability[i].pszObjId,
6441 got->rgCapability[i].pszObjId), "%s[%ld]: expected %s, got %s\n",
6442 header, i, expected->rgCapability[i].pszObjId,
6443 got->rgCapability[i].pszObjId);
6444 ok(expected->rgCapability[i].Parameters.cbData ==
6446 "%s[%ld]: expected %ld bytes, got %ld\n", header, i,
6447 expected->rgCapability[i].Parameters.cbData,
6449 if (expected->rgCapability[i].Parameters.cbData)
6450 ok(!memcmp(expected->rgCapability[i].Parameters.pbData,
6452 expected->rgCapability[i].Parameters.cbData),
6453 "%s[%ld]: unexpected value\n", header, i);
6454 }
6455}
6456
6458{
6459 static char oid1[] = "1.5.6", oid2[] = "1.2.3";
6460 BOOL ret;
6461 DWORD size = 0;
6462 CRYPT_SMIME_CAPABILITY capability[2];
6463 CRYPT_SMIME_CAPABILITIES capabilities, *ptr;
6464
6465 SetLastError(0xdeadbeef);
6469 ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
6470 if (ret)
6471 {
6472 capabilities.cCapability = 0;
6473 compareSMimeCapabilities("empty capabilities", &capabilities, ptr);
6474 LocalFree(ptr);
6475 }
6476 SetLastError(0xdeadbeef);
6479 &ptr, &size);
6480 ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
6481 if (ret)
6482 {
6483 capability[0].pszObjId = oid1;
6484 capability[0].Parameters.cbData = 0;
6485 capabilities.cCapability = 1;
6486 capabilities.rgCapability = capability;
6487 compareSMimeCapabilities("single capability", &capabilities, ptr);
6488 LocalFree(ptr);
6489 }
6490 SetLastError(0xdeadbeef);
6494 ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
6495 if (ret)
6496 {
6497 BYTE NULLparam[] = {0x05, 0x00};
6498 capability[0].pszObjId = oid1;
6499 capability[0].Parameters.cbData = 2;
6500 capability[0].Parameters.pbData = NULLparam;
6501 capabilities.cCapability = 1;
6502 capabilities.rgCapability = capability;
6503 compareSMimeCapabilities("single capability with NULL", &capabilities,
6504 ptr);
6505 LocalFree(ptr);
6506 }
6507 SetLastError(0xdeadbeef);
6510 &ptr, &size);
6511 ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
6512 if (ret)
6513 {
6514 capability[0].Parameters.cbData = 0;
6515 capability[1].pszObjId = oid2;
6516 capability[1].Parameters.cbData = 0;
6517 capabilities.cCapability = 2;
6518 compareSMimeCapabilities("two capabilities", &capabilities, ptr);
6519 LocalFree(ptr);
6520 }
6521 SetLastError(0xdeadbeef);
6523 twoCapabilities, sizeof(twoCapabilities), 0, NULL, NULL, &size);
6524 ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
6525 ptr = calloc(1, size);
6526 if (ptr)
6527 {
6528 SetLastError(0xdeadbeef);
6530 twoCapabilities, sizeof(twoCapabilities), 0, NULL, ptr, &size);
6531 ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
6532 free(ptr);
6533 }
6534}
6535
6536static BYTE encodedCommonNameNoNull[] = { 0x30,0x14,0x31,0x12,0x30,0x10,
6537 0x06,0x03,0x55,0x04,0x03,0x13,0x09,0x4a,0x75,0x61,0x6e,0x20,0x4c,0x61,0x6e,
6538 0x67 };
6539static const BYTE minimalPKCSSigner[] = {
6540 0x30,0x2b,0x02,0x01,0x00,0x30,0x18,0x30,0x14,0x31,0x12,0x30,0x10,0x06,0x03,
6541 0x55,0x04,0x03,0x13,0x09,0x4a,0x75,0x61,0x6e,0x20,0x4c,0x61,0x6e,0x67,0x02,
6542 0x00,0x30,0x04,0x06,0x00,0x05,0x00,0x30,0x04,0x06,0x00,0x05,0x00,0x04,0x00 };
6543static const BYTE PKCSSignerWithSerial[] = {
6544 0x30,0x2c,0x02,0x01,0x00,0x30,0x19,0x30,0x14,0x31,0x12,0x30,0x10,0x06,0x03,
6545 0x55,0x04,0x03,0x13,0x09,0x4a,0x75,0x61,0x6e,0x20,0x4c,0x61,0x6e,0x67,0x02,
6546 0x01,0x01,0x30,0x04,0x06,0x00,0x05,0x00,0x30,0x04,0x06,0x00,0x05,0x00,0x04,
6547 0x00 };
6549 0x30,0x2e,0x02,0x01,0x00,0x30,0x19,0x30,0x14,0x31,0x12,0x30,0x10,0x06,0x03,
6550 0x55,0x04,0x03,0x13,0x09,0x4a,0x75,0x61,0x6e,0x20,0x4c,0x61,0x6e,0x67,0x02,
6551 0x01,0x01,0x30,0x06,0x06,0x02,0x2a,0x03,0x05,0x00,0x30,0x04,0x06,0x00,0x05,
6552 0x00,0x04,0x00 };
6554 0x30,0x30,0x02,0x01,0x00,0x30,0x19,0x30,0x14,0x31,0x12,0x30,0x10,0x06,0x03,
6555 0x55,0x04,0x03,0x13,0x09,0x4a,0x75,0x61,0x6e,0x20,0x4c,0x61,0x6e,0x67,0x02,
6556 0x01,0x01,0x30,0x06,0x06,0x02,0x2a,0x03,0x05,0x00,0x30,0x06,0x06,0x02,0x2d,
6557 0x06,0x05,0x00,0x04,0x00 };
6558static const BYTE PKCSSignerWithHash[] = {
6559 0x30,0x40,0x02,0x01,0x00,0x30,0x19,0x30,0x14,0x31,0x12,0x30,0x10,0x06,0x03,
6560 0x55,0x04,0x03,0x13,0x09,0x4a,0x75,0x61,0x6e,0x20,0x4c,0x61,0x6e,0x67,0x02,
6561 0x01,0x01,0x30,0x06,0x06,0x02,0x2a,0x03,0x05,0x00,0x30,0x06,0x06,0x02,0x2d,
6562 0x06,0x05,0x00,0x04,0x10,0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,
6563 0x0a,0x0b,0x0c,0x0d,0x0e,0x0f };
65650x30,0x62,0x02,0x01,0x00,0x30,0x19,0x30,0x14,0x31,0x12,0x30,0x10,0x06,0x03,
65660x55,0x04,0x03,0x13,0x09,0x4a,0x75,0x61,0x6e,0x20,0x4c,0x61,0x6e,0x67,0x02,
65670x01,0x01,0x30,0x06,0x06,0x02,0x2a,0x03,0x05,0x00,0xa0,0x20,0x30,0x1e,0x06,
65680x03,0x55,0x04,0x03,0x31,0x17,0x30,0x15,0x31,0x13,0x30,0x11,0x06,0x03,0x55,
65690x04,0x03,0x13,0x0a,0x4a,0x75,0x61,0x6e,0x20,0x4c,0x61,0x6e,0x67,0x00,0x30,
65700x06,0x06,0x02,0x2d,0x06,0x05,0x00,0x04,0x10,0x00,0x01,0x02,0x03,0x04,0x05,
65710x06,0x07,0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f };
6572
6573static void test_encodePKCSSignerInfo(DWORD dwEncoding)
6574{
6575 static char oid1[] = "1.2.3", oid2[] = "1.5.6";
6576 BOOL ret;
6577 LPBYTE buf = NULL;
6578 DWORD size = 0;
6579 CMSG_SIGNER_INFO info = { 0 };
6580 char oid_common_name[] = szOID_COMMON_NAME;
6583 CRYPT_ATTRIBUTE attr = { oid_common_name, 1, &commonName };
6584
6585 SetLastError(0xdeadbeef);
6589 "Expected E_INVALIDARG, got %08lx\n", GetLastError());
6590 /* To be encoded, a signer must have an issuer at least, and the encoding
6591 * must include PKCS_7_ASN_ENCODING. (That isn't enough to be decoded,
6592 * see decoding tests.)
6593 */
6594 info.Issuer.cbData = sizeof(encodedCommonNameNoNull);
6595 info.Issuer.pbData = encodedCommonNameNoNull;
6596 SetLastError(0xdeadbeef);
6599 if (!(dwEncoding & PKCS_7_ASN_ENCODING))
6601 "Expected E_INVALIDARG, got %08lx\n", GetLastError());
6602 else
6603 {
6604 ok(ret, "CryptEncodeObjectEx failed: %lx\n", GetLastError());
6605 if (ret)
6606 {
6607 ok(size == sizeof(minimalPKCSSigner), "Unexpected size %ld\n", size);
6608 if (size == sizeof(minimalPKCSSigner))
6609 ok(!memcmp(buf, minimalPKCSSigner, size), "Unexpected value\n");
6610 else
6611 ok(0, "Unexpected value\n");
6612 LocalFree(buf);
6613 }
6614 }
6615 info.SerialNumber.cbData = sizeof(serialNum);
6616 info.SerialNumber.pbData = (BYTE *)serialNum;
6617 SetLastError(0xdeadbeef);
6620 if (!(dwEncoding & PKCS_7_ASN_ENCODING))
6622 "Expected E_INVALIDARG, got %08lx\n", GetLastError());
6623 else
6624 {
6625 ok(ret, "CryptEncodeObjectEx failed: %lx\n", GetLastError());
6626 if (ret)
6627 {
6628 ok(size == sizeof(PKCSSignerWithSerial), "Unexpected size %ld\n",
6629 size);
6630 if (size == sizeof(PKCSSignerWithSerial))
6632 "Unexpected value\n");
6633 else
6634 ok(0, "Unexpected value\n");
6635 LocalFree(buf);
6636 }
6637 }
6638 info.HashAlgorithm.pszObjId = oid1;
6639 SetLastError(0xdeadbeef);
6642 if (!(dwEncoding & PKCS_7_ASN_ENCODING))
6644 "Expected E_INVALIDARG, got %08lx\n", GetLastError());
6645 else
6646 {
6647 ok(ret, "CryptEncodeObjectEx failed: %lx\n", GetLastError());
6648 if (ret)
6649 {
6650 ok(size == sizeof(PKCSSignerWithHashAlgo), "Unexpected size %ld\n",
6651 size);
6652 if (size == sizeof(PKCSSignerWithHashAlgo))
6654 "Unexpected value\n");
6655 else
6656 ok(0, "Unexpected value\n");
6657 LocalFree(buf);
6658 }
6659 }
6660 info.HashEncryptionAlgorithm.pszObjId = oid2;
6661 SetLastError(0xdeadbeef);
6664 if (!(dwEncoding & PKCS_7_ASN_ENCODING))
6666 "Expected E_INVALIDARG, got %08lx\n", GetLastError());
6667 else
6668 {
6669 ok(ret, "CryptEncodeObjectEx failed: %lx\n", GetLastError());
6670 if (ret)
6671 {
6673 "Unexpected size %ld\n", size);
6676 "Unexpected value\n");
6677 else
6678 ok(0, "Unexpected value\n");
6679 LocalFree(buf);
6680 }
6681 }
6682 info.EncryptedHash.cbData = sizeof(hash);
6683 info.EncryptedHash.pbData = (BYTE *)hash;
6684 SetLastError(0xdeadbeef);
6687 if (!(dwEncoding & PKCS_7_ASN_ENCODING))
6689 "Expected E_INVALIDARG, got %08lx\n", GetLastError());
6690 else
6691 {
6692 ok(ret, "CryptEncodeObjectEx failed: %lx\n", GetLastError());
6693 if (ret)
6694 {
6695 ok(size == sizeof(PKCSSignerWithHash), "Unexpected size %ld\n",
6696 size);
6697 if (size == sizeof(PKCSSignerWithHash))
6699 "Unexpected value\n");
6700 else
6701 ok(0, "Unexpected value\n");
6702 LocalFree(buf);
6703 }
6704 }
6705 info.AuthAttrs.cAttr = 1;
6706 info.AuthAttrs.rgAttr = &attr;
6707 SetLastError(0xdeadbeef);
6710 if (!(dwEncoding & PKCS_7_ASN_ENCODING))
6712 "Expected E_INVALIDARG, got %08lx\n", GetLastError());
6713 else
6714 {
6715 ok(ret, "CryptEncodeObjectEx failed: %lx\n", GetLastError());
6716 if (ret)
6717 {
6718 ok(size == sizeof(PKCSSignerWithAuthAttr), "Unexpected size %ld\n",
6719 size);
6720 if (size == sizeof(PKCSSignerWithAuthAttr))
6722 "Unexpected value\n");
6723 else
6724 ok(0, "Unexpected value\n");
6725 LocalFree(buf);
6726 }
6727 }
6728}
6729
6730static void test_decodePKCSSignerInfo(DWORD dwEncoding)
6731{
6732 BOOL ret;
6733 LPBYTE buf = NULL;
6734 DWORD size = 0;
6736
6737 /* A PKCS signer can't be decoded without a serial number. */
6738 SetLastError(0xdeadbeef);
6743 "Expected CRYPT_E_ASN1_CORRUPT, got %lx\n",
6744 GetLastError());
6748 ok(ret, "CryptDecodeObjectEx failed: %lx\n", GetLastError());
6749 if (ret)
6750 {
6752 ok(info->dwVersion == 0, "Expected version 0, got %ld\n",
6753 info->dwVersion);
6754 ok(info->Issuer.cbData == sizeof(encodedCommonNameNoNull),
6755 "Unexpected size %ld\n", info->Issuer.cbData);
6756 ok(!memcmp(info->Issuer.pbData, encodedCommonNameNoNull,
6757 info->Issuer.cbData), "Unexpected value\n");
6758 ok(info->SerialNumber.cbData == sizeof(serialNum),
6759 "Unexpected size %ld\n", info->SerialNumber.cbData);
6760 ok(!memcmp(info->SerialNumber.pbData, serialNum, sizeof(serialNum)),
6761 "Unexpected value\n");
6762 LocalFree(buf);
6763 }
6767 if (ret)
6768 {
6770 ok(info->dwVersion == 0, "Expected version 0, got %ld\n",
6771 info->dwVersion);
6772 ok(info->Issuer.cbData == sizeof(encodedCommonNameNoNull),
6773 "Unexpected size %ld\n", info->Issuer.cbData);
6774 ok(!memcmp(info->Issuer.pbData, encodedCommonNameNoNull,
6775 info->Issuer.cbData), "Unexpected value\n");
6776 ok(info->SerialNumber.cbData == sizeof(serialNum),
6777 "Unexpected size %ld\n", info->SerialNumber.cbData);
6778 ok(!memcmp(info->SerialNumber.pbData, serialNum, sizeof(serialNum)),
6779 "Unexpected value\n");
6780 ok(!strcmp(info->HashAlgorithm.pszObjId, "1.2.3"),
6781 "Expected 1.2.3, got %s\n", info->HashAlgorithm.pszObjId);
6782 LocalFree(buf);
6783 }
6787 NULL, &buf, &size);
6788 if (ret)
6789 {
6791 ok(info->dwVersion == 0, "Expected version 0, got %ld\n",
6792 info->dwVersion);
6793 ok(info->Issuer.cbData == sizeof(encodedCommonNameNoNull),
6794 "Unexpected size %ld\n", info->Issuer.cbData);
6795 ok(!memcmp(info->Issuer.pbData, encodedCommonNameNoNull,
6796 info->Issuer.cbData), "Unexpected value\n");
6797 ok(info->SerialNumber.cbData == sizeof(serialNum),
6798 "Unexpected size %ld\n", info->SerialNumber.cbData);
6799 ok(!memcmp(info->SerialNumber.pbData, serialNum, sizeof(serialNum)),
6800 "Unexpected value\n");
6801 ok(!strcmp(info->HashAlgorithm.pszObjId, "1.2.3"),
6802 "Expected 1.2.3, got %s\n", info->HashAlgorithm.pszObjId);
6803 ok(!strcmp(info->HashEncryptionAlgorithm.pszObjId, "1.5.6"),
6804 "Expected 1.5.6, got %s\n", info->HashEncryptionAlgorithm.pszObjId);
6805 LocalFree(buf);
6806 }
6810 if (ret)
6811 {
6813 ok(info->dwVersion == 0, "Expected version 0, got %ld\n",
6814 info->dwVersion);
6815 ok(info->Issuer.cbData == sizeof(encodedCommonNameNoNull),
6816 "Unexpected size %ld\n", info->Issuer.cbData);
6817 ok(!memcmp(info->Issuer.pbData, encodedCommonNameNoNull,
6818 info->Issuer.cbData), "Unexpected value\n");
6819 ok(info->SerialNumber.cbData == sizeof(serialNum),
6820 "Unexpected size %ld\n", info->SerialNumber.cbData);
6821 ok(!memcmp(info->SerialNumber.pbData, serialNum, sizeof(serialNum)),
6822 "Unexpected value\n");
6823 ok(!strcmp(info->HashAlgorithm.pszObjId, "1.2.3"),
6824 "Expected 1.2.3, got %s\n", info->HashAlgorithm.pszObjId);
6825 ok(!strcmp(info->HashEncryptionAlgorithm.pszObjId, "1.5.6"),
6826 "Expected 1.5.6, got %s\n", info->HashEncryptionAlgorithm.pszObjId);
6827 ok(info->EncryptedHash.cbData == sizeof(hash), "Unexpected size %ld\n",
6828 info->EncryptedHash.cbData);
6829 ok(!memcmp(info->EncryptedHash.pbData, hash, sizeof(hash)),
6830 "Unexpected value\n");
6831 LocalFree(buf);
6832 }
6836 if (ret)
6837 {
6839 ok(info->AuthAttrs.cAttr == 1, "Expected 1 attribute, got %ld\n",
6840 info->AuthAttrs.cAttr);
6841 ok(!strcmp(info->AuthAttrs.rgAttr[0].pszObjId, szOID_COMMON_NAME),
6842 "Expected %s, got %s\n", szOID_COMMON_NAME,
6843 info->AuthAttrs.rgAttr[0].pszObjId);
6844 ok(info->AuthAttrs.rgAttr[0].cValue == 1, "Expected 1 value, got %ld\n",
6845 info->AuthAttrs.rgAttr[0].cValue);
6846 ok(info->AuthAttrs.rgAttr[0].rgValue[0].cbData ==
6847 sizeof(encodedCommonName), "Unexpected size %ld\n",
6848 info->AuthAttrs.rgAttr[0].rgValue[0].cbData);
6849 ok(!memcmp(info->AuthAttrs.rgAttr[0].rgValue[0].pbData,
6850 encodedCommonName, sizeof(encodedCommonName)), "Unexpected value\n");
6851 LocalFree(buf);
6852 }
6853}
6854
6855static const BYTE CMSSignerWithKeyId[] = {
68560x30,0x14,0x02,0x01,0x00,0x80,0x01,0x01,0x30,0x04,0x06,0x00,0x05,0x00,0x30,
68570x04,0x06,0x00,0x05,0x00,0x04,0x00 };
6858
6859static void test_encodeCMSSignerInfo(DWORD dwEncoding)
6860{
6861 BOOL ret;
6862 LPBYTE buf = NULL;
6863 DWORD size = 0;
6864 CMSG_CMS_SIGNER_INFO info = { 0 };
6865 static char oid1[] = "1.2.3", oid2[] = "1.5.6";
6866
6867 SetLastError(0xdeadbeef);
6870 ok(!ret, "Expected failure, got %d\n", ret);
6872 "Expected E_INVALIDARG, got %08lx\n", GetLastError());
6873 info.SignerId.dwIdChoice = CERT_ID_ISSUER_SERIAL_NUMBER;
6874 SetLastError(0xdeadbeef);
6877 ok(!ret, "Expected failure, got %d\n", ret);
6879 "Expected E_INVALIDARG, got %08lx\n", GetLastError());
6880 /* To be encoded, a signer must have a valid cert ID, where a valid ID may
6881 * be a key id or an issuer serial number with at least the issuer set, and
6882 * the encoding must include PKCS_7_ASN_ENCODING.
6883 * (That isn't enough to be decoded, see decoding tests.)
6884 */
6885 info.SignerId.IssuerSerialNumber.Issuer.cbData = sizeof(encodedCommonNameNoNull);
6886 info.SignerId.IssuerSerialNumber.Issuer.pbData = encodedCommonNameNoNull;
6887 SetLastError(0xdeadbeef);
6890 if (!(dwEncoding & PKCS_7_ASN_ENCODING))
6892 "Expected E_INVALIDARG, got %08lx\n", GetLastError());
6893 else
6894 {
6895 ok(ret, "CryptEncodeObjectEx failed: %lx\n", GetLastError());
6896 if (ret)
6897 {
6898 ok(size == sizeof(minimalPKCSSigner), "Unexpected size %ld\n", size);
6899 ok(!memcmp(buf, minimalPKCSSigner, size), "Unexpected value\n");
6900 LocalFree(buf);
6901 }
6902 }
6903 info.SignerId.IssuerSerialNumber.SerialNumber.cbData = sizeof(serialNum);
6904 info.SignerId.IssuerSerialNumber.SerialNumber.pbData = (BYTE *)serialNum;
6905 SetLastError(0xdeadbeef);
6908 if (!(dwEncoding & PKCS_7_ASN_ENCODING))
6910 "Expected E_INVALIDARG, got %08lx\n", GetLastError());
6911 else
6912 {
6913 ok(ret, "CryptEncodeObjectEx failed: %lx\n", GetLastError());
6914 if (ret)
6915 {
6916 ok(size == sizeof(PKCSSignerWithSerial), "Unexpected size %ld\n",
6917 size);
6918 ok(!memcmp(buf, PKCSSignerWithSerial, size), "Unexpected value\n");
6919 LocalFree(buf);
6920 }
6921 }
6922 info.SignerId.dwIdChoice = CERT_ID_KEY_IDENTIFIER;
6923 info.SignerId.KeyId.cbData = sizeof(serialNum);
6924 info.SignerId.KeyId.pbData = (BYTE *)serialNum;
6925 SetLastError(0xdeadbeef);
6928 if (!(dwEncoding & PKCS_7_ASN_ENCODING))
6930 "Expected E_INVALIDARG, got %08lx\n", GetLastError());
6931 else
6932 {
6933 ok(ret, "CryptEncodeObjectEx failed: %lx\n", GetLastError());
6934 if (ret)
6935 {
6936 ok(size == sizeof(CMSSignerWithKeyId), "Unexpected size %ld\n",
6937 size);
6938 ok(!memcmp(buf, CMSSignerWithKeyId, size), "Unexpected value\n");
6939 LocalFree(buf);
6940 }
6941 }
6942 /* While a CERT_ID can have a hash type, that's not allowed in CMS, where
6943 * only the IssuerAndSerialNumber and SubjectKeyIdentifier types are allowed
6944 * (see RFC 3852, section 5.3.)
6945 */
6946 info.SignerId.dwIdChoice = CERT_ID_SHA1_HASH;
6947 info.SignerId.HashId.cbData = sizeof(hash);
6948 info.SignerId.HashId.pbData = (BYTE *)hash;
6949 SetLastError(0xdeadbeef);
6953 "Expected E_INVALIDARG, got %08lx\n", GetLastError());
6954 /* Now with a hash algo */
6955 info.SignerId.dwIdChoice = CERT_ID_ISSUER_SERIAL_NUMBER;
6956 info.SignerId.IssuerSerialNumber.Issuer.cbData = sizeof(encodedCommonNameNoNull);
6957 info.SignerId.IssuerSerialNumber.Issuer.pbData = encodedCommonNameNoNull;
6958 info.HashAlgorithm.pszObjId = oid1;
6959 SetLastError(0xdeadbeef);
6962 if (!(dwEncoding & PKCS_7_ASN_ENCODING))
6964 "Expected E_INVALIDARG, got %08lx\n", GetLastError());
6965 else
6966 {
6967 ok(ret, "CryptEncodeObjectEx failed: %lx\n", GetLastError());
6968 if (ret)
6969 {
6970 ok(size == sizeof(PKCSSignerWithHashAlgo), "Unexpected size %ld\n",
6971 size);
6973 "Unexpected value\n");
6974 LocalFree(buf);
6975 }
6976 }
6977 info.HashEncryptionAlgorithm.pszObjId = oid2;
6978 SetLastError(0xdeadbeef);
6981 if (!(dwEncoding & PKCS_7_ASN_ENCODING))
6983 "Expected E_INVALIDARG, got %08lx\n", GetLastError());
6984 else
6985 {
6986 ok(ret, "CryptEncodeObjectEx failed: %lx\n", GetLastError());
6987 if (ret)
6988 {
6990 "Unexpected size %ld\n", size);
6992 "Unexpected value\n");
6993 LocalFree(buf);
6994 }
6995 }
6996 info.EncryptedHash.cbData = sizeof(hash);
6997 info.EncryptedHash.pbData = (BYTE *)hash;
6998 SetLastError(0xdeadbeef);
7001 if (!(dwEncoding & PKCS_7_ASN_ENCODING))
7003 "Expected E_INVALIDARG, got %08lx\n", GetLastError());
7004 else
7005 {
7006 ok(ret, "CryptEncodeObjectEx failed: %lx\n", GetLastError());
7007 if (ret)
7008 {
7009 ok(size == sizeof(PKCSSignerWithHash), "Unexpected size %ld\n",
7010 size);
7011 ok(!memcmp(buf, PKCSSignerWithHash, size), "Unexpected value\n");
7012 LocalFree(buf);
7013 }
7014 }
7015}
7016
7017static void test_decodeCMSSignerInfo(DWORD dwEncoding)
7018{
7019 BOOL ret;
7020 LPBYTE buf = NULL;
7021 DWORD size = 0;
7023 static const char oid1[] = "1.2.3", oid2[] = "1.5.6";
7024
7025 /* A CMS signer can't be decoded without a serial number. */
7026 SetLastError(0xdeadbeef);
7030 ok(!ret, "expected failure\n");
7032 "Expected CRYPT_E_ASN1_CORRUPT, got %lx\n", GetLastError());
7036 ok(ret, "CryptDecodeObjectEx failed: %lx\n", GetLastError());
7037 if (ret)
7038 {
7040 ok(info->dwVersion == 0, "Expected version 0, got %ld\n",
7041 info->dwVersion);
7042 ok(info->SignerId.dwIdChoice == CERT_ID_ISSUER_SERIAL_NUMBER,
7043 "Expected CERT_ID_ISSUER_SERIAL_NUMBER, got %ld\n",
7044 info->SignerId.dwIdChoice);
7045 ok(info->SignerId.IssuerSerialNumber.Issuer.cbData ==
7046 sizeof(encodedCommonNameNoNull), "Unexpected size %ld\n",
7047 info->SignerId.IssuerSerialNumber.Issuer.cbData);
7048 ok(!memcmp(info->SignerId.IssuerSerialNumber.Issuer.pbData,
7050 info->SignerId.IssuerSerialNumber.Issuer.cbData),
7051 "Unexpected value\n");
7052 ok(info->SignerId.IssuerSerialNumber.SerialNumber.cbData ==
7053 sizeof(serialNum), "Unexpected size %ld\n",
7054 info->SignerId.IssuerSerialNumber.SerialNumber.cbData);
7055 ok(!memcmp(info->SignerId.IssuerSerialNumber.SerialNumber.pbData,
7056 serialNum, sizeof(serialNum)), "Unexpected value\n");
7057 LocalFree(buf);
7058 }
7062 ok(ret, "CryptDecodeObjectEx failed: %lx\n", GetLastError());
7063 if (ret)
7064 {
7066 ok(info->dwVersion == 0, "Expected version 0, got %ld\n",
7067 info->dwVersion);
7068 ok(info->SignerId.dwIdChoice == CERT_ID_ISSUER_SERIAL_NUMBER,
7069 "Expected CERT_ID_ISSUER_SERIAL_NUMBER, got %ld\n",
7070 info->SignerId.dwIdChoice);
7071 ok(info->SignerId.IssuerSerialNumber.Issuer.cbData ==
7072 sizeof(encodedCommonNameNoNull), "Unexpected size %ld\n",
7073 info->SignerId.IssuerSerialNumber.Issuer.cbData);
7074 ok(!memcmp(info->SignerId.IssuerSerialNumber.Issuer.pbData,
7076 info->SignerId.IssuerSerialNumber.Issuer.cbData),
7077 "Unexpected value\n");
7078 ok(info->SignerId.IssuerSerialNumber.SerialNumber.cbData ==
7079 sizeof(serialNum), "Unexpected size %ld\n",
7080 info->SignerId.IssuerSerialNumber.SerialNumber.cbData);
7081 ok(!memcmp(info->SignerId.IssuerSerialNumber.SerialNumber.pbData,
7082 serialNum, sizeof(serialNum)), "Unexpected value\n");
7083 ok(!strcmp(info->HashAlgorithm.pszObjId, oid1),
7084 "Expected %s, got %s\n", oid1, info->HashAlgorithm.pszObjId);
7085 LocalFree(buf);
7086 }
7090 NULL, &buf, &size);
7091 ok(ret, "CryptDecodeObjectEx failed: %lx\n", GetLastError());
7092 if (ret)
7093 {
7095 ok(info->dwVersion == 0, "Expected version 0, got %ld\n",
7096 info->dwVersion);
7097 ok(info->SignerId.dwIdChoice == CERT_ID_ISSUER_SERIAL_NUMBER,
7098 "Expected CERT_ID_ISSUER_SERIAL_NUMBER, got %ld\n",
7099 info->SignerId.dwIdChoice);
7100 ok(info->SignerId.IssuerSerialNumber.Issuer.cbData ==
7101 sizeof(encodedCommonNameNoNull), "Unexpected size %ld\n",
7102 info->SignerId.IssuerSerialNumber.Issuer.cbData);
7103 ok(!memcmp(info->SignerId.IssuerSerialNumber.Issuer.pbData,
7105 info->SignerId.IssuerSerialNumber.Issuer.cbData),
7106 "Unexpected value\n");
7107 ok(info->SignerId.IssuerSerialNumber.SerialNumber.cbData ==
7108 sizeof(serialNum), "Unexpected size %ld\n",
7109 info->SignerId.IssuerSerialNumber.SerialNumber.cbData);
7110 ok(!memcmp(info->SignerId.IssuerSerialNumber.SerialNumber.pbData,
7111 serialNum, sizeof(serialNum)), "Unexpected value\n");
7112 ok(!strcmp(info->HashAlgorithm.pszObjId, oid1),
7113 "Expected %s, got %s\n", oid1, info->HashAlgorithm.pszObjId);
7114 ok(!strcmp(info->HashEncryptionAlgorithm.pszObjId, oid2),
7115 "Expected %s, got %s\n", oid2, info->HashEncryptionAlgorithm.pszObjId);
7116 LocalFree(buf);
7117 }
7121 ok(ret, "CryptDecodeObjectEx failed: %lx\n", GetLastError());
7122 if (ret)
7123 {
7125 ok(info->dwVersion == 0, "Expected version 0, got %ld\n",
7126 info->dwVersion);
7127 ok(info->SignerId.dwIdChoice == CERT_ID_ISSUER_SERIAL_NUMBER,
7128 "Expected CERT_ID_ISSUER_SERIAL_NUMBER, got %ld\n",
7129 info->SignerId.dwIdChoice);
7130 ok(info->SignerId.IssuerSerialNumber.Issuer.cbData ==
7131 sizeof(encodedCommonNameNoNull), "Unexpected size %ld\n",
7132 info->SignerId.IssuerSerialNumber.Issuer.cbData);
7133 ok(!memcmp(info->SignerId.IssuerSerialNumber.Issuer.pbData,
7135 info->SignerId.IssuerSerialNumber.Issuer.cbData),
7136 "Unexpected value\n");
7137 ok(info->SignerId.IssuerSerialNumber.SerialNumber.cbData ==
7138 sizeof(serialNum), "Unexpected size %ld\n",
7139 info->SignerId.IssuerSerialNumber.SerialNumber.cbData);
7140 ok(!memcmp(info->SignerId.IssuerSerialNumber.SerialNumber.pbData,
7141 serialNum, sizeof(serialNum)), "Unexpected value\n");
7142 ok(!strcmp(info->HashAlgorithm.pszObjId, oid1),
7143 "Expected %s, got %s\n", oid1, info->HashAlgorithm.pszObjId);
7144 ok(!strcmp(info->HashEncryptionAlgorithm.pszObjId, oid2),
7145 "Expected %s, got %s\n", oid2, info->HashEncryptionAlgorithm.pszObjId);
7146 ok(info->EncryptedHash.cbData == sizeof(hash), "Unexpected size %ld\n",
7147 info->EncryptedHash.cbData);
7148 ok(!memcmp(info->EncryptedHash.pbData, hash, sizeof(hash)),
7149 "Unexpected value\n");
7150 LocalFree(buf);
7151 }
7155 ok(ret, "CryptDecodeObjectEx failed: %lx\n", GetLastError());
7156 if (ret)
7157 {
7159 ok(info->dwVersion == 0, "Expected version 0, got %ld\n",
7160 info->dwVersion);
7161 ok(info->SignerId.dwIdChoice == CERT_ID_KEY_IDENTIFIER,
7162 "Expected CERT_ID_KEY_IDENTIFIER, got %ld\n",
7163 info->SignerId.dwIdChoice);
7164 ok(info->SignerId.KeyId.cbData == sizeof(serialNum),
7165 "Unexpected size %ld\n", info->SignerId.KeyId.cbData);
7166 ok(!memcmp(info->SignerId.KeyId.pbData, serialNum, sizeof(serialNum)),
7167 "Unexpected value\n");
7168 LocalFree(buf);
7169 }
7170}
7171
71730x30,0x06,0xa0,0x04,0x30,0x02,0x82,0x00 };
71750x30,0x06,0xa1,0x04,0x30,0x02,0x82,0x00 };
71770x30,0x17,0xa1,0x15,0x30,0x13,0x82,0x11,0x68,0x74,0x74,0x70,0x3a,0x2f,0x2f,
71780x77,0x69,0x6e,0x65,0x68,0x71,0x2e,0x6f,0x72,0x67 };
71800x30,0x25,0xa0,0x0c,0x30,0x0a,0x87,0x08,0x30,0x06,0x87,0x04,0x7f,0x00,0x00,
71810x01,0xa1,0x15,0x30,0x13,0x82,0x11,0x68,0x74,0x74,0x70,0x3a,0x2f,0x2f,0x77,
71820x69,0x6e,0x65,0x68,0x71,0x2e,0x6f,0x72,0x67 };
71840x30,0x28,0xa0,0x0f,0x30,0x0d,0x87,0x08,0x30,0x06,0x87,0x04,0x7f,0x00,0x00,
71850x01,0x80,0x01,0x05,0xa1,0x15,0x30,0x13,0x82,0x11,0x68,0x74,0x74,0x70,0x3a,
71860x2f,0x2f,0x77,0x69,0x6e,0x65,0x68,0x71,0x2e,0x6f,0x72,0x67 };
71880x30,0x2b,0xa0,0x12,0x30,0x10,0x87,0x08,0x30,0x06,0x87,0x04,0x7f,0x00,0x00,
71890x01,0x80,0x01,0x05,0x81,0x01,0x03,0xa1,0x15,0x30,0x13,0x82,0x11,0x68,0x74,
71900x74,0x70,0x3a,0x2f,0x2f,0x77,0x69,0x6e,0x65,0x68,0x71,0x2e,0x6f,0x72,0x67 };
7191
7192static void test_encodeNameConstraints(DWORD dwEncoding)
7193{
7194 BOOL ret;
7195 CERT_NAME_CONSTRAINTS_INFO constraints = { 0 };
7196 CERT_GENERAL_SUBTREE permitted = { { 0 } };
7197 CERT_GENERAL_SUBTREE excluded = { { 0 } };
7198 LPBYTE buf;
7199 DWORD size;
7200
7201 ret = CryptEncodeObjectEx(dwEncoding, X509_NAME_CONSTRAINTS, &constraints,
7203 ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
7204 if (ret)
7205 {
7206 ok(size == sizeof(emptySequence), "Unexpected size\n");
7207 ok(!memcmp(buf, emptySequence, size), "Unexpected value\n");
7208 LocalFree(buf);
7209 }
7210 constraints.cPermittedSubtree = 1;
7211 constraints.rgPermittedSubtree = &permitted;
7212 SetLastError(0xdeadbeef);
7213 ret = CryptEncodeObjectEx(dwEncoding, X509_NAME_CONSTRAINTS, &constraints,
7216 "Expected E_INVALIDARG, got %08lx\n", GetLastError());
7218 ret = CryptEncodeObjectEx(dwEncoding, X509_NAME_CONSTRAINTS, &constraints,
7220 ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
7221 if (ret)
7222 {
7223 ok(size == sizeof(emptyDNSPermittedConstraints), "Unexpected size\n");
7225 "Unexpected value\n");
7226 LocalFree(buf);
7227 }
7228 constraints.cPermittedSubtree = 0;
7229 constraints.cExcludedSubtree = 1;
7230 constraints.rgExcludedSubtree = &excluded;
7232 ret = CryptEncodeObjectEx(dwEncoding, X509_NAME_CONSTRAINTS, &constraints,
7234 ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
7235 if (ret)
7236 {
7237 ok(size == sizeof(emptyDNSExcludedConstraints), "Unexpected size\n");
7239 "Unexpected value\n");
7240 LocalFree(buf);
7241 }
7242 excluded.Base.pwszURL = (LPWSTR)url;
7243 ret = CryptEncodeObjectEx(dwEncoding, X509_NAME_CONSTRAINTS, &constraints,
7245 ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
7246 if (ret)
7247 {
7248 ok(size == sizeof(DNSExcludedConstraints), "Unexpected size\n");
7250 "Unexpected value\n");
7251 LocalFree(buf);
7252 }
7254 permitted.Base.IPAddress.cbData = sizeof(encodedIPAddr);
7256 constraints.cPermittedSubtree = 1;
7257 ret = CryptEncodeObjectEx(dwEncoding, X509_NAME_CONSTRAINTS, &constraints,
7259 ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
7260 if (ret)
7261 {
7263 "Unexpected size\n");
7265 "Unexpected value\n");
7266 LocalFree(buf);
7267 }
7268 permitted.dwMinimum = 5;
7269 ret = CryptEncodeObjectEx(dwEncoding, X509_NAME_CONSTRAINTS, &constraints,
7271 ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
7272 if (ret)
7273 {
7275 "Unexpected size\n");
7277 "Unexpected value\n");
7278 LocalFree(buf);
7279 }
7280 permitted.fMaximum = TRUE;
7281 permitted.dwMaximum = 3;
7282 SetLastError(0xdeadbeef);
7283 ret = CryptEncodeObjectEx(dwEncoding, X509_NAME_CONSTRAINTS, &constraints,
7285 ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
7286 if (ret)
7287 {
7289 "Unexpected size\n");
7291 "Unexpected value\n");
7292 LocalFree(buf);
7293 }
7294}
7295
7297{
7300};
7301
7303 { CERT_ALT_NAME_DNS_NAME, { 0 } }, 0 };
7305 { CERT_ALT_NAME_DNS_NAME, { 0 } }, 0 };
7307 { CERT_ALT_NAME_IP_ADDRESS, { 0 } }, 0 };
7309 { CERT_ALT_NAME_IP_ADDRESS, { 0 } }, 5, 0 };
7311 { CERT_ALT_NAME_IP_ADDRESS, { 0 } }, 5, TRUE, 3 };
7312
7314 { { sizeof(emptySequence), (LPBYTE)emptySequence }, { 0 } },
7316 { 1, &emptyDNSSubtree, 0, NULL } },
7318 { 0, NULL, 1, &emptyDNSSubtree } },
7320 { 0, NULL, 1, &DNSSubtree } },
7322 { 1, &IPAddressSubtree, 1, &DNSSubtree } },
7325 { 1, &IPAddressWithMinSubtree, 1, &DNSSubtree } },
7329};
7330
7331static void test_decodeNameConstraints(DWORD dwEncoding)
7332{
7333 BOOL ret;
7334 DWORD i;
7336
7344 for (i = 0; i < ARRAY_SIZE(encodedNameConstraints); i++)
7345 {
7346 DWORD size;
7347
7350 encodedNameConstraints[i].encoded.cbData,
7352 ok(ret, "%ld: CryptDecodeObjectEx failed: %08lx\n", i, GetLastError());
7353 if (ret)
7354 {
7355 DWORD j;
7356
7358 encodedNameConstraints[i].constraints.cPermittedSubtree)
7359 fprintf(stderr, "%ld: expected %lu permitted, got %lu\n", i,
7363 encodedNameConstraints[i].constraints.cPermittedSubtree)
7364 {
7365 for (j = 0; j < constraints->cPermittedSubtree; j++)
7366 {
7368 &encodedNameConstraints[i].constraints.rgPermittedSubtree[j].Base);
7369 }
7370 }
7372 encodedNameConstraints[i].constraints.cExcludedSubtree)
7373 fprintf(stderr, "%ld: expected %lu excluded, got %lu\n", i,
7377 encodedNameConstraints[i].constraints.cExcludedSubtree)
7378 {
7379 for (j = 0; j < constraints->cExcludedSubtree; j++)
7380 {
7382 &encodedNameConstraints[i].constraints.rgExcludedSubtree[j].Base);
7383 }
7384 }
7386 }
7387 }
7388}
7389
7390static const BYTE noticeWithDisplayText[] = {
7391 0x30,0x22,0x1e,0x20,0x00,0x54,0x00,0x68,0x00,0x69,0x00,0x73,0x00,0x20,0x00,
7392 0x69,0x00,0x73,0x00,0x20,0x00,0x61,0x00,0x20,0x00,0x6e,0x00,0x6f,0x00,0x74,
7393 0x00,0x69,0x00,0x63,0x00,0x65
7394};
7395static char org[] = "Wine";
7396static int noticeNumbers[] = { 2,3 };
7398 0x30,0x32,0x30,0x0e,0x16,0x04,0x57,0x69,0x6e,0x65,0x30,0x06,0x02,0x01,0x02,
7399 0x02,0x01,0x03,0x1e,0x20,0x00,0x54,0x00,0x68,0x00,0x69,0x00,0x73,0x00,0x20,
7400 0x00,0x69,0x00,0x73,0x00,0x20,0x00,0x61,0x00,0x20,0x00,0x6e,0x00,0x6f,0x00,
7401 0x74,0x00,0x69,0x00,0x63,0x00,0x65
7402};
7403
7405{
7406 BOOL ret;
7407 LPBYTE buf;
7408 DWORD size;
7411
7412 memset(&notice, 0, sizeof(notice));
7413 ret = CryptEncodeObjectEx(dwEncoding,
7415 NULL, &buf, &size);
7416 ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
7417 if (ret)
7418 {
7419 ok(sizeof(emptySequence) == size, "unexpected size %ld\n", size);
7420 ok(!memcmp(buf, emptySequence, size), "unexpected value\n");
7421 LocalFree(buf);
7422 }
7423 notice.pszDisplayText = (WCHAR *)L"This is a notice";
7424 ret = CryptEncodeObjectEx(dwEncoding,
7426 NULL, &buf, &size);
7427 ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
7428 if (ret)
7429 {
7430 ok(sizeof(noticeWithDisplayText) == size, "unexpected size %ld\n", size);
7431 ok(!memcmp(buf, noticeWithDisplayText, size), "unexpected value\n");
7432 LocalFree(buf);
7433 }
7434 reference.pszOrganization = org;
7435 reference.cNoticeNumbers = 2;
7436 reference.rgNoticeNumbers = noticeNumbers;
7437 notice.pNoticeReference = &reference;
7438 ret = CryptEncodeObjectEx(dwEncoding,
7440 NULL, &buf, &size);
7441 ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
7442 if (ret)
7443 {
7444 ok(sizeof(noticeWithReference) == size, "unexpected size %ld\n", size);
7445 ok(!memcmp(buf, noticeWithReference, size), "unexpected value\n");
7446 LocalFree(buf);
7447 }
7448}
7449
7451{
7452 BOOL ret;
7454 DWORD size;
7455
7456 ret = CryptDecodeObjectEx(dwEncoding,
7459 &notice, &size);
7460 ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
7461 if (ret)
7462 {
7463 ok(notice->pszDisplayText == NULL, "unexpected display text\n");
7464 ok(notice->pNoticeReference == NULL, "unexpected notice reference\n");
7466 }
7467 ret = CryptDecodeObjectEx(dwEncoding,
7471 ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
7472 if (ret)
7473 {
7474 ok(!lstrcmpW(notice->pszDisplayText, L"This is a notice"),
7475 "unexpected display text\n");
7476 ok(notice->pNoticeReference == NULL, "unexpected notice reference\n");
7478 }
7479 ret = CryptDecodeObjectEx(dwEncoding,
7483 ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
7484 if (ret)
7485 {
7486 ok(!lstrcmpW(notice->pszDisplayText, L"This is a notice"),
7487 "unexpected display text\n");
7488 ok(notice->pNoticeReference != NULL, "expected a notice reference\n");
7489 if (notice->pNoticeReference)
7490 {
7491 ok(!strcmp(notice->pNoticeReference->pszOrganization, org),
7492 "unexpected organization %s\n",
7493 notice->pNoticeReference->pszOrganization);
7494 ok(notice->pNoticeReference->cNoticeNumbers == 2,
7495 "expected 2 notice numbers, got %ld\n",
7496 notice->pNoticeReference->cNoticeNumbers);
7497 ok(notice->pNoticeReference->rgNoticeNumbers[0] == noticeNumbers[0],
7498 "unexpected notice number %d\n",
7499 notice->pNoticeReference->rgNoticeNumbers[0]);
7500 ok(notice->pNoticeReference->rgNoticeNumbers[1] == noticeNumbers[1],
7501 "unexpected notice number %d\n",
7502 notice->pNoticeReference->rgNoticeNumbers[1]);
7503 }
7505 }
7506}
7507
7508static char oid_any_policy[] = "2.5.29.32.0";
7509static const BYTE policiesWithAnyPolicy[] = {
7510 0x30,0x08,0x30,0x06,0x06,0x04,0x55,0x1d,0x20,0x00
7511};
7512static char oid1[] = "1.2.3";
7513static char oid_user_notice[] = "1.3.6.1.5.5.7.2.2";
7514static const BYTE twoPolicies[] = {
7515 0x30,0x50,0x30,0x06,0x06,0x04,0x55,0x1d,0x20,0x00,0x30,0x46,0x06,0x02,0x2a,
7516 0x03,0x30,0x40,0x30,0x3e,0x06,0x08,0x2b,0x06,0x01,0x05,0x05,0x07,0x02,0x02,
7517 0x30,0x32,0x30,0x0e,0x16,0x04,0x57,0x69,0x6e,0x65,0x30,0x06,0x02,0x01,0x02,
7518 0x02,0x01,0x03,0x1e,0x20,0x00,0x54,0x00,0x68,0x00,0x69,0x00,0x73,0x00,0x20,
7519 0x00,0x69,0x00,0x73,0x00,0x20,0x00,0x61,0x00,0x20,0x00,0x6e,0x00,0x6f,0x00,
7520 0x74,0x00,0x69,0x00,0x63,0x00,0x65
7521};
7522
7523static void test_encodeCertPolicies(DWORD dwEncoding)
7524{
7525 BOOL ret;
7529 LPBYTE buf;
7530 DWORD size;
7531
7532 memset(&info, 0, sizeof(info));
7535 ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
7536 if (ret)
7537 {
7538 ok(sizeof(emptySequence) == size, "unexpected size %ld\n", size);
7539 ok(!memcmp(buf, emptySequence, size), "unexpected value\n");
7540 LocalFree(buf);
7541 }
7542 memset(policy, 0, sizeof(policy));
7543 info.cPolicyInfo = 1;
7544 info.rgPolicyInfo = policy;
7548 "expected E_INVALIDARG, got %08lx\n", GetLastError());
7549 policy[0].pszPolicyIdentifier = oid_any_policy;
7552 ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
7553 if (ret)
7554 {
7555 ok(sizeof(policiesWithAnyPolicy) == size, "unexpected size %ld\n", size);
7556 ok(!memcmp(buf, policiesWithAnyPolicy, size), "unexpected value\n");
7557 LocalFree(buf);
7558 }
7559 policy[1].pszPolicyIdentifier = oid1;
7560 memset(&qualifier, 0, sizeof(qualifier));
7561 qualifier.pszPolicyQualifierId = oid_user_notice;
7562 qualifier.Qualifier.cbData = sizeof(noticeWithReference);
7563 qualifier.Qualifier.pbData = noticeWithReference;
7564 policy[1].cPolicyQualifier = 1;
7565 policy[1].rgPolicyQualifier = &qualifier;
7566 info.cPolicyInfo = 2;
7569 ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
7570 if (ret)
7571 {
7572 ok(sizeof(twoPolicies) == size, "unexpected size %ld\n", size);
7573 ok(!memcmp(buf, twoPolicies, size), "unexpected value\n");
7574 LocalFree(buf);
7575 }
7576}
7577
7578static void test_decodeCertPolicies(DWORD dwEncoding)
7579{
7580 BOOL ret;
7582 DWORD size;
7583
7586 &info, &size);
7587 ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
7588 if (ret)
7589 {
7590 ok(info->cPolicyInfo == 0, "unexpected policy info %ld\n",
7591 info->cPolicyInfo);
7592 LocalFree(info);
7593 }
7597 ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
7598 if (ret)
7599 {
7600 ok(info->cPolicyInfo == 1, "unexpected policy info %ld\n",
7601 info->cPolicyInfo);
7602 ok(!strcmp(info->rgPolicyInfo[0].pszPolicyIdentifier, oid_any_policy),
7603 "unexpected policy id %s\n",
7604 info->rgPolicyInfo[0].pszPolicyIdentifier);
7605 ok(info->rgPolicyInfo[0].cPolicyQualifier == 0,
7606 "unexpected policy qualifier count %ld\n",
7607 info->rgPolicyInfo[0].cPolicyQualifier);
7608 LocalFree(info);
7609 }
7611 twoPolicies, sizeof(twoPolicies),
7613 ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
7614 if (ret)
7615 {
7616 ok(info->cPolicyInfo == 2, "unexpected policy info %ld\n",
7617 info->cPolicyInfo);
7618 ok(!strcmp(info->rgPolicyInfo[0].pszPolicyIdentifier, oid_any_policy),
7619 "unexpected policy id %s\n",
7620 info->rgPolicyInfo[0].pszPolicyIdentifier);
7621 ok(info->rgPolicyInfo[0].cPolicyQualifier == 0,
7622 "unexpected policy qualifier count %ld\n",
7623 info->rgPolicyInfo[0].cPolicyQualifier);
7624 ok(!strcmp(info->rgPolicyInfo[1].pszPolicyIdentifier, oid1),
7625 "unexpected policy id %s\n",
7626 info->rgPolicyInfo[1].pszPolicyIdentifier);
7627 ok(info->rgPolicyInfo[1].cPolicyQualifier == 1,
7628 "unexpected policy qualifier count %ld\n",
7629 info->rgPolicyInfo[1].cPolicyQualifier);
7630 ok(!strcmp(
7631 info->rgPolicyInfo[1].rgPolicyQualifier[0].pszPolicyQualifierId,
7632 oid_user_notice), "unexpected policy qualifier id %s\n",
7633 info->rgPolicyInfo[1].rgPolicyQualifier[0].pszPolicyQualifierId);
7634 ok(info->rgPolicyInfo[1].rgPolicyQualifier[0].Qualifier.cbData ==
7635 sizeof(noticeWithReference), "unexpected qualifier size %ld\n",
7636 info->rgPolicyInfo[1].rgPolicyQualifier[0].Qualifier.cbData);
7637 ok(!memcmp(
7638 info->rgPolicyInfo[1].rgPolicyQualifier[0].Qualifier.pbData,
7640 "unexpected qualifier value\n");
7641 LocalFree(info);
7642 }
7644 twoPolicies, sizeof(twoPolicies), 0, NULL, NULL, &size);
7645 ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
7646 info = calloc(1, size);
7647 if (info)
7648 {
7650 twoPolicies, sizeof(twoPolicies), 0, NULL, info, &size);
7651 ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
7652 free(info);
7653 }
7654}
7655
76570x30,0x0a,0x30,0x08,0x06,0x02,0x2a,0x03,0x06,0x02,0x53,0x04 };
76590x30,0x14,0x30,0x08,0x06,0x02,0x2a,0x03,0x06,0x02,0x53,0x04,0x30,0x08,0x06,
76600x02,0x2b,0x04,0x06,0x02,0x55,0x06 };
7663
7665{
7666 static char oid2[] = "2.3.4";
7667 static char oid3[] = "1.3.4";
7668 static char oid4[] = "2.5.6";
7669 BOOL ret;
7672 LPBYTE buf;
7673 DWORD size, i;
7674
7675 /* Each of the mapping OIDs is equivalent, so check with all of them */
7676 for (i = 0; i < ARRAY_SIZE(mappingOids); i++)
7677 {
7678 memset(&info, 0, sizeof(info));
7679 ret = CryptEncodeObjectEx(dwEncoding, mappingOids[i], &info,
7681 ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
7682 if (ret)
7683 {
7684 ok(size == sizeof(emptySequence), "unexpected size %ld\n", size);
7686 "unexpected value\n");
7687 LocalFree(buf);
7688 }
7689 mapping[0].pszIssuerDomainPolicy = NULL;
7690 mapping[0].pszSubjectDomainPolicy = NULL;
7691 info.cPolicyMapping = 1;
7692 info.rgPolicyMapping = mapping;
7693 SetLastError(0xdeadbeef);
7694 ret = CryptEncodeObjectEx(dwEncoding, mappingOids[i], &info,
7697 "expected E_INVALIDARG, got %08lx\n", GetLastError());
7698 mapping[0].pszIssuerDomainPolicy = oid1;
7699 mapping[0].pszSubjectDomainPolicy = oid2;
7700 ret = CryptEncodeObjectEx(dwEncoding, mappingOids[i], &info,
7702 ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
7703 if (ret)
7704 {
7706 "unexpected size %ld\n", size);
7708 "unexpected value\n");
7709 LocalFree(buf);
7710 }
7711 mapping[1].pszIssuerDomainPolicy = oid3;
7712 mapping[1].pszSubjectDomainPolicy = oid4;
7713 info.cPolicyMapping = 2;
7714 ret = CryptEncodeObjectEx(dwEncoding, mappingOids[i], &info,
7716 ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
7717 if (ret)
7718 {
7720 "unexpected size %ld\n", size);
7722 "unexpected value\n");
7723 LocalFree(buf);
7724 }
7725 }
7726}
7727
7729{
7730 DWORD size, i;
7732 BOOL ret;
7733
7734 /* Each of the mapping OIDs is equivalent, so check with all of them */
7735 for (i = 0; i < ARRAY_SIZE(mappingOids); i++)
7736 {
7737 ret = CryptDecodeObjectEx(dwEncoding, mappingOids[i],
7739 &info, &size);
7740 ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
7741 if (ret)
7742 {
7743 ok(info->cPolicyMapping == 0,
7744 "expected 0 policy mappings, got %ld\n", info->cPolicyMapping);
7745 LocalFree(info);
7746 }
7747 ret = CryptDecodeObjectEx(dwEncoding, mappingOids[i],
7750 ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
7751 if (ret)
7752 {
7753 ok(info->cPolicyMapping == 1,
7754 "expected 1 policy mappings, got %ld\n", info->cPolicyMapping);
7755 ok(!strcmp(info->rgPolicyMapping[0].pszIssuerDomainPolicy, "1.2.3"),
7756 "unexpected issuer policy %s\n",
7757 info->rgPolicyMapping[0].pszIssuerDomainPolicy);
7758 ok(!strcmp(info->rgPolicyMapping[0].pszSubjectDomainPolicy,
7759 "2.3.4"), "unexpected subject policy %s\n",
7760 info->rgPolicyMapping[0].pszSubjectDomainPolicy);
7761 LocalFree(info);
7762 }
7763 ret = CryptDecodeObjectEx(dwEncoding, mappingOids[i],
7766 ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
7767 if (ret)
7768 {
7769 ok(info->cPolicyMapping == 2,
7770 "expected 2 policy mappings, got %ld\n", info->cPolicyMapping);
7771 ok(!strcmp(info->rgPolicyMapping[0].pszIssuerDomainPolicy, "1.2.3"),
7772 "unexpected issuer policy %s\n",
7773 info->rgPolicyMapping[0].pszIssuerDomainPolicy);
7774 ok(!strcmp(info->rgPolicyMapping[0].pszSubjectDomainPolicy,
7775 "2.3.4"), "unexpected subject policy %s\n",
7776 info->rgPolicyMapping[0].pszSubjectDomainPolicy);
7777 ok(!strcmp(info->rgPolicyMapping[1].pszIssuerDomainPolicy, "1.3.4"),
7778 "unexpected issuer policy %s\n",
7779 info->rgPolicyMapping[1].pszIssuerDomainPolicy);
7780 ok(!strcmp(info->rgPolicyMapping[1].pszSubjectDomainPolicy,
7781 "2.5.6"), "unexpected subject policy %s\n",
7782 info->rgPolicyMapping[1].pszSubjectDomainPolicy);
7783 LocalFree(info);
7784 }
7785 ret = CryptDecodeObjectEx(dwEncoding, mappingOids[i],
7787 NULL, NULL, &size);
7788 ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
7789 info = calloc(1, size);
7790 if (info)
7791 {
7792 ret = CryptDecodeObjectEx(dwEncoding, mappingOids[i],
7794 NULL, info, &size);
7795 ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
7796 free(info);
7797 }
7798 }
7799}
7800
78020x30,0x03,0x80,0x01,0x00 };
78040x30,0x03,0x81,0x01,0x01 };
78060x30,0x06,0x80,0x01,0x01,0x81,0x01,0x01 };
7807
7809{
7811 LPBYTE buf;
7812 DWORD size;
7813 BOOL ret;
7814
7815 /* Even though RFC 5280 explicitly states CAs must not issue empty
7816 * policy constraints (section 4.2.1.11), the API doesn't prevent it.
7817 */
7820 ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
7821 if (ret)
7822 {
7823 ok(size == sizeof(emptySequence), "unexpected size %ld\n", size);
7825 "unexpected value\n");
7826 LocalFree(buf);
7827 }
7828 /* If fRequireExplicitPolicy is set but dwRequireExplicitPolicySkipCerts
7829 * is not, then a skip of 0 is encoded.
7830 */
7831 info.fRequireExplicitPolicy = TRUE;
7834 ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
7835 if (ret)
7836 {
7838 "unexpected size %ld\n", size);
7840 sizeof(policyConstraintsWithRequireExplicit)), "unexpected value\n");
7841 LocalFree(buf);
7842 }
7843 /* With inhibit policy mapping */
7844 info.fRequireExplicitPolicy = FALSE;
7845 info.dwRequireExplicitPolicySkipCerts = 0;
7846 info.fInhibitPolicyMapping = TRUE;
7847 info.dwInhibitPolicyMappingSkipCerts = 1;
7850 ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
7851 if (ret)
7852 {
7854 "unexpected size %ld\n", size);
7856 sizeof(policyConstraintsWithInhibitMapping)), "unexpected value\n");
7857 LocalFree(buf);
7858 }
7859 /* And with both */
7860 info.fRequireExplicitPolicy = TRUE;
7861 info.dwRequireExplicitPolicySkipCerts = 1;
7864 ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
7865 if (ret)
7866 {
7867 ok(size == sizeof(policyConstraintsWithBoth), "unexpected size %ld\n",
7868 size);
7870 sizeof(policyConstraintsWithBoth)), "unexpected value\n");
7871 LocalFree(buf);
7872 }
7873}
7874
7876{
7878 DWORD size;
7879 BOOL ret;
7880
7881 /* Again, even though CAs must not issue such constraints, they can be
7882 * decoded.
7883 */
7886 &info, &size);
7887 ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
7888 if (ret)
7889 {
7890 ok(!info->fRequireExplicitPolicy,
7891 "expected require explicit = FALSE\n");
7892 ok(!info->fInhibitPolicyMapping,
7893 "expected implicit mapping = FALSE\n");
7894 LocalFree(info);
7895 }
7899 NULL, &info, &size);
7900 ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
7901 if (ret)
7902 {
7903 ok(info->fRequireExplicitPolicy,
7904 "expected require explicit = TRUE\n");
7905 ok(info->dwRequireExplicitPolicySkipCerts == 0, "expected 0, got %ld\n",
7906 info->dwRequireExplicitPolicySkipCerts);
7907 ok(!info->fInhibitPolicyMapping,
7908 "expected implicit mapping = FALSE\n");
7909 LocalFree(info);
7910 }
7914 NULL, &info, &size);
7915 ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
7916 if (ret)
7917 {
7918 ok(!info->fRequireExplicitPolicy,
7919 "expected require explicit = FALSE\n");
7920 ok(info->fInhibitPolicyMapping,
7921 "expected implicit mapping = TRUE\n");
7922 ok(info->dwInhibitPolicyMappingSkipCerts == 1, "expected 1, got %ld\n",
7923 info->dwInhibitPolicyMappingSkipCerts);
7924 LocalFree(info);
7925 }
7929 ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
7930 if (ret)
7931 {
7932 ok(info->fRequireExplicitPolicy,
7933 "expected require explicit = TRUE\n");
7934 ok(info->dwRequireExplicitPolicySkipCerts == 1, "expected 1, got %ld\n",
7935 info->dwRequireExplicitPolicySkipCerts);
7936 ok(info->fInhibitPolicyMapping,
7937 "expected implicit mapping = TRUE\n");
7938 ok(info->dwInhibitPolicyMappingSkipCerts == 1, "expected 1, got %ld\n",
7939 info->dwInhibitPolicyMappingSkipCerts);
7940 LocalFree(info);
7941 }
7942}
7943
7944static const BYTE rsaPrivKeyDer[] = {
79450x30,0x82,0x04,0xa5,0x02,0x01,0x00,0x02,0x82,0x01,0x01,0x00,
79460xae,0xba,0x3c,0x41,0xeb,0x25,0x41,0xb0,0x1c,0x41,0xd4,0x26,
79470xf9,0xf8,0x31,0x64,0x7e,0x97,0x65,0x54,0x9c,0x90,0xdf,0x34,
79480x07,0xfb,0xb0,0x69,0x99,0x3b,0x45,0x39,0x06,0xe4,0x3a,0x7a,
79490x01,0xe0,0xeb,0x3f,0xe1,0xd5,0x91,0xe0,0x16,0xe0,0xf2,0x35,
79500x59,0xdf,0x32,0x2d,0x69,0x3a,0x4a,0xbc,0xd1,0xba,0x1b,0x3b,
79510x7a,0x55,0x76,0xba,0x11,0xdd,0x2f,0xc7,0x58,0x66,0xf2,0x6c,
79520xd1,0x68,0x27,0x6c,0x85,0x74,0x0b,0xc9,0x7b,0x1a,0xde,0x3c,
79530x62,0x73,0xe2,0x9e,0x36,0x3a,0x29,0x3b,0x91,0x85,0x3d,0xd2,
79540xe1,0xe5,0x61,0x84,0x1e,0x28,0xfd,0xb7,0x97,0x68,0xc1,0xbb,
79550x0f,0x93,0x14,0xc2,0x03,0x60,0x41,0x11,0x7a,0xda,0x76,0x01,
79560x65,0x08,0xe6,0x0c,0xf6,0xfc,0x1d,0x64,0x12,0x7b,0x42,0xb0,
79570xb8,0xfe,0x61,0xe5,0xe2,0xe5,0x61,0x44,0xcc,0x94,0xe8,0xc0,
79580x4f,0x58,0x9a,0xea,0x99,0xaf,0x9c,0xa4,0xf2,0xd7,0x2b,0x31,
79590x90,0x3b,0x41,0x2e,0x4a,0x74,0x7c,0x1a,0xfc,0x42,0xa9,0x17,
79600xff,0x53,0x20,0x76,0xa7,0xf0,0x2c,0xb9,0xd5,0x1f,0xa9,0x8a,
79610x77,0xa8,0x09,0x5c,0x0e,0xd1,0x54,0xc5,0xf2,0x86,0xf1,0x2f,
79620x23,0xd6,0x63,0xba,0xe9,0x2b,0x73,0xf9,0xf0,0xdc,0xcb,0xf9,
79630xcb,0xe8,0x40,0x62,0x47,0x09,0x85,0xe1,0x9c,0xfd,0xcf,0x75,
79640x5a,0x65,0xfd,0x86,0x1c,0x50,0xfa,0x24,0x36,0x0f,0x54,0x5e,
79650x81,0xe7,0xf6,0x63,0x2d,0x87,0x0c,0x50,0x03,0x25,0x49,0xe7,
79660xc5,0x20,0xaa,0xbc,0x6c,0xf9,0xbe,0x49,0x8f,0x4f,0xb8,0x9a,
79670x73,0x9f,0x55,0x43,0x02,0x03,0x01,0x00,0x01,0x02,0x82,0x01,
79680x01,0x00,0x99,0x03,0xcd,0x5b,0x69,0x03,0x32,0x98,0x78,0xd6,
79690x89,0x65,0x2c,0xc9,0xd6,0xef,0x8c,0x11,0x27,0x93,0x46,0x9d,
79700x74,0x6a,0xcb,0x86,0xf6,0x02,0x34,0x47,0xfc,0xa2,0x29,0x4f,
79710xdb,0x8a,0x17,0x75,0x12,0x6f,0xda,0x65,0x3f,0x1f,0xc0,0xc9,
79720x74,0x33,0x96,0xa5,0xe8,0xfa,0x6d,0xc9,0xb7,0xc3,0xcd,0xe3,
79730x2e,0x90,0x12,0xdd,0x1f,0x61,0x69,0xdd,0x8b,0x47,0x07,0x3a,
79740xf8,0x98,0xa5,0x76,0x91,0xf7,0xee,0x93,0x26,0xf3,0x66,0x54,
79750xac,0x44,0xb3,0x6f,0x8b,0x09,0x44,0xb2,0x00,0x84,0x03,0x37,
79760x6d,0x61,0xed,0xa4,0x04,0x97,0x40,0x16,0x63,0xc2,0xd0,0xdc,
79770xd3,0xb3,0xee,0xba,0xbe,0x95,0xfd,0x80,0xe0,0xda,0xde,0xfc,
79780xcc,0x15,0x02,0x97,0x1d,0x68,0x43,0x2f,0x9c,0xc8,0x20,0x23,
79790xeb,0x00,0x4c,0x74,0x3d,0x27,0x20,0x14,0x23,0x95,0xfc,0x8c,
79800xb7,0x7e,0x7f,0xb0,0xdb,0xaf,0x8a,0x48,0x1b,0xfe,0x59,0xab,
79810x75,0xe2,0xbf,0x69,0xf2,0x73,0xe3,0xb9,0x92,0xa9,0x90,0x03,
79820xe5,0xd4,0x2d,0x86,0xff,0x12,0x54,0xb3,0xbb,0xe2,0xce,0x81,
79830x58,0x71,0xa4,0xde,0x45,0x05,0xf8,0x2d,0x45,0xf5,0xd8,0x5e,
79840x4c,0x5d,0x06,0x69,0x0c,0x86,0x9f,0x66,0x9f,0xb1,0x60,0xfd,
79850xf2,0x33,0x85,0x15,0xd5,0x18,0xf7,0xba,0x99,0x65,0x15,0x1d,
79860xfa,0xaa,0x76,0xdd,0x25,0xed,0xdf,0x90,0x6e,0xba,0x61,0x96,
79870x79,0xde,0xd2,0xda,0x66,0x03,0x74,0x3b,0x13,0x39,0x68,0xbc,
79880x94,0x01,0x00,0x2d,0xf8,0xf0,0x8c,0xbd,0x4c,0x9c,0x7e,0x87,
79890x9c,0x62,0x9f,0xb6,0x90,0x11,0x02,0x81,0x81,0x00,0xe3,0x5e,
79900xfe,0xdd,0xed,0x76,0xb6,0x4e,0xfc,0x5b,0xe0,0x20,0x99,0x7b,
79910x48,0x3b,0x1e,0x5f,0x7f,0x9f,0xa4,0x68,0xbe,0xc3,0x7f,0xb8,
79920x62,0x98,0xb0,0x95,0x8a,0xfa,0x0d,0xa3,0x79,0x63,0x39,0xf7,
79930xdb,0x76,0x3d,0x53,0x4a,0x0a,0x33,0xdf,0xe0,0x47,0x22,0xd5,
79940x96,0x80,0xc7,0xcd,0x24,0xef,0xac,0x49,0x46,0x37,0x6c,0x25,
79950xcf,0x6c,0x4d,0xe5,0x31,0xf8,0x2f,0xd2,0x59,0x74,0x00,0x38,
79960xdb,0xce,0xd1,0x72,0xc3,0xa8,0x30,0x70,0xd8,0x02,0x20,0xe7,
79970x56,0xe7,0xca,0xf0,0x3b,0x52,0x5d,0x11,0xbe,0x53,0x4e,0xd0,
79980xd9,0x2e,0xa6,0xb8,0xe2,0xd9,0xbf,0xb9,0x77,0xe7,0x3b,0xed,
79990x5e,0xd7,0x16,0x4a,0x3a,0xc5,0x86,0xd7,0x74,0x20,0xa7,0x8e,
80000xbf,0xb7,0x33,0xdb,0x51,0xe9,0x02,0x81,0x81,0x00,0xc4,0xba,
80010x57,0xf0,0x6e,0xcf,0xe8,0xce,0xce,0x9d,0x4a,0xe9,0x0f,0xe1,
80020xab,0x91,0x62,0xaa,0x66,0x5d,0x82,0x66,0x1c,0x72,0x18,0x6f,
80030x68,0x9c,0x7d,0x5e,0xfc,0xaf,0x4a,0xd6,0x8e,0xc6,0xae,0x40,
80040xf2,0x40,0x84,0x93,0xee,0x7c,0x87,0xa9,0xa6,0xcd,0x2b,0xc3,
80050xe6,0x29,0x3a,0xe2,0x4a,0xed,0xb0,0x4d,0x9f,0xc0,0xe9,0xd6,
80060xa3,0xca,0x97,0xee,0xac,0xab,0xa4,0x32,0x05,0x40,0x4d,0xf2,
80070x95,0x99,0xaf,0xa0,0xe1,0xe1,0xe7,0x3a,0x64,0xa4,0x70,0x6b,
80080x3d,0x1d,0x7b,0xf1,0x53,0xfa,0xb0,0xe0,0xe2,0x68,0x1a,0x61,
80090x2c,0x37,0xa5,0x39,0x7b,0xb2,0xcf,0xe6,0x5f,0x9b,0xc6,0x64,
80100xaf,0x48,0x86,0xfb,0xc1,0xf3,0x39,0x97,0x10,0x36,0xf5,0xa9,
80110x3d,0x08,0xa5,0x2f,0xe6,0x4b,0x02,0x81,0x81,0x00,0x86,0xe7,
80120x02,0x08,0xe2,0xaf,0xa0,0x93,0x54,0x9f,0x9e,0x67,0x39,0x29,
80130x30,0x3e,0x03,0x53,0x5e,0x01,0x76,0x26,0xbf,0xa8,0x76,0xcb,
80140x0b,0x94,0xd4,0x90,0xa5,0x98,0x9f,0x26,0xf3,0x0a,0xb0,0x86,
80150x22,0xac,0x10,0xce,0xae,0x0b,0x47,0xa3,0xf9,0x09,0xbb,0xdd,
80160x46,0x22,0xba,0x69,0x39,0x15,0x0a,0xff,0x9e,0xad,0x9b,0x79,
80170x03,0x8c,0x9a,0xda,0xf5,0xbe,0xef,0x80,0xba,0x9a,0x5c,0xd7,
80180x5f,0x73,0x62,0x49,0xd9,0x54,0x9d,0x09,0x16,0xe0,0x8c,0x6d,
80190x35,0xde,0xe9,0x45,0x87,0xac,0xe2,0x93,0x78,0x7d,0x2d,0x32,
80200x34,0xe9,0xbc,0xf9,0xcd,0x7e,0xac,0x86,0x7a,0x61,0xb3,0xe8,
80210xae,0x70,0xa7,0x44,0xfb,0x81,0xde,0xf3,0x4e,0x6f,0x61,0x7b,
80220x0c,0xbc,0xc2,0x03,0xca,0xa1,0x02,0x81,0x80,0x69,0x5b,0x4a,
80230xa1,0x4f,0x17,0x35,0x9d,0x1b,0xf6,0x0d,0x1a,0x48,0x11,0x19,
80240xab,0x20,0xe6,0x15,0x30,0x5b,0x17,0x88,0x80,0x6a,0x29,0xb0,
80250x22,0xae,0xd9,0xe2,0x05,0x96,0xd4,0xd5,0x5d,0xfe,0x10,0x76,
80260x2c,0xab,0x53,0xf6,0x52,0xe6,0xec,0xaa,0x92,0x12,0xb0,0x35,
80270x61,0x3b,0x51,0xd9,0xc2,0xf5,0xba,0x7c,0xa5,0xfa,0x15,0xa3,
80280x5e,0x6a,0x83,0xbe,0x21,0xa6,0x2b,0xcb,0xb8,0x26,0x86,0x96,
80290x2b,0xda,0x6d,0x14,0xcb,0xc0,0xe3,0xfa,0xe6,0x3d,0xf6,0x90,
80300xa2,0x6b,0xb0,0x50,0xc3,0x5f,0x5a,0xf0,0xa5,0xc4,0x0a,0xea,
80310x7d,0x5a,0x95,0x30,0x74,0x10,0xf7,0x55,0x98,0xbd,0x65,0x4a,
80320xa2,0x52,0xf8,0x1d,0x64,0xbf,0x20,0xf1,0xe4,0x1d,0x28,0x67,
80330xb1,0x6b,0x95,0xfd,0x85,0x02,0x81,0x81,0x00,0xda,0xb4,0x31,
80340x34,0xe1,0xec,0x9a,0x1e,0x07,0xd7,0xda,0x20,0x46,0xbf,0x6b,
80350xf0,0x45,0xbd,0x50,0xa2,0x0f,0x8a,0x14,0x51,0x52,0x83,0x7c,
80360x47,0xc8,0x9c,0x4e,0x68,0x6b,0xae,0x00,0x25,0x63,0xdd,0x13,
80370x2a,0x66,0x65,0xb6,0x74,0x91,0x5b,0xb6,0x47,0x3e,0x8e,0x46,
80380x62,0xcd,0x9d,0xc1,0xf7,0x14,0x14,0xbc,0x60,0xd6,0x3c,0x7c,
80390x3a,0xce,0xff,0x96,0x04,0x84,0xf6,0x44,0x1a,0xf8,0xdb,0x40,
80400x1c,0xf2,0xf1,0x4d,0xb2,0x68,0x3e,0xa3,0x0b,0xc6,0xb1,0xd0,
80410xa6,0x88,0x18,0x68,0xa1,0x05,0x2a,0xfc,0x2b,0x3a,0xa1,0xe6,
80420x31,0x4a,0x46,0x88,0x39,0x1e,0x44,0x11,0x6c,0xc5,0x8b,0xb6,
80430x8b,0xce,0x3d,0xd5,0xcb,0xbd,0xf0,0xd4,0xd9,0xfb,0x02,0x35,
80440x96,0x39,0x26,0x85,0xf9 };
8045static const BYTE rsaPrivKeyModulus[] = {
80460x43,0x55,0x9f,0x73,0x9a,0xb8,0x4f,0x8f,0x49,0xbe,0xf9,0x6c,
80470xbc,0xaa,0x20,0xc5,0xe7,0x49,0x25,0x03,0x50,0x0c,0x87,0x2d,
80480x63,0xf6,0xe7,0x81,0x5e,0x54,0x0f,0x36,0x24,0xfa,0x50,0x1c,
80490x86,0xfd,0x65,0x5a,0x75,0xcf,0xfd,0x9c,0xe1,0x85,0x09,0x47,
80500x62,0x40,0xe8,0xcb,0xf9,0xcb,0xdc,0xf0,0xf9,0x73,0x2b,0xe9,
80510xba,0x63,0xd6,0x23,0x2f,0xf1,0x86,0xf2,0xc5,0x54,0xd1,0x0e,
80520x5c,0x09,0xa8,0x77,0x8a,0xa9,0x1f,0xd5,0xb9,0x2c,0xf0,0xa7,
80530x76,0x20,0x53,0xff,0x17,0xa9,0x42,0xfc,0x1a,0x7c,0x74,0x4a,
80540x2e,0x41,0x3b,0x90,0x31,0x2b,0xd7,0xf2,0xa4,0x9c,0xaf,0x99,
80550xea,0x9a,0x58,0x4f,0xc0,0xe8,0x94,0xcc,0x44,0x61,0xe5,0xe2,
80560xe5,0x61,0xfe,0xb8,0xb0,0x42,0x7b,0x12,0x64,0x1d,0xfc,0xf6,
80570x0c,0xe6,0x08,0x65,0x01,0x76,0xda,0x7a,0x11,0x41,0x60,0x03,
80580xc2,0x14,0x93,0x0f,0xbb,0xc1,0x68,0x97,0xb7,0xfd,0x28,0x1e,
80590x84,0x61,0xe5,0xe1,0xd2,0x3d,0x85,0x91,0x3b,0x29,0x3a,0x36,
80600x9e,0xe2,0x73,0x62,0x3c,0xde,0x1a,0x7b,0xc9,0x0b,0x74,0x85,
80610x6c,0x27,0x68,0xd1,0x6c,0xf2,0x66,0x58,0xc7,0x2f,0xdd,0x11,
80620xba,0x76,0x55,0x7a,0x3b,0x1b,0xba,0xd1,0xbc,0x4a,0x3a,0x69,
80630x2d,0x32,0xdf,0x59,0x35,0xf2,0xe0,0x16,0xe0,0x91,0xd5,0xe1,
80640x3f,0xeb,0xe0,0x01,0x7a,0x3a,0xe4,0x06,0x39,0x45,0x3b,0x99,
80650x69,0xb0,0xfb,0x07,0x34,0xdf,0x90,0x9c,0x54,0x65,0x97,0x7e,
80660x64,0x31,0xf8,0xf9,0x26,0xd4,0x41,0x1c,0xb0,0x41,0x25,0xeb,
80670x41,0x3c,0xba,0xae };
8068static const BYTE rsaPrivKeyPrime1[] = {
80690xe9,0x51,0xdb,0x33,0xb7,0xbf,0x8e,0xa7,0x20,0x74,0xd7,0x86,
80700xc5,0x3a,0x4a,0x16,0xd7,0x5e,0xed,0x3b,0xe7,0x77,0xb9,0xbf,
80710xd9,0xe2,0xb8,0xa6,0x2e,0xd9,0xd0,0x4e,0x53,0xbe,0x11,0x5d,
80720x52,0x3b,0xf0,0xca,0xe7,0x56,0xe7,0x20,0x02,0xd8,0x70,0x30,
80730xa8,0xc3,0x72,0xd1,0xce,0xdb,0x38,0x00,0x74,0x59,0xd2,0x2f,
80740xf8,0x31,0xe5,0x4d,0x6c,0xcf,0x25,0x6c,0x37,0x46,0x49,0xac,
80750xef,0x24,0xcd,0xc7,0x80,0x96,0xd5,0x22,0x47,0xe0,0xdf,0x33,
80760x0a,0x4a,0x53,0x3d,0x76,0xdb,0xf7,0x39,0x63,0x79,0xa3,0x0d,
80770xfa,0x8a,0x95,0xb0,0x98,0x62,0xb8,0x7f,0xc3,0xbe,0x68,0xa4,
80780x9f,0x7f,0x5f,0x1e,0x3b,0x48,0x7b,0x99,0x20,0xe0,0x5b,0xfc,
80790x4e,0xb6,0x76,0xed,0xdd,0xfe,0x5e,0xe3 };
8080static const BYTE rsaPrivKeyPrime2[] = {
80810x4b,0xe6,0x2f,0xa5,0x08,0x3d,0xa9,0xf5,0x36,0x10,0x97,0x39,
80820xf3,0xc1,0xfb,0x86,0x48,0xaf,0x64,0xc6,0x9b,0x5f,0xe6,0xcf,
80830xb2,0x7b,0x39,0xa5,0x37,0x2c,0x61,0x1a,0x68,0xe2,0xe0,0xb0,
80840xfa,0x53,0xf1,0x7b,0x1d,0x3d,0x6b,0x70,0xa4,0x64,0x3a,0xe7,
80850xe1,0xe1,0xa0,0xaf,0x99,0x95,0xf2,0x4d,0x40,0x05,0x32,0xa4,
80860xab,0xac,0xee,0x97,0xca,0xa3,0xd6,0xe9,0xc0,0x9f,0x4d,0xb0,
80870xed,0x4a,0xe2,0x3a,0x29,0xe6,0xc3,0x2b,0xcd,0xa6,0xa9,0x87,
80880x7c,0xee,0x93,0x84,0x40,0xf2,0x40,0xae,0xc6,0x8e,0xd6,0x4a,
80890xaf,0xfc,0x5e,0x7d,0x9c,0x68,0x6f,0x18,0x72,0x1c,0x66,0x82,
80900x5d,0x66,0xaa,0x62,0x91,0xab,0xe1,0x0f,0xe9,0x4a,0x9d,0xce,
80910xce,0xe8,0xcf,0x6e,0xf0,0x57,0xba,0xc4 };
8092static const BYTE rsaPrivKeyExponent1[] = {
80930xa1,0xca,0x03,0xc2,0xbc,0x0c,0x7b,0x61,0x6f,0x4e,0xf3,0xde,
80940x81,0xfb,0x44,0xa7,0x70,0xae,0xe8,0xb3,0x61,0x7a,0x86,0xac,
80950x7e,0xcd,0xf9,0xbc,0xe9,0x34,0x32,0x2d,0x7d,0x78,0x93,0xe2,
80960xac,0x87,0x45,0xe9,0xde,0x35,0x6d,0x8c,0xe0,0x16,0x09,0x9d,
80970x54,0xd9,0x49,0x62,0x73,0x5f,0xd7,0x5c,0x9a,0xba,0x80,0xef,
80980xbe,0xf5,0xda,0x9a,0x8c,0x03,0x79,0x9b,0xad,0x9e,0xff,0x0a,
80990x15,0x39,0x69,0xba,0x22,0x46,0xdd,0xbb,0x09,0xf9,0xa3,0x47,
81000x0b,0xae,0xce,0x10,0xac,0x22,0x86,0xb0,0x0a,0xf3,0x26,0x9f,
81010x98,0xa5,0x90,0xd4,0x94,0x0b,0xcb,0x76,0xa8,0xbf,0x26,0x76,
81020x01,0x5e,0x53,0x03,0x3e,0x30,0x29,0x39,0x67,0x9e,0x9f,0x54,
81030x93,0xa0,0xaf,0xe2,0x08,0x02,0xe7,0x86 };
8104static const BYTE rsaPrivKeyExponent2[] = {
81050x85,0xfd,0x95,0x6b,0xb1,0x67,0x28,0x1d,0xe4,0xf1,0x20,0xbf,
81060x64,0x1d,0xf8,0x52,0xa2,0x4a,0x65,0xbd,0x98,0x55,0xf7,0x10,
81070x74,0x30,0x95,0x5a,0x7d,0xea,0x0a,0xc4,0xa5,0xf0,0x5a,0x5f,
81080xc3,0x50,0xb0,0x6b,0xa2,0x90,0xf6,0x3d,0xe6,0xfa,0xe3,0xc0,
81090xcb,0x14,0x6d,0xda,0x2b,0x96,0x86,0x26,0xb8,0xcb,0x2b,0xa6,
81100x21,0xbe,0x83,0x6a,0x5e,0xa3,0x15,0xfa,0xa5,0x7c,0xba,0xf5,
81110xc2,0xd9,0x51,0x3b,0x61,0x35,0xb0,0x12,0x92,0xaa,0xec,0xe6,
81120x52,0xf6,0x53,0xab,0x2c,0x76,0x10,0xfe,0x5d,0xd5,0xd4,0x96,
81130x05,0xe2,0xd9,0xae,0x22,0xb0,0x29,0x6a,0x80,0x88,0x17,0x5b,
81140x30,0x15,0xe6,0x20,0xab,0x19,0x11,0x48,0x1a,0x0d,0xf6,0x1b,
81150x9d,0x35,0x17,0x4f,0xa1,0x4a,0x5b,0x69 };
8116static const BYTE rsaPrivKeyCoefficient[] = {
81170xf9,0x85,0x26,0x39,0x96,0x35,0x02,0xfb,0xd9,0xd4,0xf0,0xbd,
81180xcb,0xd5,0x3d,0xce,0x8b,0xb6,0x8b,0xc5,0x6c,0x11,0x44,0x1e,
81190x39,0x88,0x46,0x4a,0x31,0xe6,0xa1,0x3a,0x2b,0xfc,0x2a,0x05,
81200xa1,0x68,0x18,0x88,0xa6,0xd0,0xb1,0xc6,0x0b,0xa3,0x3e,0x68,
81210xb2,0x4d,0xf1,0xf2,0x1c,0x40,0xdb,0xf8,0x1a,0x44,0xf6,0x84,
81220x04,0x96,0xff,0xce,0x3a,0x7c,0x3c,0xd6,0x60,0xbc,0x14,0x14,
81230xf7,0xc1,0x9d,0xcd,0x62,0x46,0x8e,0x3e,0x47,0xb6,0x5b,0x91,
81240x74,0xb6,0x65,0x66,0x2a,0x13,0xdd,0x63,0x25,0x00,0xae,0x6b,
81250x68,0x4e,0x9c,0xc8,0x47,0x7c,0x83,0x52,0x51,0x14,0x8a,0x0f,
81260xa2,0x50,0xbd,0x45,0xf0,0x6b,0xbf,0x46,0x20,0xda,0xd7,0x07,
81270x1e,0x9a,0xec,0xe1,0x34,0x31,0xb4,0xda };
81290x11,0x90,0xb6,0x9f,0x62,0x9c,0x87,0x7e,0x9c,0x4c,0xbd,0x8c,
81300xf0,0xf8,0x2d,0x00,0x01,0x94,0xbc,0x68,0x39,0x13,0x3b,0x74,
81310x03,0x66,0xda,0xd2,0xde,0x79,0x96,0x61,0xba,0x6e,0x90,0xdf,
81320xed,0x25,0xdd,0x76,0xaa,0xfa,0x1d,0x15,0x65,0x99,0xba,0xf7,
81330x18,0xd5,0x15,0x85,0x33,0xf2,0xfd,0x60,0xb1,0x9f,0x66,0x9f,
81340x86,0x0c,0x69,0x06,0x5d,0x4c,0x5e,0xd8,0xf5,0x45,0x2d,0xf8,
81350x05,0x45,0xde,0xa4,0x71,0x58,0x81,0xce,0xe2,0xbb,0xb3,0x54,
81360x12,0xff,0x86,0x2d,0xd4,0xe5,0x03,0x90,0xa9,0x92,0xb9,0xe3,
81370x73,0xf2,0x69,0xbf,0xe2,0x75,0xab,0x59,0xfe,0x1b,0x48,0x8a,
81380xaf,0xdb,0xb0,0x7f,0x7e,0xb7,0x8c,0xfc,0x95,0x23,0x14,0x20,
81390x27,0x3d,0x74,0x4c,0x00,0xeb,0x23,0x20,0xc8,0x9c,0x2f,0x43,
81400x68,0x1d,0x97,0x02,0x15,0xcc,0xfc,0xde,0xda,0xe0,0x80,0xfd,
81410x95,0xbe,0xba,0xee,0xb3,0xd3,0xdc,0xd0,0xc2,0x63,0x16,0x40,
81420x97,0x04,0xa4,0xed,0x61,0x6d,0x37,0x03,0x84,0x00,0xb2,0x44,
81430x09,0x8b,0x6f,0xb3,0x44,0xac,0x54,0x66,0xf3,0x26,0x93,0xee,
81440xf7,0x91,0x76,0xa5,0x98,0xf8,0x3a,0x07,0x47,0x8b,0xdd,0x69,
81450x61,0x1f,0xdd,0x12,0x90,0x2e,0xe3,0xcd,0xc3,0xb7,0xc9,0x6d,
81460xfa,0xe8,0xa5,0x96,0x33,0x74,0xc9,0xc0,0x1f,0x3f,0x65,0xda,
81470x6f,0x12,0x75,0x17,0x8a,0xdb,0x4f,0x29,0xa2,0xfc,0x47,0x34,
81480x02,0xf6,0x86,0xcb,0x6a,0x74,0x9d,0x46,0x93,0x27,0x11,0x8c,
81490xef,0xd6,0xc9,0x2c,0x65,0x89,0xd6,0x78,0x98,0x32,0x03,0x69,
81500x5b,0xcd,0x03,0x99 };
8151
8152static void test_decodeRsaPrivateKey(DWORD dwEncoding)
8153{
8154 LPBYTE buf = NULL;
8155 DWORD bufSize = 0;
8156 BOOL ret;
8157
8159 rsaPrivKeyDer, sizeof(rsaPrivKeyDer)-10,
8162 "Expected CRYPT_E_ASN1_EOD, got %08lx\n",
8163 GetLastError());
8164
8165 buf = NULL;
8166 bufSize = 0;
8170 ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
8171
8172 if (ret)
8173 {
8175 RSAPUBKEY *rsaPubKey = (RSAPUBKEY *)(buf + sizeof(BLOBHEADER));
8176 static const int bitlen = 2048;
8177 BYTE *modulus = (BYTE*)(rsaPubKey + 1);
8178 BYTE *prime1 = modulus + bitlen/8;
8179 BYTE *prime2 = prime1 + bitlen/16;
8180 BYTE *exponent1 = prime2 + bitlen/16;
8181 BYTE *exponent2 = exponent1 + bitlen/16;
8182 BYTE *coefficient = exponent2 + bitlen/16;
8183 BYTE *privateExponent = coefficient + bitlen/16;
8184
8185 ok(bufSize >= sizeof(BLOBHEADER) + sizeof(RSAPUBKEY) +
8186 (bitlen * 9 / 16),
8187 "Wrong size %ld\n", bufSize);
8188
8189 ok(hdr->bType == PRIVATEKEYBLOB,
8190 "Expected type PRIVATEKEYBLOB (%d), got %d\n", PRIVATEKEYBLOB,
8191 hdr->bType);
8192 ok(hdr->bVersion == CUR_BLOB_VERSION,
8193 "Expected version CUR_BLOB_VERSION (%d), got %d\n",
8194 CUR_BLOB_VERSION, hdr->bVersion);
8195 ok(hdr->reserved == 0, "Expected reserved 0, got %d\n",
8196 hdr->reserved);
8197 ok(hdr->aiKeyAlg == CALG_RSA_KEYX,
8198 "Expected CALG_RSA_KEYX, got %08x\n", hdr->aiKeyAlg);
8199
8200 ok(rsaPubKey->magic == 0x32415352,
8201 "Expected magic 0x32415352, got 0x%lx\n", rsaPubKey->magic);
8202 ok(rsaPubKey->bitlen == bitlen,
8203 "Expected bitlen %d, got %ld\n", bitlen, rsaPubKey->bitlen);
8204 ok(rsaPubKey->pubexp == 65537,
8205 "Expected pubexp 65537, got %ld\n", rsaPubKey->pubexp);
8206
8207 ok(!memcmp(modulus, rsaPrivKeyModulus, bitlen/8),
8208 "unexpected modulus\n");
8209 ok(!memcmp(prime1, rsaPrivKeyPrime1, bitlen/16),
8210 "unexpected prime1\n");
8211 ok(!memcmp(prime2, rsaPrivKeyPrime2, bitlen/16),
8212 "unexpected prime2\n");
8213 ok(!memcmp(exponent1, rsaPrivKeyExponent1, bitlen/16),
8214 "unexpected exponent1\n");
8215 ok(!memcmp(exponent2, rsaPrivKeyExponent2, bitlen/16),
8216 "unexpected exponent2\n");
8217 ok(!memcmp(coefficient, rsaPrivKeyCoefficient, bitlen/16),
8218 "unexpected coefficient\n");
8219 ok(!memcmp(privateExponent, rsaPrivKeyPrivateExponent, bitlen/8),
8220 "unexpected privateExponent\n");
8221
8222 LocalFree(buf);
8223 }
8224}
8225
8227{
8228 BOOL ret;
8229 DWORD size = 0;
8230 HCRYPTKEY key;
8231
8232 /* This crashes
8233 ret = CryptExportPublicKeyInfoEx(0, 0, 0, NULL, 0, NULL, NULL, NULL);
8234 */
8235 ret = CryptExportPublicKeyInfoEx(0, 0, 0, NULL, 0, NULL, NULL, &size);
8237 "Expected ERROR_INVALID_PARAMETER, got %08lx\n", GetLastError());
8239 &size);
8241 "Expected ERROR_INVALID_PARAMETER, got %08lx\n", GetLastError());
8243 NULL, &size);
8245 "Expected ERROR_INVALID_PARAMETER, got %08lx\n", GetLastError());
8247 0, NULL, NULL, &size);
8249 "Expected ERROR_INVALID_PARAMETER, got %08lx\n", GetLastError());
8250 /* Test with no key */
8252 0, NULL, NULL, &size);
8253 ok(!ret && GetLastError() == NTE_NO_KEY, "Expected NTE_NO_KEY, got %08lx\n",
8254 GetLastError());
8255 ret = CryptGenKey(csp, AT_SIGNATURE, 0, &key);
8256 ok(ret, "CryptGenKey failed: %08lx\n", GetLastError());
8257 if (ret)
8258 {
8260 NULL, 0, NULL, NULL, &size);
8261 ok(ret, "CryptExportPublicKeyInfoEx failed: %08lx\n", GetLastError());
8262 *pInfo = malloc(size);
8263 if (*pInfo)
8264 {
8266 X509_ASN_ENCODING, NULL, 0, NULL, *pInfo, &size);
8267 ok(ret, "CryptExportPublicKeyInfoEx failed: %08lx\n",
8268 GetLastError());
8269 if (ret)
8270 {
8271 /* By default (we passed NULL as the OID) the OID is
8272 * szOID_RSA_RSA.
8273 */
8274 ok(!strcmp((*pInfo)->Algorithm.pszObjId, szOID_RSA_RSA),
8275 "Expected %s, got %s\n", szOID_RSA_RSA,
8276 (*pInfo)->Algorithm.pszObjId);
8277 }
8278 }
8279 }
8281}
8282
8283static const BYTE expiredCert[] = { 0x30, 0x82, 0x01, 0x33, 0x30, 0x81, 0xe2,
8284 0xa0, 0x03, 0x02, 0x01, 0x02, 0x02, 0x10, 0xc4, 0xd7, 0x7f, 0x0e, 0x6f, 0xa6,
8285 0x8c, 0xaa, 0x47, 0x47, 0x40, 0xe7, 0xb7, 0x0b, 0x4a, 0x7f, 0x30, 0x09, 0x06,
8286 0x05, 0x2b, 0x0e, 0x03, 0x02, 0x1d, 0x05, 0x00, 0x30, 0x1f, 0x31, 0x1d, 0x30,
8287 0x1b, 0x06, 0x03, 0x55, 0x04, 0x03, 0x13, 0x14, 0x61, 0x72, 0x69, 0x63, 0x40,
8288 0x63, 0x6f, 0x64, 0x65, 0x77, 0x65, 0x61, 0x76, 0x65, 0x72, 0x73, 0x2e, 0x63,
8289 0x6f, 0x6d, 0x30, 0x1e, 0x17, 0x0d, 0x36, 0x39, 0x30, 0x31, 0x30, 0x31, 0x30,
8290 0x30, 0x30, 0x30, 0x30, 0x30, 0x5a, 0x17, 0x0d, 0x37, 0x30, 0x30, 0x31, 0x30,
8291 0x31, 0x30, 0x36, 0x30, 0x30, 0x30, 0x30, 0x5a, 0x30, 0x1f, 0x31, 0x1d, 0x30,
8292 0x1b, 0x06, 0x03, 0x55, 0x04, 0x03, 0x13, 0x14, 0x61, 0x72, 0x69, 0x63, 0x40,
8293 0x63, 0x6f, 0x64, 0x65, 0x77, 0x65, 0x61, 0x76, 0x65, 0x72, 0x73, 0x2e, 0x63,
8294 0x6f, 0x6d, 0x30, 0x5c, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7,
8295 0x0d, 0x01, 0x01, 0x01, 0x05, 0x00, 0x03, 0x4b, 0x00, 0x30, 0x48, 0x02, 0x41,
8296 0x00, 0xa1, 0xaf, 0x4a, 0xea, 0xa7, 0x83, 0x57, 0xc0, 0x37, 0x33, 0x7e, 0x29,
8297 0x5e, 0x0d, 0xfc, 0x44, 0x74, 0x3a, 0x1d, 0xc3, 0x1b, 0x1d, 0x96, 0xed, 0x4e,
8298 0xf4, 0x1b, 0x98, 0xec, 0x69, 0x1b, 0x04, 0xea, 0x25, 0xcf, 0xb3, 0x2a, 0xf5,
8299 0xd9, 0x22, 0xd9, 0x8d, 0x08, 0x39, 0x81, 0xc6, 0xe0, 0x4f, 0x12, 0x37, 0x2a,
8300 0x3f, 0x80, 0xa6, 0x6c, 0x67, 0x43, 0x3a, 0xdd, 0x95, 0x0c, 0xbb, 0x2f, 0x6b,
8301 0x02, 0x03, 0x01, 0x00, 0x01, 0x30, 0x09, 0x06, 0x05, 0x2b, 0x0e, 0x03, 0x02,
8302 0x1d, 0x05, 0x00, 0x03, 0x41, 0x00, 0x8f, 0xa2, 0x5b, 0xd6, 0xdf, 0x34, 0xd0,
8303 0xa2, 0xa7, 0x47, 0xf1, 0x13, 0x79, 0xd3, 0xf3, 0x39, 0xbd, 0x4e, 0x2b, 0xa3,
8304 0xf4, 0x63, 0x37, 0xac, 0x5a, 0x0c, 0x5e, 0x4d, 0x0d, 0x54, 0x87, 0x4f, 0x31,
8305 0xfb, 0xa0, 0xce, 0x8f, 0x9a, 0x2f, 0x4d, 0x48, 0xc6, 0x84, 0x8d, 0xf5, 0x70,
8306 0x74, 0x17, 0xa5, 0xf3, 0x66, 0x47, 0x06, 0xd6, 0x64, 0x45, 0xbc, 0x52, 0xef,
8307 0x49, 0xe5, 0xf9, 0x65, 0xf3 };
8308
8310{
8311 BOOL ret;
8312 HCRYPTKEY key;
8313#ifndef __REACTOS__
8314 BCRYPT_KEY_HANDLE key2;
8315#endif
8317 DWORD dwSize;
8318 ALG_ID ai;
8319
8320 /* These crash
8321 ret = CryptImportPublicKeyInfoEx(0, 0, NULL, 0, 0, NULL, NULL);
8322 ret = CryptImportPublicKeyInfoEx(0, 0, NULL, 0, 0, NULL, &key);
8323 ret = CryptImportPublicKeyInfoEx(0, 0, info, 0, 0, NULL, NULL);
8324 ret = CryptImportPublicKeyInfoEx(csp, X509_ASN_ENCODING, info, 0, 0, NULL,
8325 NULL);
8326 */
8327 ret = CryptImportPublicKeyInfoEx(0, 0, info, 0, 0, NULL, &key);
8329 "Expected ERROR_FILE_NOT_FOUND, got %08lx\n", GetLastError());
8330 ret = CryptImportPublicKeyInfoEx(csp, 0, info, 0, 0, NULL, &key);
8332 "Expected ERROR_FILE_NOT_FOUND, got %08lx\n", GetLastError());
8334 &key);
8336 "Expected ERROR_INVALID_PARAMETER, got %08lx\n", GetLastError());
8337
8338 /* Export key with standard algorithm (CALG_RSA_KEYX) */
8340 &key);
8341 ok(ret, "CryptImportPublicKeyInfoEx failed: %08lx\n", GetLastError());
8342
8343 dwSize = sizeof(ai);
8345 ok(ret, "CryptGetKeyParam failed: %08lx\n", GetLastError());
8346 if(ret)
8347 {
8348 ok(dwSize == sizeof(ai), "CryptGetKeyParam returned size %ld\n",dwSize);
8349 ok(ai == CALG_RSA_KEYX, "Default ALG_ID is %04x (expected CALG_RSA_KEYX)\n", ai);
8350 }
8351
8353
8354 /* Repeat with forced algorithm */
8356 &key);
8357 ok(ret, "CryptImportPublicKeyInfoEx failed: %08lx\n", GetLastError());
8358
8359 dwSize = sizeof(ai);
8361 ok(ret, "CryptGetKeyParam failed: %08lx\n", GetLastError());
8362 if(ret)
8363 {
8364 ok(dwSize == sizeof(ai), "CryptGetKeyParam returned size %ld\n",dwSize);
8365 ok(ai == CALG_RSA_SIGN, "ALG_ID is %04x (expected CALG_RSA_SIGN)\n", ai);
8366 }
8367
8369
8370 /* Test importing a public key from a certificate context */
8372 sizeof(expiredCert));
8373 ok(context != NULL, "CertCreateCertificateContext failed: %08lx\n",
8374 GetLastError());
8375 if (context)
8376 {
8378 context->pCertInfo->SubjectPublicKeyInfo.Algorithm.pszObjId),
8379 "Expected %s, got %s\n", szOID_RSA_RSA,
8380 context->pCertInfo->SubjectPublicKeyInfo.Algorithm.pszObjId);
8382 &context->pCertInfo->SubjectPublicKeyInfo, 0, 0, NULL, &key);
8383 ok(ret, "CryptImportPublicKeyInfoEx failed: %08lx\n", GetLastError());
8385
8386#ifndef __REACTOS__ // FIXME: ReactOS has no implementation for CryptImportPublicKeyInfoEx2
8388 &context->pCertInfo->SubjectPublicKeyInfo, 0, NULL, &key2);
8389 ok(ret, "CryptImportPublicKeyInfoEx2 failed: %08lx\n", GetLastError());
8390 BCryptDestroyKey(key2);
8391#endif
8392
8394 }
8395}
8396
8397static const char cspName[] = "WineCryptTemp";
8398
8399static void testPortPublicKeyInfo(void)
8400{
8401 HCRYPTPROV csp;
8402 BOOL ret;
8404
8405 /* Just in case a previous run failed, delete this thing */
8410 ok(ret,"CryptAcquireContextA failed\n");
8411
8414
8415 free(info);
8416 CryptReleaseContext(csp, 0);
8419 ok(ret,"CryptAcquireContextA failed\n");
8420}
8421
8422static void test_encodeOCSPRequestInfo(DWORD dwEncoding)
8423{
8424 static const BYTE expected[] =
8425 {0x30, 0x68, 0xa1, 0x17, 0x82, 0x15, 0x2a, 0x2e, 0x63, 0x6d, 0x2e, 0x73, 0x74, 0x65, 0x61, 0x6d,
8426 0x70, 0x6f, 0x77, 0x65, 0x72, 0x65, 0x64, 0x2e, 0x63, 0x6f, 0x6d, 0x30, 0x4d, 0x30, 0x4b, 0x30,
8427 0x49, 0x30, 0x09, 0x06, 0x05, 0x2b, 0x0e, 0x03, 0x02, 0x1a, 0x05, 0x00, 0x04, 0x14, 0xe4, 0xe3,
8428 0x95, 0xa2, 0x29, 0xd3, 0xd4, 0xc1, 0xc3, 0x1f, 0xf0, 0x98 ,0x0c, 0x0b, 0x4e, 0xc0, 0x09, 0x8a,
8429 0xab, 0xd8, 0x04, 0x14, 0xb7, 0x6b, 0xa2, 0xea, 0xa8, 0xaa, 0x84, 0x8c, 0x79, 0xea, 0xb4, 0xda,
8430 0x0f, 0x98, 0xb2, 0xc5, 0x95, 0x76, 0xb9, 0xf4, 0x02, 0x10, 0xb1, 0xc1, 0x87, 0x54, 0x54, 0xac,
8431 0x1e, 0x55, 0x40, 0xfb, 0xef, 0xd9, 0x6d, 0x8f, 0x49, 0x08};
8432 static const BYTE expected2[] =
8433 {0x30, 0x81, 0xb6, 0xa1, 0x17, 0x82, 0x15, 0x2a, 0x2e, 0x63, 0x6d, 0x2e, 0x73, 0x74, 0x65, 0x61,
8434 0x6d, 0x70, 0x6f, 0x77, 0x65, 0x72, 0x65, 0x64, 0x2e, 0x63, 0x6f, 0x6d, 0x30, 0x81, 0x9a, 0x30,
8435 0x4b, 0x30, 0x49, 0x30, 0x09, 0x06, 0x05, 0x2b, 0x0e, 0x03, 0x02, 0x1a, 0x05, 0x00, 0x04, 0x14,
8436 0xe4, 0xe3, 0x95, 0xa2, 0x29, 0xd3, 0xd4, 0xc1, 0xc3, 0x1f, 0xf0, 0x98, 0x0c, 0x0b, 0x4e, 0xc0,
8437 0x09, 0x8a, 0xab, 0xd8, 0x04, 0x14, 0xb7, 0x6b, 0xa2, 0xea, 0xa8, 0xaa, 0x84, 0x8c, 0x79, 0xea,
8438 0xb4, 0xda, 0x0f, 0x98, 0xb2, 0xc5, 0x95, 0x76, 0xb9, 0xf4, 0x02, 0x10, 0xb1, 0xc1, 0x87, 0x54,
8439 0x54, 0xac, 0x1e, 0x55, 0x40, 0xfb, 0xef, 0xd9, 0x6d, 0x8f, 0x49, 0x08, 0x30, 0x4b, 0x30, 0x49,
8440 0x30, 0x09, 0x06, 0x05, 0x2b, 0x0e, 0x03, 0x02, 0x1a, 0x05, 0x00, 0x04, 0x14, 0xe4, 0xe3, 0x95,
8441 0xa2, 0x29, 0xd3, 0xd4, 0xc1, 0xc3, 0x1f, 0xf0, 0x98, 0x0c, 0x0b, 0x4e, 0xc0, 0x09, 0x8a, 0xab,
8442 0xd8, 0x04, 0x14, 0xb7, 0x6b, 0xa2, 0xea, 0xa8, 0xaa, 0x84, 0x8c, 0x79, 0xea, 0xb4, 0xda, 0x0f,
8443 0x98, 0xb2, 0xc5, 0x95, 0x76, 0xb9, 0xf4, 0x02, 0x10, 0xb1, 0xc1, 0x87, 0x54, 0x54, 0xac, 0x1e,
8444 0x55, 0x40, 0xfb, 0xef, 0xd9, 0x6d, 0x8f, 0x49, 0x08};
8445 static const BYTE expected3[] =
8446 {0x30, 0x81, 0x9d, 0x30, 0x81, 0x9a, 0x30, 0x4b, 0x30, 0x49, 0x30, 0x09, 0x06, 0x05, 0x2b, 0x0e,
8447 0x03, 0x02, 0x1a, 0x05, 0x00, 0x04, 0x14, 0xe4, 0xe3, 0x95, 0xa2, 0x29, 0xd3, 0xd4, 0xc1, 0xc3,
8448 0x1f, 0xf0, 0x98, 0x0c, 0x0b, 0x4e, 0xc0, 0x09, 0x8a, 0xab, 0xd8, 0x04, 0x14, 0xb7, 0x6b, 0xa2,
8449 0xea, 0xa8, 0xaa, 0x84, 0x8c, 0x79, 0xea, 0xb4, 0xda, 0x0f, 0x98, 0xb2, 0xc5, 0x95, 0x76, 0xb9,
8450 0xf4, 0x02, 0x10, 0xb1, 0xc1, 0x87, 0x54, 0x54, 0xac, 0x1e, 0x55, 0x40, 0xfb, 0xef, 0xd9, 0x6d,
8451 0x8f, 0x49, 0x08, 0x30, 0x4b, 0x30, 0x49, 0x30, 0x09, 0x06, 0x05, 0x2b, 0x0e, 0x03, 0x02, 0x1a,
8452 0x05, 0x00, 0x04, 0x14, 0xe4, 0xe3, 0x95, 0xa2, 0x29, 0xd3, 0xd4, 0xc1, 0xc3, 0x1f, 0xf0, 0x98,
8453 0x0c, 0x0b, 0x4e, 0xc0, 0x09, 0x8a, 0xab, 0xd8, 0x04, 0x14, 0xb7, 0x6b, 0xa2, 0xea, 0xa8, 0xaa,
8454 0x84, 0x8c, 0x79, 0xea, 0xb4, 0xda, 0x0f, 0x98, 0xb2, 0xc5, 0x95, 0x76, 0xb9, 0xf4, 0x02, 0x10,
8455 0xb1, 0xc1, 0x87, 0x54, 0x54, 0xac, 0x1e, 0x55, 0x40, 0xfb, 0xef, 0xd9, 0x6d, 0x8f, 0x49, 0x08};
8456 static const BYTE expected4[] =
8457 {0x30, 0x6a, 0x30, 0x68, 0xa1, 0x17, 0x82, 0x15, 0x2a, 0x2e, 0x63, 0x6d, 0x2e, 0x73, 0x74, 0x65,
8458 0x61, 0x6d, 0x70, 0x6f, 0x77, 0x65, 0x72, 0x65, 0x64, 0x2e, 0x63, 0x6f, 0x6d, 0x30, 0x4d, 0x30,
8459 0x4b, 0x30, 0x49, 0x30, 0x09, 0x06, 0x05, 0x2b, 0x0e, 0x03, 0x02, 0x1a, 0x05, 0x00, 0x04, 0x14,
8460 0xe4, 0xe3, 0x95, 0xa2, 0x29, 0xd3, 0xd4, 0xc1, 0xc3, 0x1f, 0xf0, 0x98, 0x0c, 0x0b, 0x4e, 0xc0,
8461 0x09, 0x8a, 0xab, 0xd8, 0x04, 0x14, 0xb7, 0x6b, 0xa2, 0xea, 0xa8, 0xaa, 0x84, 0x8c, 0x79, 0xea,
8462 0xb4, 0xda, 0x0f, 0x98, 0xb2, 0xc5, 0x95, 0x76, 0xb9, 0xf4, 0x02, 0x10, 0xb1, 0xc1, 0x87, 0x54,
8463 0x54, 0xac, 0x1e, 0x55, 0x40, 0xfb, 0xef, 0xd9, 0x6d, 0x8f, 0x49, 0x08};
8464 static const BYTE issuer_name[] =
8465 {0xe4, 0xe3 ,0x95, 0xa2, 0x29, 0xd3, 0xd4, 0xc1, 0xc3, 0x1f, 0xf0, 0x98, 0x0c, 0x0b, 0x4e, 0xc0,
8466 0x09, 0x8a, 0xab, 0xd8};
8467 static const BYTE issuer_key[] =
8468 {0xb7, 0x6b, 0xa2, 0xea, 0xa8, 0xaa, 0x84, 0x8c, 0x79, 0xea, 0xb4, 0xda, 0x0f, 0x98, 0xb2, 0xc5,
8469 0x95, 0x76, 0xb9, 0xf4};
8470 static const BYTE serial[] =
8471 {0x08, 0x49, 0x8f, 0x6d, 0xd9, 0xef, 0xfb, 0x40, 0x55, 0x1e, 0xac, 0x54, 0x54, 0x87, 0xc1, 0xb1};
8475 OCSP_SIGNED_REQUEST_INFO info_signed;
8476 DWORD size;
8477 BYTE *buf, *buf2;
8478 BOOL ret;
8479
8480 memset(&entry, 0, sizeof(entry));
8481 entry[0].CertId.HashAlgorithm.pszObjId = (char *)szOID_OIWSEC_sha1;
8482 entry[0].CertId.IssuerNameHash.cbData = sizeof(issuer_name);
8483 entry[0].CertId.IssuerNameHash.pbData = (BYTE *)issuer_name;
8484 entry[0].CertId.IssuerKeyHash.cbData = sizeof(issuer_key);
8485 entry[0].CertId.IssuerKeyHash.pbData = (BYTE *)issuer_key;
8486 entry[0].CertId.SerialNumber.cbData = sizeof(serial);
8487 entry[0].CertId.SerialNumber.pbData = (BYTE *)serial;
8488
8489 name.dwAltNameChoice = CERT_ALT_NAME_DNS_NAME;
8490 name.pwszDNSName = (WCHAR *)L"*.cm.steampowered.com";
8491
8492 info.dwVersion = OCSP_REQUEST_V1;
8493 info.pRequestorName = &name;
8494 info.cRequestEntry = 1;
8495 info.rgRequestEntry = entry;
8496 info.cExtension = 0;
8497 info.rgExtension = NULL;
8498
8499 size = 0;
8500 SetLastError(0xdeadbeef);
8502 ok(ret, "got %08lx\n", GetLastError());
8503 ok(size == sizeof(expected), "got %lu\n", size);
8504 ok(!memcmp(buf, expected, sizeof(expected)), "unexpected value\n");
8505
8506 /* wrapped in OCSP_SIGNED_REQUEST_INFO */
8507 info_signed.ToBeSigned.cbData = size;
8508 info_signed.ToBeSigned.pbData = buf;
8509 info_signed.pOptionalSignatureInfo = NULL;
8510 size = 0;
8511 SetLastError(0xdeadbeef);
8513 &buf2, &size);
8514 ok(ret, "got %08lx\n", GetLastError());
8515 ok(size == sizeof(expected4), "got %lu\n", size);
8516 ok(!memcmp(buf2, expected4, sizeof(expected4)), "unexpected value\n");
8517 LocalFree(buf);
8518 LocalFree(buf2);
8519
8520 /* two entries */
8521 entry[1].CertId.HashAlgorithm.pszObjId = (char *)szOID_OIWSEC_sha1;
8522 entry[1].CertId.IssuerNameHash.cbData = sizeof(issuer_name);
8523 entry[1].CertId.IssuerNameHash.pbData = (BYTE *)issuer_name;
8524 entry[1].CertId.IssuerKeyHash.cbData = sizeof(issuer_key);
8525 entry[1].CertId.IssuerKeyHash.pbData = (BYTE *)issuer_key;
8526 entry[1].CertId.SerialNumber.cbData = sizeof(serial);
8527 entry[1].CertId.SerialNumber.pbData = (BYTE *)serial;
8528 info.cRequestEntry = 2;
8529
8530 size = 0;
8531 SetLastError(0xdeadbeef);
8533 ok(ret, "got %08lx\n", GetLastError());
8534 ok(size == sizeof(expected2), "got %lu\n", size);
8535 ok(!memcmp(buf, expected2, sizeof(expected2)), "unexpected value\n");
8536 LocalFree(buf);
8537
8538 /* requestor name not set */
8539 info.pRequestorName = NULL;
8540 size = 0;
8541 SetLastError(0xdeadbeef);
8543 ok(ret, "got %08lx\n", GetLastError());
8544 ok(size == sizeof(expected3), "got %lu\n", size);
8545 ok(!memcmp(buf, expected3, sizeof(expected3)), "unexpected value\n");
8546 LocalFree(buf);
8547}
8548
8549static const BYTE ocsp_response[] = {
8550 0x30, 0x03, 0x0a, 0x01, 0x06
8551};
8552
8553static const BYTE ocsp_response2[] = {
8554 0x30, 0x82, 0x01, 0xd3, 0x0a, 0x01, 0x00, 0xa0, 0x82, 0x01, 0xcc, 0x30,
8555 0x82, 0x01, 0xc8, 0x06, 0x09, 0x2b, 0x06, 0x01, 0x05, 0x05, 0x07, 0x30,
8556 0x01, 0x01, 0x04, 0x82, 0x01, 0xb9, 0x30, 0x82, 0x01, 0xb5, 0x30, 0x81,
8557 0x9e, 0xa2, 0x16, 0x04, 0x14, 0xb7, 0x6b, 0xa2, 0xea, 0xa8, 0xaa, 0x84,
8558 0x8c, 0x79, 0xea, 0xb4, 0xda, 0x0f, 0x98, 0xb2, 0xc5, 0x95, 0x76, 0xb9,
8559 0xf4, 0x18, 0x0f, 0x32, 0x30, 0x32, 0x32, 0x30, 0x33, 0x30, 0x37, 0x31,
8560 0x38, 0x33, 0x36, 0x34, 0x33, 0x5a, 0x30, 0x73, 0x30, 0x71, 0x30, 0x49,
8561 0x30, 0x09, 0x06, 0x05, 0x2b, 0x0e, 0x03, 0x02, 0x1a, 0x05, 0x00, 0x04,
8562 0x14, 0xe4, 0xe3, 0x95, 0xa2, 0x29, 0xd3, 0xd4, 0xc1, 0xc3, 0x1f, 0xf0,
8563 0x98, 0x0c, 0x0b, 0x4e, 0xc0, 0x09, 0x8a, 0xab, 0xd8, 0x04, 0x14, 0xb7,
8564 0x6b, 0xa2, 0xea, 0xa8, 0xaa, 0x84, 0x8c, 0x79, 0xea, 0xb4, 0xda, 0x0f,
8565 0x98, 0xb2, 0xc5, 0x95, 0x76, 0xb9, 0xf4, 0x02, 0x10, 0x08, 0x49, 0x8f,
8566 0x6d, 0xd9, 0xef, 0xfb, 0x40, 0x55, 0x1e, 0xac, 0x54, 0x54, 0x87, 0xc1,
8567 0xb1, 0x80, 0x00, 0x18, 0x0f, 0x32, 0x30, 0x32, 0x32, 0x30, 0x33, 0x30,
8568 0x37, 0x31, 0x38, 0x32, 0x31, 0x30, 0x31, 0x5a, 0xa0, 0x11, 0x18, 0x0f,
8569 0x32, 0x30, 0x32, 0x32, 0x30, 0x33, 0x31, 0x34, 0x31, 0x37, 0x33, 0x36,
8570 0x30, 0x31, 0x5a, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7,
8571 0x0d, 0x01, 0x01, 0x0b, 0x05, 0x00, 0x03, 0x82, 0x01, 0x01, 0x00, 0x2a,
8572 0xf3, 0x5f, 0xf7, 0x72, 0x6b, 0x27, 0x38, 0x6b, 0xae, 0x66, 0x42, 0xe0,
8573 0x3b, 0xc6, 0x44, 0x5f, 0x95, 0xe2, 0x1f, 0xbc, 0x3f, 0xb3, 0x1d, 0x6c,
8574 0x6c, 0x7c, 0x91, 0xb3, 0x02, 0x23, 0x0f, 0xf0, 0x13, 0x5f, 0x62, 0x92,
8575 0x0d, 0x91, 0xa9, 0x8f, 0x66, 0xe9, 0x18, 0xe3, 0xb1, 0xe0, 0x4c, 0x63,
8576 0x40, 0x9e, 0x14, 0x26, 0x28, 0x7a, 0x5e, 0x51, 0x99, 0x43, 0x1c, 0xd5,
8577 0xbd, 0x84, 0x88, 0x68, 0xd9, 0x0e, 0xd9, 0xf4, 0x78, 0x48, 0x9f, 0x01,
8578 0x4c, 0x34, 0x14, 0x1e, 0x7c, 0x72, 0x9c, 0xdd, 0x94, 0xcb, 0x6e, 0x28,
8579 0xf5, 0x76, 0x75, 0xa2, 0xbe, 0x4b, 0x52, 0xac, 0x38, 0x9d, 0xce, 0x52,
8580 0x68, 0x33, 0xbc, 0x52, 0xc7, 0xdc, 0x2f, 0x19, 0xff, 0x15, 0x9c, 0x4b,
8581 0xdb, 0x83, 0x4e, 0xd7, 0xf6, 0x9b, 0x7f, 0x76, 0x58, 0xa5, 0x46, 0x49,
8582 0xe3, 0x2d, 0x41, 0x26, 0xf8, 0xce, 0xb7, 0x56, 0x61, 0xb2, 0x88, 0x65,
8583 0x2b, 0xb8, 0x4d, 0xf2, 0xf2, 0x32, 0x50, 0x53, 0x8b, 0x0d, 0xc6, 0x58,
8584 0xac, 0xd8, 0xe4, 0x8d, 0x38, 0x9e, 0x61, 0xeb, 0x6b, 0xd2, 0xd6, 0x50,
8585 0x8d, 0xfa, 0x93, 0x47, 0x4e, 0x6e, 0x2b, 0xd3, 0xb9, 0xdc, 0xb9, 0xb5,
8586 0x86, 0x46, 0xcb, 0xda, 0xd9, 0xd8, 0xd5, 0x99, 0x7a, 0x7c, 0x73, 0xee,
8587 0xc1, 0x52, 0x8e, 0xc5, 0xca, 0x28, 0x1d, 0x15, 0x94, 0x06, 0xa0, 0xa5,
8588 0x01, 0xf3, 0xbd, 0x67, 0x3f, 0x3d, 0x46, 0x63, 0xc5, 0xba, 0xd5, 0x12,
8589 0xde, 0xb4, 0xc5, 0x86, 0xfe, 0x97, 0x6b, 0x70, 0xfe, 0xa4, 0x6a, 0x25,
8590 0x63, 0x8e, 0xcf, 0xa4, 0x13, 0x1c, 0x2b, 0xf7, 0xf4, 0xc9, 0x79, 0x8e,
8591 0x07, 0xa3, 0x25, 0x9f, 0xcf, 0x33, 0x65, 0x49, 0x84, 0xad, 0x7f, 0x90,
8592 0x44, 0x85, 0xd8, 0xa7, 0x73, 0x53, 0x56, 0x73, 0xca, 0x15, 0x39, 0x99,
8593 0x5f, 0x39, 0xfd
8594};
8595
8596static void test_decodeOCSPResponseInfo(DWORD dwEncoding)
8597{
8599 DWORD size;
8600 BOOL ret;
8601
8604 ok(ret, "got %08lx\n", GetLastError());
8605 ok(info->dwStatus == OCSP_UNAUTHORIZED_RESPONSE, "got %lu\n", info->dwStatus);
8606 ok(info->pszObjId == NULL, "got %s\n", wine_dbgstr_a(info->pszObjId));
8607 ok(!info->Value.cbData, "got %lu\n", info->Value.cbData);
8608 ok(info->Value.pbData == NULL, "got %p\n", info->Value.pbData);
8609 LocalFree(info);
8610
8613 ok(ret, "got %08lx\n", GetLastError());
8614 ok(info->dwStatus == OCSP_SUCCESSFUL_RESPONSE, "got %lu\n", info->dwStatus);
8615 ok(!strcmp(info->pszObjId, szOID_PKIX_OCSP_BASIC_SIGNED_RESPONSE), "got %s\n", wine_dbgstr_a(info->pszObjId));
8616 ok(info->Value.cbData == 441, "got %lu\n", info->Value.cbData);
8617 ok(info->Value.pbData != NULL, "got %p\n", info->Value.pbData);
8618 LocalFree(info);
8619}
8620
8622 0x30, 0x82, 0x01, 0xb5, 0x30, 0x81, 0x9e, 0xa2, 0x16, 0x04, 0x14, 0xb7,
8623 0x6b, 0xa2, 0xea, 0xa8, 0xaa, 0x84, 0x8c, 0x79, 0xea, 0xb4, 0xda, 0x0f,
8624 0x98, 0xb2, 0xc5, 0x95, 0x76, 0xb9, 0xf4, 0x18, 0x0f, 0x32, 0x30, 0x32,
8625 0x32, 0x30, 0x33, 0x31, 0x30, 0x31, 0x38, 0x33, 0x36, 0x34, 0x38, 0x5a,
8626 0x30, 0x73, 0x30, 0x71, 0x30, 0x49, 0x30, 0x09, 0x06, 0x05, 0x2b, 0x0e,
8627 0x03, 0x02, 0x1a, 0x05, 0x00, 0x04, 0x14, 0xe4, 0xe3, 0x95, 0xa2, 0x29,
8628 0xd3, 0xd4, 0xc1, 0xc3, 0x1f, 0xf0, 0x98, 0x0c, 0x0b, 0x4e, 0xc0, 0x09,
8629 0x8a, 0xab, 0xd8, 0x04, 0x14, 0xb7, 0x6b, 0xa2, 0xea, 0xa8, 0xaa, 0x84,
8630 0x8c, 0x79, 0xea, 0xb4, 0xda, 0x0f, 0x98, 0xb2, 0xc5, 0x95, 0x76, 0xb9,
8631 0xf4, 0x02, 0x10, 0x08, 0x49, 0x8f, 0x6d, 0xd9, 0xef, 0xfb, 0x40, 0x55,
8632 0x1e, 0xac, 0x54, 0x54, 0x87, 0xc1, 0xb1, 0x80, 0x00, 0x18, 0x0f, 0x32,
8633 0x30, 0x32, 0x32, 0x30, 0x33, 0x31, 0x30, 0x31, 0x38, 0x32, 0x31, 0x30,
8634 0x31, 0x5a, 0xa0, 0x11, 0x18, 0x0f, 0x32, 0x30, 0x32, 0x32, 0x30, 0x33,
8635 0x31, 0x37, 0x31, 0x37, 0x33, 0x36, 0x30, 0x31, 0x5a, 0x30, 0x0d, 0x06,
8636 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x0b, 0x05, 0x00,
8637 0x03, 0x82, 0x01, 0x01, 0x00, 0x6a, 0x4c, 0xfa, 0xe6, 0xe3, 0x48, 0xbb,
8638 0xd6, 0x18, 0x33, 0x04, 0x9d, 0x6a, 0x92, 0x4d, 0x01, 0x74, 0x4f, 0x1a,
8639 0x70, 0xfa, 0xf2, 0x8b, 0xba, 0x0d, 0x2c, 0x06, 0x30, 0xc9, 0x55, 0xce,
8640 0x95, 0x13, 0x4d, 0x4c, 0x65, 0x99, 0xe7, 0xd6, 0x78, 0x9c, 0x3c, 0x9a,
8641 0x60, 0xeb, 0x43, 0x3c, 0x08, 0x1c, 0x02, 0x6d, 0x45, 0x2d, 0x5b, 0xdf,
8642 0xab, 0xf2, 0x92, 0xf1, 0x71, 0x61, 0xb4, 0x34, 0xcf, 0x84, 0x1f, 0xc9,
8643 0x3f, 0x45, 0x9e, 0x64, 0x89, 0x58, 0xdb, 0x2c, 0x73, 0xa8, 0x04, 0xae,
8644 0xad, 0xf2, 0xc5, 0x80, 0x80, 0xcf, 0x96, 0x4b, 0xf1, 0xb4, 0xf1, 0x2a,
8645 0x86, 0x1c, 0x7f, 0x1d, 0xcc, 0xbf, 0xd6, 0xa2, 0x3f, 0x44, 0xb8, 0x62,
8646 0x5b, 0x9b, 0x55, 0xc1, 0x4e, 0x18, 0x67, 0x5a, 0xbe, 0x31, 0xf5, 0x16,
8647 0x6d, 0x74, 0xc4, 0xf2, 0x60, 0x4f, 0xa1, 0x63, 0x49, 0xe9, 0xff, 0x37,
8648 0x3d, 0x66, 0xcd, 0xc3, 0x79, 0x4e, 0x38, 0x68, 0x1b, 0xbf, 0x0b, 0x3b,
8649 0xdb, 0xa0, 0x13, 0x70, 0xb8, 0xd1, 0x59, 0xe2, 0x8e, 0x88, 0xfe, 0x77,
8650 0x39, 0xa8, 0x3f, 0x93, 0xe1, 0xc6, 0x5e, 0x13, 0x9e, 0xea, 0xec, 0x49,
8651 0x65, 0x0b, 0x6d, 0xbf, 0x76, 0xd5, 0x11, 0x59, 0x7b, 0xfe, 0xe6, 0xb2,
8652 0x58, 0xa8, 0xbd, 0xd0, 0xe6, 0x13, 0x26, 0x72, 0x83, 0x78, 0x90, 0x85,
8653 0x82, 0x86, 0x9f, 0x2e, 0x20, 0x64, 0x90, 0xc3, 0xd1, 0x37, 0x50, 0xac,
8654 0xde, 0x52, 0x8e, 0x83, 0x9f, 0x02, 0x7b, 0xff, 0xf1, 0xd4, 0xe5, 0x8b,
8655 0x77, 0x8d, 0xef, 0x61, 0xcb, 0x85, 0x4d, 0xa0, 0x2e, 0x05, 0x28, 0xc0,
8656 0x86, 0x78, 0x59, 0xa9, 0x94, 0xb3, 0x90, 0x6b, 0xf7, 0xff, 0xd3, 0x08,
8657 0x96, 0x7c, 0xbe, 0x22, 0xd8, 0xb6, 0x35, 0xce, 0x1e, 0xae, 0x70, 0x34,
8658 0x05, 0x51, 0x49, 0xac, 0x2f, 0xe8, 0x67, 0xcf, 0xa7
8659};
8660
8661static const BYTE ocsp_basic_response[] = {
8662 0x30, 0x81, 0x9e, 0xa2, 0x16, 0x04, 0x14, 0xb7, 0x6b, 0xa2, 0xea, 0xa8,
8663 0xaa, 0x84, 0x8c, 0x79, 0xea, 0xb4, 0xda, 0x0f, 0x98, 0xb2, 0xc5, 0x95,
8664 0x76, 0xb9, 0xf4, 0x18, 0x0f, 0x32, 0x30, 0x32, 0x32, 0x30, 0x33, 0x31,
8665 0x30, 0x31, 0x38, 0x33, 0x36, 0x34, 0x38, 0x5a, 0x30, 0x73, 0x30, 0x71,
8666 0x30, 0x49, 0x30, 0x09, 0x06, 0x05, 0x2b, 0x0e, 0x03, 0x02, 0x1a, 0x05,
8667 0x00, 0x04, 0x14, 0xe4, 0xe3, 0x95, 0xa2, 0x29, 0xd3, 0xd4, 0xc1, 0xc3,
8668 0x1f, 0xf0, 0x98, 0x0c, 0x0b, 0x4e, 0xc0, 0x09, 0x8a, 0xab, 0xd8, 0x04,
8669 0x14, 0xb7, 0x6b, 0xa2, 0xea, 0xa8, 0xaa, 0x84, 0x8c, 0x79, 0xea, 0xb4,
8670 0xda, 0x0f, 0x98, 0xb2, 0xc5, 0x95, 0x76, 0xb9, 0xf4, 0x02, 0x10, 0x08,
8671 0x49, 0x8f, 0x6d, 0xd9, 0xef, 0xfb, 0x40, 0x55, 0x1e, 0xac, 0x54, 0x54,
8672 0x87, 0xc1, 0xb1, 0x80, 0x00, 0x18, 0x0f, 0x32, 0x30, 0x32, 0x32, 0x30,
8673 0x33, 0x31, 0x30, 0x31, 0x38, 0x32, 0x31, 0x30, 0x31, 0x5a, 0xa0, 0x11,
8674 0x18, 0x0f, 0x32, 0x30, 0x32, 0x32, 0x30, 0x33, 0x31, 0x37, 0x31, 0x37,
8675 0x33, 0x36, 0x30, 0x31, 0x5a
8676};
8677
8678static const BYTE ocsp_basic_response2[] = {
8679 0x30, 0x81, 0xbe, 0xa1, 0x34, 0x30, 0x32, 0x31, 0x0b, 0x30, 0x09, 0x06,
8680 0x03, 0x55, 0x04, 0x06, 0x13, 0x02, 0x55, 0x53, 0x31, 0x16, 0x30, 0x14,
8681 0x06, 0x03, 0x55, 0x04, 0x0a, 0x13, 0x0d, 0x4c, 0x65, 0x74, 0x27, 0x73,
8682 0x20, 0x45, 0x6e, 0x63, 0x72, 0x79, 0x70, 0x74, 0x31, 0x0b, 0x30, 0x09,
8683 0x06, 0x03, 0x55, 0x04, 0x03, 0x13, 0x02, 0x52, 0x33, 0x18, 0x0f, 0x32,
8684 0x30, 0x32, 0x32, 0x31, 0x30, 0x32, 0x30, 0x30, 0x36, 0x30, 0x31, 0x30,
8685 0x30, 0x5a, 0x30, 0x75, 0x30, 0x73, 0x30, 0x4b, 0x30, 0x09, 0x06, 0x05,
8686 0x2b, 0x0e, 0x03, 0x02, 0x1a, 0x05, 0x00, 0x04, 0x14, 0x48, 0xda, 0xc9,
8687 0xa0, 0xfb, 0x2b, 0xd3, 0x2d, 0x4f, 0xf0, 0xde, 0x68, 0xd2, 0xf5, 0x67,
8688 0xb7, 0x35, 0xf9, 0xb3, 0xc4, 0x04, 0x14, 0x14, 0x2e, 0xb3, 0x17, 0xb7,
8689 0x58, 0x56, 0xcb, 0xae, 0x50, 0x09, 0x40, 0xe6, 0x1f, 0xaf, 0x9d, 0x8b,
8690 0x14, 0xc2, 0xc6, 0x02, 0x12, 0x03, 0x26, 0x1c, 0x82, 0x80, 0xf3, 0x8c,
8691 0x13, 0xef, 0xae, 0x83, 0x9d, 0x89, 0xb9, 0xcd, 0x59, 0x83, 0x5b, 0x80,
8692 0x00, 0x18, 0x0f, 0x32, 0x30, 0x32, 0x32, 0x31, 0x30, 0x32, 0x30, 0x30,
8693 0x36, 0x30, 0x30, 0x30, 0x30, 0x5a, 0xa0, 0x11, 0x18, 0x0f, 0x32, 0x30,
8694 0x32, 0x32, 0x31, 0x30, 0x32, 0x37, 0x30, 0x35, 0x35, 0x39, 0x35, 0x38,
8695 0x5a
8696};
8697
8699 0x30, 0x81, 0xb1, 0xa2, 0x16, 0x04, 0x14, 0xa4, 0x8d, 0xe5, 0xbe, 0x7c,
8700 0x79, 0xe4, 0x70, 0x23, 0x6d, 0x2e, 0x29, 0x34, 0xad, 0x23, 0x58, 0xdc,
8701 0xf5, 0x31, 0x7f, 0x18, 0x0f, 0x32, 0x30, 0x32, 0x32, 0x30, 0x33, 0x33,
8702 0x31, 0x30, 0x31, 0x32, 0x35, 0x30, 0x35, 0x5a, 0x30, 0x81, 0x85, 0x30,
8703 0x81, 0x82, 0x30, 0x49, 0x30, 0x09, 0x06, 0x05, 0x2b, 0x0e, 0x03, 0x02,
8704 0x1a, 0x05, 0x00, 0x04, 0x14, 0x74, 0xb4, 0xe7, 0x23, 0x19, 0xc7, 0x65,
8705 0x92, 0x15, 0x40, 0x44, 0x7b, 0xc7, 0xce, 0x3e, 0x90, 0xc2, 0x18, 0x76,
8706 0xeb, 0x04, 0x14, 0xa4, 0x8d, 0xe5, 0xbe, 0x7c, 0x79, 0xe4, 0x70, 0x23,
8707 0x6d, 0x2e, 0x29, 0x34, 0xad, 0x23, 0x58, 0xdc, 0xf5, 0x31, 0x7f, 0x02,
8708 0x10, 0x0d, 0x2e, 0x67, 0xa2, 0x98, 0x85, 0x3b, 0x9a, 0x54, 0x52, 0xe3,
8709 0xa2, 0x85, 0xa4, 0x57, 0x2f, 0xa1, 0x11, 0x18, 0x0f, 0x32, 0x30, 0x32,
8710 0x31, 0x31, 0x30, 0x32, 0x37, 0x32, 0x31, 0x33, 0x38, 0x34, 0x38, 0x5a,
8711 0x18, 0x0f, 0x32, 0x30, 0x32, 0x32, 0x30, 0x33, 0x33, 0x31, 0x30, 0x31,
8712 0x30, 0x39, 0x30, 0x31, 0x5a, 0xa0, 0x11, 0x18, 0x0f, 0x32, 0x30, 0x32,
8713 0x32, 0x30, 0x34, 0x30, 0x37, 0x30, 0x30, 0x32, 0x34, 0x30, 0x31, 0x5a
8714};
8715
8716static const BYTE ocsp_signature[] = {
8717 0x6a, 0x4c, 0xfa, 0xe6, 0xe3, 0x48, 0xbb, 0xd6, 0x18, 0x33, 0x04, 0x9d,
8718 0x6a, 0x92, 0x4d, 0x01, 0x74, 0x4f, 0x1a, 0x70, 0xfa, 0xf2, 0x8b, 0xba,
8719 0x0d, 0x2c, 0x06, 0x30, 0xc9, 0x55, 0xce, 0x95, 0x13, 0x4d, 0x4c, 0x65,
8720 0x99, 0xe7, 0xd6, 0x78, 0x9c, 0x3c, 0x9a, 0x60, 0xeb, 0x43, 0x3c, 0x08,
8721 0x1c, 0x02, 0x6d, 0x45, 0x2d, 0x5b, 0xdf, 0xab, 0xf2, 0x92, 0xf1, 0x71,
8722 0x61, 0xb4, 0x34, 0xcf, 0x84, 0x1f, 0xc9, 0x3f, 0x45, 0x9e, 0x64, 0x89,
8723 0x58, 0xdb, 0x2c, 0x73, 0xa8, 0x04, 0xae, 0xad, 0xf2, 0xc5, 0x80, 0x80,
8724 0xcf, 0x96, 0x4b, 0xf1, 0xb4, 0xf1, 0x2a, 0x86, 0x1c, 0x7f, 0x1d, 0xcc,
8725 0xbf, 0xd6, 0xa2, 0x3f, 0x44, 0xb8, 0x62, 0x5b, 0x9b, 0x55, 0xc1, 0x4e,
8726 0x18, 0x67, 0x5a, 0xbe, 0x31, 0xf5, 0x16, 0x6d, 0x74, 0xc4, 0xf2, 0x60,
8727 0x4f, 0xa1, 0x63, 0x49, 0xe9, 0xff, 0x37, 0x3d, 0x66, 0xcd, 0xc3, 0x79,
8728 0x4e, 0x38, 0x68, 0x1b, 0xbf, 0x0b, 0x3b, 0xdb, 0xa0, 0x13, 0x70, 0xb8,
8729 0xd1, 0x59, 0xe2, 0x8e, 0x88, 0xfe, 0x77, 0x39, 0xa8, 0x3f, 0x93, 0xe1,
8730 0xc6, 0x5e, 0x13, 0x9e, 0xea, 0xec, 0x49, 0x65, 0x0b, 0x6d, 0xbf, 0x76,
8731 0xd5, 0x11, 0x59, 0x7b, 0xfe, 0xe6, 0xb2, 0x58, 0xa8, 0xbd, 0xd0, 0xe6,
8732 0x13, 0x26, 0x72, 0x83, 0x78, 0x90, 0x85, 0x82, 0x86, 0x9f, 0x2e, 0x20,
8733 0x64, 0x90, 0xc3, 0xd1, 0x37, 0x50, 0xac, 0xde, 0x52, 0x8e, 0x83, 0x9f,
8734 0x02, 0x7b, 0xff, 0xf1, 0xd4, 0xe5, 0x8b, 0x77, 0x8d, 0xef, 0x61, 0xcb,
8735 0x85, 0x4d, 0xa0, 0x2e, 0x05, 0x28, 0xc0, 0x86, 0x78, 0x59, 0xa9, 0x94,
8736 0xb3, 0x90, 0x6b, 0xf7, 0xff, 0xd3, 0x08, 0x96, 0x7c, 0xbe, 0x22, 0xd8,
8737 0xb6, 0x35, 0xce, 0x1e, 0xae, 0x70, 0x34, 0x05, 0x51, 0x49, 0xac, 0x2f,
8738 0xe8, 0x67, 0xcf, 0xa7
8739};
8740
8742{
8743 0x30, 0x82, 0x05, 0x32, 0x30, 0x81, 0xdf, 0xa1, 0x54, 0x30, 0x52, 0x31,
8744 0x0b, 0x30, 0x09, 0x06, 0x03, 0x55, 0x04, 0x06, 0x13, 0x02, 0x4d, 0x58,
8745 0x31, 0x0b, 0x30, 0x09, 0x06, 0x03, 0x55, 0x04, 0x08, 0x0c, 0x02, 0x44,
8746 0x46, 0x31, 0x0b, 0x30, 0x09, 0x06, 0x03, 0x55, 0x04, 0x0a, 0x0c, 0x02,
8747 0x43, 0x57, 0x31, 0x0d, 0x30, 0x0b, 0x06, 0x03, 0x55, 0x04, 0x03, 0x0c,
8748 0x04, 0x74, 0x65, 0x73, 0x74, 0x31, 0x1a, 0x30, 0x18, 0x06, 0x09, 0x2a,
8749 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x09, 0x01, 0x16, 0x0b, 0x74, 0x65,
8750 0x73, 0x74, 0x40, 0x71, 0x71, 0x2e, 0x63, 0x6f, 0x6d, 0x18, 0x0f, 0x32,
8751 0x30, 0x32, 0x34, 0x30, 0x34, 0x32, 0x35, 0x30, 0x30, 0x30, 0x36, 0x31,
8752 0x31, 0x5a, 0x30, 0x51, 0x30, 0x4f, 0x30, 0x3a, 0x30, 0x09, 0x06, 0x05,
8753 0x2b, 0x0e, 0x03, 0x02, 0x1a, 0x05, 0x00, 0x04, 0x14, 0x1b, 0xe8, 0x99,
8754 0x10, 0xe7, 0x3d, 0x9c, 0x6b, 0xba, 0x65, 0xb8, 0x6e, 0x6f, 0xd1, 0x63,
8755 0x52, 0xa5, 0x6f, 0xd9, 0x81, 0x04, 0x14, 0xc4, 0x57, 0x2a, 0x53, 0xb7,
8756 0x21, 0x6d, 0x03, 0x2d, 0xd0, 0xbc, 0xd4, 0x2a, 0x88, 0xd2, 0xae, 0x62,
8757 0xa9, 0x97, 0x2a, 0x02, 0x01, 0x02, 0x80, 0x00, 0x18, 0x0f, 0x32, 0x30,
8758 0x32, 0x34, 0x30, 0x34, 0x32, 0x35, 0x30, 0x30, 0x30, 0x36, 0x31, 0x31,
8759 0x5a, 0xa1, 0x23, 0x30, 0x21, 0x30, 0x1f, 0x06, 0x09, 0x2b, 0x06, 0x01,
8760 0x05, 0x05, 0x07, 0x30, 0x01, 0x02, 0x04, 0x12, 0x04, 0x10, 0xab, 0x7a,
8761 0x07, 0x8a, 0xef, 0xc9, 0x7e, 0xb3, 0x51, 0x90, 0xa5, 0x72, 0x09, 0x60,
8762 0x84, 0x27, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d,
8763 0x01, 0x01, 0x0b, 0x05, 0x00, 0x03, 0x82, 0x01, 0x01, 0x00, 0xb5, 0x61,
8764 0x78, 0x5b, 0xc4, 0xb5, 0xe4, 0x8d, 0xff, 0xe1, 0xc5, 0x95, 0xd1, 0xad,
8765 0xb8, 0x55, 0xb4, 0xca, 0xcc, 0xf5, 0xe9, 0x6f, 0x63, 0x64, 0x4b, 0xf7,
8766 0x46, 0xf9, 0x12, 0x02, 0x36, 0xe1, 0x9f, 0xce, 0xe0, 0x5e, 0x6c, 0xf7,
8767 0x35, 0x19, 0x80, 0x89, 0x6b, 0x7d, 0x8f, 0xa1, 0x8c, 0xb1, 0x7d, 0xdc,
8768 0xf1, 0x1c, 0xf7, 0x70, 0x45, 0x77, 0xf3, 0xb4, 0x42, 0x99, 0x58, 0x68,
8769 0x11, 0xec, 0x41, 0x47, 0x11, 0xcc, 0xb1, 0x2f, 0xbb, 0x11, 0xe7, 0x81,
8770 0x7d, 0x17, 0x93, 0x30, 0xab, 0x58, 0xb1, 0xe0, 0x69, 0x34, 0x17, 0x3a,
8771 0xa0, 0x4a, 0xed, 0xd6, 0x9e, 0x02, 0xfd, 0xb7, 0xd1, 0x77, 0x3c, 0x59,
8772 0x47, 0xeb, 0xce, 0xa0, 0x64, 0x06, 0x38, 0x78, 0x96, 0x86, 0x77, 0x1e,
8773 0x3f, 0xa8, 0x56, 0x9d, 0xc4, 0x8f, 0x1d, 0x23, 0x23, 0x1c, 0xe6, 0x03,
8774 0x2c, 0xb9, 0xfd, 0xac, 0x3e, 0x30, 0x52, 0x51, 0x27, 0x35, 0x20, 0x93,
8775 0x94, 0xaa, 0x69, 0x83, 0xeb, 0x04, 0x32, 0x2a, 0xc0, 0x6b, 0x24, 0x30,
8776 0x6f, 0x0f, 0x61, 0xdb, 0xac, 0x01, 0x46, 0x71, 0x52, 0x96, 0x07, 0x48,
8777 0xba, 0xdf, 0x71, 0x96, 0x25, 0xa6, 0x04, 0x36, 0x49, 0xb9, 0xd9, 0x93,
8778 0x9a, 0x79, 0xbf, 0xad, 0x4a, 0x4f, 0x49, 0x98, 0x7d, 0xa3, 0x49, 0x1d,
8779 0x65, 0xb8, 0x51, 0x93, 0x60, 0x63, 0x91, 0x34, 0x5c, 0xe4, 0xad, 0x91,
8780 0x44, 0xc7, 0x69, 0x93, 0x82, 0x28, 0xce, 0xc1, 0xf6, 0xc2, 0xfb, 0xf5,
8781 0xef, 0xaf, 0xdb, 0xc2, 0x14, 0xed, 0x26, 0xad, 0xc9, 0xba, 0xee, 0xe8,
8782 0x40, 0xc6, 0x03, 0x21, 0x9a, 0x7a, 0x47, 0x45, 0x24, 0x5b, 0xc6, 0xf3,
8783 0xb4, 0x55, 0x7e, 0xa5, 0x86, 0x22, 0x60, 0x16, 0x4a, 0x67, 0x0b, 0xbd,
8784 0x92, 0x7a, 0x53, 0x6b, 0xa0, 0x05, 0x2e, 0x3c, 0xfa, 0x5e, 0x06, 0x4f,
8785 0xf1, 0x70, 0xa0, 0x82, 0x03, 0x38, 0x30, 0x82, 0x03, 0x34, 0x30, 0x82,
8786 0x03, 0x30, 0x30, 0x82, 0x02, 0x99, 0xa0, 0x03, 0x02, 0x01, 0x02, 0x02,
8787 0x01, 0x03, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d,
8788 0x01, 0x01, 0x0b, 0x05, 0x00, 0x30, 0x61, 0x31, 0x0b, 0x30, 0x09, 0x06,
8789 0x03, 0x55, 0x04, 0x06, 0x13, 0x02, 0x4d, 0x58, 0x31, 0x0b, 0x30, 0x09,
8790 0x06, 0x03, 0x55, 0x04, 0x08, 0x0c, 0x02, 0x44, 0x46, 0x31, 0x0d, 0x30,
8791 0x0b, 0x06, 0x03, 0x55, 0x04, 0x07, 0x0c, 0x04, 0x43, 0x44, 0x4d, 0x58,
8792 0x31, 0x0b, 0x30, 0x09, 0x06, 0x03, 0x55, 0x04, 0x0a, 0x0c, 0x02, 0x43,
8793 0x57, 0x31, 0x0d, 0x30, 0x0b, 0x06, 0x03, 0x55, 0x04, 0x03, 0x0c, 0x04,
8794 0x74, 0x65, 0x73, 0x74, 0x31, 0x1a, 0x30, 0x18, 0x06, 0x09, 0x2a, 0x86,
8795 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x09, 0x01, 0x16, 0x0b, 0x74, 0x65, 0x73,
8796 0x74, 0x40, 0x71, 0x71, 0x2e, 0x63, 0x6f, 0x6d, 0x30, 0x20, 0x17, 0x0d,
8797 0x32, 0x34, 0x30, 0x34, 0x32, 0x34, 0x32, 0x33, 0x35, 0x31, 0x31, 0x39,
8798 0x5a, 0x18, 0x0f, 0x32, 0x30, 0x35, 0x31, 0x30, 0x39, 0x30, 0x39, 0x32,
8799 0x33, 0x35, 0x31, 0x31, 0x39, 0x5a, 0x30, 0x52, 0x31, 0x0b, 0x30, 0x09,
8800 0x06, 0x03, 0x55, 0x04, 0x06, 0x13, 0x02, 0x4d, 0x58, 0x31, 0x0b, 0x30,
8801 0x09, 0x06, 0x03, 0x55, 0x04, 0x08, 0x0c, 0x02, 0x44, 0x46, 0x31, 0x0b,
8802 0x30, 0x09, 0x06, 0x03, 0x55, 0x04, 0x0a, 0x0c, 0x02, 0x43, 0x57, 0x31,
8803 0x0d, 0x30, 0x0b, 0x06, 0x03, 0x55, 0x04, 0x03, 0x0c, 0x04, 0x74, 0x65,
8804 0x73, 0x74, 0x31, 0x1a, 0x30, 0x18, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86,
8805 0xf7, 0x0d, 0x01, 0x09, 0x01, 0x16, 0x0b, 0x74, 0x65, 0x73, 0x74, 0x40,
8806 0x71, 0x71, 0x2e, 0x63, 0x6f, 0x6d, 0x30, 0x82, 0x01, 0x22, 0x30, 0x0d,
8807 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x01, 0x05,
8808 0x00, 0x03, 0x82, 0x01, 0x0f, 0x00, 0x30, 0x82, 0x01, 0x0a, 0x02, 0x82,
8809 0x01, 0x01, 0x00, 0xd5, 0x4d, 0x96, 0x69, 0x63, 0x59, 0x0a, 0x6e, 0x79,
8810 0x9e, 0x5a, 0x16, 0x0a, 0xb2, 0xc1, 0x2f, 0x9c, 0x73, 0x9f, 0x0d, 0x61,
8811 0xac, 0x48, 0x31, 0x04, 0x9f, 0xcb, 0x30, 0xb6, 0x47, 0xf3, 0xe3, 0x9d,
8812 0x9e, 0x96, 0xe6, 0xad, 0x2e, 0xe7, 0x40, 0x9e, 0x54, 0xe1, 0x85, 0x94,
8813 0x2f, 0xf5, 0xc4, 0x46, 0x21, 0x37, 0x57, 0xbe, 0x4f, 0x47, 0xda, 0x91,
8814 0x0b, 0xd6, 0x51, 0xe0, 0x13, 0x1c, 0x4b, 0x3f, 0xe8, 0xf2, 0xad, 0x8b,
8815 0xdb, 0xc1, 0x3d, 0xb5, 0x6c, 0x4d, 0xf7, 0x52, 0x5e, 0x67, 0x90, 0xd7,
8816 0xc8, 0xe9, 0xf5, 0x0a, 0xc1, 0x26, 0xbc, 0x00, 0x21, 0xca, 0xc1, 0xd5,
8817 0x37, 0xc2, 0xea, 0xd7, 0x82, 0x18, 0x94, 0x3e, 0xd7, 0x1a, 0x9e, 0xa6,
8818 0x77, 0x76, 0x37, 0xe8, 0x90, 0xeb, 0x4d, 0x09, 0x18, 0x6f, 0xda, 0xca,
8819 0x73, 0xbc, 0x15, 0x1f, 0xac, 0x14, 0x1f, 0xe5, 0x28, 0x3e, 0x04, 0x11,
8820 0x91, 0x71, 0x34, 0x50, 0xc4, 0xfc, 0x32, 0xb3, 0x2d, 0x0a, 0x9d, 0xa7,
8821 0x15, 0xca, 0x7a, 0xf8, 0x57, 0xc0, 0xe6, 0x92, 0x5e, 0x55, 0xa7, 0x45,
8822 0x58, 0x2b, 0xbf, 0x82, 0x23, 0x8d, 0xe4, 0xb7, 0x4a, 0xd4, 0x15, 0x44,
8823 0x80, 0x88, 0x16, 0x10, 0xcd, 0x42, 0x98, 0x46, 0xd1, 0x55, 0xa4, 0xa2,
8824 0xd8, 0xd8, 0x65, 0x33, 0x4d, 0x21, 0x6d, 0x1d, 0x11, 0x66, 0xd8, 0xa9,
8825 0xf9, 0x12, 0x42, 0x38, 0x2d, 0x36, 0x43, 0xa5, 0xe2, 0x5e, 0xff, 0x7c,
8826 0xae, 0xaa, 0xc8, 0x85, 0x42, 0xf3, 0xa0, 0x90, 0xd2, 0x04, 0xc9, 0xe4,
8827 0xa0, 0x0d, 0x97, 0xbb, 0x66, 0x8d, 0x81, 0xaa, 0x86, 0xa9, 0x49, 0x4c,
8828 0x14, 0x67, 0x02, 0xf6, 0x32, 0xde, 0x19, 0xf9, 0x14, 0xd0, 0xdb, 0x89,
8829 0xbf, 0x65, 0xc9, 0x87, 0x1d, 0xcc, 0xd3, 0x5f, 0x6a, 0xd4, 0x9d, 0x54,
8830 0x9d, 0x34, 0x08, 0xef, 0x7a, 0x77, 0x4f, 0x02, 0x03, 0x01, 0x00, 0x01,
8831 0xa3, 0x81, 0x80, 0x30, 0x7e, 0x30, 0x31, 0x06, 0x08, 0x2b, 0x06, 0x01,
8832 0x05, 0x05, 0x07, 0x01, 0x01, 0x04, 0x25, 0x30, 0x23, 0x30, 0x21, 0x06,
8833 0x08, 0x2b, 0x06, 0x01, 0x05, 0x05, 0x07, 0x30, 0x01, 0x86, 0x15, 0x68,
8834 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x31, 0x32, 0x37, 0x2e, 0x30, 0x2e,
8835 0x30, 0x2e, 0x31, 0x3a, 0x38, 0x30, 0x38, 0x30, 0x30, 0x09, 0x06, 0x03,
8836 0x55, 0x1d, 0x13, 0x04, 0x02, 0x30, 0x00, 0x30, 0x1d, 0x06, 0x03, 0x55,
8837 0x1d, 0x0e, 0x04, 0x16, 0x04, 0x14, 0x58, 0x25, 0x0b, 0x7b, 0x6c, 0xe7,
8838 0x50, 0xdf, 0x45, 0x4b, 0x35, 0x37, 0xd1, 0x84, 0x25, 0x66, 0xbb, 0xda,
8839 0x7b, 0xc5, 0x30, 0x1f, 0x06, 0x03, 0x55, 0x1d, 0x23, 0x04, 0x18, 0x30,
8840 0x16, 0x80, 0x14, 0xc4, 0x57, 0x2a, 0x53, 0xb7, 0x21, 0x6d, 0x03, 0x2d,
8841 0xd0, 0xbc, 0xd4, 0x2a, 0x88, 0xd2, 0xae, 0x62, 0xa9, 0x97, 0x2a, 0x30,
8842 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x0b,
8843 0x05, 0x00, 0x03, 0x81, 0x81, 0x00, 0xca, 0xbf, 0xb3, 0xcb, 0xf8, 0x5d,
8844 0x57, 0x25, 0xc4, 0xcd, 0xd3, 0xa2, 0xae, 0xcb, 0xc8, 0xe0, 0xd0, 0x16,
8845 0xa5, 0x54, 0x80, 0xf9, 0x6c, 0xa9, 0x4a, 0x8d, 0xa0, 0xea, 0x21, 0x6b,
8846 0xec, 0xfe, 0xa1, 0xdd, 0x48, 0x4c, 0xc0, 0x37, 0x5c, 0x36, 0x9f, 0x6d,
8847 0x3d, 0x89, 0x31, 0xc2, 0x74, 0xfd, 0xdf, 0x60, 0xa4, 0x05, 0xcb, 0x47,
8848 0xd2, 0x13, 0xa4, 0x23, 0x9f, 0xfb, 0x3c, 0x3f, 0x7a, 0x1f, 0x75, 0xfc,
8849 0x32, 0x8f, 0xbc, 0xb1, 0x3d, 0x7b, 0xef, 0x49, 0xd1, 0x47, 0x4a, 0x6d,
8850 0x6d, 0x8f, 0xd4, 0xb3, 0x71, 0x3d, 0x24, 0x48, 0x05, 0x1b, 0x29, 0xa7,
8851 0xe0, 0xbd, 0xad, 0x01, 0xff, 0x92, 0x2a, 0x24, 0x1e, 0x94, 0x6e, 0x59,
8852 0x7b, 0xd4, 0x98, 0xf0, 0x60, 0xe5, 0x69, 0xa2, 0x45, 0xaf, 0xd6, 0x7f,
8853 0x5b, 0x69, 0x84, 0x97, 0x23, 0xc7, 0xda, 0x3b, 0x37, 0xcd, 0x15, 0x4e,
8854 0x6b, 0xf0,
8855};
8856
8858{
8860 DWORD size;
8861 BOOL ret;
8862
8863 size = 0;
8866 ok(ret, "got %08lx\n", GetLastError());
8867 if (sizeof(void *) == 4) todo_wine ok(size == 496, "got %lu\n", size);
8868 else ok(size == 536, "got %lu\n", size);
8869 ok(info->ToBeSigned.cbData == sizeof(ocsp_basic_response), "got %lu\n", info->ToBeSigned.cbData);
8870 ok(!memcmp(info->ToBeSigned.pbData, ocsp_basic_response, sizeof(ocsp_basic_response)), "wrong data\n");
8871
8872 ok(!strcmp(info->SignatureInfo.SignatureAlgorithm.pszObjId, szOID_RSA_SHA256RSA),
8873 "got %s\n", info->SignatureInfo.SignatureAlgorithm.pszObjId);
8874 ok(info->SignatureInfo.SignatureAlgorithm.Parameters.cbData == 2,
8875 "got %lu\n", info->SignatureInfo.SignatureAlgorithm.Parameters.cbData);
8876 ok(info->SignatureInfo.SignatureAlgorithm.Parameters.pbData[0] == 5, "got 0x%02x\n",
8877 info->SignatureInfo.SignatureAlgorithm.Parameters.pbData[0]);
8878 ok(!info->SignatureInfo.SignatureAlgorithm.Parameters.pbData[1], "got 0x%02x\n",
8879 info->SignatureInfo.SignatureAlgorithm.Parameters.pbData[1]);
8880
8881 ok(info->SignatureInfo.Signature.cbData == sizeof(ocsp_signature), "got %lu\n",
8882 info->SignatureInfo.Signature.cbData);
8883 ok(!memcmp(info->SignatureInfo.Signature.pbData, ocsp_signature, sizeof(ocsp_signature)),
8884 "wrong signature data\n");
8885
8886 ok(!info->SignatureInfo.cCertEncoded, "got %lu\n", info->SignatureInfo.cCertEncoded);
8887 ok(!info->SignatureInfo.rgCertEncoded, "got %p\n", info->SignatureInfo.rgCertEncoded);
8888 LocalFree(info);
8889
8890 size = 0;
8893 ok(ret, "got %08lx\n", GetLastError());
8894 LocalFree(info);
8895}
8896
8898{
8899 static const BYTE resp_id[] = {
8900 0xb7, 0x6b, 0xa2, 0xea, 0xa8, 0xaa, 0x84, 0x8c, 0x79, 0xea, 0xb4, 0xda, 0x0f, 0x98, 0xb2, 0xc5,
8901 0x95, 0x76, 0xb9, 0xf4};
8902 static const BYTE resp_id2[] = {
8903 0xa4, 0x8d, 0xe5, 0xbe, 0x7c, 0x79, 0xe4, 0x70, 0x23, 0x6d, 0x2e, 0x29, 0x34, 0xad, 0x23, 0x58,
8904 0xdc, 0xf5, 0x31, 0x7f};
8905 static const BYTE resp_id3[] = {
8906 0x30, 0x32, 0x31, 0x0b, 0x30, 0x09, 0x06, 0x03, 0x55, 0x04, 0x06, 0x13, 0x02, 0x55, 0x53, 0x31,
8907 0x16, 0x30, 0x14, 0x06, 0x03, 0x55, 0x04, 0x0a, 0x13, 0x0d, 0x4c, 0x65, 0x74, 0x27, 0x73, 0x20,
8908 0x45, 0x6e, 0x63, 0x72, 0x79, 0x70, 0x74, 0x31, 0x0b, 0x30, 0x09, 0x06, 0x03, 0x55, 0x04, 0x03,
8909 0x13, 0x02, 0x52, 0x33};
8910 static const BYTE name_hash[] = {
8911 0xe4, 0xe3, 0x95, 0xa2, 0x29, 0xd3, 0xd4, 0xc1, 0xc3, 0x1f, 0xf0, 0x98, 0x0c, 0x0b, 0x4e, 0xc0,
8912 0x09, 0x8a, 0xab, 0xd8};
8913 static const BYTE name_hash2[] = {
8914 0x74, 0xb4, 0xe7, 0x23, 0x19, 0xc7, 0x65, 0x92, 0x15, 0x40, 0x44, 0x7b, 0xc7, 0xce, 0x3e, 0x90,
8915 0xc2, 0x18, 0x76, 0xeb};
8916 static const BYTE name_hash3[] = {
8917 0x48, 0xda, 0xc9, 0xa0, 0xfb, 0x2b, 0xd3, 0x2d, 0x4f, 0xf0, 0xde, 0x68, 0xd2, 0xf5, 0x67, 0xb7,
8918 0x35, 0xf9, 0xb3, 0xc4};
8919 static const BYTE key_hash[] = {
8920 0xb7, 0x6b, 0xa2, 0xea, 0xa8, 0xaa, 0x84, 0x8c, 0x79, 0xea, 0xb4, 0xda, 0x0f, 0x98, 0xb2, 0xc5,
8921 0x95, 0x76, 0xb9, 0xf4};
8922 static const BYTE key_hash2[] = {
8923 0xa4, 0x8d, 0xe5, 0xbe, 0x7c, 0x79, 0xe4, 0x70, 0x23, 0x6d, 0x2e, 0x29, 0x34, 0xad, 0x23, 0x58,
8924 0xdc, 0xf5, 0x31, 0x7f};
8925 static const BYTE key_hash3[] = {
8926 0x14, 0x2e, 0xb3, 0x17, 0xb7, 0x58, 0x56, 0xcb, 0xae, 0x50, 0x09, 0x40, 0xe6, 0x1f, 0xaf, 0x9d,
8927 0x8b, 0x14, 0xc2, 0xc6};
8928 static const BYTE serial[] = {
8929 0xb1, 0xc1, 0x87, 0x54, 0x54, 0xac, 0x1e, 0x55, 0x40, 0xfb, 0xef, 0xd9, 0x6d, 0x8f, 0x49, 0x08};
8930 static const BYTE serial2[] = {
8931 0x2f, 0x57, 0xa4, 0x85, 0xa2, 0xe3, 0x52, 0x54, 0x9a, 0x3b, 0x85, 0x98, 0xa2, 0x67, 0x2e, 0x0d};
8932 static const BYTE serial3[] = {
8933 0x5b, 0x83, 0x59, 0xcd, 0xb9, 0x89, 0x9d, 0x83, 0xae, 0xef, 0x13, 0x8c, 0xf3, 0x80, 0x82, 0x1c,
8934 0x26, 0x03};
8937 OCSP_BASIC_REVOKED_INFO *revoked;
8938 DWORD size;
8939 BOOL ret;
8940
8941 /* good cert */
8942 size = 0;
8945 ok(ret, "got %08lx\n", GetLastError());
8946
8947 ok(!info->dwVersion, "got %lu\n", info->dwVersion);
8948 ok(info->dwResponderIdChoice == 2, "got %lu\n", info->dwResponderIdChoice);
8949 ok(info->ByKeyResponderId.cbData == sizeof(resp_id), "got %lu\n", info->ByKeyResponderId.cbData);
8950 ok(!memcmp(info->ByKeyResponderId.pbData, resp_id, sizeof(resp_id)), "wrong data\n");
8951 ok(info->ProducedAt.dwLowDateTime == 3438583808, "got %lu\n", info->ProducedAt.dwLowDateTime);
8952 ok(info->ProducedAt.dwHighDateTime == 30946477, "got %lu\n", info->ProducedAt.dwHighDateTime);
8953 ok(info->cResponseEntry == 1, "got %lu\n", info->cResponseEntry);
8954 ok(info->rgResponseEntry != NULL, "got %p\n", info->rgResponseEntry);
8955
8956 entry = info->rgResponseEntry;
8957 ok(!strcmp(entry->CertId.HashAlgorithm.pszObjId, szOID_OIWSEC_sha1), "got '%s'\n", entry->CertId.HashAlgorithm.pszObjId);
8958 ok(entry->CertId.HashAlgorithm.Parameters.cbData == 2, "got %lu\n", entry->CertId.HashAlgorithm.Parameters.cbData);
8959 ok(entry->CertId.HashAlgorithm.Parameters.pbData[0] == 5, "got 0x%02x\n", entry->CertId.HashAlgorithm.Parameters.pbData[0]);
8960 ok(!entry->CertId.HashAlgorithm.Parameters.pbData[1], "got 0x%02x\n", entry->CertId.HashAlgorithm.Parameters.pbData[1]);
8961 ok(entry->CertId.IssuerNameHash.cbData == sizeof(name_hash), "got %lu\n", entry->CertId.IssuerNameHash.cbData);
8962 ok(!memcmp(entry->CertId.IssuerNameHash.pbData, name_hash, sizeof(name_hash)), "wrong data\n");
8963 ok(entry->CertId.IssuerKeyHash.cbData == sizeof(key_hash), "got %lu\n", entry->CertId.IssuerKeyHash.cbData);
8964 ok(!memcmp(entry->CertId.IssuerKeyHash.pbData, key_hash, sizeof(key_hash)), "wrong data\n");
8965 ok(entry->CertId.SerialNumber.cbData == sizeof(serial), "got %lu\n", entry->CertId.SerialNumber.cbData);
8966 ok(!memcmp(entry->CertId.SerialNumber.pbData, serial, sizeof(serial)), "wrong data\n");
8967 ok(entry->dwCertStatus == 0, "got %lu\n", entry->dwCertStatus);
8968 ok(entry->pRevokedInfo == NULL, "got %p\n", entry->pRevokedInfo);
8969 ok(entry->ThisUpdate.dwLowDateTime == 2558518400, "got %lu\n", entry->ThisUpdate.dwLowDateTime);
8970 ok(entry->ThisUpdate.dwHighDateTime == 30946475, "got %lu\n", entry->ThisUpdate.dwHighDateTime);
8971 ok(entry->NextUpdate.dwLowDateTime == 2014369408, "got %lu\n", entry->NextUpdate.dwLowDateTime);
8972 ok(entry->NextUpdate.dwHighDateTime == 30947877, "got %lu\n", entry->NextUpdate.dwHighDateTime);
8973 ok(!entry->cExtension, "got %lu\n", entry->cExtension);
8974 ok(entry->rgExtension == NULL, "got %p\n", entry->rgExtension);
8975
8976 ok(!info->cExtension, "got %lu\n", info->cExtension);
8977 ok(info->rgExtension == NULL, "got %p\n", info->rgExtension);
8978 LocalFree(info);
8979
8980 /* revoked cert */
8981 size = 0;
8984 ok(ret, "got %08lx\n", GetLastError());
8985
8986 ok(!info->dwVersion, "got %lu\n", info->dwVersion);
8987 ok(info->dwResponderIdChoice == 2, "got %lu\n", info->dwResponderIdChoice);
8988 ok(info->ByKeyResponderId.cbData == sizeof(resp_id), "got %lu\n", info->ByKeyResponderId.cbData);
8989 ok(!memcmp(info->ByKeyResponderId.pbData, resp_id2, sizeof(resp_id2)), "wrong data\n");
8990 ok(info->ProducedAt.dwLowDateTime == 647048832, "got %lu\n", info->ProducedAt.dwLowDateTime);
8991 ok(info->ProducedAt.dwHighDateTime == 30950558, "got %lu\n", info->ProducedAt.dwHighDateTime);
8992 ok(info->cResponseEntry == 1, "got %lu\n", info->cResponseEntry);
8993 ok(info->rgResponseEntry != NULL, "got %p\n", info->rgResponseEntry);
8994
8995 entry = info->rgResponseEntry;
8996 ok(!strcmp(entry->CertId.HashAlgorithm.pszObjId, szOID_OIWSEC_sha1), "got '%s'\n", entry->CertId.HashAlgorithm.pszObjId);
8997 ok(entry->CertId.HashAlgorithm.Parameters.cbData == 2, "got %lu\n", entry->CertId.HashAlgorithm.Parameters.cbData);
8998 ok(entry->CertId.HashAlgorithm.Parameters.pbData[0] == 5, "got 0x%02x\n", entry->CertId.HashAlgorithm.Parameters.pbData[0]);
8999 ok(!entry->CertId.HashAlgorithm.Parameters.pbData[1], "got 0x%02x\n", entry->CertId.HashAlgorithm.Parameters.pbData[1]);
9000 ok(entry->CertId.IssuerNameHash.cbData == sizeof(name_hash2), "got %lu\n", entry->CertId.IssuerNameHash.cbData);
9001 ok(!memcmp(entry->CertId.IssuerNameHash.pbData, name_hash2, sizeof(name_hash2)), "wrong data\n");
9002 ok(entry->CertId.IssuerKeyHash.cbData == sizeof(key_hash2), "got %lu\n", entry->CertId.IssuerKeyHash.cbData);
9003 ok(!memcmp(entry->CertId.IssuerKeyHash.pbData, key_hash2, sizeof(key_hash2)), "wrong data\n");
9004 ok(entry->CertId.SerialNumber.cbData == sizeof(serial2), "got %lu\n", entry->CertId.SerialNumber.cbData);
9005 ok(!memcmp(entry->CertId.SerialNumber.pbData, serial2, sizeof(serial2)), "wrong data\n");
9006 ok(entry->dwCertStatus == 1, "got %lu\n", entry->dwCertStatus);
9007 ok(entry->pRevokedInfo != NULL, "got NULL\n");
9008
9009 revoked = entry->pRevokedInfo;
9010 ok(revoked->RevocationDate.dwLowDateTime == 107865088, "got %lu\n", revoked->RevocationDate.dwLowDateTime);
9011 ok(revoked->RevocationDate.dwHighDateTime == 30919547, "got %lu\n", revoked->RevocationDate.dwHighDateTime);
9012 ok(!revoked->dwCrlReasonCode, "got %lu\n", revoked->dwCrlReasonCode);
9013
9014 ok(entry->ThisUpdate.dwLowDateTime == 3891950720, "got %lu\n", entry->ThisUpdate.dwLowDateTime);
9015 ok(entry->ThisUpdate.dwHighDateTime == 30950555, "got %lu\n", entry->ThisUpdate.dwHighDateTime);
9016 ok(entry->NextUpdate.dwLowDateTime == 3347801728, "got %lu\n", entry->NextUpdate.dwLowDateTime);
9017 ok(entry->NextUpdate.dwHighDateTime == 30951957, "got %lu\n", entry->NextUpdate.dwHighDateTime);
9018 ok(!entry->cExtension, "got %lu\n", entry->cExtension);
9019 ok(entry->rgExtension == NULL, "got %p\n", entry->rgExtension);
9020
9021 ok(!info->cExtension, "got %lu\n", info->cExtension);
9022 ok(info->rgExtension == NULL, "got %p\n", info->rgExtension);
9023 LocalFree(info);
9024
9025 size = 0;
9028 ok(ret, "got %08lx\n", GetLastError());
9029
9030 ok(!info->dwVersion, "got %lu\n", info->dwVersion);
9031 ok(info->dwResponderIdChoice == 1, "got %lu\n", info->dwResponderIdChoice);
9032 ok(info->ByNameResponderId.cbData == sizeof(resp_id3), "got %lu\n", info->ByNameResponderId.cbData);
9033 ok(!memcmp(info->ByNameResponderId.pbData, resp_id3, sizeof(resp_id3)), "wrong data\n");
9034
9035 ok(info->ProducedAt.dwLowDateTime == 1408824832, "got %lu\n", info->ProducedAt.dwLowDateTime);
9036 ok(info->ProducedAt.dwHighDateTime == 30991433, "got %lu\n", info->ProducedAt.dwHighDateTime);
9037 ok(info->cResponseEntry == 1, "got %lu\n", info->cResponseEntry);
9038 ok(info->rgResponseEntry != NULL, "got %p\n", info->rgResponseEntry);
9039
9040 entry = info->rgResponseEntry;
9041 ok(!strcmp(entry->CertId.HashAlgorithm.pszObjId, szOID_OIWSEC_sha1), "got '%s'\n", entry->CertId.HashAlgorithm.pszObjId);
9042 ok(entry->CertId.HashAlgorithm.Parameters.cbData == 2, "got %lu\n", entry->CertId.HashAlgorithm.Parameters.cbData);
9043 ok(entry->CertId.HashAlgorithm.Parameters.pbData[0] == 5, "got 0x%02x\n", entry->CertId.HashAlgorithm.Parameters.pbData[0]);
9044 ok(!entry->CertId.HashAlgorithm.Parameters.pbData[1], "got 0x%02x\n", entry->CertId.HashAlgorithm.Parameters.pbData[1]);
9045 ok(entry->CertId.IssuerNameHash.cbData == sizeof(name_hash3), "got %lu\n", entry->CertId.IssuerNameHash.cbData);
9046 ok(!memcmp(entry->CertId.IssuerNameHash.pbData, name_hash3, sizeof(name_hash3)), "wrong data\n");
9047
9048 ok(entry->CertId.IssuerKeyHash.cbData == sizeof(key_hash3), "got %lu\n", entry->CertId.IssuerKeyHash.cbData);
9049 ok(!memcmp(entry->CertId.IssuerKeyHash.pbData, key_hash3, sizeof(key_hash3)), "wrong data\n");
9050 ok(entry->CertId.SerialNumber.cbData == sizeof(serial3), "got %lu\n", entry->CertId.SerialNumber.cbData);
9051 ok(!memcmp(entry->CertId.SerialNumber.pbData, serial3, sizeof(serial3)), "wrong data\n");
9052 ok(entry->dwCertStatus == 0, "got %lu\n", entry->dwCertStatus);
9053 ok(entry->pRevokedInfo == NULL, "got %p\n", entry->pRevokedInfo);
9054 ok(entry->ThisUpdate.dwLowDateTime == 808824832, "got %lu\n", entry->ThisUpdate.dwLowDateTime);
9055 ok(entry->ThisUpdate.dwHighDateTime == 30991433, "got %lu\n", entry->ThisUpdate.dwHighDateTime);
9056 ok(entry->NextUpdate.dwLowDateTime == 1474872064, "got %lu\n", entry->NextUpdate.dwLowDateTime);
9057 ok(entry->NextUpdate.dwHighDateTime == 30992841, "got %lu\n", entry->NextUpdate.dwHighDateTime);
9058 ok(!entry->cExtension, "got %lu\n", entry->cExtension);
9059 ok(entry->rgExtension == NULL, "got %p\n", entry->rgExtension);
9060
9061 ok(!info->cExtension, "got %lu\n", info->cExtension);
9062 ok(info->rgExtension == NULL, "got %p\n", info->rgExtension);
9063 LocalFree(info);
9064}
9065
9067{
9068 static const DWORD encodings[] = { X509_ASN_ENCODING, PKCS_7_ASN_ENCODING,
9070 DWORD i;
9071
9072 for (i = 0; i < ARRAY_SIZE(encodings); i++)
9073 {
9074 test_encodeInt(encodings[i]);
9075 test_decodeInt(encodings[i]);
9076 test_encodeEnumerated(encodings[i]);
9077 test_decodeEnumerated(encodings[i]);
9078 test_encodeFiletime(encodings[i]);
9079 test_decodeFiletime(encodings[i]);
9080 test_encodeName(encodings[i]);
9081 test_decodeName(encodings[i]);
9082 test_encodeUnicodeName(encodings[i]);
9083 test_decodeUnicodeName(encodings[i]);
9084 test_encodeNameValue(encodings[i]);
9085 test_decodeNameValue(encodings[i]);
9086 test_encodeUnicodeNameValue(encodings[i]);
9087 test_decodeUnicodeNameValue(encodings[i]);
9088 test_encodeAltName(encodings[i]);
9089 test_decodeAltName(encodings[i]);
9090 test_encodeOctets(encodings[i]);
9091 test_decodeOctets(encodings[i]);
9092 test_encodeBits(encodings[i]);
9093 test_decodeBits(encodings[i]);
9094 test_encodeBasicConstraints(encodings[i]);
9095 test_decodeBasicConstraints(encodings[i]);
9096 test_encodeRsaPublicKey(encodings[i]);
9097 test_decodeRsaPublicKey(encodings[i]);
9100 test_encodeSequenceOfAny(encodings[i]);
9101 test_decodeSequenceOfAny(encodings[i]);
9102 test_encodeExtensions(encodings[i]);
9103 test_decodeExtensions(encodings[i]);
9104 test_encodePublicKeyInfo(encodings[i]);
9105 test_decodePublicKeyInfo(encodings[i]);
9106 test_encodeCertToBeSigned(encodings[i]);
9107 test_decodeCertToBeSigned(encodings[i]);
9108 test_encodeCert(encodings[i]);
9109 test_decodeCert(encodings[i]);
9110 test_encodeCRLDistPoints(encodings[i]);
9111 test_decodeCRLDistPoints(encodings[i]);
9114 test_encodeCRLToBeSigned(encodings[i]);
9115 test_decodeCRLToBeSigned(encodings[i]);
9116 test_encodeEnhancedKeyUsage(encodings[i]);
9117 test_decodeEnhancedKeyUsage(encodings[i]);
9118 test_encodeAuthorityKeyId(encodings[i]);
9119 test_decodeAuthorityKeyId(encodings[i]);
9120 test_encodeAuthorityKeyId2(encodings[i]);
9121 test_decodeAuthorityKeyId2(encodings[i]);
9124 test_encodeCTL(encodings[i]);
9125 test_decodeCTL(encodings[i]);
9126 test_encodePKCSContentInfo(encodings[i]);
9127 test_decodePKCSContentInfo(encodings[i]);
9128 test_encodePKCSAttribute(encodings[i]);
9129 test_decodePKCSAttribute(encodings[i]);
9130 test_encodePKCSAttributes(encodings[i]);
9131 test_decodePKCSAttributes(encodings[i]);
9134 test_encodePKCSSignerInfo(encodings[i]);
9135 test_decodePKCSSignerInfo(encodings[i]);
9136 test_encodeCMSSignerInfo(encodings[i]);
9137 test_decodeCMSSignerInfo(encodings[i]);
9138 test_encodeNameConstraints(encodings[i]);
9139 test_decodeNameConstraints(encodings[i]);
9142 test_encodeCertPolicies(encodings[i]);
9143 test_decodeCertPolicies(encodings[i]);
9144 test_encodeCertPolicyMappings(encodings[i]);
9145 test_decodeCertPolicyMappings(encodings[i]);
9148 test_decodeRsaPrivateKey(encodings[i]);
9149#ifdef __REACTOS__
9150 if ((GetVersion() & 0xFF) > 5) // These tests crash on Server 2003
9151 {
9152#endif
9153 test_encodeOCSPRequestInfo(encodings[i]);
9154 test_decodeOCSPResponseInfo(encodings[i]);
9157#ifdef __REACTOS__
9158 }
9159#endif
9160 }
9162}
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
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
WINBASEAPI _Check_return_ _Out_ AppPolicyProcessTerminationMethod * policy
Definition: appmodel.h:73
#define ok(value,...)
Definition: atltest.h:57
#define START_TEST(x)
Definition: atltest.h:75
#define ARRAY_SIZE(A)
Definition: main.h:20
NTSTATUS WINAPI BCryptDestroyKey(BCRYPT_KEY_HANDLE)
struct _BCRYPT_RSAKEY_BLOB BCRYPT_RSAKEY_BLOB
#define BCRYPT_RSAPUBLIC_MAGIC
Definition: bcrypt.h:133
_In_ fcb _In_ chunk _In_ uint64_t _In_ uint64_t _In_ bool _In_opt_ void _In_opt_ PIRP _In_ LIST_ENTRY _In_ uint8_t _In_ uint64_t decoded_size
Definition: btrfs_drv.h:1365
BOOL WINAPI CryptDecodeObjectEx(DWORD dwCertEncodingType, LPCSTR lpszStructType, const BYTE *pbEncoded, DWORD cbEncoded, DWORD dwFlags, PCRYPT_DECODE_PARA pDecodePara, void *pvStructInfo, DWORD *pcbStructInfo)
Definition: decode.c:6286
#define ERROR_MORE_DATA
Definition: dderror.h:13
#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
BOOL WINAPI CryptDestroyKey(HCRYPTKEY hKey)
Definition: crypt.c:930
BOOL WINAPI CryptReleaseContext(HCRYPTPROV hProv, DWORD dwFlags)
Definition: crypt.c:648
BOOL WINAPI CryptAcquireContextA(HCRYPTPROV *phProv, LPCSTR pszContainer, LPCSTR pszProvider, DWORD dwProvType, DWORD dwFlags)
Definition: crypt.c:569
BOOL WINAPI CryptGenKey(HCRYPTPROV hProv, ALG_ID Algid, DWORD dwFlags, HCRYPTKEY *phKey)
Definition: crypt.c:1451
BOOL WINAPI CryptGetKeyParam(HCRYPTKEY hKey, DWORD dwParam, BYTE *pbData, DWORD *pdwDataLen, DWORD dwFlags)
Definition: crypt.c:1649
content
Definition: atl_ax.c:994
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 CryptExportPublicKeyInfoEx(HCRYPTPROV_OR_NCRYPT_KEY_HANDLE hCryptProv, DWORD dwKeySpec, DWORD dwCertEncodingType, LPSTR pszPublicKeyObjId, DWORD dwFlags, void *pvAuxInfo, PCERT_PUBLIC_KEY_INFO pInfo, DWORD *pcbInfo)
Definition: encode.c:4934
BOOL WINAPI CryptEncodeObjectEx(DWORD dwCertEncodingType, LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, PCRYPT_ENCODE_PARA pEncodePara, void *pvEncoded, DWORD *pcbEncoded)
Definition: encode.c:4696
BOOL WINAPI CryptImportPublicKeyInfoEx(HCRYPTPROV hCryptProv, DWORD dwCertEncodingType, PCERT_PUBLIC_KEY_INFO pInfo, ALG_ID aiKeyAlg, DWORD dwFlags, void *pvAuxInfo, HCRYPTKEY *phKey)
Definition: encode.c:5044
static WCHAR aia[MAX_STRING_RESOURCE_LEN]
Definition: object.c:1601
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
#define SetLastError(x)
Definition: compat.h:752
#define lstrlenW
Definition: compat.h:750
static const WCHAR *const ext[]
Definition: module.c:53
BOOL WINAPI FileTimeToSystemTime(IN CONST FILETIME *lpFileTime, OUT LPSYSTEMTIME lpSystemTime)
Definition: time.c:188
BOOL WINAPI SystemTimeToFileTime(IN CONST SYSTEMTIME *lpSystemTime, OUT LPFILETIME lpFileTime)
Definition: time.c:158
int WINAPI lstrcmpW(LPCWSTR str1, LPCWSTR str2)
Definition: locale.c:4246
DWORD WINAPI GetVersion(void)
Definition: version.c:1458
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31
return ret
Definition: mutex.c:146
#define L(x)
Definition: resources.c:13
POINTL point
Definition: edittest.c:50
#define abs(i)
Definition: fconv.c:206
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
#define STATUS_ACCESS_VIOLATION
uint32_t serial
Definition: fsck.fat.h:29
GLenum src
Definition: glext.h:6340
GLsizeiptr size
Definition: glext.h:5919
GLenum const GLfloat * params
Definition: glext.h:5645
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
GLint reference
Definition: glext.h:11729
GLenum GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * bits
Definition: glext.h:10929
GLenum GLenum dst
Definition: glext.h:6340
GLuint GLfloat * val
Definition: glext.h:7180
GLenum GLenum GLenum GLenum mapping
Definition: glext.h:9031
GLenum GLsizei len
Definition: glext.h:6722
GLuint GLsizei bufSize
Definition: glext.h:6040
GLsizeiptr const GLvoid GLenum usage
Definition: glext.h:5919
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
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 GLint GLint j
Definition: glfuncs.h:250
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1594
#define stderr
Definition: stdio.h:100
_Check_return_opt_ _CRTIMP int __cdecl fprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format,...)
char hdr[14]
Definition: iptest.cpp:33
uint32_t entry
Definition: isohybrid.c:63
int WINAPI lstrlenA(LPCSTR lpString)
Definition: lstring.c:145
#define todo_wine
Definition: minitest.h:80
__u16 time
Definition: mkdosfs.c:8
#define error(str)
Definition: mkdosfs.c:1605
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:56
static PVOID ptr
Definition: dispmode.c:27
static struct test_info tests[]
#define sprintf
Definition: sprintf.c:45
static char org[]
Definition: encode.c:7395
static const BYTE distPointWithIssuer[]
Definition: encode.c:3563
static void test_decodeCertToBeSigned(DWORD dwEncoding)
Definition: encode.c:3260
static BYTE oneGraphic[]
Definition: encode.c:1721
static const BYTE mod2_encoded[]
Definition: encode.c:2325
static const BYTE policyConstraintsWithRequireExplicit[]
Definition: encode.c:7801
static const char surName[]
Definition: encode.c:656
static void test_decodeOctets(DWORD dwEncoding)
Definition: encode.c:1952
static const BYTE rsaPrivKeyDer[]
Definition: encode.c:7944
static const BYTE bin8[]
Definition: encode.c:69
static void compareRDNs(const CERT_RDN *expected, const CERT_RDN *got)
Definition: encode.c:989
static const BYTE indefiniteSignedPKCSContent[]
Definition: encode.c:6014
static CERT_EXTENSION nonCriticalExt
Definition: encode.c:2725
static void test_encodeEnumerated(DWORD dwEncoding)
Definition: encode.c:372
static struct EncodedNameValue embeddedNullNameValue
Definition: encode.c:1264
static const unsigned char encoded_empty_octet[]
Definition: encode.c:1894
void CRYPT_CopyReversed(BYTE *dst, const BYTE *src, size_t len)
Definition: encode.c:30
static void test_encodeName(DWORD dwEncoding)
Definition: encode.c:726
static void test_encodePolicyQualifierUserNotice(DWORD dwEncoding)
Definition: encode.c:7404
static const unsigned char bin53[]
Definition: encode.c:2037
static const BYTE bin43[]
Definition: encode.c:1198
static void test_decodeAuthorityKeyId(DWORD dwEncoding)
Definition: encode.c:4992
static const unsigned char encoded_constructed_hi_octet[]
Definition: encode.c:1943
static void test_decodeName(DWORD dwEncoding)
Definition: encode.c:1022
static const BYTE ext1[]
Definition: encode.c:2732
static const BYTE v1CRL[]
Definition: encode.c:3985
static const BYTE ocsp_signature[]
Definition: encode.c:8716
static void test_encodeAltName(DWORD dwEncoding)
Definition: encode.c:1401
static BYTE nihongoT61[]
Definition: encode.c:1727
static const struct EncodedRSAPubKey rsaPubKeys[]
Definition: encode.c:2337
static const BYTE encodedIPAddr[]
Definition: encode.c:1392
static const unsigned char bin59[]
Definition: encode.c:2139
static void test_encodeInt(DWORD dwEncoding)
Definition: encode.c:93
static void testTimeEncoding(DWORD dwEncoding, LPCSTR structType, const struct encodedFiletime *time)
Definition: encode.c:435
static void test_decodeCTL(DWORD dwEncoding)
Definition: encode.c:5780
static const char cspName[]
Definition: encode.c:8397
static void test_encodeRsaPublicKey(DWORD dwEncoding)
Definition: encode.c:2344
static void test_decodeCRLIssuingDistPoint(DWORD dwEncoding)
Definition: encode.c:3931
static const BYTE bin35[]
Definition: encode.c:583
static void test_decodeOCSPBasicSignedResponseInfo(DWORD dwEncoding)
Definition: encode.c:8857
static const BYTE emptyPKCSContentInfo[]
Definition: encode.c:5953
static const BYTE badFlagsIDP[]
Definition: encode.c:3790
static const unsigned char bin65[]
Definition: encode.c:2838
static const BYTE emptyPKCSContentInfoExtraBytes[]
Definition: encode.c:5954
static const BYTE noticeWithDisplayText[]
Definition: encode.c:7390
static const BYTE emptyCTL[]
Definition: encode.c:5405
static void compareDistPointName(const CRL_DIST_POINT_NAME *expected, const CRL_DIST_POINT_NAME *got)
Definition: encode.c:3908
static const BYTE twoRDNsExtraBytes[]
Definition: encode.c:1017
static void test_decodeCertPolicyMappings(DWORD dwEncoding)
Definition: encode.c:7728
static const BYTE bin6[]
Definition: encode.c:49
static const BYTE v3Cert[]
Definition: encode.c:2984
static void test_decodePKCSAttributes(DWORD dwEncoding)
Definition: encode.c:6298
static const BYTE doublePKCSAttributes[]
Definition: encode.c:6243
static const BYTE mod4_encoded[]
Definition: encode.c:2327
static const BYTE ocsp_response[]
Definition: encode.c:8549
static const BYTE bin33[]
Definition: encode.c:579
static const WCHAR dnsName[]
Definition: encode.c:1388
static const unsigned char bin63[]
Definition: encode.c:2225
static const BYTE bin38[]
Definition: encode.c:589
static void compareSMimeCapabilities(LPCSTR header, const CRYPT_SMIME_CAPABILITIES *expected, const CRYPT_SMIME_CAPABILITIES *got)
Definition: encode.c:6430
static void test_decodeOCSPResponseInfo(DWORD dwEncoding)
Definition: encode.c:8596
static const BYTE wine[]
Definition: encode.c:678
static BYTE nihongoUTF8[]
Definition: encode.c:1733
static const BYTE ctlWithOneEntry[]
Definition: encode.c:5434
static const BYTE bin27[]
Definition: encode.c:567
static const char * printFileTime(const FILETIME *ft)
Definition: encode.c:482
static const BYTE policyMappingWithTwoMappings[]
Definition: encode.c:7658
static char embedded_null[]
Definition: encode.c:1223
static const BYTE v2CRLWithExt[]
Definition: encode.c:4022
static const BYTE CMSSignerWithKeyId[]
Definition: encode.c:6855
static const BYTE bin19[]
Definition: encode.c:356
static const unsigned char bin68[]
Definition: encode.c:2844
static const BYTE encodedTwoRDNs[]
Definition: encode.c:664
static void test_encodePKCSAttribute(DWORD dwEncoding)
Definition: encode.c:6136
static char oid_any_policy[]
Definition: encode.c:7508
static const BYTE ocsp_basic_response[]
Definition: encode.c:8661
static const BYTE policyMappingWithOneMapping[]
Definition: encode.c:7656
static const BYTE minimalPKCSSigner[]
Definition: encode.c:6539
static BYTE generalCommonNameValue[]
Definition: encode.c:1216
static const BYTE bin36[]
Definition: encode.c:585
static const BYTE bin13[]
Definition: encode.c:75
static const BYTE bin4[]
Definition: encode.c:47
static void test_encodePKCSSMimeCapabilities(DWORD dwEncoding)
Definition: encode.c:6374
static const BYTE ctlWithUsageIdentifier[]
Definition: encode.c:5411
static CERT_GENERAL_SUBTREE IPAddressWithMinSubtree
Definition: encode.c:7308
static const BYTE bin21[]
Definition: encode.c:536
static BYTE crit_ext_data[]
Definition: encode.c:2720
static void test_decodeCMSSignerInfo(DWORD dwEncoding)
Definition: encode.c:7017
static const BYTE bytesToEncode[]
Definition: encode.c:2026
static CERT_GENERAL_SUBTREE DNSSubtree
Definition: encode.c:7304
static const BYTE serialNum[]
Definition: encode.c:3081
static void test_encodeCTL(DWORD dwEncoding)
Definition: encode.c:5445
static void compareRDNAttrs(const CERT_RDN_ATTR *expected, const CERT_RDN_ATTR *got)
Definition: encode.c:971
static void test_decodeNameValue(DWORD dwEncoding)
Definition: encode.c:1318
static const BYTE twoPolicies[]
Definition: encode.c:7514
static const BYTE bin32[]
Definition: encode.c:577
static const BYTE bin11[]
Definition: encode.c:73
static const BYTE bigCert[]
Definition: encode.c:3008
static const BYTE rsaPrivKeyPrime1[]
Definition: encode.c:8068
static BYTE emptyDNSPermittedConstraints[]
Definition: encode.c:7172
static const BYTE intPKCSAttr[]
Definition: encode.c:6133
static void compareAltNameInfo(const CERT_ALT_NAME_INFO *expected, const CERT_ALT_NAME_INFO *got)
Definition: encode.c:3897
static const BYTE modulus1[]
Definition: encode.c:2320
static const BYTE hash[]
Definition: encode.c:3387
static const struct encodedInt enums[]
Definition: encode.c:361
static CERT_RDN_ATTR decodedRdnAttrs[]
Definition: encode.c:702
static const BYTE v1Cert[]
Definition: encode.c:2974
static BYTE ia5CommonNameValue[]
Definition: encode.c:1210
static const BYTE modulus4[]
Definition: encode.c:2323
static void compareNameValues(const CERT_NAME_VALUE *expected, const CERT_NAME_VALUE *got)
Definition: encode.c:955
static const BYTE emptyCTLWithVersion1[]
Definition: encode.c:5408
static BYTE emptyDNSExcludedConstraints[]
Definition: encode.c:7174
static const BYTE ext2[]
Definition: encode.c:2734
static const unsigned char encoded_constructed_hi_octet_invalid_end[]
Definition: encode.c:1949
static const BYTE mod3_encoded[]
Definition: encode.c:2326
static void test_encodeExtensions(DWORD dwEncoding)
Definition: encode.c:2745
static CERT_EXTENSION extWithShortOid
Definition: encode.c:2728
static void test_decodePKCSAttribute(DWORD dwEncoding)
Definition: encode.c:6191
static void test_encodeCertPolicyConstraints(DWORD dwEncoding)
Definition: encode.c:7808
static const unsigned char encoded_something_long_octet[]
Definition: encode.c:1892
static void test_encodeOCSPRequestInfo(DWORD dwEncoding)
Definition: encode.c:8422
static const LPCSTR enumeratedTypes[]
Definition: encode.c:369
static const unsigned char bin71[]
Definition: encode.c:2854
static const BYTE content_constructed_abcd[]
Definition: encode.c:6057
static void test_decodeBasicConstraints(DWORD dwEncoding)
Definition: encode.c:2227
static const unsigned char encodedCommonName[]
Definition: encode.c:1394
static const BYTE v2CRL[]
Definition: encode.c:3988
static BYTE onePrintable[]
Definition: encode.c:1717
static const BYTE emptyDistPoint[]
Definition: encode.c:3557
static void test_decodePublicKeyInfo(DWORD dwEncoding)
Definition: encode.c:2931
static char oid_user_notice[]
Definition: encode.c:7513
static void test_encodeCertPolicies(DWORD dwEncoding)
Definition: encode.c:7523
static const BYTE twoRDNsNoNull[]
Definition: encode.c:848
static const BYTE bin5[]
Definition: encode.c:48
static const BYTE emptyIndefiniteSequence[]
Definition: encode.c:1016
static void test_decodeAuthorityKeyId2(DWORD dwEncoding)
Definition: encode.c:5141
static struct UnicodeExpectedError unicodeErrors[]
Definition: encode.c:1700
static CHAR oid_basic_constraints2[]
Definition: encode.c:2722
static void test_decodeCRLDistPoints(DWORD dwEncoding)
Definition: encode.c:3665
static const BYTE v1CertWithSubjectIssuerSerialAndIssuerUniqueId[]
Definition: encode.c:3056
static const BYTE authorityInfoAccessWithUrl[]
Definition: encode.c:5227
static const BYTE authorityKeyIdWithIssuer[]
Definition: encode.c:4928
static void test_decodePKCSSignerInfo(DWORD dwEncoding)
Definition: encode.c:6730
static const BYTE ctlWithThisAndNextUpdate[]
Definition: encode.c:5423
static const LPCSTR mappingOids[]
Definition: encode.c:7661
static const BYTE bin26[]
Definition: encode.c:565
static const BYTE PKCSSignerWithHashAndEncryptionAlgo[]
Definition: encode.c:6553
static const BYTE intPKCSContentInfo[]
Definition: encode.c:5958
static BYTE DNSExcludedConstraints[]
Definition: encode.c:7176
static void test_encodeCert(DWORD dwEncoding)
Definition: encode.c:3462
static const BYTE verisignCRL[]
Definition: encode.c:4146
static const BYTE singleCapabilitywithNULL[]
Definition: encode.c:6371
static const BYTE ctlWithTwoEntries[]
Definition: encode.c:5438
static const BYTE signedCTL[]
Definition: encode.c:5744
static const BYTE ocsp_basic_response2[]
Definition: encode.c:8678
static const BYTE modulus2[]
Definition: encode.c:2321
static const BYTE emptyPKCSAttributes[]
Definition: encode.c:6240
static const BYTE minnesota[]
Definition: encode.c:672
static const BYTE bin30[]
Definition: encode.c:573
static void compareCRLIssuingDistPoints(const CRL_ISSUING_DIST_POINT *expected, const CRL_ISSUING_DIST_POINT *got)
Definition: encode.c:3917
static void test_decodeInt(DWORD dwEncoding)
Definition: encode.c:205
static const BYTE modulus3[]
Definition: encode.c:2322
static const BYTE ocsp_basic_signed_response_with_cert[]
Definition: encode.c:8741
static void test_decodeCertPolicies(DWORD dwEncoding)
Definition: encode.c:7578
static const BYTE ocsp_basic_response_revoked[]
Definition: encode.c:8698
static int noticeNumbers[]
Definition: encode.c:7396
static const BYTE bin10[]
Definition: encode.c:71
static void test_decodeBits(DWORD dwEncoding)
Definition: encode.c:2080
static BYTE visibleCommonNameValue[]
Definition: encode.c:1214
static void testExportPublicKey(HCRYPTPROV csp, PCERT_PUBLIC_KEY_INFO *pInfo)
Definition: encode.c:8226
static CERT_GENERAL_SUBTREE IPAddressSubtree
Definition: encode.c:7306
static void test_encodeAuthorityInfoAccess(DWORD dwEncoding)
Definition: encode.c:5235
static const unsigned char bin61[]
Definition: encode.c:2141
static BYTE printableCommonNameValue[]
Definition: encode.c:1204
static const char bogusPrintable[]
Definition: encode.c:1195
static const BYTE signedCTLWithCTLInnerContent[]
Definition: encode.c:5759
static void test_encodeBasicConstraints(DWORD dwEncoding)
Definition: encode.c:2167
static void compareTime(const SYSTEMTIME *expected, const FILETIME *got)
Definition: encode.c:493
static const BYTE bin15[]
Definition: encode.c:83
static void test_encodeCRLDistPoints(DWORD dwEncoding)
Definition: encode.c:3574
static const BYTE bogusPKCSContentInfo[]
Definition: encode.c:5956
static const BYTE ext0[]
Definition: encode.c:2731
static void test_encodeBits(DWORD dwEncoding)
Definition: encode.c:2051
static const unsigned char bin60[]
Definition: encode.c:2140
static const BYTE encoded_abcd[]
Definition: encode.c:6053
static const BYTE v1CRLWithExt[]
Definition: encode.c:4015
static void test_decodeRsaPublicKey(DWORD dwEncoding)
Definition: encode.c:2435
static void test_encodeFiletime(DWORD dwEncoding)
Definition: encode.c:547
static const struct encodedPublicKey pubKeys[]
Definition: encode.c:2863
static void test_decodeNameConstraints(DWORD dwEncoding)
Definition: encode.c:7331
static const struct encodedInt ints[]
Definition: encode.c:52
static void test_encodeUnicodeNameValue(DWORD dwEncoding)
Definition: encode.c:1757
static BYTE oneUniversal[]
Definition: encode.c:1723
static void test_decodeExtensions(DWORD dwEncoding)
Definition: encode.c:2769
static void test_encodeEnhancedKeyUsage(DWORD dwEncoding)
Definition: encode.c:4841
static void test_decodePKCSSMimeCapabilities(DWORD dwEncoding)
Definition: encode.c:6457
static void test_decodeAltName(DWORD dwEncoding)
Definition: encode.c:1514
static const BYTE codeweavers[]
Definition: encode.c:676
static const BYTE authorityKeyIdWithId[]
Definition: encode.c:4926
static const BYTE ext3[]
Definition: encode.c:2736
static const unsigned char bin62[]
Definition: encode.c:2142
static void test_decodeEnhancedKeyUsage(DWORD dwEncoding)
Definition: encode.c:4873
static BYTE numericCommonNameValue[]
Definition: encode.c:1202
static const BYTE rsaPrivKeyModulus[]
Definition: encode.c:8045
static const char commonName[]
Definition: encode.c:655
static void compareCTLInfo(LPCSTR header, const CTL_INFO *expected, const CTL_INFO *got)
Definition: encode.c:5618
static const BYTE bin14[]
Definition: encode.c:82
static const BYTE content_abcd[]
Definition: encode.c:6044
static void test_decodeAuthorityInfoAccess(DWORD dwEncoding)
Definition: encode.c:5326
static void test_encodeCRLToBeSigned(DWORD dwEncoding)
Definition: encode.c:4030
static const BYTE v1CertWithPubKeyNoNull[]
Definition: encode.c:3030
static const BYTE policyConstraintsWithInhibitMapping[]
Definition: encode.c:7803
static const BYTE ctlWithListIdentifier[]
Definition: encode.c:5414
static BYTE bmpCommonNameValue[]
Definition: encode.c:1218
static void test_encodeNameValue(DWORD dwEncoding)
Definition: encode.c:1268
static CHAR oid_bogus[]
Definition: encode.c:2860
static const unsigned char bin57[]
Definition: encode.c:2041
static const BYTE policyConstraintsWithBoth[]
Definition: encode.c:7805
static void test_encodeUnicodeName(DWORD dwEncoding)
Definition: encode.c:858
static void comparePublicKeyInfo(const CERT_PUBLIC_KEY_INFO *expected, const CERT_PUBLIC_KEY_INFO *got)
Definition: encode.c:2909
static const BYTE distPointWithUrl[]
Definition: encode.c:3558
static BYTE bogusDER[]
Definition: encode.c:5960
static const LPCSTR keyUsages[]
Definition: encode.c:4834
static CHAR oid_short[]
Definition: encode.c:2727
static const BYTE bin28[]
Definition: encode.c:569
static void test_encodeSequenceOfAny(DWORD dwEncoding)
Definition: encode.c:2626
static const BYTE bin31[]
Definition: encode.c:575
static const unsigned char bin69[]
Definition: encode.c:2847
static const BYTE intSequence[]
Definition: encode.c:2617
static const BYTE twoCapabilities[]
Definition: encode.c:6369
static CHAR oid_codeweavers[]
Definition: encode.c:691
static const BYTE authorityKeyIdWithIssuerUrl[]
Definition: encode.c:5068
static CHAR oid_localhostAttr[]
Definition: encode.c:693
static CERT_GENERAL_SUBTREE emptyDNSSubtree
Definition: encode.c:7302
static const unsigned char decoded_something_long_octet[]
Definition: encode.c:1890
static void test_decodePolicyQualifierUserNotice(DWORD dwEncoding)
Definition: encode.c:7450
static BYTE permittedAndExcludedWithMinMaxConstraints[]
Definition: encode.c:7187
static const BYTE anyType[]
Definition: encode.c:852
static const BYTE bin12[]
Definition: encode.c:74
static const BYTE v1CertWithPubKey[]
Definition: encode.c:3018
static const BYTE params[]
Definition: encode.c:2834
static const BYTE policiesWithAnyPolicy[]
Definition: encode.c:7509
static const BYTE crlReason
Definition: encode.c:3571
static const BYTE authorityInfoAccessWithUrlAndIPAddr[]
Definition: encode.c:5230
static const BYTE authorityKeyIdWithSerial[]
Definition: encode.c:4931
static const BYTE emptyConstraint[]
Definition: encode.c:2156
static const unsigned char bin52[]
Definition: encode.c:2036
static CHAR oid_rsa[]
Definition: encode.c:2861
static const BYTE expiredCert[]
Definition: encode.c:8283
static BYTE keyId[]
Definition: encode.c:4925
static void test_encodePKCSAttributes(DWORD dwEncoding)
Definition: encode.c:6246
static BYTE noticeWithReference[]
Definition: encode.c:7397
static const BYTE ocsp_basic_signed_response[]
Definition: encode.c:8621
static const BYTE v1CRLWithEntryExt[]
Definition: encode.c:4008
static const BYTE v2Cert[]
Definition: encode.c:2979
static const BYTE ctlWithThisUpdate[]
Definition: encode.c:5420
static const BYTE v1CertWithConstraints[]
Definition: encode.c:2994
static BYTE videotexCommonNameValue[]
Definition: encode.c:1208
static struct UnicodeExpectedResult unicodeResults[]
Definition: encode.c:1736
static void test_encodePKCSContentInfo(DWORD dwEncoding)
Definition: encode.c:5962
static BYTE noncrit_ext_data[]
Definition: encode.c:2721
static const struct encodedFiletime times[]
Definition: encode.c:541
static const BYTE v1CRLWithIssuerAndEmptyEntry[]
Definition: encode.c:3996
static BYTE nihongoGeneral[]
Definition: encode.c:1729
static const BYTE v1CertWithSerial[]
Definition: encode.c:3001
static const unsigned char bin64[]
Definition: encode.c:2836
static void test_encodePublicKeyInfo(DWORD dwEncoding)
Definition: encode.c:2883
static const BYTE encodedRDNAttrs[]
Definition: encode.c:713
static CHAR oid_minnesota[]
Definition: encode.c:689
static void test_encodeCRLIssuingDistPoint(DWORD dwEncoding)
Definition: encode.c:3796
static void test_encodeRsaPublicKey_Bcrypt(DWORD dwEncoding)
Definition: encode.c:2499
static BYTE oneUTF8[]
Definition: encode.c:1726
static const BYTE aKey[]
Definition: encode.c:2832
static void test_decodeOCSPBasicResponseInfo(DWORD dwEncoding)
Definition: encode.c:8897
static const BYTE emptyNameIDP[]
Definition: encode.c:3791
static const BYTE bin18[]
Definition: encode.c:355
static const BYTE rsaPrivKeyExponent1[]
Definition: encode.c:8092
static CERT_EXTENSION criticalExt
Definition: encode.c:2723
static const BYTE bin17[]
Definition: encode.c:85
static BYTE oneTeletex[]
Definition: encode.c:1718
static BYTE oneIA5[]
Definition: encode.c:1720
static const BYTE us[]
Definition: encode.c:671
static const BYTE v1CertWithSubjectKeyId[]
Definition: encode.c:3041
static const BYTE PKCSSignerWithHash[]
Definition: encode.c:6558
static const unsigned char bin56[]
Definition: encode.c:2040
static const BYTE distPointWithReason[]
Definition: encode.c:3561
static const BYTE mixedSequence[]
Definition: encode.c:2621
static const BYTE localhostAttr[]
Definition: encode.c:680
static BYTE permittedAndExcludedConstraints[]
Definition: encode.c:7179
static const BYTE emptyPKCSAttr[]
Definition: encode.c:6129
static void test_encodeCertPolicyMappings(DWORD dwEncoding)
Definition: encode.c:7664
static unsigned char bin72[]
Definition: encode.c:2858
static const BYTE bin7[]
Definition: encode.c:50
static void test_decodeRsaPublicKey_Bcrypt(DWORD dwEncoding)
Definition: encode.c:2552
static const BYTE mod1_encoded[]
Definition: encode.c:2324
static CHAR oid_aric[]
Definition: encode.c:694
static BYTE encodedCommonNameNoNull[]
Definition: encode.c:6536
static const BYTE v1CertWithIssuerUniqueId[]
Definition: encode.c:3051
static const BYTE constraintWithDomainName[]
Definition: encode.c:2161
static const BYTE aric[]
Definition: encode.c:682
static void testTimeDecoding(DWORD dwEncoding, LPCSTR structType, const struct encodedFiletime *time)
Definition: encode.c:509
static void test_encodeCMSSignerInfo(DWORD dwEncoding)
Definition: encode.c:6859
static void testImportPublicKey(HCRYPTPROV csp, PCERT_PUBLIC_KEY_INFO info)
Definition: encode.c:8309
static BYTE utf8CommonNameValue[]
Definition: encode.c:1221
static void test_encodePKCSSignerInfo(DWORD dwEncoding)
Definition: encode.c:6573
static const unsigned char bin66[]
Definition: encode.c:2840
static const BYTE bin22[]
Definition: encode.c:538
static const BYTE bin1[]
Definition: encode.c:44
static const BYTE bin23[]
Definition: encode.c:559
static const unsigned char bin67[]
Definition: encode.c:2842
static const BYTE ctlWithSequenceNumber[]
Definition: encode.c:5417
static const BYTE encodedUsage[]
Definition: encode.c:4836
static void test_decodeCRLToBeSigned(DWORD dwEncoding)
Definition: encode.c:4691
static const BYTE signedBigCert[]
Definition: encode.c:3390
static CHAR oid_us[]
Definition: encode.c:688
static void test_decodeCert(DWORD dwEncoding)
Definition: encode.c:3485
static const BYTE bin37[]
Definition: encode.c:587
static const BYTE bin2[]
Definition: encode.c:45
static const BYTE rsaPrivKeyExponent2[]
Definition: encode.c:8104
static const BYTE bin42[]
Definition: encode.c:1197
static const BYTE bin24[]
Definition: encode.c:561
static struct UnicodeExpectedResult unicodeWeirdness[]
Definition: encode.c:1752
static const BYTE encodedOidName[]
Definition: encode.c:1396
static const BYTE PKCSSignerWithAuthAttr[]
Definition: encode.c:6564
static void test_encodeAuthorityKeyId(DWORD dwEncoding)
Definition: encode.c:4933
static const BYTE signedBigCertWithIndefiniteSeq[]
Definition: encode.c:3425
static const BYTE bogusPKCSAttr[]
Definition: encode.c:6131
#define RDNA(arr)
Definition: encode.c:685
static void test_encodeNameConstraints(DWORD dwEncoding)
Definition: encode.c:7192
static void testPortPublicKeyInfo(void)
Definition: encode.c:8399
static const BYTE rsaPrivKeyCoefficient[]
Definition: encode.c:8116
static const BYTE bin34[]
Definition: encode.c:581
static void compareAltNameEntry(const CERT_ALT_NAME_ENTRY *expected, const CERT_ALT_NAME_ENTRY *got)
Definition: encode.c:3864
static const BYTE rsaPrivKeyPrivateExponent[]
Definition: encode.c:8128
static void compareNames(const CERT_NAME_INFO *expected, const CERT_NAME_INFO *got)
Definition: encode.c:1002
static const BYTE ocsp_response2[]
Definition: encode.c:8553
static const struct Constraints2 constraints2[]
Definition: encode.c:2143
static const BYTE v1CertWithSubjectIssuerSerialAndIssuerUniqueIdNoNull[]
Definition: encode.c:3068
static const BYTE verisignCRLWithLotsOfEntries[]
Definition: encode.c:4181
static CHAR oid_wine[]
Definition: encode.c:692
static const BYTE PKCSSignerWithHashAlgo[]
Definition: encode.c:6548
static const unsigned char bin70[]
Definition: encode.c:2850
static const BYTE v1CRLWithIssuerAndEntry[]
Definition: encode.c:4002
static const struct encodedBigInt bigUInts[]
Definition: encode.c:88
static BYTE graphicCommonNameValue[]
Definition: encode.c:1212
static const BYTE emptyURLExtraBytes[]
Definition: encode.c:1383
static const WCHAR url[]
Definition: encode.c:1384
static BYTE oneBMP[]
Definition: encode.c:1725
static const char * printSystemTime(const SYSTEMTIME *st)
Definition: encode.c:473
static BYTE oneGeneral[]
Definition: encode.c:1724
static const BYTE twoRDNs[]
Definition: encode.c:660
static void test_encodeOctets(DWORD dwEncoding)
Definition: encode.c:1896
static void test_decodeUnicodeNameValue(DWORD dwEncoding)
Definition: encode.c:1858
static const unsigned char encoded_constructed_hi_octet2[]
Definition: encode.c:1945
static void test_decodeCertPolicyConstraints(DWORD dwEncoding)
Definition: encode.c:7875
static const BYTE rsaPrivKeyPrime2[]
Definition: encode.c:8080
static const BYTE emptySequence[]
Definition: encode.c:658
static const BYTE encodedURL[]
Definition: encode.c:1385
static const BYTE bin25[]
Definition: encode.c:563
static CERT_RDN_ATTR rdnAttrs[]
Definition: encode.c:695
static struct EncodedNameValue nameValues[]
Definition: encode.c:1227
static BYTE octetCommonNameValue[]
Definition: encode.c:1200
static const BYTE bin29[]
Definition: encode.c:571
static BYTE oneVideotex[]
Definition: encode.c:1719
static void test_decodeFiletime(DWORD dwEncoding)
Definition: encode.c:592
#define RDNIA5(arr)
Definition: encode.c:686
static const BYTE localhost[]
Definition: encode.c:1391
static BYTE oneNumeric[]
Definition: encode.c:1716
static const BYTE bin16[]
Definition: encode.c:84
static const char bogusIA5[]
Definition: encode.c:1194
static BYTE ia5EmbeddedNull[]
Definition: encode.c:1224
static const char bogusNumeric[]
Definition: encode.c:1196
static CERT_GENERAL_SUBTREE IPAddressWithMinMaxSubtree
Definition: encode.c:7310
static BYTE nihongoBMP[]
Definition: encode.c:1731
static const BYTE minneapolis[]
Definition: encode.c:674
static const unsigned char decoded_hi_octet[]
Definition: encode.c:1888
static const BYTE PKCSSignerWithSerial[]
Definition: encode.c:6543
static const unsigned char bin54[]
Definition: encode.c:2038
static const BYTE singleCapability[]
Definition: encode.c:6367
static void test_decodeRsaPrivateKey(DWORD dwEncoding)
Definition: encode.c:8152
static void test_decodePKCSContentInfo(DWORD dwEncoding)
Definition: encode.c:6069
static const BYTE bin3[]
Definition: encode.c:46
static const BYTE v4Cert[]
Definition: encode.c:2989
static const struct encodedBigInt bigInts[]
Definition: encode.c:77
static const BYTE ctlWithBogusEntry[]
Definition: encode.c:5430
static BYTE t61CommonNameValue[]
Definition: encode.c:1206
static void test_decodeSequenceOfAny(DWORD dwEncoding)
Definition: encode.c:2670
static const BYTE bin20[]
Definition: encode.c:534
static const BYTE bin9[]
Definition: encode.c:70
static const BYTE bin44[]
Definition: encode.c:1199
static BYTE oneVisible[]
Definition: encode.c:1722
static const BYTE ctlWithAlgId[]
Definition: encode.c:5427
static const struct EncodedNameConstraints encodedNameConstraints[]
Definition: encode.c:7313
static const unsigned char bin55[]
Definition: encode.c:2039
static void test_decodeEnumerated(DWORD dwEncoding)
Definition: encode.c:405
static const BYTE emptyURL[]
Definition: encode.c:1382
static void test_encodeAuthorityKeyId2(DWORD dwEncoding)
Definition: encode.c:5072
static void compareAuthorityInfoAccess(LPCSTR header, const CERT_AUTHORITY_INFO_ACCESS *expected, const CERT_AUTHORITY_INFO_ACCESS *got)
Definition: encode.c:5306
static const BYTE encodedDnsName[]
Definition: encode.c:1389
static const BYTE encodedDirectoryName[]
Definition: encode.c:1397
static char oid1[]
Definition: encode.c:7512
static const BYTE emptyRDNs[]
Definition: encode.c:659
static const unsigned char encoded_constructed_hi_octet3[]
Definition: encode.c:1947
static const struct encodedExtensions exts[]
Definition: encode.c:2738
static CHAR oid_minneapolis[]
Definition: encode.c:690
static const BYTE v1CRLWithIssuer[]
Definition: encode.c:3991
static const BYTE encodedDomainName[]
Definition: encode.c:2157
static const BYTE distPointWithUrlAndIssuer[]
Definition: encode.c:3566
static void test_decodeUnicodeName(DWORD dwEncoding)
Definition: encode.c:1121
static const BYTE urlIDP[]
Definition: encode.c:3792
static void test_encodeCertToBeSigned(DWORD dwEncoding)
Definition: encode.c:3083
static const unsigned char encoded_hi_octet[]
Definition: encode.c:1889
static BYTE permittedAndExcludedWithMinConstraints[]
Definition: encode.c:7183
static const BYTE singlePKCSAttributes[]
Definition: encode.c:6241
BOOL expected
Definition: store.c:2000
static APTTYPEQUALIFIER * qualifier
Definition: compobj.c:79
#define min(a, b)
Definition: monoChain.cc:55
int k
Definition: mpi.c:3369
unsigned int UINT
Definition: ndis.h:50
BYTE * PBYTE
Definition: pedump.c:66
#define calloc
Definition: rosglue.h:14
const WCHAR * str
_Check_return_ _CRTIMP int __cdecl wcsncmp(_In_reads_or_z_(_MaxCount) const wchar_t *_Str1, _In_reads_or_z_(_MaxCount) const wchar_t *_Str2, _In_ size_t _MaxCount)
#define ASN_BITS
Definition: snmp.h:104
#define ASN_OCTETSTRING
Definition: snmp.h:105
#define ASN_CONSTRUCTOR
Definition: snmp.h:92
#define ASN_SEQUENCE
Definition: snmp.h:110
#define ASN_OBJECTIDENTIFIER
Definition: snmp.h:107
#define ASN_INTEGER
Definition: snmp.h:103
#define ASN_CONTEXT
Definition: snmp.h:89
const char int int int static __inline const char * wine_dbgstr_a(const char *s)
Definition: debug.h:187
#define memset(x, y, z)
Definition: compat.h:39
CERT_BASIC_CONSTRAINTS2_INFO info
Definition: encode.c:2135
const BYTE * encoded
Definition: encode.c:2136
CRYPT_DATA_BLOB encoded
Definition: encode.c:7298
CERT_NAME_CONSTRAINTS_INFO constraints
Definition: encode.c:7299
DWORD encodedSize
Definition: encode.c:1191
const BYTE * encoded
Definition: encode.c:1190
CERT_NAME_VALUE value
Definition: encode.c:1189
size_t decodedModulusLen
Definition: encode.c:2334
const BYTE * modulus
Definition: encode.c:2331
size_t modulusLen
Definition: encode.c:2332
const BYTE * encoded
Definition: encode.c:2333
CRYPT_DATA_BLOB encoded
Definition: encode.c:1713
CERT_ALT_NAME_ENTRY AccessLocation
Definition: wincrypt.h:479
Definition: wincrypt.h:341
LPWSTR pwszURL
Definition: wincrypt.h:348
DWORD dwAltNameChoice
Definition: wincrypt.h:342
CRYPT_DATA_BLOB IPAddress
Definition: wincrypt.h:349
PCERT_ALT_NAME_ENTRY rgAltEntry
Definition: wincrypt.h:366
PCERT_ACCESS_DESCRIPTION rgAccDescr
Definition: wincrypt.h:484
LPSTR pszObjId
Definition: wincrypt.h:239
CRYPT_OBJID_BLOB Value
Definition: wincrypt.h:241
CERT_ALT_NAME_ENTRY Base
Definition: wincrypt.h:584
PCERT_GENERAL_SUBTREE rgPermittedSubtree
Definition: wincrypt.h:592
PCERT_GENERAL_SUBTREE rgExcludedSubtree
Definition: wincrypt.h:594
PCERT_RDN rgRDN
Definition: wincrypt.h:277
DWORD dwValueType
Definition: wincrypt.h:281
CERT_RDN_VALUE_BLOB Value
Definition: wincrypt.h:282
CRYPT_BIT_BLOB PublicKey
Definition: wincrypt.h:235
CRYPT_ALGORITHM_IDENTIFIER Algorithm
Definition: wincrypt.h:234
LPSTR pszObjId
Definition: wincrypt.h:265
DWORD dwValueType
Definition: wincrypt.h:266
CERT_RDN_VALUE_BLOB Value
Definition: wincrypt.h:267
DWORD cRDNAttr
Definition: wincrypt.h:271
PCERT_RDN_ATTR rgRDNAttr
Definition: wincrypt.h:272
CERT_ALT_NAME_INFO FullName
Definition: wincrypt.h:518
DWORD dwDistPointNameChoice
Definition: wincrypt.h:516
Definition: wincrypt.h:496
CRL_DIST_POINT_NAME DistPointName
Definition: wincrypt.h:576
CRYPT_BIT_BLOB OnlySomeReasonFlags
Definition: wincrypt.h:579
BYTE * pbData
Definition: wincrypt.h:112
CRYPT_OBJID_BLOB Parameters
Definition: wincrypt.h:136
PCRYPT_ATTRIBUTE rgAttr
Definition: wincrypt.h:612
PCRYPT_DATA_BLOB rgValue
Definition: wincrypt.h:607
BYTE * pbData
Definition: wincrypt.h:206
PCRYPT_DER_BLOB rgValue
Definition: wincrypt.h:468
PCRYPT_SMIME_CAPABILITY rgCapability
Definition: wincrypt.h:805
CRYPT_OBJID_BLOB Parameters
Definition: wincrypt.h:800
Definition: wincrypt.h:835
DWORD cAttribute
Definition: wincrypt.h:837
CRYPT_DATA_BLOB SubjectIdentifier
Definition: wincrypt.h:836
PCRYPT_ATTRIBUTE rgAttribute
Definition: wincrypt.h:838
CRYPT_INTEGER_BLOB SequenceNumber
Definition: wincrypt.h:845
DWORD cExtension
Definition: wincrypt.h:851
DWORD dwVersion
Definition: wincrypt.h:842
CRYPT_ALGORITHM_IDENTIFIER SubjectAlgorithm
Definition: wincrypt.h:848
FILETIME NextUpdate
Definition: wincrypt.h:847
PCTL_ENTRY rgCTLEntry
Definition: wincrypt.h:850
CRYPT_DATA_BLOB ListIdentifier
Definition: wincrypt.h:844
DWORD cCTLEntry
Definition: wincrypt.h:849
CTL_USAGE SubjectUsage
Definition: wincrypt.h:843
FILETIME ThisUpdate
Definition: wincrypt.h:846
PCERT_EXTENSION rgExtension
Definition: wincrypt.h:852
DWORD cUsageIdentifier
Definition: wincrypt.h:831
LPSTR * rgpszUsageIdentifier
Definition: wincrypt.h:832
DWORD dwHighDateTime
Definition: mapidefs.h:66
DWORD dwLowDateTime
Definition: mapidefs.h:65
Definition: wincrypt.h:700
Definition: wincrypt.h:654
POCSP_SIGNATURE_INFO pOptionalSignatureInfo
Definition: wincrypt.h:644
CRYPT_DER_BLOB ToBeSigned
Definition: wincrypt.h:643
DWORD pubexp
Definition: wincrypt.h:154
DWORD bitlen
Definition: wincrypt.h:153
DWORD magic
Definition: wincrypt.h:152
WORD wMilliseconds
Definition: minwinbase.h:263
WORD wSecond
Definition: minwinbase.h:262
WORD wMinute
Definition: minwinbase.h:261
Definition: cookie.c:202
Definition: image.c:134
Definition: http.c:7252
const BYTE * val
Definition: encode.c:64
const BYTE * decoded
Definition: encode.c:66
const BYTE * encoded
Definition: encode.c:65
const BYTE * decoded
Definition: encode.c:2033
const BYTE * encoded
Definition: encode.c:2031
DWORD cbDecoded
Definition: encode.c:2032
DWORD cUnusedBits
Definition: encode.c:2030
const BYTE * encoded
Definition: encode.c:2717
CERT_EXTENSIONS exts
Definition: encode.c:2716
SYSTEMTIME sysTime
Definition: encode.c:431
const BYTE * encodedTime
Definition: encode.c:432
const BYTE * encoded
Definition: encode.c:41
int val
Definition: encode.c:40
CERT_PUBLIC_KEY_INFO info
Definition: encode.c:2826
CERT_PUBLIC_KEY_INFO decoded
Definition: encode.c:2829
const BYTE * encodedNoNull
Definition: encode.c:2828
const BYTE * encoded
Definition: encode.c:2827
Definition: _hash_fun.h:40
Definition: copy.c:22
Definition: name.c:39
notice
Definition: t1tokens.h:26
unsigned char * LPBYTE
Definition: typedefs.h:53
Definition: pdh_main.c:96
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define MS_DEF_PROV_A
Definition: wincrypt.h:2115
#define szOID_PKIX_OCSP_BASIC_SIGNED_RESPONSE
Definition: wincrypt.h:678
#define szOID_RSA_SHA256RSA
Definition: wincrypt.h:3177
#define X509_ISSUING_DIST_POINT
Definition: wincrypt.h:3576
#define X509_AUTHORITY_KEY_ID2
Definition: wincrypt.h:3550
#define CERT_ID_ISSUER_SERIAL_NUMBER
Definition: wincrypt.h:3838
#define CRYPT_NEWKEYSET
Definition: wincrypt.h:2274
#define PKCS_UTC_TIME
Definition: wincrypt.h:3534
#define CERT_RDN_UTF8_STRING
Definition: wincrypt.h:2940
#define CERT_RDN_IA5_STRING
Definition: wincrypt.h:2931
#define CERT_RDN_GENERAL_STRING
Definition: wincrypt.h:2935
#define CRL_REASON_AFFILIATION_CHANGED
Definition: wincrypt.h:2960
#define PROV_RSA_FULL
Definition: wincrypt.h:2243
#define X509_POLICY_MAPPINGS
Definition: wincrypt.h:3578
#define X509_NAME
Definition: wincrypt.h:3524
#define X509_CERT_TO_BE_SIGNED
Definition: wincrypt.h:3518
#define X509_UNICODE_NAME
Definition: wincrypt.h:3537
#define CERT_V3
Definition: wincrypt.h:2805
#define CERT_RDN_PRINTABLE_STRING
Definition: wincrypt.h:2927
#define OCSP_REQUEST_V1
Definition: wincrypt.h:660
#define szOID_POLICY_MAPPINGS
Definition: wincrypt.h:3355
#define CERT_ALT_NAME_URL
Definition: wincrypt.h:360
#define X509_MULTI_BYTE_UINT
Definition: wincrypt.h:3557
#define PKCS_ATTRIBUTE
Definition: wincrypt.h:3539
#define CALG_RSA_SIGN
Definition: wincrypt.h:2069
#define szOID_RSA
Definition: wincrypt.h:3153
ULONG_PTR HCRYPTPROV
Definition: wincrypt.h:55
#define X509_OCTET_STRING
Definition: wincrypt.h:3543
#define szOID_BASIC_CONSTRAINTS2
Definition: wincrypt.h:3345
#define X509_MULTI_BYTE_INTEGER
Definition: wincrypt.h:3546
#define CRL_DIST_POINT_ISSUER_RDN_NAME
Definition: wincrypt.h:524
#define CERT_ALT_NAME_DIRECTORY_NAME
Definition: wincrypt.h:358
#define X509_CERT
Definition: wincrypt.h:3517
WINCRYPT32API BOOL WINAPI CryptImportPublicKeyInfoEx2(DWORD dwCertEncodingType, PCERT_PUBLIC_KEY_INFO pInfo, DWORD dwFlags, void *pvAuxInfo, BCRYPT_KEY_HANDLE *phKey)
#define CERT_ID_KEY_IDENTIFIER
Definition: wincrypt.h:3839
#define CERT_ALT_NAME_IP_ADDRESS
Definition: wincrypt.h:361
#define szOID_LEGACY_POLICY_MAPPINGS
Definition: wincrypt.h:3335
#define X509_AUTHORITY_INFO_ACCESS
Definition: wincrypt.h:3551
#define GET_CERT_ALT_NAME_VALUE_ERR_INDEX(x)
Definition: wincrypt.h:376
#define OCSP_BASIC_RESPONSE
Definition: wincrypt.h:3591
#define X509_ENUMERATED
Definition: wincrypt.h:3547
#define CERT_ALT_NAME_EDI_PARTY_NAME
Definition: wincrypt.h:359
#define CERT_RDN_UNIVERSAL_STRING
Definition: wincrypt.h:2936
#define szOID_PKIX_KP_CLIENT_AUTH
Definition: wincrypt.h:3451
#define X509_INTEGER
Definition: wincrypt.h:3545
#define CERT_ALT_NAME_RFC822_NAME
Definition: wincrypt.h:355
#define PKCS_CONTENT_INFO
Definition: wincrypt.h:3552
#define OCSP_SUCCESSFUL_RESPONSE
Definition: wincrypt.h:671
#define CERT_RDN_VISIBLE_STRING
Definition: wincrypt.h:2933
#define szOID_PKIX_KP_CODE_SIGNING
Definition: wincrypt.h:3452
#define OCSP_BASIC_SIGNED_RESPONSE
Definition: wincrypt.h:3590
#define CERT_V1
Definition: wincrypt.h:2803
#define CRYPT_DELETEKEYSET
Definition: wincrypt.h:2275
#define PRIVATEKEYBLOB
Definition: wincrypt.h:2445
#define CRL_DIST_POINT_NO_NAME
Definition: wincrypt.h:522
#define CNG_RSA_PUBLIC_KEY_BLOB
Definition: wincrypt.h:3592
#define X509_NAME_VALUE
Definition: wincrypt.h:3522
#define X509_EXTENSIONS
Definition: wincrypt.h:3521
#define CRYPT_DECODE_SHARE_OID_STRING_FLAG
Definition: wincrypt.h:3610
#define X509_ASN_ENCODING
Definition: wincrypt.h:2501
#define X509_CHOICE_OF_TIME
Definition: wincrypt.h:3549
#define PUBLICKEYBLOB
Definition: wincrypt.h:2444
#define CRYPT_DECODE_ALLOC_FLAG
Definition: wincrypt.h:3612
#define CRL_DIST_POINT_FULL_NAME
Definition: wincrypt.h:523
#define szOID_SUBJECT_KEY_IDENTIFIER
Definition: wincrypt.h:3340
#define X509_AUTHORITY_KEY_ID
Definition: wincrypt.h:3526
struct _CERT_NAME_VALUE * PCERT_NAME_VALUE
#define CERT_RDN_VIDEOTEX_STRING
Definition: wincrypt.h:2930
#define KP_ALGID
Definition: wincrypt.h:2338
#define szOID_CRL_REASON_CODE
Definition: wincrypt.h:3347
#define OCSP_UNAUTHORIZED_RESPONSE
Definition: wincrypt.h:676
#define X509_CERT_POLICIES
Definition: wincrypt.h:3533
#define CALG_RSA_KEYX
Definition: wincrypt.h:2080
#define RSA_CSP_PUBLICKEYBLOB
Definition: wincrypt.h:3536
#define szOID_SUR_NAME
Definition: wincrypt.h:3291
#define szOID_RSA_signingTime
Definition: wincrypt.h:3192
#define X509_SEQUENCE_OF_ANY
Definition: wincrypt.h:3553
#define CERT_ALT_NAME_DNS_NAME
Definition: wincrypt.h:356
#define PKCS7_SIGNER_INFO
Definition: wincrypt.h:3594
#define CERT_RDN_T61_STRING
Definition: wincrypt.h:2929
#define X509_BITS
Definition: wincrypt.h:3544
#define PKCS_RSA_PRIVATE_KEY
Definition: wincrypt.h:3563
#define szOID_OIWSEC_sha1
Definition: wincrypt.h:3253
#define X509_BASIC_CONSTRAINTS2
Definition: wincrypt.h:3532
struct _PUBLICKEYSTRUC BLOBHEADER
#define PKCS_SMIME_CAPABILITIES
Definition: wincrypt.h:3562
#define CRL_V2
Definition: wincrypt.h:2826
#define CERT_RDN_OCTET_STRING
Definition: wincrypt.h:2925
#define CMS_SIGNER_INFO
Definition: wincrypt.h:3595
#define CRYPT_ENCODE_ALLOC_FLAG
Definition: wincrypt.h:3599
#define CERT_RDN_ENCODED_BLOB
Definition: wincrypt.h:2924
#define CRL_V1
Definition: wincrypt.h:2825
#define szOID_RSA_SHA1RSA
Definition: wincrypt.h:3175
#define CERT_RDN_NUMERIC_STRING
Definition: wincrypt.h:2926
#define X509_PUBLIC_KEY_INFO
Definition: wincrypt.h:3525
#define OCSP_REQUEST
Definition: wincrypt.h:3588
#define CALG_DES
Definition: wincrypt.h:2082
#define X509_ALTERNATE_NAME
Definition: wincrypt.h:3529
#define szOID_RSA_RSA
Definition: wincrypt.h:3168
#define szOID_COMMON_NAME
Definition: wincrypt.h:3290
#define CERT_ID_SHA1_HASH
Definition: wincrypt.h:3840
#define PKCS_7_ASN_ENCODING
Definition: wincrypt.h:2503
#define PKCS_ATTRIBUTES
Definition: wincrypt.h:3570
#define AT_SIGNATURE
Definition: wincrypt.h:2240
struct _CRL_DIST_POINTS_INFO * PCRL_DIST_POINTS_INFO
#define CERT_RDN_TELETEX_STRING
Definition: wincrypt.h:2928
#define X509_NAME_CONSTRAINTS
Definition: wincrypt.h:3577
#define OCSP_SIGNED_REQUEST
Definition: wincrypt.h:3587
#define CERT_RDN_BMP_STRING
Definition: wincrypt.h:2938
#define PKCS_CTL
Definition: wincrypt.h:3556
#define X509_CRL_DIST_POINTS
Definition: wincrypt.h:3554
#define X509_CERT_CRL_TO_BE_SIGNED
Definition: wincrypt.h:3519
#define X509_BASIC_CONSTRAINTS
Definition: wincrypt.h:3530
#define CERT_ALT_NAME_REGISTERED_ID
Definition: wincrypt.h:362
ULONG_PTR HCRYPTKEY
Definition: wincrypt.h:58
#define CERT_RDN_ANY_TYPE
Definition: wincrypt.h:2923
#define X509_ENHANCED_KEY_USAGE
Definition: wincrypt.h:3555
#define CERT_ALT_NAME_X400_ADDRESS
Definition: wincrypt.h:357
#define X509_PKIX_POLICY_QUALIFIER_USERNOTICE
Definition: wincrypt.h:3566
#define CRL_REASON_KEY_COMPROMISE
Definition: wincrypt.h:2958
#define CERT_RDN_GRAPHIC_STRING
Definition: wincrypt.h:2932
#define X509_POLICY_CONSTRAINTS
Definition: wincrypt.h:3579
#define CERT_V2
Definition: wincrypt.h:2804
#define X509_UNICODE_NAME_VALUE
Definition: wincrypt.h:3541
#define CUR_BLOB_VERSION
Definition: wincrypt.h:2451
#define OCSP_RESPONSE
Definition: wincrypt.h:3589
unsigned int ALG_ID
Definition: wincrypt.h:54
#define CRYPT_E_INVALID_PRINTABLE_STRING
Definition: winerror.h:4439
#define NTE_NO_KEY
Definition: winerror.h:4260
#define NOERROR
Definition: winerror.h:3448
#define CRYPT_E_ASN1_CORRUPT
Definition: winerror.h:4502
#define CRYPT_E_NOT_CHAR_STRING
Definition: winerror.h:4442
#define CRYPT_E_BAD_ENCODE
Definition: winerror.h:4419
#define CRYPT_E_ASN1_LARGE
Definition: winerror.h:4503
#define CRYPT_E_INVALID_IA5_STRING
Definition: winerror.h:4440
#define CRYPT_E_INVALID_NUMERIC_STRING
Definition: winerror.h:4438
#define CRYPT_E_ASN1_EOD
Definition: winerror.h:4501
#define CRYPT_E_ASN1_BADTAG
Definition: winerror.h:4510
const char * LPCSTR
Definition: xmlstorage.h:183
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
__wchar_t WCHAR
Definition: xmlstorage.h:180
WCHAR * LPWSTR
Definition: xmlstorage.h:184
char * LPSTR
Definition: xmlstorage.h:182
char CHAR
Definition: xmlstorage.h:175
unsigned char BYTE
Definition: xxhash.c:193