pub struct AgileSecretKey { /* private fields */ }Expand description
Self-describing crypto-agile secret decapsulation key (automatically zeroized on drop).
Implementations§
Source§impl AgileSecretKey
impl AgileSecretKey
Sourcepub const fn algorithm(&self) -> KemAlgorithm
pub const fn algorithm(&self) -> KemAlgorithm
Returns the KEM algorithm associated with this secret key.
Sourcepub fn expose_raw_bytes(&self) -> &[u8] ⓘ
pub fn expose_raw_bytes(&self) -> &[u8] ⓘ
Explicitly borrows the raw algorithm-specific secret key bytes.
Sourcepub fn from_raw(
policy: SecurityPolicy,
algorithm: KemAlgorithm,
bytes: &[u8],
) -> Result<Self>
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.
Sourcepub fn expose_wire_bytes(&self) -> Vec<u8> ⓘ
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.
Sourcepub fn wire_algorithm(bytes: &[u8]) -> Result<KemAlgorithm>
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).
Sourcepub fn from_wire_bytes(policy: SecurityPolicy, bytes: &[u8]) -> Result<Self>
pub fn from_wire_bytes(policy: SecurityPolicy, bytes: &[u8]) -> Result<Self>
Deserializes a self-describing secret key and enforces policy + spec key checks.
Sourcepub fn decaps(
&self,
policy: SecurityPolicy,
kem_ct: &[u8],
) -> Result<SharedSecret>
pub fn decaps( &self, policy: SecurityPolicy, kem_ct: &[u8], ) -> Result<SharedSecret>
Decapsulates raw kem_ct bytes under policy.