Bruno Jesus : dssenh/tests: Add tests for the default encryption chaining mode.

Alexandre Julliard julliard at wine.codeweavers.com
Mon Jun 30 15:30:20 CDT 2014


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

Author: Bruno Jesus <00cpxxx at gmail.com>
Date:   Sun Jun 29 17:20:30 2014 -0300

dssenh/tests: Add tests for the default encryption chaining mode.

---

 dlls/dssenh/tests/dssenh.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/dlls/dssenh/tests/dssenh.c b/dlls/dssenh/tests/dssenh.c
index 75c4e4c..8b83586 100644
--- a/dlls/dssenh/tests/dssenh.c
+++ b/dlls/dssenh/tests/dssenh.c
@@ -704,6 +704,27 @@ static void test_cipher_modes(const struct ciphermode_test *tests, int testLen)
     result = CryptDestroyHash(hHash);
     ok(result, "Expected destruction of hash after deriving key.\n");
 
+    /* the default algorithm is CBC, test that without setting a mode */
+    mode = 0xdeadbeef;
+    dataLen = sizeof(mode);
+    result = CryptGetKeyParam(pKey, KP_MODE, (BYTE*)&mode, &dataLen, 0);
+    ok(result, "Expected getting of KP_MODE, got %x.\n", GetLastError());
+    ok(mode == CRYPT_MODE_CBC, "Default mode should be CBC\n");
+
+    memcpy(pbData, plainText, plainLen);
+    dataLen = plainLen;
+    result = CryptEncrypt(pKey, 0, TRUE, 0, pbData, &dataLen, 36);
+    ok(result, "Expected data encryption, got %x.\n", GetLastError());
+
+    /* Verify we have the correct encrypted data */
+    ok(!memcmp(pbData, tests[1].encrypted, dataLen), "Incorrect encrypted data.\n");
+
+    result = CryptDecrypt(pKey, 0, TRUE, 0, pbData, &dataLen);
+    ok(result, "Expected data decryption, got %x.\n", GetLastError());
+
+    /* Verify we have the correct decrypted data */
+    ok(!memcmp(pbData, (BYTE *)plainText, dataLen), "Incorrect decrypted data.\n");
+
     /* test block cipher modes */
     for(i = 0; i < testLen; i++)
     {




More information about the wine-cvs mailing list