Use Inheritence for OEMCrypto Mock Properties
Merge from Widevine repo of http://go/wvgerrit/24728 We use compiler options to set different properties in the oemcrypto mock. With this CL, we define a base class that has default properties. All other variants need only define the properties that they change. b/35141278 b/37353534 Change-Id: Id38ec5bf35dcd83cea9a066ebe201e6da7c1a2b0
This commit is contained in:
@@ -28,10 +28,14 @@ typedef std::map<SessionId, SessionContext*> ActiveSessions;
|
||||
|
||||
class CryptoEngine {
|
||||
public:
|
||||
CryptoEngine(wvcdm::FileSystem* file_system);
|
||||
~CryptoEngine();
|
||||
// This is like a factory method, except we choose which version to use at
|
||||
// compile time. It is defined in several source files. The build system
|
||||
// should choose which one to use by only linking in the correct one.
|
||||
static CryptoEngine* MakeCryptoEngine(wvcdm::FileSystem* file_system);
|
||||
|
||||
bool Initialized() { return true; }
|
||||
virtual ~CryptoEngine();
|
||||
|
||||
virtual bool Initialize() { return true; }
|
||||
|
||||
bool ValidRootOfTrust() { return root_of_trust_.Validate(); }
|
||||
|
||||
@@ -59,7 +63,7 @@ class CryptoEngine {
|
||||
return root_of_trust_.DeviceToken();
|
||||
}
|
||||
|
||||
void Terminate();
|
||||
virtual void Terminate() {}
|
||||
|
||||
SessionId CreateSession();
|
||||
|
||||
@@ -75,24 +79,60 @@ class CryptoEngine {
|
||||
return kMaxSupportedOEMCryptoSessions;
|
||||
}
|
||||
|
||||
// Configuration constants - controls behavior of this CryptoEngine
|
||||
OEMCrypto_HDCP_Capability config_current_hdcp_capability();
|
||||
OEMCrypto_HDCP_Capability config_maximum_hdcp_capability();
|
||||
// Returns the HDCP version currently in use.
|
||||
virtual OEMCrypto_HDCP_Capability config_current_hdcp_capability();
|
||||
|
||||
// Returns the max HDCP version supported.
|
||||
virtual OEMCrypto_HDCP_Capability config_maximum_hdcp_capability();
|
||||
|
||||
UsageTable& usage_table() { return usage_table_; }
|
||||
wvcdm::FileSystem* file_system() { return file_system_; }
|
||||
|
||||
bool config_local_display_only();
|
||||
bool config_closed_platform();
|
||||
bool config_supports_usage_table();
|
||||
bool config_supports_keybox();
|
||||
OEMCrypto_ProvisioningMethod config_provisioning_method();
|
||||
OEMCryptoResult get_oem_certificate(SessionContext* session,
|
||||
uint8_t* public_cert,
|
||||
size_t* public_cert_length);
|
||||
bool config_is_anti_rollback_hw_present();
|
||||
const char* config_security_level();
|
||||
uint8_t config_security_patch_level();
|
||||
// If config_local_display_only() returns true, we pretend we are using a
|
||||
// built-in display, instead of HDMI or WiFi output.
|
||||
virtual bool config_local_display_only() { return false; }
|
||||
|
||||
// A closed platform is permitted to use clear buffers.
|
||||
virtual bool config_closed_platform() { return false; }
|
||||
|
||||
// Returns true if the client supports persistent storage of
|
||||
// offline usage table information.
|
||||
virtual bool config_supports_usage_table() { return true; }
|
||||
|
||||
virtual OEMCrypto_ProvisioningMethod config_provisioning_method() {
|
||||
return OEMCrypto_Keybox;
|
||||
}
|
||||
|
||||
virtual OEMCryptoResult get_oem_certificate(SessionContext* session,
|
||||
uint8_t* public_cert,
|
||||
size_t* public_cert_length) {
|
||||
return OEMCrypto_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
// Used for OEMCrypto_IsAntiRollbackHwPresent.
|
||||
virtual bool config_is_anti_rollback_hw_present() { return false; }
|
||||
|
||||
// Returns "L3" for a software only library. L1 is for hardware protected
|
||||
// data paths.
|
||||
virtual const char* config_security_level() { return "L3"; }
|
||||
|
||||
// This should start at 0, and be incremented only when a security patch has
|
||||
// been applied to the device that fixes a security bug.
|
||||
virtual uint8_t config_security_patch_level() { return 0; }
|
||||
|
||||
// If 0 no restriction, otherwise it's the max buffer for DecryptCENC.
|
||||
virtual size_t max_buffer_size() { return 1024 * 100; } // 100 KiB.
|
||||
|
||||
// Set destination pointer based on the output destination description.
|
||||
OEMCryptoResult SetDestination(OEMCrypto_DestBufferDesc* out_description,
|
||||
size_t data_length, uint8_t subsample_flags);
|
||||
|
||||
// The current destination.
|
||||
uint8_t* destination() { return destination_; }
|
||||
|
||||
protected:
|
||||
explicit CryptoEngine(wvcdm::FileSystem* file_system);
|
||||
uint8_t* destination_;
|
||||
|
||||
private:
|
||||
ActiveSessions sessions_;
|
||||
|
||||
Reference in New Issue
Block a user