From 06c2ea4465bc479a8d0377bc5a67b281d8845e29 Mon Sep 17 00:00:00 2001 From: Othmar Gsenger Date: Fri, 6 Feb 2015 20:29:36 +0000 Subject: added unit test for new crypt implementation --- src/unittest.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'src/unittest.cpp') diff --git a/src/unittest.cpp b/src/unittest.cpp index c0ba410..1358ad4 100644 --- a/src/unittest.cpp +++ b/src/unittest.cpp @@ -96,6 +96,7 @@ #include "cryptinit.hpp" #include "crypto/interface.h" +#include "crypto/openssl.h" #include "sysExec.h" @@ -162,6 +163,22 @@ void testCrypt() exit(-1); } std::cout << STR_PASSED << "role RIGHT inbound can decrypt role LEFT's outbound packets"<< STR_END; + + memset(plain_packet.getPayload(), 0, sizeof(test)); + std::auto_ptr cnew(new crypto::Openssl()); + Buffer masterkey(crypto::SALT_LENGTH, false); + Buffer mastersalt(crypto::SALT_LENGTH, false); + cnew->calcMasterKeySalt("abc", crypto::SALT_LENGTH, masterkey , mastersalt); + cnew->decrypt(encrypted_packet, plain_packet, masterkey, mastersalt, ROLE_RIGHT ); + if (memcmp(plain_packet.getPayload(), test, sizeof(test))) { + std::cerr << "crypto test failed" << std::endl; + std::cout << test << std::endl; + ssize_t len = write(0, plain_packet.getPayload(), plain_packet.getLength()); + if (len) + len++; // fix unused varable + exit(-1); + } + std::cout << STR_PASSED << "new role RIGHT inbound can decrypt old role LEFT's outbound packets"<< STR_END; } -- cgit v1.2.3