From f6849442a9f5fa2924479320acc1259165da1c60 Mon Sep 17 00:00:00 2001 From: orignal Date: Wed, 19 Nov 2014 14:56:47 -0500 Subject: [PATCH] encrypted delivery status --- Garlic.cpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/Garlic.cpp b/Garlic.cpp index 64ad9b36..13aae1a9 100644 --- a/Garlic.cpp +++ b/Garlic.cpp @@ -272,6 +272,16 @@ namespace garlic size += 4; // create msg I2NPMessage * msg = CreateDeliveryStatusMsg (msgID); + if (m_Owner) + { + //encrypt + uint8_t key[32], tag[32]; + m_Rnd.GenerateBlock (key, 32); // random session key + m_Rnd.GenerateBlock (tag, 32); // random session tag + m_Owner->AddSessionKey (key, tag); + GarlicRoutingSession garlic (key, tag); + msg = garlic.WrapSingleMessage (msg); + } memcpy (buf + size, msg->GetBuffer (), msg->GetLength ()); size += msg->GetLength (); DeleteI2NPMessage (msg); @@ -304,9 +314,10 @@ namespace garlic { if (key) { + uint32_t ts = i2p::util::GetSecondsSinceEpoch (); auto decryption = std::make_shared(); decryption->SetKey (key); - m_Tags[SessionTag(tag)] = decryption; + m_Tags[SessionTag(tag, ts)] = decryption; } } @@ -314,7 +325,7 @@ namespace garlic { uint8_t * buf = msg->GetPayload (); uint32_t length = be32toh (*(uint32_t *)buf); - buf += 4; // lentgh + buf += 4; // length auto it = m_Tags.find (SessionTag(buf)); if (it != m_Tags.end ()) {