pub struct Sender { /* private fields */ }rustcrypto only.Expand description
The sending half: the two group counter spaces this node owns (§4.6.1).
A group message’s counter is free-running and rolls over (§4.6.5.2.2) — unlike a session’s, which must never repeat, because a group counter’s nonce is diversified by the Source Node ID as well.
Implementations§
Source§impl Sender
impl Sender
Sourcepub const fn new(node: NodeId, data: u32, control: u32) -> Self
pub const fn new(node: NodeId, data: u32, control: u32) -> Self
A sender for node, with its two counters started where the caller says.
§4.6.1.1 has a node choose its initial counters at random on boot, so these come from
Rng rather than from zero: starting at zero would make every
message this node has ever sent replayable against a peer that had not heard from it
since its last boot. Pass the random words as they come —
MessageCounter::new narrows each to the range
§4.6.1.1 specifies.
This is the factory-reset path. §4.6.1.3 randomises these two counters once, on a
factory reset, and requires them to be persisted and never to roll back after that — so
a node that has run before restores them with restore instead, and
calling this on every boot would rewind them and reuse a nonce.
Sourcepub const fn restore(node: NodeId, data: u32, control: u32) -> Self
pub const fn restore(node: NodeId, data: u32, control: u32) -> Self
A sender whose counters come from durable storage, at exactly the values given.
§4.6.1.3: “Nodes are required to persist the Global Group Encrypted Message Counters in
durable storage. In particular, Nodes are required to ensure that the value of the
Global Group Encrypted Message Counters never rolls back”. Unlike new
these values are taken as they are: they are not a random seed, they are where this node
actually was, and narrowing them to §4.6.1.1’s range would roll them back by up to 2³²
and reuse every nonce since.
Persist ahead of where the counter stands, as §4.6.3 describes for the Check-In counter: a node that stores every value writes flash on every message, and one that stores the value it is at loses the writes it had not flushed when it lost power.
Sourcepub fn send(
&mut self,
key: &OperationalKey,
group: GroupId,
protocol_header: &ProtocolHeader,
payload: &[u8],
control: bool,
scratch: &mut [u8],
out: &mut [u8],
) -> Result<usize>
pub fn send( &mut self, key: &OperationalKey, group: GroupId, protocol_header: &ProtocolHeader, payload: &[u8], control: bool, scratch: &mut [u8], out: &mut [u8], ) -> Result<usize>
Builds one group message (§4.16.2).
scratch joins the protocol header and the payload for the AEAD, as on a unicast
session; out takes the finished message, which the caller sends to
multicast_address on
PORT.
§4.16.2 step 2c: “The Security Flags SHALL have only the P Flag set” — a group message is always privacy-obfuscated, because the whole point of the address is that anyone on the link can see it.