Juan Lang : crypt32: Implement verifying the hash of a decoded hash
message .
Alexandre Julliard
julliard at wine.codeweavers.com
Tue Aug 21 15:22:22 CDT 2007
Module: wine
Branch: master
Commit: 3e88838b606a93c67e92ee1a50e5b1d53a8df730
URL: http://source.winehq.org/git/wine.git/?a=commit;h=3e88838b606a93c67e92ee1a50e5b1d53a8df730
Author: Juan Lang <juan.lang at gmail.com>
Date: Mon Aug 20 17:40:25 2007 -0700
crypt32: Implement verifying the hash of a decoded hash message.
---
dlls/crypt32/msg.c | 34 +++++++++++++++++++++++++++++++++-
dlls/crypt32/tests/msg.c | 2 +-
2 files changed, 34 insertions(+), 2 deletions(-)
diff --git a/dlls/crypt32/msg.c b/dlls/crypt32/msg.c
index 036f2f7..516bc1b 100644
--- a/dlls/crypt32/msg.c
+++ b/dlls/crypt32/msg.c
@@ -1926,6 +1926,38 @@ static BOOL CDecodeMsg_GetParam(HCRYPTMSG hCryptMsg, DWORD dwParamType,
return ret;
}
+static BOOL CDecodeHashMsg_VerifyHash(CDecodeMsg *msg)
+{
+ BOOL ret;
+ CRYPT_DATA_BLOB hashBlob;
+
+ ret = ContextPropertyList_FindProperty(msg->properties,
+ CMSG_HASH_DATA_PARAM, &hashBlob);
+ if (ret)
+ {
+ DWORD computedHashSize = 0;
+
+ ret = CDecodeHashMsg_GetParam(msg, CMSG_COMPUTED_HASH_PARAM, 0, NULL,
+ &computedHashSize);
+ if (hashBlob.cbData == computedHashSize)
+ {
+ LPBYTE computedHash = CryptMemAlloc(computedHashSize);
+
+ if (computedHash)
+ {
+ ret = CDecodeHashMsg_GetParam(msg, CMSG_COMPUTED_HASH_PARAM, 0,
+ computedHash, &computedHashSize);
+ if (ret)
+ ret = !memcmp(hashBlob.pbData, computedHash,
+ hashBlob.cbData);
+ }
+ else
+ ret = FALSE;
+ }
+ }
+ return ret;
+}
+
static BOOL CDecodeMsg_Control(HCRYPTMSG hCryptMsg, DWORD dwFlags,
DWORD dwCtrlType, const void *pvCtrlPara)
{
@@ -1955,7 +1987,7 @@ static BOOL CDecodeMsg_Control(HCRYPTMSG hCryptMsg, DWORD dwFlags,
switch (msg->type)
{
case CMSG_HASHED:
- FIXME("CMSG_CTRL_VERIFY_HASH: stub\n");
+ ret = CDecodeHashMsg_VerifyHash(msg);
break;
default:
SetLastError(CRYPT_E_INVALID_MSG_TYPE);
diff --git a/dlls/crypt32/tests/msg.c b/dlls/crypt32/tests/msg.c
index b373470..72932fe 100644
--- a/dlls/crypt32/tests/msg.c
+++ b/dlls/crypt32/tests/msg.c
@@ -2246,13 +2246,13 @@ 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,
NULL);
CryptMsgUpdate(msg, hashBareContent, sizeof(hashBareContent), TRUE);
ret = CryptMsgControl(msg, 0, CMSG_CTRL_VERIFY_HASH, NULL);
- todo_wine
ok(ret, "CryptMsgControl failed: %08x\n", GetLastError());
/* Can't decrypt an indeterminate-type message */
SetLastError(0xdeadbeef);
More information about the wine-cvs
mailing list