Fix KeyStoreClientImpl::doesKeyExist to return correct result
The KeyStoreService returns NO_ERROR if the key was found,
and another response code otherwise. All of these are
mapped to non-zero values. As a result, if a key's
existence was queried it would always respond "true",
regardless if it exists or not or if there was a permissions
error.
Test: Key existence can be successfully checked with the
keystore_cli_v2 tool.
Change-Id: Iffc2e155a61354f1fbffbece093b19e5cbc537fd
diff --git a/keystore/keystore_client_impl.cpp b/keystore/keystore_client_impl.cpp
index 18e9eb1..6fe0f31 100644
--- a/keystore/keystore_client_impl.cpp
+++ b/keystore/keystore_client_impl.cpp
@@ -436,7 +436,7 @@
int32_t result;
auto binder_result = keystore_->exist(key_name16, kDefaultUID, &result);
if (!binder_result.isOk()) return false; // binder error
- return result;
+ return result == static_cast<int32_t>(ResponseCode::NO_ERROR);
}
bool KeystoreClientImpl::listKeys(const std::string& prefix,