feat: zeroize

This commit is contained in:
2023-10-01 15:19:58 +08:00
parent 2486060e18
commit e97b5b962e
3 changed files with 11 additions and 3 deletions

View File

@@ -45,7 +45,11 @@ pub fn require_file_not_exists(path: impl AsRef<Path>) -> XResult<()> {
pub fn make_key256_and_nonce() -> (Vec<u8>, Vec<u8>) {
let key: [u8; 32] = random();
let nonce: [u8; 12] = random();
(key.into(), nonce.into())
let result = (key.into(), nonce.into());
let (mut key, mut nonce) = (key, nonce);
key.zeroize();
nonce.zeroize();
result
}
pub fn simple_kdf(input: &[u8]) -> Vec<u8> {