Juan Lang : crypt32: Add tests for verifying the hash of a detached hash message.
Alexandre Julliard
julliard at winehq.org
Wed Aug 27 08:24:09 CDT 2008
Module: wine
Branch: master
Commit: 9db120d0153b109c36015c70dbea7e64fc5b7df7
URL: http://source.winehq.org/git/wine.git/?a=commit;h=9db120d0153b109c36015c70dbea7e64fc5b7df7
Author: Juan Lang <juan.lang at gmail.com>
Date: Wed Aug 20 13:12:59 2008 -0700
crypt32: Add tests for verifying the hash of a detached hash message.
---
dlls/crypt32/tests/msg.c | 47 ++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 47 insertions(+), 0 deletions(-)
diff --git a/dlls/crypt32/tests/msg.c b/dlls/crypt32/tests/msg.c
index ba35b89..8cab0eb 100644
--- a/dlls/crypt32/tests/msg.c
+++ b/dlls/crypt32/tests/msg.c
@@ -2675,6 +2675,53 @@ static void test_msg_control(void)
"Expected CRYPT_E_INVALID_MSG_TYPE, got %08x\n", GetLastError());
CryptMsgClose(msg);
+ msg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING, CMSG_DETACHED_FLAG, 0, 0,
+ NULL, NULL);
+ /* Can't verify the hash of a detached message before it's been updated. */
+ SetLastError(0xdeadbeef);
+ ret = CryptMsgControl(msg, 0, CMSG_CTRL_VERIFY_HASH, NULL);
+ ok(!ret && GetLastError() == CRYPT_E_INVALID_MSG_TYPE,
+ "Expected CRYPT_E_INVALID_MSG_TYPE, got %08x\n", GetLastError());
+ ret = CryptMsgUpdate(msg, detachedHashContent, sizeof(detachedHashContent),
+ TRUE);
+ ok(ret, "CryptMsgUpdate failed: %08x\n", GetLastError());
+ /* Still can't verify the hash of a detached message with the content
+ * of the detached hash given..
+ */
+ SetLastError(0xdeadbeef);
+ ret = CryptMsgControl(msg, 0, CMSG_CTRL_VERIFY_HASH, NULL);
+ todo_wine
+ ok(!ret && GetLastError() == CRYPT_E_HASH_VALUE,
+ "Expected CRYPT_E_HASH_VALUE, got %08x\n", GetLastError());
+ /* and giving the content of the message after attempting to verify the
+ * hash fails.
+ */
+ SetLastError(0xdeadbeef);
+ ret = CryptMsgUpdate(msg, msgData, sizeof(msgData), TRUE);
+ todo_wine
+ ok(!ret && GetLastError() == NTE_BAD_HASH_STATE,
+ "Expected NTE_BAD_HASH_STATE, got %08x\n", GetLastError());
+ CryptMsgClose(msg);
+
+ /* Finally, verifying the hash of a detached message in the correct order:
+ * 1. Update with the detached hash message
+ * 2. Update with the content of the message
+ * 3. Verifying the hash of the message
+ * succeeds.
+ */
+ msg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING, CMSG_DETACHED_FLAG, 0, 0,
+ NULL, NULL);
+ ret = CryptMsgUpdate(msg, detachedHashContent, sizeof(detachedHashContent),
+ TRUE);
+ ok(ret, "CryptMsgUpdate failed: %08x\n", GetLastError());
+ ret = CryptMsgUpdate(msg, msgData, sizeof(msgData), TRUE);
+ ok(ret, "CryptMsgUpdate failed: %08x\n", GetLastError());
+ SetLastError(0xdeadbeef);
+ ret = CryptMsgControl(msg, 0, CMSG_CTRL_VERIFY_HASH, NULL);
+ todo_wine
+ ok(ret, "CryptMsgControl failed: %08x\n", GetLastError());
+ CryptMsgClose(msg);
+
msg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING, 0, CMSG_SIGNED, 0, NULL,
NULL);
/* Can't verify the hash of a signed message */
More information about the wine-cvs
mailing list