1 /* 2 * Copyright (C) 2022 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 } CredentialConditionTag; 42 43 typedef struct { 44 uint64_t conditionFactor; 45 uint64_t credentialId; 46 uint64_t templateId; 47 uint32_t authType; 48 uint32_t executorSensorHint; 49 uint32_t executorMatcher; 50 int32_t userId; 51 } CredentialCondition; 52 53 ResultCode GetSecureUid(int32_t userId, uint64_t *secUid); 54 ResultCode GetEnrolledInfo(int32_t userId, EnrolledInfoHal **enrolledInfos, uint32_t *num); 55 ResultCode GetEnrolledInfoAuthType(int32_t userId, uint32_t authType, EnrolledInfoHal *enrolledInfo); 56 ResultCode DeleteUserInfo(int32_t userId, LinkedList **creds); 57 58 LinkedList *QueryCredentialLimit(const CredentialCondition *limit); 59 ResultCode QueryCredentialUserId(uint64_t credentialId, int32_t *userId); 60 61 ResultCode AddCredentialInfo(int32_t userId, CredentialInfoHal *credentialInfo); 62 ResultCode SetPinSubType(int32_t userId, uint64_t pinSubType); 63 ResultCode GetPinSubType(int32_t userId, uint64_t *pinSubType); 64 ResultCode DeleteCredentialInfo(int32_t userId, uint64_t credentialId, CredentialInfoHal *credentialInfo); 65 66 void SetCredentialConditionCredentialId(CredentialCondition *condition, uint64_t credentialId); 67 void SetCredentialConditionTemplateId(CredentialCondition *condition, uint64_t templateId); 68 void SetCredentialConditionAuthType(CredentialCondition *condition, uint32_t authType); 69 void SetCredentialConditionExecutorSensorHint(CredentialCondition *condition, uint32_t executorSensorHint); 70 void SetCredentialConditionExecutorMatcher(CredentialCondition *condition, uint32_t executorMatcher); 71 void SetCredentialConditionUserId(CredentialCondition *condition, int32_t userId); 72 73 #ifdef __cplusplus 74 } 75 #endif 76 77 #endif // IDM_DATABASE_H