mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-07 09:43:56 -06:00
cryptodev: Introduce cryptodev alg type in QAPI
Introduce cryptodev alg type in cryptodev.json, then apply this to related codes, and drop 'enum CryptoDevBackendAlgType'. There are two options: 1, { 'enum': 'QCryptodevBackendAlgType', 'prefix': 'CRYPTODEV_BACKEND_ALG', 'data': ['sym', 'asym']} Then we can keep 'CRYPTODEV_BACKEND_ALG_SYM' and avoid lots of changes. 2, changes in this patch(with prefix 'QCRYPTODEV_BACKEND_ALG'). To avoid breaking the rule of QAPI, use 2 here. Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> Signed-off-by: zhenwei pi <pizhenwei@bytedance.com> Message-Id: <20230301105847.253084-4-pizhenwei@bytedance.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
This commit is contained in:
parent
3f478371fd
commit
999c789f00
6 changed files with 30 additions and 22 deletions
|
@ -462,7 +462,7 @@ static void virtio_crypto_init_request(VirtIOCrypto *vcrypto, VirtQueue *vq,
|
|||
req->in_iov = NULL;
|
||||
req->in_num = 0;
|
||||
req->in_len = 0;
|
||||
req->flags = CRYPTODEV_BACKEND_ALG__MAX;
|
||||
req->flags = QCRYPTODEV_BACKEND_ALG__MAX;
|
||||
memset(&req->op_info, 0x00, sizeof(req->op_info));
|
||||
}
|
||||
|
||||
|
@ -472,7 +472,7 @@ static void virtio_crypto_free_request(VirtIOCryptoReq *req)
|
|||
return;
|
||||
}
|
||||
|
||||
if (req->flags == CRYPTODEV_BACKEND_ALG_SYM) {
|
||||
if (req->flags == QCRYPTODEV_BACKEND_ALG_SYM) {
|
||||
size_t max_len;
|
||||
CryptoDevBackendSymOpInfo *op_info = req->op_info.u.sym_op_info;
|
||||
|
||||
|
@ -485,7 +485,7 @@ static void virtio_crypto_free_request(VirtIOCryptoReq *req)
|
|||
/* Zeroize and free request data structure */
|
||||
memset(op_info, 0, sizeof(*op_info) + max_len);
|
||||
g_free(op_info);
|
||||
} else if (req->flags == CRYPTODEV_BACKEND_ALG_ASYM) {
|
||||
} else if (req->flags == QCRYPTODEV_BACKEND_ALG_ASYM) {
|
||||
CryptoDevBackendAsymOpInfo *op_info = req->op_info.u.asym_op_info;
|
||||
if (op_info) {
|
||||
g_free(op_info->src);
|
||||
|
@ -570,10 +570,10 @@ static void virtio_crypto_req_complete(void *opaque, int ret)
|
|||
VirtIODevice *vdev = VIRTIO_DEVICE(vcrypto);
|
||||
uint8_t status = -ret;
|
||||
|
||||
if (req->flags == CRYPTODEV_BACKEND_ALG_SYM) {
|
||||
if (req->flags == QCRYPTODEV_BACKEND_ALG_SYM) {
|
||||
virtio_crypto_sym_input_data_helper(vdev, req, status,
|
||||
req->op_info.u.sym_op_info);
|
||||
} else if (req->flags == CRYPTODEV_BACKEND_ALG_ASYM) {
|
||||
} else if (req->flags == QCRYPTODEV_BACKEND_ALG_ASYM) {
|
||||
virtio_crypto_akcipher_input_data_helper(vdev, req, status,
|
||||
req->op_info.u.asym_op_info);
|
||||
}
|
||||
|
@ -875,7 +875,7 @@ virtio_crypto_handle_request(VirtIOCryptoReq *request)
|
|||
switch (opcode) {
|
||||
case VIRTIO_CRYPTO_CIPHER_ENCRYPT:
|
||||
case VIRTIO_CRYPTO_CIPHER_DECRYPT:
|
||||
op_info->algtype = request->flags = CRYPTODEV_BACKEND_ALG_SYM;
|
||||
op_info->algtype = request->flags = QCRYPTODEV_BACKEND_ALG_SYM;
|
||||
ret = virtio_crypto_handle_sym_req(vcrypto,
|
||||
&req.u.sym_req, op_info,
|
||||
out_iov, out_num);
|
||||
|
@ -885,7 +885,7 @@ virtio_crypto_handle_request(VirtIOCryptoReq *request)
|
|||
case VIRTIO_CRYPTO_AKCIPHER_DECRYPT:
|
||||
case VIRTIO_CRYPTO_AKCIPHER_SIGN:
|
||||
case VIRTIO_CRYPTO_AKCIPHER_VERIFY:
|
||||
op_info->algtype = request->flags = CRYPTODEV_BACKEND_ALG_ASYM;
|
||||
op_info->algtype = request->flags = QCRYPTODEV_BACKEND_ALG_ASYM;
|
||||
ret = virtio_crypto_handle_asym_req(vcrypto,
|
||||
&req.u.akcipher_req, op_info,
|
||||
out_iov, out_num);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue