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
87 lines
2.5 KiB
C++
87 lines
2.5 KiB
C++
// Copyright 2012 Google Inc. All Rights Reserved.
|
|
//
|
|
// OEMCrypto Client - wrapper class for C-style OEMCrypto interface
|
|
//
|
|
#ifndef CDM_BASE_CRYPTO_SESSSION_H_
|
|
#define CDM_BASE_CRYPTO_SESSSION_H_
|
|
|
|
#include <string>
|
|
#include <map>
|
|
|
|
#include "crypto_key.h"
|
|
#include "wv_cdm_types.h"
|
|
|
|
namespace wvcdm {
|
|
|
|
typedef std::map<CryptoKeyId,CryptoKey*> CryptoKeyMap;
|
|
|
|
// TODO(gmorgan): fill out input and output descriptors
|
|
typedef void* InputDescriptor;
|
|
typedef void* OutputDescriptor;
|
|
|
|
class CryptoSession {
|
|
public:
|
|
CryptoSession();
|
|
explicit CryptoSession(const std::string& sname);
|
|
~CryptoSession();
|
|
|
|
bool Open();
|
|
void Close();
|
|
|
|
bool IsValid() { return valid_; }
|
|
bool IsOpen() { return open_; }
|
|
bool SuccessStatus();
|
|
CryptoResult session_status() { return session_status_; }
|
|
CryptoSessionId oec_session_id() { return oec_session_id_; }
|
|
CdmSessionId cdm_session_id() { return cdm_session_id_; }
|
|
|
|
// Key request/response
|
|
void GenerateRequestId(std::string& req_id_str);
|
|
bool PrepareRequest(const std::string& key_deriv_message,
|
|
std::string* signature);
|
|
bool PrepareRenewalRequest(const std::string& message,
|
|
std::string* signature);
|
|
bool LoadKeys(const std::string& message,
|
|
const std::string& signature,
|
|
const std::string& mac_key_iv,
|
|
const std::string& mac_key,
|
|
int num_keys,
|
|
const CryptoKey* key_array);
|
|
bool RefreshKeys(const std::string& message,
|
|
const std::string& signature,
|
|
int num_keys,
|
|
const CryptoKey* key_array);
|
|
bool GenerateNonce(uint32_t* nonce);
|
|
|
|
// Media data path
|
|
bool SelectKey(const std::string& key_id);
|
|
bool Decrypt(const InputDescriptor input, OutputDescriptor output);
|
|
bool Decrypt(const uint8_t* encrypted_buffer,
|
|
size_t encrypted_size,
|
|
size_t block_offset,
|
|
const std::vector<uint8_t>& iv,
|
|
uint8_t* decrypted_buffer);
|
|
|
|
private:
|
|
|
|
void GenerateMacContext(const std::string& input_context,
|
|
std::string* deriv_context);
|
|
void GenerateEncryptContext(const std::string& input_context,
|
|
std::string* deriv_context);
|
|
size_t GetOffset(std::string message, std::string field);
|
|
|
|
bool valid_;
|
|
bool open_;
|
|
CdmSessionId cdm_session_id_;
|
|
CryptoSessionId oec_session_id_;
|
|
CryptoResult session_status_;
|
|
|
|
CryptoKeyMap keys_;
|
|
|
|
CORE_DISALLOW_COPY_AND_ASSIGN(CryptoSession);
|
|
};
|
|
|
|
}; // namespace wvcdm
|
|
|
|
#endif // CDM_BASE_CRYPTO_SESSSION_H_
|