Added an OTA keybox provisioner.
[ Merge of http://go/wvgerrit/133729 ] The OtaKeyboxProvisioner is a system-wide provisioner for sharing the provisioning workflow between CDM engines. Bug: 189232882 Test: GtsMediaTestCases Change-Id: I873af3087cc05e1831bdd1d2c14fb002b73e6902 Added keybox provisioning proto fields. [ Merge of http://go/wvgerrit/133730 and http://go/ag/15113032 ] This CL copies over the required license_protocol.proto changes that are required for OTA keybox provisioning. These fields are defined in the server-side certificate_provisioning.proto, defined in http://cl/377533774. Note, changes are slightly different from server proto due to the RVC version of license_protocol.proto being out of date with SC and newer changes. Bug: 189232882 Test: run_x86_64_tests Change-Id: I55fcf6a7ac2ba4b6026b9acc63e822ff33c431d9 Added OTA keybox provisioning device files. [ Merge of http://go/wvgerrit/133743 and http://go/ag/15421141 ] This change adds a new set of proto messages/fields the CDM's device files for recording device and engine information around OTA keybox provisioning (OKP). To make cleanup and thread protection possible, there is a single file which will contain all the information for the device as a whole and each CDM engine tied to an app/origin. Bug: 189232882 Test: Linux unit tests Change-Id: Iaf80cd6342f32657e04416750d9b278d935821a5 Client ID for OKP requests. [ Merge of http://go/wvgerrit/133744 and http://go/ag/15645331 ] Extended the CDM ClientIdentification class to support a subset of client info used for OKP requests. Bug: 189232882 Test: Android unit tests Merged-In: I6aafb4f2164efe69bc733ece0a912f0e91893b91 Change-Id: I6aafb4f2164efe69bc733ece0a912f0e91893b91
This commit is contained in:
@@ -67,6 +67,11 @@ class CertificateProvisioning {
|
||||
static bool ExtractAndDecodeSignedMessageForTesting(
|
||||
const std::string& provisioning_response, std::string* result);
|
||||
|
||||
// Retrieve the provisioning server URL used for certificate
|
||||
// provisioning. This will be the same value as returned in
|
||||
// |default_url| by GetProvisioningRequest().
|
||||
static void GetProvisioningServerUrl(std::string* default_url);
|
||||
|
||||
private:
|
||||
CdmResponseType GetProvisioningRequestInternal(
|
||||
SecurityLevel requested_security_level, CdmCertificateType cert_type,
|
||||
|
||||
@@ -5,33 +5,35 @@
|
||||
#ifndef WVCDM_CORE_CLIENT_IDENTIFICATION_H_
|
||||
#define WVCDM_CORE_CLIENT_IDENTIFICATION_H_
|
||||
|
||||
#include <string>
|
||||
|
||||
// ClientIdentification fills in the ClientIdentification portion
|
||||
// of the License or Provisioning request messages.
|
||||
|
||||
#include "disallow_copy_and_assign.h"
|
||||
#include "license_protocol.pb.h"
|
||||
#include "wv_cdm_types.h"
|
||||
|
||||
namespace wvcdm {
|
||||
|
||||
class CryptoSession;
|
||||
|
||||
class ClientIdentification {
|
||||
public:
|
||||
ClientIdentification() : is_license_request_(true) {}
|
||||
ClientIdentification() {}
|
||||
virtual ~ClientIdentification() {}
|
||||
|
||||
// Call this method when used with provisioning requests
|
||||
CdmResponseType Init(CryptoSession* crypto_session);
|
||||
CdmResponseType InitForProvisioning(CryptoSession* crypto_session);
|
||||
|
||||
// Use in conjunction with license requests
|
||||
// |client_token| must be provided
|
||||
// |crypto_session| input parameter, mandatory
|
||||
CdmResponseType Init(const std::string& client_token,
|
||||
CryptoSession* crypto_session);
|
||||
CdmResponseType InitForLicenseRequest(const std::string& client_token,
|
||||
CryptoSession* crypto_session);
|
||||
|
||||
// Fill the ClientIdentification portion of the license or provisioning
|
||||
// request
|
||||
CdmResponseType InitForOtaKeyboxProvisioning(CryptoSession* crypto_session);
|
||||
|
||||
// Fill the ClientIdentification portion of the license, DRM cert
|
||||
// provisioning or OTA keybox provisioning request.
|
||||
// |app_parameters| parameters provided by client/app to be included in
|
||||
// provisioning/license request. optional, only used
|
||||
// if |is_license_request| is true
|
||||
@@ -49,13 +51,13 @@ class ClientIdentification {
|
||||
bool GetProvisioningTokenType(
|
||||
video_widevine::ClientIdentification::TokenType* token_type);
|
||||
|
||||
bool is_license_request_;
|
||||
bool is_license_request_ = false;
|
||||
bool is_okp_request_ = false;
|
||||
std::string client_token_;
|
||||
CryptoSession* crypto_session_;
|
||||
std::string device_id_;
|
||||
CryptoSession* crypto_session_ = nullptr;
|
||||
|
||||
CORE_DISALLOW_COPY_AND_ASSIGN(ClientIdentification);
|
||||
};
|
||||
|
||||
} // namespace wvcdm
|
||||
|
||||
#endif // WVCDM_CORE_CLIENT_IDENTIFICATION_H_
|
||||
|
||||
@@ -26,6 +26,7 @@ namespace wvcdm {
|
||||
|
||||
class CryptoKey;
|
||||
class CryptoSessionFactory;
|
||||
class OtaKeyboxProvisioner;
|
||||
class UsageTableHeader;
|
||||
|
||||
using CryptoKeyMap = std::map<std::string, CryptoKey*>;
|
||||
@@ -41,6 +42,7 @@ OEMCrypto_Substring GetSubstring(const std::string& message = "",
|
||||
bool set_zero = false);
|
||||
OEMCryptoCipherMode ToOEMCryptoCipherMode(CdmCipherMode cipher_mode);
|
||||
|
||||
|
||||
class CryptoSession {
|
||||
public:
|
||||
using HdcpCapability = OEMCrypto_HDCP_Capability;
|
||||
@@ -288,7 +290,14 @@ class CryptoSession {
|
||||
SecurityLevel requested_security_level, CdmClientTokenType* token_type);
|
||||
|
||||
// OTA Provisioning
|
||||
// TODO(sigquit): include rest of http://go/wvgerrit/126004
|
||||
|
||||
bool needs_keybox_provisioning() const { return needs_keybox_provisioning_; }
|
||||
|
||||
// Returns a system-wide singleton instance of OtaKeyboxProvisioner
|
||||
// to be used for OTA provisioning requests/responses across apps.
|
||||
// Returns a null pointer if OTA provisioning is NOT supported, or
|
||||
// if the device has already been provisioned.
|
||||
virtual OtaKeyboxProvisioner* GetOtaKeyboxProvisioner();
|
||||
|
||||
// Generates an OTA provisioning request.
|
||||
// This should only be called by an instance of OtaKeyboxProvisioner.
|
||||
@@ -504,6 +513,11 @@ class CryptoSession {
|
||||
static std::mutex factory_mutex_;
|
||||
static std::unique_ptr<CryptoSessionFactory> factory_;
|
||||
|
||||
// A singleton instance of OtaKeyboxProvisioner. Only one will
|
||||
// be created for the system if OTA keybox provisioning is both
|
||||
// required and supported by L1.
|
||||
static std::unique_ptr<OtaKeyboxProvisioner> ota_keybox_provisioner_l1_;
|
||||
|
||||
CORE_DISALLOW_COPY_AND_ASSIGN(CryptoSession);
|
||||
}; // class CryptoSession
|
||||
|
||||
|
||||
68
libwvdrmengine/cdm/core/include/ota_keybox_provisioner.h
Normal file
68
libwvdrmengine/cdm/core/include/ota_keybox_provisioner.h
Normal file
@@ -0,0 +1,68 @@
|
||||
// Copyright 2021 Google LLC. All Rights Reserved. This file and proprietary
|
||||
// source code may only be used and distributed under the Widevine License
|
||||
// Agreement.
|
||||
#ifndef WVCDM_CORE_OTA_KEYBOX_PROVISIONER_H_
|
||||
#define WVCDM_CORE_OTA_KEYBOX_PROVISIONER_H_
|
||||
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
#include <string>
|
||||
|
||||
#include "disallow_copy_and_assign.h"
|
||||
#include "wv_cdm_types.h"
|
||||
|
||||
namespace wvcdm {
|
||||
class CryptoSession;
|
||||
|
||||
// Wrapper around an OEMCrypto system-wide OTA keybox provisioning
|
||||
// workflow.
|
||||
class OtaKeyboxProvisioner {
|
||||
public:
|
||||
// Creates a new OTA keybox provisioner. This should only be
|
||||
// created once and object ownership belongs to the CryptoSession
|
||||
// module.
|
||||
static std::unique_ptr<OtaKeyboxProvisioner> Create();
|
||||
|
||||
~OtaKeyboxProvisioner();
|
||||
|
||||
// === Request/response API ===
|
||||
|
||||
// Returns true if a provisioning response has been provided
|
||||
// and accepted by OEMCrytpo.
|
||||
bool IsProvisioned() const { return is_provisioned_; }
|
||||
|
||||
uint32_t request_count() const { return request_count_; }
|
||||
uint32_t response_count() const { return response_count_; }
|
||||
|
||||
// Generates an OTA provisioning request.
|
||||
// Generating a request will succeed so long as OTA provisioning
|
||||
// is supported and no valid response has been provided.
|
||||
CdmResponseType GenerateProvisioningRequest(CryptoSession* crypto_session,
|
||||
std::string* request);
|
||||
|
||||
// Accepts a provisioning response from the OTA provisioning
|
||||
// server. The first response which is successfully loaded is
|
||||
// is used. Any subsequent response after the first successful
|
||||
// response is silently discarded.
|
||||
CdmResponseType HandleProvisioningResponse(CryptoSession* crypto_session,
|
||||
const std::string& response);
|
||||
|
||||
private:
|
||||
OtaKeyboxProvisioner();
|
||||
|
||||
bool is_provisioned_ = false;
|
||||
|
||||
// These counters are for debugging purposes.
|
||||
// Number of requests generated.
|
||||
uint32_t request_count_ = 0;
|
||||
// Number of responses provided.
|
||||
uint32_t response_count_ = 0;
|
||||
|
||||
// It is expected that multiple CDM engines may interact with the
|
||||
// OtaKeyboxProvisioner instance simultaneously.
|
||||
mutable std::mutex mutex_;
|
||||
|
||||
CORE_DISALLOW_COPY_AND_ASSIGN(OtaKeyboxProvisioner);
|
||||
}; // class OtaKeyboxProvisioner
|
||||
} // namespace wvcdm
|
||||
#endif // WVCDM_CORE_OTA_KEYBOX_PROVISIONER_H_
|
||||
Reference in New Issue
Block a user