From 88a016184dcd6a88bfdf046da971fcaf7a8efce1 Mon Sep 17 00:00:00 2001 From: Juan Lang Date: Tue, 15 Jun 2010 11:54:23 -0700 Subject: [PATCH] crypt32: Add support for CERT_STORE_PROV_SERIALIZED to CertOpenStore. --- dlls/crypt32/store.c | 33 +++++++++++++++++++++++++++++++++ dlls/crypt32/tests/store.c | 3 --- 2 files changed, 33 insertions(+), 3 deletions(-) diff --git a/dlls/crypt32/store.c b/dlls/crypt32/store.c index dc1878603c5..df12e3e8ad3 100644 --- a/dlls/crypt32/store.c +++ b/dlls/crypt32/store.c @@ -724,6 +724,34 @@ static PWINECRYPT_CERTSTORE CRYPT_PKCSOpenStore(HCRYPTPROV hCryptProv, return store; } +static PWINECRYPT_CERTSTORE CRYPT_SerializedOpenStore(HCRYPTPROV hCryptProv, + DWORD dwFlags, const void *pvPara) +{ + HCERTSTORE store; + const CRYPT_DATA_BLOB *data = pvPara; + + TRACE("(%ld, %08x, %p)\n", hCryptProv, dwFlags, pvPara); + + if (dwFlags & CERT_STORE_DELETE_FLAG) + { + SetLastError(ERROR_CALL_NOT_IMPLEMENTED); + return NULL; + } + + store = CertOpenStore(CERT_STORE_PROV_MEMORY, 0, 0, + CERT_STORE_CREATE_NEW_FLAG, NULL); + if (store) + { + if (!CRYPT_ReadSerializedStoreFromBlob(data, store)) + { + CertCloseStore(store, 0); + store = NULL; + } + } + TRACE("returning %p\n", store); + return (PWINECRYPT_CERTSTORE)store; +} + static PWINECRYPT_CERTSTORE CRYPT_PhysOpenStoreW(HCRYPTPROV hCryptProv, DWORD dwFlags, const void *pvPara) { @@ -761,6 +789,9 @@ HCERTSTORE WINAPI CertOpenStore(LPCSTR lpszStoreProvider, case LOWORD(CERT_STORE_PROV_PKCS7): openFunc = CRYPT_PKCSOpenStore; break; + case LOWORD(CERT_STORE_PROV_SERIALIZED): + openFunc = CRYPT_SerializedOpenStore; + break; case LOWORD(CERT_STORE_PROV_REG): openFunc = CRYPT_RegOpenStore; break; @@ -801,6 +832,8 @@ HCERTSTORE WINAPI CertOpenStore(LPCSTR lpszStoreProvider, openFunc = CRYPT_SysOpenStoreW; else if (!strcasecmp(lpszStoreProvider, sz_CERT_STORE_PROV_PKCS7)) openFunc = CRYPT_PKCSOpenStore; + else if (!strcasecmp(lpszStoreProvider, sz_CERT_STORE_PROV_SERIALIZED)) + openFunc = CRYPT_SerializedOpenStore; else if (!strcasecmp(lpszStoreProvider, sz_CERT_STORE_PROV_COLLECTION)) openFunc = CRYPT_CollectionOpenStore; else if (!strcasecmp(lpszStoreProvider, sz_CERT_STORE_PROV_SYSTEM_REGISTRY)) diff --git a/dlls/crypt32/tests/store.c b/dlls/crypt32/tests/store.c index 652eac98862..3d55935073c 100644 --- a/dlls/crypt32/tests/store.c +++ b/dlls/crypt32/tests/store.c @@ -1780,11 +1780,9 @@ static void testSerializedStore(void) blob.pbData = (BYTE *)serializedStoreWithCert; store = CertOpenStore(CERT_STORE_PROV_SERIALIZED, 0, 0, CERT_STORE_DELETE_FLAG, &blob); - todo_wine ok(!store && GetLastError() == ERROR_CALL_NOT_IMPLEMENTED, "Expected ERROR_CALL_NOT_IMPLEMENTED, got %08x\n", GetLastError()); store = CertOpenStore(CERT_STORE_PROV_SERIALIZED, 0, 0, 0, &blob); - todo_wine ok(store != NULL, "CertOpenStore failed: %08x\n", GetLastError()); if (store) { @@ -1806,7 +1804,6 @@ static void testSerializedStore(void) blob.cbData = sizeof(serializedStoreWithCertAndCRL); blob.pbData = (BYTE *)serializedStoreWithCertAndCRL; store = CertOpenStore(CERT_STORE_PROV_SERIALIZED, 0, 0, 0, &blob); - todo_wine ok(store != NULL, "CertOpenStore failed: %08x\n", GetLastError()); if (store) {