virtio_crypto.h 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530
  1. #ifndef _VIRTIO_CRYPTO_H
  2. #define _VIRTIO_CRYPTO_H
  3. /* This header is BSD licensed so anyone can use the definitions to implement
  4. * compatible drivers/servers.
  5. *
  6. * Redistribution and use in source and binary forms, with or without
  7. * modification, are permitted provided that the following conditions
  8. * are met:
  9. * 1. Redistributions of source code must retain the above copyright
  10. * notice, this list of conditions and the following disclaimer.
  11. * 2. Redistributions in binary form must reproduce the above copyright
  12. * notice, this list of conditions and the following disclaimer in the
  13. * documentation and/or other materials provided with the distribution.
  14. * 3. Neither the name of IBM nor the names of its contributors
  15. * may be used to endorse or promote products derived from this software
  16. * without specific prior written permission.
  17. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  18. * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  19. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
  20. * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL IBM OR
  21. * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  22. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  23. * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  24. * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  25. * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  26. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  27. * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  28. * SUCH DAMAGE.
  29. */
  30. #include <linux/types.h>
  31. #include <linux/virtio_types.h>
  32. #include <linux/virtio_ids.h>
  33. #include <linux/virtio_config.h>
  34. #define VIRTIO_CRYPTO_SERVICE_CIPHER 0
  35. #define VIRTIO_CRYPTO_SERVICE_HASH 1
  36. #define VIRTIO_CRYPTO_SERVICE_MAC 2
  37. #define VIRTIO_CRYPTO_SERVICE_AEAD 3
  38. #define VIRTIO_CRYPTO_SERVICE_AKCIPHER 4
  39. #define VIRTIO_CRYPTO_OPCODE(service, op) (((service) << 8) | (op))
  40. struct virtio_crypto_ctrl_header {
  41. #define VIRTIO_CRYPTO_CIPHER_CREATE_SESSION \
  42. VIRTIO_CRYPTO_OPCODE(VIRTIO_CRYPTO_SERVICE_CIPHER, 0x02)
  43. #define VIRTIO_CRYPTO_CIPHER_DESTROY_SESSION \
  44. VIRTIO_CRYPTO_OPCODE(VIRTIO_CRYPTO_SERVICE_CIPHER, 0x03)
  45. #define VIRTIO_CRYPTO_HASH_CREATE_SESSION \
  46. VIRTIO_CRYPTO_OPCODE(VIRTIO_CRYPTO_SERVICE_HASH, 0x02)
  47. #define VIRTIO_CRYPTO_HASH_DESTROY_SESSION \
  48. VIRTIO_CRYPTO_OPCODE(VIRTIO_CRYPTO_SERVICE_HASH, 0x03)
  49. #define VIRTIO_CRYPTO_MAC_CREATE_SESSION \
  50. VIRTIO_CRYPTO_OPCODE(VIRTIO_CRYPTO_SERVICE_MAC, 0x02)
  51. #define VIRTIO_CRYPTO_MAC_DESTROY_SESSION \
  52. VIRTIO_CRYPTO_OPCODE(VIRTIO_CRYPTO_SERVICE_MAC, 0x03)
  53. #define VIRTIO_CRYPTO_AEAD_CREATE_SESSION \
  54. VIRTIO_CRYPTO_OPCODE(VIRTIO_CRYPTO_SERVICE_AEAD, 0x02)
  55. #define VIRTIO_CRYPTO_AEAD_DESTROY_SESSION \
  56. VIRTIO_CRYPTO_OPCODE(VIRTIO_CRYPTO_SERVICE_AEAD, 0x03)
  57. #define VIRTIO_CRYPTO_AKCIPHER_CREATE_SESSION \
  58. VIRTIO_CRYPTO_OPCODE(VIRTIO_CRYPTO_SERVICE_AKCIPHER, 0x04)
  59. #define VIRTIO_CRYPTO_AKCIPHER_DESTROY_SESSION \
  60. VIRTIO_CRYPTO_OPCODE(VIRTIO_CRYPTO_SERVICE_AKCIPHER, 0x05)
  61. __le32 opcode;
  62. __le32 algo;
  63. __le32 flag;
  64. /* data virtqueue id */
  65. __le32 queue_id;
  66. };
  67. struct virtio_crypto_cipher_session_para {
  68. #define VIRTIO_CRYPTO_NO_CIPHER 0
  69. #define VIRTIO_CRYPTO_CIPHER_ARC4 1
  70. #define VIRTIO_CRYPTO_CIPHER_AES_ECB 2
  71. #define VIRTIO_CRYPTO_CIPHER_AES_CBC 3
  72. #define VIRTIO_CRYPTO_CIPHER_AES_CTR 4
  73. #define VIRTIO_CRYPTO_CIPHER_DES_ECB 5
  74. #define VIRTIO_CRYPTO_CIPHER_DES_CBC 6
  75. #define VIRTIO_CRYPTO_CIPHER_3DES_ECB 7
  76. #define VIRTIO_CRYPTO_CIPHER_3DES_CBC 8
  77. #define VIRTIO_CRYPTO_CIPHER_3DES_CTR 9
  78. #define VIRTIO_CRYPTO_CIPHER_KASUMI_F8 10
  79. #define VIRTIO_CRYPTO_CIPHER_SNOW3G_UEA2 11
  80. #define VIRTIO_CRYPTO_CIPHER_AES_F8 12
  81. #define VIRTIO_CRYPTO_CIPHER_AES_XTS 13
  82. #define VIRTIO_CRYPTO_CIPHER_ZUC_EEA3 14
  83. __le32 algo;
  84. /* length of key */
  85. __le32 keylen;
  86. #define VIRTIO_CRYPTO_OP_ENCRYPT 1
  87. #define VIRTIO_CRYPTO_OP_DECRYPT 2
  88. /* encrypt or decrypt */
  89. __le32 op;
  90. __le32 padding;
  91. };
  92. struct virtio_crypto_session_input {
  93. /* Device-writable part */
  94. __le64 session_id;
  95. __le32 status;
  96. __le32 padding;
  97. };
  98. struct virtio_crypto_cipher_session_req {
  99. struct virtio_crypto_cipher_session_para para;
  100. __u8 padding[32];
  101. };
  102. struct virtio_crypto_hash_session_para {
  103. #define VIRTIO_CRYPTO_NO_HASH 0
  104. #define VIRTIO_CRYPTO_HASH_MD5 1
  105. #define VIRTIO_CRYPTO_HASH_SHA1 2
  106. #define VIRTIO_CRYPTO_HASH_SHA_224 3
  107. #define VIRTIO_CRYPTO_HASH_SHA_256 4
  108. #define VIRTIO_CRYPTO_HASH_SHA_384 5
  109. #define VIRTIO_CRYPTO_HASH_SHA_512 6
  110. #define VIRTIO_CRYPTO_HASH_SHA3_224 7
  111. #define VIRTIO_CRYPTO_HASH_SHA3_256 8
  112. #define VIRTIO_CRYPTO_HASH_SHA3_384 9
  113. #define VIRTIO_CRYPTO_HASH_SHA3_512 10
  114. #define VIRTIO_CRYPTO_HASH_SHA3_SHAKE128 11
  115. #define VIRTIO_CRYPTO_HASH_SHA3_SHAKE256 12
  116. __le32 algo;
  117. /* hash result length */
  118. __le32 hash_result_len;
  119. __u8 padding[8];
  120. };
  121. struct virtio_crypto_hash_create_session_req {
  122. struct virtio_crypto_hash_session_para para;
  123. __u8 padding[40];
  124. };
  125. struct virtio_crypto_mac_session_para {
  126. #define VIRTIO_CRYPTO_NO_MAC 0
  127. #define VIRTIO_CRYPTO_MAC_HMAC_MD5 1
  128. #define VIRTIO_CRYPTO_MAC_HMAC_SHA1 2
  129. #define VIRTIO_CRYPTO_MAC_HMAC_SHA_224 3
  130. #define VIRTIO_CRYPTO_MAC_HMAC_SHA_256 4
  131. #define VIRTIO_CRYPTO_MAC_HMAC_SHA_384 5
  132. #define VIRTIO_CRYPTO_MAC_HMAC_SHA_512 6
  133. #define VIRTIO_CRYPTO_MAC_CMAC_3DES 25
  134. #define VIRTIO_CRYPTO_MAC_CMAC_AES 26
  135. #define VIRTIO_CRYPTO_MAC_KASUMI_F9 27
  136. #define VIRTIO_CRYPTO_MAC_SNOW3G_UIA2 28
  137. #define VIRTIO_CRYPTO_MAC_GMAC_AES 41
  138. #define VIRTIO_CRYPTO_MAC_GMAC_TWOFISH 42
  139. #define VIRTIO_CRYPTO_MAC_CBCMAC_AES 49
  140. #define VIRTIO_CRYPTO_MAC_CBCMAC_KASUMI_F9 50
  141. #define VIRTIO_CRYPTO_MAC_XCBC_AES 53
  142. __le32 algo;
  143. /* hash result length */
  144. __le32 hash_result_len;
  145. /* length of authenticated key */
  146. __le32 auth_key_len;
  147. __le32 padding;
  148. };
  149. struct virtio_crypto_mac_create_session_req {
  150. struct virtio_crypto_mac_session_para para;
  151. __u8 padding[40];
  152. };
  153. struct virtio_crypto_aead_session_para {
  154. #define VIRTIO_CRYPTO_NO_AEAD 0
  155. #define VIRTIO_CRYPTO_AEAD_GCM 1
  156. #define VIRTIO_CRYPTO_AEAD_CCM 2
  157. #define VIRTIO_CRYPTO_AEAD_CHACHA20_POLY1305 3
  158. __le32 algo;
  159. /* length of key */
  160. __le32 key_len;
  161. /* hash result length */
  162. __le32 hash_result_len;
  163. /* length of the additional authenticated data (AAD) in bytes */
  164. __le32 aad_len;
  165. /* encrypt or decrypt, See above VIRTIO_CRYPTO_OP_* */
  166. __le32 op;
  167. __le32 padding;
  168. };
  169. struct virtio_crypto_aead_create_session_req {
  170. struct virtio_crypto_aead_session_para para;
  171. __u8 padding[32];
  172. };
  173. struct virtio_crypto_rsa_session_para {
  174. #define VIRTIO_CRYPTO_RSA_RAW_PADDING 0
  175. #define VIRTIO_CRYPTO_RSA_PKCS1_PADDING 1
  176. __le32 padding_algo;
  177. #define VIRTIO_CRYPTO_RSA_NO_HASH 0
  178. #define VIRTIO_CRYPTO_RSA_MD2 1
  179. #define VIRTIO_CRYPTO_RSA_MD3 2
  180. #define VIRTIO_CRYPTO_RSA_MD4 3
  181. #define VIRTIO_CRYPTO_RSA_MD5 4
  182. #define VIRTIO_CRYPTO_RSA_SHA1 5
  183. #define VIRTIO_CRYPTO_RSA_SHA256 6
  184. #define VIRTIO_CRYPTO_RSA_SHA384 7
  185. #define VIRTIO_CRYPTO_RSA_SHA512 8
  186. #define VIRTIO_CRYPTO_RSA_SHA224 9
  187. __le32 hash_algo;
  188. };
  189. struct virtio_crypto_ecdsa_session_para {
  190. #define VIRTIO_CRYPTO_CURVE_UNKNOWN 0
  191. #define VIRTIO_CRYPTO_CURVE_NIST_P192 1
  192. #define VIRTIO_CRYPTO_CURVE_NIST_P224 2
  193. #define VIRTIO_CRYPTO_CURVE_NIST_P256 3
  194. #define VIRTIO_CRYPTO_CURVE_NIST_P384 4
  195. #define VIRTIO_CRYPTO_CURVE_NIST_P521 5
  196. __le32 curve_id;
  197. __le32 padding;
  198. };
  199. struct virtio_crypto_akcipher_session_para {
  200. #define VIRTIO_CRYPTO_NO_AKCIPHER 0
  201. #define VIRTIO_CRYPTO_AKCIPHER_RSA 1
  202. #define VIRTIO_CRYPTO_AKCIPHER_DSA 2
  203. #define VIRTIO_CRYPTO_AKCIPHER_ECDSA 3
  204. __le32 algo;
  205. #define VIRTIO_CRYPTO_AKCIPHER_KEY_TYPE_PUBLIC 1
  206. #define VIRTIO_CRYPTO_AKCIPHER_KEY_TYPE_PRIVATE 2
  207. __le32 keytype;
  208. __le32 keylen;
  209. union {
  210. struct virtio_crypto_rsa_session_para rsa;
  211. struct virtio_crypto_ecdsa_session_para ecdsa;
  212. } u;
  213. };
  214. struct virtio_crypto_akcipher_create_session_req {
  215. struct virtio_crypto_akcipher_session_para para;
  216. __u8 padding[36];
  217. };
  218. struct virtio_crypto_alg_chain_session_para {
  219. #define VIRTIO_CRYPTO_SYM_ALG_CHAIN_ORDER_HASH_THEN_CIPHER 1
  220. #define VIRTIO_CRYPTO_SYM_ALG_CHAIN_ORDER_CIPHER_THEN_HASH 2
  221. __le32 alg_chain_order;
  222. /* Plain hash */
  223. #define VIRTIO_CRYPTO_SYM_HASH_MODE_PLAIN 1
  224. /* Authenticated hash (mac) */
  225. #define VIRTIO_CRYPTO_SYM_HASH_MODE_AUTH 2
  226. /* Nested hash */
  227. #define VIRTIO_CRYPTO_SYM_HASH_MODE_NESTED 3
  228. __le32 hash_mode;
  229. struct virtio_crypto_cipher_session_para cipher_param;
  230. union {
  231. struct virtio_crypto_hash_session_para hash_param;
  232. struct virtio_crypto_mac_session_para mac_param;
  233. __u8 padding[16];
  234. } u;
  235. /* length of the additional authenticated data (AAD) in bytes */
  236. __le32 aad_len;
  237. __le32 padding;
  238. };
  239. struct virtio_crypto_alg_chain_session_req {
  240. struct virtio_crypto_alg_chain_session_para para;
  241. };
  242. struct virtio_crypto_sym_create_session_req {
  243. union {
  244. struct virtio_crypto_cipher_session_req cipher;
  245. struct virtio_crypto_alg_chain_session_req chain;
  246. __u8 padding[48];
  247. } u;
  248. /* Device-readable part */
  249. /* No operation */
  250. #define VIRTIO_CRYPTO_SYM_OP_NONE 0
  251. /* Cipher only operation on the data */
  252. #define VIRTIO_CRYPTO_SYM_OP_CIPHER 1
  253. /*
  254. * Chain any cipher with any hash or mac operation. The order
  255. * depends on the value of alg_chain_order param
  256. */
  257. #define VIRTIO_CRYPTO_SYM_OP_ALGORITHM_CHAINING 2
  258. __le32 op_type;
  259. __le32 padding;
  260. };
  261. struct virtio_crypto_destroy_session_req {
  262. /* Device-readable part */
  263. __le64 session_id;
  264. __u8 padding[48];
  265. };
  266. /* The request of the control virtqueue's packet */
  267. struct virtio_crypto_op_ctrl_req {
  268. struct virtio_crypto_ctrl_header header;
  269. union {
  270. struct virtio_crypto_sym_create_session_req
  271. sym_create_session;
  272. struct virtio_crypto_hash_create_session_req
  273. hash_create_session;
  274. struct virtio_crypto_mac_create_session_req
  275. mac_create_session;
  276. struct virtio_crypto_aead_create_session_req
  277. aead_create_session;
  278. struct virtio_crypto_akcipher_create_session_req
  279. akcipher_create_session;
  280. struct virtio_crypto_destroy_session_req
  281. destroy_session;
  282. __u8 padding[56];
  283. } u;
  284. };
  285. struct virtio_crypto_op_header {
  286. #define VIRTIO_CRYPTO_CIPHER_ENCRYPT \
  287. VIRTIO_CRYPTO_OPCODE(VIRTIO_CRYPTO_SERVICE_CIPHER, 0x00)
  288. #define VIRTIO_CRYPTO_CIPHER_DECRYPT \
  289. VIRTIO_CRYPTO_OPCODE(VIRTIO_CRYPTO_SERVICE_CIPHER, 0x01)
  290. #define VIRTIO_CRYPTO_HASH \
  291. VIRTIO_CRYPTO_OPCODE(VIRTIO_CRYPTO_SERVICE_HASH, 0x00)
  292. #define VIRTIO_CRYPTO_MAC \
  293. VIRTIO_CRYPTO_OPCODE(VIRTIO_CRYPTO_SERVICE_MAC, 0x00)
  294. #define VIRTIO_CRYPTO_AEAD_ENCRYPT \
  295. VIRTIO_CRYPTO_OPCODE(VIRTIO_CRYPTO_SERVICE_AEAD, 0x00)
  296. #define VIRTIO_CRYPTO_AEAD_DECRYPT \
  297. VIRTIO_CRYPTO_OPCODE(VIRTIO_CRYPTO_SERVICE_AEAD, 0x01)
  298. #define VIRTIO_CRYPTO_AKCIPHER_ENCRYPT \
  299. VIRTIO_CRYPTO_OPCODE(VIRTIO_CRYPTO_SERVICE_AKCIPHER, 0x00)
  300. #define VIRTIO_CRYPTO_AKCIPHER_DECRYPT \
  301. VIRTIO_CRYPTO_OPCODE(VIRTIO_CRYPTO_SERVICE_AKCIPHER, 0x01)
  302. #define VIRTIO_CRYPTO_AKCIPHER_SIGN \
  303. VIRTIO_CRYPTO_OPCODE(VIRTIO_CRYPTO_SERVICE_AKCIPHER, 0x02)
  304. #define VIRTIO_CRYPTO_AKCIPHER_VERIFY \
  305. VIRTIO_CRYPTO_OPCODE(VIRTIO_CRYPTO_SERVICE_AKCIPHER, 0x03)
  306. __le32 opcode;
  307. /* algo should be service-specific algorithms */
  308. __le32 algo;
  309. /* session_id should be service-specific algorithms */
  310. __le64 session_id;
  311. /* control flag to control the request */
  312. __le32 flag;
  313. __le32 padding;
  314. };
  315. struct virtio_crypto_cipher_para {
  316. /*
  317. * Byte Length of valid IV/Counter
  318. *
  319. * For block ciphers in CBC or F8 mode, or for Kasumi in F8 mode, or for
  320. * SNOW3G in UEA2 mode, this is the length of the IV (which
  321. * must be the same as the block length of the cipher).
  322. * For block ciphers in CTR mode, this is the length of the counter
  323. * (which must be the same as the block length of the cipher).
  324. * For AES-XTS, this is the 128bit tweak, i, from IEEE Std 1619-2007.
  325. *
  326. * The IV/Counter will be updated after every partial cryptographic
  327. * operation.
  328. */
  329. __le32 iv_len;
  330. /* length of source data */
  331. __le32 src_data_len;
  332. /* length of dst data */
  333. __le32 dst_data_len;
  334. __le32 padding;
  335. };
  336. struct virtio_crypto_hash_para {
  337. /* length of source data */
  338. __le32 src_data_len;
  339. /* hash result length */
  340. __le32 hash_result_len;
  341. };
  342. struct virtio_crypto_mac_para {
  343. struct virtio_crypto_hash_para hash;
  344. };
  345. struct virtio_crypto_aead_para {
  346. /*
  347. * Byte Length of valid IV data pointed to by the below iv_addr
  348. * parameter.
  349. *
  350. * For GCM mode, this is either 12 (for 96-bit IVs) or 16, in which
  351. * case iv_addr points to J0.
  352. * For CCM mode, this is the length of the nonce, which can be in the
  353. * range 7 to 13 inclusive.
  354. */
  355. __le32 iv_len;
  356. /* length of additional auth data */
  357. __le32 aad_len;
  358. /* length of source data */
  359. __le32 src_data_len;
  360. /* length of dst data */
  361. __le32 dst_data_len;
  362. };
  363. struct virtio_crypto_cipher_data_req {
  364. /* Device-readable part */
  365. struct virtio_crypto_cipher_para para;
  366. __u8 padding[24];
  367. };
  368. struct virtio_crypto_hash_data_req {
  369. /* Device-readable part */
  370. struct virtio_crypto_hash_para para;
  371. __u8 padding[40];
  372. };
  373. struct virtio_crypto_mac_data_req {
  374. /* Device-readable part */
  375. struct virtio_crypto_mac_para para;
  376. __u8 padding[40];
  377. };
  378. struct virtio_crypto_alg_chain_data_para {
  379. __le32 iv_len;
  380. /* Length of source data */
  381. __le32 src_data_len;
  382. /* Length of destination data */
  383. __le32 dst_data_len;
  384. /* Starting point for cipher processing in source data */
  385. __le32 cipher_start_src_offset;
  386. /* Length of the source data that the cipher will be computed on */
  387. __le32 len_to_cipher;
  388. /* Starting point for hash processing in source data */
  389. __le32 hash_start_src_offset;
  390. /* Length of the source data that the hash will be computed on */
  391. __le32 len_to_hash;
  392. /* Length of the additional auth data */
  393. __le32 aad_len;
  394. /* Length of the hash result */
  395. __le32 hash_result_len;
  396. __le32 reserved;
  397. };
  398. struct virtio_crypto_alg_chain_data_req {
  399. /* Device-readable part */
  400. struct virtio_crypto_alg_chain_data_para para;
  401. };
  402. struct virtio_crypto_sym_data_req {
  403. union {
  404. struct virtio_crypto_cipher_data_req cipher;
  405. struct virtio_crypto_alg_chain_data_req chain;
  406. __u8 padding[40];
  407. } u;
  408. /* See above VIRTIO_CRYPTO_SYM_OP_* */
  409. __le32 op_type;
  410. __le32 padding;
  411. };
  412. struct virtio_crypto_aead_data_req {
  413. /* Device-readable part */
  414. struct virtio_crypto_aead_para para;
  415. __u8 padding[32];
  416. };
  417. struct virtio_crypto_akcipher_para {
  418. __le32 src_data_len;
  419. __le32 dst_data_len;
  420. };
  421. struct virtio_crypto_akcipher_data_req {
  422. struct virtio_crypto_akcipher_para para;
  423. __u8 padding[40];
  424. };
  425. /* The request of the data virtqueue's packet */
  426. struct virtio_crypto_op_data_req {
  427. struct virtio_crypto_op_header header;
  428. union {
  429. struct virtio_crypto_sym_data_req sym_req;
  430. struct virtio_crypto_hash_data_req hash_req;
  431. struct virtio_crypto_mac_data_req mac_req;
  432. struct virtio_crypto_aead_data_req aead_req;
  433. struct virtio_crypto_akcipher_data_req akcipher_req;
  434. __u8 padding[48];
  435. } u;
  436. };
  437. #define VIRTIO_CRYPTO_OK 0
  438. #define VIRTIO_CRYPTO_ERR 1
  439. #define VIRTIO_CRYPTO_BADMSG 2
  440. #define VIRTIO_CRYPTO_NOTSUPP 3
  441. #define VIRTIO_CRYPTO_INVSESS 4 /* Invalid session id */
  442. #define VIRTIO_CRYPTO_NOSPC 5 /* no free session ID */
  443. #define VIRTIO_CRYPTO_KEY_REJECTED 6 /* Signature verification failed */
  444. /* The accelerator hardware is ready */
  445. #define VIRTIO_CRYPTO_S_HW_READY (1 << 0)
  446. struct virtio_crypto_config {
  447. /* See VIRTIO_CRYPTO_OP_* above */
  448. __le32 status;
  449. /*
  450. * Maximum number of data queue
  451. */
  452. __le32 max_dataqueues;
  453. /*
  454. * Specifies the services mask which the device support,
  455. * see VIRTIO_CRYPTO_SERVICE_* above
  456. */
  457. __le32 crypto_services;
  458. /* Detailed algorithms mask */
  459. __le32 cipher_algo_l;
  460. __le32 cipher_algo_h;
  461. __le32 hash_algo;
  462. __le32 mac_algo_l;
  463. __le32 mac_algo_h;
  464. __le32 aead_algo;
  465. /* Maximum length of cipher key */
  466. __le32 max_cipher_key_len;
  467. /* Maximum length of authenticated key */
  468. __le32 max_auth_key_len;
  469. __le32 akcipher_algo;
  470. /* Maximum size of each crypto request's content */
  471. __le64 max_size;
  472. };
  473. struct virtio_crypto_inhdr {
  474. /* See VIRTIO_CRYPTO_* above */
  475. __u8 status;
  476. };
  477. #endif