2021-03-09 22:24:35 +00:00
|
|
|
#pragma once
|
2019-04-21 16:44:27 +00:00
|
|
|
|
2021-03-09 22:24:35 +00:00
|
|
|
#include <llarp/crypto/types.hpp>
|
|
|
|
#include "identity.hpp"
|
|
|
|
#include "protocol.hpp"
|
2019-04-21 16:44:27 +00:00
|
|
|
|
|
|
|
namespace llarp
|
|
|
|
{
|
|
|
|
namespace service
|
|
|
|
{
|
2020-04-07 18:38:56 +00:00
|
|
|
struct AsyncKeyExchange : public std::enable_shared_from_this<AsyncKeyExchange>
|
2019-04-21 16:44:27 +00:00
|
|
|
{
|
2021-03-02 15:23:38 +00:00
|
|
|
EventLoop_ptr loop;
|
2019-04-21 16:44:27 +00:00
|
|
|
SharedSecret sharedKey;
|
2019-08-02 09:27:27 +00:00
|
|
|
ServiceInfo m_remote;
|
2019-04-21 16:44:27 +00:00
|
|
|
const Identity& m_LocalIdentity;
|
|
|
|
ProtocolMessage msg;
|
|
|
|
Introduction intro;
|
|
|
|
const PQPubKey introPubKey;
|
|
|
|
Introduction remoteIntro;
|
2020-04-07 18:38:56 +00:00
|
|
|
std::function<void(std::shared_ptr<ProtocolFrame>)> hook;
|
2019-04-21 16:44:27 +00:00
|
|
|
IDataHandler* handler;
|
|
|
|
ConvoTag tag;
|
|
|
|
|
2020-04-07 18:38:56 +00:00
|
|
|
AsyncKeyExchange(
|
2021-03-02 15:23:38 +00:00
|
|
|
EventLoop_ptr l,
|
2020-04-07 18:38:56 +00:00
|
|
|
ServiceInfo r,
|
|
|
|
const Identity& localident,
|
|
|
|
const PQPubKey& introsetPubKey,
|
|
|
|
const Introduction& remote,
|
|
|
|
IDataHandler* h,
|
|
|
|
const ConvoTag& t,
|
|
|
|
ProtocolType proto);
|
2019-04-21 16:44:27 +00:00
|
|
|
|
|
|
|
static void
|
2020-04-07 18:38:56 +00:00
|
|
|
Result(std::shared_ptr<AsyncKeyExchange> user, std::shared_ptr<ProtocolFrame> frame);
|
2019-04-21 16:44:27 +00:00
|
|
|
|
|
|
|
/// given protocol message make protocol frame
|
|
|
|
static void
|
2020-04-07 18:38:56 +00:00
|
|
|
Encrypt(std::shared_ptr<AsyncKeyExchange> user, std::shared_ptr<ProtocolFrame> frame);
|
2019-04-21 16:44:27 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace service
|
|
|
|
} // namespace llarp
|