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 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 }; 74 75 union GlobalConfigValueHal { 76 int64_t pinExpiredPeriod; 77 }; 78 79 typedef struct { 80 int32_t type; 81 union GlobalConfigValueHal value; 82 } GlobalConfigParamHal; 83 84 typedef struct { 85 uint64_t pinEnrolledSysTime; 86 int64_t pinExpiredPeriod; 87 } PinExpiredInfo; 88 89 void DestroyUserInfoNode(void *userInfo); 90 void DestroyCredentialNode(void *credential); 91 void DestroyEnrolledNode(void *enrolled); 92 UserInfo *InitUserInfoNode(void); 93 94 #ifdef __cplusplus 95 } 96 #endif 97 98 #endif // IDM_COMMON_H