Exemplo n.º 1
0
        public static TMD Create(Stream stream)
        {
            u16 numcontents;

            TMD tmd = new TMD(Signature.Create(stream));

            EndianReader reader = new EndianReader(stream, Endianness.BigEndian);

            tmd.Version          = reader.ReadByte();
            tmd.CaCrlVersion     = reader.ReadByte();
            tmd.SignerCrlVersion = reader.ReadByte();
            tmd.Padding          = reader.ReadByte();
            tmd.SystemVersion    = reader.ReadUInt64();
            tmd.TitleID          = reader.ReadUInt64();
            tmd.TitleType        = reader.ReadUInt32();
            tmd.GroupID          = reader.ReadUInt16();
            reader.ReadBytes(tmd.Padding2);
            tmd.AccessRights = reader.ReadUInt32();
            tmd.TitleVersion = reader.ReadUInt16();
            numcontents      = reader.ReadUInt16();
            tmd.BootIndex    = reader.ReadUInt16();
            tmd.Padding3     = reader.ReadUInt16();

            for (int i = 0; i < numcontents; i++)
            {
                tmd.Contents.Add(TmdContent.Create(stream));
            }

            return(tmd);
        }
Exemplo n.º 2
0
        public Stream CreateDecryptionStream(TmdContent content, Stream data)
        {
            byte[] iv = new byte[0x10];
            BigEndianConverter.GetBytes(content.Index).CopyTo(iv, 0);
            Stream stream = new Substream(new AesStream(data, Key, iv), 0, content.Size);

            return(stream);
        }
Exemplo n.º 3
0
        public static TmdContent Create(Stream stream)
        {
            EndianReader reader = new EndianReader(stream, Endianness.BigEndian);

            TmdContent content = new TmdContent();

            content.ContentID = reader.ReadUInt32();
            content.Index     = reader.ReadUInt16();
            content.Type      = reader.ReadUInt16();
            content.Size      = reader.ReadInt64();
            reader.ReadBytes(content.Hash);

            return(content);
        }
Exemplo n.º 4
0
        public DlcBin(Stream stream)
        {
            Key             = new u8[Util.AesKeySize];
            Bk              = BackupHeader.Create(stream);
            stream.Position = Util.RoundUp(stream.Position, 0x40);
            TMD             = TMD.Create(stream);
            stream.Position = Util.RoundUp(stream.Position, 0x40);

            u16 index = u16.MaxValue;

            for (int i = 0; i < Bk.ContentIndex.Length; i++)
            {
                if (Bk.ContentIndex[i] != 0)
                {
                    index = (u16)(i * 8);
                    for (int k = 1; k < 8; k++)
                    {
                        if ((Bk.ContentIndex[i] & (1 << k)) != 0)
                        {
                            index += (u16)k;
                        }
                    }
                }
            }

            if (index != ushort.MaxValue)
            {
                Content = TMD.Contents[index];
            }

            RawData = new Substream(stream, stream.Position, Content != null ? Util.RoundUp(Content.Size, 0x40) : (stream.Length - stream.Position));

            if (Content != null)
            {
                byte[] iv = new byte[0x10];
                BigEndianConverter.GetBytes(Content.Index).CopyTo(iv, 0);
                Data = new Substream(new AesStream(RawData, Key, iv), 0, Content.Size);
            }
        }