Inheritance: AaltoTLS.PluginInterface.BulkCipherAlgorithm
 private void Check(BulkCipherAlgorithmARCFour cipher, int keySize)
 {
     Assert.AreEqual(keySize / 8, cipher.KeySize);
     Assert.AreEqual(0, cipher.BlockSize);
     Assert.AreEqual(keySize, cipher.Strength);
     Assert.AreEqual(BulkCipherAlgorithmType.Stream, cipher.Type);
     Assert.IsTrue(cipher.SupportsProtocolVersion(ProtocolVersion.TLS1_0));
     Assert.IsFalse(cipher.SupportsProtocolVersion(ProtocolVersion.DTLS1_0));
     Assert.IsNotNull(cipher.CreateEncryptor(new byte[keySize / 8], null));
     Assert.IsNotNull(cipher.CreateDecryptor(new byte[keySize / 8], null));
 }
        /* Test vectors from http://www.freemedialibrary.com/index.php/RC4_test_vectors */

        private void CheckVector(byte[] key, byte[] plaintext, byte[] ciphertext)
        {
            BulkCipherAlgorithmARCFour cipher    = new BulkCipherAlgorithmARCFour(key.Length * 8);
            ICryptoTransform           encryptor = cipher.CreateEncryptor(key, null);

            byte[]           enc       = encryptor.TransformFinalBlock(plaintext, 0, plaintext.Length);
            ICryptoTransform decryptor = cipher.CreateDecryptor(key, null);

            byte[] dec = decryptor.TransformFinalBlock(enc, 0, enc.Length);
            Assert.AreEqual(ciphertext, enc);
            Assert.AreEqual(plaintext, dec);
        }
Exemplo n.º 3
0
 /* Test vectors from http://www.freemedialibrary.com/index.php/RC4_test_vectors */
 private void CheckVector(byte[] key, byte[] plaintext, byte[] ciphertext)
 {
     BulkCipherAlgorithmARCFour cipher = new BulkCipherAlgorithmARCFour(key.Length*8);
     ICryptoTransform encryptor = cipher.CreateEncryptor(key, null);
     byte[] enc = encryptor.TransformFinalBlock(plaintext, 0, plaintext.Length);
     ICryptoTransform decryptor = cipher.CreateDecryptor(key, null);
     byte[] dec = decryptor.TransformFinalBlock(enc, 0, enc.Length);
     Assert.AreEqual(ciphertext, enc);
     Assert.AreEqual(plaintext, dec);
 }
 private void Check(BulkCipherAlgorithmARCFour cipher, int keySize)
 {
     Assert.AreEqual (keySize/8, cipher.KeySize);
     Assert.AreEqual (0, cipher.BlockSize);
     Assert.AreEqual (keySize, cipher.Strength);
     Assert.AreEqual (BulkCipherAlgorithmType.Stream, cipher.Type);
     Assert.IsTrue (cipher.SupportsProtocolVersion(ProtocolVersion.TLS1_0));
     Assert.IsFalse (cipher.SupportsProtocolVersion(ProtocolVersion.DTLS1_0));
     Assert.IsNotNull (cipher.CreateEncryptor(new byte[keySize/8], null));
     Assert.IsNotNull (cipher.CreateDecryptor(new byte[keySize/8], null));
 }
 public void EncryptionKeyNull()
 {
     BulkCipherAlgorithmARCFour cipher = new BulkCipherAlgorithmARCFour(128);
     cipher.CreateEncryptor(null, null);
 }
 public void EncryptionKeyInvalid()
 {
     BulkCipherAlgorithmARCFour cipher = new BulkCipherAlgorithmARCFour(128);
     cipher.CreateEncryptor(new byte[15], null);
 }
        public void DecryptionKeyInvalid()
        {
            BulkCipherAlgorithmARCFour cipher = new BulkCipherAlgorithmARCFour(128);

            cipher.CreateDecryptor(new byte[15], null);
        }
        public void DecryptionKeyNull()
        {
            BulkCipherAlgorithmARCFour cipher = new BulkCipherAlgorithmARCFour(128);

            cipher.CreateDecryptor(null, null);
        }