Ejemplo n.º 1
0
        private void InitializeWithPresetKeys(byte[] vkey, byte[] header_key, byte[] body_key, int cipher_type)
        {
            VersionKey = vkey;
            HeaderKey  = header_key;
            BodyKey    = body_key;
            CipherType = cipher_type;

            _headerBaseStream = new MemoryStream();
            _bodyBaseStream   = new MemoryStream();

            _headerStream = new BBCipherStream(_headerBaseStream, HeaderKey, VersionKey, 0, cipher_type);
            _bodyStream   = new BBCipherStream(_bodyBaseStream, BodyKey, VersionKey, 0, cipher_type);
        }
Ejemplo n.º 2
0
        private void Initialize()
        {
            using (var br = new BinaryReader(_baseStream, Encoding.ASCII, true))
            {
                br.BaseStream.Position = 3;
                var version = br.ReadByte();
                _pgd_flag = version == 0x40 ? 1 : version == 0x44 ? 2 : throw new InvalidDataException($"Invalid PGD version: 0x{version:X2}");

                //Set key index
                br.BaseStream.Position = 4;
                var key_index = br.ReadInt32();

                //Set types and definitions
                br.BaseStream.Position = 8;
                var drm_type = br.ReadInt32();

                int mac_type = 0;
                if (drm_type == 1)
                {
                    mac_type   = 1;
                    _pgd_flag |= 4;
                    if (key_index > 1)
                    {
                        mac_type   = 3;
                        _pgd_flag |= 8;
                    }
                    CipherType = 1;
                }
                else
                {
                    mac_type   = 2;
                    CipherType = 2;
                }

                GetVersionKey(mac_type);

                GetHeaderKey();
                _headerStream = new BBCipherStream(_baseStream, 0x30, 0x30, HeaderKey, VersionKey, 0, CipherType);

                GetBodyKey();
                _bodyStream = new BBCipherStream(_baseStream, 0x90, _baseStream.Length - 0x90, BodyKey, VersionKey, 0, CipherType);
            }
        }