Add recoverable errors

[ Merge of http://go/wvgerrit/71326 ]

Nonce flood, frame size, session and system invalidation errors
will now bubble up to the app. OEMCrypto v15 returns
OEMCrypto_ERROR_BUFFER_TOO_LARGE, OEMCrypto_ERROR_SESSION_LOST_STATE,
OEMCrypto_ERROR_SYSTEM_INVALIDATED and a variety of nonce errors.
These will be reported to HIDL as OUTPUT_TOO_LARGE_ERROR,
ERROR_DRM_SESSION_LOST_STATE, ERROR_DRM_INVALID_STATE and
ERROR_DRM_RESOURCE_CONTENTION.

Bug: 120572706
Test: Unit/Integration tests
Change-Id: Ida177300046327ce81592a273028ef6c3a0d9fd9
This commit is contained in:
Rahul Frias
2019-01-30 02:15:52 -08:00
parent 54104c7a22
commit 272e60db27
27 changed files with 977 additions and 648 deletions

View File

@@ -135,12 +135,12 @@ class MockCryptoSession : public TestCryptoSession {
Invoke(this, &MockCryptoSession::BaseGetUsageSupportType));
}
MOCK_METHOD1(GetClientToken, bool(std::string*));
MOCK_METHOD1(GetProvisioningToken, bool(std::string*));
MOCK_METHOD1(GetProvisioningToken, CdmResponseType(std::string*));
MOCK_METHOD0(GetPreProvisionTokenType, CdmClientTokenType());
MOCK_METHOD0(GetSecurityLevel, CdmSecurityLevel());
MOCK_METHOD0(Open, CdmResponseType());
MOCK_METHOD1(Open, CdmResponseType(SecurityLevel));
MOCK_METHOD1(LoadCertificatePrivateKey, bool(std::string&));
MOCK_METHOD1(LoadCertificatePrivateKey, CdmResponseType(std::string&));
MOCK_METHOD0(DeleteAllUsageReports, CdmResponseType());
MOCK_METHOD1(GetUsageSupportType, CdmResponseType(CdmUsageSupportType* type));
MOCK_METHOD0(GetUsageTableHeader, UsageTableHeader*());
@@ -219,7 +219,7 @@ TEST_F(CdmSessionTest, InitWithBuiltInCertificate) {
Return(true)));
EXPECT_CALL(*crypto_session_, LoadCertificatePrivateKey(StrEq(kWrappedKey)))
.InSequence(crypto_session_seq)
.WillOnce(Return(true));
.WillOnce(Return(NO_ERROR));
EXPECT_CALL(*file_handle_, Init(Eq(level))).WillOnce(Return(true));
EXPECT_CALL(*license_parser_,
Init(Eq(kToken), Eq(kClientTokenDrmCert), Eq(kEmptyString),
@@ -248,7 +248,7 @@ TEST_F(CdmSessionTest, InitWithCertificate) {
Return(true)));
EXPECT_CALL(*crypto_session_, LoadCertificatePrivateKey(StrEq(kWrappedKey)))
.InSequence(crypto_session_seq)
.WillOnce(Return(true));
.WillOnce(Return(NO_ERROR));
EXPECT_CALL(*license_parser_,
Init(Eq(kToken), Eq(kClientTokenDrmCert), Eq(kEmptyString),
false, Eq(kEmptyString), Eq(crypto_session_),
@@ -276,7 +276,7 @@ TEST_F(CdmSessionTest, ReInitFail) {
Return(true)));
EXPECT_CALL(*crypto_session_, LoadCertificatePrivateKey(StrEq(kWrappedKey)))
.InSequence(crypto_session_seq)
.WillOnce(Return(true));
.WillOnce(Return(NO_ERROR));
EXPECT_CALL(*license_parser_,
Init(Eq(kToken), Eq(kClientTokenDrmCert), Eq(kEmptyString), false,
Eq(kEmptyString), Eq(crypto_session_), Eq(policy_engine_)))
@@ -331,7 +331,7 @@ TEST_F(CdmSessionTest, UpdateUsageEntry) {
Return(true)));
EXPECT_CALL(*crypto_session_, LoadCertificatePrivateKey(StrEq(kWrappedKey)))
.InSequence(crypto_session_seq)
.WillOnce(Return(true));
.WillOnce(Return(NO_ERROR));
EXPECT_CALL(*crypto_session_, GetUsageTableHeader())
.WillOnce(Return(&usage_table_header_));
EXPECT_CALL(*license_parser_,

View File

@@ -352,7 +352,7 @@ TEST_F(CryptoSessionMetricsTest, GetProvisioningTokenValidMetrics) {
// token. Otherwise, we should be able to fetch the token.
std::string token;
if (token_type != kClientTokenDrmCert) {
ASSERT_TRUE(session->GetProvisioningToken(&token));
ASSERT_EQ(NO_ERROR, session->GetProvisioningToken(&token));
}
drm_metrics::WvCdmMetrics::CryptoMetrics metrics_proto;

View File

@@ -140,11 +140,13 @@ class MockCryptoSession : public TestCryptoSession {
MOCK_METHOD0(IsOpen, bool());
MOCK_METHOD0(request_id, const std::string&());
MOCK_METHOD1(UsageInformationSupport, bool(bool*));
MOCK_METHOD2(GetHdcpCapabilities, bool(HdcpCapability*, HdcpCapability*));
MOCK_METHOD2(GetHdcpCapabilities,
CdmResponseType(HdcpCapability*, HdcpCapability*));
MOCK_METHOD1(GetSupportedCertificateTypes, bool(SupportedCertificateTypes*));
MOCK_METHOD1(GetApiVersion, bool(uint32_t*));
MOCK_METHOD1(GenerateNonce, bool(uint32_t*));
MOCK_METHOD3(PrepareRequest, bool(const std::string&, bool, std::string*));
MOCK_METHOD1(GenerateNonce, CdmResponseType(uint32_t*));
MOCK_METHOD3(PrepareRequest,
CdmResponseType(const std::string&, bool, std::string*));
MOCK_METHOD1(LoadEntitledContentKeys,
CdmResponseType(const std::vector<CryptoKey>& key_array));
MOCK_METHOD1(GetResourceRatingTier, bool(uint32_t*));
@@ -318,7 +320,7 @@ TEST_F(CdmLicenseTest, PrepareKeyRequestValidation) {
DoAll(SetArgPointee<0>(usage_information_support), Return(true)));
EXPECT_CALL(*crypto_session_, GetHdcpCapabilities(NotNull(), NotNull()))
.WillOnce(DoAll(SetArgPointee<0>(current_hdcp_version),
SetArgPointee<1>(max_hdcp_version), Return(true)));
SetArgPointee<1>(max_hdcp_version), Return(NO_ERROR)));
EXPECT_CALL(*crypto_session_, GetSupportedCertificateTypes(NotNull()));
EXPECT_CALL(*crypto_session_, GetApiVersion(NotNull()))
.Times(2)
@@ -326,10 +328,10 @@ TEST_F(CdmLicenseTest, PrepareKeyRequestValidation) {
DoAll(SetArgPointee<0>(crypto_session_api_version), Return(true)));
EXPECT_CALL(*clock_, GetCurrentTime()).WillOnce(Return(kLicenseStartTime));
EXPECT_CALL(*crypto_session_, GenerateNonce(NotNull()))
.WillOnce(DoAll(SetArgPointee<0>(kNonce), Return(true)));
.WillOnce(DoAll(SetArgPointee<0>(kNonce), Return(NO_ERROR)));
EXPECT_CALL(*crypto_session_, PrepareRequest(_, Eq(false), NotNull()))
.WillOnce(
DoAll(SetArgPointee<2>(kLicenseRequestSignature), Return(true)));
DoAll(SetArgPointee<2>(kLicenseRequestSignature), Return(NO_ERROR)));
CreateCdmLicense();
EXPECT_TRUE(cdm_license_->Init(
@@ -438,7 +440,7 @@ TEST_F(CdmLicenseTest, PrepareKeyRequestValidationV15) {
DoAll(SetArgPointee<0>(usage_information_support), Return(true)));
EXPECT_CALL(*crypto_session_, GetHdcpCapabilities(NotNull(), NotNull()))
.WillOnce(DoAll(SetArgPointee<0>(current_hdcp_version),
SetArgPointee<1>(max_hdcp_version), Return(true)));
SetArgPointee<1>(max_hdcp_version), Return(NO_ERROR)));
EXPECT_CALL(*crypto_session_, GetSupportedCertificateTypes(NotNull()));
EXPECT_CALL(*crypto_session_, GetApiVersion(NotNull()))
.Times(2)
@@ -449,10 +451,10 @@ TEST_F(CdmLicenseTest, PrepareKeyRequestValidationV15) {
DoAll(SetArgPointee<0>(resource_rating_tier), Return(true)));
EXPECT_CALL(*clock_, GetCurrentTime()).WillOnce(Return(kLicenseStartTime));
EXPECT_CALL(*crypto_session_, GenerateNonce(NotNull()))
.WillOnce(DoAll(SetArgPointee<0>(kNonce), Return(true)));
.WillOnce(DoAll(SetArgPointee<0>(kNonce), Return(NO_ERROR)));
EXPECT_CALL(*crypto_session_, PrepareRequest(_, Eq(false), NotNull()))
.WillOnce(
DoAll(SetArgPointee<2>(kLicenseRequestSignature), Return(true)));
DoAll(SetArgPointee<2>(kLicenseRequestSignature), Return(NO_ERROR)));
CreateCdmLicense();
EXPECT_TRUE(cdm_license_->Init(

View File

@@ -70,7 +70,8 @@ class HdcpOnlyMockCryptoSession : public TestCryptoSession {
HdcpOnlyMockCryptoSession(metrics::CryptoMetrics* crypto_metrics)
: TestCryptoSession(crypto_metrics) { }
MOCK_METHOD2(GetHdcpCapabilities, bool(HdcpCapability*, HdcpCapability*));
MOCK_METHOD2(GetHdcpCapabilities,
CdmResponseType(HdcpCapability*, HdcpCapability*));
};
class MockCdmEventListener : public WvCdmEventListener {
@@ -240,7 +241,7 @@ TEST_F(PolicyEngineConstraintsTest, IsPermissiveWithoutAResolution) {
EXPECT_CALL(crypto_session_, GetHdcpCapabilities(_, _))
.WillRepeatedly(
DoAll(SetArgPointee<0>(HDCP_NO_DIGITAL_OUTPUT),
Return(false)));
Return(GET_HDCP_CAPABILITY_FAILED)));
policy_engine_->SetLicense(license_);
policy_engine_->OnTimerEvent();
@@ -273,7 +274,7 @@ TEST_F(PolicyEngineConstraintsTest, HandlesResolutionsBasedOnConstraints) {
EXPECT_CALL(crypto_session_, GetHdcpCapabilities(_, _))
.WillRepeatedly(
DoAll(SetArgPointee<0>(HDCP_NO_DIGITAL_OUTPUT),
Return(true)));
Return(NO_ERROR)));
policy_engine_->SetLicense(license_);
policy_engine_->NotifyResolution(1, kTargetRes1);
@@ -321,10 +322,10 @@ TEST_F(PolicyEngineConstraintsTest,
EXPECT_CALL(crypto_session_, GetHdcpCapabilities(_, _))
.WillOnce(
DoAll(SetArgPointee<0>(HDCP_V2_2),
Return(false)))
Return(GET_HDCP_CAPABILITY_FAILED)))
.WillOnce(
DoAll(SetArgPointee<0>(HDCP_V2_2),
Return(false)));
Return(GET_HDCP_CAPABILITY_FAILED)));
}
int64_t start_time = current_time_ + 5;
{
@@ -332,17 +333,17 @@ TEST_F(PolicyEngineConstraintsTest,
EXPECT_CALL(crypto_session_, GetHdcpCapabilities(_, _))
.WillOnce(
DoAll(SetArgPointee<0>(HDCP_V2_2),
Return(false)));
Return(GET_HDCP_CAPABILITY_FAILED)));
EXPECT_CALL(*mock_clock_, GetCurrentTime())
.WillOnce(Return(start_time + kHdcpInterval / 2))
.WillOnce(Return(start_time + kHdcpInterval));
EXPECT_CALL(crypto_session_, GetHdcpCapabilities(_, _))
.WillOnce(
DoAll(SetArgPointee<0>(HDCP_V2_2),
Return(false)))
Return(GET_HDCP_CAPABILITY_FAILED)))
.WillOnce(
DoAll(SetArgPointee<0>(HDCP_V2_2),
Return(true)));
Return(NO_ERROR)));
}
policy_engine_->NotifyResolution(1, kTargetRes1);
@@ -380,7 +381,7 @@ TEST_F(PolicyEngineConstraintsTest, HandlesConstraintOverridingHdcp) {
EXPECT_CALL(crypto_session_, GetHdcpCapabilities(_, _))
.WillRepeatedly(
DoAll(SetArgPointee<0>(HDCP_V2),
Return(true)));
Return(NO_ERROR)));
policy_engine_->SetLicense(license_);
policy_engine_->NotifyResolution(1, kTargetRes1);
@@ -425,7 +426,7 @@ TEST_F(PolicyEngineConstraintsTest, HandlesNoHdcp) {
EXPECT_CALL(crypto_session_, GetHdcpCapabilities(_, _))
.WillRepeatedly(
DoAll(SetArgPointee<0>(HDCP_NONE),
Return(true)));
Return(NO_ERROR)));
policy_engine_->SetLicense(license_);
@@ -470,7 +471,7 @@ TEST_F(PolicyEngineConstraintsTest, UsesDefaultHdcpWhenResolutionNotSet) {
EXPECT_CALL(crypto_session_, GetHdcpCapabilities(_, _))
.WillRepeatedly(
DoAll(SetArgPointee<0>(HDCP_NO_DIGITAL_OUTPUT),
Return(false)));
Return(GET_HDCP_CAPABILITY_FAILED)));
policy_engine_->SetLicense(license_);
policy_engine_->OnTimerEvent();

