Reformat wv core/include files

[ Merge of http://go/wvgerrit/80483 ]

Clang-format has been run on files in core/include

Bug: 134365840
Test: WV unit/integration tests
Change-Id: I890127f23f30f0e63f826d3638521b4cc12fb995
This commit is contained in:
Rahul Frias
2019-06-03 10:24:21 -07:00
parent 01fbaac6ad
commit 47c2068d6a
19 changed files with 215 additions and 233 deletions

View File

@@ -6,6 +6,7 @@
#define WVCDM_CORE_BUFFER_READER_H_
#include <stdint.h>
#include <string>
#include <vector>

View File

@@ -6,6 +6,7 @@
#define WVCDM_CORE_CDM_CLIENT_PROPERTY_SET_H_
#include <stdint.h>
#include <string>
#include <vector>

View File

@@ -33,30 +33,31 @@ class UsagePropertySet;
class WvCdmEventListener;
// Keep expiration time for each key set
typedef std::map<CdmKeySetId,
std::pair<CdmSessionId, int64_t> > CdmReleaseKeySetMap;
typedef std::map<CdmKeySetId, std::pair<CdmSessionId, int64_t> >
CdmReleaseKeySetMap;
class CdmEngine {
public:
virtual ~CdmEngine();
// Session related methods
virtual CdmResponseType OpenSession(
const CdmKeySystem& key_system, CdmClientPropertySet* property_set,
const CdmSessionId& forced_session_id,
WvCdmEventListener* event_listener);
virtual CdmResponseType OpenSession(const CdmKeySystem& key_system,
CdmClientPropertySet* property_set,
const CdmSessionId& forced_session_id,
WvCdmEventListener* event_listener);
virtual CdmResponseType OpenSession(
const CdmKeySystem& key_system, CdmClientPropertySet* property_set,
WvCdmEventListener* event_listener, CdmSessionId* session_id);
virtual CdmResponseType OpenSession(const CdmKeySystem& key_system,
CdmClientPropertySet* property_set,
WvCdmEventListener* event_listener,
CdmSessionId* session_id);
virtual CdmResponseType CloseSession(const CdmSessionId& session_id);
virtual bool IsOpenSession(const CdmSessionId& session_id);
virtual CdmResponseType OpenKeySetSession(
const CdmKeySetId& key_set_id, CdmClientPropertySet* property_set,
WvCdmEventListener* event_listener);
virtual CdmResponseType OpenKeySetSession(const CdmKeySetId& key_set_id,
CdmClientPropertySet* property_set,
WvCdmEventListener* event_listener);
virtual CdmResponseType CloseKeySetSession(const CdmKeySetId& key_set_id);
@@ -129,8 +130,8 @@ class CdmEngine {
virtual CdmResponseType RemoveLicense(const CdmSessionId& session_id);
// Construct valid renewal request for the current session keys.
virtual CdmResponseType GenerateRenewalRequest(
const CdmSessionId& session_id, CdmKeyRequest* key_request);
virtual CdmResponseType GenerateRenewalRequest(const CdmSessionId& session_id,
CdmKeyRequest* key_request);
// Accept renewal response and update key info.
virtual CdmResponseType RenewKey(const CdmSessionId& session_id,
@@ -174,8 +175,8 @@ class CdmEngine {
// Generate and return a valid provisioning request.
virtual CdmResponseType GetProvisioningRequest(
CdmCertificateType cert_type, const std::string& cert_authority,
const std::string& service_certificate,
CdmProvisioningRequest* request, std::string* default_url);
const std::string& service_certificate, CdmProvisioningRequest* request,
std::string* default_url);
// Verify and process a provisioning response.
virtual CdmResponseType HandleProvisioningResponse(
@@ -214,14 +215,12 @@ class CdmEngine {
// Get offline license status: active, release or unknown
virtual CdmResponseType GetOfflineLicenseState(
const std::string& key_set_id,
CdmSecurityLevel security_level,
const std::string& key_set_id, CdmSecurityLevel security_level,
CdmOfflineLicenseState* license_state);
// Remove offline license with the given key_set_id
virtual CdmResponseType RemoveOfflineLicense(
const std::string& key_set_id,
CdmSecurityLevel security_level);
virtual CdmResponseType RemoveOfflineLicense(const std::string& key_set_id,
CdmSecurityLevel security_level);
// Usage related methods for streaming licenses
// Retrieve a random usage info from the list of all usage infos for this app
@@ -249,8 +248,7 @@ class CdmEngine {
virtual CdmResponseType RemoveAllUsageInfo(const std::string& app_id);
virtual CdmResponseType RemoveUsageInfo(
const std::string& app_id,
const CdmSecureStopId& secure_stop_id);
const std::string& app_id, const CdmSecureStopId& secure_stop_id);
virtual CdmResponseType ReleaseUsageInfo(
const CdmUsageInfoReleaseMessage& message);
@@ -266,16 +264,20 @@ class CdmEngine {
// application can use outside of content stream processing
// Encrypts a buffer of app-level data.
virtual CdmResponseType GenericEncrypt(
const std::string& session_id, const std::string& in_buffer,
const std::string& key_id, const std::string& iv,
CdmEncryptionAlgorithm algorithm, std::string* out_buffer);
virtual CdmResponseType GenericEncrypt(const std::string& session_id,
const std::string& in_buffer,
const std::string& key_id,
const std::string& iv,
CdmEncryptionAlgorithm algorithm,
std::string* out_buffer);
// Decrypts a buffer of app-level data.
virtual CdmResponseType GenericDecrypt(
const std::string& session_id, const std::string& in_buffer,
const std::string& key_id, const std::string& iv,
CdmEncryptionAlgorithm algorithm, std::string* out_buffer);
virtual CdmResponseType GenericDecrypt(const std::string& session_id,
const std::string& in_buffer,
const std::string& key_id,
const std::string& iv,
CdmEncryptionAlgorithm algorithm,
std::string* out_buffer);
// Computes the signature for a message.
virtual CdmResponseType GenericSign(const std::string& session_id,
@@ -336,9 +338,7 @@ class CdmEngine {
virtual void SetAppPackageName(const std::string& app_package_name) {
app_package_name_ = app_package_name;
}
virtual const std::string& GetAppPackageName() {
return app_package_name_;
}
virtual const std::string& GetAppPackageName() { return app_package_name_; }
protected:
friend class CdmEngineFactory;
@@ -354,17 +354,17 @@ class CdmEngine {
private:
// private methods
CdmResponseType OpenSession(
const CdmKeySystem& key_system, CdmClientPropertySet* property_set,
WvCdmEventListener* event_listener, const CdmSessionId* forced_session_id,
CdmSessionId* session_id);
CdmResponseType OpenSession(const CdmKeySystem& key_system,
CdmClientPropertySet* property_set,
WvCdmEventListener* event_listener,
const CdmSessionId* forced_session_id,
CdmSessionId* session_id);
void DeleteAllUsageReportsUponFactoryReset();
bool ValidateKeySystem(const CdmKeySystem& key_system);
CdmResponseType GetUsageInfo(const std::string& app_id,
SecurityLevel requested_security_level,
int* error_detail,
CdmUsageInfo* usage_info);
int* error_detail, CdmUsageInfo* usage_info);
void OnKeyReleaseEvent(const CdmKeySetId& key_set_id);

View File

@@ -39,7 +39,7 @@ class WvCdmEventListener;
// FileSystem* file_system; // Construction of FileSystem object not shown.
// std::shared_ptr<metrics::EngineMetrics> metrics(new EngineMetrics);
// CdmEngine* e = new CdmEngineMetricsImpl<CdmEngine>(file_system, metrics);
template<class T>
template <class T>
class CdmEngineMetricsImpl : public T {
public:
// This constructor initializes the instance and takes ownership of |metrics|.
@@ -52,37 +52,37 @@ class CdmEngineMetricsImpl : public T {
: T(file_system, metrics, spoid), metrics_(metrics) {
metrics_->cdm_engine_creation_time_millis_.Record(clock_.GetCurrentTime());
std::string cdm_version;
if(Properties::GetWVCdmVersion(&cdm_version)) {
if (Properties::GetWVCdmVersion(&cdm_version)) {
metrics_->cdm_engine_cdm_version_.Record(cdm_version);
} else {
metrics_->cdm_engine_cdm_version_.SetError(false);
}
}
~CdmEngineMetricsImpl() override {};
~CdmEngineMetricsImpl() override{};
bool GetMetricsSnapshot(drm_metrics::WvCdmMetrics *metrics) override {
bool GetMetricsSnapshot(drm_metrics::WvCdmMetrics* metrics) override {
if (metrics == nullptr) return false;
metrics_->Serialize(metrics);
return true;
}
CdmResponseType OpenSession(
const CdmKeySystem& key_system, CdmClientPropertySet* property_set,
const CdmSessionId& forced_session_id, WvCdmEventListener* event_listener)
override {
CdmResponseType sts = T::OpenSession(
key_system, property_set, forced_session_id, event_listener);
CdmResponseType OpenSession(const CdmKeySystem& key_system,
CdmClientPropertySet* property_set,
const CdmSessionId& forced_session_id,
WvCdmEventListener* event_listener) override {
CdmResponseType sts = T::OpenSession(key_system, property_set,
forced_session_id, event_listener);
metrics_->cdm_engine_open_session_.Increment(sts);
return sts;
}
CdmResponseType OpenSession(
const CdmKeySystem& key_system, CdmClientPropertySet* property_set,
WvCdmEventListener* event_listener, CdmSessionId* session_id)
override {
CdmResponseType sts = T::OpenSession(
key_system, property_set, event_listener, session_id);
CdmResponseType OpenSession(const CdmKeySystem& key_system,
CdmClientPropertySet* property_set,
WvCdmEventListener* event_listener,
CdmSessionId* session_id) override {
CdmResponseType sts =
T::OpenSession(key_system, property_set, event_listener, session_id);
metrics_->cdm_engine_open_session_.Increment(sts);
return sts;
}
@@ -96,27 +96,30 @@ class CdmEngineMetricsImpl : public T {
CdmResponseType OpenKeySetSession(
const CdmKeySetId& key_set_id, CdmClientPropertySet* property_set,
WvCdmEventListener* event_listener) override {
CdmResponseType sts = T::OpenKeySetSession(key_set_id, property_set,
event_listener);
CdmResponseType sts =
T::OpenKeySetSession(key_set_id, property_set, event_listener);
metrics_->cdm_engine_open_key_set_session_.Increment(sts);
return sts;
}
CdmResponseType GenerateKeyRequest(
const CdmSessionId& session_id, const CdmKeySetId& key_set_id,
const InitializationData& init_data, const CdmLicenseType license_type,
CdmAppParameterMap& app_parameters, CdmKeyRequest* key_request) override {
CdmResponseType GenerateKeyRequest(const CdmSessionId& session_id,
const CdmKeySetId& key_set_id,
const InitializationData& init_data,
const CdmLicenseType license_type,
CdmAppParameterMap& app_parameters,
CdmKeyRequest* key_request) override {
CdmResponseType sts;
M_TIME(sts = T::GenerateKeyRequest(session_id, key_set_id, init_data,
license_type, app_parameters,
key_request),
metrics_, cdm_engine_generate_key_request_, sts, license_type);
M_TIME(
sts = T::GenerateKeyRequest(session_id, key_set_id, init_data,
license_type, app_parameters, key_request),
metrics_, cdm_engine_generate_key_request_, sts, license_type);
return sts;
}
CdmResponseType AddKey(
const CdmSessionId& session_id, const CdmKeyResponse& key_data,
CdmLicenseType* license_type, CdmKeySetId* key_set_id) override {
CdmResponseType AddKey(const CdmSessionId& session_id,
const CdmKeyResponse& key_data,
CdmLicenseType* license_type,
CdmKeySetId* key_set_id) override {
if (license_type == nullptr) {
LOGE("CdmEngine::AddKey: license_type cannot be null.");
return PARAMETER_NULL;
@@ -128,12 +131,11 @@ class CdmEngineMetricsImpl : public T {
return sts;
}
CdmResponseType RestoreKey(const CdmSessionId& session_id,
const CdmKeySetId& key_set_id) override {
CdmResponseType sts;
M_TIME(sts = T::RestoreKey(session_id, key_set_id),
metrics_, cdm_engine_restore_key_, sts);
M_TIME(sts = T::RestoreKey(session_id, key_set_id), metrics_,
cdm_engine_restore_key_, sts);
return sts;
}
@@ -146,19 +148,20 @@ class CdmEngineMetricsImpl : public T {
CdmResponseType QueryKeyStatus(const CdmSessionId& session_id,
CdmQueryMap* query_response) override {
CdmResponseType sts;
M_TIME(sts = T::QueryKeyStatus(session_id, query_response),
metrics_, cdm_engine_query_key_status_, sts);
M_TIME(sts = T::QueryKeyStatus(session_id, query_response), metrics_,
cdm_engine_query_key_status_, sts);
return sts;
}
CdmResponseType GetProvisioningRequest(
CdmCertificateType cert_type, const std::string& cert_authority,
const std::string& service_certificate,
CdmProvisioningRequest* request, std::string* default_url) override {
CdmResponseType GetProvisioningRequest(CdmCertificateType cert_type,
const std::string& cert_authority,
const std::string& service_certificate,
CdmProvisioningRequest* request,
std::string* default_url) override {
CdmResponseType sts;
M_TIME(sts = T::GetProvisioningRequest(cert_type, cert_authority,
service_certificate,
request, default_url),
service_certificate, request,
default_url),
metrics_, cdm_engine_get_provisioning_request_, sts);
return sts;
}
@@ -167,21 +170,18 @@ class CdmEngineMetricsImpl : public T {
const CdmProvisioningResponse& response, std::string* cert,
std::string* wrapped_key) override {
CdmResponseType sts;
M_TIME(
sts = T::HandleProvisioningResponse(response, cert, wrapped_key),
metrics_, cdm_engine_handle_provisioning_response_, sts);
M_TIME(sts = T::HandleProvisioningResponse(response, cert, wrapped_key),
metrics_, cdm_engine_handle_provisioning_response_, sts);
return sts;
}
CdmResponseType Unprovision(CdmSecurityLevel security_level) override {
CdmResponseType sts = T::Unprovision(security_level);
metrics_->cdm_engine_unprovision_.Increment(sts, security_level);
return sts;
}
CdmResponseType GetUsageInfo(const std::string& app_id,
int* error_detail,
CdmResponseType GetUsageInfo(const std::string& app_id, int* error_detail,
CdmUsageInfo* usage_info) override {
CdmResponseType sts;
int error_detail_alt;
@@ -193,10 +193,8 @@ class CdmEngineMetricsImpl : public T {
return sts;
}
CdmResponseType GetUsageInfo(const std::string& app_id,
const CdmSecureStopId& ssid,
int* error_detail,
const CdmSecureStopId& ssid, int* error_detail,
CdmUsageInfo* usage_info) override {
CdmResponseType sts;
int error_detail_alt;
@@ -222,15 +220,15 @@ class CdmEngineMetricsImpl : public T {
}
CdmResponseType RemoveUsageInfo(
const std::string& app_id, const CdmSecureStopId& secure_stop_id)
override {
const std::string& app_id,
const CdmSecureStopId& secure_stop_id) override {
CdmResponseType sts = T::RemoveUsageInfo(app_id, secure_stop_id);
metrics_->cdm_engine_remove_usage_info_.Increment(sts);
return sts;
}
CdmResponseType ReleaseUsageInfo(const CdmUsageInfoReleaseMessage& message)
override {
CdmResponseType ReleaseUsageInfo(
const CdmUsageInfoReleaseMessage& message) override {
CdmResponseType sts = T::ReleaseUsageInfo(message);
metrics_->cdm_engine_release_usage_info_.Increment(sts);
return sts;
@@ -240,17 +238,15 @@ class CdmEngineMetricsImpl : public T {
const std::string& app_id, CdmSecurityLevel security_level,
std::vector<std::string>* ksids,
std::vector<std::string>* provider_session_tokens) override {
CdmResponseType sts = T::ListUsageIds(app_id, security_level,
ksids, provider_session_tokens);
CdmResponseType sts =
T::ListUsageIds(app_id, security_level, ksids, provider_session_tokens);
metrics_->cdm_engine_get_secure_stop_ids_.Increment(sts);
return sts;
}
bool FindSessionForKey(const KeyId& key_id, CdmSessionId* session_id)
override {
bool status =
T::FindSessionForKey(key_id, session_id);
bool FindSessionForKey(const KeyId& key_id,
CdmSessionId* session_id) override {
bool status = T::FindSessionForKey(key_id, session_id);
metrics_->cdm_engine_find_session_for_key_.Increment(status);
return status;
}
@@ -258,8 +254,8 @@ class CdmEngineMetricsImpl : public T {
CdmResponseType Decrypt(const CdmSessionId& session_id,
const CdmDecryptionParameters& parameters) override {
CdmResponseType sts;
M_TIME(sts = T::Decrypt(session_id, parameters),
metrics_, cdm_engine_decrypt_, sts,
M_TIME(sts = T::Decrypt(session_id, parameters), metrics_,
cdm_engine_decrypt_, sts,
metrics::Pow2Bucket(parameters.encrypt_length));
return sts;
}
@@ -269,5 +265,5 @@ class CdmEngineMetricsImpl : public T {
Clock clock_;
};
} // wvcdm namespace
} // namespace wvcdm
#endif // WVCDM_CORE_CDM_ENGINE_METRICS_DECORATOR_H_

View File

@@ -64,16 +64,15 @@ class CdmSession {
// |license_type|. The |error_detail| will be filled with an internal error
// code. The |error_detail| may be a CdmResponseType or other error code type.
// It is only suitable for additional logging or debugging.
virtual CdmResponseType RestoreOfflineSession(
const CdmKeySetId& key_set_id, CdmLicenseType license_type,
int* error_detail);
virtual CdmResponseType RestoreOfflineSession(const CdmKeySetId& key_set_id,
CdmLicenseType license_type,
int* error_detail);
// Restores an usage session from the provided |usage_data|.
// The |error_detail| will be filled with an internal error code. The
// |error_detail| may be a CdmResponseType or other error code type. It is
// only suitable for additional logging or debugging.
virtual CdmResponseType RestoreUsageSession(
const DeviceFiles::CdmUsageData& usage_data,
int* error_detail);
const DeviceFiles::CdmUsageData& usage_data, int* error_detail);
virtual const CdmSessionId& session_id() { return session_id_; }
virtual const CdmKeySetId& key_set_id() { return key_set_id_; }
@@ -153,11 +152,12 @@ class CdmSession {
virtual bool license_received() { return license_received_; }
virtual bool has_provider_session_token() {
return (license_parser_.get() != NULL &&
license_parser_->provider_session_token().size() > 0);
license_parser_->provider_session_token().size() > 0);
}
virtual CdmUsageSupportType get_usage_support_type()
{ return usage_support_type_; }
virtual CdmUsageSupportType get_usage_support_type() {
return usage_support_type_;
}
// This method will remove keys by resetting crypto resources and
// policy information. This renders the session mostly useless and it is
@@ -218,8 +218,7 @@ class CdmSession {
CdmResponseType StoreLicense();
bool StoreLicense(DeviceFiles::LicenseState state,
int* error_detail);
bool StoreLicense(DeviceFiles::LicenseState state, int* error_detail);
bool UpdateUsageInfo();

View File

@@ -25,21 +25,23 @@ class ServiceCertificate;
class CertificateProvisioning {
public:
CertificateProvisioning(metrics::CryptoMetrics* metrics) :
crypto_session_(CryptoSession::MakeCryptoSession(metrics)),
cert_type_(kCertificateWidevine),
service_certificate_(new ServiceCertificate()) {}
CertificateProvisioning(metrics::CryptoMetrics* metrics)
: crypto_session_(CryptoSession::MakeCryptoSession(metrics)),
cert_type_(kCertificateWidevine),
service_certificate_(new ServiceCertificate()) {}
~CertificateProvisioning() {}
CdmResponseType Init(const std::string& service_certificate);
// Construct a valid provisioning request.
// The request will be sent to the provisioning server.
CdmResponseType GetProvisioningRequest(
SecurityLevel requested_security_level, CdmCertificateType cert_type,
const std::string& cert_authority, const std::string& origin,
const std::string& spoid, CdmProvisioningRequest* request,
std::string* default_url);
CdmResponseType GetProvisioningRequest(SecurityLevel requested_security_level,
CdmCertificateType cert_type,
const std::string& cert_authority,
const std::string& origin,
const std::string& spoid,
CdmProvisioningRequest* request,
std::string* default_url);
// Process the provisioning response.
CdmResponseType HandleProvisioningResponse(
@@ -48,12 +50,11 @@ class CertificateProvisioning {
private:
CdmResponseType SetSpoidParameter(
const std::string& origin,
const std::string& spoid,
const std::string& origin, const std::string& spoid,
video_widevine::ProvisioningRequest* request);
video_widevine::SignedProvisioningMessage::ProtocolVersion
GetProtocolVersion();
GetProtocolVersion();
std::unique_ptr<CryptoSession> crypto_session_;
CdmCertificateType cert_type_;

View File

@@ -11,15 +11,15 @@ namespace wvcdm {
class CryptoKey {
public:
CryptoKey() {};
~CryptoKey() {};
CryptoKey(){};
~CryptoKey(){};
const std::string& key_id() const { return key_id_; }
const std::string& key_data() const { return key_data_; }
const std::string& key_data_iv() const { return key_data_iv_; }
const std::string& key_control() const { return key_control_; }
const std::string& key_control_iv() const { return key_control_iv_; }
const std::string& entitlement_key_id() const {return entitlement_key_id_;}
const std::string& entitlement_key_id() const { return entitlement_key_id_; }
const std::string& track_label() const { return track_label_; }
CdmCipherMode cipher_mode() const { return cipher_mode_; }
void set_key_id(const std::string& key_id) { key_id_ = key_id; }

View File

@@ -96,32 +96,31 @@ class CryptoSession {
std::string* signature);
virtual CdmResponseType 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,
CdmLicenseKeyType key_type);
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 CdmResponseType LoadCertificatePrivateKey(std::string& wrapped_key);
virtual CdmResponseType RefreshKeys(const std::string& message,
const std::string& signature,
int num_keys,
const CryptoKey* key_array);
int num_keys, const CryptoKey* key_array);
virtual CdmResponseType GenerateNonce(uint32_t* nonce);
virtual CdmResponseType GenerateDerivedKeys(const std::string& message);
virtual CdmResponseType GenerateDerivedKeys(const std::string& message,
const std::string& session_key);
virtual CdmResponseType RewrapCertificate(
const std::string& signed_message,
const std::string& signature,
const std::string& nonce,
const std::string& private_key,
const std::string& iv,
const std::string& wrapping_key,
std::string* wrapped_private_key);
virtual CdmResponseType RewrapCertificate(const std::string& signed_message,
const std::string& signature,
const std::string& nonce,
const std::string& private_key,
const std::string& iv,
const std::string& wrapping_key,
std::string* wrapped_private_key);
// Media data path
virtual CdmResponseType Decrypt(const CdmDecryptionParameters& params);
@@ -237,8 +236,7 @@ class CryptoSession {
virtual metrics::CryptoMetrics* GetCryptoMetrics() { return metrics_; }
virtual CdmResponseType GetProvisioningMethod(
SecurityLevel requested_security_level,
CdmClientTokenType* token_type);
SecurityLevel requested_security_level, CdmClientTokenType* token_type);
protected:
// Creates an instance of CryptoSession with the given |crypto_metrics|.
@@ -269,8 +267,8 @@ class CryptoSession {
static bool ExtractSystemIdFromOemCert(const std::string& oem_cert,
uint32_t* system_id);
CdmResponseType GetSystemIdInternal(uint32_t* system_id);
CdmResponseType GenerateSignature(
const std::string& message, std::string* signature);
CdmResponseType GenerateSignature(const std::string& message,
std::string* signature);
CdmResponseType GenerateRsaSignature(const std::string& message,
std::string* signature);

View File

@@ -79,21 +79,17 @@ class DeviceFiles {
virtual bool HasCertificate();
virtual bool RemoveCertificate();
virtual bool StoreLicense(const std::string& key_set_id,
const LicenseState state,
const CdmInitData& pssh_data,
const CdmKeyMessage& key_request,
const CdmKeyResponse& key_response,
const CdmKeyMessage& key_renewal_request,
const CdmKeyResponse& key_renewal_response,
const std::string& release_server_url,
int64_t playback_start_time,
int64_t last_playback_time,
int64_t grace_period_end_time,
const CdmAppParameterMap& app_parameters,
const CdmUsageEntry& usage_entry,
uint32_t usage_entry_number,
ResponseType* result);
virtual bool StoreLicense(
const std::string& key_set_id, const LicenseState state,
const CdmInitData& pssh_data, const CdmKeyMessage& key_request,
const CdmKeyResponse& key_response,
const CdmKeyMessage& key_renewal_request,
const CdmKeyResponse& key_renewal_response,
const std::string& release_server_url, int64_t playback_start_time,
int64_t last_playback_time, int64_t grace_period_end_time,
const CdmAppParameterMap& app_parameters,
const CdmUsageEntry& usage_entry, uint32_t usage_entry_number,
ResponseType* result);
virtual bool RetrieveLicense(
const std::string& key_set_id, LicenseState* state,
@@ -135,10 +131,9 @@ class DeviceFiles {
// Retrieve usage identifying information stored on the file system.
// The caller needs to specify at least one of |ksids| or
// |provider_session_tokens|
virtual bool ListUsageIds(
const std::string& app_id,
std::vector<std::string>* ksids,
std::vector<std::string>* provider_session_tokens);
virtual bool ListUsageIds(const std::string& app_id,
std::vector<std::string>* ksids,
std::vector<std::string>* provider_session_tokens);
// Get the provider session token for the given key_set_id.
virtual bool GetProviderSessionToken(const std::string& app_id,
@@ -173,12 +168,9 @@ class DeviceFiles {
// Retrieve the usage info entry specified by |key_set_id|.
// Returns false if the entry could not be found.
virtual bool RetrieveUsageInfoByKeySetId(
const std::string& usage_info_file_name,
const std::string& key_set_id,
std::string* provider_session_token,
CdmKeyMessage* license_request,
CdmKeyResponse* license_response,
CdmUsageEntry* usage_entry,
const std::string& usage_info_file_name, const std::string& key_set_id,
std::string* provider_session_token, CdmKeyMessage* license_request,
CdmKeyResponse* license_response, CdmUsageEntry* usage_entry,
uint32_t* usage_entry_number);
// These APIs support upgrading from usage tables to usage tabler header +
@@ -218,8 +210,7 @@ class DeviceFiles {
private:
// Extract serial number and system ID from DRM Device certificate
bool ExtractDeviceInfo(const std::string& device_certificate,
std::string* serial_number,
uint32_t* system_id);
std::string* serial_number, uint32_t* system_id);
// Helpers that wrap the File interface and automatically handle hashing, as
// well as adding the device files base path to to the file name.

View File

@@ -38,13 +38,11 @@ class InitializationData {
private:
bool SelectWidevinePssh(const CdmInitData& init_data,
bool prefer_entitlements,
CdmInitData* output);
bool prefer_entitlements, CdmInitData* output);
// Helpers used by SelectWidevinePssh().
bool ExtractWidevinePsshs(const CdmInitData& init_data,
std::vector<CdmInitData>* psshs);
bool ExtractWidevinePsshData(const uint8_t* data,
size_t length,
bool ExtractWidevinePsshData(const uint8_t* data, size_t length,
CdmInitData* output);
bool ExtractHlsAttributes(const std::string& attribute_list,

View File

@@ -7,8 +7,8 @@
#include <vector>
#include "metrics_collections.h"
#include "OEMCryptoCENC.h"
#include "metrics_collections.h"
#include "wv_cdm_types.h"
namespace wvcdm {
@@ -25,8 +25,7 @@ class KeySession {
virtual KeySessionType Type() = 0;
virtual OEMCryptoResult GenerateDerivedKeys(const std::string& message) = 0;
virtual OEMCryptoResult GenerateDerivedKeys(
const std::string& message,
const std::string& session_key) = 0;
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,

View File

@@ -72,8 +72,9 @@ class LicenseKeys {
const std::vector<WidevinePsshData_EntitledKey>& keys);
// For test use: Sets the OEMCrypto security level
virtual void SetSecurityLevelForTest(
CdmSecurityLevel security_level) { security_level_ = security_level; }
virtual void SetSecurityLevelForTest(CdmSecurityLevel security_level) {
security_level_ = security_level;
}
private:
typedef ::video_widevine::License::KeyContainer KeyContainer;
@@ -126,7 +127,8 @@ class LicenseKeyStatus {
// Indicates whether a key can be used for a given security level
virtual bool MeetsSecurityLevelConstraints() const {
return meets_security_level_constraints_; }
return meets_security_level_constraints_;
}
// Applies the given changes in resolution or HDCP settings.
virtual void ApplyConstraints(uint32_t new_resolution,

View File

@@ -47,11 +47,11 @@ OEMCryptoResult OEMCrypto_ShrinkUsageTableHeader(SecurityLevel level,
uint32_t new_table_size,
uint8_t* header_buffer,
size_t* header_buffer_length);
OEMCryptoResult OEMCrypto_CreateOldUsageEntry(SecurityLevel level,
uint64_t time_since_license_received, uint64_t time_since_first_decrypt,
uint64_t time_since_last_decrypt, OEMCrypto_Usage_Entry_Status status,
uint8_t* server_mac_key, uint8_t* client_mac_key, const uint8_t* pst,
size_t pst_length);
OEMCryptoResult OEMCrypto_CreateOldUsageEntry(
SecurityLevel level, uint64_t time_since_license_received,
uint64_t time_since_first_decrypt, uint64_t time_since_last_decrypt,
OEMCrypto_Usage_Entry_Status status, uint8_t* server_mac_key,
uint8_t* client_mac_key, const uint8_t* pst, size_t pst_length);
uint32_t OEMCrypto_GetAnalogOutputFlags(SecurityLevel level);
const char* OEMCrypto_BuildInformation(SecurityLevel level);
uint32_t OEMCrypto_ResourceRatingTier(SecurityLevel level);
@@ -107,7 +107,7 @@ OEMCryptoResult OEMCrypto_LoadKeys_Back_Compat(
OEMCryptoResult OEMCrypto_UpdateUsageTable();
OEMCryptoResult OEMCrypto_DeactivateUsageEntry_V12(const uint8_t* pst,
size_t pst_length);
size_t pst_length);
OEMCryptoResult OEMCrypto_DeleteUsageEntry(
OEMCrypto_SESSION session, const uint8_t* pst, size_t pst_length,
const uint8_t* message, size_t message_length, const uint8_t* signature,

View File

@@ -68,7 +68,6 @@ class RsaPublicKey {
CORE_DISALLOW_COPY_AND_ASSIGN(RsaPublicKey);
};
/**
* Extracts an integer value from the extensions in a certificate.
* @param cert A PKCS7 encoded X.509 certificate chain.

View File

@@ -20,8 +20,7 @@
namespace wvcdm {
typedef std::map<CdmSessionId, CdmClientPropertySet*>
CdmClientPropertySetMap;
typedef std::map<CdmSessionId, CdmClientPropertySet*> CdmClientPropertySetMap;
// This class saves information about features and properties enabled
// for a given platform. At initialization it initializes properties from
@@ -67,7 +66,7 @@ class Properties {
std::string* base_path);
static bool GetFactoryKeyboxPath(std::string* keybox);
static bool GetOEMCryptoPath(std::string* library_name);
static bool GetSandboxId(std::string *sandbox_id);
static bool GetSandboxId(std::string* sandbox_id);
static bool AlwaysUseKeySetIds();
static bool UseProviderIdInProvisioningRequest();

View File

@@ -56,8 +56,8 @@ class ServiceCertificate {
static bool GetRequest(CdmKeyMessage* request);
static CdmResponseType ParseResponse(const std::string& response,
std::string* signed_certificate);
private:
private:
// Encrypt data using RSA with OAEP padding.
// |plaintext| is the data to be encrypted. |ciphertext| is a pointer to a
// string to contain the decrypted data on return, and may not be null.

View File

@@ -59,8 +59,8 @@ class UsageTableHeader {
const std::string& usage_info_filename,
uint32_t* usage_entry_number);
virtual CdmResponseType LoadEntry(CryptoSession* crypto_session,
const CdmUsageEntry& usage_entry,
uint32_t usage_entry_number);
const CdmUsageEntry& usage_entry,
uint32_t usage_entry_number);
virtual CdmResponseType UpdateEntry(CryptoSession* crypto_session,
CdmUsageEntry* usage_entry);

View File

@@ -39,36 +39,34 @@ static const char KEY_SET_ID_PREFIX[] = "ksid";
static const char KEY_SYSTEM[] = "com.widevine";
// define query keys, values here
static const std::string QUERY_KEY_LICENSE_TYPE = "LicenseType";
// "Streaming", "Offline"
static const std::string QUERY_KEY_PLAY_ALLOWED = "PlayAllowed";
// "True", "False"
static const std::string QUERY_KEY_PERSIST_ALLOWED = "PersistAllowed";
// "True", "False"
static const std::string QUERY_KEY_RENEW_ALLOWED = "RenewAllowed";
// "True", "False"
static const std::string QUERY_KEY_LICENSE_TYPE =
"LicenseType"; // "Streaming", "Offline"
static const std::string QUERY_KEY_PLAY_ALLOWED =
"PlayAllowed"; // "True", "False"
static const std::string QUERY_KEY_PERSIST_ALLOWED =
"PersistAllowed"; // "True", "False"
static const std::string QUERY_KEY_RENEW_ALLOWED =
"RenewAllowed"; // "True", "False"
static const std::string QUERY_KEY_LICENSE_DURATION_REMAINING =
"LicenseDurationRemaining"; // non-negative integer denoting seconds
"LicenseDurationRemaining"; // non-negative integer denoting seconds
static const std::string QUERY_KEY_PLAYBACK_DURATION_REMAINING =
"PlaybackDurationRemaining"; // non-negative integer denoting seconds
static const std::string QUERY_KEY_RENEWAL_SERVER_URL = "RenewalServerUrl";
// url
static const std::string QUERY_KEY_OEMCRYPTO_SESSION_ID = "OemCryptoSessionId";
// session id
static const std::string QUERY_KEY_SECURITY_LEVEL = "SecurityLevel";
// "L1", "L3"
static const std::string QUERY_KEY_DEVICE_ID = "DeviceID";
// device unique id
static const std::string QUERY_KEY_SYSTEM_ID = "SystemID";
// system id
static const std::string QUERY_KEY_PROVISIONING_ID = "ProvisioningID";
// provisioning unique id
static const std::string QUERY_KEY_CURRENT_HDCP_LEVEL = "HdcpLevel";
// current HDCP level
static const std::string QUERY_KEY_MAX_HDCP_LEVEL = "MaxHdcpLevel";
// maximum supported HDCP level
static const std::string QUERY_KEY_USAGE_SUPPORT = "UsageSupport";
// whether usage reporting is supported
"PlaybackDurationRemaining"; // non-negative integer denoting seconds
static const std::string QUERY_KEY_RENEWAL_SERVER_URL =
"RenewalServerUrl"; // url
static const std::string QUERY_KEY_OEMCRYPTO_SESSION_ID =
"OemCryptoSessionId"; // session id
static const std::string QUERY_KEY_SECURITY_LEVEL =
"SecurityLevel"; // "L1", "L3"
static const std::string QUERY_KEY_DEVICE_ID = "DeviceID"; // device unique id
static const std::string QUERY_KEY_SYSTEM_ID = "SystemID"; // system id
static const std::string QUERY_KEY_PROVISIONING_ID =
"ProvisioningID"; // provisioning unique id
static const std::string QUERY_KEY_CURRENT_HDCP_LEVEL =
"HdcpLevel"; // current HDCP level
static const std::string QUERY_KEY_MAX_HDCP_LEVEL =
"MaxHdcpLevel"; // maximum supported HDCP level
static const std::string QUERY_KEY_USAGE_SUPPORT =
"UsageSupport"; // whether usage reporting is supported
static const std::string QUERY_KEY_NUMBER_OF_OPEN_SESSIONS =
"NumberOfOpenSessions";
static const std::string QUERY_KEY_MAX_NUMBER_OF_SESSIONS =
@@ -76,14 +74,13 @@ static const std::string QUERY_KEY_MAX_NUMBER_OF_SESSIONS =
static const std::string QUERY_KEY_OEMCRYPTO_API_VERSION =
"OemCryptoApiVersion";
static const std::string QUERY_KEY_CURRENT_SRM_VERSION = "CurrentSRMVersion";
static const std::string QUERY_KEY_SRM_UPDATE_SUPPORT = "SRMUpdateSupport";
// whether OEM supports SRM update
static const std::string QUERY_KEY_SRM_UPDATE_SUPPORT =
"SRMUpdateSupport"; // whether OEM supports SRM update
static const std::string QUERY_KEY_WVCDM_VERSION = "WidevineCdmVersion";
static const std::string QUERY_KEY_RESOURCE_RATING_TIER = "ResourceRatingTier";
static const std::string QUERY_KEY_OEMCRYPTO_BUILD_INFORMATION =
"OemCryptoBuildInformation";
static const std::string QUERY_KEY_DECRYPT_HASH_SUPPORT =
"DecryptHashSupport";
static const std::string QUERY_KEY_DECRYPT_HASH_SUPPORT = "DecryptHashSupport";
static const std::string QUERY_VALUE_TRUE = "True";
static const std::string QUERY_VALUE_FALSE = "False";
@@ -125,7 +122,7 @@ static const std::string HLS_URI_ATTRIBUTE = "URI";
static const char EMPTY_ORIGIN[] = "";
static const char EMPTY_SPOID[] = "";
//Policy engine HDCP enforcement
// Policy engine HDCP enforcement
static const uint32_t HDCP_UNSPECIFIED_VIDEO_RESOLUTION = 0;
static const int64_t HDCP_DEVICE_CHECK_INTERVAL = 10;
static const char EMPTY_APP_PACKAGE_NAME[] = "";

View File

@@ -5,8 +5,9 @@
#ifndef WVCDM_CORE_WV_CDM_TYPES_H_
#define WVCDM_CORE_WV_CDM_TYPES_H_
#include <array>
#include <stdint.h>
#include <array>
#include <map>
#include <string>
#include <vector>