2 * WinTrust Cryptography functions
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
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.
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.
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
34 #include "wine/debug.h"
35 #include "wine/unicode.h"
37 WINE_DEFAULT_DEBUG_CHANNEL(wintrust
);
39 #define CATADMIN_MAGIC 0x43415441 /* 'CATA' */
40 #define CATINFO_MAGIC 0x43415449 /* 'CATI' */
55 static HCATINFO
create_catinfo(const WCHAR
*filename
)
59 if (!(ci
= HeapAlloc(GetProcessHeap(), 0, sizeof(*ci
))))
61 SetLastError(ERROR_OUTOFMEMORY
);
62 return INVALID_HANDLE_VALUE
;
64 strcpyW(ci
->file
, filename
);
65 ci
->magic
= CATINFO_MAGIC
;
69 /***********************************************************************
70 * CryptCATAdminAcquireContext (WINTRUST.@)
72 * Get a catalog administrator context handle.
75 * catAdmin [O] Pointer to the context handle.
76 * sys [I] Pointer to a GUID for the needed subsystem.
77 * dwFlags [I] Reserved.
80 * Success: TRUE. catAdmin contains the context handle.
84 BOOL WINAPI
CryptCATAdminAcquireContext(HCATADMIN
*catAdmin
,
85 const GUID
*sys
, DWORD dwFlags
)
87 static const WCHAR catroot
[] =
88 {'\\','c','a','t','r','o','o','t',0};
89 static const WCHAR fmt
[] =
90 {'%','s','\\','{','%','0','8','x','-','%','0','4','x','-','%','0',
91 '4','x','-','%','0','2','x','%','0','2','x','-','%','0','2','x',
92 '%','0','2','x','%','0','2','x','%','0','2','x','%','0','2','x',
93 '%','0','2','x','}',0};
94 static const GUID defsys
=
95 {0x127d0a1d,0x4ef2,0x11d1,{0x86,0x08,0x00,0xc0,0x4f,0xc2,0x95,0xee}};
97 WCHAR catroot_dir
[MAX_PATH
];
100 TRACE("%p %s %x\n", catAdmin
, debugstr_guid(sys
), dwFlags
);
104 SetLastError(ERROR_INVALID_PARAMETER
);
107 if (!(ca
= HeapAlloc(GetProcessHeap(), 0, sizeof(*ca
))))
109 SetLastError(ERROR_OUTOFMEMORY
);
113 GetSystemDirectoryW(catroot_dir
, MAX_PATH
);
114 strcatW(catroot_dir
, catroot
);
116 /* create the directory if it doesn't exist */
117 CreateDirectoryW(catroot_dir
, NULL
);
119 if (!sys
) sys
= &defsys
;
120 sprintfW(ca
->path
, fmt
, catroot_dir
, sys
->Data1
, sys
->Data2
,
121 sys
->Data3
, sys
->Data4
[0], sys
->Data4
[1], sys
->Data4
[2],
122 sys
->Data4
[3], sys
->Data4
[4], sys
->Data4
[5], sys
->Data4
[6],
125 /* create the directory if it doesn't exist */
126 CreateDirectoryW(ca
->path
, NULL
);
128 ca
->magic
= CATADMIN_MAGIC
;
135 /***********************************************************************
136 * CryptCATAdminAddCatalog (WINTRUST.@)
138 HCATINFO WINAPI
CryptCATAdminAddCatalog(HCATADMIN catAdmin
, PWSTR catalogFile
,
139 PWSTR selectBaseName
, DWORD flags
)
141 static const WCHAR slashW
[] = {'\\',0};
142 struct catadmin
*ca
= catAdmin
;
147 TRACE("%p %s %s %d\n", catAdmin
, debugstr_w(catalogFile
),
148 debugstr_w(selectBaseName
), flags
);
152 FIXME("NULL basename not handled\n");
153 SetLastError(ERROR_INVALID_PARAMETER
);
156 if (!ca
|| ca
->magic
!= CATADMIN_MAGIC
|| !catalogFile
|| flags
)
158 SetLastError(ERROR_INVALID_PARAMETER
);
162 len
= strlenW(ca
->path
) + strlenW(selectBaseName
) + 2;
163 if (!(target
= HeapAlloc(GetProcessHeap(), 0, len
* sizeof(WCHAR
))))
165 SetLastError(ERROR_OUTOFMEMORY
);
168 strcpyW(target
, ca
->path
);
169 strcatW(target
, slashW
);
170 strcatW(target
, selectBaseName
);
172 if (!CopyFileW(catalogFile
, target
, FALSE
))
174 HeapFree(GetProcessHeap(), 0, target
);
177 if (!(ci
= HeapAlloc(GetProcessHeap(), 0, sizeof(*ci
))))
179 HeapFree(GetProcessHeap(), 0, target
);
180 SetLastError(ERROR_OUTOFMEMORY
);
183 ci
->magic
= CATINFO_MAGIC
;
184 strcpyW(ci
->file
, target
);
186 HeapFree(GetProcessHeap(), 0, target
);
190 /***********************************************************************
191 * CryptCATAdminCalcHashFromFileHandle (WINTRUST.@)
193 BOOL WINAPI
CryptCATAdminCalcHashFromFileHandle(HANDLE hFile
, DWORD
* pcbHash
,
194 BYTE
* pbHash
, DWORD dwFlags
)
198 TRACE("%p %p %p %x\n", hFile
, pcbHash
, pbHash
, dwFlags
);
200 if (!hFile
|| !pcbHash
|| dwFlags
)
202 SetLastError(ERROR_INVALID_PARAMETER
);
208 SetLastError(ERROR_INSUFFICIENT_BUFFER
);
220 if (!(buffer
= HeapAlloc(GetProcessHeap(), 0, 4096)))
222 SetLastError(ERROR_OUTOFMEMORY
);
225 ret
= CryptAcquireContextW(&prov
, NULL
, MS_DEF_PROV_W
, PROV_RSA_FULL
, CRYPT_VERIFYCONTEXT
);
228 HeapFree(GetProcessHeap(), 0, buffer
);
231 ret
= CryptCreateHash(prov
, CALG_SHA1
, 0, 0, &hash
);
234 HeapFree(GetProcessHeap(), 0, buffer
);
235 CryptReleaseContext(prov
, 0);
238 while ((ret
= ReadFile(hFile
, buffer
, 4096, &bytes_read
, NULL
)) && bytes_read
)
240 CryptHashData(hash
, buffer
, bytes_read
, 0);
242 if (ret
) ret
= CryptGetHashParam(hash
, HP_HASHVAL
, pbHash
, pcbHash
, 0);
244 HeapFree(GetProcessHeap(), 0, buffer
);
245 CryptDestroyHash(hash
);
246 CryptReleaseContext(prov
, 0);
251 /***********************************************************************
252 * CryptCATAdminEnumCatalogFromHash (WINTRUST.@)
254 HCATINFO WINAPI
CryptCATAdminEnumCatalogFromHash(HCATADMIN hCatAdmin
, BYTE
* pbHash
,
255 DWORD cbHash
, DWORD dwFlags
,
256 HCATINFO
* phPrevCatInfo
)
258 static const WCHAR slashW
[] = {'\\',0};
259 static const WCHAR globW
[] = {'\\','*','.','c','a','t',0};
261 struct catadmin
*ca
= hCatAdmin
;
262 WIN32_FIND_DATAW data
;
263 HCATINFO prev
= NULL
;
268 TRACE("%p %p %d %x %p\n", hCatAdmin
, pbHash
, cbHash
, dwFlags
, phPrevCatInfo
);
270 if (!ca
|| ca
->magic
!= CATADMIN_MAGIC
|| !pbHash
|| cbHash
!= 20 || dwFlags
)
272 SetLastError(ERROR_INVALID_PARAMETER
);
275 if (phPrevCatInfo
) prev
= *phPrevCatInfo
;
277 ret
= CryptAcquireContextW(&prov
, NULL
, MS_DEF_PROV_W
, PROV_RSA_FULL
, CRYPT_VERIFYCONTEXT
);
278 if (!ret
) return NULL
;
284 size
= strlenW(ca
->path
) * sizeof(WCHAR
) + sizeof(globW
);
285 if (!(path
= HeapAlloc(GetProcessHeap(), 0, size
)))
287 CryptReleaseContext(prov
, 0);
288 SetLastError(ERROR_OUTOFMEMORY
);
291 strcpyW(path
, ca
->path
);
292 strcatW(path
, globW
);
294 if (ca
->find
) FindClose(ca
->find
);
295 ca
->find
= FindFirstFileW(path
, &data
);
297 HeapFree(GetProcessHeap(), 0, path
);
300 CryptReleaseContext(prov
, 0);
304 else if (!FindNextFileW(ca
->find
, &data
))
306 CryptCATAdminReleaseCatalogContext(hCatAdmin
, prev
, 0);
307 CryptReleaseContext(prov
, 0);
314 CRYPTCATMEMBER
*member
= NULL
;
318 size
= (strlenW(ca
->path
) + strlenW(data
.cFileName
) + 2) * sizeof(WCHAR
);
319 if (!(filename
= HeapAlloc(GetProcessHeap(), 0, size
)))
321 SetLastError(ERROR_OUTOFMEMORY
);
324 strcpyW(filename
, ca
->path
);
325 strcatW(filename
, slashW
);
326 strcatW(filename
, data
.cFileName
);
328 hcat
= CryptCATOpen(filename
, CRYPTCAT_OPEN_EXISTING
, prov
, 0, 0);
329 if (hcat
== INVALID_HANDLE_VALUE
)
331 WARN("couldn't open %s (%u)\n", debugstr_w(filename
), GetLastError());
334 while ((member
= CryptCATEnumerateMember(hcat
, member
)))
336 if (member
->pIndirectData
->Digest
.cbData
!= cbHash
)
338 WARN("amount of hash bytes differs: %u/%u\n", member
->pIndirectData
->Digest
.cbData
, cbHash
);
341 if (!memcmp(member
->pIndirectData
->Digest
.pbData
, pbHash
, cbHash
))
343 TRACE("file %s matches\n", debugstr_w(data
.cFileName
));
346 CryptReleaseContext(prov
, 0);
352 ci
= create_catinfo(filename
);
353 HeapFree(GetProcessHeap(), 0, filename
);
358 HeapFree(GetProcessHeap(), 0, filename
);
360 if (!FindNextFileW(ca
->find
, &data
))
364 CryptReleaseContext(prov
, 0);
371 /***********************************************************************
372 * CryptCATAdminReleaseCatalogContext (WINTRUST.@)
374 * Release a catalog context handle.
377 * hCatAdmin [I] Context handle.
378 * hCatInfo [I] Catalog handle.
379 * dwFlags [I] Reserved.
386 BOOL WINAPI
CryptCATAdminReleaseCatalogContext(HCATADMIN hCatAdmin
,
390 struct catinfo
*ci
= hCatInfo
;
391 struct catadmin
*ca
= hCatAdmin
;
393 TRACE("%p %p %x\n", hCatAdmin
, hCatInfo
, dwFlags
);
395 if (!ca
|| ca
->magic
!= CATADMIN_MAGIC
|| !ci
|| ci
->magic
!= CATINFO_MAGIC
)
397 SetLastError(ERROR_INVALID_PARAMETER
);
401 return HeapFree(GetProcessHeap(), 0, ci
);
404 /***********************************************************************
405 * CryptCATAdminReleaseContext (WINTRUST.@)
407 * Release a catalog administrator context handle.
410 * catAdmin [I] Context handle.
411 * dwFlags [I] Reserved.
418 BOOL WINAPI
CryptCATAdminReleaseContext(HCATADMIN hCatAdmin
, DWORD dwFlags
)
420 struct catadmin
*ca
= hCatAdmin
;
422 TRACE("%p %x\n", hCatAdmin
, dwFlags
);
424 if (!ca
|| ca
->magic
!= CATADMIN_MAGIC
)
426 SetLastError(ERROR_INVALID_PARAMETER
);
429 if (ca
->find
) FindClose(ca
->find
);
431 return HeapFree(GetProcessHeap(), 0, ca
);
434 /***********************************************************************
435 * CryptCATAdminRemoveCatalog (WINTRUST.@)
437 * Remove a catalog file.
440 * catAdmin [I] Context handle.
441 * pwszCatalogFile [I] Catalog file.
442 * dwFlags [I] Reserved.
449 BOOL WINAPI
CryptCATAdminRemoveCatalog(HCATADMIN hCatAdmin
, LPCWSTR pwszCatalogFile
, DWORD dwFlags
)
451 struct catadmin
*ca
= hCatAdmin
;
453 TRACE("%p %s %x\n", hCatAdmin
, debugstr_w(pwszCatalogFile
), dwFlags
);
455 if (!ca
|| ca
->magic
!= CATADMIN_MAGIC
)
457 SetLastError(ERROR_INVALID_PARAMETER
);
460 return DeleteFileW(pwszCatalogFile
);
463 /***********************************************************************
464 * CryptCATClose (WINTRUST.@)
466 BOOL WINAPI
CryptCATClose(HANDLE hCatalog
)
468 FIXME("(%p) stub\n", hCatalog
);
472 /***********************************************************************
473 * CryptCATEnumerateMember (WINTRUST.@)
475 CRYPTCATMEMBER
*WINAPI
CryptCATEnumerateMember(HANDLE hCatalog
, CRYPTCATMEMBER
* pPrevMember
)
477 FIXME("(%p, %p) stub\n", hCatalog
, pPrevMember
);
481 /***********************************************************************
482 * CryptCATOpen (WINTRUST.@)
484 HANDLE WINAPI
CryptCATOpen(LPWSTR pwszFileName
, DWORD fdwOpenFlags
, HCRYPTPROV hProv
,
485 DWORD dwPublicVersion
, DWORD dwEncodingType
)
487 FIXME("(%s, %d, %ld, %d, %d) stub\n", debugstr_w(pwszFileName
), fdwOpenFlags
,
488 hProv
, dwPublicVersion
, dwEncodingType
);
492 /***********************************************************************
493 * CryptSIPCreateIndirectData (WINTRUST.@)
495 BOOL WINAPI
CryptSIPCreateIndirectData(SIP_SUBJECTINFO
* pSubjectInfo
, DWORD
* pcbIndirectData
,
496 SIP_INDIRECT_DATA
* pIndirectData
)
498 FIXME("(%p %p %p) stub\n", pSubjectInfo
, pcbIndirectData
, pIndirectData
);
503 static BOOL
WINTRUST_GetSignedMsgFromPEFile(SIP_SUBJECTINFO
*pSubjectInfo
,
504 DWORD
*pdwEncodingType
, DWORD dwIndex
, DWORD
*pcbSignedDataMsg
,
505 BYTE
*pbSignedDataMsg
)
508 WIN_CERTIFICATE
*pCert
= NULL
;
510 TRACE("(%p %p %d %p %p)\n", pSubjectInfo
, pdwEncodingType
, dwIndex
,
511 pcbSignedDataMsg
, pbSignedDataMsg
);
513 if (!pbSignedDataMsg
)
515 WIN_CERTIFICATE cert
;
517 /* app hasn't passed buffer, just get the length */
518 ret
= ImageGetCertificateHeader(pSubjectInfo
->hFile
, dwIndex
, &cert
);
520 *pcbSignedDataMsg
= cert
.dwLength
;
526 ret
= ImageGetCertificateData(pSubjectInfo
->hFile
, dwIndex
, NULL
, &len
);
527 if (GetLastError() != ERROR_INSUFFICIENT_BUFFER
)
529 pCert
= HeapAlloc(GetProcessHeap(), 0, len
);
535 ret
= ImageGetCertificateData(pSubjectInfo
->hFile
, dwIndex
, pCert
,
539 if (*pcbSignedDataMsg
< pCert
->dwLength
)
541 *pcbSignedDataMsg
= pCert
->dwLength
;
542 SetLastError(ERROR_INSUFFICIENT_BUFFER
);
547 memcpy(pbSignedDataMsg
, pCert
->bCertificate
, pCert
->dwLength
);
548 switch (pCert
->wCertificateType
)
550 case WIN_CERT_TYPE_X509
:
551 *pdwEncodingType
= X509_ASN_ENCODING
;
553 case WIN_CERT_TYPE_PKCS_SIGNED_DATA
:
554 *pdwEncodingType
= X509_ASN_ENCODING
| PKCS_7_ASN_ENCODING
;
557 FIXME("don't know what to do for encoding type %d\n",
558 pCert
->wCertificateType
);
559 *pdwEncodingType
= 0;
564 HeapFree(GetProcessHeap(), 0, pCert
);
568 /* structure offsets */
569 #define cfhead_Signature (0x00)
570 #define cfhead_CabinetSize (0x08)
571 #define cfhead_MinorVersion (0x18)
572 #define cfhead_MajorVersion (0x19)
573 #define cfhead_Flags (0x1E)
574 #define cfhead_SIZEOF (0x24)
575 #define cfheadext_HeaderReserved (0x00)
576 #define cfheadext_SIZEOF (0x04)
577 #define cfsigninfo_CertOffset (0x04)
578 #define cfsigninfo_CertSize (0x08)
579 #define cfsigninfo_SIZEOF (0x0C)
582 #define cfheadRESERVE_PRESENT (0x0004)
584 /* endian-neutral reading of little-endian data */
585 #define EndGetI32(a) ((((a)[3])<<24)|(((a)[2])<<16)|(((a)[1])<<8)|((a)[0]))
586 #define EndGetI16(a) ((((a)[1])<<8)|((a)[0]))
588 /* For documentation purposes only: this is the structure in the reserved
589 * area of a signed cabinet file. The cert offset indicates where in the
590 * cabinet file the signature resides, and the count indicates its size.
592 typedef struct _CAB_SIGNINFO
594 WORD unk0
; /* always 0? */
595 WORD unk1
; /* always 0x0010? */
598 } CAB_SIGNINFO
, *PCAB_SIGNINFO
;
600 static BOOL
WINTRUST_GetSignedMsgFromCabFile(SIP_SUBJECTINFO
*pSubjectInfo
,
601 DWORD
*pdwEncodingType
, DWORD dwIndex
, DWORD
*pcbSignedDataMsg
,
602 BYTE
*pbSignedDataMsg
)
605 LONG base_offset
, cabsize
;
608 DWORD cert_offset
, cert_size
, dwRead
;
610 TRACE("(%p %p %d %p %p)\n", pSubjectInfo
, pdwEncodingType
, dwIndex
,
611 pcbSignedDataMsg
, pbSignedDataMsg
);
614 * FIXME: I just noticed that I am memorizing the initial file pointer
615 * offset and restoring it before reading in the rest of the header
616 * information in the cabinet. Perhaps that's correct -- that is, perhaps
617 * this API is supposed to support "streaming" cabinets which are embedded
618 * in other files, or cabinets which begin at file offsets other than zero.
619 * Otherwise, I should instead go to the absolute beginning of the file.
620 * (Either way, the semantics of wine's FDICopy require me to leave the
621 * file pointer where it is afterwards -- If Windows does not do so, we
622 * ought to duplicate the native behavior in the FDIIsCabinet API, not here.
624 * So, the answer lies in Windows; will native cabinet.dll recognize a
625 * cabinet "file" embedded in another file? Note that cabextract.c does
626 * support this, which implies that Microsoft's might. I haven't tried it
627 * yet so I don't know. ATM, most of wine's FDI cabinet routines (except
628 * this one) would not work in this way. To fix it, we could just make the
629 * various references to absolute file positions in the code relative to an
630 * initial "beginning" offset. Because the FDICopy API doesn't take a
631 * file-handle like this one, we would therein need to search through the
632 * file for the beginning of the cabinet (as we also do in cabextract.c).
633 * Note that this limits us to a maximum of one cabinet per. file: the first.
635 * So, in summary: either the code below is wrong, or the rest of fdi.c is
636 * wrong... I cannot imagine that both are correct ;) One of these flaws
637 * should be fixed after determining the behavior on Windows. We ought
638 * to check both FDIIsCabinet and FDICopy for the right behavior.
643 /* get basic offset & size info */
644 base_offset
= SetFilePointer(pSubjectInfo
->hFile
, 0L, NULL
, SEEK_CUR
);
646 if (SetFilePointer(pSubjectInfo
->hFile
, 0, NULL
, SEEK_END
) == INVALID_SET_FILE_POINTER
)
648 TRACE("seek error\n");
652 cabsize
= SetFilePointer(pSubjectInfo
->hFile
, 0L, NULL
, SEEK_CUR
);
653 if ((cabsize
== -1) || (base_offset
== -1) ||
654 (SetFilePointer(pSubjectInfo
->hFile
, base_offset
, NULL
, SEEK_SET
) == INVALID_SET_FILE_POINTER
))
656 TRACE("seek error\n");
660 /* read in the CFHEADER */
661 if (!ReadFile(pSubjectInfo
->hFile
, buf
, cfhead_SIZEOF
, &dwRead
, NULL
) ||
662 dwRead
!= cfhead_SIZEOF
)
664 TRACE("reading header failed\n");
668 /* check basic MSCF signature */
669 if (EndGetI32(buf
+cfhead_Signature
) != 0x4643534d)
671 WARN("cabinet signature not present\n");
675 /* Ignore the number of folders and files and the set and cabinet IDs */
677 /* check the header revision */
678 if ((buf
[cfhead_MajorVersion
] > 1) ||
679 (buf
[cfhead_MajorVersion
] == 1 && buf
[cfhead_MinorVersion
] > 3))
681 WARN("cabinet format version > 1.3\n");
685 /* pull the flags out */
686 flags
= EndGetI16(buf
+cfhead_Flags
);
688 if (!(flags
& cfheadRESERVE_PRESENT
))
690 TRACE("no header present, not signed\n");
694 if (!ReadFile(pSubjectInfo
->hFile
, buf
, cfheadext_SIZEOF
, &dwRead
, NULL
) ||
695 dwRead
!= cfheadext_SIZEOF
)
697 ERR("bunk reserve-sizes?\n");
701 header_resv
= EndGetI16(buf
+cfheadext_HeaderReserved
);
704 TRACE("no header_resv, not signed\n");
707 else if (header_resv
< cfsigninfo_SIZEOF
)
709 TRACE("header_resv too small, not signed\n");
713 if (header_resv
> 60000)
715 WARN("WARNING; header reserved space > 60000\n");
718 if (!ReadFile(pSubjectInfo
->hFile
, buf
, cfsigninfo_SIZEOF
, &dwRead
, NULL
) ||
719 dwRead
!= cfsigninfo_SIZEOF
)
721 ERR("couldn't read reserve\n");
725 cert_offset
= EndGetI32(buf
+cfsigninfo_CertOffset
);
726 TRACE("cert_offset: %d\n", cert_offset
);
727 cert_size
= EndGetI32(buf
+cfsigninfo_CertSize
);
728 TRACE("cert_size: %d\n", cert_size
);
730 /* The redundant checks are to avoid wraparound */
731 if (cert_offset
> cabsize
|| cert_size
> cabsize
||
732 cert_offset
+ cert_size
> cabsize
)
734 WARN("offset beyond file, not attempting to read\n");
738 SetFilePointer(pSubjectInfo
->hFile
, base_offset
, NULL
, SEEK_SET
);
739 if (!pbSignedDataMsg
)
741 *pcbSignedDataMsg
= cert_size
;
744 if (*pcbSignedDataMsg
< cert_size
)
746 *pcbSignedDataMsg
= cert_size
;
747 SetLastError(ERROR_INSUFFICIENT_BUFFER
);
750 if (SetFilePointer(pSubjectInfo
->hFile
, cert_offset
, NULL
, SEEK_SET
) == INVALID_SET_FILE_POINTER
)
752 ERR("couldn't seek to cert location\n");
755 if (!ReadFile(pSubjectInfo
->hFile
, pbSignedDataMsg
, cert_size
, &dwRead
,
756 NULL
) || dwRead
!= cert_size
)
758 ERR("couldn't read cert\n");
761 /* The encoding of the files I've seen appears to be in ASN.1
762 * format, and there isn't a field indicating the type, so assume it
765 *pdwEncodingType
= X509_ASN_ENCODING
| PKCS_7_ASN_ENCODING
;
769 static BOOL
WINTRUST_GetSignedMsgFromCatFile(SIP_SUBJECTINFO
*pSubjectInfo
,
770 DWORD
*pdwEncodingType
, DWORD dwIndex
, DWORD
*pcbSignedDataMsg
,
771 BYTE
*pbSignedDataMsg
)
775 TRACE("(%p %p %d %p %p)\n", pSubjectInfo
, pdwEncodingType
, dwIndex
,
776 pcbSignedDataMsg
, pbSignedDataMsg
);
778 if (!pbSignedDataMsg
)
780 *pcbSignedDataMsg
= GetFileSize(pSubjectInfo
->hFile
, NULL
);
785 DWORD len
= GetFileSize(pSubjectInfo
->hFile
, NULL
);
787 if (*pcbSignedDataMsg
< len
)
789 *pcbSignedDataMsg
= len
;
790 SetLastError(ERROR_INSUFFICIENT_BUFFER
);
795 ret
= ReadFile(pSubjectInfo
->hFile
, pbSignedDataMsg
, len
,
796 pcbSignedDataMsg
, NULL
);
798 *pdwEncodingType
= X509_ASN_ENCODING
| PKCS_7_ASN_ENCODING
;
804 /***********************************************************************
805 * CryptSIPGetSignedDataMsg (WINTRUST.@)
807 BOOL WINAPI
CryptSIPGetSignedDataMsg(SIP_SUBJECTINFO
* pSubjectInfo
, DWORD
* pdwEncodingType
,
808 DWORD dwIndex
, DWORD
* pcbSignedDataMsg
, BYTE
* pbSignedDataMsg
)
810 static const GUID unknown
= { 0xC689AAB8, 0x8E78, 0x11D0, { 0x8C,0x47,
811 0x00,0xC0,0x4F,0xC2,0x95,0xEE } };
812 static const GUID cabGUID
= { 0xC689AABA, 0x8E78, 0x11D0, { 0x8C,0x47,
813 0x00,0xC0,0x4F,0xC2,0x95,0xEE } };
814 static const GUID catGUID
= { 0xDE351A43, 0x8E59, 0x11D0, { 0x8C,0x47,
815 0x00,0xC0,0x4F,0xC2,0x95,0xEE }};
818 TRACE("(%p %p %d %p %p)\n", pSubjectInfo
, pdwEncodingType
, dwIndex
,
819 pcbSignedDataMsg
, pbSignedDataMsg
);
821 if (!memcmp(pSubjectInfo
->pgSubjectType
, &unknown
, sizeof(unknown
)))
822 ret
= WINTRUST_GetSignedMsgFromPEFile(pSubjectInfo
, pdwEncodingType
,
823 dwIndex
, pcbSignedDataMsg
, pbSignedDataMsg
);
824 else if (!memcmp(pSubjectInfo
->pgSubjectType
, &cabGUID
, sizeof(cabGUID
)))
825 ret
= WINTRUST_GetSignedMsgFromCabFile(pSubjectInfo
, pdwEncodingType
,
826 dwIndex
, pcbSignedDataMsg
, pbSignedDataMsg
);
827 else if (!memcmp(pSubjectInfo
->pgSubjectType
, &catGUID
, sizeof(catGUID
)))
828 ret
= WINTRUST_GetSignedMsgFromCatFile(pSubjectInfo
, pdwEncodingType
,
829 dwIndex
, pcbSignedDataMsg
, pbSignedDataMsg
);
832 FIXME("unimplemented for subject type %s\n",
833 debugstr_guid(pSubjectInfo
->pgSubjectType
));
837 TRACE("returning %d\n", ret
);
841 /***********************************************************************
842 * CryptSIPPutSignedDataMsg (WINTRUST.@)
844 BOOL WINAPI
CryptSIPPutSignedDataMsg(SIP_SUBJECTINFO
* pSubjectInfo
, DWORD pdwEncodingType
,
845 DWORD
* pdwIndex
, DWORD cbSignedDataMsg
, BYTE
* pbSignedDataMsg
)
847 FIXME("(%p %d %p %d %p) stub\n", pSubjectInfo
, pdwEncodingType
, pdwIndex
,
848 cbSignedDataMsg
, pbSignedDataMsg
);
853 /***********************************************************************
854 * CryptSIPRemoveSignedDataMsg (WINTRUST.@)
856 BOOL WINAPI
CryptSIPRemoveSignedDataMsg(SIP_SUBJECTINFO
* pSubjectInfo
,
859 FIXME("(%p %d) stub\n", pSubjectInfo
, dwIndex
);
864 /***********************************************************************
865 * CryptSIPVerifyIndirectData (WINTRUST.@)
867 BOOL WINAPI
CryptSIPVerifyIndirectData(SIP_SUBJECTINFO
* pSubjectInfo
,
868 SIP_INDIRECT_DATA
* pIndirectData
)
870 FIXME("(%p %p) stub\n", pSubjectInfo
, pIndirectData
);