CreateAeadCryptographyProvider() public method

public CreateAeadCryptographyProvider ( BlockCipherEngines engine, BlockCipherModes mode ) : ICryptographyProvider
engine BlockCipherEngines
mode BlockCipherModes
return ICryptographyProvider
Example #1
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);
                 ((XmlConnectionsSerializer) serializer).SaveFilter = saveFilter;
                 break;
             case ConnectionsSaver.Format.mRCSV:
                 serializer = new CsvConnectionsSerializerMremotengFormat();
                 ((CsvConnectionsSerializerMremotengFormat)serializer).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();
     }
 }
Example #2
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);
            }
        }