|
|
|
@ -777,20 +777,20 @@ namespace client
@@ -777,20 +777,20 @@ namespace client
|
|
|
|
|
m_DatagramDestination (nullptr), m_RefCounter (0), |
|
|
|
|
m_ReadyChecker(GetService()) |
|
|
|
|
{ |
|
|
|
|
i2p::data::CryptoKeyType keyType = GetIdentity ()->GetCryptoKeyType (); |
|
|
|
|
m_EncryptionKeyType = GetIdentity ()->GetCryptoKeyType (); |
|
|
|
|
// extract encryption type params for LS2
|
|
|
|
|
if (GetLeaseSetType () == i2p::data::NETDB_STORE_TYPE_STANDARD_LEASESET2 && params) |
|
|
|
|
{ |
|
|
|
|
auto it = params->find (I2CP_PARAM_LEASESET_ENCRYPTION_TYPE); |
|
|
|
|
if (it != params->end ()) |
|
|
|
|
keyType = std::stoi(it->second); |
|
|
|
|
m_EncryptionKeyType = std::stoi(it->second); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (isPublic) |
|
|
|
|
PersistTemporaryKeys (keyType); |
|
|
|
|
if (isPublic && m_EncryptionKeyType == GetIdentity ()->GetCryptoKeyType ()) // TODO: presist key type
|
|
|
|
|
PersistTemporaryKeys (); |
|
|
|
|
else |
|
|
|
|
i2p::data::PrivateKeys::GenerateCryptoKeyPair (keyType, m_EncryptionPrivateKey, m_EncryptionPublicKey); |
|
|
|
|
m_Decryptor = i2p::data::PrivateKeys::CreateDecryptor (keyType, m_EncryptionPrivateKey); |
|
|
|
|
i2p::data::PrivateKeys::GenerateCryptoKeyPair (m_EncryptionKeyType, m_EncryptionPrivateKey, m_EncryptionPublicKey); |
|
|
|
|
m_Decryptor = i2p::data::PrivateKeys::CreateDecryptor (m_EncryptionKeyType, m_EncryptionPrivateKey); |
|
|
|
|
if (isPublic) |
|
|
|
|
LogPrint (eLogInfo, "Destination: Local address ", GetIdentHash().ToBase32 (), " created"); |
|
|
|
|
|
|
|
|
@ -1008,7 +1008,7 @@ namespace client
@@ -1008,7 +1008,7 @@ namespace client
|
|
|
|
|
return ret; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void ClientDestination::PersistTemporaryKeys (i2p::data::CryptoKeyType keyType) |
|
|
|
|
void ClientDestination::PersistTemporaryKeys () |
|
|
|
|
{ |
|
|
|
|
std::string ident = GetIdentHash().ToBase32(); |
|
|
|
|
std::string path = i2p::fs::DataDirPath("destinations", (ident + ".dat")); |
|
|
|
@ -1020,10 +1020,10 @@ namespace client
@@ -1020,10 +1020,10 @@ namespace client
|
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
LogPrint (eLogInfo, "Destination: Creating new temporary keys of type ", (int)keyType, " for address ", ident, ".b32.i2p"); |
|
|
|
|
LogPrint (eLogInfo, "Destination: Creating new temporary keys of type for address ", ident, ".b32.i2p"); |
|
|
|
|
memset (m_EncryptionPrivateKey, 0, 256); |
|
|
|
|
memset (m_EncryptionPublicKey, 0, 256); |
|
|
|
|
i2p::data::PrivateKeys::GenerateCryptoKeyPair (keyType, m_EncryptionPrivateKey, m_EncryptionPublicKey); |
|
|
|
|
i2p::data::PrivateKeys::GenerateCryptoKeyPair (GetIdentity ()->GetCryptoKeyType (), m_EncryptionPrivateKey, m_EncryptionPublicKey); |
|
|
|
|
|
|
|
|
|
std::ofstream f1 (path, std::ofstream::binary | std::ofstream::out); |
|
|
|
|
if (f1) { |
|
|
|
@ -1048,7 +1048,7 @@ namespace client
@@ -1048,7 +1048,7 @@ namespace client
|
|
|
|
|
// 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 (), keyLen, m_EncryptionPublicKey, tunnels); |
|
|
|
|
GetIdentity (), m_EncryptionKeyType, keyLen, m_EncryptionPublicKey, tunnels); |
|
|
|
|
// sign
|
|
|
|
|
Sign (leaseSet->GetBuffer () - 1, leaseSet->GetBufferLen () - leaseSet->GetSignatureLen () + 1, leaseSet->GetSignature ()); // + leading store type
|
|
|
|
|
} |
|
|
|
|