|
|
|
@ -24,48 +24,32 @@ namespace llarp
|
|
|
|
|
constexpr std::size_t MAX_INTROSET_SIZE = 4096;
|
|
|
|
|
// 10 seconds clock skew permitted for introset expiration
|
|
|
|
|
constexpr llarp_time_t MAX_INTROSET_TIME_DELTA = (10 * 1000);
|
|
|
|
|
struct IntroSet final : public llarp::IBEncodeMessage
|
|
|
|
|
struct IntroSet final : public IBEncodeMessage
|
|
|
|
|
{
|
|
|
|
|
util::StatusObject
|
|
|
|
|
ExtractStatus() const;
|
|
|
|
|
|
|
|
|
|
ServiceInfo A;
|
|
|
|
|
std::vector< Introduction > I;
|
|
|
|
|
PQPubKey K;
|
|
|
|
|
Tag topic;
|
|
|
|
|
llarp_time_t T = 0;
|
|
|
|
|
llarp::PoW* W = nullptr;
|
|
|
|
|
llarp::Signature Z;
|
|
|
|
|
std::unique_ptr< PoW > W;
|
|
|
|
|
Signature Z;
|
|
|
|
|
|
|
|
|
|
IntroSet() = default;
|
|
|
|
|
|
|
|
|
|
IntroSet(IntroSet&& other) : IBEncodeMessage(other.version)
|
|
|
|
|
IntroSet(IntroSet&& other) = default;
|
|
|
|
|
|
|
|
|
|
IntroSet(const IntroSet& other)
|
|
|
|
|
: IBEncodeMessage(other.version)
|
|
|
|
|
, A(other.A)
|
|
|
|
|
, I(other.I)
|
|
|
|
|
, K(other.K)
|
|
|
|
|
, topic(other.topic)
|
|
|
|
|
, T(other.T)
|
|
|
|
|
, W(std::make_unique< PoW >(*other.W))
|
|
|
|
|
, Z(other.Z)
|
|
|
|
|
{
|
|
|
|
|
A = std::move(other.A);
|
|
|
|
|
I = std::move(other.I);
|
|
|
|
|
K = std::move(other.K);
|
|
|
|
|
T = std::move(other.T);
|
|
|
|
|
version = std::move(other.version);
|
|
|
|
|
topic = std::move(other.topic);
|
|
|
|
|
W = std::move(other.W);
|
|
|
|
|
Z = std::move(other.Z);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
IntroSet(const IntroSet& other) : IBEncodeMessage(other.version)
|
|
|
|
|
{
|
|
|
|
|
A = other.A;
|
|
|
|
|
I = other.I;
|
|
|
|
|
K = other.K;
|
|
|
|
|
T = other.T;
|
|
|
|
|
version = other.version;
|
|
|
|
|
topic = other.topic;
|
|
|
|
|
if(other.W)
|
|
|
|
|
W = new llarp::PoW(*other.W);
|
|
|
|
|
Z = other.Z;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
~IntroSet();
|
|
|
|
|
|
|
|
|
|
IntroSet&
|
|
|
|
|
operator=(const IntroSet& other)
|
|
|
|
|
{
|
|
|
|
@ -76,13 +60,11 @@ namespace llarp
|
|
|
|
|
T = other.T;
|
|
|
|
|
version = other.version;
|
|
|
|
|
topic = other.topic;
|
|
|
|
|
if(W)
|
|
|
|
|
W.reset();
|
|
|
|
|
if(other.W)
|
|
|
|
|
{
|
|
|
|
|
delete W;
|
|
|
|
|
W = nullptr;
|
|
|
|
|
W = std::make_unique< PoW >(*other.W);
|
|
|
|
|
}
|
|
|
|
|
if(other.W)
|
|
|
|
|
W = new llarp::PoW(*other.W);
|
|
|
|
|
Z = other.Z;
|
|
|
|
|
return *this;
|
|
|
|
|
}
|
|
|
|
@ -96,9 +78,20 @@ namespace llarp
|
|
|
|
|
bool
|
|
|
|
|
operator==(const IntroSet& other) const
|
|
|
|
|
{
|
|
|
|
|
return A == other.A && I == other.I && K == other.K && T == other.T
|
|
|
|
|
&& version == other.version && topic == other.topic && W == other.W
|
|
|
|
|
&& Z == other.Z;
|
|
|
|
|
if(std::tie(A, I, K, T, version, topic, Z)
|
|
|
|
|
!= std::tie(other.A, other.I, other.K, other.T, other.version,
|
|
|
|
|
other.topic, other.Z))
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
else if(W && other.W) // both PoW have a valid ptr
|
|
|
|
|
{
|
|
|
|
|
return *W == *other.W;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
return W == other.W; // if one is null, verify the other is null
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool
|
|
|
|
@ -132,7 +125,10 @@ namespace llarp
|
|
|
|
|
DecodeKey(const llarp_buffer_t& key, llarp_buffer_t* buf) override;
|
|
|
|
|
|
|
|
|
|
bool
|
|
|
|
|
Verify(llarp::Crypto* crypto, llarp_time_t now) const;
|
|
|
|
|
Verify(Crypto* crypto, llarp_time_t now) const;
|
|
|
|
|
|
|
|
|
|
util::StatusObject
|
|
|
|
|
ExtractStatus() const;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
inline std::ostream&
|
|
|
|
|