public void Encrypt_returns_correct_value() { foreach (var i in Rfc3610TestCases) { var aes = new SjclAes(i.Key); var ciphertext = SjclCcm.Encrypt(aes, i.Plaintext, i.Iv, i.Adata, i.TagLength); Assert.That(ciphertext, Is.EqualTo(i.Ciphertext)); } }
public void Encrypt_throws_on_too_short_iv() { var aes = new SjclAes(new byte[16]); for (var i = 0; i < 7; ++i) { Assert.That(() => SjclCcm.Encrypt(aes, new byte[1], new byte[i], new byte[0], 8), Throws.TypeOf <CryptoException>() .And.Message.EqualTo("IV must be at least 7 bytes long")); } }
public void Encrypt_throws_on_too_short_iv() { var aes = new SjclAes(new byte[16]); for (var i = 0; i < 7; ++i) { var e = Assert.Throws <CryptoException>( () => SjclCcm.Encrypt(aes, new byte[1], new byte[i], new byte[0], 8)); Assert.AreEqual("IV must be at least 7 bytes long", e.Message); } }
public void Encrypt_throws_on_invalid_tag_length() { var testCases = new int[] { -1, 0, 1, 2, 3, 5, 7, 9, 11, 13, 15, 17, 18, 19, 20, 1024 }; var aes = new SjclAes(new byte[16]); foreach (var i in testCases) { Assert.That(() => SjclCcm.Encrypt(aes, new byte[1], new byte[16], new byte[0], i), Throws.TypeOf <CryptoException>() .And.Message.EqualTo("Tag must be 4, 8, 10, 12, 14 or 16 bytes long")); } }