public LocalMachineScopeStringEncryptor(IEntropyCreator entropyCreator, IDataProtectorFactory dataProtectorFactory)
 {
     if (entropyCreator == null) throw new ArgumentNullException("entropyCreator");
       if (dataProtectorFactory == null) throw new ArgumentNullException("dataProtectorFactory");
       _entropyCreator = entropyCreator;
       _dataProtectorFactory = dataProtectorFactory;
 }
        public void SetUp()
        {
            _entropyCreator = _entropyCreator.Fake();
              _dataProtectorFactory = _dataProtectorFactory.Fake();
              _sut = new LocalMachineScopeStringEncryptor(_entropyCreator, _dataProtectorFactory);

              _dataProtector = _dataProtector.Fake();
        }
Пример #3
0
        public void SetUp()
        {
            _entropyCreator       = _entropyCreator.Fake();
            _dataProtectorFactory = _dataProtectorFactory.Fake();
            _sut = new LocalMachineScopeStringEncryptor(_entropyCreator, _dataProtectorFactory);

            _dataProtector = _dataProtector.Fake();
        }
Пример #4
0
        // This constructor is used only for testing purposes and by the singleton provider
        // and should not otherwise be called during ASP.NET request processing.
        internal AspNetCoreCryptoServiceProvider(MachineKeyConfig machineKeyConfig = null, ICryptoAlgorithmFactory cryptoAlgorithmFactory = null, IMasterKeyProvider masterKeyProvider = null, IDataProtectorFactory dataProtectorFactory = null, KeyDerivationFunction keyDerivationFunction = null)
        {
            _machineKeyConfig       = machineKeyConfig;
            _cryptoAlgorithmFactory = cryptoAlgorithmFactory;
            _masterKeyProvider      = masterKeyProvider;
            _dataProtectorFactory   = dataProtectorFactory;
            _keyDerivationFunction  = keyDerivationFunction;

            // The DataProtectorCryptoService is active if specified as such in config
            _isDataProtectorEnabled = (machineKeyConfig != null && !String.IsNullOrWhiteSpace(machineKeyConfig.DataProtectorType));
        }
        // This constructor is used only for testing purposes and by the singleton provider
        // and should not otherwise be called during ASP.NET request processing.
        internal AspNetCryptoServiceProvider(MachineKeySection machineKeySection = null, ICryptoAlgorithmFactory cryptoAlgorithmFactory = null, IMasterKeyProvider masterKeyProvider = null, IDataProtectorFactory dataProtectorFactory = null, KeyDerivationFunction keyDerivationFunction = null) {
            _machineKeySection = machineKeySection;
            _cryptoAlgorithmFactory = cryptoAlgorithmFactory;
            _masterKeyProvider = masterKeyProvider;
            _dataProtectorFactory = dataProtectorFactory;
            _keyDerivationFunction = keyDerivationFunction;

            // This CryptoServiceProvider is active if specified as such in the <system.web/machineKey> section
            IsDefaultProvider = (machineKeySection != null && machineKeySection.CompatibilityMode >= MachineKeyCompatibilityMode.Framework45);

            // The DataProtectorCryptoService is active if specified as such in config
            _isDataProtectorEnabled = (machineKeySection != null && !String.IsNullOrWhiteSpace(machineKeySection.DataProtectorType));
        }
Пример #6
0
 public LocalMachineScopeStringEncryptor(IEntropyCreator entropyCreator, IDataProtectorFactory dataProtectorFactory)
 {
     if (entropyCreator == null)
     {
         throw new ArgumentNullException("entropyCreator");
     }
     if (dataProtectorFactory == null)
     {
         throw new ArgumentNullException("dataProtectorFactory");
     }
     _entropyCreator       = entropyCreator;
     _dataProtectorFactory = dataProtectorFactory;
 }
Пример #7
0
        // This constructor is used only for testing purposes and by the singleton provider
        // and should not otherwise be called during ASP.NET request processing.
        internal AspNetCryptoServiceProvider(MachineKeySection machineKeySection = null, ICryptoAlgorithmFactory cryptoAlgorithmFactory = null, IMasterKeyProvider masterKeyProvider = null, IDataProtectorFactory dataProtectorFactory = null, KeyDerivationFunction keyDerivationFunction = null)
        {
            _machineKeySection      = machineKeySection;
            _cryptoAlgorithmFactory = cryptoAlgorithmFactory;
            _masterKeyProvider      = masterKeyProvider;
            _dataProtectorFactory   = dataProtectorFactory;
            _keyDerivationFunction  = keyDerivationFunction;

            // This CryptoServiceProvider is active if specified as such in the <system.web/machineKey> section
            IsDefaultProvider = (machineKeySection != null && machineKeySection.CompatibilityMode >= MachineKeyCompatibilityMode.Framework45);

            // The DataProtectorCryptoService is active if specified as such in config
            _isDataProtectorEnabled = (machineKeySection != null && !String.IsNullOrWhiteSpace(machineKeySection.DataProtectorType));
        }
        private byte[] _encryptionIV = null;//SORCE_CHANGED added encryption IV to re-ecrypt the data

        // This constructor is used only for testing purposes and by the singleton provider
        // and should not otherwise be called during ASP.NET request processing.
        internal AspNetCryptoServiceProvider(string strValidationKey, string strValAlgo, string strDecryptionKey, string strDecAlgo)
        {
            MachineKeySection machineKeySection = new MachineKeySection();

            machineKeySection.DecryptionKey       = strDecryptionKey;
            machineKeySection.Decryption          = strDecAlgo;
            machineKeySection.ValidationKey       = strValidationKey;
            machineKeySection.ValidationAlgorithm = strValAlgo;

            _machineKeySection      = machineKeySection;
            _cryptoAlgorithmFactory = new MachineKeyCryptoAlgorithmFactory(machineKeySection);
            _masterKeyProvider      = new MachineKeyMasterKeyProvider(machineKeySection);
            _dataProtectorFactory   = new MachineKeyDataProtectorFactory(machineKeySection);
            _keyDerivationFunction  = SP800_108.DeriveKey;

            // This CryptoServiceProvider is active if specified as such in the <system.web/machineKey> section
            IsDefaultProvider = (machineKeySection != null && machineKeySection.CompatibilityMode >= MachineKeyCompatibilityMode.Framework45);

            // The DataProtectorCryptoService is active if specified as such in config
            _isDataProtectorEnabled = (machineKeySection != null && !String.IsNullOrWhiteSpace(machineKeySection.DataProtectorType));
        }
 public DataProtectorCryptoService(IDataProtectorFactory dataProtectorFactory, Purpose purpose)
 {
     this._dataProtectorFactory = dataProtectorFactory;
     this._purpose = purpose;
 }
 public DataProtectorCryptoService(IDataProtectorFactory dataProtectorFactory, Purpose purpose) {
     _dataProtectorFactory = dataProtectorFactory;
     _purpose = purpose;
 }