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_DATABASE_H 17 #define IDM_DATABASE_H 18 19 #include <stdint.h> 20 21 #include "adaptor_memory.h" 22 #include "defines.h" 23 #include "idm_common.h" 24 #include "linked_list.h" 25 26 #ifdef __cplusplus 27 extern "C" { 28 #endif 29 30 ResultCode InitUserInfoList(void); 31 void DestroyUserInfoList(void); 32 UserInfo *InitUserInfoNode(void); 33 34 typedef enum CredentialConditionTag { 35 CREDENTIAL_CONDITION_CREDENTIAL_ID = 1, 36 CREDENTIAL_CONDITION_AUTH_TYPE = 2, // 1 << 1 37 CREDENTIAL_CONDITION_TEMPLATE_ID = 4, // 1 << 2 38 CREDENTIAL_CONDITION_SENSOR_HINT = 8, // 1 << 3 39 CREDENTIAL_CONDITION_EXECUTOR_MATCHER = 16, // 1 << 4 40 CREDENTIAL_CONDITION_USER_ID = 32, // 1 << 5 41 CREDENTIAL_CONDITION_NEED_CACHE_PIN = 64, // 1 << 6 42 } CredentialConditionTag; 43 44 typedef struct { 45 uint64_t conditionFactor; 46 uint64_t credentialId; 47 uint64_t templateId; 48 uint32_t authType; 49 uint32_t executorSensorHint; 50 uint32_t executorMatcher; 51 int32_t userId; 52 } CredentialCondition; 53 54 ResultCode GetSecureUid(int32_t userId, uint64_t *secUid); 55 ResultCode GetEnrolledInfo(int32_t userId, EnrolledInfoHal **enrolledInfos, uint32_t *num); 56 ResultCode GetEnrolledInfoAuthType(int32_t userId, uint32_t authType, EnrolledInfoHal *enrolledInfo); 57 ResultCode DeleteUserInfo(int32_t userId, LinkedList **creds); 58 59 LinkedList *QueryCredentialLimit(const CredentialCondition *limit); 60 ResultCode QueryCredentialUserId(uint64_t credentialId, int32_t *userId); 61 62 ResultCode AddCredentialInfo(int32_t userId, CredentialInfoHal *credentialInfo, int32_t userType); 63 ResultCode SetPinSubType(int32_t userId, uint64_t pinSubType); 64 ResultCode GetPinSubType(int32_t userId, uint64_t *pinSubType); 65 ResultCode DeleteCredentialInfo(int32_t userId, uint64_t credentialId, CredentialInfoHal *credentialInfo); 66 void ClearCachePin(int32_t userId); 67 68 void SetCredentialConditionCredentialId(CredentialCondition *condition, uint64_t credentialId); 69 void SetCredentialConditionTemplateId(CredentialCondition *condition, uint64_t templateId); 70 void SetCredentialConditionAuthType(CredentialCondition *condition, uint32_t authType); 71 void SetCredentialConditionExecutorSensorHint(CredentialCondition *condition, uint32_t executorSensorHint); 72 void SetCredentialConditionExecutorMatcher(CredentialCondition *condition, uint32_t executorMatcher); 73 void SetCredentialConditionUserId(CredentialCondition *condition, int32_t userId); 74 void SetCredentiaConditionNeedCachePin(CredentialCondition *condition); 75 76 ResultCode GetAllExtUserInfo(UserInfoResult *userInfos, uint32_t userInfolen, uint32_t *userInfoCount); 77 ResultCode GetEnrolledState(int32_t userId, uint32_t authType, EnrolledStateHal *enrolledStateHal); 78 ResultCode SaveGlobalConfigParam(GlobalConfigParamHal *param); 79 ResultCode GetPinExpiredInfo(int32_t userId, PinExpiredInfo *expiredInfo); 80 ResultCode QueryCredentialByIdFunc(uint64_t credentialId, LinkedList **creds); 81 82 #ifdef __cplusplus 83 } 84 #endif 85 86 #endif // IDM_DATABASE_H