Beispiel #1
0
        public void PropertyKey_ValidKey_SetsKey()
        {
            byte[]    key             = SymmetricTestsHelper.CreateKey(64);
            Symmetric symmetricHelper = new Symmetric();

            symmetricHelper.Key = key;

            Assert.AreEqual(key, symmetricHelper.Key);
        }
Beispiel #2
0
        public void Constructor_FullConstructorWithEmptyIV_Throws(
            [Values(Algorithm.DES, Algorithm.TripleDES, Algorithm.RC2, Algorithm.Rijndael)] Algorithm mode,
            [Values(64, 128, 48, 192)] int keySize)
        {
            string salt = SymmetricTestsHelper.DEFAULT_SALT;

            byte[] iv  = new byte[] { };
            byte[] key = SymmetricTestsHelper.CreateKey(keySize);

            Symmetric symmetricHelper = new Symmetric(mode, salt, iv, key);
        }
Beispiel #3
0
        public void Constructor_FullConstructorWithEmptySalt_Throws(
            [Values(Algorithm.DES, Algorithm.TripleDES, Algorithm.RC2, Algorithm.Rijndael)] Algorithm mode,
            [Values(64, 128, 48, 192)] int keySize)
        {
            string salt = String.Empty;

            byte[] iv  = SymmetricTestsHelper.GetDefaultIV(mode);
            byte[] key = SymmetricTestsHelper.CreateKey(keySize);

            Symmetric symmetricHelper = new Symmetric(mode, salt, iv, key);
        }
Beispiel #4
0
        public void Constructor_FullConstructorWithInvalidKeyLength_Throws(
            [Values(Algorithm.DES, Algorithm.TripleDES, Algorithm.RC2, Algorithm.Rijndael)] Algorithm mode,
            [Values(16, 1024)] int keySize)
        {
            string salt = SymmetricTestsHelper.DEFAULT_SALT;

            byte[] iv  = SymmetricTestsHelper.GetDefaultIV(mode);
            byte[] key = SymmetricTestsHelper.CreateKey(keySize);

            Symmetric symmetricHelper = new Symmetric(mode, salt, iv, key);
        }
Beispiel #5
0
        public void Constructor_FullConstructorWithValidParameters_InitializesWithSaltKeyAndIV(
            [Values(Algorithm.DES, Algorithm.TripleDES, Algorithm.RC2, Algorithm.Rijndael)] Algorithm mode,
            [Values(64, 128, 48, 192)] int keySize)
        {
            string salt = SymmetricTestsHelper.DEFAULT_SALT;

            byte[] iv  = SymmetricTestsHelper.GetDefaultIV(mode);
            byte[] key = SymmetricTestsHelper.CreateKey(keySize);

            Symmetric symmetricHelper = new Symmetric(mode, salt, iv, key);

            Assert.AreEqual(mode, symmetricHelper.Mode);
            Assert.AreEqual(keySize, symmetricHelper.KeySize);
            Assert.AreEqual(salt, symmetricHelper.Salt);
            Assert.AreEqual(key, symmetricHelper.Key);
            Assert.AreEqual(iv, symmetricHelper.IV);
        }
Beispiel #6
0
        public void PropertyKey_KeyWithInvalidLength_Throws([Values(16, 1024)] int keySize)
        {
            Symmetric symmetricHelper = new Symmetric();

            symmetricHelper.Key = SymmetricTestsHelper.CreateKey(keySize);
        }