commit 2a76a0acfcf6aa9def2d6585ec8e53eae19b4c3c Author: Dave Rolek dmr-x@riseup.net Date: Thu Aug 9 21:12:27 2018 +0000
Further simplify digest calculation for encryption
This is a continuation of proof-of-concept changes. Again, this is not the final form that encryption will take on. --- stem/client/__init__.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/stem/client/__init__.py b/stem/client/__init__.py index 71f6d390..83c20365 100644 --- a/stem/client/__init__.py +++ b/stem/client/__init__.py @@ -32,6 +32,7 @@ import threading import stem import stem.client.cell import stem.socket +from stem.util import str_tools import stem.util.connection
from stem.client.datatype import ZERO, LinkProtocol, Address, KDF @@ -239,12 +240,15 @@ class Circuit(object):
try: # Digests and such are computed using the RELAY cell payload. - cell = stem.client.cell.RelayCell(self.id, command, data, 0, stream_id) - payload_without_digest = cell.pack(self.relay.link_protocol)[-stem.client.cell.FIXED_PAYLOAD_LEN:] + + _, command_int = stem.client.datatype.RelayCommand.get(command) + # coerce to bytes, just in case + data = str_tools._to_bytes(data) + + payload_without_digest = stem.client.cell.RelayCell._pack_payload(command_int, 0, stream_id, 0, len(data), data) self.forward_digest.update(payload_without_digest) + payload_with_digest = stem.client.cell.RelayCell._pack_payload(command_int, 0, stream_id, self.forward_digest, len(data), data)
- cell = stem.client.cell.RelayCell(self.id, command, data, self.forward_digest, stream_id) - payload_with_digest = cell.pack(self.relay.link_protocol)[-stem.client.cell.FIXED_PAYLOAD_LEN:] encrypted_payload = self.forward_key.update(payload_with_digest) encrypted_cell = stem.client.cell.RawRelayCell(self.id, encrypted_payload)
tor-commits@lists.torproject.org