/* ** ** Copyright 2019, The Android Open Source Project ** ** Licensed under the Apache License, Version 2.0 (the "License"); ** you may not use this file except in compliance with the License. ** You may obtain a copy of the License at ** ** http://www.apache.org/licenses/LICENSE-2.0 ** ** Unless required by applicable law or agreed to in writing, software ** distributed under the License is distributed on an "AS IS" BASIS, ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ** See the License for the specific language governing permissions and ** limitations under the License. */ #ifndef HIDL_android_hardware_keymaster_V4_1_AndroidKeymaster4Device_H_ #define HIDL_android_hardware_keymaster_V4_1_AndroidKeymaster4Device_H_ #include #include #include #include "AndroidKeymaster4Device.h" namespace keymaster { class AndroidKeymaster; class KeymasterContext; namespace V4_1 { using ::android::hardware::hidl_vec; using ::android::hardware::Return; using ::android::hardware::Void; using ::android::hardware::keymaster::V4_0::ErrorCode; using ::android::hardware::keymaster::V4_0::HardwareAuthenticatorType; using ::android::hardware::keymaster::V4_0::HardwareAuthToken; using ::android::hardware::keymaster::V4_0::HmacSharingParameters; using ::android::hardware::keymaster::V4_0::KeyCharacteristics; using ::android::hardware::keymaster::V4_0::KeyFormat; using ::android::hardware::keymaster::V4_0::KeyParameter; using ::android::hardware::keymaster::V4_0::KeyPurpose; using ::android::hardware::keymaster::V4_0::OperationHandle; using ::android::hardware::keymaster::V4_0::SecurityLevel; using ::android::hardware::keymaster::V4_0::VerificationToken; using ::android::hardware::keymaster::V4_1::IKeymasterDevice; using ::android::hardware::keymaster::V4_1::Tag; using V41ErrorCode = ::android::hardware::keymaster::V4_1::ErrorCode; inline V41ErrorCode convert(ErrorCode error_code) { return static_cast(error_code); } inline ErrorCode convert(V41ErrorCode error_code) { return static_cast(error_code); } class AndroidKeymaster41Device : public IKeymasterDevice, public V4_0::ng::AndroidKeymaster4Device { using super = V4_0::ng::AndroidKeymaster4Device; public: explicit AndroidKeymaster41Device(SecurityLevel securityLevel) : super(KmVersion::KEYMASTER_4_1, securityLevel) {} virtual ~AndroidKeymaster41Device() {} Return deviceLocked(bool /* passwordOnly */, const VerificationToken& /* verificationToken */) override; Return earlyBootEnded() override; Return getHardwareInfo(super::getHardwareInfo_cb _hidl_cb) override { return super::getHardwareInfo(_hidl_cb); } Return getHmacSharingParameters(super::getHmacSharingParameters_cb _hidl_cb) override { return super::getHmacSharingParameters(_hidl_cb); } Return computeSharedHmac(const hidl_vec& params, super::computeSharedHmac_cb _hidl_cb) override { return super::computeSharedHmac(params, _hidl_cb); } Return verifyAuthorization(uint64_t challenge, const hidl_vec& parametersToVerify, const HardwareAuthToken& authToken, super::verifyAuthorization_cb _hidl_cb) override { return super::verifyAuthorization(challenge, parametersToVerify, authToken, _hidl_cb); } Return addRngEntropy(const hidl_vec& data) override { return super::addRngEntropy(data); } Return generateKey(const hidl_vec& keyParams, super::generateKey_cb _hidl_cb) override { return super::generateKey(keyParams, _hidl_cb); } Return getKeyCharacteristics(const hidl_vec& keyBlob, const hidl_vec& clientId, const hidl_vec& appData, super::getKeyCharacteristics_cb _hidl_cb) override { return super::getKeyCharacteristics(keyBlob, clientId, appData, _hidl_cb); } Return importKey(const hidl_vec& params, KeyFormat keyFormat, const hidl_vec& keyData, super::importKey_cb _hidl_cb) override { return super::importKey(params, keyFormat, keyData, _hidl_cb); } Return importWrappedKey(const hidl_vec& wrappedKeyData, const hidl_vec& wrappingKeyBlob, const hidl_vec& maskingKey, const hidl_vec& unwrappingParams, uint64_t passwordSid, uint64_t biometricSid, super::importWrappedKey_cb _hidl_cb) override { return super::importWrappedKey(wrappedKeyData, wrappingKeyBlob, maskingKey, unwrappingParams, passwordSid, biometricSid, _hidl_cb); } Return exportKey(KeyFormat exportFormat, const hidl_vec& keyBlob, const hidl_vec& clientId, const hidl_vec& appData, super::exportKey_cb _hidl_cb) override { return super::exportKey(exportFormat, keyBlob, clientId, appData, _hidl_cb); } Return attestKey(const hidl_vec& keyToAttest, const hidl_vec& attestParams, super::attestKey_cb _hidl_cb) override { return super::attestKey(keyToAttest, attestParams, _hidl_cb); } Return upgradeKey(const hidl_vec& keyBlobToUpgrade, const hidl_vec& upgradeParams, super::upgradeKey_cb _hidl_cb) override { return super::upgradeKey(keyBlobToUpgrade, upgradeParams, _hidl_cb); } Return deleteKey(const hidl_vec& keyBlob) override { return super::deleteKey(keyBlob); } Return deleteAllKeys() override { return super::deleteAllKeys(); } Return destroyAttestationIds() override { return super::destroyAttestationIds(); } Return begin(KeyPurpose purpose, const hidl_vec& key, const hidl_vec& inParams, const HardwareAuthToken& authToken, super::begin_cb _hidl_cb) override { return super::begin(purpose, key, inParams, authToken, _hidl_cb); } Return update(uint64_t operationHandle, const hidl_vec& inParams, const hidl_vec& input, const HardwareAuthToken& authToken, const VerificationToken& verificationToken, super::update_cb _hidl_cb) override { return super::update(operationHandle, inParams, input, authToken, verificationToken, _hidl_cb); } Return finish(uint64_t operationHandle, const hidl_vec& inParams, const hidl_vec& input, const hidl_vec& signature, const HardwareAuthToken& authToken, const VerificationToken& verificationToken, super::finish_cb _hidl_cb) override { return super::finish(operationHandle, inParams, input, signature, authToken, verificationToken, _hidl_cb); } Return abort(uint64_t operationHandle) override { return super::abort(operationHandle); } }; IKeymasterDevice* CreateKeymasterDevice(SecurityLevel securityLevel); } // namespace V4_1 } // namespace keymaster #endif // HIDL_android_hardware_keymaster_V4_1_AndroidKeymaster4Device_H_