| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 | using System;namespace Renci.SshNet.Security.Cryptography{    /// <summary>    /// Base class for symmetric cipher implementations.    /// </summary>    public abstract class SymmetricCipher : Cipher    {        /// <summary>        /// Gets the key.        /// </summary>        protected byte[] Key { get; private set; }        /// <summary>        /// Initializes a new instance of the <see cref="SymmetricCipher"/> class.        /// </summary>        /// <param name="key">The key.</param>        /// <exception cref="ArgumentNullException"><paramref name="key"/> is null.</exception>        protected SymmetricCipher(byte[] key)        {            if (key == null)                throw new ArgumentNullException("key");            this.Key = key;        }        /// <summary>        /// Encrypts the specified region of the input byte array and copies the encrypted data to the specified region of the output byte array.        /// </summary>        /// <param name="inputBuffer">The input data to encrypt.</param>        /// <param name="inputOffset">The offset into the input byte array from which to begin using data.</param>        /// <param name="inputCount">The number of bytes in the input byte array to use as data.</param>        /// <param name="outputBuffer">The output to which to write encrypted data.</param>        /// <param name="outputOffset">The offset into the output byte array from which to begin writing data.</param>        /// <returns>        /// The number of bytes encrypted.        /// </returns>        public abstract int EncryptBlock(byte[] inputBuffer, int inputOffset, int inputCount, byte[] outputBuffer, int outputOffset);        /// <summary>        /// Decrypts the specified region of the input byte array and copies the decrypted data to the specified region of the output byte array.        /// </summary>        /// <param name="inputBuffer">The input data to decrypt.</param>        /// <param name="inputOffset">The offset into the input byte array from which to begin using data.</param>        /// <param name="inputCount">The number of bytes in the input byte array to use as data.</param>        /// <param name="outputBuffer">The output to which to write decrypted data.</param>        /// <param name="outputOffset">The offset into the output byte array from which to begin writing data.</param>        /// <returns>        /// The number of bytes decrypted.        /// </returns>        public abstract int DecryptBlock(byte[] inputBuffer, int inputOffset, int inputCount, byte[] outputBuffer, int outputOffset);    }}
 |