crypt32(1/3): Store (most) parameters of a decoded hash message
Juan Lang
juan.lang at gmail.com
Wed Jul 18 12:14:07 CDT 2007
--Juan
-------------- next part --------------
From f3f79c7c257866421609e9323885a9de81514aa0 Mon Sep 17 00:00:00 2001
From: Juan Lang <juanlang at juan.corp.google.com>
Date: Wed, 18 Jul 2007 09:37:22 -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 a1743ff..40da5fc 100644
--- a/dlls/crypt32/tests/msg.c
+++ b/dlls/crypt32/tests/msg.c
@@ -1254,9 +1254,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_algid_param("empty hash hash algo id", msg, CMSG_HASH_ALGORITHM_PARAM,
@@ -1267,10 +1265,8 @@ 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
@@ -1280,11 +1276,9 @@ static void test_decode_msg_get_param(vo
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