feat(core): zeroize in-memory secret material (Noise/Ed25519/X25519/store key)
All checks were successful
ci / test (pull_request) Successful in 4m7s

Wrap every secret this crate holds in zeroize: the local identity and
prekey secrets (Keys), the backup bundle and its derived Argon2id wrap
key, the store data key and the SQLCipher key material, the identity
secret handed out by Store::self_identity, the raw identity-secret
copies in pay/qr signing, and the wallet RPC password plus the
user:realm:password digest input.
This commit is contained in:
Sirius DevOps 2026-09-12 13:36:21 -04:00
commit f3fca69fbe
No known key found for this signature in database
12 changed files with 297 additions and 71 deletions

View file

@ -67,7 +67,7 @@ fn first_run_creates_0700_dirs_and_self_row() {
let me = store.self_identity().expect("self");
assert_eq!(me.identity_pk.len(), 32);
assert_eq!(me.identity_sk.len(), 32);
assert_ne!(me.identity_pk, me.identity_sk);
assert_ne!(me.identity_pk, me.identity_sk.to_vec());
assert_eq!(me.onion, "");
assert_eq!(store.friend_count().unwrap(), 0);
@ -152,7 +152,7 @@ fn self_has_x25519_prekey_and_set_onion() {
let me = store.self_identity().unwrap();
assert_eq!(me.prekey_pk.len(), 32);
assert_eq!(me.prekey_sk.len(), 32);
assert_ne!(me.prekey_pk, me.prekey_sk);
assert_ne!(me.prekey_pk, me.prekey_sk.to_vec());
store.set_onion("abc.onion").unwrap();
assert_eq!(store.self_identity().unwrap().onion, "abc.onion");
}
@ -277,7 +277,7 @@ fn whole_store_file_is_encrypted_at_rest() {
(b"reply-at-rest-xyz".to_vec(), "inbound chat body"),
(hex(&pk(7)).into_bytes(), "friend pubkey hex"),
(b"friend.onion".to_vec(), "friend locator"),
(me.identity_sk.clone(), "identity secret key"),
(me.identity_sk.to_vec(), "identity secret key"),
] {
assert!(
!store_contains(dir.path(), &needle),
@ -394,7 +394,7 @@ fn env_passphrase_skips_prompt() {
unsafe {
std::env::remove_var("ONIONWIRE_STORE_PASSPHRASE");
}
assert_eq!(got.unwrap(), "from-env");
assert_eq!(got.unwrap().as_str(), "from-env");
assert!(!prompted);
}
@ -428,7 +428,7 @@ fn missing_env_reads_secret_and_strips_newline() {
Ok("secret-from-tty\n".into())
})
.unwrap();
assert_eq!(got, "secret-from-tty");
assert_eq!(got.as_str(), "secret-from-tty");
}
#[test]