Skip to content

Commit

Permalink
don't output arbitrary binary
Browse files Browse the repository at this point in the history
  • Loading branch information
heronhaye committed Nov 30, 2018
1 parent 04426fe commit 125b493
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 4 additions & 1 deletion triplesec/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,10 @@ def main():
elif args.hex:
print(binascii.hexlify(plaintext).decode())
else:
print(plaintext.decode('utf-8', 'replace'))
try:
print(plaintext.decode('ascii', 'strict'))
except UnicodeDecodeError:
sys.stderr.write("Aborting: unable to decode plaintext as ASCII. Use -b to output binary.\n")

elif args._command == 'enc':
plaintext = data
Expand Down
2 changes: 1 addition & 1 deletion triplesec/crypto.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ def decrypt(cls, data, key):
return strxor(data[cls.block_size:],
cls._gen_keystream(len(data[cls.block_size:]), tfish, ctr))

class XSalsa20:
class XSalsa20(object):
key_size = 32
iv_size = 24

Expand Down

0 comments on commit 125b493

Please sign in to comment.