| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 | using Microsoft.VisualStudio.TestTools.UnitTesting;using Renci.SshNet.Common;using Renci.SshNet.Security.Cryptography.Ciphers.Paddings;namespace Renci.SshNet.Tests.Classes.Security.Cryptography.Ciphers.Paddings{    [TestClass]    public class PKCS7PaddingTest    {        private PKCS7Padding _padding;        [TestInitialize]        public void SetUp()        {            _padding = new PKCS7Padding();        }        [TestMethod]        public void Pad_BlockSizeAndInput_LessThanBlockSize()        {            var input = new byte[] { 0x01, 0x02, 0x03, 0x04, 0x05 };            var expected = new byte[] { 0x01, 0x02, 0x03, 0x04, 0x05, 0x03, 0x03, 0x03 };            var actual = _padding.Pad(8, input);            Assert.IsTrue(expected.IsEqualTo(actual));        }        [TestMethod]        public void Pad_BlockSizeAndInput_MoreThanBlockSizeButNoMultipleOfBlockSize()        {            var input = new byte[] { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09 };            var expected = new byte[] { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07 };            var actual = _padding.Pad(8, input);            Assert.IsTrue(expected.IsEqualTo(actual));        }        [TestMethod]        public void Pad_BlockSizeAndInputAndOffsetAndLength_LessThanBlockSize()        {            var input = new byte[] { 0x0f, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06 };            var expected = new byte[] { 0x01, 0x02, 0x03, 0x04, 0x05, 0x03, 0x03, 0x03 };            var actual = _padding.Pad(8, input, 1, input.Length - 2);            Assert.IsTrue(expected.IsEqualTo(actual));        }        [TestMethod]        public void Pad_BlockSizeAndInputAndOffsetAndLength_MoreThanBlockSizeButNoMultipleOfBlockSize()        {            var input = new byte[] { 0x0f, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x10 };            var expected = new byte[] { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07 };            var actual = _padding.Pad(8, input, 1, input.Length - 2);            Assert.IsTrue(expected.IsEqualTo(actual));        }    }}
 |