1 /* 2 * Copyright (c) 2022 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef PIN_AUTH_EXECUTOR_HDI_H 17 #define PIN_AUTH_EXECUTOR_HDI_H 18 19 #include <cstdint> 20 #include <map> 21 #include <v1_0/iexecutor.h> 22 #include <vector> 23 #include "framework_types.h" 24 #include "iauth_executor_hdi.h" 25 #include "iexecute_callback.h" 26 #include "nocopyable.h" 27 28 namespace OHOS { 29 namespace UserIam { 30 namespace PinAuth { 31 namespace PinHdi = OHOS::HDI::PinAuth::V1_0; 32 class PinAuthExecutorHdi : public std::enable_shared_from_this<PinAuthExecutorHdi>, 33 public UserAuth::IAuthExecutorHdi, public NoCopyable { 34 public: 35 explicit PinAuthExecutorHdi(const sptr<HDI::PinAuth::V1_0::IExecutor> &executorProxy); 36 ~PinAuthExecutorHdi() override = default; 37 38 UserAuth::ResultCode GetExecutorInfo(UserAuth::ExecutorInfo &info) override; 39 UserAuth::ResultCode GetTemplateInfo(uint64_t templateId, UserAuth::TemplateInfo &info) override; 40 UserAuth::ResultCode OnRegisterFinish(const std::vector<uint64_t> &templateIdList, 41 const std::vector<uint8_t> &frameworkPublicKey, const std::vector<uint8_t> &extraInfo) override; 42 UserAuth::ResultCode Enroll(uint64_t scheduleId, uint32_t tokenId, const std::vector<uint8_t> &extraInfo, 43 const std::shared_ptr<UserAuth::IExecuteCallback> &callbackObj) override; 44 UserAuth::ResultCode Authenticate(uint64_t scheduleId, uint32_t tokenId, 45 const std::vector<uint64_t> &templateIdList, const std::vector<uint8_t> &extraInfo, 46 const std::shared_ptr<UserAuth::IExecuteCallback> &callbackObj) override; 47 UserAuth::ResultCode OnSetData(uint64_t scheduleId, uint64_t authSubType, const std::vector<uint8_t>& data); 48 UserAuth::ResultCode Identify(uint64_t scheduleId, uint32_t tokenId, const std::vector<uint8_t> &extraInfo, 49 const std::shared_ptr<UserAuth::IExecuteCallback> &callbackObj) override; 50 UserAuth::ResultCode Delete(const std::vector<uint64_t> &templateIdList) override; 51 UserAuth::ResultCode Cancel(uint64_t scheduleId) override; 52 UserAuth::ResultCode SendCommand(UserAuth::PropertyMode commandId, const std::vector<uint8_t> &extraInfo, 53 const std::shared_ptr<UserAuth::IExecuteCallback> &callbackObj) override; 54 55 private: 56 UserAuth::ResultCode MoveHdiExecutorInfo(PinHdi::ExecutorInfo &in, UserAuth::ExecutorInfo &out); 57 UserAuth::ResultCode MoveHdiTemplateInfo(PinHdi::TemplateInfo &in, UserAuth::TemplateInfo &out); 58 UserAuth::ResultCode ConvertCommandId(const UserAuth::PropertyMode in, PinHdi::CommandId &out); 59 UserAuth::ResultCode ConvertAuthType(const PinHdi::AuthType in, UserAuth::AuthType &out); 60 UserAuth::ResultCode ConvertExecutorRole(const PinHdi::ExecutorRole in, UserAuth::ExecutorRole &out); 61 UserAuth::ResultCode ConvertExecutorSecureLevel(const PinHdi::ExecutorSecureLevel in, 62 UserAuth::ExecutorSecureLevel &out); 63 UserAuth::ResultCode ConvertResultCode(const int32_t in); 64 sptr<PinHdi::IExecutor> executorProxy_ {nullptr}; 65 }; 66 } // PinAuth 67 } // UserIam 68 } // OHOS 69 70 #endif // PIN_AUTH_EXECUTOR_HDI_H