OEMCrypto unit tests for license release

Bug: 295956275
Change-Id: I3c8fc5fcadeae051cc734a64378e473492437c34
This commit is contained in:
Vicky Min
2023-12-05 01:36:58 +00:00
committed by Robert Shih
parent f94a8dfac9
commit d5157c536d
7 changed files with 233 additions and 21 deletions

View File

@@ -651,6 +651,28 @@ TEST_P(OEMCryptoUsageTableTest, OfflineLicenseRefresh) {
ASSERT_NO_FATAL_FAILURE(entry.GenerateVerifyReport(kActive));
}
// Test that an offline license can be loaded and that the license can be
// released
TEST_P(OEMCryptoUsageTableTest, OfflineLicenseReleaseAPI19) {
// License release is new in OEMCrypto v19.
if (wvoec::global_features.api_version < 19 || license_api_version_ < 19) {
GTEST_SKIP() << "Test for versions 19 and up only.";
}
LicenseWithUsageEntry entry;
entry.license_messages().set_api_version(license_api_version_);
entry.MakeAndLoad(this, wvoec::kControlNonceOrEntry);
Session& s = entry.session();
ASSERT_NO_FATAL_FAILURE(entry.TestDecryptCTR());
// License release message is signed by client and verified by the server.
ReleaseRoundTrip release_messages(&entry.license_messages());
MakeReleaseRequest(&release_messages);
LoadRelease(&release_messages, OEMCrypto_SUCCESS);
ASSERT_NO_FATAL_FAILURE(s.UpdateUsageEntry(&encrypted_usage_header_));
ASSERT_NO_FATAL_FAILURE(
entry.TestDecryptCTR(true, OEMCrypto_ERROR_UNKNOWN_FAILURE));
}
// Test that an offline license can be reloaded in a new session.
TEST_P(OEMCryptoUsageTableTest, ReloadOfflineLicense) {
LicenseWithUsageEntry entry;