Don't add offsets to ion handles

Fixes a secure buffer addressing offset error in the Widevine
CENC drm engine.

bug: 8667527

Merges the following from Widevine CDM repository:

Allow specification of offset into secure buffer
https://widevine-internal-review.googlesource.com/#/c/5100/

Update WVCryptoPlugin to Pass Output Offset as a Separate Parameter
https://widevine-internal-review.googlesource.com/#/c/5120/

Add offset to secure data buffer in OEMCrypto DecryptCTR
https://widevine-internal-review.googlesource.com/#/c/5110/

Change-Id: Ic3e4b35304c8fbae4aebe4c495285eb787e8c205
This commit is contained in:
Jeff Tinker
2013-04-19 16:40:38 -07:00
parent 87c3f5652f
commit d29372909d
15 changed files with 62 additions and 40 deletions

View File

@@ -91,6 +91,7 @@ class CdmEngine : public TimerHandler {
const std::vector<uint8_t>& iv,
size_t block_offset,
void* decrypt_buffer,
size_t decrypt_buffer_offset,
bool is_video);
// Is the key known to any session?

View File

@@ -58,6 +58,7 @@ class CdmSession {
const std::vector<uint8_t>& iv,
size_t block_offset,
void* decrypt_buffer,
size_t decrypt_buffer_offset,
bool is_video);
// License renewal

View File

@@ -71,6 +71,7 @@ class CryptoSession {
const std::vector<uint8_t>& iv,
size_t block_offset,
void* decrypt_buffer,
size_t decrypt_buffer_offset,
bool is_video);
private:

View File

@@ -676,6 +676,7 @@ CdmResponseType CdmEngine::Decrypt(
const std::vector<uint8_t>& iv,
size_t block_offset,
void* decrypt_buffer,
size_t decrypt_buffer_offset,
bool is_video) {
CdmSessionIter iter = sessions_.find(session_id);
if (iter == sessions_.end()) {
@@ -685,7 +686,8 @@ CdmResponseType CdmEngine::Decrypt(
return iter->second->Decrypt(is_encrypted, key_id, encrypt_buffer,
encrypt_length, iv, block_offset,
decrypt_buffer, is_video);
decrypt_buffer, decrypt_buffer_offset,
is_video);
}
bool CdmEngine::IsKeyValid(const KeyId& key_id) {

View File

@@ -151,6 +151,7 @@ CdmResponseType CdmSession::Decrypt(bool is_encrypted,
const std::vector<uint8_t>& iv,
size_t block_offset,
void* decrypt_buffer,
size_t decrypt_buffer_offset,
bool is_video) {
if (!crypto_session_ || !crypto_session_->IsOpen())
return UNKNOWN_ERROR;
@@ -168,7 +169,8 @@ CdmResponseType CdmSession::Decrypt(bool is_encrypted,
}
return crypto_session_->Decrypt(is_encrypted, encrypt_buffer, encrypt_length,
iv, block_offset, decrypt_buffer, is_video);
iv, block_offset, decrypt_buffer,
decrypt_buffer_offset, is_video);
}
// License renewal

View File

@@ -392,6 +392,7 @@ CdmResponseType CryptoSession::Decrypt(bool is_encrypted,
const std::vector<uint8_t>& iv,
size_t block_offset,
void* decrypt_buffer,
size_t decrypt_buffer_offset,
bool is_video) {
if (!is_destination_buffer_type_valid_) {
if (!SetDestinationBufferType())
@@ -404,11 +405,12 @@ CdmResponseType CryptoSession::Decrypt(bool is_encrypted,
switch (buffer_descriptor.type) {
case OEMCrypto_BufferType_Clear:
buffer_descriptor.buffer.clear.address =
static_cast<uint8_t*>(decrypt_buffer);
static_cast<uint8_t*>(decrypt_buffer) + decrypt_buffer_offset;
buffer_descriptor.buffer.clear.max_length = encrypt_length;
break;
case OEMCrypto_BufferType_Secure:
buffer_descriptor.buffer.secure.handle = decrypt_buffer;
buffer_descriptor.buffer.secure.offset = decrypt_buffer_offset;
buffer_descriptor.buffer.secure.max_length = encrypt_length;
break;
case OEMCrypto_BufferType_Direct:

View File

@@ -68,7 +68,8 @@ class WvContentDecryptionModule {
size_t encrypt_length,
const std::vector<uint8_t>& iv,
size_t block_offset,
void* decrypt_buffer);
void* decrypt_buffer,
size_t decrypt_buffer_offset);
// Event listener related methods
virtual bool AttachEventListener(const CdmSessionId& session_id,

View File

@@ -102,10 +102,12 @@ CdmResponseType WvContentDecryptionModule::Decrypt(
size_t encrypt_length,
const std::vector<uint8_t>& iv,
size_t block_offset,
void* decrypt_buffer) {
void* decrypt_buffer,
size_t decrypt_buffer_offset) {
return cdm_engine_->Decrypt(session_id, is_encrypted, key_id,
encrypt_buffer, encrypt_length, iv,
block_offset, decrypt_buffer, true);
block_offset, decrypt_buffer,
decrypt_buffer_offset, true);
}
bool WvContentDecryptionModule::AttachEventListener(

View File

@@ -289,7 +289,8 @@ TEST_F(WvCdmRequestLicenseTest, ClearDecryptionTest) {
encrypt_length,
data.iv,
data.block_offset,
&decrypt_buffer.front()));
&decrypt_buffer.front(),
0));
EXPECT_TRUE(std::equal(data.decrypt_data.begin(), data.decrypt_data.end(),
decrypt_buffer.begin()));
@@ -335,7 +336,8 @@ TEST_F(WvCdmRequestLicenseTest, ClearDecryptionNoKeyTest) {
encrypt_length,
data.iv,
data.block_offset,
&decrypt_buffer.front()));
&decrypt_buffer.front(),
0));
EXPECT_TRUE(std::equal(data.decrypt_data.begin(), data.decrypt_data.end(),
decrypt_buffer.begin()));
@@ -383,7 +385,8 @@ TEST_F(WvCdmRequestLicenseTest, DecryptionTest) {
encrypt_length,
data.iv,
data.block_offset,
&decrypt_buffer.front()));
&decrypt_buffer.front(),
0));
EXPECT_TRUE(std::equal(data.decrypt_data.begin(), data.decrypt_data.end(),
decrypt_buffer.begin()));
@@ -458,7 +461,8 @@ TEST_F(WvCdmRequestLicenseTest, SwitchKeyDecryptionTest) {
encrypt_length,
data[i].iv,
data[i].block_offset,
&decrypt_buffer.front()));
&decrypt_buffer.front(),
0));
EXPECT_TRUE(std::equal(data[i].decrypt_data.begin(),
data[i].decrypt_data.end(),
@@ -500,7 +504,8 @@ TEST_F(WvCdmRequestLicenseTest, PartialBlockDecryptionTest) {
encrypt_length,
data.iv,
data.block_offset,
&decrypt_buffer.front()));
&decrypt_buffer.front(),
0));
EXPECT_TRUE(std::equal(data.decrypt_data.begin(), data.decrypt_data.end(),
decrypt_buffer.begin()));
@@ -540,7 +545,8 @@ TEST_F(WvCdmRequestLicenseTest, PartialBlockWithOffsetDecryptionTest) {
encrypt_length,
data.iv,
data.block_offset,
&decrypt_buffer.front()));
&decrypt_buffer.front(),
0));
EXPECT_TRUE(std::equal(data.decrypt_data.begin(), data.decrypt_data.end(),
decrypt_buffer.begin()));