From 84b685adf582f18b9b96b1788ecedf199d563ff7 Mon Sep 17 00:00:00 2001 From: David Drysdale Date: Wed, 9 Aug 2023 07:00:34 +0100 Subject: [PATCH] KeyMint: allow extra error code Bug: 295055603 Test: VtsAidlKeyMintTargetTest Change-Id: Ifbd4a899364c38bb6ad63bb5b5a683c69edfb5b7 --- .../aidl/vts/functional/KeyMintTest.cpp | 21 +++++++++++-------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/security/keymint/aidl/vts/functional/KeyMintTest.cpp b/security/keymint/aidl/vts/functional/KeyMintTest.cpp index 1e61a1817b..21b93f0242 100644 --- a/security/keymint/aidl/vts/functional/KeyMintTest.cpp +++ b/security/keymint/aidl/vts/functional/KeyMintTest.cpp @@ -2565,22 +2565,24 @@ TEST_P(NewKeyGenerationTest, LimitedUsageEcdsa) { * NewKeyGenerationTest.EcdsaDefaultSize * * Verifies that failing to specify a curve for EC key generation returns - * UNSUPPORTED_KEY_SIZE. + * UNSUPPORTED_KEY_SIZE or UNSUPPORTED_EC_CURVE. */ TEST_P(NewKeyGenerationTest, EcdsaDefaultSize) { - ASSERT_EQ(ErrorCode::UNSUPPORTED_KEY_SIZE, - GenerateKey(AuthorizationSetBuilder() - .Authorization(TAG_ALGORITHM, Algorithm::EC) - .SigningKey() - .Digest(Digest::NONE) - .SetDefaultValidity())); + auto result = GenerateKey(AuthorizationSetBuilder() + .Authorization(TAG_ALGORITHM, Algorithm::EC) + .SigningKey() + .Digest(Digest::NONE) + .SetDefaultValidity()); + ASSERT_TRUE(result == ErrorCode::UNSUPPORTED_KEY_SIZE || + result == ErrorCode::UNSUPPORTED_EC_CURVE) + << "unexpected result " << result; } /* * NewKeyGenerationTest.EcdsaInvalidCurve * * Verifies that specifying an invalid curve for EC key generation returns - * UNSUPPORTED_KEY_SIZE. + * UNSUPPORTED_KEY_SIZE or UNSUPPORTED_EC_CURVE. */ TEST_P(NewKeyGenerationTest, EcdsaInvalidCurve) { for (auto curve : InvalidCurves()) { @@ -2593,7 +2595,8 @@ TEST_P(NewKeyGenerationTest, EcdsaInvalidCurve) { .SetDefaultValidity(), &key_blob, &key_characteristics); ASSERT_TRUE(result == ErrorCode::UNSUPPORTED_KEY_SIZE || - result == ErrorCode::UNSUPPORTED_EC_CURVE); + result == ErrorCode::UNSUPPORTED_EC_CURVE) + << "unexpected result " << result; } ASSERT_EQ(ErrorCode::UNSUPPORTED_KEY_SIZE,