wined3d: Honor pbos when downloading a compressed texture.
[wine/gsoc_dplay.git] / dlls / wintrust / crypt.c
blobe69db9e3763566b260434611cf5ac078e4449695
1 /*
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
21 #include <stdarg.h>
23 #include "windef.h"
24 #include "winbase.h"
25 #include "wintrust.h"
26 #include "mscat.h"
27 #include "mssip.h"
28 #include "imagehlp.h"
30 #include "wine/debug.h"
32 WINE_DEFAULT_DEBUG_CHANNEL(wintrust);
34 /***********************************************************************
35 * CryptCATAdminAcquireContext (WINTRUST.@)
37 * Get a catalog administrator context handle.
39 * PARAMS
40 * catAdmin [O] Pointer to the context handle.
41 * sysSystem [I] Pointer to a GUID for the needed subsystem.
42 * dwFlags [I] Reserved.
44 * RETURNS
45 * Success: TRUE. catAdmin contains the context handle.
46 * Failure: FALSE.
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;
55 return TRUE;
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);
66 return TRUE;
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);
78 return TRUE;
81 /***********************************************************************
82 * CryptCATAdminEnumCatalogFromHash (WINTRUST.@)
84 HCATINFO WINAPI CryptCATAdminEnumCatalogFromHash(HCATADMIN hCatAdmin,
85 BYTE* pbHash,
86 DWORD cbHash,
87 DWORD dwFlags,
88 HCATINFO* phPrevCatInfo )
90 FIXME("%p %p %d %d %p\n", hCatAdmin, pbHash, cbHash, dwFlags, phPrevCatInfo);
91 return NULL;
94 /***********************************************************************
95 * CryptCATAdminReleaseCatalogContext (WINTRUST.@)
97 * Release a catalog context handle.
99 * PARAMS
100 * hCatAdmin [I] Context handle.
101 * hCatInfo [I] Catalog handle.
102 * dwFlags [I] Reserved.
104 * RETURNS
105 * Success: TRUE.
106 * Failure: FAIL.
109 BOOL WINAPI CryptCATAdminReleaseCatalogContext(HCATADMIN hCatAdmin,
110 HCATINFO hCatInfo,
111 DWORD dwFlags)
113 FIXME("%p %p %x\n", hCatAdmin, hCatInfo, dwFlags);
114 return TRUE;
117 /***********************************************************************
118 * CryptCATAdminReleaseContext (WINTRUST.@)
120 * Release a catalog administrator context handle.
122 * PARAMS
123 * catAdmin [I] Context handle.
124 * dwFlags [I] Reserved.
126 * RETURNS
127 * Success: TRUE.
128 * Failure: FAIL.
131 BOOL WINAPI CryptCATAdminReleaseContext(HCATADMIN hCatAdmin, DWORD dwFlags )
133 FIXME("%p %x\n", hCatAdmin, dwFlags);
134 return TRUE;
137 /***********************************************************************
138 * CryptCATAdminRemoveCatalog (WINTRUST.@)
140 * Remove a catalog file.
142 * PARAMS
143 * catAdmin [I] Context handle.
144 * pwszCatalogFile [I] Catalog file.
145 * dwFlags [I] Reserved.
147 * RETURNS
148 * Success: TRUE.
149 * Failure: FALSE.
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);
164 return TRUE;
167 /***********************************************************************
168 * CryptCATEnumerateMember (WINTRUST.@)
170 CRYPTCATMEMBER *WINAPI CryptCATEnumerateMember(HANDLE hCatalog, CRYPTCATMEMBER* pPrevMember)
172 FIXME("(%p, %p) stub\n", hCatalog, pPrevMember);
173 return NULL;
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);
184 return 0;
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);
195 return FALSE;
198 /***********************************************************************
199 * CryptSIPGetSignedDataMsg (WINTRUST.@)
201 BOOL WINAPI CryptSIPGetSignedDataMsg(SIP_SUBJECTINFO* pSubjectInfo, DWORD* pdwEncodingType,
202 DWORD dwIndex, DWORD* pcbSignedDataMsg, BYTE* pbSignedDataMsg)
204 BOOL ret;
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);
216 if (ret)
217 *pcbSignedDataMsg = cert.dwLength;
219 else
221 DWORD len;
223 ret = ImageGetCertificateData(pSubjectInfo->hFile, dwIndex, NULL, &len);
224 if (!ret)
225 goto error;
226 pCert = HeapAlloc(GetProcessHeap(), 0, len);
227 if (!pCert)
229 ret = FALSE;
230 goto error;
232 ret = ImageGetCertificateData(pSubjectInfo->hFile, dwIndex, pCert,
233 &len);
234 if (!ret)
235 goto error;
236 if (*pcbSignedDataMsg < pCert->dwLength)
238 *pcbSignedDataMsg = pCert->dwLength;
239 SetLastError(ERROR_INSUFFICIENT_BUFFER);
240 ret = FALSE;
242 else
244 memcpy(pbSignedDataMsg, pCert->bCertificate, pCert->dwLength);
245 switch (pCert->wCertificateType)
247 case WIN_CERT_TYPE_X509:
248 *pdwEncodingType = X509_ASN_ENCODING;
249 break;
250 case WIN_CERT_TYPE_PKCS_SIGNED_DATA:
251 *pdwEncodingType = X509_ASN_ENCODING | PKCS_7_ASN_ENCODING;
252 break;
253 default:
254 FIXME("don't know what to do for encoding type %d\n",
255 pCert->wCertificateType);
256 *pdwEncodingType = 0;
261 error:
262 HeapFree(GetProcessHeap(), 0, pCert);
263 TRACE("returning %d\n", ret);
264 return 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);
276 return FALSE;
279 /***********************************************************************
280 * CryptSIPRemoveSignedDataMsg (WINTRUST.@)
282 BOOL WINAPI CryptSIPRemoveSignedDataMsg(SIP_SUBJECTINFO* pSubjectInfo,
283 DWORD dwIndex)
285 FIXME("(%p %d) stub\n", pSubjectInfo, dwIndex);
287 return FALSE;
290 /***********************************************************************
291 * CryptSIPVerifyIndirectData (WINTRUST.@)
293 BOOL WINAPI CryptSIPVerifyIndirectData(SIP_SUBJECTINFO* pSubjectInfo,
294 SIP_INDIRECT_DATA* pIndirectData)
296 FIXME("(%p %p) stub\n", pSubjectInfo, pIndirectData);
298 return FALSE;