mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-03-13 04:46:38 +01:00
reset keys
This commit is contained in:
parent
34295adb05
commit
205e807b66
2 changed files with 15 additions and 7 deletions
|
@ -37,6 +37,15 @@ namespace garlic
|
||||||
|
|
||||||
ECIESX25519AEADRatchetSession::ECIESX25519AEADRatchetSession (GarlicDestination * owner):
|
ECIESX25519AEADRatchetSession::ECIESX25519AEADRatchetSession (GarlicDestination * owner):
|
||||||
GarlicRoutingSession (owner, true)
|
GarlicRoutingSession (owner, true)
|
||||||
|
{
|
||||||
|
ResetKeys ();
|
||||||
|
}
|
||||||
|
|
||||||
|
ECIESX25519AEADRatchetSession::~ECIESX25519AEADRatchetSession ()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void ECIESX25519AEADRatchetSession::ResetKeys ()
|
||||||
{
|
{
|
||||||
// TODO : use precalculated hashes
|
// TODO : use precalculated hashes
|
||||||
static const char protocolName[41] = "Noise_IKelg2+hs2_25519_ChaChaPoly_SHA256"; // 40 bytes
|
static const char protocolName[41] = "Noise_IKelg2+hs2_25519_ChaChaPoly_SHA256"; // 40 bytes
|
||||||
|
@ -45,10 +54,6 @@ namespace garlic
|
||||||
SHA256 (m_H, 32, m_H);
|
SHA256 (m_H, 32, m_H);
|
||||||
}
|
}
|
||||||
|
|
||||||
ECIESX25519AEADRatchetSession::~ECIESX25519AEADRatchetSession ()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void ECIESX25519AEADRatchetSession::MixHash (const uint8_t * buf, size_t len)
|
void ECIESX25519AEADRatchetSession::MixHash (const uint8_t * buf, size_t len)
|
||||||
{
|
{
|
||||||
SHA256_CTX ctx;
|
SHA256_CTX ctx;
|
||||||
|
@ -175,6 +180,7 @@ namespace garlic
|
||||||
|
|
||||||
bool ECIESX25519AEADRatchetSession::NewOutgoingSessionMessage (const uint8_t * payload, size_t len, uint8_t * out, size_t outLen)
|
bool ECIESX25519AEADRatchetSession::NewOutgoingSessionMessage (const uint8_t * payload, size_t len, uint8_t * out, size_t outLen)
|
||||||
{
|
{
|
||||||
|
ResetKeys ();
|
||||||
// we are Alice, bpk is m_RemoteStaticKey
|
// we are Alice, bpk is m_RemoteStaticKey
|
||||||
size_t offset = 0;
|
size_t offset = 0;
|
||||||
if (!GenerateEphemeralKeysAndEncode (out + offset))
|
if (!GenerateEphemeralKeysAndEncode (out + offset))
|
||||||
|
@ -267,6 +273,7 @@ namespace garlic
|
||||||
bool ECIESX25519AEADRatchetSession::NewOutgoingSessionReply (const uint8_t * buf, size_t len, CloveHandler handleClove)
|
bool ECIESX25519AEADRatchetSession::NewOutgoingSessionReply (const uint8_t * buf, size_t len, CloveHandler handleClove)
|
||||||
{
|
{
|
||||||
// TODO
|
// TODO
|
||||||
|
LogPrint (eLogDebug, "Garlic: reply received");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -303,7 +310,7 @@ namespace garlic
|
||||||
std::vector<uint8_t> ECIESX25519AEADRatchetSession::CreatePayload (std::shared_ptr<const I2NPMessage> msg)
|
std::vector<uint8_t> ECIESX25519AEADRatchetSession::CreatePayload (std::shared_ptr<const I2NPMessage> msg)
|
||||||
{
|
{
|
||||||
size_t payloadLen = 0;
|
size_t payloadLen = 0;
|
||||||
if (payloadLen)
|
if (msg)
|
||||||
payloadLen += msg->GetPayloadLength () + 13;
|
payloadLen += msg->GetPayloadLength () + 13;
|
||||||
auto leaseSet = CreateDatabaseStoreMsg (GetOwner ()->GetLeaseSet ());
|
auto leaseSet = CreateDatabaseStoreMsg (GetOwner ()->GetLeaseSet ());
|
||||||
if (leaseSet)
|
if (leaseSet)
|
||||||
|
|
|
@ -72,6 +72,7 @@ namespace garlic
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
void ResetKeys ();
|
||||||
void MixHash (const uint8_t * buf, size_t len);
|
void MixHash (const uint8_t * buf, size_t len);
|
||||||
bool GenerateEphemeralKeysAndEncode (uint8_t * buf); // buf is 32 bytes
|
bool GenerateEphemeralKeysAndEncode (uint8_t * buf); // buf is 32 bytes
|
||||||
uint64_t CreateNewSessionTag () const;
|
uint64_t CreateNewSessionTag () const;
|
||||||
|
|
Loading…
Add table
Reference in a new issue