Juan Lang : crypt32: Add tests for opening non-detached signed
messages, and clarify detached open.
Alexandre Julliard
julliard at wine.codeweavers.com
Tue Jul 24 07:06:10 CDT 2007
Module: wine
Branch: master
Commit: 19e63d900484fe49fddbaf02cb872b7a60709a07
URL: http://source.winehq.org/git/wine.git/?a=commit;h=19e63d900484fe49fddbaf02cb872b7a60709a07
Author: Juan Lang <juan.lang at gmail.com>
Date: Mon Jul 23 17:34:14 2007 -0700
crypt32: Add tests for opening non-detached signed messages, and clarify detached open.
---
dlls/crypt32/tests/msg.c | 28 ++++++++++++++++++++++++----
1 files changed, 24 insertions(+), 4 deletions(-)
diff --git a/dlls/crypt32/tests/msg.c b/dlls/crypt32/tests/msg.c
index 94864c1..44c3098 100644
--- a/dlls/crypt32/tests/msg.c
+++ b/dlls/crypt32/tests/msg.c
@@ -1110,10 +1110,10 @@ static void test_signed_msg_update(void)
msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING,
CMSG_DETACHED_FLAG, CMSG_SIGNED, &signInfo, NULL, NULL);
ok(msg != NULL, "CryptMsgOpenToEncode failed: %x\n", GetLastError());
- /* CMSG_SIGNED allows non-final updates. */
+ /* Detached CMSG_SIGNED allows non-final updates. */
ret = CryptMsgUpdate(msg, msgData, sizeof(msgData), FALSE);
ok(ret, "CryptMsgUpdate failed: %x\n", GetLastError());
- /* CMSG_SIGNED also allows non-final updates with no data. */
+ /* Detached CMSG_SIGNED also allows non-final updates with no data. */
ret = CryptMsgUpdate(msg, NULL, 0, FALSE);
ok(ret, "CryptMsgUpdate failed: %x\n", GetLastError());
/* The final update requires a private key in the hCryptProv, in order to
@@ -1139,10 +1139,10 @@ static void test_signed_msg_update(void)
msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING,
CMSG_DETACHED_FLAG, CMSG_SIGNED, &signInfo, NULL, NULL);
ok(msg != NULL, "CryptMsgOpenToEncode failed: %x\n", GetLastError());
- /* CMSG_SIGNED allows non-final updates. */
+ /* Detached CMSG_SIGNED allows non-final updates. */
ret = CryptMsgUpdate(msg, msgData, sizeof(msgData), FALSE);
ok(ret, "CryptMsgUpdate failed: %x\n", GetLastError());
- /* CMSG_SIGNED also allows non-final updates with no data. */
+ /* Detached CMSG_SIGNED also allows non-final updates with no data. */
ret = CryptMsgUpdate(msg, NULL, 0, FALSE);
ok(ret, "CryptMsgUpdate failed: %x\n", GetLastError());
/* Now that the private key exists, the final update can succeed (even
@@ -1161,6 +1161,26 @@ static void test_signed_msg_update(void)
"Expected CRYPT_E_MSG_ERROR, got %x\n", GetLastError());
CryptMsgClose(msg);
+ msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_SIGNED, &signInfo,
+ NULL, NULL);
+ ok(msg != NULL, "CryptMsgOpenToEncode failed: %x\n", GetLastError());
+ /* Non-detached messages don't allow non-final updates.. */
+ SetLastError(0xdeadbeef);
+ ret = CryptMsgUpdate(msg, msgData, sizeof(msgData), FALSE);
+ ok(!ret && GetLastError() == CRYPT_E_MSG_ERROR,
+ "Expected CRYPT_E_MSG_ERROR, got %x\n", GetLastError());
+ /* but they do allow final ones. */
+ ret = CryptMsgUpdate(msg, msgData, sizeof(msgData), TRUE);
+ ok(ret, "CryptMsgUpdate failed: %08x\n", GetLastError());
+ CryptMsgClose(msg);
+ msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_SIGNED, &signInfo,
+ NULL, NULL);
+ ok(msg != NULL, "CryptMsgOpenToEncode failed: %x\n", GetLastError());
+ /* They also allow final updates with no data. */
+ ret = CryptMsgUpdate(msg, NULL, 0, TRUE);
+ ok(ret, "CryptMsgUpdate failed: %08x\n", GetLastError());
+ CryptMsgClose(msg);
+
CryptDestroyKey(key);
CryptReleaseContext(signer.hCryptProv, 0);
CryptAcquireContextW(&signer.hCryptProv, cspNameW, NULL, PROV_RSA_FULL,
More information about the wine-cvs
mailing list