1
2
3
4#ifndef __HISI_SEC_V2_CRYPTO_H
5#define __HISI_SEC_V2_CRYPTO_H
6
7#define SEC_IV_SIZE 24
8#define SEC_MAX_KEY_SIZE 64
9#define SEC_COMM_SCENE 0
10
11enum sec_calg {
12 SEC_CALG_3DES = 0x1,
13 SEC_CALG_AES = 0x2,
14 SEC_CALG_SM4 = 0x3,
15};
16
17enum sec_hash_alg {
18 SEC_A_HMAC_SHA1 = 0x10,
19 SEC_A_HMAC_SHA256 = 0x11,
20 SEC_A_HMAC_SHA512 = 0x15,
21};
22
23enum sec_mac_len {
24 SEC_HMAC_SHA1_MAC = 20,
25 SEC_HMAC_SHA256_MAC = 32,
26 SEC_HMAC_SHA512_MAC = 64,
27};
28
29enum sec_cmode {
30 SEC_CMODE_ECB = 0x0,
31 SEC_CMODE_CBC = 0x1,
32 SEC_CMODE_CTR = 0x4,
33 SEC_CMODE_XTS = 0x7,
34};
35
36enum sec_ckey_type {
37 SEC_CKEY_128BIT = 0x0,
38 SEC_CKEY_192BIT = 0x1,
39 SEC_CKEY_256BIT = 0x2,
40 SEC_CKEY_3DES_3KEY = 0x1,
41 SEC_CKEY_3DES_2KEY = 0x3,
42};
43
44enum sec_bd_type {
45 SEC_BD_TYPE1 = 0x1,
46 SEC_BD_TYPE2 = 0x2,
47};
48
49enum sec_auth {
50 SEC_NO_AUTH = 0x0,
51 SEC_AUTH_TYPE1 = 0x1,
52 SEC_AUTH_TYPE2 = 0x2,
53};
54
55enum sec_cipher_dir {
56 SEC_CIPHER_ENC = 0x1,
57 SEC_CIPHER_DEC = 0x2,
58};
59
60enum sec_addr_type {
61 SEC_PBUF = 0x0,
62 SEC_SGL = 0x1,
63 SEC_PRP = 0x2,
64};
65
66struct sec_sqe_type2 {
67
68
69
70
71
72
73 __le32 mac_key_alg;
74
75
76
77
78
79
80
81 __le16 icvw_kmode;
82
83
84 __u8 c_alg;
85 __u8 rsvd4;
86
87
88
89
90
91 __le32 alen_ivllen;
92
93
94
95
96
97 __le32 clen_ivhlen;
98
99 __le16 auth_src_offset;
100 __le16 cipher_src_offset;
101 __le16 cs_ip_header_offset;
102 __le16 cs_udp_header_offset;
103 __le16 pass_word_len;
104 __le16 dk_len;
105 __u8 salt3;
106 __u8 salt2;
107 __u8 salt1;
108 __u8 salt0;
109
110 __le16 tag;
111 __le16 rsvd5;
112
113
114
115
116
117
118 __le16 cph_pad;
119
120
121 __le16 c_pad_len_field;
122
123
124 __le64 long_a_data_len;
125 __le64 a_ivin_addr;
126 __le64 a_key_addr;
127 __le64 mac_addr;
128 __le64 c_ivin_addr;
129 __le64 c_key_addr;
130
131 __le64 data_src_addr;
132 __le64 data_dst_addr;
133
134
135
136
137
138
139
140
141 __le16 done_flag;
142
143 __u8 error_type;
144 __u8 warning_type;
145 __u8 mac_i3;
146 __u8 mac_i2;
147 __u8 mac_i1;
148 __u8 mac_i0;
149 __le16 check_sum_i;
150 __u8 tls_pad_len_i;
151 __u8 rsvd12;
152 __le32 counter;
153};
154
155struct sec_sqe {
156
157
158
159
160
161 __u8 type_cipher_auth;
162
163
164
165
166
167
168
169 __u8 sds_sa_type;
170
171
172
173
174
175
176
177 __u8 sdm_addr_type;
178 __u8 rsvd0;
179
180
181
182
183
184
185
186 __u8 huk_key_ci;
187
188
189
190
191
192
193 __u8 ai_apd_cs;
194
195
196
197
198
199
200
201 __u8 rca_key_frm;
202
203
204
205
206
207
208 __u8 iv_tls_ld;
209
210
211 struct sec_sqe_type2 type2;
212};
213
214int sec_register_to_crypto(void);
215void sec_unregister_from_crypto(void);
216#endif
217