diff --git a/.gitattributes b/.gitattributes index dd46d0f..71d16ea 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1 +1,2 @@ +msg_tool_xp3data/bin/*.bin binary msg_tool_xp3data/cx_cb/*.bin binary diff --git a/msg_tool_xp3data/bin/altered_pink.bin b/msg_tool_xp3data/bin/altered_pink.bin new file mode 100644 index 0000000..dab50f7 Binary files /dev/null and b/msg_tool_xp3data/bin/altered_pink.bin differ diff --git a/msg_tool_xp3data/crypt.json b/msg_tool_xp3data/crypt.json index 4b368c6..f5fd47e 100644 --- a/msg_tool_xp3data/crypt.json +++ b/msg_tool_xp3data/crypt.json @@ -109,6 +109,10 @@ "ControlBlockName": "akuratsu.bin", "Title": "あくらつ~恥辱の百合姉妹~" }, + "Altered Pink": { + "$type": "AlteredPinkCrypt", + "Title": "アルタードピンク~特務戦隊デュエルレンジャー~" + }, "Ama Koi Syrups": { "$type": "HashCrypt", "Title": "あま恋シロップス ~恥じらう恋心でシたくなる甘神様の恋祭り~ | 甘神大人的糖浆恋祭" diff --git a/msg_tool_xp3data/lib.rs b/msg_tool_xp3data/lib.rs index a6a289c..1fd312f 100644 --- a/msg_tool_xp3data/lib.rs +++ b/msg_tool_xp3data/lib.rs @@ -12,3 +12,6 @@ pub fn get_crypt_data() -> String { decoder.read_to_string(&mut out).unwrap(); out } + +/// AlteredPink KeyTable +pub const ALTERED_PINK_KEY_TABLE: &[u8] = include_bytes!("bin/altered_pink.bin"); diff --git a/src/scripts/kirikiri/archive/xp3/crypt/mod.rs b/src/scripts/kirikiri/archive/xp3/crypt/mod.rs index 0a2769f..a15b18b 100644 --- a/src/scripts/kirikiri/archive/xp3/crypt/mod.rs +++ b/src/scripts/kirikiri/archive/xp3/crypt/mod.rs @@ -163,6 +163,7 @@ enum CryptType { DieselmineCrypt, DameganeCrypt, NephriteCrypt, + AlteredPinkCrypt, } #[derive(Clone, Debug, Deserialize)] @@ -253,6 +254,7 @@ impl Schema { CryptType::DieselmineCrypt => Box::new(DieselmineCrypt::new(self.base.clone())), CryptType::DameganeCrypt => Box::new(DameganeCrypt::new(self.base.clone())), CryptType::NephriteCrypt => Box::new(NephriteCrypt::new(self.base.clone())), + CryptType::AlteredPinkCrypt => Box::new(AlteredPinkCrypt::new(self.base.clone())), }) } } @@ -878,6 +880,20 @@ impl Read for NephriteCryptReader { } } +seek_crypt_filehash_key_u8_impl!(AlteredPinkCrypt, AlteredPinkCryptReader); + +impl Read for AlteredPinkCryptReader { + fn read(&mut self, buf: &mut [u8]) -> std::io::Result { + let readed = self.inner.read(buf)?; + for (i, t) in (&mut buf[..readed]).iter_mut().enumerate() { + let offset = self.seg_start + self.pos + i as u64; + *t ^= ALTERED_PINK_KEY_TABLE[(offset & 0xFF) as usize]; + } + self.pos += readed as u64; + Ok(readed) + } +} + #[test] fn test_deserialize_crypt() { for (key, schema) in CRYPT_SCHEMA.iter() { @@ -891,3 +907,8 @@ fn test_cx_cb_table() { println!("Key: {}, List length: {}", key, list.len()); } } + +#[test] +fn test_altered_pink_key_table() { + assert_eq!(ALTERED_PINK_KEY_TABLE.len(), 0x100); +}