[ pycrypto-Bugs-1057423 ] Stream chiphers don't work
"SourceForge.net" <[email protected]> Sat, 30 Oct 2004 11:16:52 -0700
| Newsgroups | gmane.comp.python.cryptography.cvs |
|---|---|
| Message-ID | <[email protected]> |
Bugs item #1057423, was opened at 2004-10-30 18:16
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=1057423&group_id=20937
Category: None
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Erik Andersén (erik_andersen)
Assigned to: Nobody/Anonymous (nobody)
Summary: Stream chiphers don't work
Initial Comment:
The decrypted ciphertext is not equal to the
plaintext with stream ciphers.
File testcrypto:
import Crypto
from Crypto.Cipher import ARC4, XOR, DES
import unittest, random
def randString(n):
"""returns a random string of length n"""
return ''.join([chr(random.randrange(0,256)) for
dummy in xrange(n)])
n_tests = 100
class StreamCipherTest(unittest.TestCase):
def testARC4(self):
for dummy in range(n_tests):
obj = ARC4.new('jaudjdj')
s = randString(10)
self.assertEqual(obj.decrypt(obj.encrypt(s)),
s)
def testXOR(self):
for dummy in range(n_tests):
obj = XOR.new('jaudjdj')
s = randString(10)
self.assertEqual(obj.decrypt(obj.encrypt(s)),
s)
def testDES(self):
for dummy in range(n_tests):
obj = DES.new('jaudjdji', DES.MODE_ECB)
s = randString(16)
self.assertEqual(obj.decrypt(obj.encrypt(s)),
s)
if __name__ == '__main__':
print Crypto.__version__
unittest.main()
-----------------Output ------------
PythonWin 2.3.4 (#53, May 25 2004, 21:17:02)
[MSC v.1200 32 bit (Intel)] on win32.
Portions Copyright 1994-2004 Mark Hammond
([email protected]) - see 'Help/About
PythonWin' for further copyright information.
>>> 2.0
F.F
====================================
==================================
FAIL: testARC4 (__main__.StreamCipherTest)
------------------------------------------------------------------
----
Traceback (most recent call last):
File "C:\erik\python\testcrypto.py", line 18, in
testARC4
self.assertEqual(obj.decrypt(obj.encrypt(s)), s)
File "C:\Python23\lib\unittest.py", line 302, in
failUnlessEqual
raise self.failureException, AssertionError: '@i$^\x1a\xccdC\x8b\xa0' !=
'kS\xd5{\xa3\xe2\xec\x1a(~'
====================================
==================================
FAIL: testXOR (__main__.StreamCipherTest)
------------------------------------------------------------------
----
Traceback (most recent call last):
File "C:\erik\python\testcrypto.py", line 23, in
testXOR
self.assertEqual(obj.decrypt(obj.encrypt(s)), s)
File "C:\Python23\lib\unittest.py", line 302, in
failUnlessEqual
raise self.failureException, AssertionError: '\t\xef\x0b\xf4h\xeb\x89\xa2\xaf^' !
= '\x07\xe4\x1a\xfah\xee\x96\xac\xa4O'
------------------------------------------------------------------
----
Ran 3 tests in 0.047s
FAILED (failures=2)
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=120937&aid=1057423&group_id=20937
-------------------------------------------------------
This SF.Net email is sponsored by:
Sybase ASE Linux Express Edition - download now for FREE
LinuxWorld Reader's Choice Award Winner for best database on Linux.
http://ads.osdn.com/?ad_id=5588&alloc_id=12065&op=click