ReactOS  0.4.13-dev-257-gfabbd7c
crypt.c File Reference
#include <stdarg.h>
#include <stdio.h>
#include "windef.h"
#include "winbase.h"
#include "wintrust.h"
#include "mscat.h"
#include "mssip.h"
#include "imagehlp.h"
#include "winternl.h"
#include "wine/debug.h"
#include "wine/unicode.h"
Include dependency graph for crypt.c:

Go to the source code of this file.

Classes

struct  cryptcat
 
struct  catadmin
 
struct  catinfo
 
struct  _CAB_SIGNINFO
 

Macros

#define CATADMIN_MAGIC   0x43415441 /* 'CATA' */
 
#define CRYPTCAT_MAGIC   0x43415443 /* 'CATC' */
 
#define CATINFO_MAGIC   0x43415449 /* 'CATI' */
 
#define cfhead_Signature   (0x00)
 
#define cfhead_CabinetSize   (0x08)
 
#define cfhead_MinorVersion   (0x18)
 
#define cfhead_MajorVersion   (0x19)
 
#define cfhead_Flags   (0x1E)
 
#define cfhead_SIZEOF   (0x24)
 
#define cfheadext_HeaderReserved   (0x00)
 
#define cfheadext_SIZEOF   (0x04)
 
#define cfsigninfo_CertOffset   (0x04)
 
#define cfsigninfo_CertSize   (0x08)
 
#define cfsigninfo_SIZEOF   (0x0C)
 
#define cfheadRESERVE_PRESENT   (0x0004)
 
#define EndGetI32(a)   ((((a)[3])<<24)|(((a)[2])<<16)|(((a)[1])<<8)|((a)[0]))
 
#define EndGetI16(a)   ((((a)[1])<<8)|((a)[0]))
 

Typedefs

typedef struct _CAB_SIGNINFO CAB_SIGNINFO
 
typedef struct _CAB_SIGNINFOPCAB_SIGNINFO
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (wintrust)
 
static HCATINFO create_catinfo (const WCHAR *filename)
 
BOOL WINAPI CryptCATAdminAcquireContext (HCATADMIN *catAdmin, const GUID *sys, DWORD dwFlags)
 
HCATINFO WINAPI CryptCATAdminAddCatalog (HCATADMIN catAdmin, PWSTR catalogFile, PWSTR selectBaseName, DWORD flags)
 
BOOL WINAPI CryptCATAdminCalcHashFromFileHandle (HANDLE hFile, DWORD *pcbHash, BYTE *pbHash, DWORD dwFlags)
 
HCATINFO WINAPI CryptCATAdminEnumCatalogFromHash (HCATADMIN hCatAdmin, BYTE *pbHash, DWORD cbHash, DWORD dwFlags, HCATINFO *phPrevCatInfo)
 
BOOL WINAPI CryptCATAdminReleaseCatalogContext (HCATADMIN hCatAdmin, HCATINFO hCatInfo, DWORD dwFlags)
 
BOOL WINAPI CryptCATAdminReleaseContext (HCATADMIN hCatAdmin, DWORD dwFlags)
 
BOOL WINAPI CryptCATAdminRemoveCatalog (HCATADMIN hCatAdmin, LPCWSTR pwszCatalogFile, DWORD dwFlags)
 
BOOL WINAPI CryptCATAdminResolveCatalogPath (HCATADMIN hcatadmin, WCHAR *catalog_file, CATALOG_INFO *info, DWORD flags)
 
BOOL WINAPI CryptCATClose (HANDLE hCatalog)
 
CRYPTCATATTRIBUTE *WINAPI CryptCATGetAttrInfo (HANDLE hCatalog, CRYPTCATMEMBER *member, LPWSTR tag)
 
CRYPTCATATTRIBUTE *WINAPI CryptCATGetCatAttrInfo (HANDLE hCatalog, LPWSTR tag)
 
CRYPTCATMEMBER *WINAPI CryptCATGetMemberInfo (HANDLE hCatalog, LPWSTR tag)
 
CRYPTCATATTRIBUTE *WINAPI CryptCATEnumerateAttr (HANDLE hCatalog, CRYPTCATMEMBER *member, CRYPTCATATTRIBUTE *prev)
 
CRYPTCATATTRIBUTE *WINAPI CryptCATEnumerateCatAttr (HANDLE hCatalog, CRYPTCATATTRIBUTE *prev)
 
CRYPTCATMEMBER *WINAPI CryptCATEnumerateMember (HANDLE hCatalog, CRYPTCATMEMBER *prev)
 
static CTL_INFOdecode_inner_content (HANDLE hmsg, DWORD encoding, DWORD *len)
 
BOOL WINAPI CryptCATCatalogInfoFromContext (HCATINFO hcatinfo, CATALOG_INFO *info, DWORD flags)
 
HANDLE WINAPI CryptCATOpen (LPWSTR pwszFileName, DWORD fdwOpenFlags, HCRYPTPROV hProv, DWORD dwPublicVersion, DWORD dwEncodingType)
 
BOOL WINAPI CryptSIPCreateIndirectData (SIP_SUBJECTINFO *pSubjectInfo, DWORD *pcbIndirectData, SIP_INDIRECT_DATA *pIndirectData)
 
BOOL WINAPI CryptCATCDFClose (CRYPTCATCDF *pCDF)
 
CRYPTCATATTRIBUTE *WINAPI CryptCATCDFEnumCatAttributes (CRYPTCATCDF *pCDF, CRYPTCATATTRIBUTE *pPrevAttr, PFN_CDF_PARSE_ERROR_CALLBACK pfnParseError)
 
LPWSTR WINAPI CryptCATCDFEnumMembersByCDFTagEx (CRYPTCATCDF *pCDF, LPWSTR pwszPrevCDFTag, PFN_CDF_PARSE_ERROR_CALLBACK pfnParseError, CRYPTCATMEMBER **ppMember, BOOL fContinueOnError, LPVOID pvReserved)
 
CRYPTCATCDF *WINAPI CryptCATCDFOpen (LPWSTR pwszFilePath, PFN_CDF_PARSE_ERROR_CALLBACK pfnParseError)
 
static BOOL WINTRUST_GetSignedMsgFromPEFile (SIP_SUBJECTINFO *pSubjectInfo, DWORD *pdwEncodingType, DWORD dwIndex, DWORD *pcbSignedDataMsg, BYTE *pbSignedDataMsg)
 
static BOOL WINTRUST_PutSignedMsgToPEFile (SIP_SUBJECTINFO *pSubjectInfo, DWORD pdwEncodingType, DWORD *pdwIndex, DWORD cbSignedDataMsg, BYTE *pbSignedDataMsg)
 
static BOOL WINTRUST_GetSignedMsgFromCabFile (SIP_SUBJECTINFO *pSubjectInfo, DWORD *pdwEncodingType, DWORD dwIndex, DWORD *pcbSignedDataMsg, BYTE *pbSignedDataMsg)
 
static BOOL WINTRUST_GetSignedMsgFromCatFile (SIP_SUBJECTINFO *pSubjectInfo, DWORD *pdwEncodingType, DWORD dwIndex, DWORD *pcbSignedDataMsg, BYTE *pbSignedDataMsg)
 
BOOL WINAPI CryptSIPGetSignedDataMsg (SIP_SUBJECTINFO *pSubjectInfo, DWORD *pdwEncodingType, DWORD dwIndex, DWORD *pcbSignedDataMsg, BYTE *pbSignedDataMsg)
 
BOOL WINAPI CryptSIPPutSignedDataMsg (SIP_SUBJECTINFO *pSubjectInfo, DWORD pdwEncodingType, DWORD *pdwIndex, DWORD cbSignedDataMsg, BYTE *pbSignedDataMsg)
 
BOOL WINAPI CryptSIPRemoveSignedDataMsg (SIP_SUBJECTINFO *pSubjectInfo, DWORD dwIndex)
 
BOOL WINAPI CryptSIPVerifyIndirectData (SIP_SUBJECTINFO *pSubjectInfo, SIP_INDIRECT_DATA *pIndirectData)
 

Variables

static const GUID unknown
 
static const GUID cabGUID
 
static const GUID catGUID
 

Macro Definition Documentation

◆ CATADMIN_MAGIC

#define CATADMIN_MAGIC   0x43415441 /* 'CATA' */

Definition at line 40 of file crypt.c.

◆ CATINFO_MAGIC

#define CATINFO_MAGIC   0x43415449 /* 'CATI' */

Definition at line 42 of file crypt.c.

◆ cfhead_CabinetSize

#define cfhead_CabinetSize   (0x08)

Definition at line 1147 of file crypt.c.

◆ cfhead_Flags

#define cfhead_Flags   (0x1E)

Definition at line 1150 of file crypt.c.

◆ cfhead_MajorVersion

#define cfhead_MajorVersion   (0x19)

Definition at line 1149 of file crypt.c.

◆ cfhead_MinorVersion

#define cfhead_MinorVersion   (0x18)

Definition at line 1148 of file crypt.c.

◆ cfhead_Signature

#define cfhead_Signature   (0x00)

Definition at line 1146 of file crypt.c.

◆ cfhead_SIZEOF

#define cfhead_SIZEOF   (0x24)

Definition at line 1151 of file crypt.c.

◆ cfheadext_HeaderReserved

#define cfheadext_HeaderReserved   (0x00)

Definition at line 1152 of file crypt.c.

◆ cfheadext_SIZEOF

#define cfheadext_SIZEOF   (0x04)

Definition at line 1153 of file crypt.c.

◆ cfheadRESERVE_PRESENT

#define cfheadRESERVE_PRESENT   (0x0004)

Definition at line 1159 of file crypt.c.

◆ cfsigninfo_CertOffset

#define cfsigninfo_CertOffset   (0x04)

Definition at line 1154 of file crypt.c.

◆ cfsigninfo_CertSize

#define cfsigninfo_CertSize   (0x08)

Definition at line 1155 of file crypt.c.

◆ cfsigninfo_SIZEOF

#define cfsigninfo_SIZEOF   (0x0C)

Definition at line 1156 of file crypt.c.

◆ CRYPTCAT_MAGIC

#define CRYPTCAT_MAGIC   0x43415443 /* 'CATC' */

Definition at line 41 of file crypt.c.

◆ EndGetI16

#define EndGetI16 (   a)    ((((a)[1])<<8)|((a)[0]))

Definition at line 1163 of file crypt.c.

◆ EndGetI32

#define EndGetI32 (   a)    ((((a)[3])<<24)|(((a)[2])<<16)|(((a)[1])<<8)|((a)[0]))

Definition at line 1162 of file crypt.c.

Typedef Documentation

◆ CAB_SIGNINFO

◆ PCAB_SIGNINFO

Function Documentation

◆ create_catinfo()

static HCATINFO create_catinfo ( const WCHAR filename)
static

Definition at line 69 of file crypt.c.

70 {
71  struct catinfo *ci;
72 
73  if (!(ci = HeapAlloc(GetProcessHeap(), 0, sizeof(*ci))))
74  {
76  return INVALID_HANDLE_VALUE;
77  }
78  strcpyW(ci->file, filename);
79  ci->magic = CATINFO_MAGIC;
80  return ci;
81 }
DWORD magic
Definition: crypt.c:65
Definition: crypt.c:63
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
const char * filename
Definition: ioapi.h:135
WCHAR file[MAX_PATH]
Definition: crypt.c:66
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
#define SetLastError(x)
Definition: compat.h:409
WINE_UNICODE_INLINE WCHAR * strcpyW(WCHAR *dst, const WCHAR *src)
Definition: unicode.h:219
#define CATINFO_MAGIC
Definition: crypt.c:42
#define ERROR_OUTOFMEMORY
Definition: deptool.c:13

