Module cell

Module cell 

Source
Expand description

Cell types for the Tor relay protocol.

This module provides cell types used in ORPort communication as defined in the Tor protocol specification (tor-spec.txt). Cells are the fundamental unit of communication in the Tor relay protocol.

§Overview

Cells are fixed-size or variable-size messages exchanged between Tor relays and clients. Each cell has a circuit ID, command type, and payload. The format depends on the link protocol version negotiated during connection.

§Cell Types

Cells are categorized by their function:

§Connection Setup

§Circuit Management

§Data Transfer

  • RelayCell - End-to-end encrypted data (section 6.1)

§Padding

§Cell Format

Fixed-size cells (link protocol 4+):

[ CircID (4 bytes) ][ Command (1 byte) ][ Payload (509 bytes) ]

Variable-size cells:

[ CircID (4 bytes) ][ Command (1 byte) ][ Length (2 bytes) ][ Payload ]

§Example

use stem_rs::client::cell::{VersionsCell, Cell, CellType};
use stem_rs::client::datatype::LinkProtocol;

// Create a VERSIONS cell for protocol negotiation
let versions = VersionsCell::new(vec![3, 4, 5]);
let packed = versions.pack(&LinkProtocol::new(2));

// Parse a cell from bytes
let (cell, remainder) = Cell::pop(&packed, 2).unwrap();

§See Also

Structs§

AuthChallengeCell
Authentication challenge cell.
CertsCell
Relay certificates cell.
CreateFastCell
Circuit creation cell using fast handshake (no public key).
CreatedFastCell
Response to CREATE_FAST circuit creation.
DestroyCell
Circuit teardown cell.
NetinfoCell
Network information exchange cell.
PaddingCell
Fixed-size padding cell for traffic analysis resistance.
RelayCell
End-to-end encrypted relay cell.
VPaddingCell
Variable-length padding cell.
VersionsCell
Link protocol version negotiation cell.

Enums§

Cell
Parsed cell from the Tor relay protocol.
CellType
Cell command types in the Tor relay protocol.

Constants§

AUTH_CHALLENGE_SIZE
Size of the authentication challenge in AUTH_CHALLENGE cells (32 bytes).
CELL_TYPE_SIZE
Size type for cell command field (1 byte).
FIXED_PAYLOAD_LEN
Fixed payload length for fixed-size cells (509 bytes).
HASH_LEN
Length of SHA-1 hash used for key material (20 bytes).
PAYLOAD_LEN_SIZE
Size type for variable cell payload length field (2 bytes).
RELAY_DIGEST_SIZE
Size type for relay cell digest field (4 bytes).
STREAM_ID_DISALLOWED
Relay commands that must have a zero stream ID.
STREAM_ID_REQUIRED
Relay commands that require a non-zero stream ID.

Functions§

cell_by_name
Looks up a cell type by its protocol name.
cell_by_value
Looks up a cell type by its numeric command value.