keybase / python-triplesec

A Python port of the triplesec library.
BSD 3-Clause "New" or "Revised" License
82 stars 18 forks source link

triplesec CLI executable fails: sha3_512 not in hashlib #13

Closed genos closed 8 years ago

genos commented 8 years ago

After installing via pip3 [Python 3.5.2 on OS X 10.11.6], I'm unable to use the triplesec executable due to the following error:

$ triplesec -k 'key' enc 'message'                                                                                                                                                                                                                                                                                                                                  <<<
Traceback (most recent call last):
  File "/usr/local/bin/triplesec", line 11, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.5/site-packages/triplesec/__init__.py", line 325, in main
    ciphertext = encrypt(plaintext, key)
  File "/usr/local/lib/python3.5/site-packages/triplesec/__init__.py", line 102, in encrypt
    result, extra = self._encrypt(data, key, version, extra_bytes)
  File "/usr/local/lib/python3.5/site-packages/triplesec/__init__.py", line 118, in _encrypt
    macs = self._generate_macs(authenticated_data, mac_keys, version)
  File "/usr/local/lib/python3.5/site-packages/triplesec/__init__.py", line 130, in _generate_macs
    mac = m.implementation(authenticated_data, mac_keys[n])
  File "/usr/local/lib/python3.5/site-packages/triplesec/crypto.py", line 119, in HMAC_SHA3
    return hmac.new(key, data, sha3_512).digest()
  File "/usr/local/Cellar/python3/3.5.2/Frameworks/Python.framework/Versions/3.5/lib/python3.5/hmac.py", line 144, in new
    return HMAC(key, msg, digestmod)
  File "/usr/local/Cellar/python3/3.5.2/Frameworks/Python.framework/Versions/3.5/lib/python3.5/hmac.py", line 56, in __init__
    self.outer = self.digest_cons()
  File "/usr/local/lib/python3.5/site-packages/triplesec/utils.py", line 74, in <lambda>
    sha3_512 = lambda s=b'': new_sha3_512(s)
  File "/usr/local/lib/python3.5/site-packages/triplesec/utils.py", line 62, in __init__
    self._obj = hashlib.sha3_512()
AttributeError: module 'hashlib' has no attribute 'sha3_512'
cmckain15 commented 8 years ago

Install pysha3 and make sure this piece of code is in "/usr/local/lib/python3.5/site-packages/triplesec/utils.py" after the import statements:

if sys.version_info < (3, 6):
    import sha3
genos commented 8 years ago

I'm willing to hack on the code myself, but shouldn't this change be in the code, not in my local copy?

oconnor663 commented 8 years ago

I think the fix for this is in master but not yes released to PyPI. I'll confirm that and then see about getting the PyPI package updated.

oconnor663 commented 8 years ago

Ok, v0.4 is up, and it looks like it works for me. Let me know if you see this again.

genos commented 8 years ago

Great, thanks very much!