Inheritance: AaltoTLS.PluginInterface.BulkCipherAlgorithm
コード例 #1
0
 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));
 }
コード例 #2
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);
        }
コード例 #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);
 }
コード例 #4
0
 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));
 }
コード例 #5
0
 public void EncryptionKeyNull()
 {
     BulkCipherAlgorithmARCFour cipher = new BulkCipherAlgorithmARCFour(128);
     cipher.CreateEncryptor(null, null);
 }
コード例 #6
0
 public void EncryptionKeyInvalid()
 {
     BulkCipherAlgorithmARCFour cipher = new BulkCipherAlgorithmARCFour(128);
     cipher.CreateEncryptor(new byte[15], null);
 }
コード例 #7
0
        public void DecryptionKeyInvalid()
        {
            BulkCipherAlgorithmARCFour cipher = new BulkCipherAlgorithmARCFour(128);

            cipher.CreateDecryptor(new byte[15], null);
        }
コード例 #8
0
        public void DecryptionKeyNull()
        {
            BulkCipherAlgorithmARCFour cipher = new BulkCipherAlgorithmARCFour(128);

            cipher.CreateDecryptor(null, null);
        }