crypt32(1/3): Store (most) parameters of a decoded hash message (try 2)

Juan Lang juan.lang at gmail.com
Thu Jul 19 09:33:34 CDT 2007


Think I had some merging issues, this is resynched.
--Juan
-------------- next part --------------
From c80e9229cce5cd94c6acfe939b1997ec43493135 Mon Sep 17 00:00:00 2001
From: Juan Lang <juanlang at juan.corp.google.com>
Date: Thu, 19 Jul 2007 07:30:44 -0700
Subject: [PATCH] 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(CDecodeM
     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(CDe
     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(CDe
          &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(vo
 
     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(vo
     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);
-- 
1.4.1


More information about the wine-patches mailing list