View File

@@ -63,8 +63,9 @@ class HdcpOnlyMockCryptoSession : public TestCryptoSession {
HdcpOnlyMockCryptoSession(metrics::CryptoMetrics* metrics) :
TestCryptoSession(metrics) {}
MOCK_METHOD2(GetHdcpCapabilities, bool(HdcpCapability*, HdcpCapability*));
bool DoRealGetHdcpCapabilities(HdcpCapability* current,
MOCK_METHOD2(GetHdcpCapabilities,
CdmResponseType(HdcpCapability*, HdcpCapability*));
CdmResponseType DoRealGetHdcpCapabilities(HdcpCapability* current,
HdcpCapability* max) {
return CryptoSession::GetHdcpCapabilities(current, max);
}
@@ -209,7 +210,7 @@ TEST_F(PolicyEngineTest, PlaybackSuccess_OfflineLicense) {
EXPECT_CALL(crypto_session_, GetHdcpCapabilities(_, _))
.WillRepeatedly(
DoAll(SetArgPointee<0>(HDCP_NO_DIGITAL_OUTPUT),
Return(true)));
Return(NO_ERROR)));
policy_engine_->SetLicense(license_);
policy_engine_->BeginDecryption();
@@ -234,7 +235,7 @@ TEST_F(PolicyEngineTest, PlaybackSuccess_EntitlementLicense) {
EXPECT_CALL(crypto_session_, GetHdcpCapabilities(_, _))
.WillRepeatedly(
DoAll(SetArgPointee<0>(HDCP_NO_DIGITAL_OUTPUT),
Return(true)));
Return(NO_ERROR)));
License::KeyContainer* key = license_.mutable_key(0);
key->set_type(License::KeyContainer::ENTITLEMENT);
@@ -302,7 +303,7 @@ TEST_F(PolicyEngineTest, PlaybackSuccess_StreamingLicense) {
EXPECT_CALL(crypto_session_, GetHdcpCapabilities(_, _))
.WillRepeatedly(
DoAll(SetArgPointee<0>(HDCP_NO_DIGITAL_OUTPUT),
Return(false)));
Return(GET_HDCP_CAPABILITY_FAILED)));
policy_engine_->SetLicense(license_);
policy_engine_->BeginDecryption();
@@ -325,7 +326,7 @@ TEST_F(PolicyEngineTest, PlaybackFailed_CanPlayFalse) {
EXPECT_CALL(crypto_session_, GetHdcpCapabilities(_, _))
.WillRepeatedly(
DoAll(SetArgPointee<0>(HDCP_NO_DIGITAL_OUTPUT),
Return(false)));
Return(GET_HDCP_CAPABILITY_FAILED)));
policy_engine_->SetLicense(license_);
EXPECT_FALSE(policy_engine_->CanDecryptContent(kKeyId));
@@ -350,7 +351,7 @@ TEST_F(PolicyEngineTest, LicenseExpired_RentalDurationExpiredWithoutPlayback) {
EXPECT_CALL(crypto_session_, GetHdcpCapabilities(_, _))
.WillRepeatedly(
DoAll(SetArgPointee<0>(HDCP_NO_DIGITAL_OUTPUT),
Return(false)));
Return(GET_HDCP_CAPABILITY_FAILED)));
InSequence s;
ExpectSessionKeysChange(kKeyStatusUsable, true);
@@ -385,7 +386,7 @@ TEST_F(PolicyEngineTest, PlaybackOk_RentalDurationPassedWithPlayback) {
EXPECT_CALL(crypto_session_, GetHdcpCapabilities(_, _))
.WillRepeatedly(
DoAll(SetArgPointee<0>(HDCP_NO_DIGITAL_OUTPUT),
Return(false)));
Return(GET_HDCP_CAPABILITY_FAILED)));
InSequence s;
ExpectSessionKeysChange(kKeyStatusUsable, true);
@@ -420,7 +421,7 @@ TEST_F(PolicyEngineTest, PlaybackFails_PlaybackDurationExpired) {
EXPECT_CALL(crypto_session_, GetHdcpCapabilities(_, _))
.WillRepeatedly(
DoAll(SetArgPointee<0>(HDCP_NO_DIGITAL_OUTPUT),
Return(false)));
Return(GET_HDCP_CAPABILITY_FAILED)));
InSequence s;
ExpectSessionKeysChange(kKeyStatusUsable, true);
@@ -457,7 +458,7 @@ TEST_F(PolicyEngineTest, LicenseExpired_LicenseDurationExpiredWithoutPlayback) {
EXPECT_CALL(crypto_session_, GetHdcpCapabilities(_, _))
.WillRepeatedly(
DoAll(SetArgPointee<0>(HDCP_NO_DIGITAL_OUTPUT),
Return(false)));
Return(GET_HDCP_CAPABILITY_FAILED)));
InSequence s;
ExpectSessionKeysChange(kKeyStatusUsable, true);
@@ -493,7 +494,7 @@ TEST_F(PolicyEngineTest, PlaybackFails_ExpiryBeforeRenewalDelay_Offline) {
EXPECT_CALL(crypto_session_, GetHdcpCapabilities(_, _))
.WillRepeatedly(
DoAll(SetArgPointee<0>(HDCP_NO_DIGITAL_OUTPUT),
Return(false)));
Return(GET_HDCP_CAPABILITY_FAILED)));
InSequence s;
ExpectSessionKeysChange(kKeyStatusUsable, true);
@@ -533,7 +534,7 @@ TEST_F(PolicyEngineTest, PlaybackFails_ExpiryBeforeRenewalDelay_Streaming) {
EXPECT_CALL(crypto_session_, GetHdcpCapabilities(_, _))
.WillRepeatedly(
DoAll(SetArgPointee<0>(HDCP_NO_DIGITAL_OUTPUT),
Return(false)));
Return(GET_HDCP_CAPABILITY_FAILED)));
InSequence s;
ExpectSessionKeysChange(kKeyStatusUsable, true);
@@ -568,7 +569,7 @@ TEST_F(PolicyEngineTest, PlaybackOk_RentalDuration0) {
EXPECT_CALL(crypto_session_, GetHdcpCapabilities(_, _))
.WillRepeatedly(
DoAll(SetArgPointee<0>(HDCP_NO_DIGITAL_OUTPUT),
Return(false)));
Return(GET_HDCP_CAPABILITY_FAILED)));
InSequence s;
ExpectSessionKeysChange(kKeyStatusUsable, true);
@@ -605,7 +606,7 @@ TEST_F(PolicyEngineTest, PlaybackOk_PlaybackDuration0) {
EXPECT_CALL(crypto_session_, GetHdcpCapabilities(_, _))
.WillRepeatedly(
DoAll(SetArgPointee<0>(HDCP_NO_DIGITAL_OUTPUT),
Return(false)));
Return(GET_HDCP_CAPABILITY_FAILED)));
InSequence s;
ExpectSessionKeysChange(kKeyStatusUsable, true);
@@ -644,7 +645,7 @@ TEST_F(PolicyEngineTest, PlaybackOk_LicenseDuration0) {
EXPECT_CALL(crypto_session_, GetHdcpCapabilities(_, _))
.WillRepeatedly(
DoAll(SetArgPointee<0>(HDCP_NO_DIGITAL_OUTPUT),
Return(false)));
Return(GET_HDCP_CAPABILITY_FAILED)));
InSequence s;
ExpectSessionKeysChange(kKeyStatusUsable, true);
@@ -686,7 +687,7 @@ TEST_F(PolicyEngineTest, PlaybackOk_PlaybackAndRental0) {
EXPECT_CALL(crypto_session_, GetHdcpCapabilities(_, _))
.WillRepeatedly(
DoAll(SetArgPointee<0>(HDCP_NO_DIGITAL_OUTPUT),
Return(false)));
Return(GET_HDCP_CAPABILITY_FAILED)));
policy_engine_->SetLicense(license_);
policy_engine_->BeginDecryption();
@@ -836,12 +837,12 @@ TEST_F(PolicyEngineTest, PlaybackOk_Durations0) {
EXPECT_CALL(crypto_session_, GetHdcpCapabilities(_, _))
.WillRepeatedly(
DoAll(SetArgPointee<0>(HDCP_NO_DIGITAL_OUTPUT),
Return(false)));
Return(GET_HDCP_CAPABILITY_FAILED)));
EXPECT_CALL(crypto_session_, GetHdcpCapabilities(_, _))
.WillRepeatedly(
DoAll(SetArgPointee<0>(HDCP_NO_DIGITAL_OUTPUT),
Return(false)));
Return(GET_HDCP_CAPABILITY_FAILED)));
policy_engine_->SetLicense(license_);
@@ -864,7 +865,7 @@ TEST_F(PolicyEngineTest, PlaybackOk_LicenseWithFutureStartTime) {
EXPECT_CALL(crypto_session_, GetHdcpCapabilities(_, _))
.WillRepeatedly(
DoAll(SetArgPointee<0>(HDCP_NO_DIGITAL_OUTPUT),
Return(false)));
Return(GET_HDCP_CAPABILITY_FAILED)));
InSequence s;
ExpectSessionKeysChange(kKeyStatusPending, false);
@@ -903,7 +904,7 @@ TEST_F(PolicyEngineTest, PlaybackFailed_CanRenewFalse) {
EXPECT_CALL(crypto_session_, GetHdcpCapabilities(_, _))
.WillRepeatedly(
DoAll(SetArgPointee<0>(HDCP_NO_DIGITAL_OUTPUT),
Return(false)));
Return(GET_HDCP_CAPABILITY_FAILED)));
InSequence s;
ExpectSessionKeysChange(kKeyStatusUsable, true);
@@ -949,7 +950,7 @@ TEST_F(PolicyEngineTest, PlaybackOk_RenewSuccess) {
EXPECT_CALL(crypto_session_, GetHdcpCapabilities(_, _))
.WillRepeatedly(
DoAll(SetArgPointee<0>(HDCP_NO_DIGITAL_OUTPUT),
Return(false)));
Return(GET_HDCP_CAPABILITY_FAILED)));
InSequence s;
ExpectSessionKeysChange(kKeyStatusUsable, true);
@@ -1006,7 +1007,7 @@ TEST_F(PolicyEngineTest, PlaybackOk_RenewSuccess_WithFutureStartTime) {
EXPECT_CALL(crypto_session_, GetHdcpCapabilities(_, _))
.WillRepeatedly(
DoAll(SetArgPointee<0>(HDCP_NO_DIGITAL_OUTPUT),
Return(false)));
Return(GET_HDCP_CAPABILITY_FAILED)));
InSequence s;
ExpectSessionKeysChange(kKeyStatusUsable, true);
@@ -1063,7 +1064,7 @@ TEST_F(PolicyEngineTest, LicenseExpired_RenewFailedVersionNotUpdated) {
EXPECT_CALL(crypto_session_, GetHdcpCapabilities(_, _))
.WillRepeatedly(
DoAll(SetArgPointee<0>(HDCP_NO_DIGITAL_OUTPUT),
Return(false)));
Return(GET_HDCP_CAPABILITY_FAILED)));
InSequence s;
ExpectSessionKeysChange(kKeyStatusUsable, true);
@@ -1126,7 +1127,7 @@ TEST_F(PolicyEngineTest, PlaybackFailed_RepeatedRenewFailures) {
EXPECT_CALL(crypto_session_, GetHdcpCapabilities(_, _))
.WillRepeatedly(
DoAll(SetArgPointee<0>(HDCP_NO_DIGITAL_OUTPUT),
Return(false)));
Return(GET_HDCP_CAPABILITY_FAILED)));
InSequence s;
ExpectSessionKeysChange(kKeyStatusUsable, true);
@@ -1187,7 +1188,7 @@ TEST_F(PolicyEngineTest, PlaybackOk_RenewSuccessAfterExpiry) {
EXPECT_CALL(crypto_session_, GetHdcpCapabilities(_, _))
.WillRepeatedly(
DoAll(SetArgPointee<0>(HDCP_NO_DIGITAL_OUTPUT),
Return(false)));
Return(GET_HDCP_CAPABILITY_FAILED)));
InSequence s;
ExpectSessionKeysChange(kKeyStatusUsable, true);
@@ -1262,7 +1263,7 @@ TEST_F(PolicyEngineTest, PlaybackOk_RenewSuccessAfterFailures) {
EXPECT_CALL(crypto_session_, GetHdcpCapabilities(_, _))
.WillRepeatedly(
DoAll(SetArgPointee<0>(HDCP_NO_DIGITAL_OUTPUT),
Return(false)));
Return(GET_HDCP_CAPABILITY_FAILED)));
InSequence s;
ExpectSessionKeysChange(kKeyStatusUsable, true);
@@ -1321,7 +1322,7 @@ TEST_F(PolicyEngineTest, PlaybackOk_RenewedWithUsage) {
EXPECT_CALL(crypto_session_, GetHdcpCapabilities(_, _))
.WillRepeatedly(
DoAll(SetArgPointee<0>(HDCP_NO_DIGITAL_OUTPUT),
Return(false)));
Return(GET_HDCP_CAPABILITY_FAILED)));
InSequence s;
ExpectSessionKeysChange(kKeyStatusUsable, true);
@@ -1384,7 +1385,7 @@ TEST_F(PolicyEngineTest, MultipleKeysInLicense) {
EXPECT_CALL(crypto_session_, GetHdcpCapabilities(_, _))
.WillRepeatedly(
DoAll(SetArgPointee<0>(HDCP_NO_DIGITAL_OUTPUT),
Return(false)));
Return(GET_HDCP_CAPABILITY_FAILED)));
ExpectSessionKeysChange(kKeyStatusUsable, kKeyStatusUsable, true);
EXPECT_CALL(mock_event_listener_, OnExpirationUpdate(_, _));
@@ -1411,7 +1412,7 @@ TEST_F(PolicyEngineTest, PlaybackOk_SoftEnforcePlaybackDuration) {
EXPECT_CALL(crypto_session_, GetHdcpCapabilities(_, _))
.WillRepeatedly(
DoAll(SetArgPointee<0>(HDCP_NO_DIGITAL_OUTPUT),
Return(false)));
Return(GET_HDCP_CAPABILITY_FAILED)));
InSequence seq;
ExpectSessionKeysChange(kKeyStatusUsable, true);
@@ -1449,7 +1450,7 @@ TEST_F(PolicyEngineTest, LicenseExpired_SoftEnforceLoadBeforeExpire) {
EXPECT_CALL(crypto_session_, GetHdcpCapabilities(_, _))
.WillRepeatedly(
DoAll(SetArgPointee<0>(HDCP_NO_DIGITAL_OUTPUT),
Return(false)));
Return(GET_HDCP_CAPABILITY_FAILED)));
InSequence seq;
ExpectSessionKeysChange(kKeyStatusUsable, true);
@@ -1478,7 +1479,7 @@ TEST_F(PolicyEngineTest, LicenseExpired_SoftEnforceLoadAfterExpire) {
EXPECT_CALL(crypto_session_, GetHdcpCapabilities(_, _))
.WillRepeatedly(
DoAll(SetArgPointee<0>(HDCP_NO_DIGITAL_OUTPUT),
Return(false)));
Return(GET_HDCP_CAPABILITY_FAILED)));
InSequence seq;
ExpectSessionKeysChange(kKeyStatusUsable, true);
@@ -1512,7 +1513,7 @@ TEST_F(PolicyEngineTest, PlaybackOk_GracePeriod) {
EXPECT_CALL(crypto_session_, GetHdcpCapabilities(_, _))
.WillRepeatedly(
DoAll(SetArgPointee<0>(HDCP_NO_DIGITAL_OUTPUT),
Return(false)));
Return(GET_HDCP_CAPABILITY_FAILED)));
InSequence seq;
ExpectSessionKeysChange(kKeyStatusUsable, true);
@@ -1556,7 +1557,7 @@ TEST_F(PolicyEngineTest, PlaybackOk_GracePeriodWithLoad) {
EXPECT_CALL(crypto_session_, GetHdcpCapabilities(_, _))
.WillRepeatedly(
DoAll(SetArgPointee<0>(HDCP_NO_DIGITAL_OUTPUT),
Return(false)));
Return(GET_HDCP_CAPABILITY_FAILED)));
InSequence seq;
ExpectSessionKeysChange(kKeyStatusUsable, true);
@@ -1599,7 +1600,7 @@ TEST_F(PolicyEngineTest, PlaybackOk_GracePeriodWithExpiredLoad) {
EXPECT_CALL(crypto_session_, GetHdcpCapabilities(_, _))
.WillRepeatedly(
DoAll(SetArgPointee<0>(HDCP_NO_DIGITAL_OUTPUT),
Return(false)));
Return(GET_HDCP_CAPABILITY_FAILED)));
InSequence seq;
ExpectSessionKeysChange(kKeyStatusUsable, true);
@@ -1631,7 +1632,7 @@ TEST_F(PolicyEngineTest, PlaybackOk_CanStoreGracePeriod) {
EXPECT_CALL(crypto_session_, GetHdcpCapabilities(_, _))
.WillRepeatedly(
DoAll(SetArgPointee<0>(HDCP_NO_DIGITAL_OUTPUT),
Return(false)));
Return(GET_HDCP_CAPABILITY_FAILED)));
InSequence seq;
ExpectSessionKeysChange(kKeyStatusUsable, true);
@@ -1842,7 +1843,7 @@ TEST_F(PolicyEngineKeyAllowedUsageTest, AllowedUsageBasic) {
EXPECT_CALL(crypto_session_, GetHdcpCapabilities(_, _))
.WillRepeatedly(
DoAll(SetArgPointee<0>(HDCP_NO_DIGITAL_OUTPUT),
Return(false)));
Return(GET_HDCP_CAPABILITY_FAILED)));
ExpectSessionKeysChange(kKeyStatusUsable, kKeyStatusUsable, true);
EXPECT_CALL(mock_event_listener_, OnExpirationUpdate(_, _));
@@ -1902,7 +1903,7 @@ TEST_F(PolicyEngineKeyAllowedUsageTest, AllowedUsageGeneric) {
EXPECT_CALL(crypto_session_, GetHdcpCapabilities(_, _))
.WillRepeatedly(
DoAll(SetArgPointee<0>(HDCP_NO_DIGITAL_OUTPUT),
Return(false)));
Return(GET_HDCP_CAPABILITY_FAILED)));
ExpectSessionKeysChange(kKeyStatusUsable, kKeyStatusUsable, true);
EXPECT_CALL(mock_event_listener_, OnExpirationUpdate(_, _));
@@ -1970,7 +1971,7 @@ TEST_F(PolicyEngineQueryTest, QuerySuccess) {
EXPECT_CALL(crypto_session_, GetHdcpCapabilities(_, _))
.WillRepeatedly(
DoAll(SetArgPointee<0>(HDCP_NO_DIGITAL_OUTPUT),
Return(false)));
Return(GET_HDCP_CAPABILITY_FAILED)));
policy_engine_->SetLicense(license_);
@@ -1997,7 +1998,7 @@ TEST_F(PolicyEngineQueryTest, QuerySuccess_PlaybackNotBegun) {
EXPECT_CALL(crypto_session_, GetHdcpCapabilities(_, _))
.WillRepeatedly(
DoAll(SetArgPointee<0>(HDCP_NO_DIGITAL_OUTPUT),
Return(false)));
Return(GET_HDCP_CAPABILITY_FAILED)));
policy_engine_->SetLicense(license_);
@@ -2038,7 +2039,7 @@ TEST_F(PolicyEngineQueryTest, QuerySuccess_PlaybackBegun) {
EXPECT_CALL(crypto_session_, GetHdcpCapabilities(_, _))
.WillRepeatedly(
DoAll(SetArgPointee<0>(HDCP_NO_DIGITAL_OUTPUT),
Return(true)));
Return(GET_HDCP_CAPABILITY_FAILED)));
policy_engine_->SetLicense(license_);
@@ -2092,7 +2093,7 @@ TEST_F(PolicyEngineQueryTest, QuerySuccess_Offline) {
EXPECT_CALL(crypto_session_, GetHdcpCapabilities(_, _))
.WillRepeatedly(
DoAll(SetArgPointee<0>(HDCP_NO_DIGITAL_OUTPUT),
Return(false)));
Return(GET_HDCP_CAPABILITY_FAILED)));
policy_engine_->SetLicense(license_);
@@ -2179,7 +2180,7 @@ TEST_F(PolicyEngineQueryTest, QuerySuccess_CanPlayFalse) {
EXPECT_CALL(crypto_session_, GetHdcpCapabilities(_, _))
.WillRepeatedly(
DoAll(SetArgPointee<0>(HDCP_NO_DIGITAL_OUTPUT),
Return(false)));
Return(GET_HDCP_CAPABILITY_FAILED)));
policy_engine_->SetLicense(license_);
EXPECT_FALSE(policy_engine_->CanDecryptContent(kKeyId));
@@ -2219,7 +2220,7 @@ TEST_F(PolicyEngineQueryTest, QuerySuccess_RentalDurationExpired) {
EXPECT_CALL(crypto_session_, GetHdcpCapabilities(_, _))
.WillRepeatedly(
DoAll(SetArgPointee<0>(HDCP_NO_DIGITAL_OUTPUT),
Return(false)));
Return(GET_HDCP_CAPABILITY_FAILED)));
policy_engine_->SetLicense(license_);
@@ -2262,7 +2263,7 @@ TEST_F(PolicyEngineQueryTest, QuerySuccess_PlaybackDurationExpired) {
EXPECT_CALL(crypto_session_, GetHdcpCapabilities(_, _))
.WillRepeatedly(
DoAll(SetArgPointee<0>(HDCP_NO_DIGITAL_OUTPUT),
Return(false)));
Return(GET_HDCP_CAPABILITY_FAILED)));
policy_engine_->SetLicense(license_);
@@ -2301,7 +2302,7 @@ TEST_F(PolicyEngineQueryTest, QuerySuccess_LicenseDurationExpired) {
EXPECT_CALL(crypto_session_, GetHdcpCapabilities(_, _))
.WillRepeatedly(
DoAll(SetArgPointee<0>(HDCP_NO_DIGITAL_OUTPUT),
Return(false)));
Return(GET_HDCP_CAPABILITY_FAILED)));
policy_engine_->SetLicense(license_);
@@ -2344,7 +2345,7 @@ TEST_F(PolicyEngineQueryTest, QuerySuccess_RentalDuration0) {
EXPECT_CALL(crypto_session_, GetHdcpCapabilities(_, _))
.WillRepeatedly(
DoAll(SetArgPointee<0>(HDCP_NO_DIGITAL_OUTPUT),
Return(false)));
Return(GET_HDCP_CAPABILITY_FAILED)));
policy_engine_->SetLicense(license_);
@@ -2390,7 +2391,7 @@ TEST_F(PolicyEngineQueryTest, QuerySuccess_PlaybackDuration0) {
EXPECT_CALL(crypto_session_, GetHdcpCapabilities(_, _))
.WillRepeatedly(
DoAll(SetArgPointee<0>(HDCP_NO_DIGITAL_OUTPUT),
Return(false)));
Return(GET_HDCP_CAPABILITY_FAILED)));
policy_engine_->SetLicense(license_);
@@ -2447,7 +2448,7 @@ TEST_F(PolicyEngineQueryTest, QuerySuccess_LicenseDuration0) {
EXPECT_CALL(crypto_session_, GetHdcpCapabilities(_, _))
.WillRepeatedly(
DoAll(SetArgPointee<0>(HDCP_NO_DIGITAL_OUTPUT),
Return(false)));
Return(GET_HDCP_CAPABILITY_FAILED)));
policy_engine_->SetLicense(license_);
@@ -2786,7 +2787,7 @@ TEST_F(PolicyEngineQueryTest, QuerySuccess_Durations0) {
EXPECT_CALL(crypto_session_, GetHdcpCapabilities(_, _))
.WillRepeatedly(
DoAll(SetArgPointee<0>(HDCP_NO_DIGITAL_OUTPUT),
Return(false)));
Return(GET_HDCP_CAPABILITY_FAILED)));
policy_engine_->SetLicense(license_);
@@ -2824,7 +2825,7 @@ TEST_F(PolicyEngineQueryTest, QuerySuccess_LicenseWithFutureStartTime) {
EXPECT_CALL(crypto_session_, GetHdcpCapabilities(_, _))
.WillRepeatedly(
DoAll(SetArgPointee<0>(HDCP_NO_DIGITAL_OUTPUT),
Return(false)));
Return(GET_HDCP_CAPABILITY_FAILED)));
policy_engine_->SetLicense(license_);
@@ -2880,7 +2881,7 @@ TEST_F(PolicyEngineQueryTest, QuerySuccess_Renew) {
EXPECT_CALL(crypto_session_, GetHdcpCapabilities(_, _))
.WillRepeatedly(
DoAll(SetArgPointee<0>(HDCP_NO_DIGITAL_OUTPUT),
Return(false)));
Return(GET_HDCP_CAPABILITY_FAILED)));
policy_engine_->SetLicense(license_);
@@ -2938,7 +2939,7 @@ TEST_F(PolicyEngineQueryTest, QuerySuccess_RenewWithFutureStartTime) {
EXPECT_CALL(crypto_session_, GetHdcpCapabilities(_, _))
.WillRepeatedly(
DoAll(SetArgPointee<0>(HDCP_NO_DIGITAL_OUTPUT),
Return(false)));
Return(GET_HDCP_CAPABILITY_FAILED)));
policy_engine_->SetLicense(license_);
@@ -3018,7 +3019,7 @@ TEST_F(PolicyEngineTest, SetLicenseForReleaseAfterSetLicense) {
EXPECT_CALL(crypto_session_, GetHdcpCapabilities(_, _))
.WillRepeatedly(
DoAll(SetArgPointee<0>(HDCP_NO_DIGITAL_OUTPUT),
Return(false)));
Return(GET_HDCP_CAPABILITY_FAILED)));
policy_engine_->SetLicense(license_);
policy_engine_->BeginDecryption();

