• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 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 DEVICE_SECURITY_DEFINES_H
17 #define DEVICE_SECURITY_DEFINES_H
18 
19 #include <stdint.h>
20 
21 #ifdef __cplusplus
22 extern "C" {
23 #endif
24 
25 #define DEVICE_ID_MAX_LEN 64
26 
27 typedef struct DeviceIdentify {
28     uint32_t length;
29     uint8_t identity[DEVICE_ID_MAX_LEN];
30 } DeviceIdentify;
31 
32 typedef struct RequestOption {
33     uint64_t challenge;
34     uint32_t timeout;
35     uint32_t extra;
36 } RequestOption;
37 
38 #define DEFAULT_OPTION NULL
39 
40 /**
41  * The error code is synchronized with that in the JAVA, the JAVA code needs to be modified if C code changed.
42  * An error code can be added only at the end of the list.
43  */
44 enum {
45     SUCCESS = 0,
46     ERR_INVALID_PARA = 1,
47     ERR_INVALID_LEN_PARA = 2,
48     ERR_NO_MEMORY = 3,
49     ERR_MEMORY_ERR = 4,
50     ERR_NO_CHALLENGE = 5,
51     ERR_NO_CRED = 6,
52     ERR_SA_BUSY = 7,
53     ERR_TIMEOUT = 8,
54     ERR_NOEXIST_REQUEST = 9,
55     ERR_INVALID_VERSION = 10,
56     ERR_OEM_ERR = 11,
57     ERR_HUKS_ERR = 12,
58     ERR_CHALLENGE_ERR = 13,
59     ERR_NOT_ONLINE = 14,
60     ERR_INIT_SELF_ERR = 15,
61     ERR_JSON_ERR = 16,
62     ERR_IPC_ERR = 17,
63     ERR_IPC_REGISTER_ERR = 18,
64     ERR_IPC_REMOTE_OBJ_ERR = 19,
65     ERR_IPC_PROXY_ERR = 20,
66     ERR_IPC_RET_PARCEL_ERR = 21,
67     ERR_PROXY_REMOTE_ERR = 22,
68     ERR_MSG_NEIGHBOR_FULL = 23,
69     ERR_MSG_FULL = 24,
70     ERR_MSG_ADD_NEIGHBOR = 25,
71     ERR_MSG_NOT_INIT = 26,
72     ERR_MSG_CREATE_WORKQUEUE = 27,
73     ERR_NEED_COMPATIBLE = 28,
74     ERR_REG_CALLBACK = 29,
75     ERR_PERMISSION_DENIAL = 30,
76     ERR_REQUEST_CODE_ERR = 31,
77     ERR_VERIFY_MODE_CRED_ERR = 32,
78     ERR_VERIFY_SIGNED_MODE_CRED_ERR = 33,
79     ERR_VERIFY_MODE_HUKS_ERR = 34,
80     ERR_PROFILE_CONNECT_ERR = 35,
81     ERR_MSG_OPEN_SESSION = 36,
82     ERR_QUERY_WAITING = 37,
83     ERR_NOEXIST_DEVICE = 38,
84     ERR_NOEXIST_COMMON_PK_INFO = 39,
85     ERR_ECC_VERIFY_ERR = 40,
86     ERR_GET_CLOUD_CRED_INFO = 41,
87     ERR_CALL_EXTERNAL_FUNC = 42,
88     ERR_PARSE_NOUNCE = 43,
89     ERR_ROOT_PUBKEY_NOT_RIGHT = 44,
90     ERR_PARSE_CLOUD_CRED_DATA = 45,
91     ERR_PARSE_PUBKEY_CHAIN = 46,
92     ERR_CHECK_CRED_INFO = 47,
93     ERR_ATTEST_NOT_READY = 48,
94     ERR_CLOUD_CRED_NOT_EXIST = 49,
95     ERR_DEFAULT = 0xFFFF
96 };
97 
98 #ifdef __cplusplus
99 }
100 #endif
101 
102 #endif // DEVICE_SECURITY_DEFINES_H
103