From fe67eb715426dbd5bb72d133b8d708f3042f1199 Mon Sep 17 00:00:00 2001 From: Maxim Mamontov Date: Thu, 26 Jun 2014 16:24:21 +0300 Subject: [PATCH 1/1] Always think about \0 and block boundry during encryption. --- tests/test_crypto.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tests/test_crypto.cpp b/tests/test_crypto.cpp index 47dbcbb4..f95ecdb0 100644 --- a/tests/test_crypto.cpp +++ b/tests/test_crypto.cpp @@ -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)); } } -- 2.44.2