ReactOS  0.4.14-dev-323-g6fe6a88
filestore.c File Reference
#include <stdarg.h>
#include "windef.h"
#include "winbase.h"
#include "wincrypt.h"
#include "winnls.h"
#include "wine/debug.h"
#include "wine/unicode.h"
#include "crypt32_private.h"
Include dependency graph for filestore.c:

Go to the source code of this file.

Classes

struct  _WINE_FILESTOREINFO
 

Typedefs

typedef struct _WINE_FILESTOREINFO WINE_FILESTOREINFO
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (crypt)
 
static void WINAPI CRYPT_FileCloseStore (HCERTSTORE hCertStore, DWORD dwFlags)
 
static BOOL WINAPI CRYPT_FileWriteCert (HCERTSTORE hCertStore, PCCERT_CONTEXT cert, DWORD dwFlags)
 
static BOOL WINAPI CRYPT_FileDeleteCert (HCERTSTORE hCertStore, PCCERT_CONTEXT pCertContext, DWORD dwFlags)
 
static BOOL WINAPI CRYPT_FileWriteCRL (HCERTSTORE hCertStore, PCCRL_CONTEXT crl, DWORD dwFlags)
 
static BOOL WINAPI CRYPT_FileDeleteCRL (HCERTSTORE hCertStore, PCCRL_CONTEXT pCrlContext, DWORD dwFlags)
 
static BOOL WINAPI CRYPT_FileWriteCTL (HCERTSTORE hCertStore, PCCTL_CONTEXT ctl, DWORD dwFlags)
 
static BOOL WINAPI CRYPT_FileDeleteCTL (HCERTSTORE hCertStore, PCCTL_CONTEXT pCtlContext, DWORD dwFlags)
 
static BOOL CRYPT_ReadBlobFromFile (HANDLE file, PCERT_BLOB blob)
 
static BOOL WINAPI CRYPT_FileControl (HCERTSTORE hCertStore, DWORD dwFlags, DWORD dwCtrlType, void const *pvCtrlPara)
 
static WINECRYPT_CERTSTORECRYPT_CreateFileStore (DWORD dwFlags, HCERTSTORE memStore, HANDLE file, DWORD type)
 
WINECRYPT_CERTSTORECRYPT_FileOpenStore (HCRYPTPROV hCryptProv, DWORD dwFlags, const void *pvPara)
 
WINECRYPT_CERTSTORECRYPT_FileNameOpenStoreW (HCRYPTPROV hCryptProv, DWORD dwFlags, const void *pvPara)
 
WINECRYPT_CERTSTORECRYPT_FileNameOpenStoreA (HCRYPTPROV hCryptProv, DWORD dwFlags, const void *pvPara)
 

Variables

static voidfileProvFuncs []
 

Typedef Documentation

◆ WINE_FILESTOREINFO

Function Documentation

◆ CRYPT_CreateFileStore()

static WINECRYPT_CERTSTORE* CRYPT_CreateFileStore ( DWORD  dwFlags,
HCERTSTORE  memStore,
HANDLE  file,
DWORD  type 
)
static

Definition at line 218 of file filestore.c.

220 {
221  WINECRYPT_CERTSTORE *store = NULL;
223 
224  if (info)
225  {
226  CERT_STORE_PROV_INFO provInfo = { 0 };
227 
228  info->dwOpenFlags = dwFlags;
229  info->memStore = memStore;
230  info->file = file;
231  info->type = type;
232  info->dirty = FALSE;
233  provInfo.cbSize = sizeof(provInfo);
235  provInfo.rgpvStoreProvFunc = fileProvFuncs;
236  provInfo.hStoreProv = info;
237  store = CRYPT_ProvCreateStore(dwFlags, memStore, &provInfo);
238  }
239  return store;
240 }
HCERTSTOREPROV hStoreProv
Definition: wincrypt.h:1150
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
struct _test_info info[]
Definition: SetCursorPos.c:19
LPVOID WINAPI CryptMemAlloc(ULONG cbSize)
Definition: main.c:131
WINECRYPT_CERTSTORE * CRYPT_ProvCreateStore(DWORD dwFlags, WINECRYPT_CERTSTORE *memStore, const CERT_STORE_PROV_INFO *pProvInfo) DECLSPEC_HIDDEN
Definition: provstore.c:307
void ** rgpvStoreProvFunc
Definition: wincrypt.h:1149
smooth NULL
Definition: ftsmooth.c:416
static void * fileProvFuncs[]
Definition: filestore.c:201
const char file[]
Definition: icontest.c:11
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
#define ARRAY_SIZE(a)
Definition: main.h:24

