crypt32(2/10): Add more tests for opening a data message for encoding

Juan Lang juan.lang at gmail.com
Mon Jul 9 13:49:11 CDT 2007


--Juan
-------------- next part --------------
From 32c04330d6f58a71bff73c125272c071691bbccb Mon Sep 17 00:00:00 2001
From: Juan Lang <juanlang at juan.corp.google.com>
Date: Mon, 9 Jul 2007 10:55:00 -0700
Subject: [PATCH] Add more tests for opening a data message for encoding
---
 dlls/crypt32/tests/msg.c |   26 ++++++++++++++++++++++++++
 1 files changed, 26 insertions(+), 0 deletions(-)

diff --git a/dlls/crypt32/tests/msg.c b/dlls/crypt32/tests/msg.c
index 16ab7f6..e688d70 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 };
-- 
1.4.1


More information about the wine-patches mailing list