From 73abb9278df1937b7948505b6e46c47ba5ae04ae Mon Sep 17 00:00:00 2001 From: orignal Date: Tue, 9 Apr 2019 09:21:38 -0400 Subject: [PATCH] correct ecrypted LS2 size --- libi2pd/LeaseSet.cpp | 6 +++--- libi2pd/LeaseSet.h | 3 ++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/libi2pd/LeaseSet.cpp b/libi2pd/LeaseSet.cpp index 0fea8c7e..61e78baa 100644 --- a/libi2pd/LeaseSet.cpp +++ b/libi2pd/LeaseSet.cpp @@ -853,12 +853,12 @@ namespace data m_Buffer[0] = storeType; } - LocalLeaseSet2::LocalLeaseSet2 (std::shared_ptr ls, const i2p::data::PrivateKeys& keys, i2p::data::SigningKeyType blindedKeyType): + LocalLeaseSet2::LocalLeaseSet2 (std::shared_ptr ls, const i2p::data::PrivateKeys& keys, i2p::data::SigningKeyType blindedKeyType): LocalLeaseSet (ls->GetIdentity (), nullptr, 0) { size_t lenInnerPlaintext = ls->GetBufferLen () + 1, lenOuterPlaintext = lenInnerPlaintext + 32 + 1, lenOuterCiphertext = lenOuterPlaintext + 32; - m_BufferLen = 2/*blinded sig type*/ + 32/*blinded pub key*/ + 4/*published*/ + 2/*expires*/ + 2/*flags*/ + lenOuterCiphertext + 64/*signature*/; + m_BufferLen = 2/*blinded sig type*/ + 32/*blinded pub key*/ + 4/*published*/ + 2/*expires*/ + 2/*flags*/ + 2/*lenOuterCiphertext*/ + lenOuterCiphertext + 64/*signature*/; m_Buffer = new uint8_t[m_BufferLen + 1]; m_Buffer[0] = NETDB_STORE_TYPE_ENCRYPTED_LEASESET2; BlindedPublicKey blindedKey (ls->GetIdentity ()); @@ -875,7 +875,7 @@ namespace data auto expirationTime = ls->GetExpirationTime (); SetExpirationTime (expirationTime); auto expires = expirationTime/1000LL - timestamp; - htobe16buf (m_Buffer + offset, expires > 0 ? expires : 0); // expires + htobe16buf (m_Buffer + offset, expires > 0 ? expires : 0); offset += 2; // expires uint16_t flags = 0; htobe16buf (m_Buffer + offset, flags); offset += 2; // flags htobe16buf (m_Buffer + offset, lenOuterCiphertext); offset += 2; // lenOuterCiphertext diff --git a/libi2pd/LeaseSet.h b/libi2pd/LeaseSet.h index 44ed0b71..3f864452 100644 --- a/libi2pd/LeaseSet.h +++ b/libi2pd/LeaseSet.h @@ -228,6 +228,7 @@ namespace data uint8_t * GetLeases () { return m_Leases; }; const IdentHash& GetIdentHash () const { return m_Identity->GetIdentHash (); }; + std::shared_ptr GetIdentity () const { return m_Identity; }; bool IsExpired () const; uint64_t GetExpirationTime () const { return m_ExpirationTime; }; void SetExpirationTime (uint64_t expirationTime) { m_ExpirationTime = expirationTime; }; @@ -252,7 +253,7 @@ namespace data uint16_t keyType, uint16_t keyLen, const uint8_t * encryptionPublicKey, std::vector > tunnels); LocalLeaseSet2 (uint8_t storeType, std::shared_ptr identity, const uint8_t * buf, size_t len); - LocalLeaseSet2 (std::shared_ptr ls, const i2p::data::PrivateKeys& keys, i2p::data::SigningKeyType blindedKeyType = i2p::data::SIGNING_KEY_TYPE_REDDSA_SHA512_ED25519); // encrypted + LocalLeaseSet2 (std::shared_ptr ls, const i2p::data::PrivateKeys& keys, i2p::data::SigningKeyType blindedKeyType = i2p::data::SIGNING_KEY_TYPE_REDDSA_SHA512_ED25519); // encrypted virtual ~LocalLeaseSet2 () { delete[] m_Buffer; };