Consolidate provisioning related protobuf parsing
[ Merge of http://go/wvgerrit/87905 ] Protobuf parsing of the provisioning message has been centralized in certificate_provisioning.cpp since it will be invoked from multiple locations. This will also ease maintainability of the code. Bug: 142731300 Test: android unit/integration tests Change-Id: Idebf6b0145b317698559cac1cf18a3a0b98315ad
This commit is contained in:
@@ -8,6 +8,7 @@
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "certificate_provisioning.h"
|
||||
#include "file_store.h"
|
||||
#include "license_protocol.pb.h"
|
||||
#include "log.h"
|
||||
@@ -37,9 +38,6 @@ using video_widevine_client::sdk::
|
||||
using video_widevine_client::sdk::
|
||||
UsageTableInfo_UsageEntryInfo_UsageEntryStorage_USAGE_INFO;
|
||||
|
||||
using video_widevine::DrmDeviceCertificate;
|
||||
using video_widevine::SignedDrmDeviceCertificate;
|
||||
|
||||
// Stringify turns macro arguments into static C strings.
|
||||
// Example: STRINGIFY(this_argument) -> "this_argument"
|
||||
#define STRINGIFY(PARAM...) #PARAM
|
||||
@@ -164,41 +162,8 @@ bool DeviceFiles::RetrieveCertificate(std::string* certificate,
|
||||
DeviceCertificate device_certificate = file.device_certificate();
|
||||
*certificate = device_certificate.certificate();
|
||||
*wrapped_private_key = device_certificate.wrapped_private_key();
|
||||
return ExtractDeviceInfo(device_certificate.certificate(), serial_number,
|
||||
system_id);
|
||||
}
|
||||
|
||||
bool DeviceFiles::ExtractDeviceInfo(const std::string& device_certificate,
|
||||
std::string* serial_number,
|
||||
uint32_t* system_id) {
|
||||
LOGV("Extracting device info");
|
||||
if (serial_number == nullptr && system_id == nullptr) {
|
||||
LOGE("Output parameters |serial_number| and |system_id| not provided");
|
||||
return false;
|
||||
}
|
||||
|
||||
// Get serial number and system ID from certificate
|
||||
SignedDrmDeviceCertificate signed_drm_device_certificate;
|
||||
if (!signed_drm_device_certificate.ParseFromString(device_certificate) ||
|
||||
!signed_drm_device_certificate.has_drm_certificate()) {
|
||||
LOGE("Failed to parse signed DRM device certificate");
|
||||
return false;
|
||||
}
|
||||
DrmDeviceCertificate drm_device_certificate;
|
||||
if (!drm_device_certificate.ParseFromString(
|
||||
signed_drm_device_certificate.drm_certificate()) ||
|
||||
(drm_device_certificate.type() !=
|
||||
video_widevine::DrmDeviceCertificate::DRM_USER_DEVICE)) {
|
||||
LOGE("Failed to parse DRM device certificate message");
|
||||
return false;
|
||||
}
|
||||
if (serial_number != nullptr) {
|
||||
*serial_number = drm_device_certificate.serial_number();
|
||||
}
|
||||
if (system_id != nullptr) {
|
||||
*system_id = drm_device_certificate.system_id();
|
||||
}
|
||||
return true;
|
||||
return CertificateProvisioning::ExtractDeviceInfo(
|
||||
device_certificate.certificate(), serial_number, system_id);
|
||||
}
|
||||
|
||||
bool DeviceFiles::HasCertificate() {
|
||||
|
||||
Reference in New Issue
Block a user