Пример #1
0
        public void SetUp()
        {
            hashProviders           = new Dictionary <string, IHashProvider>();
            symmetricCrytoProviders = new Dictionary <string, ISymmetricCryptoProvider>();

            CreateKeyFile(symmetricKeyFile);
            CreateKeyFile(keyedHashKeyFile);

            configSource = ConfigurationSourceFactory.Create();

            HashProviderFactory factory = new HashProviderFactory(configSource);

            defaultHashProvider = factory.Create(hashInstance);
            hashProviders.Add(hashInstance, defaultHashProvider);

            SymmetricCryptoProviderFactory symmfactory = new SymmetricCryptoProviderFactory(configSource);

            defaultSymmetricCryptoProvider  = symmfactory.Create(symmInstance);
            algorithSymmetricCryptoProvider = symmfactory.Create(symmetricAlgorithm1);

            symmetricCrytoProviders.Add(symmInstance, defaultSymmetricCryptoProvider);
            symmetricCrytoProviders.Add(symmetricAlgorithm1, algorithSymmetricCryptoProvider);

            var container = EnterpriseLibraryContainer.CreateDefaultContainer(configSource);

            cryptographyManager = container.GetInstance <CryptographyManager>();
        }
        public void SetUp()
        {
            hashProviders = new Dictionary<string, IHashProvider>();
            symmetricCrytoProviders = new Dictionary<string, ISymmetricCryptoProvider>();

            CreateKeyFile(symmetricKeyFile);
            CreateKeyFile(keyedHashKeyFile);

            configSource = ConfigurationSourceFactory.Create();

            HashProviderFactory factory = new HashProviderFactory(configSource);
            defaultHashProvider = factory.Create(hashInstance);
            hashProviders.Add(hashInstance, defaultHashProvider);

            SymmetricCryptoProviderFactory symmfactory = new SymmetricCryptoProviderFactory(configSource);
            defaultSymmetricCryptoProvider = symmfactory.Create(symmInstance);
            algorithSymmetricCryptoProvider = symmfactory.Create(symmetricAlgorithm1);

            symmetricCrytoProviders.Add(symmInstance, defaultSymmetricCryptoProvider);
            symmetricCrytoProviders.Add(symmetricAlgorithm1, algorithSymmetricCryptoProvider);

            var container = EnterpriseLibraryContainer.CreateDefaultContainer(configSource);

            cryptographyManager = container.GetInstance<CryptographyManager>();
        }
        public void CreateByNameTest()
        {
            SymmetricCryptoProviderFactory factory = new SymmetricCryptoProviderFactory(CreateSource(providerName));
            ISymmetricCryptoProvider provider = factory.Create(providerName);

            Assert.AreEqual(typeof(DpapiSymmetricCryptoProvider), provider.GetType());
        }
        public void CreateByNameTest()
        {
            SymmetricCryptoProviderFactory factory  = new SymmetricCryptoProviderFactory(CreateSource(providerName));
            ISymmetricCryptoProvider       provider = factory.Create(providerName);

            Assert.AreEqual(typeof(DpapiSymmetricCryptoProvider), provider.GetType());
        }
 public void CreateProviderWithEmptyNameThrows()
 {
     SymmetricCryptoProviderFactory factory = new SymmetricCryptoProviderFactory(CreateSource(providerName));
     factory.Create(string.Empty);
 }
 public void CreateProviderWithNullNameThrows()
 {
     SymmetricCryptoProviderFactory factory = new SymmetricCryptoProviderFactory(CreateSource(providerName));
     factory.Create(null);
 }
 public void LookupInvalidProviderThrows()
 {
     SymmetricCryptoProviderFactory factory = new SymmetricCryptoProviderFactory(CreateSource(providerName));
     factory.Create("provider3");
 }
        public void CreateProviderWithEmptyNameThrows()
        {
            SymmetricCryptoProviderFactory factory = new SymmetricCryptoProviderFactory(CreateSource(providerName));

            factory.Create(string.Empty);
        }
        public void CreateProviderWithNullNameThrows()
        {
            SymmetricCryptoProviderFactory factory = new SymmetricCryptoProviderFactory(CreateSource(providerName));

            factory.Create(null);
        }
        public void LookupInvalidProviderThrows()
        {
            SymmetricCryptoProviderFactory factory = new SymmetricCryptoProviderFactory(CreateSource(providerName));

            factory.Create("provider3");
        }