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
35 #include "wine/debug.h"
37 WINE_DEFAULT_DEBUG_CHANNEL(wintrust
);
39 #define CATADMIN_MAGIC 0x43415441 /* 'CATA' */
40 #define CRYPTCAT_MAGIC 0x43415443 /* 'CATC' */
41 #define CATINFO_MAGIC 0x43415449 /* 'CATI' */
52 CRYPTCATATTRIBUTE
*attr
;
68 static HCATINFO
create_catinfo(const WCHAR
*filename
)
72 if (!(ci
= HeapAlloc(GetProcessHeap(), 0, sizeof(*ci
))))
74 SetLastError(ERROR_OUTOFMEMORY
);
75 return INVALID_HANDLE_VALUE
;
77 lstrcpyW(ci
->file
, filename
);
78 ci
->magic
= CATINFO_MAGIC
;
82 /***********************************************************************
83 * CryptCATAdminAcquireContext (WINTRUST.@)
85 * Get a catalog administrator context handle.
88 * catAdmin [O] Pointer to the context handle.
89 * sys [I] Pointer to a GUID for the needed subsystem.
90 * dwFlags [I] Reserved.
93 * Success: TRUE. catAdmin contains the context handle.
97 BOOL WINAPI
CryptCATAdminAcquireContext(HCATADMIN
*catAdmin
,
98 const GUID
*sys
, DWORD dwFlags
)
100 static const WCHAR catroot
[] =
101 {'\\','c','a','t','r','o','o','t',0};
102 static const WCHAR fmt
[] =
103 {'%','s','\\','{','%','0','8','x','-','%','0','4','x','-','%','0',
104 '4','x','-','%','0','2','x','%','0','2','x','-','%','0','2','x',
105 '%','0','2','x','%','0','2','x','%','0','2','x','%','0','2','x',
106 '%','0','2','x','}',0};
107 static const GUID defsys
=
108 {0x127d0a1d,0x4ef2,0x11d1,{0x86,0x08,0x00,0xc0,0x4f,0xc2,0x95,0xee}};
110 WCHAR catroot_dir
[MAX_PATH
];
113 TRACE("%p %s %x\n", catAdmin
, debugstr_guid(sys
), dwFlags
);
115 if (!catAdmin
|| dwFlags
)
117 SetLastError(ERROR_INVALID_PARAMETER
);
120 if (!(ca
= HeapAlloc(GetProcessHeap(), 0, sizeof(*ca
))))
122 SetLastError(ERROR_OUTOFMEMORY
);
126 GetSystemDirectoryW(catroot_dir
, MAX_PATH
);
127 lstrcatW(catroot_dir
, catroot
);
129 /* create the directory if it doesn't exist */
130 CreateDirectoryW(catroot_dir
, NULL
);
132 if (!sys
) sys
= &defsys
;
133 swprintf(ca
->path
, fmt
, catroot_dir
, sys
->Data1
, sys
->Data2
,
134 sys
->Data3
, sys
->Data4
[0], sys
->Data4
[1], sys
->Data4
[2],
135 sys
->Data4
[3], sys
->Data4
[4], sys
->Data4
[5], sys
->Data4
[6],
138 /* create the directory if it doesn't exist */
139 CreateDirectoryW(ca
->path
, NULL
);
141 ca
->magic
= CATADMIN_MAGIC
;
142 ca
->find
= INVALID_HANDLE_VALUE
;
148 /***********************************************************************
149 * CryptCATAdminAcquireContext2 (WINTRUST.@)
151 BOOL WINAPI
CryptCATAdminAcquireContext2(HCATADMIN
*catAdmin
, const GUID
*sys
, const WCHAR
*algorithm
,
152 const CERT_STRONG_SIGN_PARA
*policy
, DWORD flags
)
154 FIXME("%p %s %s %p %x stub\n", catAdmin
, debugstr_guid(sys
), debugstr_w(algorithm
), policy
, flags
);
155 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
159 /***********************************************************************
160 * CryptCATAdminAddCatalog (WINTRUST.@)
162 HCATINFO WINAPI
CryptCATAdminAddCatalog(HCATADMIN catAdmin
, PWSTR catalogFile
,
163 PWSTR selectBaseName
, DWORD flags
)
165 static const WCHAR slashW
[] = {'\\',0};
166 struct catadmin
*ca
= catAdmin
;
171 TRACE("%p %s %s %d\n", catAdmin
, debugstr_w(catalogFile
),
172 debugstr_w(selectBaseName
), flags
);
176 FIXME("NULL basename not handled\n");
177 SetLastError(ERROR_INVALID_PARAMETER
);
180 if (!ca
|| ca
->magic
!= CATADMIN_MAGIC
|| !catalogFile
|| flags
)
182 SetLastError(ERROR_INVALID_PARAMETER
);
186 len
= lstrlenW(ca
->path
) + lstrlenW(selectBaseName
) + 2;
187 if (!(target
= HeapAlloc(GetProcessHeap(), 0, len
* sizeof(WCHAR
))))
189 SetLastError(ERROR_OUTOFMEMORY
);
192 lstrcpyW(target
, ca
->path
);
193 lstrcatW(target
, slashW
);
194 lstrcatW(target
, selectBaseName
);
196 if (!CopyFileW(catalogFile
, target
, FALSE
))
198 HeapFree(GetProcessHeap(), 0, target
);
201 SetFileAttributesW(target
, FILE_ATTRIBUTE_SYSTEM
);
203 if (!(ci
= HeapAlloc(GetProcessHeap(), 0, sizeof(*ci
))))
205 HeapFree(GetProcessHeap(), 0, target
);
206 SetLastError(ERROR_OUTOFMEMORY
);
209 ci
->magic
= CATINFO_MAGIC
;
210 lstrcpyW(ci
->file
, target
);
212 HeapFree(GetProcessHeap(), 0, target
);
216 /***********************************************************************
217 * CryptCATAdminCalcHashFromFileHandle (WINTRUST.@)
219 BOOL WINAPI
CryptCATAdminCalcHashFromFileHandle(HANDLE hFile
, DWORD
* pcbHash
,
220 BYTE
* pbHash
, DWORD dwFlags
)
224 TRACE("%p %p %p %x\n", hFile
, pcbHash
, pbHash
, dwFlags
);
226 if (!hFile
|| !pcbHash
|| dwFlags
)
228 SetLastError(ERROR_INVALID_PARAMETER
);
234 SetLastError(ERROR_INSUFFICIENT_BUFFER
);
246 if (!(buffer
= HeapAlloc(GetProcessHeap(), 0, 4096)))
248 SetLastError(ERROR_OUTOFMEMORY
);
251 ret
= CryptAcquireContextW(&prov
, NULL
, MS_DEF_PROV_W
, PROV_RSA_FULL
, CRYPT_VERIFYCONTEXT
);
254 HeapFree(GetProcessHeap(), 0, buffer
);
257 ret
= CryptCreateHash(prov
, CALG_SHA1
, 0, 0, &hash
);
260 HeapFree(GetProcessHeap(), 0, buffer
);
261 CryptReleaseContext(prov
, 0);
264 while ((ret
= ReadFile(hFile
, buffer
, 4096, &bytes_read
, NULL
)) && bytes_read
)
266 CryptHashData(hash
, buffer
, bytes_read
, 0);
268 if (ret
) ret
= CryptGetHashParam(hash
, HP_HASHVAL
, pbHash
, pcbHash
, 0);
270 HeapFree(GetProcessHeap(), 0, buffer
);
271 CryptDestroyHash(hash
);
272 CryptReleaseContext(prov
, 0);
277 /***********************************************************************
278 * CryptCATAdminEnumCatalogFromHash (WINTRUST.@)
280 HCATINFO WINAPI
CryptCATAdminEnumCatalogFromHash(HCATADMIN hCatAdmin
, BYTE
* pbHash
,
281 DWORD cbHash
, DWORD dwFlags
,
282 HCATINFO
* phPrevCatInfo
)
284 static const WCHAR slashW
[] = {'\\',0};
285 static const WCHAR globW
[] = {'\\','*','.','c','a','t',0};
287 struct catadmin
*ca
= hCatAdmin
;
288 WIN32_FIND_DATAW data
;
289 HCATINFO prev
= NULL
;
294 TRACE("%p %p %d %x %p\n", hCatAdmin
, pbHash
, cbHash
, dwFlags
, phPrevCatInfo
);
296 if (!ca
|| ca
->magic
!= CATADMIN_MAGIC
|| !pbHash
|| cbHash
!= 20 || dwFlags
)
298 SetLastError(ERROR_INVALID_PARAMETER
);
301 if (phPrevCatInfo
) prev
= *phPrevCatInfo
;
303 ret
= CryptAcquireContextW(&prov
, NULL
, MS_DEF_PROV_W
, PROV_RSA_FULL
, CRYPT_VERIFYCONTEXT
);
304 if (!ret
) return NULL
;
310 size
= lstrlenW(ca
->path
) * sizeof(WCHAR
) + sizeof(globW
);
311 if (!(path
= HeapAlloc(GetProcessHeap(), 0, size
)))
313 CryptReleaseContext(prov
, 0);
314 SetLastError(ERROR_OUTOFMEMORY
);
317 lstrcpyW(path
, ca
->path
);
318 lstrcatW(path
, globW
);
321 ca
->find
= FindFirstFileW(path
, &data
);
323 HeapFree(GetProcessHeap(), 0, path
);
324 if (ca
->find
== INVALID_HANDLE_VALUE
)
326 CryptReleaseContext(prov
, 0);
330 else if (!FindNextFileW(ca
->find
, &data
))
332 CryptCATAdminReleaseCatalogContext(hCatAdmin
, prev
, 0);
333 CryptReleaseContext(prov
, 0);
340 CRYPTCATMEMBER
*member
= NULL
;
344 size
= (lstrlenW(ca
->path
) + lstrlenW(data
.cFileName
) + 2) * sizeof(WCHAR
);
345 if (!(filename
= HeapAlloc(GetProcessHeap(), 0, size
)))
347 SetLastError(ERROR_OUTOFMEMORY
);
350 lstrcpyW(filename
, ca
->path
);
351 lstrcatW(filename
, slashW
);
352 lstrcatW(filename
, data
.cFileName
);
354 hcat
= CryptCATOpen(filename
, CRYPTCAT_OPEN_EXISTING
, prov
, 0, 0);
355 if (hcat
== INVALID_HANDLE_VALUE
)
357 WARN("couldn't open %s (%u)\n", debugstr_w(filename
), GetLastError());
360 while ((member
= CryptCATEnumerateMember(hcat
, member
)))
362 if (member
->pIndirectData
->Digest
.cbData
!= cbHash
)
364 WARN("amount of hash bytes differs: %u/%u\n", member
->pIndirectData
->Digest
.cbData
, cbHash
);
367 if (!memcmp(member
->pIndirectData
->Digest
.pbData
, pbHash
, cbHash
))
369 TRACE("file %s matches\n", debugstr_w(data
.cFileName
));
372 CryptReleaseContext(prov
, 0);
376 ca
->find
= INVALID_HANDLE_VALUE
;
378 ci
= create_catinfo(filename
);
379 HeapFree(GetProcessHeap(), 0, filename
);
384 HeapFree(GetProcessHeap(), 0, filename
);
386 if (!FindNextFileW(ca
->find
, &data
))
389 ca
->find
= INVALID_HANDLE_VALUE
;
390 CryptReleaseContext(prov
, 0);
397 /***********************************************************************
398 * CryptCATAdminReleaseCatalogContext (WINTRUST.@)
400 * Release a catalog context handle.
403 * hCatAdmin [I] Context handle.
404 * hCatInfo [I] Catalog handle.
405 * dwFlags [I] Reserved.
412 BOOL WINAPI
CryptCATAdminReleaseCatalogContext(HCATADMIN hCatAdmin
,
416 struct catinfo
*ci
= hCatInfo
;
417 struct catadmin
*ca
= hCatAdmin
;
419 TRACE("%p %p %x\n", hCatAdmin
, hCatInfo
, dwFlags
);
421 if (!ca
|| ca
->magic
!= CATADMIN_MAGIC
|| !ci
|| ci
->magic
!= CATINFO_MAGIC
)
423 SetLastError(ERROR_INVALID_PARAMETER
);
427 return HeapFree(GetProcessHeap(), 0, ci
);
430 /***********************************************************************
431 * CryptCATAdminReleaseContext (WINTRUST.@)
433 * Release a catalog administrator context handle.
436 * catAdmin [I] Context handle.
437 * dwFlags [I] Reserved.
444 BOOL WINAPI
CryptCATAdminReleaseContext(HCATADMIN hCatAdmin
, DWORD dwFlags
)
446 struct catadmin
*ca
= hCatAdmin
;
448 TRACE("%p %x\n", hCatAdmin
, dwFlags
);
450 if (!ca
|| ca
->magic
!= CATADMIN_MAGIC
)
452 SetLastError(ERROR_INVALID_PARAMETER
);
455 if (ca
->find
!= INVALID_HANDLE_VALUE
) FindClose(ca
->find
);
457 return HeapFree(GetProcessHeap(), 0, ca
);
460 /***********************************************************************
461 * CryptCATAdminRemoveCatalog (WINTRUST.@)
463 * Remove a catalog file.
466 * catAdmin [I] Context handle.
467 * pwszCatalogFile [I] Catalog file.
468 * dwFlags [I] Reserved.
475 BOOL WINAPI
CryptCATAdminRemoveCatalog(HCATADMIN hCatAdmin
, LPCWSTR pwszCatalogFile
, DWORD dwFlags
)
477 struct catadmin
*ca
= hCatAdmin
;
479 TRACE("%p %s %x\n", hCatAdmin
, debugstr_w(pwszCatalogFile
), dwFlags
);
481 if (!ca
|| ca
->magic
!= CATADMIN_MAGIC
)
483 SetLastError(ERROR_INVALID_PARAMETER
);
487 /* Only delete when there is a filename and no path */
488 if (pwszCatalogFile
&& pwszCatalogFile
[0] != 0 &&
489 !wcschr(pwszCatalogFile
, '\\') && !wcschr(pwszCatalogFile
, '/') &&
490 !wcschr(pwszCatalogFile
, ':'))
492 static const WCHAR slashW
[] = {'\\',0};
496 len
= lstrlenW(ca
->path
) + lstrlenW(pwszCatalogFile
) + 2;
497 if (!(target
= HeapAlloc(GetProcessHeap(), 0, len
* sizeof(WCHAR
))))
499 SetLastError(ERROR_OUTOFMEMORY
);
502 lstrcpyW(target
, ca
->path
);
503 lstrcatW(target
, slashW
);
504 lstrcatW(target
, pwszCatalogFile
);
508 HeapFree(GetProcessHeap(), 0, target
);
514 /***********************************************************************
515 * CryptCATAdminResolveCatalogPath (WINTRUST.@)
517 BOOL WINAPI
CryptCATAdminResolveCatalogPath(HCATADMIN hcatadmin
, WCHAR
*catalog_file
,
518 CATALOG_INFO
*info
, DWORD flags
)
520 static const WCHAR slashW
[] = {'\\',0};
521 struct catadmin
*ca
= hcatadmin
;
523 TRACE("%p %s %p %x\n", hcatadmin
, debugstr_w(catalog_file
), info
, flags
);
525 if (!ca
|| ca
->magic
!= CATADMIN_MAGIC
|| !info
|| info
->cbStruct
!= sizeof(*info
) || flags
)
527 SetLastError(ERROR_INVALID_PARAMETER
);
530 lstrcpyW(info
->wszCatalogFile
, ca
->path
);
531 lstrcatW(info
->wszCatalogFile
, slashW
);
532 lstrcatW(info
->wszCatalogFile
, catalog_file
);
537 /***********************************************************************
538 * CryptCATClose (WINTRUST.@)
540 BOOL WINAPI
CryptCATClose(HANDLE hCatalog
)
542 struct cryptcat
*cc
= hCatalog
;
544 TRACE("(%p)\n", hCatalog
);
546 if (!hCatalog
|| hCatalog
== INVALID_HANDLE_VALUE
|| cc
->magic
!= CRYPTCAT_MAGIC
)
548 SetLastError(ERROR_INVALID_PARAMETER
);
551 HeapFree(GetProcessHeap(), 0, cc
->attr
);
552 HeapFree(GetProcessHeap(), 0, cc
->inner
);
553 CryptMsgClose(cc
->msg
);
556 HeapFree(GetProcessHeap(), 0, cc
);
560 /***********************************************************************
561 * CryptCATGetAttrInfo (WINTRUST.@)
563 CRYPTCATATTRIBUTE
* WINAPI
CryptCATGetAttrInfo(HANDLE hCatalog
, CRYPTCATMEMBER
*member
, LPWSTR tag
)
565 struct cryptcat
*cc
= hCatalog
;
567 FIXME("%p, %p, %s\n", hCatalog
, member
, debugstr_w(tag
));
569 if (!hCatalog
|| hCatalog
== INVALID_HANDLE_VALUE
|| cc
->magic
!= CRYPTCAT_MAGIC
)
571 SetLastError(ERROR_INVALID_PARAMETER
);
574 SetLastError(CRYPT_E_NOT_FOUND
);
578 /***********************************************************************
579 * CryptCATGetCatAttrInfo (WINTRUST.@)
581 CRYPTCATATTRIBUTE
* WINAPI
CryptCATGetCatAttrInfo(HANDLE hCatalog
, LPWSTR tag
)
583 struct cryptcat
*cc
= hCatalog
;
585 FIXME("%p, %s\n", hCatalog
, debugstr_w(tag
));
587 if (!hCatalog
|| hCatalog
== INVALID_HANDLE_VALUE
|| cc
->magic
!= CRYPTCAT_MAGIC
)
589 SetLastError(ERROR_INVALID_PARAMETER
);
592 SetLastError(CRYPT_E_NOT_FOUND
);
596 CRYPTCATMEMBER
* WINAPI
CryptCATGetMemberInfo(HANDLE hCatalog
, LPWSTR tag
)
598 struct cryptcat
*cc
= hCatalog
;
600 FIXME("%p, %s\n", hCatalog
, debugstr_w(tag
));
602 if (!hCatalog
|| hCatalog
== INVALID_HANDLE_VALUE
|| cc
->magic
!= CRYPTCAT_MAGIC
)
604 SetLastError(ERROR_INVALID_PARAMETER
);
607 SetLastError(CRYPT_E_NOT_FOUND
);
611 /***********************************************************************
612 * CryptCATEnumerateAttr (WINTRUST.@)
614 CRYPTCATATTRIBUTE
* WINAPI
CryptCATEnumerateAttr(HANDLE hCatalog
, CRYPTCATMEMBER
*member
, CRYPTCATATTRIBUTE
*prev
)
616 struct cryptcat
*cc
= hCatalog
;
618 FIXME("%p, %p, %p\n", hCatalog
, member
, prev
);
620 if (!hCatalog
|| hCatalog
== INVALID_HANDLE_VALUE
|| cc
->magic
!= CRYPTCAT_MAGIC
)
622 SetLastError(ERROR_INVALID_PARAMETER
);
625 SetLastError(CRYPT_E_NOT_FOUND
);
629 /***********************************************************************
630 * CryptCATEnumerateCatAttr (WINTRUST.@)
632 CRYPTCATATTRIBUTE
* WINAPI
CryptCATEnumerateCatAttr(HANDLE hCatalog
, CRYPTCATATTRIBUTE
*prev
)
634 struct cryptcat
*cc
= hCatalog
;
636 FIXME("%p, %p\n", hCatalog
, prev
);
638 if (!hCatalog
|| hCatalog
== INVALID_HANDLE_VALUE
|| cc
->magic
!= CRYPTCAT_MAGIC
)
640 SetLastError(ERROR_INVALID_PARAMETER
);
643 SetLastError(CRYPT_E_NOT_FOUND
);
647 /***********************************************************************
648 * CryptCATEnumerateMember (WINTRUST.@)
650 CRYPTCATMEMBER
* WINAPI
CryptCATEnumerateMember(HANDLE hCatalog
, CRYPTCATMEMBER
*prev
)
652 struct cryptcat
*cc
= hCatalog
;
653 CRYPTCATMEMBER
*member
= prev
;
657 TRACE("%p, %p\n", hCatalog
, prev
);
659 if (!hCatalog
|| hCatalog
== INVALID_HANDLE_VALUE
|| cc
->magic
!= CRYPTCAT_MAGIC
)
661 SetLastError(ERROR_INVALID_PARAMETER
);
665 /* dumping the contents makes me think that dwReserved is the iteration number */
668 if (!(member
= HeapAlloc(GetProcessHeap(), 0, sizeof(*member
))))
670 SetLastError(ERROR_OUTOFMEMORY
);
673 member
->cbStruct
= sizeof(*member
);
674 member
->pwszFileName
= member
->pwszReferenceTag
= NULL
;
675 member
->dwReserved
= 0;
676 member
->hReserved
= NULL
;
677 member
->gSubjectType
= cc
->subject
;
678 member
->fdwMemberFlags
= 0;
679 member
->pIndirectData
= NULL
;
680 member
->dwCertVersion
= cc
->inner
->dwVersion
;
682 else member
->dwReserved
++;
684 if (member
->dwReserved
>= cc
->inner
->cCTLEntry
)
686 SetLastError(ERROR_INVALID_PARAMETER
);
690 /* list them backwards, like native */
691 entry
= &cc
->inner
->rgCTLEntry
[cc
->inner
->cCTLEntry
- member
->dwReserved
- 1];
693 member
->sEncodedIndirectData
.cbData
= member
->sEncodedMemberInfo
.cbData
= 0;
694 member
->sEncodedIndirectData
.pbData
= member
->sEncodedMemberInfo
.pbData
= NULL
;
695 HeapFree(GetProcessHeap(), 0, member
->pIndirectData
);
696 member
->pIndirectData
= NULL
;
698 for (i
= 0; i
< entry
->cAttribute
; i
++)
700 CRYPT_ATTRIBUTE
*attr
= entry
->rgAttribute
+ i
;
702 if (attr
->cValue
!= 1)
704 ERR("Can't handle attr->cValue of %u\n", attr
->cValue
);
707 if (!strcmp(attr
->pszObjId
, CAT_MEMBERINFO_OBJID
))
712 member
->sEncodedMemberInfo
.cbData
= attr
->rgValue
->cbData
;
713 member
->sEncodedMemberInfo
.pbData
= attr
->rgValue
->pbData
;
715 CryptDecodeObject(cc
->encoding
, CAT_MEMBERINFO_OBJID
, attr
->rgValue
->pbData
, attr
->rgValue
->cbData
, 0, NULL
, &size
);
717 if (!(mi
= HeapAlloc(GetProcessHeap(), 0, size
)))
719 SetLastError(ERROR_OUTOFMEMORY
);
722 ret
= CryptDecodeObject(cc
->encoding
, CAT_MEMBERINFO_OBJID
, attr
->rgValue
->pbData
, attr
->rgValue
->cbData
, 0, mi
, &size
);
727 member
->dwCertVersion
= mi
->dwCertVersion
;
728 RtlInitUnicodeString(&guid
, mi
->pwszSubjGuid
);
729 if (RtlGUIDFromString(&guid
, &member
->gSubjectType
))
731 HeapFree(GetProcessHeap(), 0, mi
);
735 HeapFree(GetProcessHeap(), 0, mi
);
736 if (!ret
) goto error
;
738 else if (!strcmp(attr
->pszObjId
, SPC_INDIRECT_DATA_OBJID
))
740 /* SPC_INDIRECT_DATA_CONTENT is equal to SIP_INDIRECT_DATA */
742 member
->sEncodedIndirectData
.cbData
= attr
->rgValue
->cbData
;
743 member
->sEncodedIndirectData
.pbData
= attr
->rgValue
->pbData
;
745 CryptDecodeObject(cc
->encoding
, SPC_INDIRECT_DATA_OBJID
, attr
->rgValue
->pbData
, attr
->rgValue
->cbData
, 0, NULL
, &size
);
747 if (!(member
->pIndirectData
= HeapAlloc(GetProcessHeap(), 0, size
)))
749 SetLastError(ERROR_OUTOFMEMORY
);
752 CryptDecodeObject(cc
->encoding
, SPC_INDIRECT_DATA_OBJID
, attr
->rgValue
->pbData
, attr
->rgValue
->cbData
, 0, member
->pIndirectData
, &size
);
755 /* this object id should probably be handled in CryptCATEnumerateAttr */
756 FIXME("unhandled object id \"%s\"\n", attr
->pszObjId
);
759 if (!member
->sEncodedMemberInfo
.cbData
|| !member
->sEncodedIndirectData
.cbData
)
761 ERR("Corrupted catalog entry?\n");
762 SetLastError(CRYPT_E_ATTRIBUTES_MISSING
);
765 size
= (2 * member
->pIndirectData
->Digest
.cbData
+ 1) * sizeof(WCHAR
);
766 if (member
->pwszReferenceTag
)
767 member
->pwszReferenceTag
= HeapReAlloc(GetProcessHeap(), 0, member
->pwszReferenceTag
, size
);
769 member
->pwszReferenceTag
= HeapAlloc(GetProcessHeap(), 0, size
);
771 if (!member
->pwszReferenceTag
)
773 SetLastError(ERROR_OUTOFMEMORY
);
776 /* FIXME: reference tag is usually the file hash but doesn't have to be */
777 for (i
= 0; i
< member
->pIndirectData
->Digest
.cbData
; i
++)
781 sub
= member
->pIndirectData
->Digest
.pbData
[i
] >> 4;
782 member
->pwszReferenceTag
[i
* 2] = (sub
< 10 ? '0' + sub
: 'A' + sub
- 10);
783 sub
= member
->pIndirectData
->Digest
.pbData
[i
] & 0xf;
784 member
->pwszReferenceTag
[i
* 2 + 1] = (sub
< 10 ? '0' + sub
: 'A' + sub
- 10);
786 member
->pwszReferenceTag
[i
* 2] = 0;
790 HeapFree(GetProcessHeap(), 0, member
->pIndirectData
);
791 HeapFree(GetProcessHeap(), 0, member
->pwszReferenceTag
);
792 HeapFree(GetProcessHeap(), 0, member
);
796 static CTL_INFO
*decode_inner_content(HANDLE hmsg
, DWORD encoding
, DWORD
*len
)
801 CTL_INFO
*inner
= NULL
;
803 if (!CryptMsgGetParam(hmsg
, CMSG_INNER_CONTENT_TYPE_PARAM
, 0, NULL
, &size
)) return NULL
;
804 if (!(oid
= HeapAlloc(GetProcessHeap(), 0, size
)))
806 SetLastError(ERROR_OUTOFMEMORY
);
809 if (!CryptMsgGetParam(hmsg
, CMSG_INNER_CONTENT_TYPE_PARAM
, 0, oid
, &size
)) goto out
;
810 if (!CryptMsgGetParam(hmsg
, CMSG_CONTENT_PARAM
, 0, NULL
, &size
)) goto out
;
811 if (!(buffer
= HeapAlloc(GetProcessHeap(), 0, size
)))
813 SetLastError(ERROR_OUTOFMEMORY
);
816 if (!CryptMsgGetParam(hmsg
, CMSG_CONTENT_PARAM
, 0, buffer
, &size
)) goto out
;
817 if (!CryptDecodeObject(encoding
, oid
, buffer
, size
, 0, NULL
, &size
)) goto out
;
818 if (!(inner
= HeapAlloc(GetProcessHeap(), 0, size
)))
820 SetLastError(ERROR_OUTOFMEMORY
);
823 if (!CryptDecodeObject(encoding
, oid
, buffer
, size
, 0, inner
, &size
)) goto out
;
827 HeapFree(GetProcessHeap(), 0, oid
);
828 HeapFree(GetProcessHeap(), 0, buffer
);
832 /***********************************************************************
833 * CryptCATCatalogInfoFromContext (WINTRUST.@)
835 BOOL WINAPI
CryptCATCatalogInfoFromContext(HCATINFO hcatinfo
, CATALOG_INFO
*info
, DWORD flags
)
837 struct catinfo
*ci
= hcatinfo
;
839 TRACE("%p, %p, %x\n", hcatinfo
, info
, flags
);
841 if (!hcatinfo
|| hcatinfo
== INVALID_HANDLE_VALUE
|| ci
->magic
!= CATINFO_MAGIC
||
842 flags
|| !info
|| info
->cbStruct
!= sizeof(*info
))
844 SetLastError(ERROR_INVALID_PARAMETER
);
847 lstrcpyW(info
->wszCatalogFile
, ci
->file
);
851 /***********************************************************************
852 * CryptCATOpen (WINTRUST.@)
854 HANDLE WINAPI
CryptCATOpen(LPWSTR pwszFileName
, DWORD fdwOpenFlags
, HCRYPTPROV hProv
,
855 DWORD dwPublicVersion
, DWORD dwEncodingType
)
859 DWORD size
, flags
= OPEN_EXISTING
;
862 TRACE("%s, %x, %lx, %x, %x\n", debugstr_w(pwszFileName
), fdwOpenFlags
,
863 hProv
, dwPublicVersion
, dwEncodingType
);
867 SetLastError(ERROR_INVALID_PARAMETER
);
868 return INVALID_HANDLE_VALUE
;
871 if (!dwEncodingType
) dwEncodingType
= X509_ASN_ENCODING
| PKCS_7_ASN_ENCODING
;
873 if (fdwOpenFlags
& CRYPTCAT_OPEN_ALWAYS
) flags
|= OPEN_ALWAYS
;
874 if (fdwOpenFlags
& CRYPTCAT_OPEN_CREATENEW
) flags
|= CREATE_NEW
;
876 file
= CreateFileW(pwszFileName
, GENERIC_READ
, FILE_SHARE_READ
, NULL
, flags
, 0, NULL
);
877 if (file
== INVALID_HANDLE_VALUE
) return INVALID_HANDLE_VALUE
;
879 size
= GetFileSize(file
, NULL
);
880 if (!(buffer
= HeapAlloc(GetProcessHeap(), 0, size
)))
883 SetLastError(ERROR_OUTOFMEMORY
);
884 return INVALID_HANDLE_VALUE
;
886 if (!(hmsg
= CryptMsgOpenToDecode(dwEncodingType
, 0, 0, hProv
, NULL
, NULL
)))
889 HeapFree(GetProcessHeap(), 0, buffer
);
890 return INVALID_HANDLE_VALUE
;
892 if (!ReadFile(file
, buffer
, size
, &size
, NULL
) || !CryptMsgUpdate(hmsg
, buffer
, size
, TRUE
))
895 HeapFree(GetProcessHeap(), 0, buffer
);
897 return INVALID_HANDLE_VALUE
;
899 HeapFree(GetProcessHeap(), 0, buffer
);
902 size
= sizeof(DWORD
);
903 if (!(cc
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*cc
))))
906 SetLastError(ERROR_OUTOFMEMORY
);
907 return INVALID_HANDLE_VALUE
;
911 cc
->encoding
= dwEncodingType
;
912 if (CryptMsgGetParam(hmsg
, CMSG_ATTR_CERT_COUNT_PARAM
, 0, &cc
->attr_count
, &size
))
917 for (i
= 0; i
< cc
->attr_count
; i
++)
919 if (!CryptMsgGetParam(hmsg
, CMSG_ATTR_CERT_PARAM
, i
, NULL
, &size
))
922 HeapFree(GetProcessHeap(), 0, cc
);
923 return INVALID_HANDLE_VALUE
;
927 if (!(cc
->attr
= HeapAlloc(GetProcessHeap(), 0, sizeof(*cc
->attr
) * cc
->attr_count
+ sum
)))
930 HeapFree(GetProcessHeap(), 0, cc
);
931 SetLastError(ERROR_OUTOFMEMORY
);
932 return INVALID_HANDLE_VALUE
;
934 p
= (BYTE
*)(cc
->attr
+ cc
->attr_count
);
935 for (i
= 0; i
< cc
->attr_count
; i
++)
937 if (!CryptMsgGetParam(hmsg
, CMSG_ATTR_CERT_PARAM
, i
, NULL
, &size
))
940 HeapFree(GetProcessHeap(), 0, cc
->attr
);
941 HeapFree(GetProcessHeap(), 0, cc
);
942 return INVALID_HANDLE_VALUE
;
944 if (!CryptMsgGetParam(hmsg
, CMSG_ATTR_CERT_PARAM
, i
, p
, &size
))
947 HeapFree(GetProcessHeap(), 0, cc
->attr
);
948 HeapFree(GetProcessHeap(), 0, cc
);
949 return INVALID_HANDLE_VALUE
;
953 cc
->inner
= decode_inner_content(hmsg
, dwEncodingType
, &cc
->inner_len
);
954 if (!cc
->inner
|| !CryptSIPRetrieveSubjectGuid(pwszFileName
, NULL
, &cc
->subject
))
957 HeapFree(GetProcessHeap(), 0, cc
->attr
);
958 HeapFree(GetProcessHeap(), 0, cc
->inner
);
959 HeapFree(GetProcessHeap(), 0, cc
);
960 return INVALID_HANDLE_VALUE
;
962 cc
->magic
= CRYPTCAT_MAGIC
;
965 HeapFree(GetProcessHeap(), 0, cc
);
966 return INVALID_HANDLE_VALUE
;
969 /***********************************************************************
970 * CryptSIPCreateIndirectData (WINTRUST.@)
972 BOOL WINAPI
CryptSIPCreateIndirectData(SIP_SUBJECTINFO
* pSubjectInfo
, DWORD
* pcbIndirectData
,
973 SIP_INDIRECT_DATA
* pIndirectData
)
975 FIXME("(%p %p %p) stub\n", pSubjectInfo
, pcbIndirectData
, pIndirectData
);
981 /***********************************************************************
982 * CryptCATCDFClose (WINTRUST.@)
984 BOOL WINAPI
CryptCATCDFClose(CRYPTCATCDF
*pCDF
)
986 FIXME("(%p) stub\n", pCDF
);
991 /***********************************************************************
992 * CryptCATCDFEnumCatAttributes (WINTRUST.@)
994 CRYPTCATATTRIBUTE
* WINAPI
CryptCATCDFEnumCatAttributes(CRYPTCATCDF
*pCDF
,
995 CRYPTCATATTRIBUTE
*pPrevAttr
,
996 PFN_CDF_PARSE_ERROR_CALLBACK pfnParseError
)
998 FIXME("(%p %p %p) stub\n", pCDF
, pPrevAttr
, pfnParseError
);
1003 /***********************************************************************
1004 * CryptCATCDFEnumMembersByCDFTagEx (WINTRUST.@)
1006 LPWSTR WINAPI
CryptCATCDFEnumMembersByCDFTagEx(CRYPTCATCDF
*pCDF
, LPWSTR pwszPrevCDFTag
,
1007 PFN_CDF_PARSE_ERROR_CALLBACK pfnParseError
,
1008 CRYPTCATMEMBER
**ppMember
, BOOL fContinueOnError
,
1011 FIXME("(%p %s %p %p %d %p) stub\n", pCDF
, debugstr_w(pwszPrevCDFTag
), pfnParseError
,
1012 ppMember
, fContinueOnError
, pvReserved
);
1017 /***********************************************************************
1018 * CryptCATCDFOpen (WINTRUST.@)
1020 CRYPTCATCDF
* WINAPI
CryptCATCDFOpen(LPWSTR pwszFilePath
,
1021 PFN_CDF_PARSE_ERROR_CALLBACK pfnParseError
)
1023 FIXME("(%s %p) stub\n", debugstr_w(pwszFilePath
), pfnParseError
);
1028 static BOOL
WINTRUST_GetSignedMsgFromPEFile(SIP_SUBJECTINFO
*pSubjectInfo
,
1029 DWORD
*pdwEncodingType
, DWORD dwIndex
, DWORD
*pcbSignedDataMsg
,
1030 BYTE
*pbSignedDataMsg
)
1033 WIN_CERTIFICATE
*pCert
= NULL
;
1036 TRACE("(%p %p %d %p %p)\n", pSubjectInfo
, pdwEncodingType
, dwIndex
,
1037 pcbSignedDataMsg
, pbSignedDataMsg
);
1039 if(pSubjectInfo
->hFile
&& pSubjectInfo
->hFile
!=INVALID_HANDLE_VALUE
)
1040 file
= pSubjectInfo
->hFile
;
1043 file
= CreateFileW(pSubjectInfo
->pwsFileName
, GENERIC_READ
,
1044 FILE_SHARE_READ
|FILE_SHARE_WRITE
, NULL
, OPEN_EXISTING
, 0, NULL
);
1045 if(file
== INVALID_HANDLE_VALUE
)
1049 if (!pbSignedDataMsg
)
1051 WIN_CERTIFICATE cert
;
1053 /* app hasn't passed buffer, just get the length */
1054 ret
= ImageGetCertificateHeader(file
, dwIndex
, &cert
);
1057 switch (cert
.wCertificateType
)
1059 case WIN_CERT_TYPE_X509
:
1060 case WIN_CERT_TYPE_PKCS_SIGNED_DATA
:
1061 *pcbSignedDataMsg
= cert
.dwLength
;
1064 WARN("unknown certificate type %d\n", cert
.wCertificateType
);
1073 ret
= ImageGetCertificateData(file
, dwIndex
, NULL
, &len
);
1074 if (GetLastError() != ERROR_INSUFFICIENT_BUFFER
)
1076 pCert
= HeapAlloc(GetProcessHeap(), 0, len
);
1082 ret
= ImageGetCertificateData(file
, dwIndex
, pCert
, &len
);
1085 pCert
->dwLength
-= FIELD_OFFSET(WIN_CERTIFICATE
, bCertificate
);
1086 if (*pcbSignedDataMsg
< pCert
->dwLength
)
1088 *pcbSignedDataMsg
= pCert
->dwLength
;
1089 SetLastError(ERROR_INSUFFICIENT_BUFFER
);
1094 memcpy(pbSignedDataMsg
, pCert
->bCertificate
, pCert
->dwLength
);
1095 *pcbSignedDataMsg
= pCert
->dwLength
;
1096 switch (pCert
->wCertificateType
)
1098 case WIN_CERT_TYPE_X509
:
1099 *pdwEncodingType
= X509_ASN_ENCODING
;
1101 case WIN_CERT_TYPE_PKCS_SIGNED_DATA
:
1102 *pdwEncodingType
= X509_ASN_ENCODING
| PKCS_7_ASN_ENCODING
;
1105 WARN("don't know what to do for encoding type %d\n",
1106 pCert
->wCertificateType
);
1107 *pdwEncodingType
= 0;
1113 if(pSubjectInfo
->hFile
!= file
)
1115 HeapFree(GetProcessHeap(), 0, pCert
);
1119 static BOOL
WINTRUST_PutSignedMsgToPEFile(SIP_SUBJECTINFO
* pSubjectInfo
, DWORD pdwEncodingType
,
1120 DWORD
* pdwIndex
, DWORD cbSignedDataMsg
, BYTE
* pbSignedDataMsg
)
1122 WIN_CERTIFICATE
*cert
;
1127 if(pSubjectInfo
->hFile
&& pSubjectInfo
->hFile
!=INVALID_HANDLE_VALUE
)
1128 file
= pSubjectInfo
->hFile
;
1131 file
= CreateFileW(pSubjectInfo
->pwsFileName
, GENERIC_READ
|GENERIC_WRITE
,
1132 FILE_SHARE_READ
|FILE_SHARE_WRITE
, NULL
, OPEN_EXISTING
, 0, NULL
);
1133 if(file
== INVALID_HANDLE_VALUE
)
1137 /* int aligned WIN_CERTIFICATE structure with cbSignedDataMsg+1 bytes of data */
1138 size
= FIELD_OFFSET(WIN_CERTIFICATE
, bCertificate
[cbSignedDataMsg
+4]) & (~3);
1139 cert
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, size
);
1143 cert
->dwLength
= size
;
1144 cert
->wRevision
= WIN_CERT_REVISION_2_0
;
1145 cert
->wCertificateType
= WIN_CERT_TYPE_PKCS_SIGNED_DATA
;
1146 memcpy(cert
->bCertificate
, pbSignedDataMsg
, cbSignedDataMsg
);
1147 ret
= ImageAddCertificate(file
, cert
, pdwIndex
);
1149 HeapFree(GetProcessHeap(), 0, cert
);
1150 if(file
!= pSubjectInfo
->hFile
)
1155 /* structure offsets */
1156 #define cfhead_Signature (0x00)
1157 #define cfhead_CabinetSize (0x08)
1158 #define cfhead_MinorVersion (0x18)
1159 #define cfhead_MajorVersion (0x19)
1160 #define cfhead_Flags (0x1E)
1161 #define cfhead_SIZEOF (0x24)
1162 #define cfheadext_HeaderReserved (0x00)
1163 #define cfheadext_SIZEOF (0x04)
1164 #define cfsigninfo_CertOffset (0x04)
1165 #define cfsigninfo_CertSize (0x08)
1166 #define cfsigninfo_SIZEOF (0x0C)
1169 #define cfheadRESERVE_PRESENT (0x0004)
1171 /* endian-neutral reading of little-endian data */
1172 #define EndGetI32(a) ((((a)[3])<<24)|(((a)[2])<<16)|(((a)[1])<<8)|((a)[0]))
1173 #define EndGetI16(a) ((((a)[1])<<8)|((a)[0]))
1175 /* For documentation purposes only: this is the structure in the reserved
1176 * area of a signed cabinet file. The cert offset indicates where in the
1177 * cabinet file the signature resides, and the count indicates its size.
1179 typedef struct _CAB_SIGNINFO
1181 WORD unk0
; /* always 0? */
1182 WORD unk1
; /* always 0x0010? */
1185 } CAB_SIGNINFO
, *PCAB_SIGNINFO
;
1187 static BOOL
WINTRUST_GetSignedMsgFromCabFile(SIP_SUBJECTINFO
*pSubjectInfo
,
1188 DWORD
*pdwEncodingType
, DWORD dwIndex
, DWORD
*pcbSignedDataMsg
,
1189 BYTE
*pbSignedDataMsg
)
1192 LONG base_offset
, cabsize
;
1195 DWORD cert_offset
, cert_size
, dwRead
;
1197 TRACE("(%p %p %d %p %p)\n", pSubjectInfo
, pdwEncodingType
, dwIndex
,
1198 pcbSignedDataMsg
, pbSignedDataMsg
);
1200 /* get basic offset & size info */
1201 base_offset
= SetFilePointer(pSubjectInfo
->hFile
, 0L, NULL
, SEEK_CUR
);
1203 if (SetFilePointer(pSubjectInfo
->hFile
, 0, NULL
, SEEK_END
) == INVALID_SET_FILE_POINTER
)
1205 TRACE("seek error\n");
1209 cabsize
= SetFilePointer(pSubjectInfo
->hFile
, 0L, NULL
, SEEK_CUR
);
1210 if ((cabsize
== -1) || (base_offset
== -1) ||
1211 (SetFilePointer(pSubjectInfo
->hFile
, 0, NULL
, SEEK_SET
) == INVALID_SET_FILE_POINTER
))
1213 TRACE("seek error\n");
1217 /* read in the CFHEADER */
1218 if (!ReadFile(pSubjectInfo
->hFile
, buf
, cfhead_SIZEOF
, &dwRead
, NULL
) ||
1219 dwRead
!= cfhead_SIZEOF
)
1221 TRACE("reading header failed\n");
1225 /* check basic MSCF signature */
1226 if (EndGetI32(buf
+cfhead_Signature
) != 0x4643534d)
1228 WARN("cabinet signature not present\n");
1232 /* Ignore the number of folders and files and the set and cabinet IDs */
1234 /* check the header revision */
1235 if ((buf
[cfhead_MajorVersion
] > 1) ||
1236 (buf
[cfhead_MajorVersion
] == 1 && buf
[cfhead_MinorVersion
] > 3))
1238 WARN("cabinet format version > 1.3\n");
1242 /* pull the flags out */
1243 flags
= EndGetI16(buf
+cfhead_Flags
);
1245 if (!(flags
& cfheadRESERVE_PRESENT
))
1247 TRACE("no header present, not signed\n");
1251 if (!ReadFile(pSubjectInfo
->hFile
, buf
, cfheadext_SIZEOF
, &dwRead
, NULL
) ||
1252 dwRead
!= cfheadext_SIZEOF
)
1254 ERR("bunk reserve-sizes?\n");
1258 header_resv
= EndGetI16(buf
+cfheadext_HeaderReserved
);
1261 TRACE("no header_resv, not signed\n");
1264 else if (header_resv
< cfsigninfo_SIZEOF
)
1266 TRACE("header_resv too small, not signed\n");
1270 if (header_resv
> 60000)
1272 WARN("WARNING; header reserved space > 60000\n");
1275 if (!ReadFile(pSubjectInfo
->hFile
, buf
, cfsigninfo_SIZEOF
, &dwRead
, NULL
) ||
1276 dwRead
!= cfsigninfo_SIZEOF
)
1278 ERR("couldn't read reserve\n");
1282 cert_offset
= EndGetI32(buf
+cfsigninfo_CertOffset
);
1283 TRACE("cert_offset: %d\n", cert_offset
);
1284 cert_size
= EndGetI32(buf
+cfsigninfo_CertSize
);
1285 TRACE("cert_size: %d\n", cert_size
);
1287 /* The redundant checks are to avoid wraparound */
1288 if (cert_offset
> cabsize
|| cert_size
> cabsize
||
1289 cert_offset
+ cert_size
> cabsize
)
1291 WARN("offset beyond file, not attempting to read\n");
1295 SetFilePointer(pSubjectInfo
->hFile
, base_offset
, NULL
, SEEK_SET
);
1296 if (!pbSignedDataMsg
)
1298 *pcbSignedDataMsg
= cert_size
;
1301 if (*pcbSignedDataMsg
< cert_size
)
1303 *pcbSignedDataMsg
= cert_size
;
1304 SetLastError(ERROR_INSUFFICIENT_BUFFER
);
1307 if (SetFilePointer(pSubjectInfo
->hFile
, cert_offset
, NULL
, SEEK_SET
) == INVALID_SET_FILE_POINTER
)
1309 ERR("couldn't seek to cert location\n");
1312 if (!ReadFile(pSubjectInfo
->hFile
, pbSignedDataMsg
, cert_size
, &dwRead
,
1313 NULL
) || dwRead
!= cert_size
)
1315 ERR("couldn't read cert\n");
1316 SetFilePointer(pSubjectInfo
->hFile
, base_offset
, NULL
, SEEK_SET
);
1319 /* The encoding of the files I've seen appears to be in ASN.1
1320 * format, and there isn't a field indicating the type, so assume it
1323 *pdwEncodingType
= X509_ASN_ENCODING
| PKCS_7_ASN_ENCODING
;
1324 /* Restore base offset */
1325 SetFilePointer(pSubjectInfo
->hFile
, base_offset
, NULL
, SEEK_SET
);
1329 static BOOL
WINTRUST_GetSignedMsgFromCatFile(SIP_SUBJECTINFO
*pSubjectInfo
,
1330 DWORD
*pdwEncodingType
, DWORD dwIndex
, DWORD
*pcbSignedDataMsg
,
1331 BYTE
*pbSignedDataMsg
)
1335 TRACE("(%p %p %d %p %p)\n", pSubjectInfo
, pdwEncodingType
, dwIndex
,
1336 pcbSignedDataMsg
, pbSignedDataMsg
);
1338 if (!pbSignedDataMsg
)
1340 *pcbSignedDataMsg
= GetFileSize(pSubjectInfo
->hFile
, NULL
);
1345 DWORD len
= GetFileSize(pSubjectInfo
->hFile
, NULL
);
1347 if (*pcbSignedDataMsg
< len
)
1349 *pcbSignedDataMsg
= len
;
1350 SetLastError(ERROR_INSUFFICIENT_BUFFER
);
1355 ret
= ReadFile(pSubjectInfo
->hFile
, pbSignedDataMsg
, len
,
1356 pcbSignedDataMsg
, NULL
);
1358 *pdwEncodingType
= X509_ASN_ENCODING
| PKCS_7_ASN_ENCODING
;
1364 /* GUIDs used by CryptSIPGetSignedDataMsg and CryptSIPPutSignedDataMsg */
1365 static const GUID unknown
= { 0xC689AAB8, 0x8E78, 0x11D0, { 0x8C,0x47,
1366 0x00,0xC0,0x4F,0xC2,0x95,0xEE } };
1367 static const GUID cabGUID
= { 0xC689AABA, 0x8E78, 0x11D0, { 0x8C,0x47,
1368 0x00,0xC0,0x4F,0xC2,0x95,0xEE } };
1369 static const GUID catGUID
= { 0xDE351A43, 0x8E59, 0x11D0, { 0x8C,0x47,
1370 0x00,0xC0,0x4F,0xC2,0x95,0xEE }};
1372 /***********************************************************************
1373 * CryptSIPGetSignedDataMsg (WINTRUST.@)
1375 BOOL WINAPI
CryptSIPGetSignedDataMsg(SIP_SUBJECTINFO
* pSubjectInfo
, DWORD
* pdwEncodingType
,
1376 DWORD dwIndex
, DWORD
* pcbSignedDataMsg
, BYTE
* pbSignedDataMsg
)
1380 TRACE("(%p %p %d %p %p)\n", pSubjectInfo
, pdwEncodingType
, dwIndex
,
1381 pcbSignedDataMsg
, pbSignedDataMsg
);
1385 SetLastError(ERROR_INVALID_PARAMETER
);
1389 if (!memcmp(pSubjectInfo
->pgSubjectType
, &unknown
, sizeof(unknown
)))
1390 ret
= WINTRUST_GetSignedMsgFromPEFile(pSubjectInfo
, pdwEncodingType
,
1391 dwIndex
, pcbSignedDataMsg
, pbSignedDataMsg
);
1392 else if (!memcmp(pSubjectInfo
->pgSubjectType
, &cabGUID
, sizeof(cabGUID
)))
1393 ret
= WINTRUST_GetSignedMsgFromCabFile(pSubjectInfo
, pdwEncodingType
,
1394 dwIndex
, pcbSignedDataMsg
, pbSignedDataMsg
);
1395 else if (!memcmp(pSubjectInfo
->pgSubjectType
, &catGUID
, sizeof(catGUID
)))
1396 ret
= WINTRUST_GetSignedMsgFromCatFile(pSubjectInfo
, pdwEncodingType
,
1397 dwIndex
, pcbSignedDataMsg
, pbSignedDataMsg
);
1400 FIXME("unimplemented for subject type %s\n",
1401 debugstr_guid(pSubjectInfo
->pgSubjectType
));
1405 TRACE("returning %d\n", ret
);
1409 /***********************************************************************
1410 * CryptSIPPutSignedDataMsg (WINTRUST.@)
1412 BOOL WINAPI
CryptSIPPutSignedDataMsg(SIP_SUBJECTINFO
* pSubjectInfo
, DWORD pdwEncodingType
,
1413 DWORD
* pdwIndex
, DWORD cbSignedDataMsg
, BYTE
* pbSignedDataMsg
)
1415 TRACE("(%p %d %p %d %p)\n", pSubjectInfo
, pdwEncodingType
, pdwIndex
,
1416 cbSignedDataMsg
, pbSignedDataMsg
);
1419 SetLastError(ERROR_INVALID_PARAMETER
);
1423 if(!memcmp(pSubjectInfo
->pgSubjectType
, &unknown
, sizeof(unknown
)))
1424 return WINTRUST_PutSignedMsgToPEFile(pSubjectInfo
, pdwEncodingType
,
1425 pdwIndex
, cbSignedDataMsg
, pbSignedDataMsg
);
1427 FIXME("unimplemented for subject type %s\n",
1428 debugstr_guid(pSubjectInfo
->pgSubjectType
));
1433 /***********************************************************************
1434 * CryptSIPRemoveSignedDataMsg (WINTRUST.@)
1436 BOOL WINAPI
CryptSIPRemoveSignedDataMsg(SIP_SUBJECTINFO
* pSubjectInfo
,
1439 FIXME("(%p %d) stub\n", pSubjectInfo
, dwIndex
);
1444 /***********************************************************************
1445 * CryptSIPVerifyIndirectData (WINTRUST.@)
1447 BOOL WINAPI
CryptSIPVerifyIndirectData(SIP_SUBJECTINFO
* pSubjectInfo
,
1448 SIP_INDIRECT_DATA
* pIndirectData
)
1450 FIXME("(%p %p) stub\n", pSubjectInfo
, pIndirectData
);