summaryrefslogtreecommitdiff
path: root/security
diff options
context:
space:
mode:
authorTreeHugger Robot <treehugger-gerrit@google.com>2022-06-06 20:56:36 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2022-06-06 20:56:36 +0000
commitd782e21332b694c34fc4c6c12ea6191ae7a61c35 (patch)
tree95228a6f28ce32a6a09105759b7ab4445655d197 /security
parent1527d998cadadd56bd47ab43f083b98a5f444941 (diff)
parent8292bc9292e21b88cd6df77a3dc0969b349a4264 (diff)
Merge "Implement KeyMint2 test for VSR13" into tm-dev
Diffstat (limited to 'security')
-rw-r--r--security/keymint/aidl/vts/functional/KeyMintAidlTestBase.cpp22
-rw-r--r--security/keymint/aidl/vts/functional/KeyMintAidlTestBase.h3
-rw-r--r--security/keymint/aidl/vts/functional/KeyMintTest.cpp12
3 files changed, 37 insertions, 0 deletions
diff --git a/security/keymint/aidl/vts/functional/KeyMintAidlTestBase.cpp b/security/keymint/aidl/vts/functional/KeyMintAidlTestBase.cpp
index 70b89c3280..33945fd0e5 100644
--- a/security/keymint/aidl/vts/functional/KeyMintAidlTestBase.cpp
+++ b/security/keymint/aidl/vts/functional/KeyMintAidlTestBase.cpp
@@ -1460,6 +1460,28 @@ void verify_subject(const X509* cert, //
OPENSSL_free(cert_issuer);
}
+int get_vsr_api_level() {
+ int api_level = ::android::base::GetIntProperty("ro.board.api_level", -1);
+ if (api_level == -1) {
+ api_level = ::android::base::GetIntProperty("ro.board.first_api_level", -1);
+ }
+ if (api_level == -1) {
+ api_level = ::android::base::GetIntProperty("ro.vndk.version", -1);
+ }
+ // We really should have a VSR API level by now. But on cuttlefish, and perhaps other weird
+ // devices, we may not. So, we use the SDK first or current API level if needed. If this goes
+ // wrong, it should go wrong in the direction of being too strict rather than too lenient, which
+ // should provoke someone to examine why we don't have proper VSR API level properties.
+ if (api_level == -1) {
+ api_level = ::android::base::GetIntProperty("ro.product.first_api_level", -1);
+ }
+ if (api_level == -1) {
+ api_level = ::android::base::GetIntProperty("ro.build.version.sdk", -1);
+ }
+ EXPECT_NE(api_level, -1) << "Could not find a VSR level, or equivalent.";
+ return api_level;
+}
+
bool is_gsi_image() {
std::ifstream ifs("/system/system_ext/etc/init/init.gsi.rc");
return ifs.good();
diff --git a/security/keymint/aidl/vts/functional/KeyMintAidlTestBase.h b/security/keymint/aidl/vts/functional/KeyMintAidlTestBase.h
index 043d8b5144..8f9df24522 100644
--- a/security/keymint/aidl/vts/functional/KeyMintAidlTestBase.h
+++ b/security/keymint/aidl/vts/functional/KeyMintAidlTestBase.h
@@ -355,6 +355,9 @@ void add_tag_from_prop(AuthorizationSetBuilder* tags, TypedTag<TagType::BYTES, t
}
}
+// Return the VSR API level for this device.
+int get_vsr_api_level();
+
// Indicate whether the test is running on a GSI image.
bool is_gsi_image();
diff --git a/security/keymint/aidl/vts/functional/KeyMintTest.cpp b/security/keymint/aidl/vts/functional/KeyMintTest.cpp
index 3c2bece4af..4e746b2bb9 100644
--- a/security/keymint/aidl/vts/functional/KeyMintTest.cpp
+++ b/security/keymint/aidl/vts/functional/KeyMintTest.cpp
@@ -7991,6 +7991,18 @@ TEST_P(UnlockedDeviceRequiredTest, DISABLED_KeysBecomeUnusable) {
INSTANTIATE_KEYMINT_AIDL_TEST(UnlockedDeviceRequiredTest);
+using VsrRequirementTest = KeyMintAidlTestBase;
+
+TEST_P(VsrRequirementTest, Vsr13Test) {
+ int vsr_api_level = get_vsr_api_level();
+ if (vsr_api_level < 33) {
+ GTEST_SKIP() << "Applies only to VSR API level 33, this device is: " << vsr_api_level;
+ }
+ EXPECT_GE(AidlVersion(), 2) << "VSR 13+ requires KeyMint version 2";
+}
+
+INSTANTIATE_KEYMINT_AIDL_TEST(VsrRequirementTest);
+
} // namespace aidl::android::hardware::security::keymint::test
int main(int argc, char** argv) {