[ pycrypto-Bugs-764626 ] AES with 32-bit keys broken

"SourceForge.net" <[email protected]> Thu, 06 May 2004 05:50:10 -0700
Newsgroups gmane.comp.python.cryptography.cvs
Message-ID <[email protected]>
Bugs item #764626, was opened at 2003-07-02 10:34
Message generated for change (Comment added) made by akuchling
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=120937&aid=764626&group_id=20937

Category: None
Group: None
>Status: Closed
>Resolution: Works For Me
Priority: 5
Submitted By: Nobody/Anonymous (nobody)
Assigned to: A.M. Kuchling (akuchling)
Summary: AES with 32-bit keys broken

Initial Comment:
It looks like AES with 256-bit keys are broken. Running 
the command line:

Python test.py aes

produces the output in the enclosed file err.txt. Note 
that 128-bit keys seem to be working. I was able to 
reproduce this from an interactive session, as follows:

D:\work\Python\pycrypto-1.9a6>python
ActivePython 2.2.2 Build 224 (ActiveState Corp.) based 
on
Python 2.2.2 (#37, Nov 26 2002, 10:24:37) [MSC 32 bit 
(Intel)] on win32
Type "help", "copyright", "credits" or "license" for more 
information.
>>> from Crypto.Cipher import AES
>>> key = '1234567890123456'
>>> plain = key
>>> aes = AES.new(key, AES.MODE_ECB)
>>> cipher = aes.encrypt(plain)
>>> aes.decrypt(cipher)
'1234567890123456'	#WORKS WITH 128-BIT KEY
>>>
>>> key = '12345678901234567890123456789012'
>>> len(key)
32
>>> plain = key
>>> aes = AES.new(key, AES.MODE_ECB)
>>> cipher = aes.encrypt(plain)
>>> aes.decrypt(cipher)
'\xcde\xf6O\xbd\xea\xe8i\x86\xd21\xfa\xe1\xb2\xec\xfd
[u\x06\xfa\x8f%\xf5\xc9\xb6
\xd5\xf2\x02{\xc9\xa0\xa3' 	#FAILS WITH 256-BIT KEY
>>>

I am running Win2K, Python 2.2.2 (ActiveState Build 
224), and pyCrypto 1.9a6. I currently do not have 
access to other platforms to try and reproduce this. I 
have encountered this with ECB, CBC, and CTR modes.

Note: While messing around with this, I tried the 
following:
>>> key = '12345678901234567890123456789012'
>>> plain = key
>>> aes = AES.new(key, AES.MODE_CBC)
>>> cipher = aes.encrypt(plain)
>>> aes.decrypt(cipher)
'\xa4G\x9aD\xa5}K\x14\xd0\xeaC\xee\x0b\xd4
{d7890123456789012'

The last 16 bytes are decrypted properly for CBC mode. 
Perhaps this is a clue to what the issue may be.

email: [email protected]

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

>Comment By: A.M. Kuchling (akuchling)
Date: 2004-05-06 08:50

Message:
Logged In: YES 
user_id=11375

The test program works for me on Linux; perhaps it's an
optimizer bug
specific to the compiler used.

The CBC issue is not relevant; you can't both encrypt and
decrypt with the same object.

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

Comment By: A.M. Kuchling (akuchling)
Date: 2004-05-06 08:48

Message:
Logged In: YES 
user_id=11375

Attaching a version of the test file.


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

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


-------------------------------------------------------
This SF.Net email is sponsored by Sleepycat Software
Learn developer strategies Cisco, Motorola, Ericsson & Lucent use to deliver
higher performing products faster, at low TCO.
http://www.sleepycat.com/telcomwpreg.php?From=osdnemail3