(This is a merge of modmaker@'s change from the Widevine repo, http://go/wvgerrit/48880) When using pattern encryption, WVCryptoPlugin needs to increment the IV after each subsample. It should increment it based on the number of actually encrypted samples (i.e. ignore clear data caused by subsamples or pattern encryption). In the common encryption spec, section 9.6.1 states: If the last Block pattern in a Subsample is incomplete, the partial pattern SHALL be followed until truncated by the BytesOfProtectedData size and any partial crypt_byte_block SHALL remain unencrypted. This fixes the counting of encrypted blocks to account for partial patterns. This also makes it more efficient by removing the loop. Bug: 111001481 Test: build_and_run_all_unit_tests Test: Widevine GTS Tests Change-Id: Ibd2bf10f64461b9bce10ef07453096fe4a4f6376
85 lines
2.3 KiB
C++
85 lines
2.3 KiB
C++
//
|
|
// Copyright 2018 Google LLC. All Rights Reserved. This file and proprietary
|
|
// source code may only be used and distributed under the Widevine Master
|
|
// License Agreement.
|
|
//
|
|
|
|
#ifndef WV_CRYPTO_PLUGIN_H_
|
|
#define WV_CRYPTO_PLUGIN_H_
|
|
|
|
#include <android/hidl/memory/1.0/IMemory.h>
|
|
|
|
#include "HidlTypes.h"
|
|
#include "wv_content_decryption_module.h"
|
|
#include "WVTypes.h"
|
|
|
|
namespace wvdrm {
|
|
namespace hardware {
|
|
namespace drm {
|
|
namespace V1_2 {
|
|
namespace widevine {
|
|
|
|
using ::android::hidl::memory::V1_0::IMemory;
|
|
|
|
struct WVCryptoPlugin : public ICryptoPlugin {
|
|
WVCryptoPlugin(const void* data, size_t size,
|
|
const sp<wvcdm::WvContentDecryptionModule>& cdm);
|
|
virtual ~WVCryptoPlugin() {}
|
|
|
|
Return<bool> requiresSecureDecoderComponent(const hidl_string& mime)
|
|
override;
|
|
|
|
Return<void> notifyResolution(uint32_t width, uint32_t height) override;
|
|
|
|
Return<Status> setMediaDrmSession(const hidl_vec<uint8_t>& sessionId)
|
|
override;
|
|
|
|
Return<void> setSharedBufferBase(const hidl_memory& base,
|
|
uint32_t bufferId) override;
|
|
|
|
Return<void> decrypt(
|
|
bool secure,
|
|
const hidl_array<uint8_t, 16>& keyId,
|
|
const hidl_array<uint8_t, 16>& iv,
|
|
Mode mode,
|
|
const Pattern& pattern,
|
|
const hidl_vec<SubSample>& subSamples,
|
|
const SharedBuffer& source,
|
|
uint64_t offset,
|
|
const DestinationBuffer& destination,
|
|
decrypt_cb _hidl_cb) override;
|
|
|
|
Return<void> decrypt_1_2(
|
|
bool secure,
|
|
const hidl_array<uint8_t, 16>& keyId,
|
|
const hidl_array<uint8_t, 16>& iv,
|
|
Mode mode,
|
|
const Pattern& pattern,
|
|
const hidl_vec<SubSample>& subSamples,
|
|
const SharedBuffer& source,
|
|
uint64_t offset,
|
|
const DestinationBuffer& destination,
|
|
decrypt_1_2_cb _hidl_cb) override;
|
|
|
|
private:
|
|
WVDRM_DISALLOW_COPY_AND_ASSIGN_AND_NEW(WVCryptoPlugin);
|
|
|
|
wvcdm::CdmSessionId mSessionId;
|
|
std::map<uint32_t, sp<IMemory> > mSharedBufferMap;
|
|
|
|
sp<wvcdm::WvContentDecryptionModule> const mCDM;
|
|
|
|
Status_V1_2 attemptDecrypt(
|
|
const wvcdm::CdmDecryptionParameters& params,
|
|
bool haveEncryptedSubsamples, std::string* errorDetailMsg);
|
|
static void incrementIV(uint64_t increaseBy, std::vector<uint8_t>* ivPtr);
|
|
};
|
|
|
|
} // namespace widevine
|
|
} // namespace V1_2
|
|
} // namespace drm
|
|
} // namespace hardware
|
|
} // namespace wvdrm
|
|
|
|
#endif // WV_CRYPTO_PLUGIN_H_
|