Skip to main content

EnvelopeSession

Struct EnvelopeSession 

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

Session-local envelope state. Holds the envelope key (HKDF-derived from the TransportKey), the per-session IV, the last-seen counter, and a message budget. Consumed via &mut self so nonce reuse within a session is structurally prevented.

Implementations§

Source§

impl EnvelopeSession

Source

pub async fn new( transport_key: &TransportKey, session_id: String, iv: [u8; 12], ) -> Result<Self, EnvelopeError>

Derive a fresh envelope session from a TransportKey.

Args:

  • transport_key: the session’s transport key from crate::sas::derive_transport_key.
  • session_id: the pairing session id (part of every AAD).
  • iv: per-session 96-bit IV. Produce via OsRng at session start; transmit out-of-band to the peer.

Usage:

let session = EnvelopeSession::new(&transport_key, session_id, iv).await?;
let env = session.seal("/v1/pairing/sessions/x/response", pt).await?;
Source

pub async fn seal( &mut self, path: &str, plaintext: &[u8], ) -> Result<Envelope<Sealed>, EnvelopeError>

Seal plaintext, binding to path and the next monotonic counter.

Source

pub async fn open( &mut self, path: &str, env: Envelope<Sealed>, ) -> Result<Envelope<Open>, EnvelopeError>

Open a Envelope<Sealed>. Enforces strict-monotonic counter over the session.

Trait Implementations§

Source§

impl Drop for EnvelopeSession

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. 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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V