Example #1
0
 public void SetUp()
 {
     provider            = new KeyedHashAlgorithmProviderDataManageabilityProvider();
     machineKey          = new MockRegistryKey(true);
     userKey             = new MockRegistryKey(true);
     configurationObject = new KeyedHashAlgorithmProviderData();
 }
 public void SetUp()
 {
     provider = new KeyedHashAlgorithmProviderDataManageabilityProvider();
     machineKey = new MockRegistryKey(true);
     userKey = new MockRegistryKey(true);
     configurationObject = new KeyedHashAlgorithmProviderData();
 }
 public void Properties()
 {
     byte[] key = new byte[] {0, 1, 2, 3, 4, 5, 6};
     KeyedHashAlgorithmProviderData data = new KeyedHashAlgorithmProviderData();
     data.Key = key;
     Assert.IsTrue(CryptographyUtility.CompareBytes(key, data.Key));
 }
Example #4
0
 public ProtectedKeySettingsProperty(IServiceProvider serviceProvider, KeyedHashAlgorithmProviderData configuration)
     : base(serviceProvider, "Key",
            new EditorAttribute(typeof(KeyManagerEditor), typeof(UITypeEditor)),
            new EditorWithReadOnlyTextAttribute(true))
 {
     this.configuration = configuration;
 }
Example #5
0
        public void KeyedHashAlgorithmProviderNodeTest()
        {
            bool saltEnabled   = false;
            Type algorithmType = typeof(HMACSHA1);
            ProtectedKeySettings keySettings = new ProtectedKeySettings("some filename", DataProtectionScope.CurrentUser);
            string name = "some name";

            KeyedHashAlgorithmProviderNode node = new KeyedHashAlgorithmProviderNode();

            node.Name          = name;
            node.SaltEnabled   = saltEnabled;
            node.AlgorithmType = algorithmType;
            node.Key           = keySettings;

            Assert.AreEqual(name, node.Name);
            Assert.AreEqual(algorithmType, node.AlgorithmType);
            Assert.AreEqual(saltEnabled, node.SaltEnabled);
            Assert.AreEqual(keySettings.Filename, node.Key.Filename);
            Assert.AreEqual(keySettings.Scope, node.Key.Scope);

            KeyedHashAlgorithmProviderData data = (KeyedHashAlgorithmProviderData)node.HashProviderData;

            Assert.AreEqual(name, data.Name);
            Assert.AreEqual(algorithmType, data.AlgorithmType);
            Assert.AreEqual(saltEnabled, data.SaltEnabled);
            Assert.AreEqual(keySettings.Filename, data.ProtectedKeyFilename);
            Assert.AreEqual(keySettings.Scope, data.ProtectedKeyProtectionScope);
        }
Example #6
0
 public void SetUp()
 {
     provider            = new ConfigurationElementManageabilityProviderWrapper(new KeyedHashAlgorithmProviderDataManageabilityProvider());
     machineKey          = new MockRegistryKey(true);
     userKey             = new MockRegistryKey(true);
     wmiSettings         = new List <ConfigurationSetting>();
     configurationObject = new KeyedHashAlgorithmProviderData();
 }
        public void Properties()
        {
            byte[] key = new byte[] { 0, 1, 2, 3, 4, 5, 6 };
            KeyedHashAlgorithmProviderData data = new KeyedHashAlgorithmProviderData();

            data.Key = key;
            Assert.IsTrue(CryptographyUtility.CompareBytes(key, data.Key));
        }
 public EncryptUsingKeyedHashAlgorithmProviderNamedBuilder(IConfigureCryptography context, string algorithmProviderName)
     : base(context)
 {
     providerData = new KeyedHashAlgorithmProviderData
     {
         Name = algorithmProviderName
     };
     CryptographySettings.HashProviders.Add(providerData);
 }
        /// <summary>
        /// Gets the cryptographer used for hashing.
        /// </summary>
        /// <returns>The cryptographer initialized with the configured key.</returns>
        protected override HashCryptographer GetHashCryptographer()
        {
            HashProviderData hashProviderData = CryptoConfigurationView.GetHashProviderData(ConfigurationName);

            ArgumentValidation.CheckExpectedType(hashProviderData, typeof(KeyedHashAlgorithmProviderData));

            KeyedHashAlgorithmProviderData keyedHashAlgorithmProviderData = (KeyedHashAlgorithmProviderData)hashProviderData;

            return(new HashCryptographer(keyedHashAlgorithmProviderData.AlgorithmType, keyedHashAlgorithmProviderData.Key));
        }
        public void SetUp()
        {
            // create a new random plain text secret
            this.plainText = new byte[12];
            RNGCryptoServiceProvider.Create().GetNonZeroBytes(this.plainText);

            this.data               = new KeyedHashAlgorithmProviderData();
            this.data.Name          = "name";
            this.data.AlgorithmType = typeof(HMACSHA1).AssemblyQualifiedName;
            this.data.SaltEnabled   = false;
            this.data.Key           = new byte[] { 1, 2, 3, 4 };

            this.defaultHashProvider = (KeyedHashAlgorithmProvider)CreateProvider(this.data);
        }
        public void Properties()
        {
            Guid appID = Guid.NewGuid();
            CryptographySettings settings = new CryptographySettings();

            KeyedHashAlgorithmProviderData hashData = new KeyedHashAlgorithmProviderData();
            hashData.Name = "name";
            settings.HashProviders.Add(hashData);
            Assert.AreEqual(1, settings.HashProviders.Count, "hash collection");

            DpapiSymmetricCryptoProviderData symmData = new DpapiSymmetricCryptoProviderData();
            symmData.Name = "name";
            settings.SymmetricCryptoProviders.Add(symmData);
            Assert.AreEqual(1, settings.SymmetricCryptoProviders.Count, "symmetric collection");
        }