Referenced by CRYPT_FileNameOpenStoreW(), and CRYPT_FileOpenStore().

◆ CRYPT_FileCloseStore()

static void WINAPI CRYPT_FileCloseStore ( HCERTSTORE  hCertStore,
DWORD  dwFlags 
)
static

Definition at line 38 of file filestore.c.

39 {
40  WINE_FILESTOREINFO *store = hCertStore;
41 
42  TRACE("(%p, %08x)\n", store, dwFlags);
43  if (store->dirty)
45  store->type, CERT_STORE_SAVE_TO_FILE, store->file, 0);
46  CloseHandle(store->file);
47  CryptMemFree(store);
48 }
#define CERT_STORE_SAVE_TO_FILE
Definition: wincrypt.h:2649
#define CloseHandle
Definition: compat.h:398
#define PKCS_7_ASN_ENCODING
Definition: wincrypt.h:2299
#define X509_ASN_ENCODING
Definition: wincrypt.h:2297
HCERTSTORE memStore
Definition: filestore.c:32
#define TRACE(s)
Definition: solgame.cpp:4
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
BOOL WINAPI CertSaveStore(HCERTSTORE hCertStore, DWORD dwMsgAndCertEncodingType, DWORD dwSaveAs, DWORD dwSaveTo, void *pvSaveToPara, DWORD dwFlags)
Definition: serialize.c:895
VOID WINAPI CryptMemFree(LPVOID pv)
Definition: main.c:141

◆ CRYPT_FileControl()

static BOOL WINAPI CRYPT_FileControl ( HCERTSTORE  hCertStore,
DWORD  dwFlags,
DWORD  dwCtrlType,
void const pvCtrlPara 
)
static

Definition at line 131 of file filestore.c.

