Bug 28527 - RijndaelManaged: "Invalid input block size."
Summary: RijndaelManaged: "Invalid input block size."
Status: NEW
Alias: None
Product: Class Libraries
Classification: Mono
Component: System.Security ()
Version: unspecified
Hardware: PC Linux
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2015-03-29 19:07 UTC by Niklas Mollenhauer
Modified: 2015-03-29 19:08 UTC (History)
2 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report for Bug 28527 on GitHub or Developer Community if you have new information to add and do not yet see a matching new report.

If the latest results still closely match this report, you can use the original description:

  • Export the original title and description: GitHub Markdown or Developer Community HTML
  • Copy the title and description into the new report. Adjust them to be up-to-date if needed.
  • Add your new information.

In special cases on GitHub you might also want the comments: GitHub Markdown with public comments

Related Links:
Status:
NEW

Description Niklas Mollenhauer 2015-03-29 19:07:52 UTC
I've run into an issue with the RijndaelManaged class.

Test case:
https://github.com/nikeee/travis-test/blob/master/travis-test/RijndaelTests.cs

It runs fine with native C# (on Windows), but fails on my Ubuntu machine as well as on travis.
The travis build:
https://travis-ci.org/nikeee/travis-test/builds/56346278

Strack trace:
######################################################################
Test Error : travis_test.RijndaelTests.BlockSize
   System.Security.Cryptography.CryptographicException : Invalid input block size.
  at Mono.Security.Cryptography.SymmetricTransform.InternalTransformBlock (System.Byte[] inputBuffer, Int32 inputOffset, Int32 inputCount, System.Byte[] outputBuffer, Int32 outputOffset) [0x00000] in <filename unknown>:0
  at Mono.Security.Cryptography.SymmetricTransform.TransformBlock (System.Byte[] inputBuffer, Int32 inputOffset, Int32 inputCount, System.Byte[] outputBuffer, Int32 outputOffset) [0x00000] in <filename unknown>:0
  at System.Security.Cryptography.RijndaelManagedTransform.TransformBlock (System.Byte[] inputBuffer, Int32 inputOffset, Int32 inputCount, System.Byte[] outputBuffer, Int32 outputOffset) [0x00000] in <filename unknown>:0
  at travis_test.RijndaelTests.BlockSize () [0x00000] in <filename unknown>:0
  at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (System.Reflection.MonoMethod,object,object[],System.Exception&)
  at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] in <filename unknown>:0
######################################################################

This issue seems to be pretty similar: https://bugzilla.xamarin.com/show_bug.cgi?id=7193
Except the exception gets thrown at InternalTransformBlock, not FinalEncrypt.

This one is also pretty similar: https://bugzilla.xamarin.com/show_bug.cgi?id=14243
Except it uses AesManaged and the stack trace is entirely different.

This bug occurs with a Stream, which I am not using. Also there is no exception. It may be related anyway: https://bugzilla.xamarin.com/show_bug.cgi?id=9247

I think it might be this line responsible for the exception:
https://github.com/mono/mono/blob/master/mcs/class/Mono.Security/Mono.Security.Cryptography/SymmetricTransform.cs#L278

The Rijndael parameters:
######################################################################
Rijndael = new RijndaelManaged
{
    Padding = PaddingMode.None,
    FeedbackSize = 8,
    Mode = CipherMode.CFB,
    BlockSize = 128,
    KeySize = 128
};
######################################################################