[ Merge of http://go/wvgerrit/133744 ] This changes adds several small classes which contain and manage system and engine information related to OTA keybox provisioning. These classes closely map to the OKP device file messages. Bug: 189232882 Test: Linux unit tests Change-Id: Ia9334c38f9d7ea89b30d9ad05f0595570bb38658 Storing and loading OKP info. [ Merge of http://go/wvgerrit/133763 and http://go/ag/15645333 ] This change extends the DeviceFiles module to be able to store and load OKP info. Mild data validation is performed when storing and loading the information. Bug: 189232882 Test: Android unit tests Change-Id: I077de3234157252f2255a4389bf82a8d5344a355 System OKP fallback policy. [ Merge of http://go/wvgerrit/133783 and http://go/ag/15645334 ] SystemFallbackPolicy provides a thread-safe interface for accessing and modifying OKP info. Bug: 189232882 Test: Android unit tests Change-Id: I4e43e3bc047ed5fb6cb517b53e4094e812b70e1e Engine OKP provisioner. [ Merge of http://go/wvgerrit/133803 and http://go/ag/15645335 ] The OtaKeyboxProvisioner provides a CdmEngine-specific context for performing OTA keybox provisioning. Utilizes the system-wide SystemFallbackPolicy to relay provisioning status between engines. The provisioner will handle message wrapping and unwrapping of the raw OTA keybox request / response into the SignedProvisioningMessage which is sent to/received from the provisioning server. [ Partial merge of http://go/wvgerrit/125844 ] Note: Includes partial CryptoSession changes from various CLs. CryptoSession functionality has been stripped to reduce impact of this CL. Bug: 189232882 Test: Android unit tests Change-Id: I282bf7d1887daefb2250af1bd595c4dc3dfcfb29 Integrated OKP into CDM Engine [ Merge of http://go/wvgerrit/133804 and http://go/ag/15646376 ] Extended the functionality of the CdmEngine to check if the device requires OKP and to initialize OKP resources if required. The functionality of OpenSession() and GetProvisioningRequest() have been the most affected. If OKP is required, these methods will signal to the app that provisioning is required and will return an OKP request. Once a device is provisioned, the OKP data is cleared away and the CdmEngine will resume normal operation. Engines created after a device is provisioned will immediately enter normal operations. The exception is for CdmEngines which failed to perform OKP for some reason and are still running. Those apps will need to restart before gaining access to L1 operations. Bug: 187646550 Test: Android integration tests Merged-In: Ia572a66a7b73479355758aa3d0c682691eaca0fc Change-Id: Ia572a66a7b73479355758aa3d0c682691eaca0fc
79 lines
2.6 KiB
C++
79 lines
2.6 KiB
C++
// 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_OKP_SYSTEM_INFO_H_
|
|
#define WVCDM_CORE_OKP_SYSTEM_INFO_H_
|
|
|
|
#include <inttypes.h>
|
|
|
|
namespace wvcdm {
|
|
// OTA Keybox Provisioning (OKP)
|
|
namespace okp {
|
|
enum class SystemState {
|
|
kUnknown = 0,
|
|
kNeedsProvisioning = 1,
|
|
kFallbackMode = 2, // Fallback indicates provisioning is needed.
|
|
kProvisioned = 3
|
|
// Note: "Not needed" is represented by an absence of info.
|
|
};
|
|
// Converts a SystemState value to a human readable string. Intended
|
|
// to be used for debug logging.
|
|
const char* SystemStateToString(SystemState state);
|
|
|
|
// Container for all the device information related to OKP.
|
|
class SystemFallbackInfo {
|
|
public:
|
|
SystemState state() const { return state_; }
|
|
void SetState(SystemState state) { state_ = state; }
|
|
|
|
bool HasFirstCheckedTime() const { return first_checked_time_ != 0; }
|
|
int64_t first_checked_time() const { return first_checked_time_; }
|
|
void SetFirstCheckedTime(int64_t time) {
|
|
first_checked_time_ = (time > 0 ? time : 0);
|
|
}
|
|
|
|
bool HasBackoffStartTime() const { return backoff_start_time_ > 0; }
|
|
int64_t backoff_start_time() const { return backoff_start_time_; }
|
|
void SetBackoffStartTime(int64_t time) {
|
|
backoff_start_time_ = (time > 0 ? time : 0);
|
|
}
|
|
void ClearBackoffStartTime() { backoff_start_time_ = 0; }
|
|
|
|
bool HasBackoffDuration() const { return backoff_duration_ > 0; }
|
|
int64_t backoff_duration() const { return backoff_duration_; }
|
|
void SetBackoffDuration(int64_t duration) {
|
|
backoff_duration_ = (duration > 0 ? duration : 0);
|
|
}
|
|
void DoubleBackoffDuration() { backoff_duration_ *= 2; }
|
|
|
|
bool HasProvisioningTime() const { return provisioning_time_ != 0; }
|
|
int64_t provisioning_time() const { return provisioning_time_; }
|
|
void SetProvisioningTime(int64_t time) {
|
|
provisioning_time_ = (time > 0 ? time : 0);
|
|
}
|
|
void ClearProvisioningTime() { provisioning_time_ = 0; }
|
|
|
|
void Clear() {
|
|
state_ = SystemState::kUnknown;
|
|
first_checked_time_ = 0;
|
|
backoff_start_time_ = 0;
|
|
backoff_duration_ = 0;
|
|
provisioning_time_ = 0;
|
|
}
|
|
|
|
bool operator==(const SystemFallbackInfo& other) const;
|
|
bool operator!=(const SystemFallbackInfo& other) const {
|
|
return !(*this == other);
|
|
}
|
|
|
|
private:
|
|
SystemState state_ = SystemState::kUnknown;
|
|
int64_t first_checked_time_ = 0;
|
|
int64_t backoff_start_time_ = 0;
|
|
int64_t backoff_duration_ = 0;
|
|
int64_t provisioning_time_ = 0;
|
|
}; // class SystemFallbackInfo
|
|
} // namespace okp
|
|
} // namespace wvcdm
|
|
#endif // WVCDM_CORE_OKP_SYSTEM_INFO_H_
|