[ pycrypto-Bugs-877442 ] CBC mode broken?
"SourceForge.net" <[email protected]> Fri, 05 Mar 2004 11:14:32 -0800
| Newsgroups | gmane.comp.python.cryptography.cvs |
|---|---|
| Message-ID | <[email protected]> |
Bugs item #877442, was opened at 2004-01-15 04:52 Message generated for change (Comment added) made by akuchling You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=120937&aid=877442&group_id=20937 Category: None Group: None >Status: Closed >Resolution: Wont Fix Priority: 5 Submitted By: Joakim Sernbrant (joakims) Assigned to: A.M. Kuchling (akuchling) Summary: CBC mode broken? Initial Comment: From the api (PEP 272) it is not apparent if you can use a cipher object for both encryption and decryption but I would guess that is the intention. Then you need to maintain two IVs for CBC mode; one for encrypt and one for decrypt, PyCrypto only keeps one. Python 2.2.3 (#1, Jun 10 2003, 16:41:13) [GCC 3.3 20030604 (Red Hat Linux 3.3-5)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> from Crypto.Cipher import AES >>> key = "1234567890123456" >>> iv = "abcdefghijklmnop" >>> plain = "ABCDEFGHIJKLMNOP" >>> aes = AES.new(key, AES.MODE_CBC, iv) >>> cipher = aes.encrypt(plain) >>> print aes.decrypt(cipher) == plain 0 >>> aes2 = AES.new(key, AES.MODE_CBC, iv) >>> print aes2.decrypt(cipher) == plain 1 >>> The same probably applies to CFB, and OFB mode. ---------------------------------------------------------------------- >Comment By: A.M. Kuchling (akuchling) Date: 2004-03-05 14:14 Message: Logged In: YES user_id=11375 While it's possible to use an object for both encryption and decryption, it's not a common or suggested usage as it would be too easy to get the state of the IV confused. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=120937&aid=877442&group_id=20937 ------------------------------------------------------- This SF.Net email is sponsored by: IBM Linux Tutorials Free Linux tutorial presented by Daniel Robbins, President and CEO of GenToo technologies. Learn everything from fundamentals to system administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click