• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2022-2023 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 USERIAM_COAUTH_H
17 #define USERIAM_COAUTH_H
18 
19 #include "c_array.h"
20 #include "defines.h"
21 #include "pool.h"
22 
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26 
27 #define INVALID_SESSION_ID 0
28 #define MAX_EXECUTOR_SIZE 2
29 #define MAX_SCHEDULE_NUM 51
30 
31 typedef union AssociateId {
32     uint64_t contextId;
33     int32_t userId;
34 } AssociateId;
35 
36 typedef struct ScheduleParam {
37     uint32_t authType;
38     ScheduleMode scheduleMode;
39     AssociateId associateId;
40     Uint64Array *templateIds;
41     uint32_t collectorSensorHint;
42     uint32_t verifierSensorHint;
43     uint32_t executorMatcher;
44 } ScheduleParam;
45 
46 typedef struct CoAuthSchedule {
47     uint64_t scheduleId;
48     uint32_t authType;
49     ScheduleMode scheduleMode;
50     AssociateId associateId;
51     Uint64Array templateIds;
52     uint32_t executorSize;
53     ExecutorInfoHal executors[MAX_EXECUTOR_SIZE];
54 } CoAuthSchedule;
55 
56 ResultCode InitCoAuth(void);
57 void DestoryCoAuth(void);
58 
59 CoAuthSchedule *GenerateSchedule(const ScheduleParam *param);
60 
61 ResultCode AddCoAuthSchedule(const CoAuthSchedule *coAuthSchedule);
62 ResultCode RemoveCoAuthSchedule(uint64_t scheduleId);
63 const CoAuthSchedule *GetCoAuthSchedule(uint64_t scheduleId);
64 uint32_t GetScheduleVeriferSensorHint(const CoAuthSchedule *coAuthSchedule);
65 void DestroyCoAuthSchedule(CoAuthSchedule *coAuthSchedule);
66 CoAuthSchedule *CopyCoAuthSchedule(const CoAuthSchedule *coAuthSchedule);
67 void DestroyScheduleNode(void *data);
68 bool IsTemplateArraysValid(const Uint64Array *templateIds);
69 ResultCode CopyTemplateArrays(const Uint64Array *in, Uint64Array *out);
70 
71 #ifdef __cplusplus
72 }
73 #endif
74 
75 #endif
76