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.
27 #include "wine/port.h"
37 #include "wine/debug.h"
38 #include "wine/list.h"
39 #include "wine/exception.h"
40 #include "crypt32_private.h"
42 WINE_DEFAULT_DEBUG_CHANNEL(crypt
);
44 static const WINE_CONTEXT_INTERFACE gCertInterface
= {
45 (CreateContextFunc
)CertCreateCertificateContext
,
46 (AddContextToStoreFunc
)CertAddCertificateContextToStore
,
47 (AddEncodedContextToStoreFunc
)CertAddEncodedCertificateToStore
,
48 (DuplicateContextFunc
)CertDuplicateCertificateContext
,
49 (EnumContextsInStoreFunc
)CertEnumCertificatesInStore
,
50 (EnumPropertiesFunc
)CertEnumCertificateContextProperties
,
51 (GetContextPropertyFunc
)CertGetCertificateContextProperty
,
52 (SetContextPropertyFunc
)CertSetCertificateContextProperty
,
53 (SerializeElementFunc
)CertSerializeCertificateStoreElement
,
54 (FreeContextFunc
)CertFreeCertificateContext
,
55 (DeleteContextFunc
)CertDeleteCertificateFromStore
,
57 PCWINE_CONTEXT_INTERFACE pCertInterface
= &gCertInterface
;
59 static const WINE_CONTEXT_INTERFACE gCRLInterface
= {
60 (CreateContextFunc
)CertCreateCRLContext
,
61 (AddContextToStoreFunc
)CertAddCRLContextToStore
,
62 (AddEncodedContextToStoreFunc
)CertAddEncodedCRLToStore
,
63 (DuplicateContextFunc
)CertDuplicateCRLContext
,
64 (EnumContextsInStoreFunc
)CertEnumCRLsInStore
,
65 (EnumPropertiesFunc
)CertEnumCRLContextProperties
,
66 (GetContextPropertyFunc
)CertGetCRLContextProperty
,
67 (SetContextPropertyFunc
)CertSetCRLContextProperty
,
68 (SerializeElementFunc
)CertSerializeCRLStoreElement
,
69 (FreeContextFunc
)CertFreeCRLContext
,
70 (DeleteContextFunc
)CertDeleteCRLFromStore
,
72 PCWINE_CONTEXT_INTERFACE pCRLInterface
= &gCRLInterface
;
74 static const WINE_CONTEXT_INTERFACE gCTLInterface
= {
75 (CreateContextFunc
)CertCreateCTLContext
,
76 (AddContextToStoreFunc
)CertAddCTLContextToStore
,
77 (AddEncodedContextToStoreFunc
)CertAddEncodedCTLToStore
,
78 (DuplicateContextFunc
)CertDuplicateCTLContext
,
79 (EnumContextsInStoreFunc
)CertEnumCTLsInStore
,
80 (EnumPropertiesFunc
)CertEnumCTLContextProperties
,
81 (GetContextPropertyFunc
)CertGetCTLContextProperty
,
82 (SetContextPropertyFunc
)CertSetCTLContextProperty
,
83 (SerializeElementFunc
)CertSerializeCTLStoreElement
,
84 (FreeContextFunc
)CertFreeCTLContext
,
85 (DeleteContextFunc
)CertDeleteCTLFromStore
,
87 PCWINE_CONTEXT_INTERFACE pCTLInterface
= &gCTLInterface
;
89 typedef struct _WINE_MEMSTORE
91 WINECRYPT_CERTSTORE hdr
;
92 struct ContextList
*certs
;
93 struct ContextList
*crls
;
94 } WINE_MEMSTORE
, *PWINE_MEMSTORE
;
96 void CRYPT_InitStore(WINECRYPT_CERTSTORE
*store
, DWORD dwFlags
,
100 store
->dwMagic
= WINE_CRYPTCERTSTORE_MAGIC
;
102 store
->dwOpenFlags
= dwFlags
;
103 store
->properties
= NULL
;
106 void CRYPT_FreeStore(PWINECRYPT_CERTSTORE store
)
108 if (store
->properties
)
109 ContextPropertyList_Free(store
->properties
);
113 BOOL WINAPI
I_CertUpdateStore(HCERTSTORE store1
, HCERTSTORE store2
, DWORD unk0
,
116 static BOOL warned
= FALSE
;
117 const WINE_CONTEXT_INTERFACE
* const interfaces
[] = { pCertInterface
,
118 pCRLInterface
, pCTLInterface
};
121 TRACE("(%p, %p, %08x, %08x)\n", store1
, store2
, unk0
, unk1
);
124 FIXME("semi-stub\n");
128 /* Poor-man's resync: empty first store, then add everything from second
131 for (i
= 0; i
< sizeof(interfaces
) / sizeof(interfaces
[0]); i
++)
136 context
= interfaces
[i
]->enumContextsInStore(store1
, NULL
);
138 interfaces
[i
]->deleteFromStore(context
);
141 context
= interfaces
[i
]->enumContextsInStore(store2
, context
);
143 interfaces
[i
]->addContextToStore(store1
, context
,
144 CERT_STORE_ADD_ALWAYS
, NULL
);
150 static BOOL
CRYPT_MemAddCert(PWINECRYPT_CERTSTORE store
, void *cert
,
151 void *toReplace
, const void **ppStoreContext
)
153 WINE_MEMSTORE
*ms
= (WINE_MEMSTORE
*)store
;
154 PCERT_CONTEXT context
;
156 TRACE("(%p, %p, %p, %p)\n", store
, cert
, toReplace
, ppStoreContext
);
158 context
= (PCERT_CONTEXT
)ContextList_Add(ms
->certs
, cert
, toReplace
);
161 context
->hCertStore
= store
;
163 *ppStoreContext
= CertDuplicateCertificateContext(context
);
165 return context
? TRUE
: FALSE
;
168 static void *CRYPT_MemEnumCert(PWINECRYPT_CERTSTORE store
, void *pPrev
)
170 WINE_MEMSTORE
*ms
= (WINE_MEMSTORE
*)store
;
173 TRACE("(%p, %p)\n", store
, pPrev
);
175 ret
= ContextList_Enum(ms
->certs
, pPrev
);
177 SetLastError(CRYPT_E_NOT_FOUND
);
179 TRACE("returning %p\n", ret
);
183 static BOOL
CRYPT_MemDeleteCert(PWINECRYPT_CERTSTORE store
, void *pCertContext
)
185 WINE_MEMSTORE
*ms
= (WINE_MEMSTORE
*)store
;
187 ContextList_Delete(ms
->certs
, pCertContext
);
191 static BOOL
CRYPT_MemAddCrl(PWINECRYPT_CERTSTORE store
, void *crl
,
192 void *toReplace
, const void **ppStoreContext
)
194 WINE_MEMSTORE
*ms
= (WINE_MEMSTORE
*)store
;
195 PCRL_CONTEXT context
;
197 TRACE("(%p, %p, %p, %p)\n", store
, crl
, toReplace
, ppStoreContext
);
199 context
= (PCRL_CONTEXT
)ContextList_Add(ms
->crls
, crl
, toReplace
);
202 context
->hCertStore
= store
;
204 *ppStoreContext
= CertDuplicateCRLContext(context
);
206 return context
? TRUE
: FALSE
;
209 static void *CRYPT_MemEnumCrl(PWINECRYPT_CERTSTORE store
, void *pPrev
)
211 WINE_MEMSTORE
*ms
= (WINE_MEMSTORE
*)store
;
214 TRACE("(%p, %p)\n", store
, pPrev
);
216 ret
= ContextList_Enum(ms
->crls
, pPrev
);
218 SetLastError(CRYPT_E_NOT_FOUND
);
220 TRACE("returning %p\n", ret
);
224 static BOOL
CRYPT_MemDeleteCrl(PWINECRYPT_CERTSTORE store
, void *pCrlContext
)
226 WINE_MEMSTORE
*ms
= (WINE_MEMSTORE
*)store
;
228 ContextList_Delete(ms
->crls
, pCrlContext
);
232 static void WINAPI
CRYPT_MemCloseStore(HCERTSTORE hCertStore
, DWORD dwFlags
)
234 WINE_MEMSTORE
*store
= (WINE_MEMSTORE
*)hCertStore
;
236 TRACE("(%p, %08x)\n", store
, dwFlags
);
238 FIXME("Unimplemented flags: %08x\n", dwFlags
);
240 ContextList_Free(store
->certs
);
241 ContextList_Free(store
->crls
);
242 CRYPT_FreeStore((PWINECRYPT_CERTSTORE
)store
);
245 static WINECRYPT_CERTSTORE
*CRYPT_MemOpenStore(HCRYPTPROV hCryptProv
,
246 DWORD dwFlags
, const void *pvPara
)
248 PWINE_MEMSTORE store
;
250 TRACE("(%ld, %08x, %p)\n", hCryptProv
, dwFlags
, pvPara
);
252 if (dwFlags
& CERT_STORE_DELETE_FLAG
)
254 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
259 store
= CryptMemAlloc(sizeof(WINE_MEMSTORE
));
262 memset(store
, 0, sizeof(WINE_MEMSTORE
));
263 CRYPT_InitStore(&store
->hdr
, dwFlags
, StoreTypeMem
);
264 store
->hdr
.closeStore
= CRYPT_MemCloseStore
;
265 store
->hdr
.certs
.addContext
= CRYPT_MemAddCert
;
266 store
->hdr
.certs
.enumContext
= CRYPT_MemEnumCert
;
267 store
->hdr
.certs
.deleteContext
= CRYPT_MemDeleteCert
;
268 store
->hdr
.crls
.addContext
= CRYPT_MemAddCrl
;
269 store
->hdr
.crls
.enumContext
= CRYPT_MemEnumCrl
;
270 store
->hdr
.crls
.deleteContext
= CRYPT_MemDeleteCrl
;
271 store
->hdr
.control
= NULL
;
272 store
->certs
= ContextList_Create(pCertInterface
,
273 sizeof(CERT_CONTEXT
));
274 store
->crls
= ContextList_Create(pCRLInterface
,
275 sizeof(CRL_CONTEXT
));
276 /* Mem store doesn't need crypto provider, so close it */
277 if (hCryptProv
&& !(dwFlags
& CERT_STORE_NO_CRYPT_RELEASE_FLAG
))
278 CryptReleaseContext(hCryptProv
, 0);
281 return (PWINECRYPT_CERTSTORE
)store
;
284 static PWINECRYPT_CERTSTORE
CRYPT_SysRegOpenStoreW(HCRYPTPROV hCryptProv
,
285 DWORD dwFlags
, const void *pvPara
)
287 static const WCHAR rootW
[] = { 'R','o','o','t',0 };
288 static const WCHAR fmt
[] = { '%','s','\\','%','s',0 };
289 LPCWSTR storeName
= (LPCWSTR
)pvPara
;
291 PWINECRYPT_CERTSTORE store
= NULL
;
296 TRACE("(%ld, %08x, %s)\n", hCryptProv
, dwFlags
,
297 debugstr_w((LPCWSTR
)pvPara
));
301 SetLastError(E_INVALIDARG
);
304 if (!lstrcmpiW(storeName
, rootW
))
305 return CRYPT_RootOpenStore(hCryptProv
, dwFlags
);
308 switch (dwFlags
& CERT_SYSTEM_STORE_LOCATION_MASK
)
310 case CERT_SYSTEM_STORE_LOCAL_MACHINE
:
311 root
= HKEY_LOCAL_MACHINE
;
312 base
= CERT_LOCAL_MACHINE_SYSTEM_STORE_REGPATH
;
314 case CERT_SYSTEM_STORE_CURRENT_USER
:
315 root
= HKEY_CURRENT_USER
;
316 base
= CERT_LOCAL_MACHINE_SYSTEM_STORE_REGPATH
;
318 case CERT_SYSTEM_STORE_CURRENT_SERVICE
:
319 /* hklm\Software\Microsoft\Cryptography\Services\servicename\
322 FIXME("CERT_SYSTEM_STORE_CURRENT_SERVICE, %s: stub\n",
323 debugstr_w(storeName
));
325 case CERT_SYSTEM_STORE_SERVICES
:
326 /* hklm\Software\Microsoft\Cryptography\Services\servicename\
329 FIXME("CERT_SYSTEM_STORE_SERVICES, %s: stub\n",
330 debugstr_w(storeName
));
332 case CERT_SYSTEM_STORE_USERS
:
333 /* hku\user sid\Software\Microsoft\SystemCertificates */
334 FIXME("CERT_SYSTEM_STORE_USERS, %s: stub\n",
335 debugstr_w(storeName
));
337 case CERT_SYSTEM_STORE_CURRENT_USER_GROUP_POLICY
:
338 root
= HKEY_CURRENT_USER
;
339 base
= CERT_GROUP_POLICY_SYSTEM_STORE_REGPATH
;
341 case CERT_SYSTEM_STORE_LOCAL_MACHINE_GROUP_POLICY
:
342 root
= HKEY_LOCAL_MACHINE
;
343 base
= CERT_GROUP_POLICY_SYSTEM_STORE_REGPATH
;
345 case CERT_SYSTEM_STORE_LOCAL_MACHINE_ENTERPRISE
:
346 /* hklm\Software\Microsoft\EnterpriseCertificates */
347 FIXME("CERT_SYSTEM_STORE_LOCAL_MACHINE_ENTERPRISE, %s: stub\n",
348 debugstr_w(storeName
));
351 SetLastError(E_INVALIDARG
);
355 storePath
= CryptMemAlloc((lstrlenW(base
) + lstrlenW(storeName
) + 2) *
361 REGSAM sam
= dwFlags
& CERT_STORE_READONLY_FLAG
? KEY_READ
:
364 wsprintfW(storePath
, fmt
, base
, storeName
);
365 if (dwFlags
& CERT_STORE_OPEN_EXISTING_FLAG
)
366 rc
= RegOpenKeyExW(root
, storePath
, 0, sam
, &key
);
371 rc
= RegCreateKeyExW(root
, storePath
, 0, NULL
, 0, sam
, NULL
,
373 if (!rc
&& dwFlags
& CERT_STORE_CREATE_NEW_FLAG
&&
374 disp
== REG_OPENED_EXISTING_KEY
)
377 rc
= ERROR_FILE_EXISTS
;
382 store
= CRYPT_RegOpenStore(hCryptProv
, dwFlags
, key
);
387 CryptMemFree(storePath
);
392 static PWINECRYPT_CERTSTORE
CRYPT_SysRegOpenStoreA(HCRYPTPROV hCryptProv
,
393 DWORD dwFlags
, const void *pvPara
)
396 PWINECRYPT_CERTSTORE ret
= NULL
;
398 TRACE("(%ld, %08x, %s)\n", hCryptProv
, dwFlags
,
399 debugstr_a((LPCSTR
)pvPara
));
403 SetLastError(ERROR_FILE_NOT_FOUND
);
406 len
= MultiByteToWideChar(CP_ACP
, 0, (LPCSTR
)pvPara
, -1, NULL
, 0);
409 LPWSTR storeName
= CryptMemAlloc(len
* sizeof(WCHAR
));
413 MultiByteToWideChar(CP_ACP
, 0, (LPCSTR
)pvPara
, -1, storeName
, len
);
414 ret
= CRYPT_SysRegOpenStoreW(hCryptProv
, dwFlags
, storeName
);
415 CryptMemFree(storeName
);
421 static PWINECRYPT_CERTSTORE
CRYPT_SysOpenStoreW(HCRYPTPROV hCryptProv
,
422 DWORD dwFlags
, const void *pvPara
)
424 HCERTSTORE store
= 0;
427 TRACE("(%ld, %08x, %s)\n", hCryptProv
, dwFlags
,
428 debugstr_w((LPCWSTR
)pvPara
));
432 SetLastError(ERROR_FILE_NOT_FOUND
);
435 /* This returns a different error than system registry stores if the
436 * location is invalid.
438 switch (dwFlags
& CERT_SYSTEM_STORE_LOCATION_MASK
)
440 case CERT_SYSTEM_STORE_LOCAL_MACHINE
:
441 case CERT_SYSTEM_STORE_CURRENT_USER
:
442 case CERT_SYSTEM_STORE_CURRENT_SERVICE
:
443 case CERT_SYSTEM_STORE_SERVICES
:
444 case CERT_SYSTEM_STORE_USERS
:
445 case CERT_SYSTEM_STORE_CURRENT_USER_GROUP_POLICY
:
446 case CERT_SYSTEM_STORE_LOCAL_MACHINE_GROUP_POLICY
:
447 case CERT_SYSTEM_STORE_LOCAL_MACHINE_ENTERPRISE
:
451 SetLastError(ERROR_FILE_NOT_FOUND
);
456 HCERTSTORE regStore
= CertOpenStore(CERT_STORE_PROV_SYSTEM_REGISTRY_W
,
457 0, 0, dwFlags
, pvPara
);
461 store
= CertOpenStore(CERT_STORE_PROV_COLLECTION
, 0, 0,
462 CERT_STORE_CREATE_NEW_FLAG
, NULL
);
463 CertAddStoreToCollection(store
, regStore
,
464 dwFlags
& CERT_STORE_READONLY_FLAG
? 0 :
465 CERT_PHYSICAL_STORE_ADD_ENABLE_FLAG
, 0);
466 CertCloseStore(regStore
, 0);
467 /* CERT_SYSTEM_STORE_CURRENT_USER returns both the HKCU and HKLM
470 if ((dwFlags
& CERT_SYSTEM_STORE_LOCATION_MASK
) ==
471 CERT_SYSTEM_STORE_CURRENT_USER
)
473 dwFlags
&= ~CERT_SYSTEM_STORE_CURRENT_USER
;
474 dwFlags
|= CERT_SYSTEM_STORE_LOCAL_MACHINE
;
475 regStore
= CertOpenStore(CERT_STORE_PROV_SYSTEM_REGISTRY_W
, 0,
479 CertAddStoreToCollection(store
, regStore
,
480 dwFlags
& CERT_STORE_READONLY_FLAG
? 0 :
481 CERT_PHYSICAL_STORE_ADD_ENABLE_FLAG
, 0);
482 CertCloseStore(regStore
, 0);
485 /* System store doesn't need crypto provider, so close it */
486 if (hCryptProv
&& !(dwFlags
& CERT_STORE_NO_CRYPT_RELEASE_FLAG
))
487 CryptReleaseContext(hCryptProv
, 0);
490 return (PWINECRYPT_CERTSTORE
)store
;
493 static PWINECRYPT_CERTSTORE
CRYPT_SysOpenStoreA(HCRYPTPROV hCryptProv
,
494 DWORD dwFlags
, const void *pvPara
)
497 PWINECRYPT_CERTSTORE ret
= NULL
;
499 TRACE("(%ld, %08x, %s)\n", hCryptProv
, dwFlags
,
500 debugstr_a((LPCSTR
)pvPara
));
504 SetLastError(ERROR_FILE_NOT_FOUND
);
507 len
= MultiByteToWideChar(CP_ACP
, 0, (LPCSTR
)pvPara
, -1, NULL
, 0);
510 LPWSTR storeName
= CryptMemAlloc(len
* sizeof(WCHAR
));
514 MultiByteToWideChar(CP_ACP
, 0, (LPCSTR
)pvPara
, -1, storeName
, len
);
515 ret
= CRYPT_SysOpenStoreW(hCryptProv
, dwFlags
, storeName
);
516 CryptMemFree(storeName
);
522 static void WINAPI
CRYPT_MsgCloseStore(HCERTSTORE hCertStore
, DWORD dwFlags
)
524 HCRYPTMSG msg
= hCertStore
;
526 TRACE("(%p, %08x)\n", msg
, dwFlags
);
530 static void *msgProvFuncs
[] = {
534 static PWINECRYPT_CERTSTORE
CRYPT_MsgOpenStore(HCRYPTPROV hCryptProv
,
535 DWORD dwFlags
, const void *pvPara
)
537 PWINECRYPT_CERTSTORE store
= NULL
;
538 HCRYPTMSG msg
= (HCRYPTMSG
)pvPara
;
539 PWINECRYPT_CERTSTORE memStore
;
541 TRACE("(%ld, %08x, %p)\n", hCryptProv
, dwFlags
, pvPara
);
543 memStore
= CertOpenStore(CERT_STORE_PROV_MEMORY
, 0, 0,
544 CERT_STORE_CREATE_NEW_FLAG
, NULL
);
548 DWORD size
, count
, i
;
550 size
= sizeof(count
);
551 ret
= CryptMsgGetParam(msg
, CMSG_CERT_COUNT_PARAM
, 0, &count
, &size
);
552 for (i
= 0; ret
&& i
< count
; i
++)
555 ret
= CryptMsgGetParam(msg
, CMSG_CERT_PARAM
, i
, NULL
, &size
);
558 LPBYTE buf
= CryptMemAlloc(size
);
562 ret
= CryptMsgGetParam(msg
, CMSG_CERT_PARAM
, i
, buf
, &size
);
564 ret
= CertAddEncodedCertificateToStore(memStore
,
565 X509_ASN_ENCODING
, buf
, size
, CERT_STORE_ADD_ALWAYS
,
571 size
= sizeof(count
);
572 ret
= CryptMsgGetParam(msg
, CMSG_CRL_COUNT_PARAM
, 0, &count
, &size
);
573 for (i
= 0; ret
&& i
< count
; i
++)
576 ret
= CryptMsgGetParam(msg
, CMSG_CRL_PARAM
, i
, NULL
, &size
);
579 LPBYTE buf
= CryptMemAlloc(size
);
583 ret
= CryptMsgGetParam(msg
, CMSG_CRL_PARAM
, i
, buf
, &size
);
585 ret
= CertAddEncodedCRLToStore(memStore
,
586 X509_ASN_ENCODING
, buf
, size
, CERT_STORE_ADD_ALWAYS
,
594 CERT_STORE_PROV_INFO provInfo
= { 0 };
596 provInfo
.cbSize
= sizeof(provInfo
);
597 provInfo
.cStoreProvFunc
= sizeof(msgProvFuncs
) /
598 sizeof(msgProvFuncs
[0]);
599 provInfo
.rgpvStoreProvFunc
= msgProvFuncs
;
600 provInfo
.hStoreProv
= CryptMsgDuplicate(msg
);
601 store
= CRYPT_ProvCreateStore(dwFlags
, memStore
, &provInfo
);
602 /* Msg store doesn't need crypto provider, so close it */
603 if (hCryptProv
&& !(dwFlags
& CERT_STORE_NO_CRYPT_RELEASE_FLAG
))
604 CryptReleaseContext(hCryptProv
, 0);
607 CertCloseStore(memStore
, 0);
609 TRACE("returning %p\n", store
);
613 static PWINECRYPT_CERTSTORE
CRYPT_PKCSOpenStore(HCRYPTPROV hCryptProv
,
614 DWORD dwFlags
, const void *pvPara
)
617 PWINECRYPT_CERTSTORE store
= NULL
;
618 const CRYPT_DATA_BLOB
*data
= (const CRYPT_DATA_BLOB
*)pvPara
;
620 DWORD msgOpenFlags
= dwFlags
& CERT_STORE_NO_CRYPT_RELEASE_FLAG
? 0 :
621 CMSG_CRYPT_RELEASE_CONTEXT_FLAG
;
623 TRACE("(%ld, %08x, %p)\n", hCryptProv
, dwFlags
, pvPara
);
625 msg
= CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING
, msgOpenFlags
, CMSG_SIGNED
,
626 hCryptProv
, NULL
, NULL
);
627 ret
= CryptMsgUpdate(msg
, data
->pbData
, data
->cbData
, TRUE
);
631 msg
= CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING
, msgOpenFlags
, 0,
632 hCryptProv
, NULL
, NULL
);
633 ret
= CryptMsgUpdate(msg
, data
->pbData
, data
->cbData
, TRUE
);
636 DWORD type
, size
= sizeof(type
);
638 /* Only signed messages are allowed, check type */
639 ret
= CryptMsgGetParam(msg
, CMSG_TYPE_PARAM
, 0, &type
, &size
);
640 if (ret
&& type
!= CMSG_SIGNED
)
642 SetLastError(CRYPT_E_INVALID_MSG_TYPE
);
648 store
= CRYPT_MsgOpenStore(0, dwFlags
, msg
);
650 TRACE("returning %p\n", store
);
654 static PWINECRYPT_CERTSTORE
CRYPT_PhysOpenStoreW(HCRYPTPROV hCryptProv
,
655 DWORD dwFlags
, const void *pvPara
)
657 if (dwFlags
& CERT_SYSTEM_STORE_RELOCATE_FLAG
)
658 FIXME("(%ld, %08x, %p): stub\n", hCryptProv
, dwFlags
, pvPara
);
660 FIXME("(%ld, %08x, %s): stub\n", hCryptProv
, dwFlags
,
661 debugstr_w((LPCWSTR
)pvPara
));
665 HCERTSTORE WINAPI
CertOpenStore(LPCSTR lpszStoreProvider
,
666 DWORD dwMsgAndCertEncodingType
, HCRYPTPROV_LEGACY hCryptProv
, DWORD dwFlags
,
669 WINECRYPT_CERTSTORE
*hcs
;
670 StoreOpenFunc openFunc
= NULL
;
672 TRACE("(%s, %08x, %08lx, %08x, %p)\n", debugstr_a(lpszStoreProvider
),
673 dwMsgAndCertEncodingType
, hCryptProv
, dwFlags
, pvPara
);
675 if (!HIWORD(lpszStoreProvider
))
677 switch (LOWORD(lpszStoreProvider
))
679 case (int)CERT_STORE_PROV_MSG
:
680 openFunc
= CRYPT_MsgOpenStore
;
682 case (int)CERT_STORE_PROV_MEMORY
:
683 openFunc
= CRYPT_MemOpenStore
;
685 case (int)CERT_STORE_PROV_FILE
:
686 openFunc
= CRYPT_FileOpenStore
;
688 case (int)CERT_STORE_PROV_PKCS7
:
689 openFunc
= CRYPT_PKCSOpenStore
;
691 case (int)CERT_STORE_PROV_REG
:
692 openFunc
= CRYPT_RegOpenStore
;
694 case (int)CERT_STORE_PROV_FILENAME_A
:
695 openFunc
= CRYPT_FileNameOpenStoreA
;
697 case (int)CERT_STORE_PROV_FILENAME_W
:
698 openFunc
= CRYPT_FileNameOpenStoreW
;
700 case (int)CERT_STORE_PROV_COLLECTION
:
701 openFunc
= CRYPT_CollectionOpenStore
;
703 case (int)CERT_STORE_PROV_SYSTEM_A
:
704 openFunc
= CRYPT_SysOpenStoreA
;
706 case (int)CERT_STORE_PROV_SYSTEM_W
:
707 openFunc
= CRYPT_SysOpenStoreW
;
709 case (int)CERT_STORE_PROV_SYSTEM_REGISTRY_A
:
710 openFunc
= CRYPT_SysRegOpenStoreA
;
712 case (int)CERT_STORE_PROV_SYSTEM_REGISTRY_W
:
713 openFunc
= CRYPT_SysRegOpenStoreW
;
715 case (int)CERT_STORE_PROV_PHYSICAL_W
:
716 openFunc
= CRYPT_PhysOpenStoreW
;
719 if (LOWORD(lpszStoreProvider
))
720 FIXME("unimplemented type %d\n", LOWORD(lpszStoreProvider
));
723 else if (!strcasecmp(lpszStoreProvider
, sz_CERT_STORE_PROV_MEMORY
))
724 openFunc
= CRYPT_MemOpenStore
;
725 else if (!strcasecmp(lpszStoreProvider
, sz_CERT_STORE_PROV_FILENAME_W
))
726 openFunc
= CRYPT_FileOpenStore
;
727 else if (!strcasecmp(lpszStoreProvider
, sz_CERT_STORE_PROV_SYSTEM
))
728 openFunc
= CRYPT_SysOpenStoreW
;
729 else if (!strcasecmp(lpszStoreProvider
, sz_CERT_STORE_PROV_COLLECTION
))
730 openFunc
= CRYPT_CollectionOpenStore
;
731 else if (!strcasecmp(lpszStoreProvider
, sz_CERT_STORE_PROV_SYSTEM_REGISTRY
))
732 openFunc
= CRYPT_SysRegOpenStoreW
;
735 FIXME("unimplemented type %s\n", lpszStoreProvider
);
740 hcs
= CRYPT_ProvOpenStore(lpszStoreProvider
, dwMsgAndCertEncodingType
,
741 hCryptProv
, dwFlags
, pvPara
);
743 hcs
= openFunc(hCryptProv
, dwFlags
, pvPara
);
744 return (HCERTSTORE
)hcs
;
747 HCERTSTORE WINAPI
CertOpenSystemStoreA(HCRYPTPROV_LEGACY hProv
,
748 LPCSTR szSubSystemProtocol
)
750 if (!szSubSystemProtocol
)
752 SetLastError(E_INVALIDARG
);
755 return CertOpenStore(CERT_STORE_PROV_SYSTEM_A
, 0, hProv
,
756 CERT_SYSTEM_STORE_CURRENT_USER
, szSubSystemProtocol
);
759 HCERTSTORE WINAPI
CertOpenSystemStoreW(HCRYPTPROV_LEGACY hProv
,
760 LPCWSTR szSubSystemProtocol
)
762 if (!szSubSystemProtocol
)
764 SetLastError(E_INVALIDARG
);
767 return CertOpenStore(CERT_STORE_PROV_SYSTEM_W
, 0, hProv
,
768 CERT_SYSTEM_STORE_CURRENT_USER
, szSubSystemProtocol
);
771 #define CertContext_CopyProperties(to, from) \
772 Context_CopyProperties((to), (from), sizeof(CERT_CONTEXT))
774 BOOL WINAPI
CertAddCertificateContextToStore(HCERTSTORE hCertStore
,
775 PCCERT_CONTEXT pCertContext
, DWORD dwAddDisposition
,
776 PCCERT_CONTEXT
*ppStoreContext
)
778 PWINECRYPT_CERTSTORE store
= (PWINECRYPT_CERTSTORE
)hCertStore
;
780 PCCERT_CONTEXT toAdd
= NULL
, existing
= NULL
;
782 TRACE("(%p, %p, %08x, %p)\n", hCertStore
, pCertContext
,
783 dwAddDisposition
, ppStoreContext
);
785 if (dwAddDisposition
!= CERT_STORE_ADD_ALWAYS
)
788 DWORD size
= sizeof(hashToAdd
);
790 ret
= CertGetCertificateContextProperty(pCertContext
, CERT_HASH_PROP_ID
,
794 CRYPT_HASH_BLOB blob
= { sizeof(hashToAdd
), hashToAdd
};
796 existing
= CertFindCertificateInStore(hCertStore
,
797 pCertContext
->dwCertEncodingType
, 0, CERT_FIND_SHA1_HASH
, &blob
,
802 switch (dwAddDisposition
)
804 case CERT_STORE_ADD_ALWAYS
:
805 toAdd
= CertDuplicateCertificateContext(pCertContext
);
807 case CERT_STORE_ADD_NEW
:
810 TRACE("found matching certificate, not adding\n");
811 SetLastError(CRYPT_E_EXISTS
);
815 toAdd
= CertDuplicateCertificateContext(pCertContext
);
817 case CERT_STORE_ADD_REPLACE_EXISTING
:
818 toAdd
= CertDuplicateCertificateContext(pCertContext
);
820 case CERT_STORE_ADD_REPLACE_EXISTING_INHERIT_PROPERTIES
:
821 toAdd
= CertDuplicateCertificateContext(pCertContext
);
823 CertContext_CopyProperties(toAdd
, existing
);
825 case CERT_STORE_ADD_USE_EXISTING
:
828 CertContext_CopyProperties(existing
, pCertContext
);
829 *ppStoreContext
= CertDuplicateCertificateContext(existing
);
832 toAdd
= CertDuplicateCertificateContext(pCertContext
);
834 case CERT_STORE_ADD_NEWER
:
837 if (CompareFileTime(&existing
->pCertInfo
->NotBefore
,
838 &pCertContext
->pCertInfo
->NotBefore
) >= 0)
840 TRACE("existing certificate is newer, not adding\n");
841 SetLastError(CRYPT_E_EXISTS
);
845 toAdd
= CertDuplicateCertificateContext(pCertContext
);
848 toAdd
= CertDuplicateCertificateContext(pCertContext
);
851 FIXME("Unimplemented add disposition %d\n", dwAddDisposition
);
852 SetLastError(E_INVALIDARG
);
859 ret
= store
->certs
.addContext(store
, (void *)toAdd
,
860 (void *)existing
, (const void **)ppStoreContext
);
861 else if (ppStoreContext
)
862 *ppStoreContext
= CertDuplicateCertificateContext(toAdd
);
863 CertFreeCertificateContext(toAdd
);
865 CertFreeCertificateContext(existing
);
867 TRACE("returning %d\n", ret
);
871 PCCERT_CONTEXT WINAPI
CertEnumCertificatesInStore(HCERTSTORE hCertStore
,
872 PCCERT_CONTEXT pPrev
)
874 WINECRYPT_CERTSTORE
*hcs
= (WINECRYPT_CERTSTORE
*)hCertStore
;
877 TRACE("(%p, %p)\n", hCertStore
, pPrev
);
880 else if (hcs
->dwMagic
!= WINE_CRYPTCERTSTORE_MAGIC
)
883 ret
= (PCCERT_CONTEXT
)hcs
->certs
.enumContext(hcs
, (void *)pPrev
);
887 BOOL WINAPI
CertDeleteCertificateFromStore(PCCERT_CONTEXT pCertContext
)
891 TRACE("(%p)\n", pCertContext
);
895 else if (!pCertContext
->hCertStore
)
898 CertFreeCertificateContext(pCertContext
);
902 PWINECRYPT_CERTSTORE hcs
=
903 (PWINECRYPT_CERTSTORE
)pCertContext
->hCertStore
;
905 if (hcs
->dwMagic
!= WINE_CRYPTCERTSTORE_MAGIC
)
908 ret
= hcs
->certs
.deleteContext(hcs
, (void *)pCertContext
);
909 CertFreeCertificateContext(pCertContext
);
914 #define CrlContext_CopyProperties(to, from) \
915 Context_CopyProperties((to), (from), sizeof(CRL_CONTEXT))
917 BOOL WINAPI
CertAddCRLContextToStore(HCERTSTORE hCertStore
,
918 PCCRL_CONTEXT pCrlContext
, DWORD dwAddDisposition
,
919 PCCRL_CONTEXT
* ppStoreContext
)
921 PWINECRYPT_CERTSTORE store
= (PWINECRYPT_CERTSTORE
)hCertStore
;
923 PCCRL_CONTEXT toAdd
= NULL
, existing
= NULL
;
925 TRACE("(%p, %p, %08x, %p)\n", hCertStore
, pCrlContext
,
926 dwAddDisposition
, ppStoreContext
);
928 /* Weird case to pass a test */
929 if (dwAddDisposition
== 0)
931 SetLastError(STATUS_ACCESS_VIOLATION
);
934 if (dwAddDisposition
!= CERT_STORE_ADD_ALWAYS
)
936 existing
= CertFindCRLInStore(hCertStore
, 0, 0, CRL_FIND_EXISTING
,
940 switch (dwAddDisposition
)
942 case CERT_STORE_ADD_ALWAYS
:
943 toAdd
= CertDuplicateCRLContext(pCrlContext
);
945 case CERT_STORE_ADD_NEW
:
948 TRACE("found matching CRL, not adding\n");
949 SetLastError(CRYPT_E_EXISTS
);
953 toAdd
= CertDuplicateCRLContext(pCrlContext
);
955 case CERT_STORE_ADD_NEWER
:
958 LONG newer
= CompareFileTime(&existing
->pCrlInfo
->ThisUpdate
,
959 &pCrlContext
->pCrlInfo
->ThisUpdate
);
962 toAdd
= CertDuplicateCRLContext(pCrlContext
);
965 TRACE("existing CRL is newer, not adding\n");
966 SetLastError(CRYPT_E_EXISTS
);
971 toAdd
= CertDuplicateCRLContext(pCrlContext
);
973 case CERT_STORE_ADD_REPLACE_EXISTING
:
974 toAdd
= CertDuplicateCRLContext(pCrlContext
);
976 case CERT_STORE_ADD_REPLACE_EXISTING_INHERIT_PROPERTIES
:
977 toAdd
= CertDuplicateCRLContext(pCrlContext
);
979 CrlContext_CopyProperties(toAdd
, existing
);
981 case CERT_STORE_ADD_USE_EXISTING
:
983 CrlContext_CopyProperties(existing
, pCrlContext
);
986 FIXME("Unimplemented add disposition %d\n", dwAddDisposition
);
993 ret
= store
->crls
.addContext(store
, (void *)toAdd
,
994 (void *)existing
, (const void **)ppStoreContext
);
995 else if (ppStoreContext
)
996 *ppStoreContext
= CertDuplicateCRLContext(toAdd
);
997 CertFreeCRLContext(toAdd
);
999 CertFreeCRLContext(existing
);
1001 TRACE("returning %d\n", ret
);
1005 BOOL WINAPI
CertDeleteCRLFromStore(PCCRL_CONTEXT pCrlContext
)
1009 TRACE("(%p)\n", pCrlContext
);
1013 else if (!pCrlContext
->hCertStore
)
1016 CertFreeCRLContext(pCrlContext
);
1020 PWINECRYPT_CERTSTORE hcs
=
1021 (PWINECRYPT_CERTSTORE
)pCrlContext
->hCertStore
;
1023 if (hcs
->dwMagic
!= WINE_CRYPTCERTSTORE_MAGIC
)
1026 ret
= hcs
->crls
.deleteContext(hcs
, (void *)pCrlContext
);
1027 CertFreeCRLContext(pCrlContext
);
1032 PCCRL_CONTEXT WINAPI
CertEnumCRLsInStore(HCERTSTORE hCertStore
,
1033 PCCRL_CONTEXT pPrev
)
1035 WINECRYPT_CERTSTORE
*hcs
= (WINECRYPT_CERTSTORE
*)hCertStore
;
1038 TRACE("(%p, %p)\n", hCertStore
, pPrev
);
1041 else if (hcs
->dwMagic
!= WINE_CRYPTCERTSTORE_MAGIC
)
1044 ret
= (PCCRL_CONTEXT
)hcs
->crls
.enumContext(hcs
, (void *)pPrev
);
1048 PCCTL_CONTEXT WINAPI
CertCreateCTLContext(DWORD dwCertEncodingType
,
1049 const BYTE
* pbCtlEncoded
, DWORD cbCtlEncoded
)
1051 FIXME("(%08x, %p, %08x): stub\n", dwCertEncodingType
, pbCtlEncoded
,
1056 BOOL WINAPI
CertAddEncodedCTLToStore(HCERTSTORE hCertStore
,
1057 DWORD dwMsgAndCertEncodingType
, const BYTE
*pbCtlEncoded
, DWORD cbCtlEncoded
,
1058 DWORD dwAddDisposition
, PCCTL_CONTEXT
*ppCtlContext
)
1060 FIXME("(%p, %08x, %p, %d, %08x, %p): stub\n", hCertStore
,
1061 dwMsgAndCertEncodingType
, pbCtlEncoded
, cbCtlEncoded
, dwAddDisposition
,
1066 BOOL WINAPI
CertAddCTLContextToStore(HCERTSTORE hCertStore
,
1067 PCCTL_CONTEXT pCtlContext
, DWORD dwAddDisposition
,
1068 PCCTL_CONTEXT
* ppStoreContext
)
1070 FIXME("(%p, %p, %08x, %p): stub\n", hCertStore
, pCtlContext
,
1071 dwAddDisposition
, ppStoreContext
);
1075 PCCTL_CONTEXT WINAPI
CertDuplicateCTLContext(PCCTL_CONTEXT pCtlContext
)
1077 FIXME("(%p): stub\n", pCtlContext
);
1081 BOOL WINAPI
CertFreeCTLContext(PCCTL_CONTEXT pCtlContext
)
1083 FIXME("(%p): stub\n", pCtlContext
);
1087 BOOL WINAPI
CertDeleteCTLFromStore(PCCTL_CONTEXT pCtlContext
)
1089 FIXME("(%p): stub\n", pCtlContext
);
1093 PCCTL_CONTEXT WINAPI
CertEnumCTLsInStore(HCERTSTORE hCertStore
,
1094 PCCTL_CONTEXT pPrev
)
1096 FIXME("(%p, %p): stub\n", hCertStore
, pPrev
);
1100 HCERTSTORE WINAPI
CertDuplicateStore(HCERTSTORE hCertStore
)
1102 WINECRYPT_CERTSTORE
*hcs
= (WINECRYPT_CERTSTORE
*)hCertStore
;
1104 TRACE("(%p)\n", hCertStore
);
1106 if (hcs
&& hcs
->dwMagic
== WINE_CRYPTCERTSTORE_MAGIC
)
1107 InterlockedIncrement(&hcs
->ref
);
1111 BOOL WINAPI
CertCloseStore(HCERTSTORE hCertStore
, DWORD dwFlags
)
1113 WINECRYPT_CERTSTORE
*hcs
= (WINECRYPT_CERTSTORE
*) hCertStore
;
1115 TRACE("(%p, %08x)\n", hCertStore
, dwFlags
);
1120 if ( hcs
->dwMagic
!= WINE_CRYPTCERTSTORE_MAGIC
)
1123 if (InterlockedDecrement(&hcs
->ref
) == 0)
1125 TRACE("%p's ref count is 0, freeing\n", hcs
);
1127 hcs
->closeStore(hcs
, dwFlags
);
1130 TRACE("%p's ref count is %d\n", hcs
, hcs
->ref
);
1134 BOOL WINAPI
CertControlStore(HCERTSTORE hCertStore
, DWORD dwFlags
,
1135 DWORD dwCtrlType
, void const *pvCtrlPara
)
1137 WINECRYPT_CERTSTORE
*hcs
= (WINECRYPT_CERTSTORE
*)hCertStore
;
1140 TRACE("(%p, %08x, %d, %p)\n", hCertStore
, dwFlags
, dwCtrlType
,
1145 else if (hcs
->dwMagic
!= WINE_CRYPTCERTSTORE_MAGIC
)
1150 ret
= hcs
->control(hCertStore
, dwFlags
, dwCtrlType
, pvCtrlPara
);
1157 BOOL WINAPI
CertGetStoreProperty(HCERTSTORE hCertStore
, DWORD dwPropId
,
1158 void *pvData
, DWORD
*pcbData
)
1160 PWINECRYPT_CERTSTORE store
= (PWINECRYPT_CERTSTORE
)hCertStore
;
1163 TRACE("(%p, %d, %p, %p)\n", hCertStore
, dwPropId
, pvData
, pcbData
);
1167 case CERT_ACCESS_STATE_PROP_ID
:
1170 *pcbData
= sizeof(DWORD
);
1173 else if (*pcbData
< sizeof(DWORD
))
1175 SetLastError(ERROR_MORE_DATA
);
1176 *pcbData
= sizeof(DWORD
);
1182 if (store
->type
!= StoreTypeMem
&&
1183 !(store
->dwOpenFlags
& CERT_STORE_READONLY_FLAG
))
1184 state
|= CERT_ACCESS_STATE_WRITE_PERSIST_FLAG
;
1185 *(DWORD
*)pvData
= state
;
1190 if (store
->properties
)
1192 CRYPT_DATA_BLOB blob
;
1194 ret
= ContextPropertyList_FindProperty(store
->properties
, dwPropId
,
1199 *pcbData
= blob
.cbData
;
1200 else if (*pcbData
< blob
.cbData
)
1202 SetLastError(ERROR_MORE_DATA
);
1203 *pcbData
= blob
.cbData
;
1208 memcpy(pvData
, blob
.pbData
, blob
.cbData
);
1209 *pcbData
= blob
.cbData
;
1213 SetLastError(CRYPT_E_NOT_FOUND
);
1216 SetLastError(CRYPT_E_NOT_FOUND
);
1221 BOOL WINAPI
CertSetStoreProperty(HCERTSTORE hCertStore
, DWORD dwPropId
,
1222 DWORD dwFlags
, const void *pvData
)
1224 PWINECRYPT_CERTSTORE store
= (PWINECRYPT_CERTSTORE
)hCertStore
;
1227 TRACE("(%p, %d, %08x, %p)\n", hCertStore
, dwPropId
, dwFlags
, pvData
);
1229 if (!store
->properties
)
1230 store
->properties
= ContextPropertyList_Create();
1233 case CERT_ACCESS_STATE_PROP_ID
:
1234 SetLastError(E_INVALIDARG
);
1239 const CRYPT_DATA_BLOB
*blob
= (const CRYPT_DATA_BLOB
*)pvData
;
1241 ret
= ContextPropertyList_SetProperty(store
->properties
, dwPropId
,
1242 blob
->pbData
, blob
->cbData
);
1246 ContextPropertyList_RemoveProperty(store
->properties
, dwPropId
);
1253 DWORD WINAPI
CertEnumCTLContextProperties(PCCTL_CONTEXT pCTLContext
,
1256 FIXME("(%p, %d): stub\n", pCTLContext
, dwPropId
);
1260 BOOL WINAPI
CertGetCTLContextProperty(PCCTL_CONTEXT pCTLContext
,
1261 DWORD dwPropId
, void *pvData
, DWORD
*pcbData
)
1263 FIXME("(%p, %d, %p, %p): stub\n", pCTLContext
, dwPropId
, pvData
, pcbData
);
1267 BOOL WINAPI
CertSetCTLContextProperty(PCCTL_CONTEXT pCTLContext
,
1268 DWORD dwPropId
, DWORD dwFlags
, const void *pvData
)
1270 FIXME("(%p, %d, %08x, %p): stub\n", pCTLContext
, dwPropId
, dwFlags
,
1275 static LONG
CRYPT_OpenParentStore(DWORD dwFlags
,
1276 void *pvSystemStoreLocationPara
, HKEY
*key
)
1281 TRACE("(%08x, %p)\n", dwFlags
, pvSystemStoreLocationPara
);
1283 switch (dwFlags
& CERT_SYSTEM_STORE_LOCATION_MASK
)
1285 case CERT_SYSTEM_STORE_LOCAL_MACHINE
:
1286 root
= HKEY_LOCAL_MACHINE
;
1287 base
= CERT_LOCAL_MACHINE_SYSTEM_STORE_REGPATH
;
1289 case CERT_SYSTEM_STORE_CURRENT_USER
:
1290 root
= HKEY_CURRENT_USER
;
1291 base
= CERT_LOCAL_MACHINE_SYSTEM_STORE_REGPATH
;
1293 case CERT_SYSTEM_STORE_CURRENT_SERVICE
:
1294 /* hklm\Software\Microsoft\Cryptography\Services\servicename\
1295 * SystemCertificates
1297 FIXME("CERT_SYSTEM_STORE_CURRENT_SERVICE\n");
1298 return ERROR_FILE_NOT_FOUND
;
1299 case CERT_SYSTEM_STORE_SERVICES
:
1300 /* hklm\Software\Microsoft\Cryptography\Services\servicename\
1301 * SystemCertificates
1303 FIXME("CERT_SYSTEM_STORE_SERVICES\n");
1304 return ERROR_FILE_NOT_FOUND
;
1305 case CERT_SYSTEM_STORE_USERS
:
1306 /* hku\user sid\Software\Microsoft\SystemCertificates */
1307 FIXME("CERT_SYSTEM_STORE_USERS\n");
1308 return ERROR_FILE_NOT_FOUND
;
1309 case CERT_SYSTEM_STORE_CURRENT_USER_GROUP_POLICY
:
1310 root
= HKEY_CURRENT_USER
;
1311 base
= CERT_GROUP_POLICY_SYSTEM_STORE_REGPATH
;
1313 case CERT_SYSTEM_STORE_LOCAL_MACHINE_GROUP_POLICY
:
1314 root
= HKEY_LOCAL_MACHINE
;
1315 base
= CERT_GROUP_POLICY_SYSTEM_STORE_REGPATH
;
1317 case CERT_SYSTEM_STORE_LOCAL_MACHINE_ENTERPRISE
:
1318 /* hklm\Software\Microsoft\EnterpriseCertificates */
1319 FIXME("CERT_SYSTEM_STORE_LOCAL_MACHINE_ENTERPRISE\n");
1320 return ERROR_FILE_NOT_FOUND
;
1322 return ERROR_FILE_NOT_FOUND
;
1325 return RegOpenKeyExW(root
, base
, 0, KEY_READ
, key
);
1328 BOOL WINAPI
CertEnumSystemStore(DWORD dwFlags
, void *pvSystemStoreLocationPara
,
1329 void *pvArg
, PFN_CERT_ENUM_SYSTEM_STORE pfnEnum
)
1335 TRACE("(%08x, %p, %p, %p)\n", dwFlags
, pvSystemStoreLocationPara
, pvArg
,
1338 rc
= CRYPT_OpenParentStore(dwFlags
, pvArg
, &key
);
1342 CERT_SYSTEM_STORE_INFO info
= { sizeof(info
) };
1346 WCHAR name
[MAX_PATH
];
1347 DWORD size
= sizeof(name
) / sizeof(name
[0]);
1349 rc
= RegEnumKeyExW(key
, index
++, name
, &size
, NULL
, NULL
, NULL
,
1352 ret
= pfnEnum(name
, 0, &info
, NULL
, pvArg
);
1353 } while (ret
&& !rc
);
1354 if (ret
&& rc
!= ERROR_NO_MORE_ITEMS
)