ReactOS 0.4.16-dev-2491-g3dc6630
asn.c
Go to the documentation of this file.
1/* wintrust asn functions
2 *
3 * Copyright 2007 Juan Lang
4 *
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.
9 *
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.
14 *
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
18 *
19 */
20
21#include <stdarg.h>
22#include <stdio.h>
23#include <assert.h>
24
25#include "windef.h"
26#include "winbase.h"
27#include "winerror.h"
28#include "wincrypt.h"
29#include "wintrust.h"
30#include "snmp.h"
31#include "winternl.h"
32#include "wine/debug.h"
33#include "wine/exception.h"
34
36
37#ifdef WORDS_BIGENDIAN
38
39#define hton16(x) (x)
40#define n16toh(x) (x)
41
42#else
43
44#define hton16(x) RtlUshortByteSwap(x)
45#define n16toh(x) RtlUshortByteSwap(x)
46
47#endif
48
49#define ASN_BOOL (ASN_UNIVERSAL | ASN_PRIMITIVE | 0x01)
50#define ASN_BITSTRING (ASN_UNIVERSAL | ASN_PRIMITIVE | 0x03)
51#define ASN_BMPSTRING (ASN_UNIVERSAL | ASN_PRIMITIVE | 0x1e)
52
53static BOOL CRYPT_EncodeLen(DWORD len, BYTE *pbEncoded, DWORD *pcbEncoded)
54{
55 DWORD bytesNeeded, significantBytes = 0;
56
57 if (len <= 0x7f)
58 bytesNeeded = 1;
59 else
60 {
61 DWORD temp;
62
63 for (temp = len, significantBytes = sizeof(temp); !(temp & 0xff000000);
64 temp <<= 8, significantBytes--)
65 ;
66 bytesNeeded = significantBytes + 1;
67 }
68 if (!pbEncoded)
69 {
70 *pcbEncoded = bytesNeeded;
71 return TRUE;
72 }
73 if (*pcbEncoded < bytesNeeded)
74 {
76 return FALSE;
77 }
78 if (len <= 0x7f)
79 *pbEncoded = (BYTE)len;
80 else
81 {
82 DWORD i;
83
84 *pbEncoded++ = significantBytes | 0x80;
85 for (i = 0; i < significantBytes; i++)
86 {
87 *(pbEncoded + significantBytes - i - 1) = (BYTE)(len & 0xff);
88 len >>= 8;
89 }
90 }
91 *pcbEncoded = bytesNeeded;
92 return TRUE;
93}
94
95static BOOL WINAPI CRYPT_AsnEncodeOctets(DWORD dwCertEncodingType,
96 LPCSTR lpszStructType, const void *pvStructInfo, BYTE *pbEncoded,
97 DWORD *pcbEncoded)
98{
99 BOOL ret = TRUE;
100 const CRYPT_DATA_BLOB *blob = pvStructInfo;
101 DWORD bytesNeeded, lenBytes;
102
103 TRACE("(%ld, %p), %p, %ld\n", blob->cbData, blob->pbData, pbEncoded,
104 *pcbEncoded);
105
106 CRYPT_EncodeLen(blob->cbData, NULL, &lenBytes);
107 bytesNeeded = 1 + lenBytes + blob->cbData;
108 if (!pbEncoded)
109 *pcbEncoded = bytesNeeded;
110 else if (*pcbEncoded < bytesNeeded)
111 {
112 *pcbEncoded = bytesNeeded;
114 ret = FALSE;
115 }
116 else
117 {
118 *pbEncoded++ = ASN_OCTETSTRING;
119 CRYPT_EncodeLen(blob->cbData, pbEncoded, &lenBytes);
120 pbEncoded += lenBytes;
121 if (blob->cbData)
122 memcpy(pbEncoded, blob->pbData, blob->cbData);
123 }
124 TRACE("returning %d\n", ret);
125 return ret;
126}
127
129 LPCSTR lpszStructType, const void *pvStructInfo, BYTE *pbEncoded,
130 DWORD *pcbEncoded)
131{
132 BOOL ret = FALSE;
133
134 TRACE("(0x%08lx, %s, %p, %p, %p)\n", dwCertEncodingType,
135 debugstr_a(lpszStructType), pvStructInfo, pbEncoded,
136 pcbEncoded);
137
138 __TRY
139 {
140 const SPC_LINK *link = pvStructInfo;
141 DWORD bytesNeeded, lenBytes;
142
143 switch (link->dwLinkChoice)
144 {
146 {
147 DWORD fileNameLen, fileNameLenBytes;
148 LPWSTR ptr;
149
150 fileNameLen = link->pwszFile ?
151 lstrlenW(link->pwszFile) * sizeof(WCHAR) : 0;
152 CRYPT_EncodeLen(fileNameLen, NULL, &fileNameLenBytes);
153 CRYPT_EncodeLen(1 + fileNameLenBytes + fileNameLen, NULL,
154 &lenBytes);
155 bytesNeeded = 2 + lenBytes + fileNameLenBytes + fileNameLen;
156 if (!pbEncoded)
157 {
158 *pcbEncoded = bytesNeeded;
159 ret = TRUE;
160 }
161 else if (*pcbEncoded < bytesNeeded)
162 {
164 *pcbEncoded = bytesNeeded;
165 }
166 else
167 {
168 *pcbEncoded = bytesNeeded;
169 *pbEncoded++ = ASN_CONSTRUCTOR | ASN_CONTEXT | 2;
170 CRYPT_EncodeLen(1 + fileNameLenBytes + fileNameLen, pbEncoded,
171 &lenBytes);
172 pbEncoded += lenBytes;
173 *pbEncoded++ = ASN_CONTEXT;
174 CRYPT_EncodeLen(fileNameLen, pbEncoded, &fileNameLenBytes);
175 pbEncoded += fileNameLenBytes;
176 for (ptr = link->pwszFile; ptr && *ptr; ptr++)
177 {
178 *(WCHAR *)pbEncoded = hton16(*ptr);
179 pbEncoded += sizeof(WCHAR);
180 }
181 ret = TRUE;
182 }
183 break;
184 }
186 {
187 DWORD classIdLenBytes, dataLenBytes, dataLen;
188 CRYPT_DATA_BLOB classId = { sizeof(link->Moniker.ClassId),
189 (BYTE *)link->Moniker.ClassId };
190
191 CRYPT_EncodeLen(classId.cbData, NULL, &classIdLenBytes);
192 CRYPT_EncodeLen(link->Moniker.SerializedData.cbData, NULL,
193 &dataLenBytes);
194 dataLen = 2 + classIdLenBytes + classId.cbData +
195 dataLenBytes + link->Moniker.SerializedData.cbData;
196 CRYPT_EncodeLen(dataLen, NULL, &lenBytes);
197 bytesNeeded = 1 + dataLen + lenBytes;
198 if (!pbEncoded)
199 {
200 *pcbEncoded = bytesNeeded;
201 ret = TRUE;
202 }
203 else if (*pcbEncoded < bytesNeeded)
204 {
206 *pcbEncoded = bytesNeeded;
207 }
208 else
209 {
210 DWORD size;
211
212 *pcbEncoded = bytesNeeded;
213 *pbEncoded++ = ASN_CONSTRUCTOR | ASN_CONTEXT | 1;
214 CRYPT_EncodeLen(dataLen, pbEncoded, &lenBytes);
215 pbEncoded += lenBytes;
216 size = 1 + classIdLenBytes + classId.cbData;
218 pbEncoded, &size);
219 pbEncoded += size;
220 size = 1 + dataLenBytes + link->Moniker.SerializedData.cbData;
222 &link->Moniker.SerializedData, pbEncoded, &size);
223 pbEncoded += size;
224 ret = TRUE;
225 }
226 break;
227 }
229 {
230 LPWSTR ptr;
231 DWORD urlLen;
232
233 /* Check for invalid characters in URL */
234 ret = TRUE;
235 urlLen = 0;
236 for (ptr = link->pwszUrl; ptr && *ptr && ret; ptr++)
237 if (*ptr > 0x7f)
238 {
239 *pcbEncoded = 0;
241 ret = FALSE;
242 }
243 else
244 urlLen++;
245 if (ret)
246 {
247 CRYPT_EncodeLen(urlLen, NULL, &lenBytes);
248 bytesNeeded = 1 + lenBytes + urlLen;
249 if (!pbEncoded)
250 *pcbEncoded = bytesNeeded;
251 else if (*pcbEncoded < bytesNeeded)
252 {
254 *pcbEncoded = bytesNeeded;
255 ret = FALSE;
256 }
257 else
258 {
259 *pcbEncoded = bytesNeeded;
260 *pbEncoded++ = ASN_CONTEXT;
261 CRYPT_EncodeLen(urlLen, pbEncoded, &lenBytes);
262 pbEncoded += lenBytes;
263 for (ptr = link->pwszUrl; ptr && *ptr; ptr++)
264 *pbEncoded++ = (BYTE)*ptr;
265 }
266 }
267 break;
268 }
269 default:
271 }
272 }
274 {
276 }
278 TRACE("returning %d\n", ret);
279 return ret;
280}
281
282typedef BOOL (WINAPI *CryptEncodeObjectFunc)(DWORD, LPCSTR, const void *,
283 BYTE *, DWORD *);
284
286{
287 const void *pvStructInfo;
289 DWORD size; /* used during encoding, not for your use */
290};
291
292static BOOL CRYPT_AsnEncodeSequence(DWORD dwCertEncodingType,
293 struct AsnEncodeSequenceItem items[], DWORD cItem, BYTE *pbEncoded,
294 DWORD *pcbEncoded)
295{
296 BOOL ret;
297 DWORD i, dataLen = 0;
298
299 TRACE("%p, %ld, %p, %ld\n", items, cItem, pbEncoded, *pcbEncoded);
300 for (i = 0, ret = TRUE; ret && i < cItem; i++)
301 {
302 ret = items[i].encodeFunc(dwCertEncodingType, NULL,
303 items[i].pvStructInfo, NULL, &items[i].size);
304 /* Some functions propagate their errors through the size */
305 if (!ret)
306 *pcbEncoded = items[i].size;
307 dataLen += items[i].size;
308 }
309 if (ret)
310 {
311 DWORD lenBytes, bytesNeeded;
312
313 CRYPT_EncodeLen(dataLen, NULL, &lenBytes);
314 bytesNeeded = 1 + lenBytes + dataLen;
315 if (!pbEncoded)
316 *pcbEncoded = bytesNeeded;
317 else if (*pcbEncoded < bytesNeeded)
318 {
319 *pcbEncoded = bytesNeeded;
321 ret = FALSE;
322 }
323 else
324 {
325 *pcbEncoded = bytesNeeded;
326 *pbEncoded++ = ASN_SEQUENCE;
327 CRYPT_EncodeLen(dataLen, pbEncoded, &lenBytes);
328 pbEncoded += lenBytes;
329 for (i = 0; ret && i < cItem; i++)
330 {
331 ret = items[i].encodeFunc(dwCertEncodingType, NULL,
332 items[i].pvStructInfo, pbEncoded, &items[i].size);
333 /* Some functions propagate their errors through the size */
334 if (!ret)
335 *pcbEncoded = items[i].size;
336 pbEncoded += items[i].size;
337 }
338 }
339 }
340 TRACE("returning %d\n", ret);
341 return ret;
342}
343
344static BOOL WINAPI CRYPT_AsnEncodeBits(DWORD dwCertEncodingType,
345 LPCSTR lpszStructType, const void *pvStructInfo, BYTE *pbEncoded,
346 DWORD *pcbEncoded)
347{
348 BOOL ret = FALSE;
349
350 __TRY
351 {
352 const CRYPT_BIT_BLOB *blob = pvStructInfo;
353 DWORD bytesNeeded, lenBytes, dataBytes;
354 BYTE unusedBits;
355
356 /* yep, MS allows cUnusedBits to be >= 8 */
357 if (!blob->cUnusedBits)
358 {
359 dataBytes = blob->cbData;
360 unusedBits = 0;
361 }
362 else if (blob->cbData * 8 > blob->cUnusedBits)
363 {
364 dataBytes = (blob->cbData * 8 - blob->cUnusedBits) / 8 + 1;
365 unusedBits = blob->cUnusedBits >= 8 ? blob->cUnusedBits / 8 :
366 blob->cUnusedBits;
367 }
368 else
369 {
370 dataBytes = 0;
371 unusedBits = 0;
372 }
373 CRYPT_EncodeLen(dataBytes + 1, NULL, &lenBytes);
374 bytesNeeded = 1 + lenBytes + dataBytes + 1;
375 if (!pbEncoded)
376 {
377 *pcbEncoded = bytesNeeded;
378 ret = TRUE;
379 }
380 else if (*pcbEncoded < bytesNeeded)
381 {
382 *pcbEncoded = bytesNeeded;
384 }
385 else
386 {
387 ret = TRUE;
388 *pcbEncoded = bytesNeeded;
389 *pbEncoded++ = ASN_BITSTRING;
390 CRYPT_EncodeLen(dataBytes + 1, pbEncoded, &lenBytes);
391 pbEncoded += lenBytes;
392 *pbEncoded++ = unusedBits;
393 if (dataBytes)
394 {
395 BYTE mask = 0xff << unusedBits;
396
397 if (dataBytes > 1)
398 {
399 memcpy(pbEncoded, blob->pbData, dataBytes - 1);
400 pbEncoded += dataBytes - 1;
401 }
402 *pbEncoded = *(blob->pbData + dataBytes - 1) & mask;
403 }
404 }
405 }
407 {
409 }
411 return ret;
412}
413
415{
416 BYTE tag;
417 const void *pvStructInfo;
419};
420
421static BOOL WINAPI CRYPT_AsnEncodeConstructed(DWORD dwCertEncodingType,
422 LPCSTR lpszStructType, const void *pvStructInfo, BYTE *pbEncoded,
423 DWORD *pcbEncoded)
424{
425 BOOL ret;
426 const struct AsnConstructedItem *item = pvStructInfo;
427 DWORD len;
428
429 if ((ret = item->encodeFunc(dwCertEncodingType, lpszStructType,
430 item->pvStructInfo, NULL, &len)))
431 {
432 DWORD dataLen, bytesNeeded;
433
434 CRYPT_EncodeLen(len, NULL, &dataLen);
435 bytesNeeded = 1 + dataLen + len;
436 if (!pbEncoded)
437 *pcbEncoded = bytesNeeded;
438 else if (*pcbEncoded < bytesNeeded)
439 {
440 *pcbEncoded = bytesNeeded;
442 ret = FALSE;
443 }
444 else
445 {
446 *pcbEncoded = bytesNeeded;
447 *pbEncoded++ = ASN_CONTEXT | ASN_CONSTRUCTOR | item->tag;
448 CRYPT_EncodeLen(len, pbEncoded, &dataLen);
449 pbEncoded += dataLen;
450 ret = item->encodeFunc(dwCertEncodingType, lpszStructType,
451 item->pvStructInfo, pbEncoded, &len);
452 if (!ret)
453 {
454 /* Some functions propagate their errors through the size */
455 *pcbEncoded = len;
456 }
457 }
458 }
459 else
460 {
461 /* Some functions propagate their errors through the size */
462 *pcbEncoded = len;
463 }
464 return ret;
465}
466
467
469 LPCSTR lpszStructType, const void *pvStructInfo, BYTE *pbEncoded,
470 DWORD *pcbEncoded)
471{
472 const SPC_PE_IMAGE_DATA *imageData = pvStructInfo;
473 BOOL ret = FALSE;
474
475 TRACE("(0x%08lx, %s, %p, %p, %p)\n", dwCertEncodingType,
476 debugstr_a(lpszStructType), pvStructInfo, pbEncoded,
477 pcbEncoded);
478
479 __TRY
480 {
481 struct AsnEncodeSequenceItem items[2] = {
482 { 0 }
483 };
484 struct AsnConstructedItem constructed = { 0, imageData->pFile,
486 DWORD cItem = 0;
487
488 if (imageData->Flags.cbData)
489 {
490 items[cItem].pvStructInfo = &imageData->Flags;
491 items[cItem].encodeFunc = CRYPT_AsnEncodeBits;
492 cItem++;
493 }
494 if (imageData->pFile)
495 {
496 items[cItem].pvStructInfo = &constructed;
497 items[cItem].encodeFunc = CRYPT_AsnEncodeConstructed;
498 cItem++;
499 }
500
501 ret = CRYPT_AsnEncodeSequence(dwCertEncodingType, items, cItem,
502 pbEncoded, pcbEncoded);
503 }
505 {
507 }
509 TRACE("returning %d\n", ret);
510 return ret;
511}
512
513static BOOL WINAPI CRYPT_AsnEncodeOid(DWORD dwCertEncodingType,
514 LPCSTR lpszStructType, const void *pvStructInfo, BYTE *pbEncoded,
515 DWORD *pcbEncoded)
516{
517 LPCSTR pszObjId = pvStructInfo;
518 DWORD bytesNeeded = 0, lenBytes;
519 BOOL ret = TRUE;
520 int firstPos = 0;
521 BYTE firstByte = 0;
522
523 TRACE("%s\n", debugstr_a(pszObjId));
524
525 if (pszObjId)
526 {
527 const char *ptr;
528 int val1, val2;
529
530 if (sscanf(pszObjId, "%d.%d%n", &val1, &val2, &firstPos) != 2)
531 {
533 return FALSE;
534 }
535 bytesNeeded++;
536 firstByte = val1 * 40 + val2;
537 ptr = pszObjId + firstPos;
538 if (*ptr == '.')
539 {
540 ptr++;
541 firstPos++;
542 }
543 while (ret && *ptr)
544 {
545 int pos;
546
547 /* note I assume each component is at most 32-bits long in base 2 */
548 if (sscanf(ptr, "%d%n", &val1, &pos) == 1)
549 {
550 if (val1 >= 0x10000000)
551 bytesNeeded += 5;
552 else if (val1 >= 0x200000)
553 bytesNeeded += 4;
554 else if (val1 >= 0x4000)
555 bytesNeeded += 3;
556 else if (val1 >= 0x80)
557 bytesNeeded += 2;
558 else
559 bytesNeeded += 1;
560 ptr += pos;
561 if (*ptr == '.')
562 ptr++;
563 }
564 else
565 {
567 return FALSE;
568 }
569 }
570 CRYPT_EncodeLen(bytesNeeded, NULL, &lenBytes);
571 }
572 else
573 lenBytes = 1;
574 bytesNeeded += 1 + lenBytes;
575 if (pbEncoded)
576 {
577 if (*pcbEncoded < bytesNeeded)
578 {
580 ret = FALSE;
581 }
582 else
583 {
584 *pbEncoded++ = ASN_OBJECTIDENTIFIER;
585 CRYPT_EncodeLen(bytesNeeded - 1 - lenBytes, pbEncoded, &lenBytes);
586 pbEncoded += lenBytes;
587 if (pszObjId)
588 {
589 const char *ptr;
590 int val, pos;
591
592 *pbEncoded++ = firstByte;
593 ptr = pszObjId + firstPos;
594 while (ret && *ptr)
595 {
596 sscanf(ptr, "%d%n", &val, &pos);
597 {
598 unsigned char outBytes[5];
599 int numBytes, i;
600
601 if (val >= 0x10000000)
602 numBytes = 5;
603 else if (val >= 0x200000)
604 numBytes = 4;
605 else if (val >= 0x4000)
606 numBytes = 3;
607 else if (val >= 0x80)
608 numBytes = 2;
609 else
610 numBytes = 1;
611 for (i = numBytes; i > 0; i--)
612 {
613 outBytes[i - 1] = val & 0x7f;
614 val >>= 7;
615 }
616 for (i = 0; i < numBytes - 1; i++)
617 *pbEncoded++ = outBytes[i] | 0x80;
618 *pbEncoded++ = outBytes[i];
619 ptr += pos;
620 if (*ptr == '.')
621 ptr++;
622 }
623 }
624 }
625 }
626 }
627 *pcbEncoded = bytesNeeded;
628 return ret;
629}
630
631static BOOL WINAPI CRYPT_CopyEncodedBlob(DWORD dwCertEncodingType,
632 LPCSTR lpszStructType, const void *pvStructInfo, BYTE *pbEncoded,
633 DWORD *pcbEncoded)
634{
636 BOOL ret = TRUE;
637
638 if (!pbEncoded)
639 *pcbEncoded = blob->cbData;
640 else if (*pcbEncoded < blob->cbData)
641 {
642 *pcbEncoded = blob->cbData;
644 ret = FALSE;
645 }
646 else
647 {
648 if (blob->cbData)
649 memcpy(pbEncoded, blob->pbData, blob->cbData);
650 *pcbEncoded = blob->cbData;
651 }
652 return ret;
653}
654
655/* Different from the one in crypt32 */
657 DWORD dwCertEncodingType, LPCSTR lpszStructType, const void *pvStructInfo,
658 BYTE *pbEncoded, DWORD *pcbEncoded)
659{
661 static const BYTE asn1Null[] = { ASN_NULL, 0 };
662 static const CRYPT_DATA_BLOB nullBlob = { sizeof(asn1Null),
663 (LPBYTE)asn1Null };
664 BOOL ret;
665 struct AsnEncodeSequenceItem items[2] = {
666 { algo->pszObjId, CRYPT_AsnEncodeOid, 0 },
668 };
669 DWORD cItem = 2;
670
671 if (algo->Parameters.cbData)
672 items[1].pvStructInfo = &algo->Parameters;
673 else if (algo->pszObjId)
674 items[1].pvStructInfo = &nullBlob;
675 else
676 cItem -= 1;
677 ret = CRYPT_AsnEncodeSequence(dwCertEncodingType, items, cItem,
678 pbEncoded, pcbEncoded);
679 return ret;
680}
681
683 LPCSTR lpszStructType, const void *pvStructInfo, BYTE *pbEncoded,
684 DWORD *pcbEncoded)
685{
686 const CRYPT_ATTRIBUTE_TYPE_VALUE *typeValue = pvStructInfo;
687 struct AsnEncodeSequenceItem items[] = {
688 { typeValue->pszObjId, CRYPT_AsnEncodeOid, 0 },
689 { &typeValue->Value, CRYPT_CopyEncodedBlob, 0 },
690 };
691
693 pbEncoded, pcbEncoded);
694}
695
697{
700};
701
702static BOOL WINAPI CRYPT_AsnEncodeSPCDigest(DWORD dwCertEncodingType,
703 LPCSTR lpszStructType, const void *pvStructInfo, BYTE *pbEncoded,
704 DWORD *pcbEncoded)
705{
706 const struct SPCDigest *digest = pvStructInfo;
707 struct AsnEncodeSequenceItem items[] = {
709 { &digest->Digest, CRYPT_AsnEncodeOctets, 0 },
710 };
711
713 pbEncoded, pcbEncoded);
714}
715
717 LPCSTR lpszStructType, const void *pvStructInfo, BYTE *pbEncoded,
718 DWORD *pcbEncoded)
719{
720 BOOL ret = FALSE;
721
722 TRACE("(0x%08lx, %s, %p, %p, %p)\n", dwCertEncodingType,
723 debugstr_a(lpszStructType), pvStructInfo, pbEncoded, pcbEncoded);
724
725 __TRY
726 {
728 struct AsnEncodeSequenceItem items[] = {
730 { &data->DigestAlgorithm, CRYPT_AsnEncodeSPCDigest, 0 },
731 };
732
734 pbEncoded, pcbEncoded);
735 }
737 {
739 }
741 return ret;
742}
743
744static BOOL WINAPI CRYPT_AsnEncodeBMPString(DWORD dwCertEncodingType,
745 LPCSTR lpszStructType, const void *pvStructInfo, BYTE *pbEncoded,
746 DWORD *pcbEncoded)
747{
748 BOOL ret = TRUE;
750 DWORD bytesNeeded, lenBytes, strLen;
751
752 if (str)
753 strLen = lstrlenW(str);
754 else
755 strLen = 0;
756 CRYPT_EncodeLen(strLen * 2, NULL, &lenBytes);
757 bytesNeeded = 1 + lenBytes + strLen * 2;
758 if (!pbEncoded)
759 *pcbEncoded = bytesNeeded;
760 else if (*pcbEncoded < bytesNeeded)
761 {
762 *pcbEncoded = bytesNeeded;
764 ret = FALSE;
765 }
766 else
767 {
768 DWORD i;
769
770 *pcbEncoded = bytesNeeded;
771 *pbEncoded++ = ASN_BMPSTRING;
772 CRYPT_EncodeLen(strLen * 2, pbEncoded, &lenBytes);
773 pbEncoded += lenBytes;
774 for (i = 0; i < strLen; i++)
775 {
776 *pbEncoded++ = (str[i] & 0xff00) >> 8;
777 *pbEncoded++ = str[i] & 0x00ff;
778 }
779 }
780 return ret;
781}
782
784{
785 BYTE tag;
786 const void *pvStructInfo;
788};
789
790/* Sort of a wacky hack, it encodes something using the struct
791 * AsnEncodeTagSwappedItem's encodeFunc, then replaces the tag byte with the tag
792 * given in the struct AsnEncodeTagSwappedItem.
793 */
794static BOOL WINAPI CRYPT_AsnEncodeSwapTag(DWORD dwCertEncodingType,
795 LPCSTR lpszStructType, const void *pvStructInfo, BYTE *pbEncoded,
796 DWORD *pcbEncoded)
797{
798 BOOL ret;
800
801 ret = item->encodeFunc(dwCertEncodingType, lpszStructType,
802 item->pvStructInfo, pbEncoded, pcbEncoded);
803 if (ret && pbEncoded)
804 *pbEncoded = item->tag;
805 return ret;
806}
807
809 LPCSTR lpszStructType, const void *pvStructInfo, BYTE *pbEncoded,
810 DWORD *pcbEncoded)
811{
812 BOOL ret = FALSE;
813
814 TRACE("(0x%08lx, %s, %p, %p, %p)\n", dwCertEncodingType,
815 debugstr_a(lpszStructType), pvStructInfo, pbEncoded, pcbEncoded);
816
817 __TRY
818 {
820
821 if (info->pMoreInfo &&
822 info->pMoreInfo->dwLinkChoice != SPC_URL_LINK_CHOICE &&
823 info->pMoreInfo->dwLinkChoice != SPC_MONIKER_LINK_CHOICE &&
824 info->pMoreInfo->dwLinkChoice != SPC_FILE_LINK_CHOICE)
826 else if (info->pPublisherInfo &&
827 info->pPublisherInfo->dwLinkChoice != SPC_URL_LINK_CHOICE &&
828 info->pPublisherInfo->dwLinkChoice != SPC_MONIKER_LINK_CHOICE &&
829 info->pPublisherInfo->dwLinkChoice != SPC_FILE_LINK_CHOICE)
831 else
832 {
833 struct AsnEncodeSequenceItem items[3] = { { 0 } };
834 struct AsnConstructedItem constructed[3] = { { 0 } };
835 struct AsnEncodeTagSwappedItem swapped;
836 DWORD cItem = 0, cConstructed = 0;
837
838 if (info->pwszProgramName)
839 {
840 swapped.tag = ASN_CONTEXT;
841 swapped.pvStructInfo = info->pwszProgramName;
843 constructed[cConstructed].tag = 0;
844 constructed[cConstructed].pvStructInfo = &swapped;
845 constructed[cConstructed].encodeFunc = CRYPT_AsnEncodeSwapTag;
846 items[cItem].pvStructInfo = &constructed[cConstructed];
847 items[cItem].encodeFunc = CRYPT_AsnEncodeConstructed;
848 cConstructed++;
849 cItem++;
850 }
851 if (info->pMoreInfo)
852 {
853 constructed[cConstructed].tag = 1;
854 constructed[cConstructed].pvStructInfo = info->pMoreInfo;
855 constructed[cConstructed].encodeFunc = WVTAsn1SpcLinkEncode;
856 items[cItem].pvStructInfo = &constructed[cConstructed];
857 items[cItem].encodeFunc = CRYPT_AsnEncodeConstructed;
858 cConstructed++;
859 cItem++;
860 }
861 if (info->pPublisherInfo)
862 {
863 constructed[cConstructed].tag = 2;
864 constructed[cConstructed].pvStructInfo = info->pPublisherInfo;
865 constructed[cConstructed].encodeFunc = WVTAsn1SpcLinkEncode;
866 items[cItem].pvStructInfo = &constructed[cConstructed];
867 items[cItem].encodeFunc = CRYPT_AsnEncodeConstructed;
868 cConstructed++;
869 cItem++;
870 }
872 items, cItem, pbEncoded, pcbEncoded);
873 }
874 }
876 {
878 }
880 return ret;
881}
882
883static BOOL CRYPT_AsnEncodeInteger(DWORD dwCertEncodingType,
884 LPCSTR lpszStructType, const void *pvStructInfo, BYTE *pbEncoded,
885 DWORD *pcbEncoded)
886{
887 BOOL ret;
888
889 __TRY
890 {
891 DWORD significantBytes, lenBytes, bytesNeeded;
892 BYTE padByte = 0;
893 BOOL pad = FALSE;
895
896 significantBytes = blob->cbData;
897 if (significantBytes)
898 {
899 if (blob->pbData[significantBytes - 1] & 0x80)
900 {
901 /* negative, lop off leading (little-endian) 0xffs */
902 for (; significantBytes > 0 &&
903 blob->pbData[significantBytes - 1] == 0xff; significantBytes--)
904 ;
905 if (blob->pbData[significantBytes - 1] < 0x80)
906 {
907 padByte = 0xff;
908 pad = TRUE;
909 }
910 }
911 else
912 {
913 /* positive, lop off leading (little-endian) zeroes */
914 for (; significantBytes > 0 &&
915 !blob->pbData[significantBytes - 1]; significantBytes--)
916 ;
917 if (significantBytes == 0)
918 significantBytes = 1;
919 if (blob->pbData[significantBytes - 1] > 0x7f)
920 {
921 padByte = 0;
922 pad = TRUE;
923 }
924 }
925 }
926 if (pad)
927 CRYPT_EncodeLen(significantBytes + 1, NULL, &lenBytes);
928 else
929 CRYPT_EncodeLen(significantBytes, NULL, &lenBytes);
930 bytesNeeded = 1 + lenBytes + significantBytes;
931 if (pad)
932 bytesNeeded++;
933 if (!pbEncoded)
934 {
935 *pcbEncoded = bytesNeeded;
936 ret = TRUE;
937 }
938 else if (*pcbEncoded < bytesNeeded)
939 {
940 *pcbEncoded = bytesNeeded;
942 ret = FALSE;
943 }
944 else
945 {
946 *pcbEncoded = bytesNeeded;
947 *pbEncoded++ = ASN_INTEGER;
948 if (pad)
949 {
950 CRYPT_EncodeLen(significantBytes + 1, pbEncoded, &lenBytes);
951 pbEncoded += lenBytes;
952 *pbEncoded++ = padByte;
953 }
954 else
955 {
956 CRYPT_EncodeLen(significantBytes, pbEncoded, &lenBytes);
957 pbEncoded += lenBytes;
958 }
959 for (; significantBytes > 0; significantBytes--)
960 *(pbEncoded++) = blob->pbData[significantBytes - 1];
961 ret = TRUE;
962 }
963 }
965 {
967 ret = FALSE;
968 }
970 return ret;
971}
972
973static BOOL WINAPI CRYPT_AsnEncodeInt(DWORD dwCertEncodingType,
974 LPCSTR lpszStructType, const void *pvStructInfo, BYTE *pbEncoded,
975 DWORD *pcbEncoded)
976{
977 CRYPT_INTEGER_BLOB blob = { sizeof(INT), (BYTE *)pvStructInfo };
978
979 return CRYPT_AsnEncodeInteger(dwCertEncodingType, X509_MULTI_BYTE_INTEGER,
980 &blob, pbEncoded, pcbEncoded);
981}
982
984 LPCSTR lpszStructType, const void *pvStructInfo, BYTE *pbEncoded,
985 DWORD *pcbEncoded)
986{
987 BOOL ret = FALSE;
988
989 TRACE("(0x%08lx, %s, %p, %p, %p)\n", dwCertEncodingType,
990 debugstr_a(lpszStructType), pvStructInfo, pbEncoded, pcbEncoded);
991
992 __TRY
993 {
995 struct AsnEncodeSequenceItem items[] = {
996 { info->pwszSubjGuid, CRYPT_AsnEncodeBMPString, 0 },
997 { &info->dwCertVersion, CRYPT_AsnEncodeInt, 0 },
998 };
999
1001 pbEncoded, pcbEncoded);
1002 }
1004 {
1006 }
1007 __ENDTRY
1008 return ret;
1009}
1010
1012 LPCSTR lpszStructType, const void *pvStructInfo, BYTE *pbEncoded,
1013 DWORD *pcbEncoded)
1014{
1015 BOOL ret = FALSE;
1016
1017 TRACE("(0x%08lx, %s, %p, %p, %p)\n", dwCertEncodingType,
1018 debugstr_a(lpszStructType), pvStructInfo, pbEncoded, pcbEncoded);
1019
1020 __TRY
1021 {
1023 struct AsnEncodeSequenceItem items[] = {
1024 { value->pwszTag, CRYPT_AsnEncodeBMPString, 0 },
1025 { &value->fdwFlags, CRYPT_AsnEncodeInt, 0 },
1026 { &value->Value, CRYPT_AsnEncodeOctets, 0 },
1027 };
1028
1030 pbEncoded, pcbEncoded);
1031 }
1033 {
1035 }
1036 __ENDTRY
1037 return ret;
1038}
1039
1040static BOOL WINAPI CRYPT_AsnEncodeBool(DWORD dwCertEncodingType,
1041 LPCSTR lpszStructType, const void *pvStructInfo, BYTE *pbEncoded,
1042 DWORD *pcbEncoded)
1043{
1044 BOOL val = *(const BOOL *)pvStructInfo, ret;
1045
1046 TRACE("%d\n", val);
1047
1048 if (!pbEncoded)
1049 {
1050 *pcbEncoded = 3;
1051 ret = TRUE;
1052 }
1053 else if (*pcbEncoded < 3)
1054 {
1055 *pcbEncoded = 3;
1057 ret = FALSE;
1058 }
1059 else
1060 {
1061 *pcbEncoded = 3;
1062 *pbEncoded++ = ASN_BOOL;
1063 *pbEncoded++ = 1;
1064 *pbEncoded++ = val ? 0xff : 0;
1065 ret = TRUE;
1066 }
1067 TRACE("returning %d (%08lx)\n", ret, GetLastError());
1068 return ret;
1069}
1070
1072 LPCSTR lpszStructType, const void *pvStructInfo, BYTE *pbEncoded,
1073 DWORD *pcbEncoded)
1074{
1075 BOOL ret = FALSE;
1076
1077 TRACE("(0x%08lx, %s, %p, %p, %p)\n", dwCertEncodingType,
1078 debugstr_a(lpszStructType), pvStructInfo, pbEncoded, pcbEncoded);
1079
1080 __TRY
1081 {
1082 const SPC_FINANCIAL_CRITERIA *criteria = pvStructInfo;
1083 struct AsnEncodeSequenceItem items[] = {
1085 { &criteria->fMeetsCriteria, CRYPT_AsnEncodeBool, 0 },
1086 };
1087
1089 pbEncoded, pcbEncoded);
1090 }
1092 {
1094 }
1095 __ENDTRY
1096 return ret;
1097}
1098
1099/* Gets the number of length bytes from the given (leading) length byte */
1100#define GET_LEN_BYTES(b) ((b) <= 0x7f ? 1 : 1 + ((b) & 0x7f))
1101
1102/* Helper function to get the encoded length of the data starting at pbEncoded,
1103 * where pbEncoded[0] is the tag. If the data are too short to contain a
1104 * length or if the length is too large for cbEncoded, sets an appropriate
1105 * error code and returns FALSE.
1106 */
1107static BOOL CRYPT_GetLen(const BYTE *pbEncoded, DWORD cbEncoded, DWORD *len)
1108{
1109 BOOL ret;
1110
1111 if (cbEncoded <= 1)
1112 {
1114 ret = FALSE;
1115 }
1116 else if (pbEncoded[1] <= 0x7f)
1117 {
1118 if (pbEncoded[1] + 1 > cbEncoded)
1119 {
1121 ret = FALSE;
1122 }
1123 else
1124 {
1125 *len = pbEncoded[1];
1126 ret = TRUE;
1127 }
1128 }
1129 else if (pbEncoded[1] == 0x80)
1130 {
1131 FIXME("unimplemented for indefinite-length encoding\n");
1133 ret = FALSE;
1134 }
1135 else
1136 {
1137 BYTE lenLen = GET_LEN_BYTES(pbEncoded[1]);
1138
1139 if (lenLen > sizeof(DWORD) + 1)
1140 {
1142 ret = FALSE;
1143 }
1144 else if (lenLen + 2 > cbEncoded)
1145 {
1147 ret = FALSE;
1148 }
1149 else
1150 {
1151 DWORD out = 0;
1152
1153 pbEncoded += 2;
1154 while (--lenLen)
1155 {
1156 out <<= 8;
1157 out |= *pbEncoded++;
1158 }
1159 if (out + lenLen + 1 > cbEncoded)
1160 {
1162 ret = FALSE;
1163 }
1164 else
1165 {
1166 *len = out;
1167 ret = TRUE;
1168 }
1169 }
1170 }
1171 return ret;
1172}
1173
1174static BOOL WINAPI CRYPT_AsnDecodeOctets(DWORD dwCertEncodingType,
1175 LPCSTR lpszStructType, const BYTE *pbEncoded, DWORD cbEncoded, DWORD dwFlags,
1176 void *pvStructInfo, DWORD *pcbStructInfo)
1177{
1178 BOOL ret;
1179 DWORD bytesNeeded, dataLen;
1180
1181 TRACE("%p, %ld, %08lx, %p, %ld\n", pbEncoded, cbEncoded, dwFlags,
1182 pvStructInfo, *pcbStructInfo);
1183
1184 if (!cbEncoded)
1185 {
1187 ret = FALSE;
1188 }
1189 else if (pbEncoded[0] != ASN_OCTETSTRING)
1190 {
1192 ret = FALSE;
1193 }
1194 else if ((ret = CRYPT_GetLen(pbEncoded, cbEncoded, &dataLen)))
1195 {
1197 bytesNeeded = sizeof(CRYPT_DATA_BLOB);
1198 else
1199 bytesNeeded = dataLen + sizeof(CRYPT_DATA_BLOB);
1200 if (!pvStructInfo)
1201 *pcbStructInfo = bytesNeeded;
1202 else if (*pcbStructInfo < bytesNeeded)
1203 {
1205 *pcbStructInfo = bytesNeeded;
1206 ret = FALSE;
1207 }
1208 else
1209 {
1211 BYTE lenBytes = GET_LEN_BYTES(pbEncoded[1]);
1212
1214 blob->cbData = dataLen;
1216 blob->pbData = (BYTE *)pbEncoded + 1 + lenBytes;
1217 else
1218 {
1219 assert(blob->pbData);
1220 if (blob->cbData)
1221 memcpy(blob->pbData, pbEncoded + 1 + lenBytes,
1222 blob->cbData);
1223 }
1224 }
1225 }
1226 return ret;
1227}
1228
1230 LPCSTR lpszStructType, const BYTE *pbEncoded, DWORD cbEncoded, DWORD dwFlags,
1231 void *pvStructInfo, DWORD *pcbStructInfo)
1232{
1233 BOOL ret = FALSE;
1234 DWORD bytesNeeded = sizeof(SPC_LINK), dataLen;
1235
1236 TRACE("%p, %ld, %08lx, %p, %ld\n", pbEncoded, cbEncoded, dwFlags,
1237 pvStructInfo, *pcbStructInfo);
1238
1239 if ((ret = CRYPT_GetLen(pbEncoded, cbEncoded, &dataLen)))
1240 {
1241 BYTE lenBytes = GET_LEN_BYTES(pbEncoded[1]);
1242 DWORD realDataLen;
1243
1244 switch (pbEncoded[0])
1245 {
1246 case ASN_CONTEXT:
1247 bytesNeeded += (dataLen + 1) * sizeof(WCHAR);
1248 if (!pvStructInfo)
1249 *pcbStructInfo = bytesNeeded;
1250 else if (*pcbStructInfo < bytesNeeded)
1251 {
1252 *pcbStructInfo = bytesNeeded;
1254 ret = FALSE;
1255 }
1256 else
1257 {
1259 DWORD i;
1260
1261 link->dwLinkChoice = SPC_URL_LINK_CHOICE;
1262 for (i = 0; i < dataLen; i++)
1263 link->pwszUrl[i] =
1264 *(pbEncoded + 1 + lenBytes + i);
1265 link->pwszUrl[i] = '\0';
1266 TRACE("returning url %s\n", debugstr_w(link->pwszUrl));
1267 }
1268 break;
1269 case ASN_CONSTRUCTOR | ASN_CONTEXT | 1:
1270 {
1271 CRYPT_DATA_BLOB classId;
1272 DWORD size = sizeof(classId);
1273
1274 if ((ret = CRYPT_AsnDecodeOctets(dwCertEncodingType, NULL,
1275 pbEncoded + 1 + lenBytes, cbEncoded - 1 - lenBytes,
1276 CRYPT_DECODE_NOCOPY_FLAG, &classId, &size)))
1277 {
1278 if (classId.cbData != sizeof(SPC_UUID))
1279 {
1281 ret = FALSE;
1282 }
1283 else
1284 {
1286
1287 /* The tag length for the classId must be 1 since the
1288 * length is correct.
1289 */
1290 size = sizeof(data);
1291 if ((ret = CRYPT_AsnDecodeOctets(dwCertEncodingType, NULL,
1292 pbEncoded + 3 + lenBytes + classId.cbData,
1293 cbEncoded - 3 - lenBytes - classId.cbData,
1295 {
1296 bytesNeeded += data.cbData;
1297 if (!pvStructInfo)
1298 *pcbStructInfo = bytesNeeded;
1299 else if (*pcbStructInfo < bytesNeeded)
1300 {
1301 *pcbStructInfo = bytesNeeded;
1303 ret = FALSE;
1304 }
1305 else
1306 {
1308
1309 link->dwLinkChoice = SPC_MONIKER_LINK_CHOICE;
1310 /* pwszFile pointer was set by caller, copy it
1311 * before overwriting it
1312 */
1313 link->Moniker.SerializedData.pbData =
1314 (BYTE *)link->pwszFile;
1315 memcpy(link->Moniker.ClassId, classId.pbData,
1316 classId.cbData);
1317 memcpy(link->Moniker.SerializedData.pbData,
1318 data.pbData, data.cbData);
1319 link->Moniker.SerializedData.cbData = data.cbData;
1320 }
1321 }
1322 }
1323 }
1324 break;
1325 }
1326 case ASN_CONSTRUCTOR | ASN_CONTEXT | 2:
1327 if (dataLen && pbEncoded[1 + lenBytes] != ASN_CONTEXT)
1329 else if ((ret = CRYPT_GetLen(pbEncoded + 1 + lenBytes, dataLen,
1330 &realDataLen)))
1331 {
1332 BYTE realLenBytes = GET_LEN_BYTES(pbEncoded[2 + lenBytes]);
1333
1334 bytesNeeded += realDataLen + sizeof(WCHAR);
1335 if (!pvStructInfo)
1336 *pcbStructInfo = bytesNeeded;
1337 else if (*pcbStructInfo < bytesNeeded)
1338 {
1339 *pcbStructInfo = bytesNeeded;
1341 ret = FALSE;
1342 }
1343 else
1344 {
1346 DWORD i;
1347 const BYTE *ptr = pbEncoded + 2 + lenBytes + realLenBytes;
1348
1349 link->dwLinkChoice = SPC_FILE_LINK_CHOICE;
1350 for (i = 0; i < dataLen / sizeof(WCHAR); i++)
1351 link->pwszFile[i] =
1352 hton16(*(const WORD *)(ptr + i * sizeof(WCHAR)));
1353 link->pwszFile[realDataLen / sizeof(WCHAR)] = '\0';
1354 TRACE("returning file %s\n", debugstr_w(link->pwszFile));
1355 }
1356 }
1357 else
1358 {
1359 bytesNeeded += sizeof(WCHAR);
1360 if (!pvStructInfo)
1361 *pcbStructInfo = bytesNeeded;
1362 else if (*pcbStructInfo < bytesNeeded)
1363 {
1364 *pcbStructInfo = bytesNeeded;
1366 ret = FALSE;
1367 }
1368 else
1369 {
1371
1372 link->dwLinkChoice = SPC_FILE_LINK_CHOICE;
1373 link->pwszFile[0] = '\0';
1374 ret = TRUE;
1375 }
1376 }
1377 break;
1378 default:
1380 }
1381 }
1382 TRACE("returning %d\n", ret);
1383 return ret;
1384}
1385
1387 LPCSTR lpszStructType, const BYTE *pbEncoded, DWORD cbEncoded, DWORD dwFlags,
1388 void *pvStructInfo, DWORD *pcbStructInfo)
1389{
1390 BOOL ret = FALSE;
1391
1392 TRACE("%p, %ld, %08lx, %p, %ld\n", pbEncoded, cbEncoded, dwFlags,
1393 pvStructInfo, *pcbStructInfo);
1394
1395 __TRY
1396 {
1397 DWORD bytesNeeded;
1398
1399 ret = CRYPT_AsnDecodeSPCLinkInternal(dwCertEncodingType,
1400 lpszStructType, pbEncoded, cbEncoded, dwFlags, NULL, &bytesNeeded);
1401 if (ret)
1402 {
1403 if (!pvStructInfo)
1404 *pcbStructInfo = bytesNeeded;
1405 else if (*pcbStructInfo < bytesNeeded)
1406 {
1407 *pcbStructInfo = bytesNeeded;
1409 ret = FALSE;
1410 }
1411 else
1412 {
1414
1415 link->pwszFile =
1416 (LPWSTR)((BYTE *)pvStructInfo + sizeof(SPC_LINK));
1417 ret = CRYPT_AsnDecodeSPCLinkInternal(dwCertEncodingType,
1418 lpszStructType, pbEncoded, cbEncoded, dwFlags, pvStructInfo,
1419 pcbStructInfo);
1420 }
1421 }
1422 }
1424 {
1426 }
1427 __ENDTRY
1428 TRACE("returning %d\n", ret);
1429 return ret;
1430}
1431
1433 DWORD, DWORD, void *, DWORD *);
1434
1435/* tag:
1436 * The expected tag of the item. If tag is 0, decodeFunc is called
1437 * regardless of the tag value seen.
1438 * offset:
1439 * A sequence is decoded into a struct. The offset member is the
1440 * offset of this item within that struct.
1441 * decodeFunc:
1442 * The decoder function to use. If this is NULL, then the member isn't
1443 * decoded, but minSize space is reserved for it.
1444 * minSize:
1445 * The minimum amount of space occupied after decoding. You must set this.
1446 * optional:
1447 * If true, and the tag doesn't match the expected tag for this item,
1448 * or the decodeFunc fails with CRYPT_E_ASN1_BADTAG, then minSize space is
1449 * filled with 0 for this member.
1450 * hasPointer, pointerOffset:
1451 * If the item has dynamic data, set hasPointer to TRUE, pointerOffset to
1452 * the offset within the struct of the data pointer (or to the
1453 * first data pointer, if more than one exist).
1454 * size:
1455 * Used by CRYPT_AsnDecodeSequence, not for your use.
1456 */
1458{
1459 BYTE tag;
1460 DWORD offset;
1462 DWORD minSize;
1463 BOOL optional;
1466 DWORD size;
1467};
1468
1469/* Align up to a DWORD_PTR boundary
1470 */
1471#define ALIGN_DWORD_PTR(x) (((x) + sizeof(DWORD_PTR) - 1) & ~(sizeof(DWORD_PTR) - 1))
1472
1473#define FINALMEMBERSIZE(s, member) (sizeof(s) - offsetof(s, member))
1474#define MEMBERSIZE(s, member, nextmember) \
1475 (offsetof(s, nextmember) - offsetof(s, member))
1476
1477
1478/* Decodes the items in a sequence, where the items are described in items,
1479 * the encoded data are in pbEncoded with length cbEncoded. Decodes into
1480 * pvStructInfo. nextData is a pointer to the memory location at which the
1481 * first decoded item with a dynamic pointer should point.
1482 * Upon decoding, *cbDecoded is the total number of bytes decoded.
1483 */
1484static BOOL CRYPT_AsnDecodeSequenceItems(DWORD dwCertEncodingType,
1485 struct AsnDecodeSequenceItem items[], DWORD cItem, const BYTE *pbEncoded,
1486 DWORD cbEncoded, DWORD dwFlags, void *pvStructInfo, BYTE *nextData,
1487 DWORD *cbDecoded)
1488{
1489 BOOL ret;
1490 DWORD i, decoded = 0;
1491 const BYTE *ptr = pbEncoded;
1492
1493 TRACE("%p, %ld, %p, %ld, %08lx, %p, %p, %p\n", items, cItem, pbEncoded,
1494 cbEncoded, dwFlags, pvStructInfo, nextData, cbDecoded);
1495
1496 for (i = 0, ret = TRUE; ret && i < cItem; i++)
1497 {
1498 if (cbEncoded - (ptr - pbEncoded) != 0)
1499 {
1500 DWORD nextItemLen;
1501
1502 if ((ret = CRYPT_GetLen(ptr, cbEncoded - (ptr - pbEncoded),
1503 &nextItemLen)))
1504 {
1505 BYTE nextItemLenBytes = GET_LEN_BYTES(ptr[1]);
1506
1507 if (ptr[0] == items[i].tag || !items[i].tag)
1508 {
1509 if (nextData && pvStructInfo && items[i].hasPointer)
1510 {
1511 TRACE("Setting next pointer to %p\n",
1512 nextData);
1513 *(BYTE **)((BYTE *)pvStructInfo +
1514 items[i].pointerOffset) = nextData;
1515 }
1516 if (items[i].decodeFunc)
1517 {
1518 if (pvStructInfo)
1519 TRACE("decoding item %ld\n", i);
1520 else
1521 TRACE("sizing item %ld\n", i);
1522 ret = items[i].decodeFunc(dwCertEncodingType,
1523 NULL, ptr, 1 + nextItemLenBytes + nextItemLen,
1525 pvStructInfo ? (BYTE *)pvStructInfo + items[i].offset
1526 : NULL, &items[i].size);
1527 if (ret)
1528 {
1529 if (items[i].size < items[i].minSize)
1530 items[i].size = items[i].minSize;
1531 else if (items[i].size > items[i].minSize)
1532 {
1533 /* Account for alignment padding */
1534 items[i].size = ALIGN_DWORD_PTR(items[i].size);
1535 }
1536 TRACE("item %ld size: %ld\n", i, items[i].size);
1537 if (nextData && items[i].hasPointer &&
1538 items[i].size > items[i].minSize)
1539 nextData += items[i].size - items[i].minSize;
1540 ptr += 1 + nextItemLenBytes + nextItemLen;
1541 decoded += 1 + nextItemLenBytes + nextItemLen;
1542 TRACE("item %ld: decoded %ld bytes\n", i,
1543 1 + nextItemLenBytes + nextItemLen);
1544 }
1545 else if (items[i].optional &&
1547 {
1548 TRACE("skipping optional item %ld\n", i);
1549 items[i].size = items[i].minSize;
1551 ret = TRUE;
1552 }
1553 else
1554 TRACE("item %ld failed: %08lx\n", i,
1555 GetLastError());
1556 }
1557 else
1558 {
1559 TRACE("item %ld: decoded %ld bytes\n", i,
1560 1 + nextItemLenBytes + nextItemLen);
1561 ptr += 1 + nextItemLenBytes + nextItemLen;
1562 decoded += 1 + nextItemLenBytes + nextItemLen;
1563 items[i].size = items[i].minSize;
1564 }
1565 }
1566 else if (items[i].optional)
1567 {
1568 TRACE("skipping optional item %ld\n", i);
1569 items[i].size = items[i].minSize;
1570 }
1571 else
1572 {
1573 TRACE("item %ld: tag %02x doesn't match expected %02x\n",
1574 i, ptr[0], items[i].tag);
1576 ret = FALSE;
1577 }
1578 }
1579 }
1580 else if (items[i].optional)
1581 {
1582 TRACE("missing optional item %ld, skipping\n", i);
1583 items[i].size = items[i].minSize;
1584 }
1585 else
1586 {
1587 TRACE("not enough bytes for item %ld, failing\n", i);
1589 ret = FALSE;
1590 }
1591 }
1592 if (ret)
1593 *cbDecoded = decoded;
1594 TRACE("returning %d\n", ret);
1595 return ret;
1596}
1597
1598/* This decodes an arbitrary sequence into a contiguous block of memory
1599 * (basically, a struct.) Each element being decoded is described by a struct
1600 * AsnDecodeSequenceItem, see above.
1601 * startingPointer is an optional pointer to the first place where dynamic
1602 * data will be stored. If you know the starting offset, you may pass it
1603 * here. Otherwise, pass NULL, and one will be inferred from the items.
1604 */
1605static BOOL CRYPT_AsnDecodeSequence(DWORD dwCertEncodingType,
1606 struct AsnDecodeSequenceItem items[], DWORD cItem, const BYTE *pbEncoded,
1607 DWORD cbEncoded, DWORD dwFlags, void *pvStructInfo, DWORD *pcbStructInfo,
1608 void *startingPointer)
1609{
1610 BOOL ret;
1611
1612 TRACE("%p, %ld, %p, %ld, %08lx, %p, %ld, %p\n", items, cItem, pbEncoded,
1613 cbEncoded, dwFlags, pvStructInfo, *pcbStructInfo, startingPointer);
1614
1615 if (pbEncoded[0] == ASN_SEQUENCE)
1616 {
1617 DWORD dataLen;
1618
1619 if ((ret = CRYPT_GetLen(pbEncoded, cbEncoded, &dataLen)))
1620 {
1621 DWORD lenBytes = GET_LEN_BYTES(pbEncoded[1]), cbDecoded;
1622 const BYTE *ptr = pbEncoded + 1 + lenBytes;
1623
1624 cbEncoded -= 1 + lenBytes;
1625 if (cbEncoded < dataLen)
1626 {
1627 TRACE("dataLen %ld exceeds cbEncoded %ld, failing\n", dataLen,
1628 cbEncoded);
1630 ret = FALSE;
1631 }
1632 else
1634 cbEncoded, dwFlags, NULL, NULL, &cbDecoded);
1635 if (ret && cbDecoded != dataLen)
1636 {
1637 TRACE("expected %ld decoded, got %ld, failing\n", dataLen,
1638 cbDecoded);
1640 ret = FALSE;
1641 }
1642 if (ret)
1643 {
1644 DWORD i, bytesNeeded = 0, structSize = 0;
1645
1646 for (i = 0; i < cItem; i++)
1647 {
1648 bytesNeeded += items[i].size;
1649 structSize += items[i].minSize;
1650 }
1651 if (!pvStructInfo)
1652 *pcbStructInfo = bytesNeeded;
1653 else if (*pcbStructInfo < bytesNeeded)
1654 {
1656 *pcbStructInfo = bytesNeeded;
1657 ret = FALSE;
1658 }
1659 else
1660 {
1661 BYTE *nextData;
1662
1663 *pcbStructInfo = bytesNeeded;
1664 if (startingPointer)
1665 nextData = startingPointer;
1666 else
1667 nextData = (BYTE *)pvStructInfo + structSize;
1668 memset(pvStructInfo, 0, structSize);
1670 ptr, cbEncoded, dwFlags, pvStructInfo, nextData,
1671 &cbDecoded);
1672 }
1673 }
1674 }
1675 }
1676 else
1677 {
1679 ret = FALSE;
1680 }
1681 TRACE("returning %d (%08lx)\n", ret, GetLastError());
1682 return ret;
1683}
1684
1686 LPCSTR lpszStructType, const BYTE *pbEncoded, DWORD cbEncoded, DWORD dwFlags,
1687 void *pvStructInfo, DWORD *pcbStructInfo)
1688{
1689 BOOL ret;
1690
1691 TRACE("(%p, %ld, 0x%08lx, %p, %ld)\n", pbEncoded, cbEncoded, dwFlags,
1692 pvStructInfo, *pcbStructInfo);
1693
1694 if (pbEncoded[0] == ASN_BITSTRING)
1695 {
1696 DWORD bytesNeeded, dataLen;
1697
1698 if ((ret = CRYPT_GetLen(pbEncoded, cbEncoded, &dataLen)))
1699 {
1701 bytesNeeded = sizeof(CRYPT_BIT_BLOB);
1702 else
1703 bytesNeeded = dataLen - 1 + sizeof(CRYPT_BIT_BLOB);
1704 if (!pvStructInfo)
1705 *pcbStructInfo = bytesNeeded;
1706 else if (*pcbStructInfo < bytesNeeded)
1707 {
1708 *pcbStructInfo = bytesNeeded;
1710 ret = FALSE;
1711 }
1712 else
1713 {
1715
1716 blob = pvStructInfo;
1717 blob->cbData = dataLen - 1;
1718 blob->cUnusedBits = *(pbEncoded + 1 +
1719 GET_LEN_BYTES(pbEncoded[1]));
1721 {
1722 blob->pbData = (BYTE *)pbEncoded + 2 +
1723 GET_LEN_BYTES(pbEncoded[1]);
1724 }
1725 else
1726 {
1727 assert(blob->pbData);
1728 if (blob->cbData)
1729 {
1730 BYTE mask = 0xff << blob->cUnusedBits;
1731
1732 memcpy(blob->pbData, pbEncoded + 2 +
1733 GET_LEN_BYTES(pbEncoded[1]), blob->cbData);
1734 blob->pbData[blob->cbData - 1] &= mask;
1735 }
1736 }
1737 }
1738 }
1739 }
1740 else
1741 {
1743 ret = FALSE;
1744 }
1745 TRACE("returning %d (%08lx)\n", ret, GetLastError());
1746 return ret;
1747}
1748
1750 LPCSTR lpszStructType, const BYTE *pbEncoded, DWORD cbEncoded, DWORD dwFlags,
1751 void *pvStructInfo, DWORD *pcbStructInfo)
1752{
1753 BOOL ret = FALSE;
1754 DWORD dataLen;
1755
1756 if ((ret = CRYPT_GetLen(pbEncoded, cbEncoded, &dataLen)))
1757 {
1758 BYTE lenBytes = GET_LEN_BYTES(pbEncoded[1]);
1759 DWORD size;
1760 SPC_LINK **pLink = pvStructInfo;
1761
1762 ret = CRYPT_AsnDecodeSPCLinkInternal(dwCertEncodingType, lpszStructType,
1763 pbEncoded + 1 + lenBytes, dataLen, dwFlags, NULL, &size);
1764 if (ret)
1765 {
1766 if (!pvStructInfo)
1767 *pcbStructInfo = size + sizeof(PSPC_LINK);
1768 else if (*pcbStructInfo < size + sizeof(PSPC_LINK))
1769 {
1770 *pcbStructInfo = size + sizeof(PSPC_LINK);
1772 ret = FALSE;
1773 }
1774 else
1775 {
1776 *pcbStructInfo = size + sizeof(PSPC_LINK);
1777 /* Set imageData's pointer if necessary */
1778 if (size > sizeof(SPC_LINK))
1779 {
1780 (*pLink)->pwszUrl =
1781 (LPWSTR)((BYTE *)*pLink + sizeof(SPC_LINK));
1782 }
1783 ret = CRYPT_AsnDecodeSPCLinkInternal(dwCertEncodingType,
1784 lpszStructType, pbEncoded + 1 + lenBytes, dataLen, dwFlags,
1785 *pLink, pcbStructInfo);
1786 }
1787 }
1788 }
1789 return ret;
1790}
1791
1793 LPCSTR lpszStructType, const BYTE *pbEncoded, DWORD cbEncoded, DWORD dwFlags,
1794 void *pvStructInfo, DWORD *pcbStructInfo)
1795{
1796 BOOL ret = FALSE;
1797
1798 TRACE("%p, %ld, %08lx, %p, %ld\n", pbEncoded, cbEncoded, dwFlags,
1799 pvStructInfo, *pcbStructInfo);
1800
1801 __TRY
1802 {
1803 struct AsnDecodeSequenceItem items[] = {
1806 offsetof(SPC_PE_IMAGE_DATA, Flags.pbData), 0 },
1810 };
1811
1812 ret = CRYPT_AsnDecodeSequence(dwCertEncodingType, items, ARRAY_SIZE(items),
1813 pbEncoded, cbEncoded, dwFlags, pvStructInfo, pcbStructInfo, NULL);
1814 }
1816 {
1818 }
1819 __ENDTRY
1820 TRACE("returning %d\n", ret);
1821 return ret;
1822}
1823
1825 LPCSTR lpszStructType, const BYTE *pbEncoded, DWORD cbEncoded, DWORD dwFlags,
1826 void *pvStructInfo, DWORD *pcbStructInfo)
1827{
1828 BOOL ret = TRUE;
1829 DWORD dataLen;
1830
1831 TRACE("%p, %ld, %08lx, %p, %ld\n", pbEncoded, cbEncoded, dwFlags,
1832 pvStructInfo, *pcbStructInfo);
1833
1834 if ((ret = CRYPT_GetLen(pbEncoded, cbEncoded, &dataLen)))
1835 {
1836 BYTE lenBytes = GET_LEN_BYTES(pbEncoded[1]);
1837 DWORD bytesNeeded = sizeof(LPSTR);
1838
1839 if (dataLen)
1840 {
1841 /* The largest possible string for the first two components
1842 * is 2.175 (= 2 * 40 + 175 = 255), so this is big enough.
1843 */
1844 char firstTwo[8];
1845 const BYTE *ptr;
1846
1847 sprintf(firstTwo, "%d.%d",
1848 pbEncoded[1 + lenBytes] / 40,
1849 pbEncoded[1 + lenBytes] - (pbEncoded[1 + lenBytes] / 40)
1850 * 40);
1851 bytesNeeded += strlen(firstTwo) + 1;
1852 for (ptr = pbEncoded + 2 + lenBytes; ret &&
1853 ptr - pbEncoded - 1 - lenBytes < dataLen; )
1854 {
1855 /* large enough for ".4000000" */
1856 char str[9];
1857 int val = 0;
1858
1859 while (ptr - pbEncoded - 1 - lenBytes < dataLen &&
1860 (*ptr & 0x80))
1861 {
1862 val <<= 7;
1863 val |= *ptr & 0x7f;
1864 ptr++;
1865 }
1866 if (ptr - pbEncoded - 1 - lenBytes >= dataLen ||
1867 (*ptr & 0x80))
1868 {
1870 ret = FALSE;
1871 }
1872 else
1873 {
1874 val <<= 7;
1875 val |= *ptr++;
1876 snprintf(str, sizeof(str), ".%d", val);
1877 bytesNeeded += strlen(str);
1878 }
1879 }
1880 }
1881 else
1882 bytesNeeded += 1;
1883 if (!pvStructInfo)
1884 *pcbStructInfo = bytesNeeded;
1885 else if (*pcbStructInfo < bytesNeeded)
1886 {
1887 *pcbStructInfo = bytesNeeded;
1889 ret = FALSE;
1890 }
1891 else
1892 {
1893 LPSTR pszObjId = *(LPSTR *)pvStructInfo;
1894
1895 *pszObjId = 0;
1896 if (dataLen)
1897 {
1898 const BYTE *ptr;
1899
1900 pszObjId += sprintf(pszObjId, "%d.%d", pbEncoded[1 + lenBytes] / 40,
1901 pbEncoded[1 + lenBytes] - (pbEncoded[1 + lenBytes] /
1902 40) * 40);
1903 for (ptr = pbEncoded + 2 + lenBytes; ret &&
1904 ptr - pbEncoded - 1 - lenBytes < dataLen; )
1905 {
1906 int val = 0;
1907
1908 while (ptr - pbEncoded - 1 - lenBytes < dataLen &&
1909 (*ptr & 0x80))
1910 {
1911 val <<= 7;
1912 val |= *ptr & 0x7f;
1913 ptr++;
1914 }
1915 val <<= 7;
1916 val |= *ptr++;
1917 pszObjId += sprintf(pszObjId, ".%d", val);
1918 }
1919 }
1920 *pcbStructInfo = bytesNeeded;
1921 }
1922 }
1923 return ret;
1924}
1925
1926static BOOL WINAPI CRYPT_AsnDecodeOid(DWORD dwCertEncodingType,
1927 LPCSTR lpszStructType, const BYTE *pbEncoded, DWORD cbEncoded, DWORD dwFlags,
1928 void *pvStructInfo, DWORD *pcbStructInfo)
1929{
1930 BOOL ret = FALSE;
1931
1932 TRACE("%p, %ld, %08lx, %p, %ld\n", pbEncoded, cbEncoded, dwFlags,
1933 pvStructInfo, *pcbStructInfo);
1934
1935 if (!cbEncoded)
1937 else if (pbEncoded[0] == ASN_OBJECTIDENTIFIER)
1938 ret = CRYPT_AsnDecodeOidIgnoreTag(dwCertEncodingType, lpszStructType,
1939 pbEncoded, cbEncoded, dwFlags, pvStructInfo, pcbStructInfo);
1940 else
1942 return ret;
1943}
1944
1945static BOOL WINAPI CRYPT_AsnDecodeCopyBytes(DWORD dwCertEncodingType,
1946 LPCSTR lpszStructType, const BYTE *pbEncoded, DWORD cbEncoded, DWORD dwFlags,
1947 void *pvStructInfo, DWORD *pcbStructInfo)
1948{
1949 BOOL ret = TRUE;
1950 DWORD bytesNeeded = sizeof(CRYPT_OBJID_BLOB);
1951
1952 TRACE("%p, %ld, %08lx, %p, %ld\n", pbEncoded, cbEncoded, dwFlags,
1953 pvStructInfo, *pcbStructInfo);
1954
1956 bytesNeeded += cbEncoded;
1957 if (!pvStructInfo)
1958 *pcbStructInfo = bytesNeeded;
1959 else if (*pcbStructInfo < bytesNeeded)
1960 {
1962 *pcbStructInfo = bytesNeeded;
1963 ret = FALSE;
1964 }
1965 else
1966 {
1967 PCRYPT_OBJID_BLOB blob = pvStructInfo;
1968
1969 *pcbStructInfo = bytesNeeded;
1970 blob->cbData = cbEncoded;
1972 blob->pbData = (LPBYTE)pbEncoded;
1973 else
1974 {
1975 assert(blob->pbData);
1976 memcpy(blob->pbData, pbEncoded, blob->cbData);
1977 }
1978 }
1979 return ret;
1980}
1981
1983 LPCSTR lpszStructType, const BYTE *pbEncoded, DWORD cbEncoded, DWORD dwFlags,
1984 void *pvStructInfo, DWORD *pcbStructInfo)
1985{
1986 CRYPT_ATTRIBUTE_TYPE_VALUE *typeValue = pvStructInfo;
1987 struct AsnDecodeSequenceItem items[] = {
1990 offsetof(CRYPT_ATTRIBUTE_TYPE_VALUE, pszObjId), 0 },
1994 };
1995
1996 TRACE("%p, %ld, %08lx, %p, %ld\n", pbEncoded, cbEncoded, dwFlags,
1997 pvStructInfo, *pcbStructInfo);
1998
1999 return CRYPT_AsnDecodeSequence(dwCertEncodingType, items, ARRAY_SIZE(items),
2000 pbEncoded, cbEncoded, dwFlags, pvStructInfo, pcbStructInfo,
2001 typeValue ? typeValue->pszObjId : NULL);
2002}
2003
2005 LPCSTR lpszStructType, const BYTE *pbEncoded, DWORD cbEncoded, DWORD dwFlags,
2006 void *pvStructInfo, DWORD *pcbStructInfo)
2007{
2008 CRYPT_ALGORITHM_IDENTIFIER *algo = pvStructInfo;
2009 BOOL ret = TRUE;
2010 struct AsnDecodeSequenceItem items[] = {
2013 offsetof(CRYPT_ALGORITHM_IDENTIFIER, pszObjId), 0 },
2017 };
2018
2019 TRACE("%p, %ld, %08lx, %p, %ld\n", pbEncoded, cbEncoded, dwFlags,
2020 pvStructInfo, *pcbStructInfo);
2021
2022 ret = CRYPT_AsnDecodeSequence(dwCertEncodingType, items, ARRAY_SIZE(items),
2023 pbEncoded, cbEncoded, dwFlags, pvStructInfo, pcbStructInfo, algo ? algo->pszObjId : NULL);
2024 if (ret && pvStructInfo)
2025 {
2026 TRACE("pszObjId is %p (%s)\n", algo->pszObjId,
2027 debugstr_a(algo->pszObjId));
2028 }
2029 return ret;
2030}
2031
2032static BOOL WINAPI CRYPT_AsnDecodeSPCDigest(DWORD dwCertEncodingType,
2033 LPCSTR lpszStructType, const BYTE *pbEncoded, DWORD cbEncoded, DWORD dwFlags,
2034 void *pvStructInfo, DWORD *pcbStructInfo)
2035{
2036 struct SPCDigest *digest = pvStructInfo;
2037 struct AsnDecodeSequenceItem items[] = {
2038 { ASN_SEQUENCEOF, offsetof(struct SPCDigest, DigestAlgorithm),
2040 FALSE, TRUE,
2041 offsetof(struct SPCDigest, DigestAlgorithm.pszObjId), 0 },
2042 { ASN_OCTETSTRING, offsetof(struct SPCDigest, Digest),
2044 FALSE, TRUE, offsetof(struct SPCDigest, Digest.pbData), 0 },
2045 };
2046
2047 TRACE("%p, %ld, %08lx, %p, %ld\n", pbEncoded, cbEncoded, dwFlags,
2048 pvStructInfo, *pcbStructInfo);
2049
2050 return CRYPT_AsnDecodeSequence(dwCertEncodingType, items, ARRAY_SIZE(items),
2051 pbEncoded, cbEncoded, dwFlags, pvStructInfo, pcbStructInfo,
2052 digest ? digest->DigestAlgorithm.pszObjId : NULL);
2053}
2054
2056 LPCSTR lpszStructType, const BYTE *pbEncoded, DWORD cbEncoded, DWORD dwFlags,
2057 void *pvStructInfo, DWORD *pcbStructInfo)
2058{
2059 BOOL ret = FALSE;
2060
2061 TRACE("%p, %ld, %08lx, %p, %ld\n", pbEncoded, cbEncoded, dwFlags,
2062 pvStructInfo, *pcbStructInfo);
2063
2064 __TRY
2065 {
2066 struct AsnDecodeSequenceItem items[] = {
2070 offsetof(SPC_INDIRECT_DATA_CONTENT, Data.pszObjId), 0 },
2072 CRYPT_AsnDecodeSPCDigest, sizeof(struct SPCDigest),
2073 FALSE, TRUE,
2075 };
2076
2077 ret = CRYPT_AsnDecodeSequence(dwCertEncodingType, items, ARRAY_SIZE(items),
2078 pbEncoded, cbEncoded, dwFlags, pvStructInfo, pcbStructInfo, NULL);
2079 }
2081 {
2083 }
2084 __ENDTRY
2085 TRACE("returning %d\n", ret);
2086 return ret;
2087}
2088
2089static BOOL WINAPI CRYPT_AsnDecodeBMPString(DWORD dwCertEncodingType,
2090 LPCSTR lpszStructType, const BYTE *pbEncoded, DWORD cbEncoded, DWORD dwFlags,
2091 void *pvStructInfo, DWORD *pcbStructInfo)
2092{
2093 BOOL ret;
2094 DWORD bytesNeeded, dataLen;
2095
2096 if ((ret = CRYPT_GetLen(pbEncoded, cbEncoded, &dataLen)))
2097 {
2098 BYTE lenBytes = GET_LEN_BYTES(pbEncoded[1]);
2099
2100 bytesNeeded = dataLen + 2 + sizeof(LPWSTR);
2101 if (!pvStructInfo)
2102 *pcbStructInfo = bytesNeeded;
2103 else if (*pcbStructInfo < bytesNeeded)
2104 {
2105 *pcbStructInfo = bytesNeeded;
2107 ret = FALSE;
2108 }
2109 else
2110 {
2111 LPWSTR str;
2112 DWORD i;
2113
2114 *pcbStructInfo = bytesNeeded;
2115 assert(pvStructInfo);
2116 str = *(LPWSTR *)pvStructInfo;
2117 for (i = 0; i < dataLen / 2; i++)
2118 str[i] = (pbEncoded[1 + lenBytes + 2 * i] << 8) |
2119 pbEncoded[1 + lenBytes + 2 * i + 1];
2120 /* Decoded string is always NULL-terminated */
2121 str[i] = '\0';
2122 }
2123 }
2124 return ret;
2125}
2126
2128 LPCSTR lpszStructType, const BYTE *pbEncoded, DWORD cbEncoded, DWORD dwFlags,
2129 void *pvStructInfo, DWORD *pcbStructInfo)
2130{
2131 BOOL ret = FALSE;
2132 DWORD dataLen;
2133
2134 TRACE("(%p, %ld, %08lx, %p, %ld)\n", pbEncoded, cbEncoded, dwFlags,
2135 pvStructInfo, pvStructInfo ? *pcbStructInfo : 0);
2136
2137 if ((ret = CRYPT_GetLen(pbEncoded, cbEncoded, &dataLen)))
2138 {
2139 BYTE lenBytes = GET_LEN_BYTES(pbEncoded[1]);
2140
2141 ret = CRYPT_AsnDecodeBMPString(dwCertEncodingType, lpszStructType,
2142 pbEncoded + 1 + lenBytes, dataLen, dwFlags, pvStructInfo,
2143 pcbStructInfo);
2144 }
2145 return ret;
2146}
2147
2149 LPCSTR lpszStructType, const BYTE *pbEncoded, DWORD cbEncoded, DWORD dwFlags,
2150 void *pvStructInfo, DWORD *pcbStructInfo)
2151{
2152 BOOL ret = FALSE;
2153
2154 TRACE("%p, %ld, %08lx, %p, %ld\n", pbEncoded, cbEncoded, dwFlags,
2155 pvStructInfo, *pcbStructInfo);
2156
2157 __TRY
2158 {
2159 struct AsnDecodeSequenceItem items[] = {
2161 offsetof(SPC_SP_OPUS_INFO, pwszProgramName),
2163 offsetof(SPC_SP_OPUS_INFO, pwszProgramName), 0 },
2165 offsetof(SPC_SP_OPUS_INFO, pMoreInfo),
2167 offsetof(SPC_SP_OPUS_INFO, pMoreInfo), 0 },
2169 offsetof(SPC_SP_OPUS_INFO, pPublisherInfo),
2171 offsetof(SPC_SP_OPUS_INFO, pPublisherInfo), 0 },
2172 };
2173
2174 ret = CRYPT_AsnDecodeSequence(dwCertEncodingType, items, ARRAY_SIZE(items),
2175 pbEncoded, cbEncoded, dwFlags, pvStructInfo, pcbStructInfo, NULL);
2176 }
2178 {
2180 }
2181 __ENDTRY
2182 TRACE("returning %d\n", ret);
2183 return ret;
2184}
2185
2186/* Ignores tag. Only allows integers 4 bytes or smaller in size. */
2187static BOOL WINAPI CRYPT_AsnDecodeInt(DWORD dwCertEncodingType,
2188 LPCSTR lpszStructType, const BYTE *pbEncoded, DWORD cbEncoded, DWORD dwFlags,
2189 void *pvStructInfo, DWORD *pcbStructInfo)
2190{
2191 BOOL ret;
2192 DWORD dataLen;
2193
2194 if ((ret = CRYPT_GetLen(pbEncoded, cbEncoded, &dataLen)))
2195 {
2196 BYTE lenBytes = GET_LEN_BYTES(pbEncoded[1]);
2197
2198 if (dataLen > sizeof(int))
2199 {
2201 ret = FALSE;
2202 }
2203 else if (!pvStructInfo)
2204 *pcbStructInfo = sizeof(int);
2205 else if (*pcbStructInfo < sizeof(int))
2206 {
2207 *pcbStructInfo = sizeof(int);
2209 ret = FALSE;
2210 }
2211 else
2212 {
2213 int val;
2214 DWORD i;
2215
2216 *pcbStructInfo = sizeof(int);
2217 if (dataLen && pbEncoded[1 + lenBytes] & 0x80)
2218 {
2219 /* initialize to a negative value to sign-extend */
2220 val = -1;
2221 }
2222 else
2223 val = 0;
2224 for (i = 0; i < dataLen; i++)
2225 {
2226 val <<= 8;
2227 val |= pbEncoded[1 + lenBytes + i];
2228 }
2229 memcpy(pvStructInfo, &val, sizeof(int));
2230 }
2231 }
2232 return ret;
2233}
2234
2236 LPCSTR lpszStructType, const BYTE *pbEncoded, DWORD cbEncoded, DWORD dwFlags,
2237 void *pvStructInfo, DWORD *pcbStructInfo)
2238{
2239 BOOL ret = FALSE;
2240
2241 TRACE("%p, %ld, %08lx, %p, %ld\n", pbEncoded, cbEncoded, dwFlags,
2242 pvStructInfo, *pcbStructInfo);
2243
2244 __TRY
2245 {
2246 struct AsnDecodeSequenceItem items[] = {
2247 { ASN_BMPSTRING, offsetof(CAT_MEMBERINFO, pwszSubjGuid),
2249 offsetof(CAT_MEMBERINFO, pwszSubjGuid), 0 },
2250 { ASN_INTEGER, offsetof(CAT_MEMBERINFO, dwCertVersion),
2252 FALSE, FALSE, 0, 0 },
2253 };
2254
2255 ret = CRYPT_AsnDecodeSequence(dwCertEncodingType, items, ARRAY_SIZE(items),
2256 pbEncoded, cbEncoded, dwFlags, pvStructInfo, pcbStructInfo, NULL);
2257 }
2259 {
2261 }
2262 __ENDTRY
2263 TRACE("returning %d\n", ret);
2264 return ret;
2265}
2266
2268 LPCSTR lpszStructType, const BYTE *pbEncoded, DWORD cbEncoded, DWORD dwFlags,
2269 void *pvStructInfo, DWORD *pcbStructInfo)
2270{
2271 BOOL ret = FALSE;
2272
2273 TRACE("%p, %ld, %08lx, %p, %ld\n", pbEncoded, cbEncoded, dwFlags,
2274 pvStructInfo, *pcbStructInfo);
2275
2276 __TRY
2277 {
2278 struct AsnDecodeSequenceItem items[] = {
2281 offsetof(CAT_NAMEVALUE, pwszTag), 0 },
2282 { ASN_INTEGER, offsetof(CAT_NAMEVALUE, fdwFlags),
2284 FALSE, FALSE, 0, 0 },
2287 offsetof(CAT_NAMEVALUE, Value.pbData), 0 },
2288 };
2289
2290 ret = CRYPT_AsnDecodeSequence(dwCertEncodingType, items, ARRAY_SIZE(items),
2291 pbEncoded, cbEncoded, dwFlags, pvStructInfo, pcbStructInfo, NULL);
2292 }
2294 {
2296 }
2297 __ENDTRY
2298 TRACE("returning %d\n", ret);
2299 return ret;
2300}
2301
2302static BOOL WINAPI CRYPT_AsnDecodeBool(DWORD dwCertEncodingType,
2303 LPCSTR lpszStructType, const BYTE *pbEncoded, DWORD cbEncoded, DWORD dwFlags,
2304 void *pvStructInfo, DWORD *pcbStructInfo)
2305{
2306 BOOL ret;
2307
2308 if (cbEncoded < 3)
2309 {
2311 return FALSE;
2312 }
2313 if (GET_LEN_BYTES(pbEncoded[1]) > 1)
2314 {
2316 return FALSE;
2317 }
2318 if (pbEncoded[1] > 1)
2319 {
2321 return FALSE;
2322 }
2323 if (!pvStructInfo)
2324 {
2325 *pcbStructInfo = sizeof(BOOL);
2326 ret = TRUE;
2327 }
2328 else if (*pcbStructInfo < sizeof(BOOL))
2329 {
2330 *pcbStructInfo = sizeof(BOOL);
2332 ret = FALSE;
2333 }
2334 else
2335 {
2336 *pcbStructInfo = sizeof(BOOL);
2337 *(BOOL *)pvStructInfo = pbEncoded[2] != 0;
2338 ret = TRUE;
2339 }
2340 TRACE("returning %d (%08lx)\n", ret, GetLastError());
2341 return ret;
2342}
2343
2345 LPCSTR lpszStructType, const BYTE *pbEncoded, DWORD cbEncoded, DWORD dwFlags,
2346 void *pvStructInfo, DWORD *pcbStructInfo)
2347{
2348 BOOL ret = FALSE;
2349
2350 TRACE("(%p, %ld, %08lx, %p, %ld)\n", pbEncoded, cbEncoded, dwFlags,
2351 pvStructInfo, *pcbStructInfo);
2352
2353 __TRY
2354 {
2355 struct AsnDecodeSequenceItem items[] = {
2356 { ASN_BOOL, offsetof(SPC_FINANCIAL_CRITERIA, fFinancialInfoAvailable),
2358 fFinancialInfoAvailable, fMeetsCriteria), FALSE, FALSE, 0, 0 },
2359 { ASN_BOOL, offsetof(SPC_FINANCIAL_CRITERIA, fMeetsCriteria),
2361 fMeetsCriteria), FALSE, FALSE, 0, 0 },
2362 };
2363
2364 ret = CRYPT_AsnDecodeSequence(dwCertEncodingType, items, ARRAY_SIZE(items),
2365 pbEncoded, cbEncoded, dwFlags, pvStructInfo, pcbStructInfo, NULL);
2366 }
2368 {
2370 }
2371 __ENDTRY
2372 TRACE("returning %d\n", ret);
2373 return ret;
2374}
@ optional
Definition: SystemMenu.c:34
#define WINE_DEFAULT_DEBUG_CHANNEL(t)
Definition: precomp.h:23
#define ARRAY_SIZE(A)
Definition: main.h:20
#define FIXME(fmt,...)
Definition: precomp.h:53
const WCHAR * link
Definition: db.cpp:998
#define ERROR_MORE_DATA
Definition: dderror.h:13
#define E_INVALIDARG
Definition: ddrawi.h:101
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define SetLastError(x)
Definition: compat.h:752
#define __TRY
Definition: compat.h:80
#define __ENDTRY
Definition: compat.h:82
#define __EXCEPT_PAGE_FAULT
Definition: compat.h:81
#define lstrlenW
Definition: compat.h:750
#define assert(_expr)
Definition: assert.h:32
_ACRTIMP int __cdecl _ACRTIMP int __cdecl _ACRTIMP int __cdecl _ACRTIMP int __cdecl _ACRTIMP int __cdecl _ACRTIMP int __cdecl _ACRTIMP int __cdecl sscanf(const char *, const char *,...) __WINE_CRT_SCANF_ATTR(2
_ACRTIMP size_t __cdecl strlen(const char *)
Definition: string.c:1592
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31
BOOL WINAPI WVTAsn1SpcFinancialCriteriaInfoEncode(DWORD dwCertEncodingType, LPCSTR lpszStructType, const void *pvStructInfo, BYTE *pbEncoded, DWORD *pcbEncoded)
Definition: asn.c:1071
static BOOL WINAPI CRYPT_AsnDecodeAlgorithmId(DWORD dwCertEncodingType, LPCSTR lpszStructType, const BYTE *pbEncoded, DWORD cbEncoded, DWORD dwFlags, void *pvStructInfo, DWORD *pcbStructInfo)
Definition: asn.c:2004
static BOOL WINAPI CRYPT_AsnDecodeOctets(DWORD dwCertEncodingType, LPCSTR lpszStructType, const BYTE *pbEncoded, DWORD cbEncoded, DWORD dwFlags, void *pvStructInfo, DWORD *pcbStructInfo)
Definition: asn.c:1174
#define MEMBERSIZE(s, member, nextmember)
Definition: asn.c:1474
static BOOL WINAPI CRYPT_AsnEncodeBits(DWORD dwCertEncodingType, LPCSTR lpszStructType, const void *pvStructInfo, BYTE *pbEncoded, DWORD *pcbEncoded)
Definition: asn.c:344
static BOOL CRYPT_GetLen(const BYTE *pbEncoded, DWORD cbEncoded, DWORD *len)
Definition: asn.c:1107
BOOL WINAPI WVTAsn1SpcLinkEncode(DWORD dwCertEncodingType, LPCSTR lpszStructType, const void *pvStructInfo, BYTE *pbEncoded, DWORD *pcbEncoded)
Definition: asn.c:128
static BOOL WINAPI CRYPT_AsnDecodeBool(DWORD dwCertEncodingType, LPCSTR lpszStructType, const BYTE *pbEncoded, DWORD cbEncoded, DWORD dwFlags, void *pvStructInfo, DWORD *pcbStructInfo)
Definition: asn.c:2302
#define hton16(x)
Definition: asn.c:44
static BOOL WINAPI CRYPT_AsnDecodeAttributeTypeValue(DWORD dwCertEncodingType, LPCSTR lpszStructType, const BYTE *pbEncoded, DWORD cbEncoded, DWORD dwFlags, void *pvStructInfo, DWORD *pcbStructInfo)
Definition: asn.c:1982
static BOOL CRYPT_EncodeLen(DWORD len, BYTE *pbEncoded, DWORD *pcbEncoded)
Definition: asn.c:53
static BOOL WINAPI CRYPT_AsnDecodeBMPString(DWORD dwCertEncodingType, LPCSTR lpszStructType, const BYTE *pbEncoded, DWORD cbEncoded, DWORD dwFlags, void *pvStructInfo, DWORD *pcbStructInfo)
Definition: asn.c:2089
static BOOL WINAPI CRYPT_AsnDecodeInt(DWORD dwCertEncodingType, LPCSTR lpszStructType, const BYTE *pbEncoded, DWORD cbEncoded, DWORD dwFlags, void *pvStructInfo, DWORD *pcbStructInfo)
Definition: asn.c:2187
#define ASN_BMPSTRING
Definition: asn.c:51
static BOOL WINAPI CRYPT_AsnDecodeSPCLinkPointer(DWORD dwCertEncodingType, LPCSTR lpszStructType, const BYTE *pbEncoded, DWORD cbEncoded, DWORD dwFlags, void *pvStructInfo, DWORD *pcbStructInfo)
Definition: asn.c:1749
static BOOL CRYPT_AsnEncodeSequence(DWORD dwCertEncodingType, struct AsnEncodeSequenceItem items[], DWORD cItem, BYTE *pbEncoded, DWORD *pcbEncoded)
Definition: asn.c:292
static BOOL WINAPI CRYPT_AsnEncodeBool(DWORD dwCertEncodingType, LPCSTR lpszStructType, const void *pvStructInfo, BYTE *pbEncoded, DWORD *pcbEncoded)
Definition: asn.c:1040
static BOOL WINAPI CRYPT_AsnDecodeCopyBytes(DWORD dwCertEncodingType, LPCSTR lpszStructType, const BYTE *pbEncoded, DWORD cbEncoded, DWORD dwFlags, void *pvStructInfo, DWORD *pcbStructInfo)
Definition: asn.c:1945
BOOL WINAPI WVTAsn1SpcIndirectDataContentEncode(DWORD dwCertEncodingType, LPCSTR lpszStructType, const void *pvStructInfo, BYTE *pbEncoded, DWORD *pcbEncoded)
Definition: asn.c:716
#define ASN_BOOL
Definition: asn.c:49
static BOOL WINAPI CRYPT_AsnEncodeOctets(DWORD dwCertEncodingType, LPCSTR lpszStructType, const void *pvStructInfo, BYTE *pbEncoded, DWORD *pcbEncoded)
Definition: asn.c:95
static BOOL WINAPI CRYPT_AsnDecodeOidIgnoreTag(DWORD dwCertEncodingType, LPCSTR lpszStructType, const BYTE *pbEncoded, DWORD cbEncoded, DWORD dwFlags, void *pvStructInfo, DWORD *pcbStructInfo)
Definition: asn.c:1824
BOOL(WINAPI * CryptEncodeObjectFunc)(DWORD, LPCSTR, const void *, BYTE *, DWORD *)
Definition: asn.c:282
static BOOL WINAPI CRYPT_AsnDecodeProgramName(DWORD dwCertEncodingType, LPCSTR lpszStructType, const BYTE *pbEncoded, DWORD cbEncoded, DWORD dwFlags, void *pvStructInfo, DWORD *pcbStructInfo)
Definition: asn.c:2127
static BOOL WINAPI CRYPT_AsnEncodeAlgorithmIdWithNullParams(DWORD dwCertEncodingType, LPCSTR lpszStructType, const void *pvStructInfo, BYTE *pbEncoded, DWORD *pcbEncoded)
Definition: asn.c:656
static BOOL WINAPI CRYPT_AsnEncodeOid(DWORD dwCertEncodingType, LPCSTR lpszStructType, const void *pvStructInfo, BYTE *pbEncoded, DWORD *pcbEncoded)
Definition: asn.c:513
#define FINALMEMBERSIZE(s, member)
Definition: asn.c:1473
BOOL WINAPI WVTAsn1SpcPeImageDataDecode(DWORD dwCertEncodingType, LPCSTR lpszStructType, const BYTE *pbEncoded, DWORD cbEncoded, DWORD dwFlags, void *pvStructInfo, DWORD *pcbStructInfo)
Definition: asn.c:1792
static BOOL WINAPI CRYPT_AsnEncodeBMPString(DWORD dwCertEncodingType, LPCSTR lpszStructType, const void *pvStructInfo, BYTE *pbEncoded, DWORD *pcbEncoded)
Definition: asn.c:744
BOOL WINAPI WVTAsn1CatMemberInfoDecode(DWORD dwCertEncodingType, LPCSTR lpszStructType, const BYTE *pbEncoded, DWORD cbEncoded, DWORD dwFlags, void *pvStructInfo, DWORD *pcbStructInfo)
Definition: asn.c:2235
static BOOL WINAPI CRYPT_AsnEncodeSPCDigest(DWORD dwCertEncodingType, LPCSTR lpszStructType, const void *pvStructInfo, BYTE *pbEncoded, DWORD *pcbEncoded)
Definition: asn.c:702
static BOOL WINAPI CRYPT_AsnEncodeSwapTag(DWORD dwCertEncodingType, LPCSTR lpszStructType, const void *pvStructInfo, BYTE *pbEncoded, DWORD *pcbEncoded)
Definition: asn.c:794
static BOOL WINAPI CRYPT_AsnEncodeAttributeTypeValue(DWORD dwCertEncodingType, LPCSTR lpszStructType, const void *pvStructInfo, BYTE *pbEncoded, DWORD *pcbEncoded)
Definition: asn.c:682
#define ASN_BITSTRING
Definition: asn.c:50
BOOL WINAPI WVTAsn1SpcIndirectDataContentDecode(DWORD dwCertEncodingType, LPCSTR lpszStructType, const BYTE *pbEncoded, DWORD cbEncoded, DWORD dwFlags, void *pvStructInfo, DWORD *pcbStructInfo)
Definition: asn.c:2055
static BOOL CRYPT_AsnDecodeSPCLinkInternal(DWORD dwCertEncodingType, LPCSTR lpszStructType, const BYTE *pbEncoded, DWORD cbEncoded, DWORD dwFlags, void *pvStructInfo, DWORD *pcbStructInfo)
Definition: asn.c:1229
BOOL WINAPI WVTAsn1SpcLinkDecode(DWORD dwCertEncodingType, LPCSTR lpszStructType, const BYTE *pbEncoded, DWORD cbEncoded, DWORD dwFlags, void *pvStructInfo, DWORD *pcbStructInfo)
Definition: asn.c:1386
BOOL WINAPI WVTAsn1CatMemberInfoEncode(DWORD dwCertEncodingType, LPCSTR lpszStructType, const void *pvStructInfo, BYTE *pbEncoded, DWORD *pcbEncoded)
Definition: asn.c:983
static BOOL CRYPT_AsnDecodeSequence(DWORD dwCertEncodingType, struct AsnDecodeSequenceItem items[], DWORD cItem, const BYTE *pbEncoded, DWORD cbEncoded, DWORD dwFlags, void *pvStructInfo, DWORD *pcbStructInfo, void *startingPointer)
Definition: asn.c:1605
static BOOL WINAPI CRYPT_AsnDecodeBitsInternal(DWORD dwCertEncodingType, LPCSTR lpszStructType, const BYTE *pbEncoded, DWORD cbEncoded, DWORD dwFlags, void *pvStructInfo, DWORD *pcbStructInfo)
Definition: asn.c:1685
static BOOL CRYPT_AsnEncodeInteger(DWORD dwCertEncodingType, LPCSTR lpszStructType, const void *pvStructInfo, BYTE *pbEncoded, DWORD *pcbEncoded)
Definition: asn.c:883
BOOL WINAPI WVTAsn1CatNameValueEncode(DWORD dwCertEncodingType, LPCSTR lpszStructType, const void *pvStructInfo, BYTE *pbEncoded, DWORD *pcbEncoded)
Definition: asn.c:1011
BOOL(WINAPI * CryptDecodeObjectFunc)(DWORD, LPCSTR, const BYTE *, DWORD, DWORD, void *, DWORD *)
Definition: asn.c:1432
static BOOL WINAPI CRYPT_AsnEncodeInt(DWORD dwCertEncodingType, LPCSTR lpszStructType, const void *pvStructInfo, BYTE *pbEncoded, DWORD *pcbEncoded)
Definition: asn.c:973
BOOL WINAPI WVTAsn1SpcFinancialCriteriaInfoDecode(DWORD dwCertEncodingType, LPCSTR lpszStructType, const BYTE *pbEncoded, DWORD cbEncoded, DWORD dwFlags, void *pvStructInfo, DWORD *pcbStructInfo)
Definition: asn.c:2344
BOOL WINAPI WVTAsn1CatNameValueDecode(DWORD dwCertEncodingType, LPCSTR lpszStructType, const BYTE *pbEncoded, DWORD cbEncoded, DWORD dwFlags, void *pvStructInfo, DWORD *pcbStructInfo)
Definition: asn.c:2267
#define GET_LEN_BYTES(b)
Definition: asn.c:1100
static BOOL WINAPI CRYPT_AsnDecodeSPCDigest(DWORD dwCertEncodingType, LPCSTR lpszStructType, const BYTE *pbEncoded, DWORD cbEncoded, DWORD dwFlags, void *pvStructInfo, DWORD *pcbStructInfo)
Definition: asn.c:2032
static BOOL WINAPI CRYPT_CopyEncodedBlob(DWORD dwCertEncodingType, LPCSTR lpszStructType, const void *pvStructInfo, BYTE *pbEncoded, DWORD *pcbEncoded)
Definition: asn.c:631
static BOOL WINAPI CRYPT_AsnDecodeOid(DWORD dwCertEncodingType, LPCSTR lpszStructType, const BYTE *pbEncoded, DWORD cbEncoded, DWORD dwFlags, void *pvStructInfo, DWORD *pcbStructInfo)
Definition: asn.c:1926
#define ALIGN_DWORD_PTR(x)
Definition: asn.c:1471
BOOL WINAPI WVTAsn1SpcPeImageDataEncode(DWORD dwCertEncodingType, LPCSTR lpszStructType, const void *pvStructInfo, BYTE *pbEncoded, DWORD *pcbEncoded)
Definition: asn.c:468
static BOOL CRYPT_AsnDecodeSequenceItems(DWORD dwCertEncodingType, struct AsnDecodeSequenceItem items[], DWORD cItem, const BYTE *pbEncoded, DWORD cbEncoded, DWORD dwFlags, void *pvStructInfo, BYTE *nextData, DWORD *cbDecoded)
Definition: asn.c:1484
static BOOL WINAPI CRYPT_AsnEncodeConstructed(DWORD dwCertEncodingType, LPCSTR lpszStructType, const void *pvStructInfo, BYTE *pbEncoded, DWORD *pcbEncoded)
Definition: asn.c:421
BOOL WINAPI WVTAsn1SpcSpOpusInfoDecode(DWORD dwCertEncodingType, LPCSTR lpszStructType, const BYTE *pbEncoded, DWORD cbEncoded, DWORD dwFlags, void *pvStructInfo, DWORD *pcbStructInfo)
Definition: asn.c:2148
BOOL WINAPI WVTAsn1SpcSpOpusInfoEncode(DWORD dwCertEncodingType, LPCSTR lpszStructType, const void *pvStructInfo, BYTE *pbEncoded, DWORD *pcbEncoded)
Definition: asn.c:808
return ret
Definition: mutex.c:146
unsigned short WORD
Definition: ntddk_ex.h:93
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
#define STATUS_ACCESS_VIOLATION
MdFileObject pFile
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
GLsizeiptr size
Definition: glext.h:5919
GLintptr offset
Definition: glext.h:5920
GLenum GLint GLuint mask
Definition: glext.h:6028
GLuint GLfloat * val
Definition: glext.h:7180
GLenum GLsizei len
Definition: glext.h:6722
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define debugstr_a
Definition: kernel32.h:31
#define debugstr_w
Definition: kernel32.h:32
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
static PVOID ptr
Definition: dispmode.c:27
#define sprintf
Definition: sprintf.c:45
_In_ LPWSTR _In_ DWORD _In_ DWORD _In_ DWORD dwFlags
Definition: netsh.h:141
#define BOOL
Definition: nt_native.h:43
#define DWORD
Definition: nt_native.h:44
static TCHAR * items[]
Definition: page1.c:45
#define INT
Definition: polytest.cpp:20
_In_opt_ _In_opt_ _In_ _In_ DWORD cbData
Definition: shlwapi.h:761
const WCHAR * str
static calc_node_t temp
Definition: rpn_ieee.c:38
#define offsetof(TYPE, MEMBER)
#define ASN_OCTETSTRING
Definition: snmp.h:105
#define ASN_NULL
Definition: snmp.h:106
#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_SEQUENCEOF
Definition: snmp.h:111
#define ASN_CONTEXT
Definition: snmp.h:89
#define memset(x, y, z)
Definition: compat.h:39
#define TRACE(s)
Definition: solgame.cpp:4
const void * pvStructInfo
CryptEncodeObjectFunc encodeFunc
Definition: asn.c:418
CryptEncodeObjectExFunc encodeFunc
CryptDecodeObjectFunc decodeFunc
Definition: asn.c:1461
const void * pvStructInfo
CryptEncodeObjectFunc encodeFunc
Definition: asn.c:288
CryptEncodeObjectFunc encodeFunc
Definition: asn.c:787
const void * pvStructInfo
Definition: encode.c:290
CryptEncodeObjectExFunc encodeFunc
Definition: encode.c:291
Definition: asn.c:697
CRYPT_HASH_BLOB Digest
Definition: asn.c:699
CRYPT_ALGORITHM_IDENTIFIER DigestAlgorithm
Definition: asn.c:698
BYTE * pbData
Definition: wincrypt.h:112
CRYPT_OBJID_BLOB Parameters
Definition: wincrypt.h:136
CRYPT_OBJID_BLOB Value
Definition: wincrypt.h:141
CRYPT_BIT_BLOB Flags
Definition: wintrust.h:551
PSPC_LINK pFile
Definition: wintrust.h:552
Definition: image.c:134
Definition: ecma_167.h:138
unsigned char * LPBYTE
Definition: typedefs.h:53
Definition: pdh_main.c:96
wchar_t tm const _CrtWcstime_Writes_and_advances_ptr_ count wchar_t ** out
Definition: wcsftime.cpp:383
_Must_inspect_result_ _In_ WDFQUEUE _In_opt_ WDFREQUEST _In_opt_ WDFFILEOBJECT _Inout_opt_ PWDF_REQUEST_PARAMETERS Parameters
Definition: wdfio.h:869
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _Out_opt_ PUSHORT _Inout_opt_ PUNICODE_STRING Value
Definition: wdfregistry.h:413
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
struct _CRYPTOAPI_BLOB CRYPT_DER_BLOB
#define CRYPT_DECODE_NOCOPY_FLAG
Definition: wincrypt.h:3608
#define X509_MULTI_BYTE_INTEGER
Definition: wincrypt.h:3546
struct _CRYPTOAPI_BLOB CRYPT_DATA_BLOB
struct _CRYPT_ALGORITHM_IDENTIFIER CRYPT_ALGORITHM_IDENTIFIER
#define X509_ASN_ENCODING
Definition: wincrypt.h:2501
#define CRYPT_DECODE_ALLOC_FLAG
Definition: wincrypt.h:3612
struct _CRYPT_BIT_BLOB CRYPT_BIT_BLOB
struct _CRYPTOAPI_BLOB CRYPT_OBJID_BLOB
struct _CRYPT_ATTRIBUTE_TYPE_VALUE CRYPT_ATTRIBUTE_TYPE_VALUE
#define WINAPI
Definition: msvc.h:6
#define CRYPT_E_ASN1_ERROR
Definition: winerror.h:4499
#define NOERROR
Definition: winerror.h:3448
#define CRYPT_E_ASN1_CORRUPT
Definition: winerror.h:4502
#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_ASN1_EOD
Definition: winerror.h:4501
#define CRYPT_E_ASN1_BADTAG
Definition: winerror.h:4510
#define snprintf
Definition: wintirpc.h:48
BYTE SPC_UUID[SPC_UUID_LENGTH]
Definition: wintrust.h:515
struct SPC_LINK_ SPC_LINK
#define SPC_FILE_LINK_CHOICE
Definition: wintrust.h:536
#define SPC_MONIKER_LINK_CHOICE
Definition: wintrust.h:535
struct SPC_LINK_ * PSPC_LINK
#define SPC_URL_LINK_CHOICE
Definition: wintrust.h:534
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
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
unsigned char BYTE
Definition: xxhash.c:193