• 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
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     uint64_t enrolledSysTime;
40 } CredentialInfoHal;
41 
42 typedef struct {
43     uint32_t authType;
44     uint64_t enrolledId;
45 } EnrolledInfoHal;
46 
47 typedef struct {
48     int32_t userId;
49     uint64_t secUid;
50     uint64_t pinSubType;
51     uint64_t cachePinSubType;
52     LinkedList *credentialInfoList;
53     LinkedList *enrolledInfoList;
54     int32_t userType;
55 } UserInfo;
56 
57 typedef struct {
58     int32_t userId;
59     uint64_t secUid;
60     uint32_t pinSubType;
61     uint32_t enrollNum;
62     EnrolledInfoHal enrolledInfo[MAX_ENROLL_OUTPUT];
63 } UserInfoResult;
64 
65 typedef struct {
66     uint64_t credentialDigest;
67     uint16_t credentialCount;
68 } EnrolledStateHal;
69 
70 enum GlobalConfigTypeHal : int32_t {
71     PIN_EXPIRED_PERIOD = 1,
72 };
73 
74 union GlobalConfigValueHal {
75     int64_t pinExpiredPeriod;
76 };
77 
78 typedef struct {
79     int32_t type;
80     union GlobalConfigValueHal value;
81 } GlobalConfigParamHal;
82 
83 typedef struct {
84     uint64_t pinEnrolledSysTime;
85     int64_t pinExpiredPeriod;
86 } PinExpiredInfo;
87 
88 void DestroyUserInfoNode(void *userInfo);
89 void DestroyCredentialNode(void *credential);
90 void DestroyEnrolledNode(void *enrolled);
91 UserInfo *InitUserInfoNode(void);
92 
93 #ifdef __cplusplus
94 }
95 #endif
96 
97 #endif // IDM_COMMON_H