mirror of
https://github.com/oxen-io/lokinet.git
synced 2024-11-09 13:10:25 +00:00
40 lines
720 B
C++
40 lines
720 B
C++
|
#include <gtest/gtest.h>
|
||
|
#include <llarp/crypto.hpp>
|
||
|
#include <iostream>
|
||
|
|
||
|
namespace llarp
|
||
|
{
|
||
|
struct PQCryptoTest : public ::testing::Test
|
||
|
{
|
||
|
llarp_crypto crypto;
|
||
|
PQKeyPair keys;
|
||
|
|
||
|
PQCryptoTest()
|
||
|
{
|
||
|
llarp_crypto_libsodium_init(&crypto);
|
||
|
}
|
||
|
|
||
|
llarp_crypto * Crypto()
|
||
|
{
|
||
|
return &crypto;
|
||
|
}
|
||
|
|
||
|
void SetUp()
|
||
|
{
|
||
|
crypto.pqe_keygen(keys);
|
||
|
}
|
||
|
|
||
|
};
|
||
|
|
||
|
TEST_F(PQCryptoTest, TestCrypto)
|
||
|
{
|
||
|
PQCipherBlock block;
|
||
|
SharedSecret shared, otherShared;
|
||
|
auto c = Crypto();
|
||
|
|
||
|
ASSERT_TRUE(keys.size() == PQ_KEYPAIRSIZE);
|
||
|
ASSERT_TRUE(c->pqe_encrypt(block, shared, pq_keypair_to_public(keys)));
|
||
|
ASSERT_TRUE(c->pqe_decrypt(block, otherShared, pq_keypair_to_secret(keys)));
|
||
|
ASSERT_TRUE(otherShared == shared);
|
||
|
}
|
||
|
}
|