mirror of
https://github.com/mRemoteNG/mRemoteNG.git
synced 2026-02-17 22:11:48 +08:00
The XmlConnectionsSerializer now looks to its crypto provider for the value of KdfIterations. This insulates the function from global state (Settings)
This commit is contained in:
@@ -70,6 +70,21 @@ namespace mRemoteNGTests.Config.Serializers
|
||||
Assert.That(serializedEncryptionMode, Is.EqualTo(expectedModeAsString));
|
||||
}
|
||||
|
||||
[TestCase(1000)]
|
||||
[TestCase(1001)]
|
||||
[TestCase(9999)]
|
||||
[TestCase(10000)]
|
||||
public void KeyDerivationIterationsSerialized(int kdfIterations)
|
||||
{
|
||||
var encryptor = new AeadCryptographyProvider {KeyDerivationIterations = kdfIterations};
|
||||
_serializer = new XmlConnectionsSerializer(encryptor);
|
||||
var serializedData = _serializer.Serialize(new ConnectionInfo());
|
||||
var xmlDoc = new XmlDocument();
|
||||
xmlDoc.LoadXml(serializedData);
|
||||
var serializedIterations = xmlDoc.DocumentElement?.Attributes["KdfIterations"].Value;
|
||||
Assert.That(serializedIterations, Is.EqualTo(kdfIterations.ToString()));
|
||||
}
|
||||
|
||||
private ConnectionTreeModel SetupConnectionTreeModel()
|
||||
{
|
||||
/*
|
||||
|
||||
@@ -75,6 +75,7 @@ namespace mRemoteNG.App
|
||||
case ConnectionsSaver.Format.mRXML:
|
||||
var factory = new CryptographyProviderFactory();
|
||||
var cryptographyProvider = factory.CreateAeadCryptographyProvider(mRemoteNG.Settings.Default.EncryptionEngine, mRemoteNG.Settings.Default.EncryptionBlockCipherMode);
|
||||
cryptographyProvider.KeyDerivationIterations = Settings.Default.EncryptionKeyDerivationIterations;
|
||||
serializer = new XmlConnectionsSerializer(cryptographyProvider);
|
||||
((XmlConnectionsSerializer) serializer).SaveFilter = saveFilter;
|
||||
break;
|
||||
|
||||
@@ -235,6 +235,7 @@ namespace mRemoteNG.Config.Connections
|
||||
{
|
||||
var factory = new CryptographyProviderFactory();
|
||||
var cryptographyProvider = factory.CreateAeadCryptographyProvider(mRemoteNG.Settings.Default.EncryptionEngine, mRemoteNG.Settings.Default.EncryptionBlockCipherMode);
|
||||
cryptographyProvider.KeyDerivationIterations = mRemoteNG.Settings.Default.EncryptionKeyDerivationIterations;
|
||||
var xmlConnectionsSerializer = new XmlConnectionsSerializer(cryptographyProvider)
|
||||
{
|
||||
Export = Export,
|
||||
|
||||
@@ -154,7 +154,7 @@ namespace mRemoteNG.Config.Serializers
|
||||
_xmlTextWriter.WriteAttributeString("EncryptionEngine", "", cipherEngine ?? "");
|
||||
var cipherMode = Enum.GetName(typeof(BlockCipherModes), _cryptographyProvider.CipherMode);
|
||||
_xmlTextWriter.WriteAttributeString("BlockCipherMode", "", cipherMode ?? "");
|
||||
_xmlTextWriter.WriteAttributeString("KdfIterations", "", mRemoteNG.Settings.Default.EncryptionKeyDerivationIterations.ToString());
|
||||
_xmlTextWriter.WriteAttributeString("KdfIterations", "", _cryptographyProvider.KeyDerivationIterations.ToString());
|
||||
_xmlTextWriter.WriteAttributeString("FullFileEncryption", "", UseFullEncryption.ToString());
|
||||
|
||||
if (Export)
|
||||
|
||||
Reference in New Issue
Block a user