Browse Source

call RoutingDestination::Encrypt instead ElGamalEncrypt

pull/996/head
orignal 7 years ago
parent
commit
53d71d29ff
  1. 2
      libi2pd/Garlic.cpp
  2. 3
      libi2pd/Identity.h
  3. 2
      libi2pd/LeaseSet.cpp
  4. 3
      libi2pd/LeaseSet.h
  5. 7
      libi2pd/RouterInfo.cpp
  6. 3
      libi2pd/RouterInfo.h

2
libi2pd/Garlic.cpp

@ -189,7 +189,7 @@ namespace garlic @@ -189,7 +189,7 @@ namespace garlic
uint8_t iv[32]; // IV is first 16 bytes
SHA256(elGamal.preIV, 32, iv);
BN_CTX * ctx = BN_CTX_new ();
i2p::crypto::ElGamalEncrypt (m_Destination->GetEncryptionPublicKey (), (uint8_t *)&elGamal, buf, ctx, true);
m_Destination->Encrypt ((uint8_t *)&elGamal, buf, ctx);
BN_CTX_free (ctx);
m_Encryption.SetIV (iv);
buf += 514;

3
libi2pd/Identity.h

@ -191,8 +191,7 @@ namespace data @@ -191,8 +191,7 @@ namespace data
virtual ~RoutingDestination () {};
virtual std::shared_ptr<const IdentityEx> GetIdentity () const = 0;
virtual const uint8_t * GetEncryptionPublicKey () const = 0; // deprecated
virtual void Encrypt (const uint8_t * data, uint8_t * encrypted, BN_CTX * ctx) = 0; // encrypt data for
virtual void Encrypt (const uint8_t * data, uint8_t * encrypted, BN_CTX * ctx) const = 0; // encrypt data for
virtual bool IsDestination () const = 0; // for garlic
const IdentHash& GetIdentHash () const { return GetIdentity ()->GetIdentHash (); };

2
libi2pd/LeaseSet.cpp

@ -208,7 +208,7 @@ namespace data @@ -208,7 +208,7 @@ namespace data
return ts > m_ExpirationTime;
}
void LeaseSet::Encrypt (const uint8_t * data, uint8_t * encrypted, BN_CTX * ctx)
void LeaseSet::Encrypt (const uint8_t * data, uint8_t * encrypted, BN_CTX * ctx) const
{
auto encryptor = m_Identity->CreateEncryptor (m_EncryptionKey);
if (encryptor)

3
libi2pd/LeaseSet.h

@ -76,8 +76,7 @@ namespace data @@ -76,8 +76,7 @@ namespace data
// implements RoutingDestination
std::shared_ptr<const IdentityEx> GetIdentity () const { return m_Identity; };
const uint8_t * GetEncryptionPublicKey () const { return m_EncryptionKey; }; // deprecated
void Encrypt (const uint8_t * data, uint8_t * encrypted, BN_CTX * ctx);
void Encrypt (const uint8_t * data, uint8_t * encrypted, BN_CTX * ctx) const;
bool IsDestination () const { return true; };
private:

7
libi2pd/RouterInfo.cpp

@ -829,10 +829,11 @@ namespace data @@ -829,10 +829,11 @@ namespace data
return m_Profile;
}
void RouterInfo::Encrypt (const uint8_t * data, uint8_t * encrypted, BN_CTX * ctx)
void RouterInfo::Encrypt (const uint8_t * data, uint8_t * encrypted, BN_CTX * ctx) const
{
// TODO: we always assume ElGamal for RouterInfo, might change later
i2p::crypto::ElGamalEncrypt (m_RouterIdentity->GetEncryptionPublicKey (), data, encrypted, ctx);
auto encryptor = m_RouterIdentity->CreateEncryptor (nullptr);
if (encryptor)
encryptor->Encrypt (data, encrypted, ctx);
}
}
}

3
libi2pd/RouterInfo.h

@ -186,8 +186,7 @@ namespace data @@ -186,8 +186,7 @@ namespace data
// implements RoutingDestination
std::shared_ptr<const IdentityEx> GetIdentity () const { return m_RouterIdentity; };
const uint8_t * GetEncryptionPublicKey () const { return m_RouterIdentity->GetStandardIdentity ().publicKey; }; // deprecated
void Encrypt (const uint8_t * data, uint8_t * encrypted, BN_CTX * ctx);
void Encrypt (const uint8_t * data, uint8_t * encrypted, BN_CTX * ctx) const;
bool IsDestination () const { return false; };

Loading…
Cancel
Save