Minor refactoring of TSC decryption [ci skip]

This commit is contained in:
biroder 2023-04-10 16:23:46 +03:00 committed by GitHub
parent 0ccbbefbed
commit 72a2ada0b2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 2 deletions

View File

@ -1,6 +1,6 @@
pub fn decrypt_tsc(buf: &mut [u8]) {
let half = buf.len() / 2;
let key = if let Some(0) = buf.get(half) { 0xf9 } else { (-(*buf.get(half).unwrap() as isize)) as u8 };
let key = if let Some(0) = buf.get(half) { 0x7 } else { *buf.get(half).unwrap() };
log::info!("Decrypting TSC using key {:#x}", key);
for (idx, byte) in buf.iter_mut().enumerate() {
@ -8,6 +8,6 @@ pub fn decrypt_tsc(buf: &mut [u8]) {
continue;
}
*byte = byte.wrapping_add(key);
*byte = byte.wrapping_sub(key);
}
}