use super::{MasterKek, format};
#[cfg(feature = "unlock-age-yubikey")]
pub mod age_yubikey;
#[cfg(feature = "unlock-bip39")]
pub mod bip39;
mod kdf;
pub mod passphrase;
pub mod tpm;
#[derive(Debug, thiserror::Error)]
pub enum UnlockError {
#[error("method unavailable: {0}")]
Unavailable(String),
#[error("authentication failed")]
AuthFailed,
#[error("method not implemented: {0}")]
NotImplemented(format::MethodKind),
#[error("slot params mismatch: {0}")]
ParamsMismatch(String),
#[error("crypto: {0}")]
Crypto(String),
#[error("io: {0}")]
Io(#[from] std::io::Error),
}
pub trait UnlockMethod: Send + Sync {
fn kind(&self) -> format::MethodKind;
fn available(&self) -> bool;
fn recover_kek(&self, slot: &format::Slot, header_aad: &[u8])
-> Result<MasterKek, UnlockError>;
fn wrap_kek(
&self,
kek: &MasterKek,
header_aad: &[u8],
slot_id: u32,
) -> Result<(format::MethodParams, format::KekWrap), UnlockError>;
}