Invalid [Length] field when receiving RELAY cells via stem.client.Circuit
When receiving data via the stem.client.Circuit.send
method, the current behavior is to unpack the RELAY cell before "repacking-it" in order to get a "raw bytes" representation of the ciphertext. The ciphertext is then decrypted and the cell repacked.
See https://gitweb.torproject.org/stem.git/tree/stem/client/init.py#n250
However, when a RELAY cell is unpacked, its [Length] field is used as-is: hence, a encrypted RELAY may see its content needlessly truncated. Note that here the original value of the [Length] field is not retained, thus we'll later be unable to retrieve it.
See https://gitweb.torproject.org/stem.git/tree/stem/client/cell.py#n347
Finally, when a RELAY cell is packed, the [Length] field is computed from the length of the data stored. As this field will later be decrypted, we have an invalid [Length] field for every RELAY cell we receive via the stem.client.Circuit send
method.
See https://gitweb.torproject.org/stem.git/tree/stem/client/cell.py#n335
(note that was able to fix my local copy of stem by adding an extra keyword argument length=None
to RelayCell
's __init__
method that defaults to len(data)
and by adding an extra keyword argument "encrypted" to RelayCell
's _unpack
class method that defaults to False
in order to handle the discrepancy between the ciphertext/plaintext cases)
Trac:
Username: plcp