pub struct SecureSession {Show 15 fields
pub local_session_id: SessionId,
pub peer_session_id: SessionId,
pub kind: SessionKind,
pub role: Role,
pub peer_node_id: NodeId,
pub peer_cats: Vec<CaseAuthenticatedTag, 3>,
pub local_node_id: NodeId,
pub fabric_index: FabricIndex,
pub keys: EstablishedKeys,
pub counter: MessageCounter,
pub window: CounterWindow,
pub mrp: MrpParams,
pub session_timestamp: Instant,
pub active_timestamp: Instant,
pub peer: Option<Peer>,
}rustcrypto only.Expand description
One established secure session (§4.13.2).
Fields§
§local_session_id: SessionIdThe id this node chose, and the one peers put in messages to it.
peer_session_id: SessionIdThe id the peer chose, which this node puts in messages to it.
kind: SessionKindPASE or CASE.
role: RoleWhich end this node was, which decides the key direction.
peer_node_id: NodeIdThe peer’s operational Node ID. Meaningless for PASE, where nothing has proved an
identity yet, so it is NodeId::UNSPECIFIED there.
peer_cats: Vec<CaseAuthenticatedTag, 3>The CASE Authenticated Tags the peer’s operational certificate carried (§6.6.2.1.2).
Kept on the session because §6.6.6.3 derives the access-control subject from session metadata, never from the message — and the certificate that proved them is gone by the time an interaction arrives. At most three: §6.5.6 allows a NOC no more.
local_node_id: NodeIdThis node’s own Node ID on the session’s fabric.
fabric_index: FabricIndexThe fabric, or FabricIndex::NONE for PASE.
keys: EstablishedKeysThe keys, both directions.
counter: MessageCounterThis node’s outgoing counter for this session.
window: CounterWindowThe peer’s counters already seen (§4.6.5).
mrp: MrpParamsThe peer’s MRP parameters, from discovery or session establishment.
session_timestamp: Instant“A timestamp indicating the time at which the last message was sent or received.”
active_timestamp: Instant“A timestamp indicating the time at which the last message was received.” Drives
PeerActiveMode.
peer: Option<Peer>Where the peer was when it last sent on this session.
§4.12.4 needs the transport to decide whether MRP runs at all, and a node that starts an exchange of its own — a subscription report (§8.5.3), a BDX transfer, any command a controller sends — needs an address to send to. An exchange the peer opened learns this from the datagram that opened it; one this node opens has nothing to learn it from, so the session remembers.
None until a message has arrived, which for a session established by this node’s own
handshake means the handshake’s last message.
Implementations§
Source§impl SecureSession
impl SecureSession
Sourcepub fn new(
local_session_id: SessionId,
peer_session_id: SessionId,
kind: SessionKind,
role: Role,
keys: EstablishedKeys,
initial_counter: u32,
now: Instant,
) -> Self
pub fn new( local_session_id: SessionId, peer_session_id: SessionId, kind: SessionKind, role: Role, keys: EstablishedKeys, initial_counter: u32, now: Instant, ) -> Self
Builds a session from what establishment produced.
initial_counter is a full-width random word from Rng;
MessageCounter::new narrows it to the range §4.6.1.1 specifies, so no caller has to
know that a message counter does not start just anywhere.
Sourcepub const fn encrypt_keys(&self) -> &SessionKeys
pub const fn encrypt_keys(&self) -> &SessionKeys
The keys this node encrypts with (§4.14.1).
Sourcepub const fn decrypt_keys(&self) -> &SessionKeys
pub const fn decrypt_keys(&self) -> &SessionKeys
The keys this node decrypts with — the other direction.
Sourcepub const fn send_nonce_source(&self) -> NonceSource
pub const fn send_nonce_source(&self) -> NonceSource
Where the AEAD nonce’s Source Node ID comes from, for messages this node sends.
§4.8.1.1: a PASE session always uses the Unspecified Node ID; a CASE session uses the operational Node ID of whoever protected the message, which for an outgoing message is this node.
Sourcepub const fn recv_nonce_source(&self) -> NonceSource
pub const fn recv_nonce_source(&self) -> NonceSource
Where the nonce’s Source Node ID comes from for messages this node receives — the peer protected those, so it is the peer’s id.
Sourcepub fn next_counter(&mut self, now: Instant) -> Result<u32>
pub fn next_counter(&mut self, now: Instant) -> Result<u32>
Takes the next outgoing message counter, and marks the session used.
Sourcepub fn accept_counter(&mut self, counter: u32, now: Instant) -> Verdict
pub fn accept_counter(&mut self, counter: u32, now: Instant) -> Verdict
Judges an incoming counter and, if it is new, marks the session and peer active.
Sourcepub fn peer_active(&self, now: Instant) -> bool
pub fn peer_active(&self, now: Instant) -> bool
Whether the peer counts as active (§4.13.2, PeerActiveMode).