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.
Bug: 117993149
Test: Manual test forthcoming
Change-Id: Ib3488c6b125304fa300029e78a218f86f33d4412
Merged-In: Iffc2e155a61354f1fbffbece093b19e5cbc537fd
diff --git a/keystore/keystore_client_impl.cpp b/keystore/keystore_client_impl.cpp
index 6d998ad..994e3f2 100644
--- a/keystore/keystore_client_impl.cpp
+++ b/keystore/keystore_client_impl.cpp
@@ -366,7 +366,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,