List <PackageEntry> ParseRaHeader(Stream s, out long dataStart) { BinaryReader reader = new BinaryReader(s); byte[] keyblock = reader.ReadBytes(80); byte[] blowfishKey = new BlowfishKeyProvider().DecryptKey(keyblock); uint[] h = ReadUints(reader, 2); Blowfish fish = new Blowfish(blowfishKey); MemoryStream ms = Decrypt(h, fish); BinaryReader reader2 = new BinaryReader(ms); ushort numFiles = reader2.ReadUInt16(); reader2.ReadUInt32(); /*datasize*/ s.Position = headerStart; reader = new BinaryReader(s); int byteCount = 6 + numFiles * PackageEntry.Size; h = ReadUints(reader, (byteCount + 3) / 4); ms = Decrypt(h, fish); dataStart = headerStart + byteCount + ((~byteCount + 1) & 7); long ds; return(ParseTdHeader(ms, out ds)); }
MemoryStream DecryptHeader(Stream s, long offset, out long headerEnd) { s.Seek(offset, SeekOrigin.Begin); // Decrypt blowfish key var keyblock = s.ReadBytes(80); var blowfishKey = new BlowfishKeyProvider().DecryptKey(keyblock); var fish = new Blowfish(blowfishKey); // Decrypt first block to work out the header length var ms = Decrypt(ReadBlocks(s, offset + 80, 1), fish); var numFiles = ms.ReadUInt16(); // Decrypt the full header - round bytes up to a full block var blockCount = (13 + numFiles * PackageEntry.Size) / 8; headerEnd = offset + 80 + blockCount * 8; return(Decrypt(ReadBlocks(s, offset + 80, blockCount), fish)); }
List<PackageEntry> ParseRaHeader(Stream s, out long dataStart) { BinaryReader reader = new BinaryReader(s); byte[] keyblock = reader.ReadBytes(80); byte[] blowfishKey = new BlowfishKeyProvider().DecryptKey(keyblock); uint[] h = ReadUints(reader, 2); Blowfish fish = new Blowfish(blowfishKey); MemoryStream ms = Decrypt( h, fish ); BinaryReader reader2 = new BinaryReader(ms); ushort numFiles = reader2.ReadUInt16(); reader2.ReadUInt32(); /*datasize*/ s.Position = headerStart; reader = new BinaryReader(s); int byteCount = 6 + numFiles * PackageEntry.Size; h = ReadUints( reader, ( byteCount + 3 ) / 4 ); ms = Decrypt( h, fish ); dataStart = headerStart + byteCount + ( ( ~byteCount + 1 ) & 7 ); long ds; return ParseTdHeader( ms, out ds ); }
MemoryStream DecryptHeader(Stream s, long offset, out long headerEnd) { s.Seek(offset, SeekOrigin.Begin); var reader = new BinaryReader(s); // Decrypt blowfish key var keyblock = reader.ReadBytes(80); var blowfishKey = new BlowfishKeyProvider().DecryptKey(keyblock); var fish = new Blowfish(blowfishKey); // Decrypt first block to work out the header length var ms = Decrypt(ReadBlocks(s, offset + 80, 1), fish); var numFiles = new BinaryReader(ms).ReadUInt16(); // Decrypt the full header - round bytes up to a full block var blockCount = (13 + numFiles*PackageEntry.Size)/8; headerEnd = offset + 80 + blockCount*8; return Decrypt(ReadBlocks(s, offset + 80, blockCount), fish); }