• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * @file hks_errno.h
3  *
4  * Copyright (c) 2020 Huawei Device Co., Ltd.
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  *     http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 
18 /**
19  * @defgroup iot_hks
20  * @ingroup hks
21  */
22 
23 #ifndef HKS_ERRNO_H
24 #define HKS_ERRNO_H
25 
26 #include "hks_types.h"
27 
28 /* MBEDTLS_SUCCESS */
29 #define HKS_SUCCESS                         ((int32_t)0)
30 /* MBEDTLS_ERROR_UNKNOWN_ERROR */
31 #define HKS_FAILURE                         ((int32_t)-132)
32 /* MBEDTLS_ERROR_NOT_PERMITTED */
33 #define HKS_ERROR_NOT_PERMITTED             ((int32_t)-133)
34 /* MBEDTLS_ERROR_NOT_SUPPORTED */
35 #define HKS_ERROR_NOT_SUPPORTED             ((int32_t)-134)
36 /* MBEDTLS_ERROR_INVALID_ARGUMENT */
37 #define HKS_ERROR_INVALID_ARGUMENT          ((int32_t)-135)
38 /* MBEDTLS_ERROR_INVALID_HANDLE */
39 #define HKS_ERROR_INVALID_HANDLE            ((int32_t)-136)
40 /* MBEDTLS_ERROR_BAD_STATE */
41 #define HKS_ERROR_BAD_STATE                 ((int32_t)-137)
42 /* MBEDTLS_ERROR_BUFFER_TOO_SMALL */
43 #define HKS_ERROR_BUFFER_TOO_SMALL          ((int32_t)-138)
44 /* MBEDTLS_ERROR_OCCUPIED_SLOT */
45 #define HKS_ERROR_OCCUPIED_SLOT             ((int32_t)-139)
46 /* MBEDTLS_ERROR_EMPTY_SLOT */
47 #define HKS_ERROR_EMPTY_SLOT                ((int32_t)-140)
48 /* MBEDTLS_ERROR_INSUFFICIENT_MEMORY */
49 #define HKS_ERROR_INSUFFICIENT_MEMORY       ((int32_t)-141)
50 /* MBEDTLS_ERROR_INSUFFICIENT_STORAGE */
51 #define HKS_ERROR_INSUFFICIENT_STORAGE      ((int32_t)-142)
52 /* MBEDTLS_ERROR_INSUFFICIENT_CAPACITY */
53 #define HKS_ERROR_INSUFFICIENT_CAPACITY     ((int32_t)-143)
54 /* MBEDTLS_ERROR_COMMUNICATION_FAILURE */
55 #define HKS_ERROR_COMMUNICATION_FAILURE     ((int32_t)-145)
56 /* MBEDTLS_ERROR_STORAGE_FAILURE */
57 #define HKS_ERROR_STORAGE_FAILURE           ((int32_t)-146)
58 /* MBEDTLS_ERROR_HARDWARE_FAILURE */
59 #define HKS_ERROR_HARDWARE_FAILURE          ((int32_t)-147)
60 /* MBEDTLS_ERROR_INSUFFICIENT_ENTROPY */
61 #define HKS_ERROR_INSUFFICIENT_ENTROPY      ((int32_t)-148)
62 /* MBEDTLS_ERROR_INVALID_SIGNATURE */
63 #define HKS_ERROR_INVALID_SIGNATURE         ((int32_t)-149)
64 /* MBEDTLS_ERROR_INVALID_PADDING */
65 #define HKS_ERROR_INVALID_PADDING           ((int32_t)-150)
66 /* MBEDTLS_ERROR_TAMPERING_DETECTED */
67 #define HKS_ERROR_TAMPERING_DETECTED        ((int32_t)-151)
68 /* MBEDTLS_ERROR_DATA_CORRUPT */
69 #define HKS_ERROR_DATA_CORRUPT              ((int32_t)-152)
70 #define HKS_ERROR_MBEDTLS_RANGE_MIN         ((int32_t)-153)
71 
72 /*
73  * Error code for hks
74  * Add new error code before HKS_ERROR_RANGE_MIN
75  * Modify the value of HKS_ERROR_RANGE_MIN when adding an error code
76  * The value of HKS_ERROR_RANGE_MIN = The value of new error code - 1
77  * Such as add HKS_ERROR_XXX(-1015),must modify HKS_ERROR_RANGE_MIN to be -1016
78  */
79 #define HKS_STATUS_OK                       ((int32_t)0)
80 #define HKS_ERROR_NULL_POINTER              ((int32_t)-1000)
81 #define HKS_ERROR_DUPLICATED_REG            ((int32_t)-1001)
82 #define HKS_ERROR_FILE_SIZE_FAIL            ((int32_t)-1002)
83 #define HKS_ERROR_READ_FILE_FAIL            ((int32_t)-1003)
84 #define HKS_ERROR_INVALID_PUBLIC_KEY        ((int32_t)-1004)
85 #define HKS_ERROR_INVALID_PRIVATE_KEY       ((int32_t)-1005)
86 #define HKS_ERROR_INVALID_KEY_INFO          ((int32_t)-1006)
87 #define HKS_ERROR_BUF_TOO_SMALL             ((int32_t)-1007)
88 #define HKS_ERROR_UNKNOWN_ERROR             ((int32_t)-1008)
89 #define HKS_ERROR_ASSERT_FAIL               ((int32_t)-1009)
90 #define HKS_ERROR_KEY_NOT_EXIST             ((int32_t)-1010)
91 #define HKS_ERROR_HASH_NOT_EQUAL            ((int32_t)-1011)
92 #define HKS_ERROR_MALLOC_FAIL               ((int32_t)-1012)
93 #define HKS_ERROR_WRITE_FILE_FAIL           ((int32_t)-1013)
94 #define HKS_ERROR_REMOVE_FILE_FAIL          ((int32_t)-1014)
95 #define HKS_ERROR_INVALID_KEY_FILE          ((int32_t)-1015)
96 #define HKS_ERROR_IPC_INITIAL_FAIL          ((int32_t)-1016)
97 #define HKS_ERROR_GET_KEY_PARAM_FAIL        ((int32_t)-1017)
98 #define HKS_ERROR_AES_ENCRYPT_FAIL          ((int32_t)-1018)
99 #define HKS_ERROR_AES_DECRYPT_FAIL          ((int32_t)-1019)
100 #define HKS_ERROR_SIGN_FAIL                 ((int32_t)-1020)
101 #define HKS_ERROR_VERIFY_FAIL               ((int32_t)-1021)
102 #define HKS_ERROR_EXPORT_FAIL               ((int32_t)-1022)
103 #define HKS_ERROR_IMPORT_FAIL               ((int32_t)-1023)
104 #define HKS_ERROR_WRAP_FAIL                 ((int32_t)-1024)
105 #define HKS_ERROR_UNWRAP_FAIL               ((int32_t)-1025)
106 #define HKS_ERROR_DELETE_FAIL               ((int32_t)-1026)
107 #define HKS_ERROR_GENERATE_ASYM_FAIL        ((int32_t)-1027)
108 #define HKS_ERROR_GENERATE_SYM_FAIL         ((int32_t)-1028)
109 #define HKS_ERROR_KEY_ATTEST_FAIL           ((int32_t)-1029)
110 #define HKS_ERROR_CERT_CHAIN_FAIL           ((int32_t)-1030)
111 #define HKS_ERROR_GET_KEY_LIST_FAIL         ((int32_t)-1031)
112 #define HKS_ERROR_RANGE_MIN                 ((int32_t)-1032)
113 #define HKS_ERROR_CERT_NOT_EXIST            ((int32_t)-1033)
114 #define HKS_ERROR_INVALID_PKI_FILE          ((int32_t)-1034)
115 #define HKS_ERROR_CERT_VERIFY_FAIL          ((int32_t)-1035)
116 #define HKS_ERROR_WB_DECRYPT_FAIL           ((int32_t)-1036)
117 #define HKS_ERROR_EFUSE_WRITE_FAIL          ((int32_t)-1037)
118 #define HKS_ERROR_EFUSE_READ_FAIL           ((int32_t)-1038)
119 #define HKS_ERROR_EFUSE_LOCK_FAIL           ((int32_t)-1039)
120 #define HKS_ERROR_INTERNAL_UNKOWN           ((int32_t)-9999)
121 #define HKS_ERROR_IPC_RANGE_MIN             ((int32_t)65536)
122 #define HKS_ERROR_IPC_RANGE_MAX             ((int32_t)65556)
123 #define HKS_ERROR_PERMISSION_DENIED         ((int32_t)0xFF07)
124 
125 #endif /* HKS_ERRNO_H */
126