2023-01-09 17:47:41 +00:00
|
|
|
#include <llarp/exit/exit_messages.hpp>
|
|
|
|
#include <llarp/crypto/crypto.hpp>
|
|
|
|
#include <llarp/crypto/crypto_libsodium.hpp>
|
2019-01-26 15:40:58 +00:00
|
|
|
|
2021-03-01 21:07:32 +00:00
|
|
|
#include <catch2/catch.hpp>
|
|
|
|
|
2019-05-28 19:45:09 +00:00
|
|
|
using namespace ::llarp;
|
2021-03-01 21:07:32 +00:00
|
|
|
using namespace ::llarp::test;
|
2018-11-12 16:43:40 +00:00
|
|
|
|
2019-05-28 19:45:09 +00:00
|
|
|
using ObtainExitMessage = routing::ObtainExitMessage;
|
|
|
|
|
|
|
|
void
|
|
|
|
fill(Signature& s)
|
|
|
|
{
|
|
|
|
s.Fill(0xFF);
|
|
|
|
}
|
|
|
|
|
2023-10-19 23:09:22 +00:00
|
|
|
TEST_CASE("Sign-verify")
|
2018-11-12 16:43:40 +00:00
|
|
|
{
|
2021-03-03 13:33:20 +00:00
|
|
|
SecretKey alice{};
|
2023-10-19 23:09:22 +00:00
|
|
|
crypto::identity_keygen(alice);
|
2021-03-03 13:33:20 +00:00
|
|
|
REQUIRE(not alice.IsZero());
|
|
|
|
ObtainExitMessage msg{};
|
2019-05-28 19:45:09 +00:00
|
|
|
msg.S = randint();
|
|
|
|
msg.T = randint();
|
2021-03-01 21:07:32 +00:00
|
|
|
CHECK(msg.Sign(alice));
|
|
|
|
CHECK(msg.Verify());
|
2021-03-03 13:33:20 +00:00
|
|
|
CHECK(msg.I == PubKey{seckey_topublic(alice)});
|
2022-05-26 15:59:44 +00:00
|
|
|
CHECK(msg.version == llarp::constants::proto_version);
|
2021-03-01 21:07:32 +00:00
|
|
|
CHECK_FALSE(msg.Z.IsZero());
|
2019-04-25 23:21:19 +00:00
|
|
|
}
|