Juan Lang : crypt32: Store (most) parameters of a decoded hash message.

Alexandre Julliard julliard at wine.codeweavers.com
Fri Jul 20 06:02:18 CDT 2007


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

Author: Juan Lang <juan.lang at gmail.com>
Date:   Thu Jul 19 07:30:44 2007 -0700

crypt32: Store (most) parameters of a decoded hash message.

---

 dlls/crypt32/msg.c       |   51 +++++++++++++++++++++++++++++++++------------
 dlls/crypt32/tests/msg.c |    6 -----
 2 files changed, 37 insertions(+), 20 deletions(-)

diff --git a/dlls/crypt32/msg.c b/dlls/crypt32/msg.c
index 93cce83..a261455 100644
--- a/dlls/crypt32/msg.c
+++ b/dlls/crypt32/msg.c
@@ -631,6 +631,24 @@ static BOOL CDecodeMsg_CopyData(CDecodeMsg *msg, const BYTE *pbData,
     return ret;
 }
 
+static BOOL CDecodeMsg_DecodeDataContent(CDecodeMsg *msg, CRYPT_DER_BLOB *blob)
+{
+    BOOL ret;
+    CRYPT_DATA_BLOB *data;
+    DWORD size;
+
+    ret = CryptDecodeObjectEx(X509_ASN_ENCODING, X509_OCTET_STRING,
+     blob->pbData, blob->cbData, CRYPT_DECODE_ALLOC_FLAG, NULL, (LPBYTE)&data,
+     &size);
+    if (ret)
+    {
+        ret = ContextPropertyList_SetProperty(msg->properties,
+         CMSG_CONTENT_PARAM, data->pbData, data->cbData);
+        LocalFree(data);
+    }
+    return ret;
+}
+
 /* Decodes the content in blob as the type given, and updates the value
  * (type, parameters, etc.) of msg based on what blob contains.
  * It doesn't just use msg's type, to allow a recursive call from an implicitly
@@ -645,21 +663,9 @@ static BOOL CDecodeMsg_DecodeContent(CDecodeMsg *msg, CRYPT_DER_BLOB *blob,
     switch (type)
     {
     case CMSG_DATA:
-    {
-        CRYPT_DATA_BLOB *data;
-
-        ret = CryptDecodeObjectEx(X509_ASN_ENCODING, X509_OCTET_STRING,
-         blob->pbData, blob->cbData, CRYPT_DECODE_ALLOC_FLAG, NULL,
-         (LPBYTE)&data, &size);
-        if (ret)
-        {
-            ret = ContextPropertyList_SetProperty(msg->properties,
-             CMSG_CONTENT_PARAM, data->pbData, data->cbData);
-            LocalFree(data);
+        if ((ret = CDecodeMsg_DecodeDataContent(msg, blob)))
             msg->type = CMSG_DATA;
-        }
         break;
-    }
     case CMSG_HASHED:
     {
         CRYPT_DIGESTED_DATA *digestedData;
@@ -669,7 +675,24 @@ static BOOL CDecodeMsg_DecodeContent(CDecodeMsg *msg, CRYPT_DER_BLOB *blob,
          &size);
         if (ret)
         {
-            FIXME("need to store data for CMSG_HASHED\n");
+            msg->type = CMSG_HASHED;
+            ContextPropertyList_SetProperty(msg->properties,
+             CMSG_VERSION_PARAM, (const BYTE *)&digestedData->version,
+             sizeof(digestedData->version));
+            ContextPropertyList_SetProperty(msg->properties,
+             CMSG_INNER_CONTENT_TYPE_PARAM,
+             (const BYTE *)digestedData->ContentInfo.pszObjId,
+             digestedData->ContentInfo.pszObjId ?
+             strlen(digestedData->ContentInfo.pszObjId) + 1 : 0);
+            if (digestedData->ContentInfo.Content.cbData)
+                CDecodeMsg_DecodeDataContent(msg,
+                 &digestedData->ContentInfo.Content);
+            else
+                ContextPropertyList_SetProperty(msg->properties,
+                 CMSG_CONTENT_PARAM, NULL, 0);
+            ContextPropertyList_SetProperty(msg->properties,
+             CMSG_HASH_DATA_PARAM, digestedData->hash.pbData,
+             digestedData->hash.cbData);
             LocalFree(digestedData);
         }
         break;
diff --git a/dlls/crypt32/tests/msg.c b/dlls/crypt32/tests/msg.c
index b80a74a..0ecc62b 100644
--- a/dlls/crypt32/tests/msg.c
+++ b/dlls/crypt32/tests/msg.c
@@ -1222,9 +1222,7 @@ static void test_decode_msg_get_param(void)
 
     msg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING, 0, 0, 0, NULL, NULL);
     ret = CryptMsgUpdate(msg, hashEmptyContent, sizeof(hashEmptyContent), TRUE);
-    todo_wine
     check_param("empty hash content", msg, CMSG_CONTENT_PARAM, NULL, 0);
-    todo_wine
     check_param("empty hash hash data", msg, CMSG_HASH_DATA_PARAM, NULL, 0);
     todo_wine
     check_param("empty hash computed hash", msg, CMSG_COMPUTED_HASH_PARAM,
@@ -1232,21 +1230,17 @@ static void test_decode_msg_get_param(void)
     CryptMsgClose(msg);
     msg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING, 0, 0, 0, NULL, NULL);
     ret = CryptMsgUpdate(msg, hashContent, sizeof(hashContent), TRUE);
-    todo_wine
     check_param("hash content", msg, CMSG_CONTENT_PARAM, msgData,
      sizeof(msgData));
-    todo_wine
     check_param("hash hash data", msg, CMSG_HASH_DATA_PARAM, hashParam,
      sizeof(hashParam));
     todo_wine
     check_param("hash computed hash", msg, CMSG_COMPUTED_HASH_PARAM,
      hashParam, sizeof(hashParam));
     size = strlen(szOID_RSA_data) + 1;
-    todo_wine
     check_param("hash inner OID", msg, CMSG_INNER_CONTENT_TYPE_PARAM,
      (const BYTE *)szOID_RSA_data, strlen(szOID_RSA_data) + 1);
     version = CMSG_HASHED_DATA_V0;
-    todo_wine
     check_param("hash version", msg, CMSG_VERSION_PARAM, (const BYTE *)&version,
      sizeof(version));
     CryptMsgClose(msg);




More information about the wine-cvs mailing list