fixedlen

class cell.fixedlen.FixedLenCell(header, payload=None)[source]

Bases: oppy.cell.cell.Cell

A container class for representing fixed-length cells.

static padCellBytes(cell_bytes, link_version=3)[source]

Pad cell_bytes to uniform length.

Length depends on the Link Protocol version in use.

Parameters:
  • cell_bytes (str) – byte string to pad
  • link_version (int) – Link Protocol version in use
Returns:

str cell_bytes padded to a fixed-length

getBytes(trimmed=False)[source]

Build and return the raw bytes this cell represents.

Parameters:trimmed (bool) – ignored
Returns:str byte representation of this cell.
payloadRange()[source]

Return a two-tuple representing the (start, end) positions of this cell’s payload data (based on Link Protocol version in use).

Returns:tuple, int (start, end) indices of payload.
class Header(circ_id=None, cmd=None, link_version=3)[source]

Bases: object

A simple container class for representing the header information of a fixed-length cell.

getBytes()[source]

Return the raw bytes of this header.

Returns:str byte representation of this header
class cell.fixedlen.Create2Cell(header, htype=None, hlen=None, hdata=None)[source]

Bases: cell.fixedlen.FixedLenCell

Note

tor-spec, Section 5.1

static make(circ_id, htype=2, hlen=84, hdata='', link_version=3)[source]

Build and return a Create2 cell, using default values where possible.

Automatically create and use an appropriate FixedLenCell.Header.

Parameters:
  • circ_id (int) – Circuit ID to use for this cell
  • hlen (int) – Length of hdata segment
  • hdata (str) – Actual handshake data to use (an onion skin)
  • link_version (int) – Link Protocol version in use
Returns:

Create2Cell

getBytes(trimmed=False)[source]

Construct and return the byte string represented by this cell.

Parameters:trimmed (bool) – If True, return just the cell bytes with no padding. Otherwise, pad cell bytes out to fixed-length size according to Link Protocol version in use.
Returns:str formatted byte string represented by this cell
class cell.fixedlen.Created2Cell(header, hlen=None, hdata=None)[source]

Bases: cell.fixedlen.FixedLenCell

Note

tor-spec, Section 5.1

getBytes(trimmed=False)[source]

Construct and return the byte string represented by this cell.

Parameters:trimmed (bool) – If True, return just the bytes without padding. Otherwise, pad length out to fixed-length cell size according to Link Protocol version in use.
Returns:str raw byte string this cell represents.
class cell.fixedlen.CreatedFastCell(header)[source]

Bases: cell.fixedlen.FixedLenCell

Note

Not Implemented.

class cell.fixedlen.CreatedCell(header)[source]

Bases: cell.fixedlen.FixedLenCell

Note

Not Implemented.

class cell.fixedlen.CreateFastCell(header)[source]

Bases: cell.fixedlen.FixedLenCell

Note

Not Implemented.

class cell.fixedlen.CreateCell(header)[source]

Bases: cell.fixedlen.FixedLenCell

Note

Not Implemented.

class cell.fixedlen.DestroyCell(header, reason=None)[source]

Bases: cell.fixedlen.FixedLenCell

Note

tor-spec, Section 5.4

static make(circ_id, reason=0, link_version=3)[source]

Build and return a Destroy cell, using default values where possible.

Automatically create and use an appropriate FixedLenCell.Header.

Parameters:
  • circ_id (int) – Circuit ID to use for this cell
  • reason (int) – Reason this DESTROY cell is being sent
  • link_version (int) – Link Protocol version in use
Returns:

DestroyCell

getBytes(trimmed=False)[source]

Construct and return the byte string represented by this cell.

Parameters:trimmed (bool) – If True, return just the bytes without padding. Otherwise, pad length out to fixed-length cell size according to Link Protocol version in use.
Returns:str raw byte string this cell represents
class cell.fixedlen.EncryptedCell(header, enc_payload=None)[source]

Bases: cell.fixedlen.FixedLenCell

Note

EncryptedCell is not a defined cell type in tor-spec, but we use it as a convenient way to represent RELAY cells or RELAY_EARLY cells that have either been encrypted by oppy or received from the network and have not been decrypted yet.

static make(circ_id, payload, link_version=3, early=False)[source]

Build and return a Destroy cell, using default values where possible.

Automatically create and use an appropriate FixedLenCell.Header. The early parameter specifies whether we should send a RELAY cell or a RELAY_EARLY cell.

Warning

RELAY_EARLY cells should always be used during circuit creation to avoid certain classes of attacks. That is, whenever oppy sends a relay EXTEND2 cell, it would be sent as a RELAY_EARLY cell instead of a RELAY cell.

Reference: tor-spec, Section 5.6

Parameters:
  • circ_id (int) – Circuit ID to use for this cell
  • payload (str) – Payload bytes to use in this cell
  • link_version (int) – Link Protocol version in use
  • early (bool) – Dictate whether or not to use a RELAY_EARLY cell
Returns:

EncryptedCell

getBytes(trimmed=False)[source]

Construct and return the byte string represented by this cell.

Parameters:trimmed (bool) – ignored, encrypted cell’s don’t know anything about their payload or its length
Returns:str raw byte string this cell represents
class cell.fixedlen.NetInfoCell(header, timestamp=None, other_or_address=None, num_addresses=None, this_or_addresses=None)[source]

Bases: cell.fixedlen.FixedLenCell

Note

tor-spec.txt, Section 4.5

static make(circ_id, other_or_address, this_or_addresses, timestamp=None, link_version=3)[source]

Build and return a Destroy cell, using default values where possible.

Automatically create and use an appropriate FixedLenCell.Header.

Parameters:
  • circ_id (int) – Circuit ID to use for this cell
  • timestamp (str) – Time this NetInfoCell was created. Big-endian unsigned integer of seconds since the Unix epoch (packed format).
  • other_or_address (oppy.cell.util.TLVTriple) – Public IP address of the recipient of this NetInfoCell.
  • oppy.cell.util.TLVTriple this_or_addresses (list,) – List of the public IP address(es) of the originator of this NetInfoCell.
Returns:

NetInfoCell

getBytes(trimmed=False)[source]

Construct and return the byte string represented by this cell.

Parameters:trimmed (bool) – Whether or not we should pad this cell’s bytes. If True, pad based on Link Protocol version in use.
Returns:str raw bytes this cell represents
class cell.fixedlen.PaddingCell(header, payload=None)[source]

Bases: cell.fixedlen.FixedLenCell

Note

tor-spec, Section 3, 7.2.

Note

Padding has no cell payload fields so, we just use inherited fields.

Previous topic

cell

Next topic

relay

This Page