1 /* 2 * Copyright (c) 2022-2023 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 iam_common_defines.h 18 * 19 * @brief Some common defines in IAM. 20 * @since 3.1 21 * @version 3.2 22 */ 23 24 #ifndef IAM_COMMON_DEFINES_H 25 #define IAM_COMMON_DEFINES_H 26 27 #include <cstddef> 28 #include <cstdint> 29 30 namespace OHOS { 31 namespace UserIam { 32 namespace UserAuth { 33 /** Max length of challenge. */ 34 constexpr size_t MAX_CHALLENG_LEN = 32; 35 36 /** 37 * @brief Defines authentication type. 38 */ 39 enum AuthType : int32_t { 40 /** All authentication types. */ 41 ALL = 0, 42 /** Pin authentication. */ 43 PIN = 1, 44 /** Face authentication. */ 45 FACE = 2, 46 /** Fingerprint authentication. */ 47 FINGERPRINT = 4, 48 }; 49 50 /** 51 * @brief Defines pin auth's subtype. 52 */ 53 enum PinSubType : int32_t { 54 /** Digit password with fixed length of six. */ 55 PIN_SIX = 10000, 56 /** Digit password with unfixed length. */ 57 PIN_NUMBER = 10001, 58 /** Complex password with number and alphabet. */ 59 PIN_MIXED = 10002, 60 /** Max pin. */ 61 PIN_MAX, 62 }; 63 64 /** 65 * @brief Enumerates executor roles. 66 */ 67 enum ExecutorRole : int32_t { 68 /** Scheduler executor. */ 69 SCHEDULER = 0, 70 /** The executor acts as a collector. */ 71 COLLECTOR = 1, 72 /** The executor acts as a verifier. */ 73 VERIFIER = 2, 74 /** The executor acts as a collector and verifier. */ 75 ALL_IN_ONE = 3, 76 }; 77 78 /** 79 * @brief Enumerates executor security levels. 80 */ 81 enum ExecutorSecureLevel : int32_t { 82 /** Executor secure level 0. */ 83 ESL0 = 0, 84 /** Executor secure level 1. */ 85 ESL1 = 1, 86 /** Executor secure level 2. */ 87 ESL2 = 2, 88 /** Executor secure level 3. */ 89 ESL3 = 3, 90 }; 91 92 /** 93 * @brief Authentication trust level 94 */ 95 enum AuthTrustLevel : uint32_t { 96 /** Auth trust level 1. */ 97 ATL1 = 10000, 98 /** Auth trust level 2. */ 99 ATL2 = 20000, 100 /** Auth trust level 3. */ 101 ATL3 = 30000, 102 /** Auth trust level 4. */ 103 ATL4 = 40000, 104 }; 105 106 /** 107 * @brief Schedule mode. 108 */ 109 enum ScheduleMode : int32_t { 110 /** The schedule mode is enrollment. */ 111 ENROLL = 0, 112 /** The schedule mode is authentication. */ 113 AUTH = 1, 114 /** The schedule mode is identification. */ 115 IDENTIFY = 2, 116 }; 117 118 /** 119 * @brief Property mode. 120 */ 121 enum PropertyMode : uint32_t { 122 /** The property mode is init algorithm. */ 123 PROPERTY_INIT_ALGORITHM = 1, 124 /** The property mode is delete. */ 125 PROPERTY_MODE_DEL = 2, 126 /** The property mode is get. */ 127 PROPERTY_MODE_GET = 3, 128 /** The property mode is set. */ 129 PROPERTY_MODE_SET = 4, 130 /** The property mode is freeze. */ 131 PROPERTY_MODE_FREEZE = 5, 132 /** The property mode is unfreeze. */ 133 PROPERTY_MODE_UNFREEZE = 6, 134 /** The property mode is set cached templates. */ 135 PROPERTY_MODE_SET_CACHED_TEMPLATES = 7, 136 }; 137 138 /** 139 * @brief The result code. 140 */ 141 enum ResultCode : int32_t { 142 /** The result is success. */ 143 SUCCESS = 0, 144 /** Compile fail. */ 145 FAIL = 1, 146 /** The result is fail, because an unknown error occurred. */ 147 GENERAL_ERROR = 2, 148 /** The result is fail, because the request was canceled. */ 149 CANCELED = 3, 150 /** The result is fail ,because of time out. */ 151 TIMEOUT = 4, 152 /** The result is fail ,because type is not support. */ 153 TYPE_NOT_SUPPORT = 5, 154 /** The result is fail ,because trust level is not support. */ 155 TRUST_LEVEL_NOT_SUPPORT = 6, 156 /** The result is fail, because the service was busy. */ 157 BUSY = 7, 158 /** The result is fail, because parameters is invalid. */ 159 INVALID_PARAMETERS = 8, 160 /** The result if fail, because the status is locked. */ 161 LOCKED = 9, 162 /** The result is fail, because the user was not enrolled. */ 163 NOT_ENROLLED = 10, 164 /** The result is fail, because canceled from widget. */ 165 CANCELED_FROM_WIDGET = 11, 166 /** The result is fail, because the hardware is not supported. */ 167 HARDWARE_NOT_SUPPORTED = 12, 168 /** The result is fail, because something wrong from system. */ 169 SYSTEM_ERROR_CODE_BEGIN = 1000, 170 /** The result is fail, because something wrong from ipc. */ 171 IPC_ERROR = 1001, 172 /** The result is fail, because the context ID is invalid. */ 173 INVALID_CONTEXT_ID = 1002, 174 /** The result is fail, because something wrong when read parcel. */ 175 READ_PARCEL_ERROR = 1003, 176 /** The result is fail, because something wrong when write parcel. */ 177 WRITE_PARCEL_ERROR = 1004, 178 /** The result is fail, because permission check is failed. */ 179 CHECK_PERMISSION_FAILED = 1005, 180 /** The result is fail, because the hdi interface is invalid. */ 181 INVALID_HDI_INTERFACE = 1006, 182 /** The result is fail, because the caller app is not system. */ 183 CHECK_SYSTEM_APP_FAILED = 1007, 184 /** The result is fail, because something wrong from vendor. */ 185 VENDOR_ERROR_CODE_BEGIN = 10000, 186 }; 187 } // namespace UserAuth 188 } // namespace UserIam 189 } // namespace OHOS 190 #endif // IAM_COMMON_DEFINES_H 191