diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/main.cpp | 22 |
1 files changed, 22 insertions, 0 deletions
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 <vector> #include <chrono> #include <thread> +#include <opendht.h> 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<dht::crypto::PrivateKey>, shared_ptr<dht::crypto::Certificate>> 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(); |