Implements DES cipher algorithm.
Inheritance: BlockCipher
Exemplo n.º 1
0
 [Ignore] // placeholder for actual test
 public void DesCipherConstructorTest()
 {
     byte[] key = null; // TODO: Initialize to an appropriate value
     CipherMode mode = null; // TODO: Initialize to an appropriate value
     CipherPadding padding = null; // TODO: Initialize to an appropriate value
     DesCipher target = new DesCipher(key, mode, padding);
     Assert.Inconclusive("TODO: Implement code to verify target");
 }
Exemplo n.º 2
0
 [Ignore] // placeholder for actual test
 public void EncryptBlockTest()
 {
     byte[] key = null; // TODO: Initialize to an appropriate value
     CipherMode mode = null; // TODO: Initialize to an appropriate value
     CipherPadding padding = null; // TODO: Initialize to an appropriate value
     DesCipher target = new DesCipher(key, mode, padding); // TODO: Initialize to an appropriate value
     byte[] inputBuffer = null; // TODO: Initialize to an appropriate value
     int inputOffset = 0; // TODO: Initialize to an appropriate value
     int inputCount = 0; // TODO: Initialize to an appropriate value
     byte[] outputBuffer = null; // TODO: Initialize to an appropriate value
     int outputOffset = 0; // TODO: Initialize to an appropriate value
     int expected = 0; // TODO: Initialize to an appropriate value
     int actual;
     actual = target.EncryptBlock(inputBuffer, inputOffset, inputCount, outputBuffer, outputOffset);
     Assert.AreEqual(expected, actual);
     Assert.Inconclusive("Verify the correctness of this test method.");
 }
Exemplo n.º 3
0
        /// <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 override int DecryptBlock(byte[] inputBuffer, int inputOffset, int inputCount, byte[] outputBuffer, int outputOffset)
        {
            if ((inputOffset + this.BlockSize) > inputBuffer.Length)
            {
                throw new IndexOutOfRangeException("input buffer too short");
            }

            if ((outputOffset + this.BlockSize) > outputBuffer.Length)
            {
                throw new IndexOutOfRangeException("output buffer too short");
            }

            if (this._decryptionKey == null)
            {
                this._decryptionKey = GenerateWorkingKey(false, this.Key);
            }

            DesCipher.DesFunc(this._decryptionKey, inputBuffer, inputOffset, outputBuffer, outputOffset);

            return(this.BlockSize);
        }