From 7b565c4e7b134f1bf910925e82b267d5950abd3e Mon Sep 17 00:00:00 2001 From: Tri Vo Date: Wed, 20 Sep 2023 19:17:07 -0400 Subject: [PATCH] Don't require UNKNOWN_ERROR Negative test cases should not expect UNKNOWN_ERROR from Keymint since the exact cause of failure is known. In general, we should avoid UNKNOWN_ERROR because it makes error attribution difficult. To avoid adding retroactive requirements KM implementation, relax the check to expect any error. Bug: 298194325 Test: VtsAidlKeyMintTargetTest Change-Id: I136fb6d36ae92c9e3722ffefe9a067d3515dcbf9 --- security/keymint/aidl/vts/functional/KeyMintTest.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/security/keymint/aidl/vts/functional/KeyMintTest.cpp b/security/keymint/aidl/vts/functional/KeyMintTest.cpp index 022dd3fe7d..25ce00d6a7 100644 --- a/security/keymint/aidl/vts/functional/KeyMintTest.cpp +++ b/security/keymint/aidl/vts/functional/KeyMintTest.cpp @@ -4792,7 +4792,7 @@ TEST_P(ImportKeyTest, RsaOaepMGFDigestSuccess) { EXPECT_EQ(ErrorCode::OK, Begin(KeyPurpose::DECRYPT, params)); string result; - EXPECT_EQ(ErrorCode::UNKNOWN_ERROR, Finish(ciphertext1, &result)); + EXPECT_NE(ErrorCode::OK, Finish(ciphertext1, &result)); EXPECT_EQ(0U, result.size()); } } @@ -5300,7 +5300,7 @@ TEST_P(EncryptionOperationsTest, RsaOaepSuccess) { EXPECT_EQ(ErrorCode::OK, Begin(KeyPurpose::DECRYPT, params)); string result; - EXPECT_EQ(ErrorCode::UNKNOWN_ERROR, Finish(ciphertext1, &result)); + EXPECT_NE(ErrorCode::OK, Finish(ciphertext1, &result)); EXPECT_EQ(0U, result.size()); } } @@ -5367,7 +5367,7 @@ TEST_P(EncryptionOperationsTest, RsaOaepDecryptWithWrongDigest) { .Digest(Digest::SHA_2_256) .Padding(PaddingMode::RSA_OAEP))); string result; - EXPECT_EQ(ErrorCode::UNKNOWN_ERROR, Finish(ciphertext, &result)); + EXPECT_NE(ErrorCode::OK, Finish(ciphertext, &result)); EXPECT_EQ(0U, result.size()); } @@ -5437,7 +5437,7 @@ TEST_P(EncryptionOperationsTest, RsaOaepWithMGFDigestSuccess) { EXPECT_EQ(ErrorCode::OK, Begin(KeyPurpose::DECRYPT, params)); string result; - EXPECT_EQ(ErrorCode::UNKNOWN_ERROR, Finish(ciphertext1, &result)); + EXPECT_NE(ErrorCode::OK, Finish(ciphertext1, &result)); EXPECT_EQ(0U, result.size()); } } @@ -5481,7 +5481,7 @@ TEST_P(EncryptionOperationsTest, RsaOaepMGFDigestDefaultSuccess) { EXPECT_EQ(ErrorCode::OK, Begin(KeyPurpose::DECRYPT, params)); string result; - EXPECT_EQ(ErrorCode::UNKNOWN_ERROR, Finish(ciphertext, &result)); + EXPECT_NE(ErrorCode::OK, Finish(ciphertext, &result)); EXPECT_EQ(0U, result.size()); } @@ -5613,7 +5613,7 @@ TEST_P(EncryptionOperationsTest, RsaPkcs1Success) { EXPECT_EQ(ErrorCode::OK, Begin(KeyPurpose::DECRYPT, params)); string result; - EXPECT_EQ(ErrorCode::UNKNOWN_ERROR, Finish(ciphertext1, &result)); + EXPECT_NE(ErrorCode::OK, Finish(ciphertext1, &result)); EXPECT_EQ(0U, result.size()); }