mirror of
https://github.com/lifegpc/msg-tool.git
synced 2026-06-06 12:58:45 +08:00
Add AppliqueCrypt (untested)
This commit is contained in:
@@ -166,6 +166,7 @@ enum CryptType {
|
||||
AlteredPinkCrypt,
|
||||
NatsupochiCrypt,
|
||||
PoringSoftCrypt,
|
||||
AppliqueCrypt,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Deserialize)]
|
||||
@@ -259,6 +260,7 @@ impl Schema {
|
||||
CryptType::AlteredPinkCrypt => Box::new(AlteredPinkCrypt::new(self.base.clone())),
|
||||
CryptType::NatsupochiCrypt => Box::new(NatsupochiCrypt::new(self.base.clone())),
|
||||
CryptType::PoringSoftCrypt => Box::new(PoringSoftCrypt::new(self.base.clone())),
|
||||
CryptType::AppliqueCrypt => Box::new(AppliqueCrypt::new(self.base.clone())),
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -926,6 +928,21 @@ impl<R: Read> Read for PoringSoftCryptReader<R> {
|
||||
}
|
||||
}
|
||||
|
||||
seek_crypt_filehash_key_impl!(AppliqueCrypt, AppliqueCryptReader<T>);
|
||||
|
||||
impl<R: Read> Read for AppliqueCryptReader<R> {
|
||||
fn read(&mut self, buf: &mut [u8]) -> std::io::Result<usize> {
|
||||
let readed = self.inner.read(buf)?;
|
||||
let key = (self.key >> 12) as u8;
|
||||
let skip = (5 - (self.seg_start + self.pos).min(5) as usize).min(readed);
|
||||
for t in (&mut buf[skip..readed]).iter_mut() {
|
||||
*t ^= key;
|
||||
}
|
||||
self.pos += readed as u64;
|
||||
Ok(readed)
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_deserialize_crypt() {
|
||||
for (key, schema) in CRYPT_SCHEMA.iter() {
|
||||
|
||||
@@ -425,7 +425,9 @@ impl Read for Entry {
|
||||
let seg_pos = self.entries_pos[seg_index];
|
||||
let skip_pos = self.pos - seg_pos;
|
||||
let read_size = seg.archived_size;
|
||||
if !self.skip_decrypt && (self.index.is_encrypted() || self.force_decrypt) {
|
||||
if !self.skip_decrypt
|
||||
&& (self.index.is_encrypted() || (self.force_decrypt && self.crypt.decrypt_supported()))
|
||||
{
|
||||
if seg.is_compressed || !self.crypt.decrypt_seek_supported() {
|
||||
let mut cache: Box<dyn Read> = if seg.is_compressed {
|
||||
let mut inner =
|
||||
|
||||
Reference in New Issue
Block a user