diff options
author | Dmitry Dementyev <dementyev@google.com> | 2017-11-17 22:32:12 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2017-11-17 22:32:12 +0000 |
commit | 7ebf2fb767add88b679dde17ba730319037b755d (patch) | |
tree | 53b07a97064294db81578b0a85505a632b614a5a | |
parent | ec2384b75efccd1631d5c359d823be1e9f98f888 (diff) | |
parent | be71671a4e7e5d696ea46e26bf17211884644886 (diff) | |
download | interfaces-7ebf2fb767add88b679dde17ba730319037b755d.tar.gz |
Merge "Get rid of manually generated IKeystoreService in wifi/keystore"
-rw-r--r-- | wifi/keystore/1.0/default/include/wifikeystorehal/keystore.h | 2 | ||||
-rw-r--r-- | wifi/keystore/1.0/default/keystore.cpp | 97 |
2 files changed, 49 insertions, 50 deletions
diff --git a/wifi/keystore/1.0/default/include/wifikeystorehal/keystore.h b/wifi/keystore/1.0/default/include/wifikeystorehal/keystore.h index ce6d27b..48b2c39 100644 --- a/wifi/keystore/1.0/default/include/wifikeystorehal/keystore.h +++ b/wifi/keystore/1.0/default/include/wifikeystorehal/keystore.h @@ -5,7 +5,7 @@ #include <hidl/MQDescriptor.h> #include <hidl/Status.h> -#include <keystore/IKeystoreService.h> +#include <android/security/IKeystoreService.h> #include <binder/IServiceManager.h> namespace android { diff --git a/wifi/keystore/1.0/default/keystore.cpp b/wifi/keystore/1.0/default/keystore.cpp index 15ee64d..1245670 100644 --- a/wifi/keystore/1.0/default/keystore.cpp +++ b/wifi/keystore/1.0/default/keystore.cpp @@ -1,8 +1,9 @@ #include <android-base/logging.h> +#include <android/security/IKeystoreService.h> #include <binder/IServiceManager.h> -#include <keystore/IKeystoreService.h> #include <private/android_filesystem_config.h> +#include <vector> #include "include/wifikeystorehal/keystore.h" namespace android { @@ -11,63 +12,61 @@ namespace wifi { namespace keystore { namespace V1_0 { namespace implementation { + +using security::IKeystoreService; // Methods from ::android::hardware::wifi::keystore::V1_0::IKeystore follow. Return<void> Keystore::getBlob(const hidl_string& key, getBlob_cb _hidl_cb) { - sp<IKeystoreService> service = interface_cast<IKeystoreService>( - defaultServiceManager()->getService( - String16("android.security.keystore"))); - if (service == nullptr) { - _hidl_cb(KeystoreStatusCode::ERROR_UNKNOWN, {}); - return Void(); - } - hidl_vec<uint8_t> value; - // Retrieve the blob as wifi user. - auto ret = service->get(String16(key.c_str()), AID_WIFI, &value); - if (!ret.isOk()) { - _hidl_cb(KeystoreStatusCode::ERROR_UNKNOWN, {}); + sp<IKeystoreService> service = interface_cast<IKeystoreService>( + defaultServiceManager()->getService(String16("android.security.keystore"))); + if (service == nullptr) { + _hidl_cb(KeystoreStatusCode::ERROR_UNKNOWN, {}); + return Void(); + } + ::std::vector<uint8_t> value; + // Retrieve the blob as wifi user. + auto ret = service->get(String16(key.c_str()), AID_WIFI, &value); + if (!ret.isOk()) { + _hidl_cb(KeystoreStatusCode::ERROR_UNKNOWN, {}); + return Void(); + } + _hidl_cb(KeystoreStatusCode::SUCCESS, (hidl_vec<uint8_t>)value); return Void(); - } - _hidl_cb(KeystoreStatusCode::SUCCESS, value); - return Void(); } -Return<void> Keystore::getPublicKey( - const hidl_string& keyId, getPublicKey_cb _hidl_cb) { - sp<IKeystoreService> service = interface_cast<IKeystoreService>( - defaultServiceManager()->getService( - String16("android.security.keystore"))); - if (service == nullptr) { - _hidl_cb(KeystoreStatusCode::ERROR_UNKNOWN, {}); - return Void(); - } - hidl_vec<uint8_t> pubkey; - auto ret = service->get_pubkey(String16(keyId.c_str()), &pubkey); - if (!ret.isOk()) { - _hidl_cb(KeystoreStatusCode::ERROR_UNKNOWN, {}); +Return<void> Keystore::getPublicKey(const hidl_string& keyId, getPublicKey_cb _hidl_cb) { + sp<IKeystoreService> service = interface_cast<IKeystoreService>( + defaultServiceManager()->getService(String16("android.security.keystore"))); + if (service == nullptr) { + _hidl_cb(KeystoreStatusCode::ERROR_UNKNOWN, {}); + return Void(); + } + ::std::vector<uint8_t> pubkey; + auto ret = service->get_pubkey(String16(keyId.c_str()), &pubkey); + if (!ret.isOk()) { + _hidl_cb(KeystoreStatusCode::ERROR_UNKNOWN, {}); + return Void(); + } + _hidl_cb(KeystoreStatusCode::SUCCESS, (hidl_vec<uint8_t>)pubkey); return Void(); - } - _hidl_cb(KeystoreStatusCode::SUCCESS, pubkey); - return Void(); } -Return<void> Keystore::sign( - const hidl_string& keyId, const hidl_vec<uint8_t>& dataToSign, - sign_cb _hidl_cb) { - sp<IKeystoreService> service = interface_cast<IKeystoreService>( - defaultServiceManager()->getService( - String16("android.security.keystore"))); - if (service == nullptr) { - _hidl_cb(KeystoreStatusCode::ERROR_UNKNOWN, {}); - return Void(); - } - hidl_vec<uint8_t> signedData; - auto ret = service->sign(String16(keyId.c_str()), dataToSign, &signedData); - if (!ret.isOk()) { - _hidl_cb(KeystoreStatusCode::ERROR_UNKNOWN, {}); +Return<void> Keystore::sign(const hidl_string& keyId, const hidl_vec<uint8_t>& dataToSign, + sign_cb _hidl_cb) { + sp<IKeystoreService> service = interface_cast<IKeystoreService>( + defaultServiceManager()->getService(String16("android.security.keystore"))); + if (service == nullptr) { + _hidl_cb(KeystoreStatusCode::ERROR_UNKNOWN, {}); + return Void(); + } + ::std::vector<uint8_t> signedData; + + auto ret = service->sign(String16(keyId.c_str()), dataToSign, &signedData); + if (!ret.isOk()) { + _hidl_cb(KeystoreStatusCode::ERROR_UNKNOWN, {}); + return Void(); + } + _hidl_cb(KeystoreStatusCode::SUCCESS, (hidl_vec<uint8_t>)signedData); return Void(); - } - _hidl_cb(KeystoreStatusCode::SUCCESS, signedData); - return Void(); } IKeystore* HIDL_FETCH_IKeystore(const char* /* name */) { |