public void ShouldCipherAndDecipherWith0InitializationVector() { // 0 initialization vector may cause smaller encrypted data size than key length cipherFeedback = new CipherFeedback(rsa, 0); byte[] data = { 208, 59, 152, 15, 20, 5, 233, 119, 22, 58, 9, 128, 253, 33, 212, 58, 184, 80, 242, 239, 193, 150, 177, 195, 179, 68, 23, 13, 14, 162, 131, 226 }; byte[] cipheredData = cipherFeedback.Cipher(data); byte[] decipheredData = cipherFeedback.Decipher(cipheredData); Assert.AreEqual(data, decipheredData); }
public void ShouldCipherAndDecipherByteArrayUsingRandomBlocks() { Random random = new Random(); cipherFeedback = new CipherFeedback(rsa, 0); for (int i = 0; i < 1000; i++) { byte[] data = new byte[random.Next(64, 96)]; random.NextBytes(data); byte[] cipheredData = cipherFeedback.Cipher(data); byte[] decipheredData = cipherFeedback.Decipher(cipheredData); Assert.AreEqual(data, decipheredData); } }
public void Setup() { rsa = new MyRSA(1024); cipherFeedback = new CipherFeedback(rsa); imageBlockCipher = new ImageBlockCipher(cipherFeedback); }