Example #1
0
        public void ScheduleEncryptionKey_throws_on_incorrect_input_key_length()
        {
            var dt   = SjclAes.ComputeDoubleTable();
            var sbox = SjclAes.ComputeSboxTable(dt, SjclAes.ComputeTrippleTable(dt));

            foreach (var i in new[] { 0, 1, 2, 3, 4, 15, 17, 23, 25, 31, 33, 1024 })
            {
                var e = Assert.Throws <ArgumentException>(() => SjclAes.ScheduleEncryptionKey(new byte[i], sbox));
                Assert.AreEqual(string.Format("Invalid key length: {0}\r\nParameter name: key", i), e.Message);
            }
        }
Example #2
0
        public void ScheduleEncryptionKey_returns_correct_result()
        {
            var dt   = SjclAes.ComputeDoubleTable();
            var sbox = SjclAes.ComputeSboxTable(dt, SjclAes.ComputeTrippleTable(dt));

            foreach (var i in KeyTestCases)
            {
                var key = SjclAes.ScheduleEncryptionKey(i.Key, sbox);
                Assert.AreEqual(i.EncryptionKey, key);
            }
        }
Example #3
0
        public void ScheduleEncryptionKey_throws_on_incorrect_input_key_length()
        {
            var dt   = SjclAes.ComputeDoubleTable();
            var sbox = SjclAes.ComputeSboxTable(dt, SjclAes.ComputeTrippleTable(dt));

            foreach (var i in new[] { 0, 1, 2, 3, 4, 15, 17, 23, 25, 31, 33, 1024 })
            {
                Assert.That(() => SjclAes.ScheduleEncryptionKey(new byte[i], sbox),
                            Throws.TypeOf <ArgumentException>()
                            .And.Message.StartsWith("Invalid key length"));
            }
        }
Example #4
0
        public void ScheduleDecryptionKey_returns_correct_result()
        {
            var dt     = SjclAes.ComputeDoubleTable();
            var sbox   = SjclAes.ComputeSboxTable(dt, SjclAes.ComputeTrippleTable(dt));
            var decode = SjclAes.ComputeDecodeTable(dt, sbox);

            foreach (var i in KeyTestCases)
            {
                var encKey = SjclAes.ScheduleEncryptionKey(i.Key, sbox);
                var key    = SjclAes.ScheduleDecryptionKey(encKey, sbox, decode);
                Assert.That(key, Is.EqualTo(i.DecryptionKey));
            }
        }