|
|
@ -1013,18 +1013,15 @@ namespace client
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// if no param or valid crypto type use from identity
|
|
|
|
// if no param or valid crypto type use from identity
|
|
|
|
bool isSingleKey = false;
|
|
|
|
|
|
|
|
if (encryptionKeyTypes.empty ())
|
|
|
|
if (encryptionKeyTypes.empty ())
|
|
|
|
{
|
|
|
|
encryptionKeyTypes.insert ( { GetIdentity ()->GetCryptoKeyType (),
|
|
|
|
isSingleKey = true;
|
|
|
|
i2p::data::CRYPTO_KEY_TYPE_ECIES_X25519_AEAD }); // usually 0,4
|
|
|
|
encryptionKeyTypes.insert (GetIdentity ()->GetCryptoKeyType ());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (auto& it: encryptionKeyTypes)
|
|
|
|
for (auto& it: encryptionKeyTypes)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
auto encryptionKey = new EncryptionKey (it);
|
|
|
|
auto encryptionKey = new EncryptionKey (it);
|
|
|
|
if (IsPublic ())
|
|
|
|
if (IsPublic ())
|
|
|
|
PersistTemporaryKeys (encryptionKey, isSingleKey);
|
|
|
|
PersistTemporaryKeys (encryptionKey);
|
|
|
|
else
|
|
|
|
else
|
|
|
|
encryptionKey->GenerateKeys ();
|
|
|
|
encryptionKey->GenerateKeys ();
|
|
|
|
encryptionKey->CreateDecryptor ();
|
|
|
|
encryptionKey->CreateDecryptor ();
|
|
|
@ -1383,12 +1380,11 @@ namespace client
|
|
|
|
return ret;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void ClientDestination::PersistTemporaryKeys (EncryptionKey * keys, bool isSingleKey)
|
|
|
|
void ClientDestination::PersistTemporaryKeys (EncryptionKey * keys)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (!keys) return;
|
|
|
|
if (!keys) return;
|
|
|
|
std::string ident = GetIdentHash().ToBase32();
|
|
|
|
std::string ident = GetIdentHash().ToBase32();
|
|
|
|
std::string path = i2p::fs::DataDirPath("destinations",
|
|
|
|
std::string path = i2p::fs::DataDirPath("destinations", ident + "." + std::to_string (keys->keyType) + ".dat");
|
|
|
|
isSingleKey ? (ident + ".dat") : (ident + "." + std::to_string (keys->keyType) + ".dat"));
|
|
|
|
|
|
|
|
std::ifstream f(path, std::ifstream::binary);
|
|
|
|
std::ifstream f(path, std::ifstream::binary);
|
|
|
|
|
|
|
|
|
|
|
|
if (f) {
|
|
|
|
if (f) {
|
|
|
|