This change incorporates the following CLs from the Widevine
cdm repository:
Update the java request/response test app to match Drm API changes
Don't build the mock liboemcrypto.so by default
Do not build CDM tests by default
Fix Build Break in DrmEngine Unit Tests
Fix Build Break in WVDrmPlugin
Initial version of roadmap for CDM projects.
Implement License Query
Implement Generic DRM in OEMCrypto Reference Implementation
Add key_data_length field when calling OEMCrypto_LoadKeys
Policy engine unittests
Generalized DRM API for OEMCrypto
Fixes proto buf libraries build.
Add Version Number to OEMCrypto API
Test key control block duration field in OEMCrypto
Add fix for missing crypto offset.
Fixed android/media*/test builds and added proto files for Cert. provisioning
Refactor and clean up callback code in CDM.
Add "device_id" name-value pair to LicenseRequest::ClientIdentification
Separate unit and end-to-end tests from the top level makefie.
Includes changes for 'fall back to l3 oemcrypto lib' in top level makefile.
Fall Back to Level 3 if Level 1 Fails
Fix compilation error in wvcdm_unittest.
Fix Android build break due to Decrypt() signature change in cdm_engine.h.
Wire up callbacks and errors in the Steel proxy.
Fix lock assert if there is no keybox on the device.
RSA Certificate Unit Test
Change Generic_Verify signature to constant.
Change-Id: I2e42db9d0b4f8d4e833675ae81d0714509bbfd2c
104 lines
2.8 KiB
C++
104 lines
2.8 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() : state_(INITIAL), session_id_(GenerateSessionId()) {}
|
|
~CdmSession() {}
|
|
|
|
bool 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& init_data,
|
|
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);
|
|
|
|
// Decrypt() - Accept encrypted buffer and return decrypted data.
|
|
CdmResponseType Decrypt(const uint8_t* encrypted_buffer,
|
|
size_t encrypted_size,
|
|
size_t block_offset,
|
|
const std::vector<uint8_t>& iv,
|
|
const KeyId& key_id,
|
|
uint8_t* decrypted_buffer);
|
|
|
|
// 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();
|
|
|
|
typedef enum {
|
|
INITIAL,
|
|
LICENSE_REQUESTED,
|
|
LICENSE_RESPONSE_DONE,
|
|
RENEWAL_ENABLED,
|
|
RENEWAL_REQUESTED,
|
|
LICENSE_EXPIRED
|
|
} CdmSessionState;
|
|
|
|
// instance variables
|
|
CdmSessionState state_;
|
|
const CdmSessionId session_id_;
|
|
CdmKeySystem key_system_;
|
|
CdmLicense license_parser_;
|
|
CryptoSession* crypto_session_;
|
|
PolicyEngine policy_engine_;
|
|
|
|
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_
|