Juan Lang : crypt32: Add a couple tests that show you can' t get the hash from an encoded hash message, and fix encoded hash messages to match.

Alexandre Julliard julliard at wine.codeweavers.com
Tue Aug 21 15:22:22 CDT 2007


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

Author: Juan Lang <juan.lang at gmail.com>
Date:   Mon Aug 20 17:33:44 2007 -0700

crypt32: Add a couple tests that show you can't get the hash from an encoded hash message, and fix encoded hash messages to match.

---

 dlls/crypt32/msg.c       |    2 +-
 dlls/crypt32/tests/msg.c |   10 ++++++++++
 2 files changed, 11 insertions(+), 1 deletions(-)

diff --git a/dlls/crypt32/msg.c b/dlls/crypt32/msg.c
index 79c8f9b..036f2f7 100644
--- a/dlls/crypt32/msg.c
+++ b/dlls/crypt32/msg.c
@@ -464,7 +464,7 @@ static BOOL CHashEncodeMsg_GetParam(HCRYPTMSG hCryptMsg, DWORD dwParamType,
         }
         break;
     default:
-        ret = FALSE;
+        SetLastError(CRYPT_E_INVALID_MSG_TYPE);
     }
     return ret;
 }
diff --git a/dlls/crypt32/tests/msg.c b/dlls/crypt32/tests/msg.c
index e705824..b373470 100644
--- a/dlls/crypt32/tests/msg.c
+++ b/dlls/crypt32/tests/msg.c
@@ -788,6 +788,11 @@ static void test_hash_msg_get_param(void)
     size = 0;
     ret = CryptMsgGetParam(msg, CMSG_BARE_CONTENT_PARAM, 0, NULL, &size);
     ok(ret, "CryptMsgGetParam failed: %08x\n", GetLastError());
+    /* For an encoded hash message, the hash data aren't available */
+    SetLastError(0xdeadbeef);
+    ret = CryptMsgGetParam(msg, CMSG_HASH_DATA_PARAM, 0, NULL, &size);
+    ok(!ret && GetLastError() == CRYPT_E_INVALID_MSG_TYPE,
+     "Expected CRYPT_E_INVALID_MSG_TYPE, got %08x\n", GetLastError());
     /* The hash is also available. */
     size = 0;
     ret = CryptMsgGetParam(msg, CMSG_COMPUTED_HASH_PARAM, 0, NULL, &size);
@@ -801,6 +806,11 @@ static void test_hash_msg_get_param(void)
     ret = CryptMsgUpdate(msg, msgData, sizeof(msgData), TRUE);
     ok(!ret && GetLastError() == NTE_BAD_HASH_STATE,
      "Expected NTE_BAD_HASH_STATE, got %x\n", GetLastError());
+    /* Even after a final update, the hash data aren't available */
+    SetLastError(0xdeadbeef);
+    ret = CryptMsgGetParam(msg, CMSG_HASH_DATA_PARAM, 0, NULL, &size);
+    ok(!ret && GetLastError() == CRYPT_E_INVALID_MSG_TYPE,
+     "Expected CRYPT_E_INVALID_MSG_TYPE, got %08x\n", GetLastError());
     /* The version is also available, and should be zero for this message. */
     size = 0;
     ret = CryptMsgGetParam(msg, CMSG_VERSION_PARAM, 0, NULL, &size);




More information about the wine-cvs mailing list