1526fd984Sopenharmony_ci/*
2526fd984Sopenharmony_ci * Copyright (c) 2020 Huawei Device Co., Ltd.
3526fd984Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
4526fd984Sopenharmony_ci * you may not use this file except in compliance with the License.
5526fd984Sopenharmony_ci * You may obtain a copy of the License at
6526fd984Sopenharmony_ci *
7526fd984Sopenharmony_ci *    http://www.apache.org/licenses/LICENSE-2.0
8526fd984Sopenharmony_ci *
9526fd984Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software
10526fd984Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
11526fd984Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12526fd984Sopenharmony_ci * See the License for the specific language governing permissions and
13526fd984Sopenharmony_ci * limitations under the License.
14526fd984Sopenharmony_ci */
15526fd984Sopenharmony_ci
16526fd984Sopenharmony_ci#ifndef HKS_ERRNO_H
17526fd984Sopenharmony_ci#define HKS_ERRNO_H
18526fd984Sopenharmony_ci
19526fd984Sopenharmony_ci#include "hks_types.h"
20526fd984Sopenharmony_ci
21526fd984Sopenharmony_ci/* MBEDTLS_SUCCESS */
22526fd984Sopenharmony_ci#define HKS_SUCCESS                         ((int32_t)0)
23526fd984Sopenharmony_ci/* MBEDTLS_ERROR_UNKNOWN_ERROR */
24526fd984Sopenharmony_ci#define HKS_FAILURE                         ((int32_t)-132)
25526fd984Sopenharmony_ci/* MBEDTLS_ERROR_NOT_PERMITTED */
26526fd984Sopenharmony_ci#define HKS_ERROR_NOT_PERMITTED             ((int32_t)-133)
27526fd984Sopenharmony_ci/* MBEDTLS_ERROR_NOT_SUPPORTED */
28526fd984Sopenharmony_ci#define HKS_ERROR_NOT_SUPPORTED             ((int32_t)-134)
29526fd984Sopenharmony_ci/* MBEDTLS_ERROR_INVALID_ARGUMENT */
30526fd984Sopenharmony_ci#define HKS_ERROR_INVALID_ARGUMENT          ((int32_t)-135)
31526fd984Sopenharmony_ci/* MBEDTLS_ERROR_INVALID_HANDLE */
32526fd984Sopenharmony_ci#define HKS_ERROR_INVALID_HANDLE            ((int32_t)-136)
33526fd984Sopenharmony_ci/* MBEDTLS_ERROR_BAD_STATE */
34526fd984Sopenharmony_ci#define HKS_ERROR_BAD_STATE                 ((int32_t)-137)
35526fd984Sopenharmony_ci/* MBEDTLS_ERROR_BUFFER_TOO_SMALL */
36526fd984Sopenharmony_ci#define HKS_ERROR_BUFFER_TOO_SMALL          ((int32_t)-138)
37526fd984Sopenharmony_ci/* MBEDTLS_ERROR_OCCUPIED_SLOT */
38526fd984Sopenharmony_ci#define HKS_ERROR_OCCUPIED_SLOT             ((int32_t)-139)
39526fd984Sopenharmony_ci/* MBEDTLS_ERROR_EMPTY_SLOT */
40526fd984Sopenharmony_ci#define HKS_ERROR_EMPTY_SLOT                ((int32_t)-140)
41526fd984Sopenharmony_ci/* MBEDTLS_ERROR_INSUFFICIENT_MEMORY */
42526fd984Sopenharmony_ci#define HKS_ERROR_INSUFFICIENT_MEMORY       ((int32_t)-141)
43526fd984Sopenharmony_ci/* MBEDTLS_ERROR_INSUFFICIENT_STORAGE */
44526fd984Sopenharmony_ci#define HKS_ERROR_INSUFFICIENT_STORAGE      ((int32_t)-142)
45526fd984Sopenharmony_ci/* MBEDTLS_ERROR_INSUFFICIENT_CAPACITY */
46526fd984Sopenharmony_ci#define HKS_ERROR_INSUFFICIENT_CAPACITY     ((int32_t)-143)
47526fd984Sopenharmony_ci/* MBEDTLS_ERROR_COMMUNICATION_FAILURE */
48526fd984Sopenharmony_ci#define HKS_ERROR_COMMUNICATION_FAILURE     ((int32_t)-145)
49526fd984Sopenharmony_ci/* MBEDTLS_ERROR_STORAGE_FAILURE */
50526fd984Sopenharmony_ci#define HKS_ERROR_STORAGE_FAILURE           ((int32_t)-146)
51526fd984Sopenharmony_ci/* MBEDTLS_ERROR_HARDWARE_FAILURE */
52526fd984Sopenharmony_ci#define HKS_ERROR_HARDWARE_FAILURE          ((int32_t)-147)
53526fd984Sopenharmony_ci/* MBEDTLS_ERROR_INSUFFICIENT_ENTROPY */
54526fd984Sopenharmony_ci#define HKS_ERROR_INSUFFICIENT_ENTROPY      ((int32_t)-148)
55526fd984Sopenharmony_ci/* MBEDTLS_ERROR_INVALID_SIGNATURE */
56526fd984Sopenharmony_ci#define HKS_ERROR_INVALID_SIGNATURE         ((int32_t)-149)
57526fd984Sopenharmony_ci/* MBEDTLS_ERROR_INVALID_PADDING */
58526fd984Sopenharmony_ci#define HKS_ERROR_INVALID_PADDING           ((int32_t)-150)
59526fd984Sopenharmony_ci/* MBEDTLS_ERROR_TAMPERING_DETECTED */
60526fd984Sopenharmony_ci#define HKS_ERROR_TAMPERING_DETECTED        ((int32_t)-151)
61526fd984Sopenharmony_ci/* MBEDTLS_ERROR_DATA_CORRUPT */
62526fd984Sopenharmony_ci#define HKS_ERROR_DATA_CORRUPT              ((int32_t)-152)
63526fd984Sopenharmony_ci#define HKS_ERROR_MBEDTLS_RANGE_MIN         ((int32_t)-153)
64526fd984Sopenharmony_ci
65526fd984Sopenharmony_ci/*
66526fd984Sopenharmony_ci * Error code for hks
67526fd984Sopenharmony_ci * Add new error code before HKS_ERROR_RANGE_MIN
68526fd984Sopenharmony_ci * Modify the value of HKS_ERROR_RANGE_MIN when adding an error code
69526fd984Sopenharmony_ci * The value of HKS_ERROR_RANGE_MIN = The value of new error code - 1
70526fd984Sopenharmony_ci * Such as add HKS_ERROR_XXX(-1015),must modify HKS_ERROR_RANGE_MIN to be -1016
71526fd984Sopenharmony_ci */
72526fd984Sopenharmony_ci#define HKS_STATUS_OK                       ((int32_t)0)
73526fd984Sopenharmony_ci#define HKS_ERROR_NULL_POINTER              ((int32_t)-1000)
74526fd984Sopenharmony_ci#define HKS_ERROR_DUPLICATED_REG            ((int32_t)-1001)
75526fd984Sopenharmony_ci#define HKS_ERROR_FILE_SIZE_FAIL            ((int32_t)-1002)
76526fd984Sopenharmony_ci#define HKS_ERROR_READ_FILE_FAIL            ((int32_t)-1003)
77526fd984Sopenharmony_ci#define HKS_ERROR_INVALID_PUBLIC_KEY        ((int32_t)-1004)
78526fd984Sopenharmony_ci#define HKS_ERROR_INVALID_PRIVATE_KEY       ((int32_t)-1005)
79526fd984Sopenharmony_ci#define HKS_ERROR_INVALID_KEY_INFO          ((int32_t)-1006)
80526fd984Sopenharmony_ci#define HKS_ERROR_BUF_TOO_SMALL             ((int32_t)-1007)
81526fd984Sopenharmony_ci#define HKS_ERROR_UNKNOWN_ERROR             ((int32_t)-1008)
82526fd984Sopenharmony_ci#define HKS_ERROR_ASSERT_FAIL               ((int32_t)-1009)
83526fd984Sopenharmony_ci#define HKS_ERROR_KEY_NOT_EXIST             ((int32_t)-1010)
84526fd984Sopenharmony_ci#define HKS_ERROR_HASH_NOT_EQUAL            ((int32_t)-1011)
85526fd984Sopenharmony_ci#define HKS_ERROR_MALLOC_FAIL               ((int32_t)-1012)
86526fd984Sopenharmony_ci#define HKS_ERROR_WRITE_FILE_FAIL           ((int32_t)-1013)
87526fd984Sopenharmony_ci#define HKS_ERROR_REMOVE_FILE_FAIL          ((int32_t)-1014)
88526fd984Sopenharmony_ci#define HKS_ERROR_INVALID_KEY_FILE          ((int32_t)-1015)
89526fd984Sopenharmony_ci#define HKS_ERROR_IPC_INITIAL_FAIL          ((int32_t)-1016)
90526fd984Sopenharmony_ci#define HKS_ERROR_GET_KEY_PARAM_FAIL        ((int32_t)-1017)
91526fd984Sopenharmony_ci#define HKS_ERROR_AES_ENCRYPT_FAIL          ((int32_t)-1018)
92526fd984Sopenharmony_ci#define HKS_ERROR_AES_DECRYPT_FAIL          ((int32_t)-1019)
93526fd984Sopenharmony_ci#define HKS_ERROR_SIGN_FAIL                 ((int32_t)-1020)
94526fd984Sopenharmony_ci#define HKS_ERROR_VERIFY_FAIL               ((int32_t)-1021)
95526fd984Sopenharmony_ci#define HKS_ERROR_EXPORT_FAIL               ((int32_t)-1022)
96526fd984Sopenharmony_ci#define HKS_ERROR_IMPORT_FAIL               ((int32_t)-1023)
97526fd984Sopenharmony_ci#define HKS_ERROR_WRAP_FAIL                 ((int32_t)-1024)
98526fd984Sopenharmony_ci#define HKS_ERROR_UNWRAP_FAIL               ((int32_t)-1025)
99526fd984Sopenharmony_ci#define HKS_ERROR_DELETE_FAIL               ((int32_t)-1026)
100526fd984Sopenharmony_ci#define HKS_ERROR_GENERATE_ASYM_FAIL        ((int32_t)-1027)
101526fd984Sopenharmony_ci#define HKS_ERROR_GENERATE_SYM_FAIL         ((int32_t)-1028)
102526fd984Sopenharmony_ci#define HKS_ERROR_KEY_ATTEST_FAIL           ((int32_t)-1029)
103526fd984Sopenharmony_ci#define HKS_ERROR_CERT_CHAIN_FAIL           ((int32_t)-1030)
104526fd984Sopenharmony_ci#define HKS_ERROR_GET_KEY_LIST_FAIL         ((int32_t)-1031)
105526fd984Sopenharmony_ci#define HKS_ERROR_RANGE_MIN                 ((int32_t)-1032)
106526fd984Sopenharmony_ci#define HKS_ERROR_CERT_NOT_EXIST            ((int32_t)-1033)
107526fd984Sopenharmony_ci#define HKS_ERROR_INVALID_PKI_FILE          ((int32_t)-1034)
108526fd984Sopenharmony_ci#define HKS_ERROR_CERT_VERIFY_FAIL          ((int32_t)-1035)
109526fd984Sopenharmony_ci#define HKS_ERROR_WB_DECRYPT_FAIL           ((int32_t)-1036)
110526fd984Sopenharmony_ci#define HKS_ERROR_EFUSE_WRITE_FAIL          ((int32_t)-1037)
111526fd984Sopenharmony_ci#define HKS_ERROR_EFUSE_READ_FAIL           ((int32_t)-1038)
112526fd984Sopenharmony_ci#define HKS_ERROR_EFUSE_LOCK_FAIL           ((int32_t)-1039)
113526fd984Sopenharmony_ci#define HKS_ERROR_INTERNAL_UNKOWN           ((int32_t)-9999)
114526fd984Sopenharmony_ci#define HKS_ERROR_IPC_RANGE_MIN             ((int32_t)65536)
115526fd984Sopenharmony_ci#define HKS_ERROR_IPC_RANGE_MAX             ((int32_t)65556)
116526fd984Sopenharmony_ci#define HKS_ERROR_PERMISSION_DENIED         ((int32_t)0xFF07)
117526fd984Sopenharmony_ci
118526fd984Sopenharmony_ci#endif /* HKS_ERRNO_H */
119