mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-01-22 21:37:17 +01:00
published encrypted flag
This commit is contained in:
parent
db107602bd
commit
e6a09b49c9
|
@ -1180,9 +1180,10 @@ namespace client
|
||||||
{
|
{
|
||||||
// standard LS2 (type 3) first
|
// standard LS2 (type 3) first
|
||||||
auto keyLen = m_Decryptor ? m_Decryptor->GetPublicKeyLen () : 256;
|
auto keyLen = m_Decryptor ? m_Decryptor->GetPublicKeyLen () : 256;
|
||||||
|
bool isPublishedEncrypted = GetLeaseSetType () == i2p::data::NETDB_STORE_TYPE_ENCRYPTED_LEASESET2;
|
||||||
auto ls2 = std::make_shared<i2p::data::LocalLeaseSet2> (i2p::data::NETDB_STORE_TYPE_STANDARD_LEASESET2,
|
auto ls2 = std::make_shared<i2p::data::LocalLeaseSet2> (i2p::data::NETDB_STORE_TYPE_STANDARD_LEASESET2,
|
||||||
m_Keys, m_EncryptionKeyType, keyLen, m_EncryptionPublicKey, tunnels, IsPublic ());
|
m_Keys, m_EncryptionKeyType, keyLen, m_EncryptionPublicKey, tunnels, IsPublic (), isPublishedEncrypted);
|
||||||
if (GetLeaseSetType () == i2p::data::NETDB_STORE_TYPE_ENCRYPTED_LEASESET2) // encrypt if type 5
|
if (isPublishedEncrypted) // encrypt if type 5
|
||||||
ls2 = std::make_shared<i2p::data::LocalEncryptedLeaseSet2> (ls2, m_Keys, m_AuthType, m_AuthKeys);
|
ls2 = std::make_shared<i2p::data::LocalEncryptedLeaseSet2> (ls2, m_Keys, m_AuthType, m_AuthKeys);
|
||||||
leaseSet = ls2;
|
leaseSet = ls2;
|
||||||
}
|
}
|
||||||
|
|
|
@ -303,6 +303,11 @@ namespace data
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (flags & LEASESET2_FLAG_UNPUBLISHED_LEASESET) m_IsPublic = false;
|
if (flags & LEASESET2_FLAG_UNPUBLISHED_LEASESET) m_IsPublic = false;
|
||||||
|
if (flags & LEASESET2_FLAG_PUBLISHED_ENCRYPTED)
|
||||||
|
{
|
||||||
|
m_IsPublishedEncrypted = true;
|
||||||
|
m_IsPublic = true;
|
||||||
|
}
|
||||||
// type specific part
|
// type specific part
|
||||||
size_t s = 0;
|
size_t s = 0;
|
||||||
switch (m_StoreType)
|
switch (m_StoreType)
|
||||||
|
@ -742,7 +747,8 @@ namespace data
|
||||||
|
|
||||||
LocalLeaseSet2::LocalLeaseSet2 (uint8_t storeType, const i2p::data::PrivateKeys& keys,
|
LocalLeaseSet2::LocalLeaseSet2 (uint8_t storeType, const i2p::data::PrivateKeys& keys,
|
||||||
uint16_t keyType, uint16_t keyLen, const uint8_t * encryptionPublicKey,
|
uint16_t keyType, uint16_t keyLen, const uint8_t * encryptionPublicKey,
|
||||||
std::vector<std::shared_ptr<i2p::tunnel::InboundTunnel> > tunnels, bool isPublic):
|
std::vector<std::shared_ptr<i2p::tunnel::InboundTunnel> > tunnels,
|
||||||
|
bool isPublic, bool isPublishedEncrypted):
|
||||||
LocalLeaseSet (keys.GetPublic (), nullptr, 0)
|
LocalLeaseSet (keys.GetPublic (), nullptr, 0)
|
||||||
{
|
{
|
||||||
auto identity = keys.GetPublic ();
|
auto identity = keys.GetPublic ();
|
||||||
|
@ -757,6 +763,11 @@ namespace data
|
||||||
flags |= LEASESET2_FLAG_OFFLINE_KEYS;
|
flags |= LEASESET2_FLAG_OFFLINE_KEYS;
|
||||||
m_BufferLen += keys.GetOfflineSignature ().size ();
|
m_BufferLen += keys.GetOfflineSignature ().size ();
|
||||||
}
|
}
|
||||||
|
if (isPublishedEncrypted)
|
||||||
|
{
|
||||||
|
flags |= LEASESET2_FLAG_PUBLISHED_ENCRYPTED;
|
||||||
|
isPublic = true;
|
||||||
|
}
|
||||||
if (!isPublic) flags |= LEASESET2_FLAG_UNPUBLISHED_LEASESET;
|
if (!isPublic) flags |= LEASESET2_FLAG_UNPUBLISHED_LEASESET;
|
||||||
|
|
||||||
m_Buffer = new uint8_t[m_BufferLen + 1];
|
m_Buffer = new uint8_t[m_BufferLen + 1];
|
||||||
|
|
|
@ -82,6 +82,7 @@ namespace data
|
||||||
virtual uint8_t GetOrigStoreType () const { return NETDB_STORE_TYPE_LEASESET; };
|
virtual uint8_t GetOrigStoreType () const { return NETDB_STORE_TYPE_LEASESET; };
|
||||||
virtual uint32_t GetPublishedTimestamp () const { return 0; }; // should be set for LeaseSet2 only
|
virtual uint32_t GetPublishedTimestamp () const { return 0; }; // should be set for LeaseSet2 only
|
||||||
virtual std::shared_ptr<const i2p::crypto::Verifier> GetTransientVerifier () const { return nullptr; };
|
virtual std::shared_ptr<const i2p::crypto::Verifier> GetTransientVerifier () const { return nullptr; };
|
||||||
|
virtual bool IsPublishedEncrypted () const { return false; };
|
||||||
|
|
||||||
// implements RoutingDestination
|
// implements RoutingDestination
|
||||||
std::shared_ptr<const IdentityEx> GetIdentity () const { return m_Identity; };
|
std::shared_ptr<const IdentityEx> GetIdentity () const { return m_Identity; };
|
||||||
|
@ -130,6 +131,7 @@ namespace data
|
||||||
|
|
||||||
const uint16_t LEASESET2_FLAG_OFFLINE_KEYS = 0x0001;
|
const uint16_t LEASESET2_FLAG_OFFLINE_KEYS = 0x0001;
|
||||||
const uint16_t LEASESET2_FLAG_UNPUBLISHED_LEASESET = 0x0002;
|
const uint16_t LEASESET2_FLAG_UNPUBLISHED_LEASESET = 0x0002;
|
||||||
|
const uint16_t LEASESET2_FLAG_PUBLISHED_ENCRYPTED = 0x0004;
|
||||||
|
|
||||||
class LeaseSet2: public LeaseSet
|
class LeaseSet2: public LeaseSet
|
||||||
{
|
{
|
||||||
|
@ -141,6 +143,7 @@ namespace data
|
||||||
uint8_t GetOrigStoreType () const { return m_OrigStoreType; };
|
uint8_t GetOrigStoreType () const { return m_OrigStoreType; };
|
||||||
uint32_t GetPublishedTimestamp () const { return m_PublishedTimestamp; };
|
uint32_t GetPublishedTimestamp () const { return m_PublishedTimestamp; };
|
||||||
bool IsPublic () const { return m_IsPublic; };
|
bool IsPublic () const { return m_IsPublic; };
|
||||||
|
bool IsPublishedEncrypted () const { return m_IsPublishedEncrypted; };
|
||||||
std::shared_ptr<const i2p::crypto::Verifier> GetTransientVerifier () const { return m_TransientVerifier; };
|
std::shared_ptr<const i2p::crypto::Verifier> GetTransientVerifier () const { return m_TransientVerifier; };
|
||||||
void Update (const uint8_t * buf, size_t len, bool verifySignature);
|
void Update (const uint8_t * buf, size_t len, bool verifySignature);
|
||||||
|
|
||||||
|
@ -164,7 +167,7 @@ namespace data
|
||||||
|
|
||||||
uint8_t m_StoreType, m_OrigStoreType;
|
uint8_t m_StoreType, m_OrigStoreType;
|
||||||
uint32_t m_PublishedTimestamp = 0;
|
uint32_t m_PublishedTimestamp = 0;
|
||||||
bool m_IsPublic = true;
|
bool m_IsPublic = true, m_IsPublishedEncrypted = false;
|
||||||
std::shared_ptr<i2p::crypto::Verifier> m_TransientVerifier;
|
std::shared_ptr<i2p::crypto::Verifier> m_TransientVerifier;
|
||||||
std::shared_ptr<i2p::crypto::CryptoKeyEncryptor> m_Encryptor; // for standardLS2
|
std::shared_ptr<i2p::crypto::CryptoKeyEncryptor> m_Encryptor; // for standardLS2
|
||||||
};
|
};
|
||||||
|
@ -230,7 +233,8 @@ namespace data
|
||||||
|
|
||||||
LocalLeaseSet2 (uint8_t storeType, const i2p::data::PrivateKeys& keys,
|
LocalLeaseSet2 (uint8_t storeType, const i2p::data::PrivateKeys& keys,
|
||||||
uint16_t keyType, uint16_t keyLen, const uint8_t * encryptionPublicKey,
|
uint16_t keyType, uint16_t keyLen, const uint8_t * encryptionPublicKey,
|
||||||
std::vector<std::shared_ptr<i2p::tunnel::InboundTunnel> > tunnels, bool isPublic);
|
std::vector<std::shared_ptr<i2p::tunnel::InboundTunnel> > tunnels,
|
||||||
|
bool isPublic, bool isPublishedEncrypted = false);
|
||||||
LocalLeaseSet2 (uint8_t storeType, std::shared_ptr<const IdentityEx> identity, const uint8_t * buf, size_t len); // from I2CP
|
LocalLeaseSet2 (uint8_t storeType, std::shared_ptr<const IdentityEx> identity, const uint8_t * buf, size_t len); // from I2CP
|
||||||
|
|
||||||
virtual ~LocalLeaseSet2 () { delete[] m_Buffer; };
|
virtual ~LocalLeaseSet2 () { delete[] m_Buffer; };
|
||||||
|
|
Loading…
Reference in a new issue