feat: improve decrypt
This commit is contained in:
@@ -22,13 +22,13 @@ pub fn write_tiny_encrypt_meta(write: &mut impl Write, meta: &TinyEncryptMeta, c
|
||||
Ok(encrypted_meta_bytes.len() + 2 + 4)
|
||||
}
|
||||
|
||||
pub fn read_tiny_encrypt_meta_and_normalize(r: &mut impl Read) -> XResult<(u32, TinyEncryptMeta)> {
|
||||
pub fn read_tiny_encrypt_meta_and_normalize(r: &mut impl Read) -> XResult<(u32, bool, TinyEncryptMeta)> {
|
||||
let mut meta_len_and_meta = read_tiny_encrypt_meta(r);
|
||||
let _ = meta_len_and_meta.as_mut().map(|ml| ml.1.normalize());
|
||||
let _ = meta_len_and_meta.as_mut().map(|ml| ml.2.normalize());
|
||||
meta_len_and_meta
|
||||
}
|
||||
|
||||
pub fn read_tiny_encrypt_meta(r: &mut impl Read) -> XResult<(u32, TinyEncryptMeta)> {
|
||||
pub fn read_tiny_encrypt_meta(r: &mut impl Read) -> XResult<(u32, bool, TinyEncryptMeta)> {
|
||||
let mut meta_tag_buff = [0_u8; 2];
|
||||
opt_result!(r.read_exact(&mut meta_tag_buff), "Read tag failed: {}");
|
||||
let meta_tag = u16::from_be_bytes(meta_tag_buff);
|
||||
@@ -57,5 +57,5 @@ pub fn read_tiny_encrypt_meta(r: &mut impl Read) -> XResult<(u32, TinyEncryptMet
|
||||
}
|
||||
debugging!("Encrypted meta: {}", String::from_utf8_lossy(&meta_buff));
|
||||
|
||||
Ok((meta_length, opt_result!(serde_json::from_slice(&meta_buff), "Parse meta failed: {}")))
|
||||
Ok((meta_length, is_meta_compressed, opt_result!(serde_json::from_slice(&meta_buff), "Parse meta failed: {}")))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user