(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
59 lines
1.8 KiB
C++
59 lines
1.8 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 <stdint.h>
|
|
|
|
#include "utils/StrongPointer.h"
|
|
#include "utils/Vector.h"
|
|
|
|
#include "media/hardware/CryptoAPI.h"
|
|
#include "media/stagefright/foundation/ABase.h"
|
|
#include "media/stagefright/foundation/AString.h"
|
|
#include "wv_content_decryption_module.h"
|
|
|
|
namespace wvdrm {
|
|
|
|
class WVCryptoPlugin : public android::CryptoPlugin {
|
|
public:
|
|
WVCryptoPlugin(const void* data, size_t size,
|
|
const android::sp<wvcdm::WvContentDecryptionModule>& cdm);
|
|
virtual ~WVCryptoPlugin() {}
|
|
|
|
virtual bool requiresSecureDecoderComponent(const char* mime) const;
|
|
|
|
virtual void notifyResolution(uint32_t width, uint32_t height);
|
|
|
|
virtual android::status_t setMediaDrmSession(
|
|
const android::Vector<uint8_t>& sessionId);
|
|
|
|
virtual ssize_t decrypt(bool secure, const uint8_t key[16],
|
|
const uint8_t iv[16], Mode mode, const Pattern &pattern,
|
|
const void* srcPtr,
|
|
const SubSample* subSamples, size_t numSubSamples,
|
|
void* dstPtr, android::AString* errorDetailMsg);
|
|
|
|
private:
|
|
DISALLOW_EVIL_CONSTRUCTORS(WVCryptoPlugin);
|
|
|
|
android::sp<wvcdm::WvContentDecryptionModule> const mCDM;
|
|
|
|
bool mTestMode;
|
|
wvcdm::CdmSessionId mSessionId;
|
|
|
|
wvcdm::CdmSessionId configureTestMode(const void* data, size_t size);
|
|
android::status_t attemptDecrypt(
|
|
const wvcdm::CdmDecryptionParameters& params,
|
|
bool haveEncryptedSubsamples, android::AString* errorDetailMsg);
|
|
static void incrementIV(uint64_t increaseBy, std::vector<uint8_t>* ivPtr);
|
|
};
|
|
|
|
} // namespace wvdrm
|
|
|
|
#endif // WV_CRYPTO_PLUGIN_H_
|