Skip to main content

S0Manager

Struct S0Manager 

Source
pub struct S0Manager { /* private fields */ }
Expand description

Security 0 state for one node.

Implementations§

Source§

impl S0Manager

Source

pub fn new(own_node: u16, network_key: &NetworkKey) -> Self

A manager for own_node with the network key.

Source

pub fn set_own_node(&mut self, own_node: u16)

Changes the own node id (after being included).

Source

pub fn set_network_key(&mut self, key: &NetworkKey)

Replaces the network key (a node receiving Network Key Set).

Source

pub fn nonce_get() -> Vec<u8> ⓘ

A Nonce Get command.

Source

pub fn nonce_report(&mut self, peer: u16) -> Result<Vec<u8>, Error>

Issues a nonce for peer and returns the Nonce Report carrying it.

Source

pub fn handle_nonce_report( &mut self, peer: u16, frame: &[u8], ) -> Result<(), Error>

Stores the nonce from a peer’s Nonce Report (frame starts at 0x98 0x80).

Source

pub fn has_peer_nonce(&self, peer: u16) -> bool

Whether we hold a live nonce from peer.

Source

pub fn encapsulate( &mut self, peer: u16, command: &[u8], temp_key: bool, ) -> Result<Vec<u8>, Error>

Encapsulates command for peer with its stored nonce (consumed).

A command longer than MAX_PAYLOAD needs two frames; this returns the first and the caller sends it, fetches a new nonce and calls again with the rest via encapsulate_part.

Source

pub fn split(&mut self, command: &[u8]) -> Option<[(Vec<u8>, u8); 2]>

Splits a long command into the two halves S0 sends in sequence.

Source

pub fn encapsulate_part( &mut self, peer: u16, part: &[u8], control: u8, temp_key: bool, nonce_get: bool, ) -> Result<Vec<u8>, Error>

Encapsulates one part with an explicit frame control byte. nonce_get asks the receiver for its next nonce in the same frame.

Source

pub fn decapsulate( &mut self, peer: u16, frame: &[u8], temp_key: bool, ) -> Result<S0Payload, Error>

Decapsulates a frame from peer (frame starts at 0x98 0x81 or 0x98 0xC1).

The nonce it names must be one we issued to peer and still live; it is consumed either way.

Trait Implementations§

Source§

impl Debug for S0Manager

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.