Skip to main content

PacketSecurityBox

Struct PacketSecurityBox 

Source
pub struct PacketSecurityBox<A, C> { /* private fields */ }
Expand description

Bounded packet security helper combining nonce allocation, authentication, optional encryption, and replay checks.

Implementations§

Source§

impl<A, C> PacketSecurityBox<A, C>

Source

pub fn new(config: PacketSecurityConfig, authenticator: A, cipher: C) -> Self

Creates a packet security box.

Source

pub const fn config(&self) -> PacketSecurityConfig

Returns configuration.

Source

pub const fn stats(&self) -> PacketSecurityStats

Returns statistics.

Source

pub const fn replay(&self) -> &PacketReplayWindow

Borrows the replay window.

Source

pub fn into_inner(self) -> (A, C, PacketReplayWindow)

Consumes the box and returns its components.

Source§

impl<A, C> PacketSecurityBox<A, C>

Source

pub fn seal( &mut self, key_id: u32, payload: &[u8], ) -> Result<Vec<u8>, PacketSecurityError<A::Error, C::Error>>

Seals and encodes one payload.

Source

pub fn seal_with_key_ring( &mut self, key_ring: &PacketKeyRing, payload: &[u8], now: Tick, ) -> Result<Vec<u8>, PacketSecurityError<A::Error, C::Error>>

Selects a send key from key_ring, then seals and encodes one payload.

Source

pub fn seal_with_nonce( &mut self, key_id: u32, nonce: u64, payload: &[u8], ) -> Result<Vec<u8>, PacketSecurityError<A::Error, C::Error>>

Seals and encodes one payload with an explicit nonce.

Source

pub fn seal_into( &mut self, key_id: u32, payload: &[u8], out: &mut Vec<u8>, scratch: &mut PacketSecurityScratch, ) -> Result<u64, PacketSecurityError<A::Error, C::Error>>

Seals and appends one payload using an allocated nonce and reusable storage.

Source

pub fn seal_with_key_ring_into( &mut self, key_ring: &PacketKeyRing, payload: &[u8], now: Tick, out: &mut Vec<u8>, scratch: &mut PacketSecurityScratch, ) -> Result<(u32, u64), PacketSecurityError<A::Error, C::Error>>

Selects a key and appends one sealed payload using reusable storage.

Source

pub fn seal_with_nonce_into( &mut self, key_id: u32, nonce: u64, payload: &[u8], out: &mut Vec<u8>, scratch: &mut PacketSecurityScratch, ) -> Result<(), PacketSecurityError<A::Error, C::Error>>

Seals and appends one payload with an explicit nonce and reusable storage.

Source

pub fn open( &mut self, input: &[u8], ) -> Result<Vec<u8>, PacketSecurityError<A::Error, C::Error>>

Decodes, authenticates, replay-checks, and opens one payload.

Source

pub fn open_with_key_ring( &mut self, key_ring: &PacketKeyRing, input: &[u8], now: Tick, ) -> Result<Vec<u8>, PacketSecurityError<A::Error, C::Error>>

Decodes an envelope, validates its key against key_ring, then opens it.

Source

pub fn open_with_scratch<'a>( &mut self, input: &[u8], scratch: &'a mut PacketSecurityOpenScratch, ) -> Result<PacketSecurityOpenView<'a>, PacketSecurityError<A::Error, C::Error>>

Opens one envelope into caller-owned reusable payload storage.

Source

pub fn open_with_key_ring_and_scratch<'a>( &mut self, key_ring: &PacketKeyRing, input: &[u8], now: Tick, scratch: &'a mut PacketSecurityOpenScratch, ) -> Result<PacketSecurityOpenView<'a>, PacketSecurityError<A::Error, C::Error>>

Validates a key-ring entry and opens into caller-owned reusable storage.

Trait Implementations§

Source§

impl<A: Clone, C: Clone> Clone for PacketSecurityBox<A, C>

Source§

fn clone(&self) -> PacketSecurityBox<A, C>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<A: Debug, C: Debug> Debug for PacketSecurityBox<A, C>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<A, C> Freeze for PacketSecurityBox<A, C>
where A: Freeze, C: Freeze,

§

impl<A, C> RefUnwindSafe for PacketSecurityBox<A, C>

§

impl<A, C> Send for PacketSecurityBox<A, C>
where A: Send, C: Send,

§

impl<A, C> Sync for PacketSecurityBox<A, C>
where A: Sync, C: Sync,

§

impl<A, C> Unpin for PacketSecurityBox<A, C>
where A: Unpin, C: Unpin,

§

impl<A, C> UnsafeUnpin for PacketSecurityBox<A, C>
where A: UnsafeUnpin, C: UnsafeUnpin,

§

impl<A, C> UnwindSafe for PacketSecurityBox<A, C>
where A: UnwindSafe, C: UnwindSafe,

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.