Add unit test for preloaded license
Merge from Widevine repo of http://go/wvgerrit/96508 This adds a unit test for to verify that a preloaded license may be loaded into OEMCrypto. A preloaded license is a license that does not have a nonce, and for which there is no license request. This is used in CAS and ATSC. I also updated the test version string to OEMCrypto unit tests for API 16.2. Tests last updated 2020-03-27 Bug: 144105097 Test: ran oemcrypto unit tests on taimen and with v16 modmock. Change-Id: I6a4926917f36a084d15defa7b908d067612c4dcf
This commit is contained in:
@@ -191,7 +191,7 @@ class OEMCryptoClientTest : public ::testing::Test, public SessionUtil {
|
||||
// tests are failing when the device has the wrong keybox installed.
|
||||
TEST_F(OEMCryptoClientTest, VersionNumber) {
|
||||
const std::string log_message =
|
||||
"OEMCrypto unit tests for API 16.2. Tests last updated 2020-03-18";
|
||||
"OEMCrypto unit tests for API 16.2. Tests last updated 2020-03-27";
|
||||
cout << " " << log_message << "\n";
|
||||
LOGI("%s", log_message.c_str());
|
||||
// If any of the following fail, then it is time to update the log message
|
||||
@@ -874,6 +874,25 @@ TEST_P(OEMCryptoLicenseTest, LoadKeyNoNonce) {
|
||||
ASSERT_EQ(OEMCrypto_SUCCESS, license_messages_.LoadResponse());
|
||||
}
|
||||
|
||||
// Verify that a preloaded license may be loaded without first signing the
|
||||
// request. This test is important for the preloaded licenses used by ATSC and
|
||||
// CAS.
|
||||
TEST_P(OEMCryptoLicenseTest, LoadKeyWithNoRequest) {
|
||||
if (license_api_version_ > global_features.api_version) {
|
||||
// We should not attempt to preload a license with an API higher than that
|
||||
// of OEMCrypto.
|
||||
license_api_version_ = global_features.api_version;
|
||||
license_messages_.set_api_version(license_api_version_);
|
||||
}
|
||||
license_messages_.set_control(0);
|
||||
// The test code uses the core request to create the core response.
|
||||
license_messages_.core_request().api_major_version = ODK_MAJOR_VERSION;
|
||||
license_messages_.core_request().api_minor_version = ODK_MINOR_VERSION;
|
||||
ASSERT_NO_FATAL_FAILURE(license_messages_.CreateDefaultResponse());
|
||||
ASSERT_NO_FATAL_FAILURE(license_messages_.EncryptAndSignResponse());
|
||||
ASSERT_EQ(OEMCrypto_SUCCESS, license_messages_.LoadResponse());
|
||||
}
|
||||
|
||||
// Verify that a license may be loaded with a nonce.
|
||||
TEST_P(OEMCryptoLicenseTest, LoadKeyWithNonce) {
|
||||
ASSERT_NO_FATAL_FAILURE(session_.GenerateNonce());
|
||||
|
||||
Reference in New Issue
Block a user