Browse Source

actual key size for LS2

pull/1288/head
orignal 6 years ago
parent
commit
6569c4aa03
  1. 10
      libi2pd/CryptoKey.h
  2. 3
      libi2pd/Destination.cpp

10
libi2pd/CryptoKey.h

@ -22,6 +22,7 @@ namespace crypto @@ -22,6 +22,7 @@ namespace crypto
virtual ~CryptoKeyDecryptor () {};
virtual bool Decrypt (const uint8_t * encrypted, uint8_t * data, BN_CTX * ctx, bool zeroPadding) = 0; // 512/514 bytes encrypted, 222 bytes data
virtual size_t GetPublicKeyLen () const = 0; // we need it to set key in LS2
};
// ElGamal
@ -43,7 +44,8 @@ namespace crypto @@ -43,7 +44,8 @@ namespace crypto
ElGamalDecryptor (const uint8_t * priv);
bool Decrypt (const uint8_t * encrypted, uint8_t * data, BN_CTX * ctx, bool zeroPadding);
size_t GetPublicKeyLen () const { return 256; };
private:
uint8_t m_PrivateKey[256];
@ -73,7 +75,8 @@ namespace crypto @@ -73,7 +75,8 @@ namespace crypto
ECIESP256Decryptor (const uint8_t * priv);
~ECIESP256Decryptor ();
bool Decrypt (const uint8_t * encrypted, uint8_t * data, BN_CTX * ctx, bool zeroPadding);
size_t GetPublicKeyLen () const { return 64; };
private:
EC_GROUP * m_Curve;
@ -105,7 +108,8 @@ namespace crypto @@ -105,7 +108,8 @@ namespace crypto
ECIESGOSTR3410Decryptor (const uint8_t * priv);
~ECIESGOSTR3410Decryptor ();
bool Decrypt (const uint8_t * encrypted, uint8_t * data, BN_CTX * ctx, bool zeroPadding);
size_t GetPublicKeyLen () const { return 64; };
private:
BIGNUM * m_PrivateKey;

3
libi2pd/Destination.cpp

@ -1037,8 +1037,9 @@ namespace client @@ -1037,8 +1037,9 @@ namespace client
else
{
// standard LS2 (type 3) assumed for now. TODO: implement others
auto keyLen = m_Decryptor ? m_Decryptor->GetPublicKeyLen () : 256;
leaseSet = new i2p::data::LocalLeaseSet2 (i2p::data::NETDB_STORE_TYPE_STANDARD_LEASESET2,
GetIdentity (), GetIdentity ()->GetCryptoKeyType (), 256, m_EncryptionPublicKey, tunnels);
GetIdentity (), GetIdentity ()->GetCryptoKeyType (), keyLen, m_EncryptionPublicKey, tunnels);
// sign
Sign (leaseSet->GetBuffer () - 1, leaseSet->GetBufferLen () - leaseSet->GetSignatureLen () + 1, leaseSet->GetSignature ()); // + leading store type
}

Loading…
Cancel
Save