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
23extern "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
32typedef 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
42typedef struct {
43    uint32_t authType;
44    uint64_t enrolledId;
45} EnrolledInfoHal;
46
47typedef 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
57typedef 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
65typedef struct {
66    uint64_t credentialDigest;
67    uint16_t credentialCount;
68} EnrolledStateHal;
69
70enum GlobalConfigTypeHal : int32_t {
71    PIN_EXPIRED_PERIOD = 1,
72    ENABLE_STATUS = 2,
73};
74
75union GlobalConfigValueHal {
76    int64_t pinExpiredPeriod;
77    bool enableStatus;
78};
79
80typedef struct {
81    int32_t type;
82    union GlobalConfigValueHal value;
83    int32_t userIds[MAX_USER];
84    uint32_t userIdNum;
85    uint32_t authTypes[MAX_AUTH_TYPE_LEN];
86    uint32_t authTypeNum;
87} GlobalConfigParamHal;
88
89typedef struct {
90    int32_t type;
91    union GlobalConfigValueHal value;
92    int32_t userIds[MAX_USER];
93    uint32_t userIdNum;
94    uint32_t authType;
95} GlobalConfigInfo;
96
97typedef struct {
98    uint64_t pinEnrolledSysTime;
99    int64_t pinExpiredPeriod;
100} PinExpiredInfo;
101
102void DestroyUserInfoNode(void *userInfo);
103void DestroyCredentialNode(void *credential);
104void DestroyEnrolledNode(void *enrolled);
105UserInfo *InitUserInfoNode(void);
106
107#ifdef __cplusplus
108}
109#endif
110
111#endif // IDM_COMMON_H