Exemplo n.º 1
0
        public byte[] DecryptData(ZipReader.ZipEntry entry, byte[] block, int start, int count)
        {
            if (block == null || block.Length < count || count < 12)
            {
                throw new ArgumentException("Invalid arguments for decryption");
            }

            CRC32 crcgen = new CRC32();

            UInt32[] Keys = InitCipher(tpfkey, crcgen);

            // Decrypt crypt header
            DecryptBlock(block, start, 12, Keys, crcgen); // 12 = crypt header size

            // KFreon: Testing header
            //Console.WriteLine($"crypt header crc: {block[start + 10]}, {block[start + 11]}");

            // KFreon: Doesn't seem to require this

            /*if (block[11] != (byte)((entry.CRC >> 24) & 0xff) && (entry.BitFlag & 0x8) != 0x8)
             *  Console.WriteLine("Incorrect password");*/

            DecryptBlock(block, start + 12, count - 12, Keys, crcgen);  // Decrypt main block after crypt header
            return(block);
        }
Exemplo n.º 2
0
        public static void DecryptData(ZipReader.ZipEntry entry, byte[] block, int start, int count)
        {
            if (block == null || block.Length < count || count < 12)
            {
                throw new ArgumentException("Invalid arguments for decryption");
            }

            crcgen = new CRC32();
            InitCipher(tpfkey);

            DecryptBlock(block, start, 12);

            // KFreon: Apparently not required. Causes some TPF's to fail loading, but when commented out, TPF loads fine, so...

            /*if (block[11] != (byte)((entry.CRC >> 24) & 0xff) && (entry.BitFlag & 0x8) != 0x8)
             *  throw new FormatException("Incorrect password");*/

            DecryptBlock(block, start + 12, count - 12);
        }
Exemplo n.º 3
0
        public static void DecryptData(ZipReader.ZipEntry entry, byte[] block, int start, int count)
        {
            if (block == null || block.Length < count || count < 12)
            {
                throw new ArgumentException("Invalid arguments for decryption");
            }

            crcgen = new CRC32();
            InitCipher(tpfkey);

            DecryptBlock(block, start, 12);

            if (block[11] != (byte)((entry.CRC >> 24) & 0xff) && (entry.BitFlag & 0x8) != 0x8)
            {
                throw new FormatException("Incorrect password");
            }

            DecryptBlock(block, start + 12, count - 12);
        }
Exemplo n.º 4
0
 public KFreonZipCrypto(ZipReader.ZipEntry entry, byte[] block, int start, int count)
 {
     Blocks = DecryptData(entry, block, start, count);
 }