Example #12
0
        public void Properties()
        {
            Guid appID = Guid.NewGuid();
            CryptographySettings settings = new CryptographySettings();

            KeyedHashAlgorithmProviderData hashData = new KeyedHashAlgorithmProviderData();

            hashData.Name = "name";
            settings.HashProviders.Add(hashData);
            Assert.AreEqual(1, settings.HashProviders.Count, "hash collection");

            DpapiSymmetricCryptoProviderData symmData = new DpapiSymmetricCryptoProviderData();

            symmData.Name = "name";
            settings.SymmetricCryptoProviders.Add(symmData);
            Assert.AreEqual(1, settings.SymmetricCryptoProviders.Count, "symmetric collection");
        }
        public void KeyedHashAlgorithmProviderDataTest()
        {
            ProtectedKeySettings keySettings = new ProtectedKeySettings("some filename", DataProtectionScope.CurrentUser);
            bool saltEnabled = false;
            Type algorithmType = typeof(HMACSHA1);
            string name = "some name";

            KeyedHashAlgorithmProviderData data = new KeyedHashAlgorithmProviderData();
            data.Name = name;
            data.AlgorithmType = algorithmType;
            data.SaltEnabled = saltEnabled;
            data.ProtectedKeyFilename = keySettings.Filename;
            data.ProtectedKeyProtectionScope = keySettings.Scope;

            KeyedHashAlgorithmProviderNode node = new KeyedHashAlgorithmProviderNode(data);
            Assert.AreEqual(name, node.Name);
            Assert.AreEqual(algorithmType, node.AlgorithmType);
            Assert.AreEqual(saltEnabled, node.SaltEnabled);
            Assert.AreEqual(keySettings.Filename, node.Key.Filename);
            Assert.AreEqual(keySettings.Scope, node.Key.Scope);
        }
 /// <summary>
 /// Constructs a new instance 
 /// with the corresponding runtime configuration data.
 /// </summary>
 /// <param name="hashAlgorithmProviderData">The corresponding runtime configuration data.</param>
 public KeyedHashAlgorithmProviderNode(KeyedHashAlgorithmProviderData hashAlgorithmProviderData)
     : base(hashAlgorithmProviderData)
 {
     key = new ProtectedKeySettings(hashAlgorithmProviderData.ProtectedKeyFilename, hashAlgorithmProviderData.ProtectedKeyProtectionScope);
 }
 /// <summary>
 /// Constructs a new instance
 /// with the corresponding runtime configuration data.
 /// </summary>
 /// <param name="hashAlgorithmProviderData">The corresponding runtime configuration data.</param>
 public KeyedHashAlgorithmProviderNode(KeyedHashAlgorithmProviderData hashAlgorithmProviderData) : base(hashAlgorithmProviderData)
 {
     this.hashAlgorithmProviderData = hashAlgorithmProviderData;
 }
 /// <summary>
 /// Constructs a new instance 
 /// with the corresponding runtime configuration data.
 /// </summary>
 /// <param name="hashAlgorithmProviderData">The corresponding runtime configuration data.</param>
 public KeyedHashAlgorithmProviderNode(KeyedHashAlgorithmProviderData hashAlgorithmProviderData)
     : base(hashAlgorithmProviderData)
 {
     this.hashAlgorithmProviderData = hashAlgorithmProviderData;
 }
 /// <summary>
 /// Constructs a new instance
 /// with the corresponding runtime configuration data.
 /// </summary>
 /// <param name="hashAlgorithmProviderData">The corresponding runtime configuration data.</param>
 public KeyedHashAlgorithmProviderNode(KeyedHashAlgorithmProviderData hashAlgorithmProviderData) : base(hashAlgorithmProviderData)
 {
     key = new ProtectedKeySettings(hashAlgorithmProviderData.ProtectedKeyFilename, hashAlgorithmProviderData.ProtectedKeyProtectionScope);
 }