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:
Fred Gylys-Colwell
2017-04-14 13:47:02 -07:00
parent 86db60d097
commit ab0d00b92a
8 changed files with 215 additions and 349 deletions

View File

@@ -2,72 +2,33 @@
//
// Mock implementation of OEMCrypto APIs
//
// This file contains oemcrypto engine properties that would be for a
// level 2 device that does not have persistant storage or a keybox.
// Note: this is for illustration only. Production devices are rarely level 2.
// This file contains oemcrypto engine properties that would be for a device
// that does not have persistant storage or a keybox.
//
// Note: We also define it to be L2 for illustration only. Production devices
// are rarely level 2.
#include "oemcrypto_engine_mock.h"
namespace wvoec_mock {
// If config_local_display_only() returns true, we pretend we are using a
// built-in display, instead of HDMI or WiFi output.
bool CryptoEngine::config_local_display_only() {
return true;
}
class CertOnlyCryptoEngine : public CryptoEngine {
public:
explicit CertOnlyCryptoEngine(wvcdm::FileSystem* file_system)
: CryptoEngine(file_system) {}
// A closed platform is permitted to use clear buffers.
bool CryptoEngine::config_closed_platform() {
return false;
}
bool config_local_display_only() { return true; }
// Returns the HDCP version currently in use.
OEMCrypto_HDCP_Capability CryptoEngine::config_current_hdcp_capability() {
return config_local_display_only() ? HDCP_NO_DIGITAL_OUTPUT : HDCP_V1;
}
bool config_supports_usage_table() { return false; }
// Returns the max HDCP version supported.
OEMCrypto_HDCP_Capability CryptoEngine::config_maximum_hdcp_capability() {
return HDCP_NO_DIGITAL_OUTPUT;
}
OEMCrypto_ProvisioningMethod config_provisioning_method() {
return OEMCrypto_DrmCertificate;
}
// Returns true if the client supports persistent storage of
// offline usage table information.
bool CryptoEngine::config_supports_usage_table() {
return false;
}
const char* config_security_level() { return "L2"; }
};
// Returns true if the client uses a keybox as the root of trust.
bool CryptoEngine::config_supports_keybox() {
return false;
}
// This version uses a baked in DRM certificate.
OEMCrypto_ProvisioningMethod CryptoEngine::config_provisioning_method() {
return OEMCrypto_DrmCertificate;
}
OEMCryptoResult CryptoEngine::get_oem_certificate(SessionContext *session,
uint8_t *public_cert,
size_t *public_cert_length) {
return OEMCrypto_ERROR_NOT_IMPLEMENTED;
}
// Returns true to indicate the client does support anti-rollback hardware.
bool CryptoEngine::config_is_anti_rollback_hw_present() {
return false;
}
// Returns "L3" for a software only library. L1 is for hardware protected keys
// and data paths. L2 is for hardware protected keys but no data path
// protection.
const char* CryptoEngine::config_security_level() {
return "L2";
}
// This should start at 0, and be incremented only when a security patch has
// been applied to the device that fixes a security bug.
uint8_t CryptoEngine::config_security_patch_level() {
return 0;
CryptoEngine* CryptoEngine::MakeCryptoEngine(wvcdm::FileSystem* file_system) {
return new CertOnlyCryptoEngine(file_system);
}
} // namespace wvoec_mock