(This is a merge of go/wvgerrit/23182)

This patch adds the framework for Stable Per-Origin Identifiers to the
CDM. Calculating SPOIDs will be done on the client-side, and they are
sent as part of the provisioning request. SPOIDs are also available to
the app as the Device Unique ID, replacing the previous method of
returning the actual Device Unique ID from the keybox / OEM certificate.

Different SPOIDs must use separate storage, just as different origins
already do. Support for this has been added to the Android adapter to the
CDM Core. However, the code in the Android glue layer that would drive
this behavior will be checked in in a separate change. As such, all
Android devices will continue using the legacy behavior even after this
patch goes in, until the glue layer code can be updated.

Bug: 27101531
Test: CE CDM Unit Tests
Test: Linux Jenkins Unit Tests
Test: Android Unit Tests (with and without SPOIDs forced on)
Test: Android GTS Tests
Change-Id: Ia0caf890381cbcb97504d08b19aeab8b29bd07ae
This commit is contained in:
John W. Bruce
2017-01-25 14:35:50 -08:00
parent 5249221e3a
commit c85351682f
18 changed files with 511 additions and 290 deletions

View File

@@ -0,0 +1,64 @@
// Copyright 2016 Google Inc. All Rights Reserved.
//
// CdmIdentifier - Struct that holds all the information necessary to
// uniquely identify a CdmEngine instance in the
// WvContentDecryptionModule multiplexing layer.
#ifndef CDM_BASE_CDM_IDENTIFIER_H_
#define CDM_BASE_CDM_IDENTIFIER_H_
#include <string>
#include "wv_cdm_constants.h"
namespace wvcdm {
// CdmIdentifier contains all the information necessary to uniquely identify a
// distinct CdmEngine instance on Android. There should be a unique CdmEngine
// (and thus distinct storage space) for every combination of SPOID and origin.
struct CdmIdentifier {
// The Stable Per-Origin Identifier, or SPOID. May be blank on old, SPOID-less
// systems, in which case multiple apps with the same origin will share a
// CdmEngine and storage.
std::string spoid;
// The origin. May be blank if the app does not set an origin, which is
// the likely behavior of most non-web-browser apps.
std::string origin;
};
// Provide comparison operators
inline bool operator==(const CdmIdentifier& lhs, const CdmIdentifier& rhs) {
return lhs.spoid == rhs.spoid && lhs.origin == rhs.origin;
}
inline bool operator!=(const CdmIdentifier& lhs, const CdmIdentifier& rhs) {
return !(lhs == rhs);
}
inline bool operator<(const CdmIdentifier& lhs, const CdmIdentifier& rhs) {
return (lhs.spoid < rhs.spoid) ||
((lhs.spoid == rhs.spoid) && lhs.origin < rhs.origin);
}
inline bool operator>(const CdmIdentifier& lhs, const CdmIdentifier& rhs) {
return rhs < lhs;
}
inline bool operator<=(const CdmIdentifier& lhs, const CdmIdentifier& rhs) {
return !(lhs > rhs);
}
inline bool operator>=(const CdmIdentifier& lhs, const CdmIdentifier& rhs) {
return !(lhs < rhs);
}
// Provide default
static const CdmIdentifier kDefaultCdmIdentifier = {
EMPTY_SPOID,
EMPTY_ORIGIN
};
} // namespace wvcdm
#endif // CDM_BASE_CDM_IDENTIFIER_H_

View File

@@ -8,6 +8,7 @@
#include <UniquePtr.h>
#include <utils/RefBase.h>
#include "cdm_identifier.h"
#include "file_store.h"
#include "lock.h"
#include "timer.h"
@@ -33,7 +34,7 @@ class WvContentDecryptionModule : public android::RefBase, public TimerHandler {
// Session related methods
virtual CdmResponseType OpenSession(const CdmKeySystem& key_system,
CdmClientPropertySet* property_set,
const std::string& origin,
const CdmIdentifier& identifier,
WvCdmEventListener* event_listener,
CdmSessionId* session_id);
virtual CdmResponseType CloseSession(const CdmSessionId& session_id);
@@ -47,7 +48,7 @@ class WvContentDecryptionModule : public android::RefBase, public TimerHandler {
const CdmLicenseType license_type,
CdmAppParameterMap& app_parameters,
CdmClientPropertySet* property_set,
const std::string& origin,
const CdmIdentifier& identifier,
CdmKeyRequest* key_request);
// Accept license response and extract key info.
@@ -82,18 +83,18 @@ class WvContentDecryptionModule : public android::RefBase, public TimerHandler {
virtual CdmResponseType GetProvisioningRequest(
CdmCertificateType cert_type,
const std::string& cert_authority,
const std::string& origin,
const CdmIdentifier& identifier,
CdmProvisioningRequest* request,
std::string* default_url);
virtual CdmResponseType HandleProvisioningResponse(
const std::string& origin,
const CdmIdentifier& identifier,
CdmProvisioningResponse& response,
std::string* cert,
std::string* wrapped_key);
virtual CdmResponseType Unprovision(CdmSecurityLevel level,
const std::string& origin);
const CdmIdentifier& identifier);
// Secure stop related methods
virtual CdmResponseType GetUsageInfo(const std::string& app_id,
@@ -128,8 +129,9 @@ class WvContentDecryptionModule : public android::RefBase, public TimerHandler {
UniquePtr<CdmEngine> cdm_engine;
};
// Finds the CdmEngine instance for the given origin, creating one if needed.
CdmEngine* EnsureCdmForOrigin(const std::string& origin);
// Finds the CdmEngine instance for the given identifier, creating one if
// needed.
CdmEngine* EnsureCdmForIdentifier(const CdmIdentifier& identifier);
// Finds the CdmEngine instance for the given session id, returning NULL if
// not found.
CdmEngine* GetCdmForSessionId(const std::string& session_id);
@@ -147,7 +149,7 @@ class WvContentDecryptionModule : public android::RefBase, public TimerHandler {
// instance variables
// This manages the lifetime of the CDM instances.
std::map<std::string, CdmInfo> cdms_;
std::map<CdmIdentifier, CdmInfo> cdms_;
Lock cdms_lock_;
// This contains weak pointers to the CDM instances contained in |cdms_|.