Source release 16.2.0
This commit is contained in:
59
oemcrypto/test/oec_decrypt_fallback_chain.h
Normal file
59
oemcrypto/test/oec_decrypt_fallback_chain.h
Normal file
@@ -0,0 +1,59 @@
|
||||
// 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 CDM_OEC_DECRYPT_FALLBACK_CHAIN_H_
|
||||
#define CDM_OEC_DECRYPT_FALLBACK_CHAIN_H_
|
||||
|
||||
#include "OEMCryptoCENC.h"
|
||||
#include "disallow_copy_and_assign.h"
|
||||
|
||||
namespace wvoec {
|
||||
|
||||
// This class groups static methods relating to providing proper fallback
|
||||
// behavior when calling DecryptCENC in OEMCrypto v16. Outside code can leverage
|
||||
// this behavior by passing the samples to be decrypted to Decrypt(), which will
|
||||
// set off the chain of fallback functions as needed.
|
||||
//
|
||||
// The behavior of this class is pathological. For each block of data, it will
|
||||
// greedily try every possible way of passing data to OEMCrypto until one works.
|
||||
// In the order tried, the ways to send data are:
|
||||
// 1) Multiple Samples at once
|
||||
// 2) Individual Samples one at a time
|
||||
// 3) Individual Subsamples one at a time
|
||||
// 4) Individual Half-Subsamples one at a time
|
||||
// On a device that only accepts half-subsamples, the way OEMCrypto v15 did,
|
||||
// this results in many needless roundtrips to OEMCrypto. This would be
|
||||
// inefficient behavior for a real CDM, but for the sake of testing, we want to
|
||||
// use the maximal way the OEMCrypto implementation will accept the data. And,
|
||||
// for implementations that do not accept multiple samples or subsamples per
|
||||
// call, we want to test that they correctly reject larger calls.
|
||||
class DecryptFallbackChain {
|
||||
public:
|
||||
static OEMCryptoResult Decrypt(
|
||||
OEMCrypto_SESSION session_id, const OEMCrypto_SampleDescription* samples,
|
||||
size_t samples_length, OEMCryptoCipherMode cipher_mode,
|
||||
const OEMCrypto_CENCEncryptPatternDesc* pattern);
|
||||
|
||||
private:
|
||||
static OEMCryptoResult DecryptSample(
|
||||
OEMCrypto_SESSION session_id, const OEMCrypto_SampleDescription& sample,
|
||||
OEMCryptoCipherMode cipher_mode,
|
||||
const OEMCrypto_CENCEncryptPatternDesc* pattern);
|
||||
|
||||
static OEMCryptoResult DecryptSubsample(
|
||||
OEMCrypto_SESSION session_id, const OEMCrypto_SampleDescription& sample,
|
||||
const OEMCrypto_CENCEncryptPatternDesc* pattern);
|
||||
|
||||
static OEMCryptoResult DecryptSubsampleHalf(
|
||||
OEMCrypto_SESSION session_id, const OEMCrypto_SampleDescription& sample,
|
||||
const OEMCrypto_CENCEncryptPatternDesc* pattern);
|
||||
|
||||
// There is no reason to have an instance of this class.
|
||||
DecryptFallbackChain() = delete;
|
||||
CORE_DISALLOW_COPY_AND_ASSIGN(DecryptFallbackChain);
|
||||
};
|
||||
|
||||
} // namespace wvoec
|
||||
|
||||
#endif // CDM_OEC_DECRYPT_FALLBACK_CHAIN_H_
|
||||
Reference in New Issue
Block a user