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