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 "wintrust_priv.h"
29 WINE_DEFAULT_DEBUG_CHANNEL(wintrust
);
31 #define CATADMIN_MAGIC 0x43415441 /* 'CATA' */
32 #define CRYPTCAT_MAGIC 0x43415443 /* 'CATC' */
33 #define CATINFO_MAGIC 0x43415449 /* 'CATI' */
44 CRYPTCATATTRIBUTE
*attr
;
60 static HCATINFO
create_catinfo(const WCHAR
*filename
)
64 if (!(ci
= HeapAlloc(GetProcessHeap(), 0, sizeof(*ci
))))
66 SetLastError(ERROR_OUTOFMEMORY
);
67 return INVALID_HANDLE_VALUE
;
69 strcpyW(ci
->file
, filename
);
70 ci
->magic
= CATINFO_MAGIC
;
74 /***********************************************************************
75 * CryptCATAdminAcquireContext (WINTRUST.@)
77 * Get a catalog administrator context handle.
80 * catAdmin [O] Pointer to the context handle.
81 * sys [I] Pointer to a GUID for the needed subsystem.
82 * dwFlags [I] Reserved.
85 * Success: TRUE. catAdmin contains the context handle.
89 BOOL WINAPI
CryptCATAdminAcquireContext(HCATADMIN
*catAdmin
,
90 const GUID
*sys
, DWORD dwFlags
)
92 static const WCHAR catroot
[] =
93 {'\\','c','a','t','r','o','o','t',0};
94 static const WCHAR fmt
[] =
95 {'%','s','\\','{','%','0','8','x','-','%','0','4','x','-','%','0',
96 '4','x','-','%','0','2','x','%','0','2','x','-','%','0','2','x',
97 '%','0','2','x','%','0','2','x','%','0','2','x','%','0','2','x',
98 '%','0','2','x','}',0};
99 static const GUID defsys
=
100 {0x127d0a1d,0x4ef2,0x11d1,{0x86,0x08,0x00,0xc0,0x4f,0xc2,0x95,0xee}};
102 WCHAR catroot_dir
[MAX_PATH
];
105 TRACE("%p %s %x\n", catAdmin
, debugstr_guid(sys
), dwFlags
);
109 SetLastError(ERROR_INVALID_PARAMETER
);
112 if (!(ca
= HeapAlloc(GetProcessHeap(), 0, sizeof(*ca
))))
114 SetLastError(ERROR_OUTOFMEMORY
);
118 GetSystemDirectoryW(catroot_dir
, MAX_PATH
);
119 strcatW(catroot_dir
, catroot
);
121 /* create the directory if it doesn't exist */
122 CreateDirectoryW(catroot_dir
, NULL
);
124 if (!sys
) sys
= &defsys
;
125 sprintfW(ca
->path
, fmt
, catroot_dir
, sys
->Data1
, sys
->Data2
,
126 sys
->Data3
, sys
->Data4
[0], sys
->Data4
[1], sys
->Data4
[2],
127 sys
->Data4
[3], sys
->Data4
[4], sys
->Data4
[5], sys
->Data4
[6],
130 /* create the directory if it doesn't exist */
131 CreateDirectoryW(ca
->path
, NULL
);
133 ca
->magic
= CATADMIN_MAGIC
;
134 ca
->find
= INVALID_HANDLE_VALUE
;
140 /***********************************************************************
141 * CryptCATAdminAddCatalog (WINTRUST.@)
143 HCATINFO WINAPI
CryptCATAdminAddCatalog(HCATADMIN catAdmin
, PWSTR catalogFile
,
144 PWSTR selectBaseName
, DWORD flags
)
146 static const WCHAR slashW
[] = {'\\',0};
147 struct catadmin
*ca
= catAdmin
;
152 TRACE("%p %s %s %d\n", catAdmin
, debugstr_w(catalogFile
),
153 debugstr_w(selectBaseName
), flags
);
157 FIXME("NULL basename not handled\n");
158 SetLastError(ERROR_INVALID_PARAMETER
);
161 if (!ca
|| ca
->magic
!= CATADMIN_MAGIC
|| !catalogFile
|| flags
)
163 SetLastError(ERROR_INVALID_PARAMETER
);
167 len
= strlenW(ca
->path
) + strlenW(selectBaseName
) + 2;
168 if (!(target
= HeapAlloc(GetProcessHeap(), 0, len
* sizeof(WCHAR
))))
170 SetLastError(ERROR_OUTOFMEMORY
);
173 strcpyW(target
, ca
->path
);
174 strcatW(target
, slashW
);
175 strcatW(target
, selectBaseName
);
177 if (!CopyFileW(catalogFile
, target
, FALSE
))
179 HeapFree(GetProcessHeap(), 0, target
);
182 SetFileAttributesW(target
, FILE_ATTRIBUTE_SYSTEM
);
184 if (!(ci
= HeapAlloc(GetProcessHeap(), 0, sizeof(*ci
))))
186 HeapFree(GetProcessHeap(), 0, target
);
187 SetLastError(ERROR_OUTOFMEMORY
);
190 ci
->magic
= CATINFO_MAGIC
;
191 strcpyW(ci
->file
, target
);
193 HeapFree(GetProcessHeap(), 0, target
);
197 /***********************************************************************
198 * CryptCATAdminCalcHashFromFileHandle (WINTRUST.@)
200 BOOL WINAPI
CryptCATAdminCalcHashFromFileHandle(HANDLE hFile
, DWORD
* pcbHash
,
201 BYTE
* pbHash
, DWORD dwFlags
)
205 TRACE("%p %p %p %x\n", hFile
, pcbHash
, pbHash
, dwFlags
);
207 if (!hFile
|| !pcbHash
|| dwFlags
)
209 SetLastError(ERROR_INVALID_PARAMETER
);
215 SetLastError(ERROR_INSUFFICIENT_BUFFER
);
227 if (!(buffer
= HeapAlloc(GetProcessHeap(), 0, 4096)))
229 SetLastError(ERROR_OUTOFMEMORY
);
232 ret
= CryptAcquireContextW(&prov
, NULL
, MS_DEF_PROV_W
, PROV_RSA_FULL
, CRYPT_VERIFYCONTEXT
);
235 HeapFree(GetProcessHeap(), 0, buffer
);
238 ret
= CryptCreateHash(prov
, CALG_SHA1
, 0, 0, &hash
);
241 HeapFree(GetProcessHeap(), 0, buffer
);
242 CryptReleaseContext(prov
, 0);
245 while ((ret
= ReadFile(hFile
, buffer
, 4096, &bytes_read
, NULL
)) && bytes_read
)
247 CryptHashData(hash
, buffer
, bytes_read
, 0);
249 if (ret
) ret
= CryptGetHashParam(hash
, HP_HASHVAL
, pbHash
, pcbHash
, 0);
251 HeapFree(GetProcessHeap(), 0, buffer
);
252 CryptDestroyHash(hash
);
253 CryptReleaseContext(prov
, 0);
258 /***********************************************************************
259 * CryptCATAdminEnumCatalogFromHash (WINTRUST.@)
261 HCATINFO WINAPI
CryptCATAdminEnumCatalogFromHash(HCATADMIN hCatAdmin
, BYTE
* pbHash
,
262 DWORD cbHash
, DWORD dwFlags
,
263 HCATINFO
* phPrevCatInfo
)
265 static const WCHAR slashW
[] = {'\\',0};
266 static const WCHAR globW
[] = {'\\','*','.','c','a','t',0};
268 struct catadmin
*ca
= hCatAdmin
;
269 WIN32_FIND_DATAW data
;
270 HCATINFO prev
= NULL
;
275 TRACE("%p %p %d %x %p\n", hCatAdmin
, pbHash
, cbHash
, dwFlags
, phPrevCatInfo
);
277 if (!ca
|| ca
->magic
!= CATADMIN_MAGIC
|| !pbHash
|| cbHash
!= 20 || dwFlags
)
279 SetLastError(ERROR_INVALID_PARAMETER
);
282 if (phPrevCatInfo
) prev
= *phPrevCatInfo
;
284 ret
= CryptAcquireContextW(&prov
, NULL
, MS_DEF_PROV_W
, PROV_RSA_FULL
, CRYPT_VERIFYCONTEXT
);
285 if (!ret
) return NULL
;
291 size
= strlenW(ca
->path
) * sizeof(WCHAR
) + sizeof(globW
);
292 if (!(path
= HeapAlloc(GetProcessHeap(), 0, size
)))
294 CryptReleaseContext(prov
, 0);
295 SetLastError(ERROR_OUTOFMEMORY
);
298 strcpyW(path
, ca
->path
);
299 strcatW(path
, globW
);
302 ca
->find
= FindFirstFileW(path
, &data
);
304 HeapFree(GetProcessHeap(), 0, path
);
305 if (ca
->find
== INVALID_HANDLE_VALUE
)
307 CryptReleaseContext(prov
, 0);
311 else if (!FindNextFileW(ca
->find
, &data
))
313 CryptCATAdminReleaseCatalogContext(hCatAdmin
, prev
, 0);
314 CryptReleaseContext(prov
, 0);
321 CRYPTCATMEMBER
*member
= NULL
;
325 size
= (strlenW(ca
->path
) + strlenW(data
.cFileName
) + 2) * sizeof(WCHAR
);
326 if (!(filename
= HeapAlloc(GetProcessHeap(), 0, size
)))
328 SetLastError(ERROR_OUTOFMEMORY
);
331 strcpyW(filename
, ca
->path
);
332 strcatW(filename
, slashW
);
333 strcatW(filename
, data
.cFileName
);
335 hcat
= CryptCATOpen(filename
, CRYPTCAT_OPEN_EXISTING
, prov
, 0, 0);
336 if (hcat
== INVALID_HANDLE_VALUE
)
338 WARN("couldn't open %s (%u)\n", debugstr_w(filename
), GetLastError());
341 while ((member
= CryptCATEnumerateMember(hcat
, member
)))
343 if (member
->pIndirectData
->Digest
.cbData
!= cbHash
)
345 WARN("amount of hash bytes differs: %u/%u\n", member
->pIndirectData
->Digest
.cbData
, cbHash
);
348 if (!memcmp(member
->pIndirectData
->Digest
.pbData
, pbHash
, cbHash
))
350 TRACE("file %s matches\n", debugstr_w(data
.cFileName
));
353 CryptReleaseContext(prov
, 0);
357 ca
->find
= INVALID_HANDLE_VALUE
;
359 ci
= create_catinfo(filename
);
360 HeapFree(GetProcessHeap(), 0, filename
);
365 HeapFree(GetProcessHeap(), 0, filename
);
367 if (!FindNextFileW(ca
->find
, &data
))
370 ca
->find
= INVALID_HANDLE_VALUE
;
371 CryptReleaseContext(prov
, 0);
378 /***********************************************************************
379 * CryptCATAdminReleaseCatalogContext (WINTRUST.@)
381 * Release a catalog context handle.
384 * hCatAdmin [I] Context handle.
385 * hCatInfo [I] Catalog handle.
386 * dwFlags [I] Reserved.
393 BOOL WINAPI
CryptCATAdminReleaseCatalogContext(HCATADMIN hCatAdmin
,
397 struct catinfo
*ci
= hCatInfo
;
398 struct catadmin
*ca
= hCatAdmin
;
400 TRACE("%p %p %x\n", hCatAdmin
, hCatInfo
, dwFlags
);
402 if (!ca
|| ca
->magic
!= CATADMIN_MAGIC
|| !ci
|| ci
->magic
!= CATINFO_MAGIC
)
404 SetLastError(ERROR_INVALID_PARAMETER
);
408 return HeapFree(GetProcessHeap(), 0, ci
);
411 /***********************************************************************
412 * CryptCATAdminReleaseContext (WINTRUST.@)
414 * Release a catalog administrator context handle.
417 * catAdmin [I] Context handle.
418 * dwFlags [I] Reserved.
425 BOOL WINAPI
CryptCATAdminReleaseContext(HCATADMIN hCatAdmin
, DWORD dwFlags
)
427 struct catadmin
*ca
= hCatAdmin
;
429 TRACE("%p %x\n", hCatAdmin
, dwFlags
);
431 if (!ca
|| ca
->magic
!= CATADMIN_MAGIC
)
433 SetLastError(ERROR_INVALID_PARAMETER
);
436 if (ca
->find
!= INVALID_HANDLE_VALUE
) FindClose(ca
->find
);
438 return HeapFree(GetProcessHeap(), 0, ca
);
441 /***********************************************************************
442 * CryptCATAdminRemoveCatalog (WINTRUST.@)
444 * Remove a catalog file.
447 * catAdmin [I] Context handle.
448 * pwszCatalogFile [I] Catalog file.
449 * dwFlags [I] Reserved.
456 BOOL WINAPI
CryptCATAdminRemoveCatalog(HCATADMIN hCatAdmin
, LPCWSTR pwszCatalogFile
, DWORD dwFlags
)
458 struct catadmin
*ca
= hCatAdmin
;
460 TRACE("%p %s %x\n", hCatAdmin
, debugstr_w(pwszCatalogFile
), dwFlags
);
462 if (!ca
|| ca
->magic
!= CATADMIN_MAGIC
)
464 SetLastError(ERROR_INVALID_PARAMETER
);
468 /* Only delete when there is a filename and no path */
469 if (pwszCatalogFile
&& pwszCatalogFile
[0] != 0 &&
470 !strchrW(pwszCatalogFile
, '\\') && !strchrW(pwszCatalogFile
, '/') &&
471 !strchrW(pwszCatalogFile
, ':'))
473 static const WCHAR slashW
[] = {'\\',0};
477 len
= strlenW(ca
->path
) + strlenW(pwszCatalogFile
) + 2;
478 if (!(target
= HeapAlloc(GetProcessHeap(), 0, len
* sizeof(WCHAR
))))
480 SetLastError(ERROR_OUTOFMEMORY
);
483 strcpyW(target
, ca
->path
);
484 strcatW(target
, slashW
);
485 strcatW(target
, pwszCatalogFile
);
489 HeapFree(GetProcessHeap(), 0, target
);
495 /***********************************************************************
496 * CryptCATAdminResolveCatalogPath (WINTRUST.@)
498 BOOL WINAPI
CryptCATAdminResolveCatalogPath(HCATADMIN hcatadmin
, WCHAR
*catalog_file
,
499 CATALOG_INFO
*info
, DWORD flags
)
501 static const WCHAR slashW
[] = {'\\',0};
502 struct catadmin
*ca
= hcatadmin
;
504 TRACE("%p %s %p %x\n", hcatadmin
, debugstr_w(catalog_file
), info
, flags
);
506 if (!ca
|| ca
->magic
!= CATADMIN_MAGIC
|| !info
|| info
->cbStruct
!= sizeof(*info
) || flags
)
508 SetLastError(ERROR_INVALID_PARAMETER
);
511 strcpyW(info
->wszCatalogFile
, ca
->path
);
512 strcatW(info
->wszCatalogFile
, slashW
);
513 strcatW(info
->wszCatalogFile
, catalog_file
);
518 /***********************************************************************
519 * CryptCATClose (WINTRUST.@)
521 BOOL WINAPI
CryptCATClose(HANDLE hCatalog
)
523 struct cryptcat
*cc
= hCatalog
;
525 TRACE("(%p)\n", hCatalog
);
527 if (!hCatalog
|| hCatalog
== INVALID_HANDLE_VALUE
|| cc
->magic
!= CRYPTCAT_MAGIC
)
529 SetLastError(ERROR_INVALID_PARAMETER
);
532 HeapFree(GetProcessHeap(), 0, cc
->attr
);
533 HeapFree(GetProcessHeap(), 0, cc
->inner
);
534 CryptMsgClose(cc
->msg
);
537 HeapFree(GetProcessHeap(), 0, cc
);
541 /***********************************************************************
542 * CryptCATGetAttrInfo (WINTRUST.@)
544 CRYPTCATATTRIBUTE
* WINAPI
CryptCATGetAttrInfo(HANDLE hCatalog
, CRYPTCATMEMBER
*member
, LPWSTR tag
)
546 struct cryptcat
*cc
= hCatalog
;
548 FIXME("%p, %p, %s\n", hCatalog
, member
, debugstr_w(tag
));
550 if (!hCatalog
|| hCatalog
== INVALID_HANDLE_VALUE
|| cc
->magic
!= CRYPTCAT_MAGIC
)
552 SetLastError(ERROR_INVALID_PARAMETER
);
555 SetLastError(CRYPT_E_NOT_FOUND
);
559 /***********************************************************************
560 * CryptCATGetCatAttrInfo (WINTRUST.@)
562 CRYPTCATATTRIBUTE
* WINAPI
CryptCATGetCatAttrInfo(HANDLE hCatalog
, LPWSTR tag
)
564 struct cryptcat
*cc
= hCatalog
;
566 FIXME("%p, %s\n", hCatalog
, debugstr_w(tag
));
568 if (!hCatalog
|| hCatalog
== INVALID_HANDLE_VALUE
|| cc
->magic
!= CRYPTCAT_MAGIC
)
570 SetLastError(ERROR_INVALID_PARAMETER
);
573 SetLastError(CRYPT_E_NOT_FOUND
);
577 CRYPTCATMEMBER
* WINAPI
CryptCATGetMemberInfo(HANDLE hCatalog
, LPWSTR tag
)
579 struct cryptcat
*cc
= hCatalog
;
581 FIXME("%p, %s\n", hCatalog
, debugstr_w(tag
));
583 if (!hCatalog
|| hCatalog
== INVALID_HANDLE_VALUE
|| cc
->magic
!= CRYPTCAT_MAGIC
)
585 SetLastError(ERROR_INVALID_PARAMETER
);
588 SetLastError(CRYPT_E_NOT_FOUND
);
592 /***********************************************************************
593 * CryptCATEnumerateAttr (WINTRUST.@)
595 CRYPTCATATTRIBUTE
* WINAPI
CryptCATEnumerateAttr(HANDLE hCatalog
, CRYPTCATMEMBER
*member
, CRYPTCATATTRIBUTE
*prev
)
597 struct cryptcat
*cc
= hCatalog
;
599 FIXME("%p, %p, %p\n", hCatalog
, member
, prev
);
601 if (!hCatalog
|| hCatalog
== INVALID_HANDLE_VALUE
|| cc
->magic
!= CRYPTCAT_MAGIC
)
603 SetLastError(ERROR_INVALID_PARAMETER
);
606 SetLastError(CRYPT_E_NOT_FOUND
);
610 /***********************************************************************
611 * CryptCATEnumerateCatAttr (WINTRUST.@)
613 CRYPTCATATTRIBUTE
* WINAPI
CryptCATEnumerateCatAttr(HANDLE hCatalog
, CRYPTCATATTRIBUTE
*prev
)
615 struct cryptcat
*cc
= hCatalog
;
617 FIXME("%p, %p\n", hCatalog
, prev
);
619 if (!hCatalog
|| hCatalog
== INVALID_HANDLE_VALUE
|| cc
->magic
!= CRYPTCAT_MAGIC
)
621 SetLastError(ERROR_INVALID_PARAMETER
);
624 SetLastError(CRYPT_E_NOT_FOUND
);
628 /***********************************************************************
629 * CryptCATEnumerateMember (WINTRUST.@)
631 CRYPTCATMEMBER
* WINAPI
CryptCATEnumerateMember(HANDLE hCatalog
, CRYPTCATMEMBER
*prev
)
633 struct cryptcat
*cc
= hCatalog
;
634 CRYPTCATMEMBER
*member
= prev
;
638 TRACE("%p, %p\n", hCatalog
, prev
);
640 if (!hCatalog
|| hCatalog
== INVALID_HANDLE_VALUE
|| cc
->magic
!= CRYPTCAT_MAGIC
)
642 SetLastError(ERROR_INVALID_PARAMETER
);
646 /* dumping the contents makes me think that dwReserved is the iteration number */
649 if (!(member
= HeapAlloc(GetProcessHeap(), 0, sizeof(*member
))))
651 SetLastError(ERROR_OUTOFMEMORY
);
654 member
->cbStruct
= sizeof(*member
);
655 member
->pwszFileName
= member
->pwszReferenceTag
= NULL
;
656 member
->dwReserved
= 0;
657 member
->hReserved
= NULL
;
658 member
->gSubjectType
= cc
->subject
;
659 member
->fdwMemberFlags
= 0;
660 member
->pIndirectData
= NULL
;
661 member
->dwCertVersion
= cc
->inner
->dwVersion
;
663 else member
->dwReserved
++;
665 if (member
->dwReserved
>= cc
->inner
->cCTLEntry
)
667 SetLastError(ERROR_INVALID_PARAMETER
);
671 /* list them backwards, like native */
672 entry
= &cc
->inner
->rgCTLEntry
[cc
->inner
->cCTLEntry
- member
->dwReserved
- 1];
674 member
->sEncodedIndirectData
.cbData
= member
->sEncodedMemberInfo
.cbData
= 0;
675 member
->sEncodedIndirectData
.pbData
= member
->sEncodedMemberInfo
.pbData
= NULL
;
676 HeapFree(GetProcessHeap(), 0, member
->pIndirectData
);
677 member
->pIndirectData
= NULL
;
679 for (i
= 0; i
< entry
->cAttribute
; i
++)
681 CRYPT_ATTRIBUTE
*attr
= entry
->rgAttribute
+ i
;
683 if (attr
->cValue
!= 1)
685 ERR("Can't handle attr->cValue of %u\n", attr
->cValue
);
688 if (!strcmp(attr
->pszObjId
, CAT_MEMBERINFO_OBJID
))
693 member
->sEncodedMemberInfo
.cbData
= attr
->rgValue
->cbData
;
694 member
->sEncodedMemberInfo
.pbData
= attr
->rgValue
->pbData
;
696 CryptDecodeObject(cc
->encoding
, CAT_MEMBERINFO_OBJID
, attr
->rgValue
->pbData
, attr
->rgValue
->cbData
, 0, NULL
, &size
);
698 if (!(mi
= HeapAlloc(GetProcessHeap(), 0, size
)))
700 SetLastError(ERROR_OUTOFMEMORY
);
703 ret
= CryptDecodeObject(cc
->encoding
, CAT_MEMBERINFO_OBJID
, attr
->rgValue
->pbData
, attr
->rgValue
->cbData
, 0, mi
, &size
);
708 member
->dwCertVersion
= mi
->dwCertVersion
;
709 RtlInitUnicodeString(&guid
, mi
->pwszSubjGuid
);
710 if (RtlGUIDFromString(&guid
, &member
->gSubjectType
))
712 HeapFree(GetProcessHeap(), 0, mi
);
716 HeapFree(GetProcessHeap(), 0, mi
);
717 if (!ret
) goto error
;
719 else if (!strcmp(attr
->pszObjId
, SPC_INDIRECT_DATA_OBJID
))
721 /* SPC_INDIRECT_DATA_CONTENT is equal to SIP_INDIRECT_DATA */
723 member
->sEncodedIndirectData
.cbData
= attr
->rgValue
->cbData
;
724 member
->sEncodedIndirectData
.pbData
= attr
->rgValue
->pbData
;
726 CryptDecodeObject(cc
->encoding
, SPC_INDIRECT_DATA_OBJID
, attr
->rgValue
->pbData
, attr
->rgValue
->cbData
, 0, NULL
, &size
);
728 if (!(member
->pIndirectData
= HeapAlloc(GetProcessHeap(), 0, size
)))
730 SetLastError(ERROR_OUTOFMEMORY
);
733 CryptDecodeObject(cc
->encoding
, SPC_INDIRECT_DATA_OBJID
, attr
->rgValue
->pbData
, attr
->rgValue
->cbData
, 0, member
->pIndirectData
, &size
);
736 /* this object id should probably be handled in CryptCATEnumerateAttr */
737 FIXME("unhandled object id \"%s\"\n", attr
->pszObjId
);
740 if (!member
->sEncodedMemberInfo
.cbData
|| !member
->sEncodedIndirectData
.cbData
)
742 ERR("Corrupted catalog entry?\n");
743 SetLastError(CRYPT_E_ATTRIBUTES_MISSING
);
746 size
= (2 * member
->pIndirectData
->Digest
.cbData
+ 1) * sizeof(WCHAR
);
747 if (member
->pwszReferenceTag
)
748 member
->pwszReferenceTag
= HeapReAlloc(GetProcessHeap(), 0, member
->pwszReferenceTag
, size
);
750 member
->pwszReferenceTag
= HeapAlloc(GetProcessHeap(), 0, size
);
752 if (!member
->pwszReferenceTag
)
754 SetLastError(ERROR_OUTOFMEMORY
);
757 /* FIXME: reference tag is usually the file hash but doesn't have to be */
758 for (i
= 0; i
< member
->pIndirectData
->Digest
.cbData
; i
++)
762 sub
= member
->pIndirectData
->Digest
.pbData
[i
] >> 4;
763 member
->pwszReferenceTag
[i
* 2] = (sub
< 10 ? '0' + sub
: 'A' + sub
- 10);
764 sub
= member
->pIndirectData
->Digest
.pbData
[i
] & 0xf;
765 member
->pwszReferenceTag
[i
* 2 + 1] = (sub
< 10 ? '0' + sub
: 'A' + sub
- 10);
767 member
->pwszReferenceTag
[i
* 2] = 0;
771 HeapFree(GetProcessHeap(), 0, member
->pIndirectData
);
772 HeapFree(GetProcessHeap(), 0, member
->pwszReferenceTag
);
773 HeapFree(GetProcessHeap(), 0, member
);
777 static CTL_INFO
*decode_inner_content(HANDLE hmsg
, DWORD encoding
, DWORD
*len
)
782 CTL_INFO
*inner
= NULL
;
784 if (!CryptMsgGetParam(hmsg
, CMSG_INNER_CONTENT_TYPE_PARAM
, 0, NULL
, &size
)) return NULL
;
785 if (!(oid
= HeapAlloc(GetProcessHeap(), 0, size
)))
787 SetLastError(ERROR_OUTOFMEMORY
);
790 if (!CryptMsgGetParam(hmsg
, CMSG_INNER_CONTENT_TYPE_PARAM
, 0, oid
, &size
)) goto out
;
791 if (!CryptMsgGetParam(hmsg
, CMSG_CONTENT_PARAM
, 0, NULL
, &size
)) goto out
;
792 if (!(buffer
= HeapAlloc(GetProcessHeap(), 0, size
)))
794 SetLastError(ERROR_OUTOFMEMORY
);
797 if (!CryptMsgGetParam(hmsg
, CMSG_CONTENT_PARAM
, 0, buffer
, &size
)) goto out
;
798 if (!CryptDecodeObject(encoding
, oid
, buffer
, size
, 0, NULL
, &size
)) goto out
;
799 if (!(inner
= HeapAlloc(GetProcessHeap(), 0, size
)))
801 SetLastError(ERROR_OUTOFMEMORY
);
804 if (!CryptDecodeObject(encoding
, oid
, buffer
, size
, 0, inner
, &size
)) goto out
;
808 HeapFree(GetProcessHeap(), 0, oid
);
809 HeapFree(GetProcessHeap(), 0, buffer
);
813 /***********************************************************************
814 * CryptCATCatalogInfoFromContext (WINTRUST.@)
816 BOOL WINAPI
CryptCATCatalogInfoFromContext(HCATINFO hcatinfo
, CATALOG_INFO
*info
, DWORD flags
)
818 struct catinfo
*ci
= hcatinfo
;
820 TRACE("%p, %p, %x\n", hcatinfo
, info
, flags
);
822 if (!hcatinfo
|| hcatinfo
== INVALID_HANDLE_VALUE
|| ci
->magic
!= CATINFO_MAGIC
||
823 flags
|| !info
|| info
->cbStruct
!= sizeof(*info
))
825 SetLastError(ERROR_INVALID_PARAMETER
);
828 strcpyW(info
->wszCatalogFile
, ci
->file
);
832 /***********************************************************************
833 * CryptCATOpen (WINTRUST.@)
835 HANDLE WINAPI
CryptCATOpen(LPWSTR pwszFileName
, DWORD fdwOpenFlags
, HCRYPTPROV hProv
,
836 DWORD dwPublicVersion
, DWORD dwEncodingType
)
840 DWORD size
, flags
= OPEN_EXISTING
;
843 TRACE("%s, %x, %lx, %x, %x\n", debugstr_w(pwszFileName
), fdwOpenFlags
,
844 hProv
, dwPublicVersion
, dwEncodingType
);
848 SetLastError(ERROR_INVALID_PARAMETER
);
849 return INVALID_HANDLE_VALUE
;
852 if (!dwEncodingType
) dwEncodingType
= X509_ASN_ENCODING
| PKCS_7_ASN_ENCODING
;
854 if (fdwOpenFlags
& CRYPTCAT_OPEN_ALWAYS
) flags
|= OPEN_ALWAYS
;
855 if (fdwOpenFlags
& CRYPTCAT_OPEN_CREATENEW
) flags
|= CREATE_NEW
;
857 file
= CreateFileW(pwszFileName
, GENERIC_READ
, FILE_SHARE_READ
, NULL
, flags
, 0, NULL
);
858 if (file
== INVALID_HANDLE_VALUE
) return INVALID_HANDLE_VALUE
;
860 size
= GetFileSize(file
, NULL
);
861 if (!(buffer
= HeapAlloc(GetProcessHeap(), 0, size
)))
864 SetLastError(ERROR_OUTOFMEMORY
);
865 return INVALID_HANDLE_VALUE
;
867 if (!(hmsg
= CryptMsgOpenToDecode(dwEncodingType
, 0, 0, hProv
, NULL
, NULL
)))
870 HeapFree(GetProcessHeap(), 0, buffer
);
871 return INVALID_HANDLE_VALUE
;
873 if (!ReadFile(file
, buffer
, size
, &size
, NULL
) || !CryptMsgUpdate(hmsg
, buffer
, size
, TRUE
))
876 HeapFree(GetProcessHeap(), 0, buffer
);
878 return INVALID_HANDLE_VALUE
;
880 HeapFree(GetProcessHeap(), 0, buffer
);
883 size
= sizeof(DWORD
);
884 if (!(cc
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*cc
))))
887 SetLastError(ERROR_OUTOFMEMORY
);
888 return INVALID_HANDLE_VALUE
;
892 cc
->encoding
= dwEncodingType
;
893 if (CryptMsgGetParam(hmsg
, CMSG_ATTR_CERT_COUNT_PARAM
, 0, &cc
->attr_count
, &size
))
898 for (i
= 0; i
< cc
->attr_count
; i
++)
900 if (!CryptMsgGetParam(hmsg
, CMSG_ATTR_CERT_PARAM
, i
, NULL
, &size
))
903 return INVALID_HANDLE_VALUE
;
907 if (!(cc
->attr
= HeapAlloc(GetProcessHeap(), 0, sizeof(*cc
->attr
) * cc
->attr_count
+ sum
)))
910 SetLastError(ERROR_OUTOFMEMORY
);
911 return INVALID_HANDLE_VALUE
;
913 p
= (BYTE
*)(cc
->attr
+ cc
->attr_count
);
914 for (i
= 0; i
< cc
->attr_count
; i
++)
916 if (!CryptMsgGetParam(hmsg
, CMSG_ATTR_CERT_PARAM
, i
, NULL
, &size
))
919 HeapFree(GetProcessHeap(), 0, cc
->attr
);
920 return INVALID_HANDLE_VALUE
;
922 if (!CryptMsgGetParam(hmsg
, CMSG_ATTR_CERT_PARAM
, i
, p
, &size
))
925 HeapFree(GetProcessHeap(), 0, cc
->attr
);
926 return INVALID_HANDLE_VALUE
;
930 cc
->inner
= decode_inner_content(hmsg
, dwEncodingType
, &cc
->inner_len
);
931 if (!cc
->inner
|| !CryptSIPRetrieveSubjectGuid(pwszFileName
, NULL
, &cc
->subject
))
934 HeapFree(GetProcessHeap(), 0, cc
->attr
);
935 HeapFree(GetProcessHeap(), 0, cc
->inner
);
936 HeapFree(GetProcessHeap(), 0, cc
);
937 return INVALID_HANDLE_VALUE
;
939 cc
->magic
= CRYPTCAT_MAGIC
;
942 return INVALID_HANDLE_VALUE
;
945 /***********************************************************************
946 * CryptSIPCreateIndirectData (WINTRUST.@)
948 BOOL WINAPI
CryptSIPCreateIndirectData(SIP_SUBJECTINFO
* pSubjectInfo
, DWORD
* pcbIndirectData
,
949 SIP_INDIRECT_DATA
* pIndirectData
)
951 FIXME("(%p %p %p) stub\n", pSubjectInfo
, pcbIndirectData
, pIndirectData
);
957 /***********************************************************************
958 * CryptCATCDFClose (WINTRUST.@)
960 BOOL WINAPI
CryptCATCDFClose(CRYPTCATCDF
*pCDF
)
962 FIXME("(%p) stub\n", pCDF
);
967 /***********************************************************************
968 * CryptCATCDFEnumCatAttributes (WINTRUST.@)
970 CRYPTCATATTRIBUTE
* WINAPI
CryptCATCDFEnumCatAttributes(CRYPTCATCDF
*pCDF
,
971 CRYPTCATATTRIBUTE
*pPrevAttr
,
972 PFN_CDF_PARSE_ERROR_CALLBACK pfnParseError
)
974 FIXME("(%p %p %p) stub\n", pCDF
, pPrevAttr
, pfnParseError
);
979 /***********************************************************************
980 * CryptCATCDFEnumMembersByCDFTagEx (WINTRUST.@)
982 LPWSTR WINAPI
CryptCATCDFEnumMembersByCDFTagEx(CRYPTCATCDF
*pCDF
, LPWSTR pwszPrevCDFTag
,
983 PFN_CDF_PARSE_ERROR_CALLBACK pfnParseError
,
984 CRYPTCATMEMBER
**ppMember
, BOOL fContinueOnError
,
987 FIXME("(%p %s %p %p %d %p) stub\n", pCDF
, debugstr_w(pwszPrevCDFTag
), pfnParseError
,
988 ppMember
, fContinueOnError
, pvReserved
);
993 /***********************************************************************
994 * CryptCATCDFOpen (WINTRUST.@)
996 CRYPTCATCDF
* WINAPI
CryptCATCDFOpen(LPWSTR pwszFilePath
,
997 PFN_CDF_PARSE_ERROR_CALLBACK pfnParseError
)
999 FIXME("(%s %p) stub\n", debugstr_w(pwszFilePath
), pfnParseError
);
1004 static BOOL
WINTRUST_GetSignedMsgFromPEFile(SIP_SUBJECTINFO
*pSubjectInfo
,
1005 DWORD
*pdwEncodingType
, DWORD dwIndex
, DWORD
*pcbSignedDataMsg
,
1006 BYTE
*pbSignedDataMsg
)
1009 WIN_CERTIFICATE
*pCert
= NULL
;
1012 TRACE("(%p %p %d %p %p)\n", pSubjectInfo
, pdwEncodingType
, dwIndex
,
1013 pcbSignedDataMsg
, pbSignedDataMsg
);
1015 if(pSubjectInfo
->hFile
&& pSubjectInfo
->hFile
!=INVALID_HANDLE_VALUE
)
1016 file
= pSubjectInfo
->hFile
;
1019 file
= CreateFileW(pSubjectInfo
->pwsFileName
, GENERIC_READ
,
1020 FILE_SHARE_READ
|FILE_SHARE_WRITE
, NULL
, OPEN_EXISTING
, 0, NULL
);
1021 if(file
== INVALID_HANDLE_VALUE
)
1025 if (!pbSignedDataMsg
)
1027 WIN_CERTIFICATE cert
;
1029 /* app hasn't passed buffer, just get the length */
1030 ret
= ImageGetCertificateHeader(file
, dwIndex
, &cert
);
1033 switch (cert
.wCertificateType
)
1035 case WIN_CERT_TYPE_X509
:
1036 case WIN_CERT_TYPE_PKCS_SIGNED_DATA
:
1037 *pcbSignedDataMsg
= cert
.dwLength
;
1040 WARN("unknown certificate type %d\n", cert
.wCertificateType
);
1049 ret
= ImageGetCertificateData(file
, dwIndex
, NULL
, &len
);
1050 if (GetLastError() != ERROR_INSUFFICIENT_BUFFER
)
1052 pCert
= HeapAlloc(GetProcessHeap(), 0, len
);
1058 ret
= ImageGetCertificateData(file
, dwIndex
, pCert
, &len
);
1061 pCert
->dwLength
-= FIELD_OFFSET(WIN_CERTIFICATE
, bCertificate
);
1062 if (*pcbSignedDataMsg
< pCert
->dwLength
)
1064 *pcbSignedDataMsg
= pCert
->dwLength
;
1065 SetLastError(ERROR_INSUFFICIENT_BUFFER
);
1070 memcpy(pbSignedDataMsg
, pCert
->bCertificate
, pCert
->dwLength
);
1071 *pcbSignedDataMsg
= pCert
->dwLength
;
1072 switch (pCert
->wCertificateType
)
1074 case WIN_CERT_TYPE_X509
:
1075 *pdwEncodingType
= X509_ASN_ENCODING
;
1077 case WIN_CERT_TYPE_PKCS_SIGNED_DATA
:
1078 *pdwEncodingType
= X509_ASN_ENCODING
| PKCS_7_ASN_ENCODING
;
1081 WARN("don't know what to do for encoding type %d\n",
1082 pCert
->wCertificateType
);
1083 *pdwEncodingType
= 0;
1089 if(pSubjectInfo
->hFile
!= file
)
1091 HeapFree(GetProcessHeap(), 0, pCert
);
1095 static BOOL
WINTRUST_PutSignedMsgToPEFile(SIP_SUBJECTINFO
* pSubjectInfo
, DWORD pdwEncodingType
,
1096 DWORD
* pdwIndex
, DWORD cbSignedDataMsg
, BYTE
* pbSignedDataMsg
)
1098 WIN_CERTIFICATE
*cert
;
1103 if(pSubjectInfo
->hFile
&& pSubjectInfo
->hFile
!=INVALID_HANDLE_VALUE
)
1104 file
= pSubjectInfo
->hFile
;
1107 file
= CreateFileW(pSubjectInfo
->pwsFileName
, GENERIC_READ
|GENERIC_WRITE
,
1108 FILE_SHARE_READ
|FILE_SHARE_WRITE
, NULL
, OPEN_EXISTING
, 0, NULL
);
1109 if(file
== INVALID_HANDLE_VALUE
)
1113 /* int aligned WIN_CERTIFICATE structure with cbSignedDataMsg+1 bytes of data */
1114 size
= FIELD_OFFSET(WIN_CERTIFICATE
, bCertificate
[cbSignedDataMsg
+4]) & (~3);
1115 cert
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, size
);
1119 cert
->dwLength
= size
;
1120 cert
->wRevision
= WIN_CERT_REVISION_2_0
;
1121 cert
->wCertificateType
= WIN_CERT_TYPE_PKCS_SIGNED_DATA
;
1122 memcpy(cert
->bCertificate
, pbSignedDataMsg
, cbSignedDataMsg
);
1123 ret
= ImageAddCertificate(file
, cert
, pdwIndex
);
1125 HeapFree(GetProcessHeap(), 0, cert
);
1126 if(file
!= pSubjectInfo
->hFile
)
1131 /* structure offsets */
1132 #define cfhead_Signature (0x00)
1133 #define cfhead_CabinetSize (0x08)
1134 #define cfhead_MinorVersion (0x18)
1135 #define cfhead_MajorVersion (0x19)
1136 #define cfhead_Flags (0x1E)
1137 #define cfhead_SIZEOF (0x24)
1138 #define cfheadext_HeaderReserved (0x00)
1139 #define cfheadext_SIZEOF (0x04)
1140 #define cfsigninfo_CertOffset (0x04)
1141 #define cfsigninfo_CertSize (0x08)
1142 #define cfsigninfo_SIZEOF (0x0C)
1145 #define cfheadRESERVE_PRESENT (0x0004)
1147 /* endian-neutral reading of little-endian data */
1148 #define EndGetI32(a) ((((a)[3])<<24)|(((a)[2])<<16)|(((a)[1])<<8)|((a)[0]))
1149 #define EndGetI16(a) ((((a)[1])<<8)|((a)[0]))
1151 /* For documentation purposes only: this is the structure in the reserved
1152 * area of a signed cabinet file. The cert offset indicates where in the
1153 * cabinet file the signature resides, and the count indicates its size.
1155 typedef struct _CAB_SIGNINFO
1157 WORD unk0
; /* always 0? */
1158 WORD unk1
; /* always 0x0010? */
1161 } CAB_SIGNINFO
, *PCAB_SIGNINFO
;
1163 static BOOL
WINTRUST_GetSignedMsgFromCabFile(SIP_SUBJECTINFO
*pSubjectInfo
,
1164 DWORD
*pdwEncodingType
, DWORD dwIndex
, DWORD
*pcbSignedDataMsg
,
1165 BYTE
*pbSignedDataMsg
)
1168 LONG base_offset
, cabsize
;
1171 DWORD cert_offset
, cert_size
, dwRead
;
1173 TRACE("(%p %p %d %p %p)\n", pSubjectInfo
, pdwEncodingType
, dwIndex
,
1174 pcbSignedDataMsg
, pbSignedDataMsg
);
1176 /* get basic offset & size info */
1177 base_offset
= SetFilePointer(pSubjectInfo
->hFile
, 0L, NULL
, SEEK_CUR
);
1179 if (SetFilePointer(pSubjectInfo
->hFile
, 0, NULL
, SEEK_END
) == INVALID_SET_FILE_POINTER
)
1181 TRACE("seek error\n");
1185 cabsize
= SetFilePointer(pSubjectInfo
->hFile
, 0L, NULL
, SEEK_CUR
);
1186 if ((cabsize
== -1) || (base_offset
== -1) ||
1187 (SetFilePointer(pSubjectInfo
->hFile
, 0, NULL
, SEEK_SET
) == INVALID_SET_FILE_POINTER
))
1189 TRACE("seek error\n");
1193 /* read in the CFHEADER */
1194 if (!ReadFile(pSubjectInfo
->hFile
, buf
, cfhead_SIZEOF
, &dwRead
, NULL
) ||
1195 dwRead
!= cfhead_SIZEOF
)
1197 TRACE("reading header failed\n");
1201 /* check basic MSCF signature */
1202 if (EndGetI32(buf
+cfhead_Signature
) != 0x4643534d)
1204 WARN("cabinet signature not present\n");
1208 /* Ignore the number of folders and files and the set and cabinet IDs */
1210 /* check the header revision */
1211 if ((buf
[cfhead_MajorVersion
] > 1) ||
1212 (buf
[cfhead_MajorVersion
] == 1 && buf
[cfhead_MinorVersion
] > 3))
1214 WARN("cabinet format version > 1.3\n");
1218 /* pull the flags out */
1219 flags
= EndGetI16(buf
+cfhead_Flags
);
1221 if (!(flags
& cfheadRESERVE_PRESENT
))
1223 TRACE("no header present, not signed\n");
1227 if (!ReadFile(pSubjectInfo
->hFile
, buf
, cfheadext_SIZEOF
, &dwRead
, NULL
) ||
1228 dwRead
!= cfheadext_SIZEOF
)
1230 ERR("bunk reserve-sizes?\n");
1234 header_resv
= EndGetI16(buf
+cfheadext_HeaderReserved
);
1237 TRACE("no header_resv, not signed\n");
1240 else if (header_resv
< cfsigninfo_SIZEOF
)
1242 TRACE("header_resv too small, not signed\n");
1246 if (header_resv
> 60000)
1248 WARN("WARNING; header reserved space > 60000\n");
1251 if (!ReadFile(pSubjectInfo
->hFile
, buf
, cfsigninfo_SIZEOF
, &dwRead
, NULL
) ||
1252 dwRead
!= cfsigninfo_SIZEOF
)
1254 ERR("couldn't read reserve\n");
1258 cert_offset
= EndGetI32(buf
+cfsigninfo_CertOffset
);
1259 TRACE("cert_offset: %d\n", cert_offset
);
1260 cert_size
= EndGetI32(buf
+cfsigninfo_CertSize
);
1261 TRACE("cert_size: %d\n", cert_size
);
1263 /* The redundant checks are to avoid wraparound */
1264 if (cert_offset
> cabsize
|| cert_size
> cabsize
||
1265 cert_offset
+ cert_size
> cabsize
)
1267 WARN("offset beyond file, not attempting to read\n");
1271 SetFilePointer(pSubjectInfo
->hFile
, base_offset
, NULL
, SEEK_SET
);
1272 if (!pbSignedDataMsg
)
1274 *pcbSignedDataMsg
= cert_size
;
1277 if (*pcbSignedDataMsg
< cert_size
)
1279 *pcbSignedDataMsg
= cert_size
;
1280 SetLastError(ERROR_INSUFFICIENT_BUFFER
);
1283 if (SetFilePointer(pSubjectInfo
->hFile
, cert_offset
, NULL
, SEEK_SET
) == INVALID_SET_FILE_POINTER
)
1285 ERR("couldn't seek to cert location\n");
1288 if (!ReadFile(pSubjectInfo
->hFile
, pbSignedDataMsg
, cert_size
, &dwRead
,
1289 NULL
) || dwRead
!= cert_size
)
1291 ERR("couldn't read cert\n");
1292 SetFilePointer(pSubjectInfo
->hFile
, base_offset
, NULL
, SEEK_SET
);
1295 /* The encoding of the files I've seen appears to be in ASN.1
1296 * format, and there isn't a field indicating the type, so assume it
1299 *pdwEncodingType
= X509_ASN_ENCODING
| PKCS_7_ASN_ENCODING
;
1300 /* Restore base offset */
1301 SetFilePointer(pSubjectInfo
->hFile
, base_offset
, NULL
, SEEK_SET
);
1305 static BOOL
WINTRUST_GetSignedMsgFromCatFile(SIP_SUBJECTINFO
*pSubjectInfo
,
1306 DWORD
*pdwEncodingType
, DWORD dwIndex
, DWORD
*pcbSignedDataMsg
,
1307 BYTE
*pbSignedDataMsg
)
1311 TRACE("(%p %p %d %p %p)\n", pSubjectInfo
, pdwEncodingType
, dwIndex
,
1312 pcbSignedDataMsg
, pbSignedDataMsg
);
1314 if (!pbSignedDataMsg
)
1316 *pcbSignedDataMsg
= GetFileSize(pSubjectInfo
->hFile
, NULL
);
1321 DWORD len
= GetFileSize(pSubjectInfo
->hFile
, NULL
);
1323 if (*pcbSignedDataMsg
< len
)
1325 *pcbSignedDataMsg
= len
;
1326 SetLastError(ERROR_INSUFFICIENT_BUFFER
);
1331 ret
= ReadFile(pSubjectInfo
->hFile
, pbSignedDataMsg
, len
,
1332 pcbSignedDataMsg
, NULL
);
1334 *pdwEncodingType
= X509_ASN_ENCODING
| PKCS_7_ASN_ENCODING
;
1340 /* GUIDs used by CryptSIPGetSignedDataMsg and CryptSIPPutSignedDataMsg */
1341 static const GUID unknown
= { 0xC689AAB8, 0x8E78, 0x11D0, { 0x8C,0x47,
1342 0x00,0xC0,0x4F,0xC2,0x95,0xEE } };
1343 static const GUID cabGUID
= { 0xC689AABA, 0x8E78, 0x11D0, { 0x8C,0x47,
1344 0x00,0xC0,0x4F,0xC2,0x95,0xEE } };
1345 static const GUID catGUID
= { 0xDE351A43, 0x8E59, 0x11D0, { 0x8C,0x47,
1346 0x00,0xC0,0x4F,0xC2,0x95,0xEE }};
1348 /***********************************************************************
1349 * CryptSIPGetSignedDataMsg (WINTRUST.@)
1351 BOOL WINAPI
CryptSIPGetSignedDataMsg(SIP_SUBJECTINFO
* pSubjectInfo
, DWORD
* pdwEncodingType
,
1352 DWORD dwIndex
, DWORD
* pcbSignedDataMsg
, BYTE
* pbSignedDataMsg
)
1356 TRACE("(%p %p %d %p %p)\n", pSubjectInfo
, pdwEncodingType
, dwIndex
,
1357 pcbSignedDataMsg
, pbSignedDataMsg
);
1361 SetLastError(ERROR_INVALID_PARAMETER
);
1365 if (!memcmp(pSubjectInfo
->pgSubjectType
, &unknown
, sizeof(unknown
)))
1366 ret
= WINTRUST_GetSignedMsgFromPEFile(pSubjectInfo
, pdwEncodingType
,
1367 dwIndex
, pcbSignedDataMsg
, pbSignedDataMsg
);
1368 else if (!memcmp(pSubjectInfo
->pgSubjectType
, &cabGUID
, sizeof(cabGUID
)))
1369 ret
= WINTRUST_GetSignedMsgFromCabFile(pSubjectInfo
, pdwEncodingType
,
1370 dwIndex
, pcbSignedDataMsg
, pbSignedDataMsg
);
1371 else if (!memcmp(pSubjectInfo
->pgSubjectType
, &catGUID
, sizeof(catGUID
)))
1372 ret
= WINTRUST_GetSignedMsgFromCatFile(pSubjectInfo
, pdwEncodingType
,
1373 dwIndex
, pcbSignedDataMsg
, pbSignedDataMsg
);
1376 FIXME("unimplemented for subject type %s\n",
1377 debugstr_guid(pSubjectInfo
->pgSubjectType
));
1381 TRACE("returning %d\n", ret
);
1385 /***********************************************************************
1386 * CryptSIPPutSignedDataMsg (WINTRUST.@)
1388 BOOL WINAPI
CryptSIPPutSignedDataMsg(SIP_SUBJECTINFO
* pSubjectInfo
, DWORD pdwEncodingType
,
1389 DWORD
* pdwIndex
, DWORD cbSignedDataMsg
, BYTE
* pbSignedDataMsg
)
1391 TRACE("(%p %d %p %d %p)\n", pSubjectInfo
, pdwEncodingType
, pdwIndex
,
1392 cbSignedDataMsg
, pbSignedDataMsg
);
1395 SetLastError(ERROR_INVALID_PARAMETER
);
1399 if(!memcmp(pSubjectInfo
->pgSubjectType
, &unknown
, sizeof(unknown
)))
1400 return WINTRUST_PutSignedMsgToPEFile(pSubjectInfo
, pdwEncodingType
,
1401 pdwIndex
, cbSignedDataMsg
, pbSignedDataMsg
);
1403 FIXME("unimplemented for subject type %s\n",
1404 debugstr_guid(pSubjectInfo
->pgSubjectType
));
1409 /***********************************************************************
1410 * CryptSIPRemoveSignedDataMsg (WINTRUST.@)
1412 BOOL WINAPI
CryptSIPRemoveSignedDataMsg(SIP_SUBJECTINFO
* pSubjectInfo
,
1415 FIXME("(%p %d) stub\n", pSubjectInfo
, dwIndex
);
1420 /***********************************************************************
1421 * CryptSIPVerifyIndirectData (WINTRUST.@)
1423 BOOL WINAPI
CryptSIPVerifyIndirectData(SIP_SUBJECTINFO
* pSubjectInfo
,
1424 SIP_INDIRECT_DATA
* pIndirectData
)
1426 FIXME("(%p %p) stub\n", pSubjectInfo
, pIndirectData
);