133 {
134  WINE_FILESTOREINFO *store = hCertStore;
135  BOOL ret;
136 
137  TRACE("(%p, %08x, %d, %p)\n", hCertStore, dwFlags, dwCtrlType,
138  pvCtrlPara);
139 
140  switch (dwCtrlType)
141  {
143  store->dirty = FALSE;
144  if (store->type == CERT_STORE_SAVE_AS_STORE)
145  {
148 
149  /* FIXME: if I could translate a handle to a path, I could use
150  * CryptQueryObject instead, but there's no API to do so yet.
151  */
152  ret = CRYPT_ReadSerializedStoreFromFile(store->file, memStore);
153  if (ret)
154  I_CertUpdateStore(store->memStore, memStore, 0, 0);
155  CertCloseStore(memStore, 0);
156  }
157  else if (store->type == CERT_STORE_SAVE_AS_PKCS7)
158  {
159  CERT_BLOB blob = { 0, NULL };
160 
161  ret = CRYPT_ReadBlobFromFile(store->file, &blob);
162  if (ret)
163  {
164  HCERTSTORE messageStore;
165 
169  &messageStore, NULL, NULL);
170  I_CertUpdateStore(store->memStore, messageStore, 0, 0);
171  CertCloseStore(messageStore, 0);
172  CryptMemFree(blob.pbData);
173  }
174  }
175  else
176  {
177  WARN("unknown type %d\n", store->type);
178  ret = FALSE;
179  }
180  break;
183  {
185  ret = FALSE;
186  }
187  else if (store->dirty)
188  ret = CertSaveStore(store->memStore,
190  store->type, CERT_STORE_SAVE_TO_FILE, store->file, 0);
191  else
192  ret = TRUE;
193  break;
194  default:
195  FIXME("%d: stub\n", dwCtrlType);
196  ret = FALSE;
197  }
198  return ret;
199 }
#define CERT_STORE_SAVE_TO_FILE
Definition: wincrypt.h:2649
#define TRUE
Definition: types.h:120
BOOL CRYPT_ReadSerializedStoreFromFile(HANDLE file, HCERTSTORE store) DECLSPEC_HIDDEN
Definition: serialize.c:544
#define CERT_STORE_CTRL_RESYNC
Definition: wincrypt.h:2820
Definition: image.c:133
#define CERT_QUERY_OBJECT_BLOB
Definition: wincrypt.h:3527
#define WARN(fmt,...)
Definition: debug.h:111
static BOOL CRYPT_ReadBlobFromFile(HANDLE file, PCERT_BLOB blob)
Definition: filestore.c:110
#define PKCS_7_ASN_ENCODING
Definition: wincrypt.h:2299
#define CERT_STORE_CTRL_COMMIT
Definition: wincrypt.h:2822
#define CERT_FILE_STORE_COMMIT_ENABLE_FLAG
Definition: wincrypt.h:2475
#define X509_ASN_ENCODING
Definition: wincrypt.h:2297
#define CERT_STORE_CREATE_NEW_FLAG
Definition: wincrypt.h:2464
unsigned int BOOL
Definition: ntddk_ex.h:94
HCERTSTORE memStore
Definition: filestore.c:32
#define FIXME(fmt,...)
Definition: debug.h:110
#define CERT_STORE_PROV_MEMORY
Definition: wincrypt.h:2251
smooth NULL
Definition: ftsmooth.c:416
BOOL WINAPI CertCloseStore(HCERTSTORE hCertStore, DWORD dwFlags)
Definition: store.c:1127
BOOL WINAPI CryptQueryObject(DWORD dwObjectType, const void *pvObject, DWORD dwExpectedContentTypeFlags, DWORD dwExpectedFormatTypeFlags, DWORD dwFlags, DWORD *pdwMsgAndCertEncodingType, DWORD *pdwContentType, DWORD *pdwFormatType, HCERTSTORE *phCertStore, HCRYPTMSG *phMsg, const void **ppvContext)
Definition: object.c:699
#define TRACE(s)
Definition: solgame.cpp:4
#define CERT_STORE_SAVE_AS_PKCS7
Definition: wincrypt.h:2647
#define CERT_STORE_SAVE_AS_STORE
Definition: wincrypt.h:2646
#define SetLastError(x)
Definition: compat.h:409
#define CERT_QUERY_FORMAT_FLAG_BINARY
Definition: wincrypt.h:3583
int ret
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
BOOL WINAPI CertSaveStore(HCERTSTORE hCertStore, DWORD dwMsgAndCertEncodingType, DWORD dwSaveAs, DWORD dwSaveTo, void *pvSaveToPara, DWORD dwFlags)
Definition: serialize.c:895
BOOL WINAPI I_CertUpdateStore(HCERTSTORE store1, HCERTSTORE store2, DWORD unk0, DWORD unk1) DECLSPEC_HIDDEN
Definition: store.c:109
HCERTSTORE WINAPI CertOpenStore(LPCSTR lpszStoreProvider, DWORD dwMsgAndCertEncodingType, HCRYPTPROV_LEGACY hCryptProv, DWORD dwFlags, const void *pvPara)
Definition: store.c:815
VOID WINAPI CryptMemFree(LPVOID pv)
Definition: main.c:141
#define CERT_QUERY_CONTENT_FLAG_PKCS7_SIGNED
Definition: wincrypt.h:3554
#define ERROR_CALL_NOT_IMPLEMENTED
Definition: compat.h:92

◆ CRYPT_FileDeleteCert()

