arsenal-crypto · kdf
Declared module signatures, types, configuration, and source documentation.
Source: arsenal/crates/arsenal-crypto/src/kdf.rs. SHA-256: f900fbc6fdc13ce45694fea8fe5b1f2c5192433e7e3a9b471f0f92e226a66b34.
This source reference follows declared modules and preserves feature attributes. It includes public declarations and implementation methods in those modules. Private-module exports and trait resolution still require the compiler; not every declaration is a crate-root import. Function bodies and constant values are omitted. Source comments describe their implementation context and are not a production deployment claim.
kdf::DerivedKey
A derived key (zeroized on drop)
#[derive(Clone, Zeroize, ZeroizeOnDrop)]
pub struct DerivedKey {
}Source line: 16.
kdf::DerivedKey::from_bytes
Create from bytes
#[must_use]
pub fn from_bytes(bytes: Vec<u8>) -> Self;Source line: 23.
kdf::DerivedKey::as_bytes
Get the key bytes
#[must_use]
pub fn as_bytes(&self) -> &[u8];Source line: 29.
kdf::DerivedKey::as_array_32
Get as fixed-size array if length matches
#[must_use]
pub fn as_array_32(&self) -> Option<[u8; 32]>;Source line: 35.
kdf::DerivedKey::len
Get the length
#[must_use]
pub fn len(&self) -> usize;Source line: 47.
kdf::DerivedKey::is_empty
Check if empty
#[must_use]
pub fn is_empty(&self) -> bool;Source line: 53.
kdf::KeyDerivation
Key derivation trait
pub trait KeyDerivation {
/// Derive a key the specified length
///
/// # Errors
/// Returns an error if derivation fails
fn derive(&self, length: usize) -> ArsenalResult<DerivedKey>;
/// Derive a 32-byte key
///
/// # Errors
/// Returns an error if derivation fails
fn derive_32(&self) -> ArsenalResult<[u8; 32]> ;
}Source line: 65.
kdf::HkdfDeriver
HKDF key derivation
pub struct HkdfDeriver {
}Source line: 88.
kdf::HkdfDeriver::new
Create a new HKDF deriver from input key material
#[must_use]
pub fn new(ikm: &[u8], salt: Option<&[u8]>) -> Self;Source line: 96.
kdf::HkdfDeriver::from_shared_secret
Create from ad secret (e.g., from Diffie-Hellman)
#[must_use]
pub fn from_shared_secret(shared_secret: &[u8], context: &str) -> Self;Source line: 103.
kdf::HkdfDeriver::derive_with_info
Derive with additional info
Errors
Returns an error if derivation fails
pub fn derive_with_info(&self, info: &[u8], length: usize) -> ArsenalResult<DerivedKey>;Source line: 113.
kdf::Blake3Deriver
BLAKE3 key derivation (faster alternative to HKDF)
pub struct Blake3Deriver {
}Source line: 135.
kdf::Blake3Deriver::new
Create a new BLAKE3 deriver
#[must_use]
pub fn new(ikm: &[u8], context: impl Into<String>) -> Self;Source line: 145.
kdf::Blake3Deriver::derive_with_info
Derive with additional info
#[must_use]
pub fn derive_with_info(&self, info: &[u8], length: usize) -> DerivedKey;Source line: 154.
kdf::Argon2Params
Argon2id parameters for password hashing
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Argon2Params {
/// Memory cost in KiB
pub memory_kib: u32,
/// Time cost (iterations)
pub time_cost: u32,
/// Parallelism
pub parallelism: u32,
/// Output length
pub output_len: usize
}Source line: 189.
kdf::Argon2Deriver
Argon2id password-based key derivation
pub struct Argon2Deriver {
}Source line: 213.
kdf::Argon2Deriver::new
Create a new Argon2 deriver with random salt
Errors
Returns an error if random generation fails
pub fn new(params: Argon2Params) -> ArsenalResult<Self>;Source line: 223.
kdf::Argon2Deriver::with_salt
Create with a specific salt
#[must_use]
pub fn with_salt(params: Argon2Params, salt: [u8; 16]) -> Self;Source line: 230.
kdf::Argon2Deriver::salt
Get the salt (needed for verification)
#[must_use]
pub fn salt(&self) -> &[u8; 16];Source line: 236.
kdf::Argon2Deriver::derive_from_password
Derive a key from a password
Errors
Returns an error if derivation fails
pub fn derive_from_password(&self, password: &[u8]) -> ArsenalResult<DerivedKey>;Source line: 244.
kdf::SessionKeyDeriver
Session key deriver for deriving session-specific keys
pub struct SessionKeyDeriver {
}Source line: 280.
kdf::SessionKeyDeriver::new
Create a new session key deriver
#[must_use]
pub fn new(base_key: [u8; 32], session_id: impl Into<String>) -> Self;Source line: 290.
kdf::SessionKeyDeriver::derive_for_purpose
Derive a key for a specific purpose
#[must_use]
pub fn derive_for_purpose(&self, purpose: &str) -> [u8; 32];Source line: 299.
kdf::SessionKeyDeriver::derive_encryption_key
Derive encryption key
#[must_use]
pub fn derive_encryption_key(&self) -> [u8; 32];Source line: 308.
kdf::SessionKeyDeriver::derive_mac_key
Derive MAC key
#[must_use]
pub fn derive_mac_key(&self) -> [u8; 32];Source line: 314.
kdf::SessionKeyDeriver::derive_wrap_key
Derive wrapping key
#[must_use]
pub fn derive_wrap_key(&self) -> [u8; 32];Source line: 320.