* Update unit test make files to use BoringSSL [ Merge of http://go/wvgerrit/14173 ] This CL updates the android makefiles to use the libcrypto_static. * Do Not Run Provisioning Tests On Devices Without Keyboxes [ Merge of http://go/wvgerrit/15633 ] The provisioning tests outside OEMCrypto were failing on devices that use baked-in certificates because only OEMCrypto knows that the cert is baked in and the device cannot be reprovisioned. This change skips those two tests if the device says it does not implement rewrapping the cert. (i.e. it does not implement provisioning) Bug: 23554998 * Add new third-party libs (protobuf & gyp) [ Merge of http://go/wvgerrit/14717 ] The CE CDM used to expect these to be installed system-wide, which creates challenges for integrators who must cross-compile the CDM. These are now used in source form from third_party. Change-Id: I29cca2f9415fe2fafdf948273e5a0f5d7de50285
159 lines
6.5 KiB
C++
159 lines
6.5 KiB
C++
// Copyright 2013 Google Inc. All Rights Reserved.
|
|
//
|
|
#ifndef WVCDM_CORE_DEVICE_FILES_H_
|
|
#define WVCDM_CORE_DEVICE_FILES_H_
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <set>
|
|
#include <string>
|
|
|
|
#include "scoped_ptr.h"
|
|
#include "wv_cdm_types.h"
|
|
|
|
#if defined(UNIT_TEST)
|
|
#include <gtest/gtest_prod.h>
|
|
#endif
|
|
|
|
namespace wvcdm {
|
|
|
|
class File;
|
|
|
|
class DeviceFiles {
|
|
public:
|
|
typedef enum {
|
|
kLicenseStateActive,
|
|
kLicenseStateReleasing,
|
|
kLicenseStateUnknown,
|
|
} LicenseState;
|
|
|
|
DeviceFiles();
|
|
virtual ~DeviceFiles();
|
|
|
|
virtual bool Init(CdmSecurityLevel security_level);
|
|
virtual bool Reset(CdmSecurityLevel security_level) {
|
|
return Init(security_level);
|
|
}
|
|
|
|
virtual bool StoreCertificate(const std::string& origin,
|
|
const std::string& certificate,
|
|
const std::string& wrapped_private_key);
|
|
virtual bool RetrieveCertificate(const std::string& origin,
|
|
std::string* certificate,
|
|
std::string* wrapped_private_key);
|
|
virtual bool HasCertificate(const std::string& origin);
|
|
virtual bool RemoveCertificate(const std::string& origin);
|
|
|
|
virtual bool StoreLicense(const std::string& key_set_id,
|
|
const LicenseState state,
|
|
const CdmInitData& pssh_data,
|
|
const CdmKeyMessage& key_request,
|
|
const CdmKeyResponse& key_response,
|
|
const CdmKeyMessage& key_renewal_request,
|
|
const CdmKeyResponse& key_renewal_response,
|
|
const std::string& release_server_url,
|
|
int64_t playback_start_time,
|
|
int64_t last_playback_time,
|
|
const CdmAppParameterMap& app_parameters);
|
|
virtual bool RetrieveLicense(
|
|
const std::string& key_set_id, LicenseState* state,
|
|
CdmInitData* pssh_data, CdmKeyMessage* key_request,
|
|
CdmKeyResponse* key_response, CdmKeyMessage* key_renewal_request,
|
|
CdmKeyResponse* key_renewal_response, std::string* release_server_url,
|
|
int64_t* playback_start_time, int64_t* last_playback_time,
|
|
CdmAppParameterMap* app_parameters);
|
|
virtual bool DeleteLicense(const std::string& key_set_id);
|
|
virtual bool DeleteAllFiles();
|
|
virtual bool DeleteAllLicenses();
|
|
virtual bool LicenseExists(const std::string& key_set_id);
|
|
virtual bool ReserveLicenseId(const std::string& key_set_id);
|
|
|
|
virtual bool StoreUsageInfo(const std::string& provider_session_token,
|
|
const CdmKeyMessage& key_request,
|
|
const CdmKeyResponse& key_response,
|
|
const std::string& app_id);
|
|
virtual bool DeleteUsageInfo(const std::string& app_id,
|
|
const std::string& provider_session_token);
|
|
// Delete usage information from the file system. Puts a list of all the
|
|
// psts that were deleted from the file into |provider_session_tokens|.
|
|
virtual bool DeleteAllUsageInfoForApp(
|
|
const std::string& app_id,
|
|
std::vector<std::string>* provider_session_tokens);
|
|
// Retrieve one usage info from the file. Subsequent calls will retrieve
|
|
// subsequent entries in the table for this app_id.
|
|
virtual bool RetrieveUsageInfo(
|
|
const std::string& app_id,
|
|
std::vector<std::pair<CdmKeyMessage, CdmKeyResponse> >* usage_info);
|
|
// Retrieve the usage info entry specified by |provider_session_token|.
|
|
// Returns false if the entry could not be found.
|
|
virtual bool RetrieveUsageInfo(const std::string& app_id,
|
|
const std::string& provider_session_token,
|
|
CdmKeyMessage* license_request,
|
|
CdmKeyResponse* license_response);
|
|
|
|
private:
|
|
// Helpers that wrap the File interface and automatically handle hashing, as
|
|
// well as adding the device files base path to to the file name.
|
|
bool StoreFileWithHash(const std::string& name,
|
|
const std::string& serialized_file);
|
|
bool StoreFileRaw(const std::string& name,
|
|
const std::string& serialized_file);
|
|
bool RetrieveHashedFile(const std::string& name,
|
|
std::string* serialized_file);
|
|
bool FileExists(const std::string& name);
|
|
bool RemoveFile(const std::string& name);
|
|
ssize_t GetFileSize(const std::string& name);
|
|
|
|
// Certificate and offline licenses are now stored in security
|
|
// level specific directories. In an earlier version they were
|
|
// stored in a common directory and need to be copied over.
|
|
virtual void SecurityLevelPathBackwardCompatibility();
|
|
|
|
static std::string GetCertificateFileName(const std::string& origin);
|
|
static std::string GetLicenseFileNameExtension();
|
|
static std::string GetUsageInfoFileName(const std::string& app_id);
|
|
static std::string GetFileNameSafeHash(const std::string& input);
|
|
|
|
// For testing only:
|
|
void SetTestFile(File* file);
|
|
#if defined(UNIT_TEST)
|
|
FRIEND_TEST(DeviceFilesSecurityLevelTest, SecurityLevel);
|
|
FRIEND_TEST(DeviceCertificateStoreTest, StoreCertificate);
|
|
FRIEND_TEST(DeviceCertificateTest, ReadCertificate);
|
|
FRIEND_TEST(DeviceCertificateTest, HasCertificate);
|
|
FRIEND_TEST(DeviceFilesStoreTest, StoreLicense);
|
|
FRIEND_TEST(DeviceFilesTest, DeleteLicense);
|
|
FRIEND_TEST(DeviceFilesTest, ReserveLicenseIdsDoesNotUseFileSystem);
|
|
FRIEND_TEST(DeviceFilesTest, RetrieveLicenses);
|
|
FRIEND_TEST(DeviceFilesTest, AppParametersBackwardCompatibility);
|
|
FRIEND_TEST(DeviceFilesTest, SecurityLevelPathBackwardCompatibility);
|
|
FRIEND_TEST(DeviceFilesTest, StoreLicenses);
|
|
FRIEND_TEST(DeviceFilesTest, UpdateLicenseState);
|
|
FRIEND_TEST(DeviceFilesUsageInfoTest, Delete);
|
|
FRIEND_TEST(DeviceFilesUsageInfoTest, DeleteAll);
|
|
FRIEND_TEST(DeviceFilesUsageInfoTest, Read);
|
|
FRIEND_TEST(DeviceFilesUsageInfoTest, Store);
|
|
FRIEND_TEST(WvCdmRequestLicenseTest, UnprovisionTest);
|
|
FRIEND_TEST(WvCdmRequestLicenseTest, ForceL3Test);
|
|
FRIEND_TEST(WvCdmRequestLicenseTest, UsageInfoRetryTest);
|
|
FRIEND_TEST(WvCdmRequestLicenseTest, UsageReleaseAllTest);
|
|
FRIEND_TEST(WvCdmUsageInfoTest, UsageInfo);
|
|
FRIEND_TEST(WvCdmUsageTest, WithClientId);
|
|
FRIEND_TEST(WvCdmExtendedDurationTest, UsageOverflowTest);
|
|
#endif
|
|
|
|
static std::set<std::string> reserved_license_ids_;
|
|
|
|
scoped_ptr<File> file_;
|
|
CdmSecurityLevel security_level_;
|
|
bool initialized_;
|
|
|
|
bool test_file_;
|
|
|
|
CORE_DISALLOW_COPY_AND_ASSIGN(DeviceFiles);
|
|
};
|
|
|
|
} // namespace wvcdm
|
|
|
|
#endif // WVCDM_CORE_DEVICE_FILES_H_
|