X-Git-Url: https://git.stg.codes/stg.git/blobdiff_plain/19b50f3bd82ecc7ee07067b76a697d559b18a8f1..0d6d9ba8a9c8512a0e1fd66a398c61e656644516:/tests/test_crypto.cpp diff --git a/tests/test_crypto.cpp b/tests/test_crypto.cpp index f95ecdb0..8db8ab72 100644 --- a/tests/test_crypto.cpp +++ b/tests/test_crypto.cpp @@ -431,4 +431,40 @@ namespace tut ensure_equals("DecryptString(EncryptString(longTest)) == longTest", source, std::string(longTest)); } + template<> + template<> + void testobject::test<8>() + { + set_test_name("Check old string encryption"); + + BLOWFISH_CTX ctx; + InitContext("123456", 7, &ctx); + const unsigned char source[] = {0xe9, 0xfe, 0xcb, 0xc5, 0xad, 0x3e, 0x87, 0x39, + 0x3d, 0xd5, 0xf4, 0xed, 0xb0, 0x15, 0xe6, 0xcb, + 0x3d, 0xd5, 0xf4, 0xed, 0xb0, 0x15, 0xe6, 0xcb, + 0x3d, 0xd5, 0xf4, 0xed, 0xb0, 0x15, 0xe6, 0xcb}; + char res[32]; + DecryptString(res, source, 32, &ctx); + + ensure_equals("DecryptString(...) == 'admin'", std::string(res), "admin"); + } + + template<> + template<> + void testobject::test<9>() + { + set_test_name("Check new string encryption"); + + BLOWFISH_CTX ctx; + InitContext("123456", 7, &ctx); + const unsigned char source[] = {0xe9, 0xfe, 0xcb, 0xc5, 0xad, 0x3e, 0x87, 0x39, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; + char res[32]; + DecryptString(res, source, 32, &ctx); + + ensure_equals("DecryptString(...) == 'admin'", std::string(res), "admin"); + } + }