feat(store): encrypt chat bodies at rest; Ctrl-Q CLEAR/QUIT
All checks were successful
ci / test (pull_request) Successful in 3m13s
All checks were successful
ci / test (pull_request) Successful in 3m13s
Wrap a random 32-byte message key with Argon2id+ChaCha20-Poly1305. sqlite messages.plaintext is nonce||ciphertext; identity keys stay plaintext. Empty/wrong passphrase fails closed. Ctrl-Q types CLEAR or QUIT then Enter (Esc cancels).
This commit is contained in:
parent
1d7f8e1f35
commit
6323619d80
16 changed files with 461 additions and 35 deletions
14
src/node.rs
14
src/node.rs
|
|
@ -50,7 +50,19 @@ pub struct Node {
|
|||
|
||||
impl Node {
|
||||
pub async fn start(home: PathBuf) -> Result<Arc<Self>, String> {
|
||||
let store = Store::open_at(&home).map_err(|e| e.to_string())?;
|
||||
let pass = std::env::var("ONIONWIRE_STORE_PASSPHRASE")
|
||||
.map_err(|_| "ONIONWIRE_STORE_PASSPHRASE required".to_string())?;
|
||||
if pass.is_empty() {
|
||||
return Err("empty passphrase".into());
|
||||
}
|
||||
Self::start_with_passphrase(home, &pass).await
|
||||
}
|
||||
|
||||
pub async fn start_with_passphrase(
|
||||
home: PathBuf,
|
||||
passphrase: &str,
|
||||
) -> Result<Arc<Self>, String> {
|
||||
let store = Store::open_at_with_passphrase(&home, passphrase).map_err(|e| e.to_string())?;
|
||||
let me = store.self_identity().map_err(|e| e.to_string())?;
|
||||
let keys = Keys::from_self(&me).map_err(|e| e.to_string())?;
|
||||
let nickname = store.hs_nickname().map_err(|e| e.to_string())?;
|
||||
|
|
|
|||
Loading…
Reference in a new issue