[Mono-bugs] [Bug 644740] New: CryptoStream fails with CryptoTransform where the OutputBlockSize < InputBlockSize

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Thu Oct 7 15:20:55 EDT 2010


https://bugzilla.novell.com/show_bug.cgi?id=644740

https://bugzilla.novell.com/show_bug.cgi?id=644740#c0


           Summary: CryptoStream fails with CryptoTransform where the
                    OutputBlockSize < InputBlockSize
    Classification: Mono
           Product: Mono: Class Libraries
           Version: 2.6.x
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: Normal
          Priority: P5 - None
         Component: Mono.Security
        AssignedTo: spouliot at novell.com
        ReportedBy: bassam at symform.com
         QAContact: mono-bugs at lists.ximian.com
          Found By: ---
           Blocker: ---


User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.10)
Gecko/20100914 Firefox/3.6.10 ( .NET CLR 3.5.30729; .NET4.0E)

CryptoStream throws a ArgumentException when used with an implementation of
ICryptoTransform where the OutputBlockSize is smaller than the InputBlockSize.
By inspecting the code it looks like the size of _workingCopy buffer is
incorrect -- it should be as large as the InputBlockSize instead of
OutputBlockSize.


Reproducible: Always

Steps to Reproduce:
Here is a simple repro:

        private class MyCryptAlgorithm : ICryptoTransform
        {
            public bool CanReuseTransform { get { return true; } }
            public bool CanTransformMultipleBlocks { get { return false; } }
            public int InputBlockSize { get { return 128 * 1024; } }
            public int OutputBlockSize { get { return 64 * 1024; } }
            public int TransformBlock(byte[] inputBuffer, int inputOffset, int
inputCount, byte[] outputBuffer, int outputOffset)
            {
                return this.OutputBlockSize;
            }
            public byte[] TransformFinalBlock(byte[] inputBuffer, int
inputOffset, int inputCount)
            {
                return new byte[this.OutputBlockSize];
            }
            public void Dispose() {}
        }

        [Test]
        [Explicit("Broken on mono
https://bugzilla.novell.com/show_bug.cgi?id=644654")]
        public void CryptoStreamSmallerOutputBlockSize()
        {
            using (CryptoStream cs = new CryptoStream(Stream.Null, new
MyCryptAlgorithm(), CryptoStreamMode.Write))
            {
                byte[] buffer = new byte[512 * 1024];
                cs.Write(buffer, 0, buffer.Length);
            }
        }

Actual Results:  
   System.ArgumentException : Offset and length were out of bounds for the
array or count is greater than the number of
elements from index to the end of the source collection.
  at System.Buffer.BlockCopy (System.Array src, Int32 srcOffset, System.Array
dst, Int32 dstOffset, Int32 count) [0x0000
0] in <filename unknown>:0
  at System.Security.Cryptography.CryptoStream.Write (System.Byte[] buffer,
Int32 offset, Int32 count) [0x00000] in <fil
ename unknown>:0
  at UnitTests.Node.Client.ReedSolomonTests.CryptoStreamSmallerOutputBlockSize
() [0x00000] in <filename unknown>:0
  at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke
(object,object[],System.Exception&)
  at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags
invokeAttr, System.Reflection.Binder binder, S
ystem.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000]
in <filename unknown>:0


Expected Results:  
No exception.

-- 
Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.


More information about the mono-bugs mailing list