crypt32(6/10): Add a few tests for decoded message parameters

Juan Lang juan.lang at gmail.com
Tue Jul 17 10:27:49 CDT 2007


--Juan
-------------- next part --------------
From 5702209b4d252ae8f590ab351ccbbd050c91c2f3 Mon Sep 17 00:00:00 2001
From: Juan Lang <juanlang at juan.corp.google.com>
Date: Tue, 17 Jul 2007 07:31:51 -0700
Subject: [PATCH] Add a few tests for decoded message parameters
---
 dlls/crypt32/tests/msg.c |   44 ++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 42 insertions(+), 2 deletions(-)

diff --git a/dlls/crypt32/tests/msg.c b/dlls/crypt32/tests/msg.c
index 265205b..8458c9b 100644
--- a/dlls/crypt32/tests/msg.c
+++ b/dlls/crypt32/tests/msg.c
@@ -268,7 +268,7 @@ static void check_param(LPCSTR test, HCR
     LPBYTE buf;
     BOOL ret;
 
-    size = 0;
+    size = 0xdeadbeef;
     ret = CryptMsgGetParam(msg, param, 0, NULL, &size);
     ok(ret, "%s: CryptMsgGetParam failed: %08x\n", test, GetLastError());
     buf = HeapAlloc(GetProcessHeap(), 0, size);
@@ -276,7 +276,7 @@ static void check_param(LPCSTR test, HCR
     ok(ret, "%s: CryptMsgGetParam failed: %08x\n", test, GetLastError());
     ok(size == expectedSize, "%s: expected size %d, got %d\n", test,
      expectedSize, size);
-    if (size)
+    if (size == expectedSize && size)
         ok(!memcmp(buf, expected, size), "%s: unexpected data\n", test);
     HeapFree(GetProcessHeap(), 0, buf);
 }
@@ -1201,9 +1201,49 @@ static void test_decode_msg_update(void)
     CryptMsgClose(msg);
 }
 
+static const BYTE hashParam[] = { 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;
+    BOOL ret;
+
+    msg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING, 0, 0, 0, NULL, NULL);
+    ret = CryptMsgUpdate(msg, dataContent, sizeof(dataContent), TRUE);
+    todo_wine
+    check_param("data content", msg, CMSG_CONTENT_PARAM, msgData,
+     sizeof(msgData));
+    CryptMsgClose(msg);
+
+    msg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING, 0, 0, 0, NULL, NULL);
+    ret = CryptMsgUpdate(msg, hashEmptyContent, sizeof(hashEmptyContent), TRUE);
+    todo_wine
+    check_param("empty hash content", msg, CMSG_CONTENT_PARAM, NULL, 0);
+    todo_wine
+    check_param("empty hash hash data", msg, CMSG_HASH_DATA_PARAM, NULL, 0);
+    todo_wine
+    check_param("empty hash computed hash", msg, CMSG_COMPUTED_HASH_PARAM,
+     emptyHashParam, sizeof(emptyHashParam));
+    CryptMsgClose(msg);
+    msg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING, 0, 0, 0, NULL, NULL);
+    ret = CryptMsgUpdate(msg, hashContent, sizeof(hashContent), TRUE);
+    todo_wine
+    check_param("hash content", msg, CMSG_CONTENT_PARAM, msgData,
+     sizeof(msgData));
+    todo_wine
+    check_param("hash hash data", msg, CMSG_HASH_DATA_PARAM, hashParam,
+     sizeof(hashParam));
+    todo_wine
+    check_param("hash computed hash", msg, CMSG_COMPUTED_HASH_PARAM,
+     hashParam, sizeof(hashParam));
+    CryptMsgClose(msg);
+}
+
 static void test_decode_msg(void)
 {
     test_decode_msg_update();
+    test_decode_msg_get_param();
 }
 
 START_TEST(msg)
-- 
1.4.1


More information about the wine-patches mailing list