mshtml.idl: Added HTMLMetaElement coclass declaration.
[wine.git] / dlls / wintrust / tests / asn.c
blob82feac61bfe9c8f2594b2dee40c082ce3d3a307d
1 /* Unit test suite for wintrust asn functions
3 * Copyright 2007 Juan Lang
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20 #include <stdarg.h>
21 #include "windef.h"
22 #include "winbase.h"
23 #include "winerror.h"
24 #include "wincrypt.h"
25 #include "wintrust.h"
27 #include "wine/test.h"
29 static BOOL (WINAPI *pCryptDecodeObjectEx)(DWORD,LPCSTR,const BYTE*,DWORD,DWORD,PCRYPT_DECODE_PARA,void*,DWORD*);
30 static BOOL (WINAPI *pCryptEncodeObjectEx)(DWORD,LPCSTR,const void*,DWORD,PCRYPT_ENCODE_PARA,void*,DWORD*);
32 static const BYTE falseCriteria[] = { 0x30,0x06,0x01,0x01,0x00,0x01,0x01,0x00 };
33 static const BYTE trueCriteria[] = { 0x30,0x06,0x01,0x01,0xff,0x01,0x01,0xff };
35 static void test_encodeSPCFinancialCriteria(void)
37 BOOL ret;
38 DWORD size = 0;
39 LPBYTE buf;
40 SPC_FINANCIAL_CRITERIA criteria = { FALSE, FALSE };
42 if (!pCryptEncodeObjectEx)
44 win_skip("CryptEncodeObjectEx() is not available. Skipping the encodeFinancialCriteria tests\n");
45 return;
47 ret = pCryptEncodeObjectEx(X509_ASN_ENCODING, SPC_FINANCIAL_CRITERIA_STRUCT,
48 &criteria, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
49 ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError());
50 if (ret)
52 ok(size == sizeof(falseCriteria), "Unexpected size %d\n", size);
53 ok(!memcmp(buf, falseCriteria, size), "Unexpected value\n");
54 LocalFree(buf);
56 criteria.fFinancialInfoAvailable = criteria.fMeetsCriteria = TRUE;
57 ret = pCryptEncodeObjectEx(X509_ASN_ENCODING, SPC_FINANCIAL_CRITERIA_STRUCT,
58 &criteria, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
59 ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError());
60 if (ret)
62 ok(size == sizeof(trueCriteria), "Unexpected size %d\n", size);
63 ok(!memcmp(buf, trueCriteria, size), "Unexpected value\n");
64 LocalFree(buf);
68 static void test_decodeSPCFinancialCriteria(void)
70 BOOL ret;
71 SPC_FINANCIAL_CRITERIA criteria;
72 DWORD size = sizeof(criteria);
74 if (!pCryptDecodeObjectEx)
76 win_skip("CryptDecodeObjectEx() is not available. Skipping the decodeSPCFinancialCriteria tests\n");
77 return;
80 ret = pCryptDecodeObjectEx(X509_ASN_ENCODING, SPC_FINANCIAL_CRITERIA_STRUCT,
81 falseCriteria, sizeof(falseCriteria), 0, NULL, &criteria, &size);
82 ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
83 if (ret)
85 ok(!criteria.fFinancialInfoAvailable, "expected FALSE\n");
86 ok(!criteria.fMeetsCriteria, "expected FALSE\n");
88 ret = pCryptDecodeObjectEx(X509_ASN_ENCODING, SPC_FINANCIAL_CRITERIA_STRUCT,
89 trueCriteria, sizeof(trueCriteria), 0, NULL, &criteria, &size);
90 ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
91 if (ret)
93 ok(criteria.fFinancialInfoAvailable, "expected TRUE\n");
94 ok(criteria.fMeetsCriteria, "expected TRUE\n");
98 static WCHAR url[] = { 'h','t','t','p',':','/','/','w','i','n','e','h','q','.',
99 'o','r','g',0 };
100 static const WCHAR nihongoURL[] = { 'h','t','t','p',':','/','/',0x226f,
101 0x575b, 0 };
102 static const BYTE emptyURLSPCLink[] = { 0x80,0x00 };
103 static const BYTE urlSPCLink[] = {
104 0x80,0x11,0x68,0x74,0x74,0x70,0x3a,0x2f,0x2f,0x77,0x69,0x6e,0x65,0x68,0x71,
105 0x2e,0x6f,0x72,0x67};
106 static const BYTE fileSPCLink[] = {
107 0xa2,0x14,0x80,0x12,0x00,0x68,0x00,0x74,0x00,0x74,0x00,0x70,0x00,0x3a,0x00,
108 0x2f,0x00,0x2f,0x22,0x6f,0x57,0x5b };
109 static const BYTE emptyMonikerSPCLink[] = {
110 0xa1,0x14,0x04,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
111 0x00,0x00,0x00,0x00,0x00,0x04,0x00 };
112 static BYTE data[] = { 0xba, 0xad, 0xf0, 0x0d };
113 static const BYTE monikerSPCLink[] = {
114 0xa1,0x18,0x04,0x10,0xea,0xea,0xea,0xea,0xea,0xea,0xea,0xea,0xea,0xea,0xea,
115 0xea,0xea,0xea,0xea,0xea,0x04,0x04,0xba,0xad,0xf0,0x0d };
117 static void test_encodeSPCLink(void)
119 BOOL ret;
120 DWORD size = 0;
121 LPBYTE buf;
122 SPC_LINK link = { 0 };
124 if (!pCryptEncodeObjectEx)
126 win_skip("CryptEncodeObjectEx() is not available. Skipping the encodeSPCLink tests\n");
127 return;
130 SetLastError(0xdeadbeef);
131 ret = pCryptEncodeObjectEx(X509_ASN_ENCODING, SPC_LINK_STRUCT, &link,
132 CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
133 ok(!ret && GetLastError() == E_INVALIDARG,
134 "Expected E_INVALIDARG, got %08x\n", GetLastError());
135 link.dwLinkChoice = SPC_URL_LINK_CHOICE;
136 ret = pCryptEncodeObjectEx(X509_ASN_ENCODING, SPC_LINK_STRUCT, &link,
137 CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
138 ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError());
139 if (ret)
141 ok(size == sizeof(emptyURLSPCLink), "Unexpected size %d\n", size);
142 ok(!memcmp(buf, emptyURLSPCLink, size), "Unexpected value\n");
143 LocalFree(buf);
145 /* With an invalid char: */
146 U(link).pwszUrl = (LPWSTR)nihongoURL;
147 size = 1;
148 SetLastError(0xdeadbeef);
149 ret = pCryptEncodeObjectEx(X509_ASN_ENCODING, SPC_LINK_STRUCT, &link,
150 CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
151 ok(!ret &&
152 (GetLastError() == CRYPT_E_INVALID_IA5_STRING ||
153 GetLastError() == OSS_BAD_PTR /* WinNT */),
154 "Expected CRYPT_E_INVALID_IA5_STRING, got %08x\n", GetLastError());
155 /* Unlike the crypt32 string encoding routines, size is not set to the
156 * index of the first invalid character.
158 ok(size == 0, "Expected size 0, got %d\n", size);
159 U(link).pwszUrl = url;
160 ret = pCryptEncodeObjectEx(X509_ASN_ENCODING, SPC_LINK_STRUCT, &link,
161 CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
162 ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError());
163 if (ret)
165 ok(size == sizeof(urlSPCLink), "Unexpected size %d\n", size);
166 ok(!memcmp(buf, urlSPCLink, size), "Unexpected value\n");
167 LocalFree(buf);
169 link.dwLinkChoice = SPC_FILE_LINK_CHOICE;
170 U(link).pwszFile = (LPWSTR)nihongoURL;
171 ret = pCryptEncodeObjectEx(X509_ASN_ENCODING, SPC_LINK_STRUCT, &link,
172 CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
173 ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError());
174 if (ret)
176 ok(size == sizeof(fileSPCLink), "Unexpected size %d\n", size);
177 ok(!memcmp(buf, fileSPCLink, size), "Unexpected value\n");
178 LocalFree(buf);
180 link.dwLinkChoice = SPC_MONIKER_LINK_CHOICE;
181 memset(&U(link).Moniker, 0, sizeof(U(link).Moniker));
182 ret = pCryptEncodeObjectEx(X509_ASN_ENCODING, SPC_LINK_STRUCT, &link,
183 CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
184 ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError());
185 if (ret)
187 ok(size == sizeof(emptyMonikerSPCLink), "Unexpected size %d\n", size);
188 ok(!memcmp(buf, emptyMonikerSPCLink, size), "Unexpected value\n");
189 LocalFree(buf);
191 memset(&U(link).Moniker.ClassId, 0xea, sizeof(U(link).Moniker.ClassId));
192 U(link).Moniker.SerializedData.pbData = data;
193 U(link).Moniker.SerializedData.cbData = sizeof(data);
194 ret = pCryptEncodeObjectEx(X509_ASN_ENCODING, SPC_LINK_STRUCT, &link,
195 CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
196 ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError());
197 if (ret)
199 ok(size == sizeof(monikerSPCLink), "Unexpected size %d\n", size);
200 ok(!memcmp(buf, monikerSPCLink, size), "Unexpected value\n");
201 LocalFree(buf);
205 static const BYTE badMonikerSPCLink[] = {
206 0xa1,0x19,0x04,0x11,0xea,0xea,0xea,0xea,0xea,0xea,0xea,0xea,0xea,0xea,0xea,
207 0xea,0xea,0xea,0xea,0xea,0xea,0x04,0x04,0xba,0xad,0xf0,0x0d };
209 static void test_decodeSPCLink(void)
211 BOOL ret;
212 LPBYTE buf = NULL;
213 DWORD size = 0;
214 SPC_LINK *link;
216 if (!pCryptDecodeObjectEx)
218 win_skip("CryptDecodeObjectEx() is not available. Skipping the decodeSPCLink tests\n");
219 return;
222 ret = pCryptDecodeObjectEx(X509_ASN_ENCODING, SPC_LINK_STRUCT,
223 emptyURLSPCLink, sizeof(emptyURLSPCLink), CRYPT_DECODE_ALLOC_FLAG, NULL,
224 &buf, &size);
225 ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
226 if (ret)
228 link = (SPC_LINK *)buf;
229 ok(link->dwLinkChoice == SPC_URL_LINK_CHOICE,
230 "Expected SPC_URL_LINK_CHOICE, got %d\n", link->dwLinkChoice);
231 ok(lstrlenW(U(*link).pwszUrl) == 0, "Expected empty string\n");
232 LocalFree(buf);
234 ret = pCryptDecodeObjectEx(X509_ASN_ENCODING, SPC_LINK_STRUCT,
235 urlSPCLink, sizeof(urlSPCLink), CRYPT_DECODE_ALLOC_FLAG, NULL,
236 &buf, &size);
237 ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
238 if (ret)
240 link = (SPC_LINK *)buf;
241 ok(link->dwLinkChoice == SPC_URL_LINK_CHOICE,
242 "Expected SPC_URL_LINK_CHOICE, got %d\n", link->dwLinkChoice);
243 ok(!lstrcmpW(U(*link).pwszUrl, url), "Unexpected URL\n");
244 LocalFree(buf);
246 ret = pCryptDecodeObjectEx(X509_ASN_ENCODING, SPC_LINK_STRUCT,
247 fileSPCLink, sizeof(fileSPCLink), CRYPT_DECODE_ALLOC_FLAG, NULL,
248 &buf, &size);
249 ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
250 if (ret)
252 link = (SPC_LINK *)buf;
253 ok(link->dwLinkChoice == SPC_FILE_LINK_CHOICE,
254 "Expected SPC_FILE_LINK_CHOICE, got %d\n", link->dwLinkChoice);
255 ok(!lstrcmpW(U(*link).pwszFile, nihongoURL), "Unexpected file\n");
256 LocalFree(buf);
258 ret = pCryptDecodeObjectEx(X509_ASN_ENCODING, SPC_LINK_STRUCT,
259 emptyMonikerSPCLink, sizeof(emptyMonikerSPCLink), CRYPT_DECODE_ALLOC_FLAG,
260 NULL, &buf, &size);
261 ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
262 if (ret)
264 SPC_SERIALIZED_OBJECT emptyMoniker = { { 0 } };
266 link = (SPC_LINK *)buf;
267 ok(link->dwLinkChoice == SPC_MONIKER_LINK_CHOICE,
268 "Expected SPC_MONIKER_LINK_CHOICE, got %d\n", link->dwLinkChoice);
269 ok(!memcmp(&U(*link).Moniker.ClassId, &emptyMoniker.ClassId,
270 sizeof(emptyMoniker.ClassId)), "Unexpected value\n");
271 ok(U(*link).Moniker.SerializedData.cbData == 0,
272 "Expected no serialized data\n");
273 LocalFree(buf);
275 ret = pCryptDecodeObjectEx(X509_ASN_ENCODING, SPC_LINK_STRUCT,
276 monikerSPCLink, sizeof(monikerSPCLink), CRYPT_DECODE_ALLOC_FLAG, NULL,
277 &buf, &size);
278 ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
279 if (ret)
281 SPC_UUID id;
283 link = (SPC_LINK *)buf;
284 ok(link->dwLinkChoice == SPC_MONIKER_LINK_CHOICE,
285 "Expected SPC_MONIKER_LINK_CHOICE, got %d\n", link->dwLinkChoice);
286 memset(&id, 0xea, sizeof(id));
287 ok(!memcmp(&U(*link).Moniker.ClassId, &id, sizeof(id)),
288 "Unexpected value\n");
289 ok(U(*link).Moniker.SerializedData.cbData == sizeof(data),
290 "Unexpected data size %d\n", U(*link).Moniker.SerializedData.cbData);
291 ok(!memcmp(U(*link).Moniker.SerializedData.pbData, data, sizeof(data)),
292 "Unexpected value\n");
293 LocalFree(buf);
295 SetLastError(0xdeadbeef);
296 ret = pCryptDecodeObjectEx(X509_ASN_ENCODING, SPC_LINK_STRUCT,
297 badMonikerSPCLink, sizeof(badMonikerSPCLink), CRYPT_DECODE_ALLOC_FLAG,
298 NULL, &buf, &size);
299 ok(!ret &&
300 (GetLastError() == CRYPT_E_BAD_ENCODE ||
301 GetLastError() == OSS_DATA_ERROR /* WinNT */),
302 "Expected CRYPT_E_BAD_ENCODE, got %08x\n", GetLastError());
305 static const BYTE emptySequence[] = { 0x30,0x00 };
306 static BYTE flags[] = { 1 };
307 static const BYTE onlyFlagsPEImage[] = { 0x30,0x04,0x03,0x02,0x00,0x01 };
308 static const BYTE onlyEmptyFilePEImage[] = {
309 0x30,0x06,0xa0,0x04,0xa2,0x02,0x80,0x00 };
310 static const BYTE flagsAndEmptyFilePEImage[] = {
311 0x30,0x0a,0x03,0x02,0x00,0x01,0xa0,0x04,0xa2,0x02,0x80,0x00 };
312 static const BYTE flagsAndFilePEImage[] = {
313 0x30,0x1c,0x03,0x02,0x00,0x01,0xa0,0x16,0xa2,0x14,0x80,0x12,0x00,0x68,0x00,
314 0x74,0x00,0x74,0x00,0x70,0x00,0x3a,0x00,0x2f,0x00,0x2f,0x22,0x6f,0x57,0x5b };
316 static void test_encodeSPCPEImage(void)
318 BOOL ret;
319 DWORD size = 0;
320 LPBYTE buf;
321 SPC_PE_IMAGE_DATA imageData = { { 0 } };
322 SPC_LINK link = { 0 };
324 if (!pCryptEncodeObjectEx)
326 win_skip("CryptEncodeObjectEx() is not available. Skipping the encodeSPCPEImage tests\n");
327 return;
330 ret = pCryptEncodeObjectEx(X509_ASN_ENCODING, SPC_PE_IMAGE_DATA_STRUCT,
331 &imageData, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
332 ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError());
333 if (ret)
335 ok(size == sizeof(emptySequence), "Unexpected size %d\n", size);
336 ok(!memcmp(buf, emptySequence, sizeof(emptySequence)),
337 "Unexpected value\n");
338 LocalFree(buf);
340 /* With an invalid link: */
341 imageData.pFile = &link;
342 SetLastError(0xdeadbeef);
343 ret = pCryptEncodeObjectEx(X509_ASN_ENCODING, SPC_PE_IMAGE_DATA_STRUCT,
344 &imageData, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
345 ok(!ret && GetLastError () == E_INVALIDARG,
346 "Expected E_INVALIDARG, got %08x\n", GetLastError());
347 /* With just unused bits field set: */
348 imageData.pFile = NULL;
349 imageData.Flags.cUnusedBits = 1;
350 ret = pCryptEncodeObjectEx(X509_ASN_ENCODING, SPC_PE_IMAGE_DATA_STRUCT,
351 &imageData, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
352 ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError());
353 if (ret)
355 ok(size == sizeof(emptySequence), "Unexpected size %d\n", size);
356 ok(!memcmp(buf, emptySequence, sizeof(emptySequence)),
357 "Unexpected value\n");
358 LocalFree(buf);
360 /* With flags set: */
361 imageData.Flags.cUnusedBits = 0;
362 imageData.Flags.pbData = flags;
363 imageData.Flags.cbData = sizeof(flags);
364 ret = pCryptEncodeObjectEx(X509_ASN_ENCODING, SPC_PE_IMAGE_DATA_STRUCT,
365 &imageData, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
366 if (!ret && GetLastError() == OSS_TOO_LONG)
368 skip("SPC_PE_IMAGE_DATA_STRUCT not supported\n");
369 return;
371 ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError());
372 if (ret)
374 ok(size == sizeof(onlyFlagsPEImage), "Unexpected size %d\n", size);
375 ok(!memcmp(buf, onlyFlagsPEImage, sizeof(onlyFlagsPEImage)),
376 "Unexpected value\n");
377 LocalFree(buf);
379 /* With just an empty file: */
380 imageData.Flags.cbData = 0;
381 link.dwLinkChoice = SPC_FILE_LINK_CHOICE;
382 imageData.pFile = &link;
383 ret = pCryptEncodeObjectEx(X509_ASN_ENCODING, SPC_PE_IMAGE_DATA_STRUCT,
384 &imageData, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
385 ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError());
386 if (ret)
388 ok(size == sizeof(onlyEmptyFilePEImage), "Unexpected size %d\n", size);
389 ok(!memcmp(buf, onlyEmptyFilePEImage, sizeof(onlyEmptyFilePEImage)),
390 "Unexpected value\n");
391 LocalFree(buf);
393 /* With flags and an empty file: */
394 imageData.Flags.pbData = flags;
395 imageData.Flags.cbData = sizeof(flags);
396 ret = pCryptEncodeObjectEx(X509_ASN_ENCODING, SPC_PE_IMAGE_DATA_STRUCT,
397 &imageData, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
398 ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError());
399 if (ret)
401 ok(size == sizeof(flagsAndEmptyFilePEImage), "Unexpected size %d\n",
402 size);
403 ok(!memcmp(buf, flagsAndEmptyFilePEImage,
404 sizeof(flagsAndEmptyFilePEImage)), "Unexpected value\n");
405 LocalFree(buf);
407 /* Finally, a non-empty file: */
408 U(link).pwszFile = (LPWSTR)nihongoURL;
409 ret = pCryptEncodeObjectEx(X509_ASN_ENCODING, SPC_PE_IMAGE_DATA_STRUCT,
410 &imageData, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
411 ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError());
412 if (ret)
414 ok(size == sizeof(flagsAndFilePEImage), "Unexpected size %d\n", size);
415 ok(!memcmp(buf, flagsAndFilePEImage, sizeof(flagsAndFilePEImage)),
416 "Unexpected value\n");
417 LocalFree(buf);
421 static void test_decodeSPCPEImage(void)
423 static const WCHAR emptyString[] = { 0 };
424 BOOL ret;
425 LPBYTE buf = NULL;
426 DWORD size = 0;
427 SPC_PE_IMAGE_DATA *imageData;
429 if (!pCryptDecodeObjectEx)
431 win_skip("CryptDecodeObjectEx() is not available. Skipping the decodeSPCPEImage tests\n");
432 return;
435 ret = pCryptDecodeObjectEx(X509_ASN_ENCODING, SPC_PE_IMAGE_DATA_STRUCT,
436 emptySequence, sizeof(emptySequence),
437 CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size);
438 ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
439 if (ret)
441 imageData = (SPC_PE_IMAGE_DATA *)buf;
442 ok(imageData->Flags.cbData == 0, "Expected empty flags, got %d\n",
443 imageData->Flags.cbData);
444 ok(imageData->pFile == NULL, "Expected no file\n");
445 LocalFree(buf);
447 ret = pCryptDecodeObjectEx(X509_ASN_ENCODING, SPC_PE_IMAGE_DATA_STRUCT,
448 onlyFlagsPEImage, sizeof(onlyFlagsPEImage),
449 CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size);
450 ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
451 if (ret)
453 imageData = (SPC_PE_IMAGE_DATA *)buf;
454 ok(imageData->Flags.cbData == sizeof(flags),
455 "Unexpected flags size %d\n", imageData->Flags.cbData);
456 if (imageData->Flags.cbData)
457 ok(!memcmp(imageData->Flags.pbData, flags, sizeof(flags)),
458 "Unexpected flags\n");
459 ok(imageData->pFile == NULL, "Expected no file\n");
460 LocalFree(buf);
462 ret = pCryptDecodeObjectEx(X509_ASN_ENCODING, SPC_PE_IMAGE_DATA_STRUCT,
463 onlyEmptyFilePEImage, sizeof(onlyEmptyFilePEImage),
464 CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size);
465 ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
466 if (ret)
468 imageData = (SPC_PE_IMAGE_DATA *)buf;
469 ok(imageData->Flags.cbData == 0, "Expected empty flags, got %d\n",
470 imageData->Flags.cbData);
471 ok(imageData->pFile != NULL, "Expected a file\n");
472 if (imageData->pFile)
474 ok(imageData->pFile->dwLinkChoice == SPC_FILE_LINK_CHOICE,
475 "Expected SPC_FILE_LINK_CHOICE, got %d\n",
476 imageData->pFile->dwLinkChoice);
477 ok(!lstrcmpW(U(*imageData->pFile).pwszFile, emptyString),
478 "Unexpected file\n");
480 LocalFree(buf);
482 ret = pCryptDecodeObjectEx(X509_ASN_ENCODING, SPC_PE_IMAGE_DATA_STRUCT,
483 flagsAndEmptyFilePEImage, sizeof(flagsAndEmptyFilePEImage),
484 CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size);
485 ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
486 if (ret)
488 imageData = (SPC_PE_IMAGE_DATA *)buf;
489 ok(imageData->Flags.cbData == sizeof(flags),
490 "Unexpected flags size %d\n", imageData->Flags.cbData);
491 if (imageData->Flags.cbData)
492 ok(!memcmp(imageData->Flags.pbData, flags, sizeof(flags)),
493 "Unexpected flags\n");
494 ok(imageData->pFile != NULL, "Expected a file\n");
495 if (imageData->pFile)
497 ok(imageData->pFile->dwLinkChoice == SPC_FILE_LINK_CHOICE,
498 "Expected SPC_FILE_LINK_CHOICE, got %d\n",
499 imageData->pFile->dwLinkChoice);
500 ok(!lstrcmpW(U(*imageData->pFile).pwszFile, emptyString),
501 "Unexpected file\n");
503 LocalFree(buf);
505 ret = pCryptDecodeObjectEx(X509_ASN_ENCODING, SPC_PE_IMAGE_DATA_STRUCT,
506 flagsAndFilePEImage, sizeof(flagsAndFilePEImage),
507 CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size);
508 ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
509 if (ret)
511 imageData = (SPC_PE_IMAGE_DATA *)buf;
512 ok(imageData->Flags.cbData == sizeof(flags),
513 "Unexpected flags size %d\n", imageData->Flags.cbData);
514 if (imageData->Flags.cbData)
515 ok(!memcmp(imageData->Flags.pbData, flags, sizeof(flags)),
516 "Unexpected flags\n");
517 ok(imageData->pFile != NULL, "Expected a file\n");
518 if (imageData->pFile)
520 ok(imageData->pFile->dwLinkChoice == SPC_FILE_LINK_CHOICE,
521 "Expected SPC_FILE_LINK_CHOICE, got %d\n",
522 imageData->pFile->dwLinkChoice);
523 ok(!lstrcmpW(U(*imageData->pFile).pwszFile, nihongoURL),
524 "Unexpected file\n");
526 LocalFree(buf);
530 static WCHAR foo[] = { 'f','o','o',0 };
531 static WCHAR guidStr[] = { '{','8','b','c','9','6','b','0','0','-',
532 '8','d','a','1','-','1','1','c','f','-','8','7','3','6','-','0','0',
533 'a','a','0','0','a','4','8','5','e','b','}',0 };
535 static const BYTE emptyCatMemberInfo[] = { 0x30,0x05,0x1e,0x00,0x02,0x01,0x00 };
536 static const BYTE catMemberInfoWithSillyGuid[] = {
537 0x30,0x0b,0x1e,0x06,0x00,0x66,0x00,0x6f,0x00,0x6f,0x02,0x01,0x00 };
538 static const BYTE catMemberInfoWithGuid[] = {
539 0x30,0x51,0x1e,0x4c,0x00,0x7b,0x00,0x38,0x00,0x62,0x00,0x63,0x00,0x39,0x00,0x36,
540 0x00,0x62,0x00,0x30,0x00,0x30,0x00,0x2d,0x00,0x38,0x00,0x64,0x00,0x61,0x00,0x31,
541 0x00,0x2d,0x00,0x31,0x00,0x31,0x00,0x63,0x00,0x66,0x00,0x2d,0x00,0x38,0x00,0x37,
542 0x00,0x33,0x00,0x36,0x00,0x2d,0x00,0x30,0x00,0x30,0x00,0x61,0x00,0x61,0x00,0x30,
543 0x00,0x30,0x00,0x61,0x00,0x34,0x00,0x38,0x00,0x35,0x00,0x65,0x00,0x62,0x00,0x7d,
544 0x02,0x01,0x00 };
546 static void test_encodeCatMemberInfo(void)
548 CAT_MEMBERINFO info;
549 BOOL ret;
550 DWORD size = 0;
551 LPBYTE buf;
553 memset(&info, 0, sizeof(info));
555 if (!pCryptEncodeObjectEx)
557 win_skip("CryptEncodeObjectEx() is not available. Skipping the encodeCatMemberInfo tests\n");
558 return;
561 ret = pCryptEncodeObjectEx(X509_ASN_ENCODING, CAT_MEMBERINFO_STRUCT,
562 &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
563 ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError());
564 if (ret)
566 ok(size == sizeof(emptyCatMemberInfo), "Unexpected size %d\n", size);
567 ok(!memcmp(buf, emptyCatMemberInfo, sizeof(emptyCatMemberInfo)),
568 "Unexpected value\n");
569 LocalFree(buf);
571 info.pwszSubjGuid = foo;
572 ret = pCryptEncodeObjectEx(X509_ASN_ENCODING, CAT_MEMBERINFO_STRUCT,
573 &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
574 ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError());
575 if (ret)
577 ok(size == sizeof(catMemberInfoWithSillyGuid), "Unexpected size %d\n",
578 size);
579 ok(!memcmp(buf, catMemberInfoWithSillyGuid,
580 sizeof(catMemberInfoWithSillyGuid)), "Unexpected value\n");
581 LocalFree(buf);
583 info.pwszSubjGuid = guidStr;
584 ret = pCryptEncodeObjectEx(X509_ASN_ENCODING, CAT_MEMBERINFO_STRUCT,
585 &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
586 ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError());
587 if (ret)
589 ok(size == sizeof(catMemberInfoWithGuid), "Unexpected size %d\n",
590 size);
591 ok(!memcmp(buf, catMemberInfoWithGuid, sizeof(catMemberInfoWithGuid)),
592 "Unexpected value\n");
593 LocalFree(buf);
597 static void test_decodeCatMemberInfo(void)
599 BOOL ret;
600 LPBYTE buf;
601 DWORD size;
602 CAT_MEMBERINFO *info;
604 if (!pCryptDecodeObjectEx)
606 win_skip("CryptDecodeObjectEx() is not available. Skipping the decodeCatMemberInfo tests\n");
607 return;
610 ret = pCryptDecodeObjectEx(X509_ASN_ENCODING, CAT_MEMBERINFO_STRUCT,
611 emptyCatMemberInfo, sizeof(emptyCatMemberInfo),
612 CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size);
613 ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
614 if (ret)
616 info = (CAT_MEMBERINFO *)buf;
617 ok(!info->pwszSubjGuid || !info->pwszSubjGuid[0],
618 "expected empty pwszSubjGuid\n");
619 ok(info->dwCertVersion == 0, "expected dwCertVersion == 0, got %d\n",
620 info->dwCertVersion);
621 LocalFree(buf);
623 ret = pCryptDecodeObjectEx(X509_ASN_ENCODING, CAT_MEMBERINFO_STRUCT,
624 catMemberInfoWithSillyGuid, sizeof(catMemberInfoWithSillyGuid),
625 CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size);
626 ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
627 if (ret)
629 info = (CAT_MEMBERINFO *)buf;
630 ok(info->pwszSubjGuid && !lstrcmpW(info->pwszSubjGuid, foo),
631 "unexpected pwszSubjGuid\n");
632 ok(info->dwCertVersion == 0, "expected dwCertVersion == 0, got %d\n",
633 info->dwCertVersion);
634 LocalFree(buf);
636 ret = pCryptDecodeObjectEx(X509_ASN_ENCODING, CAT_MEMBERINFO_STRUCT,
637 catMemberInfoWithGuid, sizeof(catMemberInfoWithGuid),
638 CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size);
639 ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
640 if (ret)
642 info = (CAT_MEMBERINFO *)buf;
643 ok(info->pwszSubjGuid && !lstrcmpW(info->pwszSubjGuid, guidStr),
644 "unexpected pwszSubjGuid\n");
645 ok(info->dwCertVersion == 0, "expected dwCertVersion == 0, got %d\n",
646 info->dwCertVersion);
647 LocalFree(buf);
651 static const BYTE emptyCatNameValue[] = {
652 0x30,0x07,0x1e,0x00,0x02,0x01,0x00,0x04,0x00 };
653 static const BYTE catNameValueWithTag[] = {
654 0x30,0x0d,0x1e,0x06,0x00,0x66,0x00,0x6f,0x00,0x6f,0x02,0x01,0x00,0x04,0x00 };
655 static const BYTE catNameValueWithFlags[] = {
656 0x30,0x0a,0x1e,0x00,0x02,0x04,0xf0,0x0d,0xd0,0x0d,0x04,0x00 };
657 static const BYTE catNameValueWithValue[] = {
658 0x30,0x0b,0x1e,0x00,0x02,0x01,0x00,0x04,0x04,0x01,0x02,0x03,0x04 };
660 static BYTE aVal[] = { 1,2,3,4 };
662 static void test_encodeCatNameValue(void)
664 static WCHAR foo[] = { 'f','o','o',0 };
665 BOOL ret;
666 LPBYTE buf;
667 DWORD size;
668 CAT_NAMEVALUE value;
670 memset(&value, 0, sizeof(value));
671 ret = pCryptEncodeObjectEx(X509_ASN_ENCODING, CAT_NAMEVALUE_STRUCT,
672 &value, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
673 ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError());
674 if (ret)
676 ok(size == sizeof(emptyCatNameValue), "Unexpected size %d\n", size);
677 ok(!memcmp(buf, emptyCatNameValue, sizeof(emptyCatNameValue)),
678 "Unexpected value\n");
679 LocalFree(buf);
681 value.pwszTag = foo;
682 ret = pCryptEncodeObjectEx(X509_ASN_ENCODING, CAT_NAMEVALUE_STRUCT,
683 &value, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
684 ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError());
685 if (ret)
687 ok(size == sizeof(catNameValueWithTag), "Unexpected size %d\n", size);
688 ok(!memcmp(buf, catNameValueWithTag, sizeof(catNameValueWithTag)),
689 "Unexpected value\n");
690 LocalFree(buf);
692 value.pwszTag = NULL;
693 value.fdwFlags = 0xf00dd00d;
694 ret = pCryptEncodeObjectEx(X509_ASN_ENCODING, CAT_NAMEVALUE_STRUCT,
695 &value, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
696 ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError());
697 if (ret)
699 ok(size == sizeof(catNameValueWithFlags), "Unexpected size %d\n", size);
700 ok(!memcmp(buf, catNameValueWithFlags, sizeof(catNameValueWithFlags)),
701 "Unexpected value\n");
702 LocalFree(buf);
704 value.fdwFlags = 0;
705 value.Value.cbData = sizeof(aVal);
706 value.Value.pbData = aVal;
707 ret = pCryptEncodeObjectEx(X509_ASN_ENCODING, CAT_NAMEVALUE_STRUCT,
708 &value, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
709 ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError());
710 if (ret)
712 ok(size == sizeof(catNameValueWithValue), "Unexpected size %d\n", size);
713 ok(!memcmp(buf, catNameValueWithValue, sizeof(catNameValueWithValue)),
714 "Unexpected value\n");
715 LocalFree(buf);
719 static void test_decodeCatNameValue(void)
721 BOOL ret;
722 LPBYTE buf;
723 DWORD size;
724 CAT_NAMEVALUE *value;
726 buf = NULL;
727 ret = pCryptDecodeObjectEx(X509_ASN_ENCODING, CAT_NAMEVALUE_STRUCT,
728 emptyCatNameValue, sizeof(emptyCatNameValue),
729 CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size);
730 ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
731 if (ret)
733 value = (CAT_NAMEVALUE *)buf;
734 ok(!value->pwszTag || !value->pwszTag[0], "expected empty pwszTag\n");
735 ok(value->fdwFlags == 0, "expected fdwFlags == 0, got %08x\n",
736 value->fdwFlags);
737 ok(value->Value.cbData == 0, "expected 0-length value, got %d\n",
738 value->Value.cbData);
739 LocalFree(buf);
741 buf = NULL;
742 ret = pCryptDecodeObjectEx(X509_ASN_ENCODING, CAT_NAMEVALUE_STRUCT,
743 catNameValueWithTag, sizeof(catNameValueWithTag),
744 CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size);
745 ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
746 if (ret)
748 value = (CAT_NAMEVALUE *)buf;
749 ok(value->pwszTag && !lstrcmpW(value->pwszTag, foo),
750 "unexpected pwszTag\n");
751 ok(value->fdwFlags == 0, "expected fdwFlags == 0, got %08x\n",
752 value->fdwFlags);
753 ok(value->Value.cbData == 0, "expected 0-length value, got %d\n",
754 value->Value.cbData);
755 LocalFree(buf);
757 buf = NULL;
758 ret = pCryptDecodeObjectEx(X509_ASN_ENCODING, CAT_NAMEVALUE_STRUCT,
759 catNameValueWithFlags, sizeof(catNameValueWithFlags),
760 CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size);
761 ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
762 if (ret)
764 value = (CAT_NAMEVALUE *)buf;
765 ok(!value->pwszTag || !value->pwszTag[0], "expected empty pwszTag\n");
766 ok(value->fdwFlags == 0xf00dd00d,
767 "expected fdwFlags == 0xf00dd00d, got %08x\n", value->fdwFlags);
768 ok(value->Value.cbData == 0, "expected 0-length value, got %d\n",
769 value->Value.cbData);
770 LocalFree(buf);
772 buf = NULL;
773 ret = pCryptDecodeObjectEx(X509_ASN_ENCODING, CAT_NAMEVALUE_STRUCT,
774 catNameValueWithValue, sizeof(catNameValueWithValue),
775 CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size);
776 ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
777 if (ret)
779 value = (CAT_NAMEVALUE *)buf;
780 ok(!value->pwszTag || !value->pwszTag[0], "expected empty pwszTag\n");
781 ok(value->fdwFlags == 0, "expected fdwFlags == 0, got %08x\n",
782 value->fdwFlags);
783 ok(value->Value.cbData == sizeof(aVal), "unexpected size %d\n",
784 value->Value.cbData);
785 ok(!memcmp(value->Value.pbData, aVal, value->Value.cbData),
786 "unexpected value\n");
787 LocalFree(buf);
791 static const WCHAR progName[] = { 'A',' ','p','r','o','g','r','a','m',0 };
792 static const BYTE spOpusInfoWithProgramName[] = {
793 0x30,0x16,0xa0,0x14,0x80,0x12,0x00,0x41,0x00,0x20,0x00,0x70,0x00,0x72,0x00,0x6f,
794 0x00,0x67,0x00,0x72,0x00,0x61,0x00,0x6d };
795 static WCHAR winehq[] = { 'h','t','t','p',':','/','/','w','i','n','e','h','q',
796 '.','o','r','g','/',0 };
797 static const BYTE spOpusInfoWithMoreInfo[] = {
798 0x30,0x16,0xa1,0x14,0x80,0x12,0x68,0x74,0x74,0x70,0x3a,0x2f,0x2f,0x77,0x69,0x6e,
799 0x65,0x68,0x71,0x2e,0x6f,0x72,0x67,0x2f };
800 static const BYTE spOpusInfoWithPublisherInfo[] = {
801 0x30,0x16,0xa2,0x14,0x80,0x12,0x68,0x74,0x74,0x70,0x3a,0x2f,0x2f,0x77,0x69,0x6e,
802 0x65,0x68,0x71,0x2e,0x6f,0x72,0x67,0x2f };
804 static void test_encodeSpOpusInfo(void)
806 BOOL ret;
807 LPBYTE buf;
808 DWORD size;
809 SPC_SP_OPUS_INFO info;
810 SPC_LINK moreInfo;
812 memset(&info, 0, sizeof(info));
813 ret = pCryptEncodeObjectEx(X509_ASN_ENCODING, SPC_SP_OPUS_INFO_STRUCT,
814 &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
815 ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError());
816 if (ret)
818 ok(size == sizeof(emptySequence), "unexpected size %d\n", size);
819 ok(!memcmp(buf, emptySequence, size), "unexpected value\n");
820 LocalFree(buf);
822 info.pwszProgramName = progName;
823 ret = pCryptEncodeObjectEx(X509_ASN_ENCODING, SPC_SP_OPUS_INFO_STRUCT,
824 &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
825 ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError());
826 if (ret)
828 ok(size == sizeof(spOpusInfoWithProgramName), "unexpected size %d\n",
829 size);
830 ok(!memcmp(buf, spOpusInfoWithProgramName, size),
831 "unexpected value\n");
832 LocalFree(buf);
834 info.pwszProgramName = NULL;
835 memset(&moreInfo, 0, sizeof(moreInfo));
836 info.pMoreInfo = &moreInfo;
837 SetLastError(0xdeadbeef);
838 ret = pCryptEncodeObjectEx(X509_ASN_ENCODING, SPC_SP_OPUS_INFO_STRUCT,
839 &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
840 ok(!ret && GetLastError() == E_INVALIDARG,
841 "expected E_INVALIDARG, got %08x\n", GetLastError());
842 moreInfo.dwLinkChoice = SPC_URL_LINK_CHOICE;
843 U(moreInfo).pwszUrl = winehq;
844 ret = pCryptEncodeObjectEx(X509_ASN_ENCODING, SPC_SP_OPUS_INFO_STRUCT,
845 &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
846 ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError());
847 if (ret)
849 ok(size == sizeof(spOpusInfoWithMoreInfo),
850 "unexpected size %d\n", size);
851 ok(!memcmp(buf, spOpusInfoWithMoreInfo, size),
852 "unexpected value\n");
853 LocalFree(buf);
855 info.pMoreInfo = NULL;
856 info.pPublisherInfo = &moreInfo;
857 ret = pCryptEncodeObjectEx(X509_ASN_ENCODING, SPC_SP_OPUS_INFO_STRUCT,
858 &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
859 ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError());
860 if (ret)
862 ok(size == sizeof(spOpusInfoWithPublisherInfo),
863 "unexpected size %d\n", size);
864 ok(!memcmp(buf, spOpusInfoWithPublisherInfo, size),
865 "unexpected value\n");
866 LocalFree(buf);
870 static void test_decodeSpOpusInfo(void)
872 BOOL ret;
873 DWORD size;
874 SPC_SP_OPUS_INFO *info;
876 ret = pCryptDecodeObjectEx(X509_ASN_ENCODING, SPC_SP_OPUS_INFO_STRUCT,
877 emptySequence, sizeof(emptySequence), CRYPT_DECODE_ALLOC_FLAG, NULL,
878 &info, &size);
879 ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
880 if (ret)
882 ok(!info->pwszProgramName, "expected NULL\n");
883 ok(!info->pMoreInfo, "expected NULL\n");
884 ok(!info->pPublisherInfo, "expected NULL\n");
885 LocalFree(info);
887 ret = pCryptDecodeObjectEx(X509_ASN_ENCODING, SPC_SP_OPUS_INFO_STRUCT,
888 spOpusInfoWithProgramName, sizeof(spOpusInfoWithProgramName),
889 CRYPT_DECODE_ALLOC_FLAG, NULL, &info, &size);
890 ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
891 if (ret)
893 ok(info->pwszProgramName && !lstrcmpW(info->pwszProgramName,
894 progName), "unexpected program name\n");
895 ok(!info->pMoreInfo, "expected NULL\n");
896 ok(!info->pPublisherInfo, "expected NULL\n");
897 LocalFree(info);
899 ret = pCryptDecodeObjectEx(X509_ASN_ENCODING, SPC_SP_OPUS_INFO_STRUCT,
900 spOpusInfoWithMoreInfo, sizeof(spOpusInfoWithMoreInfo),
901 CRYPT_DECODE_ALLOC_FLAG, NULL, &info, &size);
902 ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
903 if (ret)
905 ok(!info->pwszProgramName, "expected NULL\n");
906 ok(info->pMoreInfo != NULL, "expected a value for pMoreInfo\n");
907 if (info->pMoreInfo)
909 ok(info->pMoreInfo->dwLinkChoice == SPC_URL_LINK_CHOICE,
910 "unexpected link choice %d\n", info->pMoreInfo->dwLinkChoice);
911 ok(!lstrcmpW(U(*info->pMoreInfo).pwszUrl, winehq),
912 "unexpected link value\n");
914 ok(!info->pPublisherInfo, "expected NULL\n");
915 LocalFree(info);
917 ret = pCryptDecodeObjectEx(X509_ASN_ENCODING, SPC_SP_OPUS_INFO_STRUCT,
918 spOpusInfoWithPublisherInfo, sizeof(spOpusInfoWithPublisherInfo),
919 CRYPT_DECODE_ALLOC_FLAG, NULL, &info, &size);
920 ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
921 if (ret)
923 ok(!info->pwszProgramName, "expected NULL\n");
924 ok(!info->pMoreInfo, "expected NULL\n");
925 ok(info->pPublisherInfo != NULL,
926 "expected a value for pPublisherInfo\n");
927 if (info->pPublisherInfo)
929 ok(info->pPublisherInfo->dwLinkChoice == SPC_URL_LINK_CHOICE,
930 "unexpected link choice %d\n",
931 info->pPublisherInfo->dwLinkChoice);
932 ok(!lstrcmpW(U(*info->pPublisherInfo).pwszUrl, winehq),
933 "unexpected link value\n");
935 LocalFree(info);
939 START_TEST(asn)
941 HMODULE hCrypt32 = LoadLibraryA("crypt32.dll");
942 pCryptDecodeObjectEx = (void*)GetProcAddress(hCrypt32, "CryptDecodeObjectEx");
943 pCryptEncodeObjectEx = (void*)GetProcAddress(hCrypt32, "CryptEncodeObjectEx");
945 test_encodeSPCFinancialCriteria();
946 test_decodeSPCFinancialCriteria();
947 test_encodeSPCLink();
948 test_decodeSPCLink();
949 test_encodeSPCPEImage();
950 test_decodeSPCPEImage();
951 test_encodeCatMemberInfo();
952 test_decodeCatMemberInfo();
953 test_encodeCatNameValue();
954 test_decodeCatNameValue();
955 test_encodeSpOpusInfo();
956 test_decodeSpOpusInfo();
958 FreeLibrary(hCrypt32);