Skip to main content

AgileSecretKey

Struct AgileSecretKey 

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

Self-describing crypto-agile secret decapsulation key (automatically zeroized on drop).

Implementations§

Source§

impl AgileSecretKey

Source

pub const fn algorithm(&self) -> KemAlgorithm

Returns the KEM algorithm associated with this secret key.

Source

pub fn expose_raw_bytes(&self) -> &[u8] ⓘ

Explicitly borrows the raw algorithm-specific secret key bytes.

Source

pub fn from_raw( policy: SecurityPolicy, algorithm: KemAlgorithm, bytes: &[u8], ) -> Result<Self>

Imports raw secret key bytes for an explicit algorithm, validating policy and FIPS 203 §7.3.

Source

pub fn expose_wire_bytes(&self) -> Vec<u8> ⓘ

Serializes this secret key into a self-describing versioned binary format: QASK || 0x01 || alg_id(u16 BE) || raw_secret_bytes.

Callers MUST zeroize the returned Vec<u8> after writing it to secure storage.

Source

pub fn wire_algorithm(bytes: &[u8]) -> Result<KemAlgorithm>

Reads the KEM algorithm declared by a self-describing secret key wire frame without enforcing any policy or validating the key material.

Intended for keyring routing: callers holding serialized keys can select the candidates whose algorithm matches an envelope (see crate::Envelope::inspect) and parse only those with AgileSecretKey::from_wire_bytes under the active policy, so that unrelated legacy keys in the ring never trigger a policy violation.

Returns Error::InvalidDecapsulationKey if the wire header is malformed or declares an unknown algorithm (the same checks performed by AgileSecretKey::from_wire_bytes).

Source

pub fn from_wire_bytes(policy: SecurityPolicy, bytes: &[u8]) -> Result<Self>

Deserializes a self-describing secret key and enforces policy + spec key checks.

Source

pub fn decaps( &self, policy: SecurityPolicy, kem_ct: &[u8], ) -> Result<SharedSecret>

Decapsulates raw kem_ct bytes under policy.

Trait Implementations§

Source§

impl Debug for AgileSecretKey

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Zeroize for AgileSecretKey

Source§

fn zeroize(&mut self)

Overwrites all sensitive memory owned by self with zeros.

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.