summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDamian Johnson <atagar@torproject.org>2019-05-24 11:09:26 -0700
committerDamian Johnson <atagar@torproject.org>2019-05-24 11:20:48 -0700
commiteabc0811b021f62170ceed6853ef2c602343c84b (patch)
treee0b435d5c8dccca9537bdcb0b18236085ef5b520
parent1b5cca5c4a7f9bfb2d56841ce87d6d1bf1903c6b (diff)
Hash detection in stem.client failed for pypy 3.5
Python's hashlib.HASH class is dynamically generated with different names under different python versions, making 'is this object an instance of it' uncommonly thorny. We already adjusted this once for pypy but turns out pypy 3.5 uses different case... https://trac.torproject.org/projects/tor/ticket/30598
-rw-r--r--stem/client/cell.py8
1 files changed, 4 insertions, 4 deletions
diff --git a/stem/client/cell.py b/stem/client/cell.py
index b74094c8..4b0f9fa1 100644
--- a/stem/client/cell.py
+++ b/stem/client/cell.py
@@ -347,10 +347,10 @@ class RelayCell(CircuitCell):
IS_FIXED_SIZE = True
def __init__(self, circ_id, command, data, digest = 0, stream_id = 0, recognized = 0, unused = b''):
- if 'HASH' in str(type(digest)):
+ if 'hash' in str(type(digest)).lower():
# Unfortunately hashlib generates from a dynamic private class so
# isinstance() isn't such a great option. With python2/python3 the
- # name is 'hashlib.HASH' whereas PyPy calls it just 'HASH'.
+ # name is 'hashlib.HASH' whereas PyPy calls it just 'HASH' or 'Hash'.
digest_packed = digest.digest()[:RELAY_DIGEST_SIZE.size]
digest = RELAY_DIGEST_SIZE.unpack(digest_packed)
@@ -400,7 +400,7 @@ class RelayCell(CircuitCell):
:param bytes content: cell content to be decrypted
:param cryptography.hazmat.primitives.ciphers.CipherContext key:
key established with the relay we received this cell from
- :param HASH digest: running digest held with the relay
+ :param hashlib.HASH digest: running digest held with the relay
:returns: **tuple** with our decrypted cell and updated key/digest
@@ -453,7 +453,7 @@ class RelayCell(CircuitCell):
:param int link_protocol: link protocol version
:param cryptography.hazmat.primitives.ciphers.CipherContext key:
key established with the relay we're sending this cell to
- :param HASH digest: running digest held with the relay
+ :param hashlib.HASH digest: running digest held with the relay
:returns: **tuple** with our encrypted payload and updated key/digest
"""