Combined Decrypt Calls
(This is a merge of http://go/wvgerrit/93829, http://go/wvgerrit/93830, http://go/wvgerrit/93832, http://go/wvgerrit/93833, and http://go/wvgerrit/93834 from the Widevine repo.) This implements the CDM code changes necessary to take advantage of Combined Decrypt Calls on OEMCrypto v16. The result of this is that WVCryptoPlugin is much lighter now because it can pass the full sample down to the core in one call, but CryptoSession is heavier, as it now has to handle more complex fallback logic when devices can't handle multiple subsamples at once. This patch also removes support for the 'cens' and 'cbc1' schema, which are being dropped in OEMCrypto v16. This fixes an overflow in the code for handling those schemas by removing it entirely. This patch also fixes the "in chunks" legacy decrypt path to use larger chunk sizes on devices with higher resource rating tiers. Bug: 135285640 Bug: 123435824 Bug: 138584971 Bug: 139257871 Bug: 78289910 Bug: 149361893 Test: no new CE CDM Unit Test failures Test: Google Play plays Test: Netflix plays Test: no new GTS failures Change-Id: Ic4952c9fa3bc7fd5ed08698e88254380a7a18514
This commit is contained in:
46
libwvdrmengine/cdm/util/include/advance_iv_ctr.h
Normal file
46
libwvdrmengine/cdm/util/include/advance_iv_ctr.h
Normal file
@@ -0,0 +1,46 @@
|
||||
// Copyright 2019 Google LLC. All Rights Reserved. This file and proprietary
|
||||
// source code may only be used and distributed under the Widevine Master
|
||||
// License Agreement.
|
||||
|
||||
#ifndef WVCDM_UTIL_ADVANCE_IV_CTR_H_
|
||||
#define WVCDM_UTIL_ADVANCE_IV_CTR_H_
|
||||
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "string_conversions.h"
|
||||
|
||||
namespace wvcdm {
|
||||
|
||||
// Advance an IV according to ISO-CENC's CTR modes. The lower half of the IV is
|
||||
// split off and treated as an unsigned 64-bit integer, then incremented by the
|
||||
// number of complete crypto blocks decrypted. The resulting value is then
|
||||
// copied back into the IV over the previous lower half.
|
||||
inline void AdvanceIvCtr(uint8_t (*subsample_iv)[16], size_t bytes) {
|
||||
constexpr size_t kAesBlockSize = 16;
|
||||
constexpr size_t kIvSize = kAesBlockSize;
|
||||
constexpr size_t kCounterIndex = kIvSize / 2;
|
||||
constexpr size_t kCounterSize = kIvSize / 2;
|
||||
|
||||
uint64_t counter;
|
||||
|
||||
static_assert(
|
||||
sizeof(*subsample_iv) == kIvSize,
|
||||
"The subsample_iv field is no longer the length of an AES-128 IV.");
|
||||
static_assert(sizeof(counter) == kCounterSize,
|
||||
"A uint64_t failed to be half the size of an AES-128 IV.");
|
||||
|
||||
// Defensive copy because the elements of the array may not be properly
|
||||
// aligned
|
||||
memcpy(&counter, &(*subsample_iv)[kCounterIndex], kCounterSize);
|
||||
|
||||
const size_t increment =
|
||||
bytes / kAesBlockSize; // The truncation here is intentional
|
||||
counter = htonll64(ntohll64(counter) + increment);
|
||||
|
||||
memcpy(&(*subsample_iv)[kCounterIndex], &counter, kCounterSize);
|
||||
}
|
||||
|
||||
} // namespace wvcdm
|
||||
|
||||
#endif // WVCDM_UTIL_ADVANCE_IV_CTR_H_
|
||||
Reference in New Issue
Block a user