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 constexpr int32_t USER_AUTH_TIP_SINGLE_AUTH_RESULT = 9999; 36 constexpr int INVALID_SOCKET_ID = -1; 37 constexpr int INVALID_USER_ID = -1; 38 constexpr int32_t MAIN_USER_ID = 100; 39 /** 40 * @brief Defines authentication type. 41 */ 42 constexpr uint32_t MAX_AUTH_TYPE_SIZE = 5; 43 enum AuthType : int32_t { 44 /** All authentication types. */ 45 ALL = 0, 46 /** Pin authentication. */ 47 PIN = 1, 48 /** Face authentication. */ 49 FACE = 2, 50 /** Fingerprint authentication. */ 51 FINGERPRINT = 4, 52 /** Recovery key authentication. */ 53 RECOVERY_KEY = 8, 54 /** Private pin authentication. */ 55 PRIVATE_PIN = 16, 56 }; 57 58 /** 59 * @brief Defines pin auth's subtype. 60 */ 61 enum PinSubType : int32_t { 62 /** Digit password with fixed length of six. */ 63 PIN_SIX = 10000, 64 /** Digit password with unfixed length. */ 65 PIN_NUMBER = 10001, 66 /** Complex password with number and alphabet. */ 67 PIN_MIXED = 10002, 68 /** Digit password with fixed length of four*/ 69 PIN_FOUR = 10003, 70 /** Pattern password*/ 71 PIN_PATTERN = 10004, 72 /** Password protection question */ 73 PIN_QUESTION = 10005, 74 /** Max pin. */ 75 PIN_MAX, 76 }; 77 78 /** 79 * @brief Enumerates executor roles. 80 */ 81 enum ExecutorRole : int32_t { 82 /** Scheduler executor. */ 83 SCHEDULER = 0, 84 /** The executor acts as a collector. */ 85 COLLECTOR = 1, 86 /** The executor acts as a verifier. */ 87 VERIFIER = 2, 88 /** The executor acts as a collector and verifier. */ 89 ALL_IN_ONE = 3, 90 }; 91 92 /** 93 * @brief Enumerates executor security levels. 94 */ 95 enum ExecutorSecureLevel : int32_t { 96 /** Executor secure level 0. */ 97 ESL0 = 0, 98 /** Executor secure level 1. */ 99 ESL1 = 1, 100 /** Executor secure level 2. */ 101 ESL2 = 2, 102 /** Executor secure level 3. */ 103 ESL3 = 3, 104 }; 105 106 /** 107 * @brief Authentication trust level 108 */ 109 enum AuthTrustLevel : uint32_t { 110 /** Auth trust level 1. */ 111 ATL1 = 10000, 112 /** Auth trust level 2. */ 113 ATL2 = 20000, 114 /** Auth trust level 3. */ 115 ATL3 = 30000, 116 /** Auth trust level 4. */ 117 ATL4 = 40000, 118 }; 119 120 /** 121 * @brief Schedule mode. 122 */ 123 enum ScheduleMode : int32_t { 124 /** The schedule mode is enrollment. */ 125 ENROLL = 0, 126 /** The schedule mode is authentication. */ 127 AUTH = 1, 128 /** The schedule mode is identification. */ 129 IDENTIFY = 2, 130 }; 131 132 /** 133 * @brief Property mode. 134 */ 135 enum PropertyMode : uint32_t { 136 /** The property mode is init algorithm. */ 137 PROPERTY_INIT_ALGORITHM = 1, 138 /** The property mode is delete. */ 139 PROPERTY_MODE_DEL = 2, 140 /** The property mode is get. */ 141 PROPERTY_MODE_GET = 3, 142 /** The property mode is set. */ 143 PROPERTY_MODE_SET = 4, 144 /** The property mode is freeze. */ 145 PROPERTY_MODE_FREEZE = 5, 146 /** The property mode is unfreeze. */ 147 PROPERTY_MODE_UNFREEZE = 6, 148 /** The property mode is set cached templates. */ 149 PROPERTY_MODE_SET_CACHED_TEMPLATES = 7, 150 /** The property mode is notify collector ready. */ 151 PROPERTY_MODE_NOTIFY_COLLECTOR_READY = 8, 152 }; 153 154 /** 155 * @brief The result code. 156 */ 157 enum ResultCode : int32_t { 158 /** The result is success. */ 159 SUCCESS = 0, 160 /** Compile fail. */ 161 FAIL = 1, 162 /** The result is fail, because an unknown error occurred. */ 163 GENERAL_ERROR = 2, 164 /** The result is fail, because the request was canceled. */ 165 CANCELED = 3, 166 /** The result is fail ,because of time out. */ 167 TIMEOUT = 4, 168 /** The result is fail ,because type is not support. */ 169 TYPE_NOT_SUPPORT = 5, 170 /** The result is fail ,because trust level is not support. */ 171 TRUST_LEVEL_NOT_SUPPORT = 6, 172 /** The result is fail, because the service was busy. */ 173 BUSY = 7, 174 /** The result is fail, because parameters is invalid. */ 175 INVALID_PARAMETERS = 8, 176 /** The result if fail, because the status is locked. */ 177 LOCKED = 9, 178 /** The result is fail, because the user was not enrolled. */ 179 NOT_ENROLLED = 10, 180 /** The result is fail, because canceled from widget. */ 181 CANCELED_FROM_WIDGET = 11, 182 /** The result is fail, because the hardware is not supported. */ 183 HARDWARE_NOT_SUPPORTED = 12, 184 /** The result is fail, because the pin credential is expired. */ 185 PIN_EXPIRED = 13, 186 /** The result is fail, because the PIN_MIXED does not pass complexity check. */ 187 COMPLEXITY_CHECK_FAILED = 14, 188 /** The result is fail, because something wrong from system. */ 189 SYSTEM_ERROR_CODE_BEGIN = 1000, 190 /** The result is fail, because something wrong from ipc. */ 191 IPC_ERROR = 1001, 192 /** The result is fail, because the context ID is invalid. */ 193 INVALID_CONTEXT_ID = 1002, 194 /** The result is fail, because something wrong when read parcel. */ 195 READ_PARCEL_ERROR = 1003, 196 /** The result is fail, because something wrong when write parcel. */ 197 WRITE_PARCEL_ERROR = 1004, 198 /** The result is fail, because permission check is failed. */ 199 CHECK_PERMISSION_FAILED = 1005, 200 /** The result is fail, because the hdi interface is invalid. */ 201 INVALID_HDI_INTERFACE = 1006, 202 /** The result is fail, because the caller app is not system. */ 203 CHECK_SYSTEM_APP_FAILED = 1007, 204 /** The result is fail, because something wrong when create socket. */ 205 CREATE_SOCKET_FAILED = 1008, 206 /** The result is fail, because something wrong when listen socket. */ 207 LISTEN_SOCKET_FAILED = 1009, 208 /** The result is fail, because something wrong when bind socket. */ 209 BIND_SOCKET_FAILED = 1010, 210 /** The result is fail, because something wrong from vendor. */ 211 VENDOR_ERROR_CODE_BEGIN = 10000, 212 }; 213 214 /** 215 * @brief The auth intent. 216 */ 217 enum AuthIntent : int { 218 /**< The auth intention is default. */ 219 DEFAULT = 0, 220 /**< The auth intention is unlock. */ 221 UNLOCK = 1, 222 /**< The auth intention is silent auth. */ 223 SILENT_AUTH = 2, 224 /**< The auth intention is question auth. */ 225 QUESTION_AUTH = 3, 226 }; 227 228 constexpr uint64_t INVALID_EXECUTOR_INDEX = 0; 229 } // namespace UserAuth 230 } // namespace UserIam 231 } // namespace OHOS 232 #endif // IAM_COMMON_DEFINES_H 233