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
109 lines
3.1 KiB
C++
109 lines
3.1 KiB
C++
// Copyright 2012 Google Inc. All Rights Reserved.
|
|
|
|
#ifndef CDM_BASE_CDM_SESSION_H_
|
|
#define CDM_BASE_CDM_SESSION_H_
|
|
|
|
#include <set>
|
|
|
|
#include "crypto_session.h"
|
|
#include "license.h"
|
|
#include "policy_engine.h"
|
|
#include "wv_cdm_event_listener.h"
|
|
#include "wv_cdm_types.h"
|
|
|
|
namespace wvcdm {
|
|
|
|
// TODO(kqyang): Do we need it? CdmKey not defined yet
|
|
// typedef std::map<KeyId, CdmKey*> CdmSessionKeys;
|
|
|
|
class CdmSession {
|
|
public:
|
|
CdmSession() : session_id_(GenerateSessionId()), license_received_(false) {}
|
|
~CdmSession() {}
|
|
|
|
CdmResponseType Init();
|
|
|
|
bool DestroySession();
|
|
|
|
void set_key_system(const CdmKeySystem& ksystem) { key_system_ = ksystem; }
|
|
const CdmKeySystem& key_system() { return key_system_; }
|
|
|
|
const CdmSessionId& session_id() { return session_id_; }
|
|
|
|
bool VerifySession(const CdmKeySystem& key_system,
|
|
const CdmInitData& init_data);
|
|
|
|
CdmResponseType GenerateKeyRequest(const CdmInitData& pssh_data,
|
|
const CdmLicenseType license_type,
|
|
CdmAppParameterMap& app_parameters,
|
|
CdmKeyMessage* key_request);
|
|
|
|
// AddKey() - Accept license response and extract key info.
|
|
CdmResponseType AddKey(const CdmKeyResponse& key_response);
|
|
|
|
// CancelKeyRequest() - Cancel session.
|
|
CdmResponseType CancelKeyRequest();
|
|
|
|
// Query license information
|
|
CdmResponseType QueryKeyStatus(CdmQueryMap* key_info);
|
|
|
|
// Query session control info
|
|
CdmResponseType QueryKeyControlInfo(CdmQueryMap* key_info);
|
|
|
|
// Decrypt() - Accept encrypted buffer and return decrypted data.
|
|
CdmResponseType Decrypt(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);
|
|
|
|
// License renewal
|
|
// GenerateRenewalRequest() - Construct valid renewal request for the current
|
|
// session keys.
|
|
CdmResponseType GenerateRenewalRequest(CdmKeyMessage* key_request);
|
|
|
|
// RenewKey() - Accept renewal response and update key info.
|
|
CdmResponseType RenewKey(const CdmKeyResponse& key_response);
|
|
|
|
bool IsKeyValid(const KeyId& key_id);
|
|
|
|
bool AttachEventListener(WvCdmEventListener* listener);
|
|
bool DetachEventListener(WvCdmEventListener* listener);
|
|
|
|
void OnTimerEvent();
|
|
|
|
private:
|
|
|
|
// Generate unique ID for each new session.
|
|
CdmSessionId GenerateSessionId();
|
|
|
|
bool LoadDeviceCertificate(std::string* cert, std::string* wrapped_key);
|
|
|
|
// instance variables
|
|
const CdmSessionId session_id_;
|
|
CdmKeySystem key_system_;
|
|
CdmLicense license_parser_;
|
|
CryptoSession* crypto_session_;
|
|
PolicyEngine policy_engine_;
|
|
bool license_received_;
|
|
|
|
KeyId key_id_;
|
|
|
|
// Used for certificate based licensing
|
|
std::string wrapped_key_;
|
|
|
|
std::set<WvCdmEventListener*> listeners_;
|
|
|
|
// TODO(kqyang): CdmKey not defined yet
|
|
// CdmSessionKeys session_keys_;
|
|
|
|
CORE_DISALLOW_COPY_AND_ASSIGN(CdmSession);
|
|
};
|
|
|
|
} // namespace wvcdm
|
|
|
|
#endif // CDM_BASE_CDM_SESSION_H_
|