Builds libwvmdrmengine.so, which is loaded by the new MediaDrm APIs to support playback of Widevine/CENC protected content. Change-Id: I6f57dd37083dfd96c402cb9dd137c7d74edc8f1c
82 lines
2.3 KiB
C++
82 lines
2.3 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);
|
|
|
|
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_
|