1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
|
/*
* Copyright (C) 2019-2021 Alibaba Group Holding Limited
*/
#ifndef _SC_ERRCODE_H
#define _SC_ERRCODE_H
/* common */
#ifndef SC_OK
#define SC_ERROR_BASE 0x10000000
#define SC_OK 0
#define SC_FAIL SC_ERROR_BASE + 1
#define SC_MEM_OVERFLOW SC_ERROR_BASE + 2
#define SC_PARAM_INV SC_ERROR_BASE + 3
#define SC_OPERATION_BUSY SC_ERROR_BASE + 4
#define SC_AUTH_FAIL SC_ERROR_BASE + 5
#define SC_CRYPT_FAIL SC_ERROR_BASE + 6
#define SC_NOT_SUPPORT SC_ERROR_BASE + 7
#define SC_INVALID_PADDING SC_ERROR_BASE + 8
#define SC_BAD_INPUT_DATA SC_ERROR_BASE + 9
#define SC_INVALID_KEY_LENGTH SC_ERROR_BASE + 10
#define SC_INVALID_INPUT_LENGTH SC_ERROR_BASE + 11
#define SC_FEATURE_UNAVAILABLE SC_ERROR_BASE + 12
#define SC_HW_ACCEL_FAILED SC_ERROR_BASE + 13
#define SC_CCM_AUTH_FAILED SC_ERROR_BASE + 14
#define SC_KEY_GEN_FAILED SC_ERROR_BASE + 15
#define SC_KEY_CHECK_FAILED SC_ERROR_BASE + 16
#define SC_PUBLIC_FAILED SC_ERROR_BASE + 17
#define SC_PRIVATE_FAILED SC_ERROR_BASE + 18
#define SC_VERIFY_FAILED SC_ERROR_BASE + 19
#define SC_OUTPUT_TOO_LARGE SC_ERROR_BASE + 20
#define SC_RNG_FAILED SC_ERROR_BASE + 21
#define SC_BUFFER_TOO_SMALL SC_ERROR_BASE + 22
#define SC_INVALID_FORMAT SC_ERROR_BASE + 23
#define SC_ALLOC_FAILED SC_ERROR_BASE + 24
#define SC_DRV_FAILED SC_ERROR_BASE + 25
#define CHECK_RET(x) \
do { \
if (!(x)) { \
LOG_CRIT("err %s, %d\n", __FUNCTION__, __LINE__); \
return; \
} \
} while (0)
#define CHECK_RET_WITH_RET(x, ret) \
do { \
if (!(x)) { \
LOG_CRIT("err %s, %d\n", __FUNCTION__, __LINE__); \
return ret; \
} \
} while (0)
#define CHECK_16byte_ALIGNMENT(_i, ret) \
if ((((uint64_t)_i) & 0xF) != 0) { \
LOG_CRIT("err %s, %d\n", __FUNCTION__, __LINE__); \
return ret; \
}
#define CHECK_32byte_ALIGNMENT(_i, ret) \
if ((((uint64_t)_i) & 0x1F) != 0) { \
LOG_CRIT("err %s, %d\n", __FUNCTION__, __LINE__); \
return ret; \
}
#define CHECK_64byte_ALIGNMENT(_i, ret) \
if ((((uint64_t)_i) & 0x3F) != 0) { \
LOG_CRIT("err %s, %d\n", __FUNCTION__, __LINE__); \
return ret; \
}
#define CHECK_PARAM_RET(c, r) \
do { \
if (!(c)) { \
LOG_CRIT("err %s, %d\n", __FUNCTION__, __LINE__); \
return (r); \
} \
} while (0)
#define CHECK_RET_VOID(c) \
do { \
if (!(c)) { \
LOG_CRIT("err %s, %d\n", __FUNCTION__, __LINE__); \
return; \
} \
} while (0)
#define CHECK_PARAM CHECK_PARAM_RET
#endif
#endif
|