• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2022-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 #ifndef IDM_COMMON_H
17 #define IDM_COMMON_H
18 
19 #include <stdint.h>
20 #include "linked_list.h"
21 
22 #ifdef __cplusplus
23 extern "C" {
24 #endif
25 
26 #define MAX_USER 32
27 #define MAX_CREDENTIAL 100
28 #define ROOT_SECRET_LEN 32
29 #define NO_CHECK_PIN_EXPIRED_PERIOD 0
30 #define MAX_GLOBAL_CONFIG_NUM (1 + MAX_AUTH_TYPE_LEN * 1)
31 
32 typedef struct {
33     uint64_t credentialId;
34     uint64_t templateId;
35     uint32_t authType;
36     uint32_t executorSensorHint;
37     uint32_t executorMatcher;
38     uint32_t capabilityLevel;
39     uint32_t credentialType;
40     uint64_t enrolledSysTime;
41 } CredentialInfoHal;
42 
43 typedef struct {
44     uint32_t authType;
45     uint64_t enrolledId;
46 } EnrolledInfoHal;
47 
48 typedef struct {
49     int32_t userId;
50     uint64_t secUid;
51     uint64_t pinSubType;
52     uint64_t cachePinSubType;
53     LinkedList *credentialInfoList;
54     LinkedList *enrolledInfoList;
55     int32_t userType;
56 } UserInfo;
57 
58 typedef struct {
59     int32_t userId;
60     uint64_t secUid;
61     uint32_t pinSubType;
62     uint32_t enrollNum;
63     EnrolledInfoHal enrolledInfo[MAX_ENROLL_OUTPUT];
64 } UserInfoResult;
65 
66 typedef struct {
67     uint64_t credentialDigest;
68     uint16_t credentialCount;
69 } EnrolledStateHal;
70 
71 enum GlobalConfigTypeHal : int32_t {
72     PIN_EXPIRED_PERIOD = 1,
73     ENABLE_STATUS = 2,
74 };
75 
76 union GlobalConfigValueHal {
77     int64_t pinExpiredPeriod;
78     bool enableStatus;
79 };
80 
81 typedef struct {
82     int32_t type;
83     union GlobalConfigValueHal value;
84     int32_t userIds[MAX_USER];
85     uint32_t userIdNum;
86     uint32_t authTypes[MAX_AUTH_TYPE_LEN];
87     uint32_t authTypeNum;
88 } GlobalConfigParamHal;
89 
90 typedef struct {
91     int32_t type;
92     union GlobalConfigValueHal value;
93     int32_t userIds[MAX_USER];
94     uint32_t userIdNum;
95     uint32_t authType;
96 } GlobalConfigInfo;
97 
98 typedef struct {
99     uint64_t pinEnrolledSysTime;
100     int64_t pinExpiredPeriod;
101 } PinExpiredInfo;
102 
103 void DestroyUserInfoNode(void *userInfo);
104 void DestroyCredentialNode(void *credential);
105 void DestroyEnrolledNode(void *enrolled);
106 UserInfo *InitUserInfoNode(void);
107 
108 #ifdef __cplusplus
109 }
110 #endif
111 
112 #endif // IDM_COMMON_H