Skip to content

Commit

Permalink
Simplify verification of parsing in Cdm.set_service_certificate
Browse files Browse the repository at this point in the history
  • Loading branch information
rlaphoenix committed Dec 6, 2023
1 parent a04e751 commit 25e0352
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions pywidevine/cdm.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,13 +222,10 @@ def set_service_certificate(self, session_id: bytes, certificate: Optional[Union

try:
signed_message.ParseFromString(certificate)
if (
signed_message.SerializeToString() == certificate or
if all(
# See https://github.com/devine-dl/pywidevine/issues/41
all(
bytes(chunk) == signed_message.SerializeToString()
for chunk in zip(*[iter(certificate)] * len(signed_message.SerializeToString()))
)
bytes(chunk) == signed_message.SerializeToString()
for chunk in zip(*[iter(certificate)] * len(signed_message.SerializeToString()))
):
signed_drm_certificate.ParseFromString(signed_message.msg)
else:
Expand Down

0 comments on commit 25e0352

Please sign in to comment.