[ pycrypto-Bugs-877442 ] CBC mode broken?
"SourceForge.net" <[email protected]> Thu, 15 Jan 2004 01:52:35 -0800
| Newsgroups | gmane.comp.python.cryptography.cvs |
|---|---|
| Message-ID | <[email protected]> |
Bugs item #877442, was opened at 2004-01-15 10:52 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=877442&group_id=20937 Category: None Group: None Status: Open Resolution: None Priority: 5 Submitted By: Joakim Sernbrant (joakims) Assigned to: Nobody/Anonymous (nobody) 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. ---------------------------------------------------------------------- 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: Perforce Software. Perforce is the Fast Software Configuration Management System offering advanced branching capabilities and atomic changes on 50+ platforms. Free Eval! http://www.perforce.com/perforce/loadprog.html