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 5 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 #define NO_SET_PIN_EXPIRED_PERIOD (-1) 32 #define MAX_CREDENTIAL_NUM_OF_ENROLL 2 33 34 #define ABANDON_PIN_VALID_PERIOD (96 * 3600 * 1000) 35 36 typedef struct { 37 uint64_t credentialId; 38 uint64_t templateId; 39 uint32_t authType; 40 uint32_t executorSensorHint; 41 uint32_t executorMatcher; 42 uint32_t capabilityLevel; 43 uint32_t credentialType; 44 bool isAbandoned; 45 uint64_t enrolledSysTime; 46 uint64_t abandonedSysTime; 47 } CredentialInfoHal; 48 49 typedef struct { 50 uint32_t authType; 51 uint64_t enrolledId; 52 } EnrolledInfoHal; 53 54 typedef struct { 55 int32_t userId; 56 uint64_t secUid; 57 uint64_t pinSubType; 58 uint64_t cachePinSubType; 59 LinkedList *credentialInfoList; 60 LinkedList *enrolledInfoList; 61 int32_t userType; 62 } UserInfo; 63 64 typedef struct { 65 int32_t userId; 66 uint64_t secUid; 67 uint32_t pinSubType; 68 uint32_t enrollNum; 69 EnrolledInfoHal enrolledInfo[MAX_ENROLL_OUTPUT]; 70 } UserInfoResult; 71 72 typedef struct { 73 uint64_t credentialDigest; 74 uint16_t credentialCount; 75 } EnrolledStateHal; 76 77 enum GlobalConfigTypeHal : int32_t { 78 PIN_EXPIRED_PERIOD = 1, 79 ENABLE_STATUS = 2, 80 }; 81 82 union GlobalConfigValueHal { 83 int64_t pinExpiredPeriod; 84 bool enableStatus; 85 }; 86 87 typedef struct { 88 int32_t type; 89 union GlobalConfigValueHal value; 90 int32_t userIds[MAX_USER]; 91 uint32_t userIdNum; 92 uint32_t authTypes[MAX_AUTH_TYPE_LEN]; 93 uint32_t authTypeNum; 94 } GlobalConfigParamHal; 95 96 typedef struct { 97 int32_t type; 98 union GlobalConfigValueHal value; 99 int32_t userIds[MAX_USER]; 100 uint32_t userIdNum; 101 uint32_t authType; 102 } GlobalConfigInfo; 103 104 typedef struct { 105 uint64_t pinEnrolledSysTime; 106 int64_t pinExpiredPeriod; 107 } PinExpiredInfo; 108 109 void DestroyUserInfoNode(void *userInfo); 110 void DestroyCredentialNode(void *credential); 111 void DestroyEnrolledNode(void *enrolled); 112 UserInfo *InitUserInfoNode(void); 113 114 #ifdef __cplusplus 115 } 116 #endif 117 118 #endif // IDM_COMMON_H