blob: 1bd4d730ad52eefde0ab65507bd0e8ffd183fd5d [file] [log] [blame]
Elliott Hughes180edef2023-11-02 00:08:05 +00001/*
2 * This file is auto-generated. Modifications will be lost.
3 *
4 * See https://android.googlesource.com/platform/bionic/+/master/libc/kernel/
5 * for more information.
6 */
Christopher Ferris48af7cb2017-02-21 12:35:09 -08007#ifndef _VIRTIO_CRYPTO_H
8#define _VIRTIO_CRYPTO_H
9#include <linux/types.h>
10#include <linux/virtio_types.h>
Christopher Ferris48af7cb2017-02-21 12:35:09 -080011#include <linux/virtio_ids.h>
12#include <linux/virtio_config.h>
13#define VIRTIO_CRYPTO_SERVICE_CIPHER 0
14#define VIRTIO_CRYPTO_SERVICE_HASH 1
Christopher Ferris48af7cb2017-02-21 12:35:09 -080015#define VIRTIO_CRYPTO_SERVICE_MAC 2
16#define VIRTIO_CRYPTO_SERVICE_AEAD 3
Christopher Ferris10a76e62022-06-08 13:31:52 -070017#define VIRTIO_CRYPTO_SERVICE_AKCIPHER 4
Christopher Ferris48af7cb2017-02-21 12:35:09 -080018#define VIRTIO_CRYPTO_OPCODE(service,op) (((service) << 8) | (op))
19struct virtio_crypto_ctrl_header {
Christopher Ferris48af7cb2017-02-21 12:35:09 -080020#define VIRTIO_CRYPTO_CIPHER_CREATE_SESSION VIRTIO_CRYPTO_OPCODE(VIRTIO_CRYPTO_SERVICE_CIPHER, 0x02)
21#define VIRTIO_CRYPTO_CIPHER_DESTROY_SESSION VIRTIO_CRYPTO_OPCODE(VIRTIO_CRYPTO_SERVICE_CIPHER, 0x03)
22#define VIRTIO_CRYPTO_HASH_CREATE_SESSION VIRTIO_CRYPTO_OPCODE(VIRTIO_CRYPTO_SERVICE_HASH, 0x02)
23#define VIRTIO_CRYPTO_HASH_DESTROY_SESSION VIRTIO_CRYPTO_OPCODE(VIRTIO_CRYPTO_SERVICE_HASH, 0x03)
Christopher Ferris48af7cb2017-02-21 12:35:09 -080024#define VIRTIO_CRYPTO_MAC_CREATE_SESSION VIRTIO_CRYPTO_OPCODE(VIRTIO_CRYPTO_SERVICE_MAC, 0x02)
25#define VIRTIO_CRYPTO_MAC_DESTROY_SESSION VIRTIO_CRYPTO_OPCODE(VIRTIO_CRYPTO_SERVICE_MAC, 0x03)
26#define VIRTIO_CRYPTO_AEAD_CREATE_SESSION VIRTIO_CRYPTO_OPCODE(VIRTIO_CRYPTO_SERVICE_AEAD, 0x02)
27#define VIRTIO_CRYPTO_AEAD_DESTROY_SESSION VIRTIO_CRYPTO_OPCODE(VIRTIO_CRYPTO_SERVICE_AEAD, 0x03)
Christopher Ferris10a76e62022-06-08 13:31:52 -070028#define VIRTIO_CRYPTO_AKCIPHER_CREATE_SESSION VIRTIO_CRYPTO_OPCODE(VIRTIO_CRYPTO_SERVICE_AKCIPHER, 0x04)
29#define VIRTIO_CRYPTO_AKCIPHER_DESTROY_SESSION VIRTIO_CRYPTO_OPCODE(VIRTIO_CRYPTO_SERVICE_AKCIPHER, 0x05)
Christopher Ferris48af7cb2017-02-21 12:35:09 -080030 __le32 opcode;
31 __le32 algo;
32 __le32 flag;
33 __le32 queue_id;
Christopher Ferris48af7cb2017-02-21 12:35:09 -080034};
35struct virtio_crypto_cipher_session_para {
36#define VIRTIO_CRYPTO_NO_CIPHER 0
37#define VIRTIO_CRYPTO_CIPHER_ARC4 1
Christopher Ferris48af7cb2017-02-21 12:35:09 -080038#define VIRTIO_CRYPTO_CIPHER_AES_ECB 2
39#define VIRTIO_CRYPTO_CIPHER_AES_CBC 3
40#define VIRTIO_CRYPTO_CIPHER_AES_CTR 4
41#define VIRTIO_CRYPTO_CIPHER_DES_ECB 5
Christopher Ferris48af7cb2017-02-21 12:35:09 -080042#define VIRTIO_CRYPTO_CIPHER_DES_CBC 6
43#define VIRTIO_CRYPTO_CIPHER_3DES_ECB 7
44#define VIRTIO_CRYPTO_CIPHER_3DES_CBC 8
45#define VIRTIO_CRYPTO_CIPHER_3DES_CTR 9
Christopher Ferris48af7cb2017-02-21 12:35:09 -080046#define VIRTIO_CRYPTO_CIPHER_KASUMI_F8 10
47#define VIRTIO_CRYPTO_CIPHER_SNOW3G_UEA2 11
48#define VIRTIO_CRYPTO_CIPHER_AES_F8 12
49#define VIRTIO_CRYPTO_CIPHER_AES_XTS 13
Christopher Ferris48af7cb2017-02-21 12:35:09 -080050#define VIRTIO_CRYPTO_CIPHER_ZUC_EEA3 14
51 __le32 algo;
52 __le32 keylen;
53#define VIRTIO_CRYPTO_OP_ENCRYPT 1
Christopher Ferris48af7cb2017-02-21 12:35:09 -080054#define VIRTIO_CRYPTO_OP_DECRYPT 2
55 __le32 op;
56 __le32 padding;
57};
Christopher Ferris48af7cb2017-02-21 12:35:09 -080058struct virtio_crypto_session_input {
59 __le64 session_id;
60 __le32 status;
61 __le32 padding;
Christopher Ferris48af7cb2017-02-21 12:35:09 -080062};
63struct virtio_crypto_cipher_session_req {
64 struct virtio_crypto_cipher_session_para para;
65 __u8 padding[32];
Christopher Ferris48af7cb2017-02-21 12:35:09 -080066};
67struct virtio_crypto_hash_session_para {
68#define VIRTIO_CRYPTO_NO_HASH 0
69#define VIRTIO_CRYPTO_HASH_MD5 1
Christopher Ferris48af7cb2017-02-21 12:35:09 -080070#define VIRTIO_CRYPTO_HASH_SHA1 2
71#define VIRTIO_CRYPTO_HASH_SHA_224 3
72#define VIRTIO_CRYPTO_HASH_SHA_256 4
73#define VIRTIO_CRYPTO_HASH_SHA_384 5
Christopher Ferris48af7cb2017-02-21 12:35:09 -080074#define VIRTIO_CRYPTO_HASH_SHA_512 6
75#define VIRTIO_CRYPTO_HASH_SHA3_224 7
76#define VIRTIO_CRYPTO_HASH_SHA3_256 8
77#define VIRTIO_CRYPTO_HASH_SHA3_384 9
Christopher Ferris48af7cb2017-02-21 12:35:09 -080078#define VIRTIO_CRYPTO_HASH_SHA3_512 10
79#define VIRTIO_CRYPTO_HASH_SHA3_SHAKE128 11
80#define VIRTIO_CRYPTO_HASH_SHA3_SHAKE256 12
81 __le32 algo;
Christopher Ferris48af7cb2017-02-21 12:35:09 -080082 __le32 hash_result_len;
83 __u8 padding[8];
84};
85struct virtio_crypto_hash_create_session_req {
Christopher Ferris48af7cb2017-02-21 12:35:09 -080086 struct virtio_crypto_hash_session_para para;
87 __u8 padding[40];
88};
89struct virtio_crypto_mac_session_para {
Christopher Ferris48af7cb2017-02-21 12:35:09 -080090#define VIRTIO_CRYPTO_NO_MAC 0
91#define VIRTIO_CRYPTO_MAC_HMAC_MD5 1
92#define VIRTIO_CRYPTO_MAC_HMAC_SHA1 2
93#define VIRTIO_CRYPTO_MAC_HMAC_SHA_224 3
Christopher Ferris48af7cb2017-02-21 12:35:09 -080094#define VIRTIO_CRYPTO_MAC_HMAC_SHA_256 4
95#define VIRTIO_CRYPTO_MAC_HMAC_SHA_384 5
96#define VIRTIO_CRYPTO_MAC_HMAC_SHA_512 6
97#define VIRTIO_CRYPTO_MAC_CMAC_3DES 25
Christopher Ferris48af7cb2017-02-21 12:35:09 -080098#define VIRTIO_CRYPTO_MAC_CMAC_AES 26
99#define VIRTIO_CRYPTO_MAC_KASUMI_F9 27
100#define VIRTIO_CRYPTO_MAC_SNOW3G_UIA2 28
101#define VIRTIO_CRYPTO_MAC_GMAC_AES 41
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800102#define VIRTIO_CRYPTO_MAC_GMAC_TWOFISH 42
103#define VIRTIO_CRYPTO_MAC_CBCMAC_AES 49
104#define VIRTIO_CRYPTO_MAC_CBCMAC_KASUMI_F9 50
105#define VIRTIO_CRYPTO_MAC_XCBC_AES 53
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800106 __le32 algo;
107 __le32 hash_result_len;
108 __le32 auth_key_len;
109 __le32 padding;
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800110};
111struct virtio_crypto_mac_create_session_req {
112 struct virtio_crypto_mac_session_para para;
113 __u8 padding[40];
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800114};
115struct virtio_crypto_aead_session_para {
116#define VIRTIO_CRYPTO_NO_AEAD 0
117#define VIRTIO_CRYPTO_AEAD_GCM 1
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800118#define VIRTIO_CRYPTO_AEAD_CCM 2
119#define VIRTIO_CRYPTO_AEAD_CHACHA20_POLY1305 3
120 __le32 algo;
121 __le32 key_len;
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800122 __le32 hash_result_len;
123 __le32 aad_len;
124 __le32 op;
125 __le32 padding;
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800126};
127struct virtio_crypto_aead_create_session_req {
128 struct virtio_crypto_aead_session_para para;
129 __u8 padding[32];
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800130};
Christopher Ferris10a76e62022-06-08 13:31:52 -0700131struct virtio_crypto_rsa_session_para {
132#define VIRTIO_CRYPTO_RSA_RAW_PADDING 0
133#define VIRTIO_CRYPTO_RSA_PKCS1_PADDING 1
134 __le32 padding_algo;
135#define VIRTIO_CRYPTO_RSA_NO_HASH 0
136#define VIRTIO_CRYPTO_RSA_MD2 1
137#define VIRTIO_CRYPTO_RSA_MD3 2
138#define VIRTIO_CRYPTO_RSA_MD4 3
139#define VIRTIO_CRYPTO_RSA_MD5 4
140#define VIRTIO_CRYPTO_RSA_SHA1 5
141#define VIRTIO_CRYPTO_RSA_SHA256 6
142#define VIRTIO_CRYPTO_RSA_SHA384 7
143#define VIRTIO_CRYPTO_RSA_SHA512 8
144#define VIRTIO_CRYPTO_RSA_SHA224 9
145 __le32 hash_algo;
146};
147struct virtio_crypto_ecdsa_session_para {
148#define VIRTIO_CRYPTO_CURVE_UNKNOWN 0
149#define VIRTIO_CRYPTO_CURVE_NIST_P192 1
150#define VIRTIO_CRYPTO_CURVE_NIST_P224 2
151#define VIRTIO_CRYPTO_CURVE_NIST_P256 3
152#define VIRTIO_CRYPTO_CURVE_NIST_P384 4
153#define VIRTIO_CRYPTO_CURVE_NIST_P521 5
154 __le32 curve_id;
155 __le32 padding;
156};
157struct virtio_crypto_akcipher_session_para {
158#define VIRTIO_CRYPTO_NO_AKCIPHER 0
159#define VIRTIO_CRYPTO_AKCIPHER_RSA 1
160#define VIRTIO_CRYPTO_AKCIPHER_DSA 2
161#define VIRTIO_CRYPTO_AKCIPHER_ECDSA 3
162 __le32 algo;
163#define VIRTIO_CRYPTO_AKCIPHER_KEY_TYPE_PUBLIC 1
164#define VIRTIO_CRYPTO_AKCIPHER_KEY_TYPE_PRIVATE 2
165 __le32 keytype;
166 __le32 keylen;
167 union {
168 struct virtio_crypto_rsa_session_para rsa;
169 struct virtio_crypto_ecdsa_session_para ecdsa;
170 } u;
171};
172struct virtio_crypto_akcipher_create_session_req {
173 struct virtio_crypto_akcipher_session_para para;
174 __u8 padding[36];
175};
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800176struct virtio_crypto_alg_chain_session_para {
177#define VIRTIO_CRYPTO_SYM_ALG_CHAIN_ORDER_HASH_THEN_CIPHER 1
178#define VIRTIO_CRYPTO_SYM_ALG_CHAIN_ORDER_CIPHER_THEN_HASH 2
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800179 __le32 alg_chain_order;
180#define VIRTIO_CRYPTO_SYM_HASH_MODE_PLAIN 1
181#define VIRTIO_CRYPTO_SYM_HASH_MODE_AUTH 2
182#define VIRTIO_CRYPTO_SYM_HASH_MODE_NESTED 3
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800183 __le32 hash_mode;
184 struct virtio_crypto_cipher_session_para cipher_param;
185 union {
186 struct virtio_crypto_hash_session_para hash_param;
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800187 struct virtio_crypto_mac_session_para mac_param;
188 __u8 padding[16];
189 } u;
190 __le32 aad_len;
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800191 __le32 padding;
192};
193struct virtio_crypto_alg_chain_session_req {
194 struct virtio_crypto_alg_chain_session_para para;
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800195};
196struct virtio_crypto_sym_create_session_req {
197 union {
198 struct virtio_crypto_cipher_session_req cipher;
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800199 struct virtio_crypto_alg_chain_session_req chain;
200 __u8 padding[48];
201 } u;
202#define VIRTIO_CRYPTO_SYM_OP_NONE 0
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800203#define VIRTIO_CRYPTO_SYM_OP_CIPHER 1
204#define VIRTIO_CRYPTO_SYM_OP_ALGORITHM_CHAINING 2
205 __le32 op_type;
206 __le32 padding;
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800207};
208struct virtio_crypto_destroy_session_req {
209 __le64 session_id;
210 __u8 padding[48];
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800211};
212struct virtio_crypto_op_ctrl_req {
213 struct virtio_crypto_ctrl_header header;
214 union {
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800215 struct virtio_crypto_sym_create_session_req sym_create_session;
216 struct virtio_crypto_hash_create_session_req hash_create_session;
217 struct virtio_crypto_mac_create_session_req mac_create_session;
218 struct virtio_crypto_aead_create_session_req aead_create_session;
Christopher Ferris10a76e62022-06-08 13:31:52 -0700219 struct virtio_crypto_akcipher_create_session_req akcipher_create_session;
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800220 struct virtio_crypto_destroy_session_req destroy_session;
221 __u8 padding[56];
222 } u;
223};
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800224struct virtio_crypto_op_header {
225#define VIRTIO_CRYPTO_CIPHER_ENCRYPT VIRTIO_CRYPTO_OPCODE(VIRTIO_CRYPTO_SERVICE_CIPHER, 0x00)
226#define VIRTIO_CRYPTO_CIPHER_DECRYPT VIRTIO_CRYPTO_OPCODE(VIRTIO_CRYPTO_SERVICE_CIPHER, 0x01)
227#define VIRTIO_CRYPTO_HASH VIRTIO_CRYPTO_OPCODE(VIRTIO_CRYPTO_SERVICE_HASH, 0x00)
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800228#define VIRTIO_CRYPTO_MAC VIRTIO_CRYPTO_OPCODE(VIRTIO_CRYPTO_SERVICE_MAC, 0x00)
229#define VIRTIO_CRYPTO_AEAD_ENCRYPT VIRTIO_CRYPTO_OPCODE(VIRTIO_CRYPTO_SERVICE_AEAD, 0x00)
230#define VIRTIO_CRYPTO_AEAD_DECRYPT VIRTIO_CRYPTO_OPCODE(VIRTIO_CRYPTO_SERVICE_AEAD, 0x01)
Christopher Ferris10a76e62022-06-08 13:31:52 -0700231#define VIRTIO_CRYPTO_AKCIPHER_ENCRYPT VIRTIO_CRYPTO_OPCODE(VIRTIO_CRYPTO_SERVICE_AKCIPHER, 0x00)
232#define VIRTIO_CRYPTO_AKCIPHER_DECRYPT VIRTIO_CRYPTO_OPCODE(VIRTIO_CRYPTO_SERVICE_AKCIPHER, 0x01)
233#define VIRTIO_CRYPTO_AKCIPHER_SIGN VIRTIO_CRYPTO_OPCODE(VIRTIO_CRYPTO_SERVICE_AKCIPHER, 0x02)
234#define VIRTIO_CRYPTO_AKCIPHER_VERIFY VIRTIO_CRYPTO_OPCODE(VIRTIO_CRYPTO_SERVICE_AKCIPHER, 0x03)
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800235 __le32 opcode;
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800236 __le32 algo;
237 __le64 session_id;
238 __le32 flag;
239 __le32 padding;
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800240};
241struct virtio_crypto_cipher_para {
242 __le32 iv_len;
243 __le32 src_data_len;
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800244 __le32 dst_data_len;
245 __le32 padding;
246};
247struct virtio_crypto_hash_para {
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800248 __le32 src_data_len;
249 __le32 hash_result_len;
250};
251struct virtio_crypto_mac_para {
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800252 struct virtio_crypto_hash_para hash;
253};
254struct virtio_crypto_aead_para {
255 __le32 iv_len;
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800256 __le32 aad_len;
257 __le32 src_data_len;
258 __le32 dst_data_len;
259};
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800260struct virtio_crypto_cipher_data_req {
261 struct virtio_crypto_cipher_para para;
262 __u8 padding[24];
263};
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800264struct virtio_crypto_hash_data_req {
265 struct virtio_crypto_hash_para para;
266 __u8 padding[40];
267};
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800268struct virtio_crypto_mac_data_req {
269 struct virtio_crypto_mac_para para;
270 __u8 padding[40];
271};
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800272struct virtio_crypto_alg_chain_data_para {
273 __le32 iv_len;
274 __le32 src_data_len;
275 __le32 dst_data_len;
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800276 __le32 cipher_start_src_offset;
277 __le32 len_to_cipher;
278 __le32 hash_start_src_offset;
279 __le32 len_to_hash;
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800280 __le32 aad_len;
281 __le32 hash_result_len;
282 __le32 reserved;
283};
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800284struct virtio_crypto_alg_chain_data_req {
285 struct virtio_crypto_alg_chain_data_para para;
286};
287struct virtio_crypto_sym_data_req {
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800288 union {
289 struct virtio_crypto_cipher_data_req cipher;
290 struct virtio_crypto_alg_chain_data_req chain;
291 __u8 padding[40];
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800292 } u;
293 __le32 op_type;
294 __le32 padding;
295};
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800296struct virtio_crypto_aead_data_req {
297 struct virtio_crypto_aead_para para;
298 __u8 padding[32];
299};
Christopher Ferris10a76e62022-06-08 13:31:52 -0700300struct virtio_crypto_akcipher_para {
301 __le32 src_data_len;
302 __le32 dst_data_len;
303};
304struct virtio_crypto_akcipher_data_req {
305 struct virtio_crypto_akcipher_para para;
306 __u8 padding[40];
307};
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800308struct virtio_crypto_op_data_req {
309 struct virtio_crypto_op_header header;
310 union {
311 struct virtio_crypto_sym_data_req sym_req;
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800312 struct virtio_crypto_hash_data_req hash_req;
313 struct virtio_crypto_mac_data_req mac_req;
314 struct virtio_crypto_aead_data_req aead_req;
Christopher Ferris10a76e62022-06-08 13:31:52 -0700315 struct virtio_crypto_akcipher_data_req akcipher_req;
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800316 __u8 padding[48];
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800317 } u;
318};
319#define VIRTIO_CRYPTO_OK 0
320#define VIRTIO_CRYPTO_ERR 1
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800321#define VIRTIO_CRYPTO_BADMSG 2
322#define VIRTIO_CRYPTO_NOTSUPP 3
323#define VIRTIO_CRYPTO_INVSESS 4
Christopher Ferris10a76e62022-06-08 13:31:52 -0700324#define VIRTIO_CRYPTO_NOSPC 5
325#define VIRTIO_CRYPTO_KEY_REJECTED 6
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800326#define VIRTIO_CRYPTO_S_HW_READY (1 << 0)
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800327struct virtio_crypto_config {
Christopher Ferris25c18d42020-10-14 17:42:58 -0700328 __le32 status;
329 __le32 max_dataqueues;
330 __le32 crypto_services;
331 __le32 cipher_algo_l;
332 __le32 cipher_algo_h;
333 __le32 hash_algo;
334 __le32 mac_algo_l;
335 __le32 mac_algo_h;
336 __le32 aead_algo;
337 __le32 max_cipher_key_len;
338 __le32 max_auth_key_len;
Christopher Ferris10a76e62022-06-08 13:31:52 -0700339 __le32 akcipher_algo;
Christopher Ferris25c18d42020-10-14 17:42:58 -0700340 __le64 max_size;
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800341};
342struct virtio_crypto_inhdr {
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800343 __u8 status;
344};
345#endif