pub struct FileStore { /* private fields */ }Expand description
File-based key store with optional encryption
Provides persistent storage of cryptographic keys with optional encryption at rest The key are cached in memory for performance and automatically loaded from disk
Implementations§
Source§impl FileStore
impl FileStore
Sourcepub fn new<P: AsRef<Path>>(path: P, config: StorageConfig) -> Result<Self>
pub fn new<P: AsRef<Path>>(path: P, config: StorageConfig) -> Result<Self>
Create a new FileStore at the given path
Sourcepub fn set_master_key(&mut self, key: SecretKey) -> Result<()>
pub fn set_master_key(&mut self, key: SecretKey) -> Result<()>
Set master key for encryption
Sourcepub fn init_with_password(&mut self, password: &[u8]) -> Result<()>
pub fn init_with_password(&mut self, password: &[u8]) -> Result<()>
Initialize with password-derived master key (now using per-vault salt)
Sourcepub fn derive_master_key(
password: &[u8],
salt: &[u8],
argon2_config: &Argon2Config,
) -> Result<SecretKey>
pub fn derive_master_key( password: &[u8], salt: &[u8], argon2_config: &Argon2Config, ) -> Result<SecretKey>
Derive a master key from a password using Argon2id
Sourcepub fn enable_audit_log<P: AsRef<Path>>(&mut self, log_path: P) -> Result<()>
pub fn enable_audit_log<P: AsRef<Path>>(&mut self, log_path: P) -> Result<()>
Enable audit logging to a file
Sourcepub fn set_audit_logger(&mut self, logger: Box<dyn AuditLogger>)
pub fn set_audit_logger(&mut self, logger: Box<dyn AuditLogger>)
Set a custom audit logger
Sourcepub fn export_key(&mut self, id: &KeyId, password: &[u8]) -> Result<ExportedKey>
pub fn export_key(&mut self, id: &KeyId, password: &[u8]) -> Result<ExportedKey>
Export a key to a secure, portable format
The key is encrypted with a password-derived key using Argon2id. The exported key includes all metadata and can be imported into another vault.
Sourcepub fn import_key(
&mut self,
exported: &ExportedKey,
password: &[u8],
) -> Result<KeyId>
pub fn import_key( &mut self, exported: &ExportedKey, password: &[u8], ) -> Result<KeyId>
Import a key from an exported format
Validates the key, decrypts it with the provided password, and stores it in the vault. The key will maintain its original metadata (algorithm, version, etc.).
Sourcepub fn backup(
&mut self,
password: &[u8],
config: BackupConfig,
) -> Result<VaultBackup>
pub fn backup( &mut self, password: &[u8], config: BackupConfig, ) -> Result<VaultBackup>
Create a full backup of the vault
§Arguments
password- Password to encrypt the backupconfig- Backup configuration
§Returns
The encrypted backup that can be saved to a file
§Security
The backup is encrypted using Argon2id key derivation and XChaCha20Poly1305 AEAD. All key material is protected with high-security parameters.