diff options
author | Seth Moore <sethmo@google.com> | 2021-04-30 11:41:18 -0700 |
---|---|---|
committer | Seth Moore <sethmo@google.com> | 2021-05-25 07:57:13 -0700 |
commit | 026bb7431d91f4cc8db204d2ff3e7ec2c3b728de (patch) | |
tree | 3e5be3e4f19b4400ed41403188e2d0cc17d2dff4 /security/keymint/aidl/vts/functional/KeyMintAidlTestBase.cpp | |
parent | 4477ee052ff3ebbb4521c829495105cca226246b (diff) |
Generate COSE MAC with a callback, not raw key
The cppcose_rkp library was updated to generate MAC via callback instead
of passing keys around to allow for stronger MAC key protection.
Bug: 182928606
Test: VtsHalRemotelyProvisionedComponentTargetTest
Test: RemoteProvisionerUnitTests
Change-Id: Ia8a0410408fe3064e904c5282b52f172f8134b9a
Merged-In: Ia8a0410408fe3064e904c5282b52f172f8134b9a
Diffstat (limited to 'security/keymint/aidl/vts/functional/KeyMintAidlTestBase.cpp')
-rw-r--r-- | security/keymint/aidl/vts/functional/KeyMintAidlTestBase.cpp | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/security/keymint/aidl/vts/functional/KeyMintAidlTestBase.cpp b/security/keymint/aidl/vts/functional/KeyMintAidlTestBase.cpp index 0eac033cd1..a9a67bcc50 100644 --- a/security/keymint/aidl/vts/functional/KeyMintAidlTestBase.cpp +++ b/security/keymint/aidl/vts/functional/KeyMintAidlTestBase.cpp @@ -44,7 +44,9 @@ using std::unique_ptr; using ::testing::AssertionFailure; using ::testing::AssertionResult; using ::testing::AssertionSuccess; +using ::testing::ElementsAreArray; using ::testing::MatchesRegex; +using ::testing::Not; ::std::ostream& operator<<(::std::ostream& os, const AuthorizationSet& set) { if (set.size() == 0) @@ -1548,14 +1550,17 @@ void check_maced_pubkey(const MacedPublicKey& macedPubKey, bool testMode, EXPECT_EQ(extractedTag.size(), 32U); // Compare with tag generated with kTestMacKey. Should only match in test mode - auto testTag = cppcose::generateCoseMac0Mac(remote_prov::kTestMacKey, {} /* external_aad */, - payload->value()); + auto macFunction = [](const cppcose::bytevec& input) { + return cppcose::generateHmacSha256(remote_prov::kTestMacKey, input); + }; + auto testTag = + cppcose::generateCoseMac0Mac(macFunction, {} /* external_aad */, payload->value()); ASSERT_TRUE(testTag) << "Tag calculation failed: " << testTag.message(); if (testMode) { - EXPECT_EQ(*testTag, extractedTag); + EXPECT_THAT(*testTag, ElementsAreArray(extractedTag)); } else { - EXPECT_NE(*testTag, extractedTag); + EXPECT_THAT(*testTag, Not(ElementsAreArray(extractedTag))); } if (payload_value != nullptr) { *payload_value = payload->value(); |