diff options
author | Chirag Pathak <pathakc@google.com> | 2021-01-25 21:37:06 +0000 |
---|---|---|
committer | Chirag Pathak <pathakc@google.com> | 2021-02-10 18:48:34 +0000 |
commit | 8960aaefeaedd1a31b088c618d4dece7a0ca1cc6 (patch) | |
tree | a941b6366377790aee040c1d1e47221a57775974 /security/keymint/aidl/default/service.cpp | |
parent | 9b2940dbcedefb91cb9f0457ba4e04262f931811 (diff) |
The implementation of vts and default implementation to support ISecureClock and ISharedSecret AIDLs.
Test: atest VtsAidlSecureClockTargetTest, atest VtsAidlSharedSecretTargetTest
Bug: b/175136979, b/175141176
Change-Id: I4a0d25981d0172c0e2c8defc61b325eca6d6a029
Diffstat (limited to 'security/keymint/aidl/default/service.cpp')
-rw-r--r-- | security/keymint/aidl/default/service.cpp | 31 |
1 files changed, 22 insertions, 9 deletions
diff --git a/security/keymint/aidl/default/service.cpp b/security/keymint/aidl/default/service.cpp index a710535fac..75b394e187 100644 --- a/security/keymint/aidl/default/service.cpp +++ b/security/keymint/aidl/default/service.cpp @@ -21,25 +21,38 @@ #include <android/binder_process.h> #include <AndroidKeyMintDevice.h> +#include <AndroidSecureClock.h> +#include <AndroidSharedSecret.h> #include <keymaster/soft_keymaster_logger.h> using aidl::android::hardware::security::keymint::AndroidKeyMintDevice; using aidl::android::hardware::security::keymint::SecurityLevel; +using aidl::android::hardware::security::secureclock::AndroidSecureClock; +using aidl::android::hardware::security::sharedsecret::AndroidSharedSecret; + +template <typename T, class... Args> +std::shared_ptr<T> addService(Args&&... args) { + std::shared_ptr<T> ser = ndk::SharedRefBase::make<T>(std::forward<Args>(args)...); + auto instanceName = std::string(T::descriptor) + "/default"; + LOG(INFO) << "adding keymint service instance: " << instanceName; + binder_status_t status = + AServiceManager_addService(ser->asBinder().get(), instanceName.c_str()); + CHECK(status == STATUS_OK); + return ser; +} int main() { // Zero threads seems like a useless pool, but below we'll join this thread to it, increasing // the pool size to 1. ABinderProcess_setThreadPoolMaxThreadCount(0); - std::shared_ptr<AndroidKeyMintDevice> keyMint = - ndk::SharedRefBase::make<AndroidKeyMintDevice>(SecurityLevel::SOFTWARE); - - keymaster::SoftKeymasterLogger logger; - const auto instanceName = std::string(AndroidKeyMintDevice::descriptor) + "/default"; - LOG(INFO) << "instance: " << instanceName; - binder_status_t status = - AServiceManager_addService(keyMint->asBinder().get(), instanceName.c_str()); - CHECK(status == STATUS_OK); + // Add Keymint Service + std::shared_ptr<AndroidKeyMintDevice> keyMint = + addService<AndroidKeyMintDevice>(SecurityLevel::SOFTWARE); + // Add Secure Clock Service + addService<AndroidSecureClock>(keyMint); + // Add Shared Secret Service + addService<AndroidSharedSecret>(keyMint); ABinderProcess_joinThreadPool(); return EXIT_FAILURE; // should not reach } |