From 29becbc2bf7db3b032169b301bbe1131912d3bee Mon Sep 17 00:00:00 2001 From: Fred Gylys-Colwell Date: Tue, 14 May 2019 15:37:59 -0700 Subject: [PATCH] Disable failures for LoadKeyWithSuspiciousIV and SelectKeyNotThereAPI15 Merge from Widevine repo of http://go/wvgerrit/78949 LoadKeyWithSuspiciousIV is a new test for OEMCrypto v15.2. It is being disabled since we do not require 15.2 for the Q release. SelectKeyNotThereAPI15 was failing because the error code is delayed. This is acceptable. Bug: 132720732 Test: unit tests on taimen Change-Id: Iea3fabfb3afd800065119ce812fb454be1e82644 --- .../oemcrypto/test/oemcrypto_test.cpp | 41 ++++++++++++++++--- 1 file changed, 36 insertions(+), 5 deletions(-) diff --git a/libwvdrmengine/oemcrypto/test/oemcrypto_test.cpp b/libwvdrmengine/oemcrypto/test/oemcrypto_test.cpp index 3df68bf1..9d00454d 100644 --- a/libwvdrmengine/oemcrypto/test/oemcrypto_test.cpp +++ b/libwvdrmengine/oemcrypto/test/oemcrypto_test.cpp @@ -1217,7 +1217,10 @@ TEST_F(OEMCryptoSessionTests, LoadKeyWithBadRange7) { // The IV should not be identical to the data right before the encrypted mac // keys. -TEST_F(OEMCryptoSessionTests, LoadKeyWithSuspiciousIV) { +// This test is for OEMCrypto v15.2. It is being disabled on the Android branch +// the 15.2 updates to 15.2 were not available in time for the Q release. SOC +// vendors who are able to pass this tests, should. +TEST_F(OEMCryptoSessionTests, DISABLED_LoadKeyWithSuspiciousIV) { Session s; ASSERT_NO_FATAL_FAILURE(s.open()); ASSERT_NO_FATAL_FAILURE(InstallTestSessionKeys(&s)); @@ -1540,10 +1543,38 @@ TEST_F(OEMCryptoSessionTests, SelectKeyNotThereAPI15) { ASSERT_NO_FATAL_FAILURE(s.EncryptAndSign()); ASSERT_NO_FATAL_FAILURE(s.LoadTestKeys()); const char* key_id = "no_key"; - ASSERT_EQ(OEMCrypto_ERROR_NO_CONTENT_KEY, - OEMCrypto_SelectKey( - s.session_id(), reinterpret_cast(key_id), - strlen(key_id), OEMCrypto_CipherMode_CTR)); + OEMCryptoResult sts = OEMCrypto_SelectKey( + s.session_id(), reinterpret_cast(key_id), strlen(key_id), + OEMCrypto_CipherMode_CTR); + if (sts != OEMCrypto_SUCCESS) { + EXPECT_EQ(OEMCrypto_ERROR_NO_CONTENT_KEY, sts); + } else { + // Delayed error code. If select key was a success, then we should + // eventually see the error when we decrypt. + vector in_buffer(256); + for (size_t i = 0; i < in_buffer.size(); i++) in_buffer[i] = i % 256; + vector encryptionIv(AES_BLOCK_SIZE); + EXPECT_EQ(1, GetRandBytes(encryptionIv.data(), AES_BLOCK_SIZE)); + // Describe the output + vector out_buffer(in_buffer.size()); + const bool is_encrypted = true; + OEMCrypto_DestBufferDesc destBuffer; + destBuffer.type = OEMCrypto_BufferType_Clear; + destBuffer.buffer.clear.address = out_buffer.data(); + destBuffer.buffer.clear.max_length = out_buffer.size(); + OEMCrypto_CENCEncryptPatternDesc pattern; + pattern.encrypt = 0; + pattern.skip = 0; + pattern.offset = 0; + // Decrypt the data + sts = OEMCrypto_DecryptCENC( + s.session_id(), in_buffer.data(), in_buffer.size(), is_encrypted, + encryptionIv.data(), 0, &destBuffer, &pattern, + OEMCrypto_FirstSubsample | OEMCrypto_LastSubsample); + EXPECT_TRUE( + (OEMCrypto_ERROR_NO_CONTENT_KEY == sts) // Preferred return code. + || (OEMCrypto_KEY_NOT_LOADED == sts)); // Obsolete return code. + } } // After loading keys, we should be able to query the key control block. If we