From nobody Sun Nov 24 11:16:47 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1725449210; cv=none; d=zohomail.com; s=zohoarc; b=BJmf3DsJicp1NrXPZsbCwM7xR87jNB6jiOLl02Z+Ll98CcdwPzAzeCBDDMLIo0U51AebPgDB9gfkv5sOvwN2CVNZLC1HC8b5oJyEYB0RRu+bz0S46ccAwjFKiame4oDQc0pwRP7wdbSWc/ja8KTQi/xp9ea8mNFmac/q55Q8eGU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1725449210; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=MjUHoQUWEQZufLYm+5meP3FvBAhucIo90QTzT/mE2fg=; b=icDAHh1Z7Mi/ZYERdkAogJh8QoIlv2c3vfu4eUbjTgXeZ2d9LUdzdBohfJc6xMTyVZOqAp7lDsnIeI0Xq2QI785i8tpSqQi1Mejlcf054J2eZPilBgr2EZrq2tBg83UXPJOH9EZih9Wk1rk6tbQ0R68fCZfrwyKKzEwvAJDDbuU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1725449210232402.65109305261717; Wed, 4 Sep 2024 04:26:50 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1slo95-00081j-2K; Wed, 04 Sep 2024 07:25:55 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1slo8a-0005rk-FW for qemu-devel@nongnu.org; Wed, 04 Sep 2024 07:25:25 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1slo8V-0004UW-Jp for qemu-devel@nongnu.org; Wed, 04 Sep 2024 07:25:24 -0400 Received: from mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-599-OsK3oRsuOyiaiP7MSTnNqw-1; Wed, 04 Sep 2024 07:18:51 -0400 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 660E019560A3; Wed, 4 Sep 2024 11:18:47 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.192.112]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id A08D7300019A; Wed, 4 Sep 2024 11:18:46 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id CDA0121E681A; Wed, 4 Sep 2024 13:18:36 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1725449118; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=MjUHoQUWEQZufLYm+5meP3FvBAhucIo90QTzT/mE2fg=; b=JfxVaK1v61KLhkWHUOweqK+8HqQFNsklO1voj8Sy4CkXJi7LUCrJ11Qm9IeaimKHiQw7cd wH/oV77Vn3KheM3ggIUFPs316w9pzyx/pDPzfZ00ZEz4+l82V+L6o/Dtz6KSRiNxn0Z6kK glOebjWaDIt73ph8JBkDT/CjDfV18xw= X-MC-Unique: OsK3oRsuOyiaiP7MSTnNqw-1 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: alex.williamson@redhat.com, andrew@codeconstruct.com.au, andrew@daynix.com, arei.gonglei@huawei.com, berrange@redhat.com, berto@igalia.com, borntraeger@linux.ibm.com, clg@kaod.org, david@redhat.com, den@openvz.org, eblake@redhat.com, eduardo@habkost.net, farman@linux.ibm.com, farosas@suse.de, hreitz@redhat.com, idryomov@gmail.com, iii@linux.ibm.com, jamin_lin@aspeedtech.com, jasowang@redhat.com, joel@jms.id.au, jsnow@redhat.com, kwolf@redhat.com, leetroy@gmail.com, marcandre.lureau@redhat.com, marcel.apfelbaum@gmail.com, michael.roth@amd.com, mst@redhat.com, mtosatti@redhat.com, nsg@linux.ibm.com, pasic@linux.ibm.com, pbonzini@redhat.com, peter.maydell@linaro.org, peterx@redhat.com, philmd@linaro.org, pizhenwei@bytedance.com, pl@dlhnet.de, richard.henderson@linaro.org, stefanha@redhat.com, steven_lee@aspeedtech.com, thuth@redhat.com, vsementsov@yandex-team.ru, wangyanan55@huawei.com, yuri.benditovich@daynix.com, zhao1.liu@intel.com, qemu-block@nongnu.org, qemu-arm@nongnu.org, qemu-s390x@nongnu.org, kvm@vger.kernel.org, avihaih@nvidia.com Subject: [PATCH v2 14/19] qapi/crypto: Rename QCryptoAkCipherAlgorithm to *Algo, and drop prefix Date: Wed, 4 Sep 2024 13:18:31 +0200 Message-ID: <20240904111836.3273842-15-armbru@redhat.com> In-Reply-To: <20240904111836.3273842-1-armbru@redhat.com> References: <20240904111836.3273842-1-armbru@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: 11 X-Spam_score: 1.1 X-Spam_bar: + X-Spam_report: (1.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.142, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1725449212096116600 QAPI's 'prefix' feature can make the connection between enumeration type and its constants less than obvious. It's best used with restraint. QCryptoAkCipherAlgorithm has a 'prefix' that overrides the generated enumeration constants' prefix to QCRYPTO_AKCIPHER_ALG. We could simply drop 'prefix', but then the prefix becomes QCRYPTO_AK_CIPHER_ALGORITHM, which is rather long. We could additionally rename the type to QCryptoAkCipherAlg, but I think the abbreviation "alg" is less than clear. Rename the type to QCryptoAkCipherAlgo instead. The prefix becomes QCRYPTO_AK_CIPHER_ALGO. Signed-off-by: Markus Armbruster Acked-by: Daniel P. Berrang=C3=A9 --- qapi/crypto.json | 7 +++---- crypto/akcipherpriv.h | 2 +- backends/cryptodev-builtin.c | 4 ++-- backends/cryptodev-lkcf.c | 4 ++-- crypto/akcipher.c | 2 +- tests/bench/benchmark-crypto-akcipher.c | 2 +- tests/unit/test-crypto-akcipher.c | 10 +++++----- crypto/akcipher-gcrypt.c.inc | 4 ++-- crypto/akcipher-nettle.c.inc | 4 ++-- 9 files changed, 19 insertions(+), 20 deletions(-) diff --git a/qapi/crypto.json b/qapi/crypto.json index 3e6a7fb8e5..331d49ebb8 100644 --- a/qapi/crypto.json +++ b/qapi/crypto.json @@ -586,7 +586,7 @@ '*sanity-check': 'bool', '*passwordid': 'str' } } ## -# @QCryptoAkCipherAlgorithm: +# @QCryptoAkCipherAlgo: # # The supported algorithms for asymmetric encryption ciphers # @@ -594,8 +594,7 @@ # # Since: 7.1 ## -{ 'enum': 'QCryptoAkCipherAlgorithm', - 'prefix': 'QCRYPTO_AKCIPHER_ALG', +{ 'enum': 'QCryptoAkCipherAlgo', 'data': ['rsa']} =20 ## @@ -649,6 +648,6 @@ # Since: 7.1 ## { 'union': 'QCryptoAkCipherOptions', - 'base': { 'alg': 'QCryptoAkCipherAlgorithm' }, + 'base': { 'alg': 'QCryptoAkCipherAlgo' }, 'discriminator': 'alg', 'data': { 'rsa': 'QCryptoAkCipherOptionsRSA' }} diff --git a/crypto/akcipherpriv.h b/crypto/akcipherpriv.h index 739f639bcf..3b33e54f08 100644 --- a/crypto/akcipherpriv.h +++ b/crypto/akcipherpriv.h @@ -27,7 +27,7 @@ typedef struct QCryptoAkCipherDriver QCryptoAkCipherDriver; =20 struct QCryptoAkCipher { - QCryptoAkCipherAlgorithm alg; + QCryptoAkCipherAlgo alg; QCryptoAkCipherKeyType type; int max_plaintext_len; int max_ciphertext_len; diff --git a/backends/cryptodev-builtin.c b/backends/cryptodev-builtin.c index 2672755661..d8b64091b6 100644 --- a/backends/cryptodev-builtin.c +++ b/backends/cryptodev-builtin.c @@ -64,7 +64,7 @@ static void cryptodev_builtin_init_akcipher(CryptoDevBack= end *backend) { QCryptoAkCipherOptions opts; =20 - opts.alg =3D QCRYPTO_AKCIPHER_ALG_RSA; + opts.alg =3D QCRYPTO_AK_CIPHER_ALGO_RSA; opts.u.rsa.padding_alg =3D QCRYPTO_RSA_PADDING_ALG_RAW; if (qcrypto_akcipher_supports(&opts)) { backend->conf.crypto_services |=3D @@ -318,7 +318,7 @@ static int cryptodev_builtin_create_akcipher_session( =20 switch (sess_info->algo) { case VIRTIO_CRYPTO_AKCIPHER_RSA: - opts.alg =3D QCRYPTO_AKCIPHER_ALG_RSA; + opts.alg =3D QCRYPTO_AK_CIPHER_ALGO_RSA; if (cryptodev_builtin_set_rsa_options(sess_info->u.rsa.padding_alg= o, sess_info->u.rsa.hash_algo, &opts.u.rsa, errp) !=3D 0) { return -1; diff --git a/backends/cryptodev-lkcf.c b/backends/cryptodev-lkcf.c index 6e6012e716..6fb6e03d98 100644 --- a/backends/cryptodev-lkcf.c +++ b/backends/cryptodev-lkcf.c @@ -133,7 +133,7 @@ static int cryptodev_lkcf_set_op_desc(QCryptoAkCipherOp= tions *opts, Error **errp) { QCryptoAkCipherOptionsRSA *rsa_opt; - if (opts->alg !=3D QCRYPTO_AKCIPHER_ALG_RSA) { + if (opts->alg !=3D QCRYPTO_AK_CIPHER_ALGO_RSA) { error_setg(errp, "Unsupported alg: %u", opts->alg); return -1; } @@ -518,7 +518,7 @@ static int cryptodev_lkcf_create_asym_session( =20 switch (sess_info->algo) { case VIRTIO_CRYPTO_AKCIPHER_RSA: - sess->akcipher_opts.alg =3D QCRYPTO_AKCIPHER_ALG_RSA; + sess->akcipher_opts.alg =3D QCRYPTO_AK_CIPHER_ALGO_RSA; if (cryptodev_lkcf_set_rsa_opt( sess_info->u.rsa.padding_algo, sess_info->u.rsa.hash_algo, &sess->akcipher_opts.u.rsa, &local_error) !=3D 0) { diff --git a/crypto/akcipher.c b/crypto/akcipher.c index e4bbc6e5f1..0a0576b792 100644 --- a/crypto/akcipher.c +++ b/crypto/akcipher.c @@ -115,7 +115,7 @@ int qcrypto_akcipher_export_p8info(const QCryptoAkCiphe= rOptions *opts, Error **errp) { switch (opts->alg) { - case QCRYPTO_AKCIPHER_ALG_RSA: + case QCRYPTO_AK_CIPHER_ALGO_RSA: qcrypto_akcipher_rsakey_export_p8info(key, keylen, dst, dst_len); return 0; =20 diff --git a/tests/bench/benchmark-crypto-akcipher.c b/tests/bench/benchmar= k-crypto-akcipher.c index 0029972385..225e426bde 100644 --- a/tests/bench/benchmark-crypto-akcipher.c +++ b/tests/bench/benchmark-crypto-akcipher.c @@ -25,7 +25,7 @@ static QCryptoAkCipher *create_rsa_akcipher(const uint8_t= *priv_key, { QCryptoAkCipherOptions opt; =20 - opt.alg =3D QCRYPTO_AKCIPHER_ALG_RSA; + opt.alg =3D QCRYPTO_AK_CIPHER_ALGO_RSA; opt.u.rsa.padding_alg =3D padding; opt.u.rsa.hash_alg =3D hash; return qcrypto_akcipher_new(&opt, QCRYPTO_AK_CIPHER_KEY_TYPE_PRIVATE, diff --git a/tests/unit/test-crypto-akcipher.c b/tests/unit/test-crypto-akc= ipher.c index 86501f19ab..7dd86125c2 100644 --- a/tests/unit/test-crypto-akcipher.c +++ b/tests/unit/test-crypto-akcipher.c @@ -785,7 +785,7 @@ static QCryptoAkCipherTestData akcipher_test_data[] =3D= { { .path =3D "/crypto/akcipher/rsa1024-raw", .opt =3D { - .alg =3D QCRYPTO_AKCIPHER_ALG_RSA, + .alg =3D QCRYPTO_AK_CIPHER_ALGO_RSA, .u.rsa =3D { .padding_alg =3D QCRYPTO_RSA_PADDING_ALG_RAW, }, @@ -805,7 +805,7 @@ static QCryptoAkCipherTestData akcipher_test_data[] =3D= { { .path =3D "/crypto/akcipher/rsa1024-pkcs1", .opt =3D { - .alg =3D QCRYPTO_AKCIPHER_ALG_RSA, + .alg =3D QCRYPTO_AK_CIPHER_ALGO_RSA, .u.rsa =3D { .padding_alg =3D QCRYPTO_RSA_PADDING_ALG_PKCS1, .hash_alg =3D QCRYPTO_HASH_ALGO_SHA1, @@ -830,7 +830,7 @@ static QCryptoAkCipherTestData akcipher_test_data[] =3D= { { .path =3D "/crypto/akcipher/rsa2048-raw", .opt =3D { - .alg =3D QCRYPTO_AKCIPHER_ALG_RSA, + .alg =3D QCRYPTO_AK_CIPHER_ALGO_RSA, .u.rsa =3D { .padding_alg =3D QCRYPTO_RSA_PADDING_ALG_RAW, }, @@ -850,7 +850,7 @@ static QCryptoAkCipherTestData akcipher_test_data[] =3D= { { .path =3D "/crypto/akcipher/rsa2048-pkcs1", .opt =3D { - .alg =3D QCRYPTO_AKCIPHER_ALG_RSA, + .alg =3D QCRYPTO_AK_CIPHER_ALGO_RSA, .u.rsa =3D { .padding_alg =3D QCRYPTO_RSA_PADDING_ALG_PKCS1, .hash_alg =3D QCRYPTO_HASH_ALGO_SHA1, @@ -944,7 +944,7 @@ static void test_rsakey(const void *opaque) { const QCryptoRSAKeyTestData *data =3D (const QCryptoRSAKeyTestData *)o= paque; QCryptoAkCipherOptions opt =3D { - .alg =3D QCRYPTO_AKCIPHER_ALG_RSA, + .alg =3D QCRYPTO_AK_CIPHER_ALGO_RSA, .u.rsa =3D { .padding_alg =3D QCRYPTO_RSA_PADDING_ALG_PKCS1, .hash_alg =3D QCRYPTO_HASH_ALGO_SHA1, diff --git a/crypto/akcipher-gcrypt.c.inc b/crypto/akcipher-gcrypt.c.inc index 2c81de97de..8f1c2b8143 100644 --- a/crypto/akcipher-gcrypt.c.inc +++ b/crypto/akcipher-gcrypt.c.inc @@ -59,7 +59,7 @@ QCryptoAkCipher *qcrypto_akcipher_new(const QCryptoAkCiph= erOptions *opts, Error **errp) { switch (opts->alg) { - case QCRYPTO_AKCIPHER_ALG_RSA: + case QCRYPTO_AK_CIPHER_ALGO_RSA: return (QCryptoAkCipher *)qcrypto_gcrypt_rsa_new( &opts->u.rsa, type, key, keylen, errp); =20 @@ -568,7 +568,7 @@ error: bool qcrypto_akcipher_supports(QCryptoAkCipherOptions *opts) { switch (opts->alg) { - case QCRYPTO_AKCIPHER_ALG_RSA: + case QCRYPTO_AK_CIPHER_ALGO_RSA: switch (opts->u.rsa.padding_alg) { case QCRYPTO_RSA_PADDING_ALG_RAW: return true; diff --git a/crypto/akcipher-nettle.c.inc b/crypto/akcipher-nettle.c.inc index 37a579fbd9..21f27f8286 100644 --- a/crypto/akcipher-nettle.c.inc +++ b/crypto/akcipher-nettle.c.inc @@ -61,7 +61,7 @@ QCryptoAkCipher *qcrypto_akcipher_new(const QCryptoAkCiph= erOptions *opts, Error **errp) { switch (opts->alg) { - case QCRYPTO_AKCIPHER_ALG_RSA: + case QCRYPTO_AK_CIPHER_ALGO_RSA: return qcrypto_nettle_rsa_new(&opts->u.rsa, type, key, keylen, err= p); =20 default: @@ -425,7 +425,7 @@ error: bool qcrypto_akcipher_supports(QCryptoAkCipherOptions *opts) { switch (opts->alg) { - case QCRYPTO_AKCIPHER_ALG_RSA: + case QCRYPTO_AK_CIPHER_ALGO_RSA: switch (opts->u.rsa.padding_alg) { case QCRYPTO_RSA_PADDING_ALG_PKCS1: switch (opts->u.rsa.hash_alg) { --=20 2.46.0