feat: update zeroize

This commit is contained in:
2023-10-22 22:46:25 +08:00
parent 0f02edc6f6
commit 0fa22f7f39

View File

@@ -61,7 +61,7 @@ pub struct CmdDecrypt {
impl Drop for CmdDecrypt { impl Drop for CmdDecrypt {
fn drop(&mut self) { fn drop(&mut self) {
self.pin.map(|mut p| p.zeroize()); if let Some(p) = self.pin.as_mut() { p.zeroize(); }
} }
} }
@@ -249,9 +249,10 @@ fn parse_encrypted_comment(meta: &TinyEncryptMeta, crypto: Cryptor, key: &[u8],
} }
fn parse_encrypted_meta(meta: &TinyEncryptMeta, cryptor: Cryptor, key: &[u8], nonce: &[u8]) -> XResult<Option<EncEncryptedMeta>> { fn parse_encrypted_meta(meta: &TinyEncryptMeta, cryptor: Cryptor, key: &[u8], nonce: &[u8]) -> XResult<Option<EncEncryptedMeta>> {
Ok(match &meta.encrypted_meta { let enc_encrypted_meta = match &meta.encrypted_meta {
None => None, None => return Ok(None),
Some(enc_encrypted_meta) => { Some(enc_encrypted_meta) => enc_encrypted_meta,
};
let enc_encrypted_meta_bytes = opt_result!( let enc_encrypted_meta_bytes = opt_result!(
util::decode_base64(enc_encrypted_meta), "Decode enc-encrypted-meta failed: {}"); util::decode_base64(enc_encrypted_meta), "Decode enc-encrypted-meta failed: {}");
let enc_meta = opt_result!( let enc_meta = opt_result!(
@@ -267,9 +268,7 @@ fn parse_encrypted_meta(meta: &TinyEncryptMeta, cryptor: Cryptor, key: &[u8], no
if let Some(m_time) = &enc_meta.c_time { if let Some(m_time) = &enc_meta.c_time {
information!("Source file modified time: {}", fmt.format_local(SystemTime::from_millis(*m_time))); information!("Source file modified time: {}", fmt.format_local(SystemTime::from_millis(*m_time)));
} }
Some(enc_meta) Ok(Some(enc_meta))
}
})
} }
fn try_decrypt_key(config: &Option<TinyEncryptConfig>, fn try_decrypt_key(config: &Option<TinyEncryptConfig>,