Referenced by CryptCATAdminEnumCatalogFromHash().

◆ CryptCATAdminAcquireContext()

BOOL WINAPI CryptCATAdminAcquireContext ( HCATADMIN catAdmin,
const GUID sys,
DWORD  dwFlags 
)

Definition at line 98 of file crypt.c.

100 {
101  static const WCHAR catroot[] =
102  {'\\','c','a','t','r','o','o','t',0};
103  static const WCHAR fmt[] =
104  {'%','s','\\','{','%','0','8','x','-','%','0','4','x','-','%','0',
105  '4','x','-','%','0','2','x','%','0','2','x','-','%','0','2','x',
106  '%','0','2','x','%','0','2','x','%','0','2','x','%','0','2','x',
107  '%','0','2','x','}',0};
108  static const GUID defsys =
109  {0x127d0a1d,0x4ef2,0x11d1,{0x86,0x08,0x00,0xc0,0x4f,0xc2,0x95,0xee}};
110 
111  WCHAR catroot_dir[MAX_PATH];
112  struct catadmin *ca;
113 
114  TRACE("%p %s %x\n", catAdmin, debugstr_guid(sys), dwFlags);
115 
116  if (!catAdmin || dwFlags)
117  {
119  return FALSE;
120  }
121  if (!(ca = HeapAlloc(GetProcessHeap(), 0, sizeof(*ca))))
122  {
124  return FALSE;
125  }
126 
127  GetSystemDirectoryW(catroot_dir, MAX_PATH);
128  strcatW(catroot_dir, catroot);
129 
130  /* create the directory if it doesn't exist */
131  CreateDirectoryW(catroot_dir, NULL);
132 
133  if (!sys) sys = &defsys;
134  sprintfW(ca->path, fmt, catroot_dir, sys->Data1, sys->Data2,
135  sys->Data3, sys->Data4[0], sys->Data4[1], sys->Data4[2],
136  sys->Data4[3], sys->Data4[4], sys->Data4[5], sys->Data4[6],
137  sys->Data4[7]);
138 
139  /* create the directory if it doesn't exist */
140  CreateDirectoryW(ca->path, NULL);
141 
142  ca->magic = CATADMIN_MAGIC;
143  ca->find = INVALID_HANDLE_VALUE;
144 
145  *catAdmin = ca;
146  return TRUE;
147 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
BOOL WINAPI CreateDirectoryW(IN LPCWSTR lpPathName, IN LPSECURITY_ATTRIBUTES lpSecurityAttributes)
Definition: dir.c:90
#define TRUE
Definition: types.h:120
static CHAR catroot[MAX_PATH]
Definition: crypt.c:33
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
smooth NULL
Definition: ftsmooth.c:416
#define debugstr_guid
Definition: kernel32.h:35
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define MAX_PATH
Definition: compat.h:26
#define SetLastError(x)
Definition: compat.h:409
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
#define CATADMIN_MAGIC
Definition: crypt.c:40
Definition: crypt.c:56
#define sprintfW
Definition: unicode.h:58
WINE_UNICODE_INLINE WCHAR * strcatW(WCHAR *dst, const WCHAR *src)
Definition: unicode.h:242
UINT WINAPI GetSystemDirectoryW(OUT LPWSTR lpBuffer, IN UINT uSize)
Definition: path.c:2312
static const WCHAR ca[]
Definition: main.c:457
Definition: dsound.c:943
#define ERROR_OUTOFMEMORY
Definition: deptool.c:13

Referenced by InitFunctionPtrs(), and pSetupInstallCatalog().

◆ CryptCATAdminAddCatalog()

HCATINFO WINAPI CryptCATAdminAddCatalog ( HCATADMIN  catAdmin,
PWSTR  catalogFile,
PWSTR  selectBaseName,
DWORD  flags 
)

Definition at line 152 of file crypt.c.

154 {
155  static const WCHAR slashW[] = {'\\',0};
156  struct catadmin *ca = catAdmin;
157  struct catinfo *ci;
158  WCHAR *target;
159  DWORD len;
160 
161  TRACE("%p %s %s %d\n", catAdmin, debugstr_w(catalogFile),
162  debugstr_w(selectBaseName), flags);
163 
164  if (!selectBaseName)
165  {
166  FIXME("NULL basename not handled\n");
168  return NULL;
169  }
170  if (!ca || ca->magic != CATADMIN_MAGIC || !catalogFile || flags)
171  {
173  return NULL;
174  }
175 
176  len = strlenW(ca->path) + strlenW(selectBaseName) + 2;
177  if (!(target = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR))))
178  {
180  return NULL;
181  }
182  strcpyW(target, ca->path);
184  strcatW(target, selectBaseName);
185 
186  if (!CopyFileW(catalogFile, target, FALSE))
187  {
189  return NULL;
190  }
192 
193  if (!(ci = HeapAlloc(GetProcessHeap(), 0, sizeof(*ci))))
194  {
197  return NULL;
198  }
199  ci->magic = CATINFO_MAGIC;
200  strcpyW(ci->file, target);
201 
203  return ci;
204 }
BOOL WINAPI SetFileAttributesW(LPCWSTR lpFileName, DWORD dwFileAttributes)
Definition: fileinfo.c:944
DWORD magic
Definition: crypt.c:65
Definition: crypt.c:63
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
#define FILE_ATTRIBUTE_SYSTEM
Definition: nt_native.h:704
#define debugstr_w
Definition: kernel32.h:32
#define FIXME(fmt,...)
Definition: debug.h:110
smooth NULL
Definition: ftsmooth.c:416
WCHAR file[MAX_PATH]
Definition: crypt.c:66
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
__wchar_t WCHAR
Definition: xmlstorage.h:180
BOOL WINAPI CopyFileW(IN LPCWSTR lpExistingFileName, IN LPCWSTR lpNewFileName, IN BOOL bFailIfExists)
Definition: copy.c:439
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:409
GLbitfield flags
Definition: glext.h:7161
GLenum GLsizei len
Definition: glext.h:6722
#define CATADMIN_MAGIC
Definition: crypt.c:40
WINE_UNICODE_INLINE WCHAR * strcpyW(WCHAR *dst, const WCHAR *src)
Definition: unicode.h:219
Definition: crypt.c:56
WINE_UNICODE_INLINE WCHAR * strcatW(WCHAR *dst, const WCHAR *src)
Definition: unicode.h:242
#define CATINFO_MAGIC
Definition: crypt.c:42
GLenum target
Definition: glext.h:7315
static const WCHAR ca[]
Definition: main.c:457
#define HeapFree(x, y, z)
Definition: compat.h:394
#define ERROR_OUTOFMEMORY
Definition: deptool.c:13
static const WCHAR slashW[]
Definition: devenum.c:62

Referenced by InitFunctionPtrs(), and pSetupInstallCatalog().

◆ CryptCATAdminCalcHashFromFileHandle()

BOOL WINAPI CryptCATAdminCalcHashFromFileHandle ( HANDLE  hFile,
DWORD pcbHash,
BYTE pbHash,
DWORD  dwFlags 
)

Definition at line 209 of file crypt.c.

211 {
212  BOOL ret = FALSE;
213 
214  TRACE("%p %p %p %x\n", hFile, pcbHash, pbHash, dwFlags);
215 
216  if (!hFile || !pcbHash || dwFlags)
217  {
219  return FALSE;
220  }
221  if (*pcbHash < 20)
222  {
223  *pcbHash = 20;
225  return TRUE;
226  }
227 
228  *pcbHash = 20;
229  if (pbHash)
230  {
231  HCRYPTPROV prov;
233  DWORD bytes_read;
234  BYTE *buffer;
235 
236  if (!(buffer = HeapAlloc(GetProcessHeap(), 0, 4096)))
237  {
239  return FALSE;
240  }
242  if (!ret)
243  {
245  return FALSE;
246  }
247  ret = CryptCreateHash(prov, CALG_SHA1, 0, 0, &hash);
248  if (!ret)
249  {
251  CryptReleaseContext(prov, 0);
252  return FALSE;
253  }
254  while ((ret = ReadFile(hFile, buffer, 4096, &bytes_read, NULL)) && bytes_read)
255  {
256  CryptHashData(hash, buffer, bytes_read, 0);
257  }
258  if (ret) ret = CryptGetHashParam(hash, HP_HASHVAL, pbHash, pcbHash, 0);
259 
262  CryptReleaseContext(prov, 0);
263  }
264  return ret;
265 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define TRUE
Definition: types.h:120
GLuint buffer
Definition: glext.h:5915
BOOL WINAPI CryptAcquireContextW(HCRYPTPROV *phProv, LPCWSTR pszContainer, LPCWSTR pszProvider, DWORD dwProvType, DWORD dwFlags)
Definition: crypt.c:358
BOOL WINAPI CryptGetHashParam(HCRYPTHASH hHash, DWORD dwParam, BYTE *pbData, DWORD *pdwDataLen, DWORD dwFlags)
Definition: crypt.c:1615
int hash
Definition: main.c:58
unsigned int BOOL
Definition: ntddk_ex.h:94
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:409
static const WCHAR MS_DEF_PROV_W[]
Definition: wincrypt.h:1868
BOOL WINAPI CryptDestroyHash(HCRYPTHASH hHash)
Definition: crypt.c:895
int ret
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
unsigned char BYTE
Definition: mem.h:68
BOOL WINAPI CryptCreateHash(HCRYPTPROV hProv, ALG_ID Algid, HCRYPTKEY hKey, DWORD dwFlags, HCRYPTHASH *phHash)
Definition: crypt.c:745
_In_ HANDLE hFile
Definition: mswsock.h:90
#define CRYPT_VERIFYCONTEXT
Definition: wincrypt.h:2069
ULONG_PTR HCRYPTHASH
Definition: wincrypt.h:50
ULONG_PTR HCRYPTPROV
Definition: wincrypt.h:46
BOOL WINAPI CryptHashData(HCRYPTHASH hHash, const BYTE *pbData, DWORD dwDataLen, DWORD dwFlags)
Definition: crypt.c:1776
#define CALG_SHA1
Definition: wincrypt.h:1807
BOOL WINAPI CryptReleaseContext(HCRYPTPROV hProv, ULONG_PTR dwFlags)
Definition: crypt.c:651
#define HP_HASHVAL
Definition: wincrypt.h:2183
Definition: _hash_fun.h:40
BOOL WINAPI ReadFile(IN HANDLE hFile, IN LPVOID lpBuffer, IN DWORD nNumberOfBytesToRead, OUT LPDWORD lpNumberOfBytesRead OPTIONAL, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: rw.c:123
#define HeapFree(x, y, z)
Definition: compat.h:394
#define PROV_RSA_FULL
Definition: wincrypt.h:2039
#define ERROR_OUTOFMEMORY
Definition: deptool.c:13
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10

Referenced by InitFunctionPtrs().

◆ CryptCATAdminEnumCatalogFromHash()

HCATINFO WINAPI CryptCATAdminEnumCatalogFromHash ( HCATADMIN  hCatAdmin,
BYTE pbHash,
DWORD  cbHash,
DWORD  dwFlags,
HCATINFO phPrevCatInfo 
)

Definition at line 270 of file crypt.c.

273 {
274  static const WCHAR slashW[] = {'\\',0};
275  static const WCHAR globW[] = {'\\','*','.','c','a','t',0};
276 
277  struct catadmin *ca = hCatAdmin;
279  HCATINFO prev = NULL;
280  HCRYPTPROV prov;
281  DWORD size;
282  BOOL ret;
283 
284  TRACE("%p %p %d %x %p\n", hCatAdmin, pbHash, cbHash, dwFlags, phPrevCatInfo);
285 
286  if (!ca || ca->magic != CATADMIN_MAGIC || !pbHash || cbHash != 20 || dwFlags)
287  {
289  return NULL;
290  }
291  if (phPrevCatInfo) prev = *phPrevCatInfo;
292 
294  if (!ret) return NULL;
295 
296  if (!prev)
297  {
298  WCHAR *path;
299 
300  size = strlenW(ca->path) * sizeof(WCHAR) + sizeof(globW);
301  if (!(path = HeapAlloc(GetProcessHeap(), 0, size)))
302  {
303  CryptReleaseContext(prov, 0);
305  return NULL;
306  }
307  strcpyW(path, ca->path);
308  strcatW(path, globW);
309 
310  FindClose(ca->find);
311  ca->find = FindFirstFileW(path, &data);
312 
314  if (ca->find == INVALID_HANDLE_VALUE)
315  {
316  CryptReleaseContext(prov, 0);
317  return NULL;
318  }
319  }
320  else if (!FindNextFileW(ca->find, &data))
321  {
322  CryptCATAdminReleaseCatalogContext(hCatAdmin, prev, 0);
323  CryptReleaseContext(prov, 0);
324  return NULL;
325  }
326 
327  while (1)
328  {
329  WCHAR *filename;
331  struct catinfo *ci;
332  HANDLE hcat;
333 
334  size = (strlenW(ca->path) + strlenW(data.cFileName) + 2) * sizeof(WCHAR);
335  if (!(filename = HeapAlloc(GetProcessHeap(), 0, size)))
336  {
338  return NULL;
339  }
340  strcpyW(filename, ca->path);
342  strcatW(filename, data.cFileName);
343 
344  hcat = CryptCATOpen(filename, CRYPTCAT_OPEN_EXISTING, prov, 0, 0);
345  if (hcat == INVALID_HANDLE_VALUE)
346  {
347  WARN("couldn't open %s (%u)\n", debugstr_w(filename), GetLastError());
348  continue;
349  }
350  while ((member = CryptCATEnumerateMember(hcat, member)))
351  {
352  if (member->pIndirectData->Digest.cbData != cbHash)
353  {
354  WARN("amount of hash bytes differs: %u/%u\n", member->pIndirectData->Digest.cbData, cbHash);
355  continue;
356  }
357  if (!memcmp(member->pIndirectData->Digest.pbData, pbHash, cbHash))
358  {
359  TRACE("file %s matches\n", debugstr_w(data.cFileName));
360 
361  CryptCATClose(hcat);
362  CryptReleaseContext(prov, 0);
363  if (!phPrevCatInfo)
364  {
365  FindClose(ca->find);
366  ca->find = INVALID_HANDLE_VALUE;
367  }
368  ci = create_catinfo(filename);
370  return ci;
371  }
372  }
373  CryptCATClose(hcat);
375 
376  if (!FindNextFileW(ca->find, &data))
377  {
378  FindClose(ca->find);
379  ca->find = INVALID_HANDLE_VALUE;
380  CryptReleaseContext(prov, 0);
381  return NULL;
382  }
383  }
384  return NULL;
385 }
Definition: crypt.c:63
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
BOOL WINAPI FindNextFileW(IN HANDLE hFindFile, OUT LPWIN32_FIND_DATAW lpFindFileData)
Definition: find.c:382
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
GLsizei const GLchar ** path
Definition: glext.h:7234
#define WARN(fmt,...)
Definition: debug.h:111
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
const char * filename
Definition: ioapi.h:135
BOOL WINAPI CryptAcquireContextW(HCRYPTPROV *phProv, LPCWSTR pszContainer, LPCWSTR pszProvider, DWORD dwProvType, DWORD dwFlags)
Definition: crypt.c:358
BOOL WINAPI CryptCATClose(HANDLE hCatalog)
Definition: crypt.c:530
unsigned int BOOL
Definition: ntddk_ex.h:94
#define debugstr_w
Definition: kernel32.h:32
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
GLsizeiptr size
Definition: glext.h:5919
BOOL WINAPI CryptCATAdminReleaseCatalogContext(HCATADMIN hCatAdmin, HCATINFO hCatInfo, DWORD dwFlags)
Definition: crypt.c:402
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:409
CRYPTCATMEMBER *WINAPI CryptCATEnumerateMember(HANDLE hCatalog, CRYPTCATMEMBER *prev)
Definition: crypt.c:640
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
static const WCHAR MS_DEF_PROV_W[]
Definition: wincrypt.h:1868
#define CRYPTCAT_OPEN_EXISTING
Definition: mscat.h:33
int ret
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
#define CATADMIN_MAGIC
Definition: crypt.c:40
#define CRYPT_VERIFYCONTEXT
Definition: wincrypt.h:2069
WINE_UNICODE_INLINE WCHAR * strcpyW(WCHAR *dst, const WCHAR *src)
Definition: unicode.h:219
ULONG_PTR HCRYPTPROV
Definition: wincrypt.h:46
Definition: crypt.c:56
Definition: services.c:325
WINE_UNICODE_INLINE WCHAR * strcatW(WCHAR *dst, const WCHAR *src)
Definition: unicode.h:242
BOOL WINAPI CryptReleaseContext(HCRYPTPROV hProv, ULONG_PTR dwFlags)
Definition: crypt.c:651
static HCATINFO create_catinfo(const WCHAR *filename)
Definition: crypt.c:69
static const WCHAR ca[]
Definition: main.c:457
#define HeapFree(x, y, z)
Definition: compat.h:394
#define PROV_RSA_FULL
Definition: wincrypt.h:2039
HANDLE WINAPI CryptCATOpen(LPWSTR pwszFileName, DWORD fdwOpenFlags, HCRYPTPROV hProv, DWORD dwPublicVersion, DWORD dwEncodingType)
Definition: crypt.c:844
#define ERROR_OUTOFMEMORY
Definition: deptool.c:13
HANDLE WINAPI FindFirstFileW(IN LPCWSTR lpFileName, OUT LPWIN32_FIND_DATAW lpFindFileData)
Definition: find.c:320
BOOL WINAPI FindClose(HANDLE hFindFile)
Definition: find.c:502
static const WCHAR slashW[]
Definition: devenum.c:62

◆ CryptCATAdminReleaseCatalogContext()

BOOL WINAPI CryptCATAdminReleaseCatalogContext ( HCATADMIN  hCatAdmin,
HCATINFO  hCatInfo,
DWORD  dwFlags 
)

Definition at line 402 of file crypt.c.

405 {
406  struct catinfo *ci = hCatInfo;
407  struct catadmin *ca = hCatAdmin;
408 
409  TRACE("%p %p %x\n", hCatAdmin, hCatInfo, dwFlags);
410 
411  if (!ca || ca->magic != CATADMIN_MAGIC || !ci || ci->magic != CATINFO_MAGIC)
412  {
414  return FALSE;
415  }
416  ci->magic = 0;
417  return HeapFree(GetProcessHeap(), 0, ci);
418 }
DWORD magic
Definition: crypt.c:65
Definition: crypt.c:63
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:395
#define SetLastError(x)
Definition: compat.h:409
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
#define CATADMIN_MAGIC
Definition: crypt.c:40
Definition: crypt.c:56
#define CATINFO_MAGIC
Definition: crypt.c:42
static const WCHAR ca[]
Definition: main.c:457
#define HeapFree(x, y, z)
Definition: compat.h:394

Referenced by CryptCATAdminEnumCatalogFromHash(), InitFunctionPtrs(), and pSetupInstallCatalog().

◆ CryptCATAdminReleaseContext()

BOOL WINAPI CryptCATAdminReleaseContext ( HCATADMIN  hCatAdmin,
DWORD  dwFlags 
)

Definition at line 434 of file crypt.c.

435 {
436  struct catadmin *ca = hCatAdmin;
437 
438  TRACE("%p %x\n", hCatAdmin, dwFlags);
439 
440  if (!ca || ca->magic != CATADMIN_MAGIC)
441  {
443  return FALSE;
444  }
445  if (ca->find != INVALID_HANDLE_VALUE) FindClose(ca->find);
446  ca->magic = 0;
447  return HeapFree(GetProcessHeap(), 0, ca);
448 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:395
#define SetLastError(x)
Definition: compat.h:409
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
#define CATADMIN_MAGIC
Definition: crypt.c:40
Definition: crypt.c:56
static const WCHAR ca[]
Definition: main.c:457
#define HeapFree(x, y, z)
Definition: compat.h:394
BOOL WINAPI FindClose(HANDLE hFindFile)
Definition: find.c:502

Referenced by InitFunctionPtrs(), and pSetupInstallCatalog().

◆ CryptCATAdminRemoveCatalog()

BOOL WINAPI CryptCATAdminRemoveCatalog ( HCATADMIN  hCatAdmin,
LPCWSTR  pwszCatalogFile,
DWORD  dwFlags 
)

Definition at line 465 of file crypt.c.

466 {
467  struct catadmin *ca = hCatAdmin;
468 
469  TRACE("%p %s %x\n", hCatAdmin, debugstr_w(pwszCatalogFile), dwFlags);
470 
471  if (!ca || ca->magic != CATADMIN_MAGIC)
472  {
474  return FALSE;
475  }
476 
477  /* Only delete when there is a filename and no path */
478  if (pwszCatalogFile && pwszCatalogFile[0] != 0 &&
479  !strchrW(pwszCatalogFile, '\\') && !strchrW(pwszCatalogFile, '/') &&
480  !strchrW(pwszCatalogFile, ':'))
481  {
482  static const WCHAR slashW[] = {'\\',0};
483  WCHAR *target;
484  DWORD len;
485 
486  len = strlenW(ca->path) + strlenW(pwszCatalogFile) + 2;
487  if (!(target = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR))))
488  {
490  return FALSE;
491  }
492  strcpyW(target, ca->path);
494  strcatW(target, pwszCatalogFile);
495 
497 
499  }
500 
501  return TRUE;
502 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define TRUE
Definition: types.h:120
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
WINE_UNICODE_INLINE WCHAR * strchrW(const WCHAR *str, WCHAR ch)
Definition: unicode.h:248
#define debugstr_w
Definition: kernel32.h:32
BOOL WINAPI DeleteFileW(IN LPCWSTR lpFileName)
Definition: delete.c:39
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:409
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
GLenum GLsizei len
Definition: glext.h:6722
#define CATADMIN_MAGIC
Definition: crypt.c:40
WINE_UNICODE_INLINE WCHAR * strcpyW(WCHAR *dst, const WCHAR *src)
Definition: unicode.h:219
Definition: crypt.c:56
WINE_UNICODE_INLINE WCHAR * strcatW(WCHAR *dst, const WCHAR *src)
Definition: unicode.h:242
GLenum target
Definition: glext.h:7315
static const WCHAR ca[]
Definition: main.c:457
#define HeapFree(x, y, z)
Definition: compat.h:394
#define ERROR_OUTOFMEMORY
Definition: deptool.c:13
static const WCHAR slashW[]
Definition: devenum.c:62

Referenced by InitFunctionPtrs().

◆ CryptCATAdminResolveCatalogPath()

BOOL WINAPI CryptCATAdminResolveCatalogPath ( HCATADMIN  hcatadmin,
WCHAR catalog_file,
CATALOG_INFO info,
DWORD  flags 
)

Definition at line 507 of file crypt.c.

509 {
510  static const WCHAR slashW[] = {'\\',0};
511  struct catadmin *ca = hcatadmin;
512 
513  TRACE("%p %s %p %x\n", hcatadmin, debugstr_w(catalog_file), info, flags);
514 
515  if (!ca || ca->magic != CATADMIN_MAGIC || !info || info->cbStruct != sizeof(*info) || flags)
516  {
518  return FALSE;
519  }
520  strcpyW(info->wszCatalogFile, ca->path);
521  strcatW(info->wszCatalogFile, slashW);
522  strcatW(info->wszCatalogFile, catalog_file);
523 
524  return TRUE;
525 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define TRUE
Definition: types.h:120
#define debugstr_w
Definition: kernel32.h:32
#define TRACE(s)
Definition: solgame.cpp:4
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define SetLastError(x)
Definition: compat.h:409
GLbitfield flags
Definition: glext.h:7161
#define CATADMIN_MAGIC
Definition: crypt.c:40
WINE_UNICODE_INLINE WCHAR * strcpyW(WCHAR *dst, const WCHAR *src)
Definition: unicode.h:219
Definition: crypt.c:56
WINE_UNICODE_INLINE WCHAR * strcatW(WCHAR *dst, const WCHAR *src)
Definition: unicode.h:242
static const WCHAR ca[]
Definition: main.c:457
static const WCHAR slashW[]
Definition: devenum.c:62

◆ CryptCATCatalogInfoFromContext()

BOOL WINAPI CryptCATCatalogInfoFromContext ( HCATINFO  hcatinfo,
CATALOG_INFO info,
DWORD  flags 
)

Definition at line 825 of file crypt.c.

826 {
827  struct catinfo *ci = hcatinfo;
828 
829  TRACE("%p, %p, %x\n", hcatinfo, info, flags);
830 
831  if (!hcatinfo || hcatinfo == INVALID_HANDLE_VALUE || ci->magic != CATINFO_MAGIC ||
832  flags || !info || info->cbStruct != sizeof(*info))
833  {
835  return FALSE;
836  }
837  strcpyW(info->wszCatalogFile, ci->file);
838  return TRUE;
839 }
DWORD magic
Definition: crypt.c:65
Definition: crypt.c:63
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define TRUE
Definition: types.h:120
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
WCHAR file[MAX_PATH]
Definition: crypt.c:66
#define TRACE(s)
Definition: solgame.cpp:4
#define SetLastError(x)
Definition: compat.h:409
GLbitfield flags
Definition: glext.h:7161
WINE_UNICODE_INLINE WCHAR * strcpyW(WCHAR *dst, const WCHAR *src)
Definition: unicode.h:219
#define CATINFO_MAGIC
Definition: crypt.c:42

Referenced by InitFunctionPtrs().

◆ CryptCATCDFClose()

BOOL WINAPI CryptCATCDFClose ( CRYPTCATCDF pCDF)

Definition at line 974 of file crypt.c.

975 {
976  FIXME("(%p) stub\n", pCDF);
977 
978  return FALSE;
979 }
#define FIXME(fmt,...)
Definition: debug.h:110

Referenced by InitFunctionPtrs().

◆ CryptCATCDFEnumCatAttributes()

CRYPTCATATTRIBUTE* WINAPI CryptCATCDFEnumCatAttributes ( CRYPTCATCDF pCDF,
CRYPTCATATTRIBUTE pPrevAttr,
PFN_CDF_PARSE_ERROR_CALLBACK  pfnParseError 
)

Definition at line 984 of file crypt.c.

987 {
988  FIXME("(%p %p %p) stub\n", pCDF, pPrevAttr, pfnParseError);
989 
990  return NULL;
991 }
#define FIXME(fmt,...)
Definition: debug.h:110
smooth NULL
Definition: ftsmooth.c:416

Referenced by InitFunctionPtrs().

◆ CryptCATCDFEnumMembersByCDFTagEx()

LPWSTR WINAPI CryptCATCDFEnumMembersByCDFTagEx ( CRYPTCATCDF pCDF,
LPWSTR  pwszPrevCDFTag,
PFN_CDF_PARSE_ERROR_CALLBACK  pfnParseError,
CRYPTCATMEMBER **  ppMember,
BOOL  fContinueOnError,
LPVOID  pvReserved 
)

Definition at line 996 of file crypt.c.

1000 {
1001  FIXME("(%p %s %p %p %d %p) stub\n", pCDF, debugstr_w(pwszPrevCDFTag), pfnParseError,
1002  ppMember, fContinueOnError, pvReserved);
1003 
1004  return NULL;
1005 }
#define debugstr_w
Definition: kernel32.h:32
#define FIXME(fmt,...)
Definition: debug.h:110
smooth NULL
Definition: ftsmooth.c:416
static LPCSTR DWORD void * pvReserved
Definition: str.c:196

Referenced by InitFunctionPtrs().

◆ CryptCATCDFOpen()

CRYPTCATCDF* WINAPI CryptCATCDFOpen ( LPWSTR  pwszFilePath,
PFN_CDF_PARSE_ERROR_CALLBACK  pfnParseError 
)

Definition at line 1010 of file crypt.c.

1012 {
1013  FIXME("(%s %p) stub\n", debugstr_w(pwszFilePath), pfnParseError);
1014 
1015  return NULL;
1016 }
#define debugstr_w
Definition: kernel32.h:32
#define FIXME(fmt,...)
Definition: debug.h:110
smooth NULL
Definition: ftsmooth.c:416

Referenced by InitFunctionPtrs().

◆ CryptCATClose()

BOOL WINAPI CryptCATClose ( HANDLE  hCatalog)

Definition at line 530 of file crypt.c.

531 {
532  struct cryptcat *cc = hCatalog;
533 
534  TRACE("(%p)\n", hCatalog);
535 
536  if (!hCatalog || hCatalog == INVALID_HANDLE_VALUE || cc->magic != CRYPTCAT_MAGIC)
537  {
539  return FALSE;
540  }
541  HeapFree(GetProcessHeap(), 0, cc->attr);
542  HeapFree(GetProcessHeap(), 0, cc->inner);
543  CryptMsgClose(cc->msg);
544 
545  cc->magic = 0;
546  HeapFree(GetProcessHeap(), 0, cc);
547  return TRUE;
548 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define TRUE
Definition: types.h:120
Definition: crypt.c:44
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:395
#define SetLastError(x)
Definition: compat.h:409
uint32_t cc
Definition: isohybrid.c:75
#define CRYPTCAT_MAGIC
Definition: crypt.c:41
BOOL WINAPI CryptMsgClose(HCRYPTMSG hCryptMsg)
Definition: msg.c:3598
#define HeapFree(x, y, z)
Definition: compat.h:394

Referenced by CryptCATAdminEnumCatalogFromHash(), and InitFunctionPtrs().

◆ CryptCATEnumerateAttr()

CRYPTCATATTRIBUTE* WINAPI CryptCATEnumerateAttr ( HANDLE  hCatalog,
CRYPTCATMEMBER member,
CRYPTCATATTRIBUTE prev 
)

Definition at line 604 of file crypt.c.

605 {
606  struct cryptcat *cc = hCatalog;
607 
608  FIXME("%p, %p, %p\n", hCatalog, member, prev);
609 
610  if (!hCatalog || hCatalog == INVALID_HANDLE_VALUE || cc->magic != CRYPTCAT_MAGIC)
611  {
613  return NULL;
614  }
616  return NULL;
617 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define CRYPT_E_NOT_FOUND
Definition: winerror.h:3007
Definition: crypt.c:44
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
#define FIXME(fmt,...)
Definition: debug.h:110
smooth NULL
Definition: ftsmooth.c:416
#define SetLastError(x)
Definition: compat.h:409
uint32_t cc
Definition: isohybrid.c:75
#define CRYPTCAT_MAGIC
Definition: crypt.c:41

Referenced by InitFunctionPtrs().

◆ CryptCATEnumerateCatAttr()

CRYPTCATATTRIBUTE* WINAPI CryptCATEnumerateCatAttr ( HANDLE  hCatalog,
CRYPTCATATTRIBUTE prev 
)

Definition at line 622 of file crypt.c.

623 {
624  struct cryptcat *cc = hCatalog;
625 
626  FIXME("%p, %p\n", hCatalog, prev);
627 
628  if (!hCatalog || hCatalog == INVALID_HANDLE_VALUE || cc->magic != CRYPTCAT_MAGIC)
629  {
631  return NULL;
632  }
634  return NULL;
635 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define CRYPT_E_NOT_FOUND
Definition: winerror.h:3007
Definition: crypt.c:44
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
#define FIXME(fmt,...)
Definition: debug.h:110
smooth NULL
Definition: ftsmooth.c:416
#define SetLastError(x)
Definition: compat.h:409
uint32_t cc
Definition: isohybrid.c:75
#define CRYPTCAT_MAGIC
Definition: crypt.c:41

Referenced by InitFunctionPtrs().

◆ CryptCATEnumerateMember()

CRYPTCATMEMBER* WINAPI CryptCATEnumerateMember ( HANDLE  hCatalog,
CRYPTCATMEMBER prev 
)

Definition at line 640 of file crypt.c.

641 {
642  struct cryptcat *cc = hCatalog;
643  CRYPTCATMEMBER *member = prev;
644  CTL_ENTRY *entry;
645  DWORD size, i;
646 
647  TRACE("%p, %p\n", hCatalog, prev);
648 
649  if (!hCatalog || hCatalog == INVALID_HANDLE_VALUE || cc->magic != CRYPTCAT_MAGIC)
650  {
652  return NULL;
653  }
654 
655  /* dumping the contents makes me think that dwReserved is the iteration number */
656  if (!member)
657  {
658  if (!(member = HeapAlloc(GetProcessHeap(), 0, sizeof(*member))))
659  {
661  return NULL;
662  }
663  member->cbStruct = sizeof(*member);
664  member->pwszFileName = member->pwszReferenceTag = NULL;
665  member->dwReserved = 0;
666  member->hReserved = NULL;
667  member->gSubjectType = cc->subject;
668  member->fdwMemberFlags = 0;
669  member->pIndirectData = NULL;
670  member->dwCertVersion = cc->inner->dwVersion;
671  }
672  else member->dwReserved++;
673 
674  if (member->dwReserved >= cc->inner->cCTLEntry)
675  {
677  goto error;
678  }
679 
680  /* list them backwards, like native */
681  entry = &cc->inner->rgCTLEntry[cc->inner->cCTLEntry - member->dwReserved - 1];
682 
683  member->sEncodedIndirectData.cbData = member->sEncodedMemberInfo.cbData = 0;
684  member->sEncodedIndirectData.pbData = member->sEncodedMemberInfo.pbData = NULL;
685  HeapFree(GetProcessHeap(), 0, member->pIndirectData);
686  member->pIndirectData = NULL;
687 
688  for (i = 0; i < entry->cAttribute; i++)
689  {
690  CRYPT_ATTRIBUTE *attr = entry->rgAttribute + i;
691 
692  if (attr->cValue != 1)
693  {
694  ERR("Can't handle attr->cValue of %u\n", attr->cValue);
695  continue;
696  }
697  if (!strcmp(attr->pszObjId, CAT_MEMBERINFO_OBJID))
698  {
700  BOOL ret;
701 
702  member->sEncodedMemberInfo.cbData = attr->rgValue->cbData;
703  member->sEncodedMemberInfo.pbData = attr->rgValue->pbData;
704 
705  CryptDecodeObject(cc->encoding, CAT_MEMBERINFO_OBJID, attr->rgValue->pbData, attr->rgValue->cbData, 0, NULL, &size);
706 
707  if (!(mi = HeapAlloc(GetProcessHeap(), 0, size)))
708  {
710  goto error;
711  }
712  ret = CryptDecodeObject(cc->encoding, CAT_MEMBERINFO_OBJID, attr->rgValue->pbData, attr->rgValue->cbData, 0, mi, &size);
713  if (ret)
714  {
716 
717  member->dwCertVersion = mi->dwCertVersion;
718  RtlInitUnicodeString(&guid, mi->pwszSubjGuid);
719  if (RtlGUIDFromString(&guid, &member->gSubjectType))
720  {
721  HeapFree(GetProcessHeap(), 0, mi);
722  goto error;
723  }
724  }
725  HeapFree(GetProcessHeap(), 0, mi);
726  if (!ret) goto error;
727  }
728  else if (!strcmp(attr->pszObjId, SPC_INDIRECT_DATA_OBJID))
729  {
730  /* SPC_INDIRECT_DATA_CONTENT is equal to SIP_INDIRECT_DATA */
731 
732  member->sEncodedIndirectData.cbData = attr->rgValue->cbData;
733  member->sEncodedIndirectData.pbData = attr->rgValue->pbData;
734 
735  CryptDecodeObject(cc->encoding, SPC_INDIRECT_DATA_OBJID, attr->rgValue->pbData, attr->rgValue->cbData, 0, NULL, &size);
736 
737  if (!(member->pIndirectData = HeapAlloc(GetProcessHeap(), 0, size)))
738  {
740  goto error;
741  }
742  CryptDecodeObject(cc->encoding, SPC_INDIRECT_DATA_OBJID, attr->rgValue->pbData, attr->rgValue->cbData, 0, member->pIndirectData, &size);
743  }
744  else
745  /* this object id should probably be handled in CryptCATEnumerateAttr */
746  FIXME("unhandled object id \"%s\"\n", attr->pszObjId);
747  }
748 
749  if (!member->sEncodedMemberInfo.cbData || !member->sEncodedIndirectData.cbData)
750  {
751  ERR("Corrupted catalog entry?\n");
753  goto error;
754  }
755  size = (2 * member->pIndirectData->Digest.cbData + 1) * sizeof(WCHAR);
756  if (member->pwszReferenceTag)
757  member->pwszReferenceTag = HeapReAlloc(GetProcessHeap(), 0, member->pwszReferenceTag, size);
758  else
759  member->pwszReferenceTag = HeapAlloc(GetProcessHeap(), 0, size);
760 
761  if (!member->pwszReferenceTag)
762  {
764  goto error;
765  }
766  /* FIXME: reference tag is usually the file hash but doesn't have to be */
767  for (i = 0; i < member->pIndirectData->Digest.cbData; i++)
768  {
769  DWORD sub;
770 
771  sub = member->pIndirectData->Digest.pbData[i] >> 4;
772  member->pwszReferenceTag[i * 2] = (sub < 10 ? '0' + sub : 'A' + sub - 10);
773  sub = member->pIndirectData->Digest.pbData[i] & 0xf;
774  member->pwszReferenceTag[i * 2 + 1] = (sub < 10 ? '0' + sub : 'A' + sub - 10);
775  }
776  member->pwszReferenceTag[i * 2] = 0;
777  return member;
778 
779 error:
780  HeapFree(GetProcessHeap(), 0, member->pIndirectData);
781  HeapFree(GetProcessHeap(), 0, member->pwszReferenceTag);
783  return NULL;
784 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define error(str)
Definition: mkdosfs.c:1605
BOOL WINAPI CryptDecodeObject(DWORD dwCertEncodingType, LPCSTR lpszStructType, const BYTE *pbEncoded, DWORD cbEncoded, DWORD dwFlags, void *pvStructInfo, DWORD *pcbStructInfo)
Definition: decode.c:6278
Definition: crypt.c:44
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
static MONITORINFO mi
Definition: win.c:7331
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
const GUID * guid
unsigned int BOOL
Definition: ntddk_ex.h:94
#define FIXME(fmt,...)
Definition: debug.h:110
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
GLsizeiptr size
Definition: glext.h:5919
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned long DWORD
Definition: ntddk_ex.h:95
NTSYSAPI NTSTATUS WINAPI RtlGUIDFromString(PUNICODE_STRING, GUID *)
#define SetLastError(x)
Definition: compat.h:409
Definition: cookie.c:170
int ret
uint32_t entry
Definition: isohybrid.c:63
#define ERR(fmt,...)
Definition: debug.h:109
uint32_t cc
Definition: isohybrid.c:75
#define CRYPT_E_ATTRIBUTES_MISSING
Definition: winerror.h:2999
#define CRYPTCAT_MAGIC
Definition: crypt.c:41
#define HeapReAlloc
Definition: compat.h:393
#define CAT_MEMBERINFO_OBJID
Definition: wintrust.h:499
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define SPC_INDIRECT_DATA_OBJID
Definition: wintrust.h:481
Definition: wincrypt.h:723
#define HeapFree(x, y, z)
Definition: compat.h:394
#define ERROR_OUTOFMEMORY
Definition: deptool.c:13

Referenced by CryptCATAdminEnumCatalogFromHash(), and InitFunctionPtrs().

◆ CryptCATGetAttrInfo()

CRYPTCATATTRIBUTE* WINAPI CryptCATGetAttrInfo ( HANDLE  hCatalog,
CRYPTCATMEMBER member,
LPWSTR  tag 
)

Definition at line 553 of file crypt.c.

554 {
555  struct cryptcat *cc = hCatalog;
556 
557  FIXME("%p, %p, %s\n", hCatalog, member, debugstr_w(tag));
558 
559  if (!hCatalog || hCatalog == INVALID_HANDLE_VALUE || cc->magic != CRYPTCAT_MAGIC)
560  {
562  return NULL;
563  }
565  return NULL;
566 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define CRYPT_E_NOT_FOUND
Definition: winerror.h:3007
Definition: crypt.c:44
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
Definition: ecma_167.h:138
#define debugstr_w
Definition: kernel32.h:32
#define FIXME(fmt,...)
Definition: debug.h:110
smooth NULL
Definition: ftsmooth.c:416
#define SetLastError(x)
Definition: compat.h:409
uint32_t cc
Definition: isohybrid.c:75
#define CRYPTCAT_MAGIC
Definition: crypt.c:41

◆ CryptCATGetCatAttrInfo()

CRYPTCATATTRIBUTE* WINAPI CryptCATGetCatAttrInfo ( HANDLE  hCatalog,
LPWSTR  tag 
)

Definition at line 571 of file crypt.c.

572 {
573  struct cryptcat *cc = hCatalog;
574 
575  FIXME("%p, %s\n", hCatalog, debugstr_w(tag));
576 
577  if (!hCatalog || hCatalog == INVALID_HANDLE_VALUE || cc->magic != CRYPTCAT_MAGIC)
578  {
580  return NULL;
581  }
583  return NULL;
584 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define CRYPT_E_NOT_FOUND
Definition: winerror.h:3007
Definition: crypt.c:44
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
Definition: ecma_167.h:138
#define debugstr_w
Definition: kernel32.h:32
#define FIXME(fmt,...)
Definition: debug.h:110
smooth NULL
Definition: ftsmooth.c:416
#define SetLastError(x)
Definition: compat.h:409
uint32_t cc
Definition: isohybrid.c:75
#define CRYPTCAT_MAGIC
Definition: crypt.c:41

◆ CryptCATGetMemberInfo()

CRYPTCATMEMBER* WINAPI CryptCATGetMemberInfo ( HANDLE  hCatalog,
LPWSTR  tag 
)

Definition at line 586 of file crypt.c.

587 {
588  struct cryptcat *cc = hCatalog;
589 
590  FIXME("%p, %s\n", hCatalog, debugstr_w(tag));
591 
592  if (!hCatalog || hCatalog == INVALID_HANDLE_VALUE || cc->magic != CRYPTCAT_MAGIC)
593  {
595  return NULL;
596  }
598  return NULL;
599 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define CRYPT_E_NOT_FOUND
Definition: winerror.h:3007
Definition: crypt.c:44
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
Definition: ecma_167.h:138
#define debugstr_w
Definition: kernel32.h:32
#define FIXME(fmt,...)
Definition: debug.h:110
smooth NULL
Definition: ftsmooth.c:416
#define SetLastError(x)
Definition: compat.h:409
uint32_t cc
Definition: isohybrid.c:75
#define CRYPTCAT_MAGIC
Definition: crypt.c:41

◆ CryptCATOpen()

HANDLE WINAPI CryptCATOpen ( LPWSTR  pwszFileName,
DWORD  fdwOpenFlags,
HCRYPTPROV  hProv,
DWORD  dwPublicVersion,
DWORD  dwEncodingType 
)

Definition at line 844 of file crypt.c.

846 {
847  HANDLE file, hmsg;
848  BYTE *buffer = NULL;
850  struct cryptcat *cc;
851 
852  TRACE("%s, %x, %lx, %x, %x\n", debugstr_w(pwszFileName), fdwOpenFlags,
853  hProv, dwPublicVersion, dwEncodingType);
854 
855  if (!pwszFileName)
856  {
858  return INVALID_HANDLE_VALUE;
859  }
860 
862 
863  if (fdwOpenFlags & CRYPTCAT_OPEN_ALWAYS) flags |= OPEN_ALWAYS;
864  if (fdwOpenFlags & CRYPTCAT_OPEN_CREATENEW) flags |= CREATE_NEW;
865 
866  file = CreateFileW(pwszFileName, GENERIC_READ, FILE_SHARE_READ, NULL, flags, 0, NULL);
868 
870  if (!(buffer = HeapAlloc(GetProcessHeap(), 0, size)))
871  {
872  CloseHandle(file);
874  return INVALID_HANDLE_VALUE;
875  }
876  if (!(hmsg = CryptMsgOpenToDecode(dwEncodingType, 0, 0, hProv, NULL, NULL)))
877  {
878  CloseHandle(file);
880  return INVALID_HANDLE_VALUE;
881  }
882  if (!ReadFile(file, buffer, size, &size, NULL) || !CryptMsgUpdate(hmsg, buffer, size, TRUE))
883  {
884  CloseHandle(file);
886  CryptMsgClose(hmsg);
887  return INVALID_HANDLE_VALUE;
888  }
890  CloseHandle(file);
891 
892  size = sizeof(DWORD);
893  if (!(cc = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*cc))))
894  {
895  CryptMsgClose(hmsg);
897  return INVALID_HANDLE_VALUE;
898  }
899 
900  cc->msg = hmsg;
901  cc->encoding = dwEncodingType;
902  if (CryptMsgGetParam(hmsg, CMSG_ATTR_CERT_COUNT_PARAM, 0, &cc->attr_count, &size))
903  {
904  DWORD i, sum = 0;
905  BYTE *p;
906 
907  for (i = 0; i < cc->attr_count; i++)
908  {
910  {
911  CryptMsgClose(hmsg);
912  HeapFree(GetProcessHeap(), 0, cc);
913  return INVALID_HANDLE_VALUE;
914  }
915  sum += size;
916  }
917  if (!(cc->attr = HeapAlloc(GetProcessHeap(), 0, sizeof(*cc->attr) * cc->attr_count + sum)))
918  {
919  CryptMsgClose(hmsg);
920  HeapFree(GetProcessHeap(), 0, cc);
922  return INVALID_HANDLE_VALUE;
923  }
924  p = (BYTE *)(cc->attr + cc->attr_count);
925  for (i = 0; i < cc->attr_count; i++)
926  {
928  {
929  CryptMsgClose(hmsg);
930  HeapFree(GetProcessHeap(), 0, cc->attr);
931  HeapFree(GetProcessHeap(), 0, cc);
932  return INVALID_HANDLE_VALUE;
933  }
934  if (!CryptMsgGetParam(hmsg, CMSG_ATTR_CERT_PARAM, i, p, &size))
935  {
936  CryptMsgClose(hmsg);
937  HeapFree(GetProcessHeap(), 0, cc->attr);
938  HeapFree(GetProcessHeap(), 0, cc);
939  return INVALID_HANDLE_VALUE;
940  }
941  p += size;
942  }
943  cc->inner = decode_inner_content(hmsg, dwEncodingType, &cc->inner_len);
944  if (!cc->inner || !CryptSIPRetrieveSubjectGuid(pwszFileName, NULL, &cc->subject))
945  {
946  CryptMsgClose(hmsg);
947  HeapFree(GetProcessHeap(), 0, cc->attr);
948  HeapFree(GetProcessHeap(), 0, cc->inner);
949  HeapFree(GetProcessHeap(), 0, cc);
950  return INVALID_HANDLE_VALUE;
951  }
952  cc->magic = CRYPTCAT_MAGIC;
953  return cc;
954  }
955  HeapFree(GetProcessHeap(), 0, cc);
956  return INVALID_HANDLE_VALUE;
957 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define TRUE
Definition: types.h:120
#define CloseHandle
Definition: compat.h:398
#define CMSG_ATTR_CERT_COUNT_PARAM
Definition: wincrypt.h:3951
Definition: crypt.c:44
BOOL WINAPI CryptSIPRetrieveSubjectGuid(LPCWSTR FileName, HANDLE hFileIn, GUID *pgSubject)
Definition: sip.c:310
#define CMSG_ATTR_CERT_PARAM
Definition: wincrypt.h:3952
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
GLuint buffer
Definition: glext.h:5915
#define PKCS_7_ASN_ENCODING
Definition: wincrypt.h:2299
#define FILE_SHARE_READ
Definition: compat.h:125
static HCRYPTPROV hProv
Definition: rsaenh.c:32
HCRYPTMSG WINAPI CryptMsgOpenToDecode(DWORD dwMsgEncodingType, DWORD dwFlags, DWORD dwMsgType, HCRYPTPROV_LEGACY hCryptProv, PCERT_INFO pRecipientInfo, PCMSG_STREAM_INFO pStreamInfo)
Definition: msg.c:3553
static DWORD
Definition: crypt.c:45
#define X509_ASN_ENCODING
Definition: wincrypt.h:2297
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
_In_ DWORD dwEncodingType
Definition: wincrypt.h:4629
#define debugstr_w
Definition: kernel32.h:32
#define CRYPTCAT_OPEN_CREATENEW
Definition: mscat.h:31
smooth NULL
Definition: ftsmooth.c:416
static int sum(int x_, int y_)
Definition: ptr2_test.cpp:35
#define OPEN_EXISTING
Definition: compat.h:426
#define TRACE(s)
Definition: solgame.cpp:4
GLsizeiptr size
Definition: glext.h:5919
#define GetProcessHeap()
Definition: compat.h:395
#define CRYPTCAT_OPEN_ALWAYS
Definition: mscat.h:32
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
const char file[]
Definition: icontest.c:11
unsigned long DWORD
Definition: ntddk_ex.h:95
DWORD WINAPI GetFileSize(HANDLE hFile, LPDWORD lpFileSizeHigh)
Definition: fileinfo.c:481
#define SetLastError(x)
Definition: compat.h:409
#define OPEN_ALWAYS
Definition: disk.h:70
GLbitfield flags
Definition: glext.h:7161
unsigned char BYTE
Definition: mem.h:68
#define GENERIC_READ
Definition: compat.h:124
static CTL_INFO * decode_inner_content(HANDLE hmsg, DWORD encoding, DWORD *len)
Definition: crypt.c:786
uint32_t cc
Definition: isohybrid.c:75
#define CRYPTCAT_MAGIC
Definition: crypt.c:41
#define HEAP_ZERO_MEMORY
Definition: compat.h:123
#define CreateFileW
Definition: compat.h:400
BOOL WINAPI CryptMsgClose(HCRYPTMSG hCryptMsg)
Definition: msg.c:3598
BOOL WINAPI CryptMsgUpdate(HCRYPTMSG hCryptMsg, const BYTE *pbData, DWORD cbData, BOOL fFinal)
Definition: msg.c:3617
BOOL WINAPI CryptMsgGetParam(HCRYPTMSG hCryptMsg, DWORD dwParamType, DWORD dwIndex, void *pvData, DWORD *pcbData)
Definition: msg.c:3627
#define CREATE_NEW
Definition: disk.h:69
GLfloat GLfloat p
Definition: glext.h:8902
BOOL WINAPI ReadFile(IN HANDLE hFile, IN LPVOID lpBuffer, IN DWORD nNumberOfBytesToRead, OUT LPDWORD lpNumberOfBytesRead OPTIONAL, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: rw.c:123
#define HeapFree(x, y, z)
Definition: compat.h:394
#define ERROR_OUTOFMEMORY
Definition: deptool.c:13
Definition: fci.c:126

Referenced by CryptCATAdminEnumCatalogFromHash(), and InitFunctionPtrs().

◆ CryptSIPCreateIndirectData()

BOOL WINAPI CryptSIPCreateIndirectData ( SIP_SUBJECTINFO pSubjectInfo,
DWORD pcbIndirectData,
SIP_INDIRECT_DATA pIndirectData 
)

Definition at line 962 of file crypt.c.

964 {
965  FIXME("(%p %p %p) stub\n", pSubjectInfo, pcbIndirectData, pIndirectData);
966 
967  return FALSE;
968 }
#define FIXME(fmt,...)
Definition: debug.h:110

◆ CryptSIPGetSignedDataMsg()

BOOL WINAPI CryptSIPGetSignedDataMsg ( SIP_SUBJECTINFO pSubjectInfo,
DWORD pdwEncodingType,
DWORD  dwIndex,
DWORD pcbSignedDataMsg,
BYTE pbSignedDataMsg 
)

Definition at line 1365 of file crypt.c.

1367 {
1368  BOOL ret;
1369 
1370  TRACE("(%p %p %d %p %p)\n", pSubjectInfo, pdwEncodingType, dwIndex,
1371  pcbSignedDataMsg, pbSignedDataMsg);
1372 
1373  if(!pSubjectInfo)
1374  {
1376  return FALSE;
1377  }
1378 
1379  if (!memcmp(pSubjectInfo->pgSubjectType, &unknown, sizeof(unknown)))
1380  ret = WINTRUST_GetSignedMsgFromPEFile(pSubjectInfo, pdwEncodingType,
1381  dwIndex, pcbSignedDataMsg, pbSignedDataMsg);
1382  else if (!memcmp(pSubjectInfo->pgSubjectType, &cabGUID, sizeof(cabGUID)))
1383  ret = WINTRUST_GetSignedMsgFromCabFile(pSubjectInfo, pdwEncodingType,
1384  dwIndex, pcbSignedDataMsg, pbSignedDataMsg);
1385  else if (!memcmp(pSubjectInfo->pgSubjectType, &catGUID, sizeof(catGUID)))
1386  ret = WINTRUST_GetSignedMsgFromCatFile(pSubjectInfo, pdwEncodingType,
1387  dwIndex, pcbSignedDataMsg, pbSignedDataMsg);
1388  else
1389  {
1390  FIXME("unimplemented for subject type %s\n",
1391  debugstr_guid(pSubjectInfo->pgSubjectType));
1392  ret = FALSE;
1393  }
1394 
1395  TRACE("returning %d\n", ret);
1396  return ret;
1397 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
static const GUID unknown
Definition: crypt.c:1355
static const GUID catGUID
Definition: crypt.c:1359
unsigned int BOOL
Definition: ntddk_ex.h:94
#define FIXME(fmt,...)
Definition: debug.h:110
#define debugstr_guid
Definition: kernel32.h:35
static const GUID cabGUID
Definition: crypt.c:1357
#define TRACE(s)
Definition: solgame.cpp:4
GUID * pgSubjectType
Definition: mssip.h:52
#define SetLastError(x)
Definition: compat.h:409
int ret
static BOOL WINTRUST_GetSignedMsgFromPEFile(SIP_SUBJECTINFO *pSubjectInfo, DWORD *pdwEncodingType, DWORD dwIndex, DWORD *pcbSignedDataMsg, BYTE *pbSignedDataMsg)
Definition: crypt.c:1018
static BOOL WINTRUST_GetSignedMsgFromCatFile(SIP_SUBJECTINFO *pSubjectInfo, DWORD *pdwEncodingType, DWORD dwIndex, DWORD *pcbSignedDataMsg, BYTE *pbSignedDataMsg)
Definition: crypt.c:1319
static BOOL WINTRUST_GetSignedMsgFromCabFile(SIP_SUBJECTINFO *pSubjectInfo, DWORD *pdwEncodingType, DWORD dwIndex, DWORD *pcbSignedDataMsg, BYTE *pbSignedDataMsg)
Definition: crypt.c:1177

◆ CryptSIPPutSignedDataMsg()

BOOL WINAPI CryptSIPPutSignedDataMsg ( SIP_SUBJECTINFO pSubjectInfo,
DWORD  pdwEncodingType,
DWORD pdwIndex,
DWORD  cbSignedDataMsg,
BYTE pbSignedDataMsg 
)

Definition at line 1402 of file crypt.c.

1404 {
1405  TRACE("(%p %d %p %d %p)\n", pSubjectInfo, pdwEncodingType, pdwIndex,
1406  cbSignedDataMsg, pbSignedDataMsg);
1407 
1408  if(!pSubjectInfo) {
1410  return FALSE;
1411  }
1412 
1413  if(!memcmp(pSubjectInfo->pgSubjectType, &unknown, sizeof(unknown)))
1414  return WINTRUST_PutSignedMsgToPEFile(pSubjectInfo, pdwEncodingType,
1415  pdwIndex, cbSignedDataMsg, pbSignedDataMsg);
1416  else
1417  FIXME("unimplemented for subject type %s\n",
1418  debugstr_guid(pSubjectInfo->pgSubjectType));
1419 
1420  return FALSE;
1421 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
static const GUID unknown
Definition: crypt.c:1355
#define FIXME(fmt,...)
Definition: debug.h:110
#define debugstr_guid
Definition: kernel32.h:35
#define TRACE(s)
Definition: solgame.cpp:4
GUID * pgSubjectType
Definition: mssip.h:52
#define SetLastError(x)
Definition: compat.h:409
static BOOL WINTRUST_PutSignedMsgToPEFile(SIP_SUBJECTINFO *pSubjectInfo, DWORD pdwEncodingType, DWORD *pdwIndex, DWORD cbSignedDataMsg, BYTE *pbSignedDataMsg)
Definition: crypt.c:1109

◆ CryptSIPRemoveSignedDataMsg()

BOOL WINAPI CryptSIPRemoveSignedDataMsg ( SIP_SUBJECTINFO pSubjectInfo,
DWORD  dwIndex 
)

Definition at line 1426 of file crypt.c.

1428 {
1429  FIXME("(%p %d) stub\n", pSubjectInfo, dwIndex);
1430 
1431  return FALSE;
1432 }
#define FIXME(fmt,...)
Definition: debug.h:110

◆ CryptSIPVerifyIndirectData()

BOOL WINAPI CryptSIPVerifyIndirectData ( SIP_SUBJECTINFO pSubjectInfo,
SIP_INDIRECT_DATA pIndirectData 
)

Definition at line 1437 of file crypt.c.

1439 {
1440  FIXME("(%p %p) stub\n", pSubjectInfo, pIndirectData);
1441 
1442  return FALSE;
1443 }
#define FIXME(fmt,...)
Definition: debug.h:110

◆ decode_inner_content()

static CTL_INFO* decode_inner_content ( HANDLE  hmsg,
DWORD  encoding,
DWORD len 
)
static

Definition at line 786 of file crypt.c.

787 {
788  DWORD size;
789  LPSTR oid = NULL;
790  BYTE *buffer = NULL;
791  CTL_INFO *inner = NULL;
792 
793  if (!CryptMsgGetParam(hmsg, CMSG_INNER_CONTENT_TYPE_PARAM, 0, NULL, &size)) return NULL;
794  if (!(oid = HeapAlloc(GetProcessHeap(), 0, size)))
795  {
797  return NULL;
798  }
799  if (!CryptMsgGetParam(hmsg, CMSG_INNER_CONTENT_TYPE_PARAM, 0, oid, &size)) goto out;
800  if (!CryptMsgGetParam(hmsg, CMSG_CONTENT_PARAM, 0, NULL, &size)) goto out;
801  if (!(buffer = HeapAlloc(GetProcessHeap(), 0, size)))
802  {
804  goto out;
805  }
806  if (!CryptMsgGetParam(hmsg, CMSG_CONTENT_PARAM, 0, buffer, &size)) goto out;
807  if (!CryptDecodeObject(encoding, oid, buffer, size, 0, NULL, &size)) goto out;
808  if (!(inner = HeapAlloc(GetProcessHeap(), 0, size)))
809  {
811  goto out;
812  }
813  if (!CryptDecodeObject(encoding, oid, buffer, size, 0, inner, &size)) goto out;
814  *len = size;
815 
816 out:
817  HeapFree(GetProcessHeap(), 0, oid);
819  return inner;
820 }
BOOL WINAPI CryptDecodeObject(DWORD dwCertEncodingType, LPCSTR lpszStructType, const BYTE *pbEncoded, DWORD cbEncoded, DWORD dwFlags, void *pvStructInfo, DWORD *pcbStructInfo)
Definition: decode.c:6278
GLuint buffer
Definition: glext.h:5915
char * LPSTR
Definition: xmlstorage.h:182
#define CMSG_INNER_CONTENT_TYPE_PARAM
Definition: wincrypt.h:3928
smooth NULL
Definition: ftsmooth.c:416
CTL_INFO * inner
Definition: crypt.c:49
GLsizeiptr size
Definition: glext.h:5919
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
static FILE * out
Definition: regtests2xml.c:44
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:409
GLenum GLsizei len
Definition: glext.h:6722
unsigned char BYTE
Definition: mem.h:68
ed encoding
Definition: write.c:2847
#define CMSG_CONTENT_PARAM
Definition: wincrypt.h:3926
BOOL WINAPI CryptMsgGetParam(HCRYPTMSG hCryptMsg, DWORD dwParamType, DWORD dwIndex, void *pvData, DWORD *pcbData)
Definition: msg.c:3627
#define HeapFree(x, y, z)
Definition: compat.h:394
#define ERROR_OUTOFMEMORY
Definition: deptool.c:13

Referenced by CryptCATOpen().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( wintrust  )

◆ WINTRUST_GetSignedMsgFromCabFile()

static BOOL WINTRUST_GetSignedMsgFromCabFile ( SIP_SUBJECTINFO pSubjectInfo,
DWORD pdwEncodingType,
DWORD  dwIndex,
DWORD pcbSignedDataMsg,
BYTE pbSignedDataMsg 
)
static

Definition at line 1177 of file crypt.c.

1180 {
1181  int header_resv;
1182  LONG base_offset, cabsize;
1183  USHORT flags;
1184  BYTE buf[64];
1185  DWORD cert_offset, cert_size, dwRead;
1186 
1187  TRACE("(%p %p %d %p %p)\n", pSubjectInfo, pdwEncodingType, dwIndex,
1188  pcbSignedDataMsg, pbSignedDataMsg);
1189 
1190  /* get basic offset & size info */
1191  base_offset = SetFilePointer(pSubjectInfo->hFile, 0L, NULL, SEEK_CUR);
1192 
1193  if (SetFilePointer(pSubjectInfo->hFile, 0, NULL, SEEK_END) == INVALID_SET_FILE_POINTER)
1194  {
1195  TRACE("seek error\n");
1196  return FALSE;
1197  }
1198 
1199  cabsize = SetFilePointer(pSubjectInfo->hFile, 0L, NULL, SEEK_CUR);
1200  if ((cabsize == -1) || (base_offset == -1) ||
1201  (SetFilePointer(pSubjectInfo->hFile, 0, NULL, SEEK_SET) == INVALID_SET_FILE_POINTER))
1202  {
1203  TRACE("seek error\n");
1204  return FALSE;
1205  }
1206 
1207  /* read in the CFHEADER */
1208  if (!ReadFile(pSubjectInfo->hFile, buf, cfhead_SIZEOF, &dwRead, NULL) ||
1209  dwRead != cfhead_SIZEOF)
1210  {
1211  TRACE("reading header failed\n");
1212  return FALSE;
1213  }
1214 
1215  /* check basic MSCF signature */
1216  if (EndGetI32(buf+cfhead_Signature) != 0x4643534d)
1217  {
1218  WARN("cabinet signature not present\n");
1219  return FALSE;
1220  }
1221 
1222  /* Ignore the number of folders and files and the set and cabinet IDs */
1223 
1224  /* check the header revision */
1225  if ((buf[cfhead_MajorVersion] > 1) ||
1227  {
1228  WARN("cabinet format version > 1.3\n");
1229  return FALSE;
1230  }
1231 
1232  /* pull the flags out */
1234 
1235  if (!(flags & cfheadRESERVE_PRESENT))
1236  {
1237  TRACE("no header present, not signed\n");
1238  return FALSE;
1239  }
1240 
1241  if (!ReadFile(pSubjectInfo->hFile, buf, cfheadext_SIZEOF, &dwRead, NULL) ||
1242  dwRead != cfheadext_SIZEOF)
1243  {
1244  ERR("bunk reserve-sizes?\n");
1245  return FALSE;
1246  }
1247 
1248  header_resv = EndGetI16(buf+cfheadext_HeaderReserved);
1249  if (!header_resv)
1250  {
1251  TRACE("no header_resv, not signed\n");
1252  return FALSE;
1253  }
1254  else if (header_resv < cfsigninfo_SIZEOF)
1255  {
1256  TRACE("header_resv too small, not signed\n");
1257  return FALSE;
1258  }
1259 
1260  if (header_resv > 60000)
1261  {
1262  WARN("WARNING; header reserved space > 60000\n");
1263  }
1264 
1265  if (!ReadFile(pSubjectInfo->hFile, buf, cfsigninfo_SIZEOF, &dwRead, NULL) ||
1266  dwRead != cfsigninfo_SIZEOF)
1267  {
1268  ERR("couldn't read reserve\n");
1269  return FALSE;
1270  }
1271 
1272  cert_offset = EndGetI32(buf+cfsigninfo_CertOffset);
1273  TRACE("cert_offset: %d\n", cert_offset);
1274  cert_size = EndGetI32(buf+cfsigninfo_CertSize);
1275  TRACE("cert_size: %d\n", cert_size);
1276 
1277  /* The redundant checks are to avoid wraparound */
1278  if (cert_offset > cabsize || cert_size > cabsize ||
1279  cert_offset + cert_size > cabsize)
1280  {
1281  WARN("offset beyond file, not attempting to read\n");
1282  return FALSE;
1283  }
1284 
1285  SetFilePointer(pSubjectInfo->hFile, base_offset, NULL, SEEK_SET);
1286  if (!pbSignedDataMsg)
1287  {
1288  *pcbSignedDataMsg = cert_size;
1289  return TRUE;
1290  }
1291  if (*pcbSignedDataMsg < cert_size)
1292  {
1293  *pcbSignedDataMsg = cert_size;
1295  return FALSE;
1296  }
1297  if (SetFilePointer(pSubjectInfo->hFile, cert_offset, NULL, SEEK_SET) == INVALID_SET_FILE_POINTER)
1298  {
1299  ERR("couldn't seek to cert location\n");
1300  return FALSE;
1301  }
1302  if (!ReadFile(pSubjectInfo->hFile, pbSignedDataMsg, cert_size, &dwRead,
1303  NULL) || dwRead != cert_size)
1304  {
1305  ERR("couldn't read cert\n");
1306  SetFilePointer(pSubjectInfo->hFile, base_offset, NULL, SEEK_SET);
1307  return FALSE;
1308  }
1309  /* The encoding of the files I've seen appears to be in ASN.1
1310  * format, and there isn't a field indicating the type, so assume it
1311  * always is.
1312  */
1313  *pdwEncodingType = X509_ASN_ENCODING | PKCS_7_ASN_ENCODING;
1314  /* Restore base offset */
1315  SetFilePointer(pSubjectInfo->hFile, base_offset, NULL, SEEK_SET);
1316  return TRUE;
1317 }
#define SEEK_CUR
Definition: util.h:63
#define TRUE
Definition: types.h:120
#define INVALID_SET_FILE_POINTER
Definition: winbase.h:115
#define cfheadext_SIZEOF
Definition: crypt.c:1153
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
#define cfhead_MinorVersion
Definition: crypt.c:1148
HANDLE hFile
Definition: mssip.h:53
#define WARN(fmt,...)
Definition: debug.h:111
#define cfheadext_HeaderReserved
Definition: crypt.c:1152
#define PKCS_7_ASN_ENCODING
Definition: wincrypt.h:2299
#define EndGetI32(a)
Definition: crypt.c:1162
DWORD WINAPI DECLSPEC_HOTPATCH SetFilePointer(HANDLE hFile, LONG lDistanceToMove, PLONG lpDistanceToMoveHigh, DWORD dwMoveMethod)
Definition: fileinfo.c:204
#define X509_ASN_ENCODING
Definition: wincrypt.h:2297
#define cfsigninfo_SIZEOF
Definition: crypt.c:1156
long LONG
Definition: pedump.c:60
#define cfhead_Signature
Definition: crypt.c:1146
smooth NULL
Definition: ftsmooth.c:416
#define SEEK_SET
Definition: jmemansi.c:26
#define TRACE(s)
Definition: solgame.cpp:4
#define cfsigninfo_CertSize
Definition: crypt.c:1155
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:409
GLbitfield flags
Definition: glext.h:7161
static const WCHAR L[]
Definition: oid.c:1250
#define cfhead_SIZEOF
Definition: crypt.c:1151
unsigned char BYTE
Definition: mem.h:68
#define ERR(fmt,...)
Definition: debug.h:109
#define EndGetI16(a)
Definition: crypt.c:1163
#define cfhead_Flags
Definition: crypt.c:1150
unsigned short USHORT
Definition: pedump.c:61
#define cfheadRESERVE_PRESENT
Definition: crypt.c:1159
#define cfhead_MajorVersion
Definition: crypt.c:1149
#define SEEK_END
Definition: cabinet.c:27
BOOL WINAPI ReadFile(IN HANDLE hFile, IN LPVOID lpBuffer, IN DWORD nNumberOfBytesToRead, OUT LPDWORD lpNumberOfBytesRead OPTIONAL, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: rw.c:123
#define cfsigninfo_CertOffset
Definition: crypt.c:1154
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10

Referenced by CryptSIPGetSignedDataMsg().

◆ WINTRUST_GetSignedMsgFromCatFile()

static BOOL WINTRUST_GetSignedMsgFromCatFile ( SIP_SUBJECTINFO pSubjectInfo,
DWORD pdwEncodingType,
DWORD  dwIndex,
DWORD pcbSignedDataMsg,
BYTE pbSignedDataMsg 
)
static

Definition at line 1319 of file crypt.c.

1322 {
1323  BOOL ret;
1324 
1325  TRACE("(%p %p %d %p %p)\n", pSubjectInfo, pdwEncodingType, dwIndex,
1326  pcbSignedDataMsg, pbSignedDataMsg);
1327 
1328  if (!pbSignedDataMsg)
1329  {
1330  *pcbSignedDataMsg = GetFileSize(pSubjectInfo->hFile, NULL);
1331  ret = TRUE;
1332  }
1333  else
1334  {
1335  DWORD len = GetFileSize(pSubjectInfo->hFile, NULL);
1336 
1337  if (*pcbSignedDataMsg < len)
1338  {
1339  *pcbSignedDataMsg = len;
1341  ret = FALSE;
1342  }
1343  else
1344  {
1345  ret = ReadFile(pSubjectInfo->hFile, pbSignedDataMsg, len,
1346  pcbSignedDataMsg, NULL);
1347  if (ret)
1348  *pdwEncodingType = X509_ASN_ENCODING | PKCS_7_ASN_ENCODING;
1349  }
1350  }
1351  return ret;
1352 }
#define TRUE
Definition: types.h:120
HANDLE hFile
Definition: mssip.h:53
#define PKCS_7_ASN_ENCODING
Definition: wincrypt.h:2299
#define X509_ASN_ENCODING
Definition: wincrypt.h:2297
unsigned int BOOL
Definition: ntddk_ex.h:94
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
unsigned long DWORD
Definition: ntddk_ex.h:95
DWORD WINAPI GetFileSize(HANDLE hFile, LPDWORD lpFileSizeHigh)
Definition: fileinfo.c:481
#define SetLastError(x)
Definition: compat.h:409
int ret
GLenum GLsizei len
Definition: glext.h:6722
BOOL WINAPI ReadFile(IN HANDLE hFile, IN LPVOID lpBuffer, IN DWORD nNumberOfBytesToRead, OUT LPDWORD lpNumberOfBytesRead OPTIONAL, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: rw.c:123
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10

Referenced by CryptSIPGetSignedDataMsg().

◆ WINTRUST_GetSignedMsgFromPEFile()

static BOOL WINTRUST_GetSignedMsgFromPEFile ( SIP_SUBJECTINFO pSubjectInfo,
DWORD pdwEncodingType,
DWORD  dwIndex,
DWORD pcbSignedDataMsg,
BYTE pbSignedDataMsg 
)
static

Definition at line 1018 of file crypt.c.

1021 {
1022  BOOL ret;
1023  WIN_CERTIFICATE *pCert = NULL;
1024  HANDLE file;
1025 
1026  TRACE("(%p %p %d %p %p)\n", pSubjectInfo, pdwEncodingType, dwIndex,
1027  pcbSignedDataMsg, pbSignedDataMsg);
1028 
1029  if(pSubjectInfo->hFile && pSubjectInfo->hFile!=INVALID_HANDLE_VALUE)
1030  file = pSubjectInfo->hFile;
1031  else
1032  {
1033  file = CreateFileW(pSubjectInfo->pwsFileName, GENERIC_READ,
1035  if(file == INVALID_HANDLE_VALUE)
1036  return FALSE;
1037  }
1038 
1039  if (!pbSignedDataMsg)
1040  {
1042 
1043  /* app hasn't passed buffer, just get the length */
1044  ret = ImageGetCertificateHeader(file, dwIndex, &cert);
1045  if (ret)
1046  {
1047  switch (cert.wCertificateType)
1048  {
1049  case WIN_CERT_TYPE_X509:
1051  *pcbSignedDataMsg = cert.dwLength;
1052  break;
1053  default:
1054  WARN("unknown certificate type %d\n", cert.wCertificateType);
1055  ret = FALSE;
1056  }
1057  }
1058  }
1059  else
1060  {
1061  DWORD len = 0;
1062 
1063  ret = ImageGetCertificateData(file, dwIndex, NULL, &len);
1065  goto error;
1066  pCert = HeapAlloc(GetProcessHeap(), 0, len);
1067  if (!pCert)
1068  {
1069  ret = FALSE;
1070  goto error;
1071  }
1072  ret = ImageGetCertificateData(file, dwIndex, pCert, &len);
1073  if (!ret)
1074  goto error;
1075  pCert->dwLength -= FIELD_OFFSET(WIN_CERTIFICATE, bCertificate);
1076  if (*pcbSignedDataMsg < pCert->dwLength)
1077  {
1078  *pcbSignedDataMsg = pCert->dwLength;
1080  ret = FALSE;
1081  }
1082  else
1083  {
1084  memcpy(pbSignedDataMsg, pCert->bCertificate, pCert->dwLength);
1085  *pcbSignedDataMsg = pCert->dwLength;
1086  switch (pCert->wCertificateType)
1087  {
1088  case WIN_CERT_TYPE_X509:
1089  *pdwEncodingType = X509_ASN_ENCODING;
1090  break;
1092  *pdwEncodingType = X509_ASN_ENCODING | PKCS_7_ASN_ENCODING;
1093  break;
1094  default:
1095  WARN("don't know what to do for encoding type %d\n",
1096  pCert->wCertificateType);
1097  *pdwEncodingType = 0;
1098  ret = FALSE;
1099  }
1100  }
1101  }
1102 error:
1103  if(pSubjectInfo->hFile != file)
1104  CloseHandle(file);
1105  HeapFree(GetProcessHeap(), 0, pCert);
1106  return ret;
1107 }
#define CloseHandle
Definition: compat.h:398
#define error(str)
Definition: mkdosfs.c:1605
HANDLE hFile
Definition: mssip.h:53
#define WARN(fmt,...)
Definition: debug.h:111
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
#define PKCS_7_ASN_ENCODING
Definition: wincrypt.h:2299
#define FILE_SHARE_WRITE
Definition: nt_native.h:681
BOOL WINAPI ImageGetCertificateData(HANDLE handle, DWORD Index, LPWIN_CERTIFICATE Certificate, PDWORD RequiredLength)
Definition: integrity.c:553
#define FILE_SHARE_READ
Definition: compat.h:125
#define WIN_CERT_TYPE_X509
Definition: wintrust.h:626
#define X509_ASN_ENCODING
Definition: wincrypt.h:2297
BOOL WINAPI ImageGetCertificateHeader(HANDLE handle, DWORD index, LPWIN_CERTIFICATE pCert)
Definition: integrity.c:604
unsigned int BOOL
Definition: ntddk_ex.h:94
smooth NULL
Definition: ftsmooth.c:416
static BYTE cert[]
Definition: msg.c:1437
#define OPEN_EXISTING
Definition: compat.h:426
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
static DWORD DWORD * dwLength
Definition: fusion.c:83
const char file[]
Definition: icontest.c:11
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:409
int ret
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
GLenum GLsizei len
Definition: glext.h:6722
#define GENERIC_READ
Definition: compat.h:124
UINT16 wCertificateType
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:254
#define CreateFileW
Definition: compat.h:400
#define WIN_CERT_TYPE_PKCS_SIGNED_DATA
LPCWSTR pwsFileName
Definition: mssip.h:54
#define HeapFree(x, y, z)
Definition: compat.h:394
Definition: fci.c:126
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10

Referenced by CryptSIPGetSignedDataMsg().

◆ WINTRUST_PutSignedMsgToPEFile()

static BOOL WINTRUST_PutSignedMsgToPEFile ( SIP_SUBJECTINFO pSubjectInfo,
DWORD  pdwEncodingType,
DWORD pdwIndex,
DWORD  cbSignedDataMsg,
BYTE pbSignedDataMsg 
)
static

Definition at line 1109 of file crypt.c.

1111 {
1113  HANDLE file;
1114  DWORD size;
1115  BOOL ret;
1116 
1117  if(pSubjectInfo->hFile && pSubjectInfo->hFile!=INVALID_HANDLE_VALUE)
1118  file = pSubjectInfo->hFile;
1119  else
1120  {
1123  if(file == INVALID_HANDLE_VALUE)
1124  return FALSE;
1125  }
1126 
1127  /* int aligned WIN_CERTIFICATE structure with cbSignedDataMsg+1 bytes of data */
1128  size = FIELD_OFFSET(WIN_CERTIFICATE, bCertificate[cbSignedDataMsg+4]) & (~3);
1130  if(!cert)
1131  return FALSE;
1132 
1133  cert->dwLength = size;
1134  cert->wRevision = WIN_CERT_REVISION_2_0;
1135  cert->wCertificateType = WIN_CERT_TYPE_PKCS_SIGNED_DATA;
1136  memcpy(cert->bCertificate, pbSignedDataMsg, cbSignedDataMsg);
1137  ret = ImageAddCertificate(file, cert, pdwIndex);
1138 
1139  HeapFree(GetProcessHeap(), 0, cert);
1140  if(file != pSubjectInfo->hFile)
1141  CloseHandle(file);
1142  return ret;
1143 }
#define CloseHandle
Definition: compat.h:398
HANDLE hFile
Definition: mssip.h:53
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
#define FILE_SHARE_WRITE
Definition: nt_native.h:681
#define WIN_CERT_REVISION_2_0
Definition: wintrust.h:624
#define FILE_SHARE_READ
Definition: compat.h:125
unsigned int BOOL
Definition: ntddk_ex.h:94
BOOL WINAPI ImageAddCertificate(HANDLE FileHandle, LPWIN_CERTIFICATE Certificate, PDWORD Index)
Definition: integrity.c:380
#define GENERIC_WRITE
Definition: nt_native.h:90
smooth NULL
Definition: ftsmooth.c:416
static BYTE cert[]
Definition: msg.c:1437
#define OPEN_EXISTING
Definition: compat.h:426
GLsizeiptr size
Definition: glext.h:5919
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
const char file[]
Definition: icontest.c:11
unsigned long DWORD
Definition: ntddk_ex.h:95
int ret
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define GENERIC_READ
Definition: compat.h:124
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:254
#define HEAP_ZERO_MEMORY
Definition: compat.h:123
#define CreateFileW
Definition: compat.h:400
#define WIN_CERT_TYPE_PKCS_SIGNED_DATA
LPCWSTR pwsFileName
Definition: mssip.h:54
#define HeapFree(x, y, z)
Definition: compat.h:394
Definition: fci.c:126

Referenced by CryptSIPPutSignedDataMsg().

Variable Documentation

◆ cabGUID

const GUID cabGUID
static
Initial value:
= { 0xC689AABA, 0x8E78, 0x11D0, { 0x8C,0x47,
0x00,0xC0,0x4F,0xC2,0x95,0xEE } }

Definition at line 1357 of file crypt.c.

Referenced by CryptSIPGetSignedDataMsg(), CryptSIPRetrieveSubjectGuid(), and test_SIPRetrieveSubjectGUID().

◆ catGUID

const GUID catGUID
static
Initial value:
= { 0xDE351A43, 0x8E59, 0x11D0, { 0x8C,0x47,
0x00,0xC0,0x4F,0xC2,0x95,0xEE }}

Definition at line 1359 of file crypt.c.

Referenced by CryptSIPGetSignedDataMsg(), CryptSIPRetrieveSubjectGuid(), and IsCatalogFile().

◆ unknown

const GUID unknown
static
Initial value:
= { 0xC689AAB8, 0x8E78, 0x11D0, { 0x8C,0x47,
0x00,0xC0,0x4F,0xC2,0x95,0xEE } }

Definition at line 1355 of file crypt.c.

Referenced by CryptSIPGetSignedDataMsg(), and CryptSIPPutSignedDataMsg().