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
This commit is contained in:
Fred Gylys-Colwell
2018-02-05 11:50:19 -08:00
parent 8ae3759a7d
commit a682329684
3 changed files with 10 additions and 10 deletions

View File

@@ -186,8 +186,8 @@ bool DeviceFeatures::IsTestKeyboxInstalled() {
size_t key_data_len = sizeof(key_data); size_t key_data_len = sizeof(key_data);
if (OEMCrypto_GetKeyData(key_data, &key_data_len) != OEMCrypto_SUCCESS) if (OEMCrypto_GetKeyData(key_data, &key_data_len) != OEMCrypto_SUCCESS)
return false; return false;
if (key_data_len != sizeof(kTestKeybox.data_)) return false; if (key_data_len != sizeof(kValidKeybox01.data_)) return false;
if (memcmp(key_data, kTestKeybox.data_, key_data_len)) return false; if (memcmp(key_data, kValidKeybox01.data_, key_data_len)) return false;
uint8_t dev_id[128] = {0}; uint8_t dev_id[128] = {0};
size_t dev_id_len = 128; size_t dev_id_len = 128;
if (OEMCrypto_GetDeviceID(dev_id, &dev_id_len) != OEMCrypto_SUCCESS) 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 // We use strncmp instead of memcmp because we don't really care about the
// multiple '\0' characters at the end of the device id. // multiple '\0' characters at the end of the device id.
return 0 == strncmp(reinterpret_cast<const char*>(dev_id), return 0 == strncmp(reinterpret_cast<const char*>(dev_id),
reinterpret_cast<const char*>(kTestKeybox.device_id_), reinterpret_cast<const char*>(kValidKeybox01.device_id_),
sizeof(kTestKeybox.device_id_)); sizeof(kValidKeybox01.device_id_));
} }
void DeviceFeatures::FilterOut(std::string* current_filter, void DeviceFeatures::FilterOut(std::string* current_filter,

View File

@@ -104,10 +104,10 @@ void SessionUtil::EnsureTestKeys() {
case DeviceFeatures::LOAD_TEST_KEYBOX: case DeviceFeatures::LOAD_TEST_KEYBOX:
keybox_ = kTestKeybox; keybox_ = kTestKeybox;
/* Note: If you are upgrading from an older version, it may be easier to /* 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. * used in older versions of this test.
*/ */
// keybox_ = kValidKeybox01; if (global_features.api_version < 14) keybox_ = kValidKeybox01;
ASSERT_EQ(OEMCrypto_SUCCESS, ASSERT_EQ(OEMCrypto_SUCCESS,
OEMCrypto_LoadTestKeybox( OEMCrypto_LoadTestKeybox(
reinterpret_cast<const uint8_t*>(&keybox_), reinterpret_cast<const uint8_t*>(&keybox_),
@@ -117,8 +117,8 @@ void SessionUtil::EnsureTestKeys() {
ASSERT_EQ(OEMCrypto_SUCCESS, OEMCrypto_LoadTestRSAKey()); ASSERT_EQ(OEMCrypto_SUCCESS, OEMCrypto_LoadTestRSAKey());
break; break;
case DeviceFeatures::EXISTING_TEST_KEYBOX: case DeviceFeatures::EXISTING_TEST_KEYBOX:
// already has test keybox. // already has old test keybox.
keybox_ = kTestKeybox; keybox_ = kValidKeybox01;
break; break;
case DeviceFeatures::FORCE_TEST_KEYBOX: case DeviceFeatures::FORCE_TEST_KEYBOX:
keybox_ = kTestKeybox; keybox_ = kTestKeybox;

View File

@@ -828,7 +828,7 @@ TEST_F(OEMCryptoSessionTests, LoadKeyWithNoMAC) {
ASSERT_EQ(expected_signature, signature); ASSERT_EQ(expected_signature, signature);
} }
TEST_F(OEMCryptoSessionTests, LoadEntitlementKeys) { TEST_F(OEMCryptoSessionTests, LoadEntitlementKeysAPI14) {
Session s; Session s;
ASSERT_NO_FATAL_FAILURE(s.open()); ASSERT_NO_FATAL_FAILURE(s.open());
ASSERT_NO_FATAL_FAILURE(InstallTestSessionKeys(&s)); ASSERT_NO_FATAL_FAILURE(InstallTestSessionKeys(&s));
@@ -841,7 +841,7 @@ TEST_F(OEMCryptoSessionTests, LoadEntitlementKeys) {
ASSERT_NO_FATAL_FAILURE(s.LoadEntitledContentKeys()); ASSERT_NO_FATAL_FAILURE(s.LoadEntitledContentKeys());
} }
TEST_F(OEMCryptoSessionTests, LoadEntitlementKeysNoEntitlementKeys) { TEST_F(OEMCryptoSessionTests, LoadEntitlementKeysNoEntitlementKeysAPI14) {
Session s; Session s;
ASSERT_NO_FATAL_FAILURE(s.open()); ASSERT_NO_FATAL_FAILURE(s.open());
ASSERT_NO_FATAL_FAILURE(InstallTestSessionKeys(&s)); ASSERT_NO_FATAL_FAILURE(InstallTestSessionKeys(&s));