diff options
author | dec05eba <dec05eba@protonmail.com> | 2018-04-25 05:29:43 +0200 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2020-08-18 23:25:46 +0200 |
commit | 96469ee44afb7a31157d1653c172fc11f47d675c (patch) | |
tree | 0c77ff084882ffa689d67e5eaa175997d7b0d1e7 /tests | |
parent | c985ca6ccdf2ad6f21e3fbbada76030ddccb0fa0 (diff) |
Store opendht identity in storage file (cached)
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(); |