Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to parse ClientIdentification blob #53

Open
DevLARLEY opened this issue Jan 18, 2025 · 0 comments
Open

Unable to parse ClientIdentification blob #53

DevLARLEY opened this issue Jan 18, 2025 · 0 comments

Comments

@DevLARLEY
Copy link

DevLARLEY commented Jan 18, 2025

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant