2018-12-15 16:21:52 +00:00
|
|
|
#include <messages/relay_commit.hpp>
|
2019-06-04 18:31:17 +00:00
|
|
|
#include <messages/relay_status.hpp>
|
2019-01-14 21:46:07 +00:00
|
|
|
|
2019-05-28 19:45:08 +00:00
|
|
|
#include <crypto/crypto.hpp>
|
2019-06-19 20:40:40 +00:00
|
|
|
#include <nodedb.hpp>
|
2019-06-17 23:19:39 +00:00
|
|
|
#include <path/path_context.hpp>
|
|
|
|
#include <path/transit_hop.hpp>
|
2019-02-11 19:45:42 +00:00
|
|
|
#include <router/abstractrouter.hpp>
|
2019-06-04 18:31:17 +00:00
|
|
|
#include <router/i_outbound_message_handler.hpp>
|
2019-06-19 22:30:07 +00:00
|
|
|
#include <routing/path_confirm_message.hpp>
|
2019-01-14 21:46:07 +00:00
|
|
|
#include <util/bencode.hpp>
|
|
|
|
#include <util/buffer.hpp>
|
|
|
|
#include <util/logger.hpp>
|
2019-02-11 19:45:42 +00:00
|
|
|
#include <util/logic.hpp>
|
2019-06-02 21:19:10 +00:00
|
|
|
#include <util/memfn.hpp>
|
2019-01-14 21:46:07 +00:00
|
|
|
|
2019-05-22 00:36:03 +00:00
|
|
|
#include <functional>
|
|
|
|
|
2019-01-14 21:46:07 +00:00
|
|
|
namespace llarp
|
|
|
|
{
|
|
|
|
bool
|
2019-02-02 23:12:42 +00:00
|
|
|
LR_CommitMessage::DecodeKey(const llarp_buffer_t& key, llarp_buffer_t* buf)
|
2019-01-14 21:46:07 +00:00
|
|
|
{
|
2019-02-17 12:13:34 +00:00
|
|
|
if(key == "c")
|
2019-01-14 21:46:07 +00:00
|
|
|
{
|
|
|
|
return BEncodeReadArray(frames, buf);
|
|
|
|
}
|
|
|
|
bool read = false;
|
|
|
|
if(!BEncodeMaybeReadVersion("v", version, LLARP_PROTO_VERSION, read, key,
|
|
|
|
buf))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
return read;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
LR_CommitMessage::Clear()
|
|
|
|
{
|
2019-06-15 14:55:13 +00:00
|
|
|
std::for_each(frames.begin(), frames.end(), [](auto& f) { f.Clear(); });
|
2019-01-14 21:46:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
LR_CommitMessage::BEncode(llarp_buffer_t* buf) const
|
|
|
|
{
|
|
|
|
if(!bencode_start_dict(buf))
|
|
|
|
return false;
|
|
|
|
// msg type
|
|
|
|
if(!BEncodeWriteDictMsgType(buf, "a", "c"))
|
|
|
|
return false;
|
|
|
|
// frames
|
|
|
|
if(!BEncodeWriteDictArray("c", frames, buf))
|
|
|
|
return false;
|
|
|
|
// version
|
|
|
|
if(!bencode_write_version_entry(buf))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
return bencode_end(buf);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2019-02-11 19:45:42 +00:00
|
|
|
LR_CommitMessage::HandleMessage(AbstractRouter* router) const
|
2019-01-14 21:46:07 +00:00
|
|
|
{
|
2019-04-05 14:58:22 +00:00
|
|
|
if(frames.size() != path::max_len)
|
2019-01-14 21:46:07 +00:00
|
|
|
{
|
|
|
|
llarp::LogError("LRCM invalid number of records, ", frames.size(),
|
2019-04-05 14:58:22 +00:00
|
|
|
"!=", path::max_len);
|
2019-01-14 21:46:07 +00:00
|
|
|
return false;
|
|
|
|
}
|
2019-02-11 19:45:42 +00:00
|
|
|
if(!router->pathContext().AllowingTransit())
|
2019-01-14 21:46:07 +00:00
|
|
|
{
|
|
|
|
llarp::LogError("got LRCM when not permitting transit");
|
|
|
|
return false;
|
|
|
|
}
|
2019-02-11 19:45:42 +00:00
|
|
|
return AsyncDecrypt(&router->pathContext());
|
2019-01-14 21:46:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
LR_CommitRecord::BEncode(llarp_buffer_t* buf) const
|
|
|
|
{
|
|
|
|
if(!bencode_start_dict(buf))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if(!BEncodeWriteDictEntry("c", commkey, buf))
|
|
|
|
return false;
|
|
|
|
if(!BEncodeWriteDictEntry("i", nextHop, buf))
|
|
|
|
return false;
|
|
|
|
if(lifetime > 10 && lifetime < 600)
|
|
|
|
{
|
|
|
|
if(!BEncodeWriteDictInt("i", lifetime, buf))
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if(!BEncodeWriteDictEntry("n", tunnelNonce, buf))
|
|
|
|
return false;
|
|
|
|
if(!BEncodeWriteDictEntry("r", rxid, buf))
|
|
|
|
return false;
|
|
|
|
if(!BEncodeWriteDictEntry("t", txid, buf))
|
|
|
|
return false;
|
2019-04-17 19:05:54 +00:00
|
|
|
if(nextRC)
|
|
|
|
{
|
|
|
|
if(!BEncodeWriteDictEntry("u", *nextRC, buf))
|
|
|
|
return false;
|
|
|
|
}
|
2019-01-14 21:46:07 +00:00
|
|
|
if(!bencode_write_version_entry(buf))
|
|
|
|
return false;
|
|
|
|
if(work && !BEncodeWriteDictEntry("w", *work, buf))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
return bencode_end(buf);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2019-05-22 00:36:03 +00:00
|
|
|
LR_CommitRecord::OnKey(llarp_buffer_t* buffer, llarp_buffer_t* key)
|
2019-01-14 21:46:07 +00:00
|
|
|
{
|
|
|
|
if(!key)
|
|
|
|
return true;
|
|
|
|
|
|
|
|
bool read = false;
|
|
|
|
|
2019-05-22 00:36:03 +00:00
|
|
|
if(!BEncodeMaybeReadDictEntry("c", commkey, read, *key, buffer))
|
2019-01-14 21:46:07 +00:00
|
|
|
return false;
|
2019-05-22 00:36:03 +00:00
|
|
|
if(!BEncodeMaybeReadDictEntry("i", nextHop, read, *key, buffer))
|
2019-01-14 21:46:07 +00:00
|
|
|
return false;
|
2019-05-22 00:36:03 +00:00
|
|
|
if(!BEncodeMaybeReadDictInt("l", lifetime, read, *key, buffer))
|
2019-01-14 21:46:07 +00:00
|
|
|
return false;
|
2019-05-22 00:36:03 +00:00
|
|
|
if(!BEncodeMaybeReadDictEntry("n", tunnelNonce, read, *key, buffer))
|
2019-01-14 21:46:07 +00:00
|
|
|
return false;
|
2019-05-22 00:36:03 +00:00
|
|
|
if(!BEncodeMaybeReadDictEntry("r", rxid, read, *key, buffer))
|
2019-01-14 21:46:07 +00:00
|
|
|
return false;
|
2019-05-22 00:36:03 +00:00
|
|
|
if(!BEncodeMaybeReadDictEntry("t", txid, read, *key, buffer))
|
2019-01-14 21:46:07 +00:00
|
|
|
return false;
|
2019-04-17 19:05:54 +00:00
|
|
|
if(*key == "u")
|
|
|
|
{
|
2019-05-22 00:36:03 +00:00
|
|
|
nextRC = std::make_unique< RouterContact >();
|
|
|
|
return nextRC->BDecode(buffer);
|
2019-04-17 19:05:54 +00:00
|
|
|
}
|
2019-05-22 00:36:03 +00:00
|
|
|
if(!BEncodeMaybeReadVersion("v", version, LLARP_PROTO_VERSION, read, *key,
|
|
|
|
buffer))
|
2019-01-14 21:46:07 +00:00
|
|
|
return false;
|
2019-02-17 12:13:34 +00:00
|
|
|
if(*key == "w")
|
2019-01-14 21:46:07 +00:00
|
|
|
{
|
|
|
|
// check for duplicate
|
2019-05-22 00:36:03 +00:00
|
|
|
if(work)
|
2019-01-14 21:46:07 +00:00
|
|
|
{
|
|
|
|
llarp::LogWarn("duplicate POW in LRCR");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2019-05-22 00:36:03 +00:00
|
|
|
work = std::make_unique< PoW >();
|
2019-05-24 02:01:36 +00:00
|
|
|
return bencode_decode_dict(*work, buffer);
|
2019-01-14 21:46:07 +00:00
|
|
|
}
|
|
|
|
return read;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
LR_CommitRecord::BDecode(llarp_buffer_t* buf)
|
|
|
|
{
|
2019-06-02 21:19:10 +00:00
|
|
|
return bencode_read_dict(util::memFn(&LR_CommitRecord::OnKey, this), buf);
|
2019-01-14 21:46:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
LR_CommitRecord::operator==(const LR_CommitRecord& other) const
|
|
|
|
{
|
|
|
|
if(work && other.work)
|
|
|
|
{
|
|
|
|
if(*work != *other.work)
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return nextHop == other.nextHop && commkey == other.commkey
|
|
|
|
&& txid == other.txid && rxid == other.rxid;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct LRCMFrameDecrypt
|
|
|
|
{
|
2019-07-30 23:42:13 +00:00
|
|
|
using Context = llarp::path::PathContext;
|
|
|
|
using Hop = llarp::path::TransitHop;
|
|
|
|
using Decrypter = AsyncFrameDecrypter< LRCMFrameDecrypt >;
|
2019-04-30 12:22:15 +00:00
|
|
|
using Decrypter_ptr = std::unique_ptr< Decrypter >;
|
|
|
|
Decrypter_ptr decrypter;
|
2019-01-14 21:46:07 +00:00
|
|
|
std::array< EncryptedFrame, 8 > frames;
|
|
|
|
Context* context;
|
|
|
|
// decrypted record
|
|
|
|
LR_CommitRecord record;
|
|
|
|
// the actual hop
|
|
|
|
std::shared_ptr< Hop > hop;
|
|
|
|
|
2019-04-30 12:22:15 +00:00
|
|
|
LRCMFrameDecrypt(Context* ctx, Decrypter_ptr dec,
|
2019-01-14 21:46:07 +00:00
|
|
|
const LR_CommitMessage* commit)
|
2019-04-30 12:22:15 +00:00
|
|
|
: decrypter(std::move(dec))
|
2019-02-11 14:43:48 +00:00
|
|
|
, frames(commit->frames)
|
|
|
|
, context(ctx)
|
|
|
|
, hop(std::make_shared< Hop >())
|
2019-01-14 21:46:07 +00:00
|
|
|
{
|
|
|
|
hop->info.downstream = commit->session->GetPubKey();
|
|
|
|
}
|
|
|
|
|
2019-07-30 23:42:13 +00:00
|
|
|
~LRCMFrameDecrypt() = default;
|
2019-01-14 21:46:07 +00:00
|
|
|
|
2019-06-04 18:31:17 +00:00
|
|
|
static void
|
|
|
|
OnForwardLRCMResult(AbstractRouter* router, const PathID_t pathid,
|
|
|
|
const RouterID nextHop, const SharedSecret pathKey,
|
|
|
|
SendStatus sendStatus)
|
|
|
|
{
|
|
|
|
uint64_t status = LR_StatusRecord::FAIL_DEST_INVALID;
|
|
|
|
|
|
|
|
switch(sendStatus)
|
|
|
|
{
|
|
|
|
case SendStatus::Success:
|
|
|
|
// do nothing, will forward success message later
|
|
|
|
return;
|
|
|
|
case SendStatus::Timeout:
|
|
|
|
status = LR_StatusRecord::FAIL_TIMEOUT;
|
|
|
|
break;
|
|
|
|
case SendStatus::NoLink:
|
|
|
|
status = LR_StatusRecord::FAIL_CANNOT_CONNECT;
|
|
|
|
break;
|
|
|
|
case SendStatus::InvalidRouter:
|
|
|
|
status = LR_StatusRecord::FAIL_DEST_INVALID;
|
|
|
|
break;
|
|
|
|
case SendStatus::RouterNotFound:
|
|
|
|
status = LR_StatusRecord::FAIL_DEST_UNKNOWN;
|
|
|
|
break;
|
|
|
|
case SendStatus::Congestion:
|
|
|
|
status = LR_StatusRecord::FAIL_CONGESTION;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
LogError("llarp::SendStatus value not in enum class");
|
|
|
|
std::abort();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
auto func = std::bind(&LR_StatusMessage::CreateAndSend, router, pathid,
|
|
|
|
nextHop, pathKey, status);
|
|
|
|
|
|
|
|
router->threadpool()->addJob(func);
|
|
|
|
}
|
|
|
|
|
2019-01-14 21:46:07 +00:00
|
|
|
/// this is done from logic thread
|
|
|
|
static void
|
2019-04-30 12:22:15 +00:00
|
|
|
SendLRCM(std::shared_ptr< LRCMFrameDecrypt > self)
|
2019-01-14 21:46:07 +00:00
|
|
|
{
|
2019-04-17 19:05:54 +00:00
|
|
|
if(!self->context->Router()->ConnectionToRouterAllowed(
|
|
|
|
self->hop->info.upstream))
|
|
|
|
{
|
|
|
|
// we are not allowed to forward it ... now what?
|
|
|
|
llarp::LogError("path to ", self->hop->info.upstream,
|
|
|
|
"not allowed, dropping build request on the floor");
|
2019-06-04 18:31:17 +00:00
|
|
|
OnForwardLRCMResult(self->context->Router(), self->hop->info.rxID,
|
|
|
|
self->hop->info.downstream, self->hop->pathKey,
|
|
|
|
SendStatus::InvalidRouter);
|
2019-04-30 15:01:13 +00:00
|
|
|
self->hop = nullptr;
|
2019-04-17 19:05:54 +00:00
|
|
|
return;
|
|
|
|
}
|
2019-01-14 21:46:07 +00:00
|
|
|
// persist sessions to upstream and downstream routers until the commit
|
|
|
|
// ends
|
2019-02-23 17:34:12 +00:00
|
|
|
self->context->Router()->PersistSessionUntil(
|
|
|
|
self->hop->info.downstream, self->hop->ExpireTime() + 10000);
|
|
|
|
self->context->Router()->PersistSessionUntil(
|
|
|
|
self->hop->info.upstream, self->hop->ExpireTime() + 10000);
|
2019-01-14 21:46:07 +00:00
|
|
|
// put hop
|
|
|
|
self->context->PutTransitHop(self->hop);
|
2019-04-17 19:05:54 +00:00
|
|
|
// if we have an rc for this hop...
|
|
|
|
if(self->record.nextRC)
|
|
|
|
{
|
|
|
|
// ... and it matches the next hop ...
|
|
|
|
if(self->record.nextHop == self->record.nextRC->pubkey)
|
|
|
|
{
|
|
|
|
// ... and it's valid
|
|
|
|
const auto now = self->context->Router()->Now();
|
|
|
|
if(self->record.nextRC->IsPublicRouter()
|
2019-05-28 19:45:08 +00:00
|
|
|
&& self->record.nextRC->Verify(now))
|
2019-04-17 19:05:54 +00:00
|
|
|
{
|
2019-06-04 18:31:17 +00:00
|
|
|
self->context->Router()->nodedb()->UpdateAsyncIfNewer(
|
|
|
|
*self->record.nextRC.get());
|
2019-04-17 19:05:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-01-14 21:46:07 +00:00
|
|
|
// forward to next hop
|
2019-06-04 18:31:17 +00:00
|
|
|
using std::placeholders::_1;
|
|
|
|
auto func = std::bind(&OnForwardLRCMResult, self->context->Router(),
|
|
|
|
self->hop->info.rxID, self->hop->info.downstream,
|
|
|
|
self->hop->pathKey, _1);
|
|
|
|
self->context->ForwardLRCM(self->hop->info.upstream, self->frames, func);
|
2019-01-14 21:46:07 +00:00
|
|
|
self->hop = nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
// this is called from the logic thread
|
|
|
|
static void
|
2019-04-30 12:22:15 +00:00
|
|
|
SendPathConfirm(std::shared_ptr< LRCMFrameDecrypt > self)
|
2019-01-14 21:46:07 +00:00
|
|
|
{
|
|
|
|
// persist session to downstream until path expiration
|
2019-02-23 17:34:12 +00:00
|
|
|
self->context->Router()->PersistSessionUntil(
|
|
|
|
self->hop->info.downstream, self->hop->ExpireTime() + 10000);
|
2019-01-14 21:46:07 +00:00
|
|
|
// put hop
|
|
|
|
self->context->PutTransitHop(self->hop);
|
2019-06-04 18:31:17 +00:00
|
|
|
|
2019-01-14 21:46:07 +00:00
|
|
|
// send path confirmation
|
2019-06-04 18:31:17 +00:00
|
|
|
// TODO: other status flags?
|
|
|
|
uint64_t status = LR_StatusRecord::SUCCESS;
|
|
|
|
|
|
|
|
if(!LR_StatusMessage::CreateAndSend(
|
|
|
|
self->context->Router(), self->hop->info.rxID,
|
|
|
|
self->hop->info.downstream, self->hop->pathKey, status))
|
2019-01-14 21:46:07 +00:00
|
|
|
{
|
|
|
|
llarp::LogError("failed to send path confirmation for ",
|
|
|
|
self->hop->info);
|
|
|
|
}
|
|
|
|
self->hop = nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2019-04-30 12:22:15 +00:00
|
|
|
HandleDecrypted(llarp_buffer_t* buf,
|
|
|
|
std::shared_ptr< LRCMFrameDecrypt > self)
|
2019-01-14 21:46:07 +00:00
|
|
|
{
|
|
|
|
auto now = self->context->Router()->Now();
|
|
|
|
auto& info = self->hop->info;
|
|
|
|
if(!buf)
|
|
|
|
{
|
|
|
|
llarp::LogError("LRCM decrypt failed from ", info.downstream);
|
2019-04-30 12:22:15 +00:00
|
|
|
self->decrypter = nullptr;
|
2019-01-14 21:46:07 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
buf->cur = buf->base + EncryptedFrameOverheadSize;
|
|
|
|
llarp::LogDebug("decrypted LRCM from ", info.downstream);
|
|
|
|
// successful decrypt
|
|
|
|
if(!self->record.BDecode(buf))
|
|
|
|
{
|
|
|
|
llarp::LogError("malformed frame inside LRCM from ", info.downstream);
|
2019-04-30 12:22:15 +00:00
|
|
|
self->decrypter = nullptr;
|
2019-01-14 21:46:07 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
info.txID = self->record.txid;
|
|
|
|
info.rxID = self->record.rxid;
|
|
|
|
info.upstream = self->record.nextHop;
|
|
|
|
if(self->context->HasTransitHop(info))
|
|
|
|
{
|
|
|
|
llarp::LogError("duplicate transit hop ", info);
|
2019-04-30 12:22:15 +00:00
|
|
|
self->decrypter = nullptr;
|
2019-01-14 21:46:07 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
// generate path key as we are in a worker thread
|
2019-05-28 19:45:08 +00:00
|
|
|
auto crypto = CryptoManager::instance();
|
2019-01-26 15:40:58 +00:00
|
|
|
if(!crypto->dh_server(self->hop->pathKey, self->record.commkey,
|
|
|
|
self->context->EncryptionSecretKey(),
|
|
|
|
self->record.tunnelNonce))
|
2019-01-14 21:46:07 +00:00
|
|
|
{
|
|
|
|
llarp::LogError("LRCM DH Failed ", info);
|
2019-04-30 12:22:15 +00:00
|
|
|
self->decrypter = nullptr;
|
2019-01-14 21:46:07 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
// generate hash of hop key for nonce mutation
|
2019-02-05 00:41:33 +00:00
|
|
|
crypto->shorthash(self->hop->nonceXOR,
|
|
|
|
llarp_buffer_t(self->hop->pathKey));
|
2019-05-28 19:45:08 +00:00
|
|
|
if(self->record.work && self->record.work->IsValid(now))
|
2019-01-14 21:46:07 +00:00
|
|
|
{
|
|
|
|
llarp::LogDebug("LRCM extended lifetime by ",
|
|
|
|
self->record.work->extendedLifetime, " seconds for ",
|
|
|
|
info);
|
|
|
|
self->hop->lifetime += 1000 * self->record.work->extendedLifetime;
|
|
|
|
}
|
|
|
|
else if(self->record.lifetime < 600 && self->record.lifetime > 10)
|
|
|
|
{
|
|
|
|
self->hop->lifetime = self->record.lifetime;
|
|
|
|
llarp::LogDebug("LRCM short lifespan set to ", self->hop->lifetime,
|
|
|
|
" seconds for ", info);
|
|
|
|
}
|
|
|
|
|
|
|
|
// TODO: check if we really want to accept it
|
|
|
|
self->hop->started = now;
|
|
|
|
|
|
|
|
size_t sz = self->frames[0].size();
|
|
|
|
// shift
|
|
|
|
std::array< EncryptedFrame, 8 > frames;
|
|
|
|
frames[0] = self->frames[1];
|
|
|
|
frames[1] = self->frames[2];
|
|
|
|
frames[2] = self->frames[3];
|
|
|
|
frames[3] = self->frames[4];
|
|
|
|
frames[4] = self->frames[5];
|
|
|
|
frames[5] = self->frames[6];
|
|
|
|
frames[6] = self->frames[7];
|
|
|
|
// put our response on the end
|
|
|
|
frames[7] = EncryptedFrame(sz - EncryptedFrameOverheadSize);
|
|
|
|
// random junk for now
|
|
|
|
frames[7].Randomize();
|
|
|
|
self->frames = std::move(frames);
|
|
|
|
if(self->context->HopIsUs(info.upstream))
|
|
|
|
{
|
|
|
|
// we are the farthest hop
|
|
|
|
llarp::LogDebug("We are the farthest hop for ", info);
|
|
|
|
// send a LRAM down the path
|
2019-04-30 12:22:15 +00:00
|
|
|
self->context->logic()->queue_func([=]() {
|
|
|
|
SendPathConfirm(self);
|
|
|
|
self->decrypter = nullptr;
|
|
|
|
});
|
2019-01-14 21:46:07 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// forward upstream
|
|
|
|
// we are still in the worker thread so post job to logic
|
2019-04-30 12:22:15 +00:00
|
|
|
self->context->logic()->queue_func([=]() {
|
|
|
|
SendLRCM(self);
|
|
|
|
self->decrypter = nullptr;
|
|
|
|
});
|
2019-01-14 21:46:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
bool
|
|
|
|
LR_CommitMessage::AsyncDecrypt(llarp::path::PathContext* context) const
|
|
|
|
{
|
2019-04-30 12:22:15 +00:00
|
|
|
auto decrypter = std::make_unique< LRCMFrameDecrypt::Decrypter >(
|
2019-05-28 19:45:08 +00:00
|
|
|
context->EncryptionSecretKey(), &LRCMFrameDecrypt::HandleDecrypted);
|
2019-01-14 21:46:07 +00:00
|
|
|
// copy frames so we own them
|
2019-04-30 12:22:15 +00:00
|
|
|
auto frameDecrypt = std::make_shared< LRCMFrameDecrypt >(
|
|
|
|
context, std::move(decrypter), this);
|
2019-01-14 21:46:07 +00:00
|
|
|
|
|
|
|
// decrypt frames async
|
2019-04-30 12:22:15 +00:00
|
|
|
frameDecrypt->decrypter->AsyncDecrypt(
|
|
|
|
context->Worker(), frameDecrypt->frames[0], frameDecrypt);
|
2019-01-14 21:46:07 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
} // namespace llarp
|