crypt32(15/21): Don't keep an unneeded copy of the crypto provider for each signer

Juan Lang juan.lang at gmail.com
Tue Aug 21 09:25:25 CDT 2007


--Juan
-------------- next part --------------
From cec81365dc7c2f91ae908e4fc4e208414d2919e3 Mon Sep 17 00:00:00 2001
From: Juan Lang <juan.lang at gmail.com>
Date: Mon, 20 Aug 2007 17:48:02 -0700
Subject: [PATCH] Don't keep an unneeded copy of the crypto provider for each signer
---
 dlls/crypt32/msg.c |   17 ++++++-----------
 1 files changed, 6 insertions(+), 11 deletions(-)

diff --git a/dlls/crypt32/msg.c b/dlls/crypt32/msg.c
index 2d0299c..a50fc3f 100644
--- a/dlls/crypt32/msg.c
+++ b/dlls/crypt32/msg.c
@@ -772,7 +772,6 @@ static void CSignerInfo_Free(CMSG_SIGNER
 
 typedef struct _CSignerHandles
 {
-    HCRYPTPROV prov;
     HCRYPTHASH contentHash;
     HCRYPTHASH authAttrHash;
     HCRYPTKEY  key;
@@ -791,8 +790,7 @@ typedef struct _CSignedEncodeMsg
     CSignedMsgData  msg_data;
 } CSignedEncodeMsg;
 
-/* Constructs a CSignerHandles with a copy of crypt_prov (not add-ref'ed - the
- * caller must do this if necessary), a hash handle based on HashAlgorithm, and
+/* Constructs a CSignerHandles with a hash handle based on HashAlgorithm, and
  * an authenticated attributes hash handle if hasAuthAttrs is TRUE.
  */
 static BOOL CSignerHandles_Construct(CSignerHandles *handles,
@@ -802,12 +800,10 @@ static BOOL CSignerHandles_Construct(CSi
     ALG_ID algID;
     BOOL ret;
 
-    handles->prov = crypt_prov;
     algID = CertOIDToAlgId(HashAlgorithm->pszObjId);
-    ret = CryptCreateHash(handles->prov, algID, 0, 0, &handles->contentHash);
+    ret = CryptCreateHash(crypt_prov, algID, 0, 0, &handles->contentHash);
     if (ret && hasAuthAttrs)
-        ret = CryptCreateHash(handles->prov, algID, 0, 0,
-         &handles->authAttrHash);
+        ret = CryptCreateHash(crypt_prov, algID, 0, 0, &handles->authAttrHash);
     return ret;
 }
 
@@ -820,7 +816,6 @@ static void CSignedMsgData_CloseHandles(
         CryptDestroyKey(msg_data->signerHandles[i].key);
         CryptDestroyHash(msg_data->signerHandles[i].contentHash);
         CryptDestroyHash(msg_data->signerHandles[i].authAttrHash);
-        CryptReleaseContext(msg_data->signerHandles[i].prov, 0);
     }
     CryptMemFree(msg_data->signerHandles);
 }
@@ -1214,14 +1209,14 @@ static HCRYPTMSG CSignedEncodeMsg_Open(D
                      &info->rgSigners[i]);
                     if (ret)
                     {
-                        if (!(dwFlags & CMSG_CRYPT_RELEASE_CONTEXT_FLAG))
-                            CryptContextAddRef(info->rgSigners[i].hCryptProv,
-                             NULL, 0);
                         ret = CSignerHandles_Construct(
                          &msg->msg_data.signerHandles[i],
                          info->rgSigners[i].hCryptProv,
                          &info->rgSigners[i].HashAlgorithm,
                          info->rgSigners[i].cAuthAttr > 0);
+                        if (dwFlags & CMSG_CRYPT_RELEASE_CONTEXT_FLAG)
+                            CryptReleaseContext(info->rgSigners[i].hCryptProv,
+                             0);
                     }
                 }
             }
-- 
1.4.1


More information about the wine-patches mailing list