Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support AES-128 on HLS #850

Closed
avelad opened this issue Jun 6, 2017 · 32 comments · Fixed by #4386 or #4273
Closed

Support AES-128 on HLS #850

avelad opened this issue Jun 6, 2017 · 32 comments · Fixed by #4386 or #4273
Assignees
Labels
component: HLS The issue involves Apple's HLS manifest format priority: P3 Useful but not urgent status: archived Archived and locked; will not be updated type: enhancement New feature or request
Milestone

Comments

@avelad
Copy link
Member

avelad commented Jun 6, 2017

This it's a request feature for support AES-128 on HLS. Is it possible support it?

Sample stream:
https://playertest.longtailvideo.com/adaptive/oceans_aes/oceans_aes.m3u8

Now, I get: HLS_REQUIRED_ATTRIBUTE_MISSING (KEYFORMAT)

@ismena
Copy link
Contributor

ismena commented Jun 6, 2017

@avelad I am under impression that AES-128 on HLS implies FairPlay. (Please correct me if I'm mistaken).
If that's the case, we have an issue about adding FairPlay support: #382. (You can take a look at the comments there to find out how it's going and what kind of complications we ran into with this).

If that's not related to FairPlay, let me know, we'll treat this separately!

@avelad
Copy link
Member Author

avelad commented Jun 6, 2017

It's a very simple mechanism. Each segement is encrypted with a key, for get this key only it's necessary get the response of license request of URI.

In the initial sample:

#EXT-X-KEY:METHOD=AES-128,URI="oceans.key"
#EXTINF:11, no desc
oceans_aes-audio=65000-video=236000-1.ts

The response of "oceans.key" is "õq¿ìý�¹­°\æú��ý�"
With this key, you can descrypt the segments.

A interesting article about that:
https://www.theoplayer.com/blog/content-protection-for-hls-with-aes-128-encryption

Sample:
https://tools.ietf.org/html/draft-pantos-http-live-streaming-13#section-8.4

@ismena
Copy link
Contributor

ismena commented Jun 6, 2017

Ok, let us take a look and see if we can make it work!

I'm adding this to the backlog since it requires investigation which makes me hesitant about scheduling it for 2.2. @joeyparrish please feel free to override me on this!

@ismena ismena added this to the Backlog milestone Jun 6, 2017
@ismena ismena added the component: HLS The issue involves Apple's HLS manifest format label Jun 6, 2017
@TheModMaker
Copy link
Contributor

This looks like it could be implemented using clearkey. But there is a problem. AFAIK, all clearkey implementations use AES CTR for decryption, while HLS encryption uses AES CBC. Even if the browser supported CBC, there is no way in EME to pass the encryption scheme or the IV. If you are using Widevine encryption, this info is passed in the init data, but clearkey init data doesn't support these extra fields.

See #358 for a similar situation using DASH.

@joeyparrish
Copy link
Member

If the keys are in the clear anyway, we could look into WebCrypto APIs: http://caniuse.com/#feat=cryptography

@joeyparrish joeyparrish added the type: enhancement New feature or request label Jun 7, 2017
@joeyparrish joeyparrish modified the milestones: v2.3.0, Backlog Jun 7, 2017
@joeyparrish joeyparrish modified the milestones: v2.3.0, Backlog Jul 14, 2017
@DiegoZurita
Copy link

Is there any workaround to use AES-128 HLS encrypted?

@avelad
Copy link
Member Author

avelad commented Oct 23, 2018

I found that videojs uses https://github.com/videojs/aes-decrypter

s it possible to use it like mux.js?

@TheModMaker
Copy link
Contributor

@avelad We probably wouldn't need that since we can just use the WebCrypto APIs to decrypt the content. What we could do is just query that URL and get the key, then use that with WebCrypto to decrypt the data before passing to MediaSource. I think AES-128 encrypts everything, so we might not even have to parse the container data.

@elv-peter
Copy link

I ran into this problem as well. You can easily generate a test with Bento4:

mp4hls --encryption-key 37d7ad30b2a8e801864b023e330c4b02 -o test --output-encryption-key --exec-dir=/usr/local/Cellar/bento4/1.5.1-628/bin trailer_1080p.mov

Safari, VLC, and videojs are all able to play it. Shaka gives me HLS_COULD_NOT_PARSE_SEGMENT_START_TIME (code 4030). If you decide not to add this feature, perhaps at least check for EXT-X-KEY in the manifest and output a more informative error message like "AES not supported"?

@joeyparrish
Copy link
Member

Parsing of segment start times is something we do now, but we could probably avoid in many cases. That is something we're planning for a future release, likely v2.6 or v2.7.

