diff --git a/libwvdrmengine/oemcrypto/mock/src/oemcrypto_engine_device_properties.cpp b/libwvdrmengine/oemcrypto/mock/src/oemcrypto_engine_device_properties.cpp index 6c99b997..a2707578 100644 --- a/libwvdrmengine/oemcrypto/mock/src/oemcrypto_engine_device_properties.cpp +++ b/libwvdrmengine/oemcrypto/mock/src/oemcrypto_engine_device_properties.cpp @@ -39,4 +39,10 @@ bool CryptoEngine::is_anti_rollback_hw_present() { return false; } +// Returns "L3" for a software only library. L1 is for hardware protected +// data paths. +const char* CryptoEngine::security_level() { + return "L3"; +} + } // namespace wvoec_mock diff --git a/libwvdrmengine/oemcrypto/mock/src/oemcrypto_engine_device_properties_L1.cpp b/libwvdrmengine/oemcrypto/mock/src/oemcrypto_engine_device_properties_L1.cpp new file mode 100644 index 00000000..f68dba88 --- /dev/null +++ b/libwvdrmengine/oemcrypto/mock/src/oemcrypto_engine_device_properties_L1.cpp @@ -0,0 +1,49 @@ +// Copyright 2014 Google Inc. All Rights Reserved. +// +// Mock implementation of OEMCrypto APIs +// +// This file contains oemcrypto engine properties that would be for a +// level 1 device. +#include "oemcrypto_engine_mock.h" + +namespace wvoec_mock { + +// If local_display() returns true, we pretend we are using a built-in display, +// instead of HDMI or WiFi output. +bool CryptoEngine::local_display() { + return true; +} + +// A closed platform is permitted to use clear buffers. +bool CryptoEngine::closed_platform() { + return false; +} + +// Returns the HDCP version currently in use. +OEMCrypto_HDCP_Capability CryptoEngine::current_hdcp_capability() { + return local_display() ? HDCP_NO_DIGITAL_OUTPUT : HDCP_V1; +} + +// Returns the max HDCP version supported. +OEMCrypto_HDCP_Capability CryptoEngine::maximum_hdcp_capability() { + return HDCP_NO_DIGITAL_OUTPUT; +} + +// Returns true if the client supports persistent storage of +// offline usage table information. +bool CryptoEngine::supports_storage() { + return true; +} + +// Returns true to indicate the client does support anti-rollback hardware. +bool CryptoEngine::is_anti_rollback_hw_present() { + return true; +} + +// Returns "L3" for a software only library. L1 is for hardware protected +// data paths. +const char* CryptoEngine::security_level() { + return "L1"; +} + +} // namespace wvoec_mock diff --git a/libwvdrmengine/oemcrypto/mock/src/oemcrypto_engine_mock.h b/libwvdrmengine/oemcrypto/mock/src/oemcrypto_engine_mock.h index d39cba6f..cad08487 100644 --- a/libwvdrmengine/oemcrypto/mock/src/oemcrypto_engine_mock.h +++ b/libwvdrmengine/oemcrypto/mock/src/oemcrypto_engine_mock.h @@ -257,6 +257,7 @@ class CryptoEngine { bool closed_platform(); bool supports_storage(); bool is_anti_rollback_hw_present(); + const char* security_level(); private: SessionContext* current_session_; diff --git a/libwvdrmengine/oemcrypto/mock/src/oemcrypto_mock.cpp b/libwvdrmengine/oemcrypto/mock/src/oemcrypto_mock.cpp index 4edaa21c..935d9398 100644 --- a/libwvdrmengine/oemcrypto/mock/src/oemcrypto_mock.cpp +++ b/libwvdrmengine/oemcrypto/mock/src/oemcrypto_mock.cpp @@ -1001,7 +1001,11 @@ uint32_t OEMCrypto_APIVersion() { extern "C" const char* OEMCrypto_SecurityLevel() { - return "L3"; + const char* security_level = crypto_engine->security_level(); + if (LogCategoryEnabled(kLoggingTraceOEMCryptoCalls)) { + LOGI("-- bool OEMCrypto_SecurityLevel(); // returns %s.\n", security_level); + } + return security_level; } extern "C" diff --git a/libwvdrmengine/oemcrypto/test/oemcrypto_test.cpp b/libwvdrmengine/oemcrypto/test/oemcrypto_test.cpp index 6fa6a4b2..7db9a048 100644 --- a/libwvdrmengine/oemcrypto/test/oemcrypto_test.cpp +++ b/libwvdrmengine/oemcrypto/test/oemcrypto_test.cpp @@ -1593,23 +1593,6 @@ class OEMCryptoClientTest : public ::testing::Test { } }; -TEST_F(OEMCryptoClientTest, AntiRollbackHardwareRequired) { - Session s; - s.open(); - s.GenerateDerivedKeys(); - s.FillSimpleMessage(0, wvoec_mock::kControlRequireAntiRollbackHardware, 0); - s.EncryptAndSign(); - OEMCryptoResult sts = OEMCrypto_LoadKeys( - s.session_id(), s.message_ptr(), sizeof(MessageData), &s.signature()[0], - s.signature().size(), s.encrypted_license().mac_key_iv, - s.encrypted_license().mac_keys, kNumKeys, s.key_array(), NULL, 0); - if (OEMCrypto_IsAntiRollbackHwPresent()) { - ASSERT_EQ(OEMCrypto_SUCCESS, sts); - } else { - ASSERT_EQ(OEMCrypto_ERROR_UNKNOWN_FAILURE, sts); - } -} - // // Keybox Tests // These two tests are first, becuase it might give an idea why other @@ -2347,6 +2330,23 @@ TEST_F(DISABLED_TestKeybox, LoadKeysWithNoDerivedKeys) { ASSERT_NE(OEMCrypto_SUCCESS, sts); } +TEST_F(DISABLED_TestKeybox, AntiRollbackHardwareRequired) { + Session s; + s.open(); + s.GenerateDerivedKeys(); + s.FillSimpleMessage(0, wvoec_mock::kControlRequireAntiRollbackHardware, 0); + s.EncryptAndSign(); + OEMCryptoResult sts = OEMCrypto_LoadKeys( + s.session_id(), s.message_ptr(), sizeof(MessageData), &s.signature()[0], + s.signature().size(), s.encrypted_license().mac_key_iv, + s.encrypted_license().mac_keys, kNumKeys, s.key_array(), NULL, 0); + if (OEMCrypto_IsAntiRollbackHwPresent()) { + ASSERT_EQ(OEMCrypto_SUCCESS, sts); + } else { + ASSERT_EQ(OEMCrypto_ERROR_UNKNOWN_FAILURE, sts); + } +} + class DISABLED_DecryptWithHDCP : public DISABLED_TestKeybox, public WithParamInterface { public: