Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
brainfood
/
videojs-contrib-hls
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Graphs
Network
Create a new issue
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
fe69162d
authored
2015-02-23 14:19:25 +0100
by
Rajko Stojadinovic
Committed by
David LaPalomento
2015-04-02 17:02:40 -0400
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
Properly parse the IV in m3u8 AES-128 encryption method, and actually use it to decrypt if present
1 parent
906d9cba
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
4 deletions
src/m3u8/m3u8-parser.js
src/videojs-hls.js
src/m3u8/m3u8-parser.js
View file @
fe69162
...
...
@@ -305,6 +305,9 @@
event
.
attributes
=
parseAttributes
(
match
[
1
]);
// parse the IV string into a Uint32Array
if
(
event
.
attributes
.
IV
)
{
if
(
event
.
attributes
.
IV
.
substring
(
0
,
2
)
==
'0x'
)
event
.
attributes
.
IV
=
event
.
attributes
.
IV
.
substring
(
2
);
event
.
attributes
.
IV
=
event
.
attributes
.
IV
.
match
(
/.
{8}
/g
);
event
.
attributes
.
IV
[
0
]
=
parseInt
(
event
.
attributes
.
IV
[
0
],
16
);
event
.
attributes
.
IV
[
1
]
=
parseInt
(
event
.
attributes
.
IV
[
1
],
16
);
...
...
@@ -436,7 +439,8 @@
// setup an encryption key for upcoming segments
key
=
{
method
:
entry
.
attributes
.
METHOD
||
'AES-128'
,
uri
:
entry
.
attributes
.
URI
uri
:
entry
.
attributes
.
URI
,
iv
:
entry
.
attributes
.
IV
||
null
};
},
'media-sequence'
:
function
()
{
...
...
src/videojs-hls.js
View file @
fe69162
...
...
@@ -704,11 +704,13 @@ videojs.Hls.prototype.drainBuffer = function(event) {
}
else
{
// if the media sequence is greater than 2^32, the IV will be incorrect
// assuming 10s segments, that would be about 1300 years
var
theIv
=
segment
.
key
.
iv
;
if
(
theIv
===
null
)
{
theIv
=
new
Uint32Array
([
0
,
0
,
0
,
mediaIndex
+
playlist
.
mediaSequence
]);
}
bytes
=
videojs
.
Hls
.
decrypt
(
bytes
,
segment
.
key
.
bytes
,
new
Uint32Array
([
0
,
0
,
0
,
mediaIndex
+
playlist
.
mediaSequence
]));
theIv
);
}
}
...
...
Please
register
or
sign in
to post a comment