Skip to main content

sefy_core/
lib.rs

1//! Core library behind [sefy](https://github.com/lacodda/sefy): a personal
2//! secret store that lives in one unremarkable file.
3//!
4//! A vault is a SQLite database sealed whole with XChaCha20-Poly1305 under a
5//! key derived from a master password with Argon2id. The file on disk is
6//! `salt ‖ nonce ‖ ciphertext` — no magic bytes, no header, no extension
7//! convention, nothing to mark it as a secret store.
8//!
9//! # Threat model
10//!
11//! sefy is **inconspicuous, not deniable**. It hides secrets from a passing
12//! glance, a curious file listing and a cloud-side scanner looking for known
13//! formats. It does not claim to withstand forensic analysis — a
14//! high-entropy headerless file is recognizable as *some* container to an
15//! examiner — nor to protect anyone compelled to give up a password.
16//!
17//! # Example
18//!
19//! ```
20//! use sefy_core::{ItemKind, NewItem, Payload, Query, Vault};
21//! # let directory = tempfile::tempdir().unwrap();
22//! # let path = directory.path().join("notes.bak");
23//!
24//! let mut vault = Vault::create(&path, b"master password")?;
25//! let id = vault.add(
26//!     NewItem::new("bank", Payload::Note { text: "vault code 1234".into() })
27//!         .with_tags(["money"]),
28//! )?;
29//! vault.save()?;
30//!
31//! let reopened = Vault::open(&path, b"master password")?;
32//! let found = reopened.search(&Query::all().text("bank").kind(ItemKind::Note))?;
33//! assert_eq!(found[0].id, id);
34//! # Ok::<(), sefy_core::Error>(())
35//! ```
36
37#![forbid(unsafe_code)]
38#![warn(missing_docs)]
39
40#[cfg(feature = "agent")]
41pub mod agent;
42pub mod audit;
43pub mod clipboard;
44pub mod copies;
45pub mod crypto;
46pub mod db;
47pub mod device;
48pub mod error;
49pub mod exchange;
50pub mod expiry;
51pub mod format;
52pub mod generate;
53pub mod history;
54pub mod keys;
55pub mod merge;
56pub mod model;
57pub mod otp;
58pub mod plugin;
59pub mod policy;
60pub mod strength;
61pub mod sync;
62pub mod time;
63pub mod vault;
64pub mod wipe;
65
66pub use audit::{Due, Old, Place, Report, Unreadable, Weak, audit};
67pub use error::{Error, Result};
68pub use exchange::{
69    EXPORT_VERSION, Export, ExportField, ExportItem, ExportReport, ExportStamp, ExportVersion,
70    Exported, Format, ImportReport, Notice, Outcome, Target,
71};
72pub use expiry::Expiry;
73pub use format::{FORMAT_VERSION, SEALING, Sealing};
74pub use generate::{Classes, Generated, Language, Recipe, generate};
75pub use history::{Change, ChangeKind, Line, Version};
76pub use keys::{FreshKey, KeySource, Opener};
77pub use merge::{Conflict, MergeReport, MergedItem, Side, merge};
78pub use model::{
79    AuditAs, Field, FieldSpec, Item, ItemKind, ItemSummary, LEGACY_LOGIN_NAME, NewItem, Payload,
80    Query, Template,
81};
82pub use otp::Totp;
83pub use plugin::{PROTOCOL_VERSION, Plugin};
84pub use policy::Policy;
85pub use strength::{Strength, estimate, estimate_generated};
86pub use sync::{Fetched, PullReport, SyncPreview, SyncReport, fetch, pull, push, sync};
87pub use vault::{PasswordChange, Stats, Status, SyncStamp, Vault};
88pub use wipe::Wiped;