Source release 14.2.0
This commit is contained in:
@@ -341,6 +341,17 @@ class CdmEngine {
|
||||
// Protect release_key_sets_ from non-thread-safe operations.
|
||||
Lock release_key_sets_lock_;
|
||||
|
||||
// TODO(rfrias): Replace with two sets of locks, one to protect
|
||||
// the CdmSessionMap and a per-session lock to control access to
|
||||
// session usage/destruction.
|
||||
// Locks the session map |session_map_| and session usage/destruction
|
||||
// between session management calls (OpenSession, CloseSession, etc),
|
||||
// periodic timer calls (OnTimerEvent), and calls to Decrypt.
|
||||
// The layer above the CDM implementation is expected to handle thread
|
||||
// synchronization to make sure other functions that access sessions do not
|
||||
// occur simultaneously with OpenSession or CloseSession.
|
||||
Lock session_map_lock_;
|
||||
|
||||
CORE_DISALLOW_COPY_AND_ASSIGN(CdmEngine);
|
||||
};
|
||||
|
||||
|
||||
@@ -10,8 +10,8 @@
|
||||
#include <vector>
|
||||
|
||||
#include "crypto_session.h"
|
||||
#include "disallow_copy_and_assign.h"
|
||||
#include "device_files.h"
|
||||
#include "disallow_copy_and_assign.h"
|
||||
#include "file_store.h"
|
||||
#include "initialization_data.h"
|
||||
#include "license.h"
|
||||
@@ -60,7 +60,7 @@ class CdmSession {
|
||||
WvCdmEventListener* event_listener);
|
||||
|
||||
virtual CdmResponseType RestoreOfflineSession(
|
||||
const CdmKeySetId& key_set_id, const CdmLicenseType license_type);
|
||||
const CdmKeySetId& key_set_id, CdmLicenseType license_type);
|
||||
virtual CdmResponseType RestoreUsageSession(
|
||||
const DeviceFiles::CdmUsageData& usage_data);
|
||||
|
||||
|
||||
@@ -19,11 +19,18 @@ namespace wvcdm {
|
||||
|
||||
typedef std::list<shared_ptr<CdmSession> > CdmSessionList;
|
||||
|
||||
// TODO(rfrias): Concurrency protection for this class has moved to CdmEngine.
|
||||
// Add it back when locks to control access to session usage and destruction
|
||||
// are introduced.
|
||||
class CdmSessionMap {
|
||||
public:
|
||||
CdmSessionMap() {}
|
||||
virtual ~CdmSessionMap();
|
||||
|
||||
// Use |Terminate| rather than relying on the destructor to release
|
||||
// resources, as it can be protected by locks.
|
||||
void Terminate();
|
||||
|
||||
void Add(const std::string& id, CdmSession* session);
|
||||
|
||||
bool CloseSession(const std::string& id);
|
||||
@@ -44,7 +51,6 @@ class CdmSessionMap {
|
||||
bool FindSessionNoLock(const CdmSessionId& session_id,
|
||||
shared_ptr<CdmSession>* session);
|
||||
|
||||
Lock lock_;
|
||||
CdmIdToSessionMap sessions_;
|
||||
|
||||
CORE_DISALLOW_COPY_AND_ASSIGN(CdmSessionMap);
|
||||
|
||||
@@ -26,7 +26,7 @@ class ServiceCertificate;
|
||||
class CertificateProvisioning {
|
||||
public:
|
||||
CertificateProvisioning(metrics::CryptoMetrics* metrics) :
|
||||
crypto_session_(metrics),
|
||||
crypto_session_(CryptoSession::MakeCryptoSession(metrics)),
|
||||
cert_type_(kCertificateWidevine),
|
||||
service_certificate_(new ServiceCertificate()) {}
|
||||
~CertificateProvisioning() {}
|
||||
@@ -53,7 +53,7 @@ class CertificateProvisioning {
|
||||
video_widevine::SignedProvisioningMessage::ProtocolVersion
|
||||
GetProtocolVersion();
|
||||
|
||||
CryptoSession crypto_session_;
|
||||
scoped_ptr<CryptoSession> crypto_session_;
|
||||
CdmCertificateType cert_type_;
|
||||
scoped_ptr<ServiceCertificate> service_certificate_;
|
||||
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
// source code may only be used and distributed under the Widevine Master
|
||||
// License Agreement.
|
||||
|
||||
#ifndef WVCDM_CORE_CONTENT_KEY_SESSSION_H_
|
||||
#define WVCDM_CORE_CONTENT_KEY_SESSSION_H_
|
||||
#ifndef WVCDM_CORE_CONTENT_KEY_SESSION_H_
|
||||
#define WVCDM_CORE_CONTENT_KEY_SESSION_H_
|
||||
|
||||
#include "key_session.h"
|
||||
#include "metrics_collections.h"
|
||||
@@ -73,4 +73,4 @@ class ContentKeySession : public KeySession {
|
||||
|
||||
} // namespace wvcdm
|
||||
|
||||
#endif // WVCDM_CORE_CONTENT_KEY_SESSSION_H_
|
||||
#endif // WVCDM_CORE_CONTENT_KEY_SESSION_H_
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
// source code may only be used and distributed under the Widevine Master
|
||||
// License Agreement.
|
||||
|
||||
#ifndef WVCDM_CORE_CRYPTO_SESSSION_H_
|
||||
#define WVCDM_CORE_CRYPTO_SESSSION_H_
|
||||
#ifndef WVCDM_CORE_CRYPTO_SESSION_H_
|
||||
#define WVCDM_CORE_CRYPTO_SESSION_H_
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
@@ -34,6 +34,8 @@ void GenerateEncryptContext(const std::string& input_context,
|
||||
size_t GetOffset(std::string message, std::string field);
|
||||
OEMCryptoCipherMode ToOEMCryptoCipherMode(CdmCipherMode cipher_mode);
|
||||
|
||||
class CryptoSessionFactory;
|
||||
|
||||
class CryptoSession {
|
||||
public:
|
||||
typedef OEMCrypto_HDCP_Capability HdcpCapability;
|
||||
@@ -52,7 +54,9 @@ class CryptoSession {
|
||||
// Creates an instance of CryptoSession with the given |crypto_metrics|.
|
||||
// |crypto_metrics| is owned by the caller, must NOT be null, and must
|
||||
// exist as long as the new CryptoSession exists.
|
||||
explicit CryptoSession(metrics::CryptoMetrics* crypto_metrics);
|
||||
static CryptoSession* MakeCryptoSession(
|
||||
metrics::CryptoMetrics* crypto_metrics);
|
||||
|
||||
virtual ~CryptoSession();
|
||||
|
||||
virtual bool GetProvisioningToken(std::string* client_token);
|
||||
@@ -203,8 +207,26 @@ class CryptoSession {
|
||||
SecurityLevel requested_security_level,
|
||||
CdmClientTokenType* token_type);
|
||||
|
||||
protected:
|
||||
// Creates an instance of CryptoSession with the given |crypto_metrics|.
|
||||
// |crypto_metrics| is owned by the caller, must NOT be null, and must
|
||||
// exist as long as the new CryptoSession exists.
|
||||
explicit CryptoSession(metrics::CryptoMetrics* crypto_metrics);
|
||||
|
||||
int session_count() { return session_count_; }
|
||||
|
||||
private:
|
||||
friend class CryptoSessionForTest;
|
||||
friend class CryptoSessionFactory;
|
||||
friend class WvCdmTestBase;
|
||||
|
||||
// The global factory method can be set to generate special crypto sessions
|
||||
// just for testing. These sessions will avoid nonce floods and will ask
|
||||
// OEMCrypto to use a test keybox.
|
||||
// Ownership of the object is transfered to CryptoSession.
|
||||
static void SetCryptoSessionFactory(CryptoSessionFactory* factory) {
|
||||
factory_.reset(factory);
|
||||
}
|
||||
|
||||
void Init();
|
||||
void Terminate();
|
||||
@@ -291,9 +313,25 @@ class CryptoSession {
|
||||
CdmCipherMode cipher_mode_;
|
||||
uint32_t api_version_;
|
||||
|
||||
static scoped_ptr<CryptoSessionFactory> factory_;
|
||||
|
||||
CORE_DISALLOW_COPY_AND_ASSIGN(CryptoSession);
|
||||
};
|
||||
|
||||
class CryptoSessionFactory {
|
||||
public:
|
||||
virtual ~CryptoSessionFactory() {}
|
||||
virtual CryptoSession* MakeCryptoSession(
|
||||
metrics::CryptoMetrics* crypto_metrics);
|
||||
|
||||
protected:
|
||||
friend class CryptoSession;
|
||||
CryptoSessionFactory() {}
|
||||
|
||||
private:
|
||||
CORE_DISALLOW_COPY_AND_ASSIGN(CryptoSessionFactory);
|
||||
};
|
||||
|
||||
} // namespace wvcdm
|
||||
|
||||
#endif // WVCDM_CORE_CRYPTO_SESSSION_H_
|
||||
#endif // WVCDM_CORE_CRYPTO_SESSION_H_
|
||||
|
||||
@@ -130,6 +130,8 @@ class DeviceFiles {
|
||||
const std::string& usage_info_file_name,
|
||||
std::vector<std::string>* provider_session_tokens);
|
||||
|
||||
virtual bool DeleteAllUsageInfo();
|
||||
|
||||
// Retrieve one usage info from the file. Subsequent calls will retrieve
|
||||
// subsequent entries in the table for this app_id.
|
||||
virtual bool RetrieveUsageInfo(
|
||||
@@ -187,6 +189,8 @@ class DeviceFiles {
|
||||
CdmUsageTableHeader* usage_table_header,
|
||||
std::vector<CdmUsageEntryInfo>* usage_entry_info);
|
||||
|
||||
virtual bool DeleteUsageTableInfo();
|
||||
|
||||
private:
|
||||
// Extract serial number and system ID from DRM Device certificate
|
||||
bool ExtractDeviceInfo(const std::string& device_certificate,
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
// source code may only be used and distributed under the Widevine Master
|
||||
// License Agreement.
|
||||
|
||||
#ifndef WVCDM_CORE_ENTITLEMENT_KEY_SESSSION_H_
|
||||
#define WVCDM_CORE_ENTITLEMENT_KEY_SESSSION_H_
|
||||
#ifndef WVCDM_CORE_ENTITLEMENT_KEY_SESSION_H_
|
||||
#define WVCDM_CORE_ENTITLEMENT_KEY_SESSION_H_
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
@@ -50,4 +50,4 @@ class EntitlementKeySession : public ContentKeySession {
|
||||
|
||||
} // namespace wvcdm
|
||||
|
||||
#endif // WVCDM_CORE_ENTITLEMENT_KEY_SESSSION_H_
|
||||
#endif // WVCDM_CORE_ENTITLEMENT_KEY_SESSION_H_
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
// source code may only be used and distributed under the Widevine Master
|
||||
// License Agreement.
|
||||
|
||||
#ifndef WVCDM_CORE_KEY_SESSSION_H_
|
||||
#define WVCDM_CORE_KEY_SESSSION_H_
|
||||
#ifndef WVCDM_CORE_KEY_SESSION_H_
|
||||
#define WVCDM_CORE_KEY_SESSION_H_
|
||||
|
||||
#include "metrics_collections.h"
|
||||
|
||||
@@ -47,4 +47,4 @@ typedef std::map<std::string, CryptoSessionId> SubLicenseSessionMap;
|
||||
|
||||
} // namespace wvcdm
|
||||
|
||||
#endif // WVCDM_CORE_KEY_SESSSION_H_
|
||||
#endif // WVCDM_CORE_KEY_SESSION_H_
|
||||
|
||||
@@ -155,7 +155,7 @@ class CdmLicense {
|
||||
CdmLicenseKeyType license_key_type_;
|
||||
RepeatedPtrField<License_KeyContainer> entitlement_keys_;
|
||||
#if defined(UNIT_TEST)
|
||||
friend class CdmLicenseTest;
|
||||
friend class CdmLicenseTestPeer;
|
||||
#endif
|
||||
|
||||
CORE_DISALLOW_COPY_AND_ASSIGN(CdmLicense);
|
||||
|
||||
@@ -24,7 +24,7 @@ class LicenseKeys {
|
||||
LicenseKeys() {}
|
||||
virtual ~LicenseKeys() { Clear(); }
|
||||
|
||||
virtual bool Empty() { return keys_.empty(); }
|
||||
virtual bool Empty() { return key_statuses_.empty(); }
|
||||
|
||||
// Returns true if the key is a content key (not an operator session key)
|
||||
virtual bool IsContentKey(const KeyId& key_id);
|
||||
@@ -75,11 +75,12 @@ class LicenseKeys {
|
||||
void Clear();
|
||||
|
||||
bool is_initialized_;
|
||||
// |keys_| can hold either content key statuses, or entitlement key statuses.
|
||||
std::map<KeyId, LicenseKeyStatus*> keys_;
|
||||
// |key_statuses_| can hold either content key statuses, or entitlement key
|
||||
// statuses.
|
||||
std::map<KeyId, LicenseKeyStatus*> key_statuses_;
|
||||
// |content_keyid_to_entitlement_key_id_| maps a content key id to an
|
||||
// entitlement_key_id. The resulting key id can be used to obtain the current
|
||||
// key status from |keys_| when using entitlement key licensing.
|
||||
// key status from |key_statuses_| when using entitlement key licensing.
|
||||
std::map<KeyId, KeyId> content_keyid_to_entitlement_key_id_;
|
||||
|
||||
CORE_DISALLOW_COPY_AND_ASSIGN(LicenseKeys);
|
||||
|
||||
@@ -20,7 +20,7 @@ OEMCryptoResult OEMCrypto_CopyBuffer(
|
||||
OEMCryptoResult OEMCrypto_InstallKeybox(const uint8_t* keybox,
|
||||
size_t keyBoxLength,
|
||||
SecurityLevel level);
|
||||
OEMCryptoResult OEMCrypto_IsKeyboxValid(SecurityLevel level);
|
||||
OEMCryptoResult OEMCrypto_IsKeyboxOrOEMCertValid(SecurityLevel level);
|
||||
OEMCryptoResult OEMCrypto_GetDeviceID(uint8_t* deviceID, size_t* idLength,
|
||||
SecurityLevel level);
|
||||
OEMCryptoResult OEMCrypto_GetKeyData(uint8_t* keyData, size_t* keyDataLength,
|
||||
|
||||
@@ -45,7 +45,8 @@ class PolicyEngine {
|
||||
|
||||
// Verifies whether the policy allows use of the specified key of
|
||||
// a given security level for content decryption.
|
||||
virtual bool CanUseKey(const KeyId& key_id, CdmSecurityLevel security_level);
|
||||
virtual bool CanUseKeyForSecurityLevel(const KeyId& key_id,
|
||||
CdmSecurityLevel security_level);
|
||||
|
||||
// OnTimerEvent is called when a timer fires. It notifies the Policy Engine
|
||||
// that the timer has fired and dispatches the relevant events through
|
||||
|
||||
@@ -31,6 +31,10 @@ typedef std::map<CdmSessionId, CdmClientPropertySet*>
|
||||
// Setter methods are provided but their only planned use is for testing.
|
||||
class Properties {
|
||||
public:
|
||||
// Called at least once before any properties are used. Depending on the
|
||||
// platform, this function may be called multiple times. It is called each
|
||||
// time a CdmEngine is created, and when running unit tests it is called in
|
||||
// many tests' SetUp function.
|
||||
static void Init();
|
||||
|
||||
static inline bool oem_crypto_use_secure_buffers() {
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
#include "disallow_copy_and_assign.h"
|
||||
#include "license_protocol.pb.h"
|
||||
#include "privacy_crypto.h"
|
||||
#include "scoped_ptr.h"
|
||||
#include "wv_cdm_types.h"
|
||||
|
||||
namespace wvcdm {
|
||||
@@ -78,7 +79,7 @@ class ServiceCertificate {
|
||||
std::string provider_id_;
|
||||
|
||||
// Public key.
|
||||
std::auto_ptr<RsaPublicKey> public_key_;
|
||||
scoped_ptr<RsaPublicKey> public_key_;
|
||||
|
||||
CORE_DISALLOW_COPY_AND_ASSIGN(ServiceCertificate);
|
||||
};
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#ifndef WVCDM_CORE_SUBLICENSE_KEY_SESSSION_H_
|
||||
#define WVCDM_CORE_SUBLICENSE_KEY_SESSSION_H_
|
||||
#ifndef WVCDM_CORE_SUBLICENSE_KEY_SESSION_H_
|
||||
#define WVCDM_CORE_SUBLICENSE_KEY_SESSION_H_
|
||||
|
||||
#include "crypto_key.h"
|
||||
#include "key_session.h"
|
||||
@@ -92,4 +92,4 @@ class SubLicenseKeySession : public KeySession {
|
||||
|
||||
} // namespace wvcdm
|
||||
|
||||
#endif // WVCDM_CORE_SUBLICENSE_KEY_SESSSION_H_
|
||||
#endif // WVCDM_CORE_SUBLICENSE_KEY_SESSION_H_
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "crypto_session.h"
|
||||
#include "device_files.h"
|
||||
#include "disallow_copy_and_assign.h"
|
||||
#include "file_store.h"
|
||||
@@ -18,8 +19,6 @@
|
||||
|
||||
namespace wvcdm {
|
||||
|
||||
class CryptoSession;
|
||||
|
||||
// Offline licenses/secure stops may be securely tracked using usage
|
||||
// tables (OEMCrypto v9-12) or usage table headers+usage entries
|
||||
// (OEMCrypto v13+). This class assists with the latter, synchronizing
|
||||
@@ -118,6 +117,8 @@ class UsageTableHeader {
|
||||
// data-structures
|
||||
Lock usage_table_header_lock_;
|
||||
|
||||
metrics::CryptoMetrics alternate_crypto_metrics_;
|
||||
|
||||
// Test related declarations
|
||||
friend class UsageTableHeaderTest;
|
||||
|
||||
|
||||
@@ -12,7 +12,8 @@ static const size_t KEY_CONTROL_SIZE = 16;
|
||||
static const size_t KEY_ID_SIZE = 16;
|
||||
static const size_t KEY_IV_SIZE = 16;
|
||||
static const size_t KEY_PAD_SIZE = 16;
|
||||
static const size_t KEY_SIZE = 16;
|
||||
static const size_t CONTENT_KEY_SIZE = 16;
|
||||
static const size_t SERVICE_KEY_SIZE = 16;
|
||||
static const size_t MAC_KEY_SIZE = 32;
|
||||
static const size_t KEYBOX_KEY_DATA_SIZE = 72;
|
||||
static const size_t SRM_REQUIREMENT_SIZE = 12;
|
||||
|
||||
@@ -126,7 +126,7 @@ enum CdmResponseType {
|
||||
INVALID_SESSION_ID = 83,
|
||||
KEY_REQUEST_ERROR_1 = 84,
|
||||
/* previously KEY_REQUEST_ERROR_2 = 85 */
|
||||
KEY_SIZE_ERROR = 86,
|
||||
KEY_SIZE_ERROR_1 = 86,
|
||||
KEYSET_ID_NOT_FOUND_1 = 87,
|
||||
KEYSET_ID_NOT_FOUND_2 = 88,
|
||||
KEYSET_ID_NOT_FOUND_3 = 89,
|
||||
@@ -333,9 +333,11 @@ enum CdmResponseType {
|
||||
GET_PROVISIONING_METHOD_ERROR = 289,
|
||||
SESSION_NOT_FOUND_17 = 290,
|
||||
SESSION_NOT_FOUND_18 = 291,
|
||||
/* Error code 292 can be reused as it was never present in a release */
|
||||
NO_CONTENT_KEY_3 = 292,
|
||||
DEVICE_CANNOT_REPROVISION = 293,
|
||||
SESSION_NOT_FOUND_19 = 294,
|
||||
KEY_SIZE_ERROR_2 = 295,
|
||||
// Don't forget to add new values to ../test/test_printers.cpp.
|
||||
};
|
||||
|
||||
enum CdmKeyStatus {
|
||||
|
||||
Reference in New Issue
Block a user