Break Decrypt Buffers Into 100KiB Blocks As Needed
(This is a merge of go/wvgerrit/22949) Starting with OEMCrypto v12, we are guaranteeing to integration partners that the buffers passed to OEMCrypto_DecryptCENC and OEMCrypto_CopyBuffer will not be more than 100KiB (102400 bytes) in size. For requests larger than this, we will first try to send the buffer to OEMCrypto anyway. (in case the integration supports buffers larger than the minimum) In the event that the buffer is rejected, we will break it up into 100KiB chunks and send them down individually for decryption. Breaking a subsample into smaller subsamples necessitates knowledge of how to update other decryption parameters (like the offsets and the IV) that previously the CDM Core has not needed to know about. Until now, this knowledge lived in the glue layer on the Android CDM and nowhere on the CE CDM. Now, the CryptoSession has a subset of this knowledge, in order to break up buffers successfully. For testing purposes, the Mock OEMCrypto has been modified to only support the smallest buffer size. In order to make sure the chunking code was being exercised by them, the CE CDM tests had to have the amount of data they decrypt increased by several orders of magnitude. To contain this growth, I have moved the test data to its own file. Bug: 31381719 Test: Ran the updated CE CDM integration tests Test: Modified the OEMCrypto dynamic adapter to pretend both L3 and L1 only support 100KiB buffers on a Marlin and a Ryu. Confirmed that the GTS H.264 tests (which have subsamples over 100KiB) passed still. A similar test was attempted on Fugu but Fugu cannot pass these tests even without this change present. Change-Id: Iabe7db3d87554cd1352f10a7524cd55352818397
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "lock.h"
|
||||
#include "oemcrypto_adapter.h"
|
||||
@@ -143,6 +144,18 @@ class CryptoSession {
|
||||
CdmEncryptionAlgorithm algorithm);
|
||||
size_t GenericEncryptionBlockSize(CdmEncryptionAlgorithm algorithm);
|
||||
|
||||
// These methods are used when a subsample exceeds the maximum buffer size
|
||||
// that the device can handle.
|
||||
OEMCryptoResult CopyBufferInChunks(
|
||||
const CdmDecryptionParameters& params,
|
||||
OEMCrypto_DestBufferDesc buffer_descriptor);
|
||||
OEMCryptoResult DecryptInChunks(
|
||||
const CdmDecryptionParameters& params,
|
||||
const OEMCrypto_DestBufferDesc& full_buffer_descriptor,
|
||||
const OEMCrypto_CENCEncryptPatternDesc& pattern_descriptor,
|
||||
size_t max_chunk_size);
|
||||
static void IncrementIV(uint64_t increase_by, std::vector<uint8_t>* iv_out);
|
||||
|
||||
static const size_t kAes128BlockSize = 16; // Block size for AES_CBC_128
|
||||
static const size_t kSignatureSize = 32; // size for HMAC-SHA256 signature
|
||||
static Lock crypto_lock_;
|
||||
|
||||
Reference in New Issue
Block a user