Dan Kegel : crypt32/tests: CryptUnprotectData: test zero-length payload.

Alexandre Julliard julliard at winehq.org
Wed Oct 28 10:12:24 CDT 2009


Module: wine
Branch: master
Commit: 5e25a234091dac615a5ea9bd5cf60335acb099e8
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=5e25a234091dac615a5ea9bd5cf60335acb099e8

Author: Dan Kegel <dank at kegel.com>
Date:   Tue Oct 27 18:40:31 2009 -0700

crypt32/tests: CryptUnprotectData: test zero-length payload.

---

 dlls/crypt32/tests/protectdata.c |   30 ++++++++++++++++++++++++++++++
 1 files changed, 30 insertions(+), 0 deletions(-)

diff --git a/dlls/crypt32/tests/protectdata.c b/dlls/crypt32/tests/protectdata.c
index 82cf1aa..08ab72a 100644
--- a/dlls/crypt32/tests/protectdata.c
+++ b/dlls/crypt32/tests/protectdata.c
@@ -213,6 +213,34 @@ static void test_cryptunprotectdata(void)
     plain.cbData=0;
 }
 
+static void test_simpleroundtrip(const char *plaintext, int wine_fails)
+{
+    DATA_BLOB input;
+    DATA_BLOB encrypted;
+    DATA_BLOB output;
+    int res;
+    WCHAR emptyW[1];
+
+    emptyW[0] = 0;
+    input.pbData = (unsigned char *)plaintext;
+    input.cbData = strlen(plaintext);
+    res = pCryptProtectData(&input, emptyW, NULL, NULL, NULL, 0, &encrypted);
+    ok(res != 0, "can't protect\n");
+
+    res = pCryptUnprotectData(&encrypted, NULL, NULL, NULL, NULL, 0, &output);
+    if (wine_fails) {
+      todo_wine
+        ok(res != 0, "can't unprotect; last error %u\n", GetLastError());
+    } else {
+      ok(res != 0, "can't unprotect; last error %u\n", GetLastError());
+    }
+
+    if (res) {
+      ok(output.cbData == strlen(plaintext), "output wrong length %d for input '%s', wanted %d\n", output.cbData, plaintext, strlen(plaintext));
+      ok(!memcmp(plaintext, (char *)output.pbData, output.cbData), "output wrong contents for input '%s'\n", plaintext);
+    }
+}
+
 START_TEST(protectdata)
 {
     HMODULE hCrypt32 = GetModuleHandleA("crypt32.dll");
@@ -228,6 +256,8 @@ START_TEST(protectdata)
     protected=FALSE;
     test_cryptprotectdata();
     test_cryptunprotectdata();
+    test_simpleroundtrip("", 1);
+    test_simpleroundtrip("hello", 0);
 
     /* deinit globals here */
     if (cipher.pbData) LocalFree(cipher.pbData);




More information about the wine-cvs mailing list