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

This commit is contained in:
Juan Lang 2007-07-19 07:30:44 -07:00 committed by Alexandre Julliard
parent 46a48c40ad
commit 0e90cb9629
2 changed files with 37 additions and 20 deletions

View File

@ -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;

View File

@ -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);