Source release 14.0.0
This commit is contained in:
@@ -8,10 +8,10 @@
|
||||
#include <vector>
|
||||
|
||||
#include "OEMCryptoCENC.h"
|
||||
#include "key_session.h"
|
||||
#include "lock.h"
|
||||
#include "metrics_collections.h"
|
||||
#include "oemcrypto_adapter.h"
|
||||
#include "OEMCryptoCENC.h"
|
||||
#include "scoped_ptr.h"
|
||||
#include "timer_metric.h"
|
||||
#include "wv_cdm_types.h"
|
||||
@@ -22,36 +22,14 @@ class CryptoKey;
|
||||
class UsageTableHeader;
|
||||
|
||||
typedef std::map<std::string, CryptoKey*> CryptoKeyMap;
|
||||
typedef std::map<std::string, CryptoSessionId> SubLicenseSessionMap;
|
||||
|
||||
class KeySession {
|
||||
protected:
|
||||
KeySession(metrics::CryptoMetrics* metrics) : metrics_(metrics) {}
|
||||
|
||||
public:
|
||||
typedef enum { kDefault, kSubLicense } KeySessionType;
|
||||
virtual ~KeySession() {}
|
||||
virtual KeySessionType Type() = 0;
|
||||
virtual bool GenerateDerivedKeys(const std::string& message) = 0;
|
||||
virtual bool GenerateDerivedKeys(const std::string& message,
|
||||
const std::string& session_key) = 0;
|
||||
virtual OEMCryptoResult LoadKeys(const std::string& message,
|
||||
const std::string& signature,
|
||||
const std::string& mac_key_iv,
|
||||
const std::string& mac_key,
|
||||
const std::vector<CryptoKey>& keys,
|
||||
const std::string& provider_session_token,
|
||||
CdmCipherMode* cipher_mode,
|
||||
const std::string& srm_requirement) = 0;
|
||||
virtual OEMCryptoResult SelectKey(const std::string& key_id) = 0;
|
||||
virtual OEMCryptoResult Decrypt(
|
||||
const CdmDecryptionParameters& params,
|
||||
OEMCrypto_DestBufferDesc& buffer_descriptor,
|
||||
OEMCrypto_CENCEncryptPatternDesc& pattern_descriptor) = 0;
|
||||
|
||||
protected:
|
||||
metrics::CryptoMetrics* metrics_;
|
||||
};
|
||||
// Crypto session utility functions used by KeySession implementations.
|
||||
void GenerateMacContext(const std::string& input_context,
|
||||
std::string* deriv_context);
|
||||
void GenerateEncryptContext(const std::string& input_context,
|
||||
std::string* deriv_context);
|
||||
size_t GetOffset(std::string message, std::string field);
|
||||
OEMCryptoCipherMode ToOEMCryptoCipherMode(CdmCipherMode cipher_mode);
|
||||
|
||||
class CryptoSession {
|
||||
public:
|
||||
@@ -74,7 +52,6 @@ class CryptoSession {
|
||||
explicit CryptoSession(metrics::CryptoMetrics* crypto_metrics);
|
||||
virtual ~CryptoSession();
|
||||
|
||||
virtual bool GetClientToken(std::string* client_token);
|
||||
virtual bool GetProvisioningToken(std::string* client_token);
|
||||
virtual CdmClientTokenType GetPreProvisionTokenType() {
|
||||
return pre_provision_token_type_;
|
||||
@@ -100,13 +77,15 @@ class CryptoSession {
|
||||
bool is_provisioning, std::string* signature);
|
||||
virtual bool PrepareRenewalRequest(const std::string& message,
|
||||
std::string* signature);
|
||||
virtual CdmResponseType LoadKeys(const std::string& message,
|
||||
const std::string& signature,
|
||||
const std::string& mac_key_iv,
|
||||
const std::string& mac_key,
|
||||
const std::vector<CryptoKey>& key_array,
|
||||
const std::string& provider_session_token,
|
||||
const std::string& srm_requirement);
|
||||
virtual CdmResponseType LoadKeys(
|
||||
const std::string& message, const std::string& signature,
|
||||
const std::string& mac_key_iv, const std::string& mac_key,
|
||||
const std::vector<CryptoKey>& key_array,
|
||||
const std::string& provider_session_token,
|
||||
const std::string& srm_requirement,
|
||||
CdmLicenseKeyType key_type);
|
||||
virtual CdmResponseType LoadEntitledContentKeys(
|
||||
const std::vector<CryptoKey>& key_array);
|
||||
virtual bool LoadCertificatePrivateKey(std::string& wrapped_key);
|
||||
virtual bool RefreshKeys(const std::string& message,
|
||||
const std::string& signature, int num_keys,
|
||||
@@ -192,21 +171,22 @@ class CryptoSession {
|
||||
virtual CdmResponseType LoadUsageEntry(uint32_t entry_number,
|
||||
const CdmUsageEntry& usage_entry);
|
||||
virtual CdmResponseType UpdateUsageEntry(
|
||||
CdmUsageTableHeader* usage_table_header,
|
||||
CdmUsageEntry* usage_entry);
|
||||
CdmUsageTableHeader* usage_table_header, CdmUsageEntry* usage_entry);
|
||||
virtual CdmResponseType ShrinkUsageTableHeader(
|
||||
uint32_t new_entry_count, CdmUsageTableHeader* usage_table_header);
|
||||
virtual CdmResponseType MoveUsageEntry(uint32_t new_entry_number);
|
||||
virtual bool CreateOldUsageEntry(
|
||||
uint64_t time_since_license_received,
|
||||
uint64_t time_since_first_decrypt,
|
||||
uint64_t time_since_last_decrypt,
|
||||
UsageDurationStatus status,
|
||||
const std::string& server_mac_key,
|
||||
const std::string& client_mac_key,
|
||||
const std::string& provider_session_token);
|
||||
virtual bool CreateOldUsageEntry(uint64_t time_since_license_received,
|
||||
uint64_t time_since_first_decrypt,
|
||||
uint64_t time_since_last_decrypt,
|
||||
UsageDurationStatus status,
|
||||
const std::string& server_mac_key,
|
||||
const std::string& client_mac_key,
|
||||
const std::string& provider_session_token);
|
||||
virtual CdmResponseType CopyOldUsageEntry(
|
||||
const std::string& provider_session_token);
|
||||
virtual bool GetAnalogOutputCapabilities(bool* can_support_output,
|
||||
bool* can_disable_output,
|
||||
bool* can_support_cgms_a);
|
||||
virtual metrics::CryptoMetrics* GetCryptoMetrics() { return metrics_; }
|
||||
|
||||
virtual CdmResponseType AddSubSession(const std::string& sub_session_key_id,
|
||||
@@ -217,27 +197,37 @@ class CryptoSession {
|
||||
bool* exists, uint32_t* nonce);
|
||||
|
||||
private:
|
||||
friend class CryptoSessionForTest;
|
||||
|
||||
bool GetProvisioningMethod(CdmClientTokenType* token_type);
|
||||
void Init();
|
||||
void Terminate();
|
||||
bool GetTokenFromKeybox(std::string* token);
|
||||
bool GetTokenFromOemCert(std::string* token);
|
||||
static bool ExtractSystemIdFromOemCert(const std::string& oem_cert,
|
||||
uint32_t* system_id);
|
||||
bool GetSystemIdInternal(uint32_t* system_id);
|
||||
bool GenerateSignature(const std::string& message, std::string* signature);
|
||||
bool GenerateRsaSignature(const std::string& message, std::string* signature);
|
||||
|
||||
bool SetDestinationBufferType();
|
||||
|
||||
bool RewrapDeviceRSAKey(
|
||||
const std::string& message, const std::string& signature,
|
||||
const std::string& nonce, const std::string& enc_rsa_key,
|
||||
const std::string& rsa_key_iv, std::string* wrapped_rsa_key);
|
||||
bool RewrapDeviceRSAKey(const std::string& message,
|
||||
const std::string& signature,
|
||||
const std::string& nonce,
|
||||
const std::string& enc_rsa_key,
|
||||
const std::string& rsa_key_iv,
|
||||
std::string* wrapped_rsa_key);
|
||||
|
||||
bool RewrapDeviceRSAKey30(
|
||||
const std::string& message, const std::string& nonce,
|
||||
const std::string& private_key, const std::string& iv,
|
||||
const std::string& wrapping_key, std::string* wrapped_private_key);
|
||||
bool RewrapDeviceRSAKey30(const std::string& message,
|
||||
const std::string& nonce,
|
||||
const std::string& private_key,
|
||||
const std::string& iv,
|
||||
const std::string& wrapping_key,
|
||||
std::string* wrapped_private_key);
|
||||
|
||||
CdmResponseType SelectKey(const std::string& key_id);
|
||||
CdmResponseType SelectKey(const std::string& key_id,
|
||||
CdmCipherMode cipher_mode);
|
||||
|
||||
static const OEMCrypto_Algorithm kInvalidAlgorithm =
|
||||
static_cast<OEMCrypto_Algorithm>(-1);
|
||||
@@ -267,6 +257,7 @@ class CryptoSession {
|
||||
|
||||
metrics::CryptoMetrics* metrics_;
|
||||
metrics::TimerMetric life_span_;
|
||||
uint32_t system_id_;
|
||||
|
||||
bool open_;
|
||||
CdmClientTokenType pre_provision_token_type_;
|
||||
@@ -282,8 +273,6 @@ class CryptoSession {
|
||||
bool is_destination_buffer_type_valid_;
|
||||
SecurityLevel requested_security_level_;
|
||||
|
||||
KeyId cached_key_id_;
|
||||
|
||||
bool is_usage_support_type_valid_;
|
||||
CdmUsageSupportType usage_support_type_;
|
||||
UsageTableHeader* usage_table_header_;
|
||||
@@ -294,6 +283,7 @@ class CryptoSession {
|
||||
static uint64_t request_id_index_;
|
||||
|
||||
CdmCipherMode cipher_mode_;
|
||||
uint32_t api_version_;
|
||||
|
||||
CORE_DISALLOW_COPY_AND_ASSIGN(CryptoSession);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user