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 IS_INNER_HAP_RESTORE_INDEX = 0, // 1 byte 36 IS_NEED_CHECK_CUSTOM_PROPERTY = 1, // 1 byte 37 } ReservedValue; 38 39 typedef enum { 40 RECEIVER_DECRYPT_MUST_USE_CLOUD_AND_RETURN_ENCRYPTION_VALUE = 0, 41 RECEIVER_DECRYPT_MUST_USE_CLOUD = 1, 42 ALLOW_RECEIVER_DECRYPT_WITHOUT_USE_CLOUD = 2, 43 } CloudEncOption; 44 45 typedef struct { 46 CloudEncOption opt; 47 uint8_t *extraInfo; 48 uint32_t extraInfoLen; 49 } EncAndDecOptions; 50 51 typedef struct { 52 uint8_t *accountId; 53 uint32_t accountIdLen; 54 } AccountInfo; 55 56 typedef struct { 57 char *featureName; 58 uint8_t *data; 59 uint32_t dataLen; 60 EncAndDecOptions options; 61 AccountType accountType; 62 AccountInfo senderAccountInfo; 63 uint8_t reserved[RESERVED_LEN]; 64 } DLP_PackPolicyParams; 65 66 typedef struct { 67 char *featureName; 68 uint8_t *data; 69 uint32_t dataLen; 70 EncAndDecOptions options; 71 AccountType accountType; 72 AccountInfo receiverAccountInfo; 73 uint8_t reserved[RESERVED_LEN]; 74 } DLP_EncPolicyData; 75 76 typedef struct { 77 uint8_t *data; 78 uint32_t dataLen; 79 uint8_t reserved[RESERVED_LEN]; 80 } DLP_RestorePolicyData; 81 82 typedef enum { 83 DLP_SUCCESS = 0x00000000, 84 DLP_ERROR = 0x00000001, 85 DLP_ERR_INVALID_PARAMS = 0x00000002, 86 DLP_ERR_GENERATE_KEY_FAILED = 0x00001001, 87 DLP_ERR_IPC_INTERNAL_FAILED = 0x00002001, 88 DLP_ERR_CONNECTION_TIME_OUT = 0x00003001, 89 DLP_ERR_FILE_PATH = 0x00004001, 90 DLP_ERR_CONNECTION_VIP_RIGHT_EXPIRED = 0x00003008, 91 DLP_ERR_CONNECTION_POLICY_PERMISSION_EXPIRED = 0x00003009, 92 DLP_ERR_CONNECTION_NO_PERMISSION = 0x0000300A, 93 DLP_ERR_CREDENTIAL_NOT_EXIST = 0x00005001, 94 DLP_ERR_ACCOUNT_NOT_LOG_IN = 0x00006001, 95 DLP_ERR_TOKEN_CONNECTION_FAIL = 0x00006006, 96 DLP_ERR_TOKEN_CONNECTION_TIME_OUT = 0x00006007, 97 DLP_ERR_APPID_NOT_AUTHORIZED = 0x00007003, 98 DLP_ERR_CALLBACK_TIME_OUT = 0x0000200A, 99 } DLP_ErrorCode; 100 101 typedef void (*DLP_PackPolicyCallback)(uint64_t requestId, int errorCode, DLP_EncPolicyData *outParams); 102 103 typedef void (*DLP_RestorePolicyCallback)(uint64_t requestId, int errorCode, DLP_RestorePolicyData *outParams); 104 105 #endif 106