From 96469ee44afb7a31157d1653c172fc11f47d675c Mon Sep 17 00:00:00 2001 From: dec05eba Date: Wed, 25 Apr 2018 05:29:43 +0200 Subject: Store opendht identity in storage file (cached) --- tests/main.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'tests') diff --git a/tests/main.cpp b/tests/main.cpp index d509972..3f23b32 100644 --- a/tests/main.cpp +++ b/tests/main.cpp @@ -11,6 +11,7 @@ #include #include #include +#include using namespace std; using namespace chrono_literals; @@ -108,9 +109,30 @@ void testEncryption() assertEquals(0, strncmp(message, (const char*)decryption.getDecryptedText().data, messageLength)); } +void testCachedIdentity() +{ + pair, shared_ptr> identity = dht::crypto::generateIdentity(); + dht::Blob privateKeyData = identity.first->serialize(); + printf("Private key size: %d, serialized data: %s\n", privateKeyData.size(), Hash(privateKeyData.data(), privateKeyData.size()).toString().c_str()); + + dht::crypto::PrivateKey privateKeyDeserialized(privateKeyData); + privateKeyData = identity.first->serialize(); + printf("Private key size: %d, serialized data: %s\n", privateKeyData.size(), Hash(privateKeyData.data(), privateKeyData.size()).toString().c_str()); + + dht::Blob certificateData; + identity.second->pack(certificateData); + printf("Certificate data size: %d, serialized data: %s\n", certificateData.size(), Hash(certificateData.data(), certificateData.size()).toString().c_str()); + + dht::crypto::Certificate certificateDeserialized(certificateData); + certificateData.clear(); + identity.second->pack(certificateData); + printf("Certificate data size: %d, serialized data: %s\n", certificateData.size(), Hash(certificateData.data(), certificateData.size()).toString().c_str()); +} + int main() { Log::debug("Starting tests..."); + testCachedIdentity(); testBinHexConvert(); testHash(); testEncryption(); -- cgit v1.2.3