static BOOL WINAPI CRYPT_FileDeleteCert ( HCERTSTORE  hCertStore,
PCCERT_CONTEXT  pCertContext,
DWORD  dwFlags 
)
static

Definition at line 60 of file filestore.c.

62 {
63  WINE_FILESTOREINFO *store = hCertStore;
64 
65  TRACE("(%p, %p, %08x)\n", hCertStore, pCertContext, dwFlags);
66  store->dirty = TRUE;
67  return TRUE;
68 }
#define TRUE
Definition: types.h:120
#define TRACE(s)
Definition: solgame.cpp:4
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
_In_ PCCERT_CONTEXT pCertContext
Definition: wincrypt.h:4840

◆ CRYPT_FileDeleteCRL()

static BOOL WINAPI CRYPT_FileDeleteCRL ( HCERTSTORE  hCertStore,
PCCRL_CONTEXT  pCrlContext,
DWORD  dwFlags 
)
static

Definition at line 80 of file filestore.c.

82 {
83  WINE_FILESTOREINFO *store = hCertStore;
84 
85  TRACE("(%p, %p, %08x)\n", hCertStore, pCrlContext, dwFlags);
86  store->dirty = TRUE;
87  return TRUE;
88 }
#define TRUE
Definition: types.h:120
#define TRACE(s)
Definition: solgame.cpp:4
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
_In_ PCCRL_CONTEXT pCrlContext
Definition: wincrypt.h:4996

◆ CRYPT_FileDeleteCTL()

static BOOL WINAPI CRYPT_FileDeleteCTL ( HCERTSTORE  hCertStore,
PCCTL_CONTEXT  pCtlContext,
DWORD  dwFlags 
)
static

Definition at line 100 of file filestore.c.

102 {
103  WINE_FILESTOREINFO *store = hCertStore;
104 
105  TRACE("(%p, %p, %08x)\n", hCertStore, pCtlContext, dwFlags);
106  store->dirty = TRUE;
107  return TRUE;
108 }
#define TRUE
Definition: types.h:120
#define TRACE(s)
Definition: solgame.cpp:4
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
_In_ PCCTL_CONTEXT pCtlContext
Definition: wincrypt.h:5005

◆ CRYPT_FileNameOpenStoreA()

WINECRYPT_CERTSTORE* CRYPT_FileNameOpenStoreA ( HCRYPTPROV  hCryptProv,
DWORD  dwFlags,
const void pvPara 
)

Definition at line 383 of file filestore.c.

385 {
386  int len;
388 
389  TRACE("(%ld, %08x, %s)\n", hCryptProv, dwFlags,
390  debugstr_a(pvPara));
391 
392  if (!pvPara)
393  {
395  return NULL;
396  }
397  len = MultiByteToWideChar(CP_ACP, 0, pvPara, -1, NULL, 0);
398  if (len)
399  {
400  LPWSTR storeName = CryptMemAlloc(len * sizeof(WCHAR));
401 
402  if (storeName)
403  {
404  MultiByteToWideChar(CP_ACP, 0, pvPara, -1, storeName, len);
405  ret = CRYPT_FileNameOpenStoreW(hCryptProv, dwFlags, storeName);
406  CryptMemFree(storeName);
407  }
408  }
409  return ret;
410 }
#define CP_ACP
Definition: compat.h:99
LPVOID WINAPI CryptMemAlloc(ULONG cbSize)
Definition: main.c:131
smooth NULL
Definition: ftsmooth.c:416
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
#define TRACE(s)
Definition: solgame.cpp:4
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define debugstr_a
Definition: kernel32.h:31
#define SetLastError(x)
Definition: compat.h:409
int ret
WINECRYPT_CERTSTORE * CRYPT_FileNameOpenStoreW(HCRYPTPROV hCryptProv, DWORD dwFlags, const void *pvPara)
Definition: filestore.c:292
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
GLenum GLsizei len
Definition: glext.h:6722
#define MultiByteToWideChar
Definition: compat.h:100
VOID WINAPI CryptMemFree(LPVOID pv)
Definition: main.c:141
_In_ void * pvPara
Definition: wincrypt.h:6081
WCHAR * LPWSTR
Definition: xmlstorage.h:184

