2018-07-09 19:32:11 +02:00
|
|
|
#ifndef LLARP_SERVICE_IDENTITY_HPP
|
|
|
|
#define LLARP_SERVICE_IDENTITY_HPP
|
2018-12-12 03:15:08 +01:00
|
|
|
|
2019-05-24 04:01:36 +02:00
|
|
|
#include <constants/proto.hpp>
|
2019-01-13 17:30:07 +01:00
|
|
|
#include <crypto/types.hpp>
|
2019-04-22 20:35:19 +02:00
|
|
|
#include <service/info.hpp>
|
|
|
|
#include <service/intro_set.hpp>
|
|
|
|
#include <service/vanity.hpp>
|
2019-05-24 04:01:36 +02:00
|
|
|
#include <util/buffer.hpp>
|
2018-07-09 19:32:11 +02:00
|
|
|
|
2019-05-18 19:34:07 +02:00
|
|
|
#include <tuple>
|
|
|
|
|
2018-07-09 19:32:11 +02:00
|
|
|
namespace llarp
|
|
|
|
{
|
2019-01-13 17:30:07 +01:00
|
|
|
struct Crypto;
|
|
|
|
|
2018-07-09 19:32:11 +02:00
|
|
|
namespace service
|
|
|
|
{
|
|
|
|
// private keys
|
2019-05-24 04:01:36 +02:00
|
|
|
struct Identity
|
2018-07-09 19:32:11 +02:00
|
|
|
{
|
2019-04-22 20:35:19 +02:00
|
|
|
SecretKey enckey;
|
|
|
|
SecretKey signkey;
|
|
|
|
PQKeyPair pq;
|
2019-05-24 04:01:36 +02:00
|
|
|
uint64_t version = LLARP_PROTO_VERSION;
|
2018-07-09 19:32:11 +02:00
|
|
|
VanityNonce vanity;
|
|
|
|
|
|
|
|
// public service info
|
|
|
|
ServiceInfo pub;
|
|
|
|
|
|
|
|
// regenerate secret keys
|
|
|
|
void
|
2019-04-22 20:35:19 +02:00
|
|
|
RegenerateKeys(Crypto* c);
|
2018-07-09 19:32:11 +02:00
|
|
|
|
|
|
|
bool
|
2019-05-24 04:01:36 +02:00
|
|
|
BEncode(llarp_buffer_t* buf) const;
|
2018-07-09 19:32:11 +02:00
|
|
|
|
|
|
|
bool
|
2019-04-22 20:35:19 +02:00
|
|
|
EnsureKeys(const std::string& fpath, Crypto* c);
|
2018-07-09 19:32:11 +02:00
|
|
|
|
2018-08-14 01:22:31 +02:00
|
|
|
bool
|
2019-04-22 20:35:19 +02:00
|
|
|
KeyExchange(path_dh_func dh, SharedSecret& sharedkey,
|
2019-01-02 02:04:04 +01:00
|
|
|
const ServiceInfo& other, const KeyExchangeNonce& N) const;
|
2018-08-14 01:22:31 +02:00
|
|
|
|
2018-07-09 19:32:11 +02:00
|
|
|
bool
|
2019-05-24 04:01:36 +02:00
|
|
|
DecodeKey(const llarp_buffer_t& key, llarp_buffer_t* buf);
|
2018-07-09 19:32:11 +02:00
|
|
|
|
|
|
|
bool
|
2019-04-22 20:35:19 +02:00
|
|
|
SignIntroSet(IntroSet& i, Crypto* c, llarp_time_t now) const;
|
2018-08-14 01:22:31 +02:00
|
|
|
|
|
|
|
bool
|
2019-04-22 20:35:19 +02:00
|
|
|
Sign(Crypto*, Signature& sig, const llarp_buffer_t& buf) const;
|
2018-07-09 19:32:11 +02:00
|
|
|
};
|
2019-05-18 19:34:07 +02:00
|
|
|
|
|
|
|
inline bool
|
|
|
|
operator==(const Identity& lhs, const Identity& rhs)
|
|
|
|
{
|
|
|
|
return std::tie(lhs.enckey, lhs.signkey, lhs.pq, lhs.version, lhs.vanity)
|
|
|
|
== std::tie(rhs.enckey, rhs.signkey, rhs.pq, rhs.version, rhs.vanity);
|
|
|
|
}
|
2018-07-09 19:32:11 +02:00
|
|
|
} // namespace service
|
|
|
|
} // namespace llarp
|
|
|
|
|
2018-11-05 12:27:12 +01:00
|
|
|
#endif
|