|
|
@ -867,13 +867,18 @@ namespace client |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
// if no param or valid crypto type use from identity
|
|
|
|
// if no param or valid crypto type use from identity
|
|
|
|
if (encryptionKeyTypes.empty ()) encryptionKeyTypes.insert (GetIdentity ()->GetCryptoKeyType ()); |
|
|
|
bool isSingleKey = false; |
|
|
|
|
|
|
|
if (encryptionKeyTypes.empty ()) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
isSingleKey = true; |
|
|
|
|
|
|
|
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); // TODO:
|
|
|
|
PersistTemporaryKeys (encryptionKey, isSingleKey); |
|
|
|
else |
|
|
|
else |
|
|
|
encryptionKey->GenerateKeys (); |
|
|
|
encryptionKey->GenerateKeys (); |
|
|
|
encryptionKey->CreateDecryptor (); |
|
|
|
encryptionKey->CreateDecryptor (); |
|
|
@ -1119,10 +1124,12 @@ namespace client |
|
|
|
return ret; |
|
|
|
return ret; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void ClientDestination::PersistTemporaryKeys (EncryptionKey * keys) |
|
|
|
void ClientDestination::PersistTemporaryKeys (EncryptionKey * keys, bool isSingleKey) |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
if (!keys) return; |
|
|
|
std::string ident = GetIdentHash().ToBase32(); |
|
|
|
std::string ident = GetIdentHash().ToBase32(); |
|
|
|
std::string path = i2p::fs::DataDirPath("destinations", (ident + ".dat")); |
|
|
|
std::string path = i2p::fs::DataDirPath("destinations", |
|
|
|
|
|
|
|
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) { |
|
|
|