public void Decrypt_throws_on_mismatching_tag(CcmTestCase tc) { // Change ciphertext var ciphertext = (byte[])tc.Ciphertext.Clone(); ++ciphertext[ciphertext.Length / 2]; VerifyCcmMismatchThrown(tc.Key, ciphertext, tc.Iv, tc.Adata, tc.TagLength); // Change iv var iv = (byte[])tc.Iv.Clone(); ++iv[iv.Length / 2]; VerifyCcmMismatchThrown(tc.Key, tc.Ciphertext, iv, tc.Adata, tc.TagLength); // Change adata var adata = (byte[])tc.Adata.Clone(); ++adata[adata.Length / 2]; VerifyCcmMismatchThrown(tc.Key, tc.Ciphertext, tc.Iv, adata, tc.TagLength); }
public void Decrypt_returns_correct_value(CcmTestCase tc) { var plaintext = AesCcm.Decrypt(tc.Key, tc.Ciphertext, tc.Iv, tc.Adata, tc.TagLength); Assert.Equal(tc.Plaintext, plaintext); }