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
VersionsCell- Link protocol version negotiation (section 4)NetinfoCell- Time and address information exchange (section 4.5)CertsCell- Relay certificates (section 4.2)AuthChallengeCell- Authentication challenge (section 4.3)
§Circuit Management
CreateFastCell- Create circuit without public key (section 5.1)CreatedFastCell- Circuit creation acknowledgment (section 5.1)DestroyCell- Tear down a circuit (section 5.4)
§Data Transfer
RelayCell- End-to-end encrypted data (section 6.1)
§Padding
PaddingCell- Fixed-size padding for traffic analysis resistanceVPaddingCell- Variable-size 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
datatypefor data types used in cell construction- Tor Protocol Specification
Structs§
- Auth
Challenge Cell - Authentication challenge cell.
- Certs
Cell - Relay certificates cell.
- Create
Fast Cell - Circuit creation cell using fast handshake (no public key).
- Created
Fast Cell - Response to CREATE_FAST circuit creation.
- Destroy
Cell - Circuit teardown cell.
- Netinfo
Cell - Network information exchange cell.
- Padding
Cell - Fixed-size padding cell for traffic analysis resistance.
- Relay
Cell - End-to-end encrypted relay cell.
- VPadding
Cell - Variable-length padding cell.
- Versions
Cell - Link protocol version negotiation cell.
Enums§
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.