Support Per-Origin Provisioning
This is a merge of several Widevine-side commits that, cumulatively,
allow callers to specify an origin to be used to isolate data storage
as specified in the W3C Encrypted Media Extension specification.
Separate origins have separate certificates, and consequently cannot
share device identifiers with each other.
The changes included in this are:
Add Ability to Check for Existing Certificates
http://go/wvgerrit/13974
Add Ability to Remove the Certificate
http://go/wvgerrit/13975
Make CDM Origin-Aware
http://go/wvgerrit/13977
Add Per-Origin Storage to Widevine CDM on Android
http://go/wvgerrit/14026
Remove Automatic Origin Generation
http://go/wvgerrit/14031
Bug: 19771858
Change-Id: I6a01c705d9b6b4887a9c7e6ff4399a125f781569
This commit is contained in:
@@ -32,13 +32,14 @@ class CdmEngine {
|
||||
// Session related methods
|
||||
virtual CdmResponseType OpenSession(const CdmKeySystem& key_system,
|
||||
const CdmClientPropertySet* property_set,
|
||||
const std::string& origin,
|
||||
WvCdmEventListener* event_listener,
|
||||
CdmSessionId* session_id);
|
||||
virtual CdmResponseType CloseSession(const CdmSessionId& session_id);
|
||||
|
||||
virtual CdmResponseType OpenKeySetSession(
|
||||
const CdmKeySetId& key_set_id, const CdmClientPropertySet* property_set,
|
||||
WvCdmEventListener* event_listener);
|
||||
const std::string& origin, WvCdmEventListener* event_listener);
|
||||
virtual CdmResponseType CloseKeySetSession(const CdmKeySetId& key_set_id);
|
||||
|
||||
// License related methods
|
||||
@@ -113,13 +114,18 @@ class CdmEngine {
|
||||
// Provisioning related methods
|
||||
virtual CdmResponseType GetProvisioningRequest(
|
||||
CdmCertificateType cert_type, const std::string& cert_authority,
|
||||
CdmProvisioningRequest* request, std::string* default_url);
|
||||
const std::string& origin, CdmProvisioningRequest* request,
|
||||
std::string* default_url);
|
||||
|
||||
virtual CdmResponseType HandleProvisioningResponse(
|
||||
CdmProvisioningResponse& response, std::string* cert,
|
||||
std::string* wrapped_key);
|
||||
const std::string& origin, CdmProvisioningResponse& response,
|
||||
std::string* cert, std::string* wrapped_key);
|
||||
|
||||
virtual CdmResponseType Unprovision(CdmSecurityLevel security_level);
|
||||
virtual bool IsProvisioned(CdmSecurityLevel security_level,
|
||||
const std::string& origin);
|
||||
|
||||
virtual CdmResponseType Unprovision(CdmSecurityLevel security_level,
|
||||
const std::string& origin);
|
||||
|
||||
// Usage related methods for streaming licenses
|
||||
// Retrieve a random usage info from the list of all usage infos for this app
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#define WVCDM_CORE_CDM_SESSION_H_
|
||||
|
||||
#include <set>
|
||||
#include <string>
|
||||
|
||||
#include "crypto_session.h"
|
||||
#include "device_files.h"
|
||||
@@ -22,7 +23,7 @@ class WvCdmEventListener;
|
||||
class CdmSession {
|
||||
public:
|
||||
CdmSession(const CdmClientPropertySet* cdm_client_property_set,
|
||||
WvCdmEventListener* event_listener);
|
||||
const std::string& origin, WvCdmEventListener* event_listener);
|
||||
virtual ~CdmSession();
|
||||
|
||||
virtual CdmResponseType Init();
|
||||
@@ -128,6 +129,7 @@ class CdmSession {
|
||||
// instance variables
|
||||
bool initialized_;
|
||||
CdmSessionId session_id_;
|
||||
const std::string origin_;
|
||||
scoped_ptr<CdmLicense> license_parser_;
|
||||
scoped_ptr<CryptoSession> crypto_session_;
|
||||
scoped_ptr<PolicyEngine> policy_engine_;
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
#ifndef WVCDM_CORE_CERTIFICATE_PROVISIONING_H_
|
||||
#define WVCDM_CORE_CERTIFICATE_PROVISIONING_H_
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "crypto_session.h"
|
||||
#include "oemcrypto_adapter.h"
|
||||
#include "wv_cdm_types.h"
|
||||
@@ -20,9 +22,11 @@ class CertificateProvisioning {
|
||||
CdmResponseType GetProvisioningRequest(SecurityLevel requested_security_level,
|
||||
CdmCertificateType cert_type,
|
||||
const std::string& cert_authority,
|
||||
const std::string& origin,
|
||||
CdmProvisioningRequest* request,
|
||||
std::string* default_url);
|
||||
CdmResponseType HandleProvisioningResponse(CdmProvisioningResponse& response,
|
||||
CdmResponseType HandleProvisioningResponse(const std::string& origin,
|
||||
CdmProvisioningResponse& response,
|
||||
std::string* cert,
|
||||
std::string* wrapped_key);
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#define WVCDM_CORE_DEVICE_FILES_H_
|
||||
|
||||
#include <unistd.h>
|
||||
#include <string>
|
||||
|
||||
#include "scoped_ptr.h"
|
||||
#include "wv_cdm_types.h"
|
||||
@@ -32,10 +33,14 @@ class DeviceFiles {
|
||||
return Init(security_level);
|
||||
}
|
||||
|
||||
virtual bool StoreCertificate(const std::string& certificate,
|
||||
virtual bool StoreCertificate(const std::string& origin,
|
||||
const std::string& certificate,
|
||||
const std::string& wrapped_private_key);
|
||||
virtual bool RetrieveCertificate(std::string* certificate,
|
||||
virtual bool RetrieveCertificate(const std::string& origin,
|
||||
std::string* certificate,
|
||||
std::string* wrapped_private_key);
|
||||
virtual bool HasCertificate(const std::string& origin);
|
||||
virtual bool RemoveCertificate(const std::string& origin);
|
||||
|
||||
virtual bool StoreLicense(const std::string& key_set_id,
|
||||
const LicenseState state,
|
||||
@@ -100,18 +105,21 @@ class DeviceFiles {
|
||||
// stored in a common directory and need to be copied over.
|
||||
virtual void SecurityLevelPathBackwardCompatibility();
|
||||
|
||||
// For testing only:
|
||||
static std::string GetCertificateFileName();
|
||||
static std::string GetCertificateFileName(const std::string& origin);
|
||||
static std::string GetLicenseFileNameExtension();
|
||||
static std::string GetUsageInfoFileName(const std::string& app_id);
|
||||
static std::string GetBlankFileData();
|
||||
static std::string GetFileNameSafeHash(const std::string& input);
|
||||
|
||||
// For testing only:
|
||||
void SetTestFile(File* file);
|
||||
#if defined(UNIT_TEST)
|
||||
FRIEND_TEST(DeviceFilesSecurityLevelTest, SecurityLevel);
|
||||
FRIEND_TEST(DeviceFilesStoreTest, StoreCertificate);
|
||||
FRIEND_TEST(DeviceCertificateStoreTest, StoreCertificate);
|
||||
FRIEND_TEST(DeviceCertificateTest, ReadCertificate);
|
||||
FRIEND_TEST(DeviceCertificateTest, HasCertificate);
|
||||
FRIEND_TEST(DeviceFilesStoreTest, StoreLicense);
|
||||
FRIEND_TEST(DeviceFilesTest, DeleteLicense);
|
||||
FRIEND_TEST(DeviceFilesTest, ReadCertificate);
|
||||
FRIEND_TEST(DeviceFilesTest, ReserveLicenseIds);
|
||||
FRIEND_TEST(DeviceFilesTest, RetrieveLicenses);
|
||||
FRIEND_TEST(DeviceFilesTest, SecurityLevelPathBackwardCompatibility);
|
||||
|
||||
@@ -75,6 +75,8 @@ static const std::string WEBM_VIDEO_MIME_TYPE = "video/webm";
|
||||
static const std::string WEBM_AUDIO_MIME_TYPE = "audio/webm";
|
||||
static const std::string CENC_INIT_DATA_FORMAT = "cenc";
|
||||
static const std::string WEBM_INIT_DATA_FORMAT = "webm";
|
||||
|
||||
static const char EMPTY_ORIGIN[] = "";
|
||||
} // namespace wvcdm
|
||||
|
||||
#endif // WVCDM_CORE_WV_CDM_CONSTANTS_H_
|
||||
|
||||
@@ -76,6 +76,7 @@ CdmEngine::~CdmEngine() {
|
||||
|
||||
CdmResponseType CdmEngine::OpenSession(const CdmKeySystem& key_system,
|
||||
const CdmClientPropertySet* property_set,
|
||||
const std::string& origin,
|
||||
WvCdmEventListener* event_listener,
|
||||
CdmSessionId* session_id) {
|
||||
LOGI("CdmEngine::OpenSession");
|
||||
@@ -91,7 +92,7 @@ CdmResponseType CdmEngine::OpenSession(const CdmKeySystem& key_system,
|
||||
}
|
||||
|
||||
scoped_ptr<CdmSession> new_session(
|
||||
new CdmSession(property_set, event_listener));
|
||||
new CdmSession(property_set, origin, event_listener));
|
||||
if (new_session->session_id().empty()) {
|
||||
LOGE("CdmEngine::OpenSession: failure to generate session ID");
|
||||
return UNKNOWN_ERROR;
|
||||
@@ -115,7 +116,7 @@ CdmResponseType CdmEngine::OpenSession(const CdmKeySystem& key_system,
|
||||
|
||||
CdmResponseType CdmEngine::OpenKeySetSession(
|
||||
const CdmKeySetId& key_set_id, const CdmClientPropertySet* property_set,
|
||||
WvCdmEventListener* event_listener) {
|
||||
const std::string& origin, WvCdmEventListener* event_listener) {
|
||||
LOGI("CdmEngine::OpenKeySetSession");
|
||||
|
||||
if (key_set_id.empty()) {
|
||||
@@ -125,7 +126,8 @@ CdmResponseType CdmEngine::OpenKeySetSession(
|
||||
|
||||
CdmSessionId session_id;
|
||||
CdmResponseType sts =
|
||||
OpenSession(KEY_SYSTEM, property_set, event_listener, &session_id);
|
||||
OpenSession(KEY_SYSTEM, property_set, origin, event_listener,
|
||||
&session_id);
|
||||
|
||||
if (sts != NO_ERROR) return sts;
|
||||
|
||||
@@ -503,9 +505,10 @@ CdmResponseType CdmEngine::QueryKeyControlInfo(const CdmSessionId& session_id,
|
||||
*/
|
||||
CdmResponseType CdmEngine::GetProvisioningRequest(
|
||||
CdmCertificateType cert_type, const std::string& cert_authority,
|
||||
CdmProvisioningRequest* request, std::string* default_url) {
|
||||
const std::string& origin, CdmProvisioningRequest* request,
|
||||
std::string* default_url) {
|
||||
if (!request || !default_url) {
|
||||
LOGE("CdmEngine::GetProvisioningRequest: invalid input parameters");
|
||||
LOGE("CdmEngine::GetProvisioningRequest: invalid output parameters");
|
||||
return UNKNOWN_ERROR;
|
||||
}
|
||||
if (NULL == cert_provisioning_.get()) {
|
||||
@@ -513,7 +516,7 @@ CdmResponseType CdmEngine::GetProvisioningRequest(
|
||||
}
|
||||
CdmResponseType ret = cert_provisioning_->GetProvisioningRequest(
|
||||
cert_provisioning_requested_security_level_, cert_type, cert_authority,
|
||||
request, default_url);
|
||||
origin, request, default_url);
|
||||
if (ret != NO_ERROR) {
|
||||
cert_provisioning_.reset(NULL); // Release resources.
|
||||
}
|
||||
@@ -528,8 +531,8 @@ CdmResponseType CdmEngine::GetProvisioningRequest(
|
||||
* Returns NO_ERROR for success and UNKNOWN_ERROR if fails.
|
||||
*/
|
||||
CdmResponseType CdmEngine::HandleProvisioningResponse(
|
||||
CdmProvisioningResponse& response, std::string* cert,
|
||||
std::string* wrapped_key) {
|
||||
const std::string& origin, CdmProvisioningResponse& response,
|
||||
std::string* cert, std::string* wrapped_key) {
|
||||
if (response.empty()) {
|
||||
LOGE("CdmEngine::HandleProvisioningResponse: Empty provisioning response.");
|
||||
cert_provisioning_.reset(NULL);
|
||||
@@ -553,35 +556,55 @@ CdmResponseType CdmEngine::HandleProvisioningResponse(
|
||||
return UNKNOWN_ERROR;
|
||||
}
|
||||
CdmResponseType ret = cert_provisioning_->HandleProvisioningResponse(
|
||||
response, cert, wrapped_key);
|
||||
origin, response, cert, wrapped_key);
|
||||
cert_provisioning_.reset(NULL); // Release resources.
|
||||
return ret;
|
||||
}
|
||||
|
||||
CdmResponseType CdmEngine::Unprovision(CdmSecurityLevel security_level) {
|
||||
bool CdmEngine::IsProvisioned(CdmSecurityLevel security_level,
|
||||
const std::string& origin) {
|
||||
DeviceFiles handle;
|
||||
if (!handle.Init(security_level)) {
|
||||
LOGE("CdmEngine::IsProvisioned: unable to initialize device files");
|
||||
return false;
|
||||
}
|
||||
return handle.HasCertificate(origin);
|
||||
}
|
||||
|
||||
CdmResponseType CdmEngine::Unprovision(CdmSecurityLevel security_level,
|
||||
const std::string& origin) {
|
||||
DeviceFiles handle;
|
||||
if (!handle.Init(security_level)) {
|
||||
LOGE("CdmEngine::Unprovision: unable to initialize device files");
|
||||
return UNKNOWN_ERROR;
|
||||
}
|
||||
|
||||
if (!handle.DeleteAllFiles()) {
|
||||
LOGE("CdmEngine::Unprovision: unable to delete files");
|
||||
return UNKNOWN_ERROR;
|
||||
}
|
||||
if (origin != EMPTY_ORIGIN) {
|
||||
if (!handle.RemoveCertificate(origin)) {
|
||||
LOGE("CdmEngine::Unprovision: unable to delete certificate for origin %s",
|
||||
origin.c_str());
|
||||
return UNKNOWN_ERROR;
|
||||
}
|
||||
return NO_ERROR;
|
||||
} else {
|
||||
if (!handle.DeleteAllFiles()) {
|
||||
LOGE("CdmEngine::Unprovision: unable to delete files");
|
||||
return UNKNOWN_ERROR;
|
||||
}
|
||||
|
||||
scoped_ptr<CryptoSession> crypto_session(new CryptoSession());
|
||||
CdmResponseType status = crypto_session->Open(
|
||||
security_level == kSecurityLevelL3 ? kLevel3 : kLevelDefault);
|
||||
if (NO_ERROR != status) {
|
||||
LOGE("CdmEngine::Unprovision: error opening crypto session: %d", status);
|
||||
return UNKNOWN_ERROR;
|
||||
scoped_ptr<CryptoSession> crypto_session(new CryptoSession());
|
||||
CdmResponseType status = crypto_session->Open(
|
||||
security_level == kSecurityLevelL3 ? kLevel3 : kLevelDefault);
|
||||
if (NO_ERROR != status) {
|
||||
LOGE("CdmEngine::Unprovision: error opening crypto session: %d", status);
|
||||
return UNKNOWN_ERROR;
|
||||
}
|
||||
status = crypto_session->DeleteAllUsageReports();
|
||||
if (status != NO_ERROR) {
|
||||
LOGE("CdmEngine::Unprovision: error deleteing usage reports: %d", status);
|
||||
}
|
||||
return status;
|
||||
}
|
||||
status = crypto_session->DeleteAllUsageReports();
|
||||
if (status != NO_ERROR) {
|
||||
LOGE("CdmEngine::Unprovision: error deleteing usage reports: %d", status);
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
CdmResponseType CdmEngine::GetUsageInfo(const std::string& app_id,
|
||||
@@ -592,7 +615,8 @@ CdmResponseType CdmEngine::GetUsageInfo(const std::string& app_id,
|
||||
}
|
||||
usage_property_set_->set_security_level(kLevelDefault);
|
||||
usage_property_set_->set_app_id(app_id);
|
||||
usage_session_.reset(new CdmSession(usage_property_set_.get(), NULL));
|
||||
usage_session_.reset(
|
||||
new CdmSession(usage_property_set_.get(), EMPTY_ORIGIN, NULL));
|
||||
CdmResponseType status = usage_session_->Init();
|
||||
if (NO_ERROR != status) {
|
||||
LOGE("CdmEngine::GetUsageInfo: session init error");
|
||||
@@ -610,7 +634,8 @@ CdmResponseType CdmEngine::GetUsageInfo(const std::string& app_id,
|
||||
&license_response)) {
|
||||
usage_property_set_->set_security_level(kLevel3);
|
||||
usage_property_set_->set_app_id(app_id);
|
||||
usage_session_.reset(new CdmSession(usage_property_set_.get(), NULL));
|
||||
usage_session_.reset(
|
||||
new CdmSession(usage_property_set_.get(), EMPTY_ORIGIN, NULL));
|
||||
status = usage_session_->Init();
|
||||
if (NO_ERROR != status) {
|
||||
LOGE("CdmEngine::GetUsageInfo: session init error");
|
||||
@@ -678,7 +703,8 @@ CdmResponseType CdmEngine::GetUsageInfo(const std::string& app_id,
|
||||
usage_property_set_->set_security_level(requested_security_level);
|
||||
usage_property_set_->set_app_id(app_id);
|
||||
|
||||
usage_session_.reset(new CdmSession(usage_property_set_.get(), NULL));
|
||||
usage_session_.reset(
|
||||
new CdmSession(usage_property_set_.get(), EMPTY_ORIGIN, NULL));
|
||||
|
||||
CdmResponseType status = usage_session_->Init();
|
||||
if (NO_ERROR != status) {
|
||||
|
||||
@@ -24,9 +24,11 @@ const size_t kKeySetIdLength = 14;
|
||||
namespace wvcdm {
|
||||
|
||||
CdmSession::CdmSession(const CdmClientPropertySet* cdm_client_property_set,
|
||||
const std::string& origin,
|
||||
WvCdmEventListener* event_listener)
|
||||
: initialized_(false),
|
||||
session_id_(GenerateSessionId()),
|
||||
origin_(origin),
|
||||
license_parser_(new CdmLicense),
|
||||
crypto_session_(new CryptoSession),
|
||||
policy_engine_(
|
||||
@@ -70,7 +72,7 @@ CdmResponseType CdmSession::Init() {
|
||||
if (Properties::use_certificates_as_identification()) {
|
||||
std::string wrapped_key;
|
||||
if (!file_handle_->Init(security_level_) ||
|
||||
!file_handle_->RetrieveCertificate(&token, &wrapped_key) ||
|
||||
!file_handle_->RetrieveCertificate(origin_, &token, &wrapped_key) ||
|
||||
!crypto_session_->LoadCertificatePrivateKey(wrapped_key)) {
|
||||
return NEED_PROVISIONING;
|
||||
}
|
||||
|
||||
@@ -57,8 +57,8 @@ void CertificateProvisioning::ComposeJsonRequestAsQueryString(
|
||||
*/
|
||||
CdmResponseType CertificateProvisioning::GetProvisioningRequest(
|
||||
SecurityLevel requested_security_level, CdmCertificateType cert_type,
|
||||
const std::string& cert_authority, CdmProvisioningRequest* request,
|
||||
std::string* default_url) {
|
||||
const std::string& cert_authority, const std::string& origin,
|
||||
CdmProvisioningRequest* request, std::string* default_url) {
|
||||
if (!default_url) {
|
||||
LOGE("GetProvisioningRequest: pointer for returning URL is NULL");
|
||||
return UNKNOWN_ERROR;
|
||||
@@ -113,6 +113,15 @@ CdmResponseType CertificateProvisioning::GetProvisioningRequest(
|
||||
cert_type_ = cert_type;
|
||||
options->set_certificate_authority(cert_authority);
|
||||
|
||||
if (origin != EMPTY_ORIGIN) {
|
||||
std::string device_unique_id;
|
||||
if (!crypto_session_.GetDeviceUniqueId(&device_unique_id)) {
|
||||
LOGE("GetProvisioningRequest: fails to get device unique ID");
|
||||
return UNKNOWN_ERROR;
|
||||
}
|
||||
provisioning_request.set_stable_id(device_unique_id + origin);
|
||||
}
|
||||
|
||||
std::string serialized_message;
|
||||
provisioning_request.SerializeToString(&serialized_message);
|
||||
|
||||
@@ -180,8 +189,8 @@ bool CertificateProvisioning::ParseJsonResponse(
|
||||
* Returns NO_ERROR for success and UNKNOWN_ERROR if fails.
|
||||
*/
|
||||
CdmResponseType CertificateProvisioning::HandleProvisioningResponse(
|
||||
CdmProvisioningResponse& response, std::string* cert,
|
||||
std::string* wrapped_key) {
|
||||
const std::string& origin, CdmProvisioningResponse& response,
|
||||
std::string* cert, std::string* wrapped_key) {
|
||||
// Extracts signed response from JSON string, decodes base64 signed response
|
||||
const std::string kMessageStart = "\"signedResponse\": \"";
|
||||
const std::string kMessageEnd = "\"";
|
||||
@@ -255,7 +264,7 @@ CdmResponseType CertificateProvisioning::HandleProvisioningResponse(
|
||||
LOGE("HandleProvisioningResponse: failed to init DeviceFiles");
|
||||
return UNKNOWN_ERROR;
|
||||
}
|
||||
if (!handle.StoreCertificate(device_certificate, wrapped_rsa_key)) {
|
||||
if (!handle.StoreCertificate(origin, device_certificate, wrapped_rsa_key)) {
|
||||
LOGE("HandleProvisioningResponse: failed to save provisioning certificate");
|
||||
return UNKNOWN_ERROR;
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#include "log.h"
|
||||
#include "properties.h"
|
||||
#include "string_conversions.h"
|
||||
#include "wv_cdm_constants.h"
|
||||
|
||||
#if defined(__APPLE__)
|
||||
#include <CommonCrypto/CommonDigest.h>
|
||||
@@ -31,7 +32,8 @@ using video_widevine_client::sdk::UsageInfo_ProviderSession;
|
||||
|
||||
namespace {
|
||||
|
||||
const char kCertificateFileName[] = "cert.bin";
|
||||
const char kCertificateFileNamePrefix[] = "cert";
|
||||
const char kCertificateFileNameExt[] = ".bin";
|
||||
const char kUsageInfoFileNamePrefix[] = "usage";
|
||||
const char kUsageInfoFileNameExt[] = ".bin";
|
||||
const char kLicenseFileNameExt[] = ".lic";
|
||||
@@ -86,7 +88,8 @@ bool DeviceFiles::Init(CdmSecurityLevel security_level) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool DeviceFiles::StoreCertificate(const std::string& certificate,
|
||||
bool DeviceFiles::StoreCertificate(const std::string& origin,
|
||||
const std::string& certificate,
|
||||
const std::string& wrapped_private_key) {
|
||||
if (!initialized_) {
|
||||
LOGW("DeviceFiles::StoreCertificate: not initialized");
|
||||
@@ -106,10 +109,11 @@ bool DeviceFiles::StoreCertificate(const std::string& certificate,
|
||||
std::string serialized_file;
|
||||
file.SerializeToString(&serialized_file);
|
||||
|
||||
return StoreFileWithHash(kCertificateFileName, serialized_file);
|
||||
return StoreFileWithHash(GetCertificateFileName(origin), serialized_file);
|
||||
}
|
||||
|
||||
bool DeviceFiles::RetrieveCertificate(std::string* certificate,
|
||||
bool DeviceFiles::RetrieveCertificate(const std::string& origin,
|
||||
std::string* certificate,
|
||||
std::string* wrapped_private_key) {
|
||||
if (!initialized_) {
|
||||
LOGW("DeviceFiles::RetrieveCertificate: not initialized");
|
||||
@@ -121,7 +125,9 @@ bool DeviceFiles::RetrieveCertificate(std::string* certificate,
|
||||
}
|
||||
|
||||
std::string serialized_file;
|
||||
if (!RetrieveHashedFile(kCertificateFileName, &serialized_file)) return false;
|
||||
if (!RetrieveHashedFile(GetCertificateFileName(origin), &serialized_file)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
video_widevine_client::sdk::File file;
|
||||
if (!file.ParseFromString(serialized_file)) {
|
||||
@@ -151,6 +157,24 @@ bool DeviceFiles::RetrieveCertificate(std::string* certificate,
|
||||
return true;
|
||||
}
|
||||
|
||||
bool DeviceFiles::HasCertificate(const std::string& origin) {
|
||||
if (!initialized_) {
|
||||
LOGW("DeviceFiles::HasCertificate: not initialized");
|
||||
return false;
|
||||
}
|
||||
|
||||
return FileExists(GetCertificateFileName(origin));
|
||||
}
|
||||
|
||||
bool DeviceFiles::RemoveCertificate(const std::string& origin) {
|
||||
if (!initialized_) {
|
||||
LOGW("DeviceFiles::RemoveCertificate: not initialized");
|
||||
return false;
|
||||
}
|
||||
|
||||
return RemoveFile(GetCertificateFileName(origin));
|
||||
}
|
||||
|
||||
bool DeviceFiles::StoreLicense(const std::string& key_set_id,
|
||||
const LicenseState state,
|
||||
const CdmInitData& pssh_data,
|
||||
@@ -749,8 +773,12 @@ void DeviceFiles::SecurityLevelPathBackwardCompatibility() {
|
||||
}
|
||||
}
|
||||
|
||||
std::string DeviceFiles::GetCertificateFileName() {
|
||||
return kCertificateFileName;
|
||||
std::string DeviceFiles::GetCertificateFileName(const std::string& origin) {
|
||||
std::string hash;
|
||||
if (origin != EMPTY_ORIGIN) {
|
||||
hash = GetFileNameSafeHash(origin);
|
||||
}
|
||||
return kCertificateFileNamePrefix + hash + kCertificateFileNameExt;
|
||||
}
|
||||
|
||||
std::string DeviceFiles::GetLicenseFileNameExtension() {
|
||||
@@ -758,20 +786,23 @@ std::string DeviceFiles::GetLicenseFileNameExtension() {
|
||||
}
|
||||
|
||||
std::string DeviceFiles::GetUsageInfoFileName(const std::string& app_id) {
|
||||
if (app_id == "") {
|
||||
return std::string(kUsageInfoFileNamePrefix) +
|
||||
std::string(kUsageInfoFileNameExt);
|
||||
std::string hash;
|
||||
if (app_id != "") {
|
||||
hash = GetFileNameSafeHash(app_id);
|
||||
}
|
||||
std::vector<uint8_t> hash(MD5_DIGEST_LENGTH);
|
||||
const unsigned char* input =
|
||||
reinterpret_cast<const unsigned char*>(app_id.data());
|
||||
MD5(input, app_id.size(), &hash[0]);
|
||||
return std::string(kUsageInfoFileNamePrefix) + wvcdm::Base64SafeEncode(hash) +
|
||||
std::string(kUsageInfoFileNameExt);
|
||||
return kUsageInfoFileNamePrefix + hash + kUsageInfoFileNameExt;
|
||||
}
|
||||
|
||||
std::string DeviceFiles::GetBlankFileData() { return kBlankFileData; }
|
||||
|
||||
std::string DeviceFiles::GetFileNameSafeHash(const std::string& input) {
|
||||
std::vector<uint8_t> hash(MD5_DIGEST_LENGTH);
|
||||
const unsigned char* input_ptr =
|
||||
reinterpret_cast<const unsigned char*>(input.data());
|
||||
MD5(input_ptr, input.size(), &hash[0]);
|
||||
return wvcdm::Base64SafeEncode(hash);
|
||||
}
|
||||
|
||||
void DeviceFiles::SetTestFile(File* file) {
|
||||
file_.reset(file);
|
||||
test_file_ = true;
|
||||
|
||||
@@ -48,10 +48,12 @@ class WvCdmEngineTest : public testing::Test {
|
||||
public:
|
||||
virtual void SetUp() {
|
||||
CdmResponseType status =
|
||||
cdm_engine_.OpenSession(g_key_system, NULL, NULL, &session_id_);
|
||||
cdm_engine_.OpenSession(g_key_system, NULL, EMPTY_ORIGIN, NULL,
|
||||
&session_id_);
|
||||
if (status == NEED_PROVISIONING) {
|
||||
Provision();
|
||||
status = cdm_engine_.OpenSession(g_key_system, NULL, NULL, &session_id_);
|
||||
status = cdm_engine_.OpenSession(g_key_system, NULL, EMPTY_ORIGIN, NULL,
|
||||
&session_id_);
|
||||
}
|
||||
ASSERT_EQ(NO_ERROR, status);
|
||||
ASSERT_NE("", session_id_) << "Could not open CDM session.";
|
||||
@@ -67,14 +69,15 @@ class WvCdmEngineTest : public testing::Test {
|
||||
std::string cert_authority;
|
||||
std::string cert, wrapped_key;
|
||||
ASSERT_EQ(NO_ERROR, cdm_engine_.GetProvisioningRequest(
|
||||
cert_type, cert_authority, &prov_request,
|
||||
&provisioning_server_url));
|
||||
cert_type, cert_authority, EMPTY_ORIGIN,
|
||||
&prov_request, &provisioning_server_url));
|
||||
UrlRequest url_request(provisioning_server_url);
|
||||
url_request.PostCertRequestInQueryString(prov_request);
|
||||
std::string message;
|
||||
bool ok = url_request.GetResponse(&message);
|
||||
EXPECT_TRUE(ok);
|
||||
ASSERT_EQ(NO_ERROR, cdm_engine_.HandleProvisioningResponse(message, &cert,
|
||||
ASSERT_EQ(NO_ERROR, cdm_engine_.HandleProvisioningResponse(EMPTY_ORIGIN,
|
||||
message, &cert,
|
||||
&wrapped_key));
|
||||
}
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#include "scoped_ptr.h"
|
||||
#include "string_conversions.h"
|
||||
#include "test_printers.h"
|
||||
#include "wv_cdm_constants.h"
|
||||
|
||||
namespace {
|
||||
const std::string kToken = wvcdm::a2bs_hex(
|
||||
@@ -83,6 +84,9 @@ const std::string kWrappedKey = wvcdm::a2bs_hex(
|
||||
"33EF70621A98184DDAB5E14BC971CF98CF6C91A37FFA83B00AD3BCABBAAB2DEF1C52F43003"
|
||||
"E74C92B44F9205D22262FB47948654229DE1920F8EDF96A19A88A1CA1552F8856FB4CBF83B"
|
||||
"AA3348419159D207F65FCE9C1A500C6818");
|
||||
|
||||
const std::string kTestOrigin = "com.google";
|
||||
|
||||
} // namespace
|
||||
|
||||
namespace wvcdm {
|
||||
@@ -99,7 +103,8 @@ using ::testing::StrEq;
|
||||
class MockDeviceFiles : public DeviceFiles {
|
||||
public:
|
||||
MOCK_METHOD1(Init, bool(CdmSecurityLevel));
|
||||
MOCK_METHOD2(RetrieveCertificate, bool(std::string*, std::string*));
|
||||
MOCK_METHOD3(RetrieveCertificate, bool(const std::string&, std::string*,
|
||||
std::string*));
|
||||
};
|
||||
|
||||
class MockCryptoSession : public CryptoSession {
|
||||
@@ -127,7 +132,7 @@ class MockCdmLicense : public CdmLicense {
|
||||
class CdmSessionTest : public ::testing::Test {
|
||||
protected:
|
||||
virtual void SetUp() {
|
||||
cdm_session_.reset(new CdmSession(NULL, NULL));
|
||||
cdm_session_.reset(new CdmSession(NULL, kTestOrigin, NULL));
|
||||
// Inject testing mocks.
|
||||
license_parser_ = new MockCdmLicense();
|
||||
cdm_session_->set_license_parser(license_parser_);
|
||||
@@ -156,8 +161,9 @@ TEST_F(CdmSessionTest, InitWithCertificate) {
|
||||
.InSequence(crypto_session_seq)
|
||||
.WillOnce(Return(level));
|
||||
EXPECT_CALL(*file_handle_, Init(Eq(level))).WillOnce(Return(true));
|
||||
EXPECT_CALL(*file_handle_, RetrieveCertificate(NotNull(), NotNull()))
|
||||
.WillOnce(DoAll(SetArgPointee<0>(kToken), SetArgPointee<1>(kWrappedKey),
|
||||
EXPECT_CALL(*file_handle_, RetrieveCertificate(StrEq(kTestOrigin), NotNull(),
|
||||
NotNull()))
|
||||
.WillOnce(DoAll(SetArgPointee<1>(kToken), SetArgPointee<2>(kWrappedKey),
|
||||
Return(true)));
|
||||
EXPECT_CALL(*crypto_session_, LoadCertificatePrivateKey(StrEq(kWrappedKey)))
|
||||
.InSequence(crypto_session_seq)
|
||||
@@ -202,8 +208,9 @@ TEST_F(CdmSessionTest, ReInitFail) {
|
||||
.InSequence(crypto_session_seq)
|
||||
.WillOnce(Return(level));
|
||||
EXPECT_CALL(*file_handle_, Init(Eq(level))).WillOnce(Return(true));
|
||||
EXPECT_CALL(*file_handle_, RetrieveCertificate(NotNull(), NotNull()))
|
||||
.WillOnce(DoAll(SetArgPointee<0>(kToken), SetArgPointee<1>(kWrappedKey),
|
||||
EXPECT_CALL(*file_handle_, RetrieveCertificate(StrEq(kTestOrigin), NotNull(),
|
||||
NotNull()))
|
||||
.WillOnce(DoAll(SetArgPointee<1>(kToken), SetArgPointee<2>(kWrappedKey),
|
||||
Return(true)));
|
||||
EXPECT_CALL(*crypto_session_, LoadCertificatePrivateKey(StrEq(kWrappedKey)))
|
||||
.InSequence(crypto_session_seq)
|
||||
@@ -238,7 +245,8 @@ TEST_F(CdmSessionTest, InitNeedsProvisioning) {
|
||||
.InSequence(crypto_session_seq)
|
||||
.WillOnce(Return(level));
|
||||
EXPECT_CALL(*file_handle_, Init(Eq(level))).WillOnce(Return(true));
|
||||
EXPECT_CALL(*file_handle_, RetrieveCertificate(NotNull(), NotNull()))
|
||||
EXPECT_CALL(*file_handle_, RetrieveCertificate(StrEq(kTestOrigin), NotNull(),
|
||||
NotNull()))
|
||||
.WillOnce(Return(false));
|
||||
|
||||
Properties::set_use_certificates_as_identification(true);
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
// Copyright 2013 Google Inc. All Rights Reserved.
|
||||
|
||||
#include <string>
|
||||
#include <gmock/gmock.h>
|
||||
#include <gtest/gtest.h>
|
||||
#include "device_files.h"
|
||||
#include "file_store.h"
|
||||
#include "properties.h"
|
||||
#include "string_conversions.h"
|
||||
#include "wv_cdm_constants.h"
|
||||
#include "wv_cdm_types.h"
|
||||
|
||||
namespace wvcdm {
|
||||
@@ -1230,6 +1232,8 @@ UsageInfo kUsageInfoTestData[] = {
|
||||
"0E12202FF1FBA9926A24A1F79970EC427DDF87B4421488F7952499BC33CEB282D9E48"
|
||||
"A")}};
|
||||
|
||||
const std::string kTestOrigin = "com.google";
|
||||
|
||||
} // namespace
|
||||
|
||||
class MockFile : public File {
|
||||
@@ -1278,6 +1282,23 @@ class DeviceFilesTest : public ::testing::Test {
|
||||
class DeviceFilesStoreTest : public DeviceFilesTest,
|
||||
public ::testing::WithParamInterface<bool> {};
|
||||
|
||||
struct CertStorageVariant {
|
||||
CertStorageVariant(bool dir_exists_value, const std::string& origin_value)
|
||||
: dir_exists(dir_exists_value),
|
||||
origin(origin_value) {}
|
||||
|
||||
const bool dir_exists;
|
||||
const std::string origin;
|
||||
};
|
||||
|
||||
class DeviceCertificateStoreTest
|
||||
: public DeviceFilesTest,
|
||||
public ::testing::WithParamInterface<CertStorageVariant> {};
|
||||
|
||||
class DeviceCertificateTest
|
||||
: public DeviceFilesTest,
|
||||
public ::testing::WithParamInterface<std::string> {};
|
||||
|
||||
class DeviceFilesSecurityLevelTest
|
||||
: public DeviceFilesTest,
|
||||
public ::testing::WithParamInterface<CdmSecurityLevel> {};
|
||||
@@ -1323,17 +1344,17 @@ MATCHER_P6(Contains, str1, str2, str3, str4, str5, str6, "") {
|
||||
data.find(str6) != std::string::npos);
|
||||
}
|
||||
|
||||
TEST_P(DeviceFilesStoreTest, StoreCertificate) {
|
||||
TEST_P(DeviceCertificateStoreTest, StoreCertificate) {
|
||||
MockFile file;
|
||||
CertStorageVariant params = GetParam();
|
||||
std::string certificate(GenerateRandomData(kCertificateLen));
|
||||
std::string wrapped_private_key(GenerateRandomData(kWrappedKeyLen));
|
||||
std::string device_certificate_path =
|
||||
device_base_path_ + DeviceFiles::GetCertificateFileName();
|
||||
device_base_path_ + DeviceFiles::GetCertificateFileName(params.origin);
|
||||
|
||||
bool dir_exists = GetParam();
|
||||
EXPECT_CALL(file, IsDirectory(StrEq(device_base_path_)))
|
||||
.WillOnce(Return(dir_exists));
|
||||
if (dir_exists) {
|
||||
.WillOnce(Return(params.dir_exists));
|
||||
if (params.dir_exists) {
|
||||
EXPECT_CALL(file, CreateDirectory(_)).Times(0);
|
||||
} else {
|
||||
EXPECT_CALL(file, CreateDirectory(StrEq(device_base_path_)))
|
||||
@@ -1352,16 +1373,22 @@ TEST_P(DeviceFilesStoreTest, StoreCertificate) {
|
||||
DeviceFiles device_files;
|
||||
EXPECT_TRUE(device_files.Init(kSecurityLevelL1));
|
||||
device_files.SetTestFile(&file);
|
||||
EXPECT_TRUE(device_files.StoreCertificate(certificate, wrapped_private_key));
|
||||
EXPECT_TRUE(device_files.StoreCertificate(params.origin, certificate,
|
||||
wrapped_private_key));
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(StoreCertificate, DeviceFilesStoreTest,
|
||||
::testing::Bool());
|
||||
INSTANTIATE_TEST_CASE_P(
|
||||
StoreCertificate, DeviceCertificateStoreTest,
|
||||
::testing::Values(CertStorageVariant(true, EMPTY_ORIGIN),
|
||||
CertStorageVariant(true, kTestOrigin),
|
||||
CertStorageVariant(false, EMPTY_ORIGIN),
|
||||
CertStorageVariant(false, kTestOrigin)));
|
||||
|
||||
TEST_F(DeviceFilesTest, ReadCertificate) {
|
||||
TEST_P(DeviceCertificateTest, ReadCertificate) {
|
||||
MockFile file;
|
||||
std::string origin = GetParam();
|
||||
std::string device_certificate_path =
|
||||
device_base_path_ + DeviceFiles::GetCertificateFileName();
|
||||
device_base_path_ + DeviceFiles::GetCertificateFileName(origin);
|
||||
std::string data = a2bs_hex(kTestCertificateFileData);
|
||||
|
||||
EXPECT_CALL(file, Exists(StrEq(device_certificate_path)))
|
||||
@@ -1382,11 +1409,36 @@ TEST_F(DeviceFilesTest, ReadCertificate) {
|
||||
|
||||
std::string certificate, wrapped_private_key;
|
||||
ASSERT_TRUE(
|
||||
device_files.RetrieveCertificate(&certificate, &wrapped_private_key));
|
||||
device_files.RetrieveCertificate(origin, &certificate,
|
||||
&wrapped_private_key));
|
||||
EXPECT_EQ(kTestCertificate, b2a_hex(certificate));
|
||||
EXPECT_EQ(kTestWrappedPrivateKey, b2a_hex(wrapped_private_key));
|
||||
}
|
||||
|
||||
TEST_P(DeviceCertificateTest, HasCertificate) {
|
||||
MockFile file;
|
||||
std::string origin = GetParam();
|
||||
std::string device_certificate_path =
|
||||
device_base_path_ + DeviceFiles::GetCertificateFileName(origin);
|
||||
|
||||
EXPECT_CALL(file, Exists(StrEq(device_certificate_path)))
|
||||
.WillOnce(Return(false))
|
||||
.WillOnce(Return(true));
|
||||
EXPECT_CALL(file, Open(_, _)).Times(0);
|
||||
|
||||
DeviceFiles device_files;
|
||||
ASSERT_TRUE(device_files.Init(kSecurityLevelL1));
|
||||
device_files.SetTestFile(&file);
|
||||
|
||||
// MockFile returns false.
|
||||
EXPECT_FALSE(device_files.HasCertificate(origin));
|
||||
// MockFile returns true.
|
||||
EXPECT_TRUE(device_files.HasCertificate(origin));
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(CertificateUseTests, DeviceCertificateTest,
|
||||
::testing::Values(EMPTY_ORIGIN, kTestOrigin));
|
||||
|
||||
TEST_P(DeviceFilesSecurityLevelTest, SecurityLevel) {
|
||||
MockFile file;
|
||||
std::string certificate(GenerateRandomData(kCertificateLen));
|
||||
@@ -1397,7 +1449,7 @@ TEST_P(DeviceFilesSecurityLevelTest, SecurityLevel) {
|
||||
ASSERT_TRUE(
|
||||
Properties::GetDeviceFilesBasePath(security_level, &device_base_path));
|
||||
std::string device_certificate_path =
|
||||
device_base_path + DeviceFiles::GetCertificateFileName();
|
||||
device_base_path + DeviceFiles::GetCertificateFileName(EMPTY_ORIGIN);
|
||||
|
||||
EXPECT_CALL(file, IsDirectory(StrEq(device_base_path)))
|
||||
.WillOnce(Return(false));
|
||||
@@ -1416,7 +1468,8 @@ TEST_P(DeviceFilesSecurityLevelTest, SecurityLevel) {
|
||||
DeviceFiles device_files;
|
||||
EXPECT_TRUE(device_files.Init(security_level));
|
||||
device_files.SetTestFile(&file);
|
||||
EXPECT_TRUE(device_files.StoreCertificate(certificate, wrapped_private_key));
|
||||
EXPECT_TRUE(device_files.StoreCertificate(EMPTY_ORIGIN, certificate,
|
||||
wrapped_private_key));
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(SecurityLevel, DeviceFilesSecurityLevelTest,
|
||||
@@ -1595,13 +1648,15 @@ TEST_F(DeviceFilesTest, SecurityLevelPathBackwardCompatibility) {
|
||||
EXPECT_CALL(file, CreateDirectory(StrEq(new_path))).WillOnce(Return(true));
|
||||
}
|
||||
|
||||
std::string old_path = base_path + DeviceFiles::GetCertificateFileName();
|
||||
old_files.push_back(DeviceFiles::GetCertificateFileName());
|
||||
std::string old_path =
|
||||
base_path + DeviceFiles::GetCertificateFileName(EMPTY_ORIGIN);
|
||||
old_files.push_back(DeviceFiles::GetCertificateFileName(EMPTY_ORIGIN));
|
||||
EXPECT_CALL(file, IsRegularFile(StrEq(old_path))).WillOnce(Return(true));
|
||||
EXPECT_CALL(file, Remove(StrEq(old_path))).WillOnce(Return(true));
|
||||
for (size_t i = 0; i < security_dirs.size(); ++i) {
|
||||
new_path =
|
||||
base_path + security_dirs[i] + DeviceFiles::GetCertificateFileName();
|
||||
base_path + security_dirs[i] +
|
||||
DeviceFiles::GetCertificateFileName(EMPTY_ORIGIN);
|
||||
EXPECT_CALL(file, Copy(StrEq(old_path), StrEq(new_path)))
|
||||
.WillOnce(Return(true));
|
||||
}
|
||||
@@ -1625,7 +1680,8 @@ TEST_F(DeviceFilesTest, SecurityLevelPathBackwardCompatibility) {
|
||||
|
||||
std::string data = a2bs_hex(kTestCertificateFileData);
|
||||
|
||||
new_path = device_base_path_ + DeviceFiles::GetCertificateFileName();
|
||||
new_path =
|
||||
device_base_path_ + DeviceFiles::GetCertificateFileName(EMPTY_ORIGIN);
|
||||
EXPECT_CALL(file, Exists(StrEq(new_path))).WillOnce(Return(true));
|
||||
EXPECT_CALL(file, FileSize(_)).WillOnce(Return(data.size()));
|
||||
EXPECT_CALL(file, Open(_, _)).WillOnce(Return(true));
|
||||
@@ -1642,7 +1698,8 @@ TEST_F(DeviceFilesTest, SecurityLevelPathBackwardCompatibility) {
|
||||
Properties::Init();
|
||||
std::string certificate, wrapped_private_key;
|
||||
ASSERT_TRUE(
|
||||
device_files.RetrieveCertificate(&certificate, &wrapped_private_key));
|
||||
device_files.RetrieveCertificate(EMPTY_ORIGIN, &certificate,
|
||||
&wrapped_private_key));
|
||||
}
|
||||
|
||||
TEST_F(DeviceFilesTest, UpdateLicenseState) {
|
||||
|
||||
@@ -28,6 +28,7 @@ class WvContentDecryptionModule : public TimerHandler {
|
||||
// Session related methods
|
||||
virtual CdmResponseType OpenSession(const CdmKeySystem& key_system,
|
||||
CdmClientPropertySet* property_set,
|
||||
const std::string& origin,
|
||||
WvCdmEventListener* event_listener,
|
||||
CdmSessionId* session_id);
|
||||
virtual CdmResponseType CloseSession(const CdmSessionId& session_id);
|
||||
@@ -40,6 +41,7 @@ class WvContentDecryptionModule : public TimerHandler {
|
||||
const CdmLicenseType license_type,
|
||||
CdmAppParameterMap& app_parameters,
|
||||
CdmClientPropertySet* property_set,
|
||||
const std::string& origin,
|
||||
CdmKeyMessage* key_request,
|
||||
CdmKeyRequestType* key_request_type,
|
||||
std::string* server_url);
|
||||
@@ -75,15 +77,18 @@ class WvContentDecryptionModule : public TimerHandler {
|
||||
virtual CdmResponseType GetProvisioningRequest(
|
||||
CdmCertificateType cert_type,
|
||||
const std::string& cert_authority,
|
||||
const std::string& origin,
|
||||
CdmProvisioningRequest* request,
|
||||
std::string* default_url);
|
||||
|
||||
virtual CdmResponseType HandleProvisioningResponse(
|
||||
const std::string& origin,
|
||||
CdmProvisioningResponse& response,
|
||||
std::string* cert,
|
||||
std::string* wrapped_key);
|
||||
|
||||
virtual CdmResponseType Unprovision(CdmSecurityLevel level);
|
||||
virtual CdmResponseType Unprovision(CdmSecurityLevel level,
|
||||
const std::string& origin);
|
||||
|
||||
// Secure stop related methods
|
||||
virtual CdmResponseType GetUsageInfo(const std::string& app_id,
|
||||
|
||||
@@ -39,15 +39,16 @@ bool WvContentDecryptionModule::IsWebm(const std::string& init_data_type) {
|
||||
|
||||
CdmResponseType WvContentDecryptionModule::OpenSession(
|
||||
const CdmKeySystem& key_system, CdmClientPropertySet* property_set,
|
||||
WvCdmEventListener* event_listener, CdmSessionId* session_id) {
|
||||
const std::string& origin, WvCdmEventListener* event_listener,
|
||||
CdmSessionId* session_id) {
|
||||
if (property_set && property_set->is_session_sharing_enabled()) {
|
||||
AutoLock auto_lock(session_sharing_id_generation_lock_);
|
||||
if (property_set->session_sharing_id() == 0)
|
||||
property_set->set_session_sharing_id(GenerateSessionSharingId());
|
||||
}
|
||||
|
||||
return cdm_engine_->OpenSession(key_system, property_set, event_listener,
|
||||
session_id);
|
||||
return cdm_engine_->OpenSession(key_system, property_set, origin,
|
||||
event_listener, session_id);
|
||||
}
|
||||
|
||||
CdmResponseType WvContentDecryptionModule::CloseSession(
|
||||
@@ -61,11 +62,13 @@ CdmResponseType WvContentDecryptionModule::GenerateKeyRequest(
|
||||
const CdmSessionId& session_id, const CdmKeySetId& key_set_id,
|
||||
const std::string& init_data_type, const CdmInitData& init_data,
|
||||
const CdmLicenseType license_type, CdmAppParameterMap& app_parameters,
|
||||
CdmClientPropertySet* property_set, CdmKeyMessage* key_request,
|
||||
CdmKeyRequestType* key_request_type, std::string* server_url) {
|
||||
CdmClientPropertySet* property_set, const std::string& origin,
|
||||
CdmKeyMessage* key_request, CdmKeyRequestType* key_request_type,
|
||||
std::string* server_url) {
|
||||
CdmResponseType sts;
|
||||
if (license_type == kLicenseTypeRelease) {
|
||||
sts = cdm_engine_->OpenKeySetSession(key_set_id, property_set, NULL);
|
||||
sts = cdm_engine_->OpenKeySetSession(key_set_id, property_set, origin,
|
||||
NULL);
|
||||
if (sts != NO_ERROR) return sts;
|
||||
}
|
||||
InitializationData initialization_data(init_data_type, init_data);
|
||||
@@ -132,22 +135,26 @@ CdmResponseType WvContentDecryptionModule::QueryKeyControlInfo(
|
||||
CdmResponseType WvContentDecryptionModule::GetProvisioningRequest(
|
||||
CdmCertificateType cert_type,
|
||||
const std::string& cert_authority,
|
||||
const std::string& origin,
|
||||
CdmProvisioningRequest* request,
|
||||
std::string* default_url) {
|
||||
return cdm_engine_->GetProvisioningRequest(cert_type, cert_authority,
|
||||
return cdm_engine_->GetProvisioningRequest(cert_type, cert_authority, origin,
|
||||
request, default_url);
|
||||
}
|
||||
|
||||
CdmResponseType WvContentDecryptionModule::HandleProvisioningResponse(
|
||||
const std::string& origin,
|
||||
CdmProvisioningResponse& response,
|
||||
std::string* cert,
|
||||
std::string* wrapped_key) {
|
||||
return cdm_engine_->HandleProvisioningResponse(response, cert, wrapped_key);
|
||||
return cdm_engine_->HandleProvisioningResponse(origin, response, cert,
|
||||
wrapped_key);
|
||||
}
|
||||
|
||||
CdmResponseType WvContentDecryptionModule::Unprovision(
|
||||
CdmSecurityLevel level) {
|
||||
return cdm_engine_->Unprovision(level);
|
||||
CdmSecurityLevel level,
|
||||
const std::string& origin) {
|
||||
return cdm_engine_->Unprovision(level, origin);
|
||||
}
|
||||
|
||||
CdmResponseType WvContentDecryptionModule::GetUsageInfo(
|
||||
|
||||
@@ -268,8 +268,8 @@ class WvCdmExtendedDurationTest : public WvCdmTestBase {
|
||||
CdmKeyRequestType key_request_type;
|
||||
EXPECT_EQ(KEY_MESSAGE, decryptor_.GenerateKeyRequest(
|
||||
session_id_, key_set_id_, "video/mp4", init_data,
|
||||
license_type, app_parameters, NULL, &key_msg_,
|
||||
&key_request_type, &server_url));
|
||||
license_type, app_parameters, NULL, EMPTY_ORIGIN,
|
||||
&key_msg_, &key_request_type, &server_url));
|
||||
EXPECT_EQ(kKeyRequestTypeInitial, key_request_type);
|
||||
EXPECT_EQ(0u, server_url.size());
|
||||
}
|
||||
@@ -283,8 +283,8 @@ class WvCdmExtendedDurationTest : public WvCdmTestBase {
|
||||
CdmKeyRequestType key_request_type;
|
||||
EXPECT_EQ(KEY_MESSAGE, decryptor_.GenerateKeyRequest(
|
||||
session_id_, key_set_id_, "video/mp4", init_data,
|
||||
license_type, app_parameters, NULL, &key_msg_,
|
||||
&key_request_type, server_url));
|
||||
license_type, app_parameters, NULL, EMPTY_ORIGIN,
|
||||
&key_msg_, &key_request_type, server_url));
|
||||
EXPECT_EQ(kKeyRequestTypeRenewal, key_request_type);
|
||||
// TODO(edwinwong, rfrias): Add tests cases for when license server url
|
||||
// is empty on renewal. Need appropriate key id at the server.
|
||||
@@ -300,7 +300,8 @@ class WvCdmExtendedDurationTest : public WvCdmTestBase {
|
||||
EXPECT_EQ(KEY_MESSAGE, decryptor_.GenerateKeyRequest(
|
||||
session_id, key_set_id, "video/mp4", init_data,
|
||||
kLicenseTypeRelease, app_parameters, NULL,
|
||||
&key_msg_, &key_request_type, &server_url));
|
||||
EMPTY_ORIGIN, &key_msg_, &key_request_type,
|
||||
&server_url));
|
||||
EXPECT_EQ(kKeyRequestTypeRelease, key_request_type);
|
||||
}
|
||||
|
||||
@@ -398,13 +399,14 @@ class WvCdmExtendedDurationTest : public WvCdmTestBase {
|
||||
}
|
||||
|
||||
void Unprovision() {
|
||||
EXPECT_EQ(NO_ERROR, decryptor_.Unprovision(kSecurityLevelL1));
|
||||
EXPECT_EQ(NO_ERROR, decryptor_.Unprovision(kSecurityLevelL3));
|
||||
EXPECT_EQ(NO_ERROR, decryptor_.Unprovision(kSecurityLevelL1, EMPTY_ORIGIN));
|
||||
EXPECT_EQ(NO_ERROR, decryptor_.Unprovision(kSecurityLevelL3, EMPTY_ORIGIN));
|
||||
}
|
||||
|
||||
void Provision() {
|
||||
CdmResponseType status =
|
||||
decryptor_.OpenSession(g_key_system, NULL, NULL, &session_id_);
|
||||
decryptor_.OpenSession(g_key_system, NULL, EMPTY_ORIGIN, NULL,
|
||||
&session_id_);
|
||||
switch (status) {
|
||||
case NO_ERROR:
|
||||
decryptor_.CloseSession(session_id_);
|
||||
@@ -421,7 +423,8 @@ class WvCdmExtendedDurationTest : public WvCdmTestBase {
|
||||
std::string cert_authority, cert, wrapped_key;
|
||||
|
||||
status = decryptor_.GetProvisioningRequest(
|
||||
cert_type, cert_authority, &key_msg_, &provisioning_server_url);
|
||||
cert_type, cert_authority, EMPTY_ORIGIN, &key_msg_,
|
||||
&provisioning_server_url);
|
||||
EXPECT_EQ(NO_ERROR, status);
|
||||
if (NO_ERROR != status) return;
|
||||
EXPECT_EQ(provisioning_server_url, g_config->provisioning_server_url());
|
||||
@@ -429,8 +432,9 @@ class WvCdmExtendedDurationTest : public WvCdmTestBase {
|
||||
std::string response =
|
||||
GetCertRequestResponse(g_config->provisioning_server_url());
|
||||
EXPECT_NE(0, static_cast<int>(response.size()));
|
||||
EXPECT_EQ(NO_ERROR, decryptor_.HandleProvisioningResponse(response, &cert,
|
||||
&wrapped_key));
|
||||
EXPECT_EQ(NO_ERROR,
|
||||
decryptor_.HandleProvisioningResponse(EMPTY_ORIGIN, response, &cert,
|
||||
&wrapped_key));
|
||||
EXPECT_EQ(0, static_cast<int>(cert.size()));
|
||||
EXPECT_EQ(0, static_cast<int>(wrapped_key.size()));
|
||||
decryptor_.CloseSession(session_id_);
|
||||
@@ -614,7 +618,8 @@ class WvCdmExtendedDurationTest : public WvCdmTestBase {
|
||||
}
|
||||
|
||||
std::string GetSecurityLevel(TestWvCdmClientPropertySet* property_set) {
|
||||
decryptor_.OpenSession(g_key_system, property_set, NULL, &session_id_);
|
||||
decryptor_.OpenSession(g_key_system, property_set, EMPTY_ORIGIN, NULL,
|
||||
&session_id_);
|
||||
CdmQueryMap query_info;
|
||||
EXPECT_EQ(NO_ERROR,
|
||||
decryptor_.QuerySessionStatus(session_id_, &query_info));
|
||||
@@ -647,7 +652,7 @@ class WvCdmExtendedDurationTest : public WvCdmTestBase {
|
||||
|
||||
TEST_F(WvCdmExtendedDurationTest, VerifyLicenseRequestTest) {
|
||||
Provision();
|
||||
decryptor_.OpenSession(g_key_system, NULL, NULL, &session_id_);
|
||||
decryptor_.OpenSession(g_key_system, NULL, EMPTY_ORIGIN, NULL, &session_id_);
|
||||
GenerateKeyRequest(g_key_id, kLicenseTypeStreaming);
|
||||
|
||||
EXPECT_TRUE(!key_msg_.empty());
|
||||
@@ -715,7 +720,7 @@ TEST_F(WvCdmExtendedDurationTest, VerifyLicenseRequestTest) {
|
||||
|
||||
TEST_F(WvCdmExtendedDurationTest, VerifyLicenseRenewalTest) {
|
||||
Provision();
|
||||
decryptor_.OpenSession(g_key_system, NULL, NULL, &session_id_);
|
||||
decryptor_.OpenSession(g_key_system, NULL, EMPTY_ORIGIN, NULL, &session_id_);
|
||||
GenerateKeyRequest(g_key_id, kLicenseTypeStreaming);
|
||||
VerifyKeyRequestResponse(g_license_server, g_client_auth, false);
|
||||
|
||||
@@ -803,7 +808,8 @@ TEST_F(WvCdmExtendedDurationTest, UsageOverflowTest) {
|
||||
EXPECT_TRUE(handle.DeleteAllUsageInfoForApp("", &provider_session_tokens));
|
||||
|
||||
for (size_t i = 0; i < kMaxUsageTableSize + 100; ++i) {
|
||||
decryptor_.OpenSession(g_key_system, property_set, NULL, &session_id_);
|
||||
decryptor_.OpenSession(g_key_system, property_set, EMPTY_ORIGIN, NULL,
|
||||
&session_id_);
|
||||
std::string key_id = a2bs_hex(
|
||||
"000000427073736800000000" // blob size and pssh
|
||||
"EDEF8BA979D64ACEA3C827DCD51D21ED00000022" // Widevine system id
|
||||
@@ -843,7 +849,7 @@ TEST_P(WvCdmStreamingNoPstTest, UsageTest) {
|
||||
Unprovision();
|
||||
Provision();
|
||||
|
||||
decryptor_.OpenSession(g_key_system, NULL, NULL, &session_id_);
|
||||
decryptor_.OpenSession(g_key_system, NULL, EMPTY_ORIGIN, NULL, &session_id_);
|
||||
GenerateKeyRequest(g_key_id, kLicenseTypeStreaming);
|
||||
VerifyKeyRequestResponse(g_license_server, g_client_auth, false);
|
||||
|
||||
@@ -917,7 +923,7 @@ TEST_P(WvCdmStreamingPstTest, UsageTest) {
|
||||
Unprovision();
|
||||
Provision();
|
||||
|
||||
decryptor_.OpenSession(g_key_system, NULL, NULL, &session_id_);
|
||||
decryptor_.OpenSession(g_key_system, NULL, EMPTY_ORIGIN, NULL, &session_id_);
|
||||
GenerateKeyRequest(kStreamingClip1PstInitData, kLicenseTypeStreaming);
|
||||
VerifyKeyRequestResponse(g_license_server, g_client_auth, false);
|
||||
|
||||
@@ -982,7 +988,7 @@ TEST_P(WvCdmStreamingUsageReportTest, UsageTest) {
|
||||
Unprovision();
|
||||
Provision();
|
||||
|
||||
decryptor_.OpenSession(g_key_system, NULL, NULL, &session_id_);
|
||||
decryptor_.OpenSession(g_key_system, NULL, EMPTY_ORIGIN, NULL, &session_id_);
|
||||
GenerateKeyRequest(kStreamingClip1PstInitData, kLicenseTypeStreaming);
|
||||
VerifyKeyRequestResponse(g_license_server, g_client_auth, false);
|
||||
|
||||
@@ -1078,7 +1084,7 @@ TEST_P(WvCdmOfflineUsageReportTest, UsageTest) {
|
||||
Unprovision();
|
||||
Provision();
|
||||
|
||||
decryptor_.OpenSession(g_key_system, NULL, NULL, &session_id_);
|
||||
decryptor_.OpenSession(g_key_system, NULL, EMPTY_ORIGIN, NULL, &session_id_);
|
||||
GenerateKeyRequest(kOfflineClip2PstInitData, kLicenseTypeOffline);
|
||||
VerifyKeyRequestResponse(g_license_server, g_client_auth, false);
|
||||
|
||||
@@ -1101,7 +1107,7 @@ TEST_P(WvCdmOfflineUsageReportTest, UsageTest) {
|
||||
|
||||
for (size_t i = 0; i < GetParam(); ++i) {
|
||||
session_id_.clear();
|
||||
decryptor_.OpenSession(g_key_system, NULL, NULL, &session_id_);
|
||||
decryptor_.OpenSession(g_key_system, NULL, EMPTY_ORIGIN, NULL, &session_id_);
|
||||
EXPECT_EQ(KEY_ADDED, decryptor_.RestoreKey(session_id_, key_set_id));
|
||||
|
||||
// Query and validate usage information
|
||||
@@ -1144,7 +1150,7 @@ TEST_P(WvCdmOfflineUsageReportTest, UsageTest) {
|
||||
}
|
||||
|
||||
session_id_.clear();
|
||||
decryptor_.OpenSession(g_key_system, NULL, NULL, &session_id_);
|
||||
decryptor_.OpenSession(g_key_system, NULL, EMPTY_ORIGIN, NULL, &session_id_);
|
||||
EXPECT_EQ(KEY_ADDED, decryptor_.RestoreKey(session_id_, key_set_id));
|
||||
|
||||
// Query and validate usage information
|
||||
|
||||
@@ -492,7 +492,8 @@ class WvCdmRequestLicenseTest : public WvCdmTestBase {
|
||||
EXPECT_EQ(wvcdm::KEY_MESSAGE,
|
||||
decryptor_.GenerateKeyRequest(
|
||||
session_id_, key_set_id, "video/mp4", init_data, license_type,
|
||||
app_parameters, property_set, &key_msg_, NULL, &server_url));
|
||||
app_parameters, property_set, EMPTY_ORIGIN, &key_msg_, NULL,
|
||||
&server_url));
|
||||
EXPECT_EQ(0u, server_url.size());
|
||||
}
|
||||
|
||||
@@ -512,8 +513,8 @@ class WvCdmRequestLicenseTest : public WvCdmTestBase {
|
||||
EXPECT_EQ(wvcdm::KEY_MESSAGE,
|
||||
decryptor_.GenerateKeyRequest(
|
||||
session_id_, key_set_id_, "video/mp4", init_data,
|
||||
license_type, app_parameters, property_set, &key_msg_,
|
||||
&key_request_type, server_url));
|
||||
license_type, app_parameters, property_set, EMPTY_ORIGIN,
|
||||
&key_msg_, &key_request_type, server_url));
|
||||
EXPECT_EQ(kKeyRequestTypeRenewal, key_request_type);
|
||||
// TODO(edwinwong, rfrias): Add tests cases for when license server url
|
||||
// is empty on renewal. Need appropriate key id at the server.
|
||||
@@ -534,8 +535,8 @@ class WvCdmRequestLicenseTest : public WvCdmTestBase {
|
||||
EXPECT_EQ(wvcdm::KEY_MESSAGE,
|
||||
decryptor_.GenerateKeyRequest(
|
||||
session_id, key_set_id, "video/mp4", init_data,
|
||||
kLicenseTypeRelease, app_parameters, property_set, &key_msg_,
|
||||
&key_request_type, &server_url));
|
||||
kLicenseTypeRelease, app_parameters, property_set,
|
||||
EMPTY_ORIGIN, &key_msg_, &key_request_type, &server_url));
|
||||
EXPECT_EQ(kKeyRequestTypeRelease, key_request_type);
|
||||
}
|
||||
|
||||
@@ -634,8 +635,8 @@ class WvCdmRequestLicenseTest : public WvCdmTestBase {
|
||||
}
|
||||
|
||||
void Unprovision() {
|
||||
EXPECT_EQ(NO_ERROR, decryptor_.Unprovision(kSecurityLevelL1));
|
||||
EXPECT_EQ(NO_ERROR, decryptor_.Unprovision(kSecurityLevelL3));
|
||||
EXPECT_EQ(NO_ERROR, decryptor_.Unprovision(kSecurityLevelL1, EMPTY_ORIGIN));
|
||||
EXPECT_EQ(NO_ERROR, decryptor_.Unprovision(kSecurityLevelL3, EMPTY_ORIGIN));
|
||||
}
|
||||
|
||||
void Provision(SecurityLevel level) {
|
||||
@@ -648,7 +649,8 @@ class WvCdmRequestLicenseTest : public WvCdmTestBase {
|
||||
}
|
||||
|
||||
CdmResponseType status =
|
||||
decryptor_.OpenSession(g_key_system, property_set, NULL, &session_id_);
|
||||
decryptor_.OpenSession(g_key_system, property_set, EMPTY_ORIGIN, NULL,
|
||||
&session_id_);
|
||||
switch (status) {
|
||||
case NO_ERROR:
|
||||
decryptor_.CloseSession(session_id_);
|
||||
@@ -665,7 +667,8 @@ class WvCdmRequestLicenseTest : public WvCdmTestBase {
|
||||
std::string cert_authority, cert, wrapped_key;
|
||||
|
||||
status = decryptor_.GetProvisioningRequest(
|
||||
cert_type, cert_authority, &key_msg_, &provisioning_server_url);
|
||||
cert_type, cert_authority, EMPTY_ORIGIN, &key_msg_,
|
||||
&provisioning_server_url);
|
||||
EXPECT_EQ(wvcdm::NO_ERROR, status);
|
||||
if (NO_ERROR != status) return;
|
||||
EXPECT_EQ(provisioning_server_url, g_config->provisioning_server_url());
|
||||
@@ -673,8 +676,9 @@ class WvCdmRequestLicenseTest : public WvCdmTestBase {
|
||||
std::string response =
|
||||
GetCertRequestResponse(g_config->provisioning_server_url());
|
||||
EXPECT_NE(0, static_cast<int>(response.size()));
|
||||
EXPECT_EQ(wvcdm::NO_ERROR, decryptor_.HandleProvisioningResponse(
|
||||
response, &cert, &wrapped_key));
|
||||
EXPECT_EQ(wvcdm::NO_ERROR,
|
||||
decryptor_.HandleProvisioningResponse(EMPTY_ORIGIN, response, &cert,
|
||||
&wrapped_key));
|
||||
EXPECT_EQ(0, static_cast<int>(cert.size()));
|
||||
EXPECT_EQ(0, static_cast<int>(wrapped_key.size()));
|
||||
decryptor_.CloseSession(session_id_);
|
||||
@@ -682,7 +686,8 @@ class WvCdmRequestLicenseTest : public WvCdmTestBase {
|
||||
}
|
||||
|
||||
std::string GetSecurityLevel(TestWvCdmClientPropertySet* property_set) {
|
||||
EXPECT_EQ(NO_ERROR, decryptor_.OpenSession(g_key_system, property_set, NULL,
|
||||
EXPECT_EQ(NO_ERROR, decryptor_.OpenSession(g_key_system, property_set,
|
||||
EMPTY_ORIGIN, NULL,
|
||||
&session_id_));
|
||||
CdmQueryMap query_info;
|
||||
EXPECT_EQ(wvcdm::NO_ERROR,
|
||||
@@ -719,21 +724,22 @@ class WvCdmRequestLicenseTest : public WvCdmTestBase {
|
||||
};
|
||||
|
||||
TEST_F(WvCdmRequestLicenseTest, ProvisioningTest) {
|
||||
decryptor_.OpenSession(g_key_system, NULL, NULL, &session_id_);
|
||||
decryptor_.OpenSession(g_key_system, NULL, EMPTY_ORIGIN, NULL, &session_id_);
|
||||
std::string provisioning_server_url;
|
||||
CdmCertificateType cert_type = kCertificateWidevine;
|
||||
std::string cert_authority, cert, wrapped_key;
|
||||
|
||||
EXPECT_EQ(wvcdm::NO_ERROR, decryptor_.GetProvisioningRequest(
|
||||
cert_type, cert_authority, &key_msg_,
|
||||
&provisioning_server_url));
|
||||
cert_type, cert_authority, EMPTY_ORIGIN,
|
||||
&key_msg_, &provisioning_server_url));
|
||||
EXPECT_EQ(provisioning_server_url, g_config->provisioning_server_url());
|
||||
|
||||
std::string response =
|
||||
GetCertRequestResponse(g_config->provisioning_server_url());
|
||||
EXPECT_NE(0, static_cast<int>(response.size()));
|
||||
EXPECT_EQ(wvcdm::NO_ERROR, decryptor_.HandleProvisioningResponse(
|
||||
response, &cert, &wrapped_key));
|
||||
EXPECT_EQ(wvcdm::NO_ERROR,
|
||||
decryptor_.HandleProvisioningResponse(EMPTY_ORIGIN, response, &cert,
|
||||
&wrapped_key));
|
||||
EXPECT_EQ(0, static_cast<int>(cert.size()));
|
||||
EXPECT_EQ(0, static_cast<int>(wrapped_key.size()));
|
||||
decryptor_.CloseSession(session_id_);
|
||||
@@ -747,48 +753,52 @@ TEST_F(WvCdmRequestLicenseTest, UnprovisionTest) {
|
||||
handle.SetTestFile(&file);
|
||||
std::string certificate;
|
||||
std::string wrapped_private_key;
|
||||
EXPECT_TRUE(handle.RetrieveCertificate(&certificate, &wrapped_private_key));
|
||||
EXPECT_TRUE(handle.RetrieveCertificate(EMPTY_ORIGIN, &certificate,
|
||||
&wrapped_private_key));
|
||||
|
||||
EXPECT_EQ(NO_ERROR, decryptor_.Unprovision(security_level));
|
||||
EXPECT_FALSE(handle.RetrieveCertificate(&certificate, &wrapped_private_key));
|
||||
EXPECT_EQ(NO_ERROR, decryptor_.Unprovision(security_level, EMPTY_ORIGIN));
|
||||
EXPECT_FALSE(handle.RetrieveCertificate(EMPTY_ORIGIN, &certificate,
|
||||
&wrapped_private_key));
|
||||
}
|
||||
|
||||
TEST_F(WvCdmRequestLicenseTest, ProvisioningRetryTest) {
|
||||
decryptor_.OpenSession(g_key_system, NULL, NULL, &session_id_);
|
||||
decryptor_.OpenSession(g_key_system, NULL, EMPTY_ORIGIN, NULL, &session_id_);
|
||||
std::string provisioning_server_url;
|
||||
CdmCertificateType cert_type = kCertificateWidevine;
|
||||
std::string cert_authority, cert, wrapped_key;
|
||||
|
||||
EXPECT_EQ(wvcdm::NO_ERROR, decryptor_.GetProvisioningRequest(
|
||||
cert_type, cert_authority, &key_msg_,
|
||||
&provisioning_server_url));
|
||||
cert_type, cert_authority, EMPTY_ORIGIN,
|
||||
&key_msg_, &provisioning_server_url));
|
||||
EXPECT_EQ(provisioning_server_url, g_config->provisioning_server_url());
|
||||
|
||||
EXPECT_EQ(wvcdm::NO_ERROR, decryptor_.GetProvisioningRequest(
|
||||
cert_type, cert_authority, &key_msg_,
|
||||
&provisioning_server_url));
|
||||
cert_type, cert_authority, EMPTY_ORIGIN,
|
||||
&key_msg_, &provisioning_server_url));
|
||||
EXPECT_EQ(provisioning_server_url, g_config->provisioning_server_url());
|
||||
|
||||
std::string response =
|
||||
GetCertRequestResponse(g_config->provisioning_server_url());
|
||||
EXPECT_NE(0, static_cast<int>(response.size()));
|
||||
EXPECT_EQ(wvcdm::NO_ERROR, decryptor_.HandleProvisioningResponse(
|
||||
response, &cert, &wrapped_key));
|
||||
EXPECT_EQ(wvcdm::NO_ERROR,
|
||||
decryptor_.HandleProvisioningResponse(EMPTY_ORIGIN, response, &cert,
|
||||
&wrapped_key));
|
||||
EXPECT_EQ(0, static_cast<int>(cert.size()));
|
||||
EXPECT_EQ(0, static_cast<int>(wrapped_key.size()));
|
||||
|
||||
response =
|
||||
GetCertRequestResponse(g_config->provisioning_server_url());
|
||||
EXPECT_NE(0, static_cast<int>(response.size()));
|
||||
EXPECT_EQ(wvcdm::UNKNOWN_ERROR, decryptor_.HandleProvisioningResponse(
|
||||
response, &cert, &wrapped_key));
|
||||
EXPECT_EQ(wvcdm::UNKNOWN_ERROR,
|
||||
decryptor_.HandleProvisioningResponse(EMPTY_ORIGIN, response, &cert,
|
||||
&wrapped_key));
|
||||
EXPECT_EQ(0, static_cast<int>(cert.size()));
|
||||
EXPECT_EQ(0, static_cast<int>(wrapped_key.size()));
|
||||
decryptor_.CloseSession(session_id_);
|
||||
}
|
||||
|
||||
TEST_F(WvCdmRequestLicenseTest, DISABLED_X509ProvisioningTest) {
|
||||
decryptor_.OpenSession(g_key_system, NULL, NULL, &session_id_);
|
||||
decryptor_.OpenSession(g_key_system, NULL, EMPTY_ORIGIN, NULL, &session_id_);
|
||||
std::string provisioning_server_url;
|
||||
CdmCertificateType cert_type = kCertificateX509;
|
||||
// TODO(rfrias): insert appropriate CA here
|
||||
@@ -796,15 +806,16 @@ TEST_F(WvCdmRequestLicenseTest, DISABLED_X509ProvisioningTest) {
|
||||
std::string cert, wrapped_key;
|
||||
|
||||
EXPECT_EQ(wvcdm::NO_ERROR, decryptor_.GetProvisioningRequest(
|
||||
cert_type, cert_authority, &key_msg_,
|
||||
&provisioning_server_url));
|
||||
cert_type, cert_authority, EMPTY_ORIGIN,
|
||||
&key_msg_, &provisioning_server_url));
|
||||
EXPECT_EQ(provisioning_server_url, g_config->provisioning_server_url());
|
||||
|
||||
std::string response =
|
||||
GetCertRequestResponse(g_config->provisioning_server_url());
|
||||
EXPECT_NE(0, static_cast<int>(response.size()));
|
||||
EXPECT_EQ(wvcdm::NO_ERROR, decryptor_.HandleProvisioningResponse(
|
||||
response, &cert, &wrapped_key));
|
||||
EXPECT_EQ(wvcdm::NO_ERROR,
|
||||
decryptor_.HandleProvisioningResponse(EMPTY_ORIGIN, response, &cert,
|
||||
&wrapped_key));
|
||||
EXPECT_NE(0, static_cast<int>(cert.size()));
|
||||
EXPECT_NE(0, static_cast<int>(wrapped_key.size()));
|
||||
decryptor_.CloseSession(session_id_);
|
||||
@@ -820,34 +831,39 @@ TEST_F(WvCdmRequestLicenseTest, PropertySetTest) {
|
||||
|
||||
property_set_L1.set_security_level(QUERY_VALUE_SECURITY_LEVEL_L1);
|
||||
property_set_L1.set_use_privacy_mode(true);
|
||||
decryptor_.OpenSession(g_key_system, &property_set_L1, NULL, &session_id_L1);
|
||||
decryptor_.OpenSession(g_key_system, &property_set_L1, EMPTY_ORIGIN, NULL,
|
||||
&session_id_L1);
|
||||
property_set_L3.set_security_level(QUERY_VALUE_SECURITY_LEVEL_L3);
|
||||
property_set_L3.set_use_privacy_mode(false);
|
||||
|
||||
CdmResponseType sts = decryptor_.OpenSession(g_key_system, &property_set_L3,
|
||||
NULL, &session_id_L3);
|
||||
EMPTY_ORIGIN, NULL,
|
||||
&session_id_L3);
|
||||
|
||||
if (NEED_PROVISIONING == sts) {
|
||||
std::string provisioning_server_url;
|
||||
CdmCertificateType cert_type = kCertificateWidevine;
|
||||
std::string cert_authority, cert, wrapped_key;
|
||||
EXPECT_EQ(NO_ERROR, decryptor_.GetProvisioningRequest(
|
||||
cert_type, cert_authority, &key_msg_,
|
||||
&provisioning_server_url));
|
||||
cert_type, cert_authority, EMPTY_ORIGIN,
|
||||
&key_msg_, &provisioning_server_url));
|
||||
EXPECT_EQ(provisioning_server_url, g_config->provisioning_server_url());
|
||||
std::string response =
|
||||
GetCertRequestResponse(g_config->provisioning_server_url());
|
||||
EXPECT_NE(0, static_cast<int>(response.size()));
|
||||
EXPECT_EQ(NO_ERROR, decryptor_.HandleProvisioningResponse(response, &cert,
|
||||
&wrapped_key));
|
||||
EXPECT_EQ(NO_ERROR,
|
||||
decryptor_.HandleProvisioningResponse(EMPTY_ORIGIN, response, &cert,
|
||||
&wrapped_key));
|
||||
EXPECT_EQ(NO_ERROR, decryptor_.OpenSession(g_key_system, &property_set_L3,
|
||||
NULL, &session_id_L3));
|
||||
EMPTY_ORIGIN, NULL,
|
||||
&session_id_L3));
|
||||
} else {
|
||||
EXPECT_EQ(NO_ERROR, sts);
|
||||
}
|
||||
|
||||
property_set_Ln.set_security_level("");
|
||||
decryptor_.OpenSession(g_key_system, &property_set_Ln, NULL, &session_id_Ln);
|
||||
decryptor_.OpenSession(g_key_system, &property_set_Ln, EMPTY_ORIGIN, NULL,
|
||||
&session_id_Ln);
|
||||
|
||||
std::string security_level;
|
||||
EXPECT_TRUE(Properties::GetSecurityLevel(session_id_L1, &security_level));
|
||||
@@ -888,22 +904,24 @@ TEST_F(WvCdmRequestLicenseTest, ForceL3Test) {
|
||||
|
||||
EXPECT_EQ(
|
||||
NEED_PROVISIONING,
|
||||
decryptor_.OpenSession(g_key_system, &property_set, NULL, &session_id_));
|
||||
decryptor_.OpenSession(g_key_system, &property_set, EMPTY_ORIGIN, NULL,
|
||||
&session_id_));
|
||||
std::string provisioning_server_url;
|
||||
CdmCertificateType cert_type = kCertificateWidevine;
|
||||
std::string cert_authority, cert, wrapped_key;
|
||||
EXPECT_EQ(NO_ERROR, decryptor_.GetProvisioningRequest(
|
||||
cert_type, cert_authority, &key_msg_,
|
||||
cert_type, cert_authority, EMPTY_ORIGIN, &key_msg_,
|
||||
&provisioning_server_url));
|
||||
EXPECT_EQ(provisioning_server_url, g_config->provisioning_server_url());
|
||||
std::string response =
|
||||
GetCertRequestResponse(g_config->provisioning_server_url());
|
||||
EXPECT_NE(0, static_cast<int>(response.size()));
|
||||
EXPECT_EQ(NO_ERROR, decryptor_.HandleProvisioningResponse(response, &cert,
|
||||
&wrapped_key));
|
||||
EXPECT_EQ(NO_ERROR,
|
||||
decryptor_.HandleProvisioningResponse(EMPTY_ORIGIN, response, &cert,
|
||||
&wrapped_key));
|
||||
|
||||
EXPECT_EQ(NO_ERROR, decryptor_.OpenSession(g_key_system, &property_set, NULL,
|
||||
&session_id_));
|
||||
EXPECT_EQ(NO_ERROR, decryptor_.OpenSession(g_key_system, &property_set,
|
||||
EMPTY_ORIGIN, NULL, &session_id_));
|
||||
GenerateKeyRequest(g_key_id, kLicenseTypeStreaming);
|
||||
VerifyKeyRequestResponse(g_license_server, g_client_auth, false);
|
||||
decryptor_.CloseSession(session_id_);
|
||||
@@ -913,7 +931,8 @@ TEST_F(WvCdmRequestLicenseTest, PrivacyModeTest) {
|
||||
TestWvCdmClientPropertySet property_set;
|
||||
|
||||
property_set.set_use_privacy_mode(true);
|
||||
decryptor_.OpenSession(g_key_system, &property_set, NULL, &session_id_);
|
||||
decryptor_.OpenSession(g_key_system, &property_set, EMPTY_ORIGIN, NULL,
|
||||
&session_id_);
|
||||
|
||||
GenerateKeyRequest(g_key_id, kLicenseTypeStreaming);
|
||||
std::string resp = GetKeyRequestResponse(g_license_server, g_client_auth);
|
||||
@@ -929,21 +948,22 @@ TEST_F(WvCdmRequestLicenseTest, PrivacyModeWithServiceCertificateTest) {
|
||||
|
||||
property_set.set_use_privacy_mode(true);
|
||||
property_set.set_service_certificate(a2bs_hex(kServiceCertificate));
|
||||
decryptor_.OpenSession(g_key_system, &property_set, NULL, &session_id_);
|
||||
decryptor_.OpenSession(g_key_system, &property_set, EMPTY_ORIGIN, NULL,
|
||||
&session_id_);
|
||||
GenerateKeyRequest(g_key_id, kLicenseTypeStreaming);
|
||||
VerifyKeyRequestResponse(g_license_server, g_client_auth, false);
|
||||
decryptor_.CloseSession(session_id_);
|
||||
}
|
||||
|
||||
TEST_F(WvCdmRequestLicenseTest, BaseMessageTest) {
|
||||
decryptor_.OpenSession(g_key_system, NULL, NULL, &session_id_);
|
||||
decryptor_.OpenSession(g_key_system, NULL, EMPTY_ORIGIN, NULL, &session_id_);
|
||||
GenerateKeyRequest(g_key_id, kLicenseTypeStreaming);
|
||||
GetKeyRequestResponse(g_license_server, g_client_auth);
|
||||
decryptor_.CloseSession(session_id_);
|
||||
}
|
||||
|
||||
TEST_F(WvCdmRequestLicenseTest, WrongMessageTest) {
|
||||
decryptor_.OpenSession(g_key_system, NULL, NULL, &session_id_);
|
||||
decryptor_.OpenSession(g_key_system, NULL, EMPTY_ORIGIN, NULL, &session_id_);
|
||||
|
||||
std::string wrong_message = wvcdm::a2bs_hex(g_wrong_key_id);
|
||||
GenerateKeyRequest(wrong_message, kLicenseTypeStreaming);
|
||||
@@ -971,7 +991,7 @@ TEST_F(WvCdmRequestLicenseTest, WrongMessageTest) {
|
||||
}
|
||||
|
||||
TEST_F(WvCdmRequestLicenseTest, AddStreamingKeyTest) {
|
||||
decryptor_.OpenSession(g_key_system, NULL, NULL, &session_id_);
|
||||
decryptor_.OpenSession(g_key_system, NULL, EMPTY_ORIGIN, NULL, &session_id_);
|
||||
GenerateKeyRequest(g_key_id, kLicenseTypeStreaming);
|
||||
VerifyKeyRequestResponse(g_license_server, g_client_auth, false);
|
||||
decryptor_.CloseSession(session_id_);
|
||||
@@ -986,7 +1006,7 @@ TEST_F(WvCdmRequestLicenseTest, AddKeyOfflineTest) {
|
||||
std::string client_auth;
|
||||
GetOfflineConfiguration(&key_id, &client_auth);
|
||||
|
||||
decryptor_.OpenSession(g_key_system, NULL, NULL, &session_id_);
|
||||
decryptor_.OpenSession(g_key_system, NULL, EMPTY_ORIGIN, NULL, &session_id_);
|
||||
GenerateKeyRequest(key_id, kLicenseTypeOffline);
|
||||
VerifyKeyRequestResponse(g_license_server, client_auth, false);
|
||||
decryptor_.CloseSession(session_id_);
|
||||
@@ -1001,7 +1021,7 @@ TEST_F(WvCdmRequestLicenseTest, RestoreOfflineKeyTest) {
|
||||
std::string client_auth;
|
||||
GetOfflineConfiguration(&key_id, &client_auth);
|
||||
|
||||
decryptor_.OpenSession(g_key_system, NULL, NULL, &session_id_);
|
||||
decryptor_.OpenSession(g_key_system, NULL, EMPTY_ORIGIN, NULL, &session_id_);
|
||||
GenerateKeyRequest(key_id, kLicenseTypeOffline);
|
||||
VerifyKeyRequestResponse(g_license_server, client_auth, false);
|
||||
|
||||
@@ -1010,7 +1030,7 @@ TEST_F(WvCdmRequestLicenseTest, RestoreOfflineKeyTest) {
|
||||
decryptor_.CloseSession(session_id_);
|
||||
|
||||
session_id_.clear();
|
||||
decryptor_.OpenSession(g_key_system, NULL, NULL, &session_id_);
|
||||
decryptor_.OpenSession(g_key_system, NULL, EMPTY_ORIGIN, NULL, &session_id_);
|
||||
EXPECT_EQ(wvcdm::KEY_ADDED, decryptor_.RestoreKey(session_id_, key_set_id));
|
||||
decryptor_.CloseSession(session_id_);
|
||||
}
|
||||
@@ -1024,7 +1044,7 @@ TEST_F(WvCdmRequestLicenseTest, ReleaseOfflineKeyTest) {
|
||||
std::string client_auth;
|
||||
GetOfflineConfiguration(&key_id, &client_auth);
|
||||
|
||||
decryptor_.OpenSession(g_key_system, NULL, NULL, &session_id_);
|
||||
decryptor_.OpenSession(g_key_system, NULL, EMPTY_ORIGIN, NULL, &session_id_);
|
||||
GenerateKeyRequest(key_id, kLicenseTypeOffline);
|
||||
VerifyKeyRequestResponse(g_license_server, client_auth, false);
|
||||
|
||||
@@ -1034,7 +1054,7 @@ TEST_F(WvCdmRequestLicenseTest, ReleaseOfflineKeyTest) {
|
||||
|
||||
session_id_.clear();
|
||||
key_set_id_.clear();
|
||||
decryptor_.OpenSession(g_key_system, NULL, NULL, &session_id_);
|
||||
decryptor_.OpenSession(g_key_system, NULL, EMPTY_ORIGIN, NULL, &session_id_);
|
||||
EXPECT_EQ(wvcdm::KEY_ADDED, decryptor_.RestoreKey(session_id_, key_set_id));
|
||||
decryptor_.CloseSession(session_id_);
|
||||
|
||||
@@ -1054,7 +1074,7 @@ TEST_F(WvCdmRequestLicenseTest, ReleaseRetryOfflineKeyTest) {
|
||||
std::string client_auth;
|
||||
GetOfflineConfiguration(&key_id, &client_auth);
|
||||
|
||||
decryptor_.OpenSession(g_key_system, NULL, NULL, &session_id_);
|
||||
decryptor_.OpenSession(g_key_system, NULL, EMPTY_ORIGIN, NULL, &session_id_);
|
||||
GenerateKeyRequest(key_id, kLicenseTypeOffline);
|
||||
VerifyKeyRequestResponse(g_license_server, client_auth, false);
|
||||
|
||||
@@ -1064,7 +1084,7 @@ TEST_F(WvCdmRequestLicenseTest, ReleaseRetryOfflineKeyTest) {
|
||||
|
||||
session_id_.clear();
|
||||
key_set_id_.clear();
|
||||
decryptor_.OpenSession(g_key_system, NULL, NULL, &session_id_);
|
||||
decryptor_.OpenSession(g_key_system, NULL, EMPTY_ORIGIN, NULL, &session_id_);
|
||||
EXPECT_EQ(wvcdm::KEY_ADDED, decryptor_.RestoreKey(session_id_, key_set_id));
|
||||
decryptor_.CloseSession(session_id_);
|
||||
|
||||
@@ -1073,7 +1093,7 @@ TEST_F(WvCdmRequestLicenseTest, ReleaseRetryOfflineKeyTest) {
|
||||
GenerateKeyRelease(key_set_id);
|
||||
|
||||
session_id_.clear();
|
||||
decryptor_.OpenSession(g_key_system, NULL, NULL, &session_id_);
|
||||
decryptor_.OpenSession(g_key_system, NULL, EMPTY_ORIGIN, NULL, &session_id_);
|
||||
EXPECT_EQ(wvcdm::UNKNOWN_ERROR, decryptor_.RestoreKey(session_id_, key_set_id));
|
||||
decryptor_.CloseSession(session_id_);
|
||||
|
||||
@@ -1096,28 +1116,32 @@ TEST_F(WvCdmRequestLicenseTest, ReleaseRetryL3OfflineKeyTest) {
|
||||
GetOfflineConfiguration(&key_id, &client_auth);
|
||||
|
||||
CdmResponseType sts =
|
||||
decryptor_.OpenSession(g_key_system, &property_set, NULL, &session_id_);
|
||||
decryptor_.OpenSession(g_key_system, &property_set, EMPTY_ORIGIN, NULL,
|
||||
&session_id_);
|
||||
|
||||
if (NEED_PROVISIONING == sts) {
|
||||
std::string provisioning_server_url;
|
||||
CdmCertificateType cert_type = kCertificateWidevine;
|
||||
std::string cert_authority, cert, wrapped_key;
|
||||
EXPECT_EQ(NO_ERROR, decryptor_.GetProvisioningRequest(
|
||||
cert_type, cert_authority, &key_msg_,
|
||||
cert_type, cert_authority, EMPTY_ORIGIN, &key_msg_,
|
||||
&provisioning_server_url));
|
||||
EXPECT_EQ(provisioning_server_url, g_config->provisioning_server_url());
|
||||
std::string response =
|
||||
GetCertRequestResponse(g_config->provisioning_server_url());
|
||||
EXPECT_NE(0, static_cast<int>(response.size()));
|
||||
EXPECT_EQ(NO_ERROR, decryptor_.HandleProvisioningResponse(response, &cert,
|
||||
&wrapped_key));
|
||||
EXPECT_EQ(NO_ERROR,
|
||||
decryptor_.HandleProvisioningResponse(EMPTY_ORIGIN, response, &cert,
|
||||
&wrapped_key));
|
||||
EXPECT_EQ(NO_ERROR, decryptor_.OpenSession(g_key_system, &property_set,
|
||||
NULL, &session_id_));
|
||||
EMPTY_ORIGIN, NULL,
|
||||
&session_id_));
|
||||
} else {
|
||||
EXPECT_EQ(NO_ERROR, sts);
|
||||
}
|
||||
|
||||
decryptor_.OpenSession(g_key_system, &property_set, NULL, &session_id_);
|
||||
decryptor_.OpenSession(g_key_system, &property_set, EMPTY_ORIGIN, NULL,
|
||||
&session_id_);
|
||||
GenerateKeyRequest(key_id, kLicenseTypeOffline, &property_set);
|
||||
VerifyKeyRequestResponse(g_license_server, client_auth, false);
|
||||
|
||||
@@ -1127,7 +1151,8 @@ TEST_F(WvCdmRequestLicenseTest, ReleaseRetryL3OfflineKeyTest) {
|
||||
|
||||
session_id_.clear();
|
||||
key_set_id_.clear();
|
||||
decryptor_.OpenSession(g_key_system, &property_set, NULL, &session_id_);
|
||||
decryptor_.OpenSession(g_key_system, &property_set, EMPTY_ORIGIN, NULL,
|
||||
&session_id_);
|
||||
EXPECT_EQ(wvcdm::KEY_ADDED, decryptor_.RestoreKey(session_id_, key_set_id));
|
||||
decryptor_.CloseSession(session_id_);
|
||||
|
||||
@@ -1136,7 +1161,8 @@ TEST_F(WvCdmRequestLicenseTest, ReleaseRetryL3OfflineKeyTest) {
|
||||
GenerateKeyRelease(key_set_id, &property_set);
|
||||
|
||||
session_id_.clear();
|
||||
decryptor_.OpenSession(g_key_system, &property_set, NULL, &session_id_);
|
||||
decryptor_.OpenSession(g_key_system, &property_set, EMPTY_ORIGIN, NULL,
|
||||
&session_id_);
|
||||
EXPECT_EQ(
|
||||
wvcdm::UNKNOWN_ERROR, decryptor_.RestoreKey(session_id_, key_set_id));
|
||||
decryptor_.CloseSession(session_id_);
|
||||
@@ -1157,7 +1183,7 @@ TEST_F(WvCdmRequestLicenseTest, ExpiryOnReleaseOfflineKeyTest) {
|
||||
std::string client_auth;
|
||||
GetOfflineConfiguration(&key_id, &client_auth);
|
||||
|
||||
decryptor_.OpenSession(g_key_system, NULL, NULL, &session_id_);
|
||||
decryptor_.OpenSession(g_key_system, NULL, EMPTY_ORIGIN, NULL, &session_id_);
|
||||
GenerateKeyRequest(key_id, kLicenseTypeOffline);
|
||||
VerifyKeyRequestResponse(g_license_server, client_auth, false);
|
||||
|
||||
@@ -1168,7 +1194,8 @@ TEST_F(WvCdmRequestLicenseTest, ExpiryOnReleaseOfflineKeyTest) {
|
||||
session_id_.clear();
|
||||
key_set_id_.clear();
|
||||
StrictMock<TestWvCdmEventListener> listener;
|
||||
decryptor_.OpenSession(g_key_system, NULL, &listener, &session_id_);
|
||||
decryptor_.OpenSession(g_key_system, NULL, EMPTY_ORIGIN, &listener,
|
||||
&session_id_);
|
||||
CdmSessionId restore_session_id = session_id_;
|
||||
EXPECT_CALL(listener,
|
||||
OnSessionKeysChange(restore_session_id,
|
||||
@@ -1196,7 +1223,7 @@ TEST_F(WvCdmRequestLicenseTest, ExpiryOnReleaseOfflineKeyTest) {
|
||||
}
|
||||
|
||||
TEST_F(WvCdmRequestLicenseTest, StreamingLicenseRenewal) {
|
||||
decryptor_.OpenSession(g_key_system, NULL, NULL, &session_id_);
|
||||
decryptor_.OpenSession(g_key_system, NULL, EMPTY_ORIGIN, NULL, &session_id_);
|
||||
GenerateKeyRequest(g_key_id, kLicenseTypeStreaming);
|
||||
VerifyKeyRequestResponse(g_license_server, g_client_auth, false);
|
||||
|
||||
@@ -1213,7 +1240,7 @@ TEST_F(WvCdmRequestLicenseTest, OfflineLicenseRenewal) {
|
||||
std::string client_auth;
|
||||
GetOfflineConfiguration(&key_id, &client_auth);
|
||||
|
||||
decryptor_.OpenSession(g_key_system, NULL, NULL, &session_id_);
|
||||
decryptor_.OpenSession(g_key_system, NULL, EMPTY_ORIGIN, NULL, &session_id_);
|
||||
GenerateKeyRequest(key_id, kLicenseTypeOffline);
|
||||
VerifyKeyRequestResponse(g_license_server, client_auth, false);
|
||||
|
||||
@@ -1226,7 +1253,8 @@ TEST_F(WvCdmRequestLicenseTest, OfflineLicenseRenewal) {
|
||||
|
||||
TEST_F(WvCdmRequestLicenseTest, RemoveKeys) {
|
||||
ASSERT_EQ(NO_ERROR,
|
||||
decryptor_.OpenSession(g_key_system, NULL, NULL, &session_id_));
|
||||
decryptor_.OpenSession(g_key_system, NULL, EMPTY_ORIGIN, NULL,
|
||||
&session_id_));
|
||||
GenerateKeyRequest(g_key_id, kLicenseTypeStreaming);
|
||||
VerifyKeyRequestResponse(g_license_server, g_client_auth, false);
|
||||
ASSERT_EQ(NO_ERROR, decryptor_.RemoveKeys(session_id_));
|
||||
@@ -1247,7 +1275,7 @@ TEST_F(WvCdmRequestLicenseTest, UsageInfoRetryTest) {
|
||||
EXPECT_TRUE(handle.DeleteAllUsageInfoForApp(app_id, &psts));
|
||||
|
||||
SubSampleInfo* data = &usage_info_sub_samples_icp[0];
|
||||
decryptor_.OpenSession(g_key_system, NULL, NULL, &session_id_);
|
||||
decryptor_.OpenSession(g_key_system, NULL, EMPTY_ORIGIN, NULL, &session_id_);
|
||||
std::string key_id = a2bs_hex(
|
||||
"000000427073736800000000" // blob size and pssh
|
||||
"EDEF8BA979D64ACEA3C827DCD51D21ED00000022" // Widevine system id
|
||||
@@ -1325,7 +1353,8 @@ TEST_P(WvCdmUsageInfoTest, UsageInfo) {
|
||||
|
||||
for (size_t i = 0; i < usage_info_data->usage_info; ++i) {
|
||||
SubSampleInfo* data = usage_info_data->sub_sample + i;
|
||||
decryptor_.OpenSession(g_key_system, property_set, NULL, &session_id_);
|
||||
decryptor_.OpenSession(g_key_system, property_set, EMPTY_ORIGIN, NULL,
|
||||
&session_id_);
|
||||
std::string key_id = a2bs_hex(
|
||||
"000000427073736800000000" // blob size and pssh
|
||||
"EDEF8BA979D64ACEA3C827DCD51D21ED00000022" // Widevine system id
|
||||
@@ -1404,7 +1433,7 @@ TEST_F(WvCdmRequestLicenseTest, QueryKeyStatus) {
|
||||
Unprovision();
|
||||
Provision(kLevelDefault);
|
||||
|
||||
decryptor_.OpenSession(g_key_system, NULL, NULL, &session_id_);
|
||||
decryptor_.OpenSession(g_key_system, NULL, EMPTY_ORIGIN, NULL, &session_id_);
|
||||
GenerateKeyRequest(g_key_id, kLicenseTypeStreaming);
|
||||
VerifyKeyRequestResponse(g_license_server, g_client_auth, false);
|
||||
|
||||
@@ -1477,7 +1506,7 @@ TEST_F(WvCdmRequestLicenseTest, QueryKeyControlInfo) {
|
||||
Unprovision();
|
||||
Provision(kLevelDefault);
|
||||
|
||||
decryptor_.OpenSession(g_key_system, NULL, NULL, &session_id_);
|
||||
decryptor_.OpenSession(g_key_system, NULL, EMPTY_ORIGIN, NULL, &session_id_);
|
||||
GenerateKeyRequest(g_key_id, kLicenseTypeStreaming);
|
||||
VerifyKeyRequestResponse(g_license_server, g_client_auth, false);
|
||||
|
||||
@@ -1539,26 +1568,27 @@ TEST_F(WvCdmRequestLicenseTest, SecurityLevelPathBackwardCompatibility) {
|
||||
file.Remove(path);
|
||||
}
|
||||
|
||||
decryptor_.OpenSession(g_key_system, NULL, NULL, &session_id_);
|
||||
decryptor_.OpenSession(g_key_system, NULL, EMPTY_ORIGIN, NULL, &session_id_);
|
||||
std::string provisioning_server_url;
|
||||
CdmCertificateType cert_type = kCertificateWidevine;
|
||||
std::string cert_authority, cert, wrapped_key;
|
||||
EXPECT_EQ(wvcdm::NO_ERROR, decryptor_.GetProvisioningRequest(
|
||||
cert_type, cert_authority, &key_msg_,
|
||||
&provisioning_server_url));
|
||||
cert_type, cert_authority, EMPTY_ORIGIN,
|
||||
&key_msg_, &provisioning_server_url));
|
||||
EXPECT_EQ(provisioning_server_url, g_config->provisioning_server_url());
|
||||
std::string response =
|
||||
GetCertRequestResponse(g_config->provisioning_server_url());
|
||||
EXPECT_NE(0, static_cast<int>(response.size()));
|
||||
EXPECT_EQ(wvcdm::NO_ERROR, decryptor_.HandleProvisioningResponse(
|
||||
response, &cert, &wrapped_key));
|
||||
EXPECT_EQ(wvcdm::NO_ERROR,
|
||||
decryptor_.HandleProvisioningResponse(EMPTY_ORIGIN, response, &cert,
|
||||
&wrapped_key));
|
||||
decryptor_.CloseSession(session_id_);
|
||||
|
||||
std::vector<std::string> files;
|
||||
EXPECT_TRUE(file.List(base_path, &files));
|
||||
size_t number_of_files = files.size();
|
||||
|
||||
decryptor_.OpenSession(g_key_system, NULL, NULL, &session_id_);
|
||||
decryptor_.OpenSession(g_key_system, NULL, EMPTY_ORIGIN, NULL, &session_id_);
|
||||
GenerateKeyRequest(key_id, kLicenseTypeOffline);
|
||||
VerifyKeyRequestResponse(g_license_server, client_auth, false);
|
||||
CdmKeySetId key_set_id = key_set_id_;
|
||||
@@ -1584,11 +1614,11 @@ TEST_F(WvCdmRequestLicenseTest, SecurityLevelPathBackwardCompatibility) {
|
||||
// Setup complete to earlier version (non-security level based) path.
|
||||
// Restore persistent license, retrieve L1, L3 streaming licenses to verify
|
||||
session_id_.clear();
|
||||
decryptor_.OpenSession(g_key_system, NULL, NULL, &session_id_);
|
||||
decryptor_.OpenSession(g_key_system, NULL, EMPTY_ORIGIN, NULL, &session_id_);
|
||||
EXPECT_EQ(wvcdm::KEY_ADDED, decryptor_.RestoreKey(session_id_, key_set_id));
|
||||
decryptor_.CloseSession(session_id_);
|
||||
|
||||
decryptor_.OpenSession(g_key_system, NULL, NULL, &session_id_);
|
||||
decryptor_.OpenSession(g_key_system, NULL, EMPTY_ORIGIN, NULL, &session_id_);
|
||||
GenerateKeyRequest(g_key_id, kLicenseTypeStreaming);
|
||||
VerifyKeyRequestResponse(g_license_server, client_auth, false);
|
||||
decryptor_.CloseSession(session_id_);
|
||||
@@ -1600,26 +1630,28 @@ TEST_F(WvCdmRequestLicenseTest, SecurityLevelPathBackwardCompatibility) {
|
||||
|
||||
EXPECT_EQ(
|
||||
wvcdm::NEED_PROVISIONING,
|
||||
decryptor_.OpenSession(g_key_system, &property_set, NULL, &session_id_));
|
||||
decryptor_.OpenSession(g_key_system, &property_set, EMPTY_ORIGIN, NULL,
|
||||
&session_id_));
|
||||
EXPECT_EQ(NO_ERROR, decryptor_.GetProvisioningRequest(
|
||||
cert_type, cert_authority, &key_msg_,
|
||||
cert_type, cert_authority, EMPTY_ORIGIN, &key_msg_,
|
||||
&provisioning_server_url));
|
||||
EXPECT_EQ(provisioning_server_url, g_config->provisioning_server_url());
|
||||
response =
|
||||
GetCertRequestResponse(g_config->provisioning_server_url());
|
||||
EXPECT_NE(0, static_cast<int>(response.size()));
|
||||
EXPECT_EQ(NO_ERROR, decryptor_.HandleProvisioningResponse(response, &cert,
|
||||
&wrapped_key));
|
||||
EXPECT_EQ(NO_ERROR,
|
||||
decryptor_.HandleProvisioningResponse(EMPTY_ORIGIN, response, &cert,
|
||||
&wrapped_key));
|
||||
|
||||
EXPECT_EQ(NO_ERROR, decryptor_.OpenSession(g_key_system, &property_set, NULL,
|
||||
&session_id_));
|
||||
EXPECT_EQ(NO_ERROR, decryptor_.OpenSession(g_key_system, &property_set,
|
||||
EMPTY_ORIGIN, NULL, &session_id_));
|
||||
GenerateKeyRequest(g_key_id, kLicenseTypeStreaming);
|
||||
VerifyKeyRequestResponse(g_license_server, client_auth, false);
|
||||
decryptor_.CloseSession(session_id_);
|
||||
}
|
||||
|
||||
TEST_F(WvCdmRequestLicenseTest, DISABLED_OfflineLicenseDecryptionTest) {
|
||||
decryptor_.OpenSession(g_key_system, NULL, NULL, &session_id_);
|
||||
decryptor_.OpenSession(g_key_system, NULL, EMPTY_ORIGIN, NULL, &session_id_);
|
||||
GenerateKeyRequest(g_key_id, kLicenseTypeOffline);
|
||||
VerifyKeyRequestResponse(g_license_server, g_client_auth, false);
|
||||
|
||||
@@ -1672,7 +1704,7 @@ TEST_F(WvCdmRequestLicenseTest, DISABLED_OfflineLicenseDecryptionTest) {
|
||||
}
|
||||
|
||||
TEST_F(WvCdmRequestLicenseTest, DISABLED_RestoreOfflineLicenseDecryptionTest) {
|
||||
decryptor_.OpenSession(g_key_system, NULL, NULL, &session_id_);
|
||||
decryptor_.OpenSession(g_key_system, NULL, EMPTY_ORIGIN, NULL, &session_id_);
|
||||
GenerateKeyRequest(g_key_id, kLicenseTypeOffline);
|
||||
VerifyKeyRequestResponse(g_license_server, g_client_auth, false);
|
||||
CdmKeySetId key_set_id = key_set_id_;
|
||||
@@ -1680,7 +1712,7 @@ TEST_F(WvCdmRequestLicenseTest, DISABLED_RestoreOfflineLicenseDecryptionTest) {
|
||||
decryptor_.CloseSession(session_id_);
|
||||
|
||||
session_id_.clear();
|
||||
decryptor_.OpenSession(g_key_system, NULL, NULL, &session_id_);
|
||||
decryptor_.OpenSession(g_key_system, NULL, EMPTY_ORIGIN, NULL, &session_id_);
|
||||
EXPECT_EQ(wvcdm::KEY_ADDED, decryptor_.RestoreKey(session_id_, key_set_id));
|
||||
/*
|
||||
// key 1, encrypted, 256b
|
||||
@@ -1797,7 +1829,8 @@ TEST_P(WvCdmSessionSharingTest, SessionSharingTest) {
|
||||
property_set.set_session_sharing_mode(
|
||||
session_sharing_info->session_sharing_enabled);
|
||||
|
||||
decryptor_.OpenSession(g_key_system, &property_set, NULL, &session_id_);
|
||||
decryptor_.OpenSession(g_key_system, &property_set, EMPTY_ORIGIN, NULL,
|
||||
&session_id_);
|
||||
CdmSessionId gp_session_id_1 = session_id_;
|
||||
GenerateKeyRequest(g_key_id, kLicenseTypeStreaming);
|
||||
VerifyKeyRequestResponse(g_license_server, g_client_auth, false);
|
||||
@@ -1810,7 +1843,8 @@ TEST_P(WvCdmSessionSharingTest, SessionSharingTest) {
|
||||
"edef8ba979d64acea3c827dcd51d21ed00000014" // Widevine system id
|
||||
"08011210bdf1cb4fffc6506b8b7945b0bd2917fb"); // pssh data
|
||||
|
||||
decryptor_.OpenSession(g_key_system, &property_set, NULL, &session_id_);
|
||||
decryptor_.OpenSession(g_key_system, &property_set, EMPTY_ORIGIN, NULL,
|
||||
&session_id_);
|
||||
CdmSessionId gp_session_id_2 = session_id_;
|
||||
GenerateKeyRequest(gp_key_id2, kLicenseTypeStreaming);
|
||||
VerifyKeyRequestResponse(g_license_server, gp_client_auth2, false);
|
||||
@@ -1845,7 +1879,7 @@ TEST_F(WvCdmRequestLicenseTest, DecryptionKeyExpiredTest) {
|
||||
"EDEF8BA979D64ACEA3C827DCD51D21ED00000014" // Widevine system id
|
||||
"0801121030313233343536373839616263646566"); // pssh data
|
||||
SubSampleInfo* data = &single_encrypted_sub_sample_short_expiry;
|
||||
decryptor_.OpenSession(g_key_system, NULL, NULL, &session_id_);
|
||||
decryptor_.OpenSession(g_key_system, NULL, EMPTY_ORIGIN, NULL, &session_id_);
|
||||
if (data->retrieve_key) {
|
||||
GenerateKeyRequest(kCpKeyId, kLicenseTypeStreaming);
|
||||
VerifyKeyRequestResponse(g_license_server, g_client_auth, false);
|
||||
@@ -1875,7 +1909,7 @@ class WvCdmDecryptionTest
|
||||
|
||||
TEST_P(WvCdmDecryptionTest, DecryptionTest) {
|
||||
SubSampleInfo* data = GetParam();
|
||||
decryptor_.OpenSession(g_key_system, NULL, NULL, &session_id_);
|
||||
decryptor_.OpenSession(g_key_system, NULL, EMPTY_ORIGIN, NULL, &session_id_);
|
||||
if (data->retrieve_key) {
|
||||
GenerateKeyRequest(g_key_id, kLicenseTypeStreaming);
|
||||
VerifyKeyRequestResponse(g_license_server, g_client_auth, false);
|
||||
|
||||
Reference in New Issue
Block a user