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 
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26 
27 typedef struct {
28     uint8_t token[AUTH_TOKEN_LEN];
29     int32_t userId;
30     uint32_t authType;
31     uint32_t executorSensorHint;
32     int32_t userType;
33 } PermissionCheckParam;
34 
35 typedef struct {
36     uint8_t token[AUTH_TOKEN_LEN];
37     int32_t userId;
38     uint64_t credentialId;
39 } CredentialDeleteParam;
40 
41 typedef struct {
42     uint64_t credentialId;
43     CredentialInfoHal deletedCredential;
44     Buffer *oldRootSecret;
45     Buffer *rootSecret;
46     Buffer *authToken;
47 } UpdateCredentialOutput;
48 
49 ResultCode CheckEnrollPermission(PermissionCheckParam param, uint64_t *scheduleId);
50 ResultCode CheckUpdatePermission(PermissionCheckParam param, uint64_t *scheduleId);
51 ResultCode AddCredentialFunc(int32_t userId, const Buffer *scheduleResult, uint64_t *credentialId, Buffer **rootSecret,
52     Buffer **authToken);
53 ResultCode DeleteCredentialFunc(CredentialDeleteParam param, CredentialInfoHal *credentialInfo);
54 ResultCode QueryCredentialFunc(int32_t userId, uint32_t authType, LinkedList **creds);
55 ResultCode GetUserInfoFunc(int32_t userId, uint64_t *secureUid, uint64_t *pinSubType,
56     EnrolledInfoHal **enrolledInfoArray, uint32_t *enrolledNum);
57 ResultCode UpdateCredentialFunc(int32_t userId, const Buffer *scheduleResult, UpdateCredentialOutput *output);
58 ResultCode QueryAllExtUserInfoFunc(UserInfoResult *userInfos, uint32_t userInfolen, uint32_t *userInfoCount);
59 
60 #ifdef __cplusplus
61 }
62 #endif
63 
64 #endif // USER_IDM_FUNCS_H
65