Referenced by CertOpenStore().

◆ CRYPT_FileNameOpenStoreW()

WINECRYPT_CERTSTORE* CRYPT_FileNameOpenStoreW ( HCRYPTPROV  hCryptProv,
DWORD  dwFlags,
const void pvPara 
)

Definition at line 292 of file filestore.c.

294 {
295  HCERTSTORE store = 0;
296  LPCWSTR fileName = pvPara;
298  HANDLE file;
299 
300  TRACE("(%ld, %08x, %s)\n", hCryptProv, dwFlags, debugstr_w(fileName));
301 
302  if (!fileName)
303  {
305  return NULL;
306  }
309  {
311  return NULL;
312  }
313 
318  create = CREATE_NEW;
321  else
325  if (file != INVALID_HANDLE_VALUE)
326  {
327  HCERTSTORE memStore = NULL;
328  DWORD size = GetFileSize(file, NULL), type = 0;
329 
330  /* If the file isn't empty, try to get the type from the file itself */
331  if (size)
332  {
333  DWORD contentType;
334  BOOL ret;
335 
336  /* Close the file so CryptQueryObject can succeed.. */
337  CloseHandle(file);
342  CERT_QUERY_FORMAT_FLAG_ALL, 0, NULL, &contentType, NULL,
343  &memStore, NULL, NULL);
344  if (ret)
345  {
346  if (contentType == CERT_QUERY_CONTENT_FLAG_PKCS7_SIGNED)
348  else
350  /* and reopen the file. */
353  }
354  }
355  else
356  {
357  static const WCHAR spc[] = { 's','p','c',0 };
358  static const WCHAR p7c[] = { 'p','7','c',0 };
359  LPCWSTR ext = strrchrW(fileName, '.');
360 
361  if (ext)
362  {
363  ext++;
364  if (!lstrcmpiW(ext, spc) || !lstrcmpiW(ext, p7c))
366  }
367  if (!type)
369  memStore = CertOpenStore(CERT_STORE_PROV_MEMORY, 0, 0,
371  }
372  if (memStore)
373  {
374  store = CRYPT_CreateFileStore(dwFlags, memStore, file, type);
375  /* File store doesn't need crypto provider, so close it */
376  if (hCryptProv && !(dwFlags & CERT_STORE_NO_CRYPT_RELEASE_FLAG))
377  CryptReleaseContext(hCryptProv, 0);
378  }
379  }
380  return store;
381 }
#define CloseHandle
Definition: compat.h:398
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
#define CERT_STORE_OPEN_EXISTING_FLAG
Definition: wincrypt.h:2465
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
#define CERT_QUERY_OBJECT_FILE
Definition: wincrypt.h:3526
#define CERT_FILE_STORE_COMMIT_ENABLE_FLAG
Definition: wincrypt.h:2475
#define FILE_SHARE_READ
Definition: compat.h:125
static WINECRYPT_CERTSTORE * CRYPT_CreateFileStore(DWORD dwFlags, HCERTSTORE memStore, HANDLE file, DWORD type)
Definition: filestore.c:218
int WINAPI lstrcmpiW(LPCWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:194
#define CERT_STORE_CREATE_NEW_FLAG
Definition: wincrypt.h:2464
unsigned int BOOL
Definition: ntddk_ex.h:94
#define GENERIC_WRITE
Definition: nt_native.h:90
#define debugstr_w
Definition: kernel32.h:32
#define E_INVALIDARG
Definition: ddrawi.h:101
#define CERT_STORE_PROV_MEMORY
Definition: wincrypt.h:2251
smooth NULL
Definition: ftsmooth.c:416
char ext[3]
Definition: mkdosfs.c:358
#define CERT_QUERY_CONTENT_FLAG_SERIALIZED_STORE
Definition: wincrypt.h:3546
#define OPEN_EXISTING
Definition: compat.h:426
#define CERT_QUERY_CONTENT_FLAG_CERT
Definition: wincrypt.h:3543
BOOL WINAPI CryptQueryObject(DWORD dwObjectType, const void *pvObject, DWORD dwExpectedContentTypeFlags, DWORD dwExpectedFormatTypeFlags, DWORD dwFlags, DWORD *pdwMsgAndCertEncodingType, DWORD *pdwContentType, DWORD *pdwFormatType, HCERTSTORE *phCertStore, HCRYPTMSG *phMsg, const void **ppvContext)
Definition: object.c:699
#define TRACE(s)
Definition: solgame.cpp:4
GLsizeiptr size
Definition: glext.h:5919
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define CERT_STORE_SAVE_AS_PKCS7
Definition: wincrypt.h:2647
const char file[]
Definition: icontest.c:11
unsigned long DWORD
Definition: ntddk_ex.h:95
#define CERT_STORE_SAVE_AS_STORE
Definition: wincrypt.h:2646
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
#define CERT_STORE_READONLY_FLAG
Definition: wincrypt.h:2466
int ret
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:126
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
#define GENERIC_READ
Definition: compat.h:124
WINE_UNICODE_INLINE WCHAR * strrchrW(const WCHAR *str, WCHAR ch)
Definition: unicode.h:254
GLuint GLint GLboolean GLint GLenum access
Definition: glext.h:7866
#define CERT_QUERY_FORMAT_FLAG_ALL
Definition: wincrypt.h:3589
HCERTSTORE WINAPI CertOpenStore(LPCSTR lpszStoreProvider, DWORD dwMsgAndCertEncodingType, HCRYPTPROV_LEGACY hCryptProv, DWORD dwFlags, const void *pvPara)
Definition: store.c:815
#define CreateFileW
Definition: compat.h:400
BOOL WINAPI CryptReleaseContext(HCRYPTPROV hProv, ULONG_PTR dwFlags)
Definition: crypt.c:651
#define CERT_STORE_NO_CRYPT_RELEASE_FLAG
Definition: wincrypt.h:2452
#define CERT_QUERY_CONTENT_FLAG_PKCS7_SIGNED
Definition: wincrypt.h:3554
#define CREATE_NEW
Definition: disk.h:69
#define ERROR_PATH_NOT_FOUND
Definition: winerror.h:106
_In_ void * pvPara
Definition: wincrypt.h:6081
static const struct access_res create[16]
Definition: package.c:7720
Definition: fci.c:126

Referenced by CertOpenStore(), and CRYPT_FileNameOpenStoreA().

◆ CRYPT_FileOpenStore()

WINECRYPT_CERTSTORE* CRYPT_FileOpenStore ( HCRYPTPROV  hCryptProv,
DWORD  dwFlags,
const void pvPara 
)

Definition at line 242 of file filestore.c.

244 {
245  WINECRYPT_CERTSTORE *store = NULL;
247 
248  TRACE("(%ld, %08x, %p)\n", hCryptProv, dwFlags, pvPara);
249 
250  if (!pvPara)
251  {
253  return NULL;
254  }
256  {
258  return NULL;
259  }
262  {
264  return NULL;
265  }
266 
270  {
271  HCERTSTORE memStore;
272 
273  memStore = CertOpenStore(CERT_STORE_PROV_MEMORY, 0, 0,
275  if (memStore)
276  {
278  {
279  store = CRYPT_CreateFileStore(dwFlags, memStore, file,
281  /* File store doesn't need crypto provider, so close it */
282  if (hCryptProv &&
284  CryptReleaseContext(hCryptProv, 0);
285  }
286  }
287  }
288  TRACE("returning %p\n", store);
289  return store;
290 }
#define CERT_STORE_DELETE_FLAG
Definition: wincrypt.h:2455
#define TRUE
Definition: types.h:120
BOOL CRYPT_ReadSerializedStoreFromFile(HANDLE file, HCERTSTORE store) DECLSPEC_HIDDEN
Definition: serialize.c:544
#define ERROR_INVALID_HANDLE
Definition: compat.h:88
#define CERT_FILE_STORE_COMMIT_ENABLE_FLAG
Definition: wincrypt.h:2475
static WINECRYPT_CERTSTORE * CRYPT_CreateFileStore(DWORD dwFlags, HCERTSTORE memStore, HANDLE file, DWORD type)
Definition: filestore.c:218
#define CERT_STORE_CREATE_NEW_FLAG
Definition: wincrypt.h:2464
#define GENERIC_WRITE
Definition: nt_native.h:90
#define E_INVALIDARG
Definition: ddrawi.h:101
#define CERT_STORE_PROV_MEMORY
Definition: wincrypt.h:2251
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
HANDLE WINAPI GetCurrentProcess(VOID)
Definition: proc.c:1138
PVOID HANDLE
Definition: typedefs.h:71
#define CERT_STORE_SAVE_AS_STORE
Definition: wincrypt.h:2646
#define SetLastError(x)
Definition: compat.h:409
#define CERT_STORE_READONLY_FLAG
Definition: wincrypt.h:2466
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
#define GENERIC_READ
Definition: compat.h:124
HCERTSTORE WINAPI CertOpenStore(LPCSTR lpszStoreProvider, DWORD dwMsgAndCertEncodingType, HCRYPTPROV_LEGACY hCryptProv, DWORD dwFlags, const void *pvPara)
Definition: store.c:815
BOOL WINAPI CryptReleaseContext(HCRYPTPROV hProv, ULONG_PTR dwFlags)
Definition: crypt.c:651
#define CERT_STORE_NO_CRYPT_RELEASE_FLAG
Definition: wincrypt.h:2452
_In_ void * pvPara
Definition: wincrypt.h:6081
BOOL WINAPI DuplicateHandle(IN HANDLE hSourceProcessHandle, IN HANDLE hSourceHandle, IN HANDLE hTargetProcessHandle, OUT LPHANDLE lpTargetHandle, IN DWORD dwDesiredAccess, IN BOOL bInheritHandle, IN DWORD dwOptions)
Definition: handle.c:149
Definition: fci.c:126

Referenced by CertOpenStore().

◆ CRYPT_FileWriteCert()

static BOOL WINAPI CRYPT_FileWriteCert ( HCERTSTORE  hCertStore,
PCCERT_CONTEXT  cert,
DWORD  dwFlags 
)
static

Definition at line 50 of file filestore.c.

52 {
53  WINE_FILESTOREINFO *store = hCertStore;
54 
55  TRACE("(%p, %p, %d)\n", hCertStore, cert, dwFlags);
56  store->dirty = TRUE;
57  return TRUE;
58 }
#define TRUE
Definition: types.h:120
static BYTE cert[]
Definition: msg.c:1437
#define TRACE(s)
Definition: solgame.cpp:4
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175

◆ CRYPT_FileWriteCRL()

static BOOL WINAPI CRYPT_FileWriteCRL ( HCERTSTORE  hCertStore,
PCCRL_CONTEXT  crl,
DWORD  dwFlags 
)
static

Definition at line 70 of file filestore.c.

72 {
73  WINE_FILESTOREINFO *store = hCertStore;
74 
75  TRACE("(%p, %p, %d)\n", hCertStore, crl, dwFlags);
76  store->dirty = TRUE;
77  return TRUE;
78 }
#define TRUE
Definition: types.h:120
static const BYTE crl[]
Definition: message.c:864
#define TRACE(s)
Definition: solgame.cpp:4
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175

◆ CRYPT_FileWriteCTL()

static BOOL WINAPI CRYPT_FileWriteCTL ( HCERTSTORE  hCertStore,
PCCTL_CONTEXT  ctl,
DWORD  dwFlags 
)
static

Definition at line 90 of file filestore.c.

92 {
93  WINE_FILESTOREINFO *store = hCertStore;
94 
95  TRACE("(%p, %p, %d)\n", hCertStore, ctl, dwFlags);
96  store->dirty = TRUE;
97  return TRUE;
98 }
#define TRUE
Definition: types.h:120
#define TRACE(s)
Definition: solgame.cpp:4
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175

◆ CRYPT_ReadBlobFromFile()

static BOOL CRYPT_ReadBlobFromFile ( HANDLE  file,
PCERT_BLOB  blob 
)
static

Definition at line 110 of file filestore.c.

111 {
112  BOOL ret = TRUE;
113 
114  blob->cbData = GetFileSize(file, NULL);
115  if (blob->cbData)
116  {
117  blob->pbData = CryptMemAlloc(blob->cbData);
118  if (blob->pbData)
119  {
120  DWORD read;
121 
122  ret = ReadFile(file, blob->pbData, blob->cbData, &read, NULL) && read == blob->cbData;
123  if (!ret) CryptMemFree(blob->pbData);
124  }
125  else
126  ret = FALSE;
127  }
128  return ret;
129 }
#define TRUE
Definition: types.h:120
Definition: image.c:133
LPVOID WINAPI CryptMemAlloc(ULONG cbSize)
Definition: main.c:131
unsigned int BOOL
Definition: ntddk_ex.h:94
smooth NULL
Definition: ftsmooth.c:416
unsigned long DWORD
Definition: ntddk_ex.h:95
DWORD WINAPI GetFileSize(HANDLE hFile, LPDWORD lpFileSizeHigh)
Definition: fileinfo.c:481
int ret
VOID WINAPI CryptMemFree(LPVOID pv)
Definition: main.c:141
BOOL WINAPI ReadFile(IN HANDLE hFile, IN LPVOID lpBuffer, IN DWORD nNumberOfBytesToRead, OUT LPDWORD lpNumberOfBytesRead OPTIONAL, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: rw.c:123
_CRTIMP int __cdecl read(_In_ int _FileHandle, _Out_writes_bytes_(_MaxCharCount) void *_DstBuf, _In_ unsigned int _MaxCharCount)
Definition: fci.c:126

Referenced by CRYPT_FileControl().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( crypt  )

Variable Documentation

◆ fileProvFuncs

void* fileProvFuncs[]
static
Initial value:
= {
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
}
static BOOL WINAPI CRYPT_FileDeleteCRL(HCERTSTORE hCertStore, PCCRL_CONTEXT pCrlContext, DWORD dwFlags)
Definition: filestore.c:80
static void WINAPI CRYPT_FileCloseStore(HCERTSTORE hCertStore, DWORD dwFlags)
Definition: filestore.c:38
static BOOL WINAPI CRYPT_FileDeleteCert(HCERTSTORE hCertStore, PCCERT_CONTEXT pCertContext, DWORD dwFlags)
Definition: filestore.c:60
static BOOL WINAPI CRYPT_FileWriteCTL(HCERTSTORE hCertStore, PCCTL_CONTEXT ctl, DWORD dwFlags)
Definition: filestore.c:90
static BOOL WINAPI CRYPT_FileControl(HCERTSTORE hCertStore, DWORD dwFlags, DWORD dwCtrlType, void const *pvCtrlPara)
Definition: filestore.c:131
smooth NULL
Definition: ftsmooth.c:416
static BOOL WINAPI CRYPT_FileWriteCRL(HCERTSTORE hCertStore, PCCRL_CONTEXT crl, DWORD dwFlags)
Definition: filestore.c:70
static BOOL WINAPI CRYPT_FileDeleteCTL(HCERTSTORE hCertStore, PCCTL_CONTEXT pCtlContext, DWORD dwFlags)
Definition: filestore.c:100
static BOOL WINAPI CRYPT_FileWriteCert(HCERTSTORE hCertStore, PCCERT_CONTEXT cert, DWORD dwFlags)
Definition: filestore.c:50

Definition at line 201 of file filestore.c.

Referenced by CRYPT_CreateFileStore().