[Mono-bugs] [Bug 366623] New: Decryption by SymmetricTransform with padding mode ANSIX923 throws BadPadding exception

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Mon Mar 3 10:48:35 EST 2008


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


           Summary: Decryption by SymmetricTransform with padding mode
                    ANSIX923 throws BadPadding exception
           Product: Mono: Class Libraries
           Version: 1.2.6
          Platform: x86
        OS/Version: Windows XP
            Status: NEW
          Severity: Major
          Priority: P5 - None
         Component: Mono.Security
        AssignedTo: spouliot at novell.com
        ReportedBy: oleg.ufaev at gmail.com
         QAContact: mono-bugs at lists.ximian.com
          Found By: DeveloperNet


Hi!
I found bug in SymmetricTransform.FinalDecrypt method in line 425

..
byte padding = ((total > 0) ? res[total - 1] : (byte)0);
case PaddingMode.ANSIX923:
        if ((padding == 0) || (padding > BlockSizeByte))
                ThrowBadPaddingException (algo.Padding, padding, -1);
/!\     for (int i=padding; i > 0; i--) {
                if (res [total - 1 - i] != 0x00)
                        ThrowBadPaddingException (algo.Padding, -1, i);
        }
        total -= padding;
        break;
..

In my test case i have:
total = 8
padding = 6
res = {ff ff 00 00 00 00 00 06}

In first iteration i = padding = 6, so total - 1 - i = 1 (wrong!)
res[1] != 0x00 => exception fired

variable 'i' must be initialized like this: i = padding - 1
in this case - all works fine.

Thank you for your attention!


-- 
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