From a11d764d8dcfe4e667fe8ee292d31d8fe2794cdc Mon Sep 17 00:00:00 2001 From: Fred Gylys-Colwell Date: Fri, 6 Mar 2020 15:49:17 -0800 Subject: [PATCH] Filter out nonrequired tests for v15 devices Merge from Widevine repo of http://go/wvgerrit/95263 Some OEMCrypto unit tests are not expected to pass on a v15 device, so they are being filtered out. Bug: 149861744 Test: unit tests on taimen Change-Id: Iadff592f4a0005ab7e5613b315a714e737d7e5e0 --- .../oemcrypto/test/oemcrypto_test.cpp | 38 ++++++++++++------- 1 file changed, 25 insertions(+), 13 deletions(-) diff --git a/libwvdrmengine/oemcrypto/test/oemcrypto_test.cpp b/libwvdrmengine/oemcrypto/test/oemcrypto_test.cpp index e8649e2b..6b03ffdf 100644 --- a/libwvdrmengine/oemcrypto/test/oemcrypto_test.cpp +++ b/libwvdrmengine/oemcrypto/test/oemcrypto_test.cpp @@ -1082,7 +1082,9 @@ TEST_P(OEMCryptoLicenseTest, LoadKeyWithBadRange_pst) { // The IV should not be identical to the data right before the encrypted mac // keys. This requirement was added in 15.2, so it frequently fails on // production devices. -TEST_F(OEMCryptoLicenseTestAPI15, LoadKeyWithSuspiciousIV) { +// This test is being restricted to v16 devices on rvc-dev branch because we +// only required v15.1 on Android for Q. +TEST_F(OEMCryptoLicenseTestAPI15, LoadKeyWithSuspiciousIVAPI16) { ASSERT_NO_FATAL_FAILURE(session_.GenerateNonce()); ASSERT_NO_FATAL_FAILURE(license_messages_.SignAndVerifyRequest()); ASSERT_NO_FATAL_FAILURE(license_messages_.CreateDefaultResponse()); @@ -1318,7 +1320,7 @@ TEST_P(OEMCryptoLicenseTestRangeAPI, LoadKeys) { INSTANTIATE_TEST_CASE_P(TestAll, OEMCryptoLicenseTestRangeAPI, Range(10, kCurrentAPI + 2)); -TEST_P(OEMCryptoLicenseTest, LoadKeysBadSignature) { +TEST_P(OEMCryptoLicenseTest, LoadKeysBadSignatureAPI16) { ASSERT_NO_FATAL_FAILURE(session_.GenerateNonce()); ASSERT_NO_FATAL_FAILURE(license_messages_.SignAndVerifyRequest()); ASSERT_NO_FATAL_FAILURE(license_messages_.CreateDefaultResponse()); @@ -1359,7 +1361,9 @@ TEST_P(OEMCryptoLicenseTest, LoadKeyNoKeyWithNonce) { // SelectKey should fail if we attempt to select a key that has not been loaded. // Also, the error should be NO_CONTENT_KEY. -TEST_P(OEMCryptoLicenseTest, SelectKeyNotThereAPI15) { +// This test should pass for v15 devices, except that the exact error code was +// not specified until v16. +TEST_P(OEMCryptoLicenseTest, SelectKeyNotThereAPI16) { ASSERT_NO_FATAL_FAILURE(session_.GenerateNonce()); ASSERT_NO_FATAL_FAILURE(license_messages_.SignAndVerifyRequest()); ASSERT_NO_FATAL_FAILURE(license_messages_.CreateDefaultResponse()); @@ -1683,22 +1687,28 @@ class OEMCryptoSessionTestDecryptWithHDCP : public OEMCryptoSessionTests, ASSERT_NO_FATAL_FAILURE(license_messages.EncryptAndSignResponse()); ASSERT_EQ(OEMCrypto_SUCCESS, license_messages.LoadResponse()); - if (version > maximum) { - ASSERT_NO_FATAL_FAILURE( - s.TestDecryptCTR(true, OEMCrypto_ERROR_INSUFFICIENT_HDCP)); - } else if (version > current) { + if (version > current) { if (global_features.api_version >= 16) { // Can provide either OEMCrypto_WARNING_MIXED_OUTPUT_PROTECTION or // OEMCrypto_ERROR_INSUFFICIENT_HDCP. TestDecryptCTR allows either to be // reported if OEMCrypto_WARNING_MIXED_OUTPUT_PROTECTION is expected. ASSERT_NO_FATAL_FAILURE( - s.TestDecryptCTR(true, OEMCrypto_WARNING_MIXED_OUTPUT_PROTECTION)); + s.TestDecryptCTR(true, OEMCrypto_WARNING_MIXED_OUTPUT_PROTECTION)) + << "Failed when current HDCP = " << HDCPCapabilityAsString(current) + << ", maximum HDCP = " << HDCPCapabilityAsString(maximum) + << ", license HDCP = " << HDCPCapabilityAsString(version); } else { ASSERT_NO_FATAL_FAILURE( - s.TestDecryptCTR(true, OEMCrypto_ERROR_INSUFFICIENT_HDCP)); + s.TestDecryptCTR(true, OEMCrypto_ERROR_INSUFFICIENT_HDCP)) + << "Failed when current HDCP = " << HDCPCapabilityAsString(current) + << ", maximum HDCP = " << HDCPCapabilityAsString(maximum) + << ", license HDCP = " << HDCPCapabilityAsString(version); } } else { - ASSERT_NO_FATAL_FAILURE(s.TestDecryptCTR(true, OEMCrypto_SUCCESS)); + ASSERT_NO_FATAL_FAILURE(s.TestDecryptCTR(true, OEMCrypto_SUCCESS)) + << "Failed when current HDCP = " << HDCPCapabilityAsString(current) + << ", maximum HDCP = " << HDCPCapabilityAsString(maximum) + << ", license HDCP = " << HDCPCapabilityAsString(version); } } }; @@ -2634,7 +2644,8 @@ TEST_F(OEMCryptoLoadsCertificate, SignProvisioningRequest) { ASSERT_NO_FATAL_FAILURE(provisioning_messages.SignAndVerifyRequest()); } -TEST_F(OEMCryptoLoadsCertificate, SignLargeProvisioningRequest) { +// This tests a large message size. The size is larger than we required in v15. +TEST_F(OEMCryptoLoadsCertificate, SignLargeProvisioningRequestAPI16) { Session s; ASSERT_NO_FATAL_FAILURE(s.open()); if (global_features.provisioning_method == OEMCrypto_OEMCertificate) { @@ -2750,7 +2761,8 @@ TEST_F(OEMCryptoLoadsCertificate, CertificateProvisionBadRange5Prov30_API16) { // Test that RewrapDeviceRSAKey verifies the message signature. // TODO(b/144186970): This test should also run on Prov 3.0 devices. -TEST_F(OEMCryptoLoadsCertificate, CertificateProvisionBadSignatureKeyboxTest) { +TEST_F(OEMCryptoLoadsCertificate, + CertificateProvisionBadSignatureKeyboxTestAPI16) { Session s; ProvisioningRoundTrip provisioning_messages(&s, encoded_rsa_key_); provisioning_messages.PrepareSession(keybox_); @@ -2792,7 +2804,7 @@ TEST_F(OEMCryptoLoadsCertificate, CertificateProvisionBadRSAKey) { // Test that RewrapDeviceRSAKey verifies the RSA key is valid. // TODO(b/144186970): This test should also run on Prov 3.0 devices. -TEST_F(OEMCryptoLoadsCertificate, CertificateProvisionBadRSAKeyKeyboxTest) { +TEST_F(OEMCryptoLoadsCertificate, CertificateProvisionBadRSAKeyKeyboxTestAPI16) { Session s; ProvisioningRoundTrip provisioning_messages(&s, encoded_rsa_key_); provisioning_messages.PrepareSession(keybox_);