wintrust: Record full catalog filename in catalog info structure, not just the basename.
[wine/wine64.git] / dlls / wintrust / crypt.c
blobb14fca6b38c3055942383cb098f46f05729bdde3
1 /*
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
25 #include <stdarg.h>
26 #include <stdio.h>
27 #include "windef.h"
28 #include "winbase.h"
29 #include "wintrust.h"
30 #include "mscat.h"
31 #include "mssip.h"
32 #include "imagehlp.h"
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' */
42 struct catadmin
44 DWORD magic;
45 WCHAR path[MAX_PATH];
48 struct catinfo
50 DWORD magic;
51 WCHAR file[MAX_PATH];
54 /***********************************************************************
55 * CryptCATAdminAcquireContext (WINTRUST.@)
57 * Get a catalog administrator context handle.
59 * PARAMS
60 * catAdmin [O] Pointer to the context handle.
61 * sys [I] Pointer to a GUID for the needed subsystem.
62 * dwFlags [I] Reserved.
64 * RETURNS
65 * Success: TRUE. catAdmin contains the context handle.
66 * Failure: FALSE.
69 BOOL WINAPI CryptCATAdminAcquireContext(HCATADMIN *catAdmin,
70 const GUID *sys, DWORD dwFlags)
72 static const WCHAR catroot[] =
73 {'\\','c','a','t','r','o','o','t',0};
74 static const WCHAR fmt[] =
75 {'%','s','\\','{','%','0','8','x','-','%','0','4','x','-','%','0',
76 '4','x','-','%','0','2','x','%','0','2','x','-','%','0','2','x',
77 '%','0','2','x','%','0','2','x','%','0','2','x','%','0','2','x',
78 '%','0','2','x','}',0};
79 static const GUID defsys =
80 {0x127d0a1d,0x4ef2,0x11d1,{0x86,0x08,0x00,0xc0,0x4f,0xc2,0x95,0xee}};
82 WCHAR catroot_dir[MAX_PATH];
83 struct catadmin *ca;
85 TRACE("%p %s %x\n", catAdmin, debugstr_guid(sys), dwFlags);
87 if (!catAdmin)
89 SetLastError(ERROR_INVALID_PARAMETER);
90 return FALSE;
92 if (!(ca = HeapAlloc(GetProcessHeap(), 0, sizeof(*ca))))
94 SetLastError(ERROR_OUTOFMEMORY);
95 return FALSE;
98 GetSystemDirectoryW(catroot_dir, MAX_PATH);
99 strcatW(catroot_dir, catroot);
101 /* create the directory if it doesn't exist */
102 CreateDirectoryW(catroot_dir, NULL);
104 if (!sys) sys = &defsys;
105 sprintfW(ca->path, fmt, catroot_dir, sys->Data1, sys->Data2,
106 sys->Data3, sys->Data4[0], sys->Data4[1], sys->Data4[2],
107 sys->Data4[3], sys->Data4[4], sys->Data4[5], sys->Data4[6],
108 sys->Data4[7]);
110 /* create the directory if it doesn't exist */
111 CreateDirectoryW(ca->path, NULL);
113 ca->magic = CATADMIN_MAGIC;
114 *catAdmin = ca;
115 return TRUE;
118 /***********************************************************************
119 * CryptCATAdminAddCatalog (WINTRUST.@)
121 HCATINFO WINAPI CryptCATAdminAddCatalog(HCATADMIN catAdmin, PWSTR catalogFile,
122 PWSTR selectBaseName, DWORD flags)
124 static const WCHAR slashW[] = {'\\',0};
125 struct catadmin *ca = catAdmin;
126 struct catinfo *ci;
127 WCHAR *target;
128 DWORD len;
130 TRACE("%p %s %s %d\n", catAdmin, debugstr_w(catalogFile),
131 debugstr_w(selectBaseName), flags);
133 if (!selectBaseName)
135 FIXME("NULL basename not handled\n");
136 SetLastError(ERROR_INVALID_PARAMETER);
137 return NULL;
139 if (!ca || ca->magic != CATADMIN_MAGIC || !catalogFile || flags)
141 SetLastError(ERROR_INVALID_PARAMETER);
142 return NULL;
145 len = strlenW(ca->path) + strlenW(selectBaseName) + 2;
146 if (!(target = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR))))
148 SetLastError(ERROR_OUTOFMEMORY);
149 return NULL;
151 strcpyW(target, ca->path);
152 strcatW(target, slashW);
153 strcatW(target, selectBaseName);
155 if (!CopyFileW(catalogFile, target, FALSE))
157 HeapFree(GetProcessHeap(), 0, target);
158 return NULL;
160 if (!(ci = HeapAlloc(GetProcessHeap(), 0, sizeof(*ci))))
162 HeapFree(GetProcessHeap(), 0, target);
163 SetLastError(ERROR_OUTOFMEMORY);
164 return NULL;
166 ci->magic = CATINFO_MAGIC;
167 strcpyW(ci->file, target);
169 HeapFree(GetProcessHeap(), 0, target);
170 return ci;
173 /***********************************************************************
174 * CryptCATAdminCalcHashFromFileHandle (WINTRUST.@)
176 BOOL WINAPI CryptCATAdminCalcHashFromFileHandle(HANDLE hFile, DWORD* pcbHash,
177 BYTE* pbHash, DWORD dwFlags )
179 BOOL ret = FALSE;
181 TRACE("%p %p %p %x\n", hFile, pcbHash, pbHash, dwFlags);
183 if (!hFile || !pcbHash || dwFlags)
185 SetLastError(ERROR_INVALID_PARAMETER);
186 return FALSE;
188 if (*pcbHash < 20)
190 *pcbHash = 20;
191 SetLastError(ERROR_INSUFFICIENT_BUFFER);
192 return TRUE;
195 *pcbHash = 20;
196 if (pbHash)
198 HCRYPTPROV prov;
199 HCRYPTHASH hash;
200 DWORD bytes_read;
201 BYTE *buffer;
203 if (!(buffer = HeapAlloc(GetProcessHeap(), 0, 4096)))
205 SetLastError(ERROR_OUTOFMEMORY);
206 return FALSE;
208 ret = CryptAcquireContextW(&prov, NULL, MS_DEF_PROV_W, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT);
209 if (!ret)
211 HeapFree(GetProcessHeap(), 0, buffer);
212 return FALSE;
214 ret = CryptCreateHash(prov, CALG_SHA1, 0, 0, &hash);
215 if (!ret)
217 HeapFree(GetProcessHeap(), 0, buffer);
218 CryptReleaseContext(prov, 0);
219 return FALSE;
221 while ((ret = ReadFile(hFile, buffer, 4096, &bytes_read, NULL)) && bytes_read)
223 CryptHashData(hash, buffer, bytes_read, 0);
225 if (ret) ret = CryptGetHashParam(hash, HP_HASHVAL, pbHash, pcbHash, 0);
227 HeapFree(GetProcessHeap(), 0, buffer);
228 CryptDestroyHash(hash);
229 CryptReleaseContext(prov, 0);
231 return ret;
234 /***********************************************************************
235 * CryptCATAdminEnumCatalogFromHash (WINTRUST.@)
237 HCATINFO WINAPI CryptCATAdminEnumCatalogFromHash(HCATADMIN hCatAdmin,
238 BYTE* pbHash,
239 DWORD cbHash,
240 DWORD dwFlags,
241 HCATINFO* phPrevCatInfo )
243 FIXME("%p %p %d %d %p\n", hCatAdmin, pbHash, cbHash, dwFlags, phPrevCatInfo);
244 return NULL;
247 /***********************************************************************
248 * CryptCATAdminReleaseCatalogContext (WINTRUST.@)
250 * Release a catalog context handle.
252 * PARAMS
253 * hCatAdmin [I] Context handle.
254 * hCatInfo [I] Catalog handle.
255 * dwFlags [I] Reserved.
257 * RETURNS
258 * Success: TRUE.
259 * Failure: FALSE.
262 BOOL WINAPI CryptCATAdminReleaseCatalogContext(HCATADMIN hCatAdmin,
263 HCATINFO hCatInfo,
264 DWORD dwFlags)
266 struct catinfo *ci = hCatInfo;
267 struct catadmin *ca = hCatAdmin;
269 TRACE("%p %p %x\n", hCatAdmin, hCatInfo, dwFlags);
271 if (!ca || ca->magic != CATADMIN_MAGIC || !ci || ci->magic != CATINFO_MAGIC)
273 SetLastError(ERROR_INVALID_PARAMETER);
274 return FALSE;
276 ci->magic = 0;
277 return HeapFree(GetProcessHeap(), 0, ci);
280 /***********************************************************************
281 * CryptCATAdminReleaseContext (WINTRUST.@)
283 * Release a catalog administrator context handle.
285 * PARAMS
286 * catAdmin [I] Context handle.
287 * dwFlags [I] Reserved.
289 * RETURNS
290 * Success: TRUE.
291 * Failure: FALSE.
294 BOOL WINAPI CryptCATAdminReleaseContext(HCATADMIN hCatAdmin, DWORD dwFlags )
296 struct catadmin *ca = hCatAdmin;
298 TRACE("%p %x\n", hCatAdmin, dwFlags);
300 if (!ca || ca->magic != CATADMIN_MAGIC)
302 SetLastError(ERROR_INVALID_PARAMETER);
303 return FALSE;
305 ca->magic = 0;
306 return HeapFree(GetProcessHeap(), 0, ca);
309 /***********************************************************************
310 * CryptCATAdminRemoveCatalog (WINTRUST.@)
312 * Remove a catalog file.
314 * PARAMS
315 * catAdmin [I] Context handle.
316 * pwszCatalogFile [I] Catalog file.
317 * dwFlags [I] Reserved.
319 * RETURNS
320 * Success: TRUE.
321 * Failure: FALSE.
324 BOOL WINAPI CryptCATAdminRemoveCatalog(HCATADMIN hCatAdmin, LPCWSTR pwszCatalogFile, DWORD dwFlags)
326 struct catadmin *ca = hCatAdmin;
328 TRACE("%p %s %x\n", hCatAdmin, debugstr_w(pwszCatalogFile), dwFlags);
330 if (!ca || ca->magic != CATADMIN_MAGIC)
332 SetLastError(ERROR_INVALID_PARAMETER);
333 return FALSE;
335 return DeleteFileW(pwszCatalogFile);
338 /***********************************************************************
339 * CryptCATClose (WINTRUST.@)
341 BOOL WINAPI CryptCATClose(HANDLE hCatalog)
343 FIXME("(%p) stub\n", hCatalog);
344 return TRUE;
347 /***********************************************************************
348 * CryptCATEnumerateMember (WINTRUST.@)
350 CRYPTCATMEMBER *WINAPI CryptCATEnumerateMember(HANDLE hCatalog, CRYPTCATMEMBER* pPrevMember)
352 FIXME("(%p, %p) stub\n", hCatalog, pPrevMember);
353 return NULL;
356 /***********************************************************************
357 * CryptCATOpen (WINTRUST.@)
359 HANDLE WINAPI CryptCATOpen(LPWSTR pwszFileName, DWORD fdwOpenFlags, HCRYPTPROV hProv,
360 DWORD dwPublicVersion, DWORD dwEncodingType)
362 FIXME("(%s, %d, %ld, %d, %d) stub\n", debugstr_w(pwszFileName), fdwOpenFlags,
363 hProv, dwPublicVersion, dwEncodingType);
364 return 0;
367 /***********************************************************************
368 * CryptSIPCreateIndirectData (WINTRUST.@)
370 BOOL WINAPI CryptSIPCreateIndirectData(SIP_SUBJECTINFO* pSubjectInfo, DWORD* pcbIndirectData,
371 SIP_INDIRECT_DATA* pIndirectData)
373 FIXME("(%p %p %p) stub\n", pSubjectInfo, pcbIndirectData, pIndirectData);
375 return FALSE;
378 static BOOL WINTRUST_GetSignedMsgFromPEFile(SIP_SUBJECTINFO *pSubjectInfo,
379 DWORD *pdwEncodingType, DWORD dwIndex, DWORD *pcbSignedDataMsg,
380 BYTE *pbSignedDataMsg)
382 BOOL ret;
383 WIN_CERTIFICATE *pCert = NULL;
385 TRACE("(%p %p %d %p %p)\n", pSubjectInfo, pdwEncodingType, dwIndex,
386 pcbSignedDataMsg, pbSignedDataMsg);
388 if (!pbSignedDataMsg)
390 WIN_CERTIFICATE cert;
392 /* app hasn't passed buffer, just get the length */
393 ret = ImageGetCertificateHeader(pSubjectInfo->hFile, dwIndex, &cert);
394 if (ret)
395 *pcbSignedDataMsg = cert.dwLength;
397 else
399 DWORD len = 0;
401 ret = ImageGetCertificateData(pSubjectInfo->hFile, dwIndex, NULL, &len);
402 if (GetLastError() != ERROR_INSUFFICIENT_BUFFER)
403 goto error;
404 pCert = HeapAlloc(GetProcessHeap(), 0, len);
405 if (!pCert)
407 ret = FALSE;
408 goto error;
410 ret = ImageGetCertificateData(pSubjectInfo->hFile, dwIndex, pCert,
411 &len);
412 if (!ret)
413 goto error;
414 if (*pcbSignedDataMsg < pCert->dwLength)
416 *pcbSignedDataMsg = pCert->dwLength;
417 SetLastError(ERROR_INSUFFICIENT_BUFFER);
418 ret = FALSE;
420 else
422 memcpy(pbSignedDataMsg, pCert->bCertificate, pCert->dwLength);
423 switch (pCert->wCertificateType)
425 case WIN_CERT_TYPE_X509:
426 *pdwEncodingType = X509_ASN_ENCODING;
427 break;
428 case WIN_CERT_TYPE_PKCS_SIGNED_DATA:
429 *pdwEncodingType = X509_ASN_ENCODING | PKCS_7_ASN_ENCODING;
430 break;
431 default:
432 FIXME("don't know what to do for encoding type %d\n",
433 pCert->wCertificateType);
434 *pdwEncodingType = 0;
438 error:
439 HeapFree(GetProcessHeap(), 0, pCert);
440 return ret;
443 /* structure offsets */
444 #define cfhead_Signature (0x00)
445 #define cfhead_CabinetSize (0x08)
446 #define cfhead_MinorVersion (0x18)
447 #define cfhead_MajorVersion (0x19)
448 #define cfhead_Flags (0x1E)
449 #define cfhead_SIZEOF (0x24)
450 #define cfheadext_HeaderReserved (0x00)
451 #define cfheadext_SIZEOF (0x04)
452 #define cfsigninfo_CertOffset (0x04)
453 #define cfsigninfo_CertSize (0x08)
454 #define cfsigninfo_SIZEOF (0x0C)
456 /* flags */
457 #define cfheadRESERVE_PRESENT (0x0004)
459 /* endian-neutral reading of little-endian data */
460 #define EndGetI32(a) ((((a)[3])<<24)|(((a)[2])<<16)|(((a)[1])<<8)|((a)[0]))
461 #define EndGetI16(a) ((((a)[1])<<8)|((a)[0]))
463 /* For documentation purposes only: this is the structure in the reserved
464 * area of a signed cabinet file. The cert offset indicates where in the
465 * cabinet file the signature resides, and the count indicates its size.
467 typedef struct _CAB_SIGNINFO
469 WORD unk0; /* always 0? */
470 WORD unk1; /* always 0x0010? */
471 DWORD dwCertOffset;
472 DWORD cbCertBlock;
473 } CAB_SIGNINFO, *PCAB_SIGNINFO;
475 static BOOL WINTRUST_GetSignedMsgFromCabFile(SIP_SUBJECTINFO *pSubjectInfo,
476 DWORD *pdwEncodingType, DWORD dwIndex, DWORD *pcbSignedDataMsg,
477 BYTE *pbSignedDataMsg)
479 int header_resv;
480 LONG base_offset, cabsize;
481 USHORT flags;
482 BYTE buf[64];
483 DWORD cert_offset, cert_size, dwRead;
485 TRACE("(%p %p %d %p %p)\n", pSubjectInfo, pdwEncodingType, dwIndex,
486 pcbSignedDataMsg, pbSignedDataMsg);
489 * FIXME: I just noticed that I am memorizing the initial file pointer
490 * offset and restoring it before reading in the rest of the header
491 * information in the cabinet. Perhaps that's correct -- that is, perhaps
492 * this API is supposed to support "streaming" cabinets which are embedded
493 * in other files, or cabinets which begin at file offsets other than zero.
494 * Otherwise, I should instead go to the absolute beginning of the file.
495 * (Either way, the semantics of wine's FDICopy require me to leave the
496 * file pointer where it is afterwards -- If Windows does not do so, we
497 * ought to duplicate the native behavior in the FDIIsCabinet API, not here.
499 * So, the answer lies in Windows; will native cabinet.dll recognize a
500 * cabinet "file" embedded in another file? Note that cabextract.c does
501 * support this, which implies that Microsoft's might. I haven't tried it
502 * yet so I don't know. ATM, most of wine's FDI cabinet routines (except
503 * this one) would not work in this way. To fix it, we could just make the
504 * various references to absolute file positions in the code relative to an
505 * initial "beginning" offset. Because the FDICopy API doesn't take a
506 * file-handle like this one, we would therein need to search through the
507 * file for the beginning of the cabinet (as we also do in cabextract.c).
508 * Note that this limits us to a maximum of one cabinet per. file: the first.
510 * So, in summary: either the code below is wrong, or the rest of fdi.c is
511 * wrong... I cannot imagine that both are correct ;) One of these flaws
512 * should be fixed after determining the behavior on Windows. We ought
513 * to check both FDIIsCabinet and FDICopy for the right behavior.
515 * -gmt
518 /* get basic offset & size info */
519 base_offset = SetFilePointer(pSubjectInfo->hFile, 0L, NULL, SEEK_CUR);
521 if (SetFilePointer(pSubjectInfo->hFile, 0, NULL, SEEK_END) == INVALID_SET_FILE_POINTER)
523 TRACE("seek error\n");
524 return FALSE;
527 cabsize = SetFilePointer(pSubjectInfo->hFile, 0L, NULL, SEEK_CUR);
528 if ((cabsize == -1) || (base_offset == -1) ||
529 (SetFilePointer(pSubjectInfo->hFile, base_offset, NULL, SEEK_SET) == INVALID_SET_FILE_POINTER))
531 TRACE("seek error\n");
532 return FALSE;
535 /* read in the CFHEADER */
536 if (!ReadFile(pSubjectInfo->hFile, buf, cfhead_SIZEOF, &dwRead, NULL) ||
537 dwRead != cfhead_SIZEOF)
539 TRACE("reading header failed\n");
540 return FALSE;
543 /* check basic MSCF signature */
544 if (EndGetI32(buf+cfhead_Signature) != 0x4643534d)
546 WARN("cabinet signature not present\n");
547 return FALSE;
550 /* Ignore the number of folders and files and the set and cabinet IDs */
552 /* check the header revision */
553 if ((buf[cfhead_MajorVersion] > 1) ||
554 (buf[cfhead_MajorVersion] == 1 && buf[cfhead_MinorVersion] > 3))
556 WARN("cabinet format version > 1.3\n");
557 return FALSE;
560 /* pull the flags out */
561 flags = EndGetI16(buf+cfhead_Flags);
563 if (!(flags & cfheadRESERVE_PRESENT))
565 TRACE("no header present, not signed\n");
566 return FALSE;
569 if (!ReadFile(pSubjectInfo->hFile, buf, cfheadext_SIZEOF, &dwRead, NULL) ||
570 dwRead != cfheadext_SIZEOF)
572 ERR("bunk reserve-sizes?\n");
573 return FALSE;
576 header_resv = EndGetI16(buf+cfheadext_HeaderReserved);
577 if (!header_resv)
579 TRACE("no header_resv, not signed\n");
580 return FALSE;
582 else if (header_resv < cfsigninfo_SIZEOF)
584 TRACE("header_resv too small, not signed\n");
585 return FALSE;
588 if (header_resv > 60000)
590 WARN("WARNING; header reserved space > 60000\n");
593 if (!ReadFile(pSubjectInfo->hFile, buf, cfsigninfo_SIZEOF, &dwRead, NULL) ||
594 dwRead != cfsigninfo_SIZEOF)
596 ERR("couldn't read reserve\n");
597 return FALSE;
600 cert_offset = EndGetI32(buf+cfsigninfo_CertOffset);
601 TRACE("cert_offset: %d\n", cert_offset);
602 cert_size = EndGetI32(buf+cfsigninfo_CertSize);
603 TRACE("cert_size: %d\n", cert_size);
605 /* The redundant checks are to avoid wraparound */
606 if (cert_offset > cabsize || cert_size > cabsize ||
607 cert_offset + cert_size > cabsize)
609 WARN("offset beyond file, not attempting to read\n");
610 return FALSE;
613 SetFilePointer(pSubjectInfo->hFile, base_offset, NULL, SEEK_SET);
614 if (!pbSignedDataMsg)
616 *pcbSignedDataMsg = cert_size;
617 return TRUE;
619 if (*pcbSignedDataMsg < cert_size)
621 *pcbSignedDataMsg = cert_size;
622 SetLastError(ERROR_INSUFFICIENT_BUFFER);
623 return FALSE;
625 if (SetFilePointer(pSubjectInfo->hFile, cert_offset, NULL, SEEK_SET) == INVALID_SET_FILE_POINTER)
627 ERR("couldn't seek to cert location\n");
628 return FALSE;
630 if (!ReadFile(pSubjectInfo->hFile, pbSignedDataMsg, cert_size, &dwRead,
631 NULL) || dwRead != cert_size)
633 ERR("couldn't read cert\n");
634 return FALSE;
636 /* The encoding of the files I've seen appears to be in ASN.1
637 * format, and there isn't a field indicating the type, so assume it
638 * always is.
640 *pdwEncodingType = X509_ASN_ENCODING | PKCS_7_ASN_ENCODING;
641 return TRUE;
644 static BOOL WINTRUST_GetSignedMsgFromCatFile(SIP_SUBJECTINFO *pSubjectInfo,
645 DWORD *pdwEncodingType, DWORD dwIndex, DWORD *pcbSignedDataMsg,
646 BYTE *pbSignedDataMsg)
648 BOOL ret;
650 TRACE("(%p %p %d %p %p)\n", pSubjectInfo, pdwEncodingType, dwIndex,
651 pcbSignedDataMsg, pbSignedDataMsg);
653 if (!pbSignedDataMsg)
655 *pcbSignedDataMsg = GetFileSize(pSubjectInfo->hFile, NULL);
656 ret = TRUE;
658 else
660 DWORD len = GetFileSize(pSubjectInfo->hFile, NULL);
662 if (*pcbSignedDataMsg < len)
664 *pcbSignedDataMsg = len;
665 SetLastError(ERROR_INSUFFICIENT_BUFFER);
666 ret = FALSE;
668 else
670 ret = ReadFile(pSubjectInfo->hFile, pbSignedDataMsg, len,
671 pcbSignedDataMsg, NULL);
672 if (ret)
673 *pdwEncodingType = X509_ASN_ENCODING | PKCS_7_ASN_ENCODING;
676 return ret;
679 /***********************************************************************
680 * CryptSIPGetSignedDataMsg (WINTRUST.@)
682 BOOL WINAPI CryptSIPGetSignedDataMsg(SIP_SUBJECTINFO* pSubjectInfo, DWORD* pdwEncodingType,
683 DWORD dwIndex, DWORD* pcbSignedDataMsg, BYTE* pbSignedDataMsg)
685 static const GUID unknown = { 0xC689AAB8, 0x8E78, 0x11D0, { 0x8C,0x47,
686 0x00,0xC0,0x4F,0xC2,0x95,0xEE } };
687 static const GUID cabGUID = { 0xC689AABA, 0x8E78, 0x11D0, { 0x8C,0x47,
688 0x00,0xC0,0x4F,0xC2,0x95,0xEE } };
689 static const GUID catGUID = { 0xDE351A43, 0x8E59, 0x11D0, { 0x8C,0x47,
690 0x00,0xC0,0x4F,0xC2,0x95,0xEE }};
691 BOOL ret;
693 TRACE("(%p %p %d %p %p)\n", pSubjectInfo, pdwEncodingType, dwIndex,
694 pcbSignedDataMsg, pbSignedDataMsg);
696 if (!memcmp(pSubjectInfo->pgSubjectType, &unknown, sizeof(unknown)))
697 ret = WINTRUST_GetSignedMsgFromPEFile(pSubjectInfo, pdwEncodingType,
698 dwIndex, pcbSignedDataMsg, pbSignedDataMsg);
699 else if (!memcmp(pSubjectInfo->pgSubjectType, &cabGUID, sizeof(cabGUID)))
700 ret = WINTRUST_GetSignedMsgFromCabFile(pSubjectInfo, pdwEncodingType,
701 dwIndex, pcbSignedDataMsg, pbSignedDataMsg);
702 else if (!memcmp(pSubjectInfo->pgSubjectType, &catGUID, sizeof(catGUID)))
703 ret = WINTRUST_GetSignedMsgFromCatFile(pSubjectInfo, pdwEncodingType,
704 dwIndex, pcbSignedDataMsg, pbSignedDataMsg);
705 else
707 FIXME("unimplemented for subject type %s\n",
708 debugstr_guid(pSubjectInfo->pgSubjectType));
709 ret = FALSE;
712 TRACE("returning %d\n", ret);
713 return ret;
716 /***********************************************************************
717 * CryptSIPPutSignedDataMsg (WINTRUST.@)
719 BOOL WINAPI CryptSIPPutSignedDataMsg(SIP_SUBJECTINFO* pSubjectInfo, DWORD pdwEncodingType,
720 DWORD* pdwIndex, DWORD cbSignedDataMsg, BYTE* pbSignedDataMsg)
722 FIXME("(%p %d %p %d %p) stub\n", pSubjectInfo, pdwEncodingType, pdwIndex,
723 cbSignedDataMsg, pbSignedDataMsg);
725 return FALSE;
728 /***********************************************************************
729 * CryptSIPRemoveSignedDataMsg (WINTRUST.@)
731 BOOL WINAPI CryptSIPRemoveSignedDataMsg(SIP_SUBJECTINFO* pSubjectInfo,
732 DWORD dwIndex)
734 FIXME("(%p %d) stub\n", pSubjectInfo, dwIndex);
736 return FALSE;
739 /***********************************************************************
740 * CryptSIPVerifyIndirectData (WINTRUST.@)
742 BOOL WINAPI CryptSIPVerifyIndirectData(SIP_SUBJECTINFO* pSubjectInfo,
743 SIP_INDIRECT_DATA* pIndirectData)
745 FIXME("(%p %p) stub\n", pSubjectInfo, pIndirectData);
747 return FALSE;