From eb7492a152543876997c98e49177d66f7b8784e0 Mon Sep 17 00:00:00 2001 From: Vincent Valot Date: Wed, 25 Mar 2020 11:14:52 +0100 Subject: [PATCH 1/2] Prevent loading com.apple.streamingkeydelivery key format --- src/loader/m3u8-parser.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/loader/m3u8-parser.ts b/src/loader/m3u8-parser.ts index 09cd0010a68..1d427be21d3 100644 --- a/src/loader/m3u8-parser.ts +++ b/src/loader/m3u8-parser.ts @@ -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); From 82eb3923fa4b3e98e5a094e7a0a67769ae8cb00b Mon Sep 17 00:00:00 2001 From: Vincent Valot Date: Wed, 25 Mar 2020 11:27:32 +0100 Subject: [PATCH 2/2] add a unit test --- tests/unit/loader/playlist-loader.js | 29 ++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/tests/unit/loader/playlist-loader.js b/tests/unit/loader/playlist-loader.js index 9f59c201a2d..c7dad2e2343 100644 --- a/tests/unit/loader/playlist-loader.js +++ b/tests/unit/loader/playlist-loader.js @@ -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