示例#1
0
        public string Serialize(ConnectionInfo serializationTarget)
        {
            var factory = new CryptographyProviderFactory();

            _cryptographyProvider = factory.CreateAeadCryptographyProvider(mRemoteNG.Settings.Default.EncryptionEngine, mRemoteNG.Settings.Default.EncryptionBlockCipherMode);
            return(SerializeConnectionsData(serializationTarget));
        }
        public void Setup()
        {
            var cryptoProvider = new CryptographyProviderFactory().CreateAeadCryptographyProvider(
                BlockCipherEngines.AES, BlockCipherModes.GCM);

            _connectionNodeSerializer = new XmlConnectionNodeSerializer(cryptoProvider, "myPassword1".ConvertToSecureString());
        }
        public void DecryptedTextIsEqualToOriginalPlainText(BlockCipherEngines engine, BlockCipherModes mode)
        {
            var cryptoProvider      = new CryptographyProviderFactory().CreateAeadCryptographyProvider(engine, mode);
            var cipherText          = cryptoProvider.Encrypt(_plainText, _encryptionKey);
            var decryptedCipherText = cryptoProvider.Decrypt(cipherText, _encryptionKey);

            Assert.That(decryptedCipherText, Is.EqualTo(_plainText));
        }
示例#4
0
        public void EncryptionModeSerialized(BlockCipherEngines engine, BlockCipherModes mode)
        {
            var cryptoProvider = new CryptographyProviderFactory().CreateAeadCryptographyProvider(engine, mode);
            var element        = _rootNodeSerializer.SerializeRootNodeInfo(_rootNodeInfo, cryptoProvider);
            var attributeValue = element.Attribute(XName.Get("BlockCipherMode"))?.Value;

            Assert.That(attributeValue, Is.EqualTo(mode.ToString()));
        }
        public void Setup()
        {
            var connectionTreeModel = SetupConnectionTreeModel();
            var cryptoProvider      = new CryptographyProviderFactory().CreateAeadCryptographyProvider(BlockCipherEngines.AES, BlockCipherModes.GCM);

            _originalDocument  = new XmlConnectionsDocumentCompiler(cryptoProvider).CompileDocument(connectionTreeModel, false, false);
            _documentEncryptor = new XmlConnectionsDocumentEncryptor(cryptoProvider);
        }
        public void InheritanceNotSerialiedWhenFiltered(string attributeName, ConnectionInfo connectionInfo)
        {
            var saveFilter     = new SaveFilter(true);
            var cryptoProvider = new CryptographyProviderFactory().CreateAeadCryptographyProvider(BlockCipherEngines.AES, BlockCipherModes.GCM);

            _connectionNodeSerializer = new XmlConnectionNodeSerializer(cryptoProvider, "myPassword1".ConvertToSecureString(), saveFilter);
            var returnVal       = _connectionNodeSerializer.SerializeConnectionInfo(connectionInfo);
            var targetAttribute = returnVal.Attribute(XName.Get(attributeName));

            Assert.That(targetAttribute?.Value, Is.EqualTo(false.ToString()));
        }
        public void SerializeAndDeserializeWithCustomKdfIterationsValue()
        {
            var cryptoProvider = new CryptographyProviderFactory().CreateAeadCryptographyProvider(BlockCipherEngines.AES, BlockCipherModes.GCM);

            cryptoProvider.KeyDerivationIterations = 5000;
            _serializer = new XmlConnectionsSerializer(cryptoProvider);
            var originalModel     = SetupConnectionTreeModel();
            var serializedContent = _serializer.Serialize(originalModel);

            _deserializer = new XmlConnectionsDeserializer(serializedContent);
            var deserializedModel = _deserializer.Deserialize();
            var nodeNamesFromDeserializedModel = deserializedModel.GetRecursiveChildList().Select(node => node.Name);
            var nodeNamesFromOriginalModel     = originalModel.GetRecursiveChildList().Select(node => node.Name);

            Assert.That(nodeNamesFromDeserializedModel, Is.EquivalentTo(nodeNamesFromOriginalModel));
        }
示例#8
0
        private static void SaveExportFile(string fileName, ConnectionsSaver.Format saveFormat, SaveFilter saveFilter, ConnectionInfo exportTarget)
        {
            try
            {
                ISerializer <string> serializer;
                switch (saveFormat)
                {
                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)
                    {
                        Export     = true,
                        SaveFilter = saveFilter
                    };
                    break;

                case ConnectionsSaver.Format.mRCSV:
                    serializer = new CsvConnectionsSerializerMremotengFormat
                    {
                        SaveFilter = saveFilter
                    };
                    break;

                default:
                    throw new ArgumentOutOfRangeException(nameof(saveFormat), saveFormat, null);
                }
                var serializedData   = serializer.Serialize(exportTarget);
                var fileDataProvider = new FileDataProvider(fileName);
                fileDataProvider.Save(serializedData);
            }
            catch (Exception ex)
            {
                Runtime.MessageCollector.AddExceptionStackTrace($"Export.SaveExportFile(\"{fileName}\") failed.", ex);
            }
            finally
            {
                Runtime.RemoteConnectionsSyncronizer?.Enable();
            }
        }
示例#9
0
        private void SaveToXml()
        {
            try
            {
                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,
                    SaveFilter        = SaveFilter,
                    UseFullEncryption = mRemoteNG.Settings.Default.EncryptCompleteConnectionsFile
                };
                var xml = xmlConnectionsSerializer.Serialize(ConnectionTreeModel);

                var fileDataProvider = new FileDataProviderWithBackup(ConnectionFileName);
                fileDataProvider.Save(xml);
            }
            catch (Exception ex)
            {
                Runtime.MessageCollector.AddExceptionStackTrace("SaveToXml failed", ex);
            }
        }
        public void Setup()
        {
            var cryptoProvider = new CryptographyProviderFactory().CreateAeadCryptographyProvider(BlockCipherEngines.AES, BlockCipherModes.GCM);

            _serializer = new XmlConnectionsSerializer(cryptoProvider);
        }
 public void TearDown()
 {
     _cryptographyProviderFactory = null;
 }
 public void SetUp()
 {
     _cryptographyProviderFactory = new CryptographyProviderFactory();
 }
        public void GetCipherMode(BlockCipherEngines engine, BlockCipherModes mode)
        {
            var cryptoProvider = new CryptographyProviderFactory().CreateAeadCryptographyProvider(engine, mode);

            Assert.That(cryptoProvider.CipherMode, Is.EqualTo(mode));
        }