File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -165,7 +165,7 @@ def feed(self, data = None):
165165 raise ValueError ('already finished feeder' )
166166
167167 # Finalize; process the spare bytes we were keeping
168- if not data :
168+ if data is None :
169169 result = self ._final (self ._buffer , self ._padding )
170170 self ._buffer = None
171171 return result
Original file line number Diff line number Diff line change 88for API reference and details.'''
99
1010setup (name = 'pyaes' ,
11- version = '1.6.0 ' ,
11+ version = '1.6.1 ' ,
1212 description = 'Pure-Python Implementation of the AES block-cipher and common modes of operation' ,
1313 long_description = LONG_DESCRIPTION ,
1414 author = 'Richard Moore' ,
Original file line number Diff line number Diff line change 146146 passed = decrypted == plaintext
147147 cipher_length = len (ciphertext )
148148 print (" cipher-length=%(cipher_length)s passed=%(passed)s" % locals ())
149+
150+ # Issue #15
151+ # https://github.com/ricmoo/pyaes/issues/15
152+ # @TODO: These tests need a severe overhaul; they should use deterministic input, keys and IVs...
153+ def TestIssue15 ():
154+ print ('Issue #15' )
155+
156+ key = b"abcdefghijklmnop"
157+ iv = b"0123456789012345"
158+ encrypter = pyaes .Encrypter (pyaes .AESModeOfOperationCBC (key , iv ))
159+
160+ plaintext = b"Hello World!!!!!"
161+
162+ ciphertext = to_bufferable ('' )
163+
164+ ciphertext += encrypter .feed (plaintext )
165+ ciphertext += encrypter .feed ('' )
166+ ciphertext += encrypter .feed (plaintext )
167+ ciphertext += encrypter .feed (None )
168+ expected = b'(Ob\xe5 \xae "\xdc \xb0 \x84 \xc5 \x04 \x04 GQ\xd8 .\x0e 4\xd2 b\xc1 \x15 \xe5 \x11 M\xfc \x9a \xd2 \xd5 \xc8 xP\x00 [\xd5 7\x92 \x01 \xbb \xc4 2\x18 \xbc \xbf \x1a y\x19 P'
169+
170+ decrypter = pyaes .Decrypter (pyaes .AESModeOfOperationCBC (key , iv ))
171+
172+ output = to_bufferable ('' )
173+
174+ output += decrypter .feed ('' )
175+ output += decrypter .feed (ciphertext )
176+ output += decrypter .feed ('' )
177+ output += decrypter .feed (None )
178+
179+ print (" passed=%(passed)s" % dict (passed = (ciphertext == expected and output == (plaintext + plaintext ))))
180+
181+ TestIssue15 ()
You can’t perform that action at this time.
0 commit comments