(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

@@ -16,6 +16,7 @@
#include "file_utils.h"
#include "log.h"
#include "string_conversions.h"
#include "wv_cdm_constants.h"
#include <openssl/md5.h>
#include <openssl/sha.h>
@@ -35,8 +36,8 @@ std::string GetFileNameSafeHash(const std::string& input) {
return wvcdm::Base64SafeEncode(hash);
}
std::string GetFileNameForOrigin(const std::string path,
const std::string origin) {
std::string GetFileNameForIdentifier(const std::string path,
const std::string identifier) {
std::string file_name = path;
std::string dir_path;
const size_t delimiter_pos = path.rfind(kDirectoryDelimiter);
@@ -45,8 +46,8 @@ std::string GetFileNameForOrigin(const std::string path,
file_name = path.substr(delimiter_pos + 1);
}
if (file_name == kCertificateFileName && !origin.empty()) {
const std::string hash = GetFileNameSafeHash(origin);
if (file_name == kCertificateFileName && !identifier.empty()) {
const std::string hash = GetFileNameSafeHash(identifier);
file_name = kCertificateFileNamePrefix + hash + kCertificateFileNameExt;
}
@@ -109,7 +110,7 @@ ssize_t File::Write(const char* buffer, size_t bytes) {
class FileSystem::Impl {};
FileSystem::FileSystem() : FileSystem("", NULL) {}
FileSystem::FileSystem() : FileSystem(EMPTY_ORIGIN, NULL) {}
FileSystem::FileSystem(const std::string& origin, void* /* extra_data */)
: origin_(origin) {
FileUtils::SecurityLevelPathBackwardCompatibility(kSecurityLevelL1);
@@ -121,7 +122,7 @@ FileSystem::~FileSystem() {}
File* FileSystem::Open(const std::string& in_name, int flags) {
std::string open_flags;
std::string name = GetFileNameForOrigin(in_name, origin_);
std::string name = GetFileNameForIdentifier(in_name, identifier_);
// create the enclosing directory if it does not exist
size_t delimiter_pos = name.rfind(kDirectoryDelimiter);
@@ -154,15 +155,15 @@ File* FileSystem::Open(const std::string& in_name, int flags) {
}
bool FileSystem::Exists(const std::string& path) {
return FileUtils::Exists(GetFileNameForOrigin(path, origin_));
return FileUtils::Exists(GetFileNameForIdentifier(path, identifier_));
}
bool FileSystem::Remove(const std::string& path) {
return FileUtils::Remove(GetFileNameForOrigin(path, origin_));
return FileUtils::Remove(GetFileNameForIdentifier(path, identifier_));
}
ssize_t FileSystem::FileSize(const std::string& in_path) {
std::string path = GetFileNameForOrigin(in_path, origin_);
std::string path = GetFileNameForIdentifier(in_path, identifier_);
struct stat buf;
if (stat(path.c_str(), &buf) == 0)
return buf.st_size;
@@ -172,4 +173,8 @@ ssize_t FileSystem::FileSize(const std::string& in_path) {
void FileSystem::SetOrigin(const std::string& origin) { origin_ = origin; }
void FileSystem::SetIdentifier(const std::string& identifier) {
identifier_ = identifier;
}
} // namespace wvcdm