2 * WinTrust Cryptography functions
4 * Copyright 2006 James Hawkins
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
30 #include "wine/debug.h"
32 WINE_DEFAULT_DEBUG_CHANNEL(wintrust);
34 /***********************************************************************
35 * CryptCATAdminAcquireContext (WINTRUST.@)
37 * Get a catalog administrator context handle.
40 * catAdmin [O] Pointer to the context handle.
41 * sysSystem [I] Pointer to a GUID for the needed subsystem.
42 * dwFlags [I] Reserved.
45 * Success: TRUE. catAdmin contains the context handle.
49 BOOL WINAPI CryptCATAdminAcquireContext(HCATADMIN* catAdmin,
50 const GUID *sysSystem, DWORD dwFlags )
52 FIXME("%p %s %x\n", catAdmin, debugstr_guid(sysSystem), dwFlags);
56 SetLastError(ERROR_INVALID_PARAMETER);
60 *catAdmin = (HCATADMIN)0xdeadbeef;
65 /***********************************************************************
66 * CryptCATAdminAddCatalog (WINTRUST.@)
68 BOOL WINAPI CryptCATAdminAddCatalog(HCATADMIN catAdmin, PWSTR catalogFile,
69 PWSTR selectBaseName, DWORD flags)
71 FIXME("%p %s %s %d\n", catAdmin, debugstr_w(catalogFile),
72 debugstr_w(selectBaseName), flags);
76 /***********************************************************************
77 * CryptCATAdminCalcHashFromFileHandle (WINTRUST.@)
79 BOOL WINAPI CryptCATAdminCalcHashFromFileHandle(HANDLE hFile, DWORD* pcbHash,
80 BYTE* pbHash, DWORD dwFlags )
82 FIXME("%p %p %p %x\n", hFile, pcbHash, pbHash, dwFlags);
84 if (pbHash && pcbHash) memset(pbHash, 0, *pcbHash);
88 /***********************************************************************
89 * CryptCATAdminEnumCatalogFromHash (WINTRUST.@)
91 HCATINFO WINAPI CryptCATAdminEnumCatalogFromHash(HCATADMIN hCatAdmin,
95 HCATINFO* phPrevCatInfo )
97 FIXME("%p %p %d %d %p\n", hCatAdmin, pbHash, cbHash, dwFlags, phPrevCatInfo);
101 /***********************************************************************
102 * CryptCATAdminReleaseCatalogContext (WINTRUST.@)
104 * Release a catalog context handle.
107 * hCatAdmin [I] Context handle.
108 * hCatInfo [I] Catalog handle.
109 * dwFlags [I] Reserved.
116 BOOL WINAPI CryptCATAdminReleaseCatalogContext(HCATADMIN hCatAdmin,
120 FIXME("%p %p %x\n", hCatAdmin, hCatInfo, dwFlags);
124 /***********************************************************************
125 * CryptCATAdminReleaseContext (WINTRUST.@)
127 * Release a catalog administrator context handle.
130 * catAdmin [I] Context handle.
131 * dwFlags [I] Reserved.
138 BOOL WINAPI CryptCATAdminReleaseContext(HCATADMIN hCatAdmin, DWORD dwFlags )
140 FIXME("%p %x\n", hCatAdmin, dwFlags);
144 /***********************************************************************
145 * CryptCATAdminRemoveCatalog (WINTRUST.@)
147 * Remove a catalog file.
150 * catAdmin [I] Context handle.
151 * pwszCatalogFile [I] Catalog file.
152 * dwFlags [I] Reserved.
159 BOOL WINAPI CryptCATAdminRemoveCatalog(HCATADMIN hCatAdmin, LPCWSTR pwszCatalogFile, DWORD dwFlags)
161 FIXME("%p %s %x\n", hCatAdmin, debugstr_w(pwszCatalogFile), dwFlags);
162 return DeleteFileW(pwszCatalogFile);
165 /***********************************************************************
166 * CryptCATClose (WINTRUST.@)
168 BOOL WINAPI CryptCATClose(HANDLE hCatalog)
170 FIXME("(%p) stub\n", hCatalog);
174 /***********************************************************************
175 * CryptCATEnumerateMember (WINTRUST.@)
177 CRYPTCATMEMBER *WINAPI CryptCATEnumerateMember(HANDLE hCatalog, CRYPTCATMEMBER* pPrevMember)
179 FIXME("(%p, %p) stub\n", hCatalog, pPrevMember);
183 /***********************************************************************
184 * CryptCATOpen (WINTRUST.@)
186 HANDLE WINAPI CryptCATOpen(LPWSTR pwszFileName, DWORD fdwOpenFlags, HCRYPTPROV hProv,
187 DWORD dwPublicVersion, DWORD dwEncodingType)
189 FIXME("(%s, %d, %ld, %d, %d) stub\n", debugstr_w(pwszFileName), fdwOpenFlags,
190 hProv, dwPublicVersion, dwEncodingType);
194 /***********************************************************************
195 * CryptSIPCreateIndirectData (WINTRUST.@)
197 BOOL WINAPI CryptSIPCreateIndirectData(SIP_SUBJECTINFO* pSubjectInfo, DWORD* pcbIndirectData,
198 SIP_INDIRECT_DATA* pIndirectData)
200 FIXME("(%p %p %p) stub\n", pSubjectInfo, pcbIndirectData, pIndirectData);
205 /***********************************************************************
206 * CryptSIPGetSignedDataMsg (WINTRUST.@)
208 BOOL WINAPI CryptSIPGetSignedDataMsg(SIP_SUBJECTINFO* pSubjectInfo, DWORD* pdwEncodingType,
209 DWORD dwIndex, DWORD* pcbSignedDataMsg, BYTE* pbSignedDataMsg)
212 WIN_CERTIFICATE *pCert = NULL;
214 TRACE("(%p %p %d %p %p)\n", pSubjectInfo, pdwEncodingType, dwIndex,
215 pcbSignedDataMsg, pbSignedDataMsg);
217 if (!pbSignedDataMsg)
219 WIN_CERTIFICATE cert;
221 /* app hasn't passed buffer, just get the length */
222 ret = ImageGetCertificateHeader(pSubjectInfo->hFile, dwIndex, &cert);
224 *pcbSignedDataMsg = cert.dwLength;
230 ret = ImageGetCertificateData(pSubjectInfo->hFile, dwIndex, NULL, &len);
231 if (GetLastError() != ERROR_INSUFFICIENT_BUFFER)
233 pCert = HeapAlloc(GetProcessHeap(), 0, len);
239 ret = ImageGetCertificateData(pSubjectInfo->hFile, dwIndex, pCert,
243 if (*pcbSignedDataMsg < pCert->dwLength)
245 *pcbSignedDataMsg = pCert->dwLength;
246 SetLastError(ERROR_INSUFFICIENT_BUFFER);
251 memcpy(pbSignedDataMsg, pCert->bCertificate, pCert->dwLength);
252 switch (pCert->wCertificateType)
254 case WIN_CERT_TYPE_X509:
255 *pdwEncodingType = X509_ASN_ENCODING;
257 case WIN_CERT_TYPE_PKCS_SIGNED_DATA:
258 *pdwEncodingType = X509_ASN_ENCODING | PKCS_7_ASN_ENCODING;
261 FIXME("don't know what to do for encoding type %d\n",
262 pCert->wCertificateType);
263 *pdwEncodingType = 0;
269 HeapFree(GetProcessHeap(), 0, pCert);
270 TRACE("returning %d\n", ret);
274 /***********************************************************************
275 * CryptSIPPutSignedDataMsg (WINTRUST.@)
277 BOOL WINAPI CryptSIPPutSignedDataMsg(SIP_SUBJECTINFO* pSubjectInfo, DWORD pdwEncodingType,
278 DWORD* pdwIndex, DWORD cbSignedDataMsg, BYTE* pbSignedDataMsg)
280 FIXME("(%p %d %p %d %p) stub\n", pSubjectInfo, pdwEncodingType, pdwIndex,
281 cbSignedDataMsg, pbSignedDataMsg);
286 /***********************************************************************
287 * CryptSIPRemoveSignedDataMsg (WINTRUST.@)
289 BOOL WINAPI CryptSIPRemoveSignedDataMsg(SIP_SUBJECTINFO* pSubjectInfo,
292 FIXME("(%p %d) stub\n", pSubjectInfo, dwIndex);
297 /***********************************************************************
298 * CryptSIPVerifyIndirectData (WINTRUST.@)
300 BOOL WINAPI CryptSIPVerifyIndirectData(SIP_SUBJECTINFO* pSubjectInfo,
301 SIP_INDIRECT_DATA* pIndirectData)
303 FIXME("(%p %p) stub\n", pSubjectInfo, pIndirectData);