Esempio n. 1
0
        public void Should_not_return_same_value_when_used_twice_with_same_input()
        {
            byte[] message    = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 };
            byte[] encrypted1 = new byte[16];
            byte[] encrypted2 = new byte[16];

            FrameCipher frameCipher = new FrameCipher(NetTestVectors.AesSecret);

            frameCipher.Encrypt(message, 0, 16, encrypted1, 0);
            frameCipher.Encrypt(message, 0, 16, encrypted2, 0);
            Assert.AreNotEqual(encrypted1, encrypted2);
        }
Esempio n. 2
0
        public void Can_run_twice()
        {
            byte[] message   = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 };
            byte[] encrypted = new byte[16];
            byte[] decrypted = new byte[16];

            FrameCipher frameCipher = new FrameCipher(NetTestVectors.AesSecret);

            frameCipher.Encrypt(message, 0, 16, encrypted, 0);
            frameCipher.Decrypt(encrypted, 0, 16, decrypted, 0);
            Assert.AreEqual(message, decrypted);

            Array.Clear(encrypted, 0, encrypted.Length);
            Array.Clear(decrypted, 0, decrypted.Length);
            frameCipher.Encrypt(message, 0, 16, encrypted, 0);
            frameCipher.Decrypt(encrypted, 0, 16, decrypted, 0);
            Assert.AreEqual(message, decrypted);
        }
Esempio n. 3
0
        public void Can_do_inline()
        {
            byte[] message      = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 };
            byte[] messageClone = (byte[])message.Clone();

            FrameCipher frameCipher = new FrameCipher(NetTestVectors.AesSecret);

            frameCipher.Encrypt(messageClone, 0, 16, messageClone, 0);
            frameCipher.Decrypt(messageClone, 0, 16, messageClone, 0);
            Assert.AreEqual(message, messageClone);
        }
Esempio n. 4
0
        public void Can_do_roundtrip()
        {
            byte[] message   = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 };
            byte[] encrypted = new byte[16];
            byte[] decrypted = new byte[16];

            FrameCipher frameCipher = new FrameCipher(NetTestVectors.AesSecret);

            frameCipher.Encrypt(message, 0, 16, encrypted, 0);
            frameCipher.Decrypt(encrypted, 0, 16, decrypted, 0);
            Assert.AreEqual(message, decrypted);
        }
Esempio n. 5
0
        public void Can_run_twice_longer_message()
        {
            int length = 16;

            byte[] message = new byte[length * 2];
            message[3] = 123;
            message[4] = 123;
            message[5] = 12;

            byte[] encrypted = new byte[length];
            byte[] decrypted = new byte[2 * length];

            FrameCipher frameCipher = new FrameCipher(NetTestVectors.AesSecret);

            frameCipher.Encrypt(message, 0, length, encrypted, 0);
            frameCipher.Decrypt(encrypted, 0, length, decrypted, 0);
            Assert.AreEqual(message, decrypted);

            Array.Clear(encrypted, 0, encrypted.Length);
            Array.Clear(decrypted, 0, decrypted.Length);
            frameCipher.Encrypt(message, 0, length, encrypted, 0);
            frameCipher.Decrypt(encrypted, 0, length, decrypted, 0);
            Assert.AreEqual(message, decrypted);
        }