OEMCrypto v16.1

Merge of http://go/wvgerrit/93404

This CL updates the Widevine CDM to support OEMCrypto v16.1

Test: Tested in 16.2 CL
Bug: 141247171
Change-Id: I69bd993500f6fb63bf6010c8b0250dc7acc3d71b
This commit is contained in:
Fred Gylys-Colwell
2020-01-18 10:11:24 -08:00
parent 7e2619e379
commit 7665614b2e
132 changed files with 12331 additions and 9341 deletions

View File

@@ -12,6 +12,7 @@
#include "crypto_session.h"
#include "initialization_data.h"
#include "license.h"
#include "mock_clock.h"
#include "policy_engine.h"
#include "properties.h"
#include "service_certificate.h"
@@ -112,6 +113,7 @@ const std::string kLicenseRequestSignature = a2bs_hex(
"8D24103EB15C63C227A0D57A9D90F5A409D2D55147EE10A35AE291D2D725C7F161FF827221"
"9AE18B91516E0CDD0B581590DDDEA2A2527E2C9ABA273629B586A9D22D451A827E332CFC3E"
"9BEDB6CF3D8713F9E11675DF1F5DB9038DBBECAB9D1683F8722CAF6E18EC8C04AEE5");
const std::string kFakeCoreMessage = a2bs_hex("DEADBEEF");
const CryptoSession::SupportedCertificateTypes kDefaultSupportedCertTypes = {
true, true, true};
@@ -142,8 +144,8 @@ class MockCryptoSession : public TestCryptoSession {
MOCK_METHOD1(GetSupportedCertificateTypes, bool(SupportedCertificateTypes*));
MOCK_METHOD1(GetApiVersion, bool(uint32_t*));
MOCK_METHOD1(GenerateNonce, CdmResponseType(uint32_t*));
MOCK_METHOD3(PrepareRequest,
CdmResponseType(const std::string&, bool, std::string*));
MOCK_METHOD3(PrepareAndSignLicenseRequest,
CdmResponseType(const std::string&, std::string*, std::string*));
MOCK_METHOD1(LoadEntitledContentKeys,
CdmResponseType(const std::vector<CryptoKey>& key_array));
MOCK_METHOD1(GetResourceRatingTier, bool(uint32_t*));
@@ -158,11 +160,6 @@ class MockPolicyEngine : public PolicyEngine {
void(const std::vector<video_widevine::WidevinePsshData_EntitledKey>&));
};
class MockClock : public Clock {
public:
MOCK_METHOD0(GetCurrentTime, int64_t());
};
class MockInitializationData : public InitializationData {
public:
MockInitializationData(const std::string& type, const CdmInitData& data)
@@ -326,9 +323,11 @@ TEST_F(CdmLicenseTest, PrepareKeyRequestValidation) {
EXPECT_CALL(*clock_, GetCurrentTime()).WillOnce(Return(kLicenseStartTime));
EXPECT_CALL(*crypto_session_, GenerateNonce(NotNull()))
.WillOnce(DoAll(SetArgPointee<0>(kNonce), Return(NO_ERROR)));
EXPECT_CALL(*crypto_session_, PrepareRequest(_, Eq(false), NotNull()))
.WillOnce(
DoAll(SetArgPointee<2>(kLicenseRequestSignature), Return(NO_ERROR)));
EXPECT_CALL(*crypto_session_,
PrepareAndSignLicenseRequest(_, NotNull(), NotNull()))
.WillOnce(DoAll(SetArgPointee<1>(kFakeCoreMessage),
SetArgPointee<2>(kLicenseRequestSignature),
Return(NO_ERROR)));
CreateCdmLicense();
EXPECT_TRUE(cdm_license_->Init(kToken, kClientTokenDrmCert, kEmptyString,
@@ -353,6 +352,8 @@ TEST_F(CdmLicenseTest, PrepareKeyRequestValidation) {
EXPECT_TRUE(std::equal(signed_message.signature().begin(),
signed_message.signature().end(),
kLicenseRequestSignature.begin()));
EXPECT_TRUE(signed_message.has_oemcrypto_core_message());
EXPECT_EQ(kFakeCoreMessage, signed_message.oemcrypto_core_message());
EXPECT_TRUE(!signed_message.msg().empty());
// Verify license request
@@ -447,9 +448,11 @@ TEST_F(CdmLicenseTest, PrepareKeyRequestValidationV15) {
EXPECT_CALL(*clock_, GetCurrentTime()).WillOnce(Return(kLicenseStartTime));
EXPECT_CALL(*crypto_session_, GenerateNonce(NotNull()))
.WillOnce(DoAll(SetArgPointee<0>(kNonce), Return(NO_ERROR)));
EXPECT_CALL(*crypto_session_, PrepareRequest(_, Eq(false), NotNull()))
.WillOnce(
DoAll(SetArgPointee<2>(kLicenseRequestSignature), Return(NO_ERROR)));
EXPECT_CALL(*crypto_session_,
PrepareAndSignLicenseRequest(_, NotNull(), NotNull()))
.WillOnce(DoAll(SetArgPointee<1>(kFakeCoreMessage),
SetArgPointee<2>(kLicenseRequestSignature),
Return(NO_ERROR)));
CreateCdmLicense();
EXPECT_TRUE(cdm_license_->Init(kToken, kClientTokenDrmCert, kEmptyString,
@@ -474,6 +477,8 @@ TEST_F(CdmLicenseTest, PrepareKeyRequestValidationV15) {
EXPECT_TRUE(std::equal(signed_message.signature().begin(),
signed_message.signature().end(),
kLicenseRequestSignature.begin()));
EXPECT_TRUE(signed_message.has_oemcrypto_core_message());
EXPECT_EQ(kFakeCoreMessage, signed_message.oemcrypto_core_message());
EXPECT_TRUE(!signed_message.msg().empty());
// Verify license request