Skip to content

Commit

Permalink
fix padding
Browse files Browse the repository at this point in the history
  • Loading branch information
AntonKueltz committed Nov 16, 2018
1 parent 10e0284 commit e7f924b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
11 changes: 9 additions & 2 deletions rfc7539/aead.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def run(self):

setup(
name='rfc7539',
version='1.1.0',
version='1.2.1',
author='Anton Kueltz',
author_email='[email protected]',
license='GNU General Public License v3 (GPLv3)',
Expand Down

0 comments on commit e7f924b

Please sign in to comment.