Ejemplo n.º 1
0
            public static DecrypterV106 Create(IBinaryReader reader)
            {
                try {
                    int keyXorOffs7 = (ReadByteAt(reader, 0) ^ ReadByteAt(reader, 2)) + 2;
                    reader.Position = keyXorOffs7 + (ReadByteAt(reader, 1) ^ ReadByteAt(reader, keyXorOffs7));

                    int  sha1DataLen   = reader.Read7BitEncodedInt32() + 0x80;
                    int  keyXorOffs6   = (int)reader.Position;
                    int  encryptedOffs = (int)reader.Position + sha1DataLen;
                    var  sha1Data      = reader.ReadBytes(sha1DataLen);
                    uint crc32         = CRC32.CheckSum(sha1Data);

                    reader.Position = reader.Length - 0x18;
                    uint origCrc32 = reader.ReadUInt32();
                    if (crc32 != origCrc32)
                    {
                        return(null);
                    }

                    var key0 = DeobUtils.Sha1Sum(sha1Data);                             // 1.0.6.0
                    var key6 = GetKey(reader, key0, keyXorOffs6);                       // 1.0.6.6
                    var key7 = GetKey(reader, key0, keyXorOffs7);                       // 1.0.6.7
                    return(new DecrypterV106(key0, key6, key7, encryptedOffs));
                }
                catch (IOException) {
                    return(null);
                }
            }