mirror of
https://github.com/unshackle-dl/unshackle.git
synced 2026-11-27 19:35:06 +00:00
feat(drm): add the whole-file aes-ctr cipher and paged aac rewrite
This commit is contained in:
@@ -1235,9 +1235,10 @@ A slow answer arrives as a [slow response](#slow-responses).
|
||||
| `track_id` / `track_ids` | Single track, or a batch of tracks. |
|
||||
| `challenge` | Base64 CDM challenge (proxy mode). |
|
||||
| `pssh` | Base64 PSSH (server-CDM mode). |
|
||||
| `drm_type` | `widevine` (default) or `playready`. In server-CDM mode the server's `cdm` mapping for the service decides the DRM system and the response `drm_type` names the system that licensed. The client's value decides only when the server has no mapping for the service. |
|
||||
| `drm_type` | `widevine` (default) or `playready`. In server-CDM mode the server's `cdm` mapping for the service decides the DRM system and the response `drm_type` names the system that licensed. The client's value decides only when the server has no mapping for the service. A track whose DRM is a whole-file cipher takes `clearkeyctr` with no `pssh`: the service on the server licenses it. |
|
||||
| `mode` | `proxy` (default) or `server_cdm`. |
|
||||
| `clear_tracks` (response) | Requested track ids that carry no DRM, so they have no keys. Absent when every requested track is encrypted. |
|
||||
| `file_keys` (response) | Content keys of whole-file ciphers, by track id, for a single track and for a batch. Absent when no requested track holds such a cipher. |
|
||||
| `vault_keys` (response) | KIDs whose content key came from a server vault, not the CDM. The client proves such a content key with a decode before it trusts it; the field is absent when every content key came from the CDM. |
|
||||
|
||||
| Status | Error code | Meaning |
|
||||
|
||||
@@ -390,7 +390,7 @@ A typical `get_tracks` therefore looks like fetching the manifest text with
|
||||
## DRM hooks
|
||||
|
||||
If a track carries DRM, the framework licenses and decrypts it, but it needs your
|
||||
service to talk to the platform's license server. unshackle recognizes six DRM systems:
|
||||
service to talk to the platform's license server. unshackle recognizes seven DRM systems:
|
||||
|
||||
| DRM class | System | License flow |
|
||||
|---|---|---|
|
||||
@@ -400,6 +400,7 @@ service to talk to the platform's license server. unshackle recognizes six DRM s
|
||||
| `ClearKey` | HLS AES-128 | content key fetched directly from a URI; no CDM, no challenge |
|
||||
| `MonaLisa` | Proprietary WASM DRM | keys extracted locally; no license server |
|
||||
| `BlowfishStripe` | Blowfish CBC stripe cipher | the service gives the per-track key; no CDM, no license server |
|
||||
| `ClearKeyCTR` | AES-128-CTR over a whole file | the service gives the IV and licenses the content key at the licence step; no CDM, no license server |
|
||||
|
||||
!!! warning "`ClearKey` vs `ClearKeyCENC`"
|
||||
Despite the shared prefix these are entirely different systems. `ClearKey` is HLS
|
||||
|
||||
@@ -268,7 +268,7 @@ download. For example, `dovi_tool` only matters if you download Dolby Vision vid
|
||||
| Tool | Binary looked up | Why it is needed |
|
||||
| --- | --- | --- |
|
||||
| Bento4 (`mp4decrypt`) | `mp4decrypt` | Alternative DRM decryptor to shaka-packager |
|
||||
| MP4Box (GPAC) | `MP4Box` | Muxing DTS:X Profile 2 (DTS-UHD) and MPEG-H audio, and 3D video; remuxing AC-4, MPEG-H and DTS-UHD music |
|
||||
| MP4Box (GPAC) | `MP4Box` | Muxing DTS:X Profile 2 (DTS-UHD) and MPEG-H audio, and 3D video; remuxing AC-4, MPEG-H and DTS-UHD music; trimming the coder delay of AAC files in a paged container |
|
||||
| dovi_tool | `dovi_tool` | Dolby Vision metadata handling |
|
||||
| HDR10Plus_tool | `hdr10plus_tool` | HDR10+ metadata handling |
|
||||
| SubtitleEdit | `seconv`, `SubtitleEdit` | Subtitle conversion (the `SeConv` CLI from 5.x) |
|
||||
@@ -280,10 +280,13 @@ download. For example, `dovi_tool` only matters if you download Dolby Vision vid
|
||||
| Docker | `docker` | Gluetun VPN proxy support |
|
||||
| Git | `git` | Fetching and updating remote service repositories |
|
||||
|
||||
!!! info "MP4Box is only used for DTS:X Profile 2, MPEG-H, AC-4 music and 3D video"
|
||||
!!! info "MP4Box is only used for DTS:X Profile 2, MPEG-H, AC-4 music, 3D video and paged AAC"
|
||||
Titles with DTS:X Profile 2 (DTS-UHD) or MPEG-H audio, or a stereoscopic 3D video track, mux to
|
||||
MP4; everything else muxes to MKV with `mkvmerge`. Install with `apt install gpac`.
|
||||
|
||||
AAC files that come in a paged container need MP4Box only to lose the coder delay of the encoder
|
||||
and to declare HE-AACv2, see [DRM and CDM](../guide/drm-and-cdm.md). Without MP4Box they keep the delay.
|
||||
|
||||
!!! tip "SubtitleEdit specifics"
|
||||
unshackle looks for `seconv` first, the batch CLI shipped with
|
||||
SubtitleEdit 5.x, before falling back to a `SubtitleEdit` (4.x) binary. The
|
||||
|
||||
@@ -41,7 +41,7 @@ then decrypts the file with those keys.
|
||||
|
||||
## Supported DRM systems
|
||||
|
||||
unshackle implements six DRM systems. Only the first two need a device file and a
|
||||
unshackle implements seven DRM systems. Only the first two need a device file and a
|
||||
license-server handshake. The rest are special cases.
|
||||
|
||||
| System | Device file | License flow | Decryption |
|
||||
@@ -52,13 +52,15 @@ license-server handshake. The rest are special cases.
|
||||
| **ClearKey (HLS)**, AES-128 `EXT-X-KEY` | none | Key fetched directly from a URI or `data:` URL. No CDM, no challenge. | in-process AES-CBC |
|
||||
| **MonaLisa** (proprietary, WASM) | `.mld` | Ticket from the service API; keys extracted locally via WASM. No license server. | ML-Worker binary + AES-ECB, per segment |
|
||||
| **Blowfish stripe** | none | The service gives the per-track key. No CDM, no license server. | in-process Blowfish-CBC on every third 2048-byte chunk |
|
||||
| **ClearKey (CTR)**, AES-128-CTR | none | The service gives the per-track key and IV. No CDM, no license server. | in-process AES-CTR over the whole file |
|
||||
|
||||
!!! warning "Two different ClearKeys"
|
||||
"ClearKey (HLS)" and "ClearKey (CENC)" are entirely different systems that happen
|
||||
to share a name. The HLS variant is the AES-128 content key that an `EXT-X-KEY`
|
||||
!!! warning "Three different ClearKeys"
|
||||
"ClearKey (HLS)", "ClearKey (CENC)" and "ClearKey (CTR)" are entirely different systems that
|
||||
happen to share a name. The HLS variant is the AES-128 content key that an `EXT-X-KEY`
|
||||
tag references, and unshackle decrypts it in-process. The CENC variant is the W3C
|
||||
EME `org.w3.clearkey` scheme. It delivers keys as a JWK Set, and shaka-packager or
|
||||
mp4decrypt decrypts it like Widevine. Neither involves a device file.
|
||||
mp4decrypt decrypts it like Widevine. The CTR variant is one AES-CTR stream over a
|
||||
whole file, with the content key and the IV that the service gives. None of them involves a device file.
|
||||
|
||||
### Widevine vs PlayReady
|
||||
|
||||
@@ -472,6 +474,27 @@ license hook returns) and reads the JSON Web Key set back. You do not need a dev
|
||||
file. The decrypted file still goes through shaka-packager or mp4decrypt like any
|
||||
other CENC track, so the `decryption` setting applies.
|
||||
|
||||
### ClearKey over a whole file (AES-CTR)
|
||||
|
||||
Some services encrypt one whole audio file with AES-128-CTR and give the content key and
|
||||
the IV with the track. unshackle decrypts the file in-process after the download. There is
|
||||
no device, no CDM and no license challenge. The licence step of a download or of a `--skip-dl` run licenses
|
||||
the content key, so `--list` asks for none. The IV, the length of the header in front of the media and the
|
||||
signature the file must start with travel with the track list.
|
||||
|
||||
Over `--remote` the track list carries no content key. After the track selection the client asks the server
|
||||
for the content key of each chosen track, and then it decrypts the file itself. The server licenses only for an
|
||||
API key with the `server_cdm` grant for the service. Without it, or in a remote session on the server's device, the
|
||||
track stops with one error before its download. A decrypted file with another
|
||||
signature raises an error and stays encrypted. A decrypted file in a paged AAC container (`SpAC`) becomes an
|
||||
`.m4a` file that declares HE-AACv2 and whose edit list removes the coder delay, so the file has the length of the
|
||||
track. This needs [MP4Box](../getting-started/installation.md#recommended-and-optional-tools) on the machine that
|
||||
decrypts, the client over `--remote`. Without it the file becomes one ADTS stream, which the mux step packs into
|
||||
an `.m4a` file that keeps the coder delay.
|
||||
|
||||
The client must know this cipher as well as the server: a client without it drops the DRM entry without a
|
||||
log and saves the encrypted file.
|
||||
|
||||
## Widevine and PlayReady on the same title
|
||||
|
||||
A single manifest can advertise both Widevine and PlayReady. unshackle picks the CDM
|
||||
|
||||
Reference in New Issue
Block a user