From 0d6fbb2d0ebb9403b59a16ac2ddf1c25fb1de4f2 Mon Sep 17 00:00:00 2001 From: Fred Gylys-Colwell Date: Mon, 2 May 2022 15:41:52 -0700 Subject: [PATCH 1/2] Restrict CAS unit tests to devices that support CAS Merge from Widevine repo of http://go/wvgerrit/151253 This updates the OEMCrypto unit test filters to remove CasOnly tests if the device does not implement the cas function OEMCrypto_LoadCasECMKeys. Test: unit tests on Luci Bug: 221256887 Change-Id: I7026c4318153ada1d85055704e87b2cef397ffca --- libwvdrmengine/oemcrypto/test/oec_device_features.cpp | 5 +++++ libwvdrmengine/oemcrypto/test/oec_device_features.h | 1 + 2 files changed, 6 insertions(+) diff --git a/libwvdrmengine/oemcrypto/test/oec_device_features.cpp b/libwvdrmengine/oemcrypto/test/oec_device_features.cpp index 4023081d..9db9c007 100644 --- a/libwvdrmengine/oemcrypto/test/oec_device_features.cpp +++ b/libwvdrmengine/oemcrypto/test/oec_device_features.cpp @@ -63,6 +63,10 @@ void DeviceFeatures::Initialize() { OEMCrypto_Generic_Encrypt(session, buffer, 0, iv, OEMCrypto_AES_CBC_128_NO_PADDING, buffer)); printf("generic_crypto = %s.\n", generic_crypto ? "true" : "false"); + supports_cas = + (OEMCrypto_ERROR_NOT_IMPLEMENTED != + OEMCrypto_LoadCasECMKeys(session, nullptr, 0, nullptr, nullptr)); + printf("supports_cas = %s.\n", supports_cas ? "true" : "false"); OEMCrypto_CloseSession(session); api_version = OEMCrypto_APIVersion(); printf("api_version = %u.\n", api_version); @@ -137,6 +141,7 @@ std::string DeviceFeatures::RestrictFilter(const std::string& initial_filter) { FilterOut(&filter, "OEMCryptoLoadsCert*"); if (!generic_crypto) FilterOut(&filter, "*GenericCrypto*"); if (!cast_receiver) FilterOut(&filter, "*CastReceiver*"); + if (!supports_cas) FilterOut(&filter, "*CasOnly*"); if (derive_key_method == NO_METHOD) FilterOut(&filter, "*SessionTest*"); if (provisioning_method != OEMCrypto_OEMCertificate) FilterOut(&filter, "*Prov30*"); diff --git a/libwvdrmengine/oemcrypto/test/oec_device_features.h b/libwvdrmengine/oemcrypto/test/oec_device_features.h index 06c7b587..a65eef19 100644 --- a/libwvdrmengine/oemcrypto/test/oec_device_features.h +++ b/libwvdrmengine/oemcrypto/test/oec_device_features.h @@ -51,6 +51,7 @@ class DeviceFeatures { uint32_t resource_rating; // Device's resource rating tier. bool supports_crc; // Supported decrypt hash type CRC. bool test_secure_buffers; // If we can create a secure buffer for testing. + bool supports_cas; // Device supports CAS (Condition Access System). uint32_t api_version; OEMCrypto_ProvisioningMethod provisioning_method; From 2899924d427a27bc7f80eeba70b506ba98473d3c Mon Sep 17 00:00:00 2001 From: Fred Gylys-Colwell Date: Mon, 2 May 2022 17:36:36 -0700 Subject: [PATCH 2/2] Update TestMaxDRMKeys to use 2048 bit keys only Merge from Widevine repo of http://go/wvgerrit/151254 Test: Ran tests on reference oemcrypto Bug: 228996670 Change-Id: I6ea69bad49fa2d4272fc8bb02895c17f314c7f49 --- libwvdrmengine/oemcrypto/test/oemcrypto_test.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libwvdrmengine/oemcrypto/test/oemcrypto_test.cpp b/libwvdrmengine/oemcrypto/test/oemcrypto_test.cpp index 0141bb64..7886e775 100644 --- a/libwvdrmengine/oemcrypto/test/oemcrypto_test.cpp +++ b/libwvdrmengine/oemcrypto/test/oemcrypto_test.cpp @@ -5929,9 +5929,9 @@ TEST_F(OEMCryptoLoadsCertificate, TestMaxDRMKeys) { // Attempts to load one more key than the kMaxTotalDRMPrivateKeys Session s; - encoded_rsa_key_.assign(kTestRSAPKCS8PrivateKeyInfo3_3072, - kTestRSAPKCS8PrivateKeyInfo3_3072 + - sizeof(kTestRSAPKCS8PrivateKeyInfo3_3072)); + encoded_rsa_key_.assign(kTestRSAPKCS8PrivateKeyInfo2_2048, + kTestRSAPKCS8PrivateKeyInfo2_2048 + + sizeof(kTestRSAPKCS8PrivateKeyInfo2_2048)); Session ps; ProvisioningRoundTrip provisioning_messages(&ps, encoded_rsa_key_); provisioning_messages.PrepareSession(keybox_);