[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 06/73] cryptodev-builtin: Detect akcipher capability
From: |
Michael S. Tsirkin |
Subject: |
[PULL 06/73] cryptodev-builtin: Detect akcipher capability |
Date: |
Tue, 7 Mar 2023 20:11:08 -0500 |
From: zhenwei pi <pizhenwei@bytedance.com>
Rather than exposing akcipher service/RSA algorithm to virtio crypto
device unconditionally, detect akcipher capability from akcipher
crypto framework. This avoids unsuccessful requests.
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: zhenwei pi <pizhenwei@bytedance.com>
Message-Id: <20230301105847.253084-7-pizhenwei@bytedance.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
backends/cryptodev-builtin.c | 18 +++++++++++++++---
1 file changed, 15 insertions(+), 3 deletions(-)
diff --git a/backends/cryptodev-builtin.c b/backends/cryptodev-builtin.c
index c0fbb650d7..c45b5906c5 100644
--- a/backends/cryptodev-builtin.c
+++ b/backends/cryptodev-builtin.c
@@ -59,6 +59,19 @@ struct CryptoDevBackendBuiltin {
CryptoDevBackendBuiltinSession *sessions[MAX_NUM_SESSIONS];
};
+static void cryptodev_builtin_init_akcipher(CryptoDevBackend *backend)
+{
+ QCryptoAkCipherOptions opts;
+
+ opts.alg = QCRYPTO_AKCIPHER_ALG_RSA;
+ opts.u.rsa.padding_alg = QCRYPTO_RSA_PADDING_ALG_RAW;
+ if (qcrypto_akcipher_supports(&opts)) {
+ backend->conf.crypto_services |=
+ (1u << QCRYPTODEV_BACKEND_SERVICE_AKCIPHER);
+ backend->conf.akcipher_algo = 1u << VIRTIO_CRYPTO_AKCIPHER_RSA;
+ }
+}
+
static void cryptodev_builtin_init(
CryptoDevBackend *backend, Error **errp)
{
@@ -81,11 +94,9 @@ static void cryptodev_builtin_init(
backend->conf.crypto_services =
1u << QCRYPTODEV_BACKEND_SERVICE_CIPHER |
1u << QCRYPTODEV_BACKEND_SERVICE_HASH |
- 1u << QCRYPTODEV_BACKEND_SERVICE_MAC |
- 1u << QCRYPTODEV_BACKEND_SERVICE_AKCIPHER;
+ 1u << QCRYPTODEV_BACKEND_SERVICE_MAC;
backend->conf.cipher_algo_l = 1u << VIRTIO_CRYPTO_CIPHER_AES_CBC;
backend->conf.hash_algo = 1u << VIRTIO_CRYPTO_HASH_SHA1;
- backend->conf.akcipher_algo = 1u << VIRTIO_CRYPTO_AKCIPHER_RSA;
/*
* Set the Maximum length of crypto request.
* Why this value? Just avoid to overflow when
@@ -94,6 +105,7 @@ static void cryptodev_builtin_init(
backend->conf.max_size = LONG_MAX - sizeof(CryptoDevBackendOpInfo);
backend->conf.max_cipher_key_len = CRYPTODEV_BUITLIN_MAX_CIPHER_KEY_LEN;
backend->conf.max_auth_key_len = CRYPTODEV_BUITLIN_MAX_AUTH_KEY_LEN;
+ cryptodev_builtin_init_akcipher(backend);
cryptodev_backend_set_ready(backend, true);
}
--
MST
- [PULL 00/73] virtio,pc,pci: features, fixes, Michael S. Tsirkin, 2023/03/07
- [PULL 01/73] cryptodev: Introduce cryptodev.json, Michael S. Tsirkin, 2023/03/07
- [PULL 02/73] cryptodev: Remove 'name' & 'model' fields, Michael S. Tsirkin, 2023/03/07
- [PULL 03/73] cryptodev: Introduce cryptodev alg type in QAPI, Michael S. Tsirkin, 2023/03/07
- [PULL 04/73] cryptodev: Introduce server type in QAPI, Michael S. Tsirkin, 2023/03/07
- [PULL 05/73] cryptodev: Introduce 'query-cryptodev' QMP command, Michael S. Tsirkin, 2023/03/07
- [PULL 06/73] cryptodev-builtin: Detect akcipher capability,
Michael S. Tsirkin <=
- [PULL 07/73] hmp: add cryptodev info command, Michael S. Tsirkin, 2023/03/07
- [PULL 08/73] cryptodev: Use CryptoDevBackendOpInfo for operation, Michael S. Tsirkin, 2023/03/07
- [PULL 09/73] cryptodev: Account statistics, Michael S. Tsirkin, 2023/03/07
- [PULL 10/73] cryptodev: support QoS, Michael S. Tsirkin, 2023/03/07
- [PULL 11/73] cryptodev: Support query-stats QMP command, Michael S. Tsirkin, 2023/03/07
- [PULL 12/73] MAINTAINERS: add myself as the maintainer for cryptodev, Michael S. Tsirkin, 2023/03/07
- [PULL 13/73] vdpa net: move iova tree creation from init to start, Michael S. Tsirkin, 2023/03/07
- [PULL 14/73] vdpa: Remember last call fd set, Michael S. Tsirkin, 2023/03/07
- [PULL 15/73] vdpa: Negotiate _F_SUSPEND feature, Michael S. Tsirkin, 2023/03/07
- [PULL 16/73] vdpa: rewind at get_base, not set_base, Michael S. Tsirkin, 2023/03/07