diff options
author | Janis Danisevskis <jdanis@google.com> | 2019-03-14 15:35:48 -0700 |
---|---|---|
committer | Janis Danisevskis <jdanis@google.com> | 2019-03-20 16:13:53 +0000 |
commit | c7a8b863cd9684c1221eb7edcf979fd5ed81944d (patch) | |
tree | b679594eb8d050bd617e8923972d7ebe6770c068 /keymaster | |
parent | 16e12d10c630c96f1fcac41a4abb5f6516663b7b (diff) | |
download | android_hardware_interfaces-c7a8b863cd9684c1221eb7edcf979fd5ed81944d.tar.gz android_hardware_interfaces-c7a8b863cd9684c1221eb7edcf979fd5ed81944d.tar.bz2 android_hardware_interfaces-c7a8b863cd9684c1221eb7edcf979fd5ed81944d.zip |
Keymaster support: Verbose vendor errors
Added function for verbosely logging Keymaster vendor errors.
Bug: 123562864
Test: atest android.keystore.cts
Change-Id: Ida093941d3b76b3d2e953439229081345909c16b
Diffstat (limited to 'keymaster')
-rw-r--r-- | keymaster/4.0/support/Keymaster.cpp | 13 | ||||
-rw-r--r-- | keymaster/4.0/support/include/keymasterV4_0/Keymaster.h | 6 |
2 files changed, 19 insertions, 0 deletions
diff --git a/keymaster/4.0/support/Keymaster.cpp b/keymaster/4.0/support/Keymaster.cpp index 9325cc069..e8db0744e 100644 --- a/keymaster/4.0/support/Keymaster.cpp +++ b/keymaster/4.0/support/Keymaster.cpp @@ -106,6 +106,19 @@ std::vector<std::unique_ptr<Keymaster>> enumerateDevices( return result; } +void Keymaster::logIfKeymasterVendorError(ErrorCode ec) const { + static constexpr int32_t k_keymaster_vendor_error_code_range_max = -10000; + if (static_cast<int32_t>(ec) <= k_keymaster_vendor_error_code_range_max) { + const auto& versionInfo = halVersion(); + LOG(ERROR) << "Keymaster reported error: " << static_cast<int32_t>(ec) << "\n" + << "NOTE: This is an error in the vendor specific error range.\n" + << " Refer to the vendor of the implementation for details.\n" + << " Implementation name: " << versionInfo.keymasterName << "\n" + << " Vendor name: " << versionInfo.authorName << "\n" + << " MajorVersion: " << versionInfo.majorVersion; + } +} + Keymaster::KeymasterSet Keymaster::enumerateAvailableDevices() { auto serviceManager = IServiceManager::getService(); CHECK(serviceManager) << "Could not retrieve ServiceManager"; diff --git a/keymaster/4.0/support/include/keymasterV4_0/Keymaster.h b/keymaster/4.0/support/include/keymasterV4_0/Keymaster.h index 458053a4e..43a34b055 100644 --- a/keymaster/4.0/support/include/keymasterV4_0/Keymaster.h +++ b/keymaster/4.0/support/include/keymasterV4_0/Keymaster.h @@ -65,6 +65,12 @@ class Keymaster : public IKeymasterDevice { const hidl_string& instanceName() const { return instanceName_; } /** + * If ec is in the vendor error code range (<-10000), logs the fact to logcat. + * There are no side effects otherwise. + */ + void logIfKeymasterVendorError(ErrorCode ec) const; + + /** * Returns all available Keymaster3 and Keymaster4 instances, in order of most secure to least * secure (as defined by VersionResult::operator<). */ |