public byte[] ReadInfoBlock(BinReader reader, Blowfish blowfish) { byte[] infoBufferDecompressed = new byte[InfoSizeUncompressed]; byte[] result = new byte[InfoSizeCompressed]; reader.Position = InfoOffset; reader.Read(result, 0, InfoSizeCompressed); if (IsInfoCompressed) { Decompress(result, infoBufferDecompressed, 0, (int)InfoSizeUncompressed, FileVersion < 9); // TODO: Check when exactly zlib header was removed result = infoBufferDecompressed; } if (IsInfoEncrypted && blowfish != null) { blowfish.Decipher(result, (InfoSizeUncompressed / 8) * 8); } return(result); }
public TellTaleBlowfishZlibStream(Stream stream, TellTaleFileStructureInfo fileInfo, byte[] key = null, bool useModifiedBlowfish = false) { reader = new BinReader(stream); this.fileInfo = fileInfo; virtualPosition = 0; readBuffer = new byte[fileInfo.BlockSizeUncompressed]; if (key != null) { // Blowfish is stateless decryption per block (8 bytes), so we can // create a single decrypter based on key/version specifics here: blowfish = new Blowfish(key, useModifiedBlowfish); } // ttarch1: Preload the info block if (fileInfo.HasInfo) { infoBuffer = fileInfo.ReadInfoBlock(reader, blowfish); } }