]> git.proxmox.com Git - mirror_qemu.git/blob - crypto/afalgpriv.h
crypto: cipher: add afalg-backend cipher support
[mirror_qemu.git] / crypto / afalgpriv.h
1 /*
2 * QEMU Crypto af_alg support
3 *
4 * Copyright (c) 2017 HUAWEI TECHNOLOGIES CO., LTD.
5 *
6 * Authors:
7 * Longpeng(Mike) <longpeng2@huawei.com>
8 *
9 * This work is licensed under the terms of the GNU GPL, version 2 or
10 * (at your option) any later version. See the COPYING file in the
11 * top-level directory.
12 */
13
14 #ifndef QCRYPTO_AFALGPRIV_H
15 #define QCRYPTO_AFALGPRIV_H
16
17 #include <linux/if_alg.h>
18
19 #define SALG_TYPE_LEN_MAX 14
20 #define SALG_NAME_LEN_MAX 64
21
22 #ifndef SOL_ALG
23 #define SOL_ALG 279
24 #endif
25
26 #define AFALG_TYPE_CIPHER "skcipher"
27
28 #define ALG_OPTYPE_LEN 4
29 #define ALG_MSGIV_LEN(len) (sizeof(struct af_alg_iv) + (len))
30
31 typedef struct QCryptoAFAlg QCryptoAFAlg;
32
33 struct QCryptoAFAlg {
34 int tfmfd;
35 int opfd;
36 struct msghdr *msg;
37 struct cmsghdr *cmsg;
38 };
39
40 /**
41 * qcrypto_afalg_comm_alloc:
42 * @type: the type of crypto operation
43 * @name: the name of crypto operation
44 *
45 * Allocate a QCryptoAFAlg object and bind itself to
46 * a AF_ALG socket.
47 *
48 * Returns:
49 * a new QCryptoAFAlg object, or NULL in error.
50 */
51 QCryptoAFAlg *
52 qcrypto_afalg_comm_alloc(const char *type, const char *name,
53 Error **errp);
54
55 /**
56 * afalg_comm_free:
57 * @afalg: the QCryptoAFAlg object
58 *
59 * Free the @afalg.
60 */
61 void qcrypto_afalg_comm_free(QCryptoAFAlg *afalg);
62
63 #endif