Juan Lang : crypt32: Implement CryptVerifyMessageHash.

Alexandre Julliard julliard at winehq.org
Tue Sep 9 05:50:36 CDT 2008


Module: wine
Branch: master
Commit: f98eb4a8a0aaa3244b4308c5dd4ba29eb4e1f9fd
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=f98eb4a8a0aaa3244b4308c5dd4ba29eb4e1f9fd

Author: Juan Lang <juan.lang at gmail.com>
Date:   Mon Sep  8 12:45:09 2008 -0700

crypt32: Implement CryptVerifyMessageHash.

---

 dlls/crypt32/message.c       |   36 ++++++++++++++++++++++++++++++++++--
 dlls/crypt32/tests/message.c |    5 -----
 2 files changed, 34 insertions(+), 7 deletions(-)

diff --git a/dlls/crypt32/message.c b/dlls/crypt32/message.c
index 5440a4c..b419866 100644
--- a/dlls/crypt32/message.c
+++ b/dlls/crypt32/message.c
@@ -323,8 +323,40 @@ BOOL WINAPI CryptVerifyMessageHash(PCRYPT_HASH_MESSAGE_PARA pHashPara,
  BYTE *pbHashedBlob, DWORD cbHashedBlob, BYTE *pbToBeHashed,
  DWORD *pcbToBeHashed, BYTE *pbComputedHash, DWORD *pcbComputedHash)
 {
-    FIXME("(%p, %p, %d, %p, %p, %p, %p): stub\n", pHashPara, pbHashedBlob,
+    HCRYPTMSG msg;
+    BOOL ret = FALSE;
+
+    TRACE("(%p, %p, %d, %p, %p, %p, %p)\n", pHashPara, pbHashedBlob,
      cbHashedBlob, pbToBeHashed, pcbToBeHashed, pbComputedHash,
      pcbComputedHash);
-    return FALSE;
+
+    if (pHashPara->cbSize != sizeof(CRYPT_HASH_MESSAGE_PARA))
+    {
+        SetLastError(E_INVALIDARG);
+        return FALSE;
+    }
+    if (GET_CMSG_ENCODING_TYPE(pHashPara->dwMsgEncodingType) !=
+     PKCS_7_ASN_ENCODING)
+    {
+        SetLastError(E_INVALIDARG);
+        return FALSE;
+    }
+    msg = CryptMsgOpenToDecode(pHashPara->dwMsgEncodingType, 0, 0,
+     pHashPara->hCryptProv, NULL, NULL);
+    if (msg)
+    {
+        ret = CryptMsgUpdate(msg, pbHashedBlob, cbHashedBlob, TRUE);
+        if (ret)
+        {
+            ret = CryptMsgControl(msg, 0, CMSG_CTRL_VERIFY_HASH, NULL);
+            if (ret && pcbToBeHashed)
+                ret = CryptMsgGetParam(msg, CMSG_CONTENT_PARAM, 0,
+                 pbToBeHashed, pcbToBeHashed);
+            if (ret && pcbComputedHash)
+                ret = CryptMsgGetParam(msg, CMSG_COMPUTED_HASH_PARAM, 0,
+                 pbComputedHash, pcbComputedHash);
+        }
+        CryptMsgClose(msg);
+    }
+    return ret;
 }
diff --git a/dlls/crypt32/tests/message.c b/dlls/crypt32/tests/message.c
index e1d7cf0..271bc2d 100644
--- a/dlls/crypt32/tests/message.c
+++ b/dlls/crypt32/tests/message.c
@@ -210,19 +210,16 @@ static void test_verify_message_hash(void)
         ret = CryptVerifyMessageHash(NULL, NULL, 0, NULL, NULL, NULL, NULL);
     SetLastError(0xdeadbeef);
     ret = CryptVerifyMessageHash(&para, NULL, 0, NULL, NULL, NULL, NULL);
-    todo_wine
     ok(!ret && GetLastError() == E_INVALIDARG,
      "expected E_INVALIDARG, got %08x\n", GetLastError());
     para.cbSize = sizeof(para);
     SetLastError(0xdeadbeef);
     ret = CryptVerifyMessageHash(&para, NULL, 0, NULL, NULL, NULL, NULL);
-    todo_wine
     ok(!ret && GetLastError() == E_INVALIDARG,
      "expected E_INVALIDARG, got %08x\n", GetLastError());
     para.dwMsgEncodingType = PKCS_7_ASN_ENCODING;
     SetLastError(0xdeadbeef);
     ret = CryptVerifyMessageHash(&para, NULL, 0, NULL, NULL, NULL, NULL);
-    todo_wine
     ok(!ret && GetLastError() == CRYPT_E_ASN1_EOD,
      "expected CRYPT_E_ASN1_EOD, got %08x\n", GetLastError());
     /* Verifying the hash of a detached message succeeds? */
@@ -233,11 +230,9 @@ static void test_verify_message_hash(void)
     /* As does verifying the hash of a regular message. */
     ret = CryptVerifyMessageHash(&para, hashContent, sizeof(hashContent),
      NULL, NULL, NULL, NULL);
-    todo_wine
     ok(ret, "CryptVerifyMessageHash failed: %08x\n", GetLastError());
     ret = CryptVerifyMessageHash(&para, hashContent, sizeof(hashContent),
      NULL, &size, NULL, NULL);
-    todo_wine
     ok(ret, "CryptVerifyMessageHash failed: %08x\n", GetLastError());
     if (ret)
         buf = CryptMemAlloc(size);




More information about the wine-cvs mailing list