Skip to main content

SecureSession

Struct SecureSession 

Source
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>,
}
Available on crate feature rustcrypto only.
Expand description

One established secure session (§4.13.2).

Fields§

§local_session_id: SessionId

The id this node chose, and the one peers put in messages to it.

§peer_session_id: SessionId

The id the peer chose, which this node puts in messages to it.

§kind: SessionKind

PASE or CASE.

§role: Role

Which end this node was, which decides the key direction.

§peer_node_id: NodeId

The 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: NodeId

This node’s own Node ID on the session’s fabric.

§fabric_index: FabricIndex

The fabric, or FabricIndex::NONE for PASE.

§keys: EstablishedKeys

The keys, both directions.

§counter: MessageCounter

This node’s outgoing counter for this session.

§window: CounterWindow

The peer’s counters already seen (§4.6.5).

§mrp: MrpParams

The 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

Source

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.

Source

pub const fn encrypt_keys(&self) -> &SessionKeys

The keys this node encrypts with (§4.14.1).

Source

pub const fn decrypt_keys(&self) -> &SessionKeys

The keys this node decrypts with — the other direction.

Source

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.

Source

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.

Source

pub fn next_counter(&mut self, now: Instant) -> Result<u32>

Takes the next outgoing message counter, and marks the session used.

Source

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.

Source

pub fn peer_active(&self, now: Instant) -> bool

Whether the peer counts as active (§4.13.2, PeerActiveMode).

Trait Implementations§

Source§

impl Debug for SecureSession

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.