public void Test_Decrypt() { var cipherWithFixedIv = new AeadAes256CbcHmacSha512Cipher(new FakeRandomNumberGenerator(Iv)); var actualPlainText = cipherWithFixedIv.Decrypt(Key, CipherText, AssociatedData); Assert.Equal(Plaintext, actualPlainText); }
public void Test_WorksWithRealIvGenerator() { var cipherWithRandomIv = new AeadAes256CbcHmacSha512Cipher(); var cipherText = cipherWithRandomIv.Encrypt(Key, Plaintext, AssociatedData); var roundTripPlainText = cipherWithRandomIv.Decrypt(Key, cipherText, AssociatedData); Assert.Equal(Plaintext, roundTripPlainText); }
public void Test_DecryptBadCipherText() { var cipherWithFixedIv = new AeadAes256CbcHmacSha512Cipher(new FakeRandomNumberGenerator(Iv)); var bogusCipherText = (byte[])CipherText.Clone(); bogusCipherText[0]++; Assert.Throws <InvalidCiphertextException>(() => cipherWithFixedIv.Decrypt(Key, bogusCipherText, AssociatedData)); }
public void Test_DecryptBadKeySize() { var cipherWithFixedIv = new AeadAes256CbcHmacSha512Cipher(new FakeRandomNumberGenerator(Iv)); Assert.Throws <InvalidCryptoKeyException>(() => cipherWithFixedIv.Decrypt(new byte[0], CipherText, AssociatedData)); }