pywidevine icon indicating copy to clipboard operation
pywidevine copied to clipboard

Unable to parse ClientIdentification blob

Open DevLARLEY opened this issue 1 year ago • 0 comments

Describe the bug Re-serialization of protobuf data at: https://github.com/devine-dl/pywidevine/blob/49315eceb8fd82cceb495e199d8a2846d561a79f/pywidevine/device.py#L110-L115 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

DevLARLEY avatar Jan 18 '25 11:01 DevLARLEY