summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOthmar Gsenger <otti@anytun.org>2015-02-06 20:29:36 +0000
committerOthmar Gsenger <otti@anytun.org>2015-02-06 20:29:36 +0000
commit06c2ea4465bc479a8d0377bc5a67b281d8845e29 (patch)
treefdad02058d62bf956c42b8d139c40bdfa303c8de
parentupdated unittests (diff)
added unit test for new crypt implementation
-rw-r--r--src/crypto/openssl.h2
-rw-r--r--src/unittest.cpp17
2 files changed, 18 insertions, 1 deletions
diff --git a/src/crypto/openssl.h b/src/crypto/openssl.h
index 956be99..35a2d26 100644
--- a/src/crypto/openssl.h
+++ b/src/crypto/openssl.h
@@ -50,7 +50,7 @@
namespace crypto {
- class Openssl : Interface
+ class Openssl : public Interface
{
public:
// pure virtual
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<crypto::Interface> 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;
}