示例#1
0
 public void Decrypt_returns_correct_value()
 {
     foreach (var i in Rfc3610TestCases)
     {
         var aes       = new SjclAes(i.Key);
         var plaintext = SjclCcm.Decrypt(aes, i.Ciphertext, i.Iv, i.Adata, i.TagLength);
         Assert.That(plaintext, Is.EqualTo(i.Plaintext));
     }
 }
示例#2
0
        //
        // Helpers
        //

        private static void VerifyCmmMismatchThrown(SjclAes aes, byte[] ciphertext, byte[] iv, byte[] adata, int tagLength)
        {
            Assert.That(() => SjclCcm.Decrypt(aes, ciphertext, iv, adata, tagLength),
                        Throws.TypeOf <CryptoException>()
                        .And.Message.EqualTo("CCM tag doesn't match"));
        }
        //
        // Helpers
        //

        private static void VerifyCmmMismatchThrown(SjclAes aes, byte[] ciphertext, byte[] iv, byte[] adata, int tagLength)
        {
            var e = Assert.Throws <CryptoException>(() => SjclCcm.Decrypt(aes, ciphertext, iv, adata, tagLength));

            Assert.AreEqual("CCM tag doesn't match", e.Message);
        }