Aside from that, though, you're right. We could probably detect and reject AES-128 content with a meaningful error code instead of failing to parse it.

@kevinscroggins-youi
Copy link

@joeyparrish @TheModMaker Any updates on when this feature might be implemented? Thank you!

@joeyparrish
Copy link
Member

No, it's not scheduled yet. But we are always willing to accept contributions from the community, so please feel free to discuss design and/or work on a PR if this is important to you. Thanks!

@joeyparrish joeyparrish added the flag: seeking PR We are actively seeking PRs for this; we do not currently expect the core team will resolve this label Mar 15, 2019
@anuragkalia
Copy link

I ran into this issue and so will need to add support for it, I think. Will keep it posted here if I run into some problem.

@kakyleung
Copy link

What's the conclusion about this? Does Shaka packager support AES-128 method ?

@willkk
Copy link

willkk commented Sep 30, 2019

What's the conclusion about this? Does Shaka packager support AES-128 method ?

Obviously, No!

@wjywbs
Copy link
Contributor

wjywbs commented Jan 19, 2022

@avelad Sure, I created PR #3880
@hiren3897 Yes, I used <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/mux.min.js"></script>

wjywbs added a commit to wjywbs/shaka-player that referenced this issue Feb 8, 2022
wjywbs added a commit to wjywbs/shaka-player that referenced this issue Feb 19, 2022
wjywbs added a commit to wjywbs/shaka-player that referenced this issue Mar 31, 2022
wjywbs added a commit to wjywbs/shaka-player that referenced this issue May 4, 2022
@hiren3897
Copy link

Hello @wjywbs @theodab
Can we have the estimated time for the work of this feature?

Thanks

@joeyparrish
Copy link
Member

There's no estimate available right now, because nobody on the Shaka team is working on this right now.

It will become a higher priority for us later this year, as we need this feature in Shaka to fully deprecate another player. In the meantime, community contributions are very welcome! I just exchanged messages with someone on Slack who wants to take over and improve the existing PR.

devsunb pushed a commit to inflearn/shaka-player that referenced this issue Jul 12, 2022
devsunb pushed a commit to inflearn/shaka-player that referenced this issue Jul 12, 2022
theodab added a commit to theodab/shaka-player that referenced this issue Jul 29, 2022
Also adds support for key rotation in HLS, but only for AES-128.

Based on shaka-project#3880
Issue shaka-project#850
theodab added a commit to theodab/shaka-player that referenced this issue Jul 29, 2022
Also adds support for key rotation in HLS, but only for AES-128.

Based on shaka-project#3880
Issue shaka-project#850
theodab added a commit to theodab/shaka-player that referenced this issue Jul 29, 2022
Also adds support for key rotation in HLS, but only for AES-128.

Based on shaka-project#3880
Issue shaka-project#850
theodab added a commit to theodab/shaka-player that referenced this issue Aug 3, 2022
Also adds support for key rotation in HLS, but only for AES-128.

Based on shaka-project#3880
Issue shaka-project#850
theodab added a commit to theodab/shaka-player that referenced this issue Aug 3, 2022
Also adds support for key rotation in HLS, but only for AES-128.

Based on shaka-project#3880
Issue shaka-project#850
theodab added a commit to theodab/shaka-player that referenced this issue Aug 3, 2022
Also adds support for key rotation in HLS, but only for AES-128.

Based on shaka-project#3880
Issue shaka-project#850
papico-inflab pushed a commit to inflearn/shaka-player that referenced this issue Aug 10, 2022
joeyparrish pushed a commit that referenced this issue Aug 12, 2022
Expands on the original PR (#3880) by adding support for MP4 and key rotation.

Close #850

Co-authored-by: wjywbs <[email protected]>
@avelad avelad modified the milestones: Backlog, v4.2 Aug 12, 2022
joeyparrish pushed a commit to joeyparrish/shaka-player that referenced this issue Aug 13, 2022
Expands on the original PR (shaka-project#3880) by adding support for MP4 and key rotation.

Close shaka-project#850

Co-authored-by: wjywbs <[email protected]>
@github-actions github-actions bot added the status: archived Archived and locked; will not be updated label Oct 11, 2022
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 11, 2022
echoy-harmonicinc pushed a commit to harmonicinc-com/shaka-player that referenced this issue Dec 6, 2022
Expands on the original PR (shaka-project#3880) by adding support for MP4 and key rotation.

Close shaka-project#850

Co-authored-by: wjywbs <[email protected]>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
component: HLS The issue involves Apple's HLS manifest format priority: P3 Useful but not urgent status: archived Archived and locked; will not be updated type: enhancement New feature or request
Projects
None yet