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.
26 #include "crypt32_private.h"
28 WINE_DEFAULT_DEBUG_CHANNEL(crypt
);
30 static const WINE_CONTEXT_INTERFACE gCertInterface
= {
31 (CreateContextFunc
)CertCreateCertificateContext
,
32 (AddContextToStoreFunc
)CertAddCertificateContextToStore
,
33 (AddEncodedContextToStoreFunc
)CertAddEncodedCertificateToStore
,
34 (EnumContextsInStoreFunc
)CertEnumCertificatesInStore
,
35 (EnumPropertiesFunc
)CertEnumCertificateContextProperties
,
36 (GetContextPropertyFunc
)CertGetCertificateContextProperty
,
37 (SetContextPropertyFunc
)CertSetCertificateContextProperty
,
38 (SerializeElementFunc
)CertSerializeCertificateStoreElement
,
39 (DeleteContextFunc
)CertDeleteCertificateFromStore
,
41 const WINE_CONTEXT_INTERFACE
*pCertInterface
= &gCertInterface
;
43 static const WINE_CONTEXT_INTERFACE gCRLInterface
= {
44 (CreateContextFunc
)CertCreateCRLContext
,
45 (AddContextToStoreFunc
)CertAddCRLContextToStore
,
46 (AddEncodedContextToStoreFunc
)CertAddEncodedCRLToStore
,
47 (EnumContextsInStoreFunc
)CertEnumCRLsInStore
,
48 (EnumPropertiesFunc
)CertEnumCRLContextProperties
,
49 (GetContextPropertyFunc
)CertGetCRLContextProperty
,
50 (SetContextPropertyFunc
)CertSetCRLContextProperty
,
51 (SerializeElementFunc
)CertSerializeCRLStoreElement
,
52 (DeleteContextFunc
)CertDeleteCRLFromStore
,
54 const WINE_CONTEXT_INTERFACE
*pCRLInterface
= &gCRLInterface
;
56 static const WINE_CONTEXT_INTERFACE gCTLInterface
= {
57 (CreateContextFunc
)CertCreateCTLContext
,
58 (AddContextToStoreFunc
)CertAddCTLContextToStore
,
59 (AddEncodedContextToStoreFunc
)CertAddEncodedCTLToStore
,
60 (EnumContextsInStoreFunc
)CertEnumCTLsInStore
,
61 (EnumPropertiesFunc
)CertEnumCTLContextProperties
,
62 (GetContextPropertyFunc
)CertGetCTLContextProperty
,
63 (SetContextPropertyFunc
)CertSetCTLContextProperty
,
64 (SerializeElementFunc
)CertSerializeCTLStoreElement
,
65 (DeleteContextFunc
)CertDeleteCTLFromStore
,
67 const WINE_CONTEXT_INTERFACE
*pCTLInterface
= &gCTLInterface
;
69 typedef struct _WINE_MEMSTORE
71 WINECRYPT_CERTSTORE hdr
;
78 void CRYPT_InitStore(WINECRYPT_CERTSTORE
*store
, DWORD dwFlags
, CertStoreType type
, const store_vtbl_t
*vtbl
)
81 store
->dwMagic
= WINE_CRYPTCERTSTORE_MAGIC
;
83 store
->dwOpenFlags
= dwFlags
;
85 store
->properties
= NULL
;
88 void CRYPT_FreeStore(WINECRYPT_CERTSTORE
*store
)
90 if (store
->properties
)
91 ContextPropertyList_Free(store
->properties
);
96 BOOL WINAPI
I_CertUpdateStore(HCERTSTORE store1
, HCERTSTORE store2
, DWORD unk0
,
99 static BOOL warned
= FALSE
;
100 const WINE_CONTEXT_INTERFACE
* const interfaces
[] = { pCertInterface
,
101 pCRLInterface
, pCTLInterface
};
104 TRACE("(%p, %p, %08x, %08x)\n", store1
, store2
, unk0
, unk1
);
107 FIXME("semi-stub\n");
111 /* Poor-man's resync: empty first store, then add everything from second
114 for (i
= 0; i
< sizeof(interfaces
) / sizeof(interfaces
[0]); i
++)
119 context
= interfaces
[i
]->enumContextsInStore(store1
, NULL
);
121 interfaces
[i
]->deleteFromStore(context
);
124 context
= interfaces
[i
]->enumContextsInStore(store2
, context
);
126 interfaces
[i
]->addContextToStore(store1
, context
,
127 CERT_STORE_ADD_ALWAYS
, NULL
);
133 static BOOL
MemStore_addContext(WINE_MEMSTORE
*store
, struct list
*list
, context_t
*orig_context
,
134 context_t
*existing
, context_t
**ret_context
, BOOL use_link
)
138 context
= orig_context
->vtbl
->clone(orig_context
, &store
->hdr
, use_link
);
142 TRACE("adding %p\n", context
);
143 EnterCriticalSection(&store
->cs
);
145 context
->u
.entry
.prev
= existing
->u
.entry
.prev
;
146 context
->u
.entry
.next
= existing
->u
.entry
.next
;
147 context
->u
.entry
.prev
->next
= &context
->u
.entry
;
148 context
->u
.entry
.next
->prev
= &context
->u
.entry
;
149 list_init(&existing
->u
.entry
);
151 Context_Release(existing
);
153 list_add_head(list
, &context
->u
.entry
);
155 LeaveCriticalSection(&store
->cs
);
158 *ret_context
= context
;
160 Context_Release(context
);
164 static context_t
*MemStore_enumContext(WINE_MEMSTORE
*store
, struct list
*list
, context_t
*prev
)
169 EnterCriticalSection(&store
->cs
);
171 next
= list_next(list
, &prev
->u
.entry
);
172 Context_Release(prev
);
174 next
= list_next(list
, list
);
176 LeaveCriticalSection(&store
->cs
);
179 SetLastError(CRYPT_E_NOT_FOUND
);
183 ret
= LIST_ENTRY(next
, context_t
, u
.entry
);
188 static BOOL
MemStore_deleteContext(WINE_MEMSTORE
*store
, context_t
*context
)
190 BOOL in_list
= FALSE
;
192 EnterCriticalSection(&store
->cs
);
193 if (!list_empty(&context
->u
.entry
)) {
194 list_remove(&context
->u
.entry
);
195 list_init(&context
->u
.entry
);
198 LeaveCriticalSection(&store
->cs
);
200 if(in_list
&& !context
->ref
)
201 Context_Free(context
);
205 static void free_contexts(struct list
*list
)
207 context_t
*context
, *next
;
209 LIST_FOR_EACH_ENTRY_SAFE(context
, next
, list
, context_t
, u
.entry
)
211 TRACE("freeing %p\n", context
);
212 list_remove(&context
->u
.entry
);
213 Context_Free(context
);
217 static void MemStore_releaseContext(WINECRYPT_CERTSTORE
*store
, context_t
*context
)
219 /* Free the context only if it's not in a list. Otherwise it may be reused later. */
220 if(list_empty(&context
->u
.entry
))
221 Context_Free(context
);
224 static BOOL
MemStore_addCert(WINECRYPT_CERTSTORE
*store
, context_t
*cert
,
225 context_t
*toReplace
, context_t
**ppStoreContext
, BOOL use_link
)
227 WINE_MEMSTORE
*ms
= (WINE_MEMSTORE
*)store
;
229 TRACE("(%p, %p, %p, %p)\n", store
, cert
, toReplace
, ppStoreContext
);
230 return MemStore_addContext(ms
, &ms
->certs
, cert
, toReplace
, ppStoreContext
, use_link
);
233 static context_t
*MemStore_enumCert(WINECRYPT_CERTSTORE
*store
, context_t
*prev
)
235 WINE_MEMSTORE
*ms
= (WINE_MEMSTORE
*)store
;
237 TRACE("(%p, %p)\n", store
, prev
);
239 return MemStore_enumContext(ms
, &ms
->certs
, prev
);
242 static BOOL
MemStore_deleteCert(WINECRYPT_CERTSTORE
*store
, context_t
*context
)
244 WINE_MEMSTORE
*ms
= (WINE_MEMSTORE
*)store
;
246 TRACE("(%p, %p)\n", store
, context
);
248 return MemStore_deleteContext(ms
, context
);
251 static BOOL
MemStore_addCRL(WINECRYPT_CERTSTORE
*store
, context_t
*crl
,
252 context_t
*toReplace
, context_t
**ppStoreContext
, BOOL use_link
)
254 WINE_MEMSTORE
*ms
= (WINE_MEMSTORE
*)store
;
256 TRACE("(%p, %p, %p, %p)\n", store
, crl
, toReplace
, ppStoreContext
);
258 return MemStore_addContext(ms
, &ms
->crls
, crl
, toReplace
, ppStoreContext
, use_link
);
261 static context_t
*MemStore_enumCRL(WINECRYPT_CERTSTORE
*store
, context_t
*prev
)
263 WINE_MEMSTORE
*ms
= (WINE_MEMSTORE
*)store
;
265 TRACE("(%p, %p)\n", store
, prev
);
267 return MemStore_enumContext(ms
, &ms
->crls
, prev
);
270 static BOOL
MemStore_deleteCRL(WINECRYPT_CERTSTORE
*store
, context_t
*context
)
272 WINE_MEMSTORE
*ms
= (WINE_MEMSTORE
*)store
;
274 TRACE("(%p, %p)\n", store
, context
);
276 return MemStore_deleteContext(ms
, context
);
279 static BOOL
MemStore_addCTL(WINECRYPT_CERTSTORE
*store
, context_t
*ctl
,
280 context_t
*toReplace
, context_t
**ppStoreContext
, BOOL use_link
)
282 WINE_MEMSTORE
*ms
= (WINE_MEMSTORE
*)store
;
284 TRACE("(%p, %p, %p, %p)\n", store
, ctl
, toReplace
, ppStoreContext
);
286 return MemStore_addContext(ms
, &ms
->ctls
, ctl
, toReplace
, ppStoreContext
, use_link
);
289 static context_t
*MemStore_enumCTL(WINECRYPT_CERTSTORE
*store
, context_t
*prev
)
291 WINE_MEMSTORE
*ms
= (WINE_MEMSTORE
*)store
;
293 TRACE("(%p, %p)\n", store
, prev
);
295 return MemStore_enumContext(ms
, &ms
->ctls
, prev
);
298 static BOOL
MemStore_deleteCTL(WINECRYPT_CERTSTORE
*store
, context_t
*context
)
300 WINE_MEMSTORE
*ms
= (WINE_MEMSTORE
*)store
;
302 TRACE("(%p, %p)\n", store
, context
);
304 return MemStore_deleteContext(ms
, context
);
307 static void MemStore_addref(WINECRYPT_CERTSTORE
*store
)
309 LONG ref
= InterlockedIncrement(&store
->ref
);
310 TRACE("ref = %d\n", ref
);
313 static DWORD
MemStore_release(WINECRYPT_CERTSTORE
*cert_store
, DWORD flags
)
315 WINE_MEMSTORE
*store
= (WINE_MEMSTORE
*)cert_store
;
318 if(flags
& ~CERT_CLOSE_STORE_CHECK_FLAG
)
319 FIXME("Unimplemented flags %x\n", flags
);
321 ref
= InterlockedDecrement(&store
->hdr
.ref
);
322 TRACE("(%p) ref=%d\n", store
, ref
);
324 return (flags
& CERT_CLOSE_STORE_CHECK_FLAG
) ? CRYPT_E_PENDING_CLOSE
: ERROR_SUCCESS
;
326 free_contexts(&store
->certs
);
327 free_contexts(&store
->crls
);
328 free_contexts(&store
->ctls
);
329 store
->cs
.DebugInfo
->Spare
[0] = 0;
330 DeleteCriticalSection(&store
->cs
);
331 CRYPT_FreeStore(&store
->hdr
);
332 return ERROR_SUCCESS
;
335 static BOOL
MemStore_control(WINECRYPT_CERTSTORE
*store
, DWORD dwFlags
,
336 DWORD dwCtrlType
, void const *pvCtrlPara
)
338 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
342 static const store_vtbl_t MemStoreVtbl
= {
345 MemStore_releaseContext
,
362 static WINECRYPT_CERTSTORE
*CRYPT_MemOpenStore(HCRYPTPROV hCryptProv
,
363 DWORD dwFlags
, const void *pvPara
)
365 WINE_MEMSTORE
*store
;
367 TRACE("(%ld, %08x, %p)\n", hCryptProv
, dwFlags
, pvPara
);
369 if (dwFlags
& CERT_STORE_DELETE_FLAG
)
371 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
376 store
= CryptMemAlloc(sizeof(WINE_MEMSTORE
));
379 memset(store
, 0, sizeof(WINE_MEMSTORE
));
380 CRYPT_InitStore(&store
->hdr
, dwFlags
, StoreTypeMem
, &MemStoreVtbl
);
381 InitializeCriticalSection(&store
->cs
);
382 store
->cs
.DebugInfo
->Spare
[0] = (DWORD_PTR
)(__FILE__
": ContextList.cs");
383 list_init(&store
->certs
);
384 list_init(&store
->crls
);
385 list_init(&store
->ctls
);
386 /* Mem store doesn't need crypto provider, so close it */
387 if (hCryptProv
&& !(dwFlags
& CERT_STORE_NO_CRYPT_RELEASE_FLAG
))
388 CryptReleaseContext(hCryptProv
, 0);
391 return (WINECRYPT_CERTSTORE
*)store
;
394 static const WCHAR rootW
[] = { 'R','o','o','t',0 };
396 static WINECRYPT_CERTSTORE
*CRYPT_SysRegOpenStoreW(HCRYPTPROV hCryptProv
,
397 DWORD dwFlags
, const void *pvPara
)
399 static const WCHAR fmt
[] = { '%','s','\\','%','s',0 };
400 LPCWSTR storeName
= pvPara
;
402 WINECRYPT_CERTSTORE
*store
= NULL
;
406 TRACE("(%ld, %08x, %s)\n", hCryptProv
, dwFlags
,
411 SetLastError(E_INVALIDARG
);
414 /* FIXME: In Windows, the root store (even the current user location) is
415 * protected: adding to it or removing from it present a user interface,
416 * and the keys are owned by the system process, not the current user.
417 * Wine's registry doesn't implement access controls, so a similar
418 * mechanism isn't possible yet.
420 if ((dwFlags
& CERT_SYSTEM_STORE_LOCATION_MASK
) ==
421 CERT_SYSTEM_STORE_LOCAL_MACHINE
&& !lstrcmpiW(storeName
, rootW
))
422 return CRYPT_RootOpenStore(hCryptProv
, dwFlags
);
424 switch (dwFlags
& CERT_SYSTEM_STORE_LOCATION_MASK
)
426 case CERT_SYSTEM_STORE_LOCAL_MACHINE
:
427 root
= HKEY_LOCAL_MACHINE
;
428 base
= CERT_LOCAL_MACHINE_SYSTEM_STORE_REGPATH
;
430 case CERT_SYSTEM_STORE_CURRENT_USER
:
431 root
= HKEY_CURRENT_USER
;
432 base
= CERT_LOCAL_MACHINE_SYSTEM_STORE_REGPATH
;
434 case CERT_SYSTEM_STORE_CURRENT_SERVICE
:
435 /* hklm\Software\Microsoft\Cryptography\Services\servicename\
438 FIXME("CERT_SYSTEM_STORE_CURRENT_SERVICE, %s: stub\n",
439 debugstr_w(storeName
));
441 case CERT_SYSTEM_STORE_SERVICES
:
442 /* hklm\Software\Microsoft\Cryptography\Services\servicename\
445 FIXME("CERT_SYSTEM_STORE_SERVICES, %s: stub\n",
446 debugstr_w(storeName
));
448 case CERT_SYSTEM_STORE_USERS
:
449 /* hku\user sid\Software\Microsoft\SystemCertificates */
450 FIXME("CERT_SYSTEM_STORE_USERS, %s: stub\n",
451 debugstr_w(storeName
));
453 case CERT_SYSTEM_STORE_CURRENT_USER_GROUP_POLICY
:
454 root
= HKEY_CURRENT_USER
;
455 base
= CERT_GROUP_POLICY_SYSTEM_STORE_REGPATH
;
457 case CERT_SYSTEM_STORE_LOCAL_MACHINE_GROUP_POLICY
:
458 root
= HKEY_LOCAL_MACHINE
;
459 base
= CERT_GROUP_POLICY_SYSTEM_STORE_REGPATH
;
461 case CERT_SYSTEM_STORE_LOCAL_MACHINE_ENTERPRISE
:
462 /* hklm\Software\Microsoft\EnterpriseCertificates */
463 FIXME("CERT_SYSTEM_STORE_LOCAL_MACHINE_ENTERPRISE, %s: stub\n",
464 debugstr_w(storeName
));
467 SetLastError(E_INVALIDARG
);
471 storePath
= CryptMemAlloc((lstrlenW(base
) + lstrlenW(storeName
) + 2) *
477 REGSAM sam
= dwFlags
& CERT_STORE_READONLY_FLAG
? KEY_READ
:
480 wsprintfW(storePath
, fmt
, base
, storeName
);
481 if (dwFlags
& CERT_STORE_OPEN_EXISTING_FLAG
)
482 rc
= RegOpenKeyExW(root
, storePath
, 0, sam
, &key
);
487 rc
= RegCreateKeyExW(root
, storePath
, 0, NULL
, 0, sam
, NULL
,
489 if (!rc
&& dwFlags
& CERT_STORE_CREATE_NEW_FLAG
&&
490 disp
== REG_OPENED_EXISTING_KEY
)
493 rc
= ERROR_FILE_EXISTS
;
498 store
= CRYPT_RegOpenStore(hCryptProv
, dwFlags
, key
);
503 CryptMemFree(storePath
);
508 static WINECRYPT_CERTSTORE
*CRYPT_SysRegOpenStoreA(HCRYPTPROV hCryptProv
,
509 DWORD dwFlags
, const void *pvPara
)
512 WINECRYPT_CERTSTORE
*ret
= NULL
;
514 TRACE("(%ld, %08x, %s)\n", hCryptProv
, dwFlags
,
519 SetLastError(ERROR_FILE_NOT_FOUND
);
522 len
= MultiByteToWideChar(CP_ACP
, 0, pvPara
, -1, NULL
, 0);
525 LPWSTR storeName
= CryptMemAlloc(len
* sizeof(WCHAR
));
529 MultiByteToWideChar(CP_ACP
, 0, pvPara
, -1, storeName
, len
);
530 ret
= CRYPT_SysRegOpenStoreW(hCryptProv
, dwFlags
, storeName
);
531 CryptMemFree(storeName
);
537 static WINECRYPT_CERTSTORE
*CRYPT_SysOpenStoreW(HCRYPTPROV hCryptProv
,
538 DWORD dwFlags
, const void *pvPara
)
540 HCERTSTORE store
= 0;
543 TRACE("(%ld, %08x, %s)\n", hCryptProv
, dwFlags
,
548 SetLastError(ERROR_FILE_NOT_FOUND
);
551 /* This returns a different error than system registry stores if the
552 * location is invalid.
554 switch (dwFlags
& CERT_SYSTEM_STORE_LOCATION_MASK
)
556 case CERT_SYSTEM_STORE_LOCAL_MACHINE
:
557 case CERT_SYSTEM_STORE_CURRENT_USER
:
558 case CERT_SYSTEM_STORE_CURRENT_SERVICE
:
559 case CERT_SYSTEM_STORE_SERVICES
:
560 case CERT_SYSTEM_STORE_USERS
:
561 case CERT_SYSTEM_STORE_CURRENT_USER_GROUP_POLICY
:
562 case CERT_SYSTEM_STORE_LOCAL_MACHINE_GROUP_POLICY
:
563 case CERT_SYSTEM_STORE_LOCAL_MACHINE_ENTERPRISE
:
567 SetLastError(ERROR_FILE_NOT_FOUND
);
572 HCERTSTORE regStore
= CertOpenStore(CERT_STORE_PROV_SYSTEM_REGISTRY_W
,
573 0, 0, dwFlags
, pvPara
);
577 store
= CertOpenStore(CERT_STORE_PROV_COLLECTION
, 0, 0,
578 CERT_STORE_CREATE_NEW_FLAG
, NULL
);
579 CertAddStoreToCollection(store
, regStore
,
580 dwFlags
& CERT_STORE_READONLY_FLAG
? 0 :
581 CERT_PHYSICAL_STORE_ADD_ENABLE_FLAG
, 0);
582 CertCloseStore(regStore
, 0);
583 /* CERT_SYSTEM_STORE_CURRENT_USER returns both the HKCU and HKLM
586 if ((dwFlags
& CERT_SYSTEM_STORE_LOCATION_MASK
) ==
587 CERT_SYSTEM_STORE_CURRENT_USER
)
589 dwFlags
&= ~CERT_SYSTEM_STORE_CURRENT_USER
;
590 dwFlags
|= CERT_SYSTEM_STORE_LOCAL_MACHINE
;
591 regStore
= CertOpenStore(CERT_STORE_PROV_SYSTEM_REGISTRY_W
, 0,
595 CertAddStoreToCollection(store
, regStore
,
596 dwFlags
& CERT_STORE_READONLY_FLAG
? 0 :
597 CERT_PHYSICAL_STORE_ADD_ENABLE_FLAG
, 0);
598 CertCloseStore(regStore
, 0);
601 /* System store doesn't need crypto provider, so close it */
602 if (hCryptProv
&& !(dwFlags
& CERT_STORE_NO_CRYPT_RELEASE_FLAG
))
603 CryptReleaseContext(hCryptProv
, 0);
609 static WINECRYPT_CERTSTORE
*CRYPT_SysOpenStoreA(HCRYPTPROV hCryptProv
,
610 DWORD dwFlags
, const void *pvPara
)
613 WINECRYPT_CERTSTORE
*ret
= NULL
;
615 TRACE("(%ld, %08x, %s)\n", hCryptProv
, dwFlags
,
620 SetLastError(ERROR_FILE_NOT_FOUND
);
623 len
= MultiByteToWideChar(CP_ACP
, 0, pvPara
, -1, NULL
, 0);
626 LPWSTR storeName
= CryptMemAlloc(len
* sizeof(WCHAR
));
630 MultiByteToWideChar(CP_ACP
, 0, pvPara
, -1, storeName
, len
);
631 ret
= CRYPT_SysOpenStoreW(hCryptProv
, dwFlags
, storeName
);
632 CryptMemFree(storeName
);
638 static void WINAPI
CRYPT_MsgCloseStore(HCERTSTORE hCertStore
, DWORD dwFlags
)
640 HCRYPTMSG msg
= hCertStore
;
642 TRACE("(%p, %08x)\n", msg
, dwFlags
);
646 static void *msgProvFuncs
[] = {
650 static WINECRYPT_CERTSTORE
*CRYPT_MsgOpenStore(HCRYPTPROV hCryptProv
,
651 DWORD dwFlags
, const void *pvPara
)
653 WINECRYPT_CERTSTORE
*store
= NULL
;
654 HCRYPTMSG msg
= (HCRYPTMSG
)pvPara
;
655 WINECRYPT_CERTSTORE
*memStore
;
657 TRACE("(%ld, %08x, %p)\n", hCryptProv
, dwFlags
, pvPara
);
659 memStore
= CertOpenStore(CERT_STORE_PROV_MEMORY
, 0, 0,
660 CERT_STORE_CREATE_NEW_FLAG
, NULL
);
664 DWORD size
, count
, i
;
666 size
= sizeof(count
);
667 ret
= CryptMsgGetParam(msg
, CMSG_CERT_COUNT_PARAM
, 0, &count
, &size
);
668 for (i
= 0; ret
&& i
< count
; i
++)
671 ret
= CryptMsgGetParam(msg
, CMSG_CERT_PARAM
, i
, NULL
, &size
);
674 LPBYTE buf
= CryptMemAlloc(size
);
678 ret
= CryptMsgGetParam(msg
, CMSG_CERT_PARAM
, i
, buf
, &size
);
680 ret
= CertAddEncodedCertificateToStore(memStore
,
681 X509_ASN_ENCODING
, buf
, size
, CERT_STORE_ADD_ALWAYS
,
687 size
= sizeof(count
);
688 ret
= CryptMsgGetParam(msg
, CMSG_CRL_COUNT_PARAM
, 0, &count
, &size
);
689 for (i
= 0; ret
&& i
< count
; i
++)
692 ret
= CryptMsgGetParam(msg
, CMSG_CRL_PARAM
, i
, NULL
, &size
);
695 LPBYTE buf
= CryptMemAlloc(size
);
699 ret
= CryptMsgGetParam(msg
, CMSG_CRL_PARAM
, i
, buf
, &size
);
701 ret
= CertAddEncodedCRLToStore(memStore
,
702 X509_ASN_ENCODING
, buf
, size
, CERT_STORE_ADD_ALWAYS
,
710 CERT_STORE_PROV_INFO provInfo
= { 0 };
712 provInfo
.cbSize
= sizeof(provInfo
);
713 provInfo
.cStoreProvFunc
= sizeof(msgProvFuncs
) /
714 sizeof(msgProvFuncs
[0]);
715 provInfo
.rgpvStoreProvFunc
= msgProvFuncs
;
716 provInfo
.hStoreProv
= CryptMsgDuplicate(msg
);
717 store
= CRYPT_ProvCreateStore(dwFlags
, memStore
, &provInfo
);
718 /* Msg store doesn't need crypto provider, so close it */
719 if (hCryptProv
&& !(dwFlags
& CERT_STORE_NO_CRYPT_RELEASE_FLAG
))
720 CryptReleaseContext(hCryptProv
, 0);
723 CertCloseStore(memStore
, 0);
725 TRACE("returning %p\n", store
);
729 static WINECRYPT_CERTSTORE
*CRYPT_PKCSOpenStore(HCRYPTPROV hCryptProv
,
730 DWORD dwFlags
, const void *pvPara
)
733 WINECRYPT_CERTSTORE
*store
= NULL
;
734 const CRYPT_DATA_BLOB
*data
= pvPara
;
736 DWORD msgOpenFlags
= dwFlags
& CERT_STORE_NO_CRYPT_RELEASE_FLAG
? 0 :
737 CMSG_CRYPT_RELEASE_CONTEXT_FLAG
;
739 TRACE("(%ld, %08x, %p)\n", hCryptProv
, dwFlags
, pvPara
);
741 msg
= CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING
, msgOpenFlags
, CMSG_SIGNED
,
742 hCryptProv
, NULL
, NULL
);
743 ret
= CryptMsgUpdate(msg
, data
->pbData
, data
->cbData
, TRUE
);
747 msg
= CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING
, msgOpenFlags
, 0,
748 hCryptProv
, NULL
, NULL
);
749 ret
= CryptMsgUpdate(msg
, data
->pbData
, data
->cbData
, TRUE
);
752 DWORD type
, size
= sizeof(type
);
754 /* Only signed messages are allowed, check type */
755 ret
= CryptMsgGetParam(msg
, CMSG_TYPE_PARAM
, 0, &type
, &size
);
756 if (ret
&& type
!= CMSG_SIGNED
)
758 SetLastError(CRYPT_E_INVALID_MSG_TYPE
);
764 store
= CRYPT_MsgOpenStore(0, dwFlags
, msg
);
766 TRACE("returning %p\n", store
);
770 static WINECRYPT_CERTSTORE
*CRYPT_SerializedOpenStore(HCRYPTPROV hCryptProv
,
771 DWORD dwFlags
, const void *pvPara
)
774 const CRYPT_DATA_BLOB
*data
= pvPara
;
776 TRACE("(%ld, %08x, %p)\n", hCryptProv
, dwFlags
, pvPara
);
778 if (dwFlags
& CERT_STORE_DELETE_FLAG
)
780 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
784 store
= CertOpenStore(CERT_STORE_PROV_MEMORY
, 0, 0,
785 CERT_STORE_CREATE_NEW_FLAG
, NULL
);
788 if (!CRYPT_ReadSerializedStoreFromBlob(data
, store
))
790 CertCloseStore(store
, 0);
794 TRACE("returning %p\n", store
);
795 return (WINECRYPT_CERTSTORE
*)store
;
798 static WINECRYPT_CERTSTORE
*CRYPT_PhysOpenStoreW(HCRYPTPROV hCryptProv
,
799 DWORD dwFlags
, const void *pvPara
)
801 if (dwFlags
& CERT_SYSTEM_STORE_RELOCATE_FLAG
)
802 FIXME("(%ld, %08x, %p): stub\n", hCryptProv
, dwFlags
, pvPara
);
804 FIXME("(%ld, %08x, %s): stub\n", hCryptProv
, dwFlags
,
809 HCERTSTORE WINAPI
CertOpenStore(LPCSTR lpszStoreProvider
,
810 DWORD dwMsgAndCertEncodingType
, HCRYPTPROV_LEGACY hCryptProv
, DWORD dwFlags
,
813 WINECRYPT_CERTSTORE
*hcs
;
814 StoreOpenFunc openFunc
= NULL
;
816 TRACE("(%s, %08x, %08lx, %08x, %p)\n", debugstr_a(lpszStoreProvider
),
817 dwMsgAndCertEncodingType
, hCryptProv
, dwFlags
, pvPara
);
819 if (IS_INTOID(lpszStoreProvider
))
821 switch (LOWORD(lpszStoreProvider
))
823 case LOWORD(CERT_STORE_PROV_MSG
):
824 openFunc
= CRYPT_MsgOpenStore
;
826 case LOWORD(CERT_STORE_PROV_MEMORY
):
827 openFunc
= CRYPT_MemOpenStore
;
829 case LOWORD(CERT_STORE_PROV_FILE
):
830 openFunc
= CRYPT_FileOpenStore
;
832 case LOWORD(CERT_STORE_PROV_PKCS7
):
833 openFunc
= CRYPT_PKCSOpenStore
;
835 case LOWORD(CERT_STORE_PROV_SERIALIZED
):
836 openFunc
= CRYPT_SerializedOpenStore
;
838 case LOWORD(CERT_STORE_PROV_REG
):
839 openFunc
= CRYPT_RegOpenStore
;
841 case LOWORD(CERT_STORE_PROV_FILENAME_A
):
842 openFunc
= CRYPT_FileNameOpenStoreA
;
844 case LOWORD(CERT_STORE_PROV_FILENAME_W
):
845 openFunc
= CRYPT_FileNameOpenStoreW
;
847 case LOWORD(CERT_STORE_PROV_COLLECTION
):
848 openFunc
= CRYPT_CollectionOpenStore
;
850 case LOWORD(CERT_STORE_PROV_SYSTEM_A
):
851 openFunc
= CRYPT_SysOpenStoreA
;
853 case LOWORD(CERT_STORE_PROV_SYSTEM_W
):
854 openFunc
= CRYPT_SysOpenStoreW
;
856 case LOWORD(CERT_STORE_PROV_SYSTEM_REGISTRY_A
):
857 openFunc
= CRYPT_SysRegOpenStoreA
;
859 case LOWORD(CERT_STORE_PROV_SYSTEM_REGISTRY_W
):
860 openFunc
= CRYPT_SysRegOpenStoreW
;
862 case LOWORD(CERT_STORE_PROV_PHYSICAL_W
):
863 openFunc
= CRYPT_PhysOpenStoreW
;
866 if (LOWORD(lpszStoreProvider
))
867 FIXME("unimplemented type %d\n", LOWORD(lpszStoreProvider
));
870 else if (!strcasecmp(lpszStoreProvider
, sz_CERT_STORE_PROV_MEMORY
))
871 openFunc
= CRYPT_MemOpenStore
;
872 else if (!strcasecmp(lpszStoreProvider
, sz_CERT_STORE_PROV_FILENAME_W
))
873 openFunc
= CRYPT_FileOpenStore
;
874 else if (!strcasecmp(lpszStoreProvider
, sz_CERT_STORE_PROV_SYSTEM
))
875 openFunc
= CRYPT_SysOpenStoreW
;
876 else if (!strcasecmp(lpszStoreProvider
, sz_CERT_STORE_PROV_PKCS7
))
877 openFunc
= CRYPT_PKCSOpenStore
;
878 else if (!strcasecmp(lpszStoreProvider
, sz_CERT_STORE_PROV_SERIALIZED
))
879 openFunc
= CRYPT_SerializedOpenStore
;
880 else if (!strcasecmp(lpszStoreProvider
, sz_CERT_STORE_PROV_COLLECTION
))
881 openFunc
= CRYPT_CollectionOpenStore
;
882 else if (!strcasecmp(lpszStoreProvider
, sz_CERT_STORE_PROV_SYSTEM_REGISTRY
))
883 openFunc
= CRYPT_SysRegOpenStoreW
;
886 FIXME("unimplemented type %s\n", lpszStoreProvider
);
891 hcs
= CRYPT_ProvOpenStore(lpszStoreProvider
, dwMsgAndCertEncodingType
,
892 hCryptProv
, dwFlags
, pvPara
);
894 hcs
= openFunc(hCryptProv
, dwFlags
, pvPara
);
898 HCERTSTORE WINAPI
CertOpenSystemStoreA(HCRYPTPROV_LEGACY hProv
,
899 LPCSTR szSubSystemProtocol
)
901 if (!szSubSystemProtocol
)
903 SetLastError(E_INVALIDARG
);
906 return CertOpenStore(CERT_STORE_PROV_SYSTEM_A
, 0, hProv
,
907 CERT_SYSTEM_STORE_CURRENT_USER
, szSubSystemProtocol
);
910 HCERTSTORE WINAPI
CertOpenSystemStoreW(HCRYPTPROV_LEGACY hProv
,
911 LPCWSTR szSubSystemProtocol
)
913 if (!szSubSystemProtocol
)
915 SetLastError(E_INVALIDARG
);
918 return CertOpenStore(CERT_STORE_PROV_SYSTEM_W
, 0, hProv
,
919 CERT_SYSTEM_STORE_CURRENT_USER
, szSubSystemProtocol
);
922 PCCERT_CONTEXT WINAPI
CertEnumCertificatesInStore(HCERTSTORE hCertStore
, PCCERT_CONTEXT pPrev
)
924 cert_t
*prev
= pPrev
? cert_from_ptr(pPrev
) : NULL
, *ret
;
925 WINECRYPT_CERTSTORE
*hcs
= hCertStore
;
927 TRACE("(%p, %p)\n", hCertStore
, pPrev
);
930 else if (hcs
->dwMagic
!= WINE_CRYPTCERTSTORE_MAGIC
)
933 ret
= (cert_t
*)hcs
->vtbl
->certs
.enumContext(hcs
, prev
? &prev
->base
: NULL
);
934 return ret
? &ret
->ctx
: NULL
;
937 BOOL WINAPI
CertDeleteCertificateFromStore(PCCERT_CONTEXT pCertContext
)
939 WINECRYPT_CERTSTORE
*hcs
;
941 TRACE("(%p)\n", pCertContext
);
946 hcs
= pCertContext
->hCertStore
;
948 if (hcs
->dwMagic
!= WINE_CRYPTCERTSTORE_MAGIC
)
951 return hcs
->vtbl
->certs
.delete(hcs
, &cert_from_ptr(pCertContext
)->base
);
954 BOOL WINAPI
CertAddCRLContextToStore(HCERTSTORE hCertStore
,
955 PCCRL_CONTEXT pCrlContext
, DWORD dwAddDisposition
,
956 PCCRL_CONTEXT
* ppStoreContext
)
958 WINECRYPT_CERTSTORE
*store
= hCertStore
;
960 PCCRL_CONTEXT toAdd
= NULL
, existing
= NULL
;
962 TRACE("(%p, %p, %08x, %p)\n", hCertStore
, pCrlContext
,
963 dwAddDisposition
, ppStoreContext
);
965 /* Weird case to pass a test */
966 if (dwAddDisposition
== 0)
968 SetLastError(STATUS_ACCESS_VIOLATION
);
971 if (dwAddDisposition
!= CERT_STORE_ADD_ALWAYS
)
973 existing
= CertFindCRLInStore(hCertStore
, 0, 0, CRL_FIND_EXISTING
,
977 switch (dwAddDisposition
)
979 case CERT_STORE_ADD_ALWAYS
:
980 toAdd
= CertDuplicateCRLContext(pCrlContext
);
982 case CERT_STORE_ADD_NEW
:
985 TRACE("found matching CRL, not adding\n");
986 SetLastError(CRYPT_E_EXISTS
);
990 toAdd
= CertDuplicateCRLContext(pCrlContext
);
992 case CERT_STORE_ADD_NEWER
:
995 LONG newer
= CompareFileTime(&existing
->pCrlInfo
->ThisUpdate
,
996 &pCrlContext
->pCrlInfo
->ThisUpdate
);
999 toAdd
= CertDuplicateCRLContext(pCrlContext
);
1002 TRACE("existing CRL is newer, not adding\n");
1003 SetLastError(CRYPT_E_EXISTS
);
1008 toAdd
= CertDuplicateCRLContext(pCrlContext
);
1010 case CERT_STORE_ADD_NEWER_INHERIT_PROPERTIES
:
1013 LONG newer
= CompareFileTime(&existing
->pCrlInfo
->ThisUpdate
,
1014 &pCrlContext
->pCrlInfo
->ThisUpdate
);
1018 toAdd
= CertDuplicateCRLContext(pCrlContext
);
1019 Context_CopyProperties(toAdd
, existing
);
1023 TRACE("existing CRL is newer, not adding\n");
1024 SetLastError(CRYPT_E_EXISTS
);
1029 toAdd
= CertDuplicateCRLContext(pCrlContext
);
1031 case CERT_STORE_ADD_REPLACE_EXISTING
:
1032 toAdd
= CertDuplicateCRLContext(pCrlContext
);
1034 case CERT_STORE_ADD_REPLACE_EXISTING_INHERIT_PROPERTIES
:
1035 toAdd
= CertDuplicateCRLContext(pCrlContext
);
1037 Context_CopyProperties(toAdd
, existing
);
1039 case CERT_STORE_ADD_USE_EXISTING
:
1042 Context_CopyProperties(existing
, pCrlContext
);
1044 *ppStoreContext
= CertDuplicateCRLContext(existing
);
1047 toAdd
= CertDuplicateCRLContext(pCrlContext
);
1050 FIXME("Unimplemented add disposition %d\n", dwAddDisposition
);
1057 context_t
*ret_context
;
1058 ret
= store
->vtbl
->crls
.addContext(store
, context_from_ptr(toAdd
),
1059 existing
? context_from_ptr(existing
) : NULL
, ppStoreContext
? &ret_context
: NULL
, FALSE
);
1060 if (ret
&& ppStoreContext
)
1061 *ppStoreContext
= context_ptr(ret_context
);
1062 }else if (ppStoreContext
) {
1063 *ppStoreContext
= CertDuplicateCRLContext(toAdd
);
1065 CertFreeCRLContext(toAdd
);
1068 CertFreeCRLContext(existing
);
1070 TRACE("returning %d\n", ret
);
1074 BOOL WINAPI
CertDeleteCRLFromStore(PCCRL_CONTEXT pCrlContext
)
1076 WINECRYPT_CERTSTORE
*hcs
;
1079 TRACE("(%p)\n", pCrlContext
);
1084 hcs
= pCrlContext
->hCertStore
;
1086 if (hcs
->dwMagic
!= WINE_CRYPTCERTSTORE_MAGIC
)
1089 ret
= hcs
->vtbl
->crls
.delete(hcs
, &crl_from_ptr(pCrlContext
)->base
);
1091 ret
= CertFreeCRLContext(pCrlContext
);
1095 PCCRL_CONTEXT WINAPI
CertEnumCRLsInStore(HCERTSTORE hCertStore
, PCCRL_CONTEXT pPrev
)
1097 crl_t
*ret
, *prev
= pPrev
? crl_from_ptr(pPrev
) : NULL
;
1098 WINECRYPT_CERTSTORE
*hcs
= hCertStore
;
1100 TRACE("(%p, %p)\n", hCertStore
, pPrev
);
1103 else if (hcs
->dwMagic
!= WINE_CRYPTCERTSTORE_MAGIC
)
1106 ret
= (crl_t
*)hcs
->vtbl
->crls
.enumContext(hcs
, prev
? &prev
->base
: NULL
);
1107 return ret
? &ret
->ctx
: NULL
;
1110 HCERTSTORE WINAPI
CertDuplicateStore(HCERTSTORE hCertStore
)
1112 WINECRYPT_CERTSTORE
*hcs
= hCertStore
;
1114 TRACE("(%p)\n", hCertStore
);
1116 if (hcs
&& hcs
->dwMagic
== WINE_CRYPTCERTSTORE_MAGIC
)
1117 hcs
->vtbl
->addref(hcs
);
1121 BOOL WINAPI
CertCloseStore(HCERTSTORE hCertStore
, DWORD dwFlags
)
1123 WINECRYPT_CERTSTORE
*hcs
= hCertStore
;
1126 TRACE("(%p, %08x)\n", hCertStore
, dwFlags
);
1131 if ( hcs
->dwMagic
!= WINE_CRYPTCERTSTORE_MAGIC
)
1134 res
= hcs
->vtbl
->release(hcs
, dwFlags
);
1135 if (res
!= ERROR_SUCCESS
) {
1143 BOOL WINAPI
CertControlStore(HCERTSTORE hCertStore
, DWORD dwFlags
,
1144 DWORD dwCtrlType
, void const *pvCtrlPara
)
1146 WINECRYPT_CERTSTORE
*hcs
= hCertStore
;
1149 TRACE("(%p, %08x, %d, %p)\n", hCertStore
, dwFlags
, dwCtrlType
,
1154 else if (hcs
->dwMagic
!= WINE_CRYPTCERTSTORE_MAGIC
)
1158 if (hcs
->vtbl
->control
)
1159 ret
= hcs
->vtbl
->control(hcs
, dwFlags
, dwCtrlType
, pvCtrlPara
);
1166 BOOL WINAPI
CertGetStoreProperty(HCERTSTORE hCertStore
, DWORD dwPropId
,
1167 void *pvData
, DWORD
*pcbData
)
1169 WINECRYPT_CERTSTORE
*store
= hCertStore
;
1172 TRACE("(%p, %d, %p, %p)\n", hCertStore
, dwPropId
, pvData
, pcbData
);
1176 case CERT_ACCESS_STATE_PROP_ID
:
1179 *pcbData
= sizeof(DWORD
);
1182 else if (*pcbData
< sizeof(DWORD
))
1184 SetLastError(ERROR_MORE_DATA
);
1185 *pcbData
= sizeof(DWORD
);
1191 if (store
->type
!= StoreTypeMem
&&
1192 !(store
->dwOpenFlags
& CERT_STORE_READONLY_FLAG
))
1193 state
|= CERT_ACCESS_STATE_WRITE_PERSIST_FLAG
;
1194 *(DWORD
*)pvData
= state
;
1199 if (store
->properties
)
1201 CRYPT_DATA_BLOB blob
;
1203 ret
= ContextPropertyList_FindProperty(store
->properties
, dwPropId
,
1208 *pcbData
= blob
.cbData
;
1209 else if (*pcbData
< blob
.cbData
)
1211 SetLastError(ERROR_MORE_DATA
);
1212 *pcbData
= blob
.cbData
;
1217 memcpy(pvData
, blob
.pbData
, blob
.cbData
);
1218 *pcbData
= blob
.cbData
;
1222 SetLastError(CRYPT_E_NOT_FOUND
);
1225 SetLastError(CRYPT_E_NOT_FOUND
);
1230 BOOL WINAPI
CertSetStoreProperty(HCERTSTORE hCertStore
, DWORD dwPropId
,
1231 DWORD dwFlags
, const void *pvData
)
1233 WINECRYPT_CERTSTORE
*store
= hCertStore
;
1236 TRACE("(%p, %d, %08x, %p)\n", hCertStore
, dwPropId
, dwFlags
, pvData
);
1238 if (!store
->properties
)
1239 store
->properties
= ContextPropertyList_Create();
1242 case CERT_ACCESS_STATE_PROP_ID
:
1243 SetLastError(E_INVALIDARG
);
1248 const CRYPT_DATA_BLOB
*blob
= pvData
;
1250 ret
= ContextPropertyList_SetProperty(store
->properties
, dwPropId
,
1251 blob
->pbData
, blob
->cbData
);
1255 ContextPropertyList_RemoveProperty(store
->properties
, dwPropId
);
1262 static LONG
CRYPT_OpenParentStore(DWORD dwFlags
,
1263 void *pvSystemStoreLocationPara
, HKEY
*key
)
1268 TRACE("(%08x, %p)\n", dwFlags
, pvSystemStoreLocationPara
);
1270 switch (dwFlags
& CERT_SYSTEM_STORE_LOCATION_MASK
)
1272 case CERT_SYSTEM_STORE_LOCAL_MACHINE
:
1273 root
= HKEY_LOCAL_MACHINE
;
1274 base
= CERT_LOCAL_MACHINE_SYSTEM_STORE_REGPATH
;
1276 case CERT_SYSTEM_STORE_CURRENT_USER
:
1277 root
= HKEY_CURRENT_USER
;
1278 base
= CERT_LOCAL_MACHINE_SYSTEM_STORE_REGPATH
;
1280 case CERT_SYSTEM_STORE_CURRENT_SERVICE
:
1281 /* hklm\Software\Microsoft\Cryptography\Services\servicename\
1282 * SystemCertificates
1284 FIXME("CERT_SYSTEM_STORE_CURRENT_SERVICE\n");
1285 return ERROR_FILE_NOT_FOUND
;
1286 case CERT_SYSTEM_STORE_SERVICES
:
1287 /* hklm\Software\Microsoft\Cryptography\Services\servicename\
1288 * SystemCertificates
1290 FIXME("CERT_SYSTEM_STORE_SERVICES\n");
1291 return ERROR_FILE_NOT_FOUND
;
1292 case CERT_SYSTEM_STORE_USERS
:
1293 /* hku\user sid\Software\Microsoft\SystemCertificates */
1294 FIXME("CERT_SYSTEM_STORE_USERS\n");
1295 return ERROR_FILE_NOT_FOUND
;
1296 case CERT_SYSTEM_STORE_CURRENT_USER_GROUP_POLICY
:
1297 root
= HKEY_CURRENT_USER
;
1298 base
= CERT_GROUP_POLICY_SYSTEM_STORE_REGPATH
;
1300 case CERT_SYSTEM_STORE_LOCAL_MACHINE_GROUP_POLICY
:
1301 root
= HKEY_LOCAL_MACHINE
;
1302 base
= CERT_GROUP_POLICY_SYSTEM_STORE_REGPATH
;
1304 case CERT_SYSTEM_STORE_LOCAL_MACHINE_ENTERPRISE
:
1305 /* hklm\Software\Microsoft\EnterpriseCertificates */
1306 FIXME("CERT_SYSTEM_STORE_LOCAL_MACHINE_ENTERPRISE\n");
1307 return ERROR_FILE_NOT_FOUND
;
1309 return ERROR_FILE_NOT_FOUND
;
1312 return RegOpenKeyExW(root
, base
, 0, KEY_READ
, key
);
1315 BOOL WINAPI
CertEnumSystemStore(DWORD dwFlags
, void *pvSystemStoreLocationPara
,
1316 void *pvArg
, PFN_CERT_ENUM_SYSTEM_STORE pfnEnum
)
1321 CERT_SYSTEM_STORE_INFO info
= { sizeof(info
) };
1323 TRACE("(%08x, %p, %p, %p)\n", dwFlags
, pvSystemStoreLocationPara
, pvArg
,
1326 rc
= CRYPT_OpenParentStore(dwFlags
, pvArg
, &key
);
1333 WCHAR name
[MAX_PATH
];
1334 DWORD size
= sizeof(name
) / sizeof(name
[0]);
1336 rc
= RegEnumKeyExW(key
, index
++, name
, &size
, NULL
, NULL
, NULL
,
1339 ret
= pfnEnum(name
, dwFlags
, &info
, NULL
, pvArg
);
1340 } while (ret
&& !rc
);
1341 if (ret
&& rc
!= ERROR_NO_MORE_ITEMS
)
1346 /* Include root store for the local machine location (it isn't in the
1349 if (ret
&& (dwFlags
& CERT_SYSTEM_STORE_LOCATION_MASK
) ==
1350 CERT_SYSTEM_STORE_LOCAL_MACHINE
)
1351 ret
= pfnEnum(rootW
, dwFlags
, &info
, NULL
, pvArg
);
1355 BOOL WINAPI
CertEnumPhysicalStore(const void *pvSystemStore
, DWORD dwFlags
,
1356 void *pvArg
, PFN_CERT_ENUM_PHYSICAL_STORE pfnEnum
)
1358 if (dwFlags
& CERT_SYSTEM_STORE_RELOCATE_FLAG
)
1359 FIXME("(%p, %08x, %p, %p): stub\n", pvSystemStore
, dwFlags
, pvArg
,
1362 FIXME("(%s, %08x, %p, %p): stub\n", debugstr_w(pvSystemStore
),
1368 BOOL WINAPI
CertRegisterPhysicalStore(const void *pvSystemStore
, DWORD dwFlags
,
1369 LPCWSTR pwszStoreName
, PCERT_PHYSICAL_STORE_INFO pStoreInfo
, void *pvReserved
)
1371 if (dwFlags
& CERT_SYSTEM_STORE_RELOCATE_FLAG
)
1372 FIXME("(%p, %08x, %s, %p, %p): stub\n", pvSystemStore
, dwFlags
,
1373 debugstr_w(pwszStoreName
), pStoreInfo
, pvReserved
);
1375 FIXME("(%s, %08x, %s, %p, %p): stub\n", debugstr_w(pvSystemStore
),
1376 dwFlags
, debugstr_w(pwszStoreName
), pStoreInfo
, pvReserved
);
1380 static void EmptyStore_addref(WINECRYPT_CERTSTORE
*store
)
1382 TRACE("(%p)\n", store
);
1385 static DWORD
EmptyStore_release(WINECRYPT_CERTSTORE
*store
, DWORD flags
)
1387 TRACE("(%p)\n", store
);
1388 return E_UNEXPECTED
;
1391 static void EmptyStore_releaseContext(WINECRYPT_CERTSTORE
*store
, context_t
*context
)
1393 Context_Free(context
);
1396 static BOOL
EmptyStore_add(WINECRYPT_CERTSTORE
*store
, context_t
*context
,
1397 context_t
*replace
, context_t
**ret_context
, BOOL use_link
)
1399 TRACE("(%p, %p, %p, %p)\n", store
, context
, replace
, ret_context
);
1401 /* FIXME: We should clone the context */
1403 Context_AddRef(context
);
1404 *ret_context
= context
;
1410 static context_t
*EmptyStore_enum(WINECRYPT_CERTSTORE
*store
, context_t
*prev
)
1412 TRACE("(%p, %p)\n", store
, prev
);
1414 SetLastError(CRYPT_E_NOT_FOUND
);
1418 static BOOL
EmptyStore_delete(WINECRYPT_CERTSTORE
*store
, context_t
*context
)
1423 static BOOL
EmptyStore_control(WINECRYPT_CERTSTORE
*store
, DWORD flags
, DWORD ctrl_type
, void const *ctrl_para
)
1427 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
1431 static const store_vtbl_t EmptyStoreVtbl
= {
1434 EmptyStore_releaseContext
,
1451 WINECRYPT_CERTSTORE empty_store
;
1453 void init_empty_store(void)
1455 CRYPT_InitStore(&empty_store
, CERT_STORE_READONLY_FLAG
, StoreTypeEmpty
, &EmptyStoreVtbl
);