• 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 USERIAM_EXECUTOR_MESSAGE_H
17 #define USERIAM_EXECUTOR_MESSAGE_H
18 
19 #include <stdint.h>
20 
21 #include "buffer.h"
22 #include "defines.h"
23 #include "linked_list.h"
24 
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28 
29 #define BUFFER_SIZE 2048
30 typedef enum AuthAttributeType {
31     /* Root tag */
32     AUTH_ROOT = 100000,
33     /* Result code */
34     AUTH_RESULT_CODE = 100001,
35     /* Tag of signature data in TLV */
36     AUTH_SIGNATURE = 100004,
37     /* Identify mode */
38     AUTH_IDENTIFY_MODE = 100005,
39     /* Tag of templateId data in TLV */
40     AUTH_TEMPLATE_ID = 100006,
41     /* Tag of templateId list data in TLV */
42     AUTH_TEMPLATE_ID_LIST = 100007,
43     /* Expected attribute, tag of remain count in TLV */
44     AUTH_REMAIN_COUNT = 100009,
45     /* Remain time */
46     AUTH_REMAIN_TIME = 100010,
47     /* Session id, required when decode in C */
48     AUTH_SCHEDULE_ID = 100014,
49     /* Package name */
50     AUTH_CALLER_NAME = 100015,
51     /* Schedule version */
52     AUTH_SCHEDULE_VERSION = 100016,
53     /* Tag of lock out template in TLV */
54     AUTH_LOCK_OUT_TEMPLATE = 100018,
55     /* Tag of unlock template in TLV */
56     AUTH_UNLOCK_TEMPLATE = 100019,
57     /* Tag of data */
58     AUTH_DATA = 100020,
59     /* Tag of auth subType */
60     AUTH_SUBTYPE = 100021,
61     /* Tag of auth schedule mode */
62     AUTH_SCHEDULE_MODE = 100022,
63     /* Tag of property */
64     AUTH_PROPERTY_MODE = 100023,
65     /* Tag of auth type */
66     AUTH_TYPE = 100024,
67     /* Tag of cred id */
68     AUTH_CREDENTIAL_ID = 100025,
69     /* Controller */
70     AUTH_CONTROLLER = 100026,
71     /* calleruid */
72     AUTH_CALLER_UID = 100027,
73     /* result */
74     AUTH_RESULT = 100028,
75     /* capability level */
76     AUTH_CAPABILITY_LEVEL = 100029,
77     /* algorithm setinfo */
78     ALGORITHM_INFO = 100030,
79     /* time stamp */
80     AUTH_TIME_STAMP = 100031,
81     /* root secret */
82     AUTH_ROOT_SECRET = 100032,
83 } AuthAttributeType; // the new tag must be consistent with userauth SA
84 
85 typedef struct ExecutorResultInfo {
86     int32_t result;
87     uint64_t scheduleId;
88     uint64_t templateId;
89     uint64_t authSubType;
90     uint32_t capabilityLevel;
91     int32_t freezingTime;
92     int32_t remainTimes;
93     Buffer *rootSecret;
94 } ExecutorResultInfo;
95 
96 typedef struct ExecutorMsg {
97     uint64_t executorIndex;
98     Buffer *msg;
99 } ExecutorMsg;
100 
101 ExecutorResultInfo *CreateExecutorResultInfo(const Buffer *executorResultInfo);
102 void DestoryExecutorResultInfo(ExecutorResultInfo *result);
103 ResultCode GetExecutorMsgList(uint32_t authPropertyMode, LinkedList **executorMsg);
104 
105 #ifdef __cplusplus
106 }
107 #endif
108 
109 #endif // USERIAM_EXECUTOR_MESSAGE_H