Delete secure stops by key set ID.

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

Similar to the issue with updating secure stops by PST (see
http://go/wvgerrit/165597), when deleting different secure stops with
the same PST results in unintended behavior.  This CL changes how the
CDM identifies which secure stop to delete from storaged based on the
key set ID rather than the PST.

Bug: 263316107
Test: device_files_unittest
Test: GTS MediaDrmParameterizedTests and MediaDrmStressTest
Change-Id: Ic3843a1435f252f052c7189423c211c28ed74eaa
This commit is contained in:
Alex Dale
2023-02-07 22:32:24 -08:00
parent 080bfc7414
commit 2c05c65138
6 changed files with 16 additions and 23 deletions

View File

@@ -199,7 +199,7 @@ class DeviceFiles {
std::string* provider_session_token);
virtual bool DeleteUsageInfo(const std::string& usage_info_file_name,
const std::string& provider_session_token);
const CdmKeySetId& key_set_id);
// Deletes a set of provider sessions from the specified usage info.
// Sessions removed are based on the provided |key_set_ids|. If

View File

@@ -1685,7 +1685,7 @@ CdmResponseType CdmEngine::RemoveAllUsageInfo(
}
if (!handle.DeleteUsageInfo(DeviceFiles::GetUsageInfoFileName(app_id),
usage_data[0].provider_session_token)) {
usage_data[0].key_set_id)) {
LOGW("Failed to delete usage info");
break;
}
@@ -1737,25 +1737,17 @@ CdmResponseType CdmEngine::RemoveUsageInfo(
new CdmSession(file_system_, metrics_->AddSession()));
usage_session_->Init(usage_property_set_.get());
CdmKeyMessage license_request;
CdmKeyResponse license_response;
UsageEntry usage_entry;
UsageEntryIndex usage_entry_index;
std::string drm_certificate;
CryptoWrappedKey wrapped_private_key;
if (!handle.RetrieveUsageInfo(
DeviceFiles::GetUsageInfoFileName(app_id), provider_session_token,
&license_request, &license_response, &usage_entry,
&usage_entry_index, &drm_certificate, &wrapped_private_key)) {
DeviceFiles::CdmUsageData usage_data;
if (!handle.RetrieveUsageInfo(DeviceFiles::GetUsageInfoFileName(app_id),
provider_session_token, &usage_data)) {
// Try other security level
continue;
}
if (usage_session_->SupportsUsageTable()) {
status = usage_session_->DeleteUsageEntry(usage_entry_index);
status = usage_session_->DeleteUsageEntry(usage_data.usage_entry_index);
if (!handle.DeleteUsageInfo(DeviceFiles::GetUsageInfoFileName(app_id),
provider_session_token)) {
usage_data.key_set_id)) {
status = CdmResponseType(REMOVE_USAGE_INFO_ERROR_1);
}
usage_session_.reset();

View File

@@ -1025,8 +1025,7 @@ bool CdmSession::DeleteLicenseFile() {
std::string app_id;
GetApplicationId(&app_id);
return file_handle_->DeleteUsageInfo(
DeviceFiles::GetUsageInfoFileName(app_id),
license_parser_->provider_session_token());
DeviceFiles::GetUsageInfoFileName(app_id), key_set_id_);
}
}

View File

@@ -824,7 +824,7 @@ CdmResponseType CdmUsageTable::StoreEntry(UsageEntryIndex entry_index,
}
device_files->DeleteUsageInfo(
entry_info_list_[entry_index].usage_info_file_name,
provider_session_token);
entry_info_list_[entry_index].key_set_id);
if (!device_files->StoreUsageInfo(
provider_session_token, key_request, key_response,
entry_info_list_[entry_index].usage_info_file_name,

View File

@@ -1128,7 +1128,7 @@ bool DeviceFiles::GetProviderSessionToken(const std::string& app_id,
}
bool DeviceFiles::DeleteUsageInfo(const std::string& usage_info_file_name,
const std::string& provider_session_token) {
const CdmKeySetId& key_set_id) {
RETURN_FALSE_IF_UNINITIALIZED();
video_widevine_client::sdk::File file;
if (RetrieveHashedFile(usage_info_file_name, &file) != kNoError) {
@@ -1140,17 +1140,19 @@ bool DeviceFiles::DeleteUsageInfo(const std::string& usage_info_file_name,
int index = 0;
bool found = false;
for (; index < usage_info->sessions_size(); ++index) {
if (usage_info->sessions(index).token() == provider_session_token) {
const auto& session = usage_info->sessions(index);
if (session.key_set_id() == key_set_id) {
found = true;
break;
}
}
if (!found) {
LOGE("Unable to find provider session token: pst = %s",
wvutil::b2a_hex(provider_session_token).c_str());
LOGE("Unable to find usage info: key_set_id = %s", IdToString(key_set_id));
return false;
}
LOGD("Deleting usage info: key_set_id = %s, pst = %s", IdToString(key_set_id),
wvutil::b2a_hex(usage_info->sessions(index).token()).c_str());
google::protobuf::RepeatedPtrField<UsageInfo_ProviderSession>* sessions =
usage_info->mutable_sessions();

View File

@@ -394,7 +394,7 @@ class MockDeviceFiles : public DeviceFiles {
MOCK_METHOD(bool, StoreUsageTableInfo,
(const UsageTableHeader&, const std::vector<CdmUsageEntryInfo>&),
(override));
MOCK_METHOD(bool, DeleteUsageInfo, (const std::string&, const std::string&),
MOCK_METHOD(bool, DeleteUsageInfo, (const std::string&, const CdmKeySetId&),
(override));
MOCK_METHOD(bool, DeleteMultipleUsageInfoByKeySetIds,
(const std::string&, const std::vector<std::string>&),