crypt32(1/9): Test getting the hash from a hash message with an
invalid index
Juan Lang
juan.lang at gmail.com
Wed Jul 25 20:16:37 CDT 2007
--Juan
-------------- next part --------------
From 63e363f437ec6f85c42bf9ba6148c9cc0897f6e4 Mon Sep 17 00:00:00 2001
From: Juan Lang <juanlang at juan.corp.google.com>
Date: Wed, 25 Jul 2007 18:08:58 -0700
Subject: [PATCH] Test getting the hash from a hash message with an invalid index
---
dlls/crypt32/tests/msg.c | 15 ++++++++++++++-
1 files changed, 14 insertions(+), 1 deletions(-)
diff --git a/dlls/crypt32/tests/msg.c b/dlls/crypt32/tests/msg.c
index 3bd0882..f65c7f8 100644
--- a/dlls/crypt32/tests/msg.c
+++ b/dlls/crypt32/tests/msg.c
@@ -1853,6 +1853,7 @@ static void test_decode_msg_get_param(vo
HCRYPTMSG msg;
BOOL ret;
DWORD size = 0, version;
+ LPBYTE buf;
msg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING, 0, 0, 0, NULL, NULL);
SetLastError(0xdeadbeef);
@@ -1879,7 +1880,19 @@ static void test_decode_msg_get_param(vo
sizeof(hashParam));
check_param("hash computed hash", msg, CMSG_COMPUTED_HASH_PARAM,
hashParam, sizeof(hashParam));
- size = strlen(szOID_RSA_data) + 1;
+ /* Curiously, getting the hash of index 1 succeeds, even though there's
+ * only one hash.
+ */
+ ret = CryptMsgGetParam(msg, CMSG_COMPUTED_HASH_PARAM, 1, NULL, &size);
+ ok(ret, "CryptMsgGetParam failed: %08x\n", GetLastError());
+ buf = CryptMemAlloc(size);
+ if (buf)
+ {
+ ret = CryptMsgGetParam(msg, CMSG_COMPUTED_HASH_PARAM, 1, buf, &size);
+ ok(size == sizeof(hashParam), "Unexpected size %d\n", size);
+ ok(!memcmp(buf, hashParam, size), "Unexpected value\n");
+ CryptMemFree(buf);
+ }
check_param("hash inner OID", msg, CMSG_INNER_CONTENT_TYPE_PARAM,
(const BYTE *)szOID_RSA_data, strlen(szOID_RSA_data) + 1);
version = CMSG_HASHED_DATA_V0;
--
1.4.1
More information about the wine-patches
mailing list