| 1234567891011121314151617181920212223242526272829303132333435 | using System;using System.Collections.Generic;using System.Linq;using System.Text;using Microsoft.VisualStudio.TestTools.UnitTesting;namespace Renci.SshClient.Tests.Security.Cryptography{    [TestClass]    public class TestCast    {        [TestMethod]        public void Test_Cast_128_CBC_NoPadding()        {            var key = new byte[] { 0xd3, 0x2b, 0x5e, 0x1e, 0xfe, 0x99, 0x02, 0xc2, 0x85, 0x85, 0x49, 0xb5, 0x29, 0x4a, 0x8c, 0x44 };            var iv = new byte[] { 0x76, 0xc2, 0xd7, 0x95, 0x80, 0x39, 0xd1, 0xb7 };            var input = new byte[] { 0x00, 0x00, 0x00, 0x1c, 0x0a, 0x05, 0x00, 0x00, 0x00, 0x0c, 0x73, 0x73, 0x68, 0x2d, 0x75, 0x73, 0x65, 0x72, 0x61, 0x75, 0x74, 0x68, 0xc8, 0xdc, 0xcb, 0x70, 0xb0, 0x53, 0xfe, 0xd5, 0x80, 0xf7 };            var correctEncoding = new byte[] { 0x90, 0x1c, 0x5b, 0x18, 0xc1, 0xe2, 0xce, 0x96, 0xe4, 0x55, 0x13, 0xce, 0x1d, 0x84, 0xf8, 0xb0, 0xb3, 0x22, 0x73, 0x06, 0xf6, 0xf9, 0x4b, 0x06, 0xf9, 0x07, 0x38, 0x6e, 0xea, 0x0d, 0x6a, 0xb8 };            var encodedResult = new byte[input.Length];            var decodedResult = new byte[input.Length];            var cipher = new Renci.SshClient.Security.Cryptography.Cast(128);            cipher.Mode = System.Security.Cryptography.CipherMode.CBC;            var enc = cipher.CreateEncryptor(key, iv);            enc.TransformBlock(input, 0, input.Length, encodedResult, 0);            var dec = cipher.CreateDecryptor(key, iv);            dec.TransformBlock(encodedResult, 0, encodedResult.Length, decodedResult, 0);            Assert.IsTrue(encodedResult.IsEqualTo(correctEncoding));            Assert.IsTrue(decodedResult.IsEqualTo(input));        }    }}
 |