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_DATABASE_H 17094332d3Sopenharmony_ci#define IDM_DATABASE_H 18094332d3Sopenharmony_ci 19094332d3Sopenharmony_ci#include <stdint.h> 20094332d3Sopenharmony_ci 21094332d3Sopenharmony_ci#include "adaptor_memory.h" 22094332d3Sopenharmony_ci#include "defines.h" 23094332d3Sopenharmony_ci#include "idm_common.h" 24094332d3Sopenharmony_ci#include "linked_list.h" 25094332d3Sopenharmony_ci 26094332d3Sopenharmony_ci#ifdef __cplusplus 27094332d3Sopenharmony_ciextern "C" { 28094332d3Sopenharmony_ci#endif 29094332d3Sopenharmony_ci 30094332d3Sopenharmony_ciResultCode InitUserInfoList(void); 31094332d3Sopenharmony_civoid DestroyUserInfoList(void); 32094332d3Sopenharmony_ciUserInfo *InitUserInfoNode(void); 33094332d3Sopenharmony_ci 34094332d3Sopenharmony_citypedef enum CredentialConditionTag { 35094332d3Sopenharmony_ci CREDENTIAL_CONDITION_CREDENTIAL_ID = 1, 36094332d3Sopenharmony_ci CREDENTIAL_CONDITION_AUTH_TYPE = 2, // 1 << 1 37094332d3Sopenharmony_ci CREDENTIAL_CONDITION_TEMPLATE_ID = 4, // 1 << 2 38094332d3Sopenharmony_ci CREDENTIAL_CONDITION_SENSOR_HINT = 8, // 1 << 3 39094332d3Sopenharmony_ci CREDENTIAL_CONDITION_EXECUTOR_MATCHER = 16, // 1 << 4 40094332d3Sopenharmony_ci CREDENTIAL_CONDITION_USER_ID = 32, // 1 << 5 41094332d3Sopenharmony_ci CREDENTIAL_CONDITION_NEED_CACHE_PIN = 64, // 1 << 6 42094332d3Sopenharmony_ci} CredentialConditionTag; 43094332d3Sopenharmony_ci 44094332d3Sopenharmony_citypedef struct { 45094332d3Sopenharmony_ci uint64_t conditionFactor; 46094332d3Sopenharmony_ci uint64_t credentialId; 47094332d3Sopenharmony_ci uint64_t templateId; 48094332d3Sopenharmony_ci uint32_t authType; 49094332d3Sopenharmony_ci uint32_t executorSensorHint; 50094332d3Sopenharmony_ci uint32_t executorMatcher; 51094332d3Sopenharmony_ci int32_t userId; 52094332d3Sopenharmony_ci} CredentialCondition; 53094332d3Sopenharmony_ci 54094332d3Sopenharmony_ciResultCode GetSecureUid(int32_t userId, uint64_t *secUid); 55094332d3Sopenharmony_ciResultCode GetEnrolledInfo(int32_t userId, EnrolledInfoHal **enrolledInfos, uint32_t *num); 56094332d3Sopenharmony_ciResultCode GetEnrolledInfoAuthType(int32_t userId, uint32_t authType, EnrolledInfoHal *enrolledInfo); 57094332d3Sopenharmony_ciResultCode DeleteUserInfo(int32_t userId, LinkedList **creds); 58094332d3Sopenharmony_ci 59094332d3Sopenharmony_ciLinkedList *QueryCredentialLimit(const CredentialCondition *limit); 60094332d3Sopenharmony_ciResultCode QueryCredentialUserId(uint64_t credentialId, int32_t *userId); 61094332d3Sopenharmony_ci 62094332d3Sopenharmony_ciResultCode AddCredentialInfo(int32_t userId, CredentialInfoHal *credentialInfo, int32_t userType); 63094332d3Sopenharmony_ciResultCode SetPinSubType(int32_t userId, uint64_t pinSubType); 64094332d3Sopenharmony_ciResultCode GetPinSubType(int32_t userId, uint64_t *pinSubType); 65094332d3Sopenharmony_ciResultCode DeleteCredentialInfo(int32_t userId, uint64_t credentialId, CredentialInfoHal *credentialInfo); 66094332d3Sopenharmony_civoid ClearCachePin(int32_t userId); 67094332d3Sopenharmony_ci 68094332d3Sopenharmony_civoid SetCredentialConditionCredentialId(CredentialCondition *condition, uint64_t credentialId); 69094332d3Sopenharmony_civoid SetCredentialConditionTemplateId(CredentialCondition *condition, uint64_t templateId); 70094332d3Sopenharmony_civoid SetCredentialConditionAuthType(CredentialCondition *condition, uint32_t authType); 71094332d3Sopenharmony_civoid SetCredentialConditionExecutorSensorHint(CredentialCondition *condition, uint32_t executorSensorHint); 72094332d3Sopenharmony_civoid SetCredentialConditionExecutorMatcher(CredentialCondition *condition, uint32_t executorMatcher); 73094332d3Sopenharmony_civoid SetCredentialConditionUserId(CredentialCondition *condition, int32_t userId); 74094332d3Sopenharmony_civoid SetCredentiaConditionNeedCachePin(CredentialCondition *condition); 75094332d3Sopenharmony_ci 76094332d3Sopenharmony_ciResultCode GetAllExtUserInfo(UserInfoResult *userInfos, uint32_t userInfolen, uint32_t *userInfoCount); 77094332d3Sopenharmony_ciResultCode GetEnrolledState(int32_t userId, uint32_t authType, EnrolledStateHal *enrolledStateHal); 78094332d3Sopenharmony_ciResultCode SaveGlobalConfigParam(GlobalConfigParamHal *param); 79094332d3Sopenharmony_ciResultCode GetPinExpiredInfo(int32_t userId, PinExpiredInfo *expiredInfo); 80094332d3Sopenharmony_cibool GetEnableStatus(int32_t userId, uint32_t authType); 81094332d3Sopenharmony_ci 82094332d3Sopenharmony_ci#ifdef __cplusplus 83094332d3Sopenharmony_ci} 84094332d3Sopenharmony_ci#endif 85094332d3Sopenharmony_ci 86094332d3Sopenharmony_ci#endif // IDM_DATABASE_H