From fd05fe0d132a503b00aebd263aab46e63ddcfaa7 Mon Sep 17 00:00:00 2001 From: Juan Lang Date: Mon, 9 Jul 2007 10:55:00 -0700 Subject: [PATCH] crypt32: Add more tests for opening a data message for encoding. --- dlls/crypt32/tests/msg.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/dlls/crypt32/tests/msg.c b/dlls/crypt32/tests/msg.c index 20b52ad35e3..96489bc37ea 100644 --- a/dlls/crypt32/tests/msg.c +++ b/dlls/crypt32/tests/msg.c @@ -304,6 +304,8 @@ static void test_data_msg_open(void) { HCRYPTMSG msg; CMSG_HASHED_ENCODE_INFO hashInfo = { 0 }; + CMSG_STREAM_INFO streamInfo = { 0 }; + char oid[] = "1.2.3"; /* The data message type takes no additional info */ SetLastError(0xdeadbeef); @@ -315,6 +317,30 @@ static void test_data_msg_open(void) NULL); ok(msg != NULL, "CryptMsgOpenToEncode failed: %x\n", GetLastError()); CryptMsgClose(msg); + + /* An empty stream info is allowed. */ + msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_DATA, NULL, NULL, + &streamInfo); + ok(msg != NULL, "CryptMsgOpenToEncode failed: %x\n", GetLastError()); + CryptMsgClose(msg); + + /* Passing a bogus inner OID succeeds for a non-streamed message.. */ + msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_DATA, NULL, oid, + NULL); + ok(msg != NULL, "CryptMsgOpenToEncode failed: %x\n", GetLastError()); + CryptMsgClose(msg); + /* and still succeeds when CMSG_DETACHED_FLAG is passed.. */ + msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, CMSG_DETACHED_FLAG, + CMSG_DATA, NULL, oid, NULL); + ok(msg != NULL, "CryptMsgOpenToEncode failed: %x\n", GetLastError()); + CryptMsgClose(msg); + /* and when a stream info is given, even though you're not supposed to be + * able to use anything but szOID_RSA_data when streaming is being used. + */ + msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, CMSG_DETACHED_FLAG, + CMSG_DATA, NULL, oid, &streamInfo); + ok(msg != NULL, "CryptMsgOpenToEncode failed: %x\n", GetLastError()); + CryptMsgClose(msg); } static const BYTE msgData[] = { 1, 2, 3, 4 };