Merge "Disable failures for LoadKeyWithSuspiciousIV and SelectKeyNotThereAPI15" into qt-dev

am: 3454ccf51e

Change-Id: Ibf2dd62f0a04fc3b21cfb793966c4854af66fa1b
This commit is contained in:
Fred Gylys-Colwell
2019-05-16 15:43:59 -07:00
committed by android-build-merger

View File

@@ -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<const uint8_t*>(key_id),
strlen(key_id), OEMCrypto_CipherMode_CTR));
OEMCryptoResult sts = OEMCrypto_SelectKey(
s.session_id(), reinterpret_cast<const uint8_t*>(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<uint8_t> in_buffer(256);
for (size_t i = 0; i < in_buffer.size(); i++) in_buffer[i] = i % 256;
vector<uint8_t> encryptionIv(AES_BLOCK_SIZE);
EXPECT_EQ(1, GetRandBytes(encryptionIv.data(), AES_BLOCK_SIZE));
// Describe the output
vector<uint8_t> 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