diff --git a/libi2pd/Destination.cpp b/libi2pd/Destination.cpp index 45cc400d..f88688f9 100644 --- a/libi2pd/Destination.cpp +++ b/libi2pd/Destination.cpp @@ -881,9 +881,10 @@ namespace client request->excluded.insert (nextFloodfill->GetIdentHash ()); request->requestTimeoutTimer.cancel (); - uint8_t replyKey[32], replyTag[32]; + uint8_t replyKey[32]; + uint64_t replyTag; RAND_bytes (replyKey, 32); // random session key - RAND_bytes (replyTag, 8); // random session tag + RAND_bytes ((uint8_t *)&replyTag, 8); // random session tag AddECIESx25519Key (replyKey, replyTag); auto msg = WrapMessageForRouter (nextFloodfill, diff --git a/libi2pd/Garlic.cpp b/libi2pd/Garlic.cpp index 07442b83..295bf69a 100644 --- a/libi2pd/Garlic.cpp +++ b/libi2pd/Garlic.cpp @@ -471,13 +471,6 @@ namespace garlic } } - void GarlicDestination::AddECIESx25519Key (const uint8_t * key, const uint8_t * tag) - { - uint64_t t; - memcpy (&t, tag, 8); - AddECIESx25519Key (key, t); - } - void GarlicDestination::AddECIESx25519Key (const uint8_t * key, uint64_t tag) { auto tagset = std::make_shared(this, key); diff --git a/libi2pd/Garlic.h b/libi2pd/Garlic.h index bd689be9..e4e4f538 100644 --- a/libi2pd/Garlic.h +++ b/libi2pd/Garlic.h @@ -294,7 +294,6 @@ namespace garlic protected: - void AddECIESx25519Key (const uint8_t * key, const uint8_t * tag); // one tag bool HandleECIESx25519TagMessage (uint8_t * buf, size_t len); // return true if found virtual void HandleI2NPMessage (const uint8_t * buf, size_t len) = 0; // called from clove only virtual bool HandleCloveI2NPMessage (I2NPMessageType typeID, const uint8_t * payload, diff --git a/libi2pd/I2NPProtocol.cpp b/libi2pd/I2NPProtocol.cpp index 8e2df3bb..1bfbc03a 100644 --- a/libi2pd/I2NPProtocol.cpp +++ b/libi2pd/I2NPProtocol.cpp @@ -189,7 +189,7 @@ namespace i2p std::shared_ptr CreateLeaseSetDatabaseLookupMsg (const i2p::data::IdentHash& dest, const std::unordered_set& excludedFloodfills, std::shared_ptr replyTunnel, const uint8_t * replyKey, - const uint8_t * replyTag) + uint64_t replyTag) { int cnt = excludedFloodfills.size (); auto m = cnt > 7 ? NewI2NPMessage () : NewI2NPShortMessage (); @@ -222,7 +222,7 @@ namespace i2p // encryption memcpy (buf, replyKey, 32); buf[32] = 1; // 1 tag - memcpy (buf + 33, replyTag, 8); // 8 bytes tag + memcpy (buf + 33, &replyTag, 8); // 8 bytes tag buf += 41; m->len += (buf - m->GetPayload ()); diff --git a/libi2pd/I2NPProtocol.h b/libi2pd/I2NPProtocol.h index 222bfcca..1fd34152 100644 --- a/libi2pd/I2NPProtocol.h +++ b/libi2pd/I2NPProtocol.h @@ -278,7 +278,7 @@ namespace tunnel std::shared_ptr CreateLeaseSetDatabaseLookupMsg (const i2p::data::IdentHash& dest, const std::unordered_set& excludedFloodfills, std::shared_ptr replyTunnel, - const uint8_t * replyKey, const uint8_t * replyTag); + const uint8_t * replyKey, uint64_t replyTag); std::shared_ptr CreateDatabaseSearchReply (const i2p::data::IdentHash& ident, std::vector routers); std::shared_ptr CreateDatabaseStoreMsg (std::shared_ptr router = nullptr, uint32_t replyToken = 0, std::shared_ptr replyTunnel = nullptr);