コード例 #1
0
 public void ShouldCipherAndDecipherByteArraySmallerThanBlockSize()
 {
     byte[] data           = Enumerable.Range(0, 16).Select(i => (byte)i).ToArray();
     byte[] cipheredData   = outputFeedback.Cipher(data);
     byte[] decipheredData = outputFeedback.Decipher(cipheredData);
     Assert.AreEqual(data, decipheredData);
 }
コード例 #2
0
 public void ShouldCipherAndDecipherWith0InitializationVector()
 {
     // 0 initialization vector may cause smaller encrypted data size than key length
     outputFeedback = new OutputFeedback(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   = outputFeedback.Cipher(data);
     byte[] decipheredData = outputFeedback.Decipher(cipheredData);
     Assert.AreEqual(data, decipheredData);
 }
コード例 #3
0
        public void ShouldCipherAndDecipherByteArrayUsingRandomBlocks()
        {
            Random random = new Random();

            outputFeedback = new OutputFeedback(rsa, 0);
            for (int i = 0; i < 1000; i++)
            {
                byte[] data = new byte[random.Next(64, 96)];
                random.NextBytes(data);
                byte[] cipheredData   = outputFeedback.Cipher(data);
                byte[] decipheredData = outputFeedback.Decipher(cipheredData);
                Assert.AreEqual(data, decipheredData);
            }
        }