diff --git a/rfc7539/aead.py b/rfc7539/aead.py index e46d9b6..37169c0 100644 --- a/rfc7539/aead.py +++ b/rfc7539/aead.py @@ -27,9 +27,16 @@ def _len_bytes(n): return slen +def _pad16(x): + if len(x) % 16 == 0: + return b'' + else: + return b'\x00' * (16 - (len(x) % 16)) + + def _tag_data(aad, ciphertext): - tag_data = aad + b'\x00' * (16 - (len(aad) % 16)) - tag_data += ciphertext + b'\x00' * (16 - (len(ciphertext) % 16)) + tag_data = aad + _pad16(aad) + tag_data += ciphertext + _pad16(ciphertext) tag_data += _len_bytes(len(aad)) tag_data += _len_bytes(len(ciphertext)) return tag_data diff --git a/setup.py b/setup.py index 8049d90..3b76bdd 100644 --- a/setup.py +++ b/setup.py @@ -32,7 +32,7 @@ def run(self): setup( name='rfc7539', - version='1.1.0', + version='1.2.1', author='Anton Kueltz', author_email='kueltz.anton@gmail.com', license='GNU General Public License v3 (GPLv3)',