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 /** 17 * @file co_auth_client_defines.h 18 * 19 * @brief Type definitions used by coAuth client. 20 * @since 3.1 21 * @version 3.2 22 */ 23 24 #ifndef CO_AUTH_CLIENT_DEFINES_H 25 #define CO_AUTH_CLIENT_DEFINES_H 26 27 #include <vector> 28 29 #include "attributes.h" 30 #include "iam_common_defines.h" 31 32 namespace OHOS { 33 namespace UserIam { 34 namespace UserAuth { 35 /** 36 * @brief Infomation used to describe an Executor. 37 */ 38 struct ExecutorInfo { 39 /** Authentication type supported by executor. */ 40 AuthType authType {0}; 41 /** Executor role. */ 42 ExecutorRole executorRole {0}; 43 /** Unique index of executor within each authType. */ 44 uint32_t executorSensorHint {0}; 45 /** Sensor or algorithm type supported by executor. */ 46 uint32_t executorMatcher {0}; 47 /** Executor secure level. */ 48 ExecutorSecureLevel esl {0}; 49 /** Max template acl. */ 50 uint32_t maxTemplateAcl {0}; 51 /** Used to verify the result issued by the authenticator. */ 52 std::vector<uint8_t> publicKey {}; 53 /**< Device udid. */ 54 std::string deviceUdid; 55 /**< signed remote executor info. */ 56 std::vector<uint8_t> signedRemoteExecutorInfo; 57 }; 58 59 class AuthMessage { 60 public: 61 /** 62 * @brief Function of type conversion. 63 * 64 * @param msg Incoming vector<uint8_t> type. 65 * @return Return shared_ptr<AuthMessage>. 66 */ 67 static std::shared_ptr<AuthMessage> As(const std::vector<uint8_t> &msg); 68 }; 69 70 class ExecutorMessenger { 71 public: 72 /** 73 * @brief Called by the executor, send authentication data to resource pool. 74 * 75 * @param scheduleId Specify the current schedule. 76 * @param dstRole Destination executor role. 77 * @param msg Authentication message. 78 * @return Return send data success or not(0:success; other:failed). 79 */ 80 virtual int32_t SendData(uint64_t scheduleId, ExecutorRole dstRole, const std::shared_ptr<AuthMessage> &msg) = 0; 81 82 /** 83 * @brief Called by the executor, send finish data to resource pool. 84 * 85 * @param scheduleId Specify the current schedule. 86 * @param resultCode Authentication result code. 87 * @param finalResult Authentication final result. 88 * @return Return finish success or not(0:success; other:failed). 89 */ 90 virtual int32_t Finish(uint64_t scheduleId, int32_t resultCode, const Attributes &finalResult) = 0; 91 }; 92 } // namespace UserAuth 93 } // namespace UserIam 94 } // namespace OHOS 95 96 #endif // CO_AUTH_CLIENT_DEFINES_H