• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 USER_IDM_FUNCS_H
17 #define USER_IDM_FUNCS_H
18 
19 #include "idm_database.h"
20 #include "idm_session.h"
21 #include "user_sign_centre.h"
22 #include "coauth.h"
23 
24 #ifdef __cplusplus
25 extern "C" {
26 #endif
27 
28 typedef struct {
29     uint8_t token[AUTH_TOKEN_LEN];
30     int32_t userId;
31     uint32_t authType;
32     uint32_t executorSensorHint;
33     int32_t userType;
34 } PermissionCheckParam;
35 
36 typedef struct {
37     uint8_t token[AUTH_TOKEN_LEN];
38     int32_t userId;
39     uint64_t credentialId;
40 } CredentialDeleteParam;
41 
42 typedef struct {
43     uint64_t credentialId;
44     CredentialInfoHal deletedCredential;
45     Buffer *oldRootSecret;
46     Buffer *rootSecret;
47     Buffer *authToken;
48 } UpdateCredentialOutput;
49 
50 typedef enum {
51     DELETE_CREDENTIAL = 1,
52     ABANDON_CREDENTIAL = 2,
53 } OperateType;
54 
55 typedef struct {
56     OperateType operateType;
57     CoAuthSchedule scheduleInfo;
58     uint32_t credentialCount;
59     CredentialInfoHal credentialInfos[MAX_CREDENTIAL_NUM_OF_ENROLL];
60 } OperateResult;
61 
62 ResultCode CheckEnrollPermission(PermissionCheckParam *param);
63 ResultCode CheckUpdatePermission(PermissionCheckParam *param);
64 ResultCode AddCredentialFunc(int32_t userId, const Buffer *scheduleResult, uint64_t *credentialId, Buffer **rootSecret,
65     Buffer **authToken);
66 ResultCode DeleteCredentialFunc(CredentialDeleteParam param, OperateResult *operateResult);
67 ResultCode QueryCredentialFunc(int32_t userId, uint32_t authType, LinkedList **creds);
68 ResultCode GetUserInfoFunc(int32_t userId, uint64_t *secureUid, uint64_t *pinSubType,
69     EnrolledInfoHal **enrolledInfoArray, uint32_t *enrolledNum);
70 ResultCode UpdateCredentialFunc(int32_t userId, const Buffer *scheduleResult, UpdateCredentialOutput *output);
71 ResultCode QueryAllExtUserInfoFunc(UserInfoResult *userInfos, uint32_t userInfolen, uint32_t *userInfoCount);
72 CoAuthSchedule *GenerateCoAuthSchedule(PermissionCheckParam *param, ScheduleType scheduleType);
73 ResultCode UpdateAbandonResultFunc(int32_t userId, const Buffer *scheduleResult,
74     bool *isDelete, CredentialInfoHal *credentialInfo);
75 ResultCode ClearUnavailableCredentialFunc(int32_t userId, CredentialInfoHal *credentialInfo);
76 
77 #ifdef __cplusplus
78 }
79 #endif
80 
81 #endif // USER_IDM_FUNCS_H
82