bug: 8601053
This import syncs to the widevine git repository change
commit 6a99ad1b59ad39495f62954b3065ddc22b78da49
It includes the following changes from the widevine git
repository, which complete the jb-mr2 features
Fix Unit Test Makefile
Adds support for device certificate provisioning.
Support application parameters
Certificate based licensing
Proto for client files
Implement Property Query API
Add Device Query For Unique ID
Implement Generic Crypto in DrmEngine
Do not validate Key IDs on clear playback
Allow OEMCrypto_DecryptCTR with clear content and no key
Add a case to the MediaDrm API test to repro b/8594163
Implement requiresSecureDecoderComponent
Implement Eventing API
Add end-to-end decryption test with vectors
Refactoring of properties class
Refactor OEMCrypto unittest.
Fix for b/8567853: License renewal doesn't renew license.
Add KEY_ERROR callback to WvContentDecryptionModule() ctor.
Merged certificate_provisioning.proto and
client_identification.proto to license_protocol.proto.
Fix nonce check failure after a malformed key in OEC Mock.
asynchronize decryption
Allow querying of control information
make debugging AddKey & Decrypt statuses easier
Revert "Revert "Send KEY_ERROR event to app on license
expiration or failure""
Revert "Send KEY_ERROR event to app on license expiration
or failure"
Send KEY_ERROR event to app on license expiration or failure
remove extra session id copy
use KeyError constants directly
replace variable-length arrays with std::vector and fixed-sized array
pass session ids as const references
refactor key extraction and update keys on renewal
Updates to enable renewals and signaling license expiration.
fix error constant in OEMCrypto_DecryptCTR
Change-Id: I5f7236c7bdff1d5ece6115fd2893f8a1e1e07c50
143 lines
5.5 KiB
C++
143 lines
5.5 KiB
C++
// Copyright 2013 Google Inc. All Rights Reserved.
|
|
|
|
#ifndef CDM_BASE_CDM_ENGINE_H_
|
|
#define CDM_BASE_CDM_ENGINE_H_
|
|
|
|
#include "crypto_engine.h"
|
|
#include "timer.h"
|
|
#include "wv_cdm_types.h"
|
|
|
|
namespace wvcdm {
|
|
|
|
class CdmSession;
|
|
class WvCdmEventListener;
|
|
|
|
typedef std::map<CdmSessionId, CdmSession*> CdmSessionMap;
|
|
|
|
class CdmEngine : public TimerHandler {
|
|
public:
|
|
CdmEngine();
|
|
~CdmEngine();
|
|
|
|
// Session related methods
|
|
CdmResponseType OpenSession(const CdmKeySystem& key_system,
|
|
CdmSessionId* session_id);
|
|
CdmResponseType CloseSession(const CdmSessionId& session_id);
|
|
|
|
// License related methods
|
|
// Construct a valid license request
|
|
CdmResponseType GenerateKeyRequest(const CdmSessionId& session_id,
|
|
bool is_key_system_present,
|
|
const CdmKeySystem& key_system,
|
|
const CdmInitData& init_data,
|
|
const CdmLicenseType license_type,
|
|
CdmAppParameterMap& app_parameters,
|
|
CdmKeyMessage* key_request);
|
|
|
|
// Accept license response and extract key info.
|
|
CdmResponseType AddKey(const CdmSessionId& session_id,
|
|
bool is_key_system_init_data_present,
|
|
const CdmKeySystem& key_system,
|
|
const CdmInitData& init_data,
|
|
const CdmKeyResponse& key_data);
|
|
|
|
// Cancel session and unload keys.
|
|
CdmResponseType CancelKeyRequest(const CdmSessionId& session_id,
|
|
bool is_key_system_present,
|
|
const CdmKeySystem& key_system);
|
|
|
|
// Construct valid renewal request for the current session keys.
|
|
CdmResponseType GenerateRenewalRequest(const CdmSessionId& session_id,
|
|
bool is_key_system_init_data_present,
|
|
const CdmKeySystem& key_system,
|
|
const CdmInitData& init_data,
|
|
CdmKeyMessage* key_request);
|
|
|
|
// Accept renewal response and update key info.
|
|
CdmResponseType RenewKey(const CdmSessionId& session_id,
|
|
bool is_key_system_init_data_present,
|
|
const CdmKeySystem& key_system,
|
|
const CdmInitData& init_data,
|
|
const CdmKeyResponse& key_data);
|
|
|
|
// Query system information
|
|
CdmResponseType QueryStatus(CdmQueryMap* info);
|
|
|
|
// Query license information
|
|
CdmResponseType QueryKeyStatus(const CdmSessionId& session_id,
|
|
CdmQueryMap* key_info);
|
|
|
|
// Query seesion control information
|
|
CdmResponseType QueryKeyControlInfo(const CdmSessionId& session_id,
|
|
CdmQueryMap* key_info);
|
|
|
|
// Provisioning related methods
|
|
CdmResponseType GetProvisioningRequest(CdmProvisioningRequest* request,
|
|
std::string* default_url);
|
|
|
|
CdmResponseType HandleProvisioningResponse(CdmProvisioningResponse& response);
|
|
|
|
// Secure stop related methods
|
|
CdmResponseType GetSecureStops(CdmSecureStops* secure_stops);
|
|
CdmResponseType ReleaseSecureStops(const CdmSecureStopReleaseMessage& message);
|
|
|
|
// Decryption and key related methods
|
|
// Accept encrypted buffer and return decrypted data.
|
|
CdmResponseType Decrypt(const CdmSessionId& session_id,
|
|
bool is_encrypted,
|
|
const KeyId& key_id,
|
|
const uint8_t* encrypt_buffer,
|
|
size_t encrypt_length,
|
|
const std::vector<uint8_t>& iv,
|
|
size_t block_offset,
|
|
void* decrypt_buffer,
|
|
bool is_video);
|
|
|
|
// Is the key known to any session?
|
|
bool IsKeyValid(const KeyId& key_id);
|
|
|
|
// Event listener related methods
|
|
bool AttachEventListener(const CdmSessionId& session_id,
|
|
WvCdmEventListener* listener);
|
|
bool DetachEventListener(const CdmSessionId& session_id,
|
|
WvCdmEventListener* listener);
|
|
private:
|
|
// private methods
|
|
// Cancel all sessions
|
|
bool CancelSessions();
|
|
void CleanupProvisioingSessions(CdmSession* cdm_session,
|
|
CryptoEngine* crypto_engine,
|
|
const CdmSessionId& cdm_session_id);
|
|
void ComposeJsonRequest(const std::string& message,
|
|
const std::string& signature,
|
|
CdmProvisioningRequest* request);
|
|
|
|
// Parse a blob of multiple concatenated PSSH atoms to extract the first
|
|
// widevine pssh
|
|
// TODO(gmorgan): This should be done by the user of this class.
|
|
bool ExtractWidevinePssh(const CdmInitData& init_data,
|
|
CdmInitData* output);
|
|
bool ParseJsonResponse(const CdmProvisioningResponse& json_str,
|
|
const std::string& start_substr,
|
|
const std::string& end_substr,
|
|
std::string* result);
|
|
bool ValidateKeySystem(const CdmKeySystem& key_system);
|
|
|
|
// timer related methods to drive policy decisions
|
|
void EnablePolicyTimer();
|
|
void DisablePolicyTimer();
|
|
virtual void OnTimerEvent();
|
|
|
|
// instance variables
|
|
CdmSessionMap sessions_;
|
|
|
|
// policy timer
|
|
Timer policy_timer_;
|
|
|
|
CORE_DISALLOW_COPY_AND_ASSIGN(CdmEngine);
|
|
};
|
|
|
|
} // namespace wvcdm
|
|
|
|
#endif // CDM_BASE_CDM_ENGINE_H_
|