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

Prevent loading com.apple.streamingkeydelivery key format #2606

Merged
merged 2 commits into from
Mar 26, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/loader/m3u8-parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -253,12 +253,19 @@ export default class M3U8Parser {
discontinuityCounter = parseInt(value1);
break;
case 'KEY': {
// https://tools.ietf.org/html/draft-pantos-http-live-streaming-08#section-3.4.4
// https://tools.ietf.org/html/rfc8216#section-4.3.2.4
const decryptparams = value1;
const keyAttrs = new AttrList(decryptparams);
const decryptmethod = keyAttrs.enumeratedString('METHOD');
const decrypturi = keyAttrs.URI;
const decryptiv = keyAttrs.hexadecimalInteger('IV');
// From RFC: This attribute is OPTIONAL; its absence indicates an implicit value of "identity".
const decryptkeyformat = keyAttrs.KEYFORMAT || 'identity';

if (decryptkeyformat === 'com.apple.streamingkeydelivery') {
logger.warn('Keyformat com.apple.streamingkeydelivery is not supported');
continue;
}

if (decryptmethod) {
levelkey = new LevelKey(baseurl, decrypturi);
Expand Down
29 changes: 29 additions & 0 deletions tests/unit/loader/playlist-loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,35 @@ chop/segment-5.ts
expect(result.startTimeOffset).to.equal(10.3);
});

it('parse AES encrypted URLS, with a com.apple.streamingkeydelivery KEYFORMAT', function () {
let level = `#EXTM3U
#EXT-X-VERSION:1
## Created with Unified Streaming Platform(version=1.6.7)
#EXT-X-MEDIA-SEQUENCE:1
#EXT-X-ALLOW-CACHE:NO
#EXT-X-TARGETDURATION:11
#EXT-X-KEY:METHOD=AES-128,URI="skd://assetid?keyId=1234",KEYFORMAT="com.apple.streamingkeydelivery"
#EXTINF:11,no desc
oceans_aes-audio=65000-video=236000-1.ts
#EXTINF:7,no desc
oceans_aes-audio=65000-video=236000-2.ts
#EXTINF:7,no desc
oceans_aes-audio=65000-video=236000-3.ts
#EXT-X-ENDLIST`;
let result = M3U8Parser.parseLevelPlaylist(level, 'http://foo.com/adaptive/oceans_aes/oceans_aes.m3u8', 0);
expect(result.totalduration).to.equal(25);
expect(result.startSN).to.equal(1);
expect(result.targetduration).to.equal(11);
expect(result.live).to.be.false;
expect(result.fragments).to.have.lengthOf(3);
expect(result.fragments[0].cc).to.equal(0);
expect(result.fragments[0].duration).to.equal(11);
expect(result.fragments[0].title).to.equal('no desc');
expect(result.fragments[0].level).to.equal(0);
expect(result.fragments[0].url).to.equal('http://foo.com/adaptive/oceans_aes/oceans_aes-audio=65000-video=236000-1.ts');
expect(result.fragments[0].decryptdata).to.be.null;
});

it('parse AES encrypted URLs, with implicit IV', function () {
let level = `#EXTM3U
#EXT-X-VERSION:1
Expand Down