1 /*
2  * Copyright (c) 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 MOCK_DLP_CREDENTIAL_CLIENT_DEFINES_H
17 #define MOCK_DLP_CREDENTIAL_CLIENT_DEFINES_H
18 
19 #include <stdint.h>
20 
21 #define RESERVED_LEN 64
22 
23 typedef enum {
24     CLOUD_ACCOUNT = 1,
25     DOMAIN_ACCOUNT,
26     APPLICATION_ACCOUNT,
27 } AccountType;
28 
29 typedef enum {
30     READ_ONLY = 1,
31     USE_PERM_IN_POLICY,
32 } OpenMode;
33 
34 typedef enum {
35     RECEIVER_DECRYPT_MUST_USE_CLOUD_AND_RETURN_ENCRYPTION_VALUE = 0,
36     RECEIVER_DECRYPT_MUST_USE_CLOUD = 1,
37     ALLOW_RECEIVER_DECRYPT_WITHOUT_USE_CLOUD = 2,
38 } CloudEncOption;
39 
40 typedef struct {
41     CloudEncOption opt;
42     uint8_t *extraInfo;
43     uint32_t extraInfoLen;
44 } EncAndDecOptions;
45 
46 typedef struct {
47     uint8_t *accountId;
48     uint32_t accountIdLen;
49 } AccountInfo;
50 
51 typedef struct {
52     char *featureName;
53     uint8_t *data;
54     uint32_t dataLen;
55     EncAndDecOptions options;
56     AccountType accountType;
57     AccountInfo senderAccountInfo;
58     uint8_t reserved[RESERVED_LEN];
59 } DLP_PackPolicyParams;
60 
61 typedef struct {
62     char *featureName;
63     uint8_t *data;
64     uint32_t dataLen;
65     EncAndDecOptions options;
66     AccountType accountType;
67     AccountInfo receiverAccountInfo;
68     uint8_t reserved[RESERVED_LEN];
69 } DLP_EncPolicyData;
70 
71 typedef struct {
72     uint8_t *data;
73     uint32_t dataLen;
74     uint8_t reserved[RESERVED_LEN];
75 } DLP_RestorePolicyData;
76 
77 typedef enum {
78     DLP_SUCCESS = 0x00000000,
79     DLP_ERROR = 0x00000001,
80     DLP_ERR_INVALID_PARAMS = 0x00000002,
81     DLP_ERR_GENERATE_KEY_FAILED = 0x00001001,
82     DLP_ERR_IPC_INTERNAL_FAILED = 0x00002001,
83     DLP_ERR_CONNECTION_TIME_OUT = 0x00003001,
84     DLP_ERR_FILE_PATH = 0x00004001,
85     DLP_ERR_CONNECTION_VIP_RIGHT_EXPIRED = 0x00003009,
86     DLP_ERR_CONNECTION_POLICY_PERMISSION_EXPIRED = 0x0000300B,
87     DLP_ERR_CONNECTION_NO_PERMISSION = 0x0000300C,
88     DLP_ERR_CREDENTIAL_NOT_EXIST = 0x00005001,
89     DLP_ERR_ACCOUNT_NOT_LOG_IN = 0x00006001,
90     DLP_ERR_TOKEN_CONNECTION_FAIL = 0x00006006,
91     DLP_ERR_TOKEN_CONNECTION_TIME_OUT = 0x00006007,
92     DLP_ERR_APPID_NOT_AUTHORIZED = 0x00007005,
93     DLP_ERR_CALLBACK_TIME_OUT = 0x0000200A,
94 } DLP_ErrorCode;
95 
96 typedef void (*DLP_PackPolicyCallback)(uint64_t requestId, int errorCode, DLP_EncPolicyData *outParams);
97 
98 typedef void (*DLP_RestorePolicyCallback)(uint64_t requestId, int errorCode, DLP_RestorePolicyData *outParams);
99 
100 #endif
101