[Python-modules-commits] [pyaes] 04/06: New upstream version 1.6.1

Tristan Seligmann mithrandi at moszumanska.debian.org
Mon Dec 18 12:33:05 UTC 2017


This is an automated email from the git hooks/post-receive script.

mithrandi pushed a commit to branch debian/master
in repository pyaes.

commit 4d264c969453c5165f102fbefd255dad56e17786
Author: Tristan Seligmann <mithrandi at mithrandi.net>
Date:   Mon Dec 18 14:28:58 2017 +0200

    New upstream version 1.6.1
---
 PKG-INFO                  |  2 +-
 README.md                 | 10 +++++-----
 pyaes/blockfeeder.py      |  2 +-
 setup.py                  |  2 +-
 tests/test-blockfeeder.py | 33 +++++++++++++++++++++++++++++++++
 5 files changed, 41 insertions(+), 8 deletions(-)

diff --git a/PKG-INFO b/PKG-INFO
index fa926d2..de29e21 100644
--- a/PKG-INFO
+++ b/PKG-INFO
@@ -1,6 +1,6 @@
 Metadata-Version: 1.1
 Name: pyaes
-Version: 1.6.0
+Version: 1.6.1
 Summary: Pure-Python Implementation of the AES block-cipher and common modes of operation
 Home-page: https://github.com/ricmoo/pyaes
 Author: Richard Moore
diff --git a/README.md b/README.md
index 05b39f3..26e3b2b 100644
--- a/README.md
+++ b/README.md
@@ -1,7 +1,7 @@
 pyaes
 =====
 
-A pure-Python implmentation of the AES block cipher algorithm and the common modes of operation (CBC, CFB, CTR, ECB and OFB).
+A pure-Python implementation of the AES block cipher algorithm and the common modes of operation (CBC, CFB, CTR, ECB and OFB).
 
 
 Features
@@ -9,7 +9,7 @@ Features
 
 * Supports all AES key sizes
 * Supports all AES common modes
-* Pure-Python (no external dependancies)
+* Pure-Python (no external dependencies)
 * BlockFeeder API allows streams to easily be encrypted and decrypted
 * Python 2.x and 3.x support (make sure you pass in bytes(), not strings for Python 3)
 
@@ -34,7 +34,7 @@ To generate keys from simple-to-remember passwords, consider using a _password-b
 
 ### Common Modes of Operation
 
-There are many modes of operations, each with various pros and cons. In general though, the **CBC** and **CTR** modes are recommended. The **ECB is NOT recommended.**, and is included primarilty for completeness.
+There are many modes of operations, each with various pros and cons. In general though, the **CBC** and **CTR** modes are recommended. The **ECB is NOT recommended.**, and is included primarily for completeness.
 
 Each of the following examples assumes the following key:
 ```python
@@ -92,7 +92,7 @@ ciphertext = aes.encrypt(plaintext)
 print repr(ciphertext)
 
 
-# The cipher-block chaining mode of operation maintains state, so 
+# The cipher-block chaining mode of operation maintains state, so
 # decryption requires a new instance be created
 aes = pyaes.AESModeOfOperationCBC(key, iv = iv)
 decrypted = aes.decrypt(ciphertext)
@@ -116,7 +116,7 @@ ciphertext = aes.encrypt(plaintext)
 print repr(ciphertext)
 
 
-# The cipher-block chaining mode of operation maintains state, so 
+# The cipher-block chaining mode of operation maintains state, so
 # decryption requires a new instance be created
 aes = pyaes.AESModeOfOperationCFB(key, iv = iv, segment_size = 8)
 decrypted = aes.decrypt(ciphertext)
diff --git a/pyaes/blockfeeder.py b/pyaes/blockfeeder.py
index f4113c3..b9a904d 100644
--- a/pyaes/blockfeeder.py
+++ b/pyaes/blockfeeder.py
@@ -165,7 +165,7 @@ class BlockFeeder(object):
             raise ValueError('already finished feeder')
 
         # Finalize; process the spare bytes we were keeping
-        if not data:
+        if data is None:
             result = self._final(self._buffer, self._padding)
             self._buffer = None
             return result
diff --git a/setup.py b/setup.py
index 884701d..8fd556b 100644
--- a/setup.py
+++ b/setup.py
@@ -8,7 +8,7 @@ OFB) with no dependencies beyond standard Python libraries. See README.md
 for API reference and details.'''
 
 setup(name = 'pyaes',
-      version = '1.6.0',
+      version = '1.6.1',
       description = 'Pure-Python Implementation of the AES block-cipher and common modes of operation',
       long_description = LONG_DESCRIPTION,
       author = 'Richard Moore',
diff --git a/tests/test-blockfeeder.py b/tests/test-blockfeeder.py
index 41bd487..f88f259 100644
--- a/tests/test-blockfeeder.py
+++ b/tests/test-blockfeeder.py
@@ -146,3 +146,36 @@ for mode_name in pyaes.AESModesOfOperation:
     passed = decrypted == plaintext
     cipher_length = len(ciphertext)
     print("  cipher-length=%(cipher_length)s passed=%(passed)s" % locals())
+
+# Issue #15
+# https://github.com/ricmoo/pyaes/issues/15
+# @TODO: These tests need a severe overhaul; they should use deterministic input, keys and IVs...
+def TestIssue15():
+    print('Issue #15')
+
+    key = b"abcdefghijklmnop"
+    iv = b"0123456789012345"
+    encrypter = pyaes.Encrypter(pyaes.AESModeOfOperationCBC(key, iv))
+
+    plaintext = b"Hello World!!!!!"
+
+    ciphertext = to_bufferable('')
+
+    ciphertext += encrypter.feed(plaintext)
+    ciphertext += encrypter.feed('')
+    ciphertext += encrypter.feed(plaintext)
+    ciphertext += encrypter.feed(None)
+    expected = b'(Ob\xe5\xae"\xdc\xb0\x84\xc5\x04\x04GQ\xd8.\x0e4\xd2b\xc1\x15\xe5\x11M\xfc\x9a\xd2\xd5\xc8xP\x00[\xd57\x92\x01\xbb\xc42\x18\xbc\xbf\x1ay\x19P'
+
+    decrypter = pyaes.Decrypter(pyaes.AESModeOfOperationCBC(key, iv))
+
+    output = to_bufferable('')
+
+    output += decrypter.feed('')
+    output += decrypter.feed(ciphertext)
+    output += decrypter.feed('')
+    output += decrypter.feed(None)
+
+    print("  passed=%(passed)s" % dict(passed = (ciphertext == expected and output == (plaintext + plaintext))))
+
+TestIssue15()

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/pyaes.git



More information about the Python-modules-commits mailing list