#include #include #include #include #include bool correctness_test() { std::string key = "demokey"; uint8_t ik[32]{}; hash(key.c_str(), ik); int offset = 16; char* msg = new char[256]{}; std::shared_ptr deleter(new int(), [msg](int* p) { delete p; delete[] msg; }); char source[] = "hello world"; memset(msg, 0, 256); auto len = std::snprintf(msg + offset, 256 - offset, "%s", source); if (!encrypt(ik, (uint8_t*)msg, len + offset)) { return false; } uint8_t ik2[32]{}; hash(key.c_str(), ik2); if (!decrypt(ik2, (uint8_t*)msg, len + offset)) { return false; } return std::memcmp(source, msg + offset, len) == 0; } TEST_CASE("transm encry part", "[encry]") { SECTION("correctness of encryption") { REQUIRE(correctness_test() == true); } }