Squashed commit of the following CDM changes:

* Add additional parameters to CDM decryption API
  https://widevine-internal-review.googlesource.com/#/c/6500/

* Pass Length and Flags Parameters to Decrypt()
  https://widevine-internal-review.googlesource.com/#/c/6740/

* Remove core files from oemcrypto/mock
  https://widevine-internal-review.googlesource.com/#/c/6853/

Change-Id: I1c73f5454da20da99130b161543fb990e16e7130
This commit is contained in:
Jeff Tinker
2013-07-29 17:41:22 -07:00
parent 0190f99fb3
commit f4560f109f
24 changed files with 543 additions and 789 deletions

View File

@@ -529,39 +529,41 @@ bool CryptoSession::GenerateSignature(const std::string& message, bool use_rsa,
return true;
}
CdmResponseType CryptoSession::Decrypt(
bool is_encrypted, bool is_secure, const uint8_t* encrypt_buffer,
size_t encrypt_length, const std::vector<uint8_t>& iv, size_t block_offset,
void* decrypt_buffer, size_t decrypt_buffer_offset, bool is_video) {
CdmResponseType CryptoSession::Decrypt(const CdmDecryptionParameters& params) {
if (!is_destination_buffer_type_valid_) {
if (!SetDestinationBufferType()) return UNKNOWN_ERROR;
}
OEMCrypto_DestBufferDesc buffer_descriptor;
buffer_descriptor.type =
is_secure ? destination_buffer_type_ : OEMCrypto_BufferType_Clear;
params.is_secure ? destination_buffer_type_ : OEMCrypto_BufferType_Clear;
switch (buffer_descriptor.type) {
case OEMCrypto_BufferType_Clear:
buffer_descriptor.buffer.clear.address =
static_cast<uint8_t*>(decrypt_buffer) + decrypt_buffer_offset;
buffer_descriptor.buffer.clear.max_length = encrypt_length;
static_cast<uint8_t*>(params.decrypt_buffer) + params.decrypt_buffer_offset;
buffer_descriptor.buffer.clear.max_length = params.decrypt_buffer_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;
buffer_descriptor.buffer.secure.handle = params.decrypt_buffer;
buffer_descriptor.buffer.secure.offset = params.decrypt_buffer_offset;
buffer_descriptor.buffer.secure.max_length = params.decrypt_buffer_length;
break;
case OEMCrypto_BufferType_Direct:
buffer_descriptor.type = OEMCrypto_BufferType_Direct;
buffer_descriptor.buffer.direct.is_video = is_video;
buffer_descriptor.buffer.direct.is_video = params.is_video;
break;
}
OEMCryptoResult sts = OEMCrypto_DecryptCTR(
oec_session_id_, encrypt_buffer, encrypt_length, is_encrypted, &iv[0],
block_offset, &buffer_descriptor,
OEMCrypto_FirstSubsample | OEMCrypto_LastSubsample);
oec_session_id_,
params.encrypt_buffer,
params.encrypt_length,
params.is_encrypted,
&(*params.iv).front(),
params.block_offset,
&buffer_descriptor,
params.subsample_flags);
if (OEMCrypto_SUCCESS != sts) {
return UNKNOWN_ERROR;