2017-07-14 21:04:05 +03:00
|
|
|
/*
|
|
|
|
* 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>
|
2020-08-28 20:05:14 +03:00
|
|
|
#include "crypto/cipher.h"
|
2017-07-14 21:04:05 +03:00
|
|
|
|
|
|
|
#define SALG_TYPE_LEN_MAX 14
|
|
|
|
#define SALG_NAME_LEN_MAX 64
|
|
|
|
|
2017-07-14 21:04:06 +03:00
|
|
|
#ifndef SOL_ALG
|
|
|
|
#define SOL_ALG 279
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define AFALG_TYPE_CIPHER "skcipher"
|
2017-07-14 21:04:07 +03:00
|
|
|
#define AFALG_TYPE_HASH "hash"
|
2017-07-14 21:04:06 +03:00
|
|
|
|
|
|
|
#define ALG_OPTYPE_LEN 4
|
|
|
|
#define ALG_MSGIV_LEN(len) (sizeof(struct af_alg_iv) + (len))
|
|
|
|
|
2024-09-04 14:18:33 +03:00
|
|
|
typedef struct QCryptoAFAlgo QCryptoAFAlgo;
|
2017-07-14 21:04:05 +03:00
|
|
|
|
2024-09-04 14:18:33 +03:00
|
|
|
struct QCryptoAFAlgo {
|
2020-08-28 20:05:14 +03:00
|
|
|
QCryptoCipher base;
|
|
|
|
|
2017-07-14 21:04:05 +03:00
|
|
|
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
|
|
|
|
*
|
2024-09-04 14:18:33 +03:00
|
|
|
* Allocate a QCryptoAFAlgo object and bind itself to
|
2017-07-14 21:04:05 +03:00
|
|
|
* a AF_ALG socket.
|
|
|
|
*
|
|
|
|
* Returns:
|
2024-09-04 14:18:33 +03:00
|
|
|
* a new QCryptoAFAlgo object, or NULL in error.
|
2017-07-14 21:04:05 +03:00
|
|
|
*/
|
2024-09-04 14:18:33 +03:00
|
|
|
QCryptoAFAlgo *
|
2017-07-14 21:04:05 +03:00
|
|
|
qcrypto_afalg_comm_alloc(const char *type, const char *name,
|
|
|
|
Error **errp);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* afalg_comm_free:
|
2024-09-04 14:18:33 +03:00
|
|
|
* @afalg: the QCryptoAFAlgo object
|
2017-07-14 21:04:05 +03:00
|
|
|
*
|
|
|
|
* Free the @afalg.
|
|
|
|
*/
|
2024-09-04 14:18:33 +03:00
|
|
|
void qcrypto_afalg_comm_free(QCryptoAFAlgo *afalg);
|
2017-07-14 21:04:05 +03:00
|
|
|
|
|
|
|
#endif
|