mirror of
https://github.com/unshackle-dl/unshackle.git
synced 2026-11-24 09:55:12 +00:00
fix(tracks): ignore leftover PIFF uuid when verifying decryption
A decrypter detaches only the atom it consumed, so content shipping both boxes keeps the uuid through a good decrypt and failed on mp4decrypt.
This commit is contained in:
@@ -115,17 +115,18 @@ def _senc_protects_samples(buf: bytes, body: int, end: int) -> bool:
|
||||
|
||||
|
||||
def _moof_still_encrypted(moof: bytes) -> bool:
|
||||
# senc only: a decrypter detaches just the atom it consumed, so a PIFF uuid can
|
||||
# outlive a good decrypt. ISM arrives as senc via piff_senc_to_cenc.
|
||||
# structural walk: a 4CC byte scan collides with trun payload
|
||||
from unshackle.core.manifests.ism_init import PIFF_SENC_UUID, iter_boxes
|
||||
from unshackle.core.manifests.ism_init import iter_boxes
|
||||
|
||||
body = 16 if int.from_bytes(moof[:4], "big") == 1 else 8
|
||||
for box_type, _, traf_body, traf_end in iter_boxes(moof, body, len(moof)):
|
||||
if box_type != b"traf":
|
||||
continue
|
||||
for child, usertype, child_body, child_end in iter_boxes(moof, traf_body, traf_end):
|
||||
if child == b"senc" or (child == b"uuid" and usertype == PIFF_SENC_UUID):
|
||||
if _senc_protects_samples(moof, child_body, child_end):
|
||||
return True
|
||||
for child, _usertype, child_body, child_end in iter_boxes(moof, traf_body, traf_end):
|
||||
if child == b"senc" and _senc_protects_samples(moof, child_body, child_end):
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
@@ -138,6 +139,10 @@ def assert_fragments_decrypted(path: Path) -> None:
|
||||
stderr) while leaving the payload as ciphertext. Unlike has_encrypted_sample_entry
|
||||
(moov-scoped) this is fragment-scoped; the moov comes out clean in that failure.
|
||||
|
||||
Only a standard senc counts as evidence. Some DASH content ships a PIFF uuid beside it,
|
||||
and a decrypter detaches just the atom it consumed, so that uuid outlives a good
|
||||
decrypt; counting it would condemn a healthy file.
|
||||
|
||||
The guarantee runs in one direction: a survivor proves a skip, while a clean pass is
|
||||
only as good as the decrypter's own behaviour. shaka-packager (the default
|
||||
`decryption` backend) remuxes into a single fragment and drops senc whether or not it
|
||||
|
||||
Reference in New Issue
Block a user