Add unit test for clear KCB in LS SDK 16.4 response am: 8c4c238324 am: 154a1db776
Original change: https://googleplex-android-review.googlesource.com/c/platform/vendor/widevine/+/18973819 Change-Id: I0224f6540925ad4b16988afd8e2bd76a12771c49 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -266,7 +266,7 @@ TEST_F(OEMCryptoClientTest, FreeUnallocatedSecureBufferNoFailure) {
|
||||
*/
|
||||
TEST_F(OEMCryptoClientTest, VersionNumber) {
|
||||
const std::string log_message =
|
||||
"OEMCrypto unit tests for API 17.0. Tests last updated 2022-02-18";
|
||||
"OEMCrypto unit tests for API 17.1. Tests last updated 2022-06-17";
|
||||
cout << " " << log_message << "\n";
|
||||
cout << " "
|
||||
<< "These tests are part of Android T."
|
||||
@@ -3445,6 +3445,39 @@ TEST_P(OEMCryptoLicenseTest, QueryKeyControl) {
|
||||
strlen(key_id), reinterpret_cast<uint8_t*>(&block), &size));
|
||||
}
|
||||
|
||||
// This case tests against the issue where certain 16.4.x SDK versions return a
|
||||
// clear key control block (KCB) in the license response. An OEMCrypto v17.1+
|
||||
// implementation should be able to handle the clear KCB in the 16.4.x response
|
||||
// and load the license correctly.
|
||||
TEST_F(OEMCryptoSessionTests, ClearKcbAPI16_4) {
|
||||
Session s;
|
||||
ASSERT_NO_FATAL_FAILURE(s.open());
|
||||
ASSERT_NO_FATAL_FAILURE(InstallTestRSAKey(&s));
|
||||
LicenseRoundTrip license_messages(&s);
|
||||
ASSERT_NO_FATAL_FAILURE(license_messages.SignAndVerifyRequest());
|
||||
ASSERT_NO_FATAL_FAILURE(license_messages.CreateDefaultResponse());
|
||||
// Set odk version in the license response to be 16.4
|
||||
oemcrypto_core_message::features::CoreMessageFeatures features = {};
|
||||
features.maximum_major_version = 16;
|
||||
features.maximum_minor_version = 4;
|
||||
constexpr bool kForceClearKcb = true;
|
||||
ASSERT_NO_FATAL_FAILURE(
|
||||
license_messages.EncryptAndSignResponseWithCoreMessageFeatures(
|
||||
features, kForceClearKcb));
|
||||
ASSERT_EQ(OEMCrypto_SUCCESS, license_messages.LoadResponse());
|
||||
|
||||
KeyControlBlock block;
|
||||
size_t size = sizeof(block);
|
||||
OEMCryptoResult sts = OEMCrypto_QueryKeyControl(
|
||||
s.session_id(), license_messages.response_data().keys[0].key_id,
|
||||
license_messages.response_data().keys[0].key_id_length,
|
||||
reinterpret_cast<uint8_t*>(&block), &size);
|
||||
if (sts == OEMCrypto_ERROR_NOT_IMPLEMENTED) {
|
||||
return;
|
||||
}
|
||||
ASSERT_EQ(OEMCrypto_SUCCESS, sts);
|
||||
}
|
||||
|
||||
TEST_F(OEMCryptoSessionTests,
|
||||
OEMCryptoMemoryLoadLicenseForHugeSignatureLength) {
|
||||
auto oemcrypto_function = [&](size_t signature_size) {
|
||||
|
||||
Reference in New Issue
Block a user