diff options
Diffstat (limited to 'keymaster/4.0/vts/functional/KeymasterHidlTest.cpp')
-rw-r--r-- | keymaster/4.0/vts/functional/KeymasterHidlTest.cpp | 36 |
1 files changed, 31 insertions, 5 deletions
diff --git a/keymaster/4.0/vts/functional/KeymasterHidlTest.cpp b/keymaster/4.0/vts/functional/KeymasterHidlTest.cpp index 3af1df32d3..4838e7e575 100644 --- a/keymaster/4.0/vts/functional/KeymasterHidlTest.cpp +++ b/keymaster/4.0/vts/functional/KeymasterHidlTest.cpp @@ -48,10 +48,11 @@ uint32_t KeymasterHidlTest::os_patch_level_; SecurityLevel KeymasterHidlTest::securityLevel_; hidl_string KeymasterHidlTest::name_; hidl_string KeymasterHidlTest::author_; +string KeymasterHidlTest::service_name_; -void KeymasterHidlTest::SetUpTestCase() { - string service_name = KeymasterHidlEnvironment::Instance()->getServiceName<IKeymasterDevice>(); - keymaster_ = ::testing::VtsHalHidlTargetTestBase::getService<IKeymasterDevice>(service_name); +void KeymasterHidlTest::InitializeKeymaster() { + service_name_ = KeymasterHidlEnvironment::Instance()->getServiceName<IKeymasterDevice>(); + keymaster_ = ::testing::VtsHalHidlTargetTestBase::getService<IKeymasterDevice>(service_name_); ASSERT_NE(keymaster_, nullptr); ASSERT_TRUE(keymaster_ @@ -62,18 +63,22 @@ void KeymasterHidlTest::SetUpTestCase() { author_ = author; }) .isOk()); +} + +void KeymasterHidlTest::SetUpTestCase() { + + InitializeKeymaster(); os_version_ = ::keymaster::GetOsVersion(); os_patch_level_ = ::keymaster::GetOsPatchlevel(); auto service_manager = android::hidl::manager::V1_0::IServiceManager::getService(); ASSERT_NE(nullptr, service_manager.get()); - all_keymasters_.push_back(keymaster_); service_manager->listByInterface( IKeymasterDevice::descriptor, [&](const hidl_vec<hidl_string>& names) { for (auto& name : names) { - if (name == service_name) continue; + if (name == service_name_) continue; auto keymaster = ::testing::VtsHalHidlTargetTestBase::getService<IKeymasterDevice>(name); ASSERT_NE(keymaster, nullptr); @@ -269,6 +274,13 @@ ErrorCode KeymasterHidlTest::GetCharacteristics(const HidlBuf& key_blob, return GetCharacteristics(key_blob, client_id, app_data, key_characteristics); } +ErrorCode KeymasterHidlTest::GetDebugInfo(DebugInfo* debug_info) { + EXPECT_TRUE(keymaster_->getDebugInfo([&](const DebugInfo& hidl_debug_info) { + *debug_info = hidl_debug_info; + }).isOk()); + return ErrorCode::OK; +} + ErrorCode KeymasterHidlTest::Begin(KeyPurpose purpose, const HidlBuf& key_blob, const AuthorizationSet& in_params, AuthorizationSet* out_params, OperationHandle* op_handle) { @@ -611,6 +623,20 @@ string KeymasterHidlTest::EncryptMessage(const string& message, BlockMode block_ return ciphertext; } +string KeymasterHidlTest::EncryptMessage(const string& message, BlockMode block_mode, + PaddingMode padding, uint8_t mac_length_bits, + const HidlBuf& iv_in) { + SCOPED_TRACE("EncryptMessage"); + auto params = AuthorizationSetBuilder() + .BlockMode(block_mode) + .Padding(padding) + .Authorization(TAG_MAC_LENGTH, mac_length_bits) + .Authorization(TAG_NONCE, iv_in); + AuthorizationSet out_params; + string ciphertext = EncryptMessage(message, params, &out_params); + return ciphertext; +} + string KeymasterHidlTest::DecryptMessage(const HidlBuf& key_blob, const string& ciphertext, const AuthorizationSet& params) { SCOPED_TRACE("DecryptMessage"); |