[ pycrypto-Bugs-1753779 ] incorrect pad calculation in AllOrNothing.py

"SourceForge.net" <[email protected]> Fri, 13 Jul 2007 13:23:00 -0700
Newsgroups gmane.comp.python.cryptography.cvs
Message-ID <[email protected]>
Bugs item #1753779, was opened at 2007-07-13 16:23
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=120937&aid=1753779&group_id=20937

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: None
Group: None
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Rick Hull (nwallins)
Assigned to: Nobody/Anonymous (nobody)
Summary: incorrect pad calculation in AllOrNothing.py

Initial Comment:
# Pad the text so that its length is a multiple of the cipher's
# block_size.  Pad with trailing spaces, which will be eliminated in
# the undigest() step.
block_size = self.__ciphermodule.block_size
padbytes = block_size - (len(text) % block_size)
text = text + ' ' * padbytes

the line:
padbytes = block_size - (len(text) % block_size)

will add a full block_size worth of padding when it is not needed:

block_size = 8
text = '12345678'
padbytes would therefore be calculated as 8 instead of 0

the line should read:
padbytes = block_size - (((len(text) - 1) % block_size) + 1))

using values from above:
padbytes = 8 - (((8 - 1) % 8) + 1)
= 8 - (7%8 + 1)
= 0

enjoy!



----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=120937&aid=1753779&group_id=20937

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/