From a6823296844062c12e66f4d9b27fc72f848fd753 Mon Sep 17 00:00:00 2001 From: Fred Gylys-Colwell Date: Mon, 5 Feb 2018 11:50:19 -0800 Subject: [PATCH] Fix backwards compatibility Merge from Widevine repo of http://go/wvgerrit/42403 This CL changes the names of some unit tests so that they don't run when testing an older version of oemcrypto. bug: 68275290 test: ran unit tests against v8-v14 oemcrypto. Change-Id: I773350adf4df3f3b310478400cd4d4e85789fc37 --- libwvdrmengine/oemcrypto/test/oec_device_features.cpp | 8 ++++---- .../oemcrypto/test/oemcrypto_session_tests_helper.cpp | 8 ++++---- libwvdrmengine/oemcrypto/test/oemcrypto_test.cpp | 4 ++-- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/libwvdrmengine/oemcrypto/test/oec_device_features.cpp b/libwvdrmengine/oemcrypto/test/oec_device_features.cpp index 4b6317b5..b533f940 100644 --- a/libwvdrmengine/oemcrypto/test/oec_device_features.cpp +++ b/libwvdrmengine/oemcrypto/test/oec_device_features.cpp @@ -186,8 +186,8 @@ bool DeviceFeatures::IsTestKeyboxInstalled() { size_t key_data_len = sizeof(key_data); if (OEMCrypto_GetKeyData(key_data, &key_data_len) != OEMCrypto_SUCCESS) return false; - if (key_data_len != sizeof(kTestKeybox.data_)) return false; - if (memcmp(key_data, kTestKeybox.data_, key_data_len)) return false; + if (key_data_len != sizeof(kValidKeybox01.data_)) return false; + if (memcmp(key_data, kValidKeybox01.data_, key_data_len)) return false; uint8_t dev_id[128] = {0}; size_t dev_id_len = 128; if (OEMCrypto_GetDeviceID(dev_id, &dev_id_len) != OEMCrypto_SUCCESS) @@ -195,8 +195,8 @@ bool DeviceFeatures::IsTestKeyboxInstalled() { // We use strncmp instead of memcmp because we don't really care about the // multiple '\0' characters at the end of the device id. return 0 == strncmp(reinterpret_cast(dev_id), - reinterpret_cast(kTestKeybox.device_id_), - sizeof(kTestKeybox.device_id_)); + reinterpret_cast(kValidKeybox01.device_id_), + sizeof(kValidKeybox01.device_id_)); } void DeviceFeatures::FilterOut(std::string* current_filter, diff --git a/libwvdrmengine/oemcrypto/test/oemcrypto_session_tests_helper.cpp b/libwvdrmengine/oemcrypto/test/oemcrypto_session_tests_helper.cpp index 229a168a..1a1b09be 100644 --- a/libwvdrmengine/oemcrypto/test/oemcrypto_session_tests_helper.cpp +++ b/libwvdrmengine/oemcrypto/test/oemcrypto_session_tests_helper.cpp @@ -104,10 +104,10 @@ void SessionUtil::EnsureTestKeys() { case DeviceFeatures::LOAD_TEST_KEYBOX: keybox_ = kTestKeybox; /* Note: If you are upgrading from an older version, it may be easier to - * uncomment the following line. This uses the same test keybox as we + * force the following condition. This uses the same test keybox as we * used in older versions of this test. */ - // keybox_ = kValidKeybox01; + if (global_features.api_version < 14) keybox_ = kValidKeybox01; ASSERT_EQ(OEMCrypto_SUCCESS, OEMCrypto_LoadTestKeybox( reinterpret_cast(&keybox_), @@ -117,8 +117,8 @@ void SessionUtil::EnsureTestKeys() { ASSERT_EQ(OEMCrypto_SUCCESS, OEMCrypto_LoadTestRSAKey()); break; case DeviceFeatures::EXISTING_TEST_KEYBOX: - // already has test keybox. - keybox_ = kTestKeybox; + // already has old test keybox. + keybox_ = kValidKeybox01; break; case DeviceFeatures::FORCE_TEST_KEYBOX: keybox_ = kTestKeybox; diff --git a/libwvdrmengine/oemcrypto/test/oemcrypto_test.cpp b/libwvdrmengine/oemcrypto/test/oemcrypto_test.cpp index 1611e192..c6a22f9e 100644 --- a/libwvdrmengine/oemcrypto/test/oemcrypto_test.cpp +++ b/libwvdrmengine/oemcrypto/test/oemcrypto_test.cpp @@ -828,7 +828,7 @@ TEST_F(OEMCryptoSessionTests, LoadKeyWithNoMAC) { ASSERT_EQ(expected_signature, signature); } -TEST_F(OEMCryptoSessionTests, LoadEntitlementKeys) { +TEST_F(OEMCryptoSessionTests, LoadEntitlementKeysAPI14) { Session s; ASSERT_NO_FATAL_FAILURE(s.open()); ASSERT_NO_FATAL_FAILURE(InstallTestSessionKeys(&s)); @@ -841,7 +841,7 @@ TEST_F(OEMCryptoSessionTests, LoadEntitlementKeys) { ASSERT_NO_FATAL_FAILURE(s.LoadEntitledContentKeys()); } -TEST_F(OEMCryptoSessionTests, LoadEntitlementKeysNoEntitlementKeys) { +TEST_F(OEMCryptoSessionTests, LoadEntitlementKeysNoEntitlementKeysAPI14) { Session s; ASSERT_NO_FATAL_FAILURE(s.open()); ASSERT_NO_FATAL_FAILURE(InstallTestSessionKeys(&s));