fix(store): drop payments on /wipe; document non-forensic
All checks were successful
ci / test (pull_request) Successful in 3m1s
All checks were successful
ci / test (pull_request) Successful in 3m1s
/wipe now deletes payments as well as chat, checkpoints WAL, and enables sqlite secure_delete (flash still not crypto-shred).
This commit is contained in:
parent
bfd28fce6b
commit
45c105de8a
5 changed files with 70 additions and 12 deletions
12
src/store.rs
12
src/store.rs
|
|
@ -4,9 +4,9 @@ use std::path::{Path, PathBuf};
|
|||
use std::time::{SystemTime, UNIX_EPOCH};
|
||||
|
||||
use ed25519_dalek::SigningKey;
|
||||
use rand::RngCore;
|
||||
use rand::rngs::OsRng;
|
||||
use rusqlite::{Connection, OptionalExtension, params};
|
||||
use rand::RngCore;
|
||||
use rusqlite::{params, Connection, OptionalExtension};
|
||||
use x25519_dalek::{PublicKey as X25519Public, StaticSecret};
|
||||
|
||||
pub type Result<T> = std::result::Result<T, Error>;
|
||||
|
|
@ -123,6 +123,9 @@ impl Store {
|
|||
if !journal.eq_ignore_ascii_case("wal") {
|
||||
return Err(Error(format!("journal_mode WAL failed: {journal}")));
|
||||
}
|
||||
// Overwrite freed pages on DELETE. Flash wear-leveling can still keep copies;
|
||||
// this is not a forensic / SSD crypto-shred.
|
||||
conn.pragma_update(None, "secure_delete", "ON")?;
|
||||
conn.execute_batch(
|
||||
"
|
||||
PRAGMA foreign_keys = ON;
|
||||
|
|
@ -748,14 +751,17 @@ impl Store {
|
|||
Ok(out)
|
||||
}
|
||||
|
||||
/// Overwrite message bodies, delete rows, VACUUM. Identity + friends stay.
|
||||
/// Drop chat + payments history. Identity + friends stay.
|
||||
/// Not a forensic erase: SSD wear-leveling can keep copies.
|
||||
pub fn wipe_messages(&self) -> Result<()> {
|
||||
self.conn.execute(
|
||||
"UPDATE messages SET plaintext = zeroblob(length(plaintext))",
|
||||
[],
|
||||
)?;
|
||||
self.conn.execute("DELETE FROM messages", [])?;
|
||||
self.conn.execute("DELETE FROM payments", [])?;
|
||||
self.conn.execute_batch("VACUUM")?;
|
||||
self.conn.execute_batch("PRAGMA wal_checkpoint(TRUNCATE)")?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue