However, it was failing on larger files. Why?
It turns out that PowerPacker's "encryptor", if told to encrypt more than 262144 bytes of data, will actually encrypt roughly <x mod 262144> bytes of data instead!
So, if your PowerPacked file is 262148 bytes long, only 4 bytes of that will be encrypted, the rest will be unencrypted! Isn't that wonderful?
Why does this happen? Let's look at the ppEncrypt function:
Code: Select all
; A0=buffer to encrypt, D0=length to encrypt, D1=encrypt key
ppEncrypt:
addq.l #3,d0
lsr.l #2,d0
subq.l #1,d0
1$ eor.l d1,(a0)+
dbra d0,1$
rts
You might think this makes the encryption easier... it actually makes it more difficult. PowerPacked data starts at the end of the file, and must start with a 1 bit. If that section is encrypted, I can guess one of the bits of the key straight away, halving the time required to find the key. If it's not encrypted (due to this bug), I have to guess all the bits. Bah!