View File

@@ -186,13 +186,15 @@ TestCryptoSession::TestCryptoSession(metrics::CryptoMetrics* crypto_metrics)
}
}
bool TestCryptoSession::GenerateNonce(uint32_t* nonce) {
for (int i = 0; !CryptoSession::GenerateNonce(nonce); i++) {
CdmResponseType TestCryptoSession::GenerateNonce(uint32_t* nonce) {
CdmResponseType status = CryptoSession::GenerateNonce(nonce);
for (int i = 0; status != NO_ERROR; i++) {
LOGV("Recovering from nonce flood.");
if (i > 2) return false;
if (i > 2) return status;
sleep(1);
status = CryptoSession::GenerateNonce(nonce);
}
return true;
return NO_ERROR;
}
class TestCryptoSessionFactory : public CryptoSessionFactory {

View File

@@ -71,7 +71,7 @@ class TestCryptoSession : public CryptoSession {
explicit TestCryptoSession(metrics::CryptoMetrics* crypto_metrics);
// This intercepts nonce flood errors, which is useful for tests that request
// many nonces and are not time critical.
bool GenerateNonce(uint32_t* nonce);
CdmResponseType GenerateNonce(uint32_t* nonce);
};
// A holder for a license. Users of this class will first open a session with

View File

@@ -46,9 +46,6 @@ void PrintTo(const enum CdmResponseType& value, ::std::ostream* os) {
case CERT_PROVISIONING_GET_KEYBOX_ERROR_1:
*os << "CERT_PROVISIONING_GET_KEYBOX_ERROR_1";
break;
case CERT_PROVISIONING_GET_KEYBOX_ERROR_2:
*os << "CERT_PROVISIONING_GET_KEYBOX_ERROR_2";
break;
case CERT_PROVISIONING_INVALID_CERT_TYPE:
*os << "CERT_PROVISIONING_INVALID_CERT_TYPE";
break;
@@ -58,9 +55,6 @@ void PrintTo(const enum CdmResponseType& value, ::std::ostream* os) {
case CERT_PROVISIONING_NONCE_GENERATION_ERROR:
*os << "CERT_PROVISIONING_NONCE_GENERATION_ERROR";
break;
case CERT_PROVISIONING_REQUEST_ERROR_3:
*os << "CERT_PROVISIONING_REQUEST_ERROR_3";
break;
case CERT_PROVISIONING_REQUEST_ERROR_4:
*os << "CERT_PROVISIONING_REQUEST_ERROR_4";
break;
@@ -325,9 +319,6 @@ void PrintTo(const enum CdmResponseType& value, ::std::ostream* os) {
case RENEW_KEY_ERROR_2:
*os << "RENEW_KEY_ERROR_2";
break;
case LICENSE_RENEWAL_SIGNING_ERROR:
*os << "LICENSE_RENEWAL_SIGNING_ERROR";
break;
case RESTORE_OFFLINE_LICENSE_ERROR_2:
*os << "RESTORE_OFFLINE_LICENSE_ERROR_2";
break;
@@ -451,9 +442,6 @@ void PrintTo(const enum CdmResponseType& value, ::std::ostream* os) {
case LICENSE_REQUEST_NONCE_GENERATION_ERROR:
*os << "LICENSE_REQUEST_NONCE_GENERATION_ERROR";
break;
case LICENSE_REQUEST_SIGNING_ERROR:
*os << "LICENSE_REQUEST_SIGNING_ERROR";
break;
case EMPTY_LICENSE_REQUEST:
*os << "EMPTY_LICENSE_REQUEST";
break;
@@ -553,9 +541,6 @@ void PrintTo(const enum CdmResponseType& value, ::std::ostream* os) {
case CLIENT_IDENTIFICATION_TOKEN_ERROR_1:
*os << "CLIENT_IDENTIFICATION_TOKEN_ERROR_1";
break;
case CLIENT_IDENTIFICATION_TOKEN_ERROR_2:
*os << "CLIENT_IDENTIFICATION_TOKEN_ERROR_2";
break;
case ANALOG_OUTPUT_ERROR:
*os << "ANALOG_OUTPUT_ERROR";
break;
@@ -834,12 +819,100 @@ void PrintTo(const enum CdmResponseType& value, ::std::ostream* os) {
break;
case SESSION_KEYS_NOT_FOUND_2:
*os << "SESSION_KEYS_NOT_FOUND_2";
break;
case REMOVE_OFFLINE_LICENSE_ERROR_1:
*os << "REMOVE_OFFLINE_LICENSE_ERROR_1";
break;
case REMOVE_OFFLINE_LICENSE_ERROR_2:
*os << "REMOVE_OFFLINE_LICENSE_ERROR_2";
break;
case OUTPUT_TOO_LARGE_ERROR:
*os << "OUTPUT_TOO_LARGE_ERROR";
break;
case SESSION_LOST_STATE_ERROR:
*os << "SESSION_LOST_STATE_ERROR";
break;
case GENERATE_DERIVED_KEYS_ERROR_2:
*os << "GENERATE_DERIVED_KEYS_ERROR_2";
break;
case LOAD_DEVICE_RSA_KEY_ERROR:
*os << "LOAD_DEVICE_RSA_KEY_ERROR";
break;
case NONCE_GENERATION_ERROR:
*os << "NONCE_GENERATION_ERROR";
break;
case GENERATE_SIGNATURE_ERROR:
*os << "GENERATE_SIGNATURE_ERROR";
break;
case UNKNOWN_CLIENT_TOKEN_TYPE:
*os << "UNKNOWN_CLIENT_TOKEN_TYPE";
break;
case DEACTIVATE_USAGE_ENTRY_ERROR:
*os << "DEACTIVATE_USAGE_ENTRY_ERROR";
break;
case SYSTEM_INVALIDATED_ERROR:
*os << "SYSTEM_INVALIDATED_ERROR";
break;
case OPEN_CRYPTO_SESSION_ERROR:
*os << "OPEN_CRYPTO_SESSION_ERROR";
break;
case LOAD_SRM_ERROR:
*os << "LOAD_SRM_ERROR";
break;
case RANDOM_GENERATION_ERROR:
*os << "RANDOM_GENERATION_ERROR";
break;
case CRYPTO_SESSION_NOT_INITIALIZED:
*os << "CRYPTO_SESSION_NOT_INITIALIZED";
break;
case GET_DEVICE_ID_ERROR:
*os << "GET_DEVICE_ID_ERROR";
break;
case GET_TOKEN_FROM_OEM_CERT_ERROR:
*os << "GET_TOKEN_FROM_OEM_CERT_ERROR";
break;
case CRYPTO_SESSION_NOT_OPEN:
*os << "CRYPTO_SESSION_NOT_OPEN";
break;
case GET_TOKEN_FROM_KEYBOX_ERROR:
*os << "GET_TOKEN_FROM_KEYBOX_ERROR";
break;
case KEYBOX_TOKEN_TOO_SHORT:
*os << "KEYBOX_TOKEN_TOO_SHORT";
break;
case EXTRACT_SYSTEM_ID_FROM_OEM_CERT_ERROR:
*os << "EXTRACT_SYSTEM_ID_FROM_OEM_CERT_ERROR";
break;
case RSA_SIGNATURE_GENERATION_ERROR:
*os << "RSA_SIGNATURE_GENERATION_ERROR";
break;
case GET_HDCP_CAPABILITY_FAILED:
*os << "GET_HDCP_CAPABILITY_FAILED";
break;
case GET_NUMBER_OF_OPEN_SESSIONS_ERROR:
*os << "GET_NUMBER_OF_OPEN_SESSIONS_ERROR";
break;
case GET_MAX_NUMBER_OF_OPEN_SESSIONS_ERROR:
*os << "GET_MAX_NUMBER_OF_OPEN_SESSIONS_ERROR";
break;
case NOT_IMPLEMENTED_ERROR:
*os << "NOT_IMPLEMENTED_ERROR";
break;
case GET_SRM_VERSION_ERROR:
*os << "GET_SRM_VERSION_ERROR";
break;
case REWRAP_DEVICE_RSA_KEY_ERROR:
*os << "REWRAP_DEVICE_RSA_KEY_ERROR";
break;
case REWRAP_DEVICE_RSA_KEY_30_ERROR:
*os << "REWRAP_DEVICE_RSA_KEY_30_ERROR";
break;
case SERVICE_CERTIFICATE_PROVIDER_ID_EMPTY:
*os << "SERVICE_CERTIFICATE_PROVIDER_ID_EMPTY";
break;
case INVALID_SRM_LIST:
*os << "INVALID_SRM_LIST";
break;
default:
*os << "Unknown CdmResponseType";
break;