Renaming of Usage Table related variables and types.
[ Merge of http://go/wvgerrit/164077 ] This CL makes major changes to the names of variables and types that are related to the usage table, header, entries, entry indexes, and other related data. The renaming followed these rules: 1) "Usage table header" will exclusively refer to the header blob that is OEMCrypto specific. The CDM class "UsageTableHeader" is the CDM-layer's abstraction around the "usage table" concept. The name has been updated to reflect that. 2) The "Cdm" prefix is only used for the CDM-specific data types for the usage table and entry info. It has been removed from OEMCrypto-specific types. - UsageTableHeader -> CdmUsageTable - CdmUsageTableHeader -> UsageTableHeader - CdmUsageEntry -> UsageEntry 3) The "usage_" prefix has been removed from variables when the usage table or usage entries are the subject of the function or class. 4) UsageEntryIndex is the type for entry indexes, instead of directly using uint32_t. This matches how we wrap other types in "wv_cdm_types.h" 5) Changed entry "number" to entry "index". 6) Vectors of elements have been renamed to be either pluralized or have a suffix "_list". 7) "Usage info" was occasionally being used to refer to the usage table or entries generally, rather than specifically secure-stop. - CryptoSession::HasUsageInfoSupport() -> HasUsageTableSupport() The most major change is that the files "usage_table_header*" have been renamed to be "cdm_usage_table*". Bug: 242914226 Test: run_x86_64_tests and request_license_test Change-Id: Iee98446b71f4f2934d3c9e0fb949eb05b84d1f8c
This commit is contained in:
@@ -36,6 +36,7 @@ WV_UNITTESTS="base64_test \
|
|||||||
cdm_feature_test \
|
cdm_feature_test \
|
||||||
cdm_extended_duration_test \
|
cdm_extended_duration_test \
|
||||||
cdm_session_unittest \
|
cdm_session_unittest \
|
||||||
|
cdm_usage_table_unittest \
|
||||||
certificate_provisioning_unittest \
|
certificate_provisioning_unittest \
|
||||||
counter_metric_unittest \
|
counter_metric_unittest \
|
||||||
crypto_session_unittest \
|
crypto_session_unittest \
|
||||||
@@ -69,7 +70,6 @@ WV_UNITTESTS="base64_test \
|
|||||||
service_certificate_unittest \
|
service_certificate_unittest \
|
||||||
system_id_extractor_unittest \
|
system_id_extractor_unittest \
|
||||||
timer_unittest \
|
timer_unittest \
|
||||||
usage_table_header_unittest \
|
|
||||||
value_metric_unittest \
|
value_metric_unittest \
|
||||||
wv_cdm_metrics_test"
|
wv_cdm_metrics_test"
|
||||||
|
|
||||||
|
|||||||
@@ -45,6 +45,7 @@ cc_library_static {
|
|||||||
CORE_SRC_DIR + "/cdm_engine_factory.cpp",
|
CORE_SRC_DIR + "/cdm_engine_factory.cpp",
|
||||||
CORE_SRC_DIR + "/cdm_session.cpp",
|
CORE_SRC_DIR + "/cdm_session.cpp",
|
||||||
CORE_SRC_DIR + "/cdm_session_map.cpp",
|
CORE_SRC_DIR + "/cdm_session_map.cpp",
|
||||||
|
CORE_SRC_DIR + "/cdm_usage_table.cpp",
|
||||||
CORE_SRC_DIR + "/certificate_provisioning.cpp",
|
CORE_SRC_DIR + "/certificate_provisioning.cpp",
|
||||||
CORE_SRC_DIR + "/client_identification.cpp",
|
CORE_SRC_DIR + "/client_identification.cpp",
|
||||||
CORE_SRC_DIR + "/content_key_session.cpp",
|
CORE_SRC_DIR + "/content_key_session.cpp",
|
||||||
@@ -66,7 +67,6 @@ cc_library_static {
|
|||||||
CORE_SRC_DIR + "/privacy_crypto_boringssl.cpp",
|
CORE_SRC_DIR + "/privacy_crypto_boringssl.cpp",
|
||||||
CORE_SRC_DIR + "/service_certificate.cpp",
|
CORE_SRC_DIR + "/service_certificate.cpp",
|
||||||
CORE_SRC_DIR + "/system_id_extractor.cpp",
|
CORE_SRC_DIR + "/system_id_extractor.cpp",
|
||||||
CORE_SRC_DIR + "/usage_table_header.cpp",
|
|
||||||
CORE_SRC_DIR + "/wv_cdm_types.cpp",
|
CORE_SRC_DIR + "/wv_cdm_types.cpp",
|
||||||
SRC_DIR + "/wv_content_decryption_module.cpp",
|
SRC_DIR + "/wv_content_decryption_module.cpp",
|
||||||
METRICS_SRC_DIR + "/attribute_handler.cpp",
|
METRICS_SRC_DIR + "/attribute_handler.cpp",
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ namespace wvcdm {
|
|||||||
class CdmClientPropertySet;
|
class CdmClientPropertySet;
|
||||||
class ServiceCertificate;
|
class ServiceCertificate;
|
||||||
class WvCdmEventListener;
|
class WvCdmEventListener;
|
||||||
class UsageTableHeader;
|
class CdmUsageTable;
|
||||||
|
|
||||||
class CdmSession {
|
class CdmSession {
|
||||||
public:
|
public:
|
||||||
@@ -129,7 +129,7 @@ class CdmSession {
|
|||||||
// ReleaseKey() - Accept response and release key.
|
// ReleaseKey() - Accept response and release key.
|
||||||
virtual CdmResponseType ReleaseKey(const CdmKeyResponse& key_response);
|
virtual CdmResponseType ReleaseKey(const CdmKeyResponse& key_response);
|
||||||
|
|
||||||
virtual CdmResponseType DeleteUsageEntry(uint32_t usage_entry_number);
|
virtual CdmResponseType DeleteUsageEntry(UsageEntryIndex entry_index);
|
||||||
|
|
||||||
virtual bool IsKeyLoaded(const KeyId& key_id);
|
virtual bool IsKeyLoaded(const KeyId& key_id);
|
||||||
virtual int64_t GetDurationRemaining();
|
virtual int64_t GetDurationRemaining();
|
||||||
@@ -164,9 +164,7 @@ class CdmSession {
|
|||||||
license_parser_->provider_session_token().size() > 0);
|
license_parser_->provider_session_token().size() > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual bool supports_usage_info() const {
|
virtual bool SupportsUsageTable() const { return usage_table_ != nullptr; }
|
||||||
return usage_table_header_ != nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
// This method will remove keys by resetting crypto resources and
|
// This method will remove keys by resetting crypto resources and
|
||||||
// policy information. This renders the session mostly useless and it is
|
// policy information. This renders the session mostly useless and it is
|
||||||
@@ -307,11 +305,11 @@ class CdmSession {
|
|||||||
// Usage related flags and data
|
// Usage related flags and data
|
||||||
bool is_initial_usage_update_;
|
bool is_initial_usage_update_;
|
||||||
bool is_usage_update_needed_;
|
bool is_usage_update_needed_;
|
||||||
// Only assign |usage_table_header_| if capable of supporting usage
|
// Only assign |usage_table_| if capable of supporting usage
|
||||||
// information.
|
// information.
|
||||||
UsageTableHeader* usage_table_header_ = nullptr;
|
CdmUsageTable* usage_table_ = nullptr;
|
||||||
uint32_t usage_entry_number_;
|
UsageEntryIndex usage_entry_index_;
|
||||||
CdmUsageEntry usage_entry_;
|
UsageEntry usage_entry_;
|
||||||
std::string usage_provider_session_token_;
|
std::string usage_provider_session_token_;
|
||||||
|
|
||||||
// information useful for offline and usage scenarios
|
// information useful for offline and usage scenarios
|
||||||
|
|||||||
@@ -2,8 +2,8 @@
|
|||||||
// source code may only be used and distributed under the Widevine License
|
// source code may only be used and distributed under the Widevine License
|
||||||
// Agreement.
|
// Agreement.
|
||||||
|
|
||||||
#ifndef WVCDM_CORE_USAGE_TABLE_HEADER_H_
|
#ifndef WVCDM_CORE_CDM_USAGE_TABLE_H_
|
||||||
#define WVCDM_CORE_USAGE_TABLE_HEADER_H_
|
#define WVCDM_CORE_CDM_USAGE_TABLE_H_
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
@@ -46,12 +46,12 @@ namespace wvcdm {
|
|||||||
//
|
//
|
||||||
// Upgrades from a fixed size usage table (supported by previous
|
// Upgrades from a fixed size usage table (supported by previous
|
||||||
// versions of the OEMCrypto API v9-12) are handled by this class.
|
// versions of the OEMCrypto API v9-12) are handled by this class.
|
||||||
// |usage_entry| and |usage_entry_number|s need to be saved in the license
|
// |entry| and |entry_index|s need to be saved in the license
|
||||||
// and usage info records by the caller.
|
// and usage info records by the caller.
|
||||||
class UsageTableHeader {
|
class CdmUsageTable {
|
||||||
public:
|
public:
|
||||||
UsageTableHeader();
|
CdmUsageTable();
|
||||||
virtual ~UsageTableHeader() {}
|
virtual ~CdmUsageTable() {}
|
||||||
|
|
||||||
// |crypto_session| is used to create or load a usage master table
|
// |crypto_session| is used to create or load a usage master table
|
||||||
// and not cached beyound this call.
|
// and not cached beyound this call.
|
||||||
@@ -65,36 +65,36 @@ class UsageTableHeader {
|
|||||||
|
|
||||||
// Adds a new entry to the OEMCrypto usage table header, and associates
|
// Adds a new entry to the OEMCrypto usage table header, and associates
|
||||||
// the entry with the provided |crypto_session|. The index of the new
|
// the entry with the provided |crypto_session|. The index of the new
|
||||||
// usage entry will be returned by |usage_entry_number|.
|
// usage entry will be returned by |entry_index|.
|
||||||
//
|
//
|
||||||
// Type of entry depends on the value of |persistent_license|:
|
// Type of entry depends on the value of |persistent_license|:
|
||||||
// false - usage info / secure stop record
|
// false - usage info / secure stop record
|
||||||
// true - offline license
|
// true - offline license
|
||||||
//
|
//
|
||||||
// Threading: Method takes exclusive use of |usage_table_header_lock_|.
|
// Threading: Method takes exclusive use of |lock_|.
|
||||||
virtual CdmResponseType AddEntry(CryptoSession* crypto_session,
|
virtual CdmResponseType AddEntry(CryptoSession* crypto_session,
|
||||||
bool persistent_license,
|
bool persistent_license,
|
||||||
const CdmKeySetId& key_set_id,
|
const CdmKeySetId& key_set_id,
|
||||||
const std::string& usage_info_filename,
|
const std::string& usage_info_filename,
|
||||||
const CdmKeyResponse& license_message,
|
const CdmKeyResponse& license_message,
|
||||||
uint32_t* usage_entry_number);
|
UsageEntryIndex* entry_index);
|
||||||
// Threading: Method takes exclusive use of |usage_table_header_lock_|.
|
// Threading: Method takes exclusive use of |lock_|.
|
||||||
virtual CdmResponseType LoadEntry(CryptoSession* crypto_session,
|
virtual CdmResponseType LoadEntry(CryptoSession* crypto_session,
|
||||||
const CdmUsageEntry& usage_entry,
|
const UsageEntry& entry,
|
||||||
uint32_t usage_entry_number);
|
UsageEntryIndex entry_index);
|
||||||
// Threading: Method takes exclusive use of |usage_table_header_lock_|.
|
// Threading: Method takes exclusive use of |lock_|.
|
||||||
virtual CdmResponseType UpdateEntry(uint32_t usage_entry_number,
|
virtual CdmResponseType UpdateEntry(UsageEntryIndex entry_index,
|
||||||
CryptoSession* crypto_session,
|
CryptoSession* crypto_session,
|
||||||
CdmUsageEntry* usage_entry);
|
UsageEntry* entry);
|
||||||
|
|
||||||
// The licenses or usage info records specified by |usage_entry_number|
|
// The licenses or usage info records specified by |entry_index|
|
||||||
// should not be in use by any open CryptoSession objects when calls
|
// should not be in use by any open CryptoSession objects when calls
|
||||||
// to InvalidateEntry and MoveEntry are made.
|
// to InvalidateEntry and MoveEntry are made.
|
||||||
// If |defrag_table| is true, the table will be defragmented after
|
// If |defrag_table| is true, the table will be defragmented after
|
||||||
// the entry has been invalidated.
|
// the entry has been invalidated.
|
||||||
//
|
//
|
||||||
// Threading: Method takes exclusive use of |usage_table_header_lock_|.
|
// Threading: Method takes exclusive use of |lock_|.
|
||||||
virtual CdmResponseType InvalidateEntry(uint32_t usage_entry_number,
|
virtual CdmResponseType InvalidateEntry(UsageEntryIndex entry_index,
|
||||||
bool defrag_table,
|
bool defrag_table,
|
||||||
DeviceFiles* device_files,
|
DeviceFiles* device_files,
|
||||||
metrics::CryptoMetrics* metrics);
|
metrics::CryptoMetrics* metrics);
|
||||||
@@ -107,13 +107,13 @@ class UsageTableHeader {
|
|||||||
// for the objects that InvalidateEntry depends on.
|
// for the objects that InvalidateEntry depends on.
|
||||||
//
|
//
|
||||||
// Threading: Method requires care of caller for exclusive access.
|
// Threading: Method requires care of caller for exclusive access.
|
||||||
void InvalidateEntryForTest(uint32_t usage_entry_number);
|
void InvalidateEntryForTest(UsageEntryIndex entry_index);
|
||||||
|
|
||||||
// == Table information methods ==
|
// == Table information methods ==
|
||||||
// Threading: None of the following are thread safe. Intended for
|
// Threading: None of the following are thread safe. Intended for
|
||||||
// testing or internal use.
|
// testing or internal use.
|
||||||
|
|
||||||
size_t size() { return usage_entry_info_.size(); }
|
size_t size() { return entry_info_list_.size(); }
|
||||||
|
|
||||||
size_t potential_table_capacity() const { return potential_table_capacity_; }
|
size_t potential_table_capacity() const { return potential_table_capacity_; }
|
||||||
|
|
||||||
@@ -128,8 +128,8 @@ class UsageTableHeader {
|
|||||||
// are related to offline licenses.
|
// are related to offline licenses.
|
||||||
size_t OfflineEntryCount() const;
|
size_t OfflineEntryCount() const;
|
||||||
|
|
||||||
const std::vector<CdmUsageEntryInfo>& usage_entry_info() const {
|
const std::vector<CdmUsageEntryInfo>& entry_info_list() const {
|
||||||
return usage_entry_info_;
|
return entry_info_list_;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set the reference clock used for the method GetCurrentTime().
|
// Set the reference clock used for the method GetCurrentTime().
|
||||||
@@ -141,10 +141,10 @@ class UsageTableHeader {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static bool DetermineLicenseToRemoveForTesting(
|
static bool DetermineLicenseToRemoveForTesting(
|
||||||
const std::vector<CdmUsageEntryInfo>& usage_entry_info_list,
|
const std::vector<CdmUsageEntryInfo>& entry_info_list,
|
||||||
int64_t current_time, size_t unexpired_threshold,
|
int64_t current_time, size_t unexpired_threshold,
|
||||||
uint32_t* entry_to_remove) {
|
UsageEntryIndex* entry_to_remove) {
|
||||||
return DetermineLicenseToRemove(usage_entry_info_list, current_time,
|
return DetermineLicenseToRemove(entry_info_list, current_time,
|
||||||
unexpired_threshold, entry_to_remove);
|
unexpired_threshold, entry_to_remove);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -155,13 +155,13 @@ class UsageTableHeader {
|
|||||||
|
|
||||||
// Creates a new, empty usage table. Any existing usage table files
|
// Creates a new, empty usage table. Any existing usage table files
|
||||||
// will be deleted.
|
// will be deleted.
|
||||||
// Threading: Method takes exclusive use of |usage_table_header_lock_|
|
// Threading: Method takes exclusive use of |lock_|
|
||||||
// when required.
|
// when required.
|
||||||
bool CreateNewTable(CryptoSession* const crypto_session);
|
bool CreateNewTable(CryptoSession* const crypto_session);
|
||||||
// Attempts to restore the usage table from persistent storage, and
|
// Attempts to restore the usage table from persistent storage, and
|
||||||
// loads the usage table header into OEMCrypto.
|
// loads the usage table header into OEMCrypto.
|
||||||
// Note: No other OEMCrypto session should be opened before calling.
|
// Note: No other OEMCrypto session should be opened before calling.
|
||||||
// Threading: Method takes exclusive use of |usage_table_header_lock_|
|
// Threading: Method takes exclusive use of |lock_|
|
||||||
// when required.
|
// when required.
|
||||||
bool RestoreTable(CryptoSession* const crypto_session);
|
bool RestoreTable(CryptoSession* const crypto_session);
|
||||||
|
|
||||||
@@ -173,76 +173,73 @@ class UsageTableHeader {
|
|||||||
// one more entry if the table is at or near the reported capacity.
|
// one more entry if the table is at or near the reported capacity.
|
||||||
// If this check fails, a new usage table SHOULD be created.
|
// If this check fails, a new usage table SHOULD be created.
|
||||||
// Threading: Method requires caller to take exclusive use of
|
// Threading: Method requires caller to take exclusive use of
|
||||||
// |usage_table_header_lock_|.
|
// |lock_|.
|
||||||
bool CapacityCheck(CryptoSession* const crypto_session);
|
bool CapacityCheck(CryptoSession* const crypto_session);
|
||||||
|
|
||||||
// Attempts to determine the capacity of the OEMCrypto usage table.
|
// Attempts to determine the capacity of the OEMCrypto usage table.
|
||||||
// Sets the result to |potential_table_capacity_|.
|
// Sets the result to |potential_table_capacity_|.
|
||||||
// Threading: Method requires caller to take exclusive use of
|
// Threading: Method requires caller to take exclusive use of
|
||||||
// |usage_table_header_lock_|.
|
// |lock_|.
|
||||||
bool DetermineTableCapacity(CryptoSession* crypto_session);
|
bool DetermineTableCapacity(CryptoSession* crypto_session);
|
||||||
|
|
||||||
// == Table operation methods ==
|
// == Table operation methods ==
|
||||||
// Threading: All of the following methods require caller to take
|
// Threading: All of the following methods require caller to take
|
||||||
// exclusive use of |usage_table_header_lock_|.
|
// exclusive use of |lock_|.
|
||||||
|
|
||||||
// Creates a new entry for the provided crypto session. If the
|
// Creates a new entry for the provided crypto session. If the
|
||||||
// entry is created successfully in OEMCrypto, then a new entry
|
// entry is created successfully in OEMCrypto, then a new entry
|
||||||
// info is added to the table's vector of entry info.
|
// info is added to the table's vector of entry info.
|
||||||
CdmResponseType CreateEntry(CryptoSession* const crypto_session,
|
CdmResponseType CreateEntry(CryptoSession* const crypto_session,
|
||||||
uint32_t* usage_entry_number);
|
UsageEntryIndex* entry_index);
|
||||||
|
|
||||||
// Attempts to relocate a newly created usage entry associated with
|
// Attempts to relocate a newly created usage entry associated with
|
||||||
// the provided |crypto_session| to the lowest unoccupied position in
|
// the provided |crypto_session| to the lowest unoccupied position in
|
||||||
// the table.
|
// the table.
|
||||||
// |usage_entry_number| is treated as both an input and output.
|
// |entry_index| is treated as both an input and output.
|
||||||
// Returns NO_ERROR so long as no internal operation fails,
|
// Returns NO_ERROR so long as no internal operation fails,
|
||||||
// regardless of whether the entry was moved or not.
|
// regardless of whether the entry was moved or not.
|
||||||
CdmResponseType RelocateNewEntry(CryptoSession* const crypto_session,
|
CdmResponseType RelocateNewEntry(CryptoSession* const crypto_session,
|
||||||
uint32_t* usage_entry_number);
|
UsageEntryIndex* entry_index);
|
||||||
|
|
||||||
// Checks if the specified |usage_entry_number| is known to be
|
// Checks if the specified |entry_index| is known to be
|
||||||
// unoccupied (released).
|
// unoccupied (released).
|
||||||
bool IsEntryUnoccupied(const uint32_t usage_entry_number) const;
|
bool IsEntryUnoccupied(const UsageEntryIndex entry_index) const;
|
||||||
|
|
||||||
// SetOfflineEntryInfo() and SetUsageInfoEntryInfo() populate the
|
// SetOfflineEntryInfo() and SetUsageInfoEntryInfo() populate the
|
||||||
// entry meta-data with the required information based on the type
|
// entry meta-data with the required information based on the type
|
||||||
// of entry.
|
// of entry.
|
||||||
void SetOfflineEntryInfo(const uint32_t usage_entry_number,
|
void SetOfflineEntryInfo(const UsageEntryIndex entry_index,
|
||||||
const std::string& key_set_id,
|
const std::string& key_set_id,
|
||||||
const CdmKeyResponse& license_message);
|
const CdmKeyResponse& license_message);
|
||||||
void SetUsageInfoEntryInfo(const uint32_t usage_entry_number,
|
void SetUsageInfoEntryInfo(const UsageEntryIndex entry_index,
|
||||||
const std::string& key_set_id,
|
const std::string& key_set_id,
|
||||||
const std::string& usage_info_file_name);
|
const std::string& usage_info_file_name);
|
||||||
|
|
||||||
// Shrinks the table, removing all trailing unoccupied entries.
|
// Shrinks the table, removing all trailing unoccupied entries.
|
||||||
// |usage_entry_info_| will be resized appropriately.
|
// |entry_info_list_| will be resized appropriately.
|
||||||
// Caller must store the table after a successful call.
|
// Caller must store the table after a successful call.
|
||||||
CdmResponseType RefitTable(CryptoSession* const crypto_session);
|
CdmResponseType RefitTable(CryptoSession* const crypto_session);
|
||||||
|
|
||||||
virtual CdmResponseType InvalidateEntryInternal(
|
virtual CdmResponseType InvalidateEntryInternal(
|
||||||
uint32_t usage_entry_number, bool defrag_table, DeviceFiles* device_files,
|
UsageEntryIndex entry_index, bool defrag_table, DeviceFiles* device_files,
|
||||||
metrics::CryptoMetrics* metrics);
|
metrics::CryptoMetrics* metrics);
|
||||||
|
|
||||||
CdmResponseType MoveEntry(uint32_t from /* usage entry number */,
|
CdmResponseType MoveEntry(UsageEntryIndex from, const UsageEntry& from_entry,
|
||||||
const CdmUsageEntry& from_usage_entry,
|
UsageEntryIndex to, DeviceFiles* device_files,
|
||||||
uint32_t to /* usage entry number */,
|
|
||||||
DeviceFiles* device_files,
|
|
||||||
metrics::CryptoMetrics* metrics);
|
metrics::CryptoMetrics* metrics);
|
||||||
|
|
||||||
CdmResponseType GetEntry(uint32_t usage_entry_number,
|
CdmResponseType GetEntry(UsageEntryIndex entry_index,
|
||||||
DeviceFiles* device_files,
|
DeviceFiles* device_files, UsageEntry* entry);
|
||||||
CdmUsageEntry* usage_entry);
|
CdmResponseType StoreEntry(UsageEntryIndex entry_index,
|
||||||
CdmResponseType StoreEntry(uint32_t usage_entry_number,
|
|
||||||
DeviceFiles* device_files,
|
DeviceFiles* device_files,
|
||||||
const CdmUsageEntry& usage_entry);
|
const UsageEntry& entry);
|
||||||
|
|
||||||
// Stores the usage table and it's info. This will increment
|
// Stores the usage table and it's info. This will increment
|
||||||
// |store_table_counter_| if successful.
|
// |store_table_counter_| if successful.
|
||||||
bool StoreTable();
|
bool StoreTable();
|
||||||
|
|
||||||
CdmResponseType Shrink(metrics::CryptoMetrics* metrics,
|
CdmResponseType Shrink(metrics::CryptoMetrics* metrics,
|
||||||
uint32_t number_of_usage_entries_to_delete);
|
uint32_t number_of_entries_to_delete);
|
||||||
|
|
||||||
// Must lock table before calling.
|
// Must lock table before calling.
|
||||||
CdmResponseType DefragTable(DeviceFiles* device_files,
|
CdmResponseType DefragTable(DeviceFiles* device_files,
|
||||||
@@ -286,7 +283,7 @@ class UsageTableHeader {
|
|||||||
// types.
|
// types.
|
||||||
//
|
//
|
||||||
// Parameters:
|
// Parameters:
|
||||||
// [in] usage_entry_info_list: The complete list of known usage
|
// [in] entry_info_list: The complete list of known usage
|
||||||
// entries.
|
// entries.
|
||||||
// [in] current_time: The current time to compare expiration times
|
// [in] current_time: The current time to compare expiration times
|
||||||
// against.
|
// against.
|
||||||
@@ -301,20 +298,20 @@ class UsageTableHeader {
|
|||||||
// |true| if an entry has been determined to be removed.
|
// |true| if an entry has been determined to be removed.
|
||||||
// Otherwise returns |false|.
|
// Otherwise returns |false|.
|
||||||
static bool DetermineLicenseToRemove(
|
static bool DetermineLicenseToRemove(
|
||||||
const std::vector<CdmUsageEntryInfo>& usage_entry_info_list,
|
const std::vector<CdmUsageEntryInfo>& entry_info_list,
|
||||||
int64_t current_time, size_t unexpired_threshold,
|
int64_t current_time, size_t unexpired_threshold,
|
||||||
uint32_t* entry_to_remove);
|
UsageEntryIndex* entry_to_remove);
|
||||||
|
|
||||||
// This handle and file system is only to be used when accessing
|
// This handle and file system is only to be used when accessing
|
||||||
// usage_table_header. Usage entries should use the file system provided
|
// header. Usage entries should use the file system provided
|
||||||
// by CdmSession.
|
// by CdmSession.
|
||||||
std::unique_ptr<DeviceFiles> device_files_;
|
std::unique_ptr<DeviceFiles> device_files_;
|
||||||
std::unique_ptr<wvutil::FileSystem> file_system_;
|
std::unique_ptr<wvutil::FileSystem> file_system_;
|
||||||
CdmSecurityLevel security_level_ = kSecurityLevelUninitialized;
|
CdmSecurityLevel security_level_ = kSecurityLevelUninitialized;
|
||||||
RequestedSecurityLevel requested_security_level_ = kLevelDefault;
|
RequestedSecurityLevel requested_security_level_ = kLevelDefault;
|
||||||
|
|
||||||
CdmUsageTableHeader usage_table_header_;
|
UsageTableHeader header_;
|
||||||
std::vector<CdmUsageEntryInfo> usage_entry_info_;
|
std::vector<CdmUsageEntryInfo> entry_info_list_;
|
||||||
|
|
||||||
// Table is sync with persistent storage and can be used by the CDM
|
// Table is sync with persistent storage and can be used by the CDM
|
||||||
// to interact with OEMCrypto.
|
// to interact with OEMCrypto.
|
||||||
@@ -322,7 +319,7 @@ class UsageTableHeader {
|
|||||||
|
|
||||||
// Synchonizes access to the Usage Table Header and bookkeeping
|
// Synchonizes access to the Usage Table Header and bookkeeping
|
||||||
// data-structures
|
// data-structures
|
||||||
mutable std::mutex usage_table_header_lock_;
|
mutable std::mutex lock_;
|
||||||
|
|
||||||
metrics::CryptoMetrics alternate_crypto_metrics_;
|
metrics::CryptoMetrics alternate_crypto_metrics_;
|
||||||
|
|
||||||
@@ -347,12 +344,12 @@ class UsageTableHeader {
|
|||||||
|
|
||||||
#if defined(UNIT_TEST)
|
#if defined(UNIT_TEST)
|
||||||
// Test related declarations
|
// Test related declarations
|
||||||
friend class UsageTableHeaderTest;
|
friend class CdmUsageTableTest;
|
||||||
|
|
||||||
FRIEND_TEST(UsageTableHeaderTest, Shrink_NoneOfTable);
|
FRIEND_TEST(CdmUsageTableTest, Shrink_NoneOfTable);
|
||||||
FRIEND_TEST(UsageTableHeaderTest, Shrink_PartOfTable);
|
FRIEND_TEST(CdmUsageTableTest, Shrink_PartOfTable);
|
||||||
FRIEND_TEST(UsageTableHeaderTest, Shrink_AllOfTable);
|
FRIEND_TEST(CdmUsageTableTest, Shrink_AllOfTable);
|
||||||
FRIEND_TEST(UsageTableHeaderTest, Shrink_MoreThanTable);
|
FRIEND_TEST(CdmUsageTableTest, Shrink_MoreThanTable);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// These setters are for testing only. Takes ownership of the pointers.
|
// These setters are for testing only. Takes ownership of the pointers.
|
||||||
@@ -366,9 +363,9 @@ class UsageTableHeader {
|
|||||||
// Test related data members
|
// Test related data members
|
||||||
std::unique_ptr<CryptoSession> test_crypto_session_;
|
std::unique_ptr<CryptoSession> test_crypto_session_;
|
||||||
|
|
||||||
CORE_DISALLOW_COPY_AND_ASSIGN(UsageTableHeader);
|
CORE_DISALLOW_COPY_AND_ASSIGN(CdmUsageTable);
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace wvcdm
|
} // namespace wvcdm
|
||||||
|
|
||||||
#endif // WVCDM_CORE_USAGE_TABLE_HEADER_H_
|
#endif // WVCDM_CORE_CDM_USAGE_TABLE_H_
|
||||||
@@ -26,7 +26,7 @@ namespace wvcdm {
|
|||||||
class CryptoKey;
|
class CryptoKey;
|
||||||
class CryptoSessionFactory;
|
class CryptoSessionFactory;
|
||||||
class OtaKeyboxProvisioner;
|
class OtaKeyboxProvisioner;
|
||||||
class UsageTableHeader;
|
class CdmUsageTable;
|
||||||
|
|
||||||
namespace okp {
|
namespace okp {
|
||||||
class SystemFallbackPolicy;
|
class SystemFallbackPolicy;
|
||||||
@@ -273,13 +273,13 @@ class CryptoSession {
|
|||||||
// Used to manipulate the CDM managed usage table header & entries,
|
// Used to manipulate the CDM managed usage table header & entries,
|
||||||
// delegating calls to OEMCrypto.
|
// delegating calls to OEMCrypto.
|
||||||
|
|
||||||
// Determines whether the OEMCrypto library supports usage info.
|
// Determines whether the OEMCrypto library supports usage table.
|
||||||
// As of V16, the only valid type of support is usage table header +
|
// As of V16, the only valid type of support is usage table header +
|
||||||
// usage entries.
|
// usage entries.
|
||||||
// The first method will use a cached value if present.
|
// The first method will use a cached value if present.
|
||||||
virtual bool HasUsageInfoSupport(bool* has_support);
|
virtual bool HasUsageTableSupport(bool* has_support);
|
||||||
virtual bool HasUsageInfoSupport(RequestedSecurityLevel security_level,
|
virtual bool HasUsageTableSupport(RequestedSecurityLevel security_level,
|
||||||
bool* has_support);
|
bool* has_support);
|
||||||
|
|
||||||
// Usage report.
|
// Usage report.
|
||||||
virtual CdmResponseType DeactivateUsageInformation(
|
virtual CdmResponseType DeactivateUsageInformation(
|
||||||
@@ -290,30 +290,28 @@ class CryptoSession {
|
|||||||
int64_t* seconds_since_started, int64_t* seconds_since_last_played);
|
int64_t* seconds_since_started, int64_t* seconds_since_last_played);
|
||||||
|
|
||||||
// Usage table header.
|
// Usage table header.
|
||||||
virtual UsageTableHeader* GetUsageTableHeader() {
|
virtual CdmUsageTable* GetUsageTable() { return usage_table_; }
|
||||||
return usage_table_header_;
|
|
||||||
}
|
|
||||||
// The following crypto methods do not require an open session to
|
// The following crypto methods do not require an open session to
|
||||||
// complete the operations.
|
// complete the operations.
|
||||||
virtual CdmResponseType CreateUsageTableHeader(
|
virtual CdmResponseType CreateUsageTableHeader(
|
||||||
RequestedSecurityLevel requested_security_level,
|
RequestedSecurityLevel requested_security_level,
|
||||||
CdmUsageTableHeader* usage_table_header);
|
UsageTableHeader* usage_table_header);
|
||||||
virtual CdmResponseType LoadUsageTableHeader(
|
virtual CdmResponseType LoadUsageTableHeader(
|
||||||
RequestedSecurityLevel requested_security_level,
|
RequestedSecurityLevel requested_security_level,
|
||||||
const CdmUsageTableHeader& usage_table_header);
|
const UsageTableHeader& usage_table_header);
|
||||||
virtual CdmResponseType ShrinkUsageTableHeader(
|
virtual CdmResponseType ShrinkUsageTableHeader(
|
||||||
RequestedSecurityLevel requested_security_level, uint32_t new_entry_count,
|
RequestedSecurityLevel requested_security_level, uint32_t new_entry_count,
|
||||||
CdmUsageTableHeader* usage_table_header);
|
UsageTableHeader* usage_table_header);
|
||||||
|
|
||||||
// Usage entry.
|
// Usage entry.
|
||||||
virtual CdmResponseType CreateUsageEntry(uint32_t* entry_number);
|
virtual CdmResponseType CreateUsageEntry(UsageEntryIndex* entry_index);
|
||||||
virtual CdmResponseType LoadUsageEntry(uint32_t entry_number,
|
virtual CdmResponseType LoadUsageEntry(UsageEntryIndex entry_index,
|
||||||
const CdmUsageEntry& usage_entry);
|
const UsageEntry& usage_entry);
|
||||||
virtual CdmResponseType UpdateUsageEntry(
|
virtual CdmResponseType UpdateUsageEntry(UsageTableHeader* usage_table_header,
|
||||||
CdmUsageTableHeader* usage_table_header, CdmUsageEntry* usage_entry);
|
UsageEntry* usage_entry);
|
||||||
|
|
||||||
// Adjust usage entries in usage table header.
|
// Adjust usage entries in usage table header.
|
||||||
virtual CdmResponseType MoveUsageEntry(uint32_t new_entry_number);
|
virtual CdmResponseType MoveUsageEntry(UsageEntryIndex new_entry_index);
|
||||||
|
|
||||||
virtual bool GetAnalogOutputCapabilities(bool* can_support_output,
|
virtual bool GetAnalogOutputCapabilities(bool* can_support_output,
|
||||||
bool* can_disable_output,
|
bool* can_disable_output,
|
||||||
@@ -384,11 +382,11 @@ class CryptoSession {
|
|||||||
|
|
||||||
void Init();
|
void Init();
|
||||||
|
|
||||||
// Will set up the UsageTableHeader for this session. This may require
|
// Will set up the CdmUsageTable for this session. This may require
|
||||||
// creating a new UsageTableHeader if the global instance has not
|
// creating a new CdmUsageTable if the global instance has not
|
||||||
// been initialized.
|
// been initialized.
|
||||||
// Note: This function will lock the global static field lock in write mode.
|
// Note: This function will lock the global static field lock in write mode.
|
||||||
bool SetUpUsageTableHeader(RequestedSecurityLevel requested_security_level);
|
bool SetUpUsageTable(RequestedSecurityLevel requested_security_level);
|
||||||
|
|
||||||
CdmResponseType GenerateRsaSignature(const std::string& message,
|
CdmResponseType GenerateRsaSignature(const std::string& message,
|
||||||
std::string* signature);
|
std::string* signature);
|
||||||
@@ -399,10 +397,10 @@ class CryptoSession {
|
|||||||
CdmResponseType SelectKey(const std::string& key_id,
|
CdmResponseType SelectKey(const std::string& key_id,
|
||||||
CdmCipherMode cipher_mode);
|
CdmCipherMode cipher_mode);
|
||||||
|
|
||||||
// Retrieves the OEMCrypto usage info support for the specified
|
// Retrieves the OEMCrypto usage table support for the specified
|
||||||
// |requested_security_level|.
|
// |requested_security_level|.
|
||||||
// Caller should acquire the OEMCrypto read lock before calling.
|
// Caller should acquire the OEMCrypto read lock before calling.
|
||||||
bool HasUsageInfoSupportInternal(
|
bool HasUsageTableSupportInternal(
|
||||||
RequestedSecurityLevel requested_security_level, bool* has_support);
|
RequestedSecurityLevel requested_security_level, bool* has_support);
|
||||||
|
|
||||||
// These methods fall back into each other in the order given, depending on
|
// These methods fall back into each other in the order given, depending on
|
||||||
@@ -526,12 +524,12 @@ class CryptoSession {
|
|||||||
RequestedSecurityLevel requested_security_level_;
|
RequestedSecurityLevel requested_security_level_;
|
||||||
|
|
||||||
// Open session-cached result of OEMCrypto_SupportsUsageTable().
|
// Open session-cached result of OEMCrypto_SupportsUsageTable().
|
||||||
CachedBooleanProperty has_usage_info_support_ = kBooleanUnset;
|
CachedBooleanProperty has_usage_table_support_ = kBooleanUnset;
|
||||||
UsageTableHeader* usage_table_header_ = nullptr;
|
CdmUsageTable* usage_table_ = nullptr;
|
||||||
// These fields are protected by |usage_table_mutex_| and not
|
// These fields are protected by |usage_table_mutex_| and not
|
||||||
// |static_field_mutex_|.
|
// |static_field_mutex_|.
|
||||||
static std::unique_ptr<UsageTableHeader> usage_table_header_l1_;
|
static std::unique_ptr<CdmUsageTable> usage_table_l1_;
|
||||||
static std::unique_ptr<UsageTableHeader> usage_table_header_l3_;
|
static std::unique_ptr<CdmUsageTable> usage_table_l3_;
|
||||||
|
|
||||||
std::string request_id_;
|
std::string request_id_;
|
||||||
static std::atomic<uint64_t> request_id_index_source_;
|
static std::atomic<uint64_t> request_id_index_source_;
|
||||||
|
|||||||
@@ -97,8 +97,8 @@ class DeviceFiles {
|
|||||||
// App parameters.
|
// App parameters.
|
||||||
CdmAppParameterMap app_parameters;
|
CdmAppParameterMap app_parameters;
|
||||||
// Usage entry and index.
|
// Usage entry and index.
|
||||||
CdmUsageEntry usage_entry;
|
UsageEntry usage_entry;
|
||||||
uint32_t usage_entry_number;
|
UsageEntryIndex usage_entry_index;
|
||||||
std::string drm_certificate;
|
std::string drm_certificate;
|
||||||
CryptoWrappedKey wrapped_private_key;
|
CryptoWrappedKey wrapped_private_key;
|
||||||
};
|
};
|
||||||
@@ -108,8 +108,8 @@ class DeviceFiles {
|
|||||||
CdmKeyMessage license_request;
|
CdmKeyMessage license_request;
|
||||||
CdmKeyResponse license;
|
CdmKeyResponse license;
|
||||||
std::string key_set_id;
|
std::string key_set_id;
|
||||||
CdmUsageEntry usage_entry;
|
UsageEntry usage_entry;
|
||||||
uint32_t usage_entry_number;
|
UsageEntryIndex usage_entry_index;
|
||||||
std::string drm_certificate;
|
std::string drm_certificate;
|
||||||
CryptoWrappedKey wrapped_private_key;
|
CryptoWrappedKey wrapped_private_key;
|
||||||
};
|
};
|
||||||
@@ -180,7 +180,7 @@ class DeviceFiles {
|
|||||||
const std::string& provider_session_token,
|
const std::string& provider_session_token,
|
||||||
const CdmKeyMessage& key_request, const CdmKeyResponse& key_response,
|
const CdmKeyMessage& key_request, const CdmKeyResponse& key_response,
|
||||||
const std::string& usage_info_file_name, const std::string& key_set_id,
|
const std::string& usage_info_file_name, const std::string& key_set_id,
|
||||||
const CdmUsageEntry& usage_entry, uint32_t usage_entry_number,
|
const UsageEntry& usage_entry, UsageEntryIndex usage_entry_index,
|
||||||
const std::string& drm_certificate, const CryptoWrappedKey& wrapped_key);
|
const std::string& drm_certificate, const CryptoWrappedKey& wrapped_key);
|
||||||
|
|
||||||
// Retrieve usage identifying information stored on the file system.
|
// Retrieve usage identifying information stored on the file system.
|
||||||
@@ -233,8 +233,8 @@ class DeviceFiles {
|
|||||||
const std::string& provider_session_token,
|
const std::string& provider_session_token,
|
||||||
CdmKeyMessage* license_request,
|
CdmKeyMessage* license_request,
|
||||||
CdmKeyResponse* license_response,
|
CdmKeyResponse* license_response,
|
||||||
CdmUsageEntry* usage_entry,
|
UsageEntry* usage_entry,
|
||||||
uint32_t* usage_entry_number,
|
UsageEntryIndex* usage_entry_index,
|
||||||
std::string* drm_certificate,
|
std::string* drm_certificate,
|
||||||
CryptoWrappedKey* wrapped_key);
|
CryptoWrappedKey* wrapped_key);
|
||||||
// Retrieve the usage info entry specified by |key_set_id|.
|
// Retrieve the usage info entry specified by |key_set_id|.
|
||||||
@@ -242,8 +242,8 @@ class DeviceFiles {
|
|||||||
virtual bool RetrieveUsageInfoByKeySetId(
|
virtual bool RetrieveUsageInfoByKeySetId(
|
||||||
const std::string& usage_info_file_name, const std::string& key_set_id,
|
const std::string& usage_info_file_name, const std::string& key_set_id,
|
||||||
std::string* provider_session_token, CdmKeyMessage* license_request,
|
std::string* provider_session_token, CdmKeyMessage* license_request,
|
||||||
CdmKeyResponse* license_response, CdmUsageEntry* usage_entry,
|
CdmKeyResponse* license_response, UsageEntry* usage_entry,
|
||||||
uint32_t* usage_entry_number, std::string* drm_certificate,
|
UsageEntryIndex* usage_entry_index, std::string* drm_certificate,
|
||||||
CryptoWrappedKey* wrapped_key);
|
CryptoWrappedKey* wrapped_key);
|
||||||
|
|
||||||
// These APIs support upgrading from usage tables to usage tabler header +
|
// These APIs support upgrading from usage tables to usage tabler header +
|
||||||
@@ -271,15 +271,15 @@ class DeviceFiles {
|
|||||||
virtual bool DeleteHlsAttributes(const std::string& key_set_id);
|
virtual bool DeleteHlsAttributes(const std::string& key_set_id);
|
||||||
|
|
||||||
virtual bool StoreUsageTableInfo(
|
virtual bool StoreUsageTableInfo(
|
||||||
const CdmUsageTableHeader& usage_table_header,
|
const UsageTableHeader& usage_table_header,
|
||||||
const std::vector<CdmUsageEntryInfo>& usage_entry_info);
|
const std::vector<CdmUsageEntryInfo>& usage_entry_info_list);
|
||||||
|
|
||||||
// When retrieving usage table information from the file system; any
|
// When retrieving usage table information from the file system; any
|
||||||
// table that has yet to be updated for the LRU attributes will be
|
// table that has yet to be updated for the LRU attributes will be
|
||||||
// indicated by |lru_upgrade|.
|
// indicated by |lru_upgrade|.
|
||||||
virtual bool RetrieveUsageTableInfo(
|
virtual bool RetrieveUsageTableInfo(
|
||||||
CdmUsageTableHeader* usage_table_header,
|
UsageTableHeader* usage_table_header,
|
||||||
std::vector<CdmUsageEntryInfo>* usage_entry_info, bool* lru_upgrade);
|
std::vector<CdmUsageEntryInfo>* usage_entry_info_list, bool* lru_upgrade);
|
||||||
|
|
||||||
virtual bool DeleteUsageTableInfo();
|
virtual bool DeleteUsageTableInfo();
|
||||||
|
|
||||||
|
|||||||
@@ -25,7 +25,6 @@ using CdmSecureStopId = std::string;
|
|||||||
using CdmSessionId = std::string;
|
using CdmSessionId = std::string;
|
||||||
using CdmKeySetId = std::string;
|
using CdmKeySetId = std::string;
|
||||||
using RequestId = std::string;
|
using RequestId = std::string;
|
||||||
using CryptoResult = uint32_t;
|
|
||||||
using CryptoSessionId = uint32_t;
|
using CryptoSessionId = uint32_t;
|
||||||
using EntitledKeySessionId = uint32_t;
|
using EntitledKeySessionId = uint32_t;
|
||||||
using CdmAppParameterMap = std::map<std::string, std::string>;
|
using CdmAppParameterMap = std::map<std::string, std::string>;
|
||||||
@@ -34,8 +33,11 @@ using CdmUsageInfo = std::vector<std::string>;
|
|||||||
using CdmUsageInfoReleaseMessage = std::string;
|
using CdmUsageInfoReleaseMessage = std::string;
|
||||||
using CdmProvisioningRequest = std::string;
|
using CdmProvisioningRequest = std::string;
|
||||||
using CdmProvisioningResponse = std::string;
|
using CdmProvisioningResponse = std::string;
|
||||||
using CdmUsageTableHeader = std::string;
|
|
||||||
using CdmUsageEntry = std::string;
|
// OEMCrypto's usage table information.
|
||||||
|
using UsageTableHeader = std::string;
|
||||||
|
using UsageEntry = std::string;
|
||||||
|
using UsageEntryIndex = uint32_t;
|
||||||
|
|
||||||
enum CdmKeyRequestType : uint32_t {
|
enum CdmKeyRequestType : uint32_t {
|
||||||
kKeyRequestTypeUnknown,
|
kKeyRequestTypeUnknown,
|
||||||
|
|||||||
@@ -607,11 +607,11 @@ CdmResponseType CdmEngine::QueryStatus(RequestedSecurityLevel security_level,
|
|||||||
}
|
}
|
||||||
if (query_token == QUERY_KEY_USAGE_SUPPORT) {
|
if (query_token == QUERY_KEY_USAGE_SUPPORT) {
|
||||||
bool supports_usage_reporting;
|
bool supports_usage_reporting;
|
||||||
const bool got_info = crypto_session->HasUsageInfoSupport(
|
const bool got_info = crypto_session->HasUsageTableSupport(
|
||||||
security_level, &supports_usage_reporting);
|
security_level, &supports_usage_reporting);
|
||||||
|
|
||||||
if (!got_info) {
|
if (!got_info) {
|
||||||
LOGW("HasUsageInfoSupport failed");
|
LOGW("HasUsageTableSupport failed");
|
||||||
metrics_->GetCryptoMetrics()
|
metrics_->GetCryptoMetrics()
|
||||||
->crypto_session_usage_information_support_.SetError(got_info);
|
->crypto_session_usage_information_support_.SetError(got_info);
|
||||||
return CdmResponseType(UNKNOWN_ERROR);
|
return CdmResponseType(UNKNOWN_ERROR);
|
||||||
@@ -1632,7 +1632,7 @@ CdmResponseType CdmEngine::RemoveAllUsageInfo(
|
|||||||
usage_session_.reset(new CdmSession(file_system_, metrics_->AddSession()));
|
usage_session_.reset(new CdmSession(file_system_, metrics_->AddSession()));
|
||||||
usage_session_->Init(usage_property_set_.get());
|
usage_session_->Init(usage_property_set_.get());
|
||||||
|
|
||||||
if (usage_session_->supports_usage_info()) {
|
if (usage_session_->SupportsUsageTable()) {
|
||||||
std::vector<DeviceFiles::CdmUsageData> usage_data;
|
std::vector<DeviceFiles::CdmUsageData> usage_data;
|
||||||
// Retrieve all usage information but delete only one before
|
// Retrieve all usage information but delete only one before
|
||||||
// refetching. This is because deleting the usage entry
|
// refetching. This is because deleting the usage entry
|
||||||
@@ -1647,7 +1647,7 @@ CdmResponseType CdmEngine::RemoveAllUsageInfo(
|
|||||||
if (usage_data.empty()) break;
|
if (usage_data.empty()) break;
|
||||||
|
|
||||||
CdmResponseType res =
|
CdmResponseType res =
|
||||||
usage_session_->DeleteUsageEntry(usage_data[0].usage_entry_number);
|
usage_session_->DeleteUsageEntry(usage_data[0].usage_entry_index);
|
||||||
|
|
||||||
if (res != NO_ERROR) {
|
if (res != NO_ERROR) {
|
||||||
LOGW("Failed to delete usage entry: status = %d",
|
LOGW("Failed to delete usage entry: status = %d",
|
||||||
@@ -1710,21 +1710,21 @@ CdmResponseType CdmEngine::RemoveUsageInfo(
|
|||||||
|
|
||||||
CdmKeyMessage license_request;
|
CdmKeyMessage license_request;
|
||||||
CdmKeyResponse license_response;
|
CdmKeyResponse license_response;
|
||||||
CdmUsageEntry usage_entry;
|
UsageEntry usage_entry;
|
||||||
uint32_t usage_entry_number;
|
UsageEntryIndex usage_entry_index;
|
||||||
std::string drm_certificate;
|
std::string drm_certificate;
|
||||||
CryptoWrappedKey wrapped_private_key;
|
CryptoWrappedKey wrapped_private_key;
|
||||||
|
|
||||||
if (!handle.RetrieveUsageInfo(
|
if (!handle.RetrieveUsageInfo(
|
||||||
DeviceFiles::GetUsageInfoFileName(app_id), provider_session_token,
|
DeviceFiles::GetUsageInfoFileName(app_id), provider_session_token,
|
||||||
&license_request, &license_response, &usage_entry,
|
&license_request, &license_response, &usage_entry,
|
||||||
&usage_entry_number, &drm_certificate, &wrapped_private_key)) {
|
&usage_entry_index, &drm_certificate, &wrapped_private_key)) {
|
||||||
// Try other security level
|
// Try other security level
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (usage_session_->supports_usage_info()) {
|
if (usage_session_->SupportsUsageTable()) {
|
||||||
status = usage_session_->DeleteUsageEntry(usage_entry_number);
|
status = usage_session_->DeleteUsageEntry(usage_entry_index);
|
||||||
if (!handle.DeleteUsageInfo(DeviceFiles::GetUsageInfoFileName(app_id),
|
if (!handle.DeleteUsageInfo(DeviceFiles::GetUsageInfoFileName(app_id),
|
||||||
provider_session_token)) {
|
provider_session_token)) {
|
||||||
status = CdmResponseType(REMOVE_USAGE_INFO_ERROR_1);
|
status = CdmResponseType(REMOVE_USAGE_INFO_ERROR_1);
|
||||||
@@ -1791,7 +1791,7 @@ CdmResponseType CdmEngine::LoadUsageSession(const CdmKeySetId& key_set_id,
|
|||||||
DeviceFiles::GetUsageInfoFileName(app_id), key_set_id,
|
DeviceFiles::GetUsageInfoFileName(app_id), key_set_id,
|
||||||
&(usage_data.provider_session_token), &(usage_data.license_request),
|
&(usage_data.provider_session_token), &(usage_data.license_request),
|
||||||
&(usage_data.license), &(usage_data.usage_entry),
|
&(usage_data.license), &(usage_data.usage_entry),
|
||||||
&(usage_data.usage_entry_number), &(usage_data.drm_certificate),
|
&(usage_data.usage_entry_index), &(usage_data.drm_certificate),
|
||||||
&(usage_data.wrapped_private_key))) {
|
&(usage_data.wrapped_private_key))) {
|
||||||
LOGE("Unable to find usage information");
|
LOGE("Unable to find usage information");
|
||||||
return CdmResponseType(LOAD_USAGE_INFO_MISSING);
|
return CdmResponseType(LOAD_USAGE_INFO_MISSING);
|
||||||
@@ -2120,7 +2120,7 @@ void CdmEngine::OnTimerEvent() {
|
|||||||
for (CdmSessionList::iterator iter = sessions.begin();
|
for (CdmSessionList::iterator iter = sessions.begin();
|
||||||
iter != sessions.end(); ++iter) {
|
iter != sessions.end(); ++iter) {
|
||||||
(*iter)->reset_usage_flags();
|
(*iter)->reset_usage_flags();
|
||||||
if ((*iter)->supports_usage_info() &&
|
if ((*iter)->SupportsUsageTable() &&
|
||||||
(*iter)->has_provider_session_token()) {
|
(*iter)->has_provider_session_token()) {
|
||||||
(*iter)->UpdateUsageEntryInformation();
|
(*iter)->UpdateUsageEntryInformation();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,13 +13,13 @@
|
|||||||
|
|
||||||
#include "cdm_engine.h"
|
#include "cdm_engine.h"
|
||||||
#include "cdm_random.h"
|
#include "cdm_random.h"
|
||||||
|
#include "cdm_usage_table.h"
|
||||||
#include "clock.h"
|
#include "clock.h"
|
||||||
#include "crypto_wrapped_key.h"
|
#include "crypto_wrapped_key.h"
|
||||||
#include "file_store.h"
|
#include "file_store.h"
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
#include "properties.h"
|
#include "properties.h"
|
||||||
#include "string_conversions.h"
|
#include "string_conversions.h"
|
||||||
#include "usage_table_header.h"
|
|
||||||
#include "wv_cdm_constants.h"
|
#include "wv_cdm_constants.h"
|
||||||
#include "wv_cdm_event_listener.h"
|
#include "wv_cdm_event_listener.h"
|
||||||
|
|
||||||
@@ -81,8 +81,6 @@ CdmSession::CdmSession(wvutil::FileSystem* file_system,
|
|||||||
requested_security_level_(kLevelDefault),
|
requested_security_level_(kLevelDefault),
|
||||||
is_initial_usage_update_(true),
|
is_initial_usage_update_(true),
|
||||||
is_usage_update_needed_(false),
|
is_usage_update_needed_(false),
|
||||||
usage_table_header_(nullptr),
|
|
||||||
usage_entry_number_(0),
|
|
||||||
mock_license_parser_in_use_(false),
|
mock_license_parser_in_use_(false),
|
||||||
mock_policy_engine_in_use_(false) {
|
mock_policy_engine_in_use_(false) {
|
||||||
assert(metrics_); // metrics_ must not be null.
|
assert(metrics_); // metrics_ must not be null.
|
||||||
@@ -92,7 +90,7 @@ CdmSession::CdmSession(wvutil::FileSystem* file_system,
|
|||||||
}
|
}
|
||||||
|
|
||||||
CdmSession::~CdmSession() {
|
CdmSession::~CdmSession() {
|
||||||
if (has_provider_session_token() && supports_usage_info() && !is_release_) {
|
if (has_provider_session_token() && SupportsUsageTable() && !is_release_) {
|
||||||
UpdateUsageEntryInformation();
|
UpdateUsageEntryInformation();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -149,8 +147,8 @@ CdmResponseType CdmSession::Init(CdmClientPropertySet* cdm_client_property_set,
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool has_support = false;
|
bool has_support = false;
|
||||||
if (crypto_session_->HasUsageInfoSupport(&has_support) && has_support) {
|
if (crypto_session_->HasUsageTableSupport(&has_support) && has_support) {
|
||||||
usage_table_header_ = crypto_session_->GetUsageTableHeader();
|
usage_table_ = crypto_session_->GetUsageTable();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cdm_client_property_set != nullptr)
|
if (cdm_client_property_set != nullptr)
|
||||||
@@ -247,7 +245,7 @@ CdmResponseType CdmSession::RestoreOfflineSession(const CdmKeySetId& key_set_id,
|
|||||||
offline_release_server_url_ = std::move(license_data.release_server_url);
|
offline_release_server_url_ = std::move(license_data.release_server_url);
|
||||||
app_parameters_ = std::move(license_data.app_parameters);
|
app_parameters_ = std::move(license_data.app_parameters);
|
||||||
usage_entry_ = std::move(license_data.usage_entry);
|
usage_entry_ = std::move(license_data.usage_entry);
|
||||||
usage_entry_number_ = license_data.usage_entry_number;
|
usage_entry_index_ = license_data.usage_entry_index;
|
||||||
|
|
||||||
CdmResponseType result = LoadPrivateOrLegacyKey(
|
CdmResponseType result = LoadPrivateOrLegacyKey(
|
||||||
license_data.drm_certificate, license_data.wrapped_private_key);
|
license_data.drm_certificate, license_data.wrapped_private_key);
|
||||||
@@ -273,7 +271,7 @@ CdmResponseType CdmSession::RestoreOfflineSession(const CdmKeySetId& key_set_id,
|
|||||||
|
|
||||||
std::string provider_session_token;
|
std::string provider_session_token;
|
||||||
bool sign_fake_request = false; // TODO(b/169483174): remove this variable.
|
bool sign_fake_request = false; // TODO(b/169483174): remove this variable.
|
||||||
if (supports_usage_info()) {
|
if (SupportsUsageTable()) {
|
||||||
if (!license_parser_->ExtractProviderSessionToken(
|
if (!license_parser_->ExtractProviderSessionToken(
|
||||||
key_response_, &provider_session_token)) {
|
key_response_, &provider_session_token)) {
|
||||||
provider_session_token.clear();
|
provider_session_token.clear();
|
||||||
@@ -282,8 +280,8 @@ CdmResponseType CdmSession::RestoreOfflineSession(const CdmKeySetId& key_set_id,
|
|||||||
LOGE("License usage entry is invalid, cannot restore");
|
LOGE("License usage entry is invalid, cannot restore");
|
||||||
return CdmResponseType(LICENSE_USAGE_ENTRY_MISSING);
|
return CdmResponseType(LICENSE_USAGE_ENTRY_MISSING);
|
||||||
} else {
|
} else {
|
||||||
CdmResponseType sts = usage_table_header_->LoadEntry(
|
CdmResponseType sts = usage_table_->LoadEntry(
|
||||||
crypto_session_.get(), usage_entry_, usage_entry_number_);
|
crypto_session_.get(), usage_entry_, usage_entry_index_);
|
||||||
crypto_metrics_->usage_table_header_load_entry_.Increment(sts);
|
crypto_metrics_->usage_table_header_load_entry_.Increment(sts);
|
||||||
if (sts == LOAD_USAGE_ENTRY_INVALID_SESSION) {
|
if (sts == LOAD_USAGE_ENTRY_INVALID_SESSION) {
|
||||||
LOGE("License loaded in different session: key_set_id = %s",
|
LOGE("License loaded in different session: key_set_id = %s",
|
||||||
@@ -340,9 +338,9 @@ CdmResponseType CdmSession::RestoreOfflineSession(const CdmKeySetId& key_set_id,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!provider_session_token.empty() && supports_usage_info()) {
|
if (!provider_session_token.empty() && SupportsUsageTable()) {
|
||||||
CdmResponseType sts = usage_table_header_->UpdateEntry(
|
CdmResponseType sts = usage_table_->UpdateEntry(
|
||||||
usage_entry_number_, crypto_session_.get(), &usage_entry_);
|
usage_entry_index_, crypto_session_.get(), &usage_entry_);
|
||||||
if (sts != NO_ERROR) {
|
if (sts != NO_ERROR) {
|
||||||
LOGE("Failed to update usage entry: status = %d", static_cast<int>(sts));
|
LOGE("Failed to update usage entry: status = %d", static_cast<int>(sts));
|
||||||
return sts;
|
return sts;
|
||||||
@@ -372,7 +370,7 @@ CdmResponseType CdmSession::RestoreUsageSession(
|
|||||||
key_request_ = usage_data.license_request;
|
key_request_ = usage_data.license_request;
|
||||||
key_response_ = usage_data.license;
|
key_response_ = usage_data.license;
|
||||||
usage_entry_ = usage_data.usage_entry;
|
usage_entry_ = usage_data.usage_entry;
|
||||||
usage_entry_number_ = usage_data.usage_entry_number;
|
usage_entry_index_ = usage_data.usage_entry_index;
|
||||||
usage_provider_session_token_ = usage_data.provider_session_token;
|
usage_provider_session_token_ = usage_data.provider_session_token;
|
||||||
|
|
||||||
CdmResponseType status = LoadPrivateOrLegacyKey(
|
CdmResponseType status = LoadPrivateOrLegacyKey(
|
||||||
@@ -380,9 +378,9 @@ CdmResponseType CdmSession::RestoreUsageSession(
|
|||||||
if (status != NO_ERROR) return status;
|
if (status != NO_ERROR) return status;
|
||||||
|
|
||||||
CdmResponseType sts(NO_ERROR);
|
CdmResponseType sts(NO_ERROR);
|
||||||
if (supports_usage_info()) {
|
if (SupportsUsageTable()) {
|
||||||
sts = usage_table_header_->LoadEntry(crypto_session_.get(), usage_entry_,
|
sts = usage_table_->LoadEntry(crypto_session_.get(), usage_entry_,
|
||||||
usage_entry_number_);
|
usage_entry_index_);
|
||||||
crypto_metrics_->usage_table_header_load_entry_.Increment(sts);
|
crypto_metrics_->usage_table_header_load_entry_.Increment(sts);
|
||||||
if (sts != NO_ERROR) {
|
if (sts != NO_ERROR) {
|
||||||
LOGE("Failed to load usage entry: status = %d", static_cast<int>(sts));
|
LOGE("Failed to load usage entry: status = %d", static_cast<int>(sts));
|
||||||
@@ -398,9 +396,9 @@ CdmResponseType CdmSession::RestoreUsageSession(
|
|||||||
return CdmResponseType(RELEASE_LICENSE_ERROR_2);
|
return CdmResponseType(RELEASE_LICENSE_ERROR_2);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (supports_usage_info()) {
|
if (SupportsUsageTable()) {
|
||||||
sts = usage_table_header_->UpdateEntry(
|
sts = usage_table_->UpdateEntry(usage_entry_index_, crypto_session_.get(),
|
||||||
usage_entry_number_, crypto_session_.get(), &usage_entry_);
|
&usage_entry_);
|
||||||
if (sts != NO_ERROR) {
|
if (sts != NO_ERROR) {
|
||||||
LOGE("Failed to update usage entry: status = %d", static_cast<int>(sts));
|
LOGE("Failed to update usage entry: status = %d", static_cast<int>(sts));
|
||||||
return sts;
|
return sts;
|
||||||
@@ -541,16 +539,16 @@ CdmResponseType CdmSession::AddKeyInternal(const CdmKeyResponse& key_response) {
|
|||||||
// to be created.
|
// to be created.
|
||||||
CdmResponseType sts;
|
CdmResponseType sts;
|
||||||
std::string provider_session_token;
|
std::string provider_session_token;
|
||||||
if (supports_usage_info()) {
|
if (SupportsUsageTable()) {
|
||||||
if (license_parser_->ExtractProviderSessionToken(key_response,
|
if (license_parser_->ExtractProviderSessionToken(key_response,
|
||||||
&provider_session_token) &&
|
&provider_session_token) &&
|
||||||
!provider_session_token.empty()) {
|
!provider_session_token.empty()) {
|
||||||
std::string app_id;
|
std::string app_id;
|
||||||
GetApplicationId(&app_id);
|
GetApplicationId(&app_id);
|
||||||
sts = usage_table_header_->AddEntry(
|
sts = usage_table_->AddEntry(crypto_session_.get(), is_offline_,
|
||||||
crypto_session_.get(), is_offline_, key_set_id_,
|
key_set_id_,
|
||||||
DeviceFiles::GetUsageInfoFileName(app_id), key_response,
|
DeviceFiles::GetUsageInfoFileName(app_id),
|
||||||
&usage_entry_number_);
|
key_response, &usage_entry_index_);
|
||||||
crypto_metrics_->usage_table_header_add_entry_.Increment(sts);
|
crypto_metrics_->usage_table_header_add_entry_.Increment(sts);
|
||||||
if (sts != NO_ERROR) return sts;
|
if (sts != NO_ERROR) return sts;
|
||||||
}
|
}
|
||||||
@@ -565,11 +563,10 @@ CdmResponseType CdmSession::AddKeyInternal(const CdmKeyResponse& key_response) {
|
|||||||
version_info.license_service_version());
|
version_info.license_service_version());
|
||||||
|
|
||||||
// Update or invalidate entry if usage table header+entries are supported
|
// Update or invalidate entry if usage table header+entries are supported
|
||||||
if (!provider_session_token.empty() && supports_usage_info()) {
|
if (!provider_session_token.empty() && SupportsUsageTable()) {
|
||||||
if (sts != KEY_ADDED) {
|
if (sts != KEY_ADDED) {
|
||||||
const CdmResponseType invalidate_sts =
|
const CdmResponseType invalidate_sts = usage_table_->InvalidateEntry(
|
||||||
usage_table_header_->InvalidateEntry(
|
usage_entry_index_, true, file_handle_.get(), crypto_metrics_);
|
||||||
usage_entry_number_, true, file_handle_.get(), crypto_metrics_);
|
|
||||||
crypto_metrics_->usage_table_header_delete_entry_.Increment(
|
crypto_metrics_->usage_table_header_delete_entry_.Increment(
|
||||||
invalidate_sts);
|
invalidate_sts);
|
||||||
if (invalidate_sts != NO_ERROR) {
|
if (invalidate_sts != NO_ERROR) {
|
||||||
@@ -590,9 +587,9 @@ CdmResponseType CdmSession::AddKeyInternal(const CdmKeyResponse& key_response) {
|
|||||||
license_parser_->provider_session_token().size());
|
license_parser_->provider_session_token().size());
|
||||||
|
|
||||||
if ((is_offline_ || has_provider_session_token()) && !is_temporary_) {
|
if ((is_offline_ || has_provider_session_token()) && !is_temporary_) {
|
||||||
if (has_provider_session_token() && supports_usage_info()) {
|
if (has_provider_session_token() && SupportsUsageTable()) {
|
||||||
usage_table_header_->UpdateEntry(usage_entry_number_,
|
usage_table_->UpdateEntry(usage_entry_index_, crypto_session_.get(),
|
||||||
crypto_session_.get(), &usage_entry_);
|
&usage_entry_);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!is_offline_)
|
if (!is_offline_)
|
||||||
@@ -790,16 +787,16 @@ CdmResponseType CdmSession::GenerateReleaseRequest(CdmKeyRequest* key_request) {
|
|||||||
is_release_ = true;
|
is_release_ = true;
|
||||||
license_request_latency_.Clear();
|
license_request_latency_.Clear();
|
||||||
CdmResponseType status = license_parser_->PrepareKeyUpdateRequest(
|
CdmResponseType status = license_parser_->PrepareKeyUpdateRequest(
|
||||||
false, app_parameters_, usage_table_header_ == nullptr ? nullptr : this,
|
false, app_parameters_, usage_table_ == nullptr ? nullptr : this,
|
||||||
&key_request->message, &key_request->url);
|
&key_request->message, &key_request->url);
|
||||||
|
|
||||||
key_request->type = kKeyRequestTypeRelease;
|
key_request->type = kKeyRequestTypeRelease;
|
||||||
|
|
||||||
if (KEY_MESSAGE != status) return status;
|
if (KEY_MESSAGE != status) return status;
|
||||||
|
|
||||||
if (has_provider_session_token() && supports_usage_info()) {
|
if (has_provider_session_token() && SupportsUsageTable()) {
|
||||||
status = usage_table_header_->UpdateEntry(
|
status = usage_table_->UpdateEntry(usage_entry_index_,
|
||||||
usage_entry_number_, crypto_session_.get(), &usage_entry_);
|
crypto_session_.get(), &usage_entry_);
|
||||||
|
|
||||||
if (status != NO_ERROR) {
|
if (status != NO_ERROR) {
|
||||||
LOGE("Update usage entry failed: status = %d", static_cast<int>(status));
|
LOGE("Update usage entry failed: status = %d", static_cast<int>(status));
|
||||||
@@ -811,7 +808,7 @@ CdmResponseType CdmSession::GenerateReleaseRequest(CdmKeyRequest* key_request) {
|
|||||||
if (!StoreLicense(kLicenseStateReleasing, nullptr))
|
if (!StoreLicense(kLicenseStateReleasing, nullptr))
|
||||||
return CdmResponseType(RELEASE_KEY_REQUEST_ERROR);
|
return CdmResponseType(RELEASE_KEY_REQUEST_ERROR);
|
||||||
} else if (!usage_provider_session_token_.empty()) {
|
} else if (!usage_provider_session_token_.empty()) {
|
||||||
if (supports_usage_info()) {
|
if (SupportsUsageTable()) {
|
||||||
if (!UpdateUsageInfo()) return CdmResponseType(RELEASE_USAGE_INFO_FAILED);
|
if (!UpdateUsageInfo()) return CdmResponseType(RELEASE_USAGE_INFO_FAILED);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -840,12 +837,12 @@ CdmResponseType CdmSession::ReleaseKey(const CdmKeyResponse& key_response) {
|
|||||||
return RemoveLicense();
|
return RemoveLicense();
|
||||||
}
|
}
|
||||||
|
|
||||||
CdmResponseType CdmSession::DeleteUsageEntry(uint32_t usage_entry_number) {
|
CdmResponseType CdmSession::DeleteUsageEntry(uint32_t usage_entry_index) {
|
||||||
if (!initialized_) {
|
if (!initialized_) {
|
||||||
LOGE("CDM session not initialized");
|
LOGE("CDM session not initialized");
|
||||||
return CdmResponseType(NOT_INITIALIZED_ERROR);
|
return CdmResponseType(NOT_INITIALIZED_ERROR);
|
||||||
}
|
}
|
||||||
if (!supports_usage_info()) {
|
if (!SupportsUsageTable()) {
|
||||||
LOGE("Cannot delete entry, usage table not supported");
|
LOGE("Cannot delete entry, usage table not supported");
|
||||||
return CdmResponseType(INCORRECT_USAGE_SUPPORT_TYPE_1);
|
return CdmResponseType(INCORRECT_USAGE_SUPPORT_TYPE_1);
|
||||||
}
|
}
|
||||||
@@ -860,19 +857,19 @@ CdmResponseType CdmSession::DeleteUsageEntry(uint32_t usage_entry_number) {
|
|||||||
crypto_metrics_, crypto_session_open_, sts, requested_security_level_);
|
crypto_metrics_, crypto_session_open_, sts, requested_security_level_);
|
||||||
if (sts != NO_ERROR) return sts;
|
if (sts != NO_ERROR) return sts;
|
||||||
|
|
||||||
usage_table_header_ = nullptr;
|
usage_table_ = nullptr;
|
||||||
bool has_support = false;
|
bool has_support = false;
|
||||||
if (crypto_session_->HasUsageInfoSupport(&has_support) && has_support) {
|
if (crypto_session_->HasUsageTableSupport(&has_support) && has_support) {
|
||||||
usage_table_header_ = crypto_session_->GetUsageTableHeader();
|
usage_table_ = crypto_session_->GetUsageTable();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (usage_table_header_ == nullptr) {
|
if (usage_table_ == nullptr) {
|
||||||
LOGE("Usage table header unavailable");
|
LOGE("Usage table header unavailable");
|
||||||
return CdmResponseType(INCORRECT_USAGE_SUPPORT_TYPE_1);
|
return CdmResponseType(INCORRECT_USAGE_SUPPORT_TYPE_1);
|
||||||
}
|
}
|
||||||
|
|
||||||
sts = usage_table_header_->InvalidateEntry(
|
sts = usage_table_->InvalidateEntry(usage_entry_index, true,
|
||||||
usage_entry_number, true, file_handle_.get(), crypto_metrics_);
|
file_handle_.get(), crypto_metrics_);
|
||||||
crypto_metrics_->usage_table_header_delete_entry_.Increment(sts);
|
crypto_metrics_->usage_table_header_delete_entry_.Increment(sts);
|
||||||
return sts;
|
return sts;
|
||||||
}
|
}
|
||||||
@@ -954,11 +951,11 @@ CdmResponseType CdmSession::StoreLicense() {
|
|||||||
if (!file_handle_->StoreUsageInfo(
|
if (!file_handle_->StoreUsageInfo(
|
||||||
provider_session_token, key_request_, key_response_,
|
provider_session_token, key_request_, key_response_,
|
||||||
DeviceFiles::GetUsageInfoFileName(app_id), key_set_id_, usage_entry_,
|
DeviceFiles::GetUsageInfoFileName(app_id), key_set_id_, usage_entry_,
|
||||||
usage_entry_number_, drm_certificate_, wrapped_private_key_)) {
|
usage_entry_index_, drm_certificate_, wrapped_private_key_)) {
|
||||||
LOGE("Unable to store usage info");
|
LOGE("Unable to store usage info");
|
||||||
// Usage info file is corrupt. Delete current usage entry and file.
|
// Usage info file is corrupt. Delete current usage entry and file.
|
||||||
if (supports_usage_info()) {
|
if (SupportsUsageTable()) {
|
||||||
DeleteUsageEntry(usage_entry_number_);
|
DeleteUsageEntry(usage_entry_index_);
|
||||||
} else {
|
} else {
|
||||||
LOGW("Cannot store, usage table not supported");
|
LOGW("Cannot store, usage table not supported");
|
||||||
}
|
}
|
||||||
@@ -987,7 +984,7 @@ bool CdmSession::StoreLicense(CdmOfflineLicenseState state, int* error_detail) {
|
|||||||
policy_engine_->GetGracePeriodEndTime(),
|
policy_engine_->GetGracePeriodEndTime(),
|
||||||
app_parameters_,
|
app_parameters_,
|
||||||
usage_entry_,
|
usage_entry_,
|
||||||
usage_entry_number_,
|
usage_entry_index_,
|
||||||
drm_certificate_,
|
drm_certificate_,
|
||||||
wrapped_private_key_};
|
wrapped_private_key_};
|
||||||
|
|
||||||
@@ -1011,8 +1008,8 @@ CdmResponseType CdmSession::RemoveKeys() {
|
|||||||
|
|
||||||
CdmResponseType CdmSession::RemoveLicense() {
|
CdmResponseType CdmSession::RemoveLicense() {
|
||||||
if (is_offline_ || has_provider_session_token()) {
|
if (is_offline_ || has_provider_session_token()) {
|
||||||
if (has_provider_session_token() && supports_usage_info()) {
|
if (has_provider_session_token() && SupportsUsageTable()) {
|
||||||
DeleteUsageEntry(usage_entry_number_);
|
DeleteUsageEntry(usage_entry_index_);
|
||||||
}
|
}
|
||||||
DeleteLicenseFile();
|
DeleteLicenseFile();
|
||||||
}
|
}
|
||||||
@@ -1061,9 +1058,9 @@ void CdmSession::GetApplicationId(std::string* app_id) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
CdmResponseType CdmSession::UpdateUsageEntryInformation() {
|
CdmResponseType CdmSession::UpdateUsageEntryInformation() {
|
||||||
if (!has_provider_session_token() || !supports_usage_info()) {
|
if (!has_provider_session_token() || !SupportsUsageTable()) {
|
||||||
LOGE("Unexpected state: usage_support = %s, PST present = %s, ",
|
LOGE("Unexpected state: usage_support = %s, PST present = %s, ",
|
||||||
supports_usage_info() ? "true" : "false",
|
SupportsUsageTable() ? "true" : "false",
|
||||||
has_provider_session_token() ? "yes" : "no");
|
has_provider_session_token() ? "yes" : "no");
|
||||||
return CdmResponseType(INCORRECT_USAGE_SUPPORT_TYPE_2);
|
return CdmResponseType(INCORRECT_USAGE_SUPPORT_TYPE_2);
|
||||||
}
|
}
|
||||||
@@ -1072,8 +1069,8 @@ CdmResponseType CdmSession::UpdateUsageEntryInformation() {
|
|||||||
// TODO(blueeyes): Add measurements to all UpdateEntry calls in a way that
|
// TODO(blueeyes): Add measurements to all UpdateEntry calls in a way that
|
||||||
// allos us to isolate this particular use case within
|
// allos us to isolate this particular use case within
|
||||||
// UpdateUsageEntryInformation.
|
// UpdateUsageEntryInformation.
|
||||||
M_TIME(sts = usage_table_header_->UpdateEntry(
|
M_TIME(sts = usage_table_->UpdateEntry(usage_entry_index_,
|
||||||
usage_entry_number_, crypto_session_.get(), &usage_entry_),
|
crypto_session_.get(), &usage_entry_),
|
||||||
crypto_metrics_, usage_table_header_update_entry_, sts);
|
crypto_metrics_, usage_table_header_update_entry_, sts);
|
||||||
|
|
||||||
if (sts != NO_ERROR) return sts;
|
if (sts != NO_ERROR) return sts;
|
||||||
@@ -1159,7 +1156,7 @@ bool CdmSession::UpdateUsageInfo() {
|
|||||||
usage_data.license = key_response_;
|
usage_data.license = key_response_;
|
||||||
usage_data.key_set_id = key_set_id_;
|
usage_data.key_set_id = key_set_id_;
|
||||||
usage_data.usage_entry = usage_entry_;
|
usage_data.usage_entry = usage_entry_;
|
||||||
usage_data.usage_entry_number = usage_entry_number_;
|
usage_data.usage_entry_index = usage_entry_index_;
|
||||||
|
|
||||||
return file_handle_->UpdateUsageInfo(
|
return file_handle_->UpdateUsageInfo(
|
||||||
DeviceFiles::GetUsageInfoFileName(app_id), usage_provider_session_token_,
|
DeviceFiles::GetUsageInfoFileName(app_id), usage_provider_session_token_,
|
||||||
@@ -1178,15 +1175,15 @@ bool CdmSession::VerifyOfflineUsageEntry() {
|
|||||||
// Check that the current license is the same as the expected
|
// Check that the current license is the same as the expected
|
||||||
// entry in the usage table. It is possible that the license has
|
// entry in the usage table. It is possible that the license has
|
||||||
// been removed from the usage table but the license file remains.
|
// been removed from the usage table but the license file remains.
|
||||||
if (usage_entry_number_ >= usage_table_header_->size()) {
|
if (usage_entry_index_ >= usage_table_->size()) {
|
||||||
LOGD("License usage entry does not exist: entry_number = %u, size = %zu",
|
LOGD("License usage entry does not exist: entry_index = %u, size = %zu",
|
||||||
usage_entry_number_, usage_table_header_->size());
|
usage_entry_index_, usage_table_->size());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
const CdmUsageEntryInfo& usage_entry_info =
|
const CdmUsageEntryInfo& entry_info =
|
||||||
usage_table_header_->usage_entry_info().at(usage_entry_number_);
|
usage_table_->entry_info_list().at(usage_entry_index_);
|
||||||
if (usage_entry_info.storage_type != kStorageLicense ||
|
if (entry_info.storage_type != kStorageLicense ||
|
||||||
usage_entry_info.key_set_id != key_set_id_) {
|
entry_info.key_set_id != key_set_id_) {
|
||||||
LOGD("License usage entry does not match");
|
LOGD("License usage entry does not match");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -229,9 +229,9 @@ CdmResponseType ClientIdentification::Prepare(
|
|||||||
client_capabilities->set_client_token(true);
|
client_capabilities->set_client_token(true);
|
||||||
|
|
||||||
if (is_license_request_) {
|
if (is_license_request_) {
|
||||||
bool supports_usage_information;
|
bool supports_usage_table;
|
||||||
if (crypto_session_->HasUsageInfoSupport(&supports_usage_information)) {
|
if (crypto_session_->HasUsageTableSupport(&supports_usage_table)) {
|
||||||
client_capabilities->set_session_token(supports_usage_information);
|
client_capabilities->set_session_token(supports_usage_table);
|
||||||
}
|
}
|
||||||
|
|
||||||
client_capabilities->set_anti_rollback_usage_table(
|
client_capabilities->set_anti_rollback_usage_table(
|
||||||
|
|||||||
@@ -17,6 +17,7 @@
|
|||||||
#include "advance_iv_ctr.h"
|
#include "advance_iv_ctr.h"
|
||||||
#include "arraysize.h"
|
#include "arraysize.h"
|
||||||
#include "cdm_random.h"
|
#include "cdm_random.h"
|
||||||
|
#include "cdm_usage_table.h"
|
||||||
#include "content_key_session.h"
|
#include "content_key_session.h"
|
||||||
#include "crypto_key.h"
|
#include "crypto_key.h"
|
||||||
#include "entitlement_key_session.h"
|
#include "entitlement_key_session.h"
|
||||||
@@ -28,7 +29,6 @@
|
|||||||
#include "properties.h"
|
#include "properties.h"
|
||||||
#include "pst_report.h"
|
#include "pst_report.h"
|
||||||
#include "string_conversions.h"
|
#include "string_conversions.h"
|
||||||
#include "usage_table_header.h"
|
|
||||||
#include "wv_cdm_constants.h"
|
#include "wv_cdm_constants.h"
|
||||||
|
|
||||||
// Stringify turns macro arguments into static C strings.
|
// Stringify turns macro arguments into static C strings.
|
||||||
@@ -211,8 +211,8 @@ bool CryptoSession::initialized_ = false;
|
|||||||
bool CryptoSession::needs_keybox_provisioning_ = false;
|
bool CryptoSession::needs_keybox_provisioning_ = false;
|
||||||
int CryptoSession::session_count_ = 0;
|
int CryptoSession::session_count_ = 0;
|
||||||
int CryptoSession::termination_counter_ = 0;
|
int CryptoSession::termination_counter_ = 0;
|
||||||
std::unique_ptr<UsageTableHeader> CryptoSession::usage_table_header_l1_;
|
std::unique_ptr<CdmUsageTable> CryptoSession::usage_table_l1_;
|
||||||
std::unique_ptr<UsageTableHeader> CryptoSession::usage_table_header_l3_;
|
std::unique_ptr<CdmUsageTable> CryptoSession::usage_table_l3_;
|
||||||
std::recursive_mutex CryptoSession::usage_table_mutex_;
|
std::recursive_mutex CryptoSession::usage_table_mutex_;
|
||||||
std::atomic<uint64_t> CryptoSession::request_id_index_source_(0);
|
std::atomic<uint64_t> CryptoSession::request_id_index_source_(0);
|
||||||
std::unique_ptr<okp::SystemFallbackPolicy>
|
std::unique_ptr<okp::SystemFallbackPolicy>
|
||||||
@@ -400,8 +400,8 @@ void CryptoSession::ReinitializeForTest() {
|
|||||||
}
|
}
|
||||||
initialized_ = false;
|
initialized_ = false;
|
||||||
// Tables will be reinitialized by tests when needed.
|
// Tables will be reinitialized by tests when needed.
|
||||||
usage_table_header_l1_.reset();
|
usage_table_l1_.reset();
|
||||||
usage_table_header_l3_.reset();
|
usage_table_l3_.reset();
|
||||||
}
|
}
|
||||||
// Give up if we cannot initialize at all.
|
// Give up if we cannot initialize at all.
|
||||||
const OEMCryptoResult status = OEMCrypto_Initialize();
|
const OEMCryptoResult status = OEMCrypto_Initialize();
|
||||||
@@ -479,8 +479,8 @@ bool CryptoSession::TryTerminate() {
|
|||||||
});
|
});
|
||||||
if (terminated) {
|
if (terminated) {
|
||||||
UsageTableLock lock(usage_table_mutex_);
|
UsageTableLock lock(usage_table_mutex_);
|
||||||
usage_table_header_l1_.reset();
|
usage_table_l1_.reset();
|
||||||
usage_table_header_l3_.reset();
|
usage_table_l3_.reset();
|
||||||
}
|
}
|
||||||
return terminated;
|
return terminated;
|
||||||
}
|
}
|
||||||
@@ -491,9 +491,9 @@ void CryptoSession::DisableDelayedTermination() {
|
|||||||
[&] { termination_counter_ = 0; });
|
[&] { termination_counter_ = 0; });
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CryptoSession::SetUpUsageTableHeader(
|
bool CryptoSession::SetUpUsageTable(
|
||||||
RequestedSecurityLevel requested_security_level) {
|
RequestedSecurityLevel requested_security_level) {
|
||||||
if (usage_table_header_ != nullptr) {
|
if (usage_table_ != nullptr) {
|
||||||
LOGE("Usage table is already set up for the current crypto session");
|
LOGE("Usage table is already set up for the current crypto session");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -508,7 +508,7 @@ bool CryptoSession::SetUpUsageTableHeader(
|
|||||||
|
|
||||||
// Check if usage support is available.
|
// Check if usage support is available.
|
||||||
bool supports_usage_table = false;
|
bool supports_usage_table = false;
|
||||||
if (!HasUsageInfoSupport(requested_security_level, &supports_usage_table)) {
|
if (!HasUsageTableSupport(requested_security_level, &supports_usage_table)) {
|
||||||
metrics_->oemcrypto_usage_table_support_.SetError(
|
metrics_->oemcrypto_usage_table_support_.SetError(
|
||||||
USAGE_INFORMATION_SUPPORT_FAILED);
|
USAGE_INFORMATION_SUPPORT_FAILED);
|
||||||
return false;
|
return false;
|
||||||
@@ -519,30 +519,28 @@ bool CryptoSession::SetUpUsageTableHeader(
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
LOGV("Usage table lock: SetUpUsageTableHeader()");
|
LOGV("Usage table lock: SetUpUsageTable()");
|
||||||
UsageTableLock auto_lock(usage_table_mutex_);
|
UsageTableLock auto_lock(usage_table_mutex_);
|
||||||
// TODO(b/141350978): Prevent any recursive logic.
|
// TODO(b/141350978): Prevent any recursive logic.
|
||||||
|
|
||||||
// Manipulate only the usage table for the requested security level.
|
// Manipulate only the usage table for the requested security level.
|
||||||
std::unique_ptr<UsageTableHeader>& header = security_level == kSecurityLevelL1
|
std::unique_ptr<CdmUsageTable>& table =
|
||||||
? usage_table_header_l1_
|
security_level == kSecurityLevelL1 ? usage_table_l1_ : usage_table_l3_;
|
||||||
: usage_table_header_l3_;
|
if (!table) {
|
||||||
if (!header) {
|
|
||||||
// This may be called twice within the same thread when the table
|
// This may be called twice within the same thread when the table
|
||||||
// is initialized. On the second call |header| will not be null,
|
// is initialized. On the second call |header| will not be null,
|
||||||
// causing this block to be skipped.
|
// causing this block to be skipped.
|
||||||
header.reset(new UsageTableHeader());
|
table.reset(new CdmUsageTable());
|
||||||
if (!header->Init(security_level, this)) {
|
if (!table->Init(security_level, this)) {
|
||||||
LOGE("Failed to initialize and sync usage usage table");
|
LOGE("Failed to initialize and sync usage usage table");
|
||||||
// Must be cleared globally to prevent the next session to be
|
// Must be cleared globally to prevent the next session to be
|
||||||
// opened from using the invalid UsageTableHeader.
|
// opened from using the invalid CdmUsageTable.
|
||||||
header.reset();
|
table.reset();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
usage_table_header_ = header.get();
|
usage_table_ = table.get();
|
||||||
metrics_->usage_table_header_initial_size_.Record(
|
metrics_->usage_table_header_initial_size_.Record(usage_table_->size());
|
||||||
usage_table_header_->size());
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -890,7 +888,7 @@ CdmResponseType CryptoSession::Open(
|
|||||||
RETURN_IF_UNINITIALIZED(CRYPTO_SESSION_NOT_INITIALIZED);
|
RETURN_IF_UNINITIALIZED(CRYPTO_SESSION_NOT_INITIALIZED);
|
||||||
if (open_) return CdmResponseType(NO_ERROR);
|
if (open_) return CdmResponseType(NO_ERROR);
|
||||||
|
|
||||||
if (!SetUpUsageTableHeader(requested_security_level)) {
|
if (!SetUpUsageTable(requested_security_level)) {
|
||||||
// Ignore errors since we do not know when a session is opened,
|
// Ignore errors since we do not know when a session is opened,
|
||||||
// if it is intended to be used for offline/usage session related
|
// if it is intended to be used for offline/usage session related
|
||||||
// or otherwise.
|
// or otherwise.
|
||||||
@@ -962,7 +960,7 @@ void CryptoSession::Close() {
|
|||||||
metrics_->oemcrypto_close_session_.Increment(close_sts);
|
metrics_->oemcrypto_close_session_.Increment(close_sts);
|
||||||
|
|
||||||
// Clear cached values.
|
// Clear cached values.
|
||||||
has_usage_info_support_ = kBooleanUnset;
|
has_usage_table_support_ = kBooleanUnset;
|
||||||
oem_token_.clear();
|
oem_token_.clear();
|
||||||
system_id_ = NULL_SYSTEM_ID;
|
system_id_ = NULL_SYSTEM_ID;
|
||||||
pre_provision_token_type_ = kClientTokenUninitialized;
|
pre_provision_token_type_ = kClientTokenUninitialized;
|
||||||
@@ -975,7 +973,7 @@ void CryptoSession::Close() {
|
|||||||
case OEMCrypto_SUCCESS:
|
case OEMCrypto_SUCCESS:
|
||||||
case OEMCrypto_ERROR_INVALID_SESSION:
|
case OEMCrypto_ERROR_INVALID_SESSION:
|
||||||
case OEMCrypto_ERROR_SYSTEM_INVALIDATED:
|
case OEMCrypto_ERROR_SYSTEM_INVALIDATED:
|
||||||
usage_table_header_ = nullptr;
|
usage_table_ = nullptr;
|
||||||
open_ = false;
|
open_ = false;
|
||||||
break;
|
break;
|
||||||
case OEMCrypto_ERROR_CLOSE_SESSION_FAILED:
|
case OEMCrypto_ERROR_CLOSE_SESSION_FAILED:
|
||||||
@@ -1837,38 +1835,38 @@ CdmResponseType CryptoSession::Decrypt(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CryptoSession::HasUsageInfoSupport(bool* has_support) {
|
bool CryptoSession::HasUsageTableSupport(bool* has_support) {
|
||||||
RETURN_IF_NOT_OPEN(false);
|
RETURN_IF_NOT_OPEN(false);
|
||||||
RETURN_IF_NULL(has_support, false);
|
RETURN_IF_NULL(has_support, false);
|
||||||
return WithOecReadLock("HasUsageInfoSupport", [&] {
|
return WithOecReadLock("HasUsageTableSupport", [&] {
|
||||||
// Use cached value if set.
|
// Use cached value if set.
|
||||||
if (has_usage_info_support_ != kBooleanUnset) {
|
if (has_usage_table_support_ != kBooleanUnset) {
|
||||||
*has_support = (has_usage_info_support_ == kBooleanTrue);
|
*has_support = (has_usage_table_support_ == kBooleanTrue);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (!HasUsageInfoSupportInternal(requested_security_level_, has_support)) {
|
if (!HasUsageTableSupportInternal(requested_security_level_, has_support)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// Cache result if successful.
|
// Cache result if successful.
|
||||||
has_usage_info_support_ = (*has_support ? kBooleanTrue : kBooleanFalse);
|
has_usage_table_support_ = (*has_support ? kBooleanTrue : kBooleanFalse);
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CryptoSession::HasUsageInfoSupport(
|
bool CryptoSession::HasUsageTableSupport(
|
||||||
RequestedSecurityLevel requested_security_level, bool* has_support) {
|
RequestedSecurityLevel requested_security_level, bool* has_support) {
|
||||||
RETURN_IF_UNINITIALIZED(false);
|
RETURN_IF_UNINITIALIZED(false);
|
||||||
RETURN_IF_NULL(has_support, false);
|
RETURN_IF_NULL(has_support, false);
|
||||||
return WithOecReadLock("HasUsageInfoSupport", [&] {
|
return WithOecReadLock("HasUsageTableSupport", [&] {
|
||||||
return HasUsageInfoSupportInternal(requested_security_level, has_support);
|
return HasUsageTableSupportInternal(requested_security_level, has_support);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CryptoSession::HasUsageInfoSupportInternal(
|
bool CryptoSession::HasUsageTableSupportInternal(
|
||||||
RequestedSecurityLevel requested_security_level, bool* has_support) {
|
RequestedSecurityLevel requested_security_level, bool* has_support) {
|
||||||
LOGV("requested_security_level = %s",
|
LOGV("requested_security_level = %s",
|
||||||
RequestedSecurityLevelToString(requested_security_level));
|
RequestedSecurityLevelToString(requested_security_level));
|
||||||
*has_support = WithOecReadLock("HasUsageInfoSupport", [&] {
|
*has_support = WithOecReadLock("HasUsageTableSupport", [&] {
|
||||||
return OEMCrypto_SupportsUsageTable(requested_security_level);
|
return OEMCrypto_SupportsUsageTable(requested_security_level);
|
||||||
});
|
});
|
||||||
return true;
|
return true;
|
||||||
@@ -2646,7 +2644,7 @@ CdmResponseType CryptoSession::GenericVerify(const std::string& message,
|
|||||||
|
|
||||||
CdmResponseType CryptoSession::CreateUsageTableHeader(
|
CdmResponseType CryptoSession::CreateUsageTableHeader(
|
||||||
RequestedSecurityLevel requested_security_level,
|
RequestedSecurityLevel requested_security_level,
|
||||||
CdmUsageTableHeader* usage_table_header) {
|
UsageTableHeader* usage_table_header) {
|
||||||
LOGV("Creating usage table header: requested_security_level = %s",
|
LOGV("Creating usage table header: requested_security_level = %s",
|
||||||
RequestedSecurityLevelToString(requested_security_level));
|
RequestedSecurityLevelToString(requested_security_level));
|
||||||
RETURN_IF_NULL(usage_table_header, PARAMETER_NULL);
|
RETURN_IF_NULL(usage_table_header, PARAMETER_NULL);
|
||||||
@@ -2687,7 +2685,7 @@ CdmResponseType CryptoSession::CreateUsageTableHeader(
|
|||||||
|
|
||||||
CdmResponseType CryptoSession::LoadUsageTableHeader(
|
CdmResponseType CryptoSession::LoadUsageTableHeader(
|
||||||
RequestedSecurityLevel requested_security_level,
|
RequestedSecurityLevel requested_security_level,
|
||||||
const CdmUsageTableHeader& usage_table_header) {
|
const UsageTableHeader& usage_table_header) {
|
||||||
LOGV("Loading usage table header: requested_security_level = %s",
|
LOGV("Loading usage table header: requested_security_level = %s",
|
||||||
RequestedSecurityLevelToString(requested_security_level));
|
RequestedSecurityLevelToString(requested_security_level));
|
||||||
|
|
||||||
@@ -2728,7 +2726,7 @@ CdmResponseType CryptoSession::LoadUsageTableHeader(
|
|||||||
|
|
||||||
CdmResponseType CryptoSession::ShrinkUsageTableHeader(
|
CdmResponseType CryptoSession::ShrinkUsageTableHeader(
|
||||||
RequestedSecurityLevel requested_security_level, uint32_t new_entry_count,
|
RequestedSecurityLevel requested_security_level, uint32_t new_entry_count,
|
||||||
CdmUsageTableHeader* usage_table_header) {
|
UsageTableHeader* usage_table_header) {
|
||||||
LOGV("Shrinking usage table header: requested_security_level = %s",
|
LOGV("Shrinking usage table header: requested_security_level = %s",
|
||||||
RequestedSecurityLevelToString(requested_security_level));
|
RequestedSecurityLevelToString(requested_security_level));
|
||||||
RETURN_IF_NULL(usage_table_header, PARAMETER_NULL);
|
RETURN_IF_NULL(usage_table_header, PARAMETER_NULL);
|
||||||
@@ -2766,14 +2764,14 @@ CdmResponseType CryptoSession::ShrinkUsageTableHeader(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CdmResponseType CryptoSession::CreateUsageEntry(uint32_t* entry_number) {
|
CdmResponseType CryptoSession::CreateUsageEntry(UsageEntryIndex* entry_index) {
|
||||||
LOGV("Creating usage entry: id = %u", oec_session_id_);
|
LOGV("Creating usage entry: id = %u", oec_session_id_);
|
||||||
|
|
||||||
RETURN_IF_NULL(entry_number, PARAMETER_NULL);
|
RETURN_IF_NULL(entry_index, PARAMETER_NULL);
|
||||||
|
|
||||||
OEMCryptoResult result;
|
OEMCryptoResult result;
|
||||||
WithOecWriteLock("CreateUsageEntry", [&] {
|
WithOecWriteLock("CreateUsageEntry", [&] {
|
||||||
result = OEMCrypto_CreateNewUsageEntry(oec_session_id_, entry_number);
|
result = OEMCrypto_CreateNewUsageEntry(oec_session_id_, entry_index);
|
||||||
metrics_->oemcrypto_create_new_usage_entry_.Increment(result);
|
metrics_->oemcrypto_create_new_usage_entry_.Increment(result);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -2796,14 +2794,14 @@ CdmResponseType CryptoSession::CreateUsageEntry(uint32_t* entry_number) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CdmResponseType CryptoSession::LoadUsageEntry(
|
CdmResponseType CryptoSession::LoadUsageEntry(UsageEntryIndex entry_index,
|
||||||
uint32_t entry_number, const CdmUsageEntry& usage_entry) {
|
const UsageEntry& usage_entry) {
|
||||||
LOGV("Loading usage entry: id = %u", oec_session_id_);
|
LOGV("Loading usage entry: id = %u", oec_session_id_);
|
||||||
|
|
||||||
OEMCryptoResult result;
|
OEMCryptoResult result;
|
||||||
WithOecWriteLock("LoadUsageEntry", [&] {
|
WithOecWriteLock("LoadUsageEntry", [&] {
|
||||||
result = OEMCrypto_LoadUsageEntry(
|
result = OEMCrypto_LoadUsageEntry(
|
||||||
oec_session_id_, entry_number,
|
oec_session_id_, entry_index,
|
||||||
reinterpret_cast<const uint8_t*>(usage_entry.data()),
|
reinterpret_cast<const uint8_t*>(usage_entry.data()),
|
||||||
usage_entry.size());
|
usage_entry.size());
|
||||||
metrics_->oemcrypto_load_usage_entry_.Increment(result);
|
metrics_->oemcrypto_load_usage_entry_.Increment(result);
|
||||||
@@ -2839,7 +2837,7 @@ CdmResponseType CryptoSession::LoadUsageEntry(
|
|||||||
}
|
}
|
||||||
|
|
||||||
CdmResponseType CryptoSession::UpdateUsageEntry(
|
CdmResponseType CryptoSession::UpdateUsageEntry(
|
||||||
CdmUsageTableHeader* usage_table_header, CdmUsageEntry* usage_entry) {
|
UsageTableHeader* usage_table_header, UsageEntry* usage_entry) {
|
||||||
LOGV("Updating usage entry: id = %u", oec_session_id_);
|
LOGV("Updating usage entry: id = %u", oec_session_id_);
|
||||||
|
|
||||||
RETURN_IF_NULL(usage_table_header, PARAMETER_NULL);
|
RETURN_IF_NULL(usage_table_header, PARAMETER_NULL);
|
||||||
@@ -2880,19 +2878,19 @@ CdmResponseType CryptoSession::UpdateUsageEntry(
|
|||||||
"UpdateUsageEntry");
|
"UpdateUsageEntry");
|
||||||
}
|
}
|
||||||
|
|
||||||
CdmResponseType CryptoSession::MoveUsageEntry(uint32_t new_entry_number) {
|
CdmResponseType CryptoSession::MoveUsageEntry(UsageEntryIndex new_entry_index) {
|
||||||
LOGV("Moving usage entry: id = %u", oec_session_id_);
|
LOGV("Moving usage entry: id = %u", oec_session_id_);
|
||||||
|
|
||||||
OEMCryptoResult result;
|
OEMCryptoResult result;
|
||||||
WithOecWriteLock("MoveUsageEntry", [&] {
|
WithOecWriteLock("MoveUsageEntry", [&] {
|
||||||
result = OEMCrypto_MoveEntry(oec_session_id_, new_entry_number);
|
result = OEMCrypto_MoveEntry(oec_session_id_, new_entry_index);
|
||||||
metrics_->oemcrypto_move_entry_.Increment(result);
|
metrics_->oemcrypto_move_entry_.Increment(result);
|
||||||
});
|
});
|
||||||
|
|
||||||
switch (result) {
|
switch (result) {
|
||||||
case OEMCrypto_ERROR_ENTRY_IN_USE:
|
case OEMCrypto_ERROR_ENTRY_IN_USE:
|
||||||
LOGW("OEMCrypto_MoveEntry failed: Destination index in use: index = %u",
|
LOGW("OEMCrypto_MoveEntry failed: Destination index in use: index = %u",
|
||||||
new_entry_number);
|
new_entry_index);
|
||||||
return CRYPTO_ERROR(MOVE_USAGE_ENTRY_DESTINATION_IN_USE, result);
|
return CRYPTO_ERROR(MOVE_USAGE_ENTRY_DESTINATION_IN_USE, result);
|
||||||
default:
|
default:
|
||||||
return MapOEMCryptoResult(result, MOVE_USAGE_ENTRY_UNKNOWN_ERROR,
|
return MapOEMCryptoResult(result, MOVE_USAGE_ENTRY_UNKNOWN_ERROR,
|
||||||
|
|||||||
@@ -838,7 +838,7 @@ bool DeviceFiles::StoreLicense(const CdmLicenseData& license_data,
|
|||||||
app_params->set_value(iter->second);
|
app_params->set_value(iter->second);
|
||||||
}
|
}
|
||||||
license->set_usage_entry(license_data.usage_entry);
|
license->set_usage_entry(license_data.usage_entry);
|
||||||
license->set_usage_entry_number(license_data.usage_entry_number);
|
license->set_usage_entry_index(license_data.usage_entry_index);
|
||||||
if (!license_data.drm_certificate.empty()) {
|
if (!license_data.drm_certificate.empty()) {
|
||||||
DeviceCertificate* device_certificate = license->mutable_drm_certificate();
|
DeviceCertificate* device_certificate = license->mutable_drm_certificate();
|
||||||
if (!SetDeviceCertificate(license_data.drm_certificate,
|
if (!SetDeviceCertificate(license_data.drm_certificate,
|
||||||
@@ -929,8 +929,8 @@ bool DeviceFiles::RetrieveLicense(const std::string& key_set_id,
|
|||||||
license.app_parameters(i).value();
|
license.app_parameters(i).value();
|
||||||
}
|
}
|
||||||
license_data->usage_entry = license.usage_entry();
|
license_data->usage_entry = license.usage_entry();
|
||||||
license_data->usage_entry_number =
|
license_data->usage_entry_index =
|
||||||
static_cast<uint32_t>(license.usage_entry_number());
|
static_cast<uint32_t>(license.usage_entry_index());
|
||||||
|
|
||||||
if (!license.has_drm_certificate()) {
|
if (!license.has_drm_certificate()) {
|
||||||
license_data->drm_certificate.clear();
|
license_data->drm_certificate.clear();
|
||||||
@@ -1010,8 +1010,8 @@ bool DeviceFiles::UnreserveLicenseId(const std::string& key_set_id) {
|
|||||||
bool DeviceFiles::StoreUsageInfo(
|
bool DeviceFiles::StoreUsageInfo(
|
||||||
const std::string& provider_session_token, const CdmKeyMessage& key_request,
|
const std::string& provider_session_token, const CdmKeyMessage& key_request,
|
||||||
const CdmKeyResponse& key_response, const std::string& usage_info_file_name,
|
const CdmKeyResponse& key_response, const std::string& usage_info_file_name,
|
||||||
const std::string& key_set_id, const std::string& usage_entry,
|
const std::string& key_set_id, const UsageEntry& usage_entry,
|
||||||
uint32_t usage_entry_number, const std::string& drm_certificate,
|
UsageEntryIndex usage_entry_index, const std::string& drm_certificate,
|
||||||
const CryptoWrappedKey& wrapped_private_key) {
|
const CryptoWrappedKey& wrapped_private_key) {
|
||||||
RETURN_FALSE_IF_UNINITIALIZED();
|
RETURN_FALSE_IF_UNINITIALIZED();
|
||||||
video_widevine_client::sdk::File file;
|
video_widevine_client::sdk::File file;
|
||||||
@@ -1034,7 +1034,7 @@ bool DeviceFiles::StoreUsageInfo(
|
|||||||
provider_session->set_license(key_response.data(), key_response.size());
|
provider_session->set_license(key_response.data(), key_response.size());
|
||||||
provider_session->set_key_set_id(key_set_id.data(), key_set_id.size());
|
provider_session->set_key_set_id(key_set_id.data(), key_set_id.size());
|
||||||
provider_session->set_usage_entry(usage_entry);
|
provider_session->set_usage_entry(usage_entry);
|
||||||
provider_session->set_usage_entry_number(usage_entry_number);
|
provider_session->set_usage_entry_index(usage_entry_index);
|
||||||
|
|
||||||
if (drm_certificate.size() > 0) {
|
if (drm_certificate.size() > 0) {
|
||||||
uint32_t drm_certificate_id;
|
uint32_t drm_certificate_id;
|
||||||
@@ -1235,15 +1235,15 @@ bool DeviceFiles::RetrieveUsageInfo(const std::string& usage_info_file_name,
|
|||||||
const std::string& provider_session_token,
|
const std::string& provider_session_token,
|
||||||
CdmKeyMessage* license_request,
|
CdmKeyMessage* license_request,
|
||||||
CdmKeyResponse* license,
|
CdmKeyResponse* license,
|
||||||
std::string* usage_entry,
|
UsageEntry* usage_entry,
|
||||||
uint32_t* usage_entry_number,
|
UsageEntryIndex* usage_entry_index,
|
||||||
std::string* drm_certificate,
|
std::string* drm_certificate,
|
||||||
CryptoWrappedKey* wrapped_private_key) {
|
CryptoWrappedKey* wrapped_private_key) {
|
||||||
RETURN_FALSE_IF_UNINITIALIZED();
|
RETURN_FALSE_IF_UNINITIALIZED();
|
||||||
RETURN_FALSE_IF_NULL(license_request);
|
RETURN_FALSE_IF_NULL(license_request);
|
||||||
RETURN_FALSE_IF_NULL(license);
|
RETURN_FALSE_IF_NULL(license);
|
||||||
RETURN_FALSE_IF_NULL(usage_entry);
|
RETURN_FALSE_IF_NULL(usage_entry);
|
||||||
RETURN_FALSE_IF_NULL(usage_entry_number);
|
RETURN_FALSE_IF_NULL(usage_entry_index);
|
||||||
RETURN_FALSE_IF_NULL(drm_certificate);
|
RETURN_FALSE_IF_NULL(drm_certificate);
|
||||||
RETURN_FALSE_IF_NULL(wrapped_private_key);
|
RETURN_FALSE_IF_NULL(wrapped_private_key);
|
||||||
|
|
||||||
@@ -1259,8 +1259,8 @@ bool DeviceFiles::RetrieveUsageInfo(const std::string& usage_info_file_name,
|
|||||||
*license_request = file.usage_info().sessions(index).license_request();
|
*license_request = file.usage_info().sessions(index).license_request();
|
||||||
*license = file.usage_info().sessions(index).license();
|
*license = file.usage_info().sessions(index).license();
|
||||||
*usage_entry = file.usage_info().sessions(index).usage_entry();
|
*usage_entry = file.usage_info().sessions(index).usage_entry();
|
||||||
*usage_entry_number = static_cast<uint32_t>(
|
*usage_entry_index = static_cast<UsageEntryIndex>(
|
||||||
file.usage_info().sessions(index).usage_entry_number());
|
file.usage_info().sessions(index).usage_entry_index());
|
||||||
|
|
||||||
if (!file.usage_info().sessions(index).has_drm_certificate_id()) {
|
if (!file.usage_info().sessions(index).has_drm_certificate_id()) {
|
||||||
drm_certificate->clear();
|
drm_certificate->clear();
|
||||||
@@ -1285,14 +1285,14 @@ bool DeviceFiles::RetrieveUsageInfo(const std::string& usage_info_file_name,
|
|||||||
bool DeviceFiles::RetrieveUsageInfoByKeySetId(
|
bool DeviceFiles::RetrieveUsageInfoByKeySetId(
|
||||||
const std::string& usage_info_file_name, const std::string& key_set_id,
|
const std::string& usage_info_file_name, const std::string& key_set_id,
|
||||||
std::string* provider_session_token, CdmKeyMessage* license_request,
|
std::string* provider_session_token, CdmKeyMessage* license_request,
|
||||||
CdmKeyResponse* license, std::string* usage_entry,
|
CdmKeyResponse* license, UsageEntry* usage_entry,
|
||||||
uint32_t* usage_entry_number, std::string* drm_certificate,
|
UsageEntryIndex* usage_entry_index, std::string* drm_certificate,
|
||||||
CryptoWrappedKey* wrapped_private_key) {
|
CryptoWrappedKey* wrapped_private_key) {
|
||||||
RETURN_FALSE_IF_UNINITIALIZED();
|
RETURN_FALSE_IF_UNINITIALIZED();
|
||||||
RETURN_FALSE_IF_NULL(license_request);
|
RETURN_FALSE_IF_NULL(license_request);
|
||||||
RETURN_FALSE_IF_NULL(license);
|
RETURN_FALSE_IF_NULL(license);
|
||||||
RETURN_FALSE_IF_NULL(usage_entry);
|
RETURN_FALSE_IF_NULL(usage_entry);
|
||||||
RETURN_FALSE_IF_NULL(usage_entry_number);
|
RETURN_FALSE_IF_NULL(usage_entry_index);
|
||||||
RETURN_FALSE_IF_NULL(drm_certificate);
|
RETURN_FALSE_IF_NULL(drm_certificate);
|
||||||
RETURN_FALSE_IF_NULL(wrapped_private_key);
|
RETURN_FALSE_IF_NULL(wrapped_private_key);
|
||||||
|
|
||||||
@@ -1309,8 +1309,8 @@ bool DeviceFiles::RetrieveUsageInfoByKeySetId(
|
|||||||
*license_request = file.usage_info().sessions(index).license_request();
|
*license_request = file.usage_info().sessions(index).license_request();
|
||||||
*license = file.usage_info().sessions(index).license();
|
*license = file.usage_info().sessions(index).license();
|
||||||
*usage_entry = file.usage_info().sessions(index).usage_entry();
|
*usage_entry = file.usage_info().sessions(index).usage_entry();
|
||||||
*usage_entry_number = static_cast<uint32_t>(
|
*usage_entry_index = static_cast<UsageEntryIndex>(
|
||||||
file.usage_info().sessions(index).usage_entry_number());
|
file.usage_info().sessions(index).usage_entry_index());
|
||||||
|
|
||||||
if (!file.usage_info().sessions(index).has_drm_certificate_id()) {
|
if (!file.usage_info().sessions(index).has_drm_certificate_id()) {
|
||||||
drm_certificate->clear();
|
drm_certificate->clear();
|
||||||
@@ -1354,7 +1354,7 @@ bool DeviceFiles::StoreUsageInfo(const std::string& usage_info_file_name,
|
|||||||
provider_session->set_key_set_id(usage_data[i].key_set_id.data(),
|
provider_session->set_key_set_id(usage_data[i].key_set_id.data(),
|
||||||
usage_data[i].key_set_id.size());
|
usage_data[i].key_set_id.size());
|
||||||
provider_session->set_usage_entry(usage_data[i].usage_entry);
|
provider_session->set_usage_entry(usage_data[i].usage_entry);
|
||||||
provider_session->set_usage_entry_number(usage_data[i].usage_entry_number);
|
provider_session->set_usage_entry_index(usage_data[i].usage_entry_index);
|
||||||
|
|
||||||
if (usage_data[i].drm_certificate.size() > 0) {
|
if (usage_data[i].drm_certificate.size() > 0) {
|
||||||
uint32_t drm_certificate_id;
|
uint32_t drm_certificate_id;
|
||||||
@@ -1399,7 +1399,7 @@ bool DeviceFiles::UpdateUsageInfo(const std::string& usage_info_file_name,
|
|||||||
provider_session->set_license(usage_data.license);
|
provider_session->set_license(usage_data.license);
|
||||||
provider_session->set_key_set_id(usage_data.key_set_id);
|
provider_session->set_key_set_id(usage_data.key_set_id);
|
||||||
provider_session->set_usage_entry(usage_data.usage_entry);
|
provider_session->set_usage_entry(usage_data.usage_entry);
|
||||||
provider_session->set_usage_entry_number(usage_data.usage_entry_number);
|
provider_session->set_usage_entry_index(usage_data.usage_entry_index);
|
||||||
|
|
||||||
if (usage_data.drm_certificate.size() > 0) {
|
if (usage_data.drm_certificate.size() > 0) {
|
||||||
uint32_t drm_certificate_id;
|
uint32_t drm_certificate_id;
|
||||||
@@ -1448,8 +1448,8 @@ bool DeviceFiles::RetrieveUsageInfo(const std::string& usage_info_file_name,
|
|||||||
(*usage_data)[i].license = file.usage_info().sessions(i).license();
|
(*usage_data)[i].license = file.usage_info().sessions(i).license();
|
||||||
(*usage_data)[i].key_set_id = file.usage_info().sessions(i).key_set_id();
|
(*usage_data)[i].key_set_id = file.usage_info().sessions(i).key_set_id();
|
||||||
(*usage_data)[i].usage_entry = file.usage_info().sessions(i).usage_entry();
|
(*usage_data)[i].usage_entry = file.usage_info().sessions(i).usage_entry();
|
||||||
(*usage_data)[i].usage_entry_number = static_cast<uint32_t>(
|
(*usage_data)[i].usage_entry_index = static_cast<uint32_t>(
|
||||||
file.usage_info().sessions(i).usage_entry_number());
|
file.usage_info().sessions(i).usage_entry_index());
|
||||||
|
|
||||||
if (!file.usage_info().sessions(i).has_drm_certificate_id()) {
|
if (!file.usage_info().sessions(i).has_drm_certificate_id()) {
|
||||||
(*usage_data)[i].drm_certificate.clear();
|
(*usage_data)[i].drm_certificate.clear();
|
||||||
@@ -1490,8 +1490,8 @@ bool DeviceFiles::RetrieveUsageInfo(const std::string& usage_info_file_name,
|
|||||||
usage_data->license = file.usage_info().sessions(index).license();
|
usage_data->license = file.usage_info().sessions(index).license();
|
||||||
usage_data->key_set_id = file.usage_info().sessions(index).key_set_id();
|
usage_data->key_set_id = file.usage_info().sessions(index).key_set_id();
|
||||||
usage_data->usage_entry = file.usage_info().sessions(index).usage_entry();
|
usage_data->usage_entry = file.usage_info().sessions(index).usage_entry();
|
||||||
usage_data->usage_entry_number = static_cast<uint32_t>(
|
usage_data->usage_entry_index = static_cast<uint32_t>(
|
||||||
file.usage_info().sessions(index).usage_entry_number());
|
file.usage_info().sessions(index).usage_entry_index());
|
||||||
|
|
||||||
if (!file.usage_info().sessions(index).has_drm_certificate_id()) {
|
if (!file.usage_info().sessions(index).has_drm_certificate_id()) {
|
||||||
usage_data->drm_certificate.clear();
|
usage_data->drm_certificate.clear();
|
||||||
@@ -1629,8 +1629,8 @@ bool DeviceFiles::DeleteHlsAttributes(const std::string& key_set_id) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool DeviceFiles::StoreUsageTableInfo(
|
bool DeviceFiles::StoreUsageTableInfo(
|
||||||
const CdmUsageTableHeader& usage_table_header,
|
const UsageTableHeader& table_header,
|
||||||
const std::vector<CdmUsageEntryInfo>& usage_entry_info) {
|
const std::vector<CdmUsageEntryInfo>& entry_info_list) {
|
||||||
RETURN_FALSE_IF_UNINITIALIZED();
|
RETURN_FALSE_IF_UNINITIALIZED();
|
||||||
|
|
||||||
// Fill in file information
|
// Fill in file information
|
||||||
@@ -1640,25 +1640,24 @@ bool DeviceFiles::StoreUsageTableInfo(
|
|||||||
file.set_version(video_widevine_client::sdk::File::VERSION_1);
|
file.set_version(video_widevine_client::sdk::File::VERSION_1);
|
||||||
|
|
||||||
UsageTableInfo* usage_table_info = file.mutable_usage_table_info();
|
UsageTableInfo* usage_table_info = file.mutable_usage_table_info();
|
||||||
usage_table_info->set_usage_table_header(usage_table_header);
|
usage_table_info->set_table_header(table_header);
|
||||||
for (size_t i = 0; i < usage_entry_info.size(); ++i) {
|
for (size_t i = 0; i < entry_info_list.size(); ++i) {
|
||||||
UsageTableInfo_UsageEntryInfo* info =
|
UsageTableInfo_UsageEntryInfo* info =
|
||||||
usage_table_info->add_usage_entry_info();
|
usage_table_info->add_entry_info_list();
|
||||||
info->set_key_set_id(usage_entry_info[i].key_set_id);
|
info->set_key_set_id(entry_info_list[i].key_set_id);
|
||||||
switch (usage_entry_info[i].storage_type) {
|
switch (entry_info_list[i].storage_type) {
|
||||||
case kStorageLicense:
|
case kStorageLicense:
|
||||||
info->set_storage(
|
info->set_storage(
|
||||||
UsageTableInfo_UsageEntryInfo_UsageEntryStorage_LICENSE);
|
UsageTableInfo_UsageEntryInfo_UsageEntryStorage_LICENSE);
|
||||||
info->set_last_use_time(usage_entry_info[i].last_use_time);
|
info->set_last_use_time(entry_info_list[i].last_use_time);
|
||||||
info->set_offline_license_expiry_time(
|
info->set_offline_license_expiry_time(
|
||||||
usage_entry_info[i].offline_license_expiry_time);
|
entry_info_list[i].offline_license_expiry_time);
|
||||||
break;
|
break;
|
||||||
case kStorageUsageInfo:
|
case kStorageUsageInfo:
|
||||||
info->set_storage(
|
info->set_storage(
|
||||||
UsageTableInfo_UsageEntryInfo_UsageEntryStorage_USAGE_INFO);
|
UsageTableInfo_UsageEntryInfo_UsageEntryStorage_USAGE_INFO);
|
||||||
info->set_usage_info_file_name(
|
info->set_usage_info_file_name(entry_info_list[i].usage_info_file_name);
|
||||||
usage_entry_info[i].usage_info_file_name);
|
info->set_last_use_time(entry_info_list[i].last_use_time);
|
||||||
info->set_last_use_time(usage_entry_info[i].last_use_time);
|
|
||||||
break;
|
break;
|
||||||
case kStorageTypeUnknown:
|
case kStorageTypeUnknown:
|
||||||
default:
|
default:
|
||||||
@@ -1677,11 +1676,11 @@ bool DeviceFiles::StoreUsageTableInfo(
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool DeviceFiles::RetrieveUsageTableInfo(
|
bool DeviceFiles::RetrieveUsageTableInfo(
|
||||||
CdmUsageTableHeader* usage_table_header,
|
UsageTableHeader* table_header,
|
||||||
std::vector<CdmUsageEntryInfo>* usage_entry_info, bool* lru_upgrade) {
|
std::vector<CdmUsageEntryInfo>* entry_info_list, bool* lru_upgrade) {
|
||||||
RETURN_FALSE_IF_UNINITIALIZED();
|
RETURN_FALSE_IF_UNINITIALIZED();
|
||||||
RETURN_FALSE_IF_NULL(usage_table_header);
|
RETURN_FALSE_IF_NULL(table_header);
|
||||||
RETURN_FALSE_IF_NULL(usage_entry_info);
|
RETURN_FALSE_IF_NULL(entry_info_list);
|
||||||
RETURN_FALSE_IF_NULL(lru_upgrade);
|
RETURN_FALSE_IF_NULL(lru_upgrade);
|
||||||
|
|
||||||
video_widevine_client::sdk::File file;
|
video_widevine_client::sdk::File file;
|
||||||
@@ -1713,28 +1712,28 @@ bool DeviceFiles::RetrieveUsageTableInfo(
|
|||||||
|
|
||||||
*lru_upgrade = !usage_table_info.use_lru();
|
*lru_upgrade = !usage_table_info.use_lru();
|
||||||
|
|
||||||
*usage_table_header = usage_table_info.usage_table_header();
|
*table_header = usage_table_info.table_header();
|
||||||
usage_entry_info->resize(usage_table_info.usage_entry_info_size());
|
entry_info_list->resize(usage_table_info.entry_info_list_size());
|
||||||
for (int i = 0; i < usage_table_info.usage_entry_info_size(); ++i) {
|
for (int i = 0; i < usage_table_info.entry_info_list_size(); ++i) {
|
||||||
const UsageTableInfo_UsageEntryInfo& info =
|
const UsageTableInfo_UsageEntryInfo& info =
|
||||||
usage_table_info.usage_entry_info(i);
|
usage_table_info.entry_info_list(i);
|
||||||
(*usage_entry_info)[i].key_set_id = info.key_set_id();
|
(*entry_info_list)[i].key_set_id = info.key_set_id();
|
||||||
switch (info.storage()) {
|
switch (info.storage()) {
|
||||||
case UsageTableInfo_UsageEntryInfo_UsageEntryStorage_LICENSE:
|
case UsageTableInfo_UsageEntryInfo_UsageEntryStorage_LICENSE:
|
||||||
(*usage_entry_info)[i].storage_type = kStorageLicense;
|
(*entry_info_list)[i].storage_type = kStorageLicense;
|
||||||
(*usage_entry_info)[i].last_use_time = info.last_use_time();
|
(*entry_info_list)[i].last_use_time = info.last_use_time();
|
||||||
(*usage_entry_info)[i].offline_license_expiry_time =
|
(*entry_info_list)[i].offline_license_expiry_time =
|
||||||
info.offline_license_expiry_time();
|
info.offline_license_expiry_time();
|
||||||
break;
|
break;
|
||||||
case UsageTableInfo_UsageEntryInfo_UsageEntryStorage_USAGE_INFO:
|
case UsageTableInfo_UsageEntryInfo_UsageEntryStorage_USAGE_INFO:
|
||||||
(*usage_entry_info)[i].storage_type = kStorageUsageInfo;
|
(*entry_info_list)[i].storage_type = kStorageUsageInfo;
|
||||||
(*usage_entry_info)[i].usage_info_file_name =
|
(*entry_info_list)[i].usage_info_file_name =
|
||||||
info.usage_info_file_name();
|
info.usage_info_file_name();
|
||||||
(*usage_entry_info)[i].last_use_time = info.last_use_time();
|
(*entry_info_list)[i].last_use_time = info.last_use_time();
|
||||||
break;
|
break;
|
||||||
case UsageTableInfo_UsageEntryInfo_UsageEntryStorage_UNKNOWN:
|
case UsageTableInfo_UsageEntryInfo_UsageEntryStorage_UNKNOWN:
|
||||||
default:
|
default:
|
||||||
(*usage_entry_info)[i].storage_type = kStorageTypeUnknown;
|
(*entry_info_list)[i].storage_type = kStorageTypeUnknown;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ message License {
|
|||||||
// ignored if there is no grace period.
|
// ignored if there is no grace period.
|
||||||
optional int64 grace_period_end_time = 11 [default = 0];
|
optional int64 grace_period_end_time = 11 [default = 0];
|
||||||
optional bytes usage_entry = 12;
|
optional bytes usage_entry = 12;
|
||||||
optional int64 usage_entry_number = 13;
|
optional int64 usage_entry_index = 13;
|
||||||
optional DeviceCertificate drm_certificate = 14;
|
optional DeviceCertificate drm_certificate = 14;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -88,7 +88,7 @@ message UsageInfo {
|
|||||||
optional bytes license = 3;
|
optional bytes license = 3;
|
||||||
optional bytes key_set_id = 4;
|
optional bytes key_set_id = 4;
|
||||||
optional bytes usage_entry = 5;
|
optional bytes usage_entry = 5;
|
||||||
optional int64 usage_entry_number = 6;
|
optional int64 usage_entry_index = 6;
|
||||||
// If not present, use the legacy DRM certificate rather than
|
// If not present, use the legacy DRM certificate rather than
|
||||||
// one in DrmDeviceCertificate
|
// one in DrmDeviceCertificate
|
||||||
optional uint32 drm_certificate_id = 7;
|
optional uint32 drm_certificate_id = 7;
|
||||||
@@ -131,8 +131,8 @@ message UsageTableInfo {
|
|||||||
optional int64 offline_license_expiry_time = 5 [default = 0];
|
optional int64 offline_license_expiry_time = 5 [default = 0];
|
||||||
}
|
}
|
||||||
|
|
||||||
optional bytes usage_table_header = 1;
|
optional bytes table_header = 1;
|
||||||
repeated UsageEntryInfo usage_entry_info = 2;
|
repeated UsageEntryInfo entry_info_list = 2;
|
||||||
optional bool use_lru = 3 [default = false];
|
optional bool use_lru = 3 [default = false];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -466,7 +466,7 @@ CdmResponseType CdmLicense::PrepareKeyUpdateRequest(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TODO(rfrias): Refactor to avoid needing to call CdmSession
|
// TODO(rfrias): Refactor to avoid needing to call CdmSession
|
||||||
if (cdm_session && cdm_session->supports_usage_info()) {
|
if (cdm_session && cdm_session->SupportsUsageTable()) {
|
||||||
const CdmResponseType status = cdm_session->UpdateUsageEntryInformation();
|
const CdmResponseType status = cdm_session->UpdateUsageEntryInformation();
|
||||||
if (NO_ERROR != status) return status;
|
if (NO_ERROR != status) return status;
|
||||||
}
|
}
|
||||||
@@ -822,7 +822,7 @@ CdmResponseType CdmLicense::RestoreOfflineLicense(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!provider_session_token_.empty()) {
|
if (!provider_session_token_.empty()) {
|
||||||
if (cdm_session && cdm_session->supports_usage_info()) {
|
if (cdm_session && cdm_session->SupportsUsageTable()) {
|
||||||
const CdmResponseType status = cdm_session->UpdateUsageEntryInformation();
|
const CdmResponseType status = cdm_session->UpdateUsageEntryInformation();
|
||||||
if (NO_ERROR != status) return sts;
|
if (NO_ERROR != status) return sts;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
|
#include "cdm_usage_table.h"
|
||||||
#include "crypto_key.h"
|
#include "crypto_key.h"
|
||||||
#include "crypto_wrapped_key.h"
|
#include "crypto_wrapped_key.h"
|
||||||
#include "properties.h"
|
#include "properties.h"
|
||||||
@@ -16,7 +17,6 @@
|
|||||||
#include "string_conversions.h"
|
#include "string_conversions.h"
|
||||||
#include "test_base.h"
|
#include "test_base.h"
|
||||||
#include "test_printers.h"
|
#include "test_printers.h"
|
||||||
#include "usage_table_header.h"
|
|
||||||
#include "wv_cdm_constants.h"
|
#include "wv_cdm_constants.h"
|
||||||
#include "wv_metrics.pb.h"
|
#include "wv_metrics.pb.h"
|
||||||
|
|
||||||
@@ -123,13 +123,13 @@ class MockDeviceFiles : public DeviceFiles {
|
|||||||
MOCK_METHOD(bool, HasCertificate, (bool), (override));
|
MOCK_METHOD(bool, HasCertificate, (bool), (override));
|
||||||
};
|
};
|
||||||
|
|
||||||
class MockUsageTableHeader : public UsageTableHeader {
|
class MockCdmUsageTable : public CdmUsageTable {
|
||||||
public:
|
public:
|
||||||
MockUsageTableHeader() : UsageTableHeader() {}
|
MockCdmUsageTable() : CdmUsageTable() {}
|
||||||
|
|
||||||
MOCK_METHOD(CdmResponseType, UpdateEntry,
|
MOCK_METHOD(CdmResponseType, UpdateEntry,
|
||||||
(uint32_t usage_entry_number, CryptoSession* crypto_session,
|
(UsageEntryIndex usage_entry_index, CryptoSession* crypto_session,
|
||||||
CdmUsageEntry* usage_entry),
|
UsageEntry* usage_entry),
|
||||||
(override));
|
(override));
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -137,10 +137,10 @@ class MockCryptoSession : public TestCryptoSession {
|
|||||||
public:
|
public:
|
||||||
MockCryptoSession(metrics::CryptoMetrics* crypto_metrics)
|
MockCryptoSession(metrics::CryptoMetrics* crypto_metrics)
|
||||||
: TestCryptoSession(crypto_metrics) {
|
: TestCryptoSession(crypto_metrics) {
|
||||||
// By default, call the concrete implementation of HasUsageInfoSupport.
|
// By default, call the concrete implementation of HasUsageTableSupport.
|
||||||
ON_CALL(*this, HasUsageInfoSupport(_))
|
ON_CALL(*this, HasUsageTableSupport(_))
|
||||||
.WillByDefault(
|
.WillByDefault(
|
||||||
Invoke(this, &MockCryptoSession::BaseHasUsageInfoSupport));
|
Invoke(this, &MockCryptoSession::BaseHasUsageTableSupport));
|
||||||
}
|
}
|
||||||
MOCK_METHOD(CdmResponseType, GetProvisioningToken,
|
MOCK_METHOD(CdmResponseType, GetProvisioningToken,
|
||||||
(std::string*, std::string*), (override));
|
(std::string*, std::string*), (override));
|
||||||
@@ -151,11 +151,11 @@ class MockCryptoSession : public TestCryptoSession {
|
|||||||
(override));
|
(override));
|
||||||
MOCK_METHOD(CdmResponseType, LoadCertificatePrivateKey,
|
MOCK_METHOD(CdmResponseType, LoadCertificatePrivateKey,
|
||||||
(const CryptoWrappedKey&), (override));
|
(const CryptoWrappedKey&), (override));
|
||||||
MOCK_METHOD(bool, HasUsageInfoSupport, (bool*), (override));
|
MOCK_METHOD(bool, HasUsageTableSupport, (bool*), (override));
|
||||||
MOCK_METHOD(UsageTableHeader*, GetUsageTableHeader, (), (override));
|
MOCK_METHOD(CdmUsageTable*, GetUsageTable, (), (override));
|
||||||
|
|
||||||
bool BaseHasUsageInfoSupport(bool* has_support) {
|
bool BaseHasUsageTableSupport(bool* has_support) {
|
||||||
return CryptoSession::HasUsageInfoSupport(has_support);
|
return CryptoSession::HasUsageTableSupport(has_support);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -209,7 +209,7 @@ class CdmSessionTest : public WvCdmTestBase {
|
|||||||
NiceMock<MockCryptoSession>* crypto_session_;
|
NiceMock<MockCryptoSession>* crypto_session_;
|
||||||
MockPolicyEngine* policy_engine_;
|
MockPolicyEngine* policy_engine_;
|
||||||
MockDeviceFiles* file_handle_;
|
MockDeviceFiles* file_handle_;
|
||||||
MockUsageTableHeader usage_table_header_;
|
MockCdmUsageTable usage_table_;
|
||||||
};
|
};
|
||||||
|
|
||||||
TEST_F(CdmSessionTest, InitWithBuiltInCertificate) {
|
TEST_F(CdmSessionTest, InitWithBuiltInCertificate) {
|
||||||
@@ -294,22 +294,22 @@ TEST_F(CdmSessionTest, UpdateUsageEntry) {
|
|||||||
.WillOnce(Return(level));
|
.WillOnce(Return(level));
|
||||||
EXPECT_CALL(*file_handle_, Init(Eq(level))).WillOnce(Return(true));
|
EXPECT_CALL(*file_handle_, Init(Eq(level))).WillOnce(Return(true));
|
||||||
EXPECT_CALL(*file_handle_, HasCertificate(false)).WillOnce(Return(true));
|
EXPECT_CALL(*file_handle_, HasCertificate(false)).WillOnce(Return(true));
|
||||||
EXPECT_CALL(*crypto_session_, GetUsageTableHeader())
|
EXPECT_CALL(*crypto_session_, GetUsageTable())
|
||||||
.WillOnce(Return(&usage_table_header_));
|
.WillOnce(Return(&usage_table_));
|
||||||
EXPECT_CALL(*license_parser_, Init(false, Eq(kEmptyString),
|
EXPECT_CALL(*license_parser_, Init(false, Eq(kEmptyString),
|
||||||
Eq(crypto_session_), Eq(policy_engine_)))
|
Eq(crypto_session_), Eq(policy_engine_)))
|
||||||
.WillOnce(Return(true));
|
.WillOnce(Return(true));
|
||||||
|
|
||||||
// Set up mocks and expectations for the UpdateUsageEntryInformation call.
|
// Set up mocks and expectations for the UpdateUsageEntryInformation call.
|
||||||
EXPECT_CALL(*crypto_session_, HasUsageInfoSupport(_))
|
EXPECT_CALL(*crypto_session_, HasUsageTableSupport(_))
|
||||||
.WillRepeatedly(DoAll(SetArgPointee<0>(true), Return(true)));
|
.WillRepeatedly(DoAll(SetArgPointee<0>(true), Return(true)));
|
||||||
EXPECT_CALL(*license_parser_, provider_session_token())
|
EXPECT_CALL(*license_parser_, provider_session_token())
|
||||||
.WillRepeatedly(Return("Mock provider session token"));
|
.WillRepeatedly(Return("Mock provider session token"));
|
||||||
EXPECT_CALL(usage_table_header_, UpdateEntry(_, NotNull(), NotNull()))
|
EXPECT_CALL(usage_table_, UpdateEntry(_, NotNull(), NotNull()))
|
||||||
.WillRepeatedly(Return(CdmResponseType(NO_ERROR)));
|
.WillRepeatedly(Return(CdmResponseType(NO_ERROR)));
|
||||||
|
|
||||||
EXPECT_EQ(NO_ERROR, cdm_session_->Init(nullptr));
|
EXPECT_EQ(NO_ERROR, cdm_session_->Init(nullptr));
|
||||||
EXPECT_TRUE(cdm_session_->supports_usage_info());
|
EXPECT_TRUE(cdm_session_->SupportsUsageTable());
|
||||||
EXPECT_EQ(NO_ERROR, cdm_session_->UpdateUsageEntryInformation());
|
EXPECT_EQ(NO_ERROR, cdm_session_->UpdateUsageEntryInformation());
|
||||||
|
|
||||||
// Verify the UsageEntry metric is set.
|
// Verify the UsageEntry metric is set.
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -63,21 +63,21 @@ class MockCryptoSession : public TestCryptoSession {
|
|||||||
(override));
|
(override));
|
||||||
// Usage Table Header.
|
// Usage Table Header.
|
||||||
MOCK_METHOD(CdmResponseType, CreateUsageTableHeader,
|
MOCK_METHOD(CdmResponseType, CreateUsageTableHeader,
|
||||||
(wvcdm::RequestedSecurityLevel, CdmUsageTableHeader*),
|
(wvcdm::RequestedSecurityLevel, UsageTableHeader*), (override));
|
||||||
(override));
|
|
||||||
MOCK_METHOD(CdmResponseType, LoadUsageTableHeader,
|
MOCK_METHOD(CdmResponseType, LoadUsageTableHeader,
|
||||||
(wvcdm::RequestedSecurityLevel, const CdmUsageTableHeader&),
|
(wvcdm::RequestedSecurityLevel, const UsageTableHeader&),
|
||||||
(override));
|
(override));
|
||||||
MOCK_METHOD(CdmResponseType, ShrinkUsageTableHeader,
|
MOCK_METHOD(CdmResponseType, ShrinkUsageTableHeader,
|
||||||
(wvcdm::RequestedSecurityLevel, uint32_t, CdmUsageTableHeader*),
|
(wvcdm::RequestedSecurityLevel, uint32_t, UsageTableHeader*),
|
||||||
(override));
|
(override));
|
||||||
// Usage Entry.
|
// Usage Entry.
|
||||||
MOCK_METHOD(CdmResponseType, CreateUsageEntry, (uint32_t*), (override));
|
MOCK_METHOD(CdmResponseType, CreateUsageEntry, (UsageEntryIndex*),
|
||||||
MOCK_METHOD(CdmResponseType, LoadUsageEntry, (uint32_t, const CdmUsageEntry&),
|
|
||||||
(override));
|
(override));
|
||||||
|
MOCK_METHOD(CdmResponseType, LoadUsageEntry,
|
||||||
|
(UsageEntryIndex, const UsageEntry&), (override));
|
||||||
MOCK_METHOD(CdmResponseType, UpdateUsageEntry,
|
MOCK_METHOD(CdmResponseType, UpdateUsageEntry,
|
||||||
(CdmUsageTableHeader*, CdmUsageEntry*), (override));
|
(UsageTableHeader*, UsageEntry*), (override));
|
||||||
MOCK_METHOD(CdmResponseType, MoveUsageEntry, (uint32_t), (override));
|
MOCK_METHOD(CdmResponseType, MoveUsageEntry, (UsageEntryIndex), (override));
|
||||||
};
|
};
|
||||||
|
|
||||||
class TestStubCryptoSessionFactory : public CryptoSessionFactory {
|
class TestStubCryptoSessionFactory : public CryptoSessionFactory {
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ TEST_F(CryptoSessionMetricsTest, OpenSessionValidMetrics) {
|
|||||||
session->Open(wvcdm::kLevelDefault);
|
session->Open(wvcdm::kLevelDefault);
|
||||||
// Exercise a method that will touch a metric.
|
// Exercise a method that will touch a metric.
|
||||||
bool supports_usage_table;
|
bool supports_usage_table;
|
||||||
ASSERT_TRUE(session->HasUsageInfoSupport(&supports_usage_table));
|
ASSERT_TRUE(session->HasUsageTableSupport(&supports_usage_table));
|
||||||
|
|
||||||
drm_metrics::WvCdmMetrics::CryptoMetrics metrics_proto;
|
drm_metrics::WvCdmMetrics::CryptoMetrics metrics_proto;
|
||||||
crypto_metrics.Serialize(&metrics_proto);
|
crypto_metrics.Serialize(&metrics_proto);
|
||||||
|
|||||||
@@ -1627,7 +1627,7 @@ struct LicenseInfo {
|
|||||||
int64_t grace_period_end_time;
|
int64_t grace_period_end_time;
|
||||||
std::string app_parameters;
|
std::string app_parameters;
|
||||||
std::string usage_entry;
|
std::string usage_entry;
|
||||||
uint32_t usage_entry_number;
|
uint32_t usage_entry_index;
|
||||||
std::string drm_certificate;
|
std::string drm_certificate;
|
||||||
CryptoWrappedKey::Type key_type;
|
CryptoWrappedKey::Type key_type;
|
||||||
std::string private_key;
|
std::string private_key;
|
||||||
@@ -3657,7 +3657,7 @@ const CdmUsageEntryInfo kUsageEntriesTestData[] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct UsageTableTestInfo {
|
struct UsageTableTestInfo {
|
||||||
CdmUsageTableHeader usage_table_header;
|
UsageTableHeader usage_table_header;
|
||||||
std::string file_data;
|
std::string file_data;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -4560,7 +4560,7 @@ TEST_P(DeviceFilesStoreTest, StoreLicense) {
|
|||||||
kLicenseTestData[license_num].grace_period_end_time,
|
kLicenseTestData[license_num].grace_period_end_time,
|
||||||
app_parameters,
|
app_parameters,
|
||||||
kLicenseTestData[license_num].usage_entry,
|
kLicenseTestData[license_num].usage_entry,
|
||||||
kLicenseTestData[license_num].usage_entry_number,
|
kLicenseTestData[license_num].usage_entry_index,
|
||||||
kLicenseTestData[license_num].drm_certificate,
|
kLicenseTestData[license_num].drm_certificate,
|
||||||
CryptoWrappedKey(kLicenseTestData[license_num].key_type,
|
CryptoWrappedKey(kLicenseTestData[license_num].key_type,
|
||||||
kLicenseTestData[license_num].private_key)};
|
kLicenseTestData[license_num].private_key)};
|
||||||
@@ -4629,7 +4629,7 @@ TEST_F(DeviceFilesTest, StoreLicenses) {
|
|||||||
kLicenseTestData[i].grace_period_end_time,
|
kLicenseTestData[i].grace_period_end_time,
|
||||||
app_parameters,
|
app_parameters,
|
||||||
kLicenseTestData[i].usage_entry,
|
kLicenseTestData[i].usage_entry,
|
||||||
kLicenseTestData[i].usage_entry_number,
|
kLicenseTestData[i].usage_entry_index,
|
||||||
kLicenseTestData[i].drm_certificate,
|
kLicenseTestData[i].drm_certificate,
|
||||||
CryptoWrappedKey(kLicenseTestData[i].key_type,
|
CryptoWrappedKey(kLicenseTestData[i].key_type,
|
||||||
kLicenseTestData[i].private_key)};
|
kLicenseTestData[i].private_key)};
|
||||||
@@ -4689,8 +4689,8 @@ TEST_F(DeviceFilesTest, RetrieveLicenses) {
|
|||||||
EXPECT_EQ(kLicenseTestData[i].grace_period_end_time,
|
EXPECT_EQ(kLicenseTestData[i].grace_period_end_time,
|
||||||
license_data.grace_period_end_time);
|
license_data.grace_period_end_time);
|
||||||
EXPECT_EQ(kLicenseTestData[i].usage_entry, license_data.usage_entry);
|
EXPECT_EQ(kLicenseTestData[i].usage_entry, license_data.usage_entry);
|
||||||
EXPECT_EQ(kLicenseTestData[i].usage_entry_number,
|
EXPECT_EQ(kLicenseTestData[i].usage_entry_index,
|
||||||
license_data.usage_entry_number);
|
license_data.usage_entry_index);
|
||||||
EXPECT_EQ(kLicenseTestData[i].drm_certificate,
|
EXPECT_EQ(kLicenseTestData[i].drm_certificate,
|
||||||
license_data.drm_certificate);
|
license_data.drm_certificate);
|
||||||
EXPECT_EQ(kLicenseTestData[i].key_type,
|
EXPECT_EQ(kLicenseTestData[i].key_type,
|
||||||
@@ -4755,7 +4755,7 @@ TEST_F(DeviceFilesTest, AppParametersBackwardCompatibility) {
|
|||||||
license_data.grace_period_end_time);
|
license_data.grace_period_end_time);
|
||||||
EXPECT_EQ(0u, license_data.app_parameters.size());
|
EXPECT_EQ(0u, license_data.app_parameters.size());
|
||||||
EXPECT_EQ(test_data->usage_entry, license_data.usage_entry);
|
EXPECT_EQ(test_data->usage_entry, license_data.usage_entry);
|
||||||
EXPECT_EQ(test_data->usage_entry_number, license_data.usage_entry_number);
|
EXPECT_EQ(test_data->usage_entry_index, license_data.usage_entry_index);
|
||||||
EXPECT_EQ(test_data->drm_certificate, license_data.drm_certificate);
|
EXPECT_EQ(test_data->drm_certificate, license_data.drm_certificate);
|
||||||
EXPECT_EQ(test_data->key_type, license_data.wrapped_private_key.type());
|
EXPECT_EQ(test_data->key_type, license_data.wrapped_private_key.type());
|
||||||
EXPECT_EQ(test_data->private_key, license_data.wrapped_private_key.key());
|
EXPECT_EQ(test_data->private_key, license_data.wrapped_private_key.key());
|
||||||
@@ -4794,7 +4794,7 @@ TEST_F(DeviceFilesTest, UpdateLicenseState) {
|
|||||||
kLicenseUpdateTestData[0].grace_period_end_time,
|
kLicenseUpdateTestData[0].grace_period_end_time,
|
||||||
GetAppParameters(kLicenseTestData[0].app_parameters),
|
GetAppParameters(kLicenseTestData[0].app_parameters),
|
||||||
kLicenseUpdateTestData[0].usage_entry,
|
kLicenseUpdateTestData[0].usage_entry,
|
||||||
kLicenseUpdateTestData[0].usage_entry_number,
|
kLicenseUpdateTestData[0].usage_entry_index,
|
||||||
kLicenseUpdateTestData[0].drm_certificate,
|
kLicenseUpdateTestData[0].drm_certificate,
|
||||||
CryptoWrappedKey(kLicenseTestData[0].key_type,
|
CryptoWrappedKey(kLicenseTestData[0].key_type,
|
||||||
kLicenseTestData[0].private_key)};
|
kLicenseTestData[0].private_key)};
|
||||||
@@ -4860,8 +4860,8 @@ TEST_F(DeviceFilesTest, DeleteLicense) {
|
|||||||
std::string::npos);
|
std::string::npos);
|
||||||
}
|
}
|
||||||
EXPECT_EQ(kLicenseTestData[0].usage_entry, license_data.usage_entry);
|
EXPECT_EQ(kLicenseTestData[0].usage_entry, license_data.usage_entry);
|
||||||
EXPECT_EQ(kLicenseTestData[0].usage_entry_number,
|
EXPECT_EQ(kLicenseTestData[0].usage_entry_index,
|
||||||
license_data.usage_entry_number);
|
license_data.usage_entry_index);
|
||||||
EXPECT_EQ(kLicenseTestData[0].drm_certificate, license_data.drm_certificate);
|
EXPECT_EQ(kLicenseTestData[0].drm_certificate, license_data.drm_certificate);
|
||||||
EXPECT_EQ(kLicenseTestData[0].key_type,
|
EXPECT_EQ(kLicenseTestData[0].key_type,
|
||||||
license_data.wrapped_private_key.type());
|
license_data.wrapped_private_key.type());
|
||||||
@@ -5408,8 +5408,8 @@ TEST_P(DeviceFilesUsageInfoTest, Retrieve) {
|
|||||||
usage_data_list[i].key_set_id);
|
usage_data_list[i].key_set_id);
|
||||||
EXPECT_EQ(kUsageInfoTestData[j].usage_data.usage_entry,
|
EXPECT_EQ(kUsageInfoTestData[j].usage_data.usage_entry,
|
||||||
usage_data_list[i].usage_entry);
|
usage_data_list[i].usage_entry);
|
||||||
EXPECT_EQ(kUsageInfoTestData[j].usage_data.usage_entry_number,
|
EXPECT_EQ(kUsageInfoTestData[j].usage_data.usage_entry_index,
|
||||||
usage_data_list[i].usage_entry_number);
|
usage_data_list[i].usage_entry_index);
|
||||||
EXPECT_EQ(kUsageInfoTestData[j].usage_data.drm_certificate,
|
EXPECT_EQ(kUsageInfoTestData[j].usage_data.drm_certificate,
|
||||||
usage_data_list[i].drm_certificate);
|
usage_data_list[i].drm_certificate);
|
||||||
EXPECT_EQ(kUsageInfoTestData[j].usage_data.wrapped_private_key.type(),
|
EXPECT_EQ(kUsageInfoTestData[j].usage_data.wrapped_private_key.type(),
|
||||||
@@ -5581,8 +5581,8 @@ TEST_P(DeviceFilesUsageInfoTest, RetrieveByProviderSessionToken) {
|
|||||||
usage_data.key_set_id);
|
usage_data.key_set_id);
|
||||||
EXPECT_EQ(kUsageInfoTestData[index].usage_data.usage_entry,
|
EXPECT_EQ(kUsageInfoTestData[index].usage_data.usage_entry,
|
||||||
usage_data.usage_entry);
|
usage_data.usage_entry);
|
||||||
EXPECT_EQ(kUsageInfoTestData[index].usage_data.usage_entry_number,
|
EXPECT_EQ(kUsageInfoTestData[index].usage_data.usage_entry_index,
|
||||||
usage_data.usage_entry_number);
|
usage_data.usage_entry_index);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -5813,7 +5813,7 @@ TEST_P(DeviceFilesUsageTableTest, Read) {
|
|||||||
EXPECT_TRUE(device_files.Init(kSecurityLevelL1));
|
EXPECT_TRUE(device_files.Init(kSecurityLevelL1));
|
||||||
|
|
||||||
std::vector<CdmUsageEntryInfo> usage_entry_info;
|
std::vector<CdmUsageEntryInfo> usage_entry_info;
|
||||||
CdmUsageTableHeader usage_table_header;
|
UsageTableHeader usage_table_header;
|
||||||
bool lru_upgrade;
|
bool lru_upgrade;
|
||||||
ASSERT_TRUE(device_files.RetrieveUsageTableInfo(
|
ASSERT_TRUE(device_files.RetrieveUsageTableInfo(
|
||||||
&usage_table_header, &usage_entry_info, &lru_upgrade));
|
&usage_table_header, &usage_entry_info, &lru_upgrade));
|
||||||
@@ -5861,7 +5861,7 @@ TEST_F(DeviceFilesUsageTableTest, ReadWithoutLruData) {
|
|||||||
EXPECT_TRUE(device_files.Init(kSecurityLevelL1));
|
EXPECT_TRUE(device_files.Init(kSecurityLevelL1));
|
||||||
|
|
||||||
std::vector<CdmUsageEntryInfo> usage_entry_info;
|
std::vector<CdmUsageEntryInfo> usage_entry_info;
|
||||||
CdmUsageTableHeader usage_table_header;
|
UsageTableHeader usage_table_header;
|
||||||
bool lru_upgrade;
|
bool lru_upgrade;
|
||||||
ASSERT_TRUE(device_files.RetrieveUsageTableInfo(
|
ASSERT_TRUE(device_files.RetrieveUsageTableInfo(
|
||||||
&usage_table_header, &usage_entry_info, &lru_upgrade));
|
&usage_table_header, &usage_entry_info, &lru_upgrade));
|
||||||
|
|||||||
@@ -143,7 +143,7 @@ class MockCryptoSession : public TestCryptoSession {
|
|||||||
: TestCryptoSession(crypto_metrics) {}
|
: TestCryptoSession(crypto_metrics) {}
|
||||||
MOCK_METHOD(bool, IsOpen, (), (override));
|
MOCK_METHOD(bool, IsOpen, (), (override));
|
||||||
MOCK_METHOD(const std::string&, request_id, (), (override));
|
MOCK_METHOD(const std::string&, request_id, (), (override));
|
||||||
MOCK_METHOD(bool, HasUsageInfoSupport, (bool*), (override));
|
MOCK_METHOD(bool, HasUsageTableSupport, (bool*), (override));
|
||||||
MOCK_METHOD(CdmResponseType, GetHdcpCapabilities,
|
MOCK_METHOD(CdmResponseType, GetHdcpCapabilities,
|
||||||
(HdcpCapability*, HdcpCapability*), (override));
|
(HdcpCapability*, HdcpCapability*), (override));
|
||||||
MOCK_METHOD(bool, GetSupportedCertificateTypes, (SupportedCertificateTypes*),
|
MOCK_METHOD(bool, GetSupportedCertificateTypes, (SupportedCertificateTypes*),
|
||||||
@@ -306,7 +306,7 @@ TEST_F(CdmLicenseTest, PrepareKeyRequestValidation) {
|
|||||||
EXPECT_CALL(*crypto_session_, IsOpen()).WillOnce(Return(true));
|
EXPECT_CALL(*crypto_session_, IsOpen()).WillOnce(Return(true));
|
||||||
EXPECT_CALL(*crypto_session_, request_id())
|
EXPECT_CALL(*crypto_session_, request_id())
|
||||||
.WillOnce(ReturnRef(kCryptoRequestId));
|
.WillOnce(ReturnRef(kCryptoRequestId));
|
||||||
EXPECT_CALL(*crypto_session_, HasUsageInfoSupport(NotNull()))
|
EXPECT_CALL(*crypto_session_, HasUsageTableSupport(NotNull()))
|
||||||
.WillOnce(
|
.WillOnce(
|
||||||
DoAll(SetArgPointee<0>(usage_information_support), Return(true)));
|
DoAll(SetArgPointee<0>(usage_information_support), Return(true)));
|
||||||
EXPECT_CALL(*crypto_session_, GetHdcpCapabilities(NotNull(), NotNull()))
|
EXPECT_CALL(*crypto_session_, GetHdcpCapabilities(NotNull(), NotNull()))
|
||||||
@@ -441,7 +441,7 @@ TEST_F(CdmLicenseTest, PrepareKeyRequestValidationV15) {
|
|||||||
EXPECT_CALL(*crypto_session_, IsOpen()).WillOnce(Return(true));
|
EXPECT_CALL(*crypto_session_, IsOpen()).WillOnce(Return(true));
|
||||||
EXPECT_CALL(*crypto_session_, request_id())
|
EXPECT_CALL(*crypto_session_, request_id())
|
||||||
.WillOnce(ReturnRef(kCryptoRequestId));
|
.WillOnce(ReturnRef(kCryptoRequestId));
|
||||||
EXPECT_CALL(*crypto_session_, HasUsageInfoSupport(NotNull()))
|
EXPECT_CALL(*crypto_session_, HasUsageTableSupport(NotNull()))
|
||||||
.WillOnce(
|
.WillOnce(
|
||||||
DoAll(SetArgPointee<0>(usage_information_support), Return(true)));
|
DoAll(SetArgPointee<0>(usage_information_support), Return(true)));
|
||||||
EXPECT_CALL(*crypto_session_, GetHdcpCapabilities(NotNull(), NotNull()))
|
EXPECT_CALL(*crypto_session_, GetHdcpCapabilities(NotNull(), NotNull()))
|
||||||
|
|||||||
@@ -45,6 +45,11 @@ test_src_dir := ../core/test
|
|||||||
test_main := ../core/test/test_main.cpp
|
test_main := ../core/test/test_main.cpp
|
||||||
include $(LOCAL_PATH)/integration-test.mk
|
include $(LOCAL_PATH)/integration-test.mk
|
||||||
|
|
||||||
|
test_name := cdm_usage_table_unittest
|
||||||
|
test_src_dir := ../core/test
|
||||||
|
test_main := ../core/test/test_main.cpp
|
||||||
|
include $(LOCAL_PATH)/integration-test.mk
|
||||||
|
|
||||||
test_name := certificate_provisioning_unittest
|
test_name := certificate_provisioning_unittest
|
||||||
test_src_dir := ../core/test
|
test_src_dir := ../core/test
|
||||||
test_main := ../core/test/test_main.cpp
|
test_main := ../core/test/test_main.cpp
|
||||||
@@ -169,11 +174,6 @@ test_name := timer_unittest
|
|||||||
test_src_dir := .
|
test_src_dir := .
|
||||||
include $(LOCAL_PATH)/unit-test.mk
|
include $(LOCAL_PATH)/unit-test.mk
|
||||||
|
|
||||||
test_name := usage_table_header_unittest
|
|
||||||
test_src_dir := ../core/test
|
|
||||||
test_main := ../core/test/test_main.cpp
|
|
||||||
include $(LOCAL_PATH)/integration-test.mk
|
|
||||||
|
|
||||||
test_name := value_metric_unittest
|
test_name := value_metric_unittest
|
||||||
test_src_dir := ../metrics/test
|
test_src_dir := ../metrics/test
|
||||||
include $(LOCAL_PATH)/unit-test.mk
|
include $(LOCAL_PATH)/unit-test.mk
|
||||||
|
|||||||
@@ -99,6 +99,7 @@ adb_shell_run buffer_reader_test
|
|||||||
adb_shell_run cdm_engine_metrics_decorator_unittest
|
adb_shell_run cdm_engine_metrics_decorator_unittest
|
||||||
adb_shell_run cdm_engine_test
|
adb_shell_run cdm_engine_test
|
||||||
adb_shell_run cdm_session_unittest
|
adb_shell_run cdm_session_unittest
|
||||||
|
adb_shell_run cdm_usage_table_unittest
|
||||||
adb_shell_run certificate_provisioning_unittest
|
adb_shell_run certificate_provisioning_unittest
|
||||||
adb_shell_run counter_metric_unittest
|
adb_shell_run counter_metric_unittest
|
||||||
adb_shell_run crypto_session_unittest
|
adb_shell_run crypto_session_unittest
|
||||||
@@ -125,6 +126,5 @@ adb_shell_run rw_lock_test
|
|||||||
adb_shell_run service_certificate_unittest
|
adb_shell_run service_certificate_unittest
|
||||||
adb_shell_run system_id_extractor_unittest
|
adb_shell_run system_id_extractor_unittest
|
||||||
adb_shell_run timer_unittest
|
adb_shell_run timer_unittest
|
||||||
adb_shell_run usage_table_header_unittest
|
|
||||||
adb_shell_run value_metric_unittest
|
adb_shell_run value_metric_unittest
|
||||||
adb_shell_run wv_cdm_metrics_test
|
adb_shell_run wv_cdm_metrics_test
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ WIDEVINE_TEST_MAKE_TARGETS += \
|
|||||||
cdm_extended_duration_test \
|
cdm_extended_duration_test \
|
||||||
cdm_feature_test \
|
cdm_feature_test \
|
||||||
cdm_session_unittest \
|
cdm_session_unittest \
|
||||||
|
cdm_usage_table_unittest \
|
||||||
certificate_provisioning_unittest \
|
certificate_provisioning_unittest \
|
||||||
counter_metric_unittest \
|
counter_metric_unittest \
|
||||||
crypto_session_unittest \
|
crypto_session_unittest \
|
||||||
@@ -49,7 +50,6 @@ WIDEVINE_TEST_MAKE_TARGETS += \
|
|||||||
rw_lock_test \
|
rw_lock_test \
|
||||||
service_certificate_unittest \
|
service_certificate_unittest \
|
||||||
timer_unittest \
|
timer_unittest \
|
||||||
usage_table_header_unittest \
|
|
||||||
value_metric_unittest \
|
value_metric_unittest \
|
||||||
wv_cdm_metrics_test \
|
wv_cdm_metrics_test \
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user