Add ATSC support - part 2

[ Merge of http://go/wvgerrit/100905 and http://go/ag/10708438 ]

Add support for ATSC certificate and licenses handling. ATSC
files are distinguished from the apps DRM certificate and licenses
by file naming conventions.

Bug: 139730600
Test: WV unit/integration test, GtsMediaTestCases
Change-Id: I295f66f92fe01d7716978deac9dc360d74addedd
This commit is contained in:
Rahul Frias
2020-03-17 01:35:01 -07:00
parent bbe9f6afc4
commit 8da1145012
8 changed files with 143 additions and 110 deletions

View File

@@ -159,8 +159,12 @@ CdmResponseType CdmSession::Init(CdmClientPropertySet* cdm_client_property_set,
// License server client ID token is a stored certificate. Stage it or
// indicate that provisioning is needed. Get token from stored certificate
std::string wrapped_key;
if (!file_handle_->RetrieveCertificate(&client_token, &wrapped_key,
&serial_number, nullptr)) {
bool atsc_mode_enabled = false;
if (cdm_client_property_set != nullptr)
atsc_mode_enabled = cdm_client_property_set->use_atsc_mode();
if (!file_handle_->RetrieveCertificate(atsc_mode_enabled, &client_token,
&wrapped_key, &serial_number,
nullptr)) {
return NEED_PROVISIONING;
}
CdmResponseType load_cert_sts;
@@ -186,7 +190,7 @@ CdmResponseType CdmSession::Init(CdmClientPropertySet* cdm_client_property_set,
if (forced_session_id) {
key_set_id_ = *forced_session_id;
} else {
bool ok = GenerateKeySetId(&key_set_id_);
bool ok = GenerateKeySetId(atsc_mode_enabled, &key_set_id_);
(void)ok; // ok is now used when assertions are turned off.
assert(ok);
}
@@ -849,7 +853,8 @@ CdmSessionId CdmSession::GenerateSessionId() {
return SESSION_ID_PREFIX + IntToString(++session_num);
}
bool CdmSession::GenerateKeySetId(CdmKeySetId* key_set_id) {
bool CdmSession::GenerateKeySetId(bool atsc_mode_enabled,
CdmKeySetId* key_set_id) {
RETURN_FALSE_IF_NULL(key_set_id);
std::vector<uint8_t> random_data(
@@ -861,7 +866,10 @@ bool CdmSession::GenerateKeySetId(CdmKeySetId* key_set_id) {
return false;
}
*key_set_id = KEY_SET_ID_PREFIX + b2a_hex(random_data);
if (atsc_mode_enabled)
*key_set_id = ATSC_KEY_SET_ID_PREFIX + b2a_hex(random_data);
else
*key_set_id = KEY_SET_ID_PREFIX + b2a_hex(random_data);
// key set collision
if (file_handle_->LicenseExists(*key_set_id)) {

View File

@@ -70,6 +70,7 @@ using video_widevine_client::sdk::
namespace {
const char kAtscCertificateFileName[] = "atsccert.bin";
const char kCertificateFileName[] = "cert.bin";
const char kHlsAttributesFileNameExt[] = ".hal";
const char kUsageInfoFileNamePrefix[] = "usage";
@@ -126,19 +127,21 @@ bool DeviceFiles::StoreCertificate(const std::string& certificate,
std::string serialized_file;
file.SerializeToString(&serialized_file);
return StoreFileWithHash(GetCertificateFileName(), serialized_file) ==
return StoreFileWithHash(GetCertificateFileName(false), serialized_file) ==
kNoError;
}
bool DeviceFiles::RetrieveCertificate(std::string* certificate,
bool DeviceFiles::RetrieveCertificate(bool atsc_mode_enabled,
std::string* certificate,
std::string* wrapped_private_key,
std::string* serial_number,
uint32_t* system_id) {
RETURN_FALSE_IF_UNINITIALIZED();
video_widevine_client::sdk::File file;
if (RetrieveHashedFile(GetCertificateFileName(), &file) != kNoError) {
LOGE("Unable to retrieve certificate file");
if (RetrieveHashedFile(GetCertificateFileName(atsc_mode_enabled), &file) !=
kNoError) {
LOGW("Unable to retrieve certificate file");
return false;
}
@@ -166,14 +169,16 @@ bool DeviceFiles::RetrieveCertificate(std::string* certificate,
device_certificate.certificate(), serial_number, system_id);
}
bool DeviceFiles::HasCertificate() {
bool DeviceFiles::HasCertificate(bool atsc_mode_enabled) {
RETURN_FALSE_IF_UNINITIALIZED();
return FileExists(GetCertificateFileName());
return FileExists(GetCertificateFileName(atsc_mode_enabled));
}
bool DeviceFiles::RemoveCertificate() {
RETURN_FALSE_IF_UNINITIALIZED()
return RemoveFile(GetCertificateFileName());
return RemoveFile(GetCertificateFileName(false));
}
bool DeviceFiles::StoreLicense(const CdmLicenseData& license_data,
@@ -1214,8 +1219,8 @@ ssize_t DeviceFiles::GetFileSize(const std::string& name) {
return file_system_->FileSize(path);
}
std::string DeviceFiles::GetCertificateFileName() {
return kCertificateFileName;
std::string DeviceFiles::GetCertificateFileName(bool atsc_mode_enabled) {
return atsc_mode_enabled ? kAtscCertificateFileName : kCertificateFileName;
}
std::string DeviceFiles::GetUsageTableFileName() { return kUsageTableFileName; }