Notice (2018-05-24): bugzilla.xamarin.com is now in
Please join us on
Visual Studio Developer Community and in the
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
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 on
Developer Community or GitHub with
your current version information, steps to reproduce, and relevant error
messages or log files if you are hitting an issue that looks similar to
this resolved bug and you do not yet see a matching new report.
Created attachment 2468 [details]
A class illustrating the problem.
Guys I just downloaded MonoTouch today and my application cannot authenticate. I have attached the bits of code that is not working so you can test it for yourself.
Apart from the result encrypted being different from previous versions the decrypt method throws the following error.
Bad PKCS7 padding. Invalid length 19.
Please advise as this is a show stopper for us!
It seems CC does not (directly) support 128 bits keys, i.e. two-key three-DES. That should be easy to fix (and to workaround in your application).
However I get an CryptographicUnexpectedOperationException, running your sample code (trying to create the encryptor), not a padding error (at decrypt time).
result = desCrypt.CreateEncryptor().TransformFinalBlock(buffer, 0, buffer.Length);
The two-keys TripleDES issue is fixed in:
QA: unit tests added in both branches
note: Keeping open since I cannot duplicate the original exception with the provided code.
What is the verdict or what should I do... must I downgrade MonoTouch or what is the work-around? Keep in mind that my application uses web-services that runs on windows .Net and therefore expects the byte-array to look the same as if .Net encrypted it.
I have to mention that this code extract was copied from a class that did not change for 3 years as it's our enterprise authentication security module
> What is the verdict or what should I do...
The issue I can see, using both your code and mine, is fixed (with complete compatibility).
> Apart from the result encrypted being different from previous versions the
However when I use the code (with MonoTouch 5.4.0) you provided the encrypt part throws an exception (i.e. it does not return a different encrypted result like you mentioned).
>decrypt method throws the following error.
> Bad PKCS7 padding. Invalid length 19.
and, as it does not return any data, it does not throw a padding exception on decryption.
Either the code you executed is different (than what's attached) or you're running into a different issue. Please check if the attached code and initial descriptions match.
If they do match then please attach a complete, self-contained, test case (so that every options is already set to show your issue). That way I'll be able to see/duplicate/fix it and tell what you should do.
The only thing that is different is the key I provided for obvious reasons. Do you have any idea when the fix will be released?
Another Dev of mine also logged a bug ID 6985.... this is similar to your exception. I don't know why the error I get is different but you know what they say "If it smells like poo and it tastes like poo it's probably poo"
*** Bug 6985 has been marked as a duplicate of this bug. ***
A workaround for the issue (the one I see) would be to replace:
desCrypt.Key = hash;
byte key3 = new byte ;
Buffer.BlockCopy (hash, 0, key3, 0, 16);
Buffer.BlockCopy (hash, 0, key3, 16, 8);
desCrypt.Key = key3;
That will work now (with 5.4.0) and in the future too.
OTOH it does not explain how you could get encrypted results.
Heh, the first part was easy. The confusing part was your padding exception.
From your joyous comment I assume it disappeared ?
If you still have it then please re-open the bug with a test case. Thanks!
No it sorted for now and the results are the same as what it was previously.
Will the work-aound work with the "fixed" update or should I then change the code back ?
There will be no need to remove the fix for future MonoTouch releases. The Mono (and MonoTouch) are just doing the same, but only when a 128 bit key is used. Since you'll be providing a 192 bits key then nothing will be done.
*** Bug 7096 has been marked as a duplicate of this bug. ***