2019-06-15 14:55:14 +00:00
|
|
|
#include <exit/exit_messages.hpp>
|
2018-12-12 02:52:51 +00:00
|
|
|
|
2019-01-13 16:30:07 +00:00
|
|
|
#include <crypto/crypto.hpp>
|
2019-01-26 15:40:58 +00:00
|
|
|
#include <crypto/crypto_libsodium.hpp>
|
2019-05-28 19:45:09 +00:00
|
|
|
#include <llarp_test.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);
|
|
|
|
}
|
|
|
|
|
2021-03-01 21:07:32 +00:00
|
|
|
TEST_CASE_METHOD(LlarpTest<>, "Sign-verify")
|
2018-11-12 16:43:40 +00:00
|
|
|
{
|
2021-03-03 13:33:20 +00:00
|
|
|
SecretKey alice{};
|
|
|
|
CryptoManager::instance()->identity_keygen(alice);
|
|
|
|
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
|
|
|
}
|