Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
SDK
/
exoplayer
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
38efb1fc
authored
Apr 10, 2015
by
Oliver Woodman
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Clean up Aes128DataSource.
parent
6bf52dd6
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
14 additions
and
9 deletions
library/src/main/java/com/google/android/exoplayer/hls/HlsChunkSource.java
library/src/main/java/com/google/android/exoplayer/upstream/Aes128DataSource.java
library/src/main/java/com/google/android/exoplayer/upstream/UnexpectedLengthException.java
library/src/main/java/com/google/android/exoplayer/hls/HlsChunkSource.java
View file @
38efb1fc
...
...
@@ -474,7 +474,7 @@ public class HlsChunkSource {
System
.
arraycopy
(
ivData
,
offset
,
ivDataWithPadding
,
ivDataWithPadding
.
length
-
ivData
.
length
+
offset
,
ivData
.
length
-
offset
);
encryptedDataSource
=
new
Aes128DataSource
(
secretKey
,
ivDataWithPadding
,
upstreamDataSource
);
encryptedDataSource
=
new
Aes128DataSource
(
upstreamDataSource
,
secretKey
,
ivDataWithPadding
);
encryptionKeyUri
=
keyUri
;
encryptedDataSourceIv
=
iv
;
encryptedDataSourceSecretKey
=
secretKey
;
...
...
library/src/main/java/com/google/android/exoplayer/upstream/Aes128DataSource.java
View file @
38efb1fc
...
...
@@ -34,20 +34,24 @@ import javax.crypto.spec.SecretKeySpec;
/**
* A {@link DataSource} that decrypts the data read from an upstream source, encrypted with AES-128
* with a 128-bit key and PKCS7 padding.
*
*/
public
class
Aes128DataSource
implements
DataSource
{
private
final
DataSource
upstream
;
private
final
byte
[]
secret
Key
;
private
final
byte
[]
i
v
;
private
final
byte
[]
encryption
Key
;
private
final
byte
[]
encryptionI
v
;
private
CipherInputStream
cipherInputStream
;
public
Aes128DataSource
(
byte
[]
secretKey
,
byte
[]
iv
,
DataSource
upstream
)
{
/**
* @param upstream The upstream {@link DataSource}.
* @param encryptionKey The encryption key.
* @param encryptionIv The encryption initialization vector.
*/
public
Aes128DataSource
(
DataSource
upstream
,
byte
[]
encryptionKey
,
byte
[]
encryptionIv
)
{
this
.
upstream
=
upstream
;
this
.
secretKey
=
secret
Key
;
this
.
iv
=
i
v
;
this
.
encryptionKey
=
encryption
Key
;
this
.
encryptionIv
=
encryptionI
v
;
}
@Override
...
...
@@ -61,8 +65,8 @@ public class Aes128DataSource implements DataSource {
throw
new
RuntimeException
(
e
);
}
Key
cipherKey
=
new
SecretKeySpec
(
secret
Key
,
"AES"
);
AlgorithmParameterSpec
cipherIV
=
new
IvParameterSpec
(
i
v
);
Key
cipherKey
=
new
SecretKeySpec
(
encryption
Key
,
"AES"
);
AlgorithmParameterSpec
cipherIV
=
new
IvParameterSpec
(
encryptionI
v
);
try
{
cipher
.
init
(
Cipher
.
DECRYPT_MODE
,
cipherKey
,
cipherIV
);
...
...
library/src/main/java/com/google/android/exoplayer/upstream/UnexpectedLengthException.java
View file @
38efb1fc
...
...
@@ -20,6 +20,7 @@ import java.io.IOException;
/**
* Thrown when the length of some data does not match an expected length.
*/
@Deprecated
public
final
class
UnexpectedLengthException
extends
IOException
{
/**
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment