mirror of
https://github.com/oxen-io/lokinet.git
synced 2024-11-17 15:25:35 +00:00
b597ae5a94
- Get rid of CryptoManager. - Get rid of Crypto. - Move all the Crypto instance methods to llarp::crypto functions. (None of them needed to be methods at all, so this is simple). - Move sodium/ntru initialization into static initialization. - Add llarp::csrng, which is an available llarp::CSRNG instance which is a bit easier than needing to construct a `CSRNG rng{};` in various places. - Various related small simplifications/cleanups.
32 lines
678 B
C++
32 lines
678 B
C++
#include <llarp/exit/exit_messages.hpp>
|
|
#include <llarp/crypto/crypto.hpp>
|
|
#include <llarp/crypto/crypto_libsodium.hpp>
|
|
|
|
#include <catch2/catch.hpp>
|
|
|
|
using namespace ::llarp;
|
|
using namespace ::llarp::test;
|
|
|
|
using ObtainExitMessage = routing::ObtainExitMessage;
|
|
|
|
void
|
|
fill(Signature& s)
|
|
{
|
|
s.Fill(0xFF);
|
|
}
|
|
|
|
TEST_CASE("Sign-verify")
|
|
{
|
|
SecretKey alice{};
|
|
crypto::identity_keygen(alice);
|
|
REQUIRE(not alice.IsZero());
|
|
ObtainExitMessage msg{};
|
|
msg.S = randint();
|
|
msg.T = randint();
|
|
CHECK(msg.Sign(alice));
|
|
CHECK(msg.Verify());
|
|
CHECK(msg.I == PubKey{seckey_topublic(alice)});
|
|
CHECK(msg.version == llarp::constants::proto_version);
|
|
CHECK_FALSE(msg.Z.IsZero());
|
|
}
|