Skip to content

Unable to parse ClientIdentification blob #53

Description

@DevLARLEY

Describe the bug
Re-serialization of protobuf data at:

try:
self.client_id.ParseFromString(client_id)
if self.client_id.SerializeToString() != client_id:
raise DecodeError("partial parse")
except DecodeError as e:
raise DecodeError(f"Failed to parse client_id as a ClientIdentification, {e}")

will fail with the attached client id when initializing a Device class

The protobuf library re-orders some of the last bytes in the binary data, which doesn't affect the data integrity itself, but causes the loading to fail:

last 11 bytes:

loaded:
00 48 00 20 05 50 01 58 00 60 03

dumped:
00 48 00 50 01 58 00 20 05 60 03

To Reproduce
Initialize a Device class with the attached client_id blob:

from Crypto.PublicKey import RSA
from pywidevine import Device, DeviceTypes

with open("device_client_id_blob", "rb") as f:
    device = Device(
        type_=DeviceTypes.ANDROID,
        security_level=3,
        flags=None,
        private_key=RSA.generate(2048).export_key(),
        client_id=f.read()
    )

Expected behavior
No error

device_client_id_blob.zip

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions