1094332d3Sopenharmony_ci/* 2094332d3Sopenharmony_ci * Copyright (C) 2022-2024 Huawei Device Co., Ltd. 3094332d3Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 4094332d3Sopenharmony_ci * you may not use this file except in compliance with the License. 5094332d3Sopenharmony_ci * You may obtain a copy of the License at 6094332d3Sopenharmony_ci * 7094332d3Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 8094332d3Sopenharmony_ci * 9094332d3Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software 10094332d3Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 11094332d3Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12094332d3Sopenharmony_ci * See the License for the specific language governing permissions and 13094332d3Sopenharmony_ci * limitations under the License. 14094332d3Sopenharmony_ci */ 15094332d3Sopenharmony_ci 16094332d3Sopenharmony_ci#ifndef IDM_COMMON_H 17094332d3Sopenharmony_ci#define IDM_COMMON_H 18094332d3Sopenharmony_ci 19094332d3Sopenharmony_ci#include <stdint.h> 20094332d3Sopenharmony_ci#include "linked_list.h" 21094332d3Sopenharmony_ci 22094332d3Sopenharmony_ci#ifdef __cplusplus 23094332d3Sopenharmony_ciextern "C" { 24094332d3Sopenharmony_ci#endif 25094332d3Sopenharmony_ci 26094332d3Sopenharmony_ci#define MAX_USER 32 27094332d3Sopenharmony_ci#define MAX_CREDENTIAL 100 28094332d3Sopenharmony_ci#define ROOT_SECRET_LEN 32 29094332d3Sopenharmony_ci#define NO_CHECK_PIN_EXPIRED_PERIOD 0 30094332d3Sopenharmony_ci#define MAX_GLOBAL_CONFIG_NUM (1 + MAX_AUTH_TYPE_LEN * 1) 31094332d3Sopenharmony_ci 32094332d3Sopenharmony_citypedef struct { 33094332d3Sopenharmony_ci uint64_t credentialId; 34094332d3Sopenharmony_ci uint64_t templateId; 35094332d3Sopenharmony_ci uint32_t authType; 36094332d3Sopenharmony_ci uint32_t executorSensorHint; 37094332d3Sopenharmony_ci uint32_t executorMatcher; 38094332d3Sopenharmony_ci uint32_t capabilityLevel; 39094332d3Sopenharmony_ci uint64_t enrolledSysTime; 40094332d3Sopenharmony_ci} CredentialInfoHal; 41094332d3Sopenharmony_ci 42094332d3Sopenharmony_citypedef struct { 43094332d3Sopenharmony_ci uint32_t authType; 44094332d3Sopenharmony_ci uint64_t enrolledId; 45094332d3Sopenharmony_ci} EnrolledInfoHal; 46094332d3Sopenharmony_ci 47094332d3Sopenharmony_citypedef struct { 48094332d3Sopenharmony_ci int32_t userId; 49094332d3Sopenharmony_ci uint64_t secUid; 50094332d3Sopenharmony_ci uint64_t pinSubType; 51094332d3Sopenharmony_ci uint64_t cachePinSubType; 52094332d3Sopenharmony_ci LinkedList *credentialInfoList; 53094332d3Sopenharmony_ci LinkedList *enrolledInfoList; 54094332d3Sopenharmony_ci int32_t userType; 55094332d3Sopenharmony_ci} UserInfo; 56094332d3Sopenharmony_ci 57094332d3Sopenharmony_citypedef struct { 58094332d3Sopenharmony_ci int32_t userId; 59094332d3Sopenharmony_ci uint64_t secUid; 60094332d3Sopenharmony_ci uint32_t pinSubType; 61094332d3Sopenharmony_ci uint32_t enrollNum; 62094332d3Sopenharmony_ci EnrolledInfoHal enrolledInfo[MAX_ENROLL_OUTPUT]; 63094332d3Sopenharmony_ci} UserInfoResult; 64094332d3Sopenharmony_ci 65094332d3Sopenharmony_citypedef struct { 66094332d3Sopenharmony_ci uint64_t credentialDigest; 67094332d3Sopenharmony_ci uint16_t credentialCount; 68094332d3Sopenharmony_ci} EnrolledStateHal; 69094332d3Sopenharmony_ci 70094332d3Sopenharmony_cienum GlobalConfigTypeHal : int32_t { 71094332d3Sopenharmony_ci PIN_EXPIRED_PERIOD = 1, 72094332d3Sopenharmony_ci ENABLE_STATUS = 2, 73094332d3Sopenharmony_ci}; 74094332d3Sopenharmony_ci 75094332d3Sopenharmony_ciunion GlobalConfigValueHal { 76094332d3Sopenharmony_ci int64_t pinExpiredPeriod; 77094332d3Sopenharmony_ci bool enableStatus; 78094332d3Sopenharmony_ci}; 79094332d3Sopenharmony_ci 80094332d3Sopenharmony_citypedef struct { 81094332d3Sopenharmony_ci int32_t type; 82094332d3Sopenharmony_ci union GlobalConfigValueHal value; 83094332d3Sopenharmony_ci int32_t userIds[MAX_USER]; 84094332d3Sopenharmony_ci uint32_t userIdNum; 85094332d3Sopenharmony_ci uint32_t authTypes[MAX_AUTH_TYPE_LEN]; 86094332d3Sopenharmony_ci uint32_t authTypeNum; 87094332d3Sopenharmony_ci} GlobalConfigParamHal; 88094332d3Sopenharmony_ci 89094332d3Sopenharmony_citypedef struct { 90094332d3Sopenharmony_ci int32_t type; 91094332d3Sopenharmony_ci union GlobalConfigValueHal value; 92094332d3Sopenharmony_ci int32_t userIds[MAX_USER]; 93094332d3Sopenharmony_ci uint32_t userIdNum; 94094332d3Sopenharmony_ci uint32_t authType; 95094332d3Sopenharmony_ci} GlobalConfigInfo; 96094332d3Sopenharmony_ci 97094332d3Sopenharmony_citypedef struct { 98094332d3Sopenharmony_ci uint64_t pinEnrolledSysTime; 99094332d3Sopenharmony_ci int64_t pinExpiredPeriod; 100094332d3Sopenharmony_ci} PinExpiredInfo; 101094332d3Sopenharmony_ci 102094332d3Sopenharmony_civoid DestroyUserInfoNode(void *userInfo); 103094332d3Sopenharmony_civoid DestroyCredentialNode(void *credential); 104094332d3Sopenharmony_civoid DestroyEnrolledNode(void *enrolled); 105094332d3Sopenharmony_ciUserInfo *InitUserInfoNode(void); 106094332d3Sopenharmony_ci 107094332d3Sopenharmony_ci#ifdef __cplusplus 108094332d3Sopenharmony_ci} 109094332d3Sopenharmony_ci#endif 110094332d3Sopenharmony_ci 111094332d3Sopenharmony_ci#endif // IDM_COMMON_H