2018-07-09 17:32:11 +00:00
|
|
|
#ifndef LLARP_SERVICE_IDENTITY_HPP
|
|
|
|
#define LLARP_SERVICE_IDENTITY_HPP
|
2018-12-12 02:15:08 +00:00
|
|
|
|
2019-01-13 16:30:07 +00:00
|
|
|
#include <crypto/types.hpp>
|
2018-12-12 02:15:08 +00:00
|
|
|
#include <service/Info.hpp>
|
|
|
|
#include <service/IntroSet.hpp>
|
|
|
|
#include <service/types.hpp>
|
2019-01-10 19:41:51 +00:00
|
|
|
#include <util/bencode.hpp>
|
2018-07-09 17:32:11 +00:00
|
|
|
|
|
|
|
namespace llarp
|
|
|
|
{
|
2019-01-13 16:30:07 +00:00
|
|
|
struct Crypto;
|
|
|
|
|
2018-07-09 17:32:11 +00:00
|
|
|
namespace service
|
|
|
|
{
|
|
|
|
// private keys
|
2018-11-05 11:27:12 +00:00
|
|
|
struct Identity final : public llarp::IBEncodeMessage
|
2018-07-09 17:32:11 +00:00
|
|
|
{
|
|
|
|
llarp::SecretKey enckey;
|
|
|
|
llarp::SecretKey signkey;
|
2018-08-13 23:22:31 +00:00
|
|
|
llarp::PQKeyPair pq;
|
2018-07-09 17:32:11 +00:00
|
|
|
uint64_t version = 0;
|
|
|
|
VanityNonce vanity;
|
|
|
|
|
|
|
|
// public service info
|
|
|
|
ServiceInfo pub;
|
|
|
|
|
|
|
|
~Identity();
|
|
|
|
|
|
|
|
// regenerate secret keys
|
|
|
|
void
|
2018-12-11 00:53:11 +00:00
|
|
|
RegenerateKeys(llarp::Crypto* c);
|
2018-07-09 17:32:11 +00:00
|
|
|
|
|
|
|
// load from file
|
|
|
|
bool
|
|
|
|
LoadFromFile(const std::string& fpath);
|
|
|
|
|
|
|
|
bool
|
2018-11-05 11:27:12 +00:00
|
|
|
BEncode(llarp_buffer_t* buf) const override;
|
2018-07-09 17:32:11 +00:00
|
|
|
|
|
|
|
bool
|
2018-12-11 00:53:11 +00:00
|
|
|
EnsureKeys(const std::string& fpath, llarp::Crypto* c);
|
2018-07-09 17:32:11 +00:00
|
|
|
|
2018-08-13 23:22:31 +00:00
|
|
|
bool
|
2019-01-02 01:04:03 +00:00
|
|
|
KeyExchange(llarp::path_dh_func dh, SharedSecret& sharedkey,
|
2019-01-02 01:04:04 +00:00
|
|
|
const ServiceInfo& other, const KeyExchangeNonce& N) const;
|
2018-08-13 23:22:31 +00:00
|
|
|
|
2018-07-09 17:32:11 +00:00
|
|
|
bool
|
2019-02-01 01:58:06 +00:00
|
|
|
DecodeKey(const llarp_buffer_t& key, llarp_buffer_t* buf) override;
|
2018-07-09 17:32:11 +00:00
|
|
|
|
|
|
|
bool
|
2018-12-11 00:53:11 +00:00
|
|
|
SignIntroSet(IntroSet& i, llarp::Crypto* c, llarp_time_t now) const;
|
2018-08-13 23:22:31 +00:00
|
|
|
|
|
|
|
bool
|
2019-02-01 01:58:06 +00:00
|
|
|
Sign(llarp::Crypto*, Signature& sig, const llarp_buffer_t& buf) const;
|
2018-07-09 17:32:11 +00:00
|
|
|
};
|
|
|
|
} // namespace service
|
|
|
|
} // namespace llarp
|
|
|
|
|
2018-11-05 11:27:12 +00:00
|
|
|
#endif
|