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