ReactOS 0.4.16-dev-2491-g3dc6630
crypt.c
Go to the documentation of this file.
1/*
2 * WinTrust Cryptography functions
3 *
4 * Copyright 2006 James Hawkins
5 * Copyright 2000-2002 Stuart Caie
6 * Copyright 2002 Patrik Stridvall
7 * Copyright 2003 Greg Turner
8 * Copyright 2008 Juan Lang
9 *
10 * This library is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU Lesser General Public
12 * License as published by the Free Software Foundation; either
13 * version 2.1 of the License, or (at your option) any later version.
14 *
15 * This library is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * Lesser General Public License for more details.
19 *
20 * You should have received a copy of the GNU Lesser General Public
21 * License along with this library; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
23 */
24
25#include <stdarg.h>
26#include <stdio.h>
27#include "windef.h"
28#include "winbase.h"
29#include "wintrust.h"
30#include "winver.h"
31#include "mscat.h"
32#include "mssip.h"
33#include "imagehlp.h"
34#include "winternl.h"
35
36#include "wine/debug.h"
37
39
40#define CATADMIN_MAGIC 0x43415441 /* 'CATA' */
41#define CRYPTCAT_MAGIC 0x43415443 /* 'CATC' */
42#define CATINFO_MAGIC 0x43415449 /* 'CATI' */
43
45{
54};
55
57{
64};
65
66struct catinfo
67{
70};
71
73{
74 struct catinfo *ci;
75
76 if (!(ci = malloc(sizeof(*ci))))
77 {
80 }
82 ci->magic = CATINFO_MAGIC;
83 return ci;
84}
85
86/***********************************************************************
87 * CryptCATAdminAcquireContext (WINTRUST.@)
88 *
89 * Get a catalog administrator context handle.
90 *
91 * PARAMS
92 * catAdmin [O] Pointer to the context handle.
93 * sys [I] Pointer to a GUID for the needed subsystem.
94 * dwFlags [I] Reserved.
95 *
96 * RETURNS
97 * Success: TRUE. catAdmin contains the context handle.
98 * Failure: FALSE.
99 *
100 */
102 const GUID *sys, DWORD dwFlags)
103{
104 TRACE("%p %s %lx\n", catAdmin, debugstr_guid(sys), dwFlags);
105 return CryptCATAdminAcquireContext2(catAdmin, sys, NULL, NULL, dwFlags);
106}
107
108/***********************************************************************
109 * CryptCATAdminAcquireContext2 (WINTRUST.@)
110 * Get a catalog administrator context handle.
111 *
112 * PARAMS
113 * catAdmin [O] Pointer to the context handle.
114 * sys [I] Pointer to a GUID for the needed subsystem.
115 * algorithm [I] String of hashing algorithm to use for catalog (SHA1/SHA256).
116 * policy [I] Pointer to policy structure for checking strong signatures.
117 * dwFlags [I] Reserved.
118 *
119 * RETURNS
120 * Success: TRUE. catAdmin contains the context handle.
121 * Failure: FALSE.
122 *
123 */
126{
127 static const WCHAR catroot[] =
128 {'\\','c','a','t','r','o','o','t',0};
129 static const WCHAR fmt[] =
130 {'%','s','\\','{','%','0','8','x','-','%','0','4','x','-','%','0',
131 '4','x','-','%','0','2','x','%','0','2','x','-','%','0','2','x',
132 '%','0','2','x','%','0','2','x','%','0','2','x','%','0','2','x',
133 '%','0','2','x','}',0};
134 static const GUID defsys =
135 {0x127d0a1d,0x4ef2,0x11d1,{0x86,0x08,0x00,0xc0,0x4f,0xc2,0x95,0xee}};
136
137 WCHAR catroot_dir[MAX_PATH];
138 struct catadmin *ca;
139 ALG_ID alg;
140 const WCHAR *providerName;
142
143 TRACE("%p %s %s %p %lx\n", catAdmin, debugstr_guid(sys), debugstr_w(algorithm), policy, dwFlags);
144
145 if (!catAdmin || dwFlags)
146 {
148 return FALSE;
149 }
150
151 if (policy != NULL)
152 FIXME("strong policy parameter is unimplemented\n");
153
155 {
156 alg = CALG_SHA1;
159 }
161 {
165 }
166 else
167 {
169 return FALSE;
170 }
171
172 if (!(ca = malloc(sizeof(*ca))))
173 {
175 return FALSE;
176 }
177
178 ca->alg = alg;
179 ca->providerName = providerName;
180 ca->providerType = providerType;
181
182 GetSystemDirectoryW(catroot_dir, MAX_PATH);
183 lstrcatW(catroot_dir, catroot);
184
185 /* create the directory if it doesn't exist */
186 CreateDirectoryW(catroot_dir, NULL);
187
188 if (!sys) sys = &defsys;
189 swprintf(ca->path, ARRAY_SIZE(ca->path), fmt, catroot_dir, sys->Data1, sys->Data2,
190 sys->Data3, sys->Data4[0], sys->Data4[1], sys->Data4[2],
191 sys->Data4[3], sys->Data4[4], sys->Data4[5], sys->Data4[6],
192 sys->Data4[7]);
193
194 /* create the directory if it doesn't exist */
195 CreateDirectoryW(ca->path, NULL);
196
197 ca->magic = CATADMIN_MAGIC;
198 ca->find = INVALID_HANDLE_VALUE;
199
200 *catAdmin = ca;
201 return TRUE;
202}
203
204/***********************************************************************
205 * CryptCATAdminAddCatalog (WINTRUST.@)
206 */
208 PWSTR selectBaseName, DWORD flags)
209{
210 static const WCHAR slashW[] = {'\\',0};
211 struct catadmin *ca = catAdmin;
212 struct catinfo *ci;
213 WCHAR *target;
214 DWORD len;
215
216 TRACE("%p %s %s %ld\n", catAdmin, debugstr_w(catalogFile),
217 debugstr_w(selectBaseName), flags);
218
219 if (!selectBaseName)
220 {
221 FIXME("NULL basename not handled\n");
223 return NULL;
224 }
225 if (!ca || ca->magic != CATADMIN_MAGIC || !catalogFile || flags)
226 {
228 return NULL;
229 }
230
231 len = lstrlenW(ca->path) + lstrlenW(selectBaseName) + 2;
232 if (!(target = malloc(len * sizeof(WCHAR))))
233 {
235 return NULL;
236 }
237 lstrcpyW(target, ca->path);
239 lstrcatW(target, selectBaseName);
240
241 if (!CopyFileW(catalogFile, target, FALSE))
242 {
243 free(target);
244 return NULL;
245 }
247
248 if (!(ci = malloc(sizeof(*ci))))
249 {
250 free(target);
252 return NULL;
253 }
254 ci->magic = CATINFO_MAGIC;
255 lstrcpyW(ci->file, target);
256
257 free(target);
258 return ci;
259}
260
262{
263 UINT32 size, offset, file_size, sig_pos;
265 BYTE *view;
267 BOOL ret = FALSE;
268
269 if ((file_size = GetFileSize( file, NULL )) == INVALID_FILE_SIZE) return FALSE;
270
272 return FALSE;
273
274 if (!(view = MapViewOfFile( mapping, FILE_MAP_READ, 0, 0, 0 )) || !(nt = ImageNtHeader( view ))) goto done;
275
277 {
278 const IMAGE_NT_HEADERS64 *nt64 = (const IMAGE_NT_HEADERS64 *)nt;
279
280 /* offset from start of file to checksum */
281 offset = (BYTE *)&nt64->OptionalHeader.CheckSum - view;
282
283 /* area between checksum and security directory entry */
286
289 }
291 {
292 const IMAGE_NT_HEADERS32 *nt32 = (const IMAGE_NT_HEADERS32 *)nt;
293
294 /* offset from start of file to checksum */
295 offset = (BYTE *)&nt32->OptionalHeader.CheckSum - view;
296
297 /* area between checksum and security directory entry */
300
303 }
304 else goto done;
305
306 if (!CryptHashData( hash, view, offset, 0 )) goto done;
307 offset += sizeof(DWORD); /* skip checksum */
308 if (!CryptHashData( hash, view + offset, size, 0 )) goto done;
309
310 offset += size + sizeof(IMAGE_DATA_DIRECTORY); /* skip security entry */
311 if (offset > file_size) goto done;
312 if (sig_pos)
313 {
314 if (sig_pos < offset) goto done;
315 if (sig_pos > file_size) goto done;
316 size = sig_pos - offset; /* exclude signature */
317 }
318 else size = file_size - offset;
319
320 if (!CryptHashData( hash, view + offset, size, 0 )) goto done;
321 ret = TRUE;
322
323 if (!sig_pos && (size = file_size % 8))
324 {
325 static const BYTE pad[7];
326 ret = CryptHashData( hash, pad, 8 - size, 0 );
327 }
328
329done:
332 return ret;
333}
334
336 BYTE *pbHash, DWORD dwFlags)
337{
338 BOOL ret = FALSE;
339 struct catadmin *ca = catAdmin;
343 DWORD hashLength;
344
345 if (!hFile || !pcbHash || dwFlags)
346 {
348 return FALSE;
349 }
350
351 if (ca)
352 {
353 alg = ca->alg;
354 providerName = ca->providerName;
355 providerType = ca->providerType;
356 }
357
358 switch (alg)
359 {
360 case CALG_SHA1:
361 hashLength = 20;
362 break;
363 case CALG_SHA_256:
364 hashLength = 32;
365 break;
366 default:
367 FIXME("unsupported algorithm %x\n", alg);
368 return FALSE;
369 }
370
371 if (*pcbHash < hashLength)
372 {
373 *pcbHash = hashLength;
375 return TRUE;
376 }
377
378 *pcbHash = hashLength;
379 if (pbHash)
380 {
381 HCRYPTPROV prov;
383 DWORD bytes_read;
384 BYTE *buffer;
385
386 if (!(buffer = malloc(4096)))
387 {
389 return FALSE;
390 }
392 if (!ret)
393 {
394 free(buffer);
395 return FALSE;
396 }
397 ret = CryptCreateHash(prov, alg, 0, 0, &hash);
398 if (!ret)
399 {
400 free(buffer);
401 CryptReleaseContext(prov, 0);
402 return FALSE;
403 }
404
405 if (!(ret = pe_image_hash(hFile, hash)))
406 {
407 while ((ret = ReadFile(hFile, buffer, 4096, &bytes_read, NULL)) && bytes_read)
408 {
409 CryptHashData(hash, buffer, bytes_read, 0);
410 }
411 }
412 if (ret) ret = CryptGetHashParam(hash, HP_HASHVAL, pbHash, pcbHash, 0);
413
414 free(buffer);
416 CryptReleaseContext(prov, 0);
417 }
418 return ret;
419}
420
421/***********************************************************************
422 * CryptCATAdminCalcHashFromFileHandle (WINTRUST.@)
423 */
425{
426 TRACE("%p %p %p %lx\n", hFile, pcbHash, pbHash, dwFlags);
427 return catadmin_calc_hash_from_filehandle(NULL, hFile, pcbHash, pbHash, dwFlags);
428}
429
430/***********************************************************************
431 * CryptCATAdminCalcHashFromFileHandle2 (WINTRUST.@)
432 *
433 * Calculate hash for a specific file using a catalog administrator context.
434 *
435 * PARAMS
436 * catAdmin [I] Catalog administrator context handle.
437 * hFile [I] Handle for the file to hash.
438 * pcbHash [I] Pointer to the length of the hash.
439 * pbHash [O] Pointer to the buffer that will store that hash
440 * dwFlags [I] Reserved.
441 *
442 * RETURNS
443 * Success: TRUE. If pcbHash is too small, LastError will be set to ERROR_INSUFFICIENT_BUFFER.
444 * pbHash contains the computed hash, if supplied.
445 * Failure: FALSE.
446 *
447 */
449 BYTE *pbHash, DWORD dwFlags)
450{
451 TRACE("%p %p %p %p %lx\n", catAdmin, hFile, pcbHash, pbHash, dwFlags);
452
453 if (!catAdmin || ((struct catadmin *)catAdmin)->magic != CATADMIN_MAGIC)
454 {
456 return FALSE;
457 }
458
459 return catadmin_calc_hash_from_filehandle(catAdmin, hFile, pcbHash, pbHash, dwFlags);
460}
461
462
463/***********************************************************************
464 * CryptCATAdminEnumCatalogFromHash (WINTRUST.@)
465 */
467 DWORD cbHash, DWORD dwFlags,
468 HCATINFO* phPrevCatInfo )
469{
470 static const WCHAR slashW[] = {'\\',0};
471 static const WCHAR globW[] = {'\\','*','.','c','a','t',0};
472
473 struct catadmin *ca = hCatAdmin;
475 HCATINFO prev = NULL;
476 HCRYPTPROV prov;
477 DWORD size;
478 BOOL ret;
479
480 TRACE("%p %p %ld %lx %p\n", hCatAdmin, pbHash, cbHash, dwFlags, phPrevCatInfo);
481
482 if (!ca || ca->magic != CATADMIN_MAGIC || !pbHash || cbHash != 20 || dwFlags)
483 {
485 return NULL;
486 }
487 if (phPrevCatInfo) prev = *phPrevCatInfo;
488
490 if (!ret) return NULL;
491
492 if (!prev)
493 {
494 WCHAR *path;
495
496 size = lstrlenW(ca->path) * sizeof(WCHAR) + sizeof(globW);
497 if (!(path = malloc(size)))
498 {
499 CryptReleaseContext(prov, 0);
501 return NULL;
502 }
503 lstrcpyW(path, ca->path);
504 lstrcatW(path, globW);
505
506 FindClose(ca->find);
507 ca->find = FindFirstFileW(path, &data);
508
509 free(path);
510 if (ca->find == INVALID_HANDLE_VALUE)
511 {
512 CryptReleaseContext(prov, 0);
513 return NULL;
514 }
515 }
516 else if (!FindNextFileW(ca->find, &data))
517 {
518 CryptCATAdminReleaseCatalogContext(hCatAdmin, prev, 0);
519 CryptReleaseContext(prov, 0);
520 return NULL;
521 }
522
523 while (1)
524 {
527 struct catinfo *ci;
528 HANDLE hcat;
529
530 size = (lstrlenW(ca->path) + lstrlenW(data.cFileName) + 2) * sizeof(WCHAR);
531 if (!(filename = malloc(size)))
532 {
534 return NULL;
535 }
536 lstrcpyW(filename, ca->path);
538 lstrcatW(filename, data.cFileName);
539
540 hcat = CryptCATOpen(filename, CRYPTCAT_OPEN_EXISTING, prov, 0, 0);
541 if (hcat == INVALID_HANDLE_VALUE)
542 {
543 WARN("couldn't open %s (%lu)\n", debugstr_w(filename), GetLastError());
544 continue;
545 }
546 while ((member = CryptCATEnumerateMember(hcat, member)))
547 {
548 if (member->pIndirectData->Digest.cbData != cbHash)
549 {
550 WARN("amount of hash bytes differs: %lu/%lu\n", member->pIndirectData->Digest.cbData, cbHash);
551 continue;
552 }
553 if (!memcmp(member->pIndirectData->Digest.pbData, pbHash, cbHash))
554 {
555 TRACE("file %s matches\n", debugstr_w(data.cFileName));
556
557 CryptCATClose(hcat);
558 CryptReleaseContext(prov, 0);
559 if (!phPrevCatInfo)
560 {
561 FindClose(ca->find);
562 ca->find = INVALID_HANDLE_VALUE;
563 }
565 free(filename);
566 return ci;
567 }
568 }
569 CryptCATClose(hcat);
570 free(filename);
571
572 if (!FindNextFileW(ca->find, &data))
573 {
574 FindClose(ca->find);
575 ca->find = INVALID_HANDLE_VALUE;
576 CryptReleaseContext(prov, 0);
577 return NULL;
578 }
579 }
580 return NULL;
581}
582
583/***********************************************************************
584 * CryptCATAdminReleaseCatalogContext (WINTRUST.@)
585 *
586 * Release a catalog context handle.
587 *
588 * PARAMS
589 * hCatAdmin [I] Context handle.
590 * hCatInfo [I] Catalog handle.
591 * dwFlags [I] Reserved.
592 *
593 * RETURNS
594 * Success: TRUE.
595 * Failure: FALSE.
596 *
597 */
599 HCATINFO hCatInfo,
601{
602 struct catinfo *ci = hCatInfo;
603 struct catadmin *ca = hCatAdmin;
604
605 TRACE("%p %p %lx\n", hCatAdmin, hCatInfo, dwFlags);
606
607 if (!ca || ca->magic != CATADMIN_MAGIC || !ci || ci->magic != CATINFO_MAGIC)
608 {
610 return FALSE;
611 }
612 /* Ensure compiler doesn't optimize out the assignment with 0. */
613 SecureZeroMemory(&ci->magic, sizeof(ci->magic));
614 free(ci);
615 return TRUE;
616}
617
618/***********************************************************************
619 * CryptCATAdminReleaseContext (WINTRUST.@)
620 *
621 * Release a catalog administrator context handle.
622 *
623 * PARAMS
624 * catAdmin [I] Context handle.
625 * dwFlags [I] Reserved.
626 *
627 * RETURNS
628 * Success: TRUE.
629 * Failure: FALSE.
630 *
631 */
633{
634 struct catadmin *ca = hCatAdmin;
635
636 TRACE("%p %lx\n", hCatAdmin, dwFlags);
637
638 if (!ca || ca->magic != CATADMIN_MAGIC)
639 {
641 return FALSE;
642 }
643 if (ca->find != INVALID_HANDLE_VALUE) FindClose(ca->find);
644 /* Ensure compiler doesn't optimize out the assignment with 0. */
645 SecureZeroMemory(&ca->magic, sizeof(ca->magic));
646 free(ca);
647 return TRUE;
648}
649
650/***********************************************************************
651 * CryptCATAdminRemoveCatalog (WINTRUST.@)
652 *
653 * Remove a catalog file.
654 *
655 * PARAMS
656 * catAdmin [I] Context handle.
657 * pwszCatalogFile [I] Catalog file.
658 * dwFlags [I] Reserved.
659 *
660 * RETURNS
661 * Success: TRUE.
662 * Failure: FALSE.
663 *
664 */
666{
667 struct catadmin *ca = hCatAdmin;
668
669 TRACE("%p %s %lx\n", hCatAdmin, debugstr_w(pwszCatalogFile), dwFlags);
670
671 if (!ca || ca->magic != CATADMIN_MAGIC)
672 {
674 return FALSE;
675 }
676
677 /* Only delete when there is a filename and no path */
678 if (pwszCatalogFile && pwszCatalogFile[0] != 0 &&
679 !wcschr(pwszCatalogFile, '\\') && !wcschr(pwszCatalogFile, '/') &&
680 !wcschr(pwszCatalogFile, ':'))
681 {
682 static const WCHAR slashW[] = {'\\',0};
683 WCHAR *target;
684 DWORD len;
685
686 len = lstrlenW(ca->path) + lstrlenW(pwszCatalogFile) + 2;
687 if (!(target = malloc(len * sizeof(WCHAR))))
688 {
690 return FALSE;
691 }
692 lstrcpyW(target, ca->path);
694 lstrcatW(target, pwszCatalogFile);
695
697
698 free(target);
699 }
700
701 return TRUE;
702}
703
704/***********************************************************************
705 * CryptCATAdminResolveCatalogPath (WINTRUST.@)
706 */
709{
710 static const WCHAR slashW[] = {'\\',0};
711 struct catadmin *ca = hcatadmin;
712
713 TRACE("%p %s %p %lx\n", hcatadmin, debugstr_w(catalog_file), info, flags);
714
715 if (!ca || ca->magic != CATADMIN_MAGIC || !info || info->cbStruct != sizeof(*info) || flags)
716 {
718 return FALSE;
719 }
720 lstrcpyW(info->wszCatalogFile, ca->path);
721 lstrcatW(info->wszCatalogFile, slashW);
722 lstrcatW(info->wszCatalogFile, catalog_file);
723
724 return TRUE;
725}
726
727/***********************************************************************
728 * CryptCATClose (WINTRUST.@)
729 */
731{
732 struct cryptcat *cc = hCatalog;
733
734 TRACE("(%p)\n", hCatalog);
735
736 if (!hCatalog || hCatalog == INVALID_HANDLE_VALUE || cc->magic != CRYPTCAT_MAGIC)
737 {
739 return FALSE;
740 }
741 free(cc->attr);
742 free(cc->inner);
743 CryptMsgClose(cc->msg);
744
745 /* Ensure compiler doesn't optimize out the assignment with 0. */
746 SecureZeroMemory(&cc->magic, sizeof(cc->magic));
747 free(cc);
748 return TRUE;
749}
750
751/***********************************************************************
752 * CryptCATGetAttrInfo (WINTRUST.@)
753 */
755{
756 struct cryptcat *cc = hCatalog;
757
758 FIXME("%p, %p, %s\n", hCatalog, member, debugstr_w(tag));
759
760 if (!hCatalog || hCatalog == INVALID_HANDLE_VALUE || cc->magic != CRYPTCAT_MAGIC)
761 {
763 return NULL;
764 }
766 return NULL;
767}
768
769/***********************************************************************
770 * CryptCATGetCatAttrInfo (WINTRUST.@)
771 */
773{
774 struct cryptcat *cc = hCatalog;
775
776 FIXME("%p, %s\n", hCatalog, debugstr_w(tag));
777
778 if (!hCatalog || hCatalog == INVALID_HANDLE_VALUE || cc->magic != CRYPTCAT_MAGIC)
779 {
781 return NULL;
782 }
784 return NULL;
785}
786
788{
789 struct cryptcat *cc = hCatalog;
790
791 FIXME("%p, %s\n", hCatalog, debugstr_w(tag));
792
793 if (!hCatalog || hCatalog == INVALID_HANDLE_VALUE || cc->magic != CRYPTCAT_MAGIC)
794 {
796 return NULL;
797 }
799 return NULL;
800}
801
802/***********************************************************************
803 * CryptCATEnumerateAttr (WINTRUST.@)
804 */
806{
807 struct cryptcat *cc = hCatalog;
808
809 FIXME("%p, %p, %p\n", hCatalog, member, prev);
810
811 if (!hCatalog || hCatalog == INVALID_HANDLE_VALUE || cc->magic != CRYPTCAT_MAGIC)
812 {
814 return NULL;
815 }
817 return NULL;
818}
819
820/***********************************************************************
821 * CryptCATEnumerateCatAttr (WINTRUST.@)
822 */
824{
825 struct cryptcat *cc = hCatalog;
826
827 FIXME("%p, %p\n", hCatalog, prev);
828
829 if (!hCatalog || hCatalog == INVALID_HANDLE_VALUE || cc->magic != CRYPTCAT_MAGIC)
830 {
832 return NULL;
833 }
835 return NULL;
836}
837
838/***********************************************************************
839 * CryptCATEnumerateMember (WINTRUST.@)
840 */
842{
843 struct cryptcat *cc = hCatalog;
844 CRYPTCATMEMBER *member = prev;
846 DWORD size, i;
847
848 TRACE("%p, %p\n", hCatalog, prev);
849
850 if (!hCatalog || hCatalog == INVALID_HANDLE_VALUE || cc->magic != CRYPTCAT_MAGIC)
851 {
853 return NULL;
854 }
855
856 /* dumping the contents makes me think that dwReserved is the iteration number */
857 if (!member)
858 {
859 if (!(member = malloc(sizeof(*member))))
860 {
862 return NULL;
863 }
864 member->cbStruct = sizeof(*member);
865 member->pwszFileName = member->pwszReferenceTag = NULL;
866 member->dwReserved = 0;
867 member->hReserved = NULL;
868 member->gSubjectType = cc->subject;
869 member->fdwMemberFlags = 0;
870 member->pIndirectData = NULL;
871 member->dwCertVersion = cc->inner->dwVersion;
872 }
873 else member->dwReserved++;
874
875 if (member->dwReserved >= cc->inner->cCTLEntry)
876 {
878 goto error;
879 }
880
881 /* list them backwards, like native */
882 entry = &cc->inner->rgCTLEntry[cc->inner->cCTLEntry - member->dwReserved - 1];
883
884 member->sEncodedIndirectData.cbData = member->sEncodedMemberInfo.cbData = 0;
885 member->sEncodedIndirectData.pbData = member->sEncodedMemberInfo.pbData = NULL;
886 free(member->pIndirectData);
887 member->pIndirectData = NULL;
888
889 for (i = 0; i < entry->cAttribute; i++)
890 {
891 CRYPT_ATTRIBUTE *attr = entry->rgAttribute + i;
892
893 if (attr->cValue != 1)
894 {
895 ERR("Can't handle attr->cValue of %lu\n", attr->cValue);
896 continue;
897 }
898 if (!strcmp(attr->pszObjId, CAT_MEMBERINFO_OBJID))
899 {
901 BOOL ret;
902
903 member->sEncodedMemberInfo.cbData = attr->rgValue->cbData;
904 member->sEncodedMemberInfo.pbData = attr->rgValue->pbData;
905
906 CryptDecodeObject(cc->encoding, CAT_MEMBERINFO_OBJID, attr->rgValue->pbData, attr->rgValue->cbData, 0, NULL, &size);
907
908 if (!(mi = malloc(size)))
909 {
911 goto error;
912 }
913 ret = CryptDecodeObject(cc->encoding, CAT_MEMBERINFO_OBJID, attr->rgValue->pbData, attr->rgValue->cbData, 0, mi, &size);
914 if (ret)
915 {
917
918 member->dwCertVersion = mi->dwCertVersion;
919 RtlInitUnicodeString(&guid, mi->pwszSubjGuid);
920 if (RtlGUIDFromString(&guid, &member->gSubjectType))
921 {
922 free(mi);
923 goto error;
924 }
925 }
926 free(mi);
927 if (!ret) goto error;
928 }
929 else if (!strcmp(attr->pszObjId, SPC_INDIRECT_DATA_OBJID))
930 {
931 /* SPC_INDIRECT_DATA_CONTENT is equal to SIP_INDIRECT_DATA */
932
933 member->sEncodedIndirectData.cbData = attr->rgValue->cbData;
934 member->sEncodedIndirectData.pbData = attr->rgValue->pbData;
935
936 CryptDecodeObject(cc->encoding, SPC_INDIRECT_DATA_OBJID, attr->rgValue->pbData, attr->rgValue->cbData, 0, NULL, &size);
937
938 if (!(member->pIndirectData = malloc(size)))
939 {
941 goto error;
942 }
943 CryptDecodeObject(cc->encoding, SPC_INDIRECT_DATA_OBJID, attr->rgValue->pbData, attr->rgValue->cbData, 0, member->pIndirectData, &size);
944 }
945 else
946 /* this object id should probably be handled in CryptCATEnumerateAttr */
947 FIXME("unhandled object id \"%s\"\n", attr->pszObjId);
948 }
949
950 if (!member->sEncodedMemberInfo.cbData || !member->sEncodedIndirectData.cbData)
951 {
952 ERR("Corrupted catalog entry?\n");
954 goto error;
955 }
956 size = (2 * member->pIndirectData->Digest.cbData + 1) * sizeof(WCHAR);
957 member->pwszReferenceTag = realloc(member->pwszReferenceTag, size);
958
959 if (!member->pwszReferenceTag)
960 {
962 goto error;
963 }
964 /* FIXME: reference tag is usually the file hash but doesn't have to be */
965 for (i = 0; i < member->pIndirectData->Digest.cbData; i++)
966 {
967 DWORD sub;
968
969 sub = member->pIndirectData->Digest.pbData[i] >> 4;
970 member->pwszReferenceTag[i * 2] = (sub < 10 ? '0' + sub : 'A' + sub - 10);
971 sub = member->pIndirectData->Digest.pbData[i] & 0xf;
972 member->pwszReferenceTag[i * 2 + 1] = (sub < 10 ? '0' + sub : 'A' + sub - 10);
973 }
974 member->pwszReferenceTag[i * 2] = 0;
975 return member;
976
977error:
978 free(member->pIndirectData);
979 free(member->pwszReferenceTag);
980 free(member);
981 return NULL;
982}
983
985{
986 DWORD size;
987 LPSTR oid = NULL;
988 BYTE *buffer = NULL;
990
992 if (!(oid = malloc(size)))
993 {
995 return NULL;
996 }
997 if (!CryptMsgGetParam(hmsg, CMSG_INNER_CONTENT_TYPE_PARAM, 0, oid, &size)) goto out;
998 if (!CryptMsgGetParam(hmsg, CMSG_CONTENT_PARAM, 0, NULL, &size)) goto out;
999 if (!(buffer = malloc(size)))
1000 {
1002 goto out;
1003 }
1004 if (!CryptMsgGetParam(hmsg, CMSG_CONTENT_PARAM, 0, buffer, &size)) goto out;
1005 if (!CryptDecodeObject(encoding, oid, buffer, size, 0, NULL, &size)) goto out;
1006 if (!(inner = malloc(size)))
1007 {
1009 goto out;
1010 }
1011 if (!CryptDecodeObject(encoding, oid, buffer, size, 0, inner, &size)) goto out;
1012 *len = size;
1013
1014out:
1015 free(oid);
1016 free(buffer);
1017 return inner;
1018}
1019
1020/***********************************************************************
1021 * CryptCATCatalogInfoFromContext (WINTRUST.@)
1022 */
1024{
1025 struct catinfo *ci = hcatinfo;
1026
1027 TRACE("%p, %p, %lx\n", hcatinfo, info, flags);
1028
1029 if (!hcatinfo || hcatinfo == INVALID_HANDLE_VALUE || ci->magic != CATINFO_MAGIC ||
1030 flags || !info || info->cbStruct != sizeof(*info))
1031 {
1033 return FALSE;
1034 }
1035 lstrcpyW(info->wszCatalogFile, ci->file);
1036 return TRUE;
1037}
1038
1039/***********************************************************************
1040 * CryptCATPutAttrInfo (WINTRUST.@)
1041 */
1044{
1045 FIXME("catalog %p, member %p, name %s, flags %#lx, size %lu, data %p, stub!\n",
1046 catalog, member, debugstr_w(name), flags, size, data);
1047
1049 return NULL;
1050}
1051
1052/***********************************************************************
1053 * CryptCATPutCatAttrInfo (WINTRUST.@)
1054 */
1057{
1058 FIXME("catalog %p, name %s, flags %#lx, size %lu, data %p, stub!\n",
1059 catalog, debugstr_w(name), flags, size, data);
1060
1062 return NULL;
1063}
1064
1065/***********************************************************************
1066 * CryptCATPutMemberInfo (WINTRUST.@)
1067 */
1069 WCHAR *member, GUID *subject, DWORD version, DWORD size, BYTE *data)
1070{
1071 FIXME("catalog %p, filename %s, member %s, subject %s, version %lu, size %lu, data %p, stub!\n",
1073
1075 return NULL;
1076}
1077
1078/***********************************************************************
1079 * CryptCATPersistStore (WINTRUST.@)
1080 */
1082{
1083 FIXME("catalog %p, stub!\n", catalog);
1084
1086 return FALSE;
1087}
1088
1089/***********************************************************************
1090 * CryptCATOpen (WINTRUST.@)
1091 */
1093 DWORD dwPublicVersion, DWORD dwEncodingType)
1094{
1095 HANDLE file, hmsg;
1096 BYTE *buffer = NULL;
1097 DWORD size, open_mode = OPEN_ALWAYS;
1098 struct cryptcat *cc;
1099 BOOL valid;
1100
1101 TRACE("filename %s, flags %#lx, provider %#Ix, version %#lx, type %#lx\n",
1102 debugstr_w(filename), flags, hProv, dwPublicVersion, dwEncodingType);
1103
1104 if (!filename)
1105 {
1107 return INVALID_HANDLE_VALUE;
1108 }
1109
1110 if (!dwEncodingType) dwEncodingType = X509_ASN_ENCODING | PKCS_7_ASN_ENCODING;
1111
1113 open_mode = OPEN_EXISTING;
1115 open_mode = CREATE_ALWAYS;
1116
1119
1121 if (!(buffer = malloc(size)))
1122 {
1125 return INVALID_HANDLE_VALUE;
1126 }
1127 if (!(hmsg = CryptMsgOpenToDecode(dwEncodingType, 0, 0, hProv, NULL, NULL)))
1128 {
1130 free(buffer);
1131 return INVALID_HANDLE_VALUE;
1132 }
1133 if (!size) valid = FALSE;
1134 else if (!ReadFile(file, buffer, size, &size, NULL))
1135 {
1137 free(buffer);
1138 CryptMsgClose(hmsg);
1139 return INVALID_HANDLE_VALUE;
1140 }
1141 else valid = CryptMsgUpdate(hmsg, buffer, size, TRUE);
1142 free(buffer);
1144
1145 size = sizeof(DWORD);
1146 if (!(cc = calloc(1, sizeof(*cc))))
1147 {
1148 CryptMsgClose(hmsg);
1150 return INVALID_HANDLE_VALUE;
1151 }
1152
1153 cc->msg = hmsg;
1154 cc->encoding = dwEncodingType;
1155 if (!valid)
1156 {
1157 cc->magic = CRYPTCAT_MAGIC;
1159 return cc;
1160 }
1161 else if (CryptMsgGetParam(hmsg, CMSG_ATTR_CERT_COUNT_PARAM, 0, &cc->attr_count, &size))
1162 {
1163 DWORD i, sum = 0;
1164 BYTE *p;
1165
1166 for (i = 0; i < cc->attr_count; i++)
1167 {
1169 {
1170 CryptMsgClose(hmsg);
1171 free(cc);
1172 return INVALID_HANDLE_VALUE;
1173 }
1174 sum += size;
1175 }
1176 if (!(cc->attr = malloc(sizeof(*cc->attr) * cc->attr_count + sum)))
1177 {
1178 CryptMsgClose(hmsg);
1179 free(cc);
1181 return INVALID_HANDLE_VALUE;
1182 }
1183 p = (BYTE *)(cc->attr + cc->attr_count);
1184 for (i = 0; i < cc->attr_count; i++)
1185 {
1187 {
1188 CryptMsgClose(hmsg);
1189 free(cc->attr);
1190 free(cc);
1191 return INVALID_HANDLE_VALUE;
1192 }
1194 {
1195 CryptMsgClose(hmsg);
1196 free(cc->attr);
1197 free(cc);
1198 return INVALID_HANDLE_VALUE;
1199 }
1200 p += size;
1201 }
1202 cc->inner = decode_inner_content(hmsg, dwEncodingType, &cc->inner_len);
1203 if (!cc->inner || !CryptSIPRetrieveSubjectGuid(filename, NULL, &cc->subject))
1204 {
1205 CryptMsgClose(hmsg);
1206 free(cc->attr);
1207 free(cc->inner);
1208 free(cc);
1209 return INVALID_HANDLE_VALUE;
1210 }
1211 cc->magic = CRYPTCAT_MAGIC;
1213 return cc;
1214 }
1215 free(cc);
1216 return INVALID_HANDLE_VALUE;
1217}
1218
1219/***********************************************************************
1220 * CryptSIPCreateIndirectData (WINTRUST.@)
1221 */
1223 SIP_INDIRECT_DATA* pIndirectData)
1224{
1225 FIXME("(%p %p %p) stub\n", pSubjectInfo, pcbIndirectData, pIndirectData);
1226
1227 return FALSE;
1228}
1229
1230
1231/***********************************************************************
1232 * CryptCATCDFClose (WINTRUST.@)
1233 */
1235{
1236 FIXME("(%p) stub\n", pCDF);
1237
1238 return FALSE;
1239}
1240
1241/***********************************************************************
1242 * CryptCATCDFEnumCatAttributes (WINTRUST.@)
1243 */
1245 CRYPTCATATTRIBUTE *pPrevAttr,
1246 PFN_CDF_PARSE_ERROR_CALLBACK pfnParseError)
1247{
1248 FIXME("(%p %p %p) stub\n", pCDF, pPrevAttr, pfnParseError);
1249
1250 return NULL;
1251}
1252
1253/***********************************************************************
1254 * CryptCATCDFEnumMembersByCDFTagEx (WINTRUST.@)
1255 */
1257 PFN_CDF_PARSE_ERROR_CALLBACK pfnParseError,
1258 CRYPTCATMEMBER **ppMember, BOOL fContinueOnError,
1260{
1261 FIXME("(%p %s %p %p %d %p) stub\n", pCDF, debugstr_w(pwszPrevCDFTag), pfnParseError,
1262 ppMember, fContinueOnError, pvReserved);
1263
1264 return NULL;
1265}
1266
1267/***********************************************************************
1268 * CryptCATCDFOpen (WINTRUST.@)
1269 */
1271 PFN_CDF_PARSE_ERROR_CALLBACK pfnParseError)
1272{
1273 FIXME("(%s %p) stub\n", debugstr_w(pwszFilePath), pfnParseError);
1274
1275 return NULL;
1276}
1277
1279 DWORD *pdwEncodingType, DWORD dwIndex, DWORD *pcbSignedDataMsg,
1280 BYTE *pbSignedDataMsg)
1281{
1282 BOOL ret;
1283 WIN_CERTIFICATE *pCert = NULL;
1284 HANDLE file;
1285
1286 TRACE("(%p %p %ld %p %p)\n", pSubjectInfo, pdwEncodingType, dwIndex,
1287 pcbSignedDataMsg, pbSignedDataMsg);
1288
1289 if(pSubjectInfo->hFile && pSubjectInfo->hFile!=INVALID_HANDLE_VALUE)
1290 file = pSubjectInfo->hFile;
1291 else
1292 {
1293 file = CreateFileW(pSubjectInfo->pwsFileName, GENERIC_READ,
1296 return FALSE;
1297 }
1298
1299 if (!pbSignedDataMsg)
1300 {
1302
1303 /* app hasn't passed buffer, just get the length */
1304 ret = ImageGetCertificateHeader(file, dwIndex, &cert);
1305 if (ret)
1306 {
1307 switch (cert.wCertificateType)
1308 {
1309 case WIN_CERT_TYPE_X509:
1311 *pcbSignedDataMsg = cert.dwLength;
1312 break;
1313 default:
1314 WARN("unknown certificate type %d\n", cert.wCertificateType);
1315 ret = FALSE;
1316 }
1317 }
1318 }
1319 else
1320 {
1321 DWORD len = 0;
1322
1323 ret = ImageGetCertificateData(file, dwIndex, NULL, &len);
1325 goto error;
1326 pCert = malloc(len);
1327 if (!pCert)
1328 {
1329 ret = FALSE;
1330 goto error;
1331 }
1332 ret = ImageGetCertificateData(file, dwIndex, pCert, &len);
1333 if (!ret)
1334 goto error;
1335 pCert->dwLength -= FIELD_OFFSET(WIN_CERTIFICATE, bCertificate);
1336 if (*pcbSignedDataMsg < pCert->dwLength)
1337 {
1338 *pcbSignedDataMsg = pCert->dwLength;
1340 ret = FALSE;
1341 }
1342 else
1343 {
1344 memcpy(pbSignedDataMsg, pCert->bCertificate, pCert->dwLength);
1345 *pcbSignedDataMsg = pCert->dwLength;
1346 switch (pCert->wCertificateType)
1347 {
1348 case WIN_CERT_TYPE_X509:
1349 *pdwEncodingType = X509_ASN_ENCODING;
1350 break;
1352 *pdwEncodingType = X509_ASN_ENCODING | PKCS_7_ASN_ENCODING;
1353 break;
1354 default:
1355 WARN("don't know what to do for encoding type %d\n",
1356 pCert->wCertificateType);
1357 *pdwEncodingType = 0;
1358 ret = FALSE;
1359 }
1360 }
1361 }
1362error:
1363 if(pSubjectInfo->hFile != file)
1365 free(pCert);
1366 return ret;
1367}
1368
1369static BOOL WINTRUST_PutSignedMsgToPEFile(SIP_SUBJECTINFO* pSubjectInfo, DWORD pdwEncodingType,
1370 DWORD* pdwIndex, DWORD cbSignedDataMsg, BYTE* pbSignedDataMsg)
1371{
1373 HANDLE file;
1374 DWORD size;
1375 BOOL ret;
1376
1377 if(pSubjectInfo->hFile && pSubjectInfo->hFile!=INVALID_HANDLE_VALUE)
1378 file = pSubjectInfo->hFile;
1379 else
1380 {
1384 return FALSE;
1385 }
1386
1387 /* int aligned WIN_CERTIFICATE structure with cbSignedDataMsg+1 bytes of data */
1388 size = FIELD_OFFSET(WIN_CERTIFICATE, bCertificate[cbSignedDataMsg+4]) & (~3);
1389 cert = calloc(1, size);
1390 if(!cert)
1391 return FALSE;
1392
1393 cert->dwLength = size;
1394 cert->wRevision = WIN_CERT_REVISION_2_0;
1395 cert->wCertificateType = WIN_CERT_TYPE_PKCS_SIGNED_DATA;
1396 memcpy(cert->bCertificate, pbSignedDataMsg, cbSignedDataMsg);
1397 ret = ImageAddCertificate(file, cert, pdwIndex);
1398
1399 free(cert);
1400 if(file != pSubjectInfo->hFile)
1402 return ret;
1403}
1404
1405/* structure offsets */
1406#define cfhead_Signature (0x00)
1407#define cfhead_CabinetSize (0x08)
1408#define cfhead_MinorVersion (0x18)
1409#define cfhead_MajorVersion (0x19)
1410#define cfhead_Flags (0x1E)
1411#define cfhead_SIZEOF (0x24)
1412#define cfheadext_HeaderReserved (0x00)
1413#define cfheadext_SIZEOF (0x04)
1414#define cfsigninfo_CertOffset (0x04)
1415#define cfsigninfo_CertSize (0x08)
1416#define cfsigninfo_SIZEOF (0x0C)
1417
1418/* flags */
1419#define cfheadRESERVE_PRESENT (0x0004)
1420
1421/* endian-neutral reading of little-endian data */
1422#define EndGetI32(a) ((((a)[3])<<24)|(((a)[2])<<16)|(((a)[1])<<8)|((a)[0]))
1423#define EndGetI16(a) ((((a)[1])<<8)|((a)[0]))
1424
1425/* For documentation purposes only: this is the structure in the reserved
1426 * area of a signed cabinet file. The cert offset indicates where in the
1427 * cabinet file the signature resides, and the count indicates its size.
1428 */
1429typedef struct _CAB_SIGNINFO
1430{
1431 WORD unk0; /* always 0? */
1432 WORD unk1; /* always 0x0010? */
1436
1438 DWORD *pdwEncodingType, DWORD dwIndex, DWORD *pcbSignedDataMsg,
1439 BYTE *pbSignedDataMsg)
1440{
1441 int header_resv;
1442 LONG base_offset, cabsize;
1443 USHORT flags;
1444 BYTE buf[64];
1445 DWORD cert_offset, cert_size, dwRead;
1446
1447 TRACE("(%p %p %ld %p %p)\n", pSubjectInfo, pdwEncodingType, dwIndex,
1448 pcbSignedDataMsg, pbSignedDataMsg);
1449
1450 /* get basic offset & size info */
1451 base_offset = SetFilePointer(pSubjectInfo->hFile, 0L, NULL, SEEK_CUR);
1452
1453 if (SetFilePointer(pSubjectInfo->hFile, 0, NULL, SEEK_END) == INVALID_SET_FILE_POINTER)
1454 {
1455 TRACE("seek error\n");
1456 return FALSE;
1457 }
1458
1459 cabsize = SetFilePointer(pSubjectInfo->hFile, 0L, NULL, SEEK_CUR);
1460 if ((cabsize == -1) || (base_offset == -1) ||
1462 {
1463 TRACE("seek error\n");
1464 return FALSE;
1465 }
1466
1467 /* read in the CFHEADER */
1468 if (!ReadFile(pSubjectInfo->hFile, buf, cfhead_SIZEOF, &dwRead, NULL) ||
1469 dwRead != cfhead_SIZEOF)
1470 {
1471 TRACE("reading header failed\n");
1472 return FALSE;
1473 }
1474
1475 /* check basic MSCF signature */
1476 if (EndGetI32(buf+cfhead_Signature) != 0x4643534d)
1477 {
1478 WARN("cabinet signature not present\n");
1479 return FALSE;
1480 }
1481
1482 /* Ignore the number of folders and files and the set and cabinet IDs */
1483
1484 /* check the header revision */
1485 if ((buf[cfhead_MajorVersion] > 1) ||
1487 {
1488 WARN("cabinet format version > 1.3\n");
1489 return FALSE;
1490 }
1491
1492 /* pull the flags out */
1494
1496 {
1497 TRACE("no header present, not signed\n");
1498 return FALSE;
1499 }
1500
1501 if (!ReadFile(pSubjectInfo->hFile, buf, cfheadext_SIZEOF, &dwRead, NULL) ||
1502 dwRead != cfheadext_SIZEOF)
1503 {
1504 ERR("bunk reserve-sizes?\n");
1505 return FALSE;
1506 }
1507
1508 header_resv = EndGetI16(buf+cfheadext_HeaderReserved);
1509 if (!header_resv)
1510 {
1511 TRACE("no header_resv, not signed\n");
1512 return FALSE;
1513 }
1514 else if (header_resv < cfsigninfo_SIZEOF)
1515 {
1516 TRACE("header_resv too small, not signed\n");
1517 return FALSE;
1518 }
1519
1520 if (header_resv > 60000)
1521 {
1522 WARN("WARNING; header reserved space > 60000\n");
1523 }
1524
1525 if (!ReadFile(pSubjectInfo->hFile, buf, cfsigninfo_SIZEOF, &dwRead, NULL) ||
1526 dwRead != cfsigninfo_SIZEOF)
1527 {
1528 ERR("couldn't read reserve\n");
1529 return FALSE;
1530 }
1531
1532 cert_offset = EndGetI32(buf+cfsigninfo_CertOffset);
1533 TRACE("cert_offset: %ld\n", cert_offset);
1534 cert_size = EndGetI32(buf+cfsigninfo_CertSize);
1535 TRACE("cert_size: %ld\n", cert_size);
1536
1537 /* The redundant checks are to avoid wraparound */
1538 if (cert_offset > cabsize || cert_size > cabsize ||
1539 cert_offset + cert_size > cabsize)
1540 {
1541 WARN("offset beyond file, not attempting to read\n");
1542 return FALSE;
1543 }
1544
1545 SetFilePointer(pSubjectInfo->hFile, base_offset, NULL, SEEK_SET);
1546 if (!pbSignedDataMsg)
1547 {
1548 *pcbSignedDataMsg = cert_size;
1549 return TRUE;
1550 }
1551 if (*pcbSignedDataMsg < cert_size)
1552 {
1553 *pcbSignedDataMsg = cert_size;
1555 return FALSE;
1556 }
1557 if (SetFilePointer(pSubjectInfo->hFile, cert_offset, NULL, SEEK_SET) == INVALID_SET_FILE_POINTER)
1558 {
1559 ERR("couldn't seek to cert location\n");
1560 return FALSE;
1561 }
1562 if (!ReadFile(pSubjectInfo->hFile, pbSignedDataMsg, cert_size, &dwRead,
1563 NULL) || dwRead != cert_size)
1564 {
1565 ERR("couldn't read cert\n");
1566 SetFilePointer(pSubjectInfo->hFile, base_offset, NULL, SEEK_SET);
1567 return FALSE;
1568 }
1569 /* The encoding of the files I've seen appears to be in ASN.1
1570 * format, and there isn't a field indicating the type, so assume it
1571 * always is.
1572 */
1573 *pdwEncodingType = X509_ASN_ENCODING | PKCS_7_ASN_ENCODING;
1574 /* Restore base offset */
1575 SetFilePointer(pSubjectInfo->hFile, base_offset, NULL, SEEK_SET);
1576 return TRUE;
1577}
1578
1580 DWORD *pdwEncodingType, DWORD dwIndex, DWORD *pcbSignedDataMsg,
1581 BYTE *pbSignedDataMsg)
1582{
1583 BOOL ret;
1584
1585 TRACE("(%p %p %ld %p %p)\n", pSubjectInfo, pdwEncodingType, dwIndex,
1586 pcbSignedDataMsg, pbSignedDataMsg);
1587
1588 if (!pbSignedDataMsg)
1589 {
1590 *pcbSignedDataMsg = GetFileSize(pSubjectInfo->hFile, NULL);
1591 ret = TRUE;
1592 }
1593 else
1594 {
1595 DWORD len = GetFileSize(pSubjectInfo->hFile, NULL);
1596
1597 if (*pcbSignedDataMsg < len)
1598 {
1599 *pcbSignedDataMsg = len;
1601 ret = FALSE;
1602 }
1603 else
1604 {
1605 ret = ReadFile(pSubjectInfo->hFile, pbSignedDataMsg, len,
1606 pcbSignedDataMsg, NULL);
1607 if (ret)
1608 *pdwEncodingType = X509_ASN_ENCODING | PKCS_7_ASN_ENCODING;
1609 }
1610 }
1611 return ret;
1612}
1613
1614/* GUIDs used by CryptSIPGetSignedDataMsg and CryptSIPPutSignedDataMsg */
1615static const GUID unknown = { 0xC689AAB8, 0x8E78, 0x11D0, { 0x8C,0x47,
1616 0x00,0xC0,0x4F,0xC2,0x95,0xEE } };
1617static const GUID cabGUID = { 0xC689AABA, 0x8E78, 0x11D0, { 0x8C,0x47,
1618 0x00,0xC0,0x4F,0xC2,0x95,0xEE } };
1619static const GUID catGUID = { 0xDE351A43, 0x8E59, 0x11D0, { 0x8C,0x47,
1620 0x00,0xC0,0x4F,0xC2,0x95,0xEE }};
1621
1622/***********************************************************************
1623 * CryptSIPGetSignedDataMsg (WINTRUST.@)
1624 */
1626 DWORD dwIndex, DWORD* pcbSignedDataMsg, BYTE* pbSignedDataMsg)
1627{
1628 BOOL ret;
1629
1630 TRACE("(%p %p %ld %p %p)\n", pSubjectInfo, pdwEncodingType, dwIndex,
1631 pcbSignedDataMsg, pbSignedDataMsg);
1632
1633 if(!pSubjectInfo)
1634 {
1636 return FALSE;
1637 }
1638
1639 if (!memcmp(pSubjectInfo->pgSubjectType, &unknown, sizeof(unknown)))
1640 ret = WINTRUST_GetSignedMsgFromPEFile(pSubjectInfo, pdwEncodingType,
1641 dwIndex, pcbSignedDataMsg, pbSignedDataMsg);
1642 else if (!memcmp(pSubjectInfo->pgSubjectType, &cabGUID, sizeof(cabGUID)))
1643 ret = WINTRUST_GetSignedMsgFromCabFile(pSubjectInfo, pdwEncodingType,
1644 dwIndex, pcbSignedDataMsg, pbSignedDataMsg);
1645 else if (!memcmp(pSubjectInfo->pgSubjectType, &catGUID, sizeof(catGUID)))
1646 ret = WINTRUST_GetSignedMsgFromCatFile(pSubjectInfo, pdwEncodingType,
1647 dwIndex, pcbSignedDataMsg, pbSignedDataMsg);
1648 else
1649 {
1650 FIXME("unimplemented for subject type %s\n",
1651 debugstr_guid(pSubjectInfo->pgSubjectType));
1652 ret = FALSE;
1653 }
1654
1655 TRACE("returning %d\n", ret);
1656 return ret;
1657}
1658
1659/***********************************************************************
1660 * CryptSIPPutSignedDataMsg (WINTRUST.@)
1661 */
1663 DWORD* pdwIndex, DWORD cbSignedDataMsg, BYTE* pbSignedDataMsg)
1664{
1665 TRACE("(%p %ld %p %ld %p)\n", pSubjectInfo, pdwEncodingType, pdwIndex,
1666 cbSignedDataMsg, pbSignedDataMsg);
1667
1668 if(!pSubjectInfo) {
1670 return FALSE;
1671 }
1672
1673 if(!memcmp(pSubjectInfo->pgSubjectType, &unknown, sizeof(unknown)))
1674 return WINTRUST_PutSignedMsgToPEFile(pSubjectInfo, pdwEncodingType,
1675 pdwIndex, cbSignedDataMsg, pbSignedDataMsg);
1676 else
1677 FIXME("unimplemented for subject type %s\n",
1678 debugstr_guid(pSubjectInfo->pgSubjectType));
1679
1680 return FALSE;
1681}
1682
1683/***********************************************************************
1684 * CryptSIPRemoveSignedDataMsg (WINTRUST.@)
1685 */
1687 DWORD dwIndex)
1688{
1689 FIXME("(%p %ld) stub\n", pSubjectInfo, dwIndex);
1690
1691 return FALSE;
1692}
1693
1694/***********************************************************************
1695 * CryptSIPVerifyIndirectData (WINTRUST.@)
1696 */
1698 SIP_INDIRECT_DATA* pIndirectData)
1699{
1700 FIXME("(%p %p) stub\n", pSubjectInfo, pIndirectData);
1701
1702 return FALSE;
1703}
WINBASEAPI _Check_return_ _Out_ AppPolicyProcessTerminationMethod * policy
Definition: appmodel.h:73
#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
#define WARN(fmt,...)
Definition: precomp.h:61
#define ERR(fmt,...)
Definition: precomp.h:57
#define BCRYPT_SHA256_ALGORITHM
Definition: bcrypt.h:75
#define BCRYPT_SHA1_ALGORITHM
Definition: bcrypt.h:74
#define SEEK_END
Definition: cabinet.c:29
BOOL WINAPI CryptDecodeObject(DWORD dwCertEncodingType, LPCSTR lpszStructType, const BYTE *pbEncoded, DWORD cbEncoded, DWORD dwFlags, void *pvStructInfo, DWORD *pcbStructInfo)
Definition: decode.c:6278
PIMAGE_NT_HEADERS WINAPI ImageNtHeader(_In_ PVOID)
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10
#define realloc
Definition: debug_ros.c:6
#define free
Definition: debug_ros.c:5
#define malloc
Definition: debug_ros.c:4
PIMAGE_NT_HEADERS nt
Definition: delayimp.cpp:445
#define ERROR_OUTOFMEMORY
Definition: deptool.c:13
#define ERROR_SUCCESS
Definition: deptool.c:10
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
BOOL WINAPI CryptCreateHash(HCRYPTPROV hProv, ALG_ID Algid, HCRYPTKEY hKey, DWORD dwFlags, HCRYPTHASH *phHash)
Definition: crypt.c:753
BOOL WINAPI CryptGetHashParam(HCRYPTHASH hHash, DWORD dwParam, BYTE *pbData, DWORD *pdwDataLen, DWORD dwFlags)
Definition: crypt.c:1675
BOOL WINAPI CryptDestroyHash(HCRYPTHASH hHash)
Definition: crypt.c:929
BOOL WINAPI CryptReleaseContext(HCRYPTPROV hProv, DWORD dwFlags)
Definition: crypt.c:661
BOOL WINAPI CryptHashData(HCRYPTHASH hHash, const BYTE *pbData, DWORD dwDataLen, DWORD dwFlags)
Definition: crypt.c:1836
BOOL WINAPI CryptAcquireContextW(HCRYPTPROV *phProv, LPCWSTR pszContainer, LPCWSTR pszProvider, DWORD dwProvType, DWORD dwFlags)
Definition: crypt.c:358
HCRYPTMSG WINAPI CryptMsgOpenToDecode(DWORD dwMsgEncodingType, DWORD dwFlags, DWORD dwMsgType, HCRYPTPROV_LEGACY hCryptProv, PCERT_INFO pRecipientInfo, PCMSG_STREAM_INFO pStreamInfo)
Definition: msg.c:3552
BOOL WINAPI CryptMsgGetParam(HCRYPTMSG hCryptMsg, DWORD dwParamType, DWORD dwIndex, void *pvData, DWORD *pcbData)
Definition: msg.c:3626
BOOL WINAPI CryptMsgUpdate(HCRYPTMSG hCryptMsg, const BYTE *pbData, DWORD cbData, BOOL fFinal)
Definition: msg.c:3616
BOOL WINAPI CryptMsgClose(HCRYPTMSG hCryptMsg)
Definition: msg.c:3597
BOOL WINAPI CryptSIPRetrieveSubjectGuid(LPCWSTR FileName, HANDLE hFileIn, GUID *pgSubject)
Definition: sip.c:310
static const WCHAR ca[]
Definition: main.c:457
#define CloseHandle
Definition: compat.h:739
#define wcschr
Definition: compat.h:17
#define ERROR_CALL_NOT_IMPLEMENTED
Definition: compat.h:102
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
#define PAGE_READONLY
Definition: compat.h:138
#define INVALID_SET_FILE_POINTER
Definition: compat.h:732
#define UnmapViewOfFile
Definition: compat.h:746
#define OPEN_EXISTING
Definition: compat.h:775
#define ReadFile(a, b, c, d, e)
Definition: compat.h:742
#define SetFilePointer
Definition: compat.h:743
#define SetLastError(x)
Definition: compat.h:752
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
#define CreateFileMappingW(a, b, c, d, e, f)
Definition: compat.h:744
#define GENERIC_READ
Definition: compat.h:135
#define MAX_PATH
Definition: compat.h:34
#define CreateFileW
Definition: compat.h:741
#define FILE_MAP_READ
Definition: compat.h:776
#define lstrcpyW
Definition: compat.h:749
#define MapViewOfFile
Definition: compat.h:745
#define FILE_SHARE_READ
Definition: compat.h:136
#define lstrlenW
Definition: compat.h:750
static const WCHAR version[]
Definition: asmname.c:66
static DWORD DWORD * dwLength
Definition: fusion.c:86
BOOL WINAPI ImageGetCertificateData(HANDLE handle, DWORD Index, LPWIN_CERTIFICATE Certificate, PDWORD RequiredLength)
Definition: integrity.c:553
BOOL WINAPI ImageAddCertificate(HANDLE FileHandle, LPWIN_CERTIFICATE Certificate, PDWORD Index)
Definition: integrity.c:380
BOOL WINAPI ImageGetCertificateHeader(HANDLE handle, DWORD index, LPWIN_CERTIFICATE pCert)
Definition: integrity.c:604
BOOL WINAPI CopyFileW(IN LPCWSTR lpExistingFileName, IN LPCWSTR lpNewFileName, IN BOOL bFailIfExists)
Definition: copy.c:365
BOOL WINAPI DeleteFileW(IN LPCWSTR lpFileName)
Definition: delete.c:39
BOOL WINAPI CreateDirectoryW(IN LPCWSTR lpPathName, IN LPSECURITY_ATTRIBUTES lpSecurityAttributes)
Definition: dir.c:58
BOOL WINAPI SetFileAttributesW(LPCWSTR lpFileName, DWORD dwFileAttributes)
Definition: fileinfo.c:778
DWORD WINAPI GetFileSize(HANDLE hFile, LPDWORD lpFileSizeHigh)
Definition: fileinfo.c:331
HANDLE WINAPI FindFirstFileW(IN LPCWSTR lpFileName, OUT LPWIN32_FIND_DATAW lpFindFileData)
Definition: find.c:320
BOOL WINAPI FindClose(HANDLE hFindFile)
Definition: find.c:502
BOOL WINAPI FindNextFileW(IN HANDLE hFindFile, OUT LPWIN32_FIND_DATAW lpFindFileData)
Definition: find.c:382
UINT WINAPI GetSystemDirectoryW(OUT LPWSTR lpBuffer, IN UINT uSize)
Definition: path.c:2232
GUID guid
Definition: version.c:147
static const WCHAR slashW[]
Definition: devenum.c:59
_ACRTIMP int __cdecl wcscmp(const wchar_t *, const wchar_t *)
Definition: wcs.c:1972
_ACRTIMP int __cdecl memcmp(const void *, const void *, size_t)
Definition: string.c:2802
#define SEEK_CUR
Definition: stdio.h:44
_ACRTIMP int __cdecl strcmp(const char *, const char *)
Definition: string.c:3319
#define swprintf
Definition: precomp.h:40
CRYPTCATATTRIBUTE *WINAPI CryptCATGetAttrInfo(HANDLE hCatalog, CRYPTCATMEMBER *member, LPWSTR tag)
Definition: crypt.c:754
CRYPTCATATTRIBUTE *WINAPI CryptCATPutCatAttrInfo(HANDLE catalog, WCHAR *name, DWORD flags, DWORD size, BYTE *data)
Definition: crypt.c:1055
BOOL WINAPI CryptSIPPutSignedDataMsg(SIP_SUBJECTINFO *pSubjectInfo, DWORD pdwEncodingType, DWORD *pdwIndex, DWORD cbSignedDataMsg, BYTE *pbSignedDataMsg)
Definition: crypt.c:1662
BOOL WINAPI CryptCATAdminReleaseContext(HCATADMIN hCatAdmin, DWORD dwFlags)
Definition: crypt.c:632
CRYPTCATCDF *WINAPI CryptCATCDFOpen(LPWSTR pwszFilePath, PFN_CDF_PARSE_ERROR_CALLBACK pfnParseError)
Definition: crypt.c:1270
static HCATINFO create_catinfo(const WCHAR *filename)
Definition: crypt.c:72
CRYPTCATATTRIBUTE *WINAPI CryptCATCDFEnumCatAttributes(CRYPTCATCDF *pCDF, CRYPTCATATTRIBUTE *pPrevAttr, PFN_CDF_PARSE_ERROR_CALLBACK pfnParseError)
Definition: crypt.c:1244
struct _CAB_SIGNINFO * PCAB_SIGNINFO
BOOL WINAPI CryptCATClose(HANDLE hCatalog)
Definition: crypt.c:730
CRYPTCATATTRIBUTE *WINAPI CryptCATGetCatAttrInfo(HANDLE hCatalog, LPWSTR tag)
Definition: crypt.c:772
#define cfheadext_HeaderReserved
Definition: crypt.c:1412
CRYPTCATMEMBER *WINAPI CryptCATEnumerateMember(HANDLE hCatalog, CRYPTCATMEMBER *prev)
Definition: crypt.c:841
BOOL WINAPI CryptCATCatalogInfoFromContext(HCATINFO hcatinfo, CATALOG_INFO *info, DWORD flags)
Definition: crypt.c:1023
#define cfheadRESERVE_PRESENT
Definition: crypt.c:1419
#define cfhead_Signature
Definition: crypt.c:1406
#define cfsigninfo_CertSize
Definition: crypt.c:1415
BOOL WINAPI CryptCATAdminCalcHashFromFileHandle(HANDLE hFile, DWORD *pcbHash, BYTE *pbHash, DWORD dwFlags)
Definition: crypt.c:424
static CTL_INFO * decode_inner_content(HANDLE hmsg, DWORD encoding, DWORD *len)
Definition: crypt.c:984
static const GUID unknown
Definition: crypt.c:1615
#define cfhead_MajorVersion
Definition: crypt.c:1409
#define cfsigninfo_CertOffset
Definition: crypt.c:1414
CRYPTCATATTRIBUTE *WINAPI CryptCATPutAttrInfo(HANDLE catalog, CRYPTCATMEMBER *member, WCHAR *name, DWORD flags, DWORD size, BYTE *data)
Definition: crypt.c:1042
BOOL WINAPI CryptCATCDFClose(CRYPTCATCDF *pCDF)
Definition: crypt.c:1234
BOOL WINAPI CryptCATAdminAcquireContext2(HCATADMIN *catAdmin, const GUID *sys, const WCHAR *algorithm, const CERT_STRONG_SIGN_PARA *policy, DWORD dwFlags)
Definition: crypt.c:124
static BOOL WINTRUST_GetSignedMsgFromCabFile(SIP_SUBJECTINFO *pSubjectInfo, DWORD *pdwEncodingType, DWORD dwIndex, DWORD *pcbSignedDataMsg, BYTE *pbSignedDataMsg)
Definition: crypt.c:1437
#define EndGetI16(a)
Definition: crypt.c:1423
LPWSTR WINAPI CryptCATCDFEnumMembersByCDFTagEx(CRYPTCATCDF *pCDF, LPWSTR pwszPrevCDFTag, PFN_CDF_PARSE_ERROR_CALLBACK pfnParseError, CRYPTCATMEMBER **ppMember, BOOL fContinueOnError, LPVOID pvReserved)
Definition: crypt.c:1256
BOOL WINAPI CryptCATPersistStore(HANDLE catalog)
Definition: crypt.c:1081
BOOL WINAPI CryptSIPRemoveSignedDataMsg(SIP_SUBJECTINFO *pSubjectInfo, DWORD dwIndex)
Definition: crypt.c:1686
BOOL WINAPI CryptCATAdminCalcHashFromFileHandle2(HCATADMIN catAdmin, HANDLE hFile, DWORD *pcbHash, BYTE *pbHash, DWORD dwFlags)
Definition: crypt.c:448
#define cfhead_SIZEOF
Definition: crypt.c:1411
#define cfhead_MinorVersion
Definition: crypt.c:1408
HCATINFO WINAPI CryptCATAdminAddCatalog(HCATADMIN catAdmin, PWSTR catalogFile, PWSTR selectBaseName, DWORD flags)
Definition: crypt.c:207
BOOL WINAPI CryptCATAdminReleaseCatalogContext(HCATADMIN hCatAdmin, HCATINFO hCatInfo, DWORD dwFlags)
Definition: crypt.c:598
#define EndGetI32(a)
Definition: crypt.c:1422
BOOL WINAPI CryptCATAdminRemoveCatalog(HCATADMIN hCatAdmin, LPCWSTR pwszCatalogFile, DWORD dwFlags)
Definition: crypt.c:665
static BOOL pe_image_hash(HANDLE file, HCRYPTHASH hash)
Definition: crypt.c:261
#define CATADMIN_MAGIC
Definition: crypt.c:40
CRYPTCATMEMBER *WINAPI CryptCATPutMemberInfo(HANDLE catalog, WCHAR *filename, WCHAR *member, GUID *subject, DWORD version, DWORD size, BYTE *data)
Definition: crypt.c:1068
#define cfheadext_SIZEOF
Definition: crypt.c:1413
BOOL WINAPI CryptSIPGetSignedDataMsg(SIP_SUBJECTINFO *pSubjectInfo, DWORD *pdwEncodingType, DWORD dwIndex, DWORD *pcbSignedDataMsg, BYTE *pbSignedDataMsg)
Definition: crypt.c:1625
static BOOL catadmin_calc_hash_from_filehandle(HCATADMIN catAdmin, HANDLE hFile, DWORD *pcbHash, BYTE *pbHash, DWORD dwFlags)
Definition: crypt.c:335
BOOL WINAPI CryptCATAdminResolveCatalogPath(HCATADMIN hcatadmin, WCHAR *catalog_file, CATALOG_INFO *info, DWORD flags)
Definition: crypt.c:707
CRYPTCATATTRIBUTE *WINAPI CryptCATEnumerateCatAttr(HANDLE hCatalog, CRYPTCATATTRIBUTE *prev)
Definition: crypt.c:823
BOOL WINAPI CryptSIPCreateIndirectData(SIP_SUBJECTINFO *pSubjectInfo, DWORD *pcbIndirectData, SIP_INDIRECT_DATA *pIndirectData)
Definition: crypt.c:1222
BOOL WINAPI CryptCATAdminAcquireContext(HCATADMIN *catAdmin, const GUID *sys, DWORD dwFlags)
Definition: crypt.c:101
static BOOL WINTRUST_GetSignedMsgFromPEFile(SIP_SUBJECTINFO *pSubjectInfo, DWORD *pdwEncodingType, DWORD dwIndex, DWORD *pcbSignedDataMsg, BYTE *pbSignedDataMsg)
Definition: crypt.c:1278
#define cfsigninfo_SIZEOF
Definition: crypt.c:1416
BOOL WINAPI CryptSIPVerifyIndirectData(SIP_SUBJECTINFO *pSubjectInfo, SIP_INDIRECT_DATA *pIndirectData)
Definition: crypt.c:1697
HCATINFO WINAPI CryptCATAdminEnumCatalogFromHash(HCATADMIN hCatAdmin, BYTE *pbHash, DWORD cbHash, DWORD dwFlags, HCATINFO *phPrevCatInfo)
Definition: crypt.c:466
CRYPTCATATTRIBUTE *WINAPI CryptCATEnumerateAttr(HANDLE hCatalog, CRYPTCATMEMBER *member, CRYPTCATATTRIBUTE *prev)
Definition: crypt.c:805
#define cfhead_Flags
Definition: crypt.c:1410
CRYPTCATMEMBER *WINAPI CryptCATGetMemberInfo(HANDLE hCatalog, LPWSTR tag)
Definition: crypt.c:787
HANDLE WINAPI CryptCATOpen(WCHAR *filename, DWORD flags, HCRYPTPROV hProv, DWORD dwPublicVersion, DWORD dwEncodingType)
Definition: crypt.c:1092
#define CRYPTCAT_MAGIC
Definition: crypt.c:41
static BOOL WINTRUST_PutSignedMsgToPEFile(SIP_SUBJECTINFO *pSubjectInfo, DWORD pdwEncodingType, DWORD *pdwIndex, DWORD cbSignedDataMsg, BYTE *pbSignedDataMsg)
Definition: crypt.c:1369
static const GUID catGUID
Definition: crypt.c:1619
static BOOL WINTRUST_GetSignedMsgFromCatFile(SIP_SUBJECTINFO *pSubjectInfo, DWORD *pdwEncodingType, DWORD dwIndex, DWORD *pcbSignedDataMsg, BYTE *pbSignedDataMsg)
Definition: crypt.c:1579
#define CATINFO_MAGIC
Definition: crypt.c:42
static const GUID cabGUID
Definition: crypt.c:1617
struct _CAB_SIGNINFO CAB_SIGNINFO
return ret
Definition: mutex.c:146
#define L(x)
Definition: resources.c:13
unsigned short WORD
Definition: ntddk_ex.h:93
unsigned int BOOL
Definition: ntddk_ex.h:94
struct _IMAGE_DATA_DIRECTORY IMAGE_DATA_DIRECTORY
unsigned long DWORD
Definition: ntddk_ex.h:95
BOOLEAN valid
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
GLuint buffer
Definition: glext.h:5915
GLsizeiptr size
Definition: glext.h:5919
GLintptr offset
Definition: glext.h:5920
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
GLbitfield flags
Definition: glext.h:7161
GLenum GLenum GLenum GLenum mapping
Definition: glext.h:9031
GLfloat GLfloat p
Definition: glext.h:8902
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
const char * filename
Definition: ioapi.h:137
uint32_t cc
Definition: isohybrid.c:75
uint32_t entry
Definition: isohybrid.c:63
#define SEEK_SET
Definition: jmemansi.c:26
#define debugstr_guid
Definition: kernel32.h:35
#define debugstr_w
Definition: kernel32.h:32
LPWSTR WINAPI lstrcatW(LPWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:274
#define error(str)
Definition: mkdosfs.c:1605
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define CREATE_ALWAYS
Definition: disk.h:72
#define OPEN_ALWAYS
Definition: disk.h:70
static BYTE cert[]
Definition: msg.c:1374
static LPCWSTR LPVOID pvReserved
Definition: asmcache.c:749
static HCRYPTPROV hProv
Definition: rsaenh.c:32
static MONITORINFO mi
Definition: win.c:9400
static CHAR catroot[MAX_PATH]
Definition: crypt.c:33
#define CRYPTCAT_OPEN_CREATENEW
Definition: mscat.h:40
void(WINAPI * PFN_CDF_PARSE_ERROR_CALLBACK)(DWORD, DWORD, WCHAR *)
Definition: mscat.h:115
#define CRYPTCAT_OPEN_EXISTING
Definition: mscat.h:42
_In_ HANDLE hFile
Definition: mswsock.h:90
_In_ LPWSTR _In_ DWORD _In_ DWORD _In_ DWORD dwFlags
Definition: netsh.h:141
#define FILE_SHARE_WRITE
Definition: nt_native.h:681
#define FILE_ATTRIBUTE_SYSTEM
Definition: nt_native.h:704
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define DWORD
Definition: nt_native.h:44
#define GENERIC_WRITE
Definition: nt_native.h:90
#define IMAGE_NT_OPTIONAL_HDR32_MAGIC
Definition: ntimage.h:376
#define IMAGE_NT_OPTIONAL_HDR64_MAGIC
Definition: ntimage.h:377
#define IMAGE_DIRECTORY_ENTRY_SECURITY
Definition: pedump.c:263
long LONG
Definition: pedump.c:60
unsigned short USHORT
Definition: pedump.c:61
static int sum(int x_, int y_)
Definition: ptr2_test.cpp:35
static unsigned int file_size
Definition: regtests2xml.c:47
#define calloc
Definition: rosglue.h:14
#define TRACE(s)
Definition: solgame.cpp:4
HANDLE hFile
Definition: mssip.h:53
LPCWSTR pwsFileName
Definition: mssip.h:54
GUID * pgSubjectType
Definition: mssip.h:52
UINT16 wCertificateType
DWORD cbCertBlock
Definition: crypt.c:1434
DWORD dwCertOffset
Definition: crypt.c:1433
WORD unk1
Definition: crypt.c:1432
WORD unk0
Definition: crypt.c:1431
Definition: wincrypt.h:835
IMAGE_OPTIONAL_HEADER64 OptionalHeader
Definition: ntimage.h:396
IMAGE_OPTIONAL_HEADER32 OptionalHeader
Definition: ntddk_ex.h:184
IMAGE_DATA_DIRECTORY DataDirectory[IMAGE_NUMBEROF_DIRECTORY_ENTRIES]
Definition: ntimage.h:370
IMAGE_DATA_DIRECTORY DataDirectory[IMAGE_NUMBEROF_DIRECTORY_ENTRIES]
Definition: ntddk_ex.h:178
Definition: cookie.c:202
Definition: crypt.c:57
WCHAR path[MAX_PATH]
Definition: crypt.c:59
DWORD magic
Definition: crypt.c:58
DWORD providerType
Definition: crypt.c:63
ALG_ID alg
Definition: crypt.c:61
const WCHAR * providerName
Definition: crypt.c:62
HANDLE find
Definition: crypt.c:60
Definition: crypt.c:67
DWORD magic
Definition: crypt.c:68
WCHAR file[MAX_PATH]
Definition: crypt.c:69
Definition: crypt.c:45
DWORD attr_count
Definition: crypt.c:52
HCRYPTMSG msg
Definition: crypt.c:47
DWORD inner_len
Definition: crypt.c:50
GUID subject
Definition: crypt.c:51
CRYPTCATATTRIBUTE * attr
Definition: crypt.c:53
DWORD encoding
Definition: crypt.c:48
DWORD magic
Definition: crypt.c:46
CTL_INFO * inner
Definition: crypt.c:49
Definition: fci.c:127
Definition: dsound.c:943
Definition: _hash_fun.h:40
Definition: name.c:39
Definition: ecma_167.h:138
Definition: tools.h:99
uint16_t * PWSTR
Definition: typedefs.h:56
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
uint32_t UINT32
Definition: typedefs.h:59
wchar_t tm const _CrtWcstime_Writes_and_advances_ptr_ count wchar_t ** out
Definition: wcsftime.cpp:383
#define SecureZeroMemory
Definition: winbase.h:1465
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define INVALID_FILE_SIZE
Definition: winbase.h:528
#define PROV_RSA_FULL
Definition: wincrypt.h:2243
#define CRYPT_VERIFYCONTEXT
Definition: wincrypt.h:2273
#define CALG_SHA1
Definition: wincrypt.h:2060
#define CMSG_ATTR_CERT_COUNT_PARAM
Definition: wincrypt.h:4116
ULONG_PTR HCRYPTPROV
Definition: wincrypt.h:55
#define PROV_RSA_AES
Definition: wincrypt.h:2260
unsigned int ALG_ID
Definition: wincrypt.h:54
#define CALG_SHA_256
Definition: wincrypt.h:2066
#define X509_ASN_ENCODING
Definition: wincrypt.h:2501
#define CMSG_INNER_CONTENT_TYPE_PARAM
Definition: wincrypt.h:4093
static const WCHAR MS_DEF_PROV_W[]
Definition: wincrypt.h:2119
ULONG_PTR HCRYPTHASH
Definition: wincrypt.h:59
#define PKCS_7_ASN_ENCODING
Definition: wincrypt.h:2503
#define CMSG_ATTR_CERT_PARAM
Definition: wincrypt.h:4117
#define HP_HASHVAL
Definition: wincrypt.h:2387
static const WCHAR MS_ENH_RSA_AES_PROV_W[]
Definition: wincrypt.h:2221
#define CMSG_CONTENT_PARAM
Definition: wincrypt.h:4091
#define WINAPI
Definition: msvc.h:6
NTSYSAPI NTSTATUS WINAPI RtlGUIDFromString(PUNICODE_STRING, GUID *)
#define CRYPT_E_NOT_FOUND
Definition: winerror.h:4421
#define NTE_BAD_ALGID
Definition: winerror.h:4255
#define CRYPT_E_ATTRIBUTES_MISSING
Definition: winerror.h:4413
#define IMAGE_FILE_SECURITY_DIRECTORY
Definition: winnt_old.h:676
#define WIN_CERT_TYPE_X509
Definition: wintrust.h:625
#define WIN_CERT_REVISION_2_0
Definition: wintrust.h:623
#define CAT_MEMBERINFO_OBJID
Definition: wintrust.h:498
#define WIN_CERT_TYPE_PKCS_SIGNED_DATA
Definition: wintrust.h:626
#define SPC_INDIRECT_DATA_OBJID
Definition: wintrust.h:480
static const WCHAR providerName[]
Definition: wnet.c:1544
static const WCHAR providerType[]
Definition: wnet.c:2155
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