feat(core): zeroize in-memory secret material (Noise/Ed25519/X25519/store key)
All checks were successful
ci / test (pull_request) Successful in 3m50s
All checks were successful
ci / test (pull_request) Successful in 3m50s
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:
parent
e7b37ccb40
commit
fc7378596d
12 changed files with 297 additions and 71 deletions
10
src/pay.rs
10
src/pay.rs
|
|
@ -1,5 +1,6 @@
|
|||
use ed25519_dalek::{Signature, Signer, SigningKey, Verifier, VerifyingKey};
|
||||
use sha3::{Digest, Keccak256};
|
||||
use zeroize::Zeroizing;
|
||||
|
||||
pub type Result<T> = std::result::Result<T, Error>;
|
||||
|
||||
|
|
@ -386,9 +387,12 @@ fn tagged(tag: &[u8], fields: &[&[u8]]) -> Vec<u8> {
|
|||
}
|
||||
|
||||
fn sign_bytes(identity_sk: &[u8], msg: &[u8]) -> Result<Vec<u8>> {
|
||||
let sk_bytes: [u8; 32] = identity_sk
|
||||
.try_into()
|
||||
.map_err(|_| Error("identity secret key must be 32 bytes".into()))?;
|
||||
// ed25519-dalek's `SigningKey` wipes itself on drop (its default `zeroize`
|
||||
// feature); the raw copy we make to build it is ours to wipe.
|
||||
let sk_bytes = Zeroizing::new(
|
||||
<[u8; 32]>::try_from(identity_sk)
|
||||
.map_err(|_| Error("identity secret key must be 32 bytes".into()))?,
|
||||
);
|
||||
let sk = SigningKey::from_bytes(&sk_bytes);
|
||||
Ok(sk.sign(msg).to_bytes().to_vec())
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue