feat: update zeroize
This commit is contained in:
@@ -61,7 +61,7 @@ pub struct CmdDecrypt {
|
||||
|
||||
impl Drop for CmdDecrypt {
|
||||
fn drop(&mut self) {
|
||||
self.pin.map(|mut p| p.zeroize());
|
||||
if let Some(p) = self.pin.as_mut() { p.zeroize(); }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -249,27 +249,26 @@ 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>> {
|
||||
Ok(match &meta.encrypted_meta {
|
||||
None => None,
|
||||
Some(enc_encrypted_meta) => {
|
||||
let enc_encrypted_meta_bytes = opt_result!(
|
||||
let enc_encrypted_meta = match &meta.encrypted_meta {
|
||||
None => return Ok(None),
|
||||
Some(enc_encrypted_meta) => enc_encrypted_meta,
|
||||
};
|
||||
let enc_encrypted_meta_bytes = opt_result!(
|
||||
util::decode_base64(enc_encrypted_meta), "Decode enc-encrypted-meta failed: {}");
|
||||
let enc_meta = opt_result!(
|
||||
let enc_meta = opt_result!(
|
||||
EncEncryptedMeta::unseal(cryptor, key, nonce, &enc_encrypted_meta_bytes), "Unseal enc-encrypted-meta failed: {}");
|
||||
debugging!("Encrypted meta: {:?}", enc_meta);
|
||||
if let Some(filename) = &enc_meta.filename {
|
||||
information!("Source filename: {}", filename);
|
||||
}
|
||||
let fmt = simpledateformat::fmt(DATE_TIME_FORMAT).unwrap();
|
||||
if let Some(c_time) = &enc_meta.c_time {
|
||||
information!("Source file create time: {}", fmt.format_local(SystemTime::from_millis(*c_time)));
|
||||
}
|
||||
if let Some(m_time) = &enc_meta.c_time {
|
||||
information!("Source file modified time: {}", fmt.format_local(SystemTime::from_millis(*m_time)));
|
||||
}
|
||||
Some(enc_meta)
|
||||
}
|
||||
})
|
||||
debugging!("Encrypted meta: {:?}", enc_meta);
|
||||
if let Some(filename) = &enc_meta.filename {
|
||||
information!("Source filename: {}", filename);
|
||||
}
|
||||
let fmt = simpledateformat::fmt(DATE_TIME_FORMAT).unwrap();
|
||||
if let Some(c_time) = &enc_meta.c_time {
|
||||
information!("Source file create time: {}", fmt.format_local(SystemTime::from_millis(*c_time)));
|
||||
}
|
||||
if let Some(m_time) = &enc_meta.c_time {
|
||||
information!("Source file modified time: {}", fmt.format_local(SystemTime::from_millis(*m_time)));
|
||||
}
|
||||
Ok(Some(enc_meta))
|
||||
}
|
||||
|
||||
fn try_decrypt_key(config: &Option<TinyEncryptConfig>,
|
||||
|
||||
Reference in New Issue
Block a user