From: zhenwei pi <pizhenwei@bytedance.com>
To: arei.gonglei@huawei.com, mst@redhat.com, dgilbert@redhat.com,
pbonzini@redhat.com, berrange@redhat.com
Cc: armbru@redhat.com, qemu-devel@nongnu.org,
zhenwei pi <pizhenwei@bytedance.com>
Subject: [PATCH v4 06/12] cryptodev-builtin: Detect akcipher capability
Date: Sun, 29 Jan 2023 10:57:41 +0800 [thread overview]
Message-ID: <20230129025747.682282-7-pizhenwei@bytedance.com> (raw)
In-Reply-To: <20230129025747.682282-1-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>
---
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);
}
--
2.34.1
next prev parent reply other threads:[~2023-01-29 3:00 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-29 2:57 [PATCH v4 00/12] Refactor cryptodev zhenwei pi
2023-01-29 2:57 ` [PATCH v4 01/12] cryptodev: Introduce cryptodev.json zhenwei pi
2023-01-29 2:57 ` [PATCH v4 02/12] cryptodev: Remove 'name' & 'model' fields zhenwei pi
2023-01-29 2:57 ` [PATCH v4 03/12] cryptodev: Introduce cryptodev alg type in QAPI zhenwei pi
2023-01-29 2:57 ` [PATCH v4 04/12] cryptodev: Introduce server " zhenwei pi
2023-01-29 2:57 ` [PATCH v4 05/12] cryptodev: Introduce 'query-cryptodev' QMP command zhenwei pi
2023-01-29 2:57 ` zhenwei pi [this message]
2023-01-29 2:57 ` [PATCH v4 07/12] hmp: add cryptodev info command zhenwei pi
2023-01-29 2:57 ` [PATCH v4 08/12] cryptodev: Use CryptoDevBackendOpInfo for operation zhenwei pi
2023-01-29 2:57 ` [PATCH v4 09/12] cryptodev: Account statistics zhenwei pi
2023-01-29 2:57 ` [PATCH v4 10/12] cryptodev: support QoS zhenwei pi
2023-01-29 2:57 ` [PATCH v4 11/12] cryptodev: Support query-stats QMP command zhenwei pi
2023-02-28 12:56 ` Michael S. Tsirkin
2023-02-28 13:17 ` Daniel P. Berrangé
2023-02-28 14:06 ` Markus Armbruster
2023-02-28 14:13 ` Michael S. Tsirkin
2023-02-28 14:21 ` Daniel P. Berrangé
2023-02-28 14:58 ` Michael S. Tsirkin
2023-03-01 2:53 ` zhenwei pi
2023-01-29 2:57 ` [PATCH v4 12/12] MAINTAINERS: add myself as the maintainer for cryptodev zhenwei pi
2023-02-06 0:23 ` PING: [PATCH v4 00/12] Refactor cryptodev zhenwei pi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230129025747.682282-7-pizhenwei@bytedance.com \
--to=pizhenwei@bytedance.com \
--cc=arei.gonglei@huawei.com \
--cc=armbru@redhat.com \
--cc=berrange@redhat.com \
--cc=dgilbert@redhat.com \
--cc=mst@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).