From 05fc8b5e976ad7aaf47453ecd876bf896b0abb15 Mon Sep 17 00:00:00 2001 From: Fred Gylys-Colwell Date: Wed, 14 Nov 2018 13:08:10 -0800 Subject: [PATCH] Temporarily use old test keybox Merge from Widevine repo of http://go/wvgerrit/65922 This CL puts the old 4121 test keybox back into the unit and android integration tests so that we can run tests on a device with OEMCrypto v13. This change should not be released, and should not be included in CE CDM. It should be removed once we have more test devices with v14 or v15. Bug: 119313532 Bug: 119316243 Test: unit tests Test: tested as part of http://go/ag/5501993 Change-Id: If6a459e11176e07c66fbe6fc45c63d87595a20dc --- libwvdrmengine/cdm/core/test/test_base.cpp | 17 ++++++--- libwvdrmengine/oemcrypto/test/oec_test_data.h | 35 +++++++++++++++++++ .../test/oemcrypto_session_tests_helper.cpp | 2 ++ 3 files changed, 50 insertions(+), 4 deletions(-) diff --git a/libwvdrmengine/cdm/core/test/test_base.cpp b/libwvdrmengine/cdm/core/test/test_base.cpp index 0c686e63..95618ffa 100644 --- a/libwvdrmengine/cdm/core/test/test_base.cpp +++ b/libwvdrmengine/cdm/core/test/test_base.cpp @@ -225,10 +225,19 @@ void WvCdmTestBase::SetUp() { void WvCdmTestBase::InstallTestRootOfTrust() { switch (wvoec::global_features.derive_key_method) { case wvoec::DeviceFeatures::LOAD_TEST_KEYBOX: - ASSERT_EQ(OEMCrypto_SUCCESS, - OEMCrypto_LoadTestKeybox( - reinterpret_cast(&wvoec::kTestKeybox), - sizeof(wvoec::kTestKeybox))); + // TODO(fredgc, b/119316243): REMOVE THIS! (and the lines below) + if (wvoec::global_features.api_version < 14) { + // This should work with a production android device, but will fail with + // the keyboxless ce cdm, as shipped. We are including this bit of code + // so we can develop on Android, but plan to remove it when we have a + // few more android test devices with v14 or v15 oemcrypto. + LOGE("Attempting tests without test keybox."); + } else { // TODO(fredgc, b/119316243): END OF REMOVE THIS! + ASSERT_EQ(OEMCrypto_SUCCESS, + OEMCrypto_LoadTestKeybox( + reinterpret_cast(&wvoec::kTestKeybox), + sizeof(wvoec::kTestKeybox))); + } // TODO(fredgc, b/119316243): yeah, yeah... remove this line, too. break; case wvoec::DeviceFeatures::LOAD_TEST_RSA_KEY: // Rare case: used by devices with baked in DRM cert. diff --git a/libwvdrmengine/oemcrypto/test/oec_test_data.h b/libwvdrmengine/oemcrypto/test/oec_test_data.h index 2ca1fd4a..099888dd 100644 --- a/libwvdrmengine/oemcrypto/test/oec_test_data.h +++ b/libwvdrmengine/oemcrypto/test/oec_test_data.h @@ -15,6 +15,41 @@ namespace wvoec { +// TODO(fredgc, b/119316243): REMOVE THIS KEYBOX! +// This test keybox is used for testing with OEMCrypto v13. +// It should be removed before release! +static const WidevineKeybox kTestKeyboxForV13 = { + // Sample keybox used for test vectors + { + // deviceID + 0x54, 0x65, 0x73, 0x74, 0x4b, 0x65, 0x79, 0x30, // TestKey01 + 0x31, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ........ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ........ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ........ + }, { + // key + 0xfb, 0xda, 0x04, 0x89, 0xa1, 0x58, 0x16, 0x0e, + 0xa4, 0x02, 0xe9, 0x29, 0xe3, 0xb6, 0x8f, 0x04, + }, { + // data + 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x10, 0x19, + 0x07, 0xd9, 0xff, 0xde, 0x13, 0xaa, 0x95, 0xc1, + 0x22, 0x67, 0x80, 0x53, 0x36, 0x21, 0x36, 0xbd, + 0xf8, 0x40, 0x8f, 0x82, 0x76, 0xe4, 0xc2, 0xd8, + 0x7e, 0xc5, 0x2b, 0x61, 0xaa, 0x1b, 0x9f, 0x64, + 0x6e, 0x58, 0x73, 0x49, 0x30, 0xac, 0xeb, 0xe8, + 0x99, 0xb3, 0xe4, 0x64, 0x18, 0x9a, 0x14, 0xa8, + 0x72, 0x02, 0xfb, 0x02, 0x57, 0x4e, 0x70, 0x64, + 0x0b, 0xd2, 0x2e, 0xf4, 0x4b, 0x2d, 0x7e, 0x39, + }, { + // magic + 0x6b, 0x62, 0x6f, 0x78, + }, { + // Crc + 0x0a, 0x7a, 0x2c, 0x35, + } +}; + // This is a test keybox. They will not be accepted by production systems. // By using known keyboxes for these tests, the results for a given set of // inputs to a test are predictable and can be compared to the actual results. diff --git a/libwvdrmengine/oemcrypto/test/oemcrypto_session_tests_helper.cpp b/libwvdrmengine/oemcrypto/test/oemcrypto_session_tests_helper.cpp index cb040e32..ffc67fb4 100644 --- a/libwvdrmengine/oemcrypto/test/oemcrypto_session_tests_helper.cpp +++ b/libwvdrmengine/oemcrypto/test/oemcrypto_session_tests_helper.cpp @@ -103,6 +103,8 @@ void SessionUtil::EnsureTestKeys() { switch (global_features.derive_key_method) { case DeviceFeatures::LOAD_TEST_KEYBOX: keybox_ = kTestKeybox; + // TODO(fredgc, b/119316243): REMOVE FOLLOWING LINE: + if (global_features.api_version < 14) keybox_ = kTestKeyboxForV13; ASSERT_EQ(OEMCrypto_SUCCESS, OEMCrypto_LoadTestKeybox( reinterpret_cast(&keybox_),