#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "media/cdm/aes_decryptor.h"
#include <stdint.h>
#include <memory>
#include <set>
#include <string>
#include <vector>
#include "base/containers/to_vector.h"
#include "base/debug/leak_annotations.h"
#include "base/functional/bind.h"
#include "base/json/json_reader.h"
#include "base/memory/raw_ptr.h"
#include "base/run_loop.h"
#include "base/test/scoped_feature_list.h"
#include "base/test/task_environment.h"
#include "base/values.h"
#include "media/base/cdm_callback_promise.h"
#include "media/base/cdm_config.h"
#include "media/base/cdm_key_information.h"
#include "media/base/decoder_buffer.h"
#include "media/base/decrypt_config.h"
#include "media/base/decryptor.h"
#include "media/base/media_switches.h"
#include "media/base/mock_filters.h"
#include "media/media_buildflags.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest-param-test.h"
#include "testing/gtest/include/gtest/gtest.h"
#if BUILDFLAG(ENABLE_LIBRARY_CDMS)
#include "media/cdm/api/content_decryption_module.h"
#include "media/cdm/cdm_adapter.h"
#include "media/cdm/cdm_auxiliary_helper.h"
#include "media/cdm/cdm_module.h"
#include "media/cdm/external_clear_key_test_helper.h"
#include "media/cdm/mock_helpers.h"
#include "media/cdm/simple_cdm_allocator.h"
#endif
_;
AtMost;
Gt;
IsNull;
NotNull;
SaveArg;
StrictMock;
StrNe;
Unused;
MATCHER(IsEmpty, "") { … }
MATCHER(NotEmpty, "") { … }
MATCHER(IsJSONDictionary, "") { … }
MATCHER(IsNullTime, "") { … }
namespace media {
namespace {
const uint8_t kOriginalData[] = …;
const int kOriginalDataSize = …;
const uint8_t kKeyId[] = …;
const char kKeyAsJWK[] = …;
const char kKeyAlternateAsJWK[] = …;
const char kWrongKeyAsJWK[] = …;
const char kWrongSizedKeyAsJWK[] = …;
const uint8_t kIv[] = …;
const uint8_t kEncryptedData[] = …;
const uint8_t kSubsampleEncryptedData[] = …;
const uint8_t kOriginalData2[] = …;
const uint8_t kIv2[] = …;
const uint8_t kKeyId2[] = …;
const char kKey2AsJWK[] = …;
const uint8_t kEncryptedData2[] = …;
const SubsampleEntry kSubsampleEntriesNormal[] = …;
const SubsampleEntry kSubsampleEntriesWrongSize[] = …;
const SubsampleEntry kSubsampleEntriesInvalidTotalSize[] = …;
const SubsampleEntry kSubsampleEntriesClearOnly[] = …;
const SubsampleEntry kSubsampleEntriesCypherOnly[] = …;
scoped_refptr<DecoderBuffer> CreateEncryptedBuffer(
const std::vector<uint8_t>& data,
const std::vector<uint8_t>& key_id,
const std::vector<uint8_t>& iv,
const std::vector<SubsampleEntry>& subsample_entries) { … }
scoped_refptr<DecoderBuffer> CreateClearBuffer(
const std::vector<uint8_t>& data) { … }
enum ExpectedResult { … };
enum class TestType { … };
}
class AesDecryptorTest : public testing::TestWithParam<TestType> { … };
TEST_P(AesDecryptorTest, CreateSessionWithEmptyInitData) { … }
TEST_P(AesDecryptorTest, CreateSessionWithVariousLengthInitData_WebM) { … }
TEST_P(AesDecryptorTest, MultipleCreateSession) { … }
TEST_P(AesDecryptorTest, CreateSessionWithCencInitData) { … }
TEST_P(AesDecryptorTest, CreateSessionWithKeyIdsInitData) { … }
TEST_P(AesDecryptorTest, NormalDecryption) { … }
TEST_P(AesDecryptorTest, UnencryptedFrame) { … }
TEST_P(AesDecryptorTest, WrongKey) { … }
TEST_P(AesDecryptorTest, NoKey) { … }
TEST_P(AesDecryptorTest, KeyReplacement) { … }
TEST_P(AesDecryptorTest, WrongSizedKey) { … }
TEST_P(AesDecryptorTest, MultipleKeysAndFrames) { … }
TEST_P(AesDecryptorTest, CorruptedIv) { … }
TEST_P(AesDecryptorTest, CorruptedData) { … }
TEST_P(AesDecryptorTest, EncryptedAsUnencryptedFailure) { … }
TEST_P(AesDecryptorTest, SubsampleDecryption) { … }
TEST_P(AesDecryptorTest, SubsampleDecryptionWithOffset) { … }
TEST_P(AesDecryptorTest, SubsampleWrongSize) { … }
TEST_P(AesDecryptorTest, SubsampleInvalidTotalSize) { … }
TEST_P(AesDecryptorTest, SubsampleClearBytesOnly) { … }
TEST_P(AesDecryptorTest, SubsampleCypherBytesOnly) { … }
TEST_P(AesDecryptorTest, CloseSession) { … }
TEST_P(AesDecryptorTest, RemoveSession) { … }
TEST_P(AesDecryptorTest, RemoveThenCloseSession) { … }
TEST_P(AesDecryptorTest, NoKeyAfterCloseSession) { … }
TEST_P(AesDecryptorTest, LatestKeyUsed) { … }
TEST_P(AesDecryptorTest, LatestKeyUsedAfterCloseSession) { … }
TEST_P(AesDecryptorTest, JWKKey) { … }
TEST_P(AesDecryptorTest, GetKeyIds) { … }
TEST_P(AesDecryptorTest, NoKeysChangeForSameKey) { … }
TEST_P(AesDecryptorTest, RandomSessionIDs) { … }
INSTANTIATE_TEST_SUITE_P(…);
#if BUILDFLAG(ENABLE_LIBRARY_CDMS)
INSTANTIATE_TEST_SUITE_P(…);
#endif
}