Juan Lang : crypt32: Create file store directly in CRYPT_FileNameOpenStoreW .

Alexandre Julliard julliard at winehq.org
Mon Oct 1 07:54:57 CDT 2007


Module: wine
Branch: master
Commit: 60fcce5558c1747f7db09e9cd90b9883f9d9cf2d
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=60fcce5558c1747f7db09e9cd90b9883f9d9cf2d

Author: Juan Lang <juan.lang at gmail.com>
Date:   Fri Sep 28 08:37:47 2007 -0700

crypt32: Create file store directly in CRYPT_FileNameOpenStoreW.

---

 dlls/crypt32/filestore.c |   33 +++++++++++++++++++++++++++------
 1 files changed, 27 insertions(+), 6 deletions(-)

diff --git a/dlls/crypt32/filestore.c b/dlls/crypt32/filestore.c
index fc89c0a..ffd9889 100644
--- a/dlls/crypt32/filestore.c
+++ b/dlls/crypt32/filestore.c
@@ -227,6 +227,12 @@ PWINECRYPT_CERTSTORE CRYPT_FileNameOpenStoreW(HCRYPTPROV hCryptProv,
         SetLastError(ERROR_PATH_NOT_FOUND);
         return NULL;
     }
+    if ((dwFlags & CERT_STORE_READONLY_FLAG) &&
+     (dwFlags & CERT_FILE_STORE_COMMIT_ENABLE_FLAG))
+    {
+        SetLastError(E_INVALIDARG);
+        return NULL;
+    }
 
     access = GENERIC_READ;
     if (dwFlags & CERT_FILE_STORE_COMMIT_ENABLE_FLAG)
@@ -241,12 +247,27 @@ PWINECRYPT_CERTSTORE CRYPT_FileNameOpenStoreW(HCRYPTPROV hCryptProv,
      FILE_ATTRIBUTE_NORMAL, NULL);
     if (file != INVALID_HANDLE_VALUE)
     {
-        /* FIXME: need to check whether it's a serialized store; if not, fall
-         * back to a PKCS#7 signed message, then to a single serialized cert.
-         */
-        store = CertOpenStore(CERT_STORE_PROV_FILE, 0, hCryptProv, dwFlags,
-         file);
-        CloseHandle(file);
+        HCERTSTORE memStore;
+
+        memStore = CertOpenStore(CERT_STORE_PROV_MEMORY, 0, 0,
+         CERT_STORE_CREATE_NEW_FLAG, NULL);
+        if (memStore)
+        {
+            if (CRYPT_ReadSerializedStoreFromFile(file, memStore))
+            {
+                store = CRYPT_CreateFileStore(dwFlags, memStore, file);
+                /* File store doesn't need crypto provider, so close it */
+                if (hCryptProv &&
+                 !(dwFlags & CERT_STORE_NO_CRYPT_RELEASE_FLAG))
+                    CryptReleaseContext(hCryptProv, 0);
+            }
+            else
+            {
+                /* FIXME: fall back to a PKCS#7 signed message, then to a
+                 * single serialized cert.
+                 */
+            }
+        }
     }
     return (PWINECRYPT_CERTSTORE)store;
 }




More information about the wine-cvs mailing list