aboutsummaryrefslogtreecommitdiff
path: root/crypto/afalgpriv.h
blob: 3fdcc0f8316825b9c389ef818c0f280efad44f74 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/*
 * QEMU Crypto af_alg support
 *
 * Copyright (c) 2017 HUAWEI TECHNOLOGIES CO., LTD.
 *
 * Authors:
 *    Longpeng(Mike) <longpeng2@huawei.com>
 *
 * This work is licensed under the terms of the GNU GPL, version 2 or
 * (at your option) any later version.  See the COPYING file in the
 * top-level directory.
 */

#ifndef QCRYPTO_AFALGPRIV_H
#define QCRYPTO_AFALGPRIV_H

#include <linux/if_alg.h>
#include "crypto/cipher.h"

#define SALG_TYPE_LEN_MAX 14
#define SALG_NAME_LEN_MAX 64

#ifndef SOL_ALG
#define SOL_ALG 279
#endif

#define AFALG_TYPE_CIPHER "skcipher"
#define AFALG_TYPE_HASH "hash"

#define ALG_OPTYPE_LEN 4
#define ALG_MSGIV_LEN(len) (sizeof(struct af_alg_iv) + (len))

typedef struct QCryptoAFAlgo QCryptoAFAlgo;

struct QCryptoAFAlgo {
    QCryptoCipher base;

    int tfmfd;
    int opfd;
    struct msghdr *msg;
    struct cmsghdr *cmsg;
};

/**
 * qcrypto_afalg_comm_alloc:
 * @type: the type of crypto operation
 * @name: the name of crypto operation
 *
 * Allocate a QCryptoAFAlgo object and bind itself to
 * a AF_ALG socket.
 *
 * Returns:
 *  a new QCryptoAFAlgo object, or NULL in error.
 */
QCryptoAFAlgo *
qcrypto_afalg_comm_alloc(const char *type, const char *name,
                         Error **errp);

/**
 * afalg_comm_free:
 * @afalg: the QCryptoAFAlgo object
 *
 * Free the @afalg.
 */
void qcrypto_afalg_comm_free(QCryptoAFAlgo *afalg);

#endif