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