コード例 #1
0
        // LAMESPEC: It's not clear from docs what should be happening
        // here if inputCount > InputBlockSize. It just "Converts the
        // specified region of the specified byte array" and that's all.
        public int TransformBlock(byte[] inputBuffer, int inputOffset, int inputCount, byte[] outputBuffer, int outputOffset)
        {
            if (m_disposed)
            {
                throw new ObjectDisposedException("TransformBlock");
            }
            if (inputBuffer == null)
            {
                throw new ArgumentNullException("inputBuffer");
            }
            if (outputBuffer == null)
            {
                throw new ArgumentNullException("outputBuffer");
            }
            if (inputCount < 0)
            {
                throw new ArgumentException("inputCount", "< 0");
            }
            if (inputCount > inputBuffer.Length)
            {
                throw new ArgumentException("inputCount", Locale.GetText("Overflow"));
            }
            if (inputOffset < 0)
            {
                throw new ArgumentOutOfRangeException("inputOffset", "< 0");
            }
            // ordered to avoid possible integer overflow
            if (inputOffset > inputBuffer.Length - inputCount)
            {
                throw new ArgumentException("inputOffset", Locale.GetText("Overflow"));
            }
            // ordered to avoid possible integer overflow
            if (outputOffset < 0)
            {
                throw new ArgumentOutOfRangeException("outputOffset", "< 0");
            }
            if (outputOffset > outputBuffer.Length - inputCount)
            {
                throw new ArgumentException("outputOffset", Locale.GetText("Overflow"));
            }
/// To match MS implementation
//			if (inputCount != this.InputBlockSize)
//				throw new CryptographicException (Locale.GetText ("Invalid input length"));

            Base64Helper.TransformBlock(inputBuffer, inputOffset, inputCount, outputBuffer, outputOffset);
            return(this.OutputBlockSize);
        }