Revise usage entry metadata

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

In OEMCrypto V13, usage table header and usage entries are stored in
persistent non-secure storage and loaded and unloaded from the TEE.
Information needs to be maintained to assist finding the associated license
or usage information. This information has been revised for usage information
to use key set id and usage info file name rather than provider session
token and app id.

The app id is stored in a hashed form (usage info file name) and was not
extractable during the upgrade process to OEMCrypto V13. Due to this
DeviceFiles UsageInfo routines have switched to use usage info file name
rather than app id as a key.

b/34327459

Test: Verified by unit/integration tests on angler
Change-Id: I95aa0435d0955c61fc45b951f5b5d44de2ba5cfc
This commit is contained in:
Rahul Frias
2017-02-07 10:41:02 -08:00
parent b384408dd2
commit e75d3a6512
9 changed files with 279 additions and 153 deletions

View File

@@ -1056,7 +1056,8 @@ CdmResponseType CdmEngine::GetUsageInfo(const std::string& app_id,
CdmKeyResponse license_response;
std::string usage_entry;
uint32_t usage_entry_number = 0;
if (!handle.RetrieveUsageInfo(app_id, ssid, &license_request,
if (!handle.RetrieveUsageInfo(DeviceFiles::GetUsageInfoFileName(app_id),
ssid, &license_request,
&license_response, &usage_entry,
&usage_entry_number)) {
usage_property_set_->set_security_level(kLevel3);
@@ -1071,7 +1072,8 @@ CdmResponseType CdmEngine::GetUsageInfo(const std::string& app_id,
LOGE("CdmEngine::GetUsageInfo: device file init error");
return GET_USAGE_INFO_ERROR_2;
}
if (!handle.RetrieveUsageInfo(app_id, ssid, &license_request,
if (!handle.RetrieveUsageInfo(DeviceFiles::GetUsageInfoFileName(app_id),
ssid, &license_request,
&license_response, &usage_entry,
&usage_entry_number)) {
// No entry found for that ssid.
@@ -1151,7 +1153,8 @@ CdmResponseType CdmEngine::GetUsageInfo(const std::string& app_id,
}
std::vector<std::pair<CdmKeyMessage, CdmKeyResponse> > license_info;
if (!handle.RetrieveUsageInfo(app_id, &license_info)) {
if (!handle.RetrieveUsageInfo(DeviceFiles::GetUsageInfoFileName(app_id),
&license_info)) {
LOGE("CdmEngine::GetUsageInfo: unable to read usage information");
return GET_USAGE_INFO_ERROR_4;
}
@@ -1210,7 +1213,9 @@ CdmResponseType CdmEngine::ReleaseAllUsageInfo(const std::string& app_id) {
DeviceFiles handle(file_system_);
if (handle.Init(static_cast<CdmSecurityLevel>(j))) {
std::vector<std::string> provider_session_tokens;
if (!handle.DeleteAllUsageInfoForApp(app_id, &provider_session_tokens)) {
if (!handle.DeleteAllUsageInfoForApp(
DeviceFiles::GetUsageInfoFileName(app_id),
&provider_session_tokens)) {
LOGE("CdmEngine::ReleaseAllUsageInfo: failed to delete L%d secure"
"stops", j);
status = RELEASE_ALL_USAGE_INFO_ERROR_1;
@@ -1291,10 +1296,10 @@ CdmResponseType CdmEngine::LoadUsageSession(const CdmKeySetId& key_set_id,
CdmKeyResponse key_response;
std::string usage_entry;
uint32_t usage_entry_number = 0;
if (!handle.RetrieveUsageInfoByKeySetId(app_id, key_set_id,
&provider_session_token, &key_message,
&key_response, &usage_entry,
&usage_entry_number)) {
if (!handle.RetrieveUsageInfoByKeySetId(
DeviceFiles::GetUsageInfoFileName(app_id), key_set_id,
&provider_session_token, &key_message, &key_response,
&usage_entry, &usage_entry_number)) {
LOGE("CdmEngine::LoadUsageSession: unable to find usage information");
return LOAD_USAGE_INFO_MISSING;
}