crypt32(20/21): Test and implement getting the computed hash from a decoded signed message

Juan Lang juan.lang at gmail.com
Tue Aug 21 09:27:35 CDT 2007


--Juan
-------------- next part --------------
From 43ab3c7ea10fbf1814fcd2361b8144d2c9b2164a Mon Sep 17 00:00:00 2001
From: Juan Lang <juan.lang at gmail.com>
Date: Tue, 21 Aug 2007 07:09:24 -0700
Subject: [PATCH] Test and implement getting the computed hash from a decoded signed message
---
 dlls/crypt32/msg.c       |   13 +++++++++++++
 dlls/crypt32/tests/msg.c |    7 +++++++
 2 files changed, 20 insertions(+), 0 deletions(-)

diff --git a/dlls/crypt32/msg.c b/dlls/crypt32/msg.c
index 76bb055..ace5e51 100644
--- a/dlls/crypt32/msg.c
+++ b/dlls/crypt32/msg.c
@@ -1975,6 +1975,19 @@ static BOOL CDecodeSignedMsg_GetParam(CD
         else
             SetLastError(CRYPT_E_INVALID_MSG_TYPE);
         break;
+    case CMSG_COMPUTED_HASH_PARAM:
+        if (msg->u.signed_data.info)
+        {
+            if (dwIndex >= msg->u.signed_data.info->cSignerInfo)
+                SetLastError(CRYPT_E_INVALID_INDEX);
+            else
+                ret = CryptGetHashParam(
+                 msg->u.signed_data.signerHandles[dwIndex].contentHash,
+                 HP_HASHVAL, pvData, pcbData, 0);
+        }
+        else
+            SetLastError(CRYPT_E_INVALID_MSG_TYPE);
+        break;
     case CMSG_ATTR_CERT_COUNT_PARAM:
         if (msg->u.signed_data.info)
         {
diff --git a/dlls/crypt32/tests/msg.c b/dlls/crypt32/tests/msg.c
index 72932fe..f079916 100644
--- a/dlls/crypt32/tests/msg.c
+++ b/dlls/crypt32/tests/msg.c
@@ -1989,6 +1989,10 @@ static void compare_signer_info(const CM
     /* FIXME: check more things */
 }
 
+static const BYTE signedWithCertAndCrlComputedHash[] = {
+0x08,0xd6,0xc0,0x5a,0x21,0x51,0x2a,0x79,0xa1,0xdf,0xeb,0x9d,0x2a,0x8f,0x26,
+0x2f };
+
 static void test_decode_msg_get_param(void)
 {
     HCRYPTMSG msg;
@@ -2099,6 +2103,9 @@ static void test_decode_msg_get_param(vo
     ok(ret, "CryptMsgGetParam failed: %08x\n", GetLastError());
     ok(value == 1, "Expected 1 CRL, got %d\n", value);
     check_param("crl", msg, CMSG_CRL_PARAM, crl, sizeof(crl));
+    check_param("signed with cert and CRL computed hash", msg,
+     CMSG_COMPUTED_HASH_PARAM, signedWithCertAndCrlComputedHash,
+     sizeof(signedWithCertAndCrlComputedHash));
     CryptMsgClose(msg);
 }
 
-- 
1.4.1


More information about the wine-patches mailing list