pub struct RawPacket {
pub payload: Vec<u8>,
pub extensions: Vec<u8>,
/* private fields */
}std only.Expand description
A partially-decoded v6 packet: the cleartext envelope with the entire
15-byte header-protected region (version included) left opaque, plus the
payload (the message remainder). The recv path produces this from the raw
wire bytes before it has the per-session HP key — it locates the ciphertext
sample (payload, at the fixed offset 15) and calls
RawPacket::unmask_header with the mask computed from payload to recover
the PacketHeader (including its version byte; the off-wire session_id
is then set by Session::parse_protected). This is the codec half of header
protection; the mask itself is computed by the session’s HeaderProtector
(this module stays crypto-free). Routing is by the outer (rotating) ConnId.
WIRE v6: no cleartext version byte and no length prefixes — the version is
inside masked_header, and payload is everything after the 15-byte header.
Fields§
§payload: Vec<u8>AEAD ciphertext = the message remainder after the 15-byte header (cleartext on the wire; the payload itself is the AEAD ciphertext).
extensions: Vec<u8>Forward-compat headroom — always empty on the v6 data-plane wire (retained
for the AAD/codec shape; see PhantomPacket::to_wire).
Implementations§
Source§impl RawPacket
impl RawPacket
Sourcepub fn from_wire(bytes: &[u8]) -> Result<Self, WireError>
pub fn from_wire(bytes: &[u8]) -> Result<Self, WireError>
Parse the cleartext envelope of a v6 wire packet, leaving the whole 15-byte
HP-masked header region opaque and taking payload as the remainder.
Bounds-checked exactly like PhantomPacket::from_wire — a short / hostile
buffer yields WireError::Truncated, never a panic.
Sourcepub fn unmask_header(&self, mask: &[u8]) -> Result<PacketHeader, WireError>
pub fn unmask_header(&self, mask: &[u8]) -> Result<PacketHeader, WireError>
Recover the full cleartext PacketHeader by XOR-ing the masked region
with the caller-supplied HP mask (the session’s
HeaderProtector::mask_recv over self.payload). A mask shorter than
HP_PROTECTED_LEN is rejected as WireError::Truncated rather than
panicking (the session always supplies a full 16-byte mask).
Sourcepub fn into_packet(self, header: PacketHeader) -> PhantomPacket
pub fn into_packet(self, header: PacketHeader) -> PhantomPacket
Reassemble a full PhantomPacket from this raw envelope plus a recovered
header, moving out payload / extensions.