crypt32(6/17): Test CryptMsgUpdate for data messages opened to
encode
Juan Lang
juan.lang at gmail.com
Thu Jun 28 19:28:45 CDT 2007
--Juan
-------------- next part --------------
From 4267ac7458a6faf90d88a1f01e615738e091b925 Mon Sep 17 00:00:00 2001
From: Juan Lang <juanlang at juan.corp.google.com>
Date: Thu, 28 Jun 2007 16:46:33 -0700
Subject: [PATCH] Test CryptMsgUpdate for data messages opened to encode
---
dlls/crypt32/tests/msg.c | 62 ++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 62 insertions(+), 0 deletions(-)
diff --git a/dlls/crypt32/tests/msg.c b/dlls/crypt32/tests/msg.c
index 8bebdb9..2b0b3fe 100644
--- a/dlls/crypt32/tests/msg.c
+++ b/dlls/crypt32/tests/msg.c
@@ -300,9 +300,71 @@ static void test_data_msg_open(void)
CryptMsgClose(msg);
}
+static const BYTE msgData[] = { 1, 2, 3, 4 };
+
+static void test_data_msg_update(void)
+{
+ HCRYPTMSG msg;
+ BOOL ret;
+
+ msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_DATA, NULL, NULL,
+ NULL);
+ /* Can't update a message that wasn't opened detached with final = FALSE */
+ SetLastError(0xdeadbeef);
+ ret = CryptMsgUpdate(msg, NULL, 0, FALSE);
+ todo_wine
+ ok(!ret && GetLastError() == CRYPT_E_MSG_ERROR,
+ "Expected CRYPT_E_MSG_ERROR, got %x\n", GetLastError());
+ /* Updating it with final = TRUE succeeds */
+ ret = CryptMsgUpdate(msg, msgData, sizeof(msgData), TRUE);
+ ok(ret, "CryptMsgUpdate failed: %x\n", GetLastError());
+ /* Any subsequent update will fail, as the last was final */
+ SetLastError(0xdeadbeef);
+ ret = CryptMsgUpdate(msg, msgData, sizeof(msgData), TRUE);
+ todo_wine
+ ok(!ret && GetLastError() == CRYPT_E_MSG_ERROR,
+ "Expected CRYPT_E_MSG_ERROR, got %x\n", GetLastError());
+ CryptMsgClose(msg);
+
+ msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_DATA, NULL, NULL,
+ NULL);
+ /* Can't update a message with no data */
+ SetLastError(0xdeadbeef);
+ ret = CryptMsgUpdate(msg, NULL, 0, TRUE);
+ todo_wine {
+ ok(!ret && GetLastError() == E_INVALIDARG,
+ "Expected E_INVALIDARG, got %x\n", GetLastError());
+ /* Curiously, a valid update will now fail as well, presumably because of
+ * the last (invalid, but final) update.
+ */
+ ret = CryptMsgUpdate(msg, msgData, sizeof(msgData), TRUE);
+ ok(!ret && GetLastError() == CRYPT_E_MSG_ERROR,
+ "Expected CRYPT_E_MSG_ERROR, got %x\n", GetLastError());
+ }
+ CryptMsgClose(msg);
+
+ msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, CMSG_DETACHED_FLAG,
+ CMSG_DATA, NULL, NULL, NULL);
+ /* Dont appear to be able to update CMSG-DATA with non-final updates */
+ SetLastError(0xdeadbeef);
+ ret = CryptMsgUpdate(msg, NULL, 0, FALSE);
+ todo_wine
+ ok(!ret && GetLastError() == E_INVALIDARG,
+ "Expected E_INVALIDARG, got %x\n", GetLastError());
+ SetLastError(0xdeadbeef);
+ ret = CryptMsgUpdate(msg, msgData, sizeof(msgData), FALSE);
+ todo_wine
+ ok(!ret && GetLastError() == E_INVALIDARG,
+ "Expected E_INVALIDARG, got %x\n", GetLastError());
+ ret = CryptMsgUpdate(msg, msgData, sizeof(msgData), TRUE);
+ ok(ret, "CryptMsgUpdate failed: %x\n", GetLastError());
+ CryptMsgClose(msg);
+}
+
static void test_data_msg(void)
{
test_data_msg_open();
+ test_data_msg_update();
}
START_TEST(msg)
--
1.4.1
More information about the wine-patches
mailing list