* Extend CdmLicense's stored_init_data_ [ Merge of http://go/wvgerrit/14661 ] CdmLicense will store init data when a server cert must be provisioned. After provisioning, the original init data can be used to generate the originally-intended license request. To do this before, the caller had to call CdmSession's GenerateKeyRequest with an empty InitializationData object. However, the init data's type still had to be set, as did the license type. This CL allows the caller to use a truly empty InitializationData without a type. To permit this, CdmLicense now stores a full InitializationData object, rather than just a copy of it's data field. With this CL, the caller also avoid storing the original license type. To accomplish this, CdmSession uses the already-set is_offline_ and is_release_ flags from the original call to reconstruct the intended license type. The caller uses the new type kLicenseTypeDeferred. To facilitate storing whole InitializationData objects, they are now copyable. This ultimately simplifies server cert code for the new CE CDM. * Store service certs in Properties [ Merge of http://go/wvgerrit/14664 ] This allows CE devices to mimic the Chrome CDM's behavior of sharing server certs between sessions. This also affects Android behavior. Previously, provisioned service certificates were per-session, while explicitly-set service certs were per-DRM-plugin. Now, both are per-DRM-plugin. A DRM plugin is associated with a mediaDrm object. Content providers will still be able to retrieve and use different certificates. The change here requires an app, that wishes to use different provisioned service certificates will have to use multiple mediaDrm objects. This is an unlikely scenario. Change-Id: If2586932784ed046ecab72b5720ff30547e84b97
111 lines
3.5 KiB
C++
111 lines
3.5 KiB
C++
// Copyright 2012 Google Inc. All Rights Reserved.
|
|
|
|
#ifndef WVCDM_CORE_LICENSE_H_
|
|
#define WVCDM_CORE_LICENSE_H_
|
|
|
|
#include <set>
|
|
|
|
#include "initialization_data.h"
|
|
#include "scoped_ptr.h"
|
|
#include "wv_cdm_types.h"
|
|
|
|
namespace video_widevine_server {
|
|
namespace sdk {
|
|
class SignedMessage;
|
|
class LicenseRequest;
|
|
}
|
|
} // namespace video_widevine_server
|
|
|
|
namespace wvcdm {
|
|
|
|
class Clock;
|
|
class CryptoSession;
|
|
class PolicyEngine;
|
|
|
|
class CdmLicense {
|
|
public:
|
|
CdmLicense(const CdmSessionId& session_id);
|
|
virtual ~CdmLicense();
|
|
|
|
virtual bool Init(const std::string& token, CryptoSession* session,
|
|
PolicyEngine* policy_engine);
|
|
|
|
virtual CdmResponseType PrepareKeyRequest(
|
|
const InitializationData& init_data, const CdmLicenseType license_type,
|
|
const CdmAppParameterMap& app_parameters, CdmKeyMessage* signed_request,
|
|
std::string* server_url);
|
|
virtual CdmResponseType PrepareKeyUpdateRequest(
|
|
bool is_renewal, const CdmAppParameterMap& app_parameters,
|
|
CdmKeyMessage* signed_request, std::string* server_url);
|
|
virtual CdmResponseType HandleKeyResponse(
|
|
const CdmKeyResponse& license_response);
|
|
virtual CdmResponseType HandleKeyUpdateResponse(
|
|
bool is_renewal, const CdmKeyResponse& license_response);
|
|
|
|
virtual bool RestoreOfflineLicense(
|
|
const CdmKeyMessage& license_request,
|
|
const CdmKeyResponse& license_response,
|
|
const CdmKeyResponse& license_renewal_response,
|
|
int64_t playback_start_time, int64_t last_playback_time);
|
|
virtual bool RestoreLicenseForRelease(const CdmKeyMessage& license_request,
|
|
const CdmKeyResponse& license_response);
|
|
virtual bool HasInitData() { return stored_init_data_.get(); }
|
|
virtual bool IsKeyLoaded(const KeyId& key_id);
|
|
|
|
virtual std::string provider_session_token() {
|
|
return provider_session_token_;
|
|
}
|
|
|
|
static CdmResponseType VerifySignedServiceCertificate(
|
|
const std::string& signed_service_certificate);
|
|
|
|
private:
|
|
bool PrepareServiceCertificateRequest(CdmKeyMessage* signed_request,
|
|
std::string* server_url);
|
|
|
|
CdmResponseType HandleKeyErrorResponse(
|
|
const video_widevine_server::sdk::SignedMessage& signed_message);
|
|
|
|
CdmResponseType PrepareClientId(
|
|
bool encrypt, const std::string& certificate,
|
|
const CdmAppParameterMap& app_parameters,
|
|
video_widevine_server::sdk::LicenseRequest* license_request);
|
|
template <typename T>
|
|
bool PrepareContentId(const CdmLicenseType license_type,
|
|
const std::string& request_id, T* content_id);
|
|
|
|
static CdmResponseType VerifyAndExtractSignedServiceCertificate(
|
|
const std::string& signed_service_certificate,
|
|
std::string* service_certificate);
|
|
bool GetServiceCertificate(std::string* service_certificate);
|
|
|
|
CryptoSession* session_;
|
|
PolicyEngine* policy_engine_;
|
|
std::string server_url_;
|
|
std::string token_;
|
|
const CdmSessionId session_id_;
|
|
scoped_ptr<InitializationData> stored_init_data_;
|
|
bool initialized_;
|
|
std::set<KeyId> loaded_keys_;
|
|
std::string provider_session_token_;
|
|
bool renew_with_client_id_;
|
|
|
|
// Used for certificate based licensing
|
|
CdmKeyMessage key_request_;
|
|
|
|
scoped_ptr<Clock> clock_;
|
|
|
|
// For testing
|
|
// CdmLicense takes ownership of the clock.
|
|
CdmLicense(const CdmSessionId& session_id, Clock* clock);
|
|
#if defined(UNIT_TEST)
|
|
friend class CdmLicenseTest;
|
|
#endif
|
|
|
|
CORE_DISALLOW_COPY_AND_ASSIGN(CdmLicense);
|
|
};
|
|
|
|
} // namespace wvcdm
|
|
|
|
#endif // WVCDM_CORE_LICENSE_H_
|