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
);
54 if (catAdmin
) *catAdmin
= (HCATADMIN
)0xdeadbeef;
58 /***********************************************************************
59 * CryptCATAdminAddCatalog (WINTRUST.@)
61 BOOL WINAPI
CryptCATAdminAddCatalog(HCATADMIN catAdmin
, PWSTR catalogFile
,
62 PWSTR selectBaseName
, DWORD flags
)
64 FIXME("%p %s %s %d\n", catAdmin
, debugstr_w(catalogFile
),
65 debugstr_w(selectBaseName
), flags
);
69 /***********************************************************************
70 * CryptCATAdminCalcHashFromFileHandle (WINTRUST.@)
72 BOOL WINAPI
CryptCATAdminCalcHashFromFileHandle(HANDLE hFile
, DWORD
* pcbHash
,
73 BYTE
* pbHash
, DWORD dwFlags
)
75 FIXME("%p %p %p %x\n", hFile
, pcbHash
, pbHash
, dwFlags
);
77 if (pbHash
&& pcbHash
) memset(pbHash
, 0, *pcbHash
);
81 /***********************************************************************
82 * CryptCATAdminEnumCatalogFromHash (WINTRUST.@)
84 HCATINFO WINAPI
CryptCATAdminEnumCatalogFromHash(HCATADMIN hCatAdmin
,
88 HCATINFO
* phPrevCatInfo
)
90 FIXME("%p %p %d %d %p\n", hCatAdmin
, pbHash
, cbHash
, dwFlags
, phPrevCatInfo
);
94 /***********************************************************************
95 * CryptCATAdminReleaseCatalogContext (WINTRUST.@)
97 * Release a catalog context handle.
100 * hCatAdmin [I] Context handle.
101 * hCatInfo [I] Catalog handle.
102 * dwFlags [I] Reserved.
109 BOOL WINAPI
CryptCATAdminReleaseCatalogContext(HCATADMIN hCatAdmin
,
113 FIXME("%p %p %x\n", hCatAdmin
, hCatInfo
, dwFlags
);
117 /***********************************************************************
118 * CryptCATAdminReleaseContext (WINTRUST.@)
120 * Release a catalog administrator context handle.
123 * catAdmin [I] Context handle.
124 * dwFlags [I] Reserved.
131 BOOL WINAPI
CryptCATAdminReleaseContext(HCATADMIN hCatAdmin
, DWORD dwFlags
)
133 FIXME("%p %x\n", hCatAdmin
, dwFlags
);
137 /***********************************************************************
138 * CryptCATAdminRemoveCatalog (WINTRUST.@)
140 * Remove a catalog file.
143 * catAdmin [I] Context handle.
144 * pwszCatalogFile [I] Catalog file.
145 * dwFlags [I] Reserved.
152 BOOL WINAPI
CryptCATAdminRemoveCatalog(HCATADMIN hCatAdmin
, LPCWSTR pwszCatalogFile
, DWORD dwFlags
)
154 FIXME("%p %s %x\n", hCatAdmin
, debugstr_w(pwszCatalogFile
), dwFlags
);
155 return DeleteFileW(pwszCatalogFile
);
158 /***********************************************************************
159 * CryptCATClose (WINTRUST.@)
161 BOOL WINAPI
CryptCATClose(HANDLE hCatalog
)
163 FIXME("(%p) stub\n", hCatalog
);
167 /***********************************************************************
168 * CryptCATEnumerateMember (WINTRUST.@)
170 CRYPTCATMEMBER
*WINAPI
CryptCATEnumerateMember(HANDLE hCatalog
, CRYPTCATMEMBER
* pPrevMember
)
172 FIXME("(%p, %p) stub\n", hCatalog
, pPrevMember
);
176 /***********************************************************************
177 * CryptCATOpen (WINTRUST.@)
179 HANDLE WINAPI
CryptCATOpen(LPWSTR pwszFileName
, DWORD fdwOpenFlags
, HCRYPTPROV hProv
,
180 DWORD dwPublicVersion
, DWORD dwEncodingType
)
182 FIXME("(%s, %d, %ld, %d, %d) stub\n", debugstr_w(pwszFileName
), fdwOpenFlags
,
183 hProv
, dwPublicVersion
, dwEncodingType
);
187 /***********************************************************************
188 * CryptSIPCreateIndirectData (WINTRUST.@)
190 BOOL WINAPI
CryptSIPCreateIndirectData(SIP_SUBJECTINFO
* pSubjectInfo
, DWORD
* pcbIndirectData
,
191 SIP_INDIRECT_DATA
* pIndirectData
)
193 FIXME("(%p %p %p) stub\n", pSubjectInfo
, pcbIndirectData
, pIndirectData
);
198 /***********************************************************************
199 * CryptSIPGetSignedDataMsg (WINTRUST.@)
201 BOOL WINAPI
CryptSIPGetSignedDataMsg(SIP_SUBJECTINFO
* pSubjectInfo
, DWORD
* pdwEncodingType
,
202 DWORD dwIndex
, DWORD
* pcbSignedDataMsg
, BYTE
* pbSignedDataMsg
)
205 WIN_CERTIFICATE
*pCert
= NULL
;
207 TRACE("(%p %p %d %p %p)\n", pSubjectInfo
, pdwEncodingType
, dwIndex
,
208 pcbSignedDataMsg
, pbSignedDataMsg
);
210 if (!pbSignedDataMsg
)
212 WIN_CERTIFICATE cert
;
214 /* app hasn't passed buffer, just get the length */
215 ret
= ImageGetCertificateHeader(pSubjectInfo
->hFile
, dwIndex
, &cert
);
217 *pcbSignedDataMsg
= cert
.dwLength
;
223 ret
= ImageGetCertificateData(pSubjectInfo
->hFile
, dwIndex
, NULL
, &len
);
226 pCert
= HeapAlloc(GetProcessHeap(), 0, len
);
232 ret
= ImageGetCertificateData(pSubjectInfo
->hFile
, dwIndex
, pCert
,
236 if (*pcbSignedDataMsg
< pCert
->dwLength
)
238 *pcbSignedDataMsg
= pCert
->dwLength
;
239 SetLastError(ERROR_INSUFFICIENT_BUFFER
);
244 memcpy(pbSignedDataMsg
, pCert
->bCertificate
, pCert
->dwLength
);
245 switch (pCert
->wCertificateType
)
247 case WIN_CERT_TYPE_X509
:
248 *pdwEncodingType
= X509_ASN_ENCODING
;
250 case WIN_CERT_TYPE_PKCS_SIGNED_DATA
:
251 *pdwEncodingType
= X509_ASN_ENCODING
| PKCS_7_ASN_ENCODING
;
254 FIXME("don't know what to do for encoding type %d\n",
255 pCert
->wCertificateType
);
256 *pdwEncodingType
= 0;
262 HeapFree(GetProcessHeap(), 0, pCert
);
263 TRACE("returning %d\n", ret
);
267 /***********************************************************************
268 * CryptSIPPutSignedDataMsg (WINTRUST.@)
270 BOOL WINAPI
CryptSIPPutSignedDataMsg(SIP_SUBJECTINFO
* pSubjectInfo
, DWORD pdwEncodingType
,
271 DWORD
* pdwIndex
, DWORD cbSignedDataMsg
, BYTE
* pbSignedDataMsg
)
273 FIXME("(%p %d %p %d %p) stub\n", pSubjectInfo
, pdwEncodingType
, pdwIndex
,
274 cbSignedDataMsg
, pbSignedDataMsg
);
279 /***********************************************************************
280 * CryptSIPRemoveSignedDataMsg (WINTRUST.@)
282 BOOL WINAPI
CryptSIPRemoveSignedDataMsg(SIP_SUBJECTINFO
* pSubjectInfo
,
285 FIXME("(%p %d) stub\n", pSubjectInfo
, dwIndex
);
290 /***********************************************************************
291 * CryptSIPVerifyIndirectData (WINTRUST.@)
293 BOOL WINAPI
CryptSIPVerifyIndirectData(SIP_SUBJECTINFO
* pSubjectInfo
,
294 SIP_INDIRECT_DATA
* pIndirectData
)
296 FIXME("(%p %p) stub\n", pSubjectInfo
, pIndirectData
);