diff options
author | David Drysdale <drysdale@google.com> | 2021-04-30 16:38:38 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2021-04-30 16:38:38 +0000 |
commit | b5ee70f12558a7d4c25b35757647d0cd740526d8 (patch) | |
tree | eae8368664ec855614317da6f733b178f04b2f97 /security/keymint/aidl/vts/functional/KeyMintTest.cpp | |
parent | 3b2b180a29600885ddd3ff342bb4dddf0cd471f4 (diff) | |
parent | bb3d85eaa4c8564ea864df2dd5abea8c585e0408 (diff) |
Merge "Test for patchlevels and too much entropy"
Diffstat (limited to 'security/keymint/aidl/vts/functional/KeyMintTest.cpp')
-rw-r--r-- | security/keymint/aidl/vts/functional/KeyMintTest.cpp | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/security/keymint/aidl/vts/functional/KeyMintTest.cpp b/security/keymint/aidl/vts/functional/KeyMintTest.cpp index 287b4dbd60..f9a99aaafa 100644 --- a/security/keymint/aidl/vts/functional/KeyMintTest.cpp +++ b/security/keymint/aidl/vts/functional/KeyMintTest.cpp @@ -67,6 +67,8 @@ namespace aidl::android::hardware::security::keymint::test { namespace { +bool check_patchLevels = false; + template <TagType tag_type, Tag tag, typename ValueT> bool contains(const vector<KeyParameter>& set, TypedTag<tag_type, tag> ttag, ValueT expected_value) { @@ -330,6 +332,15 @@ class NewKeyGenerationTest : public KeyMintAidlTestBase { EXPECT_TRUE(os_pl); EXPECT_EQ(*os_pl, os_patch_level()); + if (check_patchLevels) { + // Should include vendor and boot patchlevels. + auto vendor_pl = auths.GetTagValue(TAG_VENDOR_PATCHLEVEL); + EXPECT_TRUE(vendor_pl); + EXPECT_EQ(*vendor_pl, vendor_patch_level()); + auto boot_pl = auths.GetTagValue(TAG_BOOT_PATCHLEVEL); + EXPECT_TRUE(boot_pl); + } + return auths; } }; @@ -5312,6 +5323,16 @@ TEST_P(AddEntropyTest, AddLargeEntropy) { EXPECT_TRUE(keyMint().addRngEntropy(AidlBuf(string(2 * 1024, 'a'))).isOk()); } +/* + * AddEntropyTest.AddTooLargeEntropy + * + * Verifies that the addRngEntropy method rejects more than 2KiB of data. + */ +TEST_P(AddEntropyTest, AddTooLargeEntropy) { + ErrorCode rc = GetReturnErrorCode(keyMint().addRngEntropy(AidlBuf(string(2 * 1024 + 1, 'a')))); + EXPECT_EQ(ErrorCode::INVALID_INPUT_LENGTH, rc); +} + INSTANTIATE_KEYMINT_AIDL_TEST(AddEntropyTest); typedef KeyMintAidlTestBase KeyDeletionTest; @@ -5765,6 +5786,10 @@ int main(int argc, char** argv) { } else { std::cout << "NOT dumping attestations" << std::endl; } + // TODO(drysdale): Remove this flag when available KeyMint devices comply with spec + if (std::string(argv[i]) == "--check_patchLevels") { + aidl::android::hardware::security::keymint::test::check_patchLevels = true; + } } } return RUN_ALL_TESTS(); |