Add Provisioning 4 support
Widevine provisioning 4 support is added in this patch.
This commit is contained in:
@@ -31,6 +31,9 @@ class Properties {
|
||||
// Sets the |device_name| field value to be populated in and EMM license
|
||||
// request. Returns false if unable to set the value.
|
||||
static bool GetDeviceName(std::string* device_name);
|
||||
// Sets the |build_info| field value to be populated in and EMM license
|
||||
// request. Returns false if unable to set the value.
|
||||
static bool GetBuildInfo(std::string* build_info);
|
||||
// Returns a path to CAS oemcrypto library, either default,
|
||||
// or overridden through system property.
|
||||
// Returned path could be either absolute or relative.
|
||||
|
||||
@@ -7,7 +7,8 @@
|
||||
#ifndef WVCDM_UTIL_FILE_STORE_H_
|
||||
#define WVCDM_UTIL_FILE_STORE_H_
|
||||
|
||||
#include <cstdint>
|
||||
#include <stddef.h>
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
@@ -18,16 +19,35 @@
|
||||
|
||||
namespace wvutil {
|
||||
|
||||
// Fixed filename for ATSC DRM certificate pre-installed
|
||||
// on ATSC devices for ATSC licenses.
|
||||
static const std::string kAtscCertificateFileName = "atsccert.bin";
|
||||
// General filename for either global or unmapped app-origin
|
||||
// DRM certificates.
|
||||
static const std::string kCertificateFileName = "cert1.bin";
|
||||
// File extension for DRM and OEM certificate files.
|
||||
static const std::string kCertificateFileNameExt = ".bin";
|
||||
static const std::string kCertificateFileNamePrefix = "cert1_";
|
||||
// Filename prefix for mapped (scoped) DRM certificate filenames
|
||||
// specific to a particular app-origin.
|
||||
static const std::string kScopedCertificateFilenamePrefix = "cert1_";
|
||||
// TODO(b/376533901): Replace this constant with
|
||||
// kScopedCertificateFilenamePrefix in source code..
|
||||
static const std::string kCertificateFileNamePrefix =
|
||||
kScopedCertificateFilenamePrefix;
|
||||
// Legacy general filename for either global or unmapped app-origin
|
||||
// DRM certificates.
|
||||
static const std::string kLegacyCertificateFileName = "cert.bin";
|
||||
static const std::string kLegacyCertificateFileNamePrefix = "cert";
|
||||
// Legacy filename prefix for mapped (scoped) DRM certificate filenames
|
||||
// specific to a particular app-origin.
|
||||
static const std::string kLegacyScopedCertificateFilenamePrefix = "cert";
|
||||
// TODO(b/376533901): Replace this constant with
|
||||
// kLegacyScopedCertificateFilenamePrefix in source code..
|
||||
static const std::string kLegacyCertificateFileNamePrefix =
|
||||
kLegacyScopedCertificateFilenamePrefix;
|
||||
// Filename for global OEM certificates.
|
||||
static const std::string kOemCertificateFileName = "oemcert.bin";
|
||||
static const std::string kOemCertificateFileNamePrefix = "oemcert_";
|
||||
|
||||
// File class. The implementation is platform dependent.
|
||||
// File interface. The implementation is platform dependent.
|
||||
class File {
|
||||
public:
|
||||
File() {}
|
||||
@@ -35,35 +55,70 @@ class File {
|
||||
virtual ssize_t Read(char* buffer, size_t bytes) = 0;
|
||||
virtual ssize_t Write(const char* buffer, size_t bytes) = 0;
|
||||
|
||||
friend class FileSystem;
|
||||
CORE_DISALLOW_COPY_AND_ASSIGN(File);
|
||||
};
|
||||
|
||||
// File system base class. The implementation is platform dependent.
|
||||
class FileSystem {
|
||||
public:
|
||||
FileSystem();
|
||||
FileSystem(const std::string& origin, void* extra_data);
|
||||
virtual ~FileSystem();
|
||||
|
||||
// Concreate implementation of FileSystem.
|
||||
// Depending on the platform, this may be vendor or Widevine implemented.
|
||||
class Impl;
|
||||
|
||||
// defines as bit flag
|
||||
enum OpenFlags {
|
||||
kNoFlags = 0,
|
||||
kCreate = 1,
|
||||
kReadOnly = 2, // defaults to read and write access
|
||||
kTruncate = 4
|
||||
};
|
||||
// Flags for calls to Open.
|
||||
static constexpr int kNoFlags = 0;
|
||||
// Create file if does not already exist, open file if it does exist.
|
||||
static constexpr int kCreate = (1 << 0);
|
||||
// Open file as read-only; typically should not be used with kCreate.
|
||||
static constexpr int kReadOnly = (1 << 1);
|
||||
// Open file and truncated. May be used with kCreate; should not
|
||||
// be used with kReadOnly.
|
||||
static constexpr int kTruncate = (1 << 2);
|
||||
|
||||
virtual std::unique_ptr<File> Open(const std::string& file_path, int flags);
|
||||
|
||||
virtual bool Exists(const std::string& file_path);
|
||||
virtual bool Exists(const std::string& file_path, int* errno_value);
|
||||
virtual bool Remove(const std::string& file_path);
|
||||
// Checks if the |path| exists. The |path| may be a file or directory.
|
||||
// Return true if an entry in the file system exists; false otherwise.
|
||||
virtual bool Exists(const std::string& path);
|
||||
// Same as above, except the optional parameter of |errno_value| should
|
||||
// be set to 0 or the value of C errno when attempting to check
|
||||
// the existence of a file.
|
||||
virtual bool Exists(const std::string& path, int* errno_value);
|
||||
|
||||
// Removes the specified |path|.
|
||||
//
|
||||
// If |path| is a regular file, the file should be removed.
|
||||
// If |path| is a directory, both the directory and the directory
|
||||
// contents should be removed.
|
||||
//
|
||||
// Implementation must support a |path| containing a single wildcard
|
||||
// character in the filename component of the path.
|
||||
//
|
||||
// Return value:
|
||||
// - true : File/directory was removed, or file/directory did not exist
|
||||
// - false : File/directory could not be removed, or other error.
|
||||
virtual bool Remove(const std::string& path);
|
||||
|
||||
// Obtain the size of a file in bytes. |file_path| must be a file,
|
||||
// and not a directory.
|
||||
//
|
||||
// Return value:
|
||||
// - non-negative : size of file in bytes if file exists
|
||||
// - negative : file does not exist, or error occurred.
|
||||
virtual ssize_t FileSize(const std::string& file_path);
|
||||
|
||||
// Return the filenames stored at dir_path.
|
||||
// dir_path will be stripped from the returned names.
|
||||
// Return the entries stored at |dir_path| (includes both files
|
||||
// and directories).
|
||||
//
|
||||
// Return value:
|
||||
// - true : Directory exists, and directory entry names are stored
|
||||
// in |names|; |names| may be empty if directory was empty.
|
||||
// - false : Directory does not exist, |dir_path| is not a directory,
|
||||
// or error was encountered.
|
||||
virtual bool List(const std::string& dir_path,
|
||||
std::vector<std::string>* names);
|
||||
|
||||
|
||||
@@ -13,4 +13,12 @@
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef WEAK
|
||||
# if defined(__GNUC__) || defined(__clang__)
|
||||
# define WEAK __attribute__((weak))
|
||||
# else
|
||||
# define WEAK
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#endif // WVCDM_UTIL_WV_ATTRIBUTES_H_
|
||||
|
||||
@@ -71,6 +71,14 @@ bool Properties::GetProductName(std::string* product_name) {
|
||||
return GetAndroidProperty("ro.product.name", product_name);
|
||||
}
|
||||
|
||||
bool Properties::GetBuildInfo(std::string* build_info) {
|
||||
if (!build_info) {
|
||||
LOGW("Properties::GetBuildInfo: Invalid parameter");
|
||||
return false;
|
||||
}
|
||||
return GetAndroidProperty("ro.build.fingerprint", build_info);
|
||||
}
|
||||
|
||||
bool Properties::GetOEMCryptoPath(std::string* path) {
|
||||
if (path == nullptr) {
|
||||
LOGW("Properties::GetOEMCryptoPath: Invalid parameter");
|
||||
|
||||
@@ -32,12 +32,12 @@ const char kBase64SafeCodes[] =
|
||||
|
||||
// Decodes a single Base64 encoded character into its 6-bit value.
|
||||
// The provided |codes| must be a Base64 character map.
|
||||
int DecodeBase64Char(char c, const char* codes) {
|
||||
int32_t DecodeBase64Char(char c, const char* codes) {
|
||||
const char* c_in_codes = strchr(codes, c);
|
||||
if (c_in_codes == nullptr) return -1;
|
||||
const uintptr_t c_in_codes_int = reinterpret_cast<uintptr_t>(c_in_codes);
|
||||
const uintptr_t codes_int = reinterpret_cast<uintptr_t>(codes);
|
||||
return static_cast<int>(c_in_codes_int - codes_int);
|
||||
return static_cast<int32_t>(c_in_codes_int - codes_int);
|
||||
}
|
||||
|
||||
bool DecodeHexChar(char ch, uint8_t* digit) {
|
||||
@@ -124,7 +124,7 @@ std::vector<uint8_t> Base64DecodeInternal(const char* encoded, size_t length,
|
||||
break;
|
||||
}
|
||||
|
||||
const int decoded = DecodeBase64Char(encoded[i], codes);
|
||||
const int32_t decoded = DecodeBase64Char(encoded[i], codes);
|
||||
if (decoded < 0) {
|
||||
LOGE("base64Decode failed");
|
||||
return std::vector<uint8_t>();
|
||||
@@ -167,8 +167,8 @@ std::vector<uint8_t> a2b_hex(const std::string& byte) {
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < count / 2; ++i) {
|
||||
unsigned char msb = 0; // most significant 4 bits
|
||||
unsigned char lsb = 0; // least significant 4 bits
|
||||
uint8_t msb = 0; // most significant 4 bits
|
||||
uint8_t lsb = 0; // least significant 4 bits
|
||||
if (!DecodeHexChar(byte[i * 2], &msb) ||
|
||||
!DecodeHexChar(byte[i * 2 + 1], &lsb)) {
|
||||
LOGE("Invalid hex value %c%c at index %zu", byte[i * 2], byte[i * 2 + 1],
|
||||
@@ -219,7 +219,7 @@ std::string unlimited_b2a_hex(const std::string& byte) {
|
||||
}
|
||||
|
||||
std::string HexEncode(const uint8_t* in_buffer, size_t size) {
|
||||
constexpr unsigned int kMaxSafeSize = 2048;
|
||||
constexpr size_t kMaxSafeSize = 2048;
|
||||
if (size > kMaxSafeSize) size = kMaxSafeSize;
|
||||
return UnlimitedHexEncode(in_buffer, size);
|
||||
}
|
||||
@@ -229,7 +229,7 @@ std::string UnlimitedHexEncode(const uint8_t* in_buffer, size_t size) {
|
||||
if (size == 0) return "";
|
||||
// Each input byte creates two output hex characters.
|
||||
std::string out_buffer(size * 2, '\0');
|
||||
for (unsigned int i = 0; i < size; ++i) {
|
||||
for (size_t i = 0; i < size; ++i) {
|
||||
char byte = in_buffer[i];
|
||||
out_buffer[(i << 1)] = kHexChars[(byte >> 4) & 0xf];
|
||||
out_buffer[(i << 1) + 1] = kHexChars[byte & 0xf];
|
||||
@@ -331,7 +331,7 @@ int64_t htonll64(int64_t x) {
|
||||
}
|
||||
|
||||
// Encode unsigned integer into a big endian formatted string
|
||||
std::string EncodeUint32(unsigned int u) {
|
||||
std::string EncodeUint32(uint32_t u) {
|
||||
std::string s;
|
||||
s.push_back((u >> 24) & 0xFF);
|
||||
s.push_back((u >> 16) & 0xFF);
|
||||
|
||||
Reference in New Issue
Block a user