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
Describe the bug
Re-serialization of protobuf data at:
pywidevine/pywidevine/device.py
Lines 110 to 115 in 49315ec
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:
To Reproduce
Initialize a Device class with the attached client_id blob:
Expected behavior
No error
device_client_id_blob.zip