2 * Copyright 2002 Mike McCormack for CodeWeavers
3 * Copyright 2004-2006 Juan Lang
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20 * - The concept of physical stores and locations isn't implemented. (This
21 * doesn't mean registry stores et al aren't implemented. See the PSDK for
22 * registering and enumerating physical stores and locations.)
23 * - Many flags, options and whatnot are unimplemented.
35 #include "wine/debug.h"
36 #include "wine/exception.h"
37 #include "crypt32_private.h"
39 WINE_DEFAULT_DEBUG_CHANNEL(crypt
);
41 static const WINE_CONTEXT_INTERFACE gCertInterface
= {
42 (CreateContextFunc
)CertCreateCertificateContext
,
43 (AddContextToStoreFunc
)CertAddCertificateContextToStore
,
44 (AddEncodedContextToStoreFunc
)CertAddEncodedCertificateToStore
,
45 (EnumContextsInStoreFunc
)CertEnumCertificatesInStore
,
46 (EnumPropertiesFunc
)CertEnumCertificateContextProperties
,
47 (GetContextPropertyFunc
)CertGetCertificateContextProperty
,
48 (SetContextPropertyFunc
)CertSetCertificateContextProperty
,
49 (SerializeElementFunc
)CertSerializeCertificateStoreElement
,
50 (DeleteContextFunc
)CertDeleteCertificateFromStore
,
52 const WINE_CONTEXT_INTERFACE
*pCertInterface
= &gCertInterface
;
54 static const WINE_CONTEXT_INTERFACE gCRLInterface
= {
55 (CreateContextFunc
)CertCreateCRLContext
,
56 (AddContextToStoreFunc
)CertAddCRLContextToStore
,
57 (AddEncodedContextToStoreFunc
)CertAddEncodedCRLToStore
,
58 (EnumContextsInStoreFunc
)CertEnumCRLsInStore
,
59 (EnumPropertiesFunc
)CertEnumCRLContextProperties
,
60 (GetContextPropertyFunc
)CertGetCRLContextProperty
,
61 (SetContextPropertyFunc
)CertSetCRLContextProperty
,
62 (SerializeElementFunc
)CertSerializeCRLStoreElement
,
63 (DeleteContextFunc
)CertDeleteCRLFromStore
,
65 const WINE_CONTEXT_INTERFACE
*pCRLInterface
= &gCRLInterface
;
67 static const WINE_CONTEXT_INTERFACE gCTLInterface
= {
68 (CreateContextFunc
)CertCreateCTLContext
,
69 (AddContextToStoreFunc
)CertAddCTLContextToStore
,
70 (AddEncodedContextToStoreFunc
)CertAddEncodedCTLToStore
,
71 (EnumContextsInStoreFunc
)CertEnumCTLsInStore
,
72 (EnumPropertiesFunc
)CertEnumCTLContextProperties
,
73 (GetContextPropertyFunc
)CertGetCTLContextProperty
,
74 (SetContextPropertyFunc
)CertSetCTLContextProperty
,
75 (SerializeElementFunc
)CertSerializeCTLStoreElement
,
76 (DeleteContextFunc
)CertDeleteCTLFromStore
,
78 const WINE_CONTEXT_INTERFACE
*pCTLInterface
= &gCTLInterface
;
80 typedef struct _WINE_MEMSTORE
82 WINECRYPT_CERTSTORE hdr
;
89 void CRYPT_InitStore(WINECRYPT_CERTSTORE
*store
, DWORD dwFlags
, CertStoreType type
, const store_vtbl_t
*vtbl
)
92 store
->dwMagic
= WINE_CRYPTCERTSTORE_MAGIC
;
94 store
->dwOpenFlags
= dwFlags
;
96 store
->properties
= NULL
;
99 void CRYPT_FreeStore(WINECRYPT_CERTSTORE
*store
)
101 if (store
->properties
)
102 ContextPropertyList_Free(store
->properties
);
107 BOOL WINAPI
I_CertUpdateStore(HCERTSTORE store1
, HCERTSTORE store2
, DWORD unk0
,
110 static BOOL warned
= FALSE
;
111 const WINE_CONTEXT_INTERFACE
* const interfaces
[] = { pCertInterface
,
112 pCRLInterface
, pCTLInterface
};
115 TRACE("(%p, %p, %08x, %08x)\n", store1
, store2
, unk0
, unk1
);
118 FIXME("semi-stub\n");
122 /* Poor-man's resync: empty first store, then add everything from second
125 for (i
= 0; i
< ARRAY_SIZE(interfaces
); i
++)
130 context
= interfaces
[i
]->enumContextsInStore(store1
, NULL
);
132 interfaces
[i
]->deleteFromStore(context
);
135 context
= interfaces
[i
]->enumContextsInStore(store2
, context
);
137 interfaces
[i
]->addContextToStore(store1
, context
,
138 CERT_STORE_ADD_ALWAYS
, NULL
);
144 static BOOL
MemStore_addContext(WINE_MEMSTORE
*store
, struct list
*list
, context_t
*orig_context
,
145 context_t
*existing
, context_t
**ret_context
, BOOL use_link
)
149 context
= orig_context
->vtbl
->clone(orig_context
, &store
->hdr
, use_link
);
153 TRACE("adding %p\n", context
);
154 EnterCriticalSection(&store
->cs
);
156 context
->u
.entry
.prev
= existing
->u
.entry
.prev
;
157 context
->u
.entry
.next
= existing
->u
.entry
.next
;
158 context
->u
.entry
.prev
->next
= &context
->u
.entry
;
159 context
->u
.entry
.next
->prev
= &context
->u
.entry
;
160 list_init(&existing
->u
.entry
);
162 Context_Release(existing
);
164 list_add_head(list
, &context
->u
.entry
);
166 LeaveCriticalSection(&store
->cs
);
169 *ret_context
= context
;
171 Context_Release(context
);
175 static context_t
*MemStore_enumContext(WINE_MEMSTORE
*store
, struct list
*list
, context_t
*prev
)
180 EnterCriticalSection(&store
->cs
);
182 next
= list_next(list
, &prev
->u
.entry
);
183 Context_Release(prev
);
185 next
= list_next(list
, list
);
187 LeaveCriticalSection(&store
->cs
);
190 SetLastError(CRYPT_E_NOT_FOUND
);
194 ret
= LIST_ENTRY(next
, context_t
, u
.entry
);
199 static BOOL
MemStore_deleteContext(WINE_MEMSTORE
*store
, context_t
*context
)
201 BOOL in_list
= FALSE
;
203 EnterCriticalSection(&store
->cs
);
204 if (!list_empty(&context
->u
.entry
)) {
205 list_remove(&context
->u
.entry
);
206 list_init(&context
->u
.entry
);
209 LeaveCriticalSection(&store
->cs
);
211 if(in_list
&& !context
->ref
)
212 Context_Free(context
);
216 static void free_contexts(struct list
*list
)
218 context_t
*context
, *next
;
220 LIST_FOR_EACH_ENTRY_SAFE(context
, next
, list
, context_t
, u
.entry
)
222 TRACE("freeing %p\n", context
);
223 list_remove(&context
->u
.entry
);
224 Context_Free(context
);
228 static void MemStore_releaseContext(WINECRYPT_CERTSTORE
*store
, context_t
*context
)
230 /* Free the context only if it's not in a list. Otherwise it may be reused later. */
231 if(list_empty(&context
->u
.entry
))
232 Context_Free(context
);
235 static BOOL
MemStore_addCert(WINECRYPT_CERTSTORE
*store
, context_t
*cert
,
236 context_t
*toReplace
, context_t
**ppStoreContext
, BOOL use_link
)
238 WINE_MEMSTORE
*ms
= (WINE_MEMSTORE
*)store
;
240 TRACE("(%p, %p, %p, %p)\n", store
, cert
, toReplace
, ppStoreContext
);
241 return MemStore_addContext(ms
, &ms
->certs
, cert
, toReplace
, ppStoreContext
, use_link
);
244 static context_t
*MemStore_enumCert(WINECRYPT_CERTSTORE
*store
, context_t
*prev
)
246 WINE_MEMSTORE
*ms
= (WINE_MEMSTORE
*)store
;
248 TRACE("(%p, %p)\n", store
, prev
);
250 return MemStore_enumContext(ms
, &ms
->certs
, prev
);
253 static BOOL
MemStore_deleteCert(WINECRYPT_CERTSTORE
*store
, context_t
*context
)
255 WINE_MEMSTORE
*ms
= (WINE_MEMSTORE
*)store
;
257 TRACE("(%p, %p)\n", store
, context
);
259 return MemStore_deleteContext(ms
, context
);
262 static BOOL
MemStore_addCRL(WINECRYPT_CERTSTORE
*store
, context_t
*crl
,
263 context_t
*toReplace
, context_t
**ppStoreContext
, BOOL use_link
)
265 WINE_MEMSTORE
*ms
= (WINE_MEMSTORE
*)store
;
267 TRACE("(%p, %p, %p, %p)\n", store
, crl
, toReplace
, ppStoreContext
);
269 return MemStore_addContext(ms
, &ms
->crls
, crl
, toReplace
, ppStoreContext
, use_link
);
272 static context_t
*MemStore_enumCRL(WINECRYPT_CERTSTORE
*store
, context_t
*prev
)
274 WINE_MEMSTORE
*ms
= (WINE_MEMSTORE
*)store
;
276 TRACE("(%p, %p)\n", store
, prev
);
278 return MemStore_enumContext(ms
, &ms
->crls
, prev
);
281 static BOOL
MemStore_deleteCRL(WINECRYPT_CERTSTORE
*store
, context_t
*context
)
283 WINE_MEMSTORE
*ms
= (WINE_MEMSTORE
*)store
;
285 TRACE("(%p, %p)\n", store
, context
);
287 return MemStore_deleteContext(ms
, context
);
290 static BOOL
MemStore_addCTL(WINECRYPT_CERTSTORE
*store
, context_t
*ctl
,
291 context_t
*toReplace
, context_t
**ppStoreContext
, BOOL use_link
)
293 WINE_MEMSTORE
*ms
= (WINE_MEMSTORE
*)store
;
295 TRACE("(%p, %p, %p, %p)\n", store
, ctl
, toReplace
, ppStoreContext
);
297 return MemStore_addContext(ms
, &ms
->ctls
, ctl
, toReplace
, ppStoreContext
, use_link
);
300 static context_t
*MemStore_enumCTL(WINECRYPT_CERTSTORE
*store
, context_t
*prev
)
302 WINE_MEMSTORE
*ms
= (WINE_MEMSTORE
*)store
;
304 TRACE("(%p, %p)\n", store
, prev
);
306 return MemStore_enumContext(ms
, &ms
->ctls
, prev
);
309 static BOOL
MemStore_deleteCTL(WINECRYPT_CERTSTORE
*store
, context_t
*context
)
311 WINE_MEMSTORE
*ms
= (WINE_MEMSTORE
*)store
;
313 TRACE("(%p, %p)\n", store
, context
);
315 return MemStore_deleteContext(ms
, context
);
318 static void MemStore_addref(WINECRYPT_CERTSTORE
*store
)
320 LONG ref
= InterlockedIncrement(&store
->ref
);
321 TRACE("ref = %d\n", ref
);
324 static DWORD
MemStore_release(WINECRYPT_CERTSTORE
*cert_store
, DWORD flags
)
326 WINE_MEMSTORE
*store
= (WINE_MEMSTORE
*)cert_store
;
329 if(flags
& ~CERT_CLOSE_STORE_CHECK_FLAG
)
330 FIXME("Unimplemented flags %x\n", flags
);
332 ref
= InterlockedDecrement(&store
->hdr
.ref
);
333 TRACE("(%p) ref=%d\n", store
, ref
);
335 return (flags
& CERT_CLOSE_STORE_CHECK_FLAG
) ? CRYPT_E_PENDING_CLOSE
: ERROR_SUCCESS
;
337 free_contexts(&store
->certs
);
338 free_contexts(&store
->crls
);
339 free_contexts(&store
->ctls
);
340 store
->cs
.DebugInfo
->Spare
[0] = 0;
341 DeleteCriticalSection(&store
->cs
);
342 CRYPT_FreeStore(&store
->hdr
);
343 return ERROR_SUCCESS
;
346 static BOOL
MemStore_control(WINECRYPT_CERTSTORE
*store
, DWORD dwFlags
,
347 DWORD dwCtrlType
, void const *pvCtrlPara
)
349 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
353 static const store_vtbl_t MemStoreVtbl
= {
356 MemStore_releaseContext
,
373 static WINECRYPT_CERTSTORE
*CRYPT_MemOpenStore(HCRYPTPROV hCryptProv
,
374 DWORD dwFlags
, const void *pvPara
)
376 WINE_MEMSTORE
*store
;
378 TRACE("(%ld, %08x, %p)\n", hCryptProv
, dwFlags
, pvPara
);
380 if (dwFlags
& CERT_STORE_DELETE_FLAG
)
382 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
387 store
= CryptMemAlloc(sizeof(WINE_MEMSTORE
));
390 memset(store
, 0, sizeof(WINE_MEMSTORE
));
391 CRYPT_InitStore(&store
->hdr
, dwFlags
, StoreTypeMem
, &MemStoreVtbl
);
392 InitializeCriticalSection(&store
->cs
);
393 store
->cs
.DebugInfo
->Spare
[0] = (DWORD_PTR
)(__FILE__
": ContextList.cs");
394 list_init(&store
->certs
);
395 list_init(&store
->crls
);
396 list_init(&store
->ctls
);
397 /* Mem store doesn't need crypto provider, so close it */
398 if (hCryptProv
&& !(dwFlags
& CERT_STORE_NO_CRYPT_RELEASE_FLAG
))
399 CryptReleaseContext(hCryptProv
, 0);
402 return (WINECRYPT_CERTSTORE
*)store
;
405 static WINECRYPT_CERTSTORE
*CRYPT_SysRegOpenStoreW(HCRYPTPROV hCryptProv
,
406 DWORD dwFlags
, const void *pvPara
)
408 LPCWSTR storeName
= pvPara
;
410 WINECRYPT_CERTSTORE
*store
= NULL
;
414 TRACE("(%ld, %08x, %s)\n", hCryptProv
, dwFlags
,
419 SetLastError(E_INVALIDARG
);
423 switch (dwFlags
& CERT_SYSTEM_STORE_LOCATION_MASK
)
425 case CERT_SYSTEM_STORE_LOCAL_MACHINE
:
426 root
= HKEY_LOCAL_MACHINE
;
427 base
= CERT_LOCAL_MACHINE_SYSTEM_STORE_REGPATH
;
428 /* If the HKLM\Root certs are requested, expressing system certs into the registry */
429 if (!lstrcmpiW(storeName
, L
"Root"))
430 CRYPT_ImportSystemRootCertsToReg();
432 case CERT_SYSTEM_STORE_CURRENT_USER
:
433 root
= HKEY_CURRENT_USER
;
434 base
= CERT_LOCAL_MACHINE_SYSTEM_STORE_REGPATH
;
436 case CERT_SYSTEM_STORE_CURRENT_SERVICE
:
437 /* hklm\Software\Microsoft\Cryptography\Services\servicename\
440 FIXME("CERT_SYSTEM_STORE_CURRENT_SERVICE, %s: stub\n",
441 debugstr_w(storeName
));
443 case CERT_SYSTEM_STORE_SERVICES
:
444 /* hklm\Software\Microsoft\Cryptography\Services\servicename\
447 FIXME("CERT_SYSTEM_STORE_SERVICES, %s: stub\n",
448 debugstr_w(storeName
));
450 case CERT_SYSTEM_STORE_USERS
:
451 /* hku\user sid\Software\Microsoft\SystemCertificates */
452 FIXME("CERT_SYSTEM_STORE_USERS, %s: stub\n",
453 debugstr_w(storeName
));
455 case CERT_SYSTEM_STORE_CURRENT_USER_GROUP_POLICY
:
456 root
= HKEY_CURRENT_USER
;
457 base
= CERT_GROUP_POLICY_SYSTEM_STORE_REGPATH
;
459 case CERT_SYSTEM_STORE_LOCAL_MACHINE_GROUP_POLICY
:
460 root
= HKEY_LOCAL_MACHINE
;
461 base
= CERT_GROUP_POLICY_SYSTEM_STORE_REGPATH
;
463 case CERT_SYSTEM_STORE_LOCAL_MACHINE_ENTERPRISE
:
464 /* hklm\Software\Microsoft\EnterpriseCertificates */
465 FIXME("CERT_SYSTEM_STORE_LOCAL_MACHINE_ENTERPRISE, %s: stub\n",
466 debugstr_w(storeName
));
469 SetLastError(E_INVALIDARG
);
473 storePath
= CryptMemAlloc((lstrlenW(base
) + lstrlenW(storeName
) + 2) *
479 REGSAM sam
= dwFlags
& CERT_STORE_READONLY_FLAG
? KEY_READ
:
482 wsprintfW(storePath
, L
"%s\\%s", base
, storeName
);
483 if (dwFlags
& CERT_STORE_OPEN_EXISTING_FLAG
)
484 rc
= RegOpenKeyExW(root
, storePath
, 0, sam
, &key
);
489 rc
= RegCreateKeyExW(root
, storePath
, 0, NULL
, 0, sam
, NULL
,
491 if (!rc
&& dwFlags
& CERT_STORE_CREATE_NEW_FLAG
&&
492 disp
== REG_OPENED_EXISTING_KEY
)
495 rc
= ERROR_FILE_EXISTS
;
500 store
= CRYPT_RegOpenStore(hCryptProv
, dwFlags
, key
);
505 CryptMemFree(storePath
);
510 static WINECRYPT_CERTSTORE
*CRYPT_SysRegOpenStoreA(HCRYPTPROV hCryptProv
,
511 DWORD dwFlags
, const void *pvPara
)
514 WINECRYPT_CERTSTORE
*ret
= NULL
;
516 TRACE("(%ld, %08x, %s)\n", hCryptProv
, dwFlags
,
521 SetLastError(ERROR_FILE_NOT_FOUND
);
524 len
= MultiByteToWideChar(CP_ACP
, 0, pvPara
, -1, NULL
, 0);
527 LPWSTR storeName
= CryptMemAlloc(len
* sizeof(WCHAR
));
531 MultiByteToWideChar(CP_ACP
, 0, pvPara
, -1, storeName
, len
);
532 ret
= CRYPT_SysRegOpenStoreW(hCryptProv
, dwFlags
, storeName
);
533 CryptMemFree(storeName
);
539 static WINECRYPT_CERTSTORE
*CRYPT_SysOpenStoreW(HCRYPTPROV hCryptProv
,
540 DWORD dwFlags
, const void *pvPara
)
542 HCERTSTORE store
= 0;
545 TRACE("(%ld, %08x, %s)\n", hCryptProv
, dwFlags
,
550 SetLastError(ERROR_FILE_NOT_FOUND
);
553 /* This returns a different error than system registry stores if the
554 * location is invalid.
556 switch (dwFlags
& CERT_SYSTEM_STORE_LOCATION_MASK
)
558 case CERT_SYSTEM_STORE_LOCAL_MACHINE
:
559 case CERT_SYSTEM_STORE_CURRENT_USER
:
560 case CERT_SYSTEM_STORE_CURRENT_SERVICE
:
561 case CERT_SYSTEM_STORE_SERVICES
:
562 case CERT_SYSTEM_STORE_USERS
:
563 case CERT_SYSTEM_STORE_CURRENT_USER_GROUP_POLICY
:
564 case CERT_SYSTEM_STORE_LOCAL_MACHINE_GROUP_POLICY
:
565 case CERT_SYSTEM_STORE_LOCAL_MACHINE_ENTERPRISE
:
569 SetLastError(ERROR_FILE_NOT_FOUND
);
574 HCERTSTORE regStore
= CertOpenStore(CERT_STORE_PROV_SYSTEM_REGISTRY_W
,
575 0, 0, dwFlags
, pvPara
);
579 store
= CertOpenStore(CERT_STORE_PROV_COLLECTION
, 0, 0,
580 CERT_STORE_CREATE_NEW_FLAG
, NULL
);
581 CertAddStoreToCollection(store
, regStore
,
582 dwFlags
& CERT_STORE_READONLY_FLAG
? 0 :
583 CERT_PHYSICAL_STORE_ADD_ENABLE_FLAG
, 0);
584 CertCloseStore(regStore
, 0);
585 /* CERT_SYSTEM_STORE_CURRENT_USER returns both the HKCU and HKLM
588 if ((dwFlags
& CERT_SYSTEM_STORE_LOCATION_MASK
) ==
589 CERT_SYSTEM_STORE_CURRENT_USER
)
591 dwFlags
&= ~CERT_SYSTEM_STORE_CURRENT_USER
;
592 dwFlags
|= CERT_SYSTEM_STORE_LOCAL_MACHINE
;
593 regStore
= CertOpenStore(CERT_STORE_PROV_SYSTEM_REGISTRY_W
, 0,
597 CertAddStoreToCollection(store
, regStore
,
598 dwFlags
& CERT_STORE_READONLY_FLAG
? 0 :
599 CERT_PHYSICAL_STORE_ADD_ENABLE_FLAG
, 0);
600 CertCloseStore(regStore
, 0);
603 /* System store doesn't need crypto provider, so close it */
604 if (hCryptProv
&& !(dwFlags
& CERT_STORE_NO_CRYPT_RELEASE_FLAG
))
605 CryptReleaseContext(hCryptProv
, 0);
611 static WINECRYPT_CERTSTORE
*CRYPT_SysOpenStoreA(HCRYPTPROV hCryptProv
,
612 DWORD dwFlags
, const void *pvPara
)
615 WINECRYPT_CERTSTORE
*ret
= NULL
;
617 TRACE("(%ld, %08x, %s)\n", hCryptProv
, dwFlags
,
622 SetLastError(ERROR_FILE_NOT_FOUND
);
625 len
= MultiByteToWideChar(CP_ACP
, 0, pvPara
, -1, NULL
, 0);
628 LPWSTR storeName
= CryptMemAlloc(len
* sizeof(WCHAR
));
632 MultiByteToWideChar(CP_ACP
, 0, pvPara
, -1, storeName
, len
);
633 ret
= CRYPT_SysOpenStoreW(hCryptProv
, dwFlags
, storeName
);
634 CryptMemFree(storeName
);
640 static void WINAPI
CRYPT_MsgCloseStore(HCERTSTORE hCertStore
, DWORD dwFlags
)
642 HCRYPTMSG msg
= hCertStore
;
644 TRACE("(%p, %08x)\n", msg
, dwFlags
);
648 static void *msgProvFuncs
[] = {
652 static WINECRYPT_CERTSTORE
*CRYPT_MsgOpenStore(HCRYPTPROV hCryptProv
,
653 DWORD dwFlags
, const void *pvPara
)
655 WINECRYPT_CERTSTORE
*store
= NULL
;
656 HCRYPTMSG msg
= (HCRYPTMSG
)pvPara
;
657 WINECRYPT_CERTSTORE
*memStore
;
659 TRACE("(%ld, %08x, %p)\n", hCryptProv
, dwFlags
, pvPara
);
661 memStore
= CertOpenStore(CERT_STORE_PROV_MEMORY
, 0, 0,
662 CERT_STORE_CREATE_NEW_FLAG
, NULL
);
666 DWORD size
, count
, i
;
668 size
= sizeof(count
);
669 ret
= CryptMsgGetParam(msg
, CMSG_CERT_COUNT_PARAM
, 0, &count
, &size
);
670 for (i
= 0; ret
&& i
< count
; i
++)
673 ret
= CryptMsgGetParam(msg
, CMSG_CERT_PARAM
, i
, NULL
, &size
);
676 LPBYTE buf
= CryptMemAlloc(size
);
680 ret
= CryptMsgGetParam(msg
, CMSG_CERT_PARAM
, i
, buf
, &size
);
682 ret
= CertAddEncodedCertificateToStore(memStore
,
683 X509_ASN_ENCODING
, buf
, size
, CERT_STORE_ADD_ALWAYS
,
689 size
= sizeof(count
);
690 ret
= CryptMsgGetParam(msg
, CMSG_CRL_COUNT_PARAM
, 0, &count
, &size
);
691 for (i
= 0; ret
&& i
< count
; i
++)
694 ret
= CryptMsgGetParam(msg
, CMSG_CRL_PARAM
, i
, NULL
, &size
);
697 LPBYTE buf
= CryptMemAlloc(size
);
701 ret
= CryptMsgGetParam(msg
, CMSG_CRL_PARAM
, i
, buf
, &size
);
703 ret
= CertAddEncodedCRLToStore(memStore
,
704 X509_ASN_ENCODING
, buf
, size
, CERT_STORE_ADD_ALWAYS
,
712 CERT_STORE_PROV_INFO provInfo
= { 0 };
714 provInfo
.cbSize
= sizeof(provInfo
);
715 provInfo
.cStoreProvFunc
= ARRAY_SIZE(msgProvFuncs
);
716 provInfo
.rgpvStoreProvFunc
= msgProvFuncs
;
717 provInfo
.hStoreProv
= CryptMsgDuplicate(msg
);
718 store
= CRYPT_ProvCreateStore(dwFlags
, memStore
, &provInfo
);
719 /* Msg store doesn't need crypto provider, so close it */
720 if (hCryptProv
&& !(dwFlags
& CERT_STORE_NO_CRYPT_RELEASE_FLAG
))
721 CryptReleaseContext(hCryptProv
, 0);
724 CertCloseStore(memStore
, 0);
726 TRACE("returning %p\n", store
);
730 static WINECRYPT_CERTSTORE
*CRYPT_PKCSOpenStore(HCRYPTPROV hCryptProv
,
731 DWORD dwFlags
, const void *pvPara
)
734 WINECRYPT_CERTSTORE
*store
= NULL
;
735 const CRYPT_DATA_BLOB
*data
= pvPara
;
737 DWORD msgOpenFlags
= dwFlags
& CERT_STORE_NO_CRYPT_RELEASE_FLAG
? 0 :
738 CMSG_CRYPT_RELEASE_CONTEXT_FLAG
;
740 TRACE("(%ld, %08x, %p)\n", hCryptProv
, dwFlags
, pvPara
);
742 msg
= CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING
, msgOpenFlags
, CMSG_SIGNED
,
743 hCryptProv
, NULL
, NULL
);
744 ret
= CryptMsgUpdate(msg
, data
->pbData
, data
->cbData
, TRUE
);
748 msg
= CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING
, msgOpenFlags
, 0,
749 hCryptProv
, NULL
, NULL
);
750 ret
= CryptMsgUpdate(msg
, data
->pbData
, data
->cbData
, TRUE
);
753 DWORD type
, size
= sizeof(type
);
755 /* Only signed messages are allowed, check type */
756 ret
= CryptMsgGetParam(msg
, CMSG_TYPE_PARAM
, 0, &type
, &size
);
757 if (ret
&& type
!= CMSG_SIGNED
)
759 SetLastError(CRYPT_E_INVALID_MSG_TYPE
);
765 store
= CRYPT_MsgOpenStore(0, dwFlags
, msg
);
767 TRACE("returning %p\n", store
);
771 static WINECRYPT_CERTSTORE
*CRYPT_SerializedOpenStore(HCRYPTPROV hCryptProv
,
772 DWORD dwFlags
, const void *pvPara
)
775 const CRYPT_DATA_BLOB
*data
= pvPara
;
777 TRACE("(%ld, %08x, %p)\n", hCryptProv
, dwFlags
, pvPara
);
779 if (dwFlags
& CERT_STORE_DELETE_FLAG
)
781 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
785 store
= CertOpenStore(CERT_STORE_PROV_MEMORY
, 0, 0,
786 CERT_STORE_CREATE_NEW_FLAG
, NULL
);
789 if (!CRYPT_ReadSerializedStoreFromBlob(data
, store
))
791 CertCloseStore(store
, 0);
795 TRACE("returning %p\n", store
);
796 return (WINECRYPT_CERTSTORE
*)store
;
799 static WINECRYPT_CERTSTORE
*CRYPT_PhysOpenStoreW(HCRYPTPROV hCryptProv
,
800 DWORD dwFlags
, const void *pvPara
)
802 if (dwFlags
& CERT_SYSTEM_STORE_RELOCATE_FLAG
)
803 FIXME("(%ld, %08x, %p): stub\n", hCryptProv
, dwFlags
, pvPara
);
805 FIXME("(%ld, %08x, %s): stub\n", hCryptProv
, dwFlags
,
810 HCERTSTORE WINAPI
CertOpenStore(LPCSTR lpszStoreProvider
,
811 DWORD dwMsgAndCertEncodingType
, HCRYPTPROV_LEGACY hCryptProv
, DWORD dwFlags
,
814 WINECRYPT_CERTSTORE
*hcs
;
815 StoreOpenFunc openFunc
= NULL
;
817 TRACE("(%s, %08x, %08lx, %08x, %p)\n", debugstr_a(lpszStoreProvider
),
818 dwMsgAndCertEncodingType
, hCryptProv
, dwFlags
, pvPara
);
820 if (IS_INTOID(lpszStoreProvider
))
822 switch (LOWORD(lpszStoreProvider
))
824 case LOWORD(CERT_STORE_PROV_MSG
):
825 openFunc
= CRYPT_MsgOpenStore
;
827 case LOWORD(CERT_STORE_PROV_MEMORY
):
828 openFunc
= CRYPT_MemOpenStore
;
830 case LOWORD(CERT_STORE_PROV_FILE
):
831 openFunc
= CRYPT_FileOpenStore
;
833 case LOWORD(CERT_STORE_PROV_PKCS7
):
834 openFunc
= CRYPT_PKCSOpenStore
;
836 case LOWORD(CERT_STORE_PROV_SERIALIZED
):
837 openFunc
= CRYPT_SerializedOpenStore
;
839 case LOWORD(CERT_STORE_PROV_REG
):
840 openFunc
= CRYPT_RegOpenStore
;
842 case LOWORD(CERT_STORE_PROV_FILENAME_A
):
843 openFunc
= CRYPT_FileNameOpenStoreA
;
845 case LOWORD(CERT_STORE_PROV_FILENAME_W
):
846 openFunc
= CRYPT_FileNameOpenStoreW
;
848 case LOWORD(CERT_STORE_PROV_COLLECTION
):
849 openFunc
= CRYPT_CollectionOpenStore
;
851 case LOWORD(CERT_STORE_PROV_SYSTEM_A
):
852 openFunc
= CRYPT_SysOpenStoreA
;
854 case LOWORD(CERT_STORE_PROV_SYSTEM_W
):
855 openFunc
= CRYPT_SysOpenStoreW
;
857 case LOWORD(CERT_STORE_PROV_SYSTEM_REGISTRY_A
):
858 openFunc
= CRYPT_SysRegOpenStoreA
;
860 case LOWORD(CERT_STORE_PROV_SYSTEM_REGISTRY_W
):
861 openFunc
= CRYPT_SysRegOpenStoreW
;
863 case LOWORD(CERT_STORE_PROV_PHYSICAL_W
):
864 openFunc
= CRYPT_PhysOpenStoreW
;
867 if (LOWORD(lpszStoreProvider
))
868 FIXME("unimplemented type %d\n", LOWORD(lpszStoreProvider
));
871 else if (!stricmp(lpszStoreProvider
, sz_CERT_STORE_PROV_MEMORY
))
872 openFunc
= CRYPT_MemOpenStore
;
873 else if (!stricmp(lpszStoreProvider
, sz_CERT_STORE_PROV_FILENAME_W
))
874 openFunc
= CRYPT_FileOpenStore
;
875 else if (!stricmp(lpszStoreProvider
, sz_CERT_STORE_PROV_SYSTEM
))
876 openFunc
= CRYPT_SysOpenStoreW
;
877 else if (!stricmp(lpszStoreProvider
, sz_CERT_STORE_PROV_PKCS7
))
878 openFunc
= CRYPT_PKCSOpenStore
;
879 else if (!stricmp(lpszStoreProvider
, sz_CERT_STORE_PROV_SERIALIZED
))
880 openFunc
= CRYPT_SerializedOpenStore
;
881 else if (!stricmp(lpszStoreProvider
, sz_CERT_STORE_PROV_COLLECTION
))
882 openFunc
= CRYPT_CollectionOpenStore
;
883 else if (!stricmp(lpszStoreProvider
, sz_CERT_STORE_PROV_SYSTEM_REGISTRY
))
884 openFunc
= CRYPT_SysRegOpenStoreW
;
887 FIXME("unimplemented type %s\n", lpszStoreProvider
);
892 hcs
= CRYPT_ProvOpenStore(lpszStoreProvider
, dwMsgAndCertEncodingType
,
893 hCryptProv
, dwFlags
, pvPara
);
895 hcs
= openFunc(hCryptProv
, dwFlags
, pvPara
);
899 HCERTSTORE WINAPI
CertOpenSystemStoreA(HCRYPTPROV_LEGACY hProv
,
900 LPCSTR szSubSystemProtocol
)
902 if (!szSubSystemProtocol
)
904 SetLastError(E_INVALIDARG
);
907 return CertOpenStore(CERT_STORE_PROV_SYSTEM_A
, 0, hProv
,
908 CERT_SYSTEM_STORE_CURRENT_USER
, szSubSystemProtocol
);
911 HCERTSTORE WINAPI
CertOpenSystemStoreW(HCRYPTPROV_LEGACY hProv
,
912 LPCWSTR szSubSystemProtocol
)
914 if (!szSubSystemProtocol
)
916 SetLastError(E_INVALIDARG
);
919 return CertOpenStore(CERT_STORE_PROV_SYSTEM_W
, 0, hProv
,
920 CERT_SYSTEM_STORE_CURRENT_USER
, szSubSystemProtocol
);
923 PCCERT_CONTEXT WINAPI
CertEnumCertificatesInStore(HCERTSTORE hCertStore
, PCCERT_CONTEXT pPrev
)
925 cert_t
*prev
= pPrev
? cert_from_ptr(pPrev
) : NULL
, *ret
;
926 WINECRYPT_CERTSTORE
*hcs
= hCertStore
;
928 TRACE("(%p, %p)\n", hCertStore
, pPrev
);
931 else if (hcs
->dwMagic
!= WINE_CRYPTCERTSTORE_MAGIC
)
934 ret
= (cert_t
*)hcs
->vtbl
->certs
.enumContext(hcs
, prev
? &prev
->base
: NULL
);
935 return ret
? &ret
->ctx
: NULL
;
938 BOOL WINAPI
CertDeleteCertificateFromStore(PCCERT_CONTEXT pCertContext
)
940 WINECRYPT_CERTSTORE
*hcs
;
942 TRACE("(%p)\n", pCertContext
);
947 hcs
= pCertContext
->hCertStore
;
949 if (hcs
->dwMagic
!= WINE_CRYPTCERTSTORE_MAGIC
)
952 return hcs
->vtbl
->certs
.delete(hcs
, &cert_from_ptr(pCertContext
)->base
);
955 BOOL WINAPI
CertAddCRLContextToStore(HCERTSTORE hCertStore
,
956 PCCRL_CONTEXT pCrlContext
, DWORD dwAddDisposition
,
957 PCCRL_CONTEXT
* ppStoreContext
)
959 WINECRYPT_CERTSTORE
*store
= hCertStore
;
961 PCCRL_CONTEXT toAdd
= NULL
, existing
= NULL
;
963 TRACE("(%p, %p, %08x, %p)\n", hCertStore
, pCrlContext
,
964 dwAddDisposition
, ppStoreContext
);
966 /* Weird case to pass a test */
967 if (dwAddDisposition
== 0)
969 SetLastError(STATUS_ACCESS_VIOLATION
);
972 if (dwAddDisposition
!= CERT_STORE_ADD_ALWAYS
)
974 existing
= CertFindCRLInStore(hCertStore
, 0, 0, CRL_FIND_EXISTING
,
978 switch (dwAddDisposition
)
980 case CERT_STORE_ADD_ALWAYS
:
981 toAdd
= CertDuplicateCRLContext(pCrlContext
);
983 case CERT_STORE_ADD_NEW
:
986 TRACE("found matching CRL, not adding\n");
987 SetLastError(CRYPT_E_EXISTS
);
991 toAdd
= CertDuplicateCRLContext(pCrlContext
);
993 case CERT_STORE_ADD_NEWER
:
996 LONG newer
= CompareFileTime(&existing
->pCrlInfo
->ThisUpdate
,
997 &pCrlContext
->pCrlInfo
->ThisUpdate
);
1000 toAdd
= CertDuplicateCRLContext(pCrlContext
);
1003 TRACE("existing CRL is newer, not adding\n");
1004 SetLastError(CRYPT_E_EXISTS
);
1009 toAdd
= CertDuplicateCRLContext(pCrlContext
);
1011 case CERT_STORE_ADD_NEWER_INHERIT_PROPERTIES
:
1014 LONG newer
= CompareFileTime(&existing
->pCrlInfo
->ThisUpdate
,
1015 &pCrlContext
->pCrlInfo
->ThisUpdate
);
1019 toAdd
= CertDuplicateCRLContext(pCrlContext
);
1020 Context_CopyProperties(toAdd
, existing
);
1024 TRACE("existing CRL is newer, not adding\n");
1025 SetLastError(CRYPT_E_EXISTS
);
1030 toAdd
= CertDuplicateCRLContext(pCrlContext
);
1032 case CERT_STORE_ADD_REPLACE_EXISTING
:
1033 toAdd
= CertDuplicateCRLContext(pCrlContext
);
1035 case CERT_STORE_ADD_REPLACE_EXISTING_INHERIT_PROPERTIES
:
1036 toAdd
= CertDuplicateCRLContext(pCrlContext
);
1038 Context_CopyProperties(toAdd
, existing
);
1040 case CERT_STORE_ADD_USE_EXISTING
:
1043 Context_CopyProperties(existing
, pCrlContext
);
1045 *ppStoreContext
= CertDuplicateCRLContext(existing
);
1048 toAdd
= CertDuplicateCRLContext(pCrlContext
);
1051 FIXME("Unimplemented add disposition %d\n", dwAddDisposition
);
1058 context_t
*ret_context
;
1059 ret
= store
->vtbl
->crls
.addContext(store
, context_from_ptr(toAdd
),
1060 existing
? context_from_ptr(existing
) : NULL
, ppStoreContext
? &ret_context
: NULL
, FALSE
);
1061 if (ret
&& ppStoreContext
)
1062 *ppStoreContext
= context_ptr(ret_context
);
1063 }else if (ppStoreContext
) {
1064 *ppStoreContext
= CertDuplicateCRLContext(toAdd
);
1066 CertFreeCRLContext(toAdd
);
1069 CertFreeCRLContext(existing
);
1071 TRACE("returning %d\n", ret
);
1075 BOOL WINAPI
CertDeleteCRLFromStore(PCCRL_CONTEXT pCrlContext
)
1077 WINECRYPT_CERTSTORE
*hcs
;
1080 TRACE("(%p)\n", pCrlContext
);
1085 hcs
= pCrlContext
->hCertStore
;
1087 if (hcs
->dwMagic
!= WINE_CRYPTCERTSTORE_MAGIC
)
1090 ret
= hcs
->vtbl
->crls
.delete(hcs
, &crl_from_ptr(pCrlContext
)->base
);
1092 ret
= CertFreeCRLContext(pCrlContext
);
1096 PCCRL_CONTEXT WINAPI
CertEnumCRLsInStore(HCERTSTORE hCertStore
, PCCRL_CONTEXT pPrev
)
1098 crl_t
*ret
, *prev
= pPrev
? crl_from_ptr(pPrev
) : NULL
;
1099 WINECRYPT_CERTSTORE
*hcs
= hCertStore
;
1101 TRACE("(%p, %p)\n", hCertStore
, pPrev
);
1104 else if (hcs
->dwMagic
!= WINE_CRYPTCERTSTORE_MAGIC
)
1107 ret
= (crl_t
*)hcs
->vtbl
->crls
.enumContext(hcs
, prev
? &prev
->base
: NULL
);
1108 return ret
? &ret
->ctx
: NULL
;
1111 HCERTSTORE WINAPI
CertDuplicateStore(HCERTSTORE hCertStore
)
1113 WINECRYPT_CERTSTORE
*hcs
= hCertStore
;
1115 TRACE("(%p)\n", hCertStore
);
1117 if (hcs
&& hcs
->dwMagic
== WINE_CRYPTCERTSTORE_MAGIC
)
1118 hcs
->vtbl
->addref(hcs
);
1122 BOOL WINAPI
CertCloseStore(HCERTSTORE hCertStore
, DWORD dwFlags
)
1124 WINECRYPT_CERTSTORE
*hcs
= hCertStore
;
1127 TRACE("(%p, %08x)\n", hCertStore
, dwFlags
);
1132 if ( hcs
->dwMagic
!= WINE_CRYPTCERTSTORE_MAGIC
)
1135 res
= hcs
->vtbl
->release(hcs
, dwFlags
);
1136 if (res
!= ERROR_SUCCESS
) {
1144 BOOL WINAPI
CertControlStore(HCERTSTORE hCertStore
, DWORD dwFlags
,
1145 DWORD dwCtrlType
, void const *pvCtrlPara
)
1147 WINECRYPT_CERTSTORE
*hcs
= hCertStore
;
1150 TRACE("(%p, %08x, %d, %p)\n", hCertStore
, dwFlags
, dwCtrlType
,
1155 else if (hcs
->dwMagic
!= WINE_CRYPTCERTSTORE_MAGIC
)
1159 if (hcs
->vtbl
->control
)
1160 ret
= hcs
->vtbl
->control(hcs
, dwFlags
, dwCtrlType
, pvCtrlPara
);
1167 BOOL WINAPI
CertGetStoreProperty(HCERTSTORE hCertStore
, DWORD dwPropId
,
1168 void *pvData
, DWORD
*pcbData
)
1170 WINECRYPT_CERTSTORE
*store
= hCertStore
;
1173 TRACE("(%p, %d, %p, %p)\n", hCertStore
, dwPropId
, pvData
, pcbData
);
1177 case CERT_ACCESS_STATE_PROP_ID
:
1180 *pcbData
= sizeof(DWORD
);
1183 else if (*pcbData
< sizeof(DWORD
))
1185 SetLastError(ERROR_MORE_DATA
);
1186 *pcbData
= sizeof(DWORD
);
1192 if (store
->type
!= StoreTypeMem
&&
1193 !(store
->dwOpenFlags
& CERT_STORE_READONLY_FLAG
))
1194 state
|= CERT_ACCESS_STATE_WRITE_PERSIST_FLAG
;
1195 *(DWORD
*)pvData
= state
;
1200 if (store
->properties
)
1202 CRYPT_DATA_BLOB blob
;
1204 ret
= ContextPropertyList_FindProperty(store
->properties
, dwPropId
,
1209 *pcbData
= blob
.cbData
;
1210 else if (*pcbData
< blob
.cbData
)
1212 SetLastError(ERROR_MORE_DATA
);
1213 *pcbData
= blob
.cbData
;
1218 memcpy(pvData
, blob
.pbData
, blob
.cbData
);
1219 *pcbData
= blob
.cbData
;
1223 SetLastError(CRYPT_E_NOT_FOUND
);
1226 SetLastError(CRYPT_E_NOT_FOUND
);
1231 BOOL WINAPI
CertSetStoreProperty(HCERTSTORE hCertStore
, DWORD dwPropId
,
1232 DWORD dwFlags
, const void *pvData
)
1234 WINECRYPT_CERTSTORE
*store
= hCertStore
;
1237 TRACE("(%p, %d, %08x, %p)\n", hCertStore
, dwPropId
, dwFlags
, pvData
);
1239 if (!store
->properties
)
1240 store
->properties
= ContextPropertyList_Create();
1243 case CERT_ACCESS_STATE_PROP_ID
:
1244 SetLastError(E_INVALIDARG
);
1249 const CRYPT_DATA_BLOB
*blob
= pvData
;
1251 ret
= ContextPropertyList_SetProperty(store
->properties
, dwPropId
,
1252 blob
->pbData
, blob
->cbData
);
1256 ContextPropertyList_RemoveProperty(store
->properties
, dwPropId
);
1263 static LONG
CRYPT_OpenParentStore(DWORD dwFlags
,
1264 void *pvSystemStoreLocationPara
, HKEY
*key
)
1269 TRACE("(%08x, %p)\n", dwFlags
, pvSystemStoreLocationPara
);
1271 switch (dwFlags
& CERT_SYSTEM_STORE_LOCATION_MASK
)
1273 case CERT_SYSTEM_STORE_LOCAL_MACHINE
:
1274 root
= HKEY_LOCAL_MACHINE
;
1275 base
= CERT_LOCAL_MACHINE_SYSTEM_STORE_REGPATH
;
1277 case CERT_SYSTEM_STORE_CURRENT_USER
:
1278 root
= HKEY_CURRENT_USER
;
1279 base
= CERT_LOCAL_MACHINE_SYSTEM_STORE_REGPATH
;
1281 case CERT_SYSTEM_STORE_CURRENT_SERVICE
:
1282 /* hklm\Software\Microsoft\Cryptography\Services\servicename\
1283 * SystemCertificates
1285 FIXME("CERT_SYSTEM_STORE_CURRENT_SERVICE\n");
1286 return ERROR_FILE_NOT_FOUND
;
1287 case CERT_SYSTEM_STORE_SERVICES
:
1288 /* hklm\Software\Microsoft\Cryptography\Services\servicename\
1289 * SystemCertificates
1291 FIXME("CERT_SYSTEM_STORE_SERVICES\n");
1292 return ERROR_FILE_NOT_FOUND
;
1293 case CERT_SYSTEM_STORE_USERS
:
1294 /* hku\user sid\Software\Microsoft\SystemCertificates */
1295 FIXME("CERT_SYSTEM_STORE_USERS\n");
1296 return ERROR_FILE_NOT_FOUND
;
1297 case CERT_SYSTEM_STORE_CURRENT_USER_GROUP_POLICY
:
1298 root
= HKEY_CURRENT_USER
;
1299 base
= CERT_GROUP_POLICY_SYSTEM_STORE_REGPATH
;
1301 case CERT_SYSTEM_STORE_LOCAL_MACHINE_GROUP_POLICY
:
1302 root
= HKEY_LOCAL_MACHINE
;
1303 base
= CERT_GROUP_POLICY_SYSTEM_STORE_REGPATH
;
1305 case CERT_SYSTEM_STORE_LOCAL_MACHINE_ENTERPRISE
:
1306 /* hklm\Software\Microsoft\EnterpriseCertificates */
1307 FIXME("CERT_SYSTEM_STORE_LOCAL_MACHINE_ENTERPRISE\n");
1308 return ERROR_FILE_NOT_FOUND
;
1310 return ERROR_FILE_NOT_FOUND
;
1313 return RegOpenKeyExW(root
, base
, 0, KEY_READ
, key
);
1316 BOOL WINAPI
CertEnumSystemStore(DWORD dwFlags
, void *pvSystemStoreLocationPara
,
1317 void *pvArg
, PFN_CERT_ENUM_SYSTEM_STORE pfnEnum
)
1322 CERT_SYSTEM_STORE_INFO info
= { sizeof(info
) };
1324 TRACE("(%08x, %p, %p, %p)\n", dwFlags
, pvSystemStoreLocationPara
, pvArg
,
1327 rc
= CRYPT_OpenParentStore(dwFlags
, pvArg
, &key
);
1334 WCHAR name
[MAX_PATH
];
1335 DWORD size
= ARRAY_SIZE(name
);
1337 rc
= RegEnumKeyExW(key
, index
++, name
, &size
, NULL
, NULL
, NULL
,
1340 ret
= pfnEnum(name
, dwFlags
, &info
, NULL
, pvArg
);
1341 } while (ret
&& !rc
);
1342 if (ret
&& rc
!= ERROR_NO_MORE_ITEMS
)
1347 /* Include root store for the local machine location (it isn't in the
1350 if (ret
&& (dwFlags
& CERT_SYSTEM_STORE_LOCATION_MASK
) ==
1351 CERT_SYSTEM_STORE_LOCAL_MACHINE
)
1352 ret
= pfnEnum(L
"Root", dwFlags
, &info
, NULL
, pvArg
);
1356 BOOL WINAPI
CertEnumPhysicalStore(const void *pvSystemStore
, DWORD dwFlags
,
1357 void *pvArg
, PFN_CERT_ENUM_PHYSICAL_STORE pfnEnum
)
1359 if (dwFlags
& CERT_SYSTEM_STORE_RELOCATE_FLAG
)
1360 FIXME("(%p, %08x, %p, %p): stub\n", pvSystemStore
, dwFlags
, pvArg
,
1363 FIXME("(%s, %08x, %p, %p): stub\n", debugstr_w(pvSystemStore
),
1369 BOOL WINAPI
CertRegisterPhysicalStore(const void *pvSystemStore
, DWORD dwFlags
,
1370 LPCWSTR pwszStoreName
, PCERT_PHYSICAL_STORE_INFO pStoreInfo
, void *pvReserved
)
1372 if (dwFlags
& CERT_SYSTEM_STORE_RELOCATE_FLAG
)
1373 FIXME("(%p, %08x, %s, %p, %p): stub\n", pvSystemStore
, dwFlags
,
1374 debugstr_w(pwszStoreName
), pStoreInfo
, pvReserved
);
1376 FIXME("(%s, %08x, %s, %p, %p): stub\n", debugstr_w(pvSystemStore
),
1377 dwFlags
, debugstr_w(pwszStoreName
), pStoreInfo
, pvReserved
);
1381 BOOL WINAPI
CertUnregisterPhysicalStore(const void *pvSystemStore
, DWORD dwFlags
,
1382 LPCWSTR pwszStoreName
)
1384 FIXME("(%p, %08x, %s): stub\n", pvSystemStore
, dwFlags
, debugstr_w(pwszStoreName
));
1388 BOOL WINAPI
CertRegisterSystemStore(const void *pvSystemStore
, DWORD dwFlags
,
1389 PCERT_SYSTEM_STORE_INFO pStoreInfo
, void *pvReserved
)
1393 if (dwFlags
& CERT_SYSTEM_STORE_RELOCATE_FLAG
)
1395 FIXME("(%p, %08x, %p, %p): flag not supported\n", pvSystemStore
, dwFlags
, pStoreInfo
, pvReserved
);
1399 TRACE("(%s, %08x, %p, %p)\n", debugstr_w(pvSystemStore
), dwFlags
, pStoreInfo
, pvReserved
);
1401 hstore
= CertOpenStore(CERT_STORE_PROV_SYSTEM_REGISTRY_W
, 0, 0, dwFlags
, pvSystemStore
);
1404 CertCloseStore(hstore
, 0);
1411 BOOL WINAPI
CertUnregisterSystemStore(const void *pvSystemStore
, DWORD dwFlags
)
1415 if (dwFlags
& CERT_SYSTEM_STORE_RELOCATE_FLAG
)
1417 FIXME("(%p, %08x): flag not supported\n", pvSystemStore
, dwFlags
);
1420 TRACE("(%s, %08x)\n", debugstr_w(pvSystemStore
), dwFlags
);
1422 hstore
= CertOpenStore(CERT_STORE_PROV_SYSTEM_REGISTRY_W
, 0, 0, dwFlags
| CERT_STORE_OPEN_EXISTING_FLAG
, pvSystemStore
);
1426 hstore
= CertOpenStore(CERT_STORE_PROV_SYSTEM_REGISTRY_W
, 0, 0, dwFlags
| CERT_STORE_DELETE_FLAG
, pvSystemStore
);
1427 if (hstore
== NULL
&& GetLastError() == 0)
1433 static void EmptyStore_addref(WINECRYPT_CERTSTORE
*store
)
1435 TRACE("(%p)\n", store
);
1438 static DWORD
EmptyStore_release(WINECRYPT_CERTSTORE
*store
, DWORD flags
)
1440 TRACE("(%p)\n", store
);
1441 return E_UNEXPECTED
;
1444 static void EmptyStore_releaseContext(WINECRYPT_CERTSTORE
*store
, context_t
*context
)
1446 Context_Free(context
);
1449 static BOOL
EmptyStore_add(WINECRYPT_CERTSTORE
*store
, context_t
*context
,
1450 context_t
*replace
, context_t
**ret_context
, BOOL use_link
)
1452 TRACE("(%p, %p, %p, %p)\n", store
, context
, replace
, ret_context
);
1454 /* FIXME: We should clone the context */
1456 Context_AddRef(context
);
1457 *ret_context
= context
;
1463 static context_t
*EmptyStore_enum(WINECRYPT_CERTSTORE
*store
, context_t
*prev
)
1465 TRACE("(%p, %p)\n", store
, prev
);
1467 SetLastError(CRYPT_E_NOT_FOUND
);
1471 static BOOL
EmptyStore_delete(WINECRYPT_CERTSTORE
*store
, context_t
*context
)
1476 static BOOL
EmptyStore_control(WINECRYPT_CERTSTORE
*store
, DWORD flags
, DWORD ctrl_type
, void const *ctrl_para
)
1480 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
1484 static const store_vtbl_t EmptyStoreVtbl
= {
1487 EmptyStore_releaseContext
,
1504 WINECRYPT_CERTSTORE empty_store
;
1506 void init_empty_store(void)
1508 CRYPT_InitStore(&empty_store
, CERT_STORE_READONLY_FLAG
, StoreTypeEmpty
, &EmptyStoreVtbl
);