]> git.stg.codes - stg.git/commitdiff
Always think about \0 and block boundry during encryption.
authorMaxim Mamontov <faust@stg.dp.ua>
Thu, 26 Jun 2014 13:24:21 +0000 (16:24 +0300)
committerMaxim Mamontov <faust.madf@gmail.com>
Fri, 9 Jan 2015 20:48:54 +0000 (22:48 +0200)
tests/test_crypto.cpp

index 47dbcbb4361daa0b1341882da7e39f7290433573..f95ecdb0d006f6f8cd61eeea880fb590ab5d79e9 100644 (file)
@@ -423,11 +423,12 @@ namespace tut
 
         BLOWFISH_CTX ctx;
         InitContext("pr7Hhen", 7, &ctx);
-        char longTest[] = "abcdefghijklmnopqrstuvwxyz 0123456789 ABCDEFGHIJKLMNOPQRSTUVWXYZ";
-        EncryptString(longTest, longTest, sizeof(longTest), &ctx);
+        std::string source("abcdefghijklmnopqrstuvwxyz 0123456789 ABCDEFGHIJKLMNOPQRSTUVWXYZ");
+        char longTest[source.length() + 8];
+        EncryptString(longTest, source.c_str(), source.length() + 1, &ctx);
         DecryptString(longTest, longTest, sizeof(longTest), &ctx);
 
-        ensure("DecryptString(EncryptString(longTest)) == longTest", equalString(longTest, "abcdefghijklmnopqrstuvwxyz 0123456789 ABCDEFGHIJKLMNOPQRSTUVWXYZ", sizeof(longTest)));
+        ensure_equals("DecryptString(EncryptString(longTest)) == longTest", source, std::string(longTest));
     }
 
 }