Widevine CENC drm engine update: enable decryption
This import syncs to the widevine git repostiory change commit ab3e1e43642cf36900f55169597a33f222709fdb Change-Id: I3a6f1e2969e5fe7ed1ca12f90b0eb0a3b7899835
This commit is contained in:
@@ -81,11 +81,12 @@ class CdmEngine : public TimerHandler {
|
||||
CdmResponseType Decrypt(const CdmSessionId& session_id,
|
||||
bool is_encrypted,
|
||||
const KeyId& key_id,
|
||||
const uint8_t* encrypted_buffer,
|
||||
size_t encrypted_size,
|
||||
const uint8_t* encrypt_buffer,
|
||||
size_t encrypt_length,
|
||||
const std::vector<uint8_t>& iv,
|
||||
size_t block_offset,
|
||||
uint8_t* decrypted_buffer);
|
||||
void* decrypt_buffer,
|
||||
bool is_video);
|
||||
|
||||
// Is the key known to any session?
|
||||
bool IsKeyValid(const KeyId& key_id);
|
||||
|
||||
@@ -18,7 +18,9 @@ namespace wvcdm {
|
||||
|
||||
class CdmSession {
|
||||
public:
|
||||
CdmSession() : state_(INITIAL), session_id_(GenerateSessionId()) {}
|
||||
CdmSession() : session_id_(GenerateSessionId()),
|
||||
license_received_(false),
|
||||
properties_valid_(false) {}
|
||||
~CdmSession() {}
|
||||
|
||||
bool Init();
|
||||
@@ -46,12 +48,14 @@ class CdmSession {
|
||||
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,
|
||||
CdmResponseType Decrypt(bool is_encrypted,
|
||||
const KeyId& key_id,
|
||||
uint8_t* decrypted_buffer);
|
||||
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
|
||||
@@ -73,22 +77,18 @@ class CdmSession {
|
||||
// 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_;
|
||||
bool license_received_;
|
||||
|
||||
bool properties_valid_;
|
||||
bool require_explicit_renew_request_;
|
||||
|
||||
KeyId key_id_;
|
||||
|
||||
std::set<WvCdmEventListener*> listeners_;
|
||||
|
||||
|
||||
@@ -38,7 +38,21 @@ class CryptoEngine {
|
||||
|
||||
bool GetToken(std::string* token);
|
||||
|
||||
CdmResponseType Query(CdmQueryMap* info);
|
||||
typedef enum {
|
||||
kSecurityLevelL1,
|
||||
kSecurityLevelL2,
|
||||
kSecurityLevelL3,
|
||||
kSecurityLevelUnknown
|
||||
} SecurityLevel;
|
||||
|
||||
SecurityLevel GetSecurityLevel();
|
||||
|
||||
bool properties_valid() const { return properties_valid_; }
|
||||
bool oem_crypto_use_secure_buffers() const
|
||||
{ return oem_crypto_use_secure_buffers_; }
|
||||
bool oem_crypto_use_fifo() const { return oem_crypto_use_fifo_; }
|
||||
bool oem_crypto_use_userspace_buffers() const
|
||||
{ return oem_crypto_use_userspace_buffers_; }
|
||||
|
||||
private:
|
||||
|
||||
@@ -55,6 +69,11 @@ private:
|
||||
mutable Lock sessions_lock_;
|
||||
CryptoSessionMap sessions_;
|
||||
|
||||
bool properties_valid_;
|
||||
bool oem_crypto_use_secure_buffers_;
|
||||
bool oem_crypto_use_fifo_;
|
||||
bool oem_crypto_use_userspace_buffers_;
|
||||
|
||||
CORE_DISALLOW_COPY_AND_ASSIGN(CryptoEngine);
|
||||
};
|
||||
|
||||
|
||||
@@ -9,16 +9,13 @@
|
||||
#include <map>
|
||||
|
||||
#include "crypto_key.h"
|
||||
#include "OEMCryptoCENC.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();
|
||||
@@ -55,12 +52,13 @@ class CryptoSession {
|
||||
|
||||
// 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);
|
||||
CdmResponseType Decrypt(bool is_encrypted,
|
||||
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);
|
||||
|
||||
private:
|
||||
|
||||
@@ -69,6 +67,7 @@ class CryptoSession {
|
||||
void GenerateEncryptContext(const std::string& input_context,
|
||||
std::string* deriv_context);
|
||||
size_t GetOffset(std::string message, std::string field);
|
||||
bool SetDestinationBufferType();
|
||||
|
||||
bool valid_;
|
||||
bool open_;
|
||||
@@ -76,6 +75,9 @@ class CryptoSession {
|
||||
CryptoSessionId oec_session_id_;
|
||||
CryptoResult session_status_;
|
||||
|
||||
OEMCryptoBufferType destination_buffer_type_;
|
||||
bool is_destination_buffer_type_valid_;
|
||||
|
||||
CryptoKeyMap keys_;
|
||||
|
||||
CORE_DISALLOW_COPY_AND_ASSIGN(CryptoSession);
|
||||
|
||||
@@ -19,7 +19,20 @@ static const size_t MAC_KEY_SIZE = 32;
|
||||
// define boolean property keys here
|
||||
// If false begin license usage on first playback
|
||||
static std::string kPropertyKeyBeginLicenseUsageWhenReceived =
|
||||
"WVBeginLicenseUsageWhenReceived";
|
||||
"WVBeginLicenseUsageWhenReceived";
|
||||
// If false, calls to Generate Key request, after the first one,
|
||||
// will result in a renewal request being generated
|
||||
static std::string kPropertyKeyRequireExplicitRenewRequest =
|
||||
"WVRequireExplicitRenewRequest";
|
||||
// Set only one of the three below to true. If secure buffer
|
||||
// is selected, fallback to userspace buffers may occur
|
||||
// if L1/L2 OEMCrypto APIs fail
|
||||
static std::string kPropertyKeyOemCryptoUseSecureBuffers =
|
||||
"WVBeginLicenseOemCryptoUseSecureBuffer";
|
||||
static std::string kPropertyKeyOemCryptoUseFifo =
|
||||
"WVBeginLicenseOemCryptoUseFifo";
|
||||
static std::string kPropertyKeyOemCryptoUseUserSpaceBuffers =
|
||||
"WVBeginLicenseOemCryptoUseUserSpaceBuffers";
|
||||
|
||||
// define query keys, values here
|
||||
static const std::string QUERY_KEY_LICENSE_TYPE = "LicenseType";
|
||||
@@ -38,6 +51,7 @@ static const std::string QUERY_KEY_RENEWAL_SERVER_URL = "RenewalServerUrl";
|
||||
// url
|
||||
static const std::string QUERY_KEY_SECURITY_LEVEL = "SecurityLevel";
|
||||
// "L1", "L3"
|
||||
|
||||
static const std::string QUERY_VALUE_TRUE = "True";
|
||||
static const std::string QUERY_VALUE_FALSE = "False";
|
||||
static const std::string QUERY_VALUE_STREAMING = "Streaming";
|
||||
@@ -45,7 +59,7 @@ static const std::string QUERY_VALUE_OFFLINE = "Offline";
|
||||
static const std::string QUERY_VALUE_SECURITY_LEVEL_L1 = "L1";
|
||||
static const std::string QUERY_VALUE_SECURITY_LEVEL_L2 = "L2";
|
||||
static const std::string QUERY_VALUE_SECURITY_LEVEL_L3 = "L3";
|
||||
|
||||
static const std::string QUERY_VALUE_SECURITY_LEVEL_Unknown = "Unknown";
|
||||
|
||||
} // namespace wvcdm
|
||||
|
||||
|
||||
Reference in New Issue
Block a user