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