mirror of
https://gitlab.com/qemu-project/qemu.git
synced 2026-10-28 14:04:39 +08:00
AEAD modes such as GCM authenticate optional associated data (AAD) and produce an authentication tag, which the block-cipher encrypt/decrypt interface cannot express. Add qcrypto_cipher_setaad() and qcrypto_cipher_gettag() plus the matching backend driver hooks. The generic front-end reports an error when the selected mode's driver does not implement them, so calling them on a non-AEAD mode fails cleanly. Signed-off-by: Jamin Lin <jamin_lin@aspeedtech.com> Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> Reviewed-by: Kane Chen <kane_chen@aspeedtech.com> Link: https://lore.kernel.org/qemu-devel/20260811060115.1849266-9-jamin_lin@aspeedtech.com Signed-off-by: Cédric Le Goater <clg@redhat.com>
61 lines
1.6 KiB
C
61 lines
1.6 KiB
C
/*
|
|
* QEMU Crypto cipher driver supports
|
|
*
|
|
* 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_CIPHERPRIV_H
|
|
#define QCRYPTO_CIPHERPRIV_H
|
|
|
|
#include "qapi/qapi-types-crypto.h"
|
|
|
|
struct QCryptoCipherDriver {
|
|
int (*cipher_encrypt)(QCryptoCipher *cipher,
|
|
const void *in,
|
|
void *out,
|
|
size_t len,
|
|
Error **errp);
|
|
|
|
int (*cipher_decrypt)(QCryptoCipher *cipher,
|
|
const void *in,
|
|
void *out,
|
|
size_t len,
|
|
Error **errp);
|
|
|
|
int (*cipher_setiv)(QCryptoCipher *cipher,
|
|
const uint8_t *iv, size_t niv,
|
|
Error **errp);
|
|
|
|
int (*cipher_setaad)(QCryptoCipher *cipher,
|
|
const uint8_t *aad, size_t len,
|
|
Error **errp);
|
|
|
|
int (*cipher_gettag)(QCryptoCipher *cipher,
|
|
uint8_t *tag, size_t len,
|
|
Error **errp);
|
|
|
|
void (*cipher_free)(QCryptoCipher *cipher);
|
|
};
|
|
|
|
#ifdef CONFIG_AF_ALG
|
|
|
|
#include "afalgpriv.h"
|
|
|
|
extern QCryptoCipher *
|
|
qcrypto_afalg_cipher_ctx_new(QCryptoCipherAlgo alg,
|
|
QCryptoCipherMode mode,
|
|
const uint8_t *key,
|
|
size_t nkey, Error **errp);
|
|
|
|
#endif
|
|
|
|
#endif
|