blob: 2ce760fe2048e7296615bb6766f975cf2b0c37d8 [file] [log] [blame]
Christopher Ferris48af7cb2017-02-21 12:35:09 -08001/****************************************************************************
2 ****************************************************************************
3 ***
4 *** This header was automatically generated from a Linux kernel header
5 *** of the same name, to make information necessary for userspace to
6 *** call into the kernel available to libc. It contains only constants,
7 *** structures, and macros generated from the original header, and thus,
8 *** contains no copyrightable information.
9 ***
10 *** To edit the content of this header, modify the corresponding
11 *** source file (e.g. under external/kernel-headers/original/) then
12 *** run bionic/libc/kernel/tools/update_all.py
13 ***
14 *** Any manual change here will be lost the next time this script will
15 *** be run. You've been warned!
16 ***
17 ****************************************************************************
18 ****************************************************************************/
19#ifndef _VIRTIO_CRYPTO_H
20#define _VIRTIO_CRYPTO_H
21#include <linux/types.h>
22#include <linux/virtio_types.h>
Christopher Ferris48af7cb2017-02-21 12:35:09 -080023#include <linux/virtio_ids.h>
24#include <linux/virtio_config.h>
25#define VIRTIO_CRYPTO_SERVICE_CIPHER 0
26#define VIRTIO_CRYPTO_SERVICE_HASH 1
Christopher Ferris48af7cb2017-02-21 12:35:09 -080027#define VIRTIO_CRYPTO_SERVICE_MAC 2
28#define VIRTIO_CRYPTO_SERVICE_AEAD 3
29#define VIRTIO_CRYPTO_OPCODE(service,op) (((service) << 8) | (op))
30struct virtio_crypto_ctrl_header {
Christopher Ferris48af7cb2017-02-21 12:35:09 -080031#define VIRTIO_CRYPTO_CIPHER_CREATE_SESSION VIRTIO_CRYPTO_OPCODE(VIRTIO_CRYPTO_SERVICE_CIPHER, 0x02)
32#define VIRTIO_CRYPTO_CIPHER_DESTROY_SESSION VIRTIO_CRYPTO_OPCODE(VIRTIO_CRYPTO_SERVICE_CIPHER, 0x03)
33#define VIRTIO_CRYPTO_HASH_CREATE_SESSION VIRTIO_CRYPTO_OPCODE(VIRTIO_CRYPTO_SERVICE_HASH, 0x02)
34#define VIRTIO_CRYPTO_HASH_DESTROY_SESSION VIRTIO_CRYPTO_OPCODE(VIRTIO_CRYPTO_SERVICE_HASH, 0x03)
Christopher Ferris48af7cb2017-02-21 12:35:09 -080035#define VIRTIO_CRYPTO_MAC_CREATE_SESSION VIRTIO_CRYPTO_OPCODE(VIRTIO_CRYPTO_SERVICE_MAC, 0x02)
36#define VIRTIO_CRYPTO_MAC_DESTROY_SESSION VIRTIO_CRYPTO_OPCODE(VIRTIO_CRYPTO_SERVICE_MAC, 0x03)
37#define VIRTIO_CRYPTO_AEAD_CREATE_SESSION VIRTIO_CRYPTO_OPCODE(VIRTIO_CRYPTO_SERVICE_AEAD, 0x02)
38#define VIRTIO_CRYPTO_AEAD_DESTROY_SESSION VIRTIO_CRYPTO_OPCODE(VIRTIO_CRYPTO_SERVICE_AEAD, 0x03)
Christopher Ferris48af7cb2017-02-21 12:35:09 -080039 __le32 opcode;
40 __le32 algo;
41 __le32 flag;
42 __le32 queue_id;
Christopher Ferris48af7cb2017-02-21 12:35:09 -080043};
44struct virtio_crypto_cipher_session_para {
45#define VIRTIO_CRYPTO_NO_CIPHER 0
46#define VIRTIO_CRYPTO_CIPHER_ARC4 1
Christopher Ferris48af7cb2017-02-21 12:35:09 -080047#define VIRTIO_CRYPTO_CIPHER_AES_ECB 2
48#define VIRTIO_CRYPTO_CIPHER_AES_CBC 3
49#define VIRTIO_CRYPTO_CIPHER_AES_CTR 4
50#define VIRTIO_CRYPTO_CIPHER_DES_ECB 5
Christopher Ferris48af7cb2017-02-21 12:35:09 -080051#define VIRTIO_CRYPTO_CIPHER_DES_CBC 6
52#define VIRTIO_CRYPTO_CIPHER_3DES_ECB 7
53#define VIRTIO_CRYPTO_CIPHER_3DES_CBC 8
54#define VIRTIO_CRYPTO_CIPHER_3DES_CTR 9
Christopher Ferris48af7cb2017-02-21 12:35:09 -080055#define VIRTIO_CRYPTO_CIPHER_KASUMI_F8 10
56#define VIRTIO_CRYPTO_CIPHER_SNOW3G_UEA2 11
57#define VIRTIO_CRYPTO_CIPHER_AES_F8 12
58#define VIRTIO_CRYPTO_CIPHER_AES_XTS 13
Christopher Ferris48af7cb2017-02-21 12:35:09 -080059#define VIRTIO_CRYPTO_CIPHER_ZUC_EEA3 14
60 __le32 algo;
61 __le32 keylen;
62#define VIRTIO_CRYPTO_OP_ENCRYPT 1
Christopher Ferris48af7cb2017-02-21 12:35:09 -080063#define VIRTIO_CRYPTO_OP_DECRYPT 2
64 __le32 op;
65 __le32 padding;
66};
Christopher Ferris48af7cb2017-02-21 12:35:09 -080067struct virtio_crypto_session_input {
68 __le64 session_id;
69 __le32 status;
70 __le32 padding;
Christopher Ferris48af7cb2017-02-21 12:35:09 -080071};
72struct virtio_crypto_cipher_session_req {
73 struct virtio_crypto_cipher_session_para para;
74 __u8 padding[32];
Christopher Ferris48af7cb2017-02-21 12:35:09 -080075};
76struct virtio_crypto_hash_session_para {
77#define VIRTIO_CRYPTO_NO_HASH 0
78#define VIRTIO_CRYPTO_HASH_MD5 1
Christopher Ferris48af7cb2017-02-21 12:35:09 -080079#define VIRTIO_CRYPTO_HASH_SHA1 2
80#define VIRTIO_CRYPTO_HASH_SHA_224 3
81#define VIRTIO_CRYPTO_HASH_SHA_256 4
82#define VIRTIO_CRYPTO_HASH_SHA_384 5
Christopher Ferris48af7cb2017-02-21 12:35:09 -080083#define VIRTIO_CRYPTO_HASH_SHA_512 6
84#define VIRTIO_CRYPTO_HASH_SHA3_224 7
85#define VIRTIO_CRYPTO_HASH_SHA3_256 8
86#define VIRTIO_CRYPTO_HASH_SHA3_384 9
Christopher Ferris48af7cb2017-02-21 12:35:09 -080087#define VIRTIO_CRYPTO_HASH_SHA3_512 10
88#define VIRTIO_CRYPTO_HASH_SHA3_SHAKE128 11
89#define VIRTIO_CRYPTO_HASH_SHA3_SHAKE256 12
90 __le32 algo;
Christopher Ferris48af7cb2017-02-21 12:35:09 -080091 __le32 hash_result_len;
92 __u8 padding[8];
93};
94struct virtio_crypto_hash_create_session_req {
Christopher Ferris48af7cb2017-02-21 12:35:09 -080095 struct virtio_crypto_hash_session_para para;
96 __u8 padding[40];
97};
98struct virtio_crypto_mac_session_para {
Christopher Ferris48af7cb2017-02-21 12:35:09 -080099#define VIRTIO_CRYPTO_NO_MAC 0
100#define VIRTIO_CRYPTO_MAC_HMAC_MD5 1
101#define VIRTIO_CRYPTO_MAC_HMAC_SHA1 2
102#define VIRTIO_CRYPTO_MAC_HMAC_SHA_224 3
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800103#define VIRTIO_CRYPTO_MAC_HMAC_SHA_256 4
104#define VIRTIO_CRYPTO_MAC_HMAC_SHA_384 5
105#define VIRTIO_CRYPTO_MAC_HMAC_SHA_512 6
106#define VIRTIO_CRYPTO_MAC_CMAC_3DES 25
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800107#define VIRTIO_CRYPTO_MAC_CMAC_AES 26
108#define VIRTIO_CRYPTO_MAC_KASUMI_F9 27
109#define VIRTIO_CRYPTO_MAC_SNOW3G_UIA2 28
110#define VIRTIO_CRYPTO_MAC_GMAC_AES 41
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800111#define VIRTIO_CRYPTO_MAC_GMAC_TWOFISH 42
112#define VIRTIO_CRYPTO_MAC_CBCMAC_AES 49
113#define VIRTIO_CRYPTO_MAC_CBCMAC_KASUMI_F9 50
114#define VIRTIO_CRYPTO_MAC_XCBC_AES 53
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800115 __le32 algo;
116 __le32 hash_result_len;
117 __le32 auth_key_len;
118 __le32 padding;
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800119};
120struct virtio_crypto_mac_create_session_req {
121 struct virtio_crypto_mac_session_para para;
122 __u8 padding[40];
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800123};
124struct virtio_crypto_aead_session_para {
125#define VIRTIO_CRYPTO_NO_AEAD 0
126#define VIRTIO_CRYPTO_AEAD_GCM 1
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800127#define VIRTIO_CRYPTO_AEAD_CCM 2
128#define VIRTIO_CRYPTO_AEAD_CHACHA20_POLY1305 3
129 __le32 algo;
130 __le32 key_len;
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800131 __le32 hash_result_len;
132 __le32 aad_len;
133 __le32 op;
134 __le32 padding;
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800135};
136struct virtio_crypto_aead_create_session_req {
137 struct virtio_crypto_aead_session_para para;
138 __u8 padding[32];
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800139};
140struct virtio_crypto_alg_chain_session_para {
141#define VIRTIO_CRYPTO_SYM_ALG_CHAIN_ORDER_HASH_THEN_CIPHER 1
142#define VIRTIO_CRYPTO_SYM_ALG_CHAIN_ORDER_CIPHER_THEN_HASH 2
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800143 __le32 alg_chain_order;
144#define VIRTIO_CRYPTO_SYM_HASH_MODE_PLAIN 1
145#define VIRTIO_CRYPTO_SYM_HASH_MODE_AUTH 2
146#define VIRTIO_CRYPTO_SYM_HASH_MODE_NESTED 3
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800147 __le32 hash_mode;
148 struct virtio_crypto_cipher_session_para cipher_param;
149 union {
150 struct virtio_crypto_hash_session_para hash_param;
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800151 struct virtio_crypto_mac_session_para mac_param;
152 __u8 padding[16];
153 } u;
154 __le32 aad_len;
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800155 __le32 padding;
156};
157struct virtio_crypto_alg_chain_session_req {
158 struct virtio_crypto_alg_chain_session_para para;
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800159};
160struct virtio_crypto_sym_create_session_req {
161 union {
162 struct virtio_crypto_cipher_session_req cipher;
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800163 struct virtio_crypto_alg_chain_session_req chain;
164 __u8 padding[48];
165 } u;
166#define VIRTIO_CRYPTO_SYM_OP_NONE 0
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800167#define VIRTIO_CRYPTO_SYM_OP_CIPHER 1
168#define VIRTIO_CRYPTO_SYM_OP_ALGORITHM_CHAINING 2
169 __le32 op_type;
170 __le32 padding;
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800171};
172struct virtio_crypto_destroy_session_req {
173 __le64 session_id;
174 __u8 padding[48];
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800175};
176struct virtio_crypto_op_ctrl_req {
177 struct virtio_crypto_ctrl_header header;
178 union {
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800179 struct virtio_crypto_sym_create_session_req sym_create_session;
180 struct virtio_crypto_hash_create_session_req hash_create_session;
181 struct virtio_crypto_mac_create_session_req mac_create_session;
182 struct virtio_crypto_aead_create_session_req aead_create_session;
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800183 struct virtio_crypto_destroy_session_req destroy_session;
184 __u8 padding[56];
185 } u;
186};
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800187struct virtio_crypto_op_header {
188#define VIRTIO_CRYPTO_CIPHER_ENCRYPT VIRTIO_CRYPTO_OPCODE(VIRTIO_CRYPTO_SERVICE_CIPHER, 0x00)
189#define VIRTIO_CRYPTO_CIPHER_DECRYPT VIRTIO_CRYPTO_OPCODE(VIRTIO_CRYPTO_SERVICE_CIPHER, 0x01)
190#define VIRTIO_CRYPTO_HASH VIRTIO_CRYPTO_OPCODE(VIRTIO_CRYPTO_SERVICE_HASH, 0x00)
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800191#define VIRTIO_CRYPTO_MAC VIRTIO_CRYPTO_OPCODE(VIRTIO_CRYPTO_SERVICE_MAC, 0x00)
192#define VIRTIO_CRYPTO_AEAD_ENCRYPT VIRTIO_CRYPTO_OPCODE(VIRTIO_CRYPTO_SERVICE_AEAD, 0x00)
193#define VIRTIO_CRYPTO_AEAD_DECRYPT VIRTIO_CRYPTO_OPCODE(VIRTIO_CRYPTO_SERVICE_AEAD, 0x01)
194 __le32 opcode;
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800195 __le32 algo;
196 __le64 session_id;
197 __le32 flag;
198 __le32 padding;
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800199};
200struct virtio_crypto_cipher_para {
201 __le32 iv_len;
202 __le32 src_data_len;
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800203 __le32 dst_data_len;
204 __le32 padding;
205};
206struct virtio_crypto_hash_para {
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800207 __le32 src_data_len;
208 __le32 hash_result_len;
209};
210struct virtio_crypto_mac_para {
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800211 struct virtio_crypto_hash_para hash;
212};
213struct virtio_crypto_aead_para {
214 __le32 iv_len;
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800215 __le32 aad_len;
216 __le32 src_data_len;
217 __le32 dst_data_len;
218};
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800219struct virtio_crypto_cipher_data_req {
220 struct virtio_crypto_cipher_para para;
221 __u8 padding[24];
222};
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800223struct virtio_crypto_hash_data_req {
224 struct virtio_crypto_hash_para para;
225 __u8 padding[40];
226};
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800227struct virtio_crypto_mac_data_req {
228 struct virtio_crypto_mac_para para;
229 __u8 padding[40];
230};
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800231struct virtio_crypto_alg_chain_data_para {
232 __le32 iv_len;
233 __le32 src_data_len;
234 __le32 dst_data_len;
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800235 __le32 cipher_start_src_offset;
236 __le32 len_to_cipher;
237 __le32 hash_start_src_offset;
238 __le32 len_to_hash;
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800239 __le32 aad_len;
240 __le32 hash_result_len;
241 __le32 reserved;
242};
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800243struct virtio_crypto_alg_chain_data_req {
244 struct virtio_crypto_alg_chain_data_para para;
245};
246struct virtio_crypto_sym_data_req {
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800247 union {
248 struct virtio_crypto_cipher_data_req cipher;
249 struct virtio_crypto_alg_chain_data_req chain;
250 __u8 padding[40];
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800251 } u;
252 __le32 op_type;
253 __le32 padding;
254};
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800255struct virtio_crypto_aead_data_req {
256 struct virtio_crypto_aead_para para;
257 __u8 padding[32];
258};
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800259struct virtio_crypto_op_data_req {
260 struct virtio_crypto_op_header header;
261 union {
262 struct virtio_crypto_sym_data_req sym_req;
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800263 struct virtio_crypto_hash_data_req hash_req;
264 struct virtio_crypto_mac_data_req mac_req;
265 struct virtio_crypto_aead_data_req aead_req;
266 __u8 padding[48];
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800267 } u;
268};
269#define VIRTIO_CRYPTO_OK 0
270#define VIRTIO_CRYPTO_ERR 1
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800271#define VIRTIO_CRYPTO_BADMSG 2
272#define VIRTIO_CRYPTO_NOTSUPP 3
273#define VIRTIO_CRYPTO_INVSESS 4
274#define VIRTIO_CRYPTO_S_HW_READY (1 << 0)
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800275struct virtio_crypto_config {
Christopher Ferris25c18d42020-10-14 17:42:58 -0700276 __le32 status;
277 __le32 max_dataqueues;
278 __le32 crypto_services;
279 __le32 cipher_algo_l;
280 __le32 cipher_algo_h;
281 __le32 hash_algo;
282 __le32 mac_algo_l;
283 __le32 mac_algo_h;
284 __le32 aead_algo;
285 __le32 max_cipher_key_len;
286 __le32 max_auth_key_len;
287 __le32 reserve;
288 __le64 max_size;
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800289};
290struct virtio_crypto_inhdr {
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800291 __u8 status;
292};
293#endif