ReactOS 0.4.15-dev-7918-g2a2556c
provstore.c File Reference
#include <stdarg.h>
#include <assert.h>
#include "windef.h"
#include "winbase.h"
#include "wincrypt.h"
#include "wine/debug.h"
#include "crypt32_private.h"
Include dependency graph for provstore.c:

Go to the source code of this file.

Classes

struct  _WINE_PROVIDERSTORE
 

Typedefs

typedef struct _WINE_PROVIDERSTORE WINE_PROVIDERSTORE
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (crypt)
 
static void ProvStore_addref (WINECRYPT_CERTSTORE *store)
 
static DWORD ProvStore_release (WINECRYPT_CERTSTORE *cert_store, DWORD flags)
 
static void ProvStore_releaseContext (WINECRYPT_CERTSTORE *store, context_t *context)
 
static BOOL ProvStore_addCert (WINECRYPT_CERTSTORE *store, context_t *cert, context_t *toReplace, context_t **ppStoreContext, BOOL use_link)
 
static context_tProvStore_enumCert (WINECRYPT_CERTSTORE *store, context_t *prev)
 
static BOOL ProvStore_deleteCert (WINECRYPT_CERTSTORE *store, context_t *context)
 
static BOOL ProvStore_addCRL (WINECRYPT_CERTSTORE *store, context_t *crl, context_t *toReplace, context_t **ppStoreContext, BOOL use_link)
 
static context_tProvStore_enumCRL (WINECRYPT_CERTSTORE *store, context_t *prev)
 
static BOOL ProvStore_deleteCRL (WINECRYPT_CERTSTORE *store, context_t *crl)
 
static BOOL ProvStore_addCTL (WINECRYPT_CERTSTORE *store, context_t *ctl, context_t *toReplace, context_t **ppStoreContext, BOOL use_link)
 
static context_tProvStore_enumCTL (WINECRYPT_CERTSTORE *store, context_t *prev)
 
static BOOL ProvStore_deleteCTL (WINECRYPT_CERTSTORE *store, context_t *ctl)
 
static BOOL ProvStore_control (WINECRYPT_CERTSTORE *cert_store, DWORD dwFlags, DWORD dwCtrlType, void const *pvCtrlPara)
 
WINECRYPT_CERTSTORECRYPT_ProvCreateStore (DWORD dwFlags, WINECRYPT_CERTSTORE *memStore, const CERT_STORE_PROV_INFO *pProvInfo)
 
WINECRYPT_CERTSTORECRYPT_ProvOpenStore (LPCSTR lpszStoreProvider, DWORD dwEncodingType, HCRYPTPROV hCryptProv, DWORD dwFlags, const void *pvPara)
 

Variables

static const store_vtbl_t ProvStoreVtbl
 

Typedef Documentation

◆ WINE_PROVIDERSTORE

Function Documentation

◆ CRYPT_ProvCreateStore()

WINECRYPT_CERTSTORE * CRYPT_ProvCreateStore ( DWORD  dwFlags,
WINECRYPT_CERTSTORE memStore,
const CERT_STORE_PROV_INFO pProvInfo 
)

Definition at line 307 of file provstore.c.

309{
311
312 if (ret)
313 {
315 ret->dwStoreProvFlags = pProvInfo->dwStoreProvFlags;
316 if (ret->dwStoreProvFlags & CERT_STORE_PROV_EXTERNAL_FLAG)
317 {
318 CertCloseStore(memStore, 0);
319 ret->memStore = NULL;
320 }
321 else
322 ret->memStore = memStore;
323 ret->hStoreProv = pProvInfo->hStoreProv;
325 ret->provCloseStore =
327 else
328 ret->provCloseStore = NULL;
329 if (pProvInfo->cStoreProvFunc >
331 ret->provWriteCert = pProvInfo->rgpvStoreProvFunc[
333 else
334 ret->provWriteCert = NULL;
335 if (pProvInfo->cStoreProvFunc >
337 ret->provDeleteCert = pProvInfo->rgpvStoreProvFunc[
339 else
340 ret->provDeleteCert = NULL;
341 if (pProvInfo->cStoreProvFunc >
343 ret->provWriteCrl = pProvInfo->rgpvStoreProvFunc[
345 else
346 ret->provWriteCrl = NULL;
347 if (pProvInfo->cStoreProvFunc >
349 ret->provDeleteCrl = pProvInfo->rgpvStoreProvFunc[
351 else
352 ret->provDeleteCrl = NULL;
353 if (pProvInfo->cStoreProvFunc >
355 ret->provWriteCtl = pProvInfo->rgpvStoreProvFunc[
357 else
358 ret->provWriteCtl = NULL;
359 if (pProvInfo->cStoreProvFunc >
361 ret->provDeleteCtl = pProvInfo->rgpvStoreProvFunc[
363 else
364 ret->provDeleteCtl = NULL;
365 if (pProvInfo->cStoreProvFunc >
367 ret->provControl = pProvInfo->rgpvStoreProvFunc[
369 else
370 ret->provControl = NULL;
371 }
372 return (WINECRYPT_CERTSTORE*)ret;
373}
@ StoreTypeProvider
void CRYPT_InitStore(WINECRYPT_CERTSTORE *store, DWORD dwFlags, CertStoreType type, const store_vtbl_t *) DECLSPEC_HIDDEN
Definition: store.c:91
#define NULL
Definition: types.h:112
LPVOID WINAPI CryptMemAlloc(ULONG cbSize)
Definition: main.c:131
BOOL WINAPI CertCloseStore(HCERTSTORE hCertStore, DWORD dwFlags)
Definition: store.c:1127
static const store_vtbl_t ProvStoreVtbl
Definition: provstore.c:287
void ** rgpvStoreProvFunc
Definition: wincrypt.h:1149
HCERTSTOREPROV hStoreProv
Definition: wincrypt.h:1150
int ret
#define CERT_STORE_PROV_WRITE_CTL_FUNC
Definition: wincrypt.h:2563
#define CERT_STORE_PROV_CONTROL_FUNC
Definition: wincrypt.h:2566
#define CERT_STORE_PROV_EXTERNAL_FLAG
Definition: wincrypt.h:2546
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1176
#define CERT_STORE_PROV_CLOSE_FUNC
Definition: wincrypt.h:2553
#define CERT_STORE_PROV_DELETE_CTL_FUNC
Definition: wincrypt.h:2564
#define CERT_STORE_PROV_DELETE_CRL_FUNC
Definition: wincrypt.h:2560
#define CERT_STORE_PROV_DELETE_CERT_FUNC
Definition: wincrypt.h:2556
#define CERT_STORE_PROV_WRITE_CERT_FUNC
Definition: wincrypt.h:2555
#define CERT_STORE_PROV_WRITE_CRL_FUNC
Definition: wincrypt.h:2559

Referenced by create_root_store(), CRYPT_CreateFileStore(), CRYPT_MsgOpenStore(), CRYPT_ProvOpenStore(), and CRYPT_RegOpenStore().

◆ CRYPT_ProvOpenStore()

WINECRYPT_CERTSTORE * CRYPT_ProvOpenStore ( LPCSTR  lpszStoreProvider,
DWORD  dwEncodingType,
HCRYPTPROV  hCryptProv,
DWORD  dwFlags,
const void pvPara 
)

Definition at line 375 of file provstore.c.

377{
378 static HCRYPTOIDFUNCSET set = NULL;
380 HCRYPTOIDFUNCADDR hFunc;
382
383 if (!set)
385 CryptGetOIDFunctionAddress(set, dwEncodingType, lpszStoreProvider, 0,
386 (void **)&provOpenFunc, &hFunc);
387 if (provOpenFunc)
388 {
389 CERT_STORE_PROV_INFO provInfo = { 0 };
390
391 provInfo.cbSize = sizeof(provInfo);
393 provOpenFunc(lpszStoreProvider, dwEncodingType, hCryptProv,
394 dwFlags, pvPara, NULL, &provInfo);
395 else
396 {
397 HCERTSTORE memStore;
398
399 memStore = CertOpenStore(CERT_STORE_PROV_MEMORY, 0, 0,
401 if (memStore)
402 {
403 if (provOpenFunc(lpszStoreProvider, dwEncodingType, hCryptProv,
404 dwFlags, pvPara, memStore, &provInfo))
405 ret = CRYPT_ProvCreateStore(dwFlags, memStore, &provInfo);
406 else
407 CertCloseStore(memStore, 0);
408 }
409 }
411 }
412 else
414 return ret;
415}
Definition: _set.h:50
HCRYPTOIDFUNCSET WINAPI CryptInitOIDFunctionSet(LPCSTR pszFuncName, DWORD dwFlags)
Definition: oid.c:114
BOOL WINAPI CryptGetOIDFunctionAddress(HCRYPTOIDFUNCSET hFuncSet, DWORD dwEncodingType, LPCSTR pszOID, DWORD dwFlags, void **ppvFuncAddr, HCRYPTOIDFUNCADDR *phFuncAddr)
Definition: oid.c:387
BOOL WINAPI CryptFreeOIDFunctionAddress(HCRYPTOIDFUNCADDR hFuncAddr, DWORD dwFlags)
Definition: oid.c:468
HCERTSTORE WINAPI CertOpenStore(LPCSTR lpszStoreProvider, DWORD dwMsgAndCertEncodingType, HCRYPTPROV_LEGACY hCryptProv, DWORD dwFlags, const void *pvPara)
Definition: store.c:815
#define SetLastError(x)
Definition: compat.h:752
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
WINECRYPT_CERTSTORE * CRYPT_ProvCreateStore(DWORD dwFlags, WINECRYPT_CERTSTORE *memStore, const CERT_STORE_PROV_INFO *pProvInfo)
Definition: provstore.c:307
#define CERT_STORE_CREATE_NEW_FLAG
Definition: wincrypt.h:2464
_In_ DWORD dwEncodingType
Definition: wincrypt.h:4625
#define CERT_STORE_PROV_MEMORY
Definition: wincrypt.h:2251
_In_ void * pvPara
Definition: wincrypt.h:6077
BOOL(WINAPI * PFN_CERT_DLL_OPEN_STORE_PROV_FUNC)(_In_ LPCSTR lpszStoreProvider, _In_ DWORD dwEncodingType, _In_opt_ HCRYPTPROV_LEGACY hCryptProv, _In_ DWORD dwFlags, _In_opt_ const void *pvPara, _In_ HCERTSTORE hCertStore, _Inout_ PCERT_STORE_PROV_INFO pStoreProvInfo)
Definition: wincrypt.h:1156
#define CRYPT_OID_OPEN_STORE_PROV_FUNC
Definition: wincrypt.h:2491
#define CERT_STORE_DELETE_FLAG
Definition: wincrypt.h:2455

Referenced by CertOpenStore().

◆ ProvStore_addCert()

static BOOL ProvStore_addCert ( WINECRYPT_CERTSTORE store,
context_t cert,
context_t toReplace,
context_t **  ppStoreContext,
BOOL  use_link 
)
static

Definition at line 81 of file provstore.c.

83{
85 BOOL ret;
86
87 TRACE("(%p, %p, %p, %p)\n", store, cert, toReplace, ppStoreContext);
88
89 if (toReplace)
90 ret = ps->memStore->vtbl->certs.addContext(ps->memStore, cert, toReplace,
92 else
93 {
94 ret = TRUE;
95 if (ps->provWriteCert)
97 if (ret)
100 }
101 /* dirty trick: replace the returned context's hCertStore with
102 * store.
103 */
104 if (ret && ppStoreContext)
105 (*(cert_t**)ppStoreContext)->ctx.hCertStore = store;
106 return ret;
107}
static void * context_ptr(context_t *context)
#define TRUE
Definition: types.h:120
unsigned int BOOL
Definition: ntddk_ex.h:94
static BYTE cert[]
Definition: msg.c:1437
#define TRACE(s)
Definition: solgame.cpp:4
const store_vtbl_t * vtbl
BOOL(* addContext)(struct WINE_CRYPTCERTSTORE *, context_t *, context_t *, context_t **, BOOL)
HCERTSTOREPROV hStoreProv
Definition: provstore.c:35
WINECRYPT_CERTSTORE * memStore
Definition: provstore.c:34
PFN_CERT_STORE_PROV_WRITE_CERT provWriteCert
Definition: provstore.c:37
CONTEXT_FUNCS certs
_In_ PCCERT_CONTEXT _In_ DWORD _Outptr_opt_ PCCERT_CONTEXT * ppStoreContext
Definition: wincrypt.h:4985
#define CERT_STORE_PROV_WRITE_ADD_FLAG
Definition: wincrypt.h:2971

◆ ProvStore_addCRL()

static BOOL ProvStore_addCRL ( WINECRYPT_CERTSTORE store,
context_t crl,
context_t toReplace,
context_t **  ppStoreContext,
BOOL  use_link 
)
static

Definition at line 139 of file provstore.c.

141{
143 BOOL ret;
144
145 TRACE("(%p, %p, %p, %p)\n", store, crl, toReplace, ppStoreContext);
146
147 if (toReplace)
148 ret = ps->memStore->vtbl->crls.addContext(ps->memStore, crl, toReplace,
150 else
151 {
153 {
155 ret = FALSE;
156 }
157 else
158 {
159 ret = TRUE;
160 if (ps->provWriteCrl)
163 if (ret)
166 }
167 }
168 /* dirty trick: replace the returned context's hCertStore with
169 * store.
170 */
171 if (ret && ppStoreContext)
172 (*(crl_t**)ppStoreContext)->ctx.hCertStore = store;
173 return ret;
174}
#define FALSE
Definition: types.h:117
#define ERROR_ACCESS_DENIED
Definition: compat.h:97
static const BYTE crl[]
Definition: message.c:864
WINECRYPT_CERTSTORE hdr
Definition: provstore.c:32
PFN_CERT_STORE_PROV_WRITE_CRL provWriteCrl
Definition: provstore.c:39
CONTEXT_FUNCS crls
#define CERT_STORE_READONLY_FLAG
Definition: wincrypt.h:2466

◆ ProvStore_addCTL()

static BOOL ProvStore_addCTL ( WINECRYPT_CERTSTORE store,
context_t ctl,
context_t toReplace,
context_t **  ppStoreContext,
BOOL  use_link 
)
static

Definition at line 206 of file provstore.c.

208{
210 BOOL ret;
211
212 TRACE("(%p, %p, %p, %p)\n", store, ctl, toReplace, ppStoreContext);
213
214 if (toReplace)
215 ret = ps->memStore->vtbl->ctls.addContext(ps->memStore, ctl, toReplace,
217 else
218 {
220 {
222 ret = FALSE;
223 }
224 else
225 {
226 ret = TRUE;
227 if (ps->provWriteCtl)
228 ret = ps->provWriteCtl(ps->hStoreProv, context_ptr(ctl),
230 if (ret)
231 ret = ps->memStore->vtbl->ctls.addContext(ps->memStore, ctl, NULL,
233 }
234 }
235 /* dirty trick: replace the returned context's hCertStore with
236 * store.
237 */
238 if (ret && ppStoreContext)
239 (*(ctl_t**)ppStoreContext)->ctx.hCertStore = store;
240 return ret;
241}
PFN_CERT_STORE_PROV_WRITE_CTL provWriteCtl
Definition: provstore.c:41
CONTEXT_FUNCS ctls

◆ ProvStore_addref()

static void ProvStore_addref ( WINECRYPT_CERTSTORE store)
static

Definition at line 46 of file provstore.c.

47{
49 TRACE("ref = %d\n", ref);
50}
#define InterlockedIncrement
Definition: armddk.h:53
long LONG
Definition: pedump.c:60
Definition: send.c:48

◆ ProvStore_control()

static BOOL ProvStore_control ( WINECRYPT_CERTSTORE cert_store,
DWORD  dwFlags,
DWORD  dwCtrlType,
void const pvCtrlPara 
)
static

Definition at line 273 of file provstore.c.

274{
276 BOOL ret = TRUE;
277
278 TRACE("(%p, %08x, %d, %p)\n", store, dwFlags, dwCtrlType,
279 pvCtrlPara);
280
281 if (store->provControl)
282 ret = store->provControl(store->hStoreProv, dwFlags, dwCtrlType,
283 pvCtrlPara);
284 return ret;
285}
DWORD cert_store
Definition: store.c:344
PFN_CERT_STORE_PROV_CONTROL provControl
Definition: provstore.c:43

◆ ProvStore_deleteCert()

static BOOL ProvStore_deleteCert ( WINECRYPT_CERTSTORE store,
context_t context 
)
static

Definition at line 125 of file provstore.c.

126{
128 BOOL ret = TRUE;
129
130 TRACE("(%p, %p)\n", store, context);
131
132 if (ps->provDeleteCert)
134 if (ret)
136 return ret;
137}
BOOL(* delete)(struct WINE_CRYPTCERTSTORE *, context_t *)
PFN_CERT_STORE_PROV_DELETE_CERT provDeleteCert
Definition: provstore.c:38
Definition: http.c:7252

◆ ProvStore_deleteCRL()

static BOOL ProvStore_deleteCRL ( WINECRYPT_CERTSTORE store,
context_t crl 
)
static

Definition at line 192 of file provstore.c.

193{
195 BOOL ret = TRUE;
196
197 TRACE("(%p, %p)\n", store, crl);
198
199 if (ps->provDeleteCrl)
201 if (ret)
202 ret = ps->memStore->vtbl->crls.delete(ps->memStore, crl);
203 return ret;
204}
PFN_CERT_STORE_PROV_DELETE_CRL provDeleteCrl
Definition: provstore.c:40

◆ ProvStore_deleteCTL()

static BOOL ProvStore_deleteCTL ( WINECRYPT_CERTSTORE store,
context_t ctl 
)
static

Definition at line 259 of file provstore.c.

260{
262 BOOL ret = TRUE;
263
264 TRACE("(%p, %p)\n", store, ctl);
265
266 if (ps->provDeleteCtl)
267 ret = ps->provDeleteCtl(ps->hStoreProv, context_ptr(ctl), 0);
268 if (ret)
269 ret = ps->memStore->vtbl->ctls.delete(ps->memStore, ctl);
270 return ret;
271}
PFN_CERT_STORE_PROV_DELETE_CTL provDeleteCtl
Definition: provstore.c:42

◆ ProvStore_enumCert()

static context_t * ProvStore_enumCert ( WINECRYPT_CERTSTORE store,
context_t prev 
)
static

Definition at line 109 of file provstore.c.

110{
112 cert_t *ret;
113
114 ret = (cert_t*)ps->memStore->vtbl->certs.enumContext(ps->memStore, prev);
115 if (!ret)
116 return NULL;
117
118 /* same dirty trick: replace the returned context's hCertStore with
119 * store.
120 */
121 ret->ctx.hCertStore = store;
122 return &ret->base;
123}
context_t *(* enumContext)(struct WINE_CRYPTCERTSTORE *store, context_t *prev)

◆ ProvStore_enumCRL()

static context_t * ProvStore_enumCRL ( WINECRYPT_CERTSTORE store,
context_t prev 
)
static

Definition at line 176 of file provstore.c.

177{
179 crl_t *ret;
180
181 ret = (crl_t*)ps->memStore->vtbl->crls.enumContext(ps->memStore, prev);
182 if (!ret)
183 return NULL;
184
185 /* same dirty trick: replace the returned context's hCertStore with
186 * store.
187 */
188 ret->ctx.hCertStore = store;
189 return &ret->base;
190}

◆ ProvStore_enumCTL()

static context_t * ProvStore_enumCTL ( WINECRYPT_CERTSTORE store,
context_t prev 
)
static

Definition at line 243 of file provstore.c.

244{
246 ctl_t *ret;
247
248 ret = (ctl_t*)ps->memStore->vtbl->ctls.enumContext(ps->memStore, prev);
249 if (!ret)
250 return NULL;
251
252 /* same dirty trick: replace the returned context's hCertStore with
253 * store.
254 */
255 ret->ctx.hCertStore = store;
256 return &ret->base;
257}

◆ ProvStore_release()

static DWORD ProvStore_release ( WINECRYPT_CERTSTORE cert_store,
DWORD  flags 
)
static

Definition at line 52 of file provstore.c.

53{
55 LONG ref;
56
57 if(flags)
58 FIXME("Unimplemented flags %x\n", flags);
59
61 TRACE("(%p) ref=%d\n", store, ref);
62
63 if(ref)
64 return ERROR_SUCCESS;
65
66 if (store->provCloseStore)
67 store->provCloseStore(store->hStoreProv, flags);
69 store->memStore->vtbl->release(store->memStore, flags);
70 CRYPT_FreeStore(&store->hdr);
71 return ERROR_SUCCESS;
72}
#define InterlockedDecrement
Definition: armddk.h:52
#define FIXME(fmt,...)
Definition: debug.h:111
void CRYPT_FreeStore(WINECRYPT_CERTSTORE *store) DECLSPEC_HIDDEN
Definition: store.c:101
#define ERROR_SUCCESS
Definition: deptool.c:10
GLbitfield flags
Definition: glext.h:7161
PFN_CERT_STORE_PROV_CLOSE provCloseStore
Definition: provstore.c:36
DWORD dwStoreProvFlags
Definition: provstore.c:33
DWORD(* release)(struct WINE_CRYPTCERTSTORE *, DWORD)

◆ ProvStore_releaseContext()

static void ProvStore_releaseContext ( WINECRYPT_CERTSTORE store,
context_t context 
)
static

Definition at line 74 of file provstore.c.

75{
76 /* As long as we don't have contexts properly stored (and hack around hCertStore
77 in add* and enum* functions), this function should never be called. */
78 assert(0);
79}
#define assert(x)
Definition: debug.h:53

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( crypt  )

Variable Documentation

◆ ProvStoreVtbl

const store_vtbl_t ProvStoreVtbl
static
Initial value:
= {
{
}, {
}, {
}
}
static BOOL ProvStore_addCRL(WINECRYPT_CERTSTORE *store, context_t *crl, context_t *toReplace, context_t **ppStoreContext, BOOL use_link)
Definition: provstore.c:139
static BOOL ProvStore_deleteCert(WINECRYPT_CERTSTORE *store, context_t *context)
Definition: provstore.c:125
static void ProvStore_addref(WINECRYPT_CERTSTORE *store)
Definition: provstore.c:46
static context_t * ProvStore_enumCert(WINECRYPT_CERTSTORE *store, context_t *prev)
Definition: provstore.c:109
static BOOL ProvStore_deleteCRL(WINECRYPT_CERTSTORE *store, context_t *crl)
Definition: provstore.c:192
static BOOL ProvStore_deleteCTL(WINECRYPT_CERTSTORE *store, context_t *ctl)
Definition: provstore.c:259
static BOOL ProvStore_addCTL(WINECRYPT_CERTSTORE *store, context_t *ctl, context_t *toReplace, context_t **ppStoreContext, BOOL use_link)
Definition: provstore.c:206
static BOOL ProvStore_addCert(WINECRYPT_CERTSTORE *store, context_t *cert, context_t *toReplace, context_t **ppStoreContext, BOOL use_link)
Definition: provstore.c:81
static context_t * ProvStore_enumCTL(WINECRYPT_CERTSTORE *store, context_t *prev)
Definition: provstore.c:243
static BOOL ProvStore_control(WINECRYPT_CERTSTORE *cert_store, DWORD dwFlags, DWORD dwCtrlType, void const *pvCtrlPara)
Definition: provstore.c:273
static context_t * ProvStore_enumCRL(WINECRYPT_CERTSTORE *store, context_t *prev)
Definition: provstore.c:176
static DWORD ProvStore_release(WINECRYPT_CERTSTORE *cert_store, DWORD flags)
Definition: provstore.c:52
static void ProvStore_releaseContext(WINECRYPT_CERTSTORE *store, context_t *context)
Definition: provstore.c:74

Definition at line 287 of file provstore.c.

Referenced by CRYPT_ProvCreateStore().