mirror of
https://github.com/devine-dl/pywidevine.git
synced 2024-10-30 05:29:21 +00:00
Cdm: Fix size and Improve code of Android Session IDs
This commit is contained in:
parent
e9e65e5760
commit
53f7c1dd62
@ -257,12 +257,9 @@ class Cdm:
|
|||||||
def create_session_id(self, device: Device) -> bytes:
|
def create_session_id(self, device: Device) -> bytes:
|
||||||
"""Create a Session ID based on OEM Crypto API session values."""
|
"""Create a Session ID based on OEM Crypto API session values."""
|
||||||
if device.type == device.Types.ANDROID:
|
if device.type == device.Types.ANDROID:
|
||||||
session_id = "{hex:16X}{counter}".format(
|
# Note: this reversing is quite old and needs verifying in later OEM Crypto versions like 16
|
||||||
hex=random.getrandbits(64),
|
# though ultimately it shouldn't really matter
|
||||||
counter=f"{self.NUM_OF_SESSIONS:02}"
|
return get_random_bytes(8) + self.NUM_OF_SESSIONS.to_bytes(8, "little")
|
||||||
)
|
|
||||||
session_id.ljust(32, "0")
|
|
||||||
return session_id.encode("ascii")
|
|
||||||
|
|
||||||
if device.type == device.Types.CHROME:
|
if device.type == device.Types.CHROME:
|
||||||
return get_random_bytes(16)
|
return get_random_bytes(16)
|
||||||
|
Loading…
Reference in New Issue
Block a user