crypt32: Fix verifying the hash of a detached hash message.
This commit is contained in:
parent
0fbef45f55
commit
13545bee2d
|
@ -1607,12 +1607,15 @@ static BOOL CDecodeMsg_DecodeHashedContent(CDecodeMsg *msg,
|
|||
(const BYTE *)digestedData->ContentInfo.pszObjId,
|
||||
digestedData->ContentInfo.pszObjId ?
|
||||
strlen(digestedData->ContentInfo.pszObjId) + 1 : 0);
|
||||
if (!(msg->base.open_flags & CMSG_DETACHED_FLAG))
|
||||
{
|
||||
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);
|
||||
|
@ -1715,6 +1718,17 @@ static BOOL CDecodeMsg_FinalizeHashedContent(CDecodeMsg *msg,
|
|||
{
|
||||
CRYPT_DATA_BLOB content;
|
||||
|
||||
if (msg->base.open_flags & CMSG_DETACHED_FLAG)
|
||||
{
|
||||
/* Unlike for non-detached messages, the data were never stored as
|
||||
* the content param, but were saved in msg->detached_data instead.
|
||||
* Set the content property with the detached data so the data may
|
||||
* be hashed.
|
||||
*/
|
||||
ContextPropertyList_SetProperty(msg->properties,
|
||||
CMSG_CONTENT_PARAM, msg->detached_data.pbData,
|
||||
msg->detached_data.cbData);
|
||||
}
|
||||
ret = ContextPropertyList_FindProperty(msg->properties,
|
||||
CMSG_CONTENT_PARAM, &content);
|
||||
if (ret)
|
||||
|
@ -2480,11 +2494,24 @@ static BOOL CDecodeHashMsg_VerifyHash(CDecodeMsg *msg)
|
|||
ret = CDecodeHashMsg_GetParam(msg, CMSG_COMPUTED_HASH_PARAM, 0,
|
||||
computedHash, &computedHashSize);
|
||||
if (ret)
|
||||
ret = !memcmp(hashBlob.pbData, computedHash,
|
||||
hashBlob.cbData);
|
||||
{
|
||||
if (memcmp(hashBlob.pbData, computedHash, hashBlob.cbData))
|
||||
{
|
||||
SetLastError(CRYPT_E_HASH_VALUE);
|
||||
ret = FALSE;
|
||||
}
|
||||
}
|
||||
CryptMemFree(computedHash);
|
||||
}
|
||||
else
|
||||
{
|
||||
SetLastError(ERROR_OUTOFMEMORY);
|
||||
ret = FALSE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
SetLastError(CRYPT_E_HASH_VALUE);
|
||||
ret = FALSE;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2660,7 +2660,6 @@ static void test_msg_control(void)
|
|||
TRUE);
|
||||
/* Oddly enough, this fails */
|
||||
ret = CryptMsgControl(msg, 0, CMSG_CTRL_VERIFY_HASH, NULL);
|
||||
todo_wine
|
||||
ok(!ret, "Expected failure\n");
|
||||
CryptMsgClose(msg);
|
||||
msg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING, 0, CMSG_HASHED, 0, NULL,
|
||||
|
@ -2690,7 +2689,6 @@ static void test_msg_control(void)
|
|||
*/
|
||||
SetLastError(0xdeadbeef);
|
||||
ret = CryptMsgControl(msg, 0, CMSG_CTRL_VERIFY_HASH, NULL);
|
||||
todo_wine
|
||||
ok(!ret && GetLastError() == CRYPT_E_HASH_VALUE,
|
||||
"Expected CRYPT_E_HASH_VALUE, got %08x\n", GetLastError());
|
||||
/* and giving the content of the message after attempting to verify the
|
||||
|
@ -2718,7 +2716,6 @@ static void test_msg_control(void)
|
|||
ok(ret, "CryptMsgUpdate failed: %08x\n", GetLastError());
|
||||
SetLastError(0xdeadbeef);
|
||||
ret = CryptMsgControl(msg, 0, CMSG_CTRL_VERIFY_HASH, NULL);
|
||||
todo_wine
|
||||
ok(ret, "CryptMsgControl failed: %08x\n", GetLastError());
|
||||
CryptMsgClose(msg);
|
||||
|
||||
|
|
Loading…
Reference in New Issue