1 /*
2  * Copyright (c) 2023-2024 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 user_auth_common_defines.h
18  *
19  * @brief Some common defines in IAM.
20  * @since 3.1
21  * @version 3.2
22  */
23 
24 #ifndef USER_AUTH_COMMON_DEFINES_H
25 #define USER_AUTH_COMMON_DEFINES_H
26 
27 #include <cstddef>
28 #include <cstdint>
29 
30 #include <string>
31 #include <vector>
32 
33 #include "iam_common_defines.h"
34 #include "user_auth_client_defines.h"
35 
36 namespace OHOS {
37 namespace UserIam {
38 namespace UserAuth {
39 
40 const std::string NOTICE_VERSION_STR = "1";
41 const std::string CMD_NOTIFY_AUTH_START = "CMD_NOTIFY_AUTH_START";
42 const std::string CMD_NOTIFY_AUTH_RESULT = "CMD_NOTIFY_AUTH_RESULT";
43 const std::string CMD_NOTIFY_AUTH_TIP = "CMD_NOTIFY_AUTH_TIP";
44 const uint64_t BAD_CONTEXT_ID = 0;
45 
46 /**
47  * @brief Notice type for user authentication.
48  */
49 enum NoticeType : int32_t {
50     /** notice from widget. */
51     WIDGET_NOTICE = 1,
52 };
53 
54 /**
55  * @brief Auth parameter.
56  */
57 struct AuthParamInner {
58     /** user id */
59     int32_t userId;
60     /** is userId specified */
61     bool isUserIdSpecified;
62     /** challenge value */
63     std::vector<uint8_t> challenge;
64     /** Credential type for authentication. */
65     AuthType authType;
66     /** Credential type for authentication. */
67     std::vector<AuthType> authTypes;
68     /** Trust level of authentication result. */
69     AuthTrustLevel authTrustLevel;
70     /** Reuse unlock authentication result. */
71     ReuseUnlockResult reuseUnlockResult;
72     /** Auth intention. */
73     AuthIntent authIntent;
74 };
75 
76 /**
77  * @brief EnrolledId digest and credential count.
78  */
79 struct EnrolledState {
80     /** The credential digest. */
81     uint64_t credentialDigest {0};
82     /** The credential count */
83     uint16_t credentialCount {0};
84 };
85 
86 } // namespace UserAuth
87 } // namespace UserIam
88 } // namespace OHOS
89 #endif // USER_AUTH_COMMON_DEFINES_H
90