From nobody Sun Nov 24 08:32:09 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=1725449209; cv=none; d=zohomail.com; s=zohoarc; b=eR1rikPU8lEGEYzLioJQxbg7106xrE/m2MtM0EATEUA6N5/6wlD2fXrFgOxveal0RD6SwLN2SSTPDnSRHFMDKUVEdK06fw5k558WkAciCs/O0tezduzdFxs8dvnfnFlOfEAnKeypRG0zb/ocQDMsEznurz8GW2Ahjiob9Af05tU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1725449209; 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=JwzLbDHsyLFUJ/vXiw1wuo5kYGCQumsIXEoc9OcztJ8=; b=HuMj6BkGsxpJ4GnELdtb7SGraVKESpOGZ8qIv646hCfvholmIXAk2r8mRVRzyfNEQY2BjnDf1/0RAJXXZ+PvRV6L1iEwaOk/Lw+qwU/kerYFOuidmmvFN9n+uyFrPIUJKP0+M1GK1/2AGpOnYGKkS85hUYKwt6jN5482JaN8wP4= 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 1725449209927789.6418727448453; Wed, 4 Sep 2024 04:26:49 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1slo8c-0005qs-37; Wed, 04 Sep 2024 07:25:26 -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 1slo8Y-0005h4-0M for qemu-devel@nongnu.org; Wed, 04 Sep 2024 07:25:22 -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-0004UG-44 for qemu-devel@nongnu.org; Wed, 04 Sep 2024 07:25:21 -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-246-tzF7ZPmeNqWeDANuQ5DEzA-1; Wed, 04 Sep 2024 07:18:48 -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 D02DF1955E8C; Wed, 4 Sep 2024 11:18:42 +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 976F2300019A; Wed, 4 Sep 2024 11:18:38 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 8EA7521E691E; 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=JwzLbDHsyLFUJ/vXiw1wuo5kYGCQumsIXEoc9OcztJ8=; b=QYEmtc3qSOeEcYU+jIMHA5KgJYpSPBXOccBaileSYMBm9TfuONWfyiligcLWjzHDbZZYAa RSsnjIr84aOu7zC63JawERw+CVCs4tuSSFXow2JbibLE3l9/Udkc3C4jurNMUQ2l79jkjY xRPdYBgB9y5n0AXlsQYgsE2gQGzgQLU= X-MC-Unique: tzF7ZPmeNqWeDANuQ5DEzA-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 01/19] qapi: Smarter camel_to_upper() to reduce need for 'prefix' Date: Wed, 4 Sep 2024 13:18:18 +0200 Message-ID: <20240904111836.3273842-2-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: 1725449212152116600 camel_to_upper() converts its argument from camel case to upper case with '_' between words. Used for generated enumeration constant prefixes. When some of the words are spelled all caps, where exactly to insert '_' is guesswork. camel_to_upper()'s guesses are bad enough in places to make people override them with a 'prefix' in the schema. Rewrite it to guess better: 1. Insert '_' after a non-upper case character followed by an upper case character: OneTwo -> ONE_TWO One2Three -> ONE2_THREE 2. Insert '_' before the last upper case character followed by a non-upper case character: ACRONYMWord -> ACRONYM_Word Except at the beginning (as in OneTwo above), or when there is already one: AbCd -> AB_CD This changes the default enumeration constant prefix for a number of enums. Generated enumeration constants change only where the default is not overridden with 'prefix'. The following enumerations without a 'prefix' change: enum old camel_to_upper() new camel_to_upper() ------------------------------------------------------------------ DisplayGLMode DISPLAYGL_MODE DISPLAY_GL_MODE EbpfProgramID EBPF_PROGRAMID EBPF_PROGRAM_ID HmatLBDataType HMATLB_DATA_TYPE HMAT_LB_DATA_TYPE HmatLBMemoryHierarchy HMATLB_MEMORY_HIERARCHY HMAT_LB_MEMORY_HIERARCHY MultiFDCompression MULTIFD_COMPRESSION MULTI_FD_COMPRESSION OffAutoPCIBAR OFF_AUTOPCIBAR OFF_AUTO_PCIBAR QCryptoBlockFormat Q_CRYPTO_BLOCK_FORMAT QCRYPTO_BLOCK_FORMAT QCryptoBlockLUKSKeyslotState Q_CRYPTO_BLOCKLUKS_KEYSLOT_STATE QCRYPTO_BLOCK_LUKS_KEYSLOT_STATE QKeyCode Q_KEY_CODE QKEY_CODE XDbgBlockGraphNodeType X_DBG_BLOCK_GRAPH_NODE_TYPE XDBG_BLOCK_GRAPH_NODE_TYPE TestUnionEnumA TEST_UNION_ENUMA TEST_UNION_ENUM_A Add a 'prefix' so generated code doesn't change now. Subsequent commits will remove most of them again. Two will remain: MULTIFD_COMPRESSION, because migration code generally spells "multifd" that way, and Q_KEY_CODE, because that one is baked into subprojects/keycodemapdb/tools/keymap-gen. The following enumerations with a 'prefix' change so that the prefix is now superfluous: enum old camel_to_upper() new camel_to_upper() [equal to prefix] ------------------------------------------------------------------ BlkdebugIOType BLKDEBUGIO_TYPE BLKDEBUG_IO_TYPE QCryptoTLSCredsEndpoint Q_CRYPTOTLS_CREDS_ENDPOINT QCRYPTO_TLS_CREDS_ENDPOINT QCryptoSecretFormat Q_CRYPTO_SECRET_FORMAT QCRYPTO_SECRET_FORMAT QCryptoCipherMode Q_CRYPTO_CIPHER_MODE QCRYPTO_CIPHER_MODE QCryptodevBackendType Q_CRYPTODEV_BACKEND_TYPE QCRYPTODEV_BACKEND_TYPE QType [builtin] Q_TYPE QTYPE Drop these prefixes. The following enumerations with a 'prefix' change without making the 'prefix' superfluous: enum old camel_to_upper() new camel_to_upper() [equal to prefix] prefix ------------------------------------------------------------------ CpuS390Entitlement CPUS390_ENTITLEMENT CPU_S390_ENTITLEMENT S390_CPU_ENTITLEMENT CpuS390Polarization CPUS390_POLARIZATION CPU_S390_POLARIZATION S390_CPU_POLARIZATION CpuS390State CPUS390_STATE CPU_S390_STATE S390_CPU_STATE QAuthZListFormat Q_AUTHZ_LIST_FORMAT QAUTH_Z_LIST_FORMAT QAUTHZ_LIST_FORMAT QAuthZListPolicy Q_AUTHZ_LIST_POLICY QAUTH_Z_LIST_POLICY QAUTHZ_LIST_POLICY QCryptoAkCipherAlgorithm Q_CRYPTO_AK_CIPHER_ALGORITHM QCRYPTO_AK_CIPHER_ALGORITHM QCRYPTO_AKCIPHER_ALG QCryptoAkCipherKeyType Q_CRYPTO_AK_CIPHER_KEY_TYPE QCRYPTO_AK_CIPHER_KEY_TYPE QCRYPTO_AKCIPHER_KEY_TYPE QCryptoCipherAlgorithm Q_CRYPTO_CIPHER_ALGORITHM QCRYPTO_CIPHER_ALGORITHM QCRYPTO_CIPHER_ALG QCryptoHashAlgorithm Q_CRYPTO_HASH_ALGORITHM QCRYPTO_HASH_ALGORITHM QCRYPTO_HASH_ALG QCryptoIVGenAlgorithm Q_CRYPTOIV_GEN_ALGORITHM QCRYPTO_IV_GEN_ALGORITHM QCRYPTO_IVGEN_ALG QCryptoRSAPaddingAlgorithm Q_CRYPTORSA_PADDING_ALGORITHM QCRYPTO_RSA_PADDING_ALGORITHM QCRYPTO_RSA_PADDING_ALG QCryptodevBackendAlgType Q_CRYPTODEV_BACKEND_ALG_TYPE QCRYPTODEV_BACKEND_ALG_TYPE QCRYPTODEV_BACKEND_ALG QCryptodevBackendServiceType Q_CRYPTODEV_BACKEND_SERVICE_TYPE QCRYPTODEV_BACKEND_SERVICE_TYPE QCRYPTODEV_BACKEND_SERVICE Subsequent commits will tweak things to remove most of these prefixes. Only QAUTHZ_LIST_FORMAT and QAUTHZ_LIST_POLICY will remain. Signed-off-by: Markus Armbruster Reviewed-by: Daniel P. Berrang=C3=A9 --- qapi/block-core.json | 3 +- qapi/common.json | 1 + qapi/crypto.json | 6 ++-- qapi/cryptodev.json | 1 - qapi/ebpf.json | 1 + qapi/machine.json | 2 ++ qapi/migration.json | 1 + qapi/ui.json | 2 ++ scripts/qapi/common.py | 42 ++++++++++++++---------- scripts/qapi/schema.py | 2 +- tests/qapi-schema/alternate-array.out | 1 - tests/qapi-schema/comments.out | 1 - tests/qapi-schema/doc-good.out | 1 - tests/qapi-schema/empty.out | 1 - tests/qapi-schema/include-repetition.out | 1 - tests/qapi-schema/include-simple.out | 1 - tests/qapi-schema/indented-expr.out | 1 - tests/qapi-schema/qapi-schema-test.json | 1 + tests/qapi-schema/qapi-schema-test.out | 2 +- 19 files changed, 38 insertions(+), 33 deletions(-) diff --git a/qapi/block-core.json b/qapi/block-core.json index aa40d44f1d..452047102a 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -2011,6 +2011,7 @@ # Since: 4.0 ## { 'enum': 'XDbgBlockGraphNodeType', + 'prefix': 'X_DBG_BLOCK_GRAPH_NODE_TYPE', # TODO drop 'data': [ 'block-backend', 'block-job', 'block-driver' ] } =20 ## @@ -3746,7 +3747,7 @@ # # Since: 4.1 ## -{ 'enum': 'BlkdebugIOType', 'prefix': 'BLKDEBUG_IO_TYPE', +{ 'enum': 'BlkdebugIOType', 'data': [ 'read', 'write', 'write-zeroes', 'discard', 'flush', 'block-status' ] } =20 diff --git a/qapi/common.json b/qapi/common.json index 7558ce5430..25726d3113 100644 --- a/qapi/common.json +++ b/qapi/common.json @@ -92,6 +92,7 @@ # Since: 2.12 ## { 'enum': 'OffAutoPCIBAR', + 'prefix': 'OFF_AUTOPCIBAR', # TODO drop 'data': [ 'off', 'auto', 'bar0', 'bar1', 'bar2', 'bar3', 'bar4', 'bar5' = ] } =20 ## diff --git a/qapi/crypto.json b/qapi/crypto.json index 97e02dbd59..a192641a03 100644 --- a/qapi/crypto.json +++ b/qapi/crypto.json @@ -20,7 +20,6 @@ # Since: 2.5 ## { 'enum': 'QCryptoTLSCredsEndpoint', - 'prefix': 'QCRYPTO_TLS_CREDS_ENDPOINT', 'data': ['client', 'server']} =20 ## @@ -36,7 +35,6 @@ # Since: 2.6 ## { 'enum': 'QCryptoSecretFormat', - 'prefix': 'QCRYPTO_SECRET_FORMAT', 'data': ['raw', 'base64']} =20 ## @@ -123,7 +121,6 @@ # Since: 2.6 ## { 'enum': 'QCryptoCipherMode', - 'prefix': 'QCRYPTO_CIPHER_MODE', 'data': ['ecb', 'cbc', 'xts', 'ctr']} =20 ## @@ -160,7 +157,7 @@ # Since: 2.6 ## { 'enum': 'QCryptoBlockFormat', -# 'prefix': 'QCRYPTO_BLOCK_FORMAT', + 'prefix': 'Q_CRYPTO_BLOCK_FORMAT', # TODO drop 'data': ['qcow', 'luks']} =20 ## @@ -363,6 +360,7 @@ # Since: 5.1 ## { 'enum': 'QCryptoBlockLUKSKeyslotState', + 'prefix': 'Q_CRYPTO_BLOCKLUKS_KEYSLOT_STATE', # TODO drop 'data': [ 'active', 'inactive' ] } =20 ## diff --git a/qapi/cryptodev.json b/qapi/cryptodev.json index 68289f4984..60f8fe8e4a 100644 --- a/qapi/cryptodev.json +++ b/qapi/cryptodev.json @@ -48,7 +48,6 @@ # Since: 8.0 ## { 'enum': 'QCryptodevBackendType', - 'prefix': 'QCRYPTODEV_BACKEND_TYPE', 'data': ['builtin', 'vhost-user', 'lkcf']} =20 ## diff --git a/qapi/ebpf.json b/qapi/ebpf.json index db19ae850f..42df548777 100644 --- a/qapi/ebpf.json +++ b/qapi/ebpf.json @@ -42,6 +42,7 @@ # Since: 9.0 ## { 'enum': 'EbpfProgramID', + 'prefix': 'EBPF_PROGRAMID', # TODO drop 'if': 'CONFIG_EBPF', 'data': [ { 'name': 'rss' } ] } =20 diff --git a/qapi/machine.json b/qapi/machine.json index d4317435e7..552d1c20e9 100644 --- a/qapi/machine.json +++ b/qapi/machine.json @@ -686,6 +686,7 @@ # Since: 5.0 ## { 'enum': 'HmatLBMemoryHierarchy', + 'prefix': 'HMATLB_MEMORY_HIERARCHY', # TODO drop 'data': [ 'memory', 'first-level', 'second-level', 'third-level' ] } =20 ## @@ -712,6 +713,7 @@ # Since: 5.0 ## { 'enum': 'HmatLBDataType', + 'prefix': 'HMATLB_DATA_TYPE', # TODO drop 'data': [ 'access-latency', 'read-latency', 'write-latency', 'access-bandwidth', 'read-bandwidth', 'write-bandwidth' ] } =20 diff --git a/qapi/migration.json b/qapi/migration.json index 7324571e92..f0ff7b93b4 100644 --- a/qapi/migration.json +++ b/qapi/migration.json @@ -571,6 +571,7 @@ # Since: 5.0 ## { 'enum': 'MultiFDCompression', + 'prefix': 'MULTIFD_COMPRESSION', 'data': [ 'none', 'zlib', { 'name': 'zstd', 'if': 'CONFIG_ZSTD' }, { 'name': 'qpl', 'if': 'CONFIG_QPL' }, diff --git a/qapi/ui.json b/qapi/ui.json index 8c8464faac..f61a2b6b65 100644 --- a/qapi/ui.json +++ b/qapi/ui.json @@ -949,6 +949,7 @@ # Since: 1.3 ## { 'enum': 'QKeyCode', + 'prefix': 'Q_KEY_CODE', 'data': [ 'unmapped', 'shift', 'shift_r', 'alt', 'alt_r', 'ctrl', 'ctrl_r', 'menu', 'esc', '1', '2', '3', '4', '5', '6', '7', '8= ', @@ -1396,6 +1397,7 @@ # Since: 3.0 ## { 'enum' : 'DisplayGLMode', + 'prefix' : 'DISPLAYGL_MODE', # TODO drop 'data' : [ 'off', 'on', 'core', 'es' ] } =20 ## diff --git a/scripts/qapi/common.py b/scripts/qapi/common.py index 737b059e62..d7c8aa3365 100644 --- a/scripts/qapi/common.py +++ b/scripts/qapi/common.py @@ -40,22 +40,28 @@ def camel_to_upper(value: str) -> str: ENUM_Name2 -> ENUM_NAME2 ENUM24_Name -> ENUM24_NAME """ - c_fun_str =3D c_name(value, False) - if value.isupper(): - return c_fun_str + ret =3D value[0] + upc =3D value[0].isupper() =20 - new_name =3D '' - length =3D len(c_fun_str) - for i in range(length): - char =3D c_fun_str[i] - # When char is upper case and no '_' appears before, do more checks - if char.isupper() and (i > 0) and c_fun_str[i - 1] !=3D '_': - if i < length - 1 and c_fun_str[i + 1].islower(): - new_name +=3D '_' - elif c_fun_str[i - 1].isdigit(): - new_name +=3D '_' - new_name +=3D char - return new_name.lstrip('_').upper() + # Copy remainder of ``value`` to ``ret`` with '_' inserted + for ch in value[1:]: + if ch.isupper() =3D=3D upc: + pass + elif upc: + # ``ret`` ends in upper case, next char isn't: insert '_' + # before the last upper case char unless there is one + # already, or it's at the beginning + if len(ret) > 2 and ret[-2].isalnum(): + ret =3D ret[:-1] + '_' + ret[-1] + else: + # ``ret`` doesn't end in upper case, next char is: insert + # '_' before it + if ret[-1].isalnum(): + ret +=3D '_' + ret +=3D ch + upc =3D ch.isupper() + + return c_name(ret.upper()).lstrip('_') =20 =20 def c_enum_const(type_name: str, @@ -68,9 +74,9 @@ def c_enum_const(type_name: str, :param const_name: The name of this constant. :param prefix: Optional, prefix that overrides the type_name. """ - if prefix is not None: - type_name =3D prefix - return camel_to_upper(type_name) + '_' + c_name(const_name, False).upp= er() + if prefix is None: + prefix =3D camel_to_upper(type_name) + return prefix + '_' + c_name(const_name, False).upper() =20 =20 def c_name(name: str, protect: bool =3D True) -> str: diff --git a/scripts/qapi/schema.py b/scripts/qapi/schema.py index d65c35f6ee..e97c978d38 100644 --- a/scripts/qapi/schema.py +++ b/scripts/qapi/schema.py @@ -1249,7 +1249,7 @@ def _def_predefineds(self) -> None: [{'name': n} for n in qtypes], None) =20 self._def_definition(QAPISchemaEnumType( - 'QType', None, None, None, None, qtype_values, 'QTYPE')) + 'QType', None, None, None, None, qtype_values, None)) =20 def _make_features( self, diff --git a/tests/qapi-schema/alternate-array.out b/tests/qapi-schema/alte= rnate-array.out index a657d85738..2f30973ac3 100644 --- a/tests/qapi-schema/alternate-array.out +++ b/tests/qapi-schema/alternate-array.out @@ -1,7 +1,6 @@ module ./builtin object q_empty enum QType - prefix QTYPE member none member qnull member qnum diff --git a/tests/qapi-schema/comments.out b/tests/qapi-schema/comments.out index ce4f6a4f0f..937070c2c4 100644 --- a/tests/qapi-schema/comments.out +++ b/tests/qapi-schema/comments.out @@ -1,7 +1,6 @@ module ./builtin object q_empty enum QType - prefix QTYPE member none member qnull member qnum diff --git a/tests/qapi-schema/doc-good.out b/tests/qapi-schema/doc-good.out index 6d24f1127b..ec277be91e 100644 --- a/tests/qapi-schema/doc-good.out +++ b/tests/qapi-schema/doc-good.out @@ -1,7 +1,6 @@ module ./builtin object q_empty enum QType - prefix QTYPE member none member qnull member qnum diff --git a/tests/qapi-schema/empty.out b/tests/qapi-schema/empty.out index 3feb3f69d3..d1981f8586 100644 --- a/tests/qapi-schema/empty.out +++ b/tests/qapi-schema/empty.out @@ -1,7 +1,6 @@ module ./builtin object q_empty enum QType - prefix QTYPE member none member qnull member qnum diff --git a/tests/qapi-schema/include-repetition.out b/tests/qapi-schema/i= nclude-repetition.out index 16dbd9b819..c564d27862 100644 --- a/tests/qapi-schema/include-repetition.out +++ b/tests/qapi-schema/include-repetition.out @@ -1,7 +1,6 @@ module ./builtin object q_empty enum QType - prefix QTYPE member none member qnull member qnum diff --git a/tests/qapi-schema/include-simple.out b/tests/qapi-schema/inclu= de-simple.out index 48e923bfbc..ec8200ab18 100644 --- a/tests/qapi-schema/include-simple.out +++ b/tests/qapi-schema/include-simple.out @@ -1,7 +1,6 @@ module ./builtin object q_empty enum QType - prefix QTYPE member none member qnull member qnum diff --git a/tests/qapi-schema/indented-expr.out b/tests/qapi-schema/indent= ed-expr.out index 6a30ded3fa..a7c22c3eef 100644 --- a/tests/qapi-schema/indented-expr.out +++ b/tests/qapi-schema/indented-expr.out @@ -1,7 +1,6 @@ module ./builtin object q_empty enum QType - prefix QTYPE member none member qnull member qnum diff --git a/tests/qapi-schema/qapi-schema-test.json b/tests/qapi-schema/qa= pi-schema-test.json index 8ca977c49d..0f5f54e621 100644 --- a/tests/qapi-schema/qapi-schema-test.json +++ b/tests/qapi-schema/qapi-schema-test.json @@ -119,6 +119,7 @@ 'data': [ 'value-a', 'value-b' ] } =20 { 'enum': 'TestUnionEnumA', + 'prefix': 'TEST_UNION_ENUMA', # TODO drop 'data': [ 'value-a1', 'value-a2' ] } =20 { 'struct': 'TestUnionTypeA1', diff --git a/tests/qapi-schema/qapi-schema-test.out b/tests/qapi-schema/qap= i-schema-test.out index e2f0981348..add7346f49 100644 --- a/tests/qapi-schema/qapi-schema-test.out +++ b/tests/qapi-schema/qapi-schema-test.out @@ -1,7 +1,6 @@ module ./builtin object q_empty enum QType - prefix QTYPE member none member qnull member qnum @@ -109,6 +108,7 @@ enum TestUnionEnum member value-a member value-b enum TestUnionEnumA + prefix TEST_UNION_ENUMA member value-a1 member value-a2 object TestUnionTypeA1 --=20 2.46.0 From nobody Sun Nov 24 08:32:09 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=1725449247; cv=none; d=zohomail.com; s=zohoarc; b=iMslCIDkDeDJpRwbilHASx6cHSaN0wrOBEKjyz/8XCg07zIEH3jD+pBCxFLmISi50mQLiOhfbN/LlSSQnA6sUD/UYc64mC+R286S0BKtSkMibJ3wwBKy0/6MEe4YlYyJCV3UF8v2PF4FL9w4xgWIiQZLHUnKMOww4HvRyjhaiVo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1725449247; 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=u8HGx870TvahmH1JUtPzVJvMkaa7TMgcPX/CncVr9MI=; b=nV/Akzv7eUx8i+Cp+abQ/9MHOzsgxouXsa1p/3lJ8ij/KbsLFUJfgfjROKvJKS8ocaVvp5Zes82DqK8cT/KMH/Y3D3Hc/kXanl9DWVJi7emtLfoqYQ0zBWztFcHEfuWarzwgGIaghlPhhEmtj8Xux0Nl107u1tLJ859glP11aOY= 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 1725449247669428.0792413083267; Wed, 4 Sep 2024 04:27:27 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1slo8R-0005Cd-BE; Wed, 04 Sep 2024 07:25:15 -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 1slo8O-00050t-7f for qemu-devel@nongnu.org; Wed, 04 Sep 2024 07:25:12 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1slo8K-0004Ou-68 for qemu-devel@nongnu.org; Wed, 04 Sep 2024 07:25:11 -0400 Received: from mx-prod-mc-03.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-669-8yEoSOX5PNa8sItUOf5ZuQ-1; Wed, 04 Sep 2024 07:18:47 -0400 Received: from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.15]) (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-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 1BD001956048; Wed, 4 Sep 2024 11:18:42 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.192.112]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id B01361956086; Wed, 4 Sep 2024 11:18:38 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 937AE21E692E; 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=1725449106; 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=u8HGx870TvahmH1JUtPzVJvMkaa7TMgcPX/CncVr9MI=; b=Q0gNsj0KekWX+J1Je2Lb6BHt4rS6z4rW1bj9RvO04cNY4QWdnMi8RSGeCIDGi0di2dzW7U cSpCsp8LXz57b02GyYMRvlm5fwkl0PgsvufAeMPn3eQ4LEXMzQ0c17x+o1ageLRSDS5unA PxYCJAZpxuhV5Pv1LzbE4SoUCXTGvmA= X-MC-Unique: 8yEoSOX5PNa8sItUOf5ZuQ-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 02/19] tests/qapi-schema: Drop temporary 'prefix' Date: Wed, 4 Sep 2024 13:18:19 +0200 Message-ID: <20240904111836.3273842-3-armbru@redhat.com> In-Reply-To: <20240904111836.3273842-1-armbru@redhat.com> References: <20240904111836.3273842-1-armbru@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.15 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.129.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_H3=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: 1725449248067116600 Content-Type: text/plain; charset="utf-8" Recent commit "qapi: Smarter camel_to_upper() to reduce need for 'prefix'" added a temporary 'prefix' to delay changing the generated code. Revert it. This changes TestUnionEnumA's generated enumeration constant prefix from TEST_UNION_ENUMA to TEST_UNION_ENUM_A. Signed-off-by: Markus Armbruster Reviewed-by: Thomas Huth --- tests/unit/test-qobject-input-visitor.c | 4 ++-- tests/unit/test-qobject-output-visitor.c | 4 ++-- tests/qapi-schema/qapi-schema-test.json | 1 - tests/qapi-schema/qapi-schema-test.out | 1 - 4 files changed, 4 insertions(+), 6 deletions(-) diff --git a/tests/unit/test-qobject-input-visitor.c b/tests/unit/test-qobj= ect-input-visitor.c index 024e26c49e..5479e68237 100644 --- a/tests/unit/test-qobject-input-visitor.c +++ b/tests/unit/test-qobject-input-visitor.c @@ -720,7 +720,7 @@ static void test_visitor_in_union_in_union(TestInputVis= itorData *data, =20 visit_type_TestUnionInUnion(v, NULL, &tmp, &error_abort); g_assert_cmpint(tmp->type, =3D=3D, TEST_UNION_ENUM_VALUE_A); - g_assert_cmpint(tmp->u.value_a.type_a, =3D=3D, TEST_UNION_ENUMA_VALUE_= A1); + g_assert_cmpint(tmp->u.value_a.type_a, =3D=3D, TEST_UNION_ENUM_A_VALUE= _A1); g_assert_cmpint(tmp->u.value_a.u.value_a1.integer, =3D=3D, 2); g_assert_cmpint(strcmp(tmp->u.value_a.u.value_a1.name, "fish"), =3D=3D= , 0); =20 @@ -734,7 +734,7 @@ static void test_visitor_in_union_in_union(TestInputVis= itorData *data, =20 visit_type_TestUnionInUnion(v, NULL, &tmp, &error_abort); g_assert_cmpint(tmp->type, =3D=3D, TEST_UNION_ENUM_VALUE_A); - g_assert_cmpint(tmp->u.value_a.type_a, =3D=3D, TEST_UNION_ENUMA_VALUE_= A2); + g_assert_cmpint(tmp->u.value_a.type_a, =3D=3D, TEST_UNION_ENUM_A_VALUE= _A2); g_assert_cmpint(tmp->u.value_a.u.value_a2.integer, =3D=3D, 1729); g_assert_cmpint(tmp->u.value_a.u.value_a2.size, =3D=3D, 87539319); =20 diff --git a/tests/unit/test-qobject-output-visitor.c b/tests/unit/test-qob= ject-output-visitor.c index 1535b3ad17..3455f3b107 100644 --- a/tests/unit/test-qobject-output-visitor.c +++ b/tests/unit/test-qobject-output-visitor.c @@ -359,7 +359,7 @@ static void test_visitor_out_union_in_union(TestOutputV= isitorData *data, =20 TestUnionInUnion *tmp =3D g_new0(TestUnionInUnion, 1); tmp->type =3D TEST_UNION_ENUM_VALUE_A; - tmp->u.value_a.type_a =3D TEST_UNION_ENUMA_VALUE_A1; + tmp->u.value_a.type_a =3D TEST_UNION_ENUM_A_VALUE_A1; tmp->u.value_a.u.value_a1.integer =3D 42; tmp->u.value_a.u.value_a1.name =3D g_strdup("fish"); =20 @@ -377,7 +377,7 @@ static void test_visitor_out_union_in_union(TestOutputV= isitorData *data, visitor_reset(data); tmp =3D g_new0(TestUnionInUnion, 1); tmp->type =3D TEST_UNION_ENUM_VALUE_A; - tmp->u.value_a.type_a =3D TEST_UNION_ENUMA_VALUE_A2; + tmp->u.value_a.type_a =3D TEST_UNION_ENUM_A_VALUE_A2; tmp->u.value_a.u.value_a2.integer =3D 1729; tmp->u.value_a.u.value_a2.size =3D 87539319; =20 diff --git a/tests/qapi-schema/qapi-schema-test.json b/tests/qapi-schema/qa= pi-schema-test.json index 0f5f54e621..8ca977c49d 100644 --- a/tests/qapi-schema/qapi-schema-test.json +++ b/tests/qapi-schema/qapi-schema-test.json @@ -119,7 +119,6 @@ 'data': [ 'value-a', 'value-b' ] } =20 { 'enum': 'TestUnionEnumA', - 'prefix': 'TEST_UNION_ENUMA', # TODO drop 'data': [ 'value-a1', 'value-a2' ] } =20 { 'struct': 'TestUnionTypeA1', diff --git a/tests/qapi-schema/qapi-schema-test.out b/tests/qapi-schema/qap= i-schema-test.out index add7346f49..4617eb4e98 100644 --- a/tests/qapi-schema/qapi-schema-test.out +++ b/tests/qapi-schema/qapi-schema-test.out @@ -108,7 +108,6 @@ enum TestUnionEnum member value-a member value-b enum TestUnionEnumA - prefix TEST_UNION_ENUMA member value-a1 member value-a2 object TestUnionTypeA1 --=20 2.46.0 From nobody Sun Nov 24 08:32:09 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=1725449303; cv=none; d=zohomail.com; s=zohoarc; b=n/JBDXEuZDhWP810sVNIksDhM+kw540QakFWHtQ4+/y6E9xtasGmIoeI2AWfccK9z0O3AVu9+jxXSxgBngAzz+/d9BCEDC/T2aXaKgQIS09kRGYeEYS4uNLo/99kn6BUoztmREVvXDndEjJT3212zy19yEC9Fh3ArC7Do6eD2qE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1725449303; 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=60/S7nrmH8dWcOxOWOtd93pxbq0cOxGZapRifYABfNs=; b=T92qHwJXUymixAxZc5GuOBsyzMUfssbCfEqLpf39oRWaL4dcEPYSOTbgnfUG71/J6um1C+2E5ehi4HRdEN1CAsZ+5P7lPLVB8gXEQ0LCmCzQg4QNyWciW4a7YB+LpeHHtfbTYWhA09PQXcaGpg6azalzC8h6zBWyQ/9M0+TCxM4= 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 1725449303663404.991016258474; Wed, 4 Sep 2024 04:28:23 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1slo9R-00028I-IH; Wed, 04 Sep 2024 07:26:17 -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 1slo9I-0001Ci-HA for qemu-devel@nongnu.org; Wed, 04 Sep 2024 07:26:11 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1slo9C-0004lZ-U1 for qemu-devel@nongnu.org; Wed, 04 Sep 2024 07:26:08 -0400 Received: from mx-prod-mc-05.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-640-sjpFcQu1MvupF4SYoECIcA-1; Wed, 04 Sep 2024 07:18:46 -0400 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (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-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id D3DE71955F56; Wed, 4 Sep 2024 11:18:41 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.192.112]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id AA1FB19560AA; Wed, 4 Sep 2024 11:18:38 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 97E0921E6939; 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=1725449161; 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=60/S7nrmH8dWcOxOWOtd93pxbq0cOxGZapRifYABfNs=; b=dfJ/wHUj70Co0ZgzW9LhAw5r303tnn0aSYXGT1gB7vh1Sl/iWoWLlovTgj33zxjhm2bYte 8khWQds3HukvQEdvDFn+ex2KmViHoxxxxrZuELvH0uI8RwVWhAPrIPc1oV1+q0Wp4rHJ14 8C4/3VqHsGHPuWXaebmMApMaNFHu/To= X-MC-Unique: sjpFcQu1MvupF4SYoECIcA-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 03/19] qapi/block-core: Drop temporary 'prefix' Date: Wed, 4 Sep 2024 13:18:20 +0200 Message-ID: <20240904111836.3273842-4-armbru@redhat.com> In-Reply-To: <20240904111836.3273842-1-armbru@redhat.com> References: <20240904111836.3273842-1-armbru@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 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.129.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_H3=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: 1725449304405116600 Content-Type: text/plain; charset="utf-8" Recent commit "qapi: Smarter camel_to_upper() to reduce need for 'prefix'" added a temporary 'prefix' to delay changing the generated code. Revert it. This improves XDbgBlockGraphNodeType's generated enumeration constant prefix from X_DBG_BLOCK_GRAPH_NODE_TYPE_BLOCK_BACKEND to XDBG_BLOCK_GRAPH_NODE_TYPE_BLOCK_BACKEND. Signed-off-by: Markus Armbruster Reviewed-by: Vladimir Sementsov-Ogievskiy --- qapi/block-core.json | 1 - block.c | 6 +++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/qapi/block-core.json b/qapi/block-core.json index 452047102a..a7ae2da47b 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -2011,7 +2011,6 @@ # Since: 4.0 ## { 'enum': 'XDbgBlockGraphNodeType', - 'prefix': 'X_DBG_BLOCK_GRAPH_NODE_TYPE', # TODO drop 'data': [ 'block-backend', 'block-job', 'block-driver' ] } =20 ## diff --git a/block.c b/block.c index c317de9eaa..7d90007cae 100644 --- a/block.c +++ b/block.c @@ -6351,7 +6351,7 @@ XDbgBlockGraph *bdrv_get_xdbg_block_graph(Error **err= p) if (!*name) { name =3D allocated_name =3D blk_get_attached_dev_id(blk); } - xdbg_graph_add_node(gr, blk, X_DBG_BLOCK_GRAPH_NODE_TYPE_BLOCK_BAC= KEND, + xdbg_graph_add_node(gr, blk, XDBG_BLOCK_GRAPH_NODE_TYPE_BLOCK_BACK= END, name); g_free(allocated_name); if (blk_root(blk)) { @@ -6364,7 +6364,7 @@ XDbgBlockGraph *bdrv_get_xdbg_block_graph(Error **err= p) job =3D block_job_next_locked(job)) { GSList *el; =20 - xdbg_graph_add_node(gr, job, X_DBG_BLOCK_GRAPH_NODE_TYPE_BLOCK= _JOB, + xdbg_graph_add_node(gr, job, XDBG_BLOCK_GRAPH_NODE_TYPE_BLOCK_= JOB, job->job.id); for (el =3D job->nodes; el; el =3D el->next) { xdbg_graph_add_edge(gr, job, (BdrvChild *)el->data); @@ -6373,7 +6373,7 @@ XDbgBlockGraph *bdrv_get_xdbg_block_graph(Error **err= p) } =20 QTAILQ_FOREACH(bs, &graph_bdrv_states, node_list) { - xdbg_graph_add_node(gr, bs, X_DBG_BLOCK_GRAPH_NODE_TYPE_BLOCK_DRIV= ER, + xdbg_graph_add_node(gr, bs, XDBG_BLOCK_GRAPH_NODE_TYPE_BLOCK_DRIVE= R, bs->node_name); QLIST_FOREACH(child, &bs->children, next) { xdbg_graph_add_edge(gr, bs, child); --=20 2.46.0 From nobody Sun Nov 24 08:32:09 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=1725449385; cv=none; d=zohomail.com; s=zohoarc; b=izgOXM0qLOD4brXcqRhL+tZ16bmmXoLZqyQiZ5MSHm3auPs9uq/kzMDIGwlbI03rAS2aVAwvSAqZ+XhyI5eraBIfbwapJASWmaSgyMW0/ylNh9NpJEK5ajy+5e1rFKe8qHuVa059o7b+TR07bGHhSMenqP05bV9Z8E7Ck8vrcGo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1725449385; 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=AOXOx69AjXFnVeSXCiUEnvi9+g/XRHvEVNlHUQEOkmw=; b=JdQCUGeGe0tJu4JROmyXiiZgzMncgjRbhaXEN1dnXxvU+J47RemOKIiC8h+zBhvLF3QC4xxwdL+Hg0YqCfzZO3qO/V4PX26FbMoFwG6AgDfEo3Iqam331JCnI14cGRLbTUwN7WM2kZbTrERACZETR6m+4yzmn0pdwBp0GnjCYdk= 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 1725449385544977.5138243533775; Wed, 4 Sep 2024 04:29:45 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1slo94-0007pj-0C; Wed, 04 Sep 2024 07:25:54 -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 1slo8Z-0005mc-GB for qemu-devel@nongnu.org; Wed, 04 Sep 2024 07:25:23 -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-0004UV-Jp for qemu-devel@nongnu.org; Wed, 04 Sep 2024 07:25:22 -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-654-ofAYSMSyOQ-lOH4Y7zlY6Q-1; Wed, 04 Sep 2024 07:18:50 -0400 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (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 C6CEF1955D45; Wed, 4 Sep 2024 11:18:41 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.192.112]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 9702119560A3; Wed, 4 Sep 2024 11:18:38 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 9C53021E6889; 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=AOXOx69AjXFnVeSXCiUEnvi9+g/XRHvEVNlHUQEOkmw=; b=PBFTwjXofXPKv1dGdMWPMw8/CAXCNF7fHwduLysO0WddfGEW62ZCfy02x/1dQXBKobAURa t9YfDsXJ/OHHevoh54CpOdDSOsAw0ieN3aOjsvKDzVzujeFeaSxCPGLdsY0ZkYwhNjhZ31 f5Jz9ZxA9U0yF/JIXFSGJvBMkfjucxY= X-MC-Unique: ofAYSMSyOQ-lOH4Y7zlY6Q-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, =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Subject: [PATCH v2 04/19] qapi/common: Drop temporary 'prefix' Date: Wed, 4 Sep 2024 13:18:21 +0200 Message-ID: <20240904111836.3273842-5-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.0 on 10.30.177.17 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: 1725449386762116600 Recent commit "qapi: Smarter camel_to_upper() to reduce need for 'prefix'" added a temporary 'prefix' to delay changing the generated code. Revert it. This improves OffAutoPCIBAR's generated enumeration constant prefix from OFF_AUTOPCIBAR to OFF_AUTO_PCIBAR. Signed-off-by: Markus Armbruster Reviewed-by: C=C3=A9dric Le Goater --- qapi/common.json | 1 - hw/vfio/pci.c | 10 +++++----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/qapi/common.json b/qapi/common.json index 25726d3113..7558ce5430 100644 --- a/qapi/common.json +++ b/qapi/common.json @@ -92,7 +92,6 @@ # Since: 2.12 ## { 'enum': 'OffAutoPCIBAR', - 'prefix': 'OFF_AUTOPCIBAR', # TODO drop 'data': [ 'off', 'auto', 'bar0', 'bar1', 'bar2', 'bar3', 'bar4', 'bar5' = ] } =20 ## diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c index 2407720c35..0a99e55247 100644 --- a/hw/vfio/pci.c +++ b/hw/vfio/pci.c @@ -1452,7 +1452,7 @@ static bool vfio_pci_relocate_msix(VFIOPCIDevice *vde= v, Error **errp) int target_bar =3D -1; size_t msix_sz; =20 - if (!vdev->msix || vdev->msix_relo =3D=3D OFF_AUTOPCIBAR_OFF) { + if (!vdev->msix || vdev->msix_relo =3D=3D OFF_AUTO_PCIBAR_OFF) { return true; } =20 @@ -1464,7 +1464,7 @@ static bool vfio_pci_relocate_msix(VFIOPCIDevice *vde= v, Error **errp) /* PCI BARs must be a power of 2 */ msix_sz =3D pow2ceil(msix_sz); =20 - if (vdev->msix_relo =3D=3D OFF_AUTOPCIBAR_AUTO) { + if (vdev->msix_relo =3D=3D OFF_AUTO_PCIBAR_AUTO) { /* * TODO: Lookup table for known devices. * @@ -1479,7 +1479,7 @@ static bool vfio_pci_relocate_msix(VFIOPCIDevice *vde= v, Error **errp) return false; } } else { - target_bar =3D (int)(vdev->msix_relo - OFF_AUTOPCIBAR_BAR0); + target_bar =3D (int)(vdev->msix_relo - OFF_AUTO_PCIBAR_BAR0); } =20 /* I/O port BARs cannot host MSI-X structures */ @@ -1624,7 +1624,7 @@ static bool vfio_msix_early_setup(VFIOPCIDevice *vdev= , Error **errp) } else if (vfio_pci_is(vdev, PCI_VENDOR_ID_BAIDU, PCI_DEVICE_ID_KUNLUN_VF)) { msix->pba_offset =3D 0xb400; - } else if (vdev->msix_relo =3D=3D OFF_AUTOPCIBAR_OFF) { + } else if (vdev->msix_relo =3D=3D OFF_AUTO_PCIBAR_OFF) { error_setg(errp, "hardware reports invalid configuration, " "MSIX PBA outside of specified BAR"); g_free(msix); @@ -3403,7 +3403,7 @@ static Property vfio_pci_dev_properties[] =3D { nv_gpudirect_clique, qdev_prop_nv_gpudirect_clique, uint8_t), DEFINE_PROP_OFF_AUTO_PCIBAR("x-msix-relocation", VFIOPCIDevice, msix_r= elo, - OFF_AUTOPCIBAR_OFF), + OFF_AUTO_PCIBAR_OFF), #ifdef CONFIG_IOMMUFD DEFINE_PROP_LINK("iommufd", VFIOPCIDevice, vbasedev.iommufd, TYPE_IOMMUFD_BACKEND, IOMMUFDBackend *), --=20 2.46.0 From nobody Sun Nov 24 08:32:09 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=1725449158; cv=none; d=zohomail.com; s=zohoarc; b=WAOzyuU4DJiyDRlT8HX+eXxTanw3nVjFT8FmL/5W0z+LUSmu3wlWORempGDV0/iu+X1VJYnQiCNnvR59cq2566sOUO1y0N4EwQuPBsLfOYSz2vizD+7+a9oSFEXVrWcQ7u+TMD30sTVNDG1Rl++sdSRnsMoertV2Y/mNcC7C3iw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1725449158; 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=nUroX0vXvKhL/8z7tcNdIRkDute+jOG+hDXiUvRu6WU=; b=HqSmguERu5xXwYqzLrqhxhfQxxZ5lRZO5tsQfvhbF4u98D3gnFemrjsfS2RA4XWRxS15WmD0LKrka7fOdgOoB1EjmXkQGeOQaw5+MPRTY7nyhpYbmjyMoxr3Yeq00IhxnMfCj7Q8jBmI7nVZyoc1HrcDaroGl3cuftjwoFV5dO8= 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 1725449158600192.92551326157036; Wed, 4 Sep 2024 04:25:58 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1slo8T-0005N3-IR; Wed, 04 Sep 2024 07:25:17 -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 1slo8R-0005EB-Gc for qemu-devel@nongnu.org; Wed, 04 Sep 2024 07:25:15 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1slo8N-0004Q8-Uk for qemu-devel@nongnu.org; Wed, 04 Sep 2024 07:25:15 -0400 Received: from mx-prod-mc-05.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-584-iYG9wXhTNGKOqN7f6QET-Q-1; Wed, 04 Sep 2024 07:18:50 -0400 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (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-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id AF1DD1955F25; Wed, 4 Sep 2024 11:18:46 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.192.112]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id BCA411956052; Wed, 4 Sep 2024 11:18:43 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id A118621E688F; 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=1725449109; 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=nUroX0vXvKhL/8z7tcNdIRkDute+jOG+hDXiUvRu6WU=; b=PtGyxMm0YePFN+L6iL1iza941p9kujgYv3G44BwSiOYznwaWTUyub3T8+9cF1viR/ZwjFN s0moJNqJ2EwvjwLhtC18WTqq4OHTzt6CdEbCQoY5uQH8MruOG7NRKZ4XJbdGqlxQuHt4fB ww1SXgrGODACBgbJBhvSuOl3ifb09s0= X-MC-Unique: iYG9wXhTNGKOqN7f6QET-Q-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 05/19] qapi/crypto: Drop temporary 'prefix' Date: Wed, 4 Sep 2024 13:18:22 +0200 Message-ID: <20240904111836.3273842-6-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.0 on 10.30.177.17 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.129.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_H3=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: 1725449159832116600 Recent commit "qapi: Smarter camel_to_upper() to reduce need for 'prefix'" added two temporary 'prefix' to delay changing the generated code. Revert them. This improves QCryptoBlockFormat's generated enumeration constant prefix from Q_CRYPTO_BLOCK_FORMAT to QCRYPTO_BLOCK_FORMAT, and QCryptoBlockLUKSKeyslotState's from Q_CRYPTO_BLOCKLUKS_KEYSLOT_STATE to QCRYPTO_BLOCK_LUKS_KEYSLOT_STATE. Signed-off-by: Markus Armbruster Acked-by: Daniel P. Berrang=C3=A9 --- qapi/crypto.json | 2 -- block/crypto.c | 10 +++++----- block/qcow.c | 2 +- block/qcow2.c | 10 +++++----- crypto/block-luks.c | 4 ++-- crypto/block.c | 4 ++-- tests/unit/test-crypto-block.c | 14 +++++++------- 7 files changed, 22 insertions(+), 24 deletions(-) diff --git a/qapi/crypto.json b/qapi/crypto.json index a192641a03..fb00c706b2 100644 --- a/qapi/crypto.json +++ b/qapi/crypto.json @@ -157,7 +157,6 @@ # Since: 2.6 ## { 'enum': 'QCryptoBlockFormat', - 'prefix': 'Q_CRYPTO_BLOCK_FORMAT', # TODO drop 'data': ['qcow', 'luks']} =20 ## @@ -360,7 +359,6 @@ # Since: 5.1 ## { 'enum': 'QCryptoBlockLUKSKeyslotState', - 'prefix': 'Q_CRYPTO_BLOCKLUKS_KEYSLOT_STATE', # TODO drop 'data': [ 'active', 'inactive' ] } =20 ## diff --git a/block/crypto.c b/block/crypto.c index 4eed3ffa6a..80b2dba17a 100644 --- a/block/crypto.c +++ b/block/crypto.c @@ -682,7 +682,7 @@ err: static int block_crypto_probe_luks(const uint8_t *buf, int buf_size, const char *filename) { - return block_crypto_probe_generic(Q_CRYPTO_BLOCK_FORMAT_LUKS, + return block_crypto_probe_generic(QCRYPTO_BLOCK_FORMAT_LUKS, buf, buf_size, filename); } =20 @@ -691,7 +691,7 @@ static int block_crypto_open_luks(BlockDriverState *bs, int flags, Error **errp) { - return block_crypto_open_generic(Q_CRYPTO_BLOCK_FORMAT_LUKS, + return block_crypto_open_generic(QCRYPTO_BLOCK_FORMAT_LUKS, &block_crypto_runtime_opts_luks, bs, options, flags, errp); } @@ -724,7 +724,7 @@ block_crypto_co_create_luks(BlockdevCreateOptions *crea= te_options, Error **errp) } =20 create_opts =3D (QCryptoBlockCreateOptions) { - .format =3D Q_CRYPTO_BLOCK_FORMAT_LUKS, + .format =3D QCRYPTO_BLOCK_FORMAT_LUKS, .u.luks =3D *qapi_BlockdevCreateOptionsLUKS_base(luks_opts), }; =20 @@ -889,7 +889,7 @@ block_crypto_get_specific_info_luks(BlockDriverState *b= s, Error **errp) if (!info) { return NULL; } - assert(info->format =3D=3D Q_CRYPTO_BLOCK_FORMAT_LUKS); + assert(info->format =3D=3D QCRYPTO_BLOCK_FORMAT_LUKS); =20 spec_info =3D g_new(ImageInfoSpecific, 1); spec_info->type =3D IMAGE_INFO_SPECIFIC_KIND_LUKS; @@ -1002,7 +1002,7 @@ coroutine_fn block_crypto_co_amend_luks(BlockDriverSt= ate *bs, QCryptoBlockAmendOptions amend_opts; =20 amend_opts =3D (QCryptoBlockAmendOptions) { - .format =3D Q_CRYPTO_BLOCK_FORMAT_LUKS, + .format =3D QCRYPTO_BLOCK_FORMAT_LUKS, .u.luks =3D *qapi_BlockdevAmendOptionsLUKS_base(&opts->u.luks), }; return block_crypto_amend_options_generic_luks(bs, &amend_opts, diff --git a/block/qcow.c b/block/qcow.c index c2f89db055..84d1cca296 100644 --- a/block/qcow.c +++ b/block/qcow.c @@ -831,7 +831,7 @@ qcow_co_create(BlockdevCreateOptions *opts, Error **err= p) } =20 if (qcow_opts->encrypt && - qcow_opts->encrypt->format !=3D Q_CRYPTO_BLOCK_FORMAT_QCOW) + qcow_opts->encrypt->format !=3D QCRYPTO_BLOCK_FORMAT_QCOW) { error_setg(errp, "Unsupported encryption format"); return -EINVAL; diff --git a/block/qcow2.c b/block/qcow2.c index 70b19730a3..dd359d241b 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -3214,10 +3214,10 @@ qcow2_set_up_encryption(BlockDriverState *bs, int fmt, ret; =20 switch (cryptoopts->format) { - case Q_CRYPTO_BLOCK_FORMAT_LUKS: + case QCRYPTO_BLOCK_FORMAT_LUKS: fmt =3D QCOW_CRYPT_LUKS; break; - case Q_CRYPTO_BLOCK_FORMAT_QCOW: + case QCRYPTO_BLOCK_FORMAT_QCOW: fmt =3D QCOW_CRYPT_AES; break; default: @@ -5306,10 +5306,10 @@ qcow2_get_specific_info(BlockDriverState *bs, Error= **errp) ImageInfoSpecificQCow2Encryption *qencrypt =3D g_new(ImageInfoSpecificQCow2Encryption, 1); switch (encrypt_info->format) { - case Q_CRYPTO_BLOCK_FORMAT_QCOW: + case QCRYPTO_BLOCK_FORMAT_QCOW: qencrypt->format =3D BLOCKDEV_QCOW2_ENCRYPTION_FORMAT_AES; break; - case Q_CRYPTO_BLOCK_FORMAT_LUKS: + case QCRYPTO_BLOCK_FORMAT_LUKS: qencrypt->format =3D BLOCKDEV_QCOW2_ENCRYPTION_FORMAT_LUKS; qencrypt->u.luks =3D encrypt_info->u.luks; break; @@ -5948,7 +5948,7 @@ static int coroutine_fn qcow2_co_amend(BlockDriverSta= te *bs, return -EOPNOTSUPP; } =20 - if (qopts->encrypt->format !=3D Q_CRYPTO_BLOCK_FORMAT_LUKS) { + if (qopts->encrypt->format !=3D QCRYPTO_BLOCK_FORMAT_LUKS) { error_setg(errp, "Amend can't be used to change the qcow2 encryption= format"); return -EOPNOTSUPP; diff --git a/crypto/block-luks.c b/crypto/block-luks.c index 45347adeeb..7b9c7b292d 100644 --- a/crypto/block-luks.c +++ b/crypto/block-luks.c @@ -1861,11 +1861,11 @@ qcrypto_block_luks_amend_options(QCryptoBlock *bloc= k, QCryptoBlockAmendOptionsLUKS *opts_luks =3D &options->u.luks; =20 switch (opts_luks->state) { - case Q_CRYPTO_BLOCKLUKS_KEYSLOT_STATE_ACTIVE: + case QCRYPTO_BLOCK_LUKS_KEYSLOT_STATE_ACTIVE: return qcrypto_block_luks_amend_add_keyslot(block, readfunc, writefunc, opaque, opts_luks, force, errp= ); - case Q_CRYPTO_BLOCKLUKS_KEYSLOT_STATE_INACTIVE: + case QCRYPTO_BLOCK_LUKS_KEYSLOT_STATE_INACTIVE: return qcrypto_block_luks_amend_erase_keyslots(block, readfunc, writefunc, opaque, opts_luks, force, e= rrp); diff --git a/crypto/block.c b/crypto/block.c index 3bcc4270c3..899561a080 100644 --- a/crypto/block.c +++ b/crypto/block.c @@ -26,8 +26,8 @@ #include "block-luks.h" =20 static const QCryptoBlockDriver *qcrypto_block_drivers[] =3D { - [Q_CRYPTO_BLOCK_FORMAT_QCOW] =3D &qcrypto_block_driver_qcow, - [Q_CRYPTO_BLOCK_FORMAT_LUKS] =3D &qcrypto_block_driver_luks, + [QCRYPTO_BLOCK_FORMAT_QCOW] =3D &qcrypto_block_driver_qcow, + [QCRYPTO_BLOCK_FORMAT_LUKS] =3D &qcrypto_block_driver_luks, }; =20 =20 diff --git a/tests/unit/test-crypto-block.c b/tests/unit/test-crypto-block.c index 42cfab6067..2a6c6e99e5 100644 --- a/tests/unit/test-crypto-block.c +++ b/tests/unit/test-crypto-block.c @@ -39,14 +39,14 @@ #endif =20 static QCryptoBlockCreateOptions qcow_create_opts =3D { - .format =3D Q_CRYPTO_BLOCK_FORMAT_QCOW, + .format =3D QCRYPTO_BLOCK_FORMAT_QCOW, .u.qcow =3D { .key_secret =3D (char *)"sec0", }, }; =20 static QCryptoBlockOpenOptions qcow_open_opts =3D { - .format =3D Q_CRYPTO_BLOCK_FORMAT_QCOW, + .format =3D QCRYPTO_BLOCK_FORMAT_QCOW, .u.qcow =3D { .key_secret =3D (char *)"sec0", }, @@ -55,7 +55,7 @@ static QCryptoBlockOpenOptions qcow_open_opts =3D { =20 #ifdef TEST_LUKS static QCryptoBlockOpenOptions luks_open_opts =3D { - .format =3D Q_CRYPTO_BLOCK_FORMAT_LUKS, + .format =3D QCRYPTO_BLOCK_FORMAT_LUKS, .u.luks =3D { .key_secret =3D (char *)"sec0", }, @@ -64,7 +64,7 @@ static QCryptoBlockOpenOptions luks_open_opts =3D { =20 /* Creation with all default values */ static QCryptoBlockCreateOptions luks_create_opts_default =3D { - .format =3D Q_CRYPTO_BLOCK_FORMAT_LUKS, + .format =3D QCRYPTO_BLOCK_FORMAT_LUKS, .u.luks =3D { .key_secret =3D (char *)"sec0", }, @@ -73,7 +73,7 @@ static QCryptoBlockCreateOptions luks_create_opts_default= =3D { =20 /* ...and with explicit values */ static QCryptoBlockCreateOptions luks_create_opts_aes256_cbc_plain64 =3D { - .format =3D Q_CRYPTO_BLOCK_FORMAT_LUKS, + .format =3D QCRYPTO_BLOCK_FORMAT_LUKS, .u.luks =3D { .key_secret =3D (char *)"sec0", .has_cipher_alg =3D true, @@ -87,7 +87,7 @@ static QCryptoBlockCreateOptions luks_create_opts_aes256_= cbc_plain64 =3D { =20 =20 static QCryptoBlockCreateOptions luks_create_opts_aes256_cbc_essiv =3D { - .format =3D Q_CRYPTO_BLOCK_FORMAT_LUKS, + .format =3D QCRYPTO_BLOCK_FORMAT_LUKS, .u.luks =3D { .key_secret =3D (char *)"sec0", .has_cipher_alg =3D true, @@ -572,7 +572,7 @@ int main(int argc, char **argv) g_assert(qcrypto_init(NULL) =3D=3D 0); =20 for (i =3D 0; i < G_N_ELEMENTS(test_data); i++) { - if (test_data[i].open_opts->format =3D=3D Q_CRYPTO_BLOCK_FORMAT_LU= KS && + if (test_data[i].open_opts->format =3D=3D QCRYPTO_BLOCK_FORMAT_LUK= S && !qcrypto_hash_supports(test_data[i].hash_alg)) { continue; } --=20 2.46.0 From nobody Sun Nov 24 08:32:09 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=1725449199; cv=none; d=zohomail.com; s=zohoarc; b=UBkKp2UpnHfIlGU6fLVrrYOCcS7QSLiXWUx8MFcpzeEmcq42FLlFqTVUJD9upM+0qho2opuFftGV41LxFDoleFaXjaQfMZPb4UmgP6n95ahJ701UrEWL+D2QNJNM+eQaVFaEUMxiSFtSbf/wflZk/45sOCpEuPutHFrHduH5qqw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1725449199; 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=v5OxU5+fri0QNP4QtfQ3jXNPwWqLTQ/eTokftl8fAO4=; b=mt66CCrE7tALodeVOcB/x/V+9m6l26XiW4UisTJJu2MoWByEaE11MfUe3IaB2VVlnJ9aRZFT/L35FAksAhIGfUR1RFA8AtlreSpGpfqN6lgXte3LEXyYSWpgKoj76852C/LmDdoZB4N4yd7RyW0VN1nzxexcktDr+AZBC2BnRoo= 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 172544919950881.28777353056614; Wed, 4 Sep 2024 04:26:39 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1slo9L-00015a-Ma; Wed, 04 Sep 2024 07:26:11 -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 1slo9F-0000sK-FS for qemu-devel@nongnu.org; Wed, 04 Sep 2024 07:26:05 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1slo9C-0004kc-63 for qemu-devel@nongnu.org; Wed, 04 Sep 2024 07:26:05 -0400 Received: from mx-prod-mc-05.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-186-pVd6KmuaMr2gAXdvQZzOMA-1; Wed, 04 Sep 2024 07:18:52 -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-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 89E3D1955DB2; Wed, 4 Sep 2024 11:18:44 +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 CA934300019A; Wed, 4 Sep 2024 11:18:43 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id A626921E6891; 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=1725449161; 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=v5OxU5+fri0QNP4QtfQ3jXNPwWqLTQ/eTokftl8fAO4=; b=SM6iXgrUxON8IxMyRqQ/tb7CNblgxowdtNmB0Ts+mTTvCz/SNIdgh/wSOljkhnjLq2XjcE dxjc3++V0nRyozVgdM6dQwl0+4Iq8OfTsFjkXl9eOTiPC+0+Ra2VE5+aVlfhBzkGkRJliC FRNIBiZM8j9Vwm58n2SOi5VN847D0yQ= X-MC-Unique: pVd6KmuaMr2gAXdvQZzOMA-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 06/19] qapi/ebpf: Drop temporary 'prefix' Date: Wed, 4 Sep 2024 13:18:23 +0200 Message-ID: <20240904111836.3273842-7-armbru@redhat.com> In-Reply-To: <20240904111836.3273842-1-armbru@redhat.com> References: <20240904111836.3273842-1-armbru@redhat.com> MIME-Version: 1.0 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.129.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_H3=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: 1725449199934116600 Content-Type: text/plain; charset="utf-8" Recent commit "qapi: Smarter camel_to_upper() to reduce need for 'prefix'" added a temporary 'prefix' to delay changing the generated code. Revert it. This improves EbpfProgramID's generated enumeration constant prefix from EBPF_PROGRAMID to EBPF_PROGRAM_ID. Signed-off-by: Markus Armbruster --- qapi/ebpf.json | 1 - ebpf/ebpf_rss.c | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/qapi/ebpf.json b/qapi/ebpf.json index 42df548777..db19ae850f 100644 --- a/qapi/ebpf.json +++ b/qapi/ebpf.json @@ -42,7 +42,6 @@ # Since: 9.0 ## { 'enum': 'EbpfProgramID', - 'prefix': 'EBPF_PROGRAMID', # TODO drop 'if': 'CONFIG_EBPF', 'data': [ { 'name': 'rss' } ] } =20 diff --git a/ebpf/ebpf_rss.c b/ebpf/ebpf_rss.c index 87f0714910..dcaa80f380 100644 --- a/ebpf/ebpf_rss.c +++ b/ebpf/ebpf_rss.c @@ -271,4 +271,4 @@ void ebpf_rss_unload(struct EBPFRSSContext *ctx) ctx->map_indirections_table =3D -1; } =20 -ebpf_binary_init(EBPF_PROGRAMID_RSS, rss_bpf__elf_bytes) +ebpf_binary_init(EBPF_PROGRAM_ID_RSS, rss_bpf__elf_bytes) --=20 2.46.0 From nobody Sun Nov 24 08:32:09 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=1725449361; cv=none; d=zohomail.com; s=zohoarc; b=nvP7pEc0mkqDcJzjpZprIrZnhQPtsmrQOmTi85hJ2weYis3ZK+5vfaywZTiPdWQ/UIeMHoj/kDGKUPJBLGijUSOmF2XBGg06VCBxc9+nxfnHAqh0TctyLY0hJW8OIdLaXOK5z+NsE3crf1DwtjZ2HFkc7WOQJyrVOVKvS77N8Ro= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1725449361; 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=cgyAtkjmkamaAiZWsKefrgdh6QwwNTx6VRHP9div+qI=; b=VcKECAs1FXX0luRMPAEZ9EW6MJvwU89e8dv1QHXcKBsK9Ow2+JoE4Vk9X8VuGnIivzoiTNnyGmRFHOwHqawuB1pTPm7Amfo8qfy1jc7IYNgP+LZEwfELd6xiWMyCUSOjjcTYcUXZLnQcAf4kGNLz8KMsMR+piVvzju6ysDDmot0= 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 172544936161177.48141209880077; Wed, 4 Sep 2024 04:29:21 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1slo9H-00012p-8t; Wed, 04 Sep 2024 07:26:07 -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 1slo9F-0000sq-I5 for qemu-devel@nongnu.org; Wed, 04 Sep 2024 07:26:05 -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 1slo9B-0004kK-VQ for qemu-devel@nongnu.org; Wed, 04 Sep 2024 07:26:05 -0400 Received: from mx-prod-mc-03.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-92-Ma6bQ6FpOSGSk9Gn1qDidg-1; Wed, 04 Sep 2024 07:18:53 -0400 Received: from mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.40]) (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-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id EE7111955D71; Wed, 4 Sep 2024 11:18:44 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.192.112]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id B28EC195605A; Wed, 4 Sep 2024 11:18:43 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id AB26A21E68B2; 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=1725449160; 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=cgyAtkjmkamaAiZWsKefrgdh6QwwNTx6VRHP9div+qI=; b=VqAhNw88thl2DXDWgan3N7IvmTMCfki3g/k7jVMm5M9dCuf4wcNKHmW3MSqUU7s/X414Xe vDBCYOy2ih7B1ShOgErpE+jYxTqPc2KHlDJYcOmpBI93aT5hnwFjTErYJBymX/Vatgf/a0 QZQ5p2hZHcQDDYmQbT/3ydz3ZxSUwW4= X-MC-Unique: Ma6bQ6FpOSGSk9Gn1qDidg-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 07/19] qapi/machine: Drop temporary 'prefix' Date: Wed, 4 Sep 2024 13:18:24 +0200 Message-ID: <20240904111836.3273842-8-armbru@redhat.com> In-Reply-To: <20240904111836.3273842-1-armbru@redhat.com> References: <20240904111836.3273842-1-armbru@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.40 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: 1725449362697116600 Content-Type: text/plain; charset="utf-8" Recent commit "qapi: Smarter camel_to_upper() to reduce need for 'prefix'" added a temporary 'prefix' to delay changing the generated code. Revert it. This improves HmatLBDataType's generated enumeration constant prefix from HMATLB_DATA_TYPE to HMAT_LB_DATA_TYPE, and HmatLBMemoryHierarchy's from HMATLB_MEMORY_HIERARCHY to HMAT_LB_MEMORY_HIERARCHY. Signed-off-by: Markus Armbruster Reviewed-by: Zhao Liu --- qapi/machine.json | 2 -- hw/core/numa.c | 4 ++-- hw/pci-bridge/cxl_upstream.c | 4 ++-- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/qapi/machine.json b/qapi/machine.json index 552d1c20e9..d4317435e7 100644 --- a/qapi/machine.json +++ b/qapi/machine.json @@ -686,7 +686,6 @@ # Since: 5.0 ## { 'enum': 'HmatLBMemoryHierarchy', - 'prefix': 'HMATLB_MEMORY_HIERARCHY', # TODO drop 'data': [ 'memory', 'first-level', 'second-level', 'third-level' ] } =20 ## @@ -713,7 +712,6 @@ # Since: 5.0 ## { 'enum': 'HmatLBDataType', - 'prefix': 'HMATLB_DATA_TYPE', # TODO drop 'data': [ 'access-latency', 'read-latency', 'write-latency', 'access-bandwidth', 'read-bandwidth', 'write-bandwidth' ] } =20 diff --git a/hw/core/numa.c b/hw/core/numa.c index f8ce332cfe..fb81c1ed51 100644 --- a/hw/core/numa.c +++ b/hw/core/numa.c @@ -249,7 +249,7 @@ void parse_numa_hmat_lb(NumaState *numa_state, NumaHmat= LBOptions *node, lb_data.initiator =3D node->initiator; lb_data.target =3D node->target; =20 - if (node->data_type <=3D HMATLB_DATA_TYPE_WRITE_LATENCY) { + if (node->data_type <=3D HMAT_LB_DATA_TYPE_WRITE_LATENCY) { /* Input latency data */ =20 if (!node->has_latency) { @@ -313,7 +313,7 @@ void parse_numa_hmat_lb(NumaState *numa_state, NumaHmat= LBOptions *node, numa_info[node->target].lb_info_provided |=3D BIT(0); } lb_data.data =3D node->latency; - } else if (node->data_type >=3D HMATLB_DATA_TYPE_ACCESS_BANDWIDTH) { + } else if (node->data_type >=3D HMAT_LB_DATA_TYPE_ACCESS_BANDWIDTH) { /* Input bandwidth data */ if (!node->has_bandwidth) { error_setg(errp, "Missing 'bandwidth' option"); diff --git a/hw/pci-bridge/cxl_upstream.c b/hw/pci-bridge/cxl_upstream.c index e51221a5f3..f3e46f0651 100644 --- a/hw/pci-bridge/cxl_upstream.c +++ b/hw/pci-bridge/cxl_upstream.c @@ -234,7 +234,7 @@ static int build_cdat_table(CDATSubHeader ***cdat_table= , void *priv) .type =3D CDAT_TYPE_SSLBIS, .length =3D sslbis_size, }, - .data_type =3D HMATLB_DATA_TYPE_ACCESS_LATENCY, + .data_type =3D HMAT_LB_DATA_TYPE_ACCESS_LATENCY, .entry_base_unit =3D 10000, }, }; @@ -254,7 +254,7 @@ static int build_cdat_table(CDATSubHeader ***cdat_table= , void *priv) .type =3D CDAT_TYPE_SSLBIS, .length =3D sslbis_size, }, - .data_type =3D HMATLB_DATA_TYPE_ACCESS_BANDWIDTH, + .data_type =3D HMAT_LB_DATA_TYPE_ACCESS_BANDWIDTH, .entry_base_unit =3D 1024, }, }; --=20 2.46.0 From nobody Sun Nov 24 08:32:09 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=1725449191; cv=none; d=zohomail.com; s=zohoarc; b=SEr8SeDzj/VctqbUAFgwd7f1te0yEhyBfHk0hckpmGN2cKxVdXibkWBI7Vyr6SzG3n+S7/4znn0qviU2qW2WinNDloXwr8fmeYHBvHvTyuEd0PE7tv2ApO6uqydTcAcAbGR4QmHskszH6jmEqP+7wXKD9HJf7Z9kuTB/5jNcbms= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1725449191; 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=mx0VBf7PIZMmG9UblVDStv63N2fkZrKVnw2Bb2K1RLo=; b=kc5s299GDgOvtFY1wUJ5HixyIYltOzfbf63TB1lVq+W5O5+koCUTiOayy9pigERnZSIHqf/26p6XcUtBTg29wd2zixRopR29o0RWmfuv5KruwrE6ldupr5/4K5+4ASfH9y0TQxN0vwUBmpKX6hczny/vG4Xp1vwBxozigcNzzIs= 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 1725449191725418.55569918845447; Wed, 4 Sep 2024 04:26:31 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1slo8Q-00056T-36; Wed, 04 Sep 2024 07:25:14 -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 1slo8O-00050h-5n for qemu-devel@nongnu.org; Wed, 04 Sep 2024 07:25:12 -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 1slo8K-0004Ot-6A for qemu-devel@nongnu.org; Wed, 04 Sep 2024 07:25:11 -0400 Received: from mx-prod-mc-03.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-330-f_RRaaRgPMeBbeFZ_Pxv9g-1; Wed, 04 Sep 2024 07:18:49 -0400 Received: from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.15]) (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-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id DF53D1955DA6; Wed, 4 Sep 2024 11:18:45 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.192.112]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id C8C501956086; Wed, 4 Sep 2024 11:18:43 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id AF9F021E68BD; 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=1725449106; 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=mx0VBf7PIZMmG9UblVDStv63N2fkZrKVnw2Bb2K1RLo=; b=ctHXnx3aJ1jFbObUQp4G/Er3AoHRxTnmJcPsv0dNOSWl9ioSWrVzfkTbQUnaVTnboOwGAK rKWIoaMzEJB+LvYuYkfLRmDDWrHGVXeaxImIMJEyNjI55m3wCOVSZGsQlXSxA6L+uwq8cQ ZSPrBzwzuS/UrOeyBlZrQUr6OXhJcS4= X-MC-Unique: f_RRaaRgPMeBbeFZ_Pxv9g-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 08/19] qapi/ui: Drop temporary 'prefix' Date: Wed, 4 Sep 2024 13:18:25 +0200 Message-ID: <20240904111836.3273842-9-armbru@redhat.com> In-Reply-To: <20240904111836.3273842-1-armbru@redhat.com> References: <20240904111836.3273842-1-armbru@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.15 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: 1725449191899116600 Content-Type: text/plain; charset="utf-8" Recent commit "qapi: Smarter camel_to_upper() to reduce need for 'prefix'" added a temporary 'prefix' to delay changing the generated code. Revert it. This improves DisplayGLMode's generated enumeration constant prefix from DISPLAYGL_MODE to DISPLAY_GL_MODE. Signed-off-by: Markus Armbruster --- qapi/ui.json | 1 - system/vl.c | 2 +- ui/dbus.c | 8 ++++---- ui/egl-context.c | 2 +- ui/egl-headless.c | 2 +- ui/egl-helpers.c | 12 ++++++------ ui/gtk.c | 4 ++-- ui/sdl2-gl.c | 8 ++++---- ui/sdl2.c | 2 +- ui/spice-core.c | 2 +- 10 files changed, 21 insertions(+), 22 deletions(-) diff --git a/qapi/ui.json b/qapi/ui.json index f61a2b6b65..460a26b981 100644 --- a/qapi/ui.json +++ b/qapi/ui.json @@ -1397,7 +1397,6 @@ # Since: 3.0 ## { 'enum' : 'DisplayGLMode', - 'prefix' : 'DISPLAYGL_MODE', # TODO drop 'data' : [ 'off', 'on', 'core', 'es' ] } =20 ## diff --git a/system/vl.c b/system/vl.c index 01b8b8e77a..fe547ca47c 100644 --- a/system/vl.c +++ b/system/vl.c @@ -1971,7 +1971,7 @@ static void qemu_create_early_backends(void) =20 qemu_console_early_init(); =20 - if (dpy.has_gl && dpy.gl !=3D DISPLAYGL_MODE_OFF && display_opengl =3D= =3D 0) { + if (dpy.has_gl && dpy.gl !=3D DISPLAY_GL_MODE_OFF && display_opengl = =3D=3D 0) { #if defined(CONFIG_OPENGL) error_report("OpenGL is not supported by display backend '%s'", DisplayType_str(dpy.type)); diff --git a/ui/dbus.c b/ui/dbus.c index e08b5de064..7ecd39e784 100644 --- a/ui/dbus.c +++ b/ui/dbus.c @@ -176,7 +176,7 @@ dbus_display_add_console(DBusDisplay *dd, int idx, Erro= r **errp) assert(con); =20 if (qemu_console_is_graphic(con) && - dd->gl_mode !=3D DISPLAYGL_MODE_OFF) { + dd->gl_mode !=3D DISPLAY_GL_MODE_OFF) { qemu_console_set_display_gl_ctx(con, &dd->glctx); } =20 @@ -466,9 +466,9 @@ static const TypeInfo dbus_vc_type_info =3D { static void early_dbus_init(DisplayOptions *opts) { - DisplayGLMode mode =3D opts->has_gl ? opts->gl : DISPLAYGL_MODE_OFF; + DisplayGLMode mode =3D opts->has_gl ? opts->gl : DISPLAY_GL_MODE_OFF; =20 - if (mode !=3D DISPLAYGL_MODE_OFF) { + if (mode !=3D DISPLAY_GL_MODE_OFF) { #ifdef CONFIG_OPENGL egl_init(opts->u.dbus.rendernode, mode, &error_fatal); #else @@ -482,7 +482,7 @@ early_dbus_init(DisplayOptions *opts) static void dbus_init(DisplayState *ds, DisplayOptions *opts) { - DisplayGLMode mode =3D opts->has_gl ? opts->gl : DISPLAYGL_MODE_OFF; + DisplayGLMode mode =3D opts->has_gl ? opts->gl : DISPLAY_GL_MODE_OFF; =20 if (opts->u.dbus.addr && opts->u.dbus.p2p) { error_report("dbus: can't accept both addr=3DX and p2p=3Dyes optio= ns"); diff --git a/ui/egl-context.c b/ui/egl-context.c index 9e0df466f3..aed3e3ba1f 100644 --- a/ui/egl-context.c +++ b/ui/egl-context.c @@ -17,7 +17,7 @@ QEMUGLContext qemu_egl_create_context(DisplayGLCtx *dgc, EGL_CONTEXT_MINOR_VERSION_KHR, params->minor_ver, EGL_NONE }; - bool gles =3D (qemu_egl_mode =3D=3D DISPLAYGL_MODE_ES); + bool gles =3D (qemu_egl_mode =3D=3D DISPLAY_GL_MODE_ES); =20 ctx =3D eglCreateContext(qemu_egl_display, qemu_egl_config, eglGetCurrentContext(), diff --git a/ui/egl-headless.c b/ui/egl-headless.c index 6187249c73..1f6b845500 100644 --- a/ui/egl-headless.c +++ b/ui/egl-headless.c @@ -207,7 +207,7 @@ static const DisplayGLCtxOps eglctx_ops =3D { =20 static void early_egl_headless_init(DisplayOptions *opts) { - DisplayGLMode mode =3D DISPLAYGL_MODE_ON; + DisplayGLMode mode =3D DISPLAY_GL_MODE_ON; =20 if (opts->has_gl) { mode =3D opts->gl; diff --git a/ui/egl-helpers.c b/ui/egl-helpers.c index 99b2ebbe23..81a57fa975 100644 --- a/ui/egl-helpers.c +++ b/ui/egl-helpers.c @@ -503,7 +503,7 @@ static int qemu_egl_init_dpy(EGLNativeDisplayType dpy, EGLint major, minor; EGLBoolean b; EGLint n; - bool gles =3D (mode =3D=3D DISPLAYGL_MODE_ES); + bool gles =3D (mode =3D=3D DISPLAY_GL_MODE_ES); =20 qemu_egl_display =3D qemu_egl_get_display(dpy, platform); if (qemu_egl_display =3D=3D EGL_NO_DISPLAY) { @@ -533,7 +533,7 @@ static int qemu_egl_init_dpy(EGLNativeDisplayType dpy, return -1; } =20 - qemu_egl_mode =3D gles ? DISPLAYGL_MODE_ES : DISPLAYGL_MODE_CORE; + qemu_egl_mode =3D gles ? DISPLAY_GL_MODE_ES : DISPLAY_GL_MODE_CORE; return 0; } =20 @@ -564,8 +564,8 @@ int qemu_egl_init_dpy_mesa(EGLNativeDisplayType dpy, Di= splayGLMode mode) int qemu_egl_init_dpy_win32(EGLNativeDisplayType dpy, DisplayGLMode mode) { /* prefer GL ES, as that's what ANGLE supports */ - if (mode =3D=3D DISPLAYGL_MODE_ON) { - mode =3D DISPLAYGL_MODE_ES; + if (mode =3D=3D DISPLAY_GL_MODE_ON) { + mode =3D DISPLAY_GL_MODE_ES; } =20 if (qemu_egl_init_dpy(dpy, 0, mode) < 0) { @@ -618,7 +618,7 @@ EGLContext qemu_egl_init_ctx(void) EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE }; - bool gles =3D (qemu_egl_mode =3D=3D DISPLAYGL_MODE_ES); + bool gles =3D (qemu_egl_mode =3D=3D DISPLAY_GL_MODE_ES); EGLContext ectx; EGLBoolean b; =20 @@ -642,7 +642,7 @@ bool egl_init(const char *rendernode, DisplayGLMode mod= e, Error **errp) { ERRP_GUARD(); =20 - if (mode =3D=3D DISPLAYGL_MODE_OFF) { + if (mode =3D=3D DISPLAY_GL_MODE_OFF) { error_setg(errp, "egl: turning off GL doesn't make sense"); return false; } diff --git a/ui/gtk.c b/ui/gtk.c index 8e14c2ac81..bf9d3dd679 100644 --- a/ui/gtk.c +++ b/ui/gtk.c @@ -2514,7 +2514,7 @@ static void early_gtk_display_init(DisplayOptions *op= ts) } =20 assert(opts->type =3D=3D DISPLAY_TYPE_GTK); - if (opts->has_gl && opts->gl !=3D DISPLAYGL_MODE_OFF) { + if (opts->has_gl && opts->gl !=3D DISPLAY_GL_MODE_OFF) { #if defined(CONFIG_OPENGL) #if defined(GDK_WINDOWING_WAYLAND) if (GDK_IS_WAYLAND_DISPLAY(gdk_display_get_default())) { @@ -2530,7 +2530,7 @@ static void early_gtk_display_init(DisplayOptions *op= ts) #endif { #ifdef CONFIG_X11 - DisplayGLMode mode =3D opts->has_gl ? opts->gl : DISPLAYGL_MOD= E_ON; + DisplayGLMode mode =3D opts->has_gl ? opts->gl : DISPLAY_GL_MO= DE_ON; gtk_egl_init(mode); #endif } diff --git a/ui/sdl2-gl.c b/ui/sdl2-gl.c index 91b7ee2419..e01d9ab0c7 100644 --- a/ui/sdl2-gl.c +++ b/ui/sdl2-gl.c @@ -147,11 +147,11 @@ QEMUGLContext sdl2_gl_create_context(DisplayGLCtx *dg= c, SDL_GL_MakeCurrent(scon->real_window, scon->winctx); =20 SDL_GL_SetAttribute(SDL_GL_SHARE_WITH_CURRENT_CONTEXT, 1); - if (scon->opts->gl =3D=3D DISPLAYGL_MODE_ON || - scon->opts->gl =3D=3D DISPLAYGL_MODE_CORE) { + if (scon->opts->gl =3D=3D DISPLAY_GL_MODE_ON || + scon->opts->gl =3D=3D DISPLAY_GL_MODE_CORE) { SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE); - } else if (scon->opts->gl =3D=3D DISPLAYGL_MODE_ES) { + } else if (scon->opts->gl =3D=3D DISPLAY_GL_MODE_ES) { SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_ES); } @@ -163,7 +163,7 @@ QEMUGLContext sdl2_gl_create_context(DisplayGLCtx *dgc, /* If SDL fail to create a GL context and we use the "on" flag, * then try to fallback to GLES. */ - if (!ctx && scon->opts->gl =3D=3D DISPLAYGL_MODE_ON) { + if (!ctx && scon->opts->gl =3D=3D DISPLAY_GL_MODE_ON) { SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_ES); ctx =3D SDL_GL_CreateContext(scon->real_window); diff --git a/ui/sdl2.c b/ui/sdl2.c index 98ed974371..251ce97796 100644 --- a/ui/sdl2.c +++ b/ui/sdl2.c @@ -107,7 +107,7 @@ void sdl2_window_create(struct sdl2_console *scon) if (scon->opengl) { const char *driver =3D "opengl"; =20 - if (scon->opts->gl =3D=3D DISPLAYGL_MODE_ES) { + if (scon->opts->gl =3D=3D DISPLAY_GL_MODE_ES) { driver =3D "opengles2"; } =20 diff --git a/ui/spice-core.c b/ui/spice-core.c index 15be640286..bd9dbe03f1 100644 --- a/ui/spice-core.c +++ b/ui/spice-core.c @@ -840,7 +840,7 @@ static void qemu_spice_init(void) "incompatible with -spice port/tls-port"); exit(1); } - egl_init(qemu_opt_get(opts, "rendernode"), DISPLAYGL_MODE_ON, &err= or_fatal); + egl_init(qemu_opt_get(opts, "rendernode"), DISPLAY_GL_MODE_ON, &er= ror_fatal); spice_opengl =3D 1; } #endif --=20 2.46.0 From nobody Sun Nov 24 08:32:09 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=IokBXGWKAO7h9FGqWBmMaC2j/gGzVWIcMKuxaJKMooCuNUQ4zzREUCdQX/ONQ0DTHH11h9X3hE13/2Fm1aRN8zeYqIefpYb3IkBrNpYvG4L9r7yFsaKMIxLqWce4muVS3TIhBvEehWoT8ZtuB3wzJdESGo7BgMPybGhAqM4Olbw= 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=XgpYkJsaI9m1H5zaH4zbGBX7PFklNC5stqAFMp25Csk=; b=VI6bNzAJ6l91rBzaO1u5OkBXUoYM3ftYVhlT0+xKr1pz41TUsB8WuMLPYCgQKM8g2YoCSPBlWkA76JGz2Xkz8q32mrbt/hUtWeo4EUvhYniHWI8M3oGgQbd0ofJPDQ6Ao/0hMxL5fyZMCXMwpOtR1uDUop5ogUYBmlX2UXOvcX8= 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 1725449210069925.95706946824; 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 1slo9T-0002bu-NS; Wed, 04 Sep 2024 07:26:24 -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 1slo9K-0001Kq-1M for qemu-devel@nongnu.org; Wed, 04 Sep 2024 07:26:11 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1slo9C-0004ku-V0 for qemu-devel@nongnu.org; Wed, 04 Sep 2024 07:26:09 -0400 Received: from mx-prod-mc-03.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-526-63Bd3otfNrOJFq-UnnzLfw-1; Wed, 04 Sep 2024 07:18:49 -0400 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (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-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 42F9D1955D57; Wed, 4 Sep 2024 11:18:45 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.192.112]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 27DC419560AE; Wed, 4 Sep 2024 11:18:44 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id B4BE621E681F; 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=1725449161; 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=XgpYkJsaI9m1H5zaH4zbGBX7PFklNC5stqAFMp25Csk=; b=OId3LlgybunkkZyO4e5UGMVh915YkudF0tVX2z1GqZYlymmlBUZAN1efKdC/KeaNwWl2w3 AQILW07/P4FTFOg2tt14tZBoXfP/x0nGX1bem0W01j6d8p7TmUj85F0YtHRYl0zeCcOXIg xLAJ5uIx1j4HU7nq+gZwhOKbYE9P+/w= X-MC-Unique: 63Bd3otfNrOJFq-UnnzLfw-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 09/19] qapi/machine: Rename CpuS390* to S390Cpu*, and drop 'prefix' Date: Wed, 4 Sep 2024 13:18:26 +0200 Message-ID: <20240904111836.3273842-10-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.0 on 10.30.177.12 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.129.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_H3=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: 1725449212099116600 QAPI's 'prefix' feature can make the connection between enumeration type and its constants less than obvious. It's best used with restraint. CpuS390Entitlement has a 'prefix' to change the generated enumeration constants' prefix from CPU_S390_ENTITLEMENT to S390_CPU_ENTITLEMENT. Rename the type to S390CpuEntitlement, so that 'prefix' is not needed. Likewise change CpuS390Polarization to S390CpuPolarization, and CpuS390State to S390CpuState. Signed-off-by: Markus Armbruster Reviewed-by: Daniel P. Berrang=C3=A9 Reviewed-by: Zhao Liu Acked-by: Thomas Huth --- qapi/machine-common.json | 5 ++--- qapi/machine-target.json | 11 +++++------ qapi/machine.json | 9 ++++----- qapi/pragma.json | 6 +++--- include/hw/qdev-properties-system.h | 2 +- include/hw/s390x/cpu-topology.h | 2 +- target/s390x/cpu.h | 2 +- hw/core/qdev-properties-system.c | 6 +++--- hw/s390x/cpu-topology.c | 6 +++--- 9 files changed, 23 insertions(+), 26 deletions(-) diff --git a/qapi/machine-common.json b/qapi/machine-common.json index fa6bd71d12..b64e4895cf 100644 --- a/qapi/machine-common.json +++ b/qapi/machine-common.json @@ -9,13 +9,12 @@ ## =20 ## -# @CpuS390Entitlement: +# @S390CpuEntitlement: # # An enumeration of CPU entitlements that can be assumed by a virtual # S390 CPU # # Since: 8.2 ## -{ 'enum': 'CpuS390Entitlement', - 'prefix': 'S390_CPU_ENTITLEMENT', +{ 'enum': 'S390CpuEntitlement', 'data': [ 'auto', 'low', 'medium', 'high' ] } diff --git a/qapi/machine-target.json b/qapi/machine-target.json index 1a394c08f5..541f93eeb7 100644 --- a/qapi/machine-target.json +++ b/qapi/machine-target.json @@ -405,15 +405,14 @@ 'TARGET_RISCV' ] } } =20 ## -# @CpuS390Polarization: +# @S390CpuPolarization: # # An enumeration of CPU polarization that can be assumed by a virtual # S390 CPU # # Since: 8.2 ## -{ 'enum': 'CpuS390Polarization', - 'prefix': 'S390_CPU_POLARIZATION', +{ 'enum': 'S390CpuPolarization', 'data': [ 'horizontal', 'vertical' ], 'if': 'TARGET_S390X' } @@ -450,7 +449,7 @@ '*socket-id': 'uint16', '*book-id': 'uint16', '*drawer-id': 'uint16', - '*entitlement': 'CpuS390Entitlement', + '*entitlement': 'S390CpuEntitlement', '*dedicated': 'bool' }, 'features': [ 'unstable' ], @@ -488,7 +487,7 @@ # "timestamp": { "seconds": 1401385907, "microseconds": 422329 } } ## { 'event': 'CPU_POLARIZATION_CHANGE', - 'data': { 'polarization': 'CpuS390Polarization' }, + 'data': { 'polarization': 'S390CpuPolarization' }, 'features': [ 'unstable' ], 'if': { 'all': [ 'TARGET_S390X', 'CONFIG_KVM' ] } } @@ -503,7 +502,7 @@ # Since: 8.2 ## { 'struct': 'CpuPolarizationInfo', - 'data': { 'polarization': 'CpuS390Polarization' }, + 'data': { 'polarization': 'S390CpuPolarization' }, 'if': { 'all': [ 'TARGET_S390X', 'CONFIG_KVM' ] } } =20 diff --git a/qapi/machine.json b/qapi/machine.json index d4317435e7..63a5eb0070 100644 --- a/qapi/machine.json +++ b/qapi/machine.json @@ -41,15 +41,14 @@ 'x86_64', 'xtensa', 'xtensaeb' ] } =20 ## -# @CpuS390State: +# @S390CpuState: # # An enumeration of cpu states that can be assumed by a virtual S390 # CPU # # Since: 2.12 ## -{ 'enum': 'CpuS390State', - 'prefix': 'S390_CPU_STATE', +{ 'enum': 'S390CpuState', 'data': [ 'uninitialized', 'stopped', 'check-stop', 'operating', 'load' = ] } =20 ## @@ -66,9 +65,9 @@ # Since: 2.12 ## { 'struct': 'CpuInfoS390', - 'data': { 'cpu-state': 'CpuS390State', + 'data': { 'cpu-state': 'S390CpuState', '*dedicated': 'bool', - '*entitlement': 'CpuS390Entitlement' } } + '*entitlement': 'S390CpuEntitlement' } } =20 ## # @CpuInfoFast: diff --git a/qapi/pragma.json b/qapi/pragma.json index 59fbe74b8c..fad3a31628 100644 --- a/qapi/pragma.json +++ b/qapi/pragma.json @@ -47,9 +47,6 @@ 'BlockdevSnapshotWrapper', 'BlockdevVmdkAdapterType', 'ChardevBackendKind', - 'CpuS390Entitlement', - 'CpuS390Polarization', - 'CpuS390State', 'CxlCorErrorType', 'DisplayProtocol', 'DriveBackupWrapper', @@ -74,6 +71,9 @@ 'QKeyCode', 'RbdAuthMode', 'RbdImageEncryptionFormat', + 'S390CpuEntitlement', + 'S390CpuPolarization', + 'S390CpuState', 'String', 'StringWrapper', 'SysEmuTarget', diff --git a/include/hw/qdev-properties-system.h b/include/hw/qdev-properti= es-system.h index 438f65389f..cdcc63056e 100644 --- a/include/hw/qdev-properties-system.h +++ b/include/hw/qdev-properties-system.h @@ -88,7 +88,7 @@ extern const PropertyInfo qdev_prop_iothread_vq_mapping_l= ist; =20 #define DEFINE_PROP_CPUS390ENTITLEMENT(_n, _s, _f, _d) \ DEFINE_PROP_SIGNED(_n, _s, _f, _d, qdev_prop_cpus390entitlement, \ - CpuS390Entitlement) + S390CpuEntitlement) =20 #define DEFINE_PROP_IOTHREAD_VQ_MAPPING_LIST(_name, _state, _field) \ DEFINE_PROP(_name, _state, _field, qdev_prop_iothread_vq_mapping_list,= \ diff --git a/include/hw/s390x/cpu-topology.h b/include/hw/s390x/cpu-topolog= y.h index c064f427e9..a11b1baa77 100644 --- a/include/hw/s390x/cpu-topology.h +++ b/include/hw/s390x/cpu-topology.h @@ -37,7 +37,7 @@ typedef struct S390TopologyEntry { =20 typedef struct S390Topology { uint8_t *cores_per_socket; - CpuS390Polarization polarization; + S390CpuPolarization polarization; } S390Topology; =20 typedef QTAILQ_HEAD(, S390TopologyEntry) S390TopologyList; diff --git a/target/s390x/cpu.h b/target/s390x/cpu.h index d6b75ad0e0..6cbd77dfdf 100644 --- a/target/s390x/cpu.h +++ b/target/s390x/cpu.h @@ -133,7 +133,7 @@ typedef struct CPUArchState { int32_t book_id; int32_t drawer_id; bool dedicated; - CpuS390Entitlement entitlement; /* Used only for vertical polarization= */ + S390CpuEntitlement entitlement; /* Used only for vertical polarization= */ uint64_t cpuid; #endif =20 diff --git a/hw/core/qdev-properties-system.c b/hw/core/qdev-properties-sys= tem.c index f13350b4fb..f2db20417a 100644 --- a/hw/core/qdev-properties-system.c +++ b/hw/core/qdev-properties-system.c @@ -1188,12 +1188,12 @@ const PropertyInfo qdev_prop_uuid =3D { =20 /* --- s390 cpu entitlement policy --- */ =20 -QEMU_BUILD_BUG_ON(sizeof(CpuS390Entitlement) !=3D sizeof(int)); +QEMU_BUILD_BUG_ON(sizeof(S390CpuEntitlement) !=3D sizeof(int)); =20 const PropertyInfo qdev_prop_cpus390entitlement =3D { - .name =3D "CpuS390Entitlement", + .name =3D "S390CpuEntitlement", .description =3D "low/medium (default)/high", - .enum_table =3D &CpuS390Entitlement_lookup, + .enum_table =3D &S390CpuEntitlement_lookup, .get =3D qdev_propinfo_get_enum, .set =3D qdev_propinfo_set_enum, .set_default_value =3D qdev_propinfo_set_default_value_enum, diff --git a/hw/s390x/cpu-topology.c b/hw/s390x/cpu-topology.c index f16bdf65fa..7d4e1f5472 100644 --- a/hw/s390x/cpu-topology.c +++ b/hw/s390x/cpu-topology.c @@ -105,7 +105,7 @@ static void s390_topology_init(MachineState *ms) */ void s390_handle_ptf(S390CPU *cpu, uint8_t r1, uintptr_t ra) { - CpuS390Polarization polarization; + S390CpuPolarization polarization; CPUS390XState *env =3D &cpu->env; uint64_t reg =3D env->regs[r1]; int fc =3D reg & S390_TOPO_FC_MASK; @@ -357,7 +357,7 @@ static void s390_change_topology(uint16_t core_id, bool has_book_id, uint16_t book_id, bool has_drawer_id, uint16_t drawer_id, bool has_entitlement, - CpuS390Entitlement entitlement, + S390CpuEntitlement entitlement, bool has_dedicated, bool dedicated, Error **errp) { @@ -446,7 +446,7 @@ void qmp_set_cpu_topology(uint16_t core, bool has_socket, uint16_t socket, bool has_book, uint16_t book, bool has_drawer, uint16_t drawer, - bool has_entitlement, CpuS390Entitlement entitle= ment, + bool has_entitlement, S390CpuEntitlement entitle= ment, bool has_dedicated, bool dedicated, Error **errp) { --=20 2.46.0 From nobody Sun Nov 24 08:32:09 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=1725449414; cv=none; d=zohomail.com; s=zohoarc; b=jos8fcgQ1Gbpo80injh3/AdybRdF03yJLVXtsd2XKL/pxMwNu9LdjIrA8hQhgBCzyhqYChCLdVtiw6iGzyUIEd6PXkaTnMqZWo0EYwvcN+Z4dFY00nQt+qw7VAH/JKJMkcP5UhlkcoU6uzz49zlDWwXVWS6Uq3hKO84sNkBd2qk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1725449414; 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=exP//E9i5wK2gHhGXlaYilKR5VvVnUFMPHblLY32rno=; b=fk4v3fknwC6I49sgodpAdqxNjI7V/pe3bQoptqvWBcsGxCDRA4lt8rK4tgTz6fe63BO33Lid/Lqv0uGPLuS0uYMAUkJOqCJl07oBTE+afMxSLWr9lOW3M8ipjccetakukFdNlHXTJ5pfSnLp2O34+082FVtpblwjH6qpH2UiNqQ= 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 1725449414194126.6415617808824; Wed, 4 Sep 2024 04:30:14 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1slo9Q-00026j-9A; Wed, 04 Sep 2024 07:26:16 -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 1slo9M-0001ci-W1 for qemu-devel@nongnu.org; Wed, 04 Sep 2024 07:26:13 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1slo9D-0004kq-1K for qemu-devel@nongnu.org; Wed, 04 Sep 2024 07:26:12 -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-523-PrQIcrxeMyCg09Ng8bdaoQ-1; Wed, 04 Sep 2024 07:18:49 -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 066021955D59; Wed, 4 Sep 2024 11:18:45 +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 1688730001AB; Wed, 4 Sep 2024 11:18:44 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id B976521E6828; 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=1725449161; 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=exP//E9i5wK2gHhGXlaYilKR5VvVnUFMPHblLY32rno=; b=dxOe9OO3OZ8YuHG7eBmcy78sMwsnSx1ShwGGG/+AFUILBmchgHDj789EoO/X1wbECyeA28 tBfCySVSFmCRHMGnwoW+BSlh8AbhU3L7yHVFvl6OOdRAxTdfL3wxTKX6z0tcEaoWEDz3BI OT850gbiQ626iwN3WLXhUbu8Fb/qDQQ= X-MC-Unique: PrQIcrxeMyCg09Ng8bdaoQ-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 10/19] qapi/crypto: Drop unwanted 'prefix' Date: Wed, 4 Sep 2024 13:18:27 +0200 Message-ID: <20240904111836.3273842-11-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.129.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_H3=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: 1725449415178116600 QAPI's 'prefix' feature can make the connection between enumeration type and its constants less than obvious. It's best used with restraint. QCryptoAkCipherKeyType has a 'prefix' that overrides the generated enumeration constants' prefix to QCRYPTO_AKCIPHER_KEY_TYPE. Drop it. The prefix becomes QCRYPTO_AK_CIPHER_KEY_TYPE. Signed-off-by: Markus Armbruster Acked-by: Daniel P. Berrang=C3=A9 --- qapi/crypto.json | 1 - backends/cryptodev-builtin.c | 4 ++-- backends/cryptodev-lkcf.c | 6 +++--- tests/bench/benchmark-crypto-akcipher.c | 2 +- tests/unit/test-crypto-akcipher.c | 28 ++++++++++++------------- crypto/akcipher-gcrypt.c.inc | 8 +++---- crypto/akcipher-nettle.c.inc | 8 +++---- crypto/rsakey-builtin.c.inc | 4 ++-- crypto/rsakey-nettle.c.inc | 4 ++-- 9 files changed, 32 insertions(+), 33 deletions(-) diff --git a/qapi/crypto.json b/qapi/crypto.json index fb00c706b2..b5c25e7cd9 100644 --- a/qapi/crypto.json +++ b/qapi/crypto.json @@ -609,7 +609,6 @@ # Since: 7.1 ## { 'enum': 'QCryptoAkCipherKeyType', - 'prefix': 'QCRYPTO_AKCIPHER_KEY_TYPE', 'data': ['public', 'private']} =20 ## diff --git a/backends/cryptodev-builtin.c b/backends/cryptodev-builtin.c index 940104ee55..e95af9bb72 100644 --- a/backends/cryptodev-builtin.c +++ b/backends/cryptodev-builtin.c @@ -334,11 +334,11 @@ static int cryptodev_builtin_create_akcipher_session( =20 switch (sess_info->keytype) { case VIRTIO_CRYPTO_AKCIPHER_KEY_TYPE_PUBLIC: - type =3D QCRYPTO_AKCIPHER_KEY_TYPE_PUBLIC; + type =3D QCRYPTO_AK_CIPHER_KEY_TYPE_PUBLIC; break; =20 case VIRTIO_CRYPTO_AKCIPHER_KEY_TYPE_PRIVATE: - type =3D QCRYPTO_AKCIPHER_KEY_TYPE_PRIVATE; + type =3D QCRYPTO_AK_CIPHER_KEY_TYPE_PRIVATE; break; =20 default: diff --git a/backends/cryptodev-lkcf.c b/backends/cryptodev-lkcf.c index 45aba1ff67..e1ee11a158 100644 --- a/backends/cryptodev-lkcf.c +++ b/backends/cryptodev-lkcf.c @@ -322,7 +322,7 @@ static void cryptodev_lkcf_execute_task(CryptoDevLKCFTa= sk *task) * 2. generally, public key related compution is fast, just compute it= with * thread-pool. */ - if (session->keytype =3D=3D QCRYPTO_AKCIPHER_KEY_TYPE_PRIVATE) { + if (session->keytype =3D=3D QCRYPTO_AK_CIPHER_KEY_TYPE_PRIVATE) { if (qcrypto_akcipher_export_p8info(&session->akcipher_opts, session->key, session->keylen, &p8info, &p8info_len, @@ -534,11 +534,11 @@ static int cryptodev_lkcf_create_asym_session( =20 switch (sess_info->keytype) { case VIRTIO_CRYPTO_AKCIPHER_KEY_TYPE_PUBLIC: - sess->keytype =3D QCRYPTO_AKCIPHER_KEY_TYPE_PUBLIC; + sess->keytype =3D QCRYPTO_AK_CIPHER_KEY_TYPE_PUBLIC; break; =20 case VIRTIO_CRYPTO_AKCIPHER_KEY_TYPE_PRIVATE: - sess->keytype =3D QCRYPTO_AKCIPHER_KEY_TYPE_PRIVATE; + sess->keytype =3D QCRYPTO_AK_CIPHER_KEY_TYPE_PRIVATE; break; =20 default: diff --git a/tests/bench/benchmark-crypto-akcipher.c b/tests/bench/benchmar= k-crypto-akcipher.c index 5e68cb0a1c..bbc29c9b12 100644 --- a/tests/bench/benchmark-crypto-akcipher.c +++ b/tests/bench/benchmark-crypto-akcipher.c @@ -28,7 +28,7 @@ static QCryptoAkCipher *create_rsa_akcipher(const uint8_t= *priv_key, opt.alg =3D QCRYPTO_AKCIPHER_ALG_RSA; opt.u.rsa.padding_alg =3D padding; opt.u.rsa.hash_alg =3D hash; - return qcrypto_akcipher_new(&opt, QCRYPTO_AKCIPHER_KEY_TYPE_PRIVATE, + return qcrypto_akcipher_new(&opt, QCRYPTO_AK_CIPHER_KEY_TYPE_PRIVATE, priv_key, keylen, &error_abort); } =20 diff --git a/tests/unit/test-crypto-akcipher.c b/tests/unit/test-crypto-akc= ipher.c index 4f1f4214dd..59bc6f1e69 100644 --- a/tests/unit/test-crypto-akcipher.c +++ b/tests/unit/test-crypto-akcipher.c @@ -692,7 +692,7 @@ struct QCryptoAkCipherTestData { static QCryptoRSAKeyTestData rsakey_test_data[] =3D { { .path =3D "/crypto/akcipher/rsakey-1024-public", - .key_type =3D QCRYPTO_AKCIPHER_KEY_TYPE_PUBLIC, + .key_type =3D QCRYPTO_AK_CIPHER_KEY_TYPE_PUBLIC, .key =3D rsa1024_public_key, .keylen =3D sizeof(rsa1024_public_key), .is_valid_key =3D true, @@ -700,7 +700,7 @@ static QCryptoRSAKeyTestData rsakey_test_data[] =3D { }, { .path =3D "/crypto/akcipher/rsakey-1024-private", - .key_type =3D QCRYPTO_AKCIPHER_KEY_TYPE_PRIVATE, + .key_type =3D QCRYPTO_AK_CIPHER_KEY_TYPE_PRIVATE, .key =3D rsa1024_private_key, .keylen =3D sizeof(rsa1024_private_key), .is_valid_key =3D true, @@ -708,7 +708,7 @@ static QCryptoRSAKeyTestData rsakey_test_data[] =3D { }, { .path =3D "/crypto/akcipher/rsakey-2048-public", - .key_type =3D QCRYPTO_AKCIPHER_KEY_TYPE_PUBLIC, + .key_type =3D QCRYPTO_AK_CIPHER_KEY_TYPE_PUBLIC, .key =3D rsa2048_public_key, .keylen =3D sizeof(rsa2048_public_key), .is_valid_key =3D true, @@ -716,7 +716,7 @@ static QCryptoRSAKeyTestData rsakey_test_data[] =3D { }, { .path =3D "/crypto/akcipher/rsakey-2048-private", - .key_type =3D QCRYPTO_AKCIPHER_KEY_TYPE_PRIVATE, + .key_type =3D QCRYPTO_AK_CIPHER_KEY_TYPE_PRIVATE, .key =3D rsa2048_private_key, .keylen =3D sizeof(rsa2048_private_key), .is_valid_key =3D true, @@ -724,56 +724,56 @@ static QCryptoRSAKeyTestData rsakey_test_data[] =3D { }, { .path =3D "/crypto/akcipher/rsakey-public-lack-elem", - .key_type =3D QCRYPTO_AKCIPHER_KEY_TYPE_PUBLIC, + .key_type =3D QCRYPTO_AK_CIPHER_KEY_TYPE_PUBLIC, .key =3D rsa_public_key_lack_element, .keylen =3D sizeof(rsa_public_key_lack_element), .is_valid_key =3D false, }, { .path =3D "/crypto/akcipher/rsakey-private-lack-elem", - .key_type =3D QCRYPTO_AKCIPHER_KEY_TYPE_PRIVATE, + .key_type =3D QCRYPTO_AK_CIPHER_KEY_TYPE_PRIVATE, .key =3D rsa_private_key_lack_element, .keylen =3D sizeof(rsa_private_key_lack_element), .is_valid_key =3D false, }, { .path =3D "/crypto/akcipher/rsakey-public-empty-elem", - .key_type =3D QCRYPTO_AKCIPHER_KEY_TYPE_PUBLIC, + .key_type =3D QCRYPTO_AK_CIPHER_KEY_TYPE_PUBLIC, .key =3D rsa_public_key_empty_element, .keylen =3D sizeof(rsa_public_key_empty_element), .is_valid_key =3D false, }, { .path =3D "/crypto/akcipher/rsakey-private-empty-elem", - .key_type =3D QCRYPTO_AKCIPHER_KEY_TYPE_PRIVATE, + .key_type =3D QCRYPTO_AK_CIPHER_KEY_TYPE_PRIVATE, .key =3D rsa_private_key_empty_element, .keylen =3D sizeof(rsa_private_key_empty_element), .is_valid_key =3D false, }, { .path =3D "/crypto/akcipher/rsakey-public-empty-key", - .key_type =3D QCRYPTO_AKCIPHER_KEY_TYPE_PUBLIC, + .key_type =3D QCRYPTO_AK_CIPHER_KEY_TYPE_PUBLIC, .key =3D NULL, .keylen =3D 0, .is_valid_key =3D false, }, { .path =3D "/crypto/akcipher/rsakey-private-empty-key", - .key_type =3D QCRYPTO_AKCIPHER_KEY_TYPE_PRIVATE, + .key_type =3D QCRYPTO_AK_CIPHER_KEY_TYPE_PRIVATE, .key =3D NULL, .keylen =3D 0, .is_valid_key =3D false, }, { .path =3D "/crypto/akcipher/rsakey-public-invalid-length-val", - .key_type =3D QCRYPTO_AKCIPHER_KEY_TYPE_PUBLIC, + .key_type =3D QCRYPTO_AK_CIPHER_KEY_TYPE_PUBLIC, .key =3D rsa_public_key_invalid_length_val, .keylen =3D sizeof(rsa_public_key_invalid_length_val), .is_valid_key =3D false, }, { .path =3D "/crypto/akcipher/rsakey-public-extra-elem", - .key_type =3D QCRYPTO_AKCIPHER_KEY_TYPE_PUBLIC, + .key_type =3D QCRYPTO_AK_CIPHER_KEY_TYPE_PUBLIC, .key =3D rsa_public_key_extra_elem, .keylen =3D sizeof(rsa_public_key_extra_elem), .is_valid_key =3D false, @@ -885,12 +885,12 @@ static void test_akcipher(const void *opaque) return; } pub_key =3D qcrypto_akcipher_new(&data->opt, - QCRYPTO_AKCIPHER_KEY_TYPE_PUBLIC, + QCRYPTO_AK_CIPHER_KEY_TYPE_PUBLIC, data->pub_key, data->pub_key_len, &error_abort); g_assert(pub_key !=3D NULL); priv_key =3D qcrypto_akcipher_new(&data->opt, - QCRYPTO_AKCIPHER_KEY_TYPE_PRIVATE, + QCRYPTO_AK_CIPHER_KEY_TYPE_PRIVATE, data->priv_key, data->priv_key_len, &error_abort); g_assert(priv_key !=3D NULL); diff --git a/crypto/akcipher-gcrypt.c.inc b/crypto/akcipher-gcrypt.c.inc index abb1fb272e..e942d43421 100644 --- a/crypto/akcipher-gcrypt.c.inc +++ b/crypto/akcipher-gcrypt.c.inc @@ -85,7 +85,7 @@ static int qcrypto_gcrypt_parse_rsa_private_key( const uint8_t *key, size_t keylen, Error **errp) { g_autoptr(QCryptoAkCipherRSAKey) rsa_key =3D qcrypto_akcipher_rsakey_p= arse( - QCRYPTO_AKCIPHER_KEY_TYPE_PRIVATE, key, keylen, errp); + QCRYPTO_AK_CIPHER_KEY_TYPE_PRIVATE, key, keylen, errp); gcry_mpi_t n =3D NULL, e =3D NULL, d =3D NULL, p =3D NULL, q =3D NULL,= u =3D NULL; bool compute_mul_inv =3D false; int ret =3D -1; @@ -178,7 +178,7 @@ static int qcrypto_gcrypt_parse_rsa_public_key(QCryptoG= cryptRSA *rsa, { =20 g_autoptr(QCryptoAkCipherRSAKey) rsa_key =3D qcrypto_akcipher_rsakey_p= arse( - QCRYPTO_AKCIPHER_KEY_TYPE_PUBLIC, key, keylen, errp); + QCRYPTO_AK_CIPHER_KEY_TYPE_PUBLIC, key, keylen, errp); gcry_mpi_t n =3D NULL, e =3D NULL; int ret =3D -1; gcry_error_t err; @@ -540,13 +540,13 @@ static QCryptoGcryptRSA *qcrypto_gcrypt_rsa_new( rsa->akcipher.driver =3D &gcrypt_rsa; =20 switch (type) { - case QCRYPTO_AKCIPHER_KEY_TYPE_PRIVATE: + case QCRYPTO_AK_CIPHER_KEY_TYPE_PRIVATE: if (qcrypto_gcrypt_parse_rsa_private_key(rsa, key, keylen, errp) != =3D 0) { goto error; } break; =20 - case QCRYPTO_AKCIPHER_KEY_TYPE_PUBLIC: + case QCRYPTO_AK_CIPHER_KEY_TYPE_PUBLIC: if (qcrypto_gcrypt_parse_rsa_public_key(rsa, key, keylen, errp) != =3D 0) { goto error; } diff --git a/crypto/akcipher-nettle.c.inc b/crypto/akcipher-nettle.c.inc index 02699e6e6d..62ac8699c4 100644 --- a/crypto/akcipher-nettle.c.inc +++ b/crypto/akcipher-nettle.c.inc @@ -87,7 +87,7 @@ static int qcrypt_nettle_parse_rsa_private_key(QCryptoNet= tleRSA *rsa, Error **errp) { g_autoptr(QCryptoAkCipherRSAKey) rsa_key =3D qcrypto_akcipher_rsakey_p= arse( - QCRYPTO_AKCIPHER_KEY_TYPE_PRIVATE, key, keylen, errp); + QCRYPTO_AK_CIPHER_KEY_TYPE_PRIVATE, key, keylen, errp); =20 if (!rsa_key) { return -1; @@ -137,7 +137,7 @@ static int qcrypt_nettle_parse_rsa_public_key(QCryptoNe= ttleRSA *rsa, Error **errp) { g_autoptr(QCryptoAkCipherRSAKey) rsa_key =3D qcrypto_akcipher_rsakey_p= arse( - QCRYPTO_AKCIPHER_KEY_TYPE_PUBLIC, key, keylen, errp); + QCRYPTO_AK_CIPHER_KEY_TYPE_PUBLIC, key, keylen, errp); =20 if (!rsa_key) { return -1; @@ -397,13 +397,13 @@ static QCryptoAkCipher *qcrypto_nettle_rsa_new( rsa_private_key_init(&rsa->priv); =20 switch (type) { - case QCRYPTO_AKCIPHER_KEY_TYPE_PRIVATE: + case QCRYPTO_AK_CIPHER_KEY_TYPE_PRIVATE: if (qcrypt_nettle_parse_rsa_private_key(rsa, key, keylen, errp) != =3D 0) { goto error; } break; =20 - case QCRYPTO_AKCIPHER_KEY_TYPE_PUBLIC: + case QCRYPTO_AK_CIPHER_KEY_TYPE_PUBLIC: if (qcrypt_nettle_parse_rsa_public_key(rsa, key, keylen, errp) != =3D 0) { goto error; } diff --git a/crypto/rsakey-builtin.c.inc b/crypto/rsakey-builtin.c.inc index 46cc7afe87..6337b84c54 100644 --- a/crypto/rsakey-builtin.c.inc +++ b/crypto/rsakey-builtin.c.inc @@ -183,10 +183,10 @@ QCryptoAkCipherRSAKey *qcrypto_akcipher_rsakey_parse( size_t keylen, Error **errp) { switch (type) { - case QCRYPTO_AKCIPHER_KEY_TYPE_PRIVATE: + case QCRYPTO_AK_CIPHER_KEY_TYPE_PRIVATE: return qcrypto_builtin_rsa_private_key_parse(key, keylen, errp); =20 - case QCRYPTO_AKCIPHER_KEY_TYPE_PUBLIC: + case QCRYPTO_AK_CIPHER_KEY_TYPE_PUBLIC: return qcrypto_builtin_rsa_public_key_parse(key, keylen, errp); =20 default: diff --git a/crypto/rsakey-nettle.c.inc b/crypto/rsakey-nettle.c.inc index cc49872e78..b7f34b0234 100644 --- a/crypto/rsakey-nettle.c.inc +++ b/crypto/rsakey-nettle.c.inc @@ -145,10 +145,10 @@ QCryptoAkCipherRSAKey *qcrypto_akcipher_rsakey_parse( size_t keylen, Error **errp) { switch (type) { - case QCRYPTO_AKCIPHER_KEY_TYPE_PRIVATE: + case QCRYPTO_AK_CIPHER_KEY_TYPE_PRIVATE: return qcrypto_nettle_rsa_private_key_parse(key, keylen, errp); =20 - case QCRYPTO_AKCIPHER_KEY_TYPE_PUBLIC: + case QCRYPTO_AK_CIPHER_KEY_TYPE_PUBLIC: return qcrypto_nettle_rsa_public_key_parse(key, keylen, errp); =20 default: --=20 2.46.0 From nobody Sun Nov 24 08:32:09 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=1725449192; cv=none; d=zohomail.com; s=zohoarc; b=i3rTaXxKSRrMYMsfdnwySHLK5cPgjp+Q35YKZKbnhWQ/18U6hZjBIWdKzMhSiVdTfdKu+/m6BFrBQvKv8n4hpvLDqNeea8zXVKz4qz7W5us1FwhGacng7zdTFInoDTtdLrlNhagb2SnX+2yGWE/dIDwRBTF2L4fuIkP6f2zs7cc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1725449192; 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=QX4JUInoHUF7q6csJlaRB2sSg2TElp2pQDt4acUj8qE=; b=Dnl9/6kTrWqg7n2tij+jw/U7Wf/lmICKm+rSiXLFMYAjuz5P6i96bkDa7kBx3HuoQlSWYaI2xVKkZBj2TyoChhMeyIEGFXn0rFtkJrxnGXk64txm2dYk8FWRa0pMxjvvNMLJJfxhoYQsX8qP6wTqupY3SLB0jSbgiWAq7nNx8KE= 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 1725449192023960.6151498718153; Wed, 4 Sep 2024 04:26:32 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1slo93-0007ZN-Sy; Wed, 04 Sep 2024 07:25:53 -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 1slo8f-0006D3-Mp for qemu-devel@nongnu.org; Wed, 04 Sep 2024 07:25:29 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1slo8V-0004UP-Q0 for qemu-devel@nongnu.org; Wed, 04 Sep 2024 07:25:28 -0400 Received: from mx-prod-mc-01.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-570-kPFm4qfVNPiD0eqbEwR-kw-1; Wed, 04 Sep 2024 07:18:50 -0400 Received: from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.15]) (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-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 78745196CE1D; Wed, 4 Sep 2024 11:18:46 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.192.112]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 08D731956094; Wed, 4 Sep 2024 11:18:45 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id BF11421E6829; 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=QX4JUInoHUF7q6csJlaRB2sSg2TElp2pQDt4acUj8qE=; b=c6PO2LIYxxPCMgpEF54fGIHaK5P6xDp+GE8tFHY7IyyYxsFs0WNtVEcGN7o8GoMJPdGAOa Whgdiig/ccS4JqdwIQIShFPLjqgwhbZxZlw8wwbDIXAb2Y87NV33BXhr+RHZtdModpeWOV E1H1idXfQsT44mUQmJqgsflzY59JQhw= X-MC-Unique: kPFm4qfVNPiD0eqbEwR-kw-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 11/19] qapi/crypto: Rename QCryptoHashAlgorithm to *Algo, and drop prefix Date: Wed, 4 Sep 2024 13:18:28 +0200 Message-ID: <20240904111836.3273842-12-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.0 on 10.30.177.15 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.129.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_H3=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: 1725449194116116600 QAPI's 'prefix' feature can make the connection between enumeration type and its constants less than obvious. It's best used with restraint. QCryptoHashAlgorithm has a 'prefix' that overrides the generated enumeration constants' prefix to QCRYPTO_HASH_ALG. We could simply drop 'prefix', but then the prefix becomes QCRYPTO_HASH_ALGORITHM, which is rather long. We could additionally rename the type to QCryptoHashAlg, but I think the abbreviation "alg" is less than clear. Rename the type to QCryptoHashAlgo instead. The prefix becomes to QCRYPTO_HASH_ALGO. Signed-off-by: Markus Armbruster Acked-by: Daniel P. Berrang=C3=A9 --- qapi/crypto.json | 17 +++++----- crypto/blockpriv.h | 2 +- crypto/hashpriv.h | 2 +- crypto/hmacpriv.h | 4 +-- crypto/ivgenpriv.h | 2 +- include/crypto/afsplit.h | 8 ++--- include/crypto/block.h | 2 +- include/crypto/hash.h | 18 +++++----- include/crypto/hmac.h | 6 ++-- include/crypto/ivgen.h | 6 ++-- include/crypto/pbkdf.h | 10 +++--- backends/cryptodev-builtin.c | 8 ++--- backends/cryptodev-lkcf.c | 10 +++--- block/parallels-ext.c | 2 +- block/quorum.c | 4 +-- crypto/afsplit.c | 6 ++-- crypto/block-luks.c | 16 ++++----- crypto/block.c | 2 +- crypto/hash-afalg.c | 26 +++++++-------- crypto/hash-gcrypt.c | 20 +++++------ crypto/hash-glib.c | 20 +++++------ crypto/hash-gnutls.c | 20 +++++------ crypto/hash-nettle.c | 18 +++++----- crypto/hash.c | 30 ++++++++--------- crypto/hmac-gcrypt.c | 22 ++++++------- crypto/hmac-glib.c | 22 ++++++------- crypto/hmac-gnutls.c | 22 ++++++------- crypto/hmac-nettle.c | 22 ++++++------- crypto/hmac.c | 2 +- crypto/ivgen.c | 4 +-- crypto/pbkdf-gcrypt.c | 36 ++++++++++---------- crypto/pbkdf-gnutls.c | 36 ++++++++++---------- crypto/pbkdf-nettle.c | 32 +++++++++--------- crypto/pbkdf-stub.c | 4 +-- crypto/pbkdf.c | 2 +- hw/misc/aspeed_hace.c | 16 ++++----- io/channel-websock.c | 2 +- target/i386/sev.c | 6 ++-- tests/bench/benchmark-crypto-akcipher.c | 12 +++---- tests/bench/benchmark-crypto-hash.c | 10 +++--- tests/bench/benchmark-crypto-hmac.c | 6 ++-- tests/unit/test-crypto-afsplit.c | 10 +++--- tests/unit/test-crypto-akcipher.c | 6 ++-- tests/unit/test-crypto-block.c | 16 ++++----- tests/unit/test-crypto-hash.c | 42 +++++++++++------------ tests/unit/test-crypto-hmac.c | 16 ++++----- tests/unit/test-crypto-ivgen.c | 8 ++--- tests/unit/test-crypto-pbkdf.c | 44 ++++++++++++------------- ui/vnc.c | 2 +- util/hbitmap.c | 2 +- crypto/akcipher-gcrypt.c.inc | 14 ++++---- crypto/akcipher-nettle.c.inc | 26 +++++++-------- 52 files changed, 350 insertions(+), 351 deletions(-) diff --git a/qapi/crypto.json b/qapi/crypto.json index b5c25e7cd9..68393568cf 100644 --- a/qapi/crypto.json +++ b/qapi/crypto.json @@ -38,7 +38,7 @@ 'data': ['raw', 'base64']} =20 ## -# @QCryptoHashAlgorithm: +# @QCryptoHashAlgo: # # The supported algorithms for computing content digests # @@ -58,8 +58,7 @@ # # Since: 2.6 ## -{ 'enum': 'QCryptoHashAlgorithm', - 'prefix': 'QCRYPTO_HASH_ALG', +{ 'enum': 'QCryptoHashAlgo', 'data': ['md5', 'sha1', 'sha224', 'sha256', 'sha384', 'sha512', 'ripemd1= 60']} =20 ## @@ -229,8 +228,8 @@ 'data': { '*cipher-alg': 'QCryptoCipherAlgorithm', '*cipher-mode': 'QCryptoCipherMode', '*ivgen-alg': 'QCryptoIVGenAlgorithm', - '*ivgen-hash-alg': 'QCryptoHashAlgorithm', - '*hash-alg': 'QCryptoHashAlgorithm', + '*ivgen-hash-alg': 'QCryptoHashAlgo', + '*hash-alg': 'QCryptoHashAlgo', '*iter-time': 'int' }} =20 ## @@ -326,8 +325,8 @@ 'data': {'cipher-alg': 'QCryptoCipherAlgorithm', 'cipher-mode': 'QCryptoCipherMode', 'ivgen-alg': 'QCryptoIVGenAlgorithm', - '*ivgen-hash-alg': 'QCryptoHashAlgorithm', - 'hash-alg': 'QCryptoHashAlgorithm', + '*ivgen-hash-alg': 'QCryptoHashAlgo', + 'hash-alg': 'QCryptoHashAlgo', 'detached-header': 'bool', 'payload-offset': 'int', 'master-key-iters': 'int', @@ -631,14 +630,14 @@ # # Specific parameters for RSA algorithm. # -# @hash-alg: QCryptoHashAlgorithm +# @hash-alg: QCryptoHashAlgo # # @padding-alg: QCryptoRSAPaddingAlgorithm # # Since: 7.1 ## { 'struct': 'QCryptoAkCipherOptionsRSA', - 'data': { 'hash-alg':'QCryptoHashAlgorithm', + 'data': { 'hash-alg':'QCryptoHashAlgo', 'padding-alg': 'QCryptoRSAPaddingAlgorithm'}} =20 ## diff --git a/crypto/blockpriv.h b/crypto/blockpriv.h index b8f77cb5eb..cf1a66c00d 100644 --- a/crypto/blockpriv.h +++ b/crypto/blockpriv.h @@ -44,7 +44,7 @@ struct QCryptoBlock { QCryptoIVGen *ivgen; QemuMutex mutex; =20 - QCryptoHashAlgorithm kdfhash; + QCryptoHashAlgo kdfhash; size_t niv; uint64_t payload_offset; /* In bytes */ uint64_t sector_size; /* In bytes */ diff --git a/crypto/hashpriv.h b/crypto/hashpriv.h index cee26ccb47..47daec3f7a 100644 --- a/crypto/hashpriv.h +++ b/crypto/hashpriv.h @@ -18,7 +18,7 @@ typedef struct QCryptoHashDriver QCryptoHashDriver; =20 struct QCryptoHashDriver { - int (*hash_bytesv)(QCryptoHashAlgorithm alg, + int (*hash_bytesv)(QCryptoHashAlgo alg, const struct iovec *iov, size_t niov, uint8_t **result, diff --git a/crypto/hmacpriv.h b/crypto/hmacpriv.h index 62dfe8257a..bd4c498c62 100644 --- a/crypto/hmacpriv.h +++ b/crypto/hmacpriv.h @@ -28,7 +28,7 @@ struct QCryptoHmacDriver { void (*hmac_free)(QCryptoHmac *hmac); }; =20 -void *qcrypto_hmac_ctx_new(QCryptoHashAlgorithm alg, +void *qcrypto_hmac_ctx_new(QCryptoHashAlgo alg, const uint8_t *key, size_t nkey, Error **errp); extern QCryptoHmacDriver qcrypto_hmac_lib_driver; @@ -37,7 +37,7 @@ extern QCryptoHmacDriver qcrypto_hmac_lib_driver; =20 #include "afalgpriv.h" =20 -QCryptoAFAlg *qcrypto_afalg_hmac_ctx_new(QCryptoHashAlgorithm alg, +QCryptoAFAlg *qcrypto_afalg_hmac_ctx_new(QCryptoHashAlgo alg, const uint8_t *key, size_t nkey, Error **errp); extern QCryptoHmacDriver qcrypto_hmac_afalg_driver; diff --git a/crypto/ivgenpriv.h b/crypto/ivgenpriv.h index cecdbedfde..0227ae4d00 100644 --- a/crypto/ivgenpriv.h +++ b/crypto/ivgenpriv.h @@ -42,7 +42,7 @@ struct QCryptoIVGen { =20 QCryptoIVGenAlgorithm algorithm; QCryptoCipherAlgorithm cipher; - QCryptoHashAlgorithm hash; + QCryptoHashAlgo hash; }; =20 =20 diff --git a/include/crypto/afsplit.h b/include/crypto/afsplit.h index 4894d64330..06f28fe67c 100644 --- a/include/crypto/afsplit.h +++ b/include/crypto/afsplit.h @@ -46,7 +46,7 @@ * * splitkey =3D g_new0(uint8_t, nkey * stripes); * - * if (qcrypto_afsplit_encode(QCRYPTO_HASH_ALG_SHA256, + * if (qcrypto_afsplit_encode(QCRYPTO_HASH_ALGO_SHA256, * nkey, stripes, * masterkey, splitkey, errp) < 0) { * g_free(splitkey); @@ -71,7 +71,7 @@ * * masterkey =3D g_new0(uint8_t, nkey); * - * if (qcrypto_afsplit_decode(QCRYPTO_HASH_ALG_SHA256, + * if (qcrypto_afsplit_decode(QCRYPTO_HASH_ALGO_SHA256, * nkey, stripes, * splitkey, masterkey, errp) < 0) { * g_free(splitkey); @@ -102,7 +102,7 @@ * * Returns: 0 on success, -1 on error; */ -int qcrypto_afsplit_encode(QCryptoHashAlgorithm hash, +int qcrypto_afsplit_encode(QCryptoHashAlgo hash, size_t blocklen, uint32_t stripes, const uint8_t *in, @@ -124,7 +124,7 @@ int qcrypto_afsplit_encode(QCryptoHashAlgorithm hash, * * Returns: 0 on success, -1 on error; */ -int qcrypto_afsplit_decode(QCryptoHashAlgorithm hash, +int qcrypto_afsplit_decode(QCryptoHashAlgo hash, size_t blocklen, uint32_t stripes, const uint8_t *in, diff --git a/include/crypto/block.h b/include/crypto/block.h index 5b5d039800..b013d27f00 100644 --- a/include/crypto/block.h +++ b/include/crypto/block.h @@ -287,7 +287,7 @@ QCryptoIVGen *qcrypto_block_get_ivgen(QCryptoBlock *blo= ck); * * Returns: the hash algorithm */ -QCryptoHashAlgorithm qcrypto_block_get_kdf_hash(QCryptoBlock *block); +QCryptoHashAlgo qcrypto_block_get_kdf_hash(QCryptoBlock *block); =20 /** * qcrypto_block_get_payload_offset: diff --git a/include/crypto/hash.h b/include/crypto/hash.h index 54d87aa2a1..67be72b01d 100644 --- a/include/crypto/hash.h +++ b/include/crypto/hash.h @@ -23,7 +23,7 @@ =20 #include "qapi/qapi-types-crypto.h" =20 -/* See also "QCryptoHashAlgorithm" defined in qapi/crypto.json */ +/* See also "QCryptoHashAlgo" defined in qapi/crypto.json */ =20 /** * qcrypto_hash_supports: @@ -34,7 +34,7 @@ * * Returns: true if the algorithm is supported, false otherwise */ -gboolean qcrypto_hash_supports(QCryptoHashAlgorithm alg); +gboolean qcrypto_hash_supports(QCryptoHashAlgo alg); =20 =20 /** @@ -45,7 +45,7 @@ gboolean qcrypto_hash_supports(QCryptoHashAlgorithm alg); * * Returns: the digest length in bytes */ -size_t qcrypto_hash_digest_len(QCryptoHashAlgorithm alg); +size_t qcrypto_hash_digest_len(QCryptoHashAlgo alg); =20 /** * qcrypto_hash_bytesv: @@ -65,7 +65,7 @@ size_t qcrypto_hash_digest_len(QCryptoHashAlgorithm alg); * * Returns: 0 on success, -1 on error */ -int qcrypto_hash_bytesv(QCryptoHashAlgorithm alg, +int qcrypto_hash_bytesv(QCryptoHashAlgo alg, const struct iovec *iov, size_t niov, uint8_t **result, @@ -90,7 +90,7 @@ int qcrypto_hash_bytesv(QCryptoHashAlgorithm alg, * * Returns: 0 on success, -1 on error */ -int qcrypto_hash_bytes(QCryptoHashAlgorithm alg, +int qcrypto_hash_bytes(QCryptoHashAlgo alg, const char *buf, size_t len, uint8_t **result, @@ -114,7 +114,7 @@ int qcrypto_hash_bytes(QCryptoHashAlgorithm alg, * * Returns: 0 on success, -1 on error */ -int qcrypto_hash_digestv(QCryptoHashAlgorithm alg, +int qcrypto_hash_digestv(QCryptoHashAlgo alg, const struct iovec *iov, size_t niov, char **digest, @@ -137,7 +137,7 @@ int qcrypto_hash_digestv(QCryptoHashAlgorithm alg, * * Returns: 0 on success, -1 on error */ -int qcrypto_hash_digest(QCryptoHashAlgorithm alg, +int qcrypto_hash_digest(QCryptoHashAlgo alg, const char *buf, size_t len, char **digest, @@ -160,7 +160,7 @@ int qcrypto_hash_digest(QCryptoHashAlgorithm alg, * * Returns: 0 on success, -1 on error */ -int qcrypto_hash_base64v(QCryptoHashAlgorithm alg, +int qcrypto_hash_base64v(QCryptoHashAlgo alg, const struct iovec *iov, size_t niov, char **base64, @@ -183,7 +183,7 @@ int qcrypto_hash_base64v(QCryptoHashAlgorithm alg, * * Returns: 0 on success, -1 on error */ -int qcrypto_hash_base64(QCryptoHashAlgorithm alg, +int qcrypto_hash_base64(QCryptoHashAlgo alg, const char *buf, size_t len, char **base64, diff --git a/include/crypto/hmac.h b/include/crypto/hmac.h index ad4d778416..c69a0dfab3 100644 --- a/include/crypto/hmac.h +++ b/include/crypto/hmac.h @@ -16,7 +16,7 @@ =20 typedef struct QCryptoHmac QCryptoHmac; struct QCryptoHmac { - QCryptoHashAlgorithm alg; + QCryptoHashAlgo alg; void *opaque; void *driver; }; @@ -31,7 +31,7 @@ struct QCryptoHmac { * Returns: * true if the algorithm is supported, false otherwise */ -bool qcrypto_hmac_supports(QCryptoHashAlgorithm alg); +bool qcrypto_hmac_supports(QCryptoHashAlgo alg); =20 /** * qcrypto_hmac_new: @@ -52,7 +52,7 @@ bool qcrypto_hmac_supports(QCryptoHashAlgorithm alg); * Returns: * a new hmac object, or NULL on error */ -QCryptoHmac *qcrypto_hmac_new(QCryptoHashAlgorithm alg, +QCryptoHmac *qcrypto_hmac_new(QCryptoHashAlgo alg, const uint8_t *key, size_t nkey, Error **errp); =20 diff --git a/include/crypto/ivgen.h b/include/crypto/ivgen.h index a09d5732da..ab5f1a648e 100644 --- a/include/crypto/ivgen.h +++ b/include/crypto/ivgen.h @@ -46,7 +46,7 @@ * * QCryptoIVGen *ivgen =3D qcrypto_ivgen_new(QCRYPTO_IVGEN_ALG_ESSIV, * QCRYPTO_CIPHER_ALG_AES_128, - * QCRYPTO_HASH_ALG_SHA256, + * QCRYPTO_HASH_ALGO_SHA256, * key, nkey, errp); * if (!ivgen) { * return -1; @@ -135,7 +135,7 @@ typedef struct QCryptoIVGen QCryptoIVGen; */ QCryptoIVGen *qcrypto_ivgen_new(QCryptoIVGenAlgorithm alg, QCryptoCipherAlgorithm cipheralg, - QCryptoHashAlgorithm hash, + QCryptoHashAlgo hash, const uint8_t *key, size_t nkey, Error **errp); =20 @@ -191,7 +191,7 @@ QCryptoCipherAlgorithm qcrypto_ivgen_get_cipher(QCrypto= IVGen *ivgen); * * Returns: the hash algorithm */ -QCryptoHashAlgorithm qcrypto_ivgen_get_hash(QCryptoIVGen *ivgen); +QCryptoHashAlgo qcrypto_ivgen_get_hash(QCryptoIVGen *ivgen); =20 =20 /** diff --git a/include/crypto/pbkdf.h b/include/crypto/pbkdf.h index 2c31a44a27..6cf29e78ee 100644 --- a/include/crypto/pbkdf.h +++ b/include/crypto/pbkdf.h @@ -50,7 +50,7 @@ * return -1; * } * - * iterations =3D qcrypto_pbkdf2_count_iters(QCRYPTO_HASH_ALG_SHA256, + * iterations =3D qcrypto_pbkdf2_count_iters(QCRYPTO_HASH_ALGO_SHA256, * (const uint8_t *)password, * strlen(password), * salt, nkey, errp); @@ -60,7 +60,7 @@ * return -1; * } * - * if (qcrypto_pbkdf2(QCRYPTO_HASH_ALG_SHA256, + * if (qcrypto_pbkdf2(QCRYPTO_HASH_ALGO_SHA256, * (const uint8_t *)password, strlen(password), * salt, nkey, iterations, key, nkey, errp) < 0) { * g_free(key); @@ -92,7 +92,7 @@ * * Returns true if supported, false otherwise */ -bool qcrypto_pbkdf2_supports(QCryptoHashAlgorithm hash); +bool qcrypto_pbkdf2_supports(QCryptoHashAlgo hash); =20 =20 /** @@ -119,7 +119,7 @@ bool qcrypto_pbkdf2_supports(QCryptoHashAlgorithm hash); * * Returns: 0 on success, -1 on error */ -int qcrypto_pbkdf2(QCryptoHashAlgorithm hash, +int qcrypto_pbkdf2(QCryptoHashAlgo hash, const uint8_t *key, size_t nkey, const uint8_t *salt, size_t nsalt, uint64_t iterations, @@ -147,7 +147,7 @@ int qcrypto_pbkdf2(QCryptoHashAlgorithm hash, * * Returns: number of iterations in 1 second, -1 on error */ -uint64_t qcrypto_pbkdf2_count_iters(QCryptoHashAlgorithm hash, +uint64_t qcrypto_pbkdf2_count_iters(QCryptoHashAlgo hash, const uint8_t *key, size_t nkey, const uint8_t *salt, size_t nsalt, size_t nout, diff --git a/backends/cryptodev-builtin.c b/backends/cryptodev-builtin.c index e95af9bb72..4a49d328ec 100644 --- a/backends/cryptodev-builtin.c +++ b/backends/cryptodev-builtin.c @@ -169,16 +169,16 @@ static int cryptodev_builtin_get_rsa_hash_algo( { switch (virtio_rsa_hash) { case VIRTIO_CRYPTO_RSA_MD5: - return QCRYPTO_HASH_ALG_MD5; + return QCRYPTO_HASH_ALGO_MD5; =20 case VIRTIO_CRYPTO_RSA_SHA1: - return QCRYPTO_HASH_ALG_SHA1; + return QCRYPTO_HASH_ALGO_SHA1; =20 case VIRTIO_CRYPTO_RSA_SHA256: - return QCRYPTO_HASH_ALG_SHA256; + return QCRYPTO_HASH_ALGO_SHA256; =20 case VIRTIO_CRYPTO_RSA_SHA512: - return QCRYPTO_HASH_ALG_SHA512; + return QCRYPTO_HASH_ALGO_SHA512; =20 default: error_setg(errp, "Unsupported rsa hash algo: %d", virtio_rsa_hash); diff --git a/backends/cryptodev-lkcf.c b/backends/cryptodev-lkcf.c index e1ee11a158..6e6012e716 100644 --- a/backends/cryptodev-lkcf.c +++ b/backends/cryptodev-lkcf.c @@ -142,7 +142,7 @@ static int cryptodev_lkcf_set_op_desc(QCryptoAkCipherOp= tions *opts, if (rsa_opt->padding_alg =3D=3D QCRYPTO_RSA_PADDING_ALG_PKCS1) { snprintf(key_desc, desc_len, "enc=3D%s hash=3D%s", QCryptoRSAPaddingAlgorithm_str(rsa_opt->padding_alg), - QCryptoHashAlgorithm_str(rsa_opt->hash_alg)); + QCryptoHashAlgo_str(rsa_opt->hash_alg)); =20 } else { snprintf(key_desc, desc_len, "enc=3D%s", @@ -161,19 +161,19 @@ static int cryptodev_lkcf_set_rsa_opt(int virtio_padd= ing_alg, =20 switch (virtio_hash_alg) { case VIRTIO_CRYPTO_RSA_MD5: - opt->hash_alg =3D QCRYPTO_HASH_ALG_MD5; + opt->hash_alg =3D QCRYPTO_HASH_ALGO_MD5; break; =20 case VIRTIO_CRYPTO_RSA_SHA1: - opt->hash_alg =3D QCRYPTO_HASH_ALG_SHA1; + opt->hash_alg =3D QCRYPTO_HASH_ALGO_SHA1; break; =20 case VIRTIO_CRYPTO_RSA_SHA256: - opt->hash_alg =3D QCRYPTO_HASH_ALG_SHA256; + opt->hash_alg =3D QCRYPTO_HASH_ALGO_SHA256; break; =20 case VIRTIO_CRYPTO_RSA_SHA512: - opt->hash_alg =3D QCRYPTO_HASH_ALG_SHA512; + opt->hash_alg =3D QCRYPTO_HASH_ALGO_SHA512; break; =20 default: diff --git a/block/parallels-ext.c b/block/parallels-ext.c index b4e14c88f2..778b8f684e 100644 --- a/block/parallels-ext.c +++ b/block/parallels-ext.c @@ -206,7 +206,7 @@ parallels_parse_format_extension(BlockDriverState *bs, = uint8_t *ext_cluster, goto fail; } =20 - ret =3D qcrypto_hash_bytes(QCRYPTO_HASH_ALG_MD5, (char *)pos, remainin= g, + ret =3D qcrypto_hash_bytes(QCRYPTO_HASH_ALGO_MD5, (char *)pos, remaini= ng, &hash, &hash_len, errp); if (ret < 0) { goto fail; diff --git a/block/quorum.c b/block/quorum.c index db8fe891c4..46be65a95f 100644 --- a/block/quorum.c +++ b/block/quorum.c @@ -393,7 +393,7 @@ static int quorum_compute_hash(QuorumAIOCB *acb, int i,= QuorumVoteValue *hash) /* XXX - would be nice if we could pass in the Error ** * and propagate that back, but this quorum code is * restricted to just errno values currently */ - if (qcrypto_hash_bytesv(QCRYPTO_HASH_ALG_SHA256, + if (qcrypto_hash_bytesv(QCRYPTO_HASH_ALGO_SHA256, qiov->iov, qiov->niov, &data, &len, NULL) < 0) { @@ -1308,7 +1308,7 @@ static BlockDriver bdrv_quorum =3D { =20 static void bdrv_quorum_init(void) { - if (!qcrypto_hash_supports(QCRYPTO_HASH_ALG_SHA256)) { + if (!qcrypto_hash_supports(QCRYPTO_HASH_ALGO_SHA256)) { /* SHA256 hash support is required for quorum device */ return; } diff --git a/crypto/afsplit.c b/crypto/afsplit.c index b1a5a20899..b2e383aa67 100644 --- a/crypto/afsplit.c +++ b/crypto/afsplit.c @@ -40,7 +40,7 @@ static void qcrypto_afsplit_xor(size_t blocklen, } =20 =20 -static int qcrypto_afsplit_hash(QCryptoHashAlgorithm hash, +static int qcrypto_afsplit_hash(QCryptoHashAlgo hash, size_t blocklen, uint8_t *block, Error **errp) @@ -85,7 +85,7 @@ static int qcrypto_afsplit_hash(QCryptoHashAlgorithm hash, } =20 =20 -int qcrypto_afsplit_encode(QCryptoHashAlgorithm hash, +int qcrypto_afsplit_encode(QCryptoHashAlgo hash, size_t blocklen, uint32_t stripes, const uint8_t *in, @@ -117,7 +117,7 @@ int qcrypto_afsplit_encode(QCryptoHashAlgorithm hash, } =20 =20 -int qcrypto_afsplit_decode(QCryptoHashAlgorithm hash, +int qcrypto_afsplit_decode(QCryptoHashAlgo hash, size_t blocklen, uint32_t stripes, const uint8_t *in, diff --git a/crypto/block-luks.c b/crypto/block-luks.c index 7b9c7b292d..59af733b8c 100644 --- a/crypto/block-luks.c +++ b/crypto/block-luks.c @@ -132,7 +132,7 @@ struct QCryptoBlockLUKS { QCryptoIVGenAlgorithm ivgen_alg; =20 /* Hash algorithm used for IV generation*/ - QCryptoHashAlgorithm ivgen_hash_alg; + QCryptoHashAlgo ivgen_hash_alg; =20 /* * Encryption algorithm used for IV generation. @@ -141,7 +141,7 @@ struct QCryptoBlockLUKS { QCryptoCipherAlgorithm ivgen_cipher_alg; =20 /* Hash algorithm used in pbkdf2 function */ - QCryptoHashAlgorithm hash_alg; + QCryptoHashAlgo hash_alg; =20 /* Name of the secret that was used to open the image */ char *secret; @@ -223,7 +223,7 @@ static int qcrypto_block_luks_name_lookup(const char *n= ame, =20 #define qcrypto_block_luks_hash_name_lookup(name, errp) \ qcrypto_block_luks_name_lookup(name, \ - &QCryptoHashAlgorithm_lookup, \ + &QCryptoHashAlgo_lookup, \ "Hash algorithm", \ errp) =20 @@ -264,7 +264,7 @@ qcrypto_block_luks_has_format(const uint8_t *buf, */ static QCryptoCipherAlgorithm qcrypto_block_luks_essiv_cipher(QCryptoCipherAlgorithm cipher, - QCryptoHashAlgorithm hash, + QCryptoHashAlgo hash, Error **errp) { size_t digestlen =3D qcrypto_hash_digest_len(hash); @@ -1331,11 +1331,11 @@ qcrypto_block_luks_create(QCryptoBlock *block, luks_opts.ivgen_alg =3D QCRYPTO_IVGEN_ALG_PLAIN64; } if (!luks_opts.has_hash_alg) { - luks_opts.hash_alg =3D QCRYPTO_HASH_ALG_SHA256; + luks_opts.hash_alg =3D QCRYPTO_HASH_ALGO_SHA256; } if (luks_opts.ivgen_alg =3D=3D QCRYPTO_IVGEN_ALG_ESSIV) { if (!luks_opts.has_ivgen_hash_alg) { - luks_opts.ivgen_hash_alg =3D QCRYPTO_HASH_ALG_SHA256; + luks_opts.ivgen_hash_alg =3D QCRYPTO_HASH_ALGO_SHA256; luks_opts.has_ivgen_hash_alg =3D true; } } @@ -1386,13 +1386,13 @@ qcrypto_block_luks_create(QCryptoBlock *block, cipher_mode =3D QCryptoCipherMode_str(luks_opts.cipher_mode); ivgen_alg =3D QCryptoIVGenAlgorithm_str(luks_opts.ivgen_alg); if (luks_opts.has_ivgen_hash_alg) { - ivgen_hash_alg =3D QCryptoHashAlgorithm_str(luks_opts.ivgen_hash_a= lg); + ivgen_hash_alg =3D QCryptoHashAlgo_str(luks_opts.ivgen_hash_alg); cipher_mode_spec =3D g_strdup_printf("%s-%s:%s", cipher_mode, ivge= n_alg, ivgen_hash_alg); } else { cipher_mode_spec =3D g_strdup_printf("%s-%s", cipher_mode, ivgen_a= lg); } - hash_alg =3D QCryptoHashAlgorithm_str(luks_opts.hash_alg); + hash_alg =3D QCryptoHashAlgo_str(luks_opts.hash_alg); =20 =20 if (strlen(cipher_alg) >=3D QCRYPTO_BLOCK_LUKS_CIPHER_NAME_LEN) { diff --git a/crypto/block.c b/crypto/block.c index 899561a080..9846caa591 100644 --- a/crypto/block.c +++ b/crypto/block.c @@ -332,7 +332,7 @@ QCryptoIVGen *qcrypto_block_get_ivgen(QCryptoBlock *blo= ck) } =20 =20 -QCryptoHashAlgorithm qcrypto_block_get_kdf_hash(QCryptoBlock *block) +QCryptoHashAlgo qcrypto_block_get_kdf_hash(QCryptoBlock *block) { return block->kdfhash; } diff --git a/crypto/hash-afalg.c b/crypto/hash-afalg.c index 3ebea39292..8fc6bd0edf 100644 --- a/crypto/hash-afalg.c +++ b/crypto/hash-afalg.c @@ -20,7 +20,7 @@ #include "hmacpriv.h" =20 static char * -qcrypto_afalg_hash_format_name(QCryptoHashAlgorithm alg, +qcrypto_afalg_hash_format_name(QCryptoHashAlgo alg, bool is_hmac, Error **errp) { @@ -28,25 +28,25 @@ qcrypto_afalg_hash_format_name(QCryptoHashAlgorithm alg, const char *alg_name; =20 switch (alg) { - case QCRYPTO_HASH_ALG_MD5: + case QCRYPTO_HASH_ALGO_MD5: alg_name =3D "md5"; break; - case QCRYPTO_HASH_ALG_SHA1: + case QCRYPTO_HASH_ALGO_SHA1: alg_name =3D "sha1"; break; - case QCRYPTO_HASH_ALG_SHA224: + case QCRYPTO_HASH_ALGO_SHA224: alg_name =3D "sha224"; break; - case QCRYPTO_HASH_ALG_SHA256: + case QCRYPTO_HASH_ALGO_SHA256: alg_name =3D "sha256"; break; - case QCRYPTO_HASH_ALG_SHA384: + case QCRYPTO_HASH_ALGO_SHA384: alg_name =3D "sha384"; break; - case QCRYPTO_HASH_ALG_SHA512: + case QCRYPTO_HASH_ALGO_SHA512: alg_name =3D "sha512"; break; - case QCRYPTO_HASH_ALG_RIPEMD160: + case QCRYPTO_HASH_ALGO_RIPEMD160: alg_name =3D "rmd160"; break; =20 @@ -65,7 +65,7 @@ qcrypto_afalg_hash_format_name(QCryptoHashAlgorithm alg, } =20 static QCryptoAFAlg * -qcrypto_afalg_hash_hmac_ctx_new(QCryptoHashAlgorithm alg, +qcrypto_afalg_hash_hmac_ctx_new(QCryptoHashAlgo alg, const uint8_t *key, size_t nkey, bool is_hmac, Error **errp) { @@ -99,14 +99,14 @@ qcrypto_afalg_hash_hmac_ctx_new(QCryptoHashAlgorithm al= g, } =20 static QCryptoAFAlg * -qcrypto_afalg_hash_ctx_new(QCryptoHashAlgorithm alg, +qcrypto_afalg_hash_ctx_new(QCryptoHashAlgo alg, Error **errp) { return qcrypto_afalg_hash_hmac_ctx_new(alg, NULL, 0, false, errp); } =20 QCryptoAFAlg * -qcrypto_afalg_hmac_ctx_new(QCryptoHashAlgorithm alg, +qcrypto_afalg_hmac_ctx_new(QCryptoHashAlgo alg, const uint8_t *key, size_t nkey, Error **errp) { @@ -115,7 +115,7 @@ qcrypto_afalg_hmac_ctx_new(QCryptoHashAlgorithm alg, =20 static int qcrypto_afalg_hash_hmac_bytesv(QCryptoAFAlg *hmac, - QCryptoHashAlgorithm alg, + QCryptoHashAlgo alg, const struct iovec *iov, size_t niov, uint8_t **result, size_t *resultlen, @@ -173,7 +173,7 @@ out: } =20 static int -qcrypto_afalg_hash_bytesv(QCryptoHashAlgorithm alg, +qcrypto_afalg_hash_bytesv(QCryptoHashAlgo alg, const struct iovec *iov, size_t niov, uint8_t **result, size_t *resultlen, diff --git a/crypto/hash-gcrypt.c b/crypto/hash-gcrypt.c index 829e48258d..0973cc0d93 100644 --- a/crypto/hash-gcrypt.c +++ b/crypto/hash-gcrypt.c @@ -25,17 +25,17 @@ #include "hashpriv.h" =20 =20 -static int qcrypto_hash_alg_map[QCRYPTO_HASH_ALG__MAX] =3D { - [QCRYPTO_HASH_ALG_MD5] =3D GCRY_MD_MD5, - [QCRYPTO_HASH_ALG_SHA1] =3D GCRY_MD_SHA1, - [QCRYPTO_HASH_ALG_SHA224] =3D GCRY_MD_SHA224, - [QCRYPTO_HASH_ALG_SHA256] =3D GCRY_MD_SHA256, - [QCRYPTO_HASH_ALG_SHA384] =3D GCRY_MD_SHA384, - [QCRYPTO_HASH_ALG_SHA512] =3D GCRY_MD_SHA512, - [QCRYPTO_HASH_ALG_RIPEMD160] =3D GCRY_MD_RMD160, +static int qcrypto_hash_alg_map[QCRYPTO_HASH_ALGO__MAX] =3D { + [QCRYPTO_HASH_ALGO_MD5] =3D GCRY_MD_MD5, + [QCRYPTO_HASH_ALGO_SHA1] =3D GCRY_MD_SHA1, + [QCRYPTO_HASH_ALGO_SHA224] =3D GCRY_MD_SHA224, + [QCRYPTO_HASH_ALGO_SHA256] =3D GCRY_MD_SHA256, + [QCRYPTO_HASH_ALGO_SHA384] =3D GCRY_MD_SHA384, + [QCRYPTO_HASH_ALGO_SHA512] =3D GCRY_MD_SHA512, + [QCRYPTO_HASH_ALGO_RIPEMD160] =3D GCRY_MD_RMD160, }; =20 -gboolean qcrypto_hash_supports(QCryptoHashAlgorithm alg) +gboolean qcrypto_hash_supports(QCryptoHashAlgo alg) { if (alg < G_N_ELEMENTS(qcrypto_hash_alg_map) && qcrypto_hash_alg_map[alg] !=3D GCRY_MD_NONE) { @@ -46,7 +46,7 @@ gboolean qcrypto_hash_supports(QCryptoHashAlgorithm alg) =20 =20 static int -qcrypto_gcrypt_hash_bytesv(QCryptoHashAlgorithm alg, +qcrypto_gcrypt_hash_bytesv(QCryptoHashAlgo alg, const struct iovec *iov, size_t niov, uint8_t **result, diff --git a/crypto/hash-glib.c b/crypto/hash-glib.c index 82de9db705..821fc9ac0c 100644 --- a/crypto/hash-glib.c +++ b/crypto/hash-glib.c @@ -24,17 +24,17 @@ #include "hashpriv.h" =20 =20 -static int qcrypto_hash_alg_map[QCRYPTO_HASH_ALG__MAX] =3D { - [QCRYPTO_HASH_ALG_MD5] =3D G_CHECKSUM_MD5, - [QCRYPTO_HASH_ALG_SHA1] =3D G_CHECKSUM_SHA1, - [QCRYPTO_HASH_ALG_SHA224] =3D -1, - [QCRYPTO_HASH_ALG_SHA256] =3D G_CHECKSUM_SHA256, - [QCRYPTO_HASH_ALG_SHA384] =3D -1, - [QCRYPTO_HASH_ALG_SHA512] =3D G_CHECKSUM_SHA512, - [QCRYPTO_HASH_ALG_RIPEMD160] =3D -1, +static int qcrypto_hash_alg_map[QCRYPTO_HASH_ALGO__MAX] =3D { + [QCRYPTO_HASH_ALGO_MD5] =3D G_CHECKSUM_MD5, + [QCRYPTO_HASH_ALGO_SHA1] =3D G_CHECKSUM_SHA1, + [QCRYPTO_HASH_ALGO_SHA224] =3D -1, + [QCRYPTO_HASH_ALGO_SHA256] =3D G_CHECKSUM_SHA256, + [QCRYPTO_HASH_ALGO_SHA384] =3D -1, + [QCRYPTO_HASH_ALGO_SHA512] =3D G_CHECKSUM_SHA512, + [QCRYPTO_HASH_ALGO_RIPEMD160] =3D -1, }; =20 -gboolean qcrypto_hash_supports(QCryptoHashAlgorithm alg) +gboolean qcrypto_hash_supports(QCryptoHashAlgo alg) { if (alg < G_N_ELEMENTS(qcrypto_hash_alg_map) && qcrypto_hash_alg_map[alg] !=3D -1) { @@ -45,7 +45,7 @@ gboolean qcrypto_hash_supports(QCryptoHashAlgorithm alg) =20 =20 static int -qcrypto_glib_hash_bytesv(QCryptoHashAlgorithm alg, +qcrypto_glib_hash_bytesv(QCryptoHashAlgo alg, const struct iovec *iov, size_t niov, uint8_t **result, diff --git a/crypto/hash-gnutls.c b/crypto/hash-gnutls.c index 17911ac5d1..0636c0727a 100644 --- a/crypto/hash-gnutls.c +++ b/crypto/hash-gnutls.c @@ -25,17 +25,17 @@ #include "hashpriv.h" =20 =20 -static int qcrypto_hash_alg_map[QCRYPTO_HASH_ALG__MAX] =3D { - [QCRYPTO_HASH_ALG_MD5] =3D GNUTLS_DIG_MD5, - [QCRYPTO_HASH_ALG_SHA1] =3D GNUTLS_DIG_SHA1, - [QCRYPTO_HASH_ALG_SHA224] =3D GNUTLS_DIG_SHA224, - [QCRYPTO_HASH_ALG_SHA256] =3D GNUTLS_DIG_SHA256, - [QCRYPTO_HASH_ALG_SHA384] =3D GNUTLS_DIG_SHA384, - [QCRYPTO_HASH_ALG_SHA512] =3D GNUTLS_DIG_SHA512, - [QCRYPTO_HASH_ALG_RIPEMD160] =3D GNUTLS_DIG_RMD160, +static int qcrypto_hash_alg_map[QCRYPTO_HASH_ALGO__MAX] =3D { + [QCRYPTO_HASH_ALGO_MD5] =3D GNUTLS_DIG_MD5, + [QCRYPTO_HASH_ALGO_SHA1] =3D GNUTLS_DIG_SHA1, + [QCRYPTO_HASH_ALGO_SHA224] =3D GNUTLS_DIG_SHA224, + [QCRYPTO_HASH_ALGO_SHA256] =3D GNUTLS_DIG_SHA256, + [QCRYPTO_HASH_ALGO_SHA384] =3D GNUTLS_DIG_SHA384, + [QCRYPTO_HASH_ALGO_SHA512] =3D GNUTLS_DIG_SHA512, + [QCRYPTO_HASH_ALGO_RIPEMD160] =3D GNUTLS_DIG_RMD160, }; =20 -gboolean qcrypto_hash_supports(QCryptoHashAlgorithm alg) +gboolean qcrypto_hash_supports(QCryptoHashAlgo alg) { size_t i; const gnutls_digest_algorithm_t *algs; @@ -54,7 +54,7 @@ gboolean qcrypto_hash_supports(QCryptoHashAlgorithm alg) =20 =20 static int -qcrypto_gnutls_hash_bytesv(QCryptoHashAlgorithm alg, +qcrypto_gnutls_hash_bytesv(QCryptoHashAlgo alg, const struct iovec *iov, size_t niov, uint8_t **result, diff --git a/crypto/hash-nettle.c b/crypto/hash-nettle.c index 1ca1a41062..8b08a9c675 100644 --- a/crypto/hash-nettle.c +++ b/crypto/hash-nettle.c @@ -50,43 +50,43 @@ struct qcrypto_hash_alg { qcrypto_nettle_result result; size_t len; } qcrypto_hash_alg_map[] =3D { - [QCRYPTO_HASH_ALG_MD5] =3D { + [QCRYPTO_HASH_ALGO_MD5] =3D { .init =3D (qcrypto_nettle_init)md5_init, .write =3D (qcrypto_nettle_write)md5_update, .result =3D (qcrypto_nettle_result)md5_digest, .len =3D MD5_DIGEST_SIZE, }, - [QCRYPTO_HASH_ALG_SHA1] =3D { + [QCRYPTO_HASH_ALGO_SHA1] =3D { .init =3D (qcrypto_nettle_init)sha1_init, .write =3D (qcrypto_nettle_write)sha1_update, .result =3D (qcrypto_nettle_result)sha1_digest, .len =3D SHA1_DIGEST_SIZE, }, - [QCRYPTO_HASH_ALG_SHA224] =3D { + [QCRYPTO_HASH_ALGO_SHA224] =3D { .init =3D (qcrypto_nettle_init)sha224_init, .write =3D (qcrypto_nettle_write)sha224_update, .result =3D (qcrypto_nettle_result)sha224_digest, .len =3D SHA224_DIGEST_SIZE, }, - [QCRYPTO_HASH_ALG_SHA256] =3D { + [QCRYPTO_HASH_ALGO_SHA256] =3D { .init =3D (qcrypto_nettle_init)sha256_init, .write =3D (qcrypto_nettle_write)sha256_update, .result =3D (qcrypto_nettle_result)sha256_digest, .len =3D SHA256_DIGEST_SIZE, }, - [QCRYPTO_HASH_ALG_SHA384] =3D { + [QCRYPTO_HASH_ALGO_SHA384] =3D { .init =3D (qcrypto_nettle_init)sha384_init, .write =3D (qcrypto_nettle_write)sha384_update, .result =3D (qcrypto_nettle_result)sha384_digest, .len =3D SHA384_DIGEST_SIZE, }, - [QCRYPTO_HASH_ALG_SHA512] =3D { + [QCRYPTO_HASH_ALGO_SHA512] =3D { .init =3D (qcrypto_nettle_init)sha512_init, .write =3D (qcrypto_nettle_write)sha512_update, .result =3D (qcrypto_nettle_result)sha512_digest, .len =3D SHA512_DIGEST_SIZE, }, - [QCRYPTO_HASH_ALG_RIPEMD160] =3D { + [QCRYPTO_HASH_ALGO_RIPEMD160] =3D { .init =3D (qcrypto_nettle_init)ripemd160_init, .write =3D (qcrypto_nettle_write)ripemd160_update, .result =3D (qcrypto_nettle_result)ripemd160_digest, @@ -94,7 +94,7 @@ struct qcrypto_hash_alg { }, }; =20 -gboolean qcrypto_hash_supports(QCryptoHashAlgorithm alg) +gboolean qcrypto_hash_supports(QCryptoHashAlgo alg) { if (alg < G_N_ELEMENTS(qcrypto_hash_alg_map) && qcrypto_hash_alg_map[alg].init !=3D NULL) { @@ -105,7 +105,7 @@ gboolean qcrypto_hash_supports(QCryptoHashAlgorithm alg) =20 =20 static int -qcrypto_nettle_hash_bytesv(QCryptoHashAlgorithm alg, +qcrypto_nettle_hash_bytesv(QCryptoHashAlgo alg, const struct iovec *iov, size_t niov, uint8_t **result, diff --git a/crypto/hash.c b/crypto/hash.c index b0f8228bdc..a1ae9be977 100644 --- a/crypto/hash.c +++ b/crypto/hash.c @@ -22,23 +22,23 @@ #include "crypto/hash.h" #include "hashpriv.h" =20 -static size_t qcrypto_hash_alg_size[QCRYPTO_HASH_ALG__MAX] =3D { - [QCRYPTO_HASH_ALG_MD5] =3D 16, - [QCRYPTO_HASH_ALG_SHA1] =3D 20, - [QCRYPTO_HASH_ALG_SHA224] =3D 28, - [QCRYPTO_HASH_ALG_SHA256] =3D 32, - [QCRYPTO_HASH_ALG_SHA384] =3D 48, - [QCRYPTO_HASH_ALG_SHA512] =3D 64, - [QCRYPTO_HASH_ALG_RIPEMD160] =3D 20, +static size_t qcrypto_hash_alg_size[QCRYPTO_HASH_ALGO__MAX] =3D { + [QCRYPTO_HASH_ALGO_MD5] =3D 16, + [QCRYPTO_HASH_ALGO_SHA1] =3D 20, + [QCRYPTO_HASH_ALGO_SHA224] =3D 28, + [QCRYPTO_HASH_ALGO_SHA256] =3D 32, + [QCRYPTO_HASH_ALGO_SHA384] =3D 48, + [QCRYPTO_HASH_ALGO_SHA512] =3D 64, + [QCRYPTO_HASH_ALGO_RIPEMD160] =3D 20, }; =20 -size_t qcrypto_hash_digest_len(QCryptoHashAlgorithm alg) +size_t qcrypto_hash_digest_len(QCryptoHashAlgo alg) { assert(alg < G_N_ELEMENTS(qcrypto_hash_alg_size)); return qcrypto_hash_alg_size[alg]; } =20 -int qcrypto_hash_bytesv(QCryptoHashAlgorithm alg, +int qcrypto_hash_bytesv(QCryptoHashAlgo alg, const struct iovec *iov, size_t niov, uint8_t **result, @@ -65,7 +65,7 @@ int qcrypto_hash_bytesv(QCryptoHashAlgorithm alg, } =20 =20 -int qcrypto_hash_bytes(QCryptoHashAlgorithm alg, +int qcrypto_hash_bytes(QCryptoHashAlgo alg, const char *buf, size_t len, uint8_t **result, @@ -79,7 +79,7 @@ int qcrypto_hash_bytes(QCryptoHashAlgorithm alg, =20 static const char hex[] =3D "0123456789abcdef"; =20 -int qcrypto_hash_digestv(QCryptoHashAlgorithm alg, +int qcrypto_hash_digestv(QCryptoHashAlgo alg, const struct iovec *iov, size_t niov, char **digest, @@ -103,7 +103,7 @@ int qcrypto_hash_digestv(QCryptoHashAlgorithm alg, return 0; } =20 -int qcrypto_hash_digest(QCryptoHashAlgorithm alg, +int qcrypto_hash_digest(QCryptoHashAlgo alg, const char *buf, size_t len, char **digest, @@ -114,7 +114,7 @@ int qcrypto_hash_digest(QCryptoHashAlgorithm alg, return qcrypto_hash_digestv(alg, &iov, 1, digest, errp); } =20 -int qcrypto_hash_base64v(QCryptoHashAlgorithm alg, +int qcrypto_hash_base64v(QCryptoHashAlgo alg, const struct iovec *iov, size_t niov, char **base64, @@ -132,7 +132,7 @@ int qcrypto_hash_base64v(QCryptoHashAlgorithm alg, return 0; } =20 -int qcrypto_hash_base64(QCryptoHashAlgorithm alg, +int qcrypto_hash_base64(QCryptoHashAlgo alg, const char *buf, size_t len, char **base64, diff --git a/crypto/hmac-gcrypt.c b/crypto/hmac-gcrypt.c index 0c6f979711..19990cb6ed 100644 --- a/crypto/hmac-gcrypt.c +++ b/crypto/hmac-gcrypt.c @@ -18,14 +18,14 @@ #include "hmacpriv.h" #include =20 -static int qcrypto_hmac_alg_map[QCRYPTO_HASH_ALG__MAX] =3D { - [QCRYPTO_HASH_ALG_MD5] =3D GCRY_MAC_HMAC_MD5, - [QCRYPTO_HASH_ALG_SHA1] =3D GCRY_MAC_HMAC_SHA1, - [QCRYPTO_HASH_ALG_SHA224] =3D GCRY_MAC_HMAC_SHA224, - [QCRYPTO_HASH_ALG_SHA256] =3D GCRY_MAC_HMAC_SHA256, - [QCRYPTO_HASH_ALG_SHA384] =3D GCRY_MAC_HMAC_SHA384, - [QCRYPTO_HASH_ALG_SHA512] =3D GCRY_MAC_HMAC_SHA512, - [QCRYPTO_HASH_ALG_RIPEMD160] =3D GCRY_MAC_HMAC_RMD160, +static int qcrypto_hmac_alg_map[QCRYPTO_HASH_ALGO__MAX] =3D { + [QCRYPTO_HASH_ALGO_MD5] =3D GCRY_MAC_HMAC_MD5, + [QCRYPTO_HASH_ALGO_SHA1] =3D GCRY_MAC_HMAC_SHA1, + [QCRYPTO_HASH_ALGO_SHA224] =3D GCRY_MAC_HMAC_SHA224, + [QCRYPTO_HASH_ALGO_SHA256] =3D GCRY_MAC_HMAC_SHA256, + [QCRYPTO_HASH_ALGO_SHA384] =3D GCRY_MAC_HMAC_SHA384, + [QCRYPTO_HASH_ALGO_SHA512] =3D GCRY_MAC_HMAC_SHA512, + [QCRYPTO_HASH_ALGO_RIPEMD160] =3D GCRY_MAC_HMAC_RMD160, }; =20 typedef struct QCryptoHmacGcrypt QCryptoHmacGcrypt; @@ -33,7 +33,7 @@ struct QCryptoHmacGcrypt { gcry_mac_hd_t handle; }; =20 -bool qcrypto_hmac_supports(QCryptoHashAlgorithm alg) +bool qcrypto_hmac_supports(QCryptoHashAlgo alg) { if (alg < G_N_ELEMENTS(qcrypto_hmac_alg_map) && qcrypto_hmac_alg_map[alg] !=3D GCRY_MAC_NONE) { @@ -43,7 +43,7 @@ bool qcrypto_hmac_supports(QCryptoHashAlgorithm alg) return false; } =20 -void *qcrypto_hmac_ctx_new(QCryptoHashAlgorithm alg, +void *qcrypto_hmac_ctx_new(QCryptoHashAlgo alg, const uint8_t *key, size_t nkey, Error **errp) { @@ -52,7 +52,7 @@ void *qcrypto_hmac_ctx_new(QCryptoHashAlgorithm alg, =20 if (!qcrypto_hmac_supports(alg)) { error_setg(errp, "Unsupported hmac algorithm %s", - QCryptoHashAlgorithm_str(alg)); + QCryptoHashAlgo_str(alg)); return NULL; } =20 diff --git a/crypto/hmac-glib.c b/crypto/hmac-glib.c index 509bbc74c2..ea80c8d1b2 100644 --- a/crypto/hmac-glib.c +++ b/crypto/hmac-glib.c @@ -17,14 +17,14 @@ #include "crypto/hmac.h" #include "hmacpriv.h" =20 -static int qcrypto_hmac_alg_map[QCRYPTO_HASH_ALG__MAX] =3D { - [QCRYPTO_HASH_ALG_MD5] =3D G_CHECKSUM_MD5, - [QCRYPTO_HASH_ALG_SHA1] =3D G_CHECKSUM_SHA1, - [QCRYPTO_HASH_ALG_SHA256] =3D G_CHECKSUM_SHA256, - [QCRYPTO_HASH_ALG_SHA512] =3D G_CHECKSUM_SHA512, - [QCRYPTO_HASH_ALG_SHA224] =3D -1, - [QCRYPTO_HASH_ALG_SHA384] =3D -1, - [QCRYPTO_HASH_ALG_RIPEMD160] =3D -1, +static int qcrypto_hmac_alg_map[QCRYPTO_HASH_ALGO__MAX] =3D { + [QCRYPTO_HASH_ALGO_MD5] =3D G_CHECKSUM_MD5, + [QCRYPTO_HASH_ALGO_SHA1] =3D G_CHECKSUM_SHA1, + [QCRYPTO_HASH_ALGO_SHA256] =3D G_CHECKSUM_SHA256, + [QCRYPTO_HASH_ALGO_SHA512] =3D G_CHECKSUM_SHA512, + [QCRYPTO_HASH_ALGO_SHA224] =3D -1, + [QCRYPTO_HASH_ALGO_SHA384] =3D -1, + [QCRYPTO_HASH_ALGO_RIPEMD160] =3D -1, }; =20 typedef struct QCryptoHmacGlib QCryptoHmacGlib; @@ -32,7 +32,7 @@ struct QCryptoHmacGlib { GHmac *ghmac; }; =20 -bool qcrypto_hmac_supports(QCryptoHashAlgorithm alg) +bool qcrypto_hmac_supports(QCryptoHashAlgo alg) { if (alg < G_N_ELEMENTS(qcrypto_hmac_alg_map) && qcrypto_hmac_alg_map[alg] !=3D -1) { @@ -42,7 +42,7 @@ bool qcrypto_hmac_supports(QCryptoHashAlgorithm alg) return false; } =20 -void *qcrypto_hmac_ctx_new(QCryptoHashAlgorithm alg, +void *qcrypto_hmac_ctx_new(QCryptoHashAlgo alg, const uint8_t *key, size_t nkey, Error **errp) { @@ -50,7 +50,7 @@ void *qcrypto_hmac_ctx_new(QCryptoHashAlgorithm alg, =20 if (!qcrypto_hmac_supports(alg)) { error_setg(errp, "Unsupported hmac algorithm %s", - QCryptoHashAlgorithm_str(alg)); + QCryptoHashAlgo_str(alg)); return NULL; } =20 diff --git a/crypto/hmac-gnutls.c b/crypto/hmac-gnutls.c index 24db383322..822995505c 100644 --- a/crypto/hmac-gnutls.c +++ b/crypto/hmac-gnutls.c @@ -20,14 +20,14 @@ #include "crypto/hmac.h" #include "hmacpriv.h" =20 -static int qcrypto_hmac_alg_map[QCRYPTO_HASH_ALG__MAX] =3D { - [QCRYPTO_HASH_ALG_MD5] =3D GNUTLS_MAC_MD5, - [QCRYPTO_HASH_ALG_SHA1] =3D GNUTLS_MAC_SHA1, - [QCRYPTO_HASH_ALG_SHA224] =3D GNUTLS_MAC_SHA224, - [QCRYPTO_HASH_ALG_SHA256] =3D GNUTLS_MAC_SHA256, - [QCRYPTO_HASH_ALG_SHA384] =3D GNUTLS_MAC_SHA384, - [QCRYPTO_HASH_ALG_SHA512] =3D GNUTLS_MAC_SHA512, - [QCRYPTO_HASH_ALG_RIPEMD160] =3D GNUTLS_MAC_RMD160, +static int qcrypto_hmac_alg_map[QCRYPTO_HASH_ALGO__MAX] =3D { + [QCRYPTO_HASH_ALGO_MD5] =3D GNUTLS_MAC_MD5, + [QCRYPTO_HASH_ALGO_SHA1] =3D GNUTLS_MAC_SHA1, + [QCRYPTO_HASH_ALGO_SHA224] =3D GNUTLS_MAC_SHA224, + [QCRYPTO_HASH_ALGO_SHA256] =3D GNUTLS_MAC_SHA256, + [QCRYPTO_HASH_ALGO_SHA384] =3D GNUTLS_MAC_SHA384, + [QCRYPTO_HASH_ALGO_SHA512] =3D GNUTLS_MAC_SHA512, + [QCRYPTO_HASH_ALGO_RIPEMD160] =3D GNUTLS_MAC_RMD160, }; =20 typedef struct QCryptoHmacGnutls QCryptoHmacGnutls; @@ -35,7 +35,7 @@ struct QCryptoHmacGnutls { gnutls_hmac_hd_t handle; }; =20 -bool qcrypto_hmac_supports(QCryptoHashAlgorithm alg) +bool qcrypto_hmac_supports(QCryptoHashAlgo alg) { size_t i; const gnutls_digest_algorithm_t *algs; @@ -52,7 +52,7 @@ bool qcrypto_hmac_supports(QCryptoHashAlgorithm alg) return false; } =20 -void *qcrypto_hmac_ctx_new(QCryptoHashAlgorithm alg, +void *qcrypto_hmac_ctx_new(QCryptoHashAlgo alg, const uint8_t *key, size_t nkey, Error **errp) { @@ -61,7 +61,7 @@ void *qcrypto_hmac_ctx_new(QCryptoHashAlgorithm alg, =20 if (!qcrypto_hmac_supports(alg)) { error_setg(errp, "Unsupported hmac algorithm %s", - QCryptoHashAlgorithm_str(alg)); + QCryptoHashAlgo_str(alg)); return NULL; } =20 diff --git a/crypto/hmac-nettle.c b/crypto/hmac-nettle.c index 1ad6c4f253..54dd75d5ff 100644 --- a/crypto/hmac-nettle.c +++ b/crypto/hmac-nettle.c @@ -46,44 +46,44 @@ struct qcrypto_nettle_hmac_alg { qcrypto_nettle_hmac_update update; qcrypto_nettle_hmac_digest digest; size_t len; -} qcrypto_hmac_alg_map[QCRYPTO_HASH_ALG__MAX] =3D { - [QCRYPTO_HASH_ALG_MD5] =3D { +} qcrypto_hmac_alg_map[QCRYPTO_HASH_ALGO__MAX] =3D { + [QCRYPTO_HASH_ALGO_MD5] =3D { .setkey =3D (qcrypto_nettle_hmac_setkey)hmac_md5_set_key, .update =3D (qcrypto_nettle_hmac_update)hmac_md5_update, .digest =3D (qcrypto_nettle_hmac_digest)hmac_md5_digest, .len =3D MD5_DIGEST_SIZE, }, - [QCRYPTO_HASH_ALG_SHA1] =3D { + [QCRYPTO_HASH_ALGO_SHA1] =3D { .setkey =3D (qcrypto_nettle_hmac_setkey)hmac_sha1_set_key, .update =3D (qcrypto_nettle_hmac_update)hmac_sha1_update, .digest =3D (qcrypto_nettle_hmac_digest)hmac_sha1_digest, .len =3D SHA1_DIGEST_SIZE, }, - [QCRYPTO_HASH_ALG_SHA224] =3D { + [QCRYPTO_HASH_ALGO_SHA224] =3D { .setkey =3D (qcrypto_nettle_hmac_setkey)hmac_sha224_set_key, .update =3D (qcrypto_nettle_hmac_update)hmac_sha224_update, .digest =3D (qcrypto_nettle_hmac_digest)hmac_sha224_digest, .len =3D SHA224_DIGEST_SIZE, }, - [QCRYPTO_HASH_ALG_SHA256] =3D { + [QCRYPTO_HASH_ALGO_SHA256] =3D { .setkey =3D (qcrypto_nettle_hmac_setkey)hmac_sha256_set_key, .update =3D (qcrypto_nettle_hmac_update)hmac_sha256_update, .digest =3D (qcrypto_nettle_hmac_digest)hmac_sha256_digest, .len =3D SHA256_DIGEST_SIZE, }, - [QCRYPTO_HASH_ALG_SHA384] =3D { + [QCRYPTO_HASH_ALGO_SHA384] =3D { .setkey =3D (qcrypto_nettle_hmac_setkey)hmac_sha384_set_key, .update =3D (qcrypto_nettle_hmac_update)hmac_sha384_update, .digest =3D (qcrypto_nettle_hmac_digest)hmac_sha384_digest, .len =3D SHA384_DIGEST_SIZE, }, - [QCRYPTO_HASH_ALG_SHA512] =3D { + [QCRYPTO_HASH_ALGO_SHA512] =3D { .setkey =3D (qcrypto_nettle_hmac_setkey)hmac_sha512_set_key, .update =3D (qcrypto_nettle_hmac_update)hmac_sha512_update, .digest =3D (qcrypto_nettle_hmac_digest)hmac_sha512_digest, .len =3D SHA512_DIGEST_SIZE, }, - [QCRYPTO_HASH_ALG_RIPEMD160] =3D { + [QCRYPTO_HASH_ALGO_RIPEMD160] =3D { .setkey =3D (qcrypto_nettle_hmac_setkey)hmac_ripemd160_set_key, .update =3D (qcrypto_nettle_hmac_update)hmac_ripemd160_update, .digest =3D (qcrypto_nettle_hmac_digest)hmac_ripemd160_digest, @@ -91,7 +91,7 @@ struct qcrypto_nettle_hmac_alg { }, }; =20 -bool qcrypto_hmac_supports(QCryptoHashAlgorithm alg) +bool qcrypto_hmac_supports(QCryptoHashAlgo alg) { if (alg < G_N_ELEMENTS(qcrypto_hmac_alg_map) && qcrypto_hmac_alg_map[alg].setkey !=3D NULL) { @@ -101,7 +101,7 @@ bool qcrypto_hmac_supports(QCryptoHashAlgorithm alg) return false; } =20 -void *qcrypto_hmac_ctx_new(QCryptoHashAlgorithm alg, +void *qcrypto_hmac_ctx_new(QCryptoHashAlgo alg, const uint8_t *key, size_t nkey, Error **errp) { @@ -109,7 +109,7 @@ void *qcrypto_hmac_ctx_new(QCryptoHashAlgorithm alg, =20 if (!qcrypto_hmac_supports(alg)) { error_setg(errp, "Unsupported hmac algorithm %s", - QCryptoHashAlgorithm_str(alg)); + QCryptoHashAlgo_str(alg)); return NULL; } =20 diff --git a/crypto/hmac.c b/crypto/hmac.c index 4de7e8c9cb..422e005182 100644 --- a/crypto/hmac.c +++ b/crypto/hmac.c @@ -83,7 +83,7 @@ int qcrypto_hmac_digest(QCryptoHmac *hmac, return qcrypto_hmac_digestv(hmac, &iov, 1, digest, errp); } =20 -QCryptoHmac *qcrypto_hmac_new(QCryptoHashAlgorithm alg, +QCryptoHmac *qcrypto_hmac_new(QCryptoHashAlgo alg, const uint8_t *key, size_t nkey, Error **errp) { diff --git a/crypto/ivgen.c b/crypto/ivgen.c index 12822f8519..080846cb74 100644 --- a/crypto/ivgen.c +++ b/crypto/ivgen.c @@ -29,7 +29,7 @@ =20 QCryptoIVGen *qcrypto_ivgen_new(QCryptoIVGenAlgorithm alg, QCryptoCipherAlgorithm cipheralg, - QCryptoHashAlgorithm hash, + QCryptoHashAlgo hash, const uint8_t *key, size_t nkey, Error **errp) { @@ -85,7 +85,7 @@ QCryptoCipherAlgorithm qcrypto_ivgen_get_cipher(QCryptoIV= Gen *ivgen) } =20 =20 -QCryptoHashAlgorithm qcrypto_ivgen_get_hash(QCryptoIVGen *ivgen) +QCryptoHashAlgo qcrypto_ivgen_get_hash(QCryptoIVGen *ivgen) { return ivgen->hash; } diff --git a/crypto/pbkdf-gcrypt.c b/crypto/pbkdf-gcrypt.c index a8d8e64f4d..d4230c0f9c 100644 --- a/crypto/pbkdf-gcrypt.c +++ b/crypto/pbkdf-gcrypt.c @@ -23,37 +23,37 @@ #include "qapi/error.h" #include "crypto/pbkdf.h" =20 -bool qcrypto_pbkdf2_supports(QCryptoHashAlgorithm hash) +bool qcrypto_pbkdf2_supports(QCryptoHashAlgo hash) { switch (hash) { - case QCRYPTO_HASH_ALG_MD5: - case QCRYPTO_HASH_ALG_SHA1: - case QCRYPTO_HASH_ALG_SHA224: - case QCRYPTO_HASH_ALG_SHA256: - case QCRYPTO_HASH_ALG_SHA384: - case QCRYPTO_HASH_ALG_SHA512: - case QCRYPTO_HASH_ALG_RIPEMD160: + case QCRYPTO_HASH_ALGO_MD5: + case QCRYPTO_HASH_ALGO_SHA1: + case QCRYPTO_HASH_ALGO_SHA224: + case QCRYPTO_HASH_ALGO_SHA256: + case QCRYPTO_HASH_ALGO_SHA384: + case QCRYPTO_HASH_ALGO_SHA512: + case QCRYPTO_HASH_ALGO_RIPEMD160: return true; default: return false; } } =20 -int qcrypto_pbkdf2(QCryptoHashAlgorithm hash, +int qcrypto_pbkdf2(QCryptoHashAlgo hash, const uint8_t *key, size_t nkey, const uint8_t *salt, size_t nsalt, uint64_t iterations, uint8_t *out, size_t nout, Error **errp) { - static const int hash_map[QCRYPTO_HASH_ALG__MAX] =3D { - [QCRYPTO_HASH_ALG_MD5] =3D GCRY_MD_MD5, - [QCRYPTO_HASH_ALG_SHA1] =3D GCRY_MD_SHA1, - [QCRYPTO_HASH_ALG_SHA224] =3D GCRY_MD_SHA224, - [QCRYPTO_HASH_ALG_SHA256] =3D GCRY_MD_SHA256, - [QCRYPTO_HASH_ALG_SHA384] =3D GCRY_MD_SHA384, - [QCRYPTO_HASH_ALG_SHA512] =3D GCRY_MD_SHA512, - [QCRYPTO_HASH_ALG_RIPEMD160] =3D GCRY_MD_RMD160, + static const int hash_map[QCRYPTO_HASH_ALGO__MAX] =3D { + [QCRYPTO_HASH_ALGO_MD5] =3D GCRY_MD_MD5, + [QCRYPTO_HASH_ALGO_SHA1] =3D GCRY_MD_SHA1, + [QCRYPTO_HASH_ALGO_SHA224] =3D GCRY_MD_SHA224, + [QCRYPTO_HASH_ALGO_SHA256] =3D GCRY_MD_SHA256, + [QCRYPTO_HASH_ALGO_SHA384] =3D GCRY_MD_SHA384, + [QCRYPTO_HASH_ALGO_SHA512] =3D GCRY_MD_SHA512, + [QCRYPTO_HASH_ALGO_RIPEMD160] =3D GCRY_MD_RMD160, }; int ret; =20 @@ -68,7 +68,7 @@ int qcrypto_pbkdf2(QCryptoHashAlgorithm hash, hash_map[hash] =3D=3D GCRY_MD_NONE) { error_setg_errno(errp, ENOSYS, "PBKDF does not support hash algorithm %s", - QCryptoHashAlgorithm_str(hash)); + QCryptoHashAlgo_str(hash)); return -1; } =20 diff --git a/crypto/pbkdf-gnutls.c b/crypto/pbkdf-gnutls.c index 2dfbbd382c..68ed77f437 100644 --- a/crypto/pbkdf-gnutls.c +++ b/crypto/pbkdf-gnutls.c @@ -23,37 +23,37 @@ #include "qapi/error.h" #include "crypto/pbkdf.h" =20 -bool qcrypto_pbkdf2_supports(QCryptoHashAlgorithm hash) +bool qcrypto_pbkdf2_supports(QCryptoHashAlgo hash) { switch (hash) { - case QCRYPTO_HASH_ALG_MD5: - case QCRYPTO_HASH_ALG_SHA1: - case QCRYPTO_HASH_ALG_SHA224: - case QCRYPTO_HASH_ALG_SHA256: - case QCRYPTO_HASH_ALG_SHA384: - case QCRYPTO_HASH_ALG_SHA512: - case QCRYPTO_HASH_ALG_RIPEMD160: + case QCRYPTO_HASH_ALGO_MD5: + case QCRYPTO_HASH_ALGO_SHA1: + case QCRYPTO_HASH_ALGO_SHA224: + case QCRYPTO_HASH_ALGO_SHA256: + case QCRYPTO_HASH_ALGO_SHA384: + case QCRYPTO_HASH_ALGO_SHA512: + case QCRYPTO_HASH_ALGO_RIPEMD160: return true; default: return false; } } =20 -int qcrypto_pbkdf2(QCryptoHashAlgorithm hash, +int qcrypto_pbkdf2(QCryptoHashAlgo hash, const uint8_t *key, size_t nkey, const uint8_t *salt, size_t nsalt, uint64_t iterations, uint8_t *out, size_t nout, Error **errp) { - static const int hash_map[QCRYPTO_HASH_ALG__MAX] =3D { - [QCRYPTO_HASH_ALG_MD5] =3D GNUTLS_DIG_MD5, - [QCRYPTO_HASH_ALG_SHA1] =3D GNUTLS_DIG_SHA1, - [QCRYPTO_HASH_ALG_SHA224] =3D GNUTLS_DIG_SHA224, - [QCRYPTO_HASH_ALG_SHA256] =3D GNUTLS_DIG_SHA256, - [QCRYPTO_HASH_ALG_SHA384] =3D GNUTLS_DIG_SHA384, - [QCRYPTO_HASH_ALG_SHA512] =3D GNUTLS_DIG_SHA512, - [QCRYPTO_HASH_ALG_RIPEMD160] =3D GNUTLS_DIG_RMD160, + static const int hash_map[QCRYPTO_HASH_ALGO__MAX] =3D { + [QCRYPTO_HASH_ALGO_MD5] =3D GNUTLS_DIG_MD5, + [QCRYPTO_HASH_ALGO_SHA1] =3D GNUTLS_DIG_SHA1, + [QCRYPTO_HASH_ALGO_SHA224] =3D GNUTLS_DIG_SHA224, + [QCRYPTO_HASH_ALGO_SHA256] =3D GNUTLS_DIG_SHA256, + [QCRYPTO_HASH_ALGO_SHA384] =3D GNUTLS_DIG_SHA384, + [QCRYPTO_HASH_ALGO_SHA512] =3D GNUTLS_DIG_SHA512, + [QCRYPTO_HASH_ALGO_RIPEMD160] =3D GNUTLS_DIG_RMD160, }; int ret; const gnutls_datum_t gkey =3D { (unsigned char *)key, nkey }; @@ -70,7 +70,7 @@ int qcrypto_pbkdf2(QCryptoHashAlgorithm hash, hash_map[hash] =3D=3D GNUTLS_DIG_UNKNOWN) { error_setg_errno(errp, ENOSYS, "PBKDF does not support hash algorithm %s", - QCryptoHashAlgorithm_str(hash)); + QCryptoHashAlgo_str(hash)); return -1; } =20 diff --git a/crypto/pbkdf-nettle.c b/crypto/pbkdf-nettle.c index d6293c25a1..93e686c2c6 100644 --- a/crypto/pbkdf-nettle.c +++ b/crypto/pbkdf-nettle.c @@ -25,22 +25,22 @@ #include "crypto/pbkdf.h" =20 =20 -bool qcrypto_pbkdf2_supports(QCryptoHashAlgorithm hash) +bool qcrypto_pbkdf2_supports(QCryptoHashAlgo hash) { switch (hash) { - case QCRYPTO_HASH_ALG_SHA1: - case QCRYPTO_HASH_ALG_SHA224: - case QCRYPTO_HASH_ALG_SHA256: - case QCRYPTO_HASH_ALG_SHA384: - case QCRYPTO_HASH_ALG_SHA512: - case QCRYPTO_HASH_ALG_RIPEMD160: + case QCRYPTO_HASH_ALGO_SHA1: + case QCRYPTO_HASH_ALGO_SHA224: + case QCRYPTO_HASH_ALGO_SHA256: + case QCRYPTO_HASH_ALGO_SHA384: + case QCRYPTO_HASH_ALGO_SHA512: + case QCRYPTO_HASH_ALGO_RIPEMD160: return true; default: return false; } } =20 -int qcrypto_pbkdf2(QCryptoHashAlgorithm hash, +int qcrypto_pbkdf2(QCryptoHashAlgo hash, const uint8_t *key, size_t nkey, const uint8_t *salt, size_t nsalt, uint64_t iterations, @@ -65,43 +65,43 @@ int qcrypto_pbkdf2(QCryptoHashAlgorithm hash, } =20 switch (hash) { - case QCRYPTO_HASH_ALG_MD5: + case QCRYPTO_HASH_ALGO_MD5: hmac_md5_set_key(&ctx.md5, nkey, key); PBKDF2(&ctx.md5, hmac_md5_update, hmac_md5_digest, MD5_DIGEST_SIZE, iterations, nsalt, salt, nout, out); break; =20 - case QCRYPTO_HASH_ALG_SHA1: + case QCRYPTO_HASH_ALGO_SHA1: hmac_sha1_set_key(&ctx.sha1, nkey, key); PBKDF2(&ctx.sha1, hmac_sha1_update, hmac_sha1_digest, SHA1_DIGEST_SIZE, iterations, nsalt, salt, nout, out); break; =20 - case QCRYPTO_HASH_ALG_SHA224: + case QCRYPTO_HASH_ALGO_SHA224: hmac_sha224_set_key(&ctx.sha224, nkey, key); PBKDF2(&ctx.sha224, hmac_sha224_update, hmac_sha224_digest, SHA224_DIGEST_SIZE, iterations, nsalt, salt, nout, out); break; =20 - case QCRYPTO_HASH_ALG_SHA256: + case QCRYPTO_HASH_ALGO_SHA256: hmac_sha256_set_key(&ctx.sha256, nkey, key); PBKDF2(&ctx.sha256, hmac_sha256_update, hmac_sha256_digest, SHA256_DIGEST_SIZE, iterations, nsalt, salt, nout, out); break; =20 - case QCRYPTO_HASH_ALG_SHA384: + case QCRYPTO_HASH_ALGO_SHA384: hmac_sha384_set_key(&ctx.sha384, nkey, key); PBKDF2(&ctx.sha384, hmac_sha384_update, hmac_sha384_digest, SHA384_DIGEST_SIZE, iterations, nsalt, salt, nout, out); break; =20 - case QCRYPTO_HASH_ALG_SHA512: + case QCRYPTO_HASH_ALGO_SHA512: hmac_sha512_set_key(&ctx.sha512, nkey, key); PBKDF2(&ctx.sha512, hmac_sha512_update, hmac_sha512_digest, SHA512_DIGEST_SIZE, iterations, nsalt, salt, nout, out); break; =20 - case QCRYPTO_HASH_ALG_RIPEMD160: + case QCRYPTO_HASH_ALGO_RIPEMD160: hmac_ripemd160_set_key(&ctx.ripemd160, nkey, key); PBKDF2(&ctx.ripemd160, hmac_ripemd160_update, hmac_ripemd160_diges= t, RIPEMD160_DIGEST_SIZE, iterations, nsalt, salt, nout, out); @@ -110,7 +110,7 @@ int qcrypto_pbkdf2(QCryptoHashAlgorithm hash, default: error_setg_errno(errp, ENOSYS, "PBKDF does not support hash algorithm %s", - QCryptoHashAlgorithm_str(hash)); + QCryptoHashAlgo_str(hash)); return -1; } return 0; diff --git a/crypto/pbkdf-stub.c b/crypto/pbkdf-stub.c index 9c4622e424..9f29d0eed7 100644 --- a/crypto/pbkdf-stub.c +++ b/crypto/pbkdf-stub.c @@ -22,12 +22,12 @@ #include "qapi/error.h" #include "crypto/pbkdf.h" =20 -bool qcrypto_pbkdf2_supports(QCryptoHashAlgorithm hash G_GNUC_UNUSED) +bool qcrypto_pbkdf2_supports(QCryptoHashAlgo hash G_GNUC_UNUSED) { return false; } =20 -int qcrypto_pbkdf2(QCryptoHashAlgorithm hash G_GNUC_UNUSED, +int qcrypto_pbkdf2(QCryptoHashAlgo hash G_GNUC_UNUSED, const uint8_t *key G_GNUC_UNUSED, size_t nkey G_GNUC_UNUSED, const uint8_t *salt G_GNUC_UNUSED, diff --git a/crypto/pbkdf.c b/crypto/pbkdf.c index 8d198c152c..051dbbbd2e 100644 --- a/crypto/pbkdf.c +++ b/crypto/pbkdf.c @@ -85,7 +85,7 @@ static int qcrypto_pbkdf2_get_thread_cpu(unsigned long lo= ng *val_ms, #endif } =20 -uint64_t qcrypto_pbkdf2_count_iters(QCryptoHashAlgorithm hash, +uint64_t qcrypto_pbkdf2_count_iters(QCryptoHashAlgo hash, const uint8_t *key, size_t nkey, const uint8_t *salt, size_t nsalt, size_t nout, diff --git a/hw/misc/aspeed_hace.c b/hw/misc/aspeed_hace.c index c06c04ddc6..3541adf813 100644 --- a/hw/misc/aspeed_hace.c +++ b/hw/misc/aspeed_hace.c @@ -68,15 +68,15 @@ =20 static const struct { uint32_t mask; - QCryptoHashAlgorithm algo; + QCryptoHashAlgo algo; } hash_algo_map[] =3D { - { HASH_ALGO_MD5, QCRYPTO_HASH_ALG_MD5 }, - { HASH_ALGO_SHA1, QCRYPTO_HASH_ALG_SHA1 }, - { HASH_ALGO_SHA224, QCRYPTO_HASH_ALG_SHA224 }, - { HASH_ALGO_SHA256, QCRYPTO_HASH_ALG_SHA256 }, - { HASH_ALGO_SHA512_SERIES | HASH_ALGO_SHA512_SHA512, QCRYPTO_HASH_ALG_= SHA512 }, - { HASH_ALGO_SHA512_SERIES | HASH_ALGO_SHA512_SHA384, QCRYPTO_HASH_ALG_= SHA384 }, - { HASH_ALGO_SHA512_SERIES | HASH_ALGO_SHA512_SHA256, QCRYPTO_HASH_ALG_= SHA256 }, + { HASH_ALGO_MD5, QCRYPTO_HASH_ALGO_MD5 }, + { HASH_ALGO_SHA1, QCRYPTO_HASH_ALGO_SHA1 }, + { HASH_ALGO_SHA224, QCRYPTO_HASH_ALGO_SHA224 }, + { HASH_ALGO_SHA256, QCRYPTO_HASH_ALGO_SHA256 }, + { HASH_ALGO_SHA512_SERIES | HASH_ALGO_SHA512_SHA512, QCRYPTO_HASH_ALGO= _SHA512 }, + { HASH_ALGO_SHA512_SERIES | HASH_ALGO_SHA512_SHA384, QCRYPTO_HASH_ALGO= _SHA384 }, + { HASH_ALGO_SHA512_SERIES | HASH_ALGO_SHA512_SHA256, QCRYPTO_HASH_ALGO= _SHA256 }, }; =20 static int hash_algo_lookup(uint32_t reg) diff --git a/io/channel-websock.c b/io/channel-websock.c index de39f0d182..55192b770a 100644 --- a/io/channel-websock.c +++ b/io/channel-websock.c @@ -351,7 +351,7 @@ static void qio_channel_websock_handshake_send_res_ok(Q= IOChannelWebsock *ioc, QIO_CHANNEL_WEBSOCK_GUID_LEN + 1); =20 /* hash and encode it */ - if (qcrypto_hash_base64(QCRYPTO_HASH_ALG_SHA1, + if (qcrypto_hash_base64(QCRYPTO_HASH_ALGO_SHA1, combined_key, QIO_CHANNEL_WEBSOCK_CLIENT_KEY_LEN + QIO_CHANNEL_WEBSOCK_GUID_LEN, diff --git a/target/i386/sev.c b/target/i386/sev.c index a0d271f898..1a4eb1ada6 100644 --- a/target/i386/sev.c +++ b/target/i386/sev.c @@ -1883,7 +1883,7 @@ static bool build_kernel_loader_hashes(PaddedSevHashT= able *padded_ht, * be used. */ hashp =3D cmdline_hash; - if (qcrypto_hash_bytes(QCRYPTO_HASH_ALG_SHA256, ctx->cmdline_data, + if (qcrypto_hash_bytes(QCRYPTO_HASH_ALGO_SHA256, ctx->cmdline_data, ctx->cmdline_size, &hashp, &hash_len, errp) < 0= ) { return false; } @@ -1894,7 +1894,7 @@ static bool build_kernel_loader_hashes(PaddedSevHashT= able *padded_ht, * -initrd, an empty buffer will be used (ctx->initrd_size =3D=3D 0). */ hashp =3D initrd_hash; - if (qcrypto_hash_bytes(QCRYPTO_HASH_ALG_SHA256, ctx->initrd_data, + if (qcrypto_hash_bytes(QCRYPTO_HASH_ALGO_SHA256, ctx->initrd_data, ctx->initrd_size, &hashp, &hash_len, errp) < 0)= { return false; } @@ -1906,7 +1906,7 @@ static bool build_kernel_loader_hashes(PaddedSevHashT= able *padded_ht, { .iov_base =3D ctx->setup_data, .iov_len =3D ctx->setup_size }, { .iov_base =3D ctx->kernel_data, .iov_len =3D ctx->kernel_size } }; - if (qcrypto_hash_bytesv(QCRYPTO_HASH_ALG_SHA256, iov, ARRAY_SIZE(iov), + if (qcrypto_hash_bytesv(QCRYPTO_HASH_ALGO_SHA256, iov, ARRAY_SIZE(iov), &hashp, &hash_len, errp) < 0) { return false; } diff --git a/tests/bench/benchmark-crypto-akcipher.c b/tests/bench/benchmar= k-crypto-akcipher.c index bbc29c9b12..0029972385 100644 --- a/tests/bench/benchmark-crypto-akcipher.c +++ b/tests/bench/benchmark-crypto-akcipher.c @@ -21,7 +21,7 @@ static QCryptoAkCipher *create_rsa_akcipher(const uint8_t *priv_key, size_t keylen, QCryptoRSAPaddingAlgorithm pad= ding, - QCryptoHashAlgorithm hash) + QCryptoHashAlgo hash) { QCryptoAkCipherOptions opt; =20 @@ -40,7 +40,7 @@ static void test_rsa_speed(const uint8_t *priv_key, size_= t keylen, #define SIGN_TIMES 10000 #define VERIFY_TIMES 100000 #define PADDING QCRYPTO_RSA_PADDING_ALG_PKCS1 -#define HASH QCRYPTO_HASH_ALG_SHA1 +#define HASH QCRYPTO_HASH_ALGO_SHA1 =20 g_autoptr(QCryptoAkCipher) rsa =3D create_rsa_akcipher(priv_key, keylen, PADDING, HASH); @@ -54,7 +54,7 @@ static void test_rsa_speed(const uint8_t *priv_key, size_= t keylen, =20 g_test_message("benchmark rsa%zu (%s-%s) sign...", key_size, QCryptoRSAPaddingAlgorithm_str(PADDING), - QCryptoHashAlgorithm_str(HASH)); + QCryptoHashAlgo_str(HASH)); g_test_timer_start(); for (count =3D 0; count < SIGN_TIMES; ++count) { g_assert(qcrypto_akcipher_sign(rsa, dgst, SHA1_DGST_LEN, @@ -65,13 +65,13 @@ static void test_rsa_speed(const uint8_t *priv_key, siz= e_t keylen, g_test_message("rsa%zu (%s-%s) sign %zu times in %.2f seconds," " %.2f times/sec ", key_size, QCryptoRSAPaddingAlgorithm_str(PADDING), - QCryptoHashAlgorithm_str(HASH), + QCryptoHashAlgo_str(HASH), count, g_test_timer_last(), (double)count / g_test_timer_last()); =20 g_test_message("benchmark rsa%zu (%s-%s) verification...", key_size, QCryptoRSAPaddingAlgorithm_str(PADDING), - QCryptoHashAlgorithm_str(HASH)); + QCryptoHashAlgo_str(HASH)); g_test_timer_start(); for (count =3D 0; count < VERIFY_TIMES; ++count) { g_assert(qcrypto_akcipher_verify(rsa, signature, key_size / BYTE, @@ -82,7 +82,7 @@ static void test_rsa_speed(const uint8_t *priv_key, size_= t keylen, g_test_message("rsa%zu (%s-%s) verify %zu times in %.2f seconds," " %.2f times/sec ", key_size, QCryptoRSAPaddingAlgorithm_str(PADDING), - QCryptoHashAlgorithm_str(HASH), + QCryptoHashAlgo_str(HASH), count, g_test_timer_last(), (double)count / g_test_timer_last()); } diff --git a/tests/bench/benchmark-crypto-hash.c b/tests/bench/benchmark-cr= ypto-hash.c index 927b00bb4d..252098a69d 100644 --- a/tests/bench/benchmark-crypto-hash.c +++ b/tests/bench/benchmark-crypto-hash.c @@ -17,7 +17,7 @@ =20 typedef struct QCryptoHashOpts { size_t chunk_size; - QCryptoHashAlgorithm alg; + QCryptoHashAlgo alg; } QCryptoHashOpts; =20 static void test_hash_speed(const void *opaque) @@ -49,7 +49,7 @@ static void test_hash_speed(const void *opaque) g_test_timer_elapsed(); =20 g_test_message("hash(%s): chunk %zu bytes %.2f MB/sec", - QCryptoHashAlgorithm_str(opts->alg), + QCryptoHashAlgo_str(opts->alg), opts->chunk_size, total / g_test_timer_last()); =20 g_free(out); @@ -65,14 +65,14 @@ int main(int argc, char **argv) =20 #define TEST_ONE(a, c) \ QCryptoHashOpts opts ## a ## c =3D { \ - .alg =3D QCRYPTO_HASH_ALG_ ## a, .chunk_size =3D c, \ + .alg =3D QCRYPTO_HASH_ALGO_ ## a, .chunk_size =3D c, \ }; \ memset(name, 0 , sizeof(name)); \ snprintf(name, sizeof(name), \ "/crypto/benchmark/hash/%s/bufsize-%d", \ - QCryptoHashAlgorithm_str(QCRYPTO_HASH_ALG_ ## a), \ + QCryptoHashAlgo_str(QCRYPTO_HASH_ALGO_ ## a), \ c); \ - if (qcrypto_hash_supports(QCRYPTO_HASH_ALG_ ## a)) \ + if (qcrypto_hash_supports(QCRYPTO_HASH_ALGO_ ## a)) \ g_test_add_data_func(name, \ &opts ## a ## c, \ test_hash_speed); diff --git a/tests/bench/benchmark-crypto-hmac.c b/tests/bench/benchmark-cr= ypto-hmac.c index 5cca636789..d51de98f47 100644 --- a/tests/bench/benchmark-crypto-hmac.c +++ b/tests/bench/benchmark-crypto-hmac.c @@ -28,7 +28,7 @@ static void test_hmac_speed(const void *opaque) Error *err =3D NULL; int ret; =20 - if (!qcrypto_hmac_supports(QCRYPTO_HASH_ALG_SHA256)) { + if (!qcrypto_hmac_supports(QCRYPTO_HASH_ALGO_SHA256)) { return; } =20 @@ -40,7 +40,7 @@ static void test_hmac_speed(const void *opaque) =20 g_test_timer_start(); do { - hmac =3D qcrypto_hmac_new(QCRYPTO_HASH_ALG_SHA256, + hmac =3D qcrypto_hmac_new(QCRYPTO_HASH_ALGO_SHA256, (const uint8_t *)KEY, strlen(KEY), &err); g_assert(err =3D=3D NULL); g_assert(hmac !=3D NULL); @@ -56,7 +56,7 @@ static void test_hmac_speed(const void *opaque) =20 total /=3D MiB; g_test_message("hmac(%s): chunk %zu bytes %.2f MB/sec", - QCryptoHashAlgorithm_str(QCRYPTO_HASH_ALG_SHA256), + QCryptoHashAlgo_str(QCRYPTO_HASH_ALGO_SHA256), chunk_size, total / g_test_timer_last()); =20 g_free(out); diff --git a/tests/unit/test-crypto-afsplit.c b/tests/unit/test-crypto-afsp= lit.c index 00a7c180fd..45e9046bf6 100644 --- a/tests/unit/test-crypto-afsplit.c +++ b/tests/unit/test-crypto-afsplit.c @@ -26,7 +26,7 @@ typedef struct QCryptoAFSplitTestData QCryptoAFSplitTestData; struct QCryptoAFSplitTestData { const char *path; - QCryptoHashAlgorithm hash; + QCryptoHashAlgo hash; uint32_t stripes; size_t blocklen; const uint8_t *key; @@ -36,7 +36,7 @@ struct QCryptoAFSplitTestData { static QCryptoAFSplitTestData test_data[] =3D { { .path =3D "/crypto/afsplit/sha256/5", - .hash =3D QCRYPTO_HASH_ALG_SHA256, + .hash =3D QCRYPTO_HASH_ALGO_SHA256, .stripes =3D 5, .blocklen =3D 32, .key =3D (const uint8_t *) @@ -68,7 +68,7 @@ static QCryptoAFSplitTestData test_data[] =3D { }, { .path =3D "/crypto/afsplit/sha256/5000", - .hash =3D QCRYPTO_HASH_ALG_SHA256, + .hash =3D QCRYPTO_HASH_ALGO_SHA256, .stripes =3D 5000, .blocklen =3D 16, .key =3D (const uint8_t *) @@ -77,7 +77,7 @@ static QCryptoAFSplitTestData test_data[] =3D { }, { .path =3D "/crypto/afsplit/sha1/1000", - .hash =3D QCRYPTO_HASH_ALG_SHA1, + .hash =3D QCRYPTO_HASH_ALGO_SHA1, .stripes =3D 1000, .blocklen =3D 32, .key =3D (const uint8_t *) @@ -88,7 +88,7 @@ static QCryptoAFSplitTestData test_data[] =3D { }, { .path =3D "/crypto/afsplit/sha256/big", - .hash =3D QCRYPTO_HASH_ALG_SHA256, + .hash =3D QCRYPTO_HASH_ALGO_SHA256, .stripes =3D 1000, .blocklen =3D 64, .key =3D (const uint8_t *) diff --git a/tests/unit/test-crypto-akcipher.c b/tests/unit/test-crypto-akc= ipher.c index 59bc6f1e69..86501f19ab 100644 --- a/tests/unit/test-crypto-akcipher.c +++ b/tests/unit/test-crypto-akcipher.c @@ -808,7 +808,7 @@ static QCryptoAkCipherTestData akcipher_test_data[] =3D= { .alg =3D QCRYPTO_AKCIPHER_ALG_RSA, .u.rsa =3D { .padding_alg =3D QCRYPTO_RSA_PADDING_ALG_PKCS1, - .hash_alg =3D QCRYPTO_HASH_ALG_SHA1, + .hash_alg =3D QCRYPTO_HASH_ALGO_SHA1, }, }, .pub_key =3D rsa1024_public_key, @@ -853,7 +853,7 @@ static QCryptoAkCipherTestData akcipher_test_data[] =3D= { .alg =3D QCRYPTO_AKCIPHER_ALG_RSA, .u.rsa =3D { .padding_alg =3D QCRYPTO_RSA_PADDING_ALG_PKCS1, - .hash_alg =3D QCRYPTO_HASH_ALG_SHA1, + .hash_alg =3D QCRYPTO_HASH_ALGO_SHA1, }, }, .pub_key =3D rsa2048_public_key, @@ -947,7 +947,7 @@ static void test_rsakey(const void *opaque) .alg =3D QCRYPTO_AKCIPHER_ALG_RSA, .u.rsa =3D { .padding_alg =3D QCRYPTO_RSA_PADDING_ALG_PKCS1, - .hash_alg =3D QCRYPTO_HASH_ALG_SHA1, + .hash_alg =3D QCRYPTO_HASH_ALGO_SHA1, } }; g_autoptr(QCryptoAkCipher) key =3D qcrypto_akcipher_new( diff --git a/tests/unit/test-crypto-block.c b/tests/unit/test-crypto-block.c index 2a6c6e99e5..c2f5fe7b25 100644 --- a/tests/unit/test-crypto-block.c +++ b/tests/unit/test-crypto-block.c @@ -97,9 +97,9 @@ static QCryptoBlockCreateOptions luks_create_opts_aes256_= cbc_essiv =3D { .has_ivgen_alg =3D true, .ivgen_alg =3D QCRYPTO_IVGEN_ALG_ESSIV, .has_ivgen_hash_alg =3D true, - .ivgen_hash_alg =3D QCRYPTO_HASH_ALG_SHA256, + .ivgen_hash_alg =3D QCRYPTO_HASH_ALGO_SHA256, .has_hash_alg =3D true, - .hash_alg =3D QCRYPTO_HASH_ALG_SHA1, + .hash_alg =3D QCRYPTO_HASH_ALGO_SHA1, }, }; #endif /* TEST_LUKS */ @@ -114,10 +114,10 @@ static struct QCryptoBlockTestData { =20 QCryptoCipherAlgorithm cipher_alg; QCryptoCipherMode cipher_mode; - QCryptoHashAlgorithm hash_alg; + QCryptoHashAlgo hash_alg; =20 QCryptoIVGenAlgorithm ivgen_alg; - QCryptoHashAlgorithm ivgen_hash; + QCryptoHashAlgo ivgen_hash; =20 bool slow; } test_data[] =3D { @@ -143,7 +143,7 @@ static struct QCryptoBlockTestData { =20 .cipher_alg =3D QCRYPTO_CIPHER_ALG_AES_256, .cipher_mode =3D QCRYPTO_CIPHER_MODE_XTS, - .hash_alg =3D QCRYPTO_HASH_ALG_SHA256, + .hash_alg =3D QCRYPTO_HASH_ALGO_SHA256, =20 .ivgen_alg =3D QCRYPTO_IVGEN_ALG_PLAIN64, =20 @@ -158,7 +158,7 @@ static struct QCryptoBlockTestData { =20 .cipher_alg =3D QCRYPTO_CIPHER_ALG_AES_256, .cipher_mode =3D QCRYPTO_CIPHER_MODE_CBC, - .hash_alg =3D QCRYPTO_HASH_ALG_SHA256, + .hash_alg =3D QCRYPTO_HASH_ALGO_SHA256, =20 .ivgen_alg =3D QCRYPTO_IVGEN_ALG_PLAIN64, =20 @@ -173,10 +173,10 @@ static struct QCryptoBlockTestData { =20 .cipher_alg =3D QCRYPTO_CIPHER_ALG_AES_256, .cipher_mode =3D QCRYPTO_CIPHER_MODE_CBC, - .hash_alg =3D QCRYPTO_HASH_ALG_SHA1, + .hash_alg =3D QCRYPTO_HASH_ALGO_SHA1, =20 .ivgen_alg =3D QCRYPTO_IVGEN_ALG_ESSIV, - .ivgen_hash =3D QCRYPTO_HASH_ALG_SHA256, + .ivgen_hash =3D QCRYPTO_HASH_ALGO_SHA256, =20 .slow =3D true, }, diff --git a/tests/unit/test-crypto-hash.c b/tests/unit/test-crypto-hash.c index 1f4abb822b..124d204485 100644 --- a/tests/unit/test-crypto-hash.c +++ b/tests/unit/test-crypto-hash.c @@ -55,31 +55,31 @@ #define OUTPUT_RIPEMD160_B64 "89ZY+tP9+ytSyTac8NRBJJ3fqKA=3D" =20 static const char *expected_outputs[] =3D { - [QCRYPTO_HASH_ALG_MD5] =3D OUTPUT_MD5, - [QCRYPTO_HASH_ALG_SHA1] =3D OUTPUT_SHA1, - [QCRYPTO_HASH_ALG_SHA224] =3D OUTPUT_SHA224, - [QCRYPTO_HASH_ALG_SHA256] =3D OUTPUT_SHA256, - [QCRYPTO_HASH_ALG_SHA384] =3D OUTPUT_SHA384, - [QCRYPTO_HASH_ALG_SHA512] =3D OUTPUT_SHA512, - [QCRYPTO_HASH_ALG_RIPEMD160] =3D OUTPUT_RIPEMD160, + [QCRYPTO_HASH_ALGO_MD5] =3D OUTPUT_MD5, + [QCRYPTO_HASH_ALGO_SHA1] =3D OUTPUT_SHA1, + [QCRYPTO_HASH_ALGO_SHA224] =3D OUTPUT_SHA224, + [QCRYPTO_HASH_ALGO_SHA256] =3D OUTPUT_SHA256, + [QCRYPTO_HASH_ALGO_SHA384] =3D OUTPUT_SHA384, + [QCRYPTO_HASH_ALGO_SHA512] =3D OUTPUT_SHA512, + [QCRYPTO_HASH_ALGO_RIPEMD160] =3D OUTPUT_RIPEMD160, }; static const char *expected_outputs_b64[] =3D { - [QCRYPTO_HASH_ALG_MD5] =3D OUTPUT_MD5_B64, - [QCRYPTO_HASH_ALG_SHA1] =3D OUTPUT_SHA1_B64, - [QCRYPTO_HASH_ALG_SHA224] =3D OUTPUT_SHA224_B64, - [QCRYPTO_HASH_ALG_SHA256] =3D OUTPUT_SHA256_B64, - [QCRYPTO_HASH_ALG_SHA384] =3D OUTPUT_SHA384_B64, - [QCRYPTO_HASH_ALG_SHA512] =3D OUTPUT_SHA512_B64, - [QCRYPTO_HASH_ALG_RIPEMD160] =3D OUTPUT_RIPEMD160_B64, + [QCRYPTO_HASH_ALGO_MD5] =3D OUTPUT_MD5_B64, + [QCRYPTO_HASH_ALGO_SHA1] =3D OUTPUT_SHA1_B64, + [QCRYPTO_HASH_ALGO_SHA224] =3D OUTPUT_SHA224_B64, + [QCRYPTO_HASH_ALGO_SHA256] =3D OUTPUT_SHA256_B64, + [QCRYPTO_HASH_ALGO_SHA384] =3D OUTPUT_SHA384_B64, + [QCRYPTO_HASH_ALGO_SHA512] =3D OUTPUT_SHA512_B64, + [QCRYPTO_HASH_ALGO_RIPEMD160] =3D OUTPUT_RIPEMD160_B64, }; static const int expected_lens[] =3D { - [QCRYPTO_HASH_ALG_MD5] =3D 16, - [QCRYPTO_HASH_ALG_SHA1] =3D 20, - [QCRYPTO_HASH_ALG_SHA224] =3D 28, - [QCRYPTO_HASH_ALG_SHA256] =3D 32, - [QCRYPTO_HASH_ALG_SHA384] =3D 48, - [QCRYPTO_HASH_ALG_SHA512] =3D 64, - [QCRYPTO_HASH_ALG_RIPEMD160] =3D 20, + [QCRYPTO_HASH_ALGO_MD5] =3D 16, + [QCRYPTO_HASH_ALGO_SHA1] =3D 20, + [QCRYPTO_HASH_ALGO_SHA224] =3D 28, + [QCRYPTO_HASH_ALGO_SHA256] =3D 32, + [QCRYPTO_HASH_ALGO_SHA384] =3D 48, + [QCRYPTO_HASH_ALGO_SHA512] =3D 64, + [QCRYPTO_HASH_ALGO_RIPEMD160] =3D 20, }; =20 static const char hex[] =3D "0123456789abcdef"; diff --git a/tests/unit/test-crypto-hmac.c b/tests/unit/test-crypto-hmac.c index 23eb724d94..3fa50f24bb 100644 --- a/tests/unit/test-crypto-hmac.c +++ b/tests/unit/test-crypto-hmac.c @@ -27,43 +27,43 @@ =20 typedef struct QCryptoHmacTestData QCryptoHmacTestData; struct QCryptoHmacTestData { - QCryptoHashAlgorithm alg; + QCryptoHashAlgo alg; const char *hex_digest; }; =20 static QCryptoHmacTestData test_data[] =3D { { - .alg =3D QCRYPTO_HASH_ALG_MD5, + .alg =3D QCRYPTO_HASH_ALGO_MD5, .hex_digest =3D "ede9cb83679ba82d88fbeae865b3f8fc", }, { - .alg =3D QCRYPTO_HASH_ALG_SHA1, + .alg =3D QCRYPTO_HASH_ALGO_SHA1, .hex_digest =3D "c7b5a631e3aac975c4ededfcd346e469" "dbc5f2d1", }, { - .alg =3D QCRYPTO_HASH_ALG_SHA224, + .alg =3D QCRYPTO_HASH_ALGO_SHA224, .hex_digest =3D "5f768179dbb29ca722875d0f461a2e2f" "597d0210340a84df1a8e9c63", }, { - .alg =3D QCRYPTO_HASH_ALG_SHA256, + .alg =3D QCRYPTO_HASH_ALGO_SHA256, .hex_digest =3D "3798f363c57afa6edaffe39016ca7bad" "efd1e670afb0e3987194307dec3197db", }, { - .alg =3D QCRYPTO_HASH_ALG_SHA384, + .alg =3D QCRYPTO_HASH_ALGO_SHA384, .hex_digest =3D "d218680a6032d33dccd9882d6a6a7164" "64f26623be257a9b2919b185294f4a49" "9e54b190bfd6bc5cedd2cd05c7e65e82", }, { - .alg =3D QCRYPTO_HASH_ALG_SHA512, + .alg =3D QCRYPTO_HASH_ALGO_SHA512, .hex_digest =3D "835a4f5b3750b4c1fccfa88da2f746a4" "900160c9f18964309bb736c13b59491b" @@ -71,7 +71,7 @@ static QCryptoHmacTestData test_data[] =3D { "94c4ba26862b2dadb59b7ede1d08d53e", }, { - .alg =3D QCRYPTO_HASH_ALG_RIPEMD160, + .alg =3D QCRYPTO_HASH_ALGO_RIPEMD160, .hex_digest =3D "94964ed4c1155b62b668c241d67279e5" "8a711676", diff --git a/tests/unit/test-crypto-ivgen.c b/tests/unit/test-crypto-ivgen.c index 29630ed348..9aa3f6018b 100644 --- a/tests/unit/test-crypto-ivgen.c +++ b/tests/unit/test-crypto-ivgen.c @@ -27,7 +27,7 @@ struct QCryptoIVGenTestData { const char *path; uint64_t sector; QCryptoIVGenAlgorithm ivalg; - QCryptoHashAlgorithm hashalg; + QCryptoHashAlgo hashalg; QCryptoCipherAlgorithm cipheralg; const uint8_t *key; size_t nkey; @@ -94,7 +94,7 @@ struct QCryptoIVGenTestData { .sector =3D 0x1, .ivalg =3D QCRYPTO_IVGEN_ALG_ESSIV, .cipheralg =3D QCRYPTO_CIPHER_ALG_AES_128, - .hashalg =3D QCRYPTO_HASH_ALG_SHA256, + .hashalg =3D QCRYPTO_HASH_ALGO_SHA256, .key =3D (const uint8_t *)"\x00\x01\x02\x03\x04\x05\x06\x07" "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f", .nkey =3D 16, @@ -108,7 +108,7 @@ struct QCryptoIVGenTestData { .sector =3D 0x1f2e3d4cULL, .ivalg =3D QCRYPTO_IVGEN_ALG_ESSIV, .cipheralg =3D QCRYPTO_CIPHER_ALG_AES_128, - .hashalg =3D QCRYPTO_HASH_ALG_SHA256, + .hashalg =3D QCRYPTO_HASH_ALGO_SHA256, .key =3D (const uint8_t *)"\x00\x01\x02\x03\x04\x05\x06\x07" "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f", .nkey =3D 16, @@ -122,7 +122,7 @@ struct QCryptoIVGenTestData { .sector =3D 0x1f2e3d4c5b6a7988ULL, .ivalg =3D QCRYPTO_IVGEN_ALG_ESSIV, .cipheralg =3D QCRYPTO_CIPHER_ALG_AES_128, - .hashalg =3D QCRYPTO_HASH_ALG_SHA256, + .hashalg =3D QCRYPTO_HASH_ALGO_SHA256, .key =3D (const uint8_t *)"\x00\x01\x02\x03\x04\x05\x06\x07" "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f", .nkey =3D 16, diff --git a/tests/unit/test-crypto-pbkdf.c b/tests/unit/test-crypto-pbkdf.c index 43c417f6b4..d2cbd5b26e 100644 --- a/tests/unit/test-crypto-pbkdf.c +++ b/tests/unit/test-crypto-pbkdf.c @@ -32,7 +32,7 @@ typedef struct QCryptoPbkdfTestData QCryptoPbkdfTestData; struct QCryptoPbkdfTestData { const char *path; - QCryptoHashAlgorithm hash; + QCryptoHashAlgo hash; unsigned int iterations; const char *key; size_t nkey; @@ -53,7 +53,7 @@ static QCryptoPbkdfTestData test_data[] =3D { /* RFC 3962 test data */ { .path =3D "/crypto/pbkdf/rfc3962/sha1/iter1", - .hash =3D QCRYPTO_HASH_ALG_SHA1, + .hash =3D QCRYPTO_HASH_ALGO_SHA1, .iterations =3D 1, .key =3D "password", .nkey =3D 8, @@ -67,7 +67,7 @@ static QCryptoPbkdfTestData test_data[] =3D { }, { .path =3D "/crypto/pbkdf/rfc3962/sha1/iter2", - .hash =3D QCRYPTO_HASH_ALG_SHA1, + .hash =3D QCRYPTO_HASH_ALGO_SHA1, .iterations =3D 2, .key =3D "password", .nkey =3D 8, @@ -81,7 +81,7 @@ static QCryptoPbkdfTestData test_data[] =3D { }, { .path =3D "/crypto/pbkdf/rfc3962/sha1/iter1200a", - .hash =3D QCRYPTO_HASH_ALG_SHA1, + .hash =3D QCRYPTO_HASH_ALGO_SHA1, .iterations =3D 1200, .key =3D "password", .nkey =3D 8, @@ -95,7 +95,7 @@ static QCryptoPbkdfTestData test_data[] =3D { }, { .path =3D "/crypto/pbkdf/rfc3962/sha1/iter5", - .hash =3D QCRYPTO_HASH_ALG_SHA1, + .hash =3D QCRYPTO_HASH_ALGO_SHA1, .iterations =3D 5, .key =3D "password", .nkey =3D 8, @@ -109,7 +109,7 @@ static QCryptoPbkdfTestData test_data[] =3D { }, { .path =3D "/crypto/pbkdf/rfc3962/sha1/iter1200b", - .hash =3D QCRYPTO_HASH_ALG_SHA1, + .hash =3D QCRYPTO_HASH_ALGO_SHA1, .iterations =3D 1200, .key =3D "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", @@ -124,7 +124,7 @@ static QCryptoPbkdfTestData test_data[] =3D { }, { .path =3D "/crypto/pbkdf/rfc3962/sha1/iter1200c", - .hash =3D QCRYPTO_HASH_ALG_SHA1, + .hash =3D QCRYPTO_HASH_ALGO_SHA1, .iterations =3D 1200, .key =3D "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", @@ -139,7 +139,7 @@ static QCryptoPbkdfTestData test_data[] =3D { }, { .path =3D "/crypto/pbkdf/rfc3962/sha1/iter50", - .hash =3D QCRYPTO_HASH_ALG_SHA1, + .hash =3D QCRYPTO_HASH_ALGO_SHA1, .iterations =3D 50, .key =3D "\360\235\204\236", /* g-clef ("\xf09d849e) */ .nkey =3D 4, @@ -155,7 +155,7 @@ static QCryptoPbkdfTestData test_data[] =3D { /* RFC-6070 test data */ { .path =3D "/crypto/pbkdf/rfc6070/sha1/iter1", - .hash =3D QCRYPTO_HASH_ALG_SHA1, + .hash =3D QCRYPTO_HASH_ALGO_SHA1, .iterations =3D 1, .key =3D "password", .nkey =3D 8, @@ -167,7 +167,7 @@ static QCryptoPbkdfTestData test_data[] =3D { }, { .path =3D "/crypto/pbkdf/rfc6070/sha1/iter2", - .hash =3D QCRYPTO_HASH_ALG_SHA1, + .hash =3D QCRYPTO_HASH_ALGO_SHA1, .iterations =3D 2, .key =3D "password", .nkey =3D 8, @@ -179,7 +179,7 @@ static QCryptoPbkdfTestData test_data[] =3D { }, { .path =3D "/crypto/pbkdf/rfc6070/sha1/iter4096", - .hash =3D QCRYPTO_HASH_ALG_SHA1, + .hash =3D QCRYPTO_HASH_ALGO_SHA1, .iterations =3D 4096, .key =3D "password", .nkey =3D 8, @@ -191,7 +191,7 @@ static QCryptoPbkdfTestData test_data[] =3D { }, { .path =3D "/crypto/pbkdf/rfc6070/sha1/iter16777216", - .hash =3D QCRYPTO_HASH_ALG_SHA1, + .hash =3D QCRYPTO_HASH_ALGO_SHA1, .iterations =3D 16777216, .key =3D "password", .nkey =3D 8, @@ -204,7 +204,7 @@ static QCryptoPbkdfTestData test_data[] =3D { }, { .path =3D "/crypto/pbkdf/rfc6070/sha1/iter4096a", - .hash =3D QCRYPTO_HASH_ALG_SHA1, + .hash =3D QCRYPTO_HASH_ALGO_SHA1, .iterations =3D 4096, .key =3D "passwordPASSWORDpassword", .nkey =3D 24, @@ -217,7 +217,7 @@ static QCryptoPbkdfTestData test_data[] =3D { }, { .path =3D "/crypto/pbkdf/rfc6070/sha1/iter4096b", - .hash =3D QCRYPTO_HASH_ALG_SHA1, + .hash =3D QCRYPTO_HASH_ALGO_SHA1, .iterations =3D 4096, .key =3D "pass\0word", .nkey =3D 9, @@ -232,7 +232,7 @@ static QCryptoPbkdfTestData test_data[] =3D { { /* empty password test. */ .path =3D "/crypto/pbkdf/nonrfc/sha1/iter2", - .hash =3D QCRYPTO_HASH_ALG_SHA1, + .hash =3D QCRYPTO_HASH_ALGO_SHA1, .iterations =3D 2, .key =3D "", .nkey =3D 0, @@ -245,7 +245,7 @@ static QCryptoPbkdfTestData test_data[] =3D { { /* Password exceeds block size test */ .path =3D "/crypto/pbkdf/nonrfc/sha256/iter1200", - .hash =3D QCRYPTO_HASH_ALG_SHA256, + .hash =3D QCRYPTO_HASH_ALGO_SHA256, .iterations =3D 1200, .key =3D "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", @@ -260,7 +260,7 @@ static QCryptoPbkdfTestData test_data[] =3D { }, { .path =3D "/crypto/pbkdf/nonrfc/sha512/iter1200", - .hash =3D QCRYPTO_HASH_ALG_SHA512, + .hash =3D QCRYPTO_HASH_ALGO_SHA512, .iterations =3D 1200, .key =3D "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" @@ -277,7 +277,7 @@ static QCryptoPbkdfTestData test_data[] =3D { }, { .path =3D "/crypto/pbkdf/nonrfc/sha224/iter1200", - .hash =3D QCRYPTO_HASH_ALG_SHA224, + .hash =3D QCRYPTO_HASH_ALGO_SHA224, .iterations =3D 1200, .key =3D "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" @@ -294,7 +294,7 @@ static QCryptoPbkdfTestData test_data[] =3D { }, { .path =3D "/crypto/pbkdf/nonrfc/sha384/iter1200", - .hash =3D QCRYPTO_HASH_ALG_SHA384, + .hash =3D QCRYPTO_HASH_ALGO_SHA384, .iterations =3D 1200, .key =3D "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" @@ -311,7 +311,7 @@ static QCryptoPbkdfTestData test_data[] =3D { }, { .path =3D "/crypto/pbkdf/nonrfc/ripemd160/iter1200", - .hash =3D QCRYPTO_HASH_ALG_RIPEMD160, + .hash =3D QCRYPTO_HASH_ALGO_RIPEMD160, .iterations =3D 1200, .key =3D "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" @@ -329,7 +329,7 @@ static QCryptoPbkdfTestData test_data[] =3D { #if 0 { .path =3D "/crypto/pbkdf/nonrfc/whirlpool/iter1200", - .hash =3D QCRYPTO_HASH_ALG_WHIRLPOOL, + .hash =3D QCRYPTO_HASH_ALGO_WHIRLPOOL, .iterations =3D 1200, .key =3D "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", @@ -403,7 +403,7 @@ static void test_pbkdf_timing(void) memset(key, 0x5d, sizeof(key)); memset(salt, 0x7c, sizeof(salt)); =20 - iters =3D qcrypto_pbkdf2_count_iters(QCRYPTO_HASH_ALG_SHA256, + iters =3D qcrypto_pbkdf2_count_iters(QCRYPTO_HASH_ALGO_SHA256, key, sizeof(key), salt, sizeof(salt), 32, diff --git a/ui/vnc.c b/ui/vnc.c index dae5d51210..9a17994969 100644 --- a/ui/vnc.c +++ b/ui/vnc.c @@ -3852,7 +3852,7 @@ static int vnc_display_get_addresses(QemuOpts *opts, return 0; } if (qemu_opt_get(opts, "websocket") && - !qcrypto_hash_supports(QCRYPTO_HASH_ALG_SHA1)) { + !qcrypto_hash_supports(QCRYPTO_HASH_ALGO_SHA1)) { error_setg(errp, "SHA1 hash support is required for websockets"); return -1; diff --git a/util/hbitmap.c b/util/hbitmap.c index 6d6e1b595d..d9a1dabc63 100644 --- a/util/hbitmap.c +++ b/util/hbitmap.c @@ -949,7 +949,7 @@ char *hbitmap_sha256(const HBitmap *bitmap, Error **err= p) size_t size =3D bitmap->sizes[HBITMAP_LEVELS - 1] * sizeof(unsigned lo= ng); char *data =3D (char *)bitmap->levels[HBITMAP_LEVELS - 1]; char *hash =3D NULL; - qcrypto_hash_digest(QCRYPTO_HASH_ALG_SHA256, data, size, &hash, errp); + qcrypto_hash_digest(QCRYPTO_HASH_ALGO_SHA256, data, size, &hash, errp); =20 return hash; } diff --git a/crypto/akcipher-gcrypt.c.inc b/crypto/akcipher-gcrypt.c.inc index e942d43421..2c81de97de 100644 --- a/crypto/akcipher-gcrypt.c.inc +++ b/crypto/akcipher-gcrypt.c.inc @@ -33,7 +33,7 @@ typedef struct QCryptoGcryptRSA { QCryptoAkCipher akcipher; gcry_sexp_t key; QCryptoRSAPaddingAlgorithm padding_alg; - QCryptoHashAlgorithm hash_alg; + QCryptoHashAlgo hash_alg; } QCryptoGcryptRSA; =20 static void qcrypto_gcrypt_rsa_free(QCryptoAkCipher *akcipher) @@ -417,7 +417,7 @@ static int qcrypto_gcrypt_rsa_sign(QCryptoAkCipher *akc= ipher, =20 err =3D gcry_sexp_build(&dgst_sexp, NULL, "(data (flags pkcs1) (hash %s %b))", - QCryptoHashAlgorithm_str(rsa->hash_alg), + QCryptoHashAlgo_str(rsa->hash_alg), in_len, in); if (gcry_err_code(err) !=3D 0) { error_setg(errp, "Failed to build dgst: %s/%s", @@ -497,7 +497,7 @@ static int qcrypto_gcrypt_rsa_verify(QCryptoAkCipher *a= kcipher, =20 err =3D gcry_sexp_build(&dgst_sexp, NULL, "(data (flags pkcs1) (hash %s %b))", - QCryptoHashAlgorithm_str(rsa->hash_alg), + QCryptoHashAlgo_str(rsa->hash_alg), in2_len, in2); if (gcry_err_code(err) !=3D 0) { error_setg(errp, "Failed to build dgst: %s/%s", @@ -575,10 +575,10 @@ bool qcrypto_akcipher_supports(QCryptoAkCipherOptions= *opts) =20 case QCRYPTO_RSA_PADDING_ALG_PKCS1: switch (opts->u.rsa.hash_alg) { - case QCRYPTO_HASH_ALG_MD5: - case QCRYPTO_HASH_ALG_SHA1: - case QCRYPTO_HASH_ALG_SHA256: - case QCRYPTO_HASH_ALG_SHA512: + case QCRYPTO_HASH_ALGO_MD5: + case QCRYPTO_HASH_ALGO_SHA1: + case QCRYPTO_HASH_ALGO_SHA256: + case QCRYPTO_HASH_ALGO_SHA512: return true; =20 default: diff --git a/crypto/akcipher-nettle.c.inc b/crypto/akcipher-nettle.c.inc index 62ac8699c4..37a579fbd9 100644 --- a/crypto/akcipher-nettle.c.inc +++ b/crypto/akcipher-nettle.c.inc @@ -34,7 +34,7 @@ typedef struct QCryptoNettleRSA { struct rsa_public_key pub; struct rsa_private_key priv; QCryptoRSAPaddingAlgorithm padding_alg; - QCryptoHashAlgorithm hash_alg; + QCryptoHashAlgo hash_alg; } QCryptoNettleRSA; =20 static void qcrypto_nettle_rsa_free(QCryptoAkCipher *akcipher) @@ -276,19 +276,19 @@ static int qcrypto_nettle_rsa_sign(QCryptoAkCipher *a= kcipher, =20 mpz_init(s); switch (rsa->hash_alg) { - case QCRYPTO_HASH_ALG_MD5: + case QCRYPTO_HASH_ALGO_MD5: rv =3D rsa_md5_sign_digest(&rsa->priv, data, s); break; =20 - case QCRYPTO_HASH_ALG_SHA1: + case QCRYPTO_HASH_ALGO_SHA1: rv =3D rsa_sha1_sign_digest(&rsa->priv, data, s); break; =20 - case QCRYPTO_HASH_ALG_SHA256: + case QCRYPTO_HASH_ALGO_SHA256: rv =3D rsa_sha256_sign_digest(&rsa->priv, data, s); break; =20 - case QCRYPTO_HASH_ALG_SHA512: + case QCRYPTO_HASH_ALGO_SHA512: rv =3D rsa_sha512_sign_digest(&rsa->priv, data, s); break; =20 @@ -341,19 +341,19 @@ static int qcrypto_nettle_rsa_verify(QCryptoAkCipher = *akcipher, =20 nettle_mpz_init_set_str_256_u(s, sig_len, sig); switch (rsa->hash_alg) { - case QCRYPTO_HASH_ALG_MD5: + case QCRYPTO_HASH_ALGO_MD5: rv =3D rsa_md5_verify_digest(&rsa->pub, data, s); break; =20 - case QCRYPTO_HASH_ALG_SHA1: + case QCRYPTO_HASH_ALGO_SHA1: rv =3D rsa_sha1_verify_digest(&rsa->pub, data, s); break; =20 - case QCRYPTO_HASH_ALG_SHA256: + case QCRYPTO_HASH_ALGO_SHA256: rv =3D rsa_sha256_verify_digest(&rsa->pub, data, s); break; =20 - case QCRYPTO_HASH_ALG_SHA512: + case QCRYPTO_HASH_ALGO_SHA512: rv =3D rsa_sha512_verify_digest(&rsa->pub, data, s); break; =20 @@ -429,10 +429,10 @@ bool qcrypto_akcipher_supports(QCryptoAkCipherOptions= *opts) switch (opts->u.rsa.padding_alg) { case QCRYPTO_RSA_PADDING_ALG_PKCS1: switch (opts->u.rsa.hash_alg) { - case QCRYPTO_HASH_ALG_MD5: - case QCRYPTO_HASH_ALG_SHA1: - case QCRYPTO_HASH_ALG_SHA256: - case QCRYPTO_HASH_ALG_SHA512: + case QCRYPTO_HASH_ALGO_MD5: + case QCRYPTO_HASH_ALGO_SHA1: + case QCRYPTO_HASH_ALGO_SHA256: + case QCRYPTO_HASH_ALGO_SHA512: return true; =20 default: --=20 2.46.0 From nobody Sun Nov 24 08:32:09 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=1725449239; cv=none; d=zohomail.com; s=zohoarc; b=nxbYI6Yz/TOWFscLXxbtzVQdoTuk5A2B4Evo78G4D/ASJAAlMZVAxxTrXtm/teaBcb6a70bPg6SWK9ybr63KTO+LI87RfZW+7U2h1PB8h+IbDfbAGwg3FqMqXOtD0fPag84dwet+T9WVTRTDmqSwPRQwSPIVSytAR94gNz0oD3Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1725449239; 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=z3uQt/+SiPIadLyzyyQpdBIqIRk2kr2aqhw0ZJtjfdY=; b=kw8U+/AV7nJCq/N17ASNkxKsdSJse1Lmnx0eIHexZ9RXPlsvDfOJLZQZTkgtvA15VuH1DR5ZQDO5otw5qe3OsqtuotEf1j6MmcJZRzrmphbTt7voqlEJBdH6Hy4naaOHxb83JSawfg/visytWUVyqbgpxuaZx45f5mMRa+pJ2fE= 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 172544923903257.4704245778039; Wed, 4 Sep 2024 04:27:19 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1slo95-00084s-Dq; 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 1slo8g-0006GM-FQ for qemu-devel@nongnu.org; Wed, 04 Sep 2024 07:25:30 -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 1slo8W-0004V3-9O for qemu-devel@nongnu.org; Wed, 04 Sep 2024 07:25:30 -0400 Received: from mx-prod-mc-01.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-444-6Jl6ORluM_atKYsEPg3h4w-1; Wed, 04 Sep 2024 07:18:51 -0400 Received: from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.15]) (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-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id F3D361955D45; Wed, 4 Sep 2024 11:18:45 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.192.112]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id E30A51956088; Wed, 4 Sep 2024 11:18:44 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id C452C21E682A; 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=z3uQt/+SiPIadLyzyyQpdBIqIRk2kr2aqhw0ZJtjfdY=; b=PseNiVQdrnpFGETK6eOfjT/NFfadDmySU3LsVOPyEBj3OC7anyR3kP4LrmG6vFxs0Z/9JD Km57lXQJNnwvHGMbwyj0bEjw6hmmia/5BMkUZegYEAW9lvCaQY5xRW8sxsShzJ/alDVWPt jd4h9ezezmDFOz/H9JL1CMG1MUJ8jFE= X-MC-Unique: 6Jl6ORluM_atKYsEPg3h4w-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 12/19] qapi/crypto: Rename QCryptoCipherAlgorithm to *Algo, and drop prefix Date: Wed, 4 Sep 2024 13:18:29 +0200 Message-ID: <20240904111836.3273842-13-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.0 on 10.30.177.15 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: 16 X-Spam_score: 1.6 X-Spam_bar: + X-Spam_report: (1.6 / 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, PDS_BTC_ID=0.499, 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: 1725449240213116600 QAPI's 'prefix' feature can make the connection between enumeration type and its constants less than obvious. It's best used with restraint. QCryptoCipherAlgorithm has a 'prefix' that overrides the generated enumeration constants' prefix to QCRYPTO_CIPHER_ALG. We could simply drop 'prefix', but then the prefix becomes QCRYPTO_CIPHER_ALGORITHM, which is rather long. We could additionally rename the type to QCryptoCipherAlg, but I think the abbreviation "alg" is less than clear. Rename the type to QCryptoCipherAlgo instead. The prefix becomes QCRYPTO_CIPHER_ALGO. Signed-off-by: Markus Armbruster Acked-by: Daniel P. Berrang=C3=A9 --- qapi/block-core.json | 2 +- qapi/crypto.json | 9 ++- crypto/blockpriv.h | 4 +- crypto/cipherpriv.h | 2 +- crypto/ivgenpriv.h | 2 +- include/crypto/cipher.h | 18 +++--- include/crypto/ivgen.h | 10 +-- include/crypto/pbkdf.h | 4 +- backends/cryptodev-builtin.c | 16 ++--- block/rbd.c | 4 +- crypto/block-luks.c | 92 +++++++++++++-------------- crypto/block-qcow.c | 4 +- crypto/block.c | 2 +- crypto/cipher-afalg.c | 24 +++---- crypto/cipher.c | 72 ++++++++++----------- crypto/ivgen.c | 4 +- crypto/secret_common.c | 2 +- tests/bench/benchmark-crypto-cipher.c | 22 +++---- tests/unit/test-crypto-block.c | 14 ++-- tests/unit/test-crypto-cipher.c | 66 +++++++++---------- tests/unit/test-crypto-ivgen.c | 8 +-- ui/vnc.c | 4 +- crypto/cipher-builtin.c.inc | 18 +++--- crypto/cipher-gcrypt.c.inc | 56 ++++++++-------- crypto/cipher-gnutls.c.inc | 38 +++++------ crypto/cipher-nettle.c.inc | 58 ++++++++--------- 26 files changed, 277 insertions(+), 278 deletions(-) diff --git a/qapi/block-core.json b/qapi/block-core.json index a7ae2da47b..9f6dd59298 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -4163,7 +4163,7 @@ ## { 'struct': 'RbdEncryptionCreateOptionsLUKSBase', 'base': 'RbdEncryptionOptionsLUKSBase', - 'data': { '*cipher-alg': 'QCryptoCipherAlgorithm' } } + 'data': { '*cipher-alg': 'QCryptoCipherAlgo' } } =20 ## # @RbdEncryptionOptionsLUKS: diff --git a/qapi/crypto.json b/qapi/crypto.json index 68393568cf..0591d62f67 100644 --- a/qapi/crypto.json +++ b/qapi/crypto.json @@ -62,7 +62,7 @@ 'data': ['md5', 'sha1', 'sha224', 'sha256', 'sha384', 'sha512', 'ripemd1= 60']} =20 ## -# @QCryptoCipherAlgorithm: +# @QCryptoCipherAlgo: # # The supported algorithms for content encryption ciphers # @@ -95,8 +95,7 @@ # # Since: 2.6 ## -{ 'enum': 'QCryptoCipherAlgorithm', - 'prefix': 'QCRYPTO_CIPHER_ALG', +{ 'enum': 'QCryptoCipherAlgo', 'data': ['aes-128', 'aes-192', 'aes-256', 'des', '3des', 'cast5-128', @@ -225,7 +224,7 @@ ## { 'struct': 'QCryptoBlockCreateOptionsLUKS', 'base': 'QCryptoBlockOptionsLUKS', - 'data': { '*cipher-alg': 'QCryptoCipherAlgorithm', + 'data': { '*cipher-alg': 'QCryptoCipherAlgo', '*cipher-mode': 'QCryptoCipherMode', '*ivgen-alg': 'QCryptoIVGenAlgorithm', '*ivgen-hash-alg': 'QCryptoHashAlgo', @@ -322,7 +321,7 @@ # Since: 2.7 ## { 'struct': 'QCryptoBlockInfoLUKS', - 'data': {'cipher-alg': 'QCryptoCipherAlgorithm', + 'data': {'cipher-alg': 'QCryptoCipherAlgo', 'cipher-mode': 'QCryptoCipherMode', 'ivgen-alg': 'QCryptoIVGenAlgorithm', '*ivgen-hash-alg': 'QCryptoHashAlgo', diff --git a/crypto/blockpriv.h b/crypto/blockpriv.h index cf1a66c00d..edf0b3a3d9 100644 --- a/crypto/blockpriv.h +++ b/crypto/blockpriv.h @@ -33,7 +33,7 @@ struct QCryptoBlock { void *opaque; =20 /* Cipher parameters */ - QCryptoCipherAlgorithm alg; + QCryptoCipherAlgo alg; QCryptoCipherMode mode; uint8_t *key; size_t nkey; @@ -132,7 +132,7 @@ int qcrypto_block_encrypt_helper(QCryptoBlock *block, Error **errp); =20 int qcrypto_block_init_cipher(QCryptoBlock *block, - QCryptoCipherAlgorithm alg, + QCryptoCipherAlgo alg, QCryptoCipherMode mode, const uint8_t *key, size_t nkey, Error **errp); diff --git a/crypto/cipherpriv.h b/crypto/cipherpriv.h index 396527857d..64737ce961 100644 --- a/crypto/cipherpriv.h +++ b/crypto/cipherpriv.h @@ -42,7 +42,7 @@ struct QCryptoCipherDriver { #include "afalgpriv.h" =20 extern QCryptoCipher * -qcrypto_afalg_cipher_ctx_new(QCryptoCipherAlgorithm alg, +qcrypto_afalg_cipher_ctx_new(QCryptoCipherAlgo alg, QCryptoCipherMode mode, const uint8_t *key, size_t nkey, Error **errp); diff --git a/crypto/ivgenpriv.h b/crypto/ivgenpriv.h index 0227ae4d00..ef24c76345 100644 --- a/crypto/ivgenpriv.h +++ b/crypto/ivgenpriv.h @@ -41,7 +41,7 @@ struct QCryptoIVGen { void *private; =20 QCryptoIVGenAlgorithm algorithm; - QCryptoCipherAlgorithm cipher; + QCryptoCipherAlgo cipher; QCryptoHashAlgo hash; }; =20 diff --git a/include/crypto/cipher.h b/include/crypto/cipher.h index 083e12a7d9..92939310ef 100644 --- a/include/crypto/cipher.h +++ b/include/crypto/cipher.h @@ -26,7 +26,7 @@ typedef struct QCryptoCipher QCryptoCipher; typedef struct QCryptoCipherDriver QCryptoCipherDriver; =20 -/* See also "QCryptoCipherAlgorithm" and "QCryptoCipherMode" +/* See also "QCryptoCipherAlgo" and "QCryptoCipherMode" * enums defined in qapi/crypto.json */ =20 /** @@ -50,12 +50,12 @@ typedef struct QCryptoCipherDriver QCryptoCipherDriver; * size_t keylen =3D 16; * uint8_t iv =3D ....; * - * if (!qcrypto_cipher_supports(QCRYPTO_CIPHER_ALG_AES_128)) { + * if (!qcrypto_cipher_supports(QCRYPTO_CIPHER_ALGO_AES_128)) { * error_report(errp, "Feature requires AES cipher support"); * return -1; * } * - * cipher =3D qcrypto_cipher_new(QCRYPTO_CIPHER_ALG_AES_128, + * cipher =3D qcrypto_cipher_new(QCRYPTO_CIPHER_ALGO_AES_128, * QCRYPTO_CIPHER_MODE_CBC, * key, keylen, * errp); @@ -78,7 +78,7 @@ typedef struct QCryptoCipherDriver QCryptoCipherDriver; */ =20 struct QCryptoCipher { - QCryptoCipherAlgorithm alg; + QCryptoCipherAlgo alg; QCryptoCipherMode mode; const QCryptoCipherDriver *driver; }; @@ -93,7 +93,7 @@ struct QCryptoCipher { * * Returns: true if the algorithm is supported, false otherwise */ -bool qcrypto_cipher_supports(QCryptoCipherAlgorithm alg, +bool qcrypto_cipher_supports(QCryptoCipherAlgo alg, QCryptoCipherMode mode); =20 /** @@ -106,7 +106,7 @@ bool qcrypto_cipher_supports(QCryptoCipherAlgorithm alg, * * Returns: the block size in bytes */ -size_t qcrypto_cipher_get_block_len(QCryptoCipherAlgorithm alg); +size_t qcrypto_cipher_get_block_len(QCryptoCipherAlgo alg); =20 =20 /** @@ -117,7 +117,7 @@ size_t qcrypto_cipher_get_block_len(QCryptoCipherAlgori= thm alg); * * Returns: the key size in bytes */ -size_t qcrypto_cipher_get_key_len(QCryptoCipherAlgorithm alg); +size_t qcrypto_cipher_get_key_len(QCryptoCipherAlgo alg); =20 =20 /** @@ -130,7 +130,7 @@ size_t qcrypto_cipher_get_key_len(QCryptoCipherAlgorith= m alg); * * Returns: the IV size in bytes, or 0 if no IV is permitted */ -size_t qcrypto_cipher_get_iv_len(QCryptoCipherAlgorithm alg, +size_t qcrypto_cipher_get_iv_len(QCryptoCipherAlgo alg, QCryptoCipherMode mode); =20 =20 @@ -156,7 +156,7 @@ size_t qcrypto_cipher_get_iv_len(QCryptoCipherAlgorithm= alg, * * Returns: a new cipher object, or NULL on error */ -QCryptoCipher *qcrypto_cipher_new(QCryptoCipherAlgorithm alg, +QCryptoCipher *qcrypto_cipher_new(QCryptoCipherAlgo alg, QCryptoCipherMode mode, const uint8_t *key, size_t nkey, Error **errp); diff --git a/include/crypto/ivgen.h b/include/crypto/ivgen.h index ab5f1a648e..b059e332cd 100644 --- a/include/crypto/ivgen.h +++ b/include/crypto/ivgen.h @@ -45,21 +45,21 @@ * g_assert((ndata % 512) =3D=3D 0); * * QCryptoIVGen *ivgen =3D qcrypto_ivgen_new(QCRYPTO_IVGEN_ALG_ESSIV, - * QCRYPTO_CIPHER_ALG_AES_128, + * QCRYPTO_CIPHER_ALGO_AES_128, * QCRYPTO_HASH_ALGO_SHA256, * key, nkey, errp); * if (!ivgen) { * return -1; * } * - * QCryptoCipher *cipher =3D qcrypto_cipher_new(QCRYPTO_CIPHER_ALG_AES_128, + * QCryptoCipher *cipher =3D qcrypto_cipher_new(QCRYPTO_CIPHER_ALGO_AES_12= 8, * QCRYPTO_CIPHER_MODE_CBC, * key, nkey, errp); * if (!cipher) { * goto error; * } * - * niv =3D qcrypto_cipher_get_iv_len(QCRYPTO_CIPHER_ALG_AES_128, + * niv =3D qcrypto_cipher_get_iv_len(QCRYPTO_CIPHER_ALGO_AES_128, * QCRYPTO_CIPHER_MODE_CBC); * iv =3D g_new0(uint8_t, niv); * @@ -134,7 +134,7 @@ typedef struct QCryptoIVGen QCryptoIVGen; * Returns: a new IV generator, or NULL on error */ QCryptoIVGen *qcrypto_ivgen_new(QCryptoIVGenAlgorithm alg, - QCryptoCipherAlgorithm cipheralg, + QCryptoCipherAlgo cipheralg, QCryptoHashAlgo hash, const uint8_t *key, size_t nkey, Error **errp); @@ -179,7 +179,7 @@ QCryptoIVGenAlgorithm qcrypto_ivgen_get_algorithm(QCryp= toIVGen *ivgen); * * Returns: the cipher algorithm */ -QCryptoCipherAlgorithm qcrypto_ivgen_get_cipher(QCryptoIVGen *ivgen); +QCryptoCipherAlgo qcrypto_ivgen_get_cipher(QCryptoIVGen *ivgen); =20 =20 /** diff --git a/include/crypto/pbkdf.h b/include/crypto/pbkdf.h index 6cf29e78ee..cf59fce610 100644 --- a/include/crypto/pbkdf.h +++ b/include/crypto/pbkdf.h @@ -38,7 +38,7 @@ * .... * * char *password =3D "a-typical-awful-user-password"; - * size_t nkey =3D qcrypto_cipher_get_key_len(QCRYPTO_CIPHER_ALG_AES_128); + * size_t nkey =3D qcrypto_cipher_get_key_len(QCRYPTO_CIPHER_ALGO_AES_128); * uint8_t *salt =3D g_new0(uint8_t, nkey); * uint8_t *key =3D g_new0(uint8_t, nkey); * int iterations; @@ -70,7 +70,7 @@ * * g_free(salt); * - * cipher =3D qcrypto_cipher_new(QCRYPTO_CIPHER_ALG_AES_128, + * cipher =3D qcrypto_cipher_new(QCRYPTO_CIPHER_ALGO_AES_128, * QCRYPTO_CIPHER_MODE_ECB, * key, nkey, errp); * g_free(key); diff --git a/backends/cryptodev-builtin.c b/backends/cryptodev-builtin.c index 4a49d328ec..2672755661 100644 --- a/backends/cryptodev-builtin.c +++ b/backends/cryptodev-builtin.c @@ -138,18 +138,18 @@ cryptodev_builtin_get_aes_algo(uint32_t key_len, int = mode, Error **errp) int algo; =20 if (key_len =3D=3D AES_KEYSIZE_128) { - algo =3D QCRYPTO_CIPHER_ALG_AES_128; + algo =3D QCRYPTO_CIPHER_ALGO_AES_128; } else if (key_len =3D=3D AES_KEYSIZE_192) { - algo =3D QCRYPTO_CIPHER_ALG_AES_192; + algo =3D QCRYPTO_CIPHER_ALGO_AES_192; } else if (key_len =3D=3D AES_KEYSIZE_256) { /* equals AES_KEYSIZE_128= _XTS */ if (mode =3D=3D QCRYPTO_CIPHER_MODE_XTS) { - algo =3D QCRYPTO_CIPHER_ALG_AES_128; + algo =3D QCRYPTO_CIPHER_ALGO_AES_128; } else { - algo =3D QCRYPTO_CIPHER_ALG_AES_256; + algo =3D QCRYPTO_CIPHER_ALGO_AES_256; } } else if (key_len =3D=3D AES_KEYSIZE_256_XTS) { if (mode =3D=3D QCRYPTO_CIPHER_MODE_XTS) { - algo =3D QCRYPTO_CIPHER_ALG_AES_256; + algo =3D QCRYPTO_CIPHER_ALGO_AES_256; } else { goto err; } @@ -271,15 +271,15 @@ static int cryptodev_builtin_create_cipher_session( break; case VIRTIO_CRYPTO_CIPHER_3DES_ECB: mode =3D QCRYPTO_CIPHER_MODE_ECB; - algo =3D QCRYPTO_CIPHER_ALG_3DES; + algo =3D QCRYPTO_CIPHER_ALGO_3DES; break; case VIRTIO_CRYPTO_CIPHER_3DES_CBC: mode =3D QCRYPTO_CIPHER_MODE_CBC; - algo =3D QCRYPTO_CIPHER_ALG_3DES; + algo =3D QCRYPTO_CIPHER_ALGO_3DES; break; case VIRTIO_CRYPTO_CIPHER_3DES_CTR: mode =3D QCRYPTO_CIPHER_MODE_CTR; - algo =3D QCRYPTO_CIPHER_ALG_3DES; + algo =3D QCRYPTO_CIPHER_ALGO_3DES; break; default: error_setg(errp, "Unsupported cipher alg :%u", diff --git a/block/rbd.c b/block/rbd.c index 9c0fd0cb3f..04ed0e242e 100644 --- a/block/rbd.c +++ b/block/rbd.c @@ -367,11 +367,11 @@ static int qemu_rbd_convert_luks_create_options( =20 if (luks_opts->has_cipher_alg) { switch (luks_opts->cipher_alg) { - case QCRYPTO_CIPHER_ALG_AES_128: { + case QCRYPTO_CIPHER_ALGO_AES_128: { *alg =3D RBD_ENCRYPTION_ALGORITHM_AES128; break; } - case QCRYPTO_CIPHER_ALG_AES_256: { + case QCRYPTO_CIPHER_ALGO_AES_256: { *alg =3D RBD_ENCRYPTION_ALGORITHM_AES256; break; } diff --git a/crypto/block-luks.c b/crypto/block-luks.c index 59af733b8c..8eadf124fc 100644 --- a/crypto/block-luks.c +++ b/crypto/block-luks.c @@ -68,38 +68,38 @@ struct QCryptoBlockLUKSCipherNameMap { =20 static const QCryptoBlockLUKSCipherSizeMap qcrypto_block_luks_cipher_size_map_aes[] =3D { - { 16, QCRYPTO_CIPHER_ALG_AES_128 }, - { 24, QCRYPTO_CIPHER_ALG_AES_192 }, - { 32, QCRYPTO_CIPHER_ALG_AES_256 }, + { 16, QCRYPTO_CIPHER_ALGO_AES_128 }, + { 24, QCRYPTO_CIPHER_ALGO_AES_192 }, + { 32, QCRYPTO_CIPHER_ALGO_AES_256 }, { 0, 0 }, }; =20 static const QCryptoBlockLUKSCipherSizeMap qcrypto_block_luks_cipher_size_map_cast5[] =3D { - { 16, QCRYPTO_CIPHER_ALG_CAST5_128 }, + { 16, QCRYPTO_CIPHER_ALGO_CAST5_128 }, { 0, 0 }, }; =20 static const QCryptoBlockLUKSCipherSizeMap qcrypto_block_luks_cipher_size_map_serpent[] =3D { - { 16, QCRYPTO_CIPHER_ALG_SERPENT_128 }, - { 24, QCRYPTO_CIPHER_ALG_SERPENT_192 }, - { 32, QCRYPTO_CIPHER_ALG_SERPENT_256 }, + { 16, QCRYPTO_CIPHER_ALGO_SERPENT_128 }, + { 24, QCRYPTO_CIPHER_ALGO_SERPENT_192 }, + { 32, QCRYPTO_CIPHER_ALGO_SERPENT_256 }, { 0, 0 }, }; =20 static const QCryptoBlockLUKSCipherSizeMap qcrypto_block_luks_cipher_size_map_twofish[] =3D { - { 16, QCRYPTO_CIPHER_ALG_TWOFISH_128 }, - { 24, QCRYPTO_CIPHER_ALG_TWOFISH_192 }, - { 32, QCRYPTO_CIPHER_ALG_TWOFISH_256 }, + { 16, QCRYPTO_CIPHER_ALGO_TWOFISH_128 }, + { 24, QCRYPTO_CIPHER_ALGO_TWOFISH_192 }, + { 32, QCRYPTO_CIPHER_ALGO_TWOFISH_256 }, { 0, 0 }, }; =20 #ifdef CONFIG_CRYPTO_SM4 static const QCryptoBlockLUKSCipherSizeMap qcrypto_block_luks_cipher_size_map_sm4[] =3D { - { 16, QCRYPTO_CIPHER_ALG_SM4}, + { 16, QCRYPTO_CIPHER_ALGO_SM4}, { 0, 0 }, }; #endif @@ -123,7 +123,7 @@ struct QCryptoBlockLUKS { QCryptoBlockLUKSHeader header; =20 /* Main encryption algorithm used for encryption*/ - QCryptoCipherAlgorithm cipher_alg; + QCryptoCipherAlgo cipher_alg; =20 /* Mode of encryption for the selected encryption algorithm */ QCryptoCipherMode cipher_mode; @@ -138,7 +138,7 @@ struct QCryptoBlockLUKS { * Encryption algorithm used for IV generation. * Usually the same as main encryption algorithm */ - QCryptoCipherAlgorithm ivgen_cipher_alg; + QCryptoCipherAlgo ivgen_cipher_alg; =20 /* Hash algorithm used in pbkdf2 function */ QCryptoHashAlgo hash_alg; @@ -179,7 +179,7 @@ static int qcrypto_block_luks_cipher_name_lookup(const = char *name, } =20 static const char * -qcrypto_block_luks_cipher_alg_lookup(QCryptoCipherAlgorithm alg, +qcrypto_block_luks_cipher_alg_lookup(QCryptoCipherAlgo alg, Error **errp) { const QCryptoBlockLUKSCipherNameMap *map =3D @@ -195,7 +195,7 @@ qcrypto_block_luks_cipher_alg_lookup(QCryptoCipherAlgor= ithm alg, } =20 error_setg(errp, "Algorithm '%s' not supported", - QCryptoCipherAlgorithm_str(alg)); + QCryptoCipherAlgo_str(alg)); return NULL; } =20 @@ -262,8 +262,8 @@ qcrypto_block_luks_has_format(const uint8_t *buf, * the cipher since that gets a key length matching the digest * size, not AES 128 with truncated digest as might be imagined */ -static QCryptoCipherAlgorithm -qcrypto_block_luks_essiv_cipher(QCryptoCipherAlgorithm cipher, +static QCryptoCipherAlgo +qcrypto_block_luks_essiv_cipher(QCryptoCipherAlgo cipher, QCryptoHashAlgo hash, Error **errp) { @@ -274,54 +274,54 @@ qcrypto_block_luks_essiv_cipher(QCryptoCipherAlgorith= m cipher, } =20 switch (cipher) { - case QCRYPTO_CIPHER_ALG_AES_128: - case QCRYPTO_CIPHER_ALG_AES_192: - case QCRYPTO_CIPHER_ALG_AES_256: + case QCRYPTO_CIPHER_ALGO_AES_128: + case QCRYPTO_CIPHER_ALGO_AES_192: + case QCRYPTO_CIPHER_ALGO_AES_256: if (digestlen =3D=3D qcrypto_cipher_get_key_len( - QCRYPTO_CIPHER_ALG_AES_128)) { - return QCRYPTO_CIPHER_ALG_AES_128; + QCRYPTO_CIPHER_ALGO_AES_128)) { + return QCRYPTO_CIPHER_ALGO_AES_128; } else if (digestlen =3D=3D qcrypto_cipher_get_key_len( - QCRYPTO_CIPHER_ALG_AES_192)) { - return QCRYPTO_CIPHER_ALG_AES_192; + QCRYPTO_CIPHER_ALGO_AES_192)) { + return QCRYPTO_CIPHER_ALGO_AES_192; } else if (digestlen =3D=3D qcrypto_cipher_get_key_len( - QCRYPTO_CIPHER_ALG_AES_256)) { - return QCRYPTO_CIPHER_ALG_AES_256; + QCRYPTO_CIPHER_ALGO_AES_256)) { + return QCRYPTO_CIPHER_ALGO_AES_256; } else { error_setg(errp, "No AES cipher with key size %zu available", digestlen); return 0; } break; - case QCRYPTO_CIPHER_ALG_SERPENT_128: - case QCRYPTO_CIPHER_ALG_SERPENT_192: - case QCRYPTO_CIPHER_ALG_SERPENT_256: + case QCRYPTO_CIPHER_ALGO_SERPENT_128: + case QCRYPTO_CIPHER_ALGO_SERPENT_192: + case QCRYPTO_CIPHER_ALGO_SERPENT_256: if (digestlen =3D=3D qcrypto_cipher_get_key_len( - QCRYPTO_CIPHER_ALG_SERPENT_128)) { - return QCRYPTO_CIPHER_ALG_SERPENT_128; + QCRYPTO_CIPHER_ALGO_SERPENT_128)) { + return QCRYPTO_CIPHER_ALGO_SERPENT_128; } else if (digestlen =3D=3D qcrypto_cipher_get_key_len( - QCRYPTO_CIPHER_ALG_SERPENT_192)) { - return QCRYPTO_CIPHER_ALG_SERPENT_192; + QCRYPTO_CIPHER_ALGO_SERPENT_192)) { + return QCRYPTO_CIPHER_ALGO_SERPENT_192; } else if (digestlen =3D=3D qcrypto_cipher_get_key_len( - QCRYPTO_CIPHER_ALG_SERPENT_256)) { - return QCRYPTO_CIPHER_ALG_SERPENT_256; + QCRYPTO_CIPHER_ALGO_SERPENT_256)) { + return QCRYPTO_CIPHER_ALGO_SERPENT_256; } else { error_setg(errp, "No Serpent cipher with key size %zu availabl= e", digestlen); return 0; } break; - case QCRYPTO_CIPHER_ALG_TWOFISH_128: - case QCRYPTO_CIPHER_ALG_TWOFISH_192: - case QCRYPTO_CIPHER_ALG_TWOFISH_256: + case QCRYPTO_CIPHER_ALGO_TWOFISH_128: + case QCRYPTO_CIPHER_ALGO_TWOFISH_192: + case QCRYPTO_CIPHER_ALGO_TWOFISH_256: if (digestlen =3D=3D qcrypto_cipher_get_key_len( - QCRYPTO_CIPHER_ALG_TWOFISH_128)) { - return QCRYPTO_CIPHER_ALG_TWOFISH_128; + QCRYPTO_CIPHER_ALGO_TWOFISH_128)) { + return QCRYPTO_CIPHER_ALGO_TWOFISH_128; } else if (digestlen =3D=3D qcrypto_cipher_get_key_len( - QCRYPTO_CIPHER_ALG_TWOFISH_192)) { - return QCRYPTO_CIPHER_ALG_TWOFISH_192; + QCRYPTO_CIPHER_ALGO_TWOFISH_192)) { + return QCRYPTO_CIPHER_ALGO_TWOFISH_192; } else if (digestlen =3D=3D qcrypto_cipher_get_key_len( - QCRYPTO_CIPHER_ALG_TWOFISH_256)) { - return QCRYPTO_CIPHER_ALG_TWOFISH_256; + QCRYPTO_CIPHER_ALGO_TWOFISH_256)) { + return QCRYPTO_CIPHER_ALGO_TWOFISH_256; } else { error_setg(errp, "No Twofish cipher with key size %zu availabl= e", digestlen); @@ -330,7 +330,7 @@ qcrypto_block_luks_essiv_cipher(QCryptoCipherAlgorithm = cipher, break; default: error_setg(errp, "Cipher %s not supported with essiv", - QCryptoCipherAlgorithm_str(cipher)); + QCryptoCipherAlgo_str(cipher)); return 0; } } @@ -1322,7 +1322,7 @@ qcrypto_block_luks_create(QCryptoBlock *block, luks_opts.iter_time =3D QCRYPTO_BLOCK_LUKS_DEFAULT_ITER_TIME_MS; } if (!luks_opts.has_cipher_alg) { - luks_opts.cipher_alg =3D QCRYPTO_CIPHER_ALG_AES_256; + luks_opts.cipher_alg =3D QCRYPTO_CIPHER_ALGO_AES_256; } if (!luks_opts.has_cipher_mode) { luks_opts.cipher_mode =3D QCRYPTO_CIPHER_MODE_XTS; diff --git a/crypto/block-qcow.c b/crypto/block-qcow.c index 42e9556e42..a0ba9c1f2e 100644 --- a/crypto/block-qcow.c +++ b/crypto/block-qcow.c @@ -62,7 +62,7 @@ qcrypto_block_qcow_init(QCryptoBlock *block, memcpy(keybuf, password, MIN(len, sizeof(keybuf))); g_free(password); =20 - block->niv =3D qcrypto_cipher_get_iv_len(QCRYPTO_CIPHER_ALG_AES_128, + block->niv =3D qcrypto_cipher_get_iv_len(QCRYPTO_CIPHER_ALGO_AES_128, QCRYPTO_CIPHER_MODE_CBC); block->ivgen =3D qcrypto_ivgen_new(QCRYPTO_IVGEN_ALG_PLAIN64, 0, 0, NULL, 0, errp); @@ -71,7 +71,7 @@ qcrypto_block_qcow_init(QCryptoBlock *block, goto fail; } =20 - ret =3D qcrypto_block_init_cipher(block, QCRYPTO_CIPHER_ALG_AES_128, + ret =3D qcrypto_block_init_cipher(block, QCRYPTO_CIPHER_ALGO_AES_128, QCRYPTO_CIPHER_MODE_CBC, keybuf, G_N_ELEMENTS(keybuf), errp); diff --git a/crypto/block.c b/crypto/block.c index 9846caa591..96c83e60b9 100644 --- a/crypto/block.c +++ b/crypto/block.c @@ -267,7 +267,7 @@ static void qcrypto_block_push_cipher(QCryptoBlock *blo= ck, =20 =20 int qcrypto_block_init_cipher(QCryptoBlock *block, - QCryptoCipherAlgorithm alg, + QCryptoCipherAlgo alg, QCryptoCipherMode mode, const uint8_t *key, size_t nkey, Error **errp) diff --git a/crypto/cipher-afalg.c b/crypto/cipher-afalg.c index 3df8fc54c0..c08eb7a39b 100644 --- a/crypto/cipher-afalg.c +++ b/crypto/cipher-afalg.c @@ -18,7 +18,7 @@ =20 =20 static char * -qcrypto_afalg_cipher_format_name(QCryptoCipherAlgorithm alg, +qcrypto_afalg_cipher_format_name(QCryptoCipherAlgo alg, QCryptoCipherMode mode, Error **errp) { @@ -27,22 +27,22 @@ qcrypto_afalg_cipher_format_name(QCryptoCipherAlgorithm= alg, const char *mode_name; =20 switch (alg) { - case QCRYPTO_CIPHER_ALG_AES_128: - case QCRYPTO_CIPHER_ALG_AES_192: - case QCRYPTO_CIPHER_ALG_AES_256: + case QCRYPTO_CIPHER_ALGO_AES_128: + case QCRYPTO_CIPHER_ALGO_AES_192: + case QCRYPTO_CIPHER_ALGO_AES_256: alg_name =3D "aes"; break; - case QCRYPTO_CIPHER_ALG_CAST5_128: + case QCRYPTO_CIPHER_ALGO_CAST5_128: alg_name =3D "cast5"; break; - case QCRYPTO_CIPHER_ALG_SERPENT_128: - case QCRYPTO_CIPHER_ALG_SERPENT_192: - case QCRYPTO_CIPHER_ALG_SERPENT_256: + case QCRYPTO_CIPHER_ALGO_SERPENT_128: + case QCRYPTO_CIPHER_ALGO_SERPENT_192: + case QCRYPTO_CIPHER_ALGO_SERPENT_256: alg_name =3D "serpent"; break; - case QCRYPTO_CIPHER_ALG_TWOFISH_128: - case QCRYPTO_CIPHER_ALG_TWOFISH_192: - case QCRYPTO_CIPHER_ALG_TWOFISH_256: + case QCRYPTO_CIPHER_ALGO_TWOFISH_128: + case QCRYPTO_CIPHER_ALGO_TWOFISH_192: + case QCRYPTO_CIPHER_ALGO_TWOFISH_256: alg_name =3D "twofish"; break; =20 @@ -60,7 +60,7 @@ qcrypto_afalg_cipher_format_name(QCryptoCipherAlgorithm a= lg, static const struct QCryptoCipherDriver qcrypto_cipher_afalg_driver; =20 QCryptoCipher * -qcrypto_afalg_cipher_ctx_new(QCryptoCipherAlgorithm alg, +qcrypto_afalg_cipher_ctx_new(QCryptoCipherAlgo alg, QCryptoCipherMode mode, const uint8_t *key, size_t nkey, Error **errp) diff --git a/crypto/cipher.c b/crypto/cipher.c index 5f512768ea..c14a8b8a11 100644 --- a/crypto/cipher.c +++ b/crypto/cipher.c @@ -25,39 +25,39 @@ #include "cipherpriv.h" =20 =20 -static const size_t alg_key_len[QCRYPTO_CIPHER_ALG__MAX] =3D { - [QCRYPTO_CIPHER_ALG_AES_128] =3D 16, - [QCRYPTO_CIPHER_ALG_AES_192] =3D 24, - [QCRYPTO_CIPHER_ALG_AES_256] =3D 32, - [QCRYPTO_CIPHER_ALG_DES] =3D 8, - [QCRYPTO_CIPHER_ALG_3DES] =3D 24, - [QCRYPTO_CIPHER_ALG_CAST5_128] =3D 16, - [QCRYPTO_CIPHER_ALG_SERPENT_128] =3D 16, - [QCRYPTO_CIPHER_ALG_SERPENT_192] =3D 24, - [QCRYPTO_CIPHER_ALG_SERPENT_256] =3D 32, - [QCRYPTO_CIPHER_ALG_TWOFISH_128] =3D 16, - [QCRYPTO_CIPHER_ALG_TWOFISH_192] =3D 24, - [QCRYPTO_CIPHER_ALG_TWOFISH_256] =3D 32, +static const size_t alg_key_len[QCRYPTO_CIPHER_ALGO__MAX] =3D { + [QCRYPTO_CIPHER_ALGO_AES_128] =3D 16, + [QCRYPTO_CIPHER_ALGO_AES_192] =3D 24, + [QCRYPTO_CIPHER_ALGO_AES_256] =3D 32, + [QCRYPTO_CIPHER_ALGO_DES] =3D 8, + [QCRYPTO_CIPHER_ALGO_3DES] =3D 24, + [QCRYPTO_CIPHER_ALGO_CAST5_128] =3D 16, + [QCRYPTO_CIPHER_ALGO_SERPENT_128] =3D 16, + [QCRYPTO_CIPHER_ALGO_SERPENT_192] =3D 24, + [QCRYPTO_CIPHER_ALGO_SERPENT_256] =3D 32, + [QCRYPTO_CIPHER_ALGO_TWOFISH_128] =3D 16, + [QCRYPTO_CIPHER_ALGO_TWOFISH_192] =3D 24, + [QCRYPTO_CIPHER_ALGO_TWOFISH_256] =3D 32, #ifdef CONFIG_CRYPTO_SM4 - [QCRYPTO_CIPHER_ALG_SM4] =3D 16, + [QCRYPTO_CIPHER_ALGO_SM4] =3D 16, #endif }; =20 -static const size_t alg_block_len[QCRYPTO_CIPHER_ALG__MAX] =3D { - [QCRYPTO_CIPHER_ALG_AES_128] =3D 16, - [QCRYPTO_CIPHER_ALG_AES_192] =3D 16, - [QCRYPTO_CIPHER_ALG_AES_256] =3D 16, - [QCRYPTO_CIPHER_ALG_DES] =3D 8, - [QCRYPTO_CIPHER_ALG_3DES] =3D 8, - [QCRYPTO_CIPHER_ALG_CAST5_128] =3D 8, - [QCRYPTO_CIPHER_ALG_SERPENT_128] =3D 16, - [QCRYPTO_CIPHER_ALG_SERPENT_192] =3D 16, - [QCRYPTO_CIPHER_ALG_SERPENT_256] =3D 16, - [QCRYPTO_CIPHER_ALG_TWOFISH_128] =3D 16, - [QCRYPTO_CIPHER_ALG_TWOFISH_192] =3D 16, - [QCRYPTO_CIPHER_ALG_TWOFISH_256] =3D 16, +static const size_t alg_block_len[QCRYPTO_CIPHER_ALGO__MAX] =3D { + [QCRYPTO_CIPHER_ALGO_AES_128] =3D 16, + [QCRYPTO_CIPHER_ALGO_AES_192] =3D 16, + [QCRYPTO_CIPHER_ALGO_AES_256] =3D 16, + [QCRYPTO_CIPHER_ALGO_DES] =3D 8, + [QCRYPTO_CIPHER_ALGO_3DES] =3D 8, + [QCRYPTO_CIPHER_ALGO_CAST5_128] =3D 8, + [QCRYPTO_CIPHER_ALGO_SERPENT_128] =3D 16, + [QCRYPTO_CIPHER_ALGO_SERPENT_192] =3D 16, + [QCRYPTO_CIPHER_ALGO_SERPENT_256] =3D 16, + [QCRYPTO_CIPHER_ALGO_TWOFISH_128] =3D 16, + [QCRYPTO_CIPHER_ALGO_TWOFISH_192] =3D 16, + [QCRYPTO_CIPHER_ALGO_TWOFISH_256] =3D 16, #ifdef CONFIG_CRYPTO_SM4 - [QCRYPTO_CIPHER_ALG_SM4] =3D 16, + [QCRYPTO_CIPHER_ALGO_SM4] =3D 16, #endif }; =20 @@ -69,21 +69,21 @@ static const bool mode_need_iv[QCRYPTO_CIPHER_MODE__MAX= ] =3D { }; =20 =20 -size_t qcrypto_cipher_get_block_len(QCryptoCipherAlgorithm alg) +size_t qcrypto_cipher_get_block_len(QCryptoCipherAlgo alg) { assert(alg < G_N_ELEMENTS(alg_key_len)); return alg_block_len[alg]; } =20 =20 -size_t qcrypto_cipher_get_key_len(QCryptoCipherAlgorithm alg) +size_t qcrypto_cipher_get_key_len(QCryptoCipherAlgo alg) { assert(alg < G_N_ELEMENTS(alg_key_len)); return alg_key_len[alg]; } =20 =20 -size_t qcrypto_cipher_get_iv_len(QCryptoCipherAlgorithm alg, +size_t qcrypto_cipher_get_iv_len(QCryptoCipherAlgo alg, QCryptoCipherMode mode) { if (alg >=3D G_N_ELEMENTS(alg_block_len)) { @@ -101,20 +101,20 @@ size_t qcrypto_cipher_get_iv_len(QCryptoCipherAlgorit= hm alg, =20 =20 static bool -qcrypto_cipher_validate_key_length(QCryptoCipherAlgorithm alg, +qcrypto_cipher_validate_key_length(QCryptoCipherAlgo alg, QCryptoCipherMode mode, size_t nkey, Error **errp) { - if ((unsigned)alg >=3D QCRYPTO_CIPHER_ALG__MAX) { + if ((unsigned)alg >=3D QCRYPTO_CIPHER_ALGO__MAX) { error_setg(errp, "Cipher algorithm %d out of range", alg); return false; } =20 if (mode =3D=3D QCRYPTO_CIPHER_MODE_XTS) { - if (alg =3D=3D QCRYPTO_CIPHER_ALG_DES || - alg =3D=3D QCRYPTO_CIPHER_ALG_3DES) { + if (alg =3D=3D QCRYPTO_CIPHER_ALGO_DES || + alg =3D=3D QCRYPTO_CIPHER_ALGO_3DES) { error_setg(errp, "XTS mode not compatible with DES/3DES"); return false; } @@ -148,7 +148,7 @@ qcrypto_cipher_validate_key_length(QCryptoCipherAlgorit= hm alg, #include "cipher-builtin.c.inc" #endif =20 -QCryptoCipher *qcrypto_cipher_new(QCryptoCipherAlgorithm alg, +QCryptoCipher *qcrypto_cipher_new(QCryptoCipherAlgo alg, QCryptoCipherMode mode, const uint8_t *key, size_t nkey, Error **errp) diff --git a/crypto/ivgen.c b/crypto/ivgen.c index 080846cb74..ec0cb1a25b 100644 --- a/crypto/ivgen.c +++ b/crypto/ivgen.c @@ -28,7 +28,7 @@ =20 =20 QCryptoIVGen *qcrypto_ivgen_new(QCryptoIVGenAlgorithm alg, - QCryptoCipherAlgorithm cipheralg, + QCryptoCipherAlgo cipheralg, QCryptoHashAlgo hash, const uint8_t *key, size_t nkey, Error **errp) @@ -79,7 +79,7 @@ QCryptoIVGenAlgorithm qcrypto_ivgen_get_algorithm(QCrypto= IVGen *ivgen) } =20 =20 -QCryptoCipherAlgorithm qcrypto_ivgen_get_cipher(QCryptoIVGen *ivgen) +QCryptoCipherAlgo qcrypto_ivgen_get_cipher(QCryptoIVGen *ivgen) { return ivgen->cipher; } diff --git a/crypto/secret_common.c b/crypto/secret_common.c index 3441c44ca8..2c141107a5 100644 --- a/crypto/secret_common.c +++ b/crypto/secret_common.c @@ -71,7 +71,7 @@ static void qcrypto_secret_decrypt(QCryptoSecretCommon *s= ecret, return; } =20 - aes =3D qcrypto_cipher_new(QCRYPTO_CIPHER_ALG_AES_256, + aes =3D qcrypto_cipher_new(QCRYPTO_CIPHER_ALGO_AES_256, QCRYPTO_CIPHER_MODE_CBC, key, keylen, errp); diff --git a/tests/bench/benchmark-crypto-cipher.c b/tests/bench/benchmark-= crypto-cipher.c index c04f0a0fba..889a29ba5c 100644 --- a/tests/bench/benchmark-crypto-cipher.c +++ b/tests/bench/benchmark-crypto-cipher.c @@ -17,7 +17,7 @@ =20 static void test_cipher_speed(size_t chunk_size, QCryptoCipherMode mode, - QCryptoCipherAlgorithm alg) + QCryptoCipherAlgo alg) { QCryptoCipher *cipher; Error *err =3D NULL; @@ -71,7 +71,7 @@ static void test_cipher_speed(size_t chunk_size, g_test_timer_elapsed(); =20 g_test_message("enc(%s-%s) chunk %zu bytes %.2f MB/sec ", - QCryptoCipherAlgorithm_str(alg), + QCryptoCipherAlgo_str(alg), QCryptoCipherMode_str(mode), chunk_size, (double)total / MiB / g_test_timer_last()); =20 @@ -88,7 +88,7 @@ static void test_cipher_speed(size_t chunk_size, g_test_timer_elapsed(); =20 g_test_message("dec(%s-%s) chunk %zu bytes %.2f MB/sec ", - QCryptoCipherAlgorithm_str(alg), + QCryptoCipherAlgo_str(alg), QCryptoCipherMode_str(mode), chunk_size, (double)total / MiB / g_test_timer_last()); =20 @@ -105,7 +105,7 @@ static void test_cipher_speed_ecb_aes_128(const void *o= paque) size_t chunk_size =3D (size_t)opaque; test_cipher_speed(chunk_size, QCRYPTO_CIPHER_MODE_ECB, - QCRYPTO_CIPHER_ALG_AES_128); + QCRYPTO_CIPHER_ALGO_AES_128); } =20 static void test_cipher_speed_ecb_aes_256(const void *opaque) @@ -113,7 +113,7 @@ static void test_cipher_speed_ecb_aes_256(const void *o= paque) size_t chunk_size =3D (size_t)opaque; test_cipher_speed(chunk_size, QCRYPTO_CIPHER_MODE_ECB, - QCRYPTO_CIPHER_ALG_AES_256); + QCRYPTO_CIPHER_ALGO_AES_256); } =20 static void test_cipher_speed_cbc_aes_128(const void *opaque) @@ -121,7 +121,7 @@ static void test_cipher_speed_cbc_aes_128(const void *o= paque) size_t chunk_size =3D (size_t)opaque; test_cipher_speed(chunk_size, QCRYPTO_CIPHER_MODE_CBC, - QCRYPTO_CIPHER_ALG_AES_128); + QCRYPTO_CIPHER_ALGO_AES_128); } =20 static void test_cipher_speed_cbc_aes_256(const void *opaque) @@ -129,7 +129,7 @@ static void test_cipher_speed_cbc_aes_256(const void *o= paque) size_t chunk_size =3D (size_t)opaque; test_cipher_speed(chunk_size, QCRYPTO_CIPHER_MODE_CBC, - QCRYPTO_CIPHER_ALG_AES_256); + QCRYPTO_CIPHER_ALGO_AES_256); } =20 static void test_cipher_speed_ctr_aes_128(const void *opaque) @@ -137,7 +137,7 @@ static void test_cipher_speed_ctr_aes_128(const void *o= paque) size_t chunk_size =3D (size_t)opaque; test_cipher_speed(chunk_size, QCRYPTO_CIPHER_MODE_CTR, - QCRYPTO_CIPHER_ALG_AES_128); + QCRYPTO_CIPHER_ALGO_AES_128); } =20 static void test_cipher_speed_ctr_aes_256(const void *opaque) @@ -145,7 +145,7 @@ static void test_cipher_speed_ctr_aes_256(const void *o= paque) size_t chunk_size =3D (size_t)opaque; test_cipher_speed(chunk_size, QCRYPTO_CIPHER_MODE_CTR, - QCRYPTO_CIPHER_ALG_AES_256); + QCRYPTO_CIPHER_ALGO_AES_256); } =20 static void test_cipher_speed_xts_aes_128(const void *opaque) @@ -153,7 +153,7 @@ static void test_cipher_speed_xts_aes_128(const void *o= paque) size_t chunk_size =3D (size_t)opaque; test_cipher_speed(chunk_size, QCRYPTO_CIPHER_MODE_XTS, - QCRYPTO_CIPHER_ALG_AES_128); + QCRYPTO_CIPHER_ALGO_AES_128); } =20 static void test_cipher_speed_xts_aes_256(const void *opaque) @@ -161,7 +161,7 @@ static void test_cipher_speed_xts_aes_256(const void *o= paque) size_t chunk_size =3D (size_t)opaque; test_cipher_speed(chunk_size, QCRYPTO_CIPHER_MODE_XTS, - QCRYPTO_CIPHER_ALG_AES_256); + QCRYPTO_CIPHER_ALGO_AES_256); } =20 =20 diff --git a/tests/unit/test-crypto-block.c b/tests/unit/test-crypto-block.c index c2f5fe7b25..1a0d329368 100644 --- a/tests/unit/test-crypto-block.c +++ b/tests/unit/test-crypto-block.c @@ -77,7 +77,7 @@ static QCryptoBlockCreateOptions luks_create_opts_aes256_= cbc_plain64 =3D { .u.luks =3D { .key_secret =3D (char *)"sec0", .has_cipher_alg =3D true, - .cipher_alg =3D QCRYPTO_CIPHER_ALG_AES_256, + .cipher_alg =3D QCRYPTO_CIPHER_ALGO_AES_256, .has_cipher_mode =3D true, .cipher_mode =3D QCRYPTO_CIPHER_MODE_CBC, .has_ivgen_alg =3D true, @@ -91,7 +91,7 @@ static QCryptoBlockCreateOptions luks_create_opts_aes256_= cbc_essiv =3D { .u.luks =3D { .key_secret =3D (char *)"sec0", .has_cipher_alg =3D true, - .cipher_alg =3D QCRYPTO_CIPHER_ALG_AES_256, + .cipher_alg =3D QCRYPTO_CIPHER_ALGO_AES_256, .has_cipher_mode =3D true, .cipher_mode =3D QCRYPTO_CIPHER_MODE_CBC, .has_ivgen_alg =3D true, @@ -112,7 +112,7 @@ static struct QCryptoBlockTestData { =20 bool expect_header; =20 - QCryptoCipherAlgorithm cipher_alg; + QCryptoCipherAlgo cipher_alg; QCryptoCipherMode cipher_mode; QCryptoHashAlgo hash_alg; =20 @@ -128,7 +128,7 @@ static struct QCryptoBlockTestData { =20 .expect_header =3D false, =20 - .cipher_alg =3D QCRYPTO_CIPHER_ALG_AES_128, + .cipher_alg =3D QCRYPTO_CIPHER_ALGO_AES_128, .cipher_mode =3D QCRYPTO_CIPHER_MODE_CBC, =20 .ivgen_alg =3D QCRYPTO_IVGEN_ALG_PLAIN64, @@ -141,7 +141,7 @@ static struct QCryptoBlockTestData { =20 .expect_header =3D true, =20 - .cipher_alg =3D QCRYPTO_CIPHER_ALG_AES_256, + .cipher_alg =3D QCRYPTO_CIPHER_ALGO_AES_256, .cipher_mode =3D QCRYPTO_CIPHER_MODE_XTS, .hash_alg =3D QCRYPTO_HASH_ALGO_SHA256, =20 @@ -156,7 +156,7 @@ static struct QCryptoBlockTestData { =20 .expect_header =3D true, =20 - .cipher_alg =3D QCRYPTO_CIPHER_ALG_AES_256, + .cipher_alg =3D QCRYPTO_CIPHER_ALGO_AES_256, .cipher_mode =3D QCRYPTO_CIPHER_MODE_CBC, .hash_alg =3D QCRYPTO_HASH_ALGO_SHA256, =20 @@ -171,7 +171,7 @@ static struct QCryptoBlockTestData { =20 .expect_header =3D true, =20 - .cipher_alg =3D QCRYPTO_CIPHER_ALG_AES_256, + .cipher_alg =3D QCRYPTO_CIPHER_ALGO_AES_256, .cipher_mode =3D QCRYPTO_CIPHER_MODE_CBC, .hash_alg =3D QCRYPTO_HASH_ALGO_SHA1, =20 diff --git a/tests/unit/test-crypto-cipher.c b/tests/unit/test-crypto-ciphe= r.c index f5152e569d..b328b482e1 100644 --- a/tests/unit/test-crypto-cipher.c +++ b/tests/unit/test-crypto-cipher.c @@ -27,7 +27,7 @@ typedef struct QCryptoCipherTestData QCryptoCipherTestData; struct QCryptoCipherTestData { const char *path; - QCryptoCipherAlgorithm alg; + QCryptoCipherAlgo alg; QCryptoCipherMode mode; const char *key; const char *plaintext; @@ -43,7 +43,7 @@ static QCryptoCipherTestData test_data[] =3D { { /* NIST F.1.1 ECB-AES128.Encrypt */ .path =3D "/crypto/cipher/aes-ecb-128", - .alg =3D QCRYPTO_CIPHER_ALG_AES_128, + .alg =3D QCRYPTO_CIPHER_ALGO_AES_128, .mode =3D QCRYPTO_CIPHER_MODE_ECB, .key =3D "2b7e151628aed2a6abf7158809cf4f3c", .plaintext =3D @@ -60,7 +60,7 @@ static QCryptoCipherTestData test_data[] =3D { { /* NIST F.1.3 ECB-AES192.Encrypt */ .path =3D "/crypto/cipher/aes-ecb-192", - .alg =3D QCRYPTO_CIPHER_ALG_AES_192, + .alg =3D QCRYPTO_CIPHER_ALGO_AES_192, .mode =3D QCRYPTO_CIPHER_MODE_ECB, .key =3D "8e73b0f7da0e6452c810f32b809079e562f8ead2522c6b7b", .plaintext =3D @@ -77,7 +77,7 @@ static QCryptoCipherTestData test_data[] =3D { { /* NIST F.1.5 ECB-AES256.Encrypt */ .path =3D "/crypto/cipher/aes-ecb-256", - .alg =3D QCRYPTO_CIPHER_ALG_AES_256, + .alg =3D QCRYPTO_CIPHER_ALGO_AES_256, .mode =3D QCRYPTO_CIPHER_MODE_ECB, .key =3D "603deb1015ca71be2b73aef0857d7781" @@ -96,7 +96,7 @@ static QCryptoCipherTestData test_data[] =3D { { /* NIST F.2.1 CBC-AES128.Encrypt */ .path =3D "/crypto/cipher/aes-cbc-128", - .alg =3D QCRYPTO_CIPHER_ALG_AES_128, + .alg =3D QCRYPTO_CIPHER_ALGO_AES_128, .mode =3D QCRYPTO_CIPHER_MODE_CBC, .key =3D "2b7e151628aed2a6abf7158809cf4f3c", .iv =3D "000102030405060708090a0b0c0d0e0f", @@ -114,7 +114,7 @@ static QCryptoCipherTestData test_data[] =3D { { /* NIST F.2.3 CBC-AES128.Encrypt */ .path =3D "/crypto/cipher/aes-cbc-192", - .alg =3D QCRYPTO_CIPHER_ALG_AES_192, + .alg =3D QCRYPTO_CIPHER_ALGO_AES_192, .mode =3D QCRYPTO_CIPHER_MODE_CBC, .key =3D "8e73b0f7da0e6452c810f32b809079e562f8ead2522c6b7b", .iv =3D "000102030405060708090a0b0c0d0e0f", @@ -132,7 +132,7 @@ static QCryptoCipherTestData test_data[] =3D { { /* NIST F.2.5 CBC-AES128.Encrypt */ .path =3D "/crypto/cipher/aes-cbc-256", - .alg =3D QCRYPTO_CIPHER_ALG_AES_256, + .alg =3D QCRYPTO_CIPHER_ALGO_AES_256, .mode =3D QCRYPTO_CIPHER_MODE_CBC, .key =3D "603deb1015ca71be2b73aef0857d7781" @@ -156,7 +156,7 @@ static QCryptoCipherTestData test_data[] =3D { * ciphertext in ECB and CBC modes */ .path =3D "/crypto/cipher/des-ecb-56-one-block", - .alg =3D QCRYPTO_CIPHER_ALG_DES, + .alg =3D QCRYPTO_CIPHER_ALGO_DES, .mode =3D QCRYPTO_CIPHER_MODE_ECB, .key =3D "80c4a2e691d5b3f7", .plaintext =3D "70617373776f7264", @@ -165,7 +165,7 @@ static QCryptoCipherTestData test_data[] =3D { { /* See previous comment */ .path =3D "/crypto/cipher/des-cbc-56-one-block", - .alg =3D QCRYPTO_CIPHER_ALG_DES, + .alg =3D QCRYPTO_CIPHER_ALGO_DES, .mode =3D QCRYPTO_CIPHER_MODE_CBC, .key =3D "80c4a2e691d5b3f7", .iv =3D "0000000000000000", @@ -174,7 +174,7 @@ static QCryptoCipherTestData test_data[] =3D { }, { .path =3D "/crypto/cipher/des-ecb-56", - .alg =3D QCRYPTO_CIPHER_ALG_DES, + .alg =3D QCRYPTO_CIPHER_ALGO_DES, .mode =3D QCRYPTO_CIPHER_MODE_ECB, .key =3D "80c4a2e691d5b3f7", .plaintext =3D @@ -191,7 +191,7 @@ static QCryptoCipherTestData test_data[] =3D { { /* Borrowed from linux-kernel crypto/testmgr.h */ .path =3D "/crypto/cipher/3des-cbc", - .alg =3D QCRYPTO_CIPHER_ALG_3DES, + .alg =3D QCRYPTO_CIPHER_ALGO_3DES, .mode =3D QCRYPTO_CIPHER_MODE_CBC, .key =3D "e9c0ff2e760b6424444d995a12d640c0" @@ -220,7 +220,7 @@ static QCryptoCipherTestData test_data[] =3D { { /* Borrowed from linux-kernel crypto/testmgr.h */ .path =3D "/crypto/cipher/3des-ecb", - .alg =3D QCRYPTO_CIPHER_ALG_3DES, + .alg =3D QCRYPTO_CIPHER_ALGO_3DES, .mode =3D QCRYPTO_CIPHER_MODE_ECB, .key =3D "0123456789abcdef5555555555555555" @@ -233,7 +233,7 @@ static QCryptoCipherTestData test_data[] =3D { { /* Borrowed from linux-kernel crypto/testmgr.h */ .path =3D "/crypto/cipher/3des-ctr", - .alg =3D QCRYPTO_CIPHER_ALG_3DES, + .alg =3D QCRYPTO_CIPHER_ALGO_3DES, .mode =3D QCRYPTO_CIPHER_MODE_CTR, .key =3D "9cd6f39cb95a67005a67002dceeb2dce" @@ -308,7 +308,7 @@ static QCryptoCipherTestData test_data[] =3D { { /* RFC 2144, Appendix B.1 */ .path =3D "/crypto/cipher/cast5-128", - .alg =3D QCRYPTO_CIPHER_ALG_CAST5_128, + .alg =3D QCRYPTO_CIPHER_ALGO_CAST5_128, .mode =3D QCRYPTO_CIPHER_MODE_ECB, .key =3D "0123456712345678234567893456789A", .plaintext =3D "0123456789abcdef", @@ -317,7 +317,7 @@ static QCryptoCipherTestData test_data[] =3D { { /* libgcrypt serpent.c */ .path =3D "/crypto/cipher/serpent-128", - .alg =3D QCRYPTO_CIPHER_ALG_SERPENT_128, + .alg =3D QCRYPTO_CIPHER_ALGO_SERPENT_128, .mode =3D QCRYPTO_CIPHER_MODE_ECB, .key =3D "00000000000000000000000000000000", .plaintext =3D "d29d576fcea3a3a7ed9099f29273d78e", @@ -326,7 +326,7 @@ static QCryptoCipherTestData test_data[] =3D { { /* libgcrypt serpent.c */ .path =3D "/crypto/cipher/serpent-192", - .alg =3D QCRYPTO_CIPHER_ALG_SERPENT_192, + .alg =3D QCRYPTO_CIPHER_ALGO_SERPENT_192, .mode =3D QCRYPTO_CIPHER_MODE_ECB, .key =3D "00000000000000000000000000000000" "0000000000000000", @@ -336,7 +336,7 @@ static QCryptoCipherTestData test_data[] =3D { { /* libgcrypt serpent.c */ .path =3D "/crypto/cipher/serpent-256a", - .alg =3D QCRYPTO_CIPHER_ALG_SERPENT_256, + .alg =3D QCRYPTO_CIPHER_ALGO_SERPENT_256, .mode =3D QCRYPTO_CIPHER_MODE_ECB, .key =3D "00000000000000000000000000000000" "00000000000000000000000000000000", @@ -346,7 +346,7 @@ static QCryptoCipherTestData test_data[] =3D { { /* libgcrypt serpent.c */ .path =3D "/crypto/cipher/serpent-256b", - .alg =3D QCRYPTO_CIPHER_ALG_SERPENT_256, + .alg =3D QCRYPTO_CIPHER_ALGO_SERPENT_256, .mode =3D QCRYPTO_CIPHER_MODE_ECB, .key =3D "00000000000000000000000000000000" "00000000000000000000000000000000", @@ -356,7 +356,7 @@ static QCryptoCipherTestData test_data[] =3D { { /* Twofish paper "Known Answer Test" */ .path =3D "/crypto/cipher/twofish-128", - .alg =3D QCRYPTO_CIPHER_ALG_TWOFISH_128, + .alg =3D QCRYPTO_CIPHER_ALGO_TWOFISH_128, .mode =3D QCRYPTO_CIPHER_MODE_ECB, .key =3D "d491db16e7b1c39e86cb086b789f5419", .plaintext =3D "019f9809de1711858faac3a3ba20fbc3", @@ -365,7 +365,7 @@ static QCryptoCipherTestData test_data[] =3D { { /* Twofish paper "Known Answer Test", I=3D3 */ .path =3D "/crypto/cipher/twofish-192", - .alg =3D QCRYPTO_CIPHER_ALG_TWOFISH_192, + .alg =3D QCRYPTO_CIPHER_ALGO_TWOFISH_192, .mode =3D QCRYPTO_CIPHER_MODE_ECB, .key =3D "88b2b2706b105e36b446bb6d731a1e88" "efa71f788965bd44", @@ -375,7 +375,7 @@ static QCryptoCipherTestData test_data[] =3D { { /* Twofish paper "Known Answer Test", I=3D4 */ .path =3D "/crypto/cipher/twofish-256", - .alg =3D QCRYPTO_CIPHER_ALG_TWOFISH_256, + .alg =3D QCRYPTO_CIPHER_ALGO_TWOFISH_256, .mode =3D QCRYPTO_CIPHER_MODE_ECB, .key =3D "d43bb7556ea32e46f2a282b7d45b4e0d" "57ff739d4dc92c1bd7fc01700cc8216f", @@ -386,7 +386,7 @@ static QCryptoCipherTestData test_data[] =3D { { /* SM4, GB/T 32907-2016, Appendix A.1 */ .path =3D "/crypto/cipher/sm4", - .alg =3D QCRYPTO_CIPHER_ALG_SM4, + .alg =3D QCRYPTO_CIPHER_ALGO_SM4, .mode =3D QCRYPTO_CIPHER_MODE_ECB, .key =3D "0123456789abcdeffedcba9876543210", .plaintext =3D @@ -398,7 +398,7 @@ static QCryptoCipherTestData test_data[] =3D { { /* #1 32 byte key, 32 byte PTX */ .path =3D "/crypto/cipher/aes-xts-128-1", - .alg =3D QCRYPTO_CIPHER_ALG_AES_128, + .alg =3D QCRYPTO_CIPHER_ALGO_AES_128, .mode =3D QCRYPTO_CIPHER_MODE_XTS, .key =3D "00000000000000000000000000000000" @@ -415,7 +415,7 @@ static QCryptoCipherTestData test_data[] =3D { { /* #2, 32 byte key, 32 byte PTX */ .path =3D "/crypto/cipher/aes-xts-128-2", - .alg =3D QCRYPTO_CIPHER_ALG_AES_128, + .alg =3D QCRYPTO_CIPHER_ALGO_AES_128, .mode =3D QCRYPTO_CIPHER_MODE_XTS, .key =3D "11111111111111111111111111111111" @@ -432,7 +432,7 @@ static QCryptoCipherTestData test_data[] =3D { { /* #5 from xts.7, 32 byte key, 32 byte PTX */ .path =3D "/crypto/cipher/aes-xts-128-3", - .alg =3D QCRYPTO_CIPHER_ALG_AES_128, + .alg =3D QCRYPTO_CIPHER_ALGO_AES_128, .mode =3D QCRYPTO_CIPHER_MODE_XTS, .key =3D "fffefdfcfbfaf9f8f7f6f5f4f3f2f1f0" @@ -449,7 +449,7 @@ static QCryptoCipherTestData test_data[] =3D { { /* #4, 32 byte key, 512 byte PTX */ .path =3D "/crypto/cipher/aes-xts-128-4", - .alg =3D QCRYPTO_CIPHER_ALG_AES_128, + .alg =3D QCRYPTO_CIPHER_ALGO_AES_128, .mode =3D QCRYPTO_CIPHER_MODE_XTS, .key =3D "27182818284590452353602874713526" @@ -528,7 +528,7 @@ static QCryptoCipherTestData test_data[] =3D { * which is incompatible with XTS */ .path =3D "/crypto/cipher/cast5-xts-128", - .alg =3D QCRYPTO_CIPHER_ALG_CAST5_128, + .alg =3D QCRYPTO_CIPHER_ALGO_CAST5_128, .mode =3D QCRYPTO_CIPHER_MODE_XTS, .key =3D "27182818284590452353602874713526" @@ -537,7 +537,7 @@ static QCryptoCipherTestData test_data[] =3D { { /* NIST F.5.1 CTR-AES128.Encrypt */ .path =3D "/crypto/cipher/aes-ctr-128", - .alg =3D QCRYPTO_CIPHER_ALG_AES_128, + .alg =3D QCRYPTO_CIPHER_ALGO_AES_128, .mode =3D QCRYPTO_CIPHER_MODE_CTR, .key =3D "2b7e151628aed2a6abf7158809cf4f3c", .iv =3D "f0f1f2f3f4f5f6f7f8f9fafbfcfdfeff", @@ -555,7 +555,7 @@ static QCryptoCipherTestData test_data[] =3D { { /* NIST F.5.3 CTR-AES192.Encrypt */ .path =3D "/crypto/cipher/aes-ctr-192", - .alg =3D QCRYPTO_CIPHER_ALG_AES_192, + .alg =3D QCRYPTO_CIPHER_ALGO_AES_192, .mode =3D QCRYPTO_CIPHER_MODE_CTR, .key =3D "8e73b0f7da0e6452c810f32b809079e562f8ead2522c6b7b", .iv =3D "f0f1f2f3f4f5f6f7f8f9fafbfcfdfeff", @@ -573,7 +573,7 @@ static QCryptoCipherTestData test_data[] =3D { { /* NIST F.5.5 CTR-AES256.Encrypt */ .path =3D "/crypto/cipher/aes-ctr-256", - .alg =3D QCRYPTO_CIPHER_ALG_AES_256, + .alg =3D QCRYPTO_CIPHER_ALGO_AES_256, .mode =3D QCRYPTO_CIPHER_MODE_CTR, .key =3D "603deb1015ca71be2b73aef0857d7781" "1f352c073b6108d72d9810a30914dff4", @@ -750,7 +750,7 @@ static void test_cipher_null_iv(void) uint8_t ciphertext[32] =3D { 0 }; =20 cipher =3D qcrypto_cipher_new( - QCRYPTO_CIPHER_ALG_AES_256, + QCRYPTO_CIPHER_ALGO_AES_256, QCRYPTO_CIPHER_MODE_CBC, key, sizeof(key), &error_abort); @@ -779,7 +779,7 @@ static void test_cipher_short_plaintext(void) int ret; =20 cipher =3D qcrypto_cipher_new( - QCRYPTO_CIPHER_ALG_AES_256, + QCRYPTO_CIPHER_ALGO_AES_256, QCRYPTO_CIPHER_MODE_CBC, key, sizeof(key), &error_abort); @@ -823,7 +823,7 @@ int main(int argc, char **argv) g_test_add_data_func(test_data[i].path, &test_data[i], test_ci= pher); } else { g_printerr("# skip unsupported %s:%s\n", - QCryptoCipherAlgorithm_str(test_data[i].alg), + QCryptoCipherAlgo_str(test_data[i].alg), QCryptoCipherMode_str(test_data[i].mode)); } } diff --git a/tests/unit/test-crypto-ivgen.c b/tests/unit/test-crypto-ivgen.c index 9aa3f6018b..6b4110775a 100644 --- a/tests/unit/test-crypto-ivgen.c +++ b/tests/unit/test-crypto-ivgen.c @@ -28,7 +28,7 @@ struct QCryptoIVGenTestData { uint64_t sector; QCryptoIVGenAlgorithm ivalg; QCryptoHashAlgo hashalg; - QCryptoCipherAlgorithm cipheralg; + QCryptoCipherAlgo cipheralg; const uint8_t *key; size_t nkey; const uint8_t *iv; @@ -93,7 +93,7 @@ struct QCryptoIVGenTestData { "/crypto/ivgen/essiv/1", .sector =3D 0x1, .ivalg =3D QCRYPTO_IVGEN_ALG_ESSIV, - .cipheralg =3D QCRYPTO_CIPHER_ALG_AES_128, + .cipheralg =3D QCRYPTO_CIPHER_ALGO_AES_128, .hashalg =3D QCRYPTO_HASH_ALGO_SHA256, .key =3D (const uint8_t *)"\x00\x01\x02\x03\x04\x05\x06\x07" "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f", @@ -107,7 +107,7 @@ struct QCryptoIVGenTestData { "/crypto/ivgen/essiv/1f2e3d4c", .sector =3D 0x1f2e3d4cULL, .ivalg =3D QCRYPTO_IVGEN_ALG_ESSIV, - .cipheralg =3D QCRYPTO_CIPHER_ALG_AES_128, + .cipheralg =3D QCRYPTO_CIPHER_ALGO_AES_128, .hashalg =3D QCRYPTO_HASH_ALGO_SHA256, .key =3D (const uint8_t *)"\x00\x01\x02\x03\x04\x05\x06\x07" "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f", @@ -121,7 +121,7 @@ struct QCryptoIVGenTestData { "/crypto/ivgen/essiv/1f2e3d4c5b6a7988", .sector =3D 0x1f2e3d4c5b6a7988ULL, .ivalg =3D QCRYPTO_IVGEN_ALG_ESSIV, - .cipheralg =3D QCRYPTO_CIPHER_ALG_AES_128, + .cipheralg =3D QCRYPTO_CIPHER_ALGO_AES_128, .hashalg =3D QCRYPTO_HASH_ALGO_SHA256, .key =3D (const uint8_t *)"\x00\x01\x02\x03\x04\x05\x06\x07" "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f", diff --git a/ui/vnc.c b/ui/vnc.c index 9a17994969..b59af625dd 100644 --- a/ui/vnc.c +++ b/ui/vnc.c @@ -2783,7 +2783,7 @@ static int protocol_client_auth_vnc(VncState *vs, uin= t8_t *data, size_t len) vnc_munge_des_rfb_key(key, sizeof(key)); =20 cipher =3D qcrypto_cipher_new( - QCRYPTO_CIPHER_ALG_DES, + QCRYPTO_CIPHER_ALGO_DES, QCRYPTO_CIPHER_MODE_ECB, key, G_N_ELEMENTS(key), &err); @@ -4064,7 +4064,7 @@ void vnc_display_open(const char *id, Error **errp) } if (password) { if (!qcrypto_cipher_supports( - QCRYPTO_CIPHER_ALG_DES, QCRYPTO_CIPHER_MODE_ECB)) { + QCRYPTO_CIPHER_ALGO_DES, QCRYPTO_CIPHER_MODE_ECB)) { error_setg(errp, "Cipher backend does not support DES algorithm"); goto fail; diff --git a/crypto/cipher-builtin.c.inc b/crypto/cipher-builtin.c.inc index b409089095..da5fcbd9a3 100644 --- a/crypto/cipher-builtin.c.inc +++ b/crypto/cipher-builtin.c.inc @@ -221,13 +221,13 @@ static const struct QCryptoCipherDriver qcrypto_ciphe= r_aes_driver_cbc =3D { .cipher_free =3D qcrypto_cipher_ctx_free, }; =20 -bool qcrypto_cipher_supports(QCryptoCipherAlgorithm alg, +bool qcrypto_cipher_supports(QCryptoCipherAlgo alg, QCryptoCipherMode mode) { switch (alg) { - case QCRYPTO_CIPHER_ALG_AES_128: - case QCRYPTO_CIPHER_ALG_AES_192: - case QCRYPTO_CIPHER_ALG_AES_256: + case QCRYPTO_CIPHER_ALGO_AES_128: + case QCRYPTO_CIPHER_ALGO_AES_192: + case QCRYPTO_CIPHER_ALGO_AES_256: switch (mode) { case QCRYPTO_CIPHER_MODE_ECB: case QCRYPTO_CIPHER_MODE_CBC: @@ -241,7 +241,7 @@ bool qcrypto_cipher_supports(QCryptoCipherAlgorithm alg, } } =20 -static QCryptoCipher *qcrypto_cipher_ctx_new(QCryptoCipherAlgorithm alg, +static QCryptoCipher *qcrypto_cipher_ctx_new(QCryptoCipherAlgo alg, QCryptoCipherMode mode, const uint8_t *key, size_t nkey, @@ -252,9 +252,9 @@ static QCryptoCipher *qcrypto_cipher_ctx_new(QCryptoCip= herAlgorithm alg, } =20 switch (alg) { - case QCRYPTO_CIPHER_ALG_AES_128: - case QCRYPTO_CIPHER_ALG_AES_192: - case QCRYPTO_CIPHER_ALG_AES_256: + case QCRYPTO_CIPHER_ALGO_AES_128: + case QCRYPTO_CIPHER_ALGO_AES_192: + case QCRYPTO_CIPHER_ALGO_AES_256: { QCryptoCipherBuiltinAES *ctx; const QCryptoCipherDriver *drv; @@ -292,7 +292,7 @@ static QCryptoCipher *qcrypto_cipher_ctx_new(QCryptoCip= herAlgorithm alg, default: error_setg(errp, "Unsupported cipher algorithm %s", - QCryptoCipherAlgorithm_str(alg)); + QCryptoCipherAlgo_str(alg)); return NULL; } =20 diff --git a/crypto/cipher-gcrypt.c.inc b/crypto/cipher-gcrypt.c.inc index 4a8314746d..12eb9ddb5a 100644 --- a/crypto/cipher-gcrypt.c.inc +++ b/crypto/cipher-gcrypt.c.inc @@ -20,33 +20,33 @@ =20 #include =20 -static int qcrypto_cipher_alg_to_gcry_alg(QCryptoCipherAlgorithm alg) +static int qcrypto_cipher_alg_to_gcry_alg(QCryptoCipherAlgo alg) { switch (alg) { - case QCRYPTO_CIPHER_ALG_DES: + case QCRYPTO_CIPHER_ALGO_DES: return GCRY_CIPHER_DES; - case QCRYPTO_CIPHER_ALG_3DES: + case QCRYPTO_CIPHER_ALGO_3DES: return GCRY_CIPHER_3DES; - case QCRYPTO_CIPHER_ALG_AES_128: + case QCRYPTO_CIPHER_ALGO_AES_128: return GCRY_CIPHER_AES128; - case QCRYPTO_CIPHER_ALG_AES_192: + case QCRYPTO_CIPHER_ALGO_AES_192: return GCRY_CIPHER_AES192; - case QCRYPTO_CIPHER_ALG_AES_256: + case QCRYPTO_CIPHER_ALGO_AES_256: return GCRY_CIPHER_AES256; - case QCRYPTO_CIPHER_ALG_CAST5_128: + case QCRYPTO_CIPHER_ALGO_CAST5_128: return GCRY_CIPHER_CAST5; - case QCRYPTO_CIPHER_ALG_SERPENT_128: + case QCRYPTO_CIPHER_ALGO_SERPENT_128: return GCRY_CIPHER_SERPENT128; - case QCRYPTO_CIPHER_ALG_SERPENT_192: + case QCRYPTO_CIPHER_ALGO_SERPENT_192: return GCRY_CIPHER_SERPENT192; - case QCRYPTO_CIPHER_ALG_SERPENT_256: + case QCRYPTO_CIPHER_ALGO_SERPENT_256: return GCRY_CIPHER_SERPENT256; - case QCRYPTO_CIPHER_ALG_TWOFISH_128: + case QCRYPTO_CIPHER_ALGO_TWOFISH_128: return GCRY_CIPHER_TWOFISH128; - case QCRYPTO_CIPHER_ALG_TWOFISH_256: + case QCRYPTO_CIPHER_ALGO_TWOFISH_256: return GCRY_CIPHER_TWOFISH; #ifdef CONFIG_CRYPTO_SM4 - case QCRYPTO_CIPHER_ALG_SM4: + case QCRYPTO_CIPHER_ALGO_SM4: return GCRY_CIPHER_SM4; #endif default: @@ -70,23 +70,23 @@ static int qcrypto_cipher_mode_to_gcry_mode(QCryptoCiph= erMode mode) } } =20 -bool qcrypto_cipher_supports(QCryptoCipherAlgorithm alg, +bool qcrypto_cipher_supports(QCryptoCipherAlgo alg, QCryptoCipherMode mode) { switch (alg) { - case QCRYPTO_CIPHER_ALG_DES: - case QCRYPTO_CIPHER_ALG_3DES: - case QCRYPTO_CIPHER_ALG_AES_128: - case QCRYPTO_CIPHER_ALG_AES_192: - case QCRYPTO_CIPHER_ALG_AES_256: - case QCRYPTO_CIPHER_ALG_CAST5_128: - case QCRYPTO_CIPHER_ALG_SERPENT_128: - case QCRYPTO_CIPHER_ALG_SERPENT_192: - case QCRYPTO_CIPHER_ALG_SERPENT_256: - case QCRYPTO_CIPHER_ALG_TWOFISH_128: - case QCRYPTO_CIPHER_ALG_TWOFISH_256: + case QCRYPTO_CIPHER_ALGO_DES: + case QCRYPTO_CIPHER_ALGO_3DES: + case QCRYPTO_CIPHER_ALGO_AES_128: + case QCRYPTO_CIPHER_ALGO_AES_192: + case QCRYPTO_CIPHER_ALGO_AES_256: + case QCRYPTO_CIPHER_ALGO_CAST5_128: + case QCRYPTO_CIPHER_ALGO_SERPENT_128: + case QCRYPTO_CIPHER_ALGO_SERPENT_192: + case QCRYPTO_CIPHER_ALGO_SERPENT_256: + case QCRYPTO_CIPHER_ALGO_TWOFISH_128: + case QCRYPTO_CIPHER_ALGO_TWOFISH_256: #ifdef CONFIG_CRYPTO_SM4 - case QCRYPTO_CIPHER_ALG_SM4: + case QCRYPTO_CIPHER_ALGO_SM4: #endif break; default: @@ -228,7 +228,7 @@ static const struct QCryptoCipherDriver qcrypto_gcrypt_= ctr_driver =3D { .cipher_free =3D qcrypto_gcrypt_ctx_free, }; =20 -static QCryptoCipher *qcrypto_cipher_ctx_new(QCryptoCipherAlgorithm alg, +static QCryptoCipher *qcrypto_cipher_ctx_new(QCryptoCipherAlgo alg, QCryptoCipherMode mode, const uint8_t *key, size_t nkey, @@ -246,7 +246,7 @@ static QCryptoCipher *qcrypto_cipher_ctx_new(QCryptoCip= herAlgorithm alg, gcryalg =3D qcrypto_cipher_alg_to_gcry_alg(alg); if (gcryalg =3D=3D GCRY_CIPHER_NONE) { error_setg(errp, "Unsupported cipher algorithm %s", - QCryptoCipherAlgorithm_str(alg)); + QCryptoCipherAlgo_str(alg)); return NULL; } =20 diff --git a/crypto/cipher-gnutls.c.inc b/crypto/cipher-gnutls.c.inc index d3e231c13c..b9450d48b0 100644 --- a/crypto/cipher-gnutls.c.inc +++ b/crypto/cipher-gnutls.c.inc @@ -27,7 +27,7 @@ #define QEMU_GNUTLS_XTS #endif =20 -bool qcrypto_cipher_supports(QCryptoCipherAlgorithm alg, +bool qcrypto_cipher_supports(QCryptoCipherAlgo alg, QCryptoCipherMode mode) { =20 @@ -35,11 +35,11 @@ bool qcrypto_cipher_supports(QCryptoCipherAlgorithm alg, case QCRYPTO_CIPHER_MODE_ECB: case QCRYPTO_CIPHER_MODE_CBC: switch (alg) { - case QCRYPTO_CIPHER_ALG_AES_128: - case QCRYPTO_CIPHER_ALG_AES_192: - case QCRYPTO_CIPHER_ALG_AES_256: - case QCRYPTO_CIPHER_ALG_DES: - case QCRYPTO_CIPHER_ALG_3DES: + case QCRYPTO_CIPHER_ALGO_AES_128: + case QCRYPTO_CIPHER_ALGO_AES_192: + case QCRYPTO_CIPHER_ALGO_AES_256: + case QCRYPTO_CIPHER_ALGO_DES: + case QCRYPTO_CIPHER_ALGO_3DES: return true; default: return false; @@ -47,8 +47,8 @@ bool qcrypto_cipher_supports(QCryptoCipherAlgorithm alg, #ifdef QEMU_GNUTLS_XTS case QCRYPTO_CIPHER_MODE_XTS: switch (alg) { - case QCRYPTO_CIPHER_ALG_AES_128: - case QCRYPTO_CIPHER_ALG_AES_256: + case QCRYPTO_CIPHER_ALGO_AES_128: + case QCRYPTO_CIPHER_ALGO_AES_256: return true; default: return false; @@ -229,7 +229,7 @@ static struct QCryptoCipherDriver gnutls_driver =3D { .cipher_free =3D qcrypto_gnutls_cipher_free, }; =20 -static QCryptoCipher *qcrypto_cipher_ctx_new(QCryptoCipherAlgorithm alg, +static QCryptoCipher *qcrypto_cipher_ctx_new(QCryptoCipherAlgo alg, QCryptoCipherMode mode, const uint8_t *key, size_t nkey, @@ -244,10 +244,10 @@ static QCryptoCipher *qcrypto_cipher_ctx_new(QCryptoC= ipherAlgorithm alg, #ifdef QEMU_GNUTLS_XTS case QCRYPTO_CIPHER_MODE_XTS: switch (alg) { - case QCRYPTO_CIPHER_ALG_AES_128: + case QCRYPTO_CIPHER_ALGO_AES_128: galg =3D GNUTLS_CIPHER_AES_128_XTS; break; - case QCRYPTO_CIPHER_ALG_AES_256: + case QCRYPTO_CIPHER_ALGO_AES_256: galg =3D GNUTLS_CIPHER_AES_256_XTS; break; default: @@ -259,19 +259,19 @@ static QCryptoCipher *qcrypto_cipher_ctx_new(QCryptoC= ipherAlgorithm alg, case QCRYPTO_CIPHER_MODE_ECB: case QCRYPTO_CIPHER_MODE_CBC: switch (alg) { - case QCRYPTO_CIPHER_ALG_AES_128: + case QCRYPTO_CIPHER_ALGO_AES_128: galg =3D GNUTLS_CIPHER_AES_128_CBC; break; - case QCRYPTO_CIPHER_ALG_AES_192: + case QCRYPTO_CIPHER_ALGO_AES_192: galg =3D GNUTLS_CIPHER_AES_192_CBC; break; - case QCRYPTO_CIPHER_ALG_AES_256: + case QCRYPTO_CIPHER_ALGO_AES_256: galg =3D GNUTLS_CIPHER_AES_256_CBC; break; - case QCRYPTO_CIPHER_ALG_DES: + case QCRYPTO_CIPHER_ALGO_DES: galg =3D GNUTLS_CIPHER_DES_CBC; break; - case QCRYPTO_CIPHER_ALG_3DES: + case QCRYPTO_CIPHER_ALGO_3DES: galg =3D GNUTLS_CIPHER_3DES_CBC; break; default: @@ -284,7 +284,7 @@ static QCryptoCipher *qcrypto_cipher_ctx_new(QCryptoCip= herAlgorithm alg, =20 if (galg =3D=3D GNUTLS_CIPHER_UNKNOWN) { error_setg(errp, "Unsupported cipher algorithm %s with %s mode", - QCryptoCipherAlgorithm_str(alg), + QCryptoCipherAlgo_str(alg), QCryptoCipherMode_str(mode)); return NULL; } @@ -310,8 +310,8 @@ static QCryptoCipher *qcrypto_cipher_ctx_new(QCryptoCip= herAlgorithm alg, } } =20 - if (alg =3D=3D QCRYPTO_CIPHER_ALG_DES || - alg =3D=3D QCRYPTO_CIPHER_ALG_3DES) + if (alg =3D=3D QCRYPTO_CIPHER_ALGO_DES || + alg =3D=3D QCRYPTO_CIPHER_ALGO_3DES) ctx->blocksize =3D 8; else ctx->blocksize =3D 16; diff --git a/crypto/cipher-nettle.c.inc b/crypto/cipher-nettle.c.inc index 42b39e18a2..ece5d65492 100644 --- a/crypto/cipher-nettle.c.inc +++ b/crypto/cipher-nettle.c.inc @@ -454,24 +454,24 @@ DEFINE_ECB(qcrypto_nettle_sm4, sm4_encrypt_native, sm4_decrypt_native) #endif =20 -bool qcrypto_cipher_supports(QCryptoCipherAlgorithm alg, +bool qcrypto_cipher_supports(QCryptoCipherAlgo alg, QCryptoCipherMode mode) { switch (alg) { - case QCRYPTO_CIPHER_ALG_DES: - case QCRYPTO_CIPHER_ALG_3DES: - case QCRYPTO_CIPHER_ALG_AES_128: - case QCRYPTO_CIPHER_ALG_AES_192: - case QCRYPTO_CIPHER_ALG_AES_256: - case QCRYPTO_CIPHER_ALG_CAST5_128: - case QCRYPTO_CIPHER_ALG_SERPENT_128: - case QCRYPTO_CIPHER_ALG_SERPENT_192: - case QCRYPTO_CIPHER_ALG_SERPENT_256: - case QCRYPTO_CIPHER_ALG_TWOFISH_128: - case QCRYPTO_CIPHER_ALG_TWOFISH_192: - case QCRYPTO_CIPHER_ALG_TWOFISH_256: + case QCRYPTO_CIPHER_ALGO_DES: + case QCRYPTO_CIPHER_ALGO_3DES: + case QCRYPTO_CIPHER_ALGO_AES_128: + case QCRYPTO_CIPHER_ALGO_AES_192: + case QCRYPTO_CIPHER_ALGO_AES_256: + case QCRYPTO_CIPHER_ALGO_CAST5_128: + case QCRYPTO_CIPHER_ALGO_SERPENT_128: + case QCRYPTO_CIPHER_ALGO_SERPENT_192: + case QCRYPTO_CIPHER_ALGO_SERPENT_256: + case QCRYPTO_CIPHER_ALGO_TWOFISH_128: + case QCRYPTO_CIPHER_ALGO_TWOFISH_192: + case QCRYPTO_CIPHER_ALGO_TWOFISH_256: #ifdef CONFIG_CRYPTO_SM4 - case QCRYPTO_CIPHER_ALG_SM4: + case QCRYPTO_CIPHER_ALGO_SM4: #endif break; default: @@ -489,7 +489,7 @@ bool qcrypto_cipher_supports(QCryptoCipherAlgorithm alg, } } =20 -static QCryptoCipher *qcrypto_cipher_ctx_new(QCryptoCipherAlgorithm alg, +static QCryptoCipher *qcrypto_cipher_ctx_new(QCryptoCipherAlgo alg, QCryptoCipherMode mode, const uint8_t *key, size_t nkey, @@ -510,7 +510,7 @@ static QCryptoCipher *qcrypto_cipher_ctx_new(QCryptoCip= herAlgorithm alg, } =20 switch (alg) { - case QCRYPTO_CIPHER_ALG_DES: + case QCRYPTO_CIPHER_ALGO_DES: { QCryptoNettleDES *ctx; const QCryptoCipherDriver *drv; @@ -536,7 +536,7 @@ static QCryptoCipher *qcrypto_cipher_ctx_new(QCryptoCip= herAlgorithm alg, return &ctx->base; } =20 - case QCRYPTO_CIPHER_ALG_3DES: + case QCRYPTO_CIPHER_ALGO_3DES: { QCryptoNettleDES3 *ctx; const QCryptoCipherDriver *drv; @@ -561,7 +561,7 @@ static QCryptoCipher *qcrypto_cipher_ctx_new(QCryptoCip= herAlgorithm alg, return &ctx->base; } =20 - case QCRYPTO_CIPHER_ALG_AES_128: + case QCRYPTO_CIPHER_ALGO_AES_128: { QCryptoNettleAES128 *ctx =3D g_new0(QCryptoNettleAES128, 1); =20 @@ -590,7 +590,7 @@ static QCryptoCipher *qcrypto_cipher_ctx_new(QCryptoCip= herAlgorithm alg, return &ctx->base; } =20 - case QCRYPTO_CIPHER_ALG_AES_192: + case QCRYPTO_CIPHER_ALGO_AES_192: { QCryptoNettleAES192 *ctx =3D g_new0(QCryptoNettleAES192, 1); =20 @@ -619,7 +619,7 @@ static QCryptoCipher *qcrypto_cipher_ctx_new(QCryptoCip= herAlgorithm alg, return &ctx->base; } =20 - case QCRYPTO_CIPHER_ALG_AES_256: + case QCRYPTO_CIPHER_ALGO_AES_256: { QCryptoNettleAES256 *ctx =3D g_new0(QCryptoNettleAES256, 1); =20 @@ -648,7 +648,7 @@ static QCryptoCipher *qcrypto_cipher_ctx_new(QCryptoCip= herAlgorithm alg, return &ctx->base; } =20 - case QCRYPTO_CIPHER_ALG_CAST5_128: + case QCRYPTO_CIPHER_ALGO_CAST5_128: { QCryptoNettleCAST128 *ctx; const QCryptoCipherDriver *drv; @@ -674,9 +674,9 @@ static QCryptoCipher *qcrypto_cipher_ctx_new(QCryptoCip= herAlgorithm alg, return &ctx->base; } =20 - case QCRYPTO_CIPHER_ALG_SERPENT_128: - case QCRYPTO_CIPHER_ALG_SERPENT_192: - case QCRYPTO_CIPHER_ALG_SERPENT_256: + case QCRYPTO_CIPHER_ALGO_SERPENT_128: + case QCRYPTO_CIPHER_ALGO_SERPENT_192: + case QCRYPTO_CIPHER_ALGO_SERPENT_256: { QCryptoNettleSerpent *ctx =3D g_new0(QCryptoNettleSerpent, 1); =20 @@ -703,9 +703,9 @@ static QCryptoCipher *qcrypto_cipher_ctx_new(QCryptoCip= herAlgorithm alg, return &ctx->base; } =20 - case QCRYPTO_CIPHER_ALG_TWOFISH_128: - case QCRYPTO_CIPHER_ALG_TWOFISH_192: - case QCRYPTO_CIPHER_ALG_TWOFISH_256: + case QCRYPTO_CIPHER_ALGO_TWOFISH_128: + case QCRYPTO_CIPHER_ALGO_TWOFISH_192: + case QCRYPTO_CIPHER_ALGO_TWOFISH_256: { QCryptoNettleTwofish *ctx =3D g_new0(QCryptoNettleTwofish, 1); =20 @@ -732,7 +732,7 @@ static QCryptoCipher *qcrypto_cipher_ctx_new(QCryptoCip= herAlgorithm alg, return &ctx->base; } #ifdef CONFIG_CRYPTO_SM4 - case QCRYPTO_CIPHER_ALG_SM4: + case QCRYPTO_CIPHER_ALGO_SM4: { QCryptoNettleSm4 *ctx =3D g_new0(QCryptoNettleSm4, 1); =20 @@ -753,7 +753,7 @@ static QCryptoCipher *qcrypto_cipher_ctx_new(QCryptoCip= herAlgorithm alg, =20 default: error_setg(errp, "Unsupported cipher algorithm %s", - QCryptoCipherAlgorithm_str(alg)); + QCryptoCipherAlgo_str(alg)); return NULL; } =20 --=20 2.46.0 From nobody Sun Nov 24 08:32:09 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=1725449303; cv=none; d=zohomail.com; s=zohoarc; b=VrwNZqQga2k+RwNDv0u+2UAvY96yT7UXwb44T0APHtPxywfQ56sMUHZ8aLLWGVR7iUDT/9Oi+t82rREr+FubRM3EVEO2GMcHdOFLXdLoh2j9nJzS2qqQJky7NgoBdCJqUfbsFI04z3Qi1ivduzkRuTWVrB4tmoXq06zI0hx2Zxc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1725449303; 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=tvQ0bkuh975N3/39hMCT7dsPlX5V08GBG2VFlBYmSHw=; b=DLgadqfjo7t8bt9da+pcL7uNWEDjFfjYN1fcue2iD8yIKId0ziTfghzd/igBMidTK5++lXW22hvRkZ/gzUyzL3tWAMrDHHHPIXHrz+N9cl6A31M5im1EoL4TlqzWBgHQzl/gxUZM1QSZ89iJ9yekBS057z3XCDaESdUkM7N37UM= 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 17254493035051018.8635497461094; Wed, 4 Sep 2024 04:28:23 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1slo96-0008H9-Vg; Wed, 04 Sep 2024 07:25:57 -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 1slo8h-0006JG-5Y for qemu-devel@nongnu.org; Wed, 04 Sep 2024 07:25:32 -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 1slo8W-0004V1-AY for qemu-devel@nongnu.org; Wed, 04 Sep 2024 07:25:30 -0400 Received: from mx-prod-mc-02.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-597-kfPfu0HXPWi1c5ZIfT_ZuQ-1; Wed, 04 Sep 2024 07:18:51 -0400 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (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-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 4F2C31953963; Wed, 4 Sep 2024 11:18:47 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.192.112]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id B6E9919560AB; Wed, 4 Sep 2024 11:18:46 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id C8E4721E682B; 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=tvQ0bkuh975N3/39hMCT7dsPlX5V08GBG2VFlBYmSHw=; b=WGo7sGzp+dV2iYVt7cJpVtCAMUVxawGqF8qLvRVUSpAsplDUrTngaTzqNl0jGlOstNYIrA 4Ld2rnwP+Ruhg8evPv+J1yEn2rbXtzAhdKOn4nrncgya7+g0aUNnfvPxGiyWwKw+aMa0OP 1uvOpSvnUQqMw0PC6mtIHxYhvwzpiak= X-MC-Unique: kfPfu0HXPWi1c5ZIfT_ZuQ-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 13/19] qapi/crypto: Rename QCryptoIVGenAlgorithm to *Algo, and drop prefix Date: Wed, 4 Sep 2024 13:18:30 +0200 Message-ID: <20240904111836.3273842-14-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.0 on 10.30.177.12 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: 1725449304573116600 QAPI's 'prefix' feature can make the connection between enumeration type and its constants less than obvious. It's best used with restraint. QCryptoIVGenAlgorithm has a 'prefix' that overrides the generated enumeration constants' prefix to QCRYPTO_IVGEN_ALG. We could simply drop 'prefix', but then the prefix becomes QCRYPTO_IV_GEN_ALGORITHM, which is rather long. We could additionally rename the type to QCryptoIVGenAlg, but I think the abbreviation "alg" is less than clear. Rename the type to QCryptoIVGenAlgo instead. The prefix becomes QCRYPTO_IV_GEN_ALGO. Signed-off-by: Markus Armbruster Acked-by: Daniel P. Berrang=C3=A9 --- qapi/crypto.json | 9 ++++----- crypto/ivgenpriv.h | 2 +- include/crypto/ivgen.h | 14 +++++++------- crypto/block-luks.c | 16 ++++++++-------- crypto/block-qcow.c | 2 +- crypto/ivgen.c | 10 +++++----- tests/unit/test-crypto-block.c | 14 +++++++------- tests/unit/test-crypto-ivgen.c | 22 +++++++++++----------- 8 files changed, 44 insertions(+), 45 deletions(-) diff --git a/qapi/crypto.json b/qapi/crypto.json index 0591d62f67..3e6a7fb8e5 100644 --- a/qapi/crypto.json +++ b/qapi/crypto.json @@ -122,7 +122,7 @@ 'data': ['ecb', 'cbc', 'xts', 'ctr']} =20 ## -# @QCryptoIVGenAlgorithm: +# @QCryptoIVGenAlgo: # # The supported algorithms for generating initialization vectors for # full disk encryption. The 'plain' generator should not be used for @@ -138,8 +138,7 @@ # # Since: 2.6 ## -{ 'enum': 'QCryptoIVGenAlgorithm', - 'prefix': 'QCRYPTO_IVGEN_ALG', +{ 'enum': 'QCryptoIVGenAlgo', 'data': ['plain', 'plain64', 'essiv']} =20 ## @@ -226,7 +225,7 @@ 'base': 'QCryptoBlockOptionsLUKS', 'data': { '*cipher-alg': 'QCryptoCipherAlgo', '*cipher-mode': 'QCryptoCipherMode', - '*ivgen-alg': 'QCryptoIVGenAlgorithm', + '*ivgen-alg': 'QCryptoIVGenAlgo', '*ivgen-hash-alg': 'QCryptoHashAlgo', '*hash-alg': 'QCryptoHashAlgo', '*iter-time': 'int' }} @@ -323,7 +322,7 @@ { 'struct': 'QCryptoBlockInfoLUKS', 'data': {'cipher-alg': 'QCryptoCipherAlgo', 'cipher-mode': 'QCryptoCipherMode', - 'ivgen-alg': 'QCryptoIVGenAlgorithm', + 'ivgen-alg': 'QCryptoIVGenAlgo', '*ivgen-hash-alg': 'QCryptoHashAlgo', 'hash-alg': 'QCryptoHashAlgo', 'detached-header': 'bool', diff --git a/crypto/ivgenpriv.h b/crypto/ivgenpriv.h index ef24c76345..e3388d30be 100644 --- a/crypto/ivgenpriv.h +++ b/crypto/ivgenpriv.h @@ -40,7 +40,7 @@ struct QCryptoIVGen { QCryptoIVGenDriver *driver; void *private; =20 - QCryptoIVGenAlgorithm algorithm; + QCryptoIVGenAlgo algorithm; QCryptoCipherAlgo cipher; QCryptoHashAlgo hash; }; diff --git a/include/crypto/ivgen.h b/include/crypto/ivgen.h index b059e332cd..bfa5d28103 100644 --- a/include/crypto/ivgen.h +++ b/include/crypto/ivgen.h @@ -44,7 +44,7 @@ * * g_assert((ndata % 512) =3D=3D 0); * - * QCryptoIVGen *ivgen =3D qcrypto_ivgen_new(QCRYPTO_IVGEN_ALG_ESSIV, + * QCryptoIVGen *ivgen =3D qcrypto_ivgen_new(QCRYPTO_IV_GEN_ALGO_ESSIV, * QCRYPTO_CIPHER_ALGO_AES_128, * QCRYPTO_HASH_ALGO_SHA256, * key, nkey, errp); @@ -97,7 +97,7 @@ =20 typedef struct QCryptoIVGen QCryptoIVGen; =20 -/* See also QCryptoIVGenAlgorithm enum in qapi/crypto.json */ +/* See also QCryptoIVGenAlgo enum in qapi/crypto.json */ =20 =20 /** @@ -113,19 +113,19 @@ typedef struct QCryptoIVGen QCryptoIVGen; * are required or not depends on the choice of @alg * requested. * - * - QCRYPTO_IVGEN_ALG_PLAIN + * - QCRYPTO_IV_GEN_ALGO_PLAIN * * The IVs are generated by the 32-bit truncated sector * number. This should never be used for block devices * that are larger than 2^32 sectors in size. * All the other parameters are unused. * - * - QCRYPTO_IVGEN_ALG_PLAIN64 + * - QCRYPTO_IV_GEN_ALGO_PLAIN64 * * The IVs are generated by the 64-bit sector number. * All the other parameters are unused. * - * - QCRYPTO_IVGEN_ALG_ESSIV: + * - QCRYPTO_IV_GEN_ALGO_ESSIV: * * The IVs are generated by encrypting the 64-bit sector * number with a hash of an encryption key. The @cipheralg, @@ -133,7 +133,7 @@ typedef struct QCryptoIVGen QCryptoIVGen; * * Returns: a new IV generator, or NULL on error */ -QCryptoIVGen *qcrypto_ivgen_new(QCryptoIVGenAlgorithm alg, +QCryptoIVGen *qcrypto_ivgen_new(QCryptoIVGenAlgo alg, QCryptoCipherAlgo cipheralg, QCryptoHashAlgo hash, const uint8_t *key, size_t nkey, @@ -167,7 +167,7 @@ int qcrypto_ivgen_calculate(QCryptoIVGen *ivgen, * * Returns: the IV generator algorithm */ -QCryptoIVGenAlgorithm qcrypto_ivgen_get_algorithm(QCryptoIVGen *ivgen); +QCryptoIVGenAlgo qcrypto_ivgen_get_algorithm(QCryptoIVGen *ivgen); =20 =20 /** diff --git a/crypto/block-luks.c b/crypto/block-luks.c index 8eadf124fc..0926ad28f0 100644 --- a/crypto/block-luks.c +++ b/crypto/block-luks.c @@ -129,7 +129,7 @@ struct QCryptoBlockLUKS { QCryptoCipherMode cipher_mode; =20 /* Initialization vector generation algorithm */ - QCryptoIVGenAlgorithm ivgen_alg; + QCryptoIVGenAlgo ivgen_alg; =20 /* Hash algorithm used for IV generation*/ QCryptoHashAlgo ivgen_hash_alg; @@ -229,7 +229,7 @@ static int qcrypto_block_luks_name_lookup(const char *n= ame, =20 #define qcrypto_block_luks_ivgen_name_lookup(name, errp) \ qcrypto_block_luks_name_lookup(name, \ - &QCryptoIVGenAlgorithm_lookup, \ + &QCryptoIVGenAlgo_lookup, \ "IV generator", \ errp) =20 @@ -660,7 +660,7 @@ qcrypto_block_luks_parse_header(QCryptoBlockLUKS *luks,= Error **errp) return -1; } =20 - if (luks->ivgen_alg =3D=3D QCRYPTO_IVGEN_ALG_ESSIV) { + if (luks->ivgen_alg =3D=3D QCRYPTO_IV_GEN_ALGO_ESSIV) { if (!ivhash_name) { error_setg(errp, "Missing IV generator hash specification"); return -1; @@ -1328,12 +1328,12 @@ qcrypto_block_luks_create(QCryptoBlock *block, luks_opts.cipher_mode =3D QCRYPTO_CIPHER_MODE_XTS; } if (!luks_opts.has_ivgen_alg) { - luks_opts.ivgen_alg =3D QCRYPTO_IVGEN_ALG_PLAIN64; + luks_opts.ivgen_alg =3D QCRYPTO_IV_GEN_ALGO_PLAIN64; } if (!luks_opts.has_hash_alg) { luks_opts.hash_alg =3D QCRYPTO_HASH_ALGO_SHA256; } - if (luks_opts.ivgen_alg =3D=3D QCRYPTO_IVGEN_ALG_ESSIV) { + if (luks_opts.ivgen_alg =3D=3D QCRYPTO_IV_GEN_ALGO_ESSIV) { if (!luks_opts.has_ivgen_hash_alg) { luks_opts.ivgen_hash_alg =3D QCRYPTO_HASH_ALGO_SHA256; luks_opts.has_ivgen_hash_alg =3D true; @@ -1384,7 +1384,7 @@ qcrypto_block_luks_create(QCryptoBlock *block, } =20 cipher_mode =3D QCryptoCipherMode_str(luks_opts.cipher_mode); - ivgen_alg =3D QCryptoIVGenAlgorithm_str(luks_opts.ivgen_alg); + ivgen_alg =3D QCryptoIVGenAlgo_str(luks_opts.ivgen_alg); if (luks_opts.has_ivgen_hash_alg) { ivgen_hash_alg =3D QCryptoHashAlgo_str(luks_opts.ivgen_hash_alg); cipher_mode_spec =3D g_strdup_printf("%s-%s:%s", cipher_mode, ivge= n_alg, @@ -1411,7 +1411,7 @@ qcrypto_block_luks_create(QCryptoBlock *block, goto error; } =20 - if (luks_opts.ivgen_alg =3D=3D QCRYPTO_IVGEN_ALG_ESSIV) { + if (luks_opts.ivgen_alg =3D=3D QCRYPTO_IV_GEN_ALGO_ESSIV) { luks->ivgen_cipher_alg =3D qcrypto_block_luks_essiv_cipher(luks_opts.cipher_alg, luks_opts.ivgen_hash_alg, @@ -1886,7 +1886,7 @@ static int qcrypto_block_luks_get_info(QCryptoBlock *= block, info->u.luks.cipher_alg =3D luks->cipher_alg; info->u.luks.cipher_mode =3D luks->cipher_mode; info->u.luks.ivgen_alg =3D luks->ivgen_alg; - if (info->u.luks.ivgen_alg =3D=3D QCRYPTO_IVGEN_ALG_ESSIV) { + if (info->u.luks.ivgen_alg =3D=3D QCRYPTO_IV_GEN_ALGO_ESSIV) { info->u.luks.has_ivgen_hash_alg =3D true; info->u.luks.ivgen_hash_alg =3D luks->ivgen_hash_alg; } diff --git a/crypto/block-qcow.c b/crypto/block-qcow.c index a0ba9c1f2e..054078b895 100644 --- a/crypto/block-qcow.c +++ b/crypto/block-qcow.c @@ -64,7 +64,7 @@ qcrypto_block_qcow_init(QCryptoBlock *block, =20 block->niv =3D qcrypto_cipher_get_iv_len(QCRYPTO_CIPHER_ALGO_AES_128, QCRYPTO_CIPHER_MODE_CBC); - block->ivgen =3D qcrypto_ivgen_new(QCRYPTO_IVGEN_ALG_PLAIN64, + block->ivgen =3D qcrypto_ivgen_new(QCRYPTO_IV_GEN_ALGO_PLAIN64, 0, 0, NULL, 0, errp); if (!block->ivgen) { ret =3D -ENOTSUP; diff --git a/crypto/ivgen.c b/crypto/ivgen.c index ec0cb1a25b..6b7d24d889 100644 --- a/crypto/ivgen.c +++ b/crypto/ivgen.c @@ -27,7 +27,7 @@ #include "ivgen-essiv.h" =20 =20 -QCryptoIVGen *qcrypto_ivgen_new(QCryptoIVGenAlgorithm alg, +QCryptoIVGen *qcrypto_ivgen_new(QCryptoIVGenAlgo alg, QCryptoCipherAlgo cipheralg, QCryptoHashAlgo hash, const uint8_t *key, size_t nkey, @@ -40,13 +40,13 @@ QCryptoIVGen *qcrypto_ivgen_new(QCryptoIVGenAlgorithm a= lg, ivgen->hash =3D hash; =20 switch (alg) { - case QCRYPTO_IVGEN_ALG_PLAIN: + case QCRYPTO_IV_GEN_ALGO_PLAIN: ivgen->driver =3D &qcrypto_ivgen_plain; break; - case QCRYPTO_IVGEN_ALG_PLAIN64: + case QCRYPTO_IV_GEN_ALGO_PLAIN64: ivgen->driver =3D &qcrypto_ivgen_plain64; break; - case QCRYPTO_IVGEN_ALG_ESSIV: + case QCRYPTO_IV_GEN_ALGO_ESSIV: ivgen->driver =3D &qcrypto_ivgen_essiv; break; default: @@ -73,7 +73,7 @@ int qcrypto_ivgen_calculate(QCryptoIVGen *ivgen, } =20 =20 -QCryptoIVGenAlgorithm qcrypto_ivgen_get_algorithm(QCryptoIVGen *ivgen) +QCryptoIVGenAlgo qcrypto_ivgen_get_algorithm(QCryptoIVGen *ivgen) { return ivgen->algorithm; } diff --git a/tests/unit/test-crypto-block.c b/tests/unit/test-crypto-block.c index 1a0d329368..9217b9a2ef 100644 --- a/tests/unit/test-crypto-block.c +++ b/tests/unit/test-crypto-block.c @@ -81,7 +81,7 @@ static QCryptoBlockCreateOptions luks_create_opts_aes256_= cbc_plain64 =3D { .has_cipher_mode =3D true, .cipher_mode =3D QCRYPTO_CIPHER_MODE_CBC, .has_ivgen_alg =3D true, - .ivgen_alg =3D QCRYPTO_IVGEN_ALG_PLAIN64, + .ivgen_alg =3D QCRYPTO_IV_GEN_ALGO_PLAIN64, }, }; =20 @@ -95,7 +95,7 @@ static QCryptoBlockCreateOptions luks_create_opts_aes256_= cbc_essiv =3D { .has_cipher_mode =3D true, .cipher_mode =3D QCRYPTO_CIPHER_MODE_CBC, .has_ivgen_alg =3D true, - .ivgen_alg =3D QCRYPTO_IVGEN_ALG_ESSIV, + .ivgen_alg =3D QCRYPTO_IV_GEN_ALGO_ESSIV, .has_ivgen_hash_alg =3D true, .ivgen_hash_alg =3D QCRYPTO_HASH_ALGO_SHA256, .has_hash_alg =3D true, @@ -116,7 +116,7 @@ static struct QCryptoBlockTestData { QCryptoCipherMode cipher_mode; QCryptoHashAlgo hash_alg; =20 - QCryptoIVGenAlgorithm ivgen_alg; + QCryptoIVGenAlgo ivgen_alg; QCryptoHashAlgo ivgen_hash; =20 bool slow; @@ -131,7 +131,7 @@ static struct QCryptoBlockTestData { .cipher_alg =3D QCRYPTO_CIPHER_ALGO_AES_128, .cipher_mode =3D QCRYPTO_CIPHER_MODE_CBC, =20 - .ivgen_alg =3D QCRYPTO_IVGEN_ALG_PLAIN64, + .ivgen_alg =3D QCRYPTO_IV_GEN_ALGO_PLAIN64, }, #ifdef TEST_LUKS { @@ -145,7 +145,7 @@ static struct QCryptoBlockTestData { .cipher_mode =3D QCRYPTO_CIPHER_MODE_XTS, .hash_alg =3D QCRYPTO_HASH_ALGO_SHA256, =20 - .ivgen_alg =3D QCRYPTO_IVGEN_ALG_PLAIN64, + .ivgen_alg =3D QCRYPTO_IV_GEN_ALGO_PLAIN64, =20 .slow =3D true, }, @@ -160,7 +160,7 @@ static struct QCryptoBlockTestData { .cipher_mode =3D QCRYPTO_CIPHER_MODE_CBC, .hash_alg =3D QCRYPTO_HASH_ALGO_SHA256, =20 - .ivgen_alg =3D QCRYPTO_IVGEN_ALG_PLAIN64, + .ivgen_alg =3D QCRYPTO_IV_GEN_ALGO_PLAIN64, =20 .slow =3D true, }, @@ -175,7 +175,7 @@ static struct QCryptoBlockTestData { .cipher_mode =3D QCRYPTO_CIPHER_MODE_CBC, .hash_alg =3D QCRYPTO_HASH_ALGO_SHA1, =20 - .ivgen_alg =3D QCRYPTO_IVGEN_ALG_ESSIV, + .ivgen_alg =3D QCRYPTO_IV_GEN_ALGO_ESSIV, .ivgen_hash =3D QCRYPTO_HASH_ALGO_SHA256, =20 .slow =3D true, diff --git a/tests/unit/test-crypto-ivgen.c b/tests/unit/test-crypto-ivgen.c index 6b4110775a..bc9ffe34e7 100644 --- a/tests/unit/test-crypto-ivgen.c +++ b/tests/unit/test-crypto-ivgen.c @@ -26,7 +26,7 @@ struct QCryptoIVGenTestData { const char *path; uint64_t sector; - QCryptoIVGenAlgorithm ivalg; + QCryptoIVGenAlgo ivalg; QCryptoHashAlgo hashalg; QCryptoCipherAlgo cipheralg; const uint8_t *key; @@ -38,7 +38,7 @@ struct QCryptoIVGenTestData { { "/crypto/ivgen/plain/1", .sector =3D 0x1, - .ivalg =3D QCRYPTO_IVGEN_ALG_PLAIN, + .ivalg =3D QCRYPTO_IV_GEN_ALGO_PLAIN, .iv =3D (const uint8_t *)"\x01\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00", .niv =3D 16, @@ -47,7 +47,7 @@ struct QCryptoIVGenTestData { { "/crypto/ivgen/plain/1f2e3d4c", .sector =3D 0x1f2e3d4cULL, - .ivalg =3D QCRYPTO_IVGEN_ALG_PLAIN, + .ivalg =3D QCRYPTO_IV_GEN_ALGO_PLAIN, .iv =3D (const uint8_t *)"\x4c\x3d\x2e\x1f\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00", .niv =3D 16, @@ -56,7 +56,7 @@ struct QCryptoIVGenTestData { { "/crypto/ivgen/plain/1f2e3d4c5b6a7988", .sector =3D 0x1f2e3d4c5b6a7988ULL, - .ivalg =3D QCRYPTO_IVGEN_ALG_PLAIN, + .ivalg =3D QCRYPTO_IV_GEN_ALGO_PLAIN, .iv =3D (const uint8_t *)"\x88\x79\x6a\x5b\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00", .niv =3D 16, @@ -65,7 +65,7 @@ struct QCryptoIVGenTestData { { "/crypto/ivgen/plain64/1", .sector =3D 0x1, - .ivalg =3D QCRYPTO_IVGEN_ALG_PLAIN64, + .ivalg =3D QCRYPTO_IV_GEN_ALGO_PLAIN64, .iv =3D (const uint8_t *)"\x01\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00", .niv =3D 16, @@ -74,7 +74,7 @@ struct QCryptoIVGenTestData { { "/crypto/ivgen/plain64/1f2e3d4c", .sector =3D 0x1f2e3d4cULL, - .ivalg =3D QCRYPTO_IVGEN_ALG_PLAIN64, + .ivalg =3D QCRYPTO_IV_GEN_ALGO_PLAIN64, .iv =3D (const uint8_t *)"\x4c\x3d\x2e\x1f\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00", .niv =3D 16, @@ -83,7 +83,7 @@ struct QCryptoIVGenTestData { { "/crypto/ivgen/plain64/1f2e3d4c5b6a7988", .sector =3D 0x1f2e3d4c5b6a7988ULL, - .ivalg =3D QCRYPTO_IVGEN_ALG_PLAIN64, + .ivalg =3D QCRYPTO_IV_GEN_ALGO_PLAIN64, .iv =3D (const uint8_t *)"\x88\x79\x6a\x5b\x4c\x3d\x2e\x1f" "\x00\x00\x00\x00\x00\x00\x00\x00", .niv =3D 16, @@ -92,7 +92,7 @@ struct QCryptoIVGenTestData { { "/crypto/ivgen/essiv/1", .sector =3D 0x1, - .ivalg =3D QCRYPTO_IVGEN_ALG_ESSIV, + .ivalg =3D QCRYPTO_IV_GEN_ALGO_ESSIV, .cipheralg =3D QCRYPTO_CIPHER_ALGO_AES_128, .hashalg =3D QCRYPTO_HASH_ALGO_SHA256, .key =3D (const uint8_t *)"\x00\x01\x02\x03\x04\x05\x06\x07" @@ -106,7 +106,7 @@ struct QCryptoIVGenTestData { { "/crypto/ivgen/essiv/1f2e3d4c", .sector =3D 0x1f2e3d4cULL, - .ivalg =3D QCRYPTO_IVGEN_ALG_ESSIV, + .ivalg =3D QCRYPTO_IV_GEN_ALGO_ESSIV, .cipheralg =3D QCRYPTO_CIPHER_ALGO_AES_128, .hashalg =3D QCRYPTO_HASH_ALGO_SHA256, .key =3D (const uint8_t *)"\x00\x01\x02\x03\x04\x05\x06\x07" @@ -120,7 +120,7 @@ struct QCryptoIVGenTestData { { "/crypto/ivgen/essiv/1f2e3d4c5b6a7988", .sector =3D 0x1f2e3d4c5b6a7988ULL, - .ivalg =3D QCRYPTO_IVGEN_ALG_ESSIV, + .ivalg =3D QCRYPTO_IV_GEN_ALGO_ESSIV, .cipheralg =3D QCRYPTO_CIPHER_ALGO_AES_128, .hashalg =3D QCRYPTO_HASH_ALGO_SHA256, .key =3D (const uint8_t *)"\x00\x01\x02\x03\x04\x05\x06\x07" @@ -166,7 +166,7 @@ int main(int argc, char **argv) size_t i; g_test_init(&argc, &argv, NULL); for (i =3D 0; i < G_N_ELEMENTS(test_data); i++) { - if (test_data[i].ivalg =3D=3D QCRYPTO_IVGEN_ALG_ESSIV && + if (test_data[i].ivalg =3D=3D QCRYPTO_IV_GEN_ALGO_ESSIV && !qcrypto_hash_supports(test_data[i].hashalg)) { continue; } --=20 2.46.0 From nobody Sun Nov 24 08:32:09 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 From nobody Sun Nov 24 08:32:09 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=1725449300; cv=none; d=zohomail.com; s=zohoarc; b=CMnvlRGBZrr7MQGKgvDAPpS47P7LNOabTXectocUqnbs2a4vhj+uzBTO427LvWoatSWEEVPch5exzWkq94+BEerfJ4DVrQSJ8aQKxDdFcagcx7Rd8UbvdqZPfbAKHISB3Ko/4P2WeJ8O4Z4yxHCAYUnJc+8mjgbtM1hwHK0lF6g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1725449300; 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=70jMuVZso5R0028zPf4/S/G6TSwBNhjs4yo5beZEVtA=; b=If1D1Qu0ademVMlNG1ykG9BwjHC8fITFA4lgQtuqsGn311KYXBjmsQ11ohOV8cVjtgzYjWyJK3ipHxsvSY95T7SNuttBJTtOZcLiIs/+8Ao9CcaF5ZCmfLOgeNcMbYvN8cktzKCLI0WS/4e4Jr9CAZptoHyhVpCr/VGTH/9XtBo= 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 1725449300202903.8711686935674; Wed, 4 Sep 2024 04:28:20 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1slo9h-0003dU-D7; Wed, 04 Sep 2024 07:26:33 -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 1slo9M-0001Yr-HE for qemu-devel@nongnu.org; Wed, 04 Sep 2024 07:26:12 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1slo9D-0004kl-1F for qemu-devel@nongnu.org; Wed, 04 Sep 2024 07:26:12 -0400 Received: from mx-prod-mc-03.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-444-EQ1bwIKsP2y4bb1iuwKx4A-1; Wed, 04 Sep 2024 07:18:51 -0400 Received: from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.15]) (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-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 7AACE1955D80; Wed, 4 Sep 2024 11:18:47 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.192.112]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id E9A431956086; Wed, 4 Sep 2024 11:18:46 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id D25F121E682D; 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=1725449161; 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=70jMuVZso5R0028zPf4/S/G6TSwBNhjs4yo5beZEVtA=; b=WtjVQ2rEp0ruPwq5XowTsQhL4tpEpsJw0t5+sg9knPntTts8n6MQnVmz8o26+bxuNFIlAe cvrzORYGi4sNJRmTbtACScu3+M6Ny9XDxVWiiEOCz4ekArJXNAQ2CbQDBF5sYSF7qSrOGN 8KPo0fLe+txktPlhp5CNH70TGdYQMpk= X-MC-Unique: EQ1bwIKsP2y4bb1iuwKx4A-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 15/19] qapi/crypto: Rename QCryptoRSAPaddingAlgorithm to *Algo, and drop prefix Date: Wed, 4 Sep 2024 13:18:32 +0200 Message-ID: <20240904111836.3273842-16-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.0 on 10.30.177.15 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.129.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_H3=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: 1725449302618116600 QAPI's 'prefix' feature can make the connection between enumeration type and its constants less than obvious. It's best used with restraint. QCryptoRSAPaddingAlgorithm has a 'prefix' that overrides the generated enumeration constants' prefix to QCRYPTO_RSA_PADDING_ALG. We could simply drop 'prefix', but then the prefix becomes QCRYPTO_RSA_PADDING_ALGORITHM, which is rather long. We could additionally rename the type to QCryptoRSAPaddingAlg, but I think the abbreviation "alg" is less than clear. Rename the type to QCryptoRSAPaddingAlgo instead. The prefix becomes QCRYPTO_RSA_PADDING_ALGO. Signed-off-by: Markus Armbruster Acked-by: Daniel P. Berrang=C3=A9 --- qapi/crypto.json | 9 ++++----- backends/cryptodev-builtin.c | 6 +++--- backends/cryptodev-lkcf.c | 10 +++++----- tests/bench/benchmark-crypto-akcipher.c | 12 ++++++------ tests/unit/test-crypto-akcipher.c | 10 +++++----- crypto/akcipher-gcrypt.c.inc | 18 +++++++++--------- crypto/akcipher-nettle.c.inc | 18 +++++++++--------- 7 files changed, 41 insertions(+), 42 deletions(-) diff --git a/qapi/crypto.json b/qapi/crypto.json index 331d49ebb8..867b09d322 100644 --- a/qapi/crypto.json +++ b/qapi/crypto.json @@ -608,7 +608,7 @@ 'data': ['public', 'private']} =20 ## -# @QCryptoRSAPaddingAlgorithm: +# @QCryptoRSAPaddingAlgo: # # The padding algorithm for RSA. # @@ -618,8 +618,7 @@ # # Since: 7.1 ## -{ 'enum': 'QCryptoRSAPaddingAlgorithm', - 'prefix': 'QCRYPTO_RSA_PADDING_ALG', +{ 'enum': 'QCryptoRSAPaddingAlgo', 'data': ['raw', 'pkcs1']} =20 ## @@ -629,13 +628,13 @@ # # @hash-alg: QCryptoHashAlgo # -# @padding-alg: QCryptoRSAPaddingAlgorithm +# @padding-alg: QCryptoRSAPaddingAlgo # # Since: 7.1 ## { 'struct': 'QCryptoAkCipherOptionsRSA', 'data': { 'hash-alg':'QCryptoHashAlgo', - 'padding-alg': 'QCryptoRSAPaddingAlgorithm'}} + 'padding-alg': 'QCryptoRSAPaddingAlgo'}} =20 ## # @QCryptoAkCipherOptions: diff --git a/backends/cryptodev-builtin.c b/backends/cryptodev-builtin.c index d8b64091b6..6f3990481b 100644 --- a/backends/cryptodev-builtin.c +++ b/backends/cryptodev-builtin.c @@ -65,7 +65,7 @@ static void cryptodev_builtin_init_akcipher(CryptoDevBack= end *backend) QCryptoAkCipherOptions opts; =20 opts.alg =3D QCRYPTO_AK_CIPHER_ALGO_RSA; - opts.u.rsa.padding_alg =3D QCRYPTO_RSA_PADDING_ALG_RAW; + opts.u.rsa.padding_alg =3D QCRYPTO_RSA_PADDING_ALGO_RAW; if (qcrypto_akcipher_supports(&opts)) { backend->conf.crypto_services |=3D (1u << QCRYPTODEV_BACKEND_SERVICE_AKCIPHER); @@ -200,12 +200,12 @@ static int cryptodev_builtin_set_rsa_options( return -1; } opt->hash_alg =3D hash_alg; - opt->padding_alg =3D QCRYPTO_RSA_PADDING_ALG_PKCS1; + opt->padding_alg =3D QCRYPTO_RSA_PADDING_ALGO_PKCS1; return 0; } =20 if (virtio_padding_algo =3D=3D VIRTIO_CRYPTO_RSA_RAW_PADDING) { - opt->padding_alg =3D QCRYPTO_RSA_PADDING_ALG_RAW; + opt->padding_alg =3D QCRYPTO_RSA_PADDING_ALGO_RAW; return 0; } =20 diff --git a/backends/cryptodev-lkcf.c b/backends/cryptodev-lkcf.c index 6fb6e03d98..fde32950f6 100644 --- a/backends/cryptodev-lkcf.c +++ b/backends/cryptodev-lkcf.c @@ -139,14 +139,14 @@ static int cryptodev_lkcf_set_op_desc(QCryptoAkCipher= Options *opts, } =20 rsa_opt =3D &opts->u.rsa; - if (rsa_opt->padding_alg =3D=3D QCRYPTO_RSA_PADDING_ALG_PKCS1) { + if (rsa_opt->padding_alg =3D=3D QCRYPTO_RSA_PADDING_ALGO_PKCS1) { snprintf(key_desc, desc_len, "enc=3D%s hash=3D%s", - QCryptoRSAPaddingAlgorithm_str(rsa_opt->padding_alg), + QCryptoRSAPaddingAlgo_str(rsa_opt->padding_alg), QCryptoHashAlgo_str(rsa_opt->hash_alg)); =20 } else { snprintf(key_desc, desc_len, "enc=3D%s", - QCryptoRSAPaddingAlgorithm_str(rsa_opt->padding_alg)); + QCryptoRSAPaddingAlgo_str(rsa_opt->padding_alg)); } return 0; } @@ -157,7 +157,7 @@ static int cryptodev_lkcf_set_rsa_opt(int virtio_paddin= g_alg, Error **errp) { if (virtio_padding_alg =3D=3D VIRTIO_CRYPTO_RSA_PKCS1_PADDING) { - opt->padding_alg =3D QCRYPTO_RSA_PADDING_ALG_PKCS1; + opt->padding_alg =3D QCRYPTO_RSA_PADDING_ALGO_PKCS1; =20 switch (virtio_hash_alg) { case VIRTIO_CRYPTO_RSA_MD5: @@ -184,7 +184,7 @@ static int cryptodev_lkcf_set_rsa_opt(int virtio_paddin= g_alg, } =20 if (virtio_padding_alg =3D=3D VIRTIO_CRYPTO_RSA_RAW_PADDING) { - opt->padding_alg =3D QCRYPTO_RSA_PADDING_ALG_RAW; + opt->padding_alg =3D QCRYPTO_RSA_PADDING_ALGO_RAW; return 0; } =20 diff --git a/tests/bench/benchmark-crypto-akcipher.c b/tests/bench/benchmar= k-crypto-akcipher.c index 225e426bde..750c7e89ee 100644 --- a/tests/bench/benchmark-crypto-akcipher.c +++ b/tests/bench/benchmark-crypto-akcipher.c @@ -20,7 +20,7 @@ =20 static QCryptoAkCipher *create_rsa_akcipher(const uint8_t *priv_key, size_t keylen, - QCryptoRSAPaddingAlgorithm pad= ding, + QCryptoRSAPaddingAlgo padding, QCryptoHashAlgo hash) { QCryptoAkCipherOptions opt; @@ -39,7 +39,7 @@ static void test_rsa_speed(const uint8_t *priv_key, size_= t keylen, #define SHA1_DGST_LEN 20 #define SIGN_TIMES 10000 #define VERIFY_TIMES 100000 -#define PADDING QCRYPTO_RSA_PADDING_ALG_PKCS1 +#define PADDING QCRYPTO_RSA_PADDING_ALGO_PKCS1 #define HASH QCRYPTO_HASH_ALGO_SHA1 =20 g_autoptr(QCryptoAkCipher) rsa =3D @@ -53,7 +53,7 @@ static void test_rsa_speed(const uint8_t *priv_key, size_= t keylen, signature =3D g_new0(uint8_t, key_size / BYTE); =20 g_test_message("benchmark rsa%zu (%s-%s) sign...", key_size, - QCryptoRSAPaddingAlgorithm_str(PADDING), + QCryptoRSAPaddingAlgo_str(PADDING), QCryptoHashAlgo_str(HASH)); g_test_timer_start(); for (count =3D 0; count < SIGN_TIMES; ++count) { @@ -64,13 +64,13 @@ static void test_rsa_speed(const uint8_t *priv_key, siz= e_t keylen, g_test_timer_elapsed(); g_test_message("rsa%zu (%s-%s) sign %zu times in %.2f seconds," " %.2f times/sec ", - key_size, QCryptoRSAPaddingAlgorithm_str(PADDING), + key_size, QCryptoRSAPaddingAlgo_str(PADDING), QCryptoHashAlgo_str(HASH), count, g_test_timer_last(), (double)count / g_test_timer_last()); =20 g_test_message("benchmark rsa%zu (%s-%s) verification...", key_size, - QCryptoRSAPaddingAlgorithm_str(PADDING), + QCryptoRSAPaddingAlgo_str(PADDING), QCryptoHashAlgo_str(HASH)); g_test_timer_start(); for (count =3D 0; count < VERIFY_TIMES; ++count) { @@ -81,7 +81,7 @@ static void test_rsa_speed(const uint8_t *priv_key, size_= t keylen, g_test_timer_elapsed(); g_test_message("rsa%zu (%s-%s) verify %zu times in %.2f seconds," " %.2f times/sec ", - key_size, QCryptoRSAPaddingAlgorithm_str(PADDING), + key_size, QCryptoRSAPaddingAlgo_str(PADDING), QCryptoHashAlgo_str(HASH), count, g_test_timer_last(), (double)count / g_test_timer_last()); diff --git a/tests/unit/test-crypto-akcipher.c b/tests/unit/test-crypto-akc= ipher.c index 7dd86125c2..53c2211ba8 100644 --- a/tests/unit/test-crypto-akcipher.c +++ b/tests/unit/test-crypto-akcipher.c @@ -787,7 +787,7 @@ static QCryptoAkCipherTestData akcipher_test_data[] =3D= { .opt =3D { .alg =3D QCRYPTO_AK_CIPHER_ALGO_RSA, .u.rsa =3D { - .padding_alg =3D QCRYPTO_RSA_PADDING_ALG_RAW, + .padding_alg =3D QCRYPTO_RSA_PADDING_ALGO_RAW, }, }, .pub_key =3D rsa1024_public_key, @@ -807,7 +807,7 @@ static QCryptoAkCipherTestData akcipher_test_data[] =3D= { .opt =3D { .alg =3D QCRYPTO_AK_CIPHER_ALGO_RSA, .u.rsa =3D { - .padding_alg =3D QCRYPTO_RSA_PADDING_ALG_PKCS1, + .padding_alg =3D QCRYPTO_RSA_PADDING_ALGO_PKCS1, .hash_alg =3D QCRYPTO_HASH_ALGO_SHA1, }, }, @@ -832,7 +832,7 @@ static QCryptoAkCipherTestData akcipher_test_data[] =3D= { .opt =3D { .alg =3D QCRYPTO_AK_CIPHER_ALGO_RSA, .u.rsa =3D { - .padding_alg =3D QCRYPTO_RSA_PADDING_ALG_RAW, + .padding_alg =3D QCRYPTO_RSA_PADDING_ALGO_RAW, }, }, .pub_key =3D rsa2048_public_key, @@ -852,7 +852,7 @@ static QCryptoAkCipherTestData akcipher_test_data[] =3D= { .opt =3D { .alg =3D QCRYPTO_AK_CIPHER_ALGO_RSA, .u.rsa =3D { - .padding_alg =3D QCRYPTO_RSA_PADDING_ALG_PKCS1, + .padding_alg =3D QCRYPTO_RSA_PADDING_ALGO_PKCS1, .hash_alg =3D QCRYPTO_HASH_ALGO_SHA1, }, }, @@ -946,7 +946,7 @@ static void test_rsakey(const void *opaque) QCryptoAkCipherOptions opt =3D { .alg =3D QCRYPTO_AK_CIPHER_ALGO_RSA, .u.rsa =3D { - .padding_alg =3D QCRYPTO_RSA_PADDING_ALG_PKCS1, + .padding_alg =3D QCRYPTO_RSA_PADDING_ALGO_PKCS1, .hash_alg =3D QCRYPTO_HASH_ALGO_SHA1, } }; diff --git a/crypto/akcipher-gcrypt.c.inc b/crypto/akcipher-gcrypt.c.inc index 8f1c2b8143..5a880f6638 100644 --- a/crypto/akcipher-gcrypt.c.inc +++ b/crypto/akcipher-gcrypt.c.inc @@ -32,7 +32,7 @@ typedef struct QCryptoGcryptRSA { QCryptoAkCipher akcipher; gcry_sexp_t key; - QCryptoRSAPaddingAlgorithm padding_alg; + QCryptoRSAPaddingAlgo padding_alg; QCryptoHashAlgo hash_alg; } QCryptoGcryptRSA; =20 @@ -241,7 +241,7 @@ static int qcrypto_gcrypt_rsa_encrypt(QCryptoAkCipher *= akcipher, =20 err =3D gcry_sexp_build(&data_sexp, NULL, "(data (flags %s) (value %b))", - QCryptoRSAPaddingAlgorithm_str(rsa->padding_alg), + QCryptoRSAPaddingAlgo_str(rsa->padding_alg), in_len, in); if (gcry_err_code(err) !=3D 0) { error_setg(errp, "Failed to build plaintext: %s/%s", @@ -263,7 +263,7 @@ static int qcrypto_gcrypt_rsa_encrypt(QCryptoAkCipher *= akcipher, goto cleanup; } =20 - if (rsa->padding_alg =3D=3D QCRYPTO_RSA_PADDING_ALG_RAW) { + if (rsa->padding_alg =3D=3D QCRYPTO_RSA_PADDING_ALGO_RAW) { cipher_mpi =3D gcry_sexp_nth_mpi(cipher_sexp_item, 1, GCRYMPI_FMT_= USG); if (!cipher_mpi) { error_setg(errp, "Invalid ciphertext result"); @@ -332,7 +332,7 @@ static int qcrypto_gcrypt_rsa_decrypt(QCryptoAkCipher *= akcipher, =20 err =3D gcry_sexp_build(&cipher_sexp, NULL, "(enc-val (flags %s) (rsa (a %b) ))", - QCryptoRSAPaddingAlgorithm_str(rsa->padding_alg), + QCryptoRSAPaddingAlgo_str(rsa->padding_alg), in_len, in); if (gcry_err_code(err) !=3D 0) { error_setg(errp, "Failed to build ciphertext: %s/%s", @@ -348,7 +348,7 @@ static int qcrypto_gcrypt_rsa_decrypt(QCryptoAkCipher *= akcipher, } =20 /* S-expression of plaintext: (value plaintext) */ - if (rsa->padding_alg =3D=3D QCRYPTO_RSA_PADDING_ALG_RAW) { + if (rsa->padding_alg =3D=3D QCRYPTO_RSA_PADDING_ALGO_RAW) { data_mpi =3D gcry_sexp_nth_mpi(data_sexp, 1, GCRYMPI_FMT_USG); if (!data_mpi) { error_setg(errp, "Invalid plaintext result"); @@ -410,7 +410,7 @@ static int qcrypto_gcrypt_rsa_sign(QCryptoAkCipher *akc= ipher, return ret; } =20 - if (rsa->padding_alg !=3D QCRYPTO_RSA_PADDING_ALG_PKCS1) { + if (rsa->padding_alg !=3D QCRYPTO_RSA_PADDING_ALGO_PKCS1) { error_setg(errp, "Invalid padding %u", rsa->padding_alg); return ret; } @@ -482,7 +482,7 @@ static int qcrypto_gcrypt_rsa_verify(QCryptoAkCipher *a= kcipher, return ret; } =20 - if (rsa->padding_alg !=3D QCRYPTO_RSA_PADDING_ALG_PKCS1) { + if (rsa->padding_alg !=3D QCRYPTO_RSA_PADDING_ALGO_PKCS1) { error_setg(errp, "Invalid padding %u", rsa->padding_alg); return ret; } @@ -570,10 +570,10 @@ bool qcrypto_akcipher_supports(QCryptoAkCipherOptions= *opts) switch (opts->alg) { case QCRYPTO_AK_CIPHER_ALGO_RSA: switch (opts->u.rsa.padding_alg) { - case QCRYPTO_RSA_PADDING_ALG_RAW: + case QCRYPTO_RSA_PADDING_ALGO_RAW: return true; =20 - case QCRYPTO_RSA_PADDING_ALG_PKCS1: + case QCRYPTO_RSA_PADDING_ALGO_PKCS1: switch (opts->u.rsa.hash_alg) { case QCRYPTO_HASH_ALGO_MD5: case QCRYPTO_HASH_ALGO_SHA1: diff --git a/crypto/akcipher-nettle.c.inc b/crypto/akcipher-nettle.c.inc index 21f27f8286..1720f84362 100644 --- a/crypto/akcipher-nettle.c.inc +++ b/crypto/akcipher-nettle.c.inc @@ -33,7 +33,7 @@ typedef struct QCryptoNettleRSA { QCryptoAkCipher akcipher; struct rsa_public_key pub; struct rsa_private_key priv; - QCryptoRSAPaddingAlgorithm padding_alg; + QCryptoRSAPaddingAlgo padding_alg; QCryptoHashAlgo hash_alg; } QCryptoNettleRSA; =20 @@ -184,11 +184,11 @@ static int qcrypto_nettle_rsa_encrypt(QCryptoAkCipher= *akcipher, =20 /* Nettle do not support RSA encryption without any padding */ switch (rsa->padding_alg) { - case QCRYPTO_RSA_PADDING_ALG_RAW: + case QCRYPTO_RSA_PADDING_ALGO_RAW: error_setg(errp, "RSA with raw padding is not supported"); break; =20 - case QCRYPTO_RSA_PADDING_ALG_PKCS1: + case QCRYPTO_RSA_PADDING_ALGO_PKCS1: mpz_init(c); if (rsa_encrypt(&rsa->pub, NULL, wrap_nettle_random_func, data_len, (uint8_t *)data, c) !=3D 1) { @@ -223,11 +223,11 @@ static int qcrypto_nettle_rsa_decrypt(QCryptoAkCipher= *akcipher, } =20 switch (rsa->padding_alg) { - case QCRYPTO_RSA_PADDING_ALG_RAW: + case QCRYPTO_RSA_PADDING_ALGO_RAW: error_setg(errp, "RSA with raw padding is not supported"); break; =20 - case QCRYPTO_RSA_PADDING_ALG_PKCS1: + case QCRYPTO_RSA_PADDING_ALGO_PKCS1: nettle_mpz_init_set_str_256_u(c, enc_len, enc); if (!rsa_decrypt(&rsa->priv, &data_len, (uint8_t *)data, c)) { error_setg(errp, "Failed to decrypt"); @@ -257,7 +257,7 @@ static int qcrypto_nettle_rsa_sign(QCryptoAkCipher *akc= ipher, * The RSA algorithm cannot be used for signature/verification * without padding. */ - if (rsa->padding_alg =3D=3D QCRYPTO_RSA_PADDING_ALG_RAW) { + if (rsa->padding_alg =3D=3D QCRYPTO_RSA_PADDING_ALGO_RAW) { error_setg(errp, "Try to make signature without padding"); return ret; } @@ -324,7 +324,7 @@ static int qcrypto_nettle_rsa_verify(QCryptoAkCipher *a= kcipher, * The RSA algorithm cannot be used for signature/verification * without padding. */ - if (rsa->padding_alg =3D=3D QCRYPTO_RSA_PADDING_ALG_RAW) { + if (rsa->padding_alg =3D=3D QCRYPTO_RSA_PADDING_ALGO_RAW) { error_setg(errp, "Try to verify signature without padding"); return ret; } @@ -427,7 +427,7 @@ bool qcrypto_akcipher_supports(QCryptoAkCipherOptions *= opts) switch (opts->alg) { case QCRYPTO_AK_CIPHER_ALGO_RSA: switch (opts->u.rsa.padding_alg) { - case QCRYPTO_RSA_PADDING_ALG_PKCS1: + case QCRYPTO_RSA_PADDING_ALGO_PKCS1: switch (opts->u.rsa.hash_alg) { case QCRYPTO_HASH_ALGO_MD5: case QCRYPTO_HASH_ALGO_SHA1: @@ -439,7 +439,7 @@ bool qcrypto_akcipher_supports(QCryptoAkCipherOptions *= opts) return false; } =20 - case QCRYPTO_RSA_PADDING_ALG_RAW: + case QCRYPTO_RSA_PADDING_ALGO_RAW: default: return false; } --=20 2.46.0 From nobody Sun Nov 24 08:32:09 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=1725449161; cv=none; d=zohomail.com; s=zohoarc; b=YIHUei9HvsibmwtO66wH77EnptLvQYgIkZhqx3+rqTyERW+0qjtXU9iozpThgACy067yc6PlCxJtfsFOHjLP6a2ML4pyyRQaCcYMVKXfoFoxiNBzRv4FqjUd7hyOHJBPZTjn0ARj7tLY7oUwTlKjtLeXc+KZlr50ykFAWqxYki8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1725449161; 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=gWp+iCFBJ9F2d1YyCUo75gPc+JrIQoSE3ebW3zYSASw=; b=gkmkuaZ8N1cqyb4uOhW9Qy9mfYC57FqBTXCKrsEHgLv1kHYofcOBRhne3LaNx4zKXMOvHYb3jBT9b2g/fPrtPly7e7ambeq4ZqweqaXSUR585tLX6jNqmiARe6DR3lHUW2iioB2edDcpspiOCEaTsQWDaBWLYViLF5Cbn9RsoW8= 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 1725449161774481.3551962059952; Wed, 4 Sep 2024 04:26:01 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1slo8f-0006CV-Lo; Wed, 04 Sep 2024 07:25:29 -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 1slo8Y-0005kU-TS for qemu-devel@nongnu.org; Wed, 04 Sep 2024 07:25:23 -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-0004UH-BD for qemu-devel@nongnu.org; Wed, 04 Sep 2024 07:25:22 -0400 Received: from mx-prod-mc-02.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-442-RA6P3sr1OiqPVB6mMsX1Cw-1; Wed, 04 Sep 2024 07:18:52 -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-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 91BE41956096; 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 E9DE030001AB; Wed, 4 Sep 2024 11:18:46 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id D6E9421E682E; 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=gWp+iCFBJ9F2d1YyCUo75gPc+JrIQoSE3ebW3zYSASw=; b=MOqUdpZ5HXmjQEM/zzsUmIJ2HwVI8AAfUfIISo3bBQdIlu15L6Fp531KAlkm3ee71pI6iK 2yjfZjZixd5Ltwfpfd/L9a8aHKC9DJZsmqq6FcBtfGV8cr9ohbMx/cVUCl20ySeHiIP+tK y1SAklsI/gviYwr53q1+GAfNGQs2dd8= X-MC-Unique: RA6P3sr1OiqPVB6mMsX1Cw-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 16/19] qapi/crypto: Rename QCryptoAFAlg to QCryptoAFAlgo Date: Wed, 4 Sep 2024 13:18:33 +0200 Message-ID: <20240904111836.3273842-17-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: 1725449163979116600 For consistency with other types names *Algo. Signed-off-by: Markus Armbruster Acked-by: Daniel P. Berrang=C3=A9 --- crypto/afalgpriv.h | 14 +++++++------- crypto/hmacpriv.h | 2 +- crypto/afalg.c | 8 ++++---- crypto/cipher-afalg.c | 12 ++++++------ crypto/hash-afalg.c | 14 +++++++------- 5 files changed, 25 insertions(+), 25 deletions(-) diff --git a/crypto/afalgpriv.h b/crypto/afalgpriv.h index 5a2393f1b7..3fdcc0f831 100644 --- a/crypto/afalgpriv.h +++ b/crypto/afalgpriv.h @@ -30,9 +30,9 @@ #define ALG_OPTYPE_LEN 4 #define ALG_MSGIV_LEN(len) (sizeof(struct af_alg_iv) + (len)) =20 -typedef struct QCryptoAFAlg QCryptoAFAlg; +typedef struct QCryptoAFAlgo QCryptoAFAlgo; =20 -struct QCryptoAFAlg { +struct QCryptoAFAlgo { QCryptoCipher base; =20 int tfmfd; @@ -46,22 +46,22 @@ struct QCryptoAFAlg { * @type: the type of crypto operation * @name: the name of crypto operation * - * Allocate a QCryptoAFAlg object and bind itself to + * Allocate a QCryptoAFAlgo object and bind itself to * a AF_ALG socket. * * Returns: - * a new QCryptoAFAlg object, or NULL in error. + * a new QCryptoAFAlgo object, or NULL in error. */ -QCryptoAFAlg * +QCryptoAFAlgo * qcrypto_afalg_comm_alloc(const char *type, const char *name, Error **errp); =20 /** * afalg_comm_free: - * @afalg: the QCryptoAFAlg object + * @afalg: the QCryptoAFAlgo object * * Free the @afalg. */ -void qcrypto_afalg_comm_free(QCryptoAFAlg *afalg); +void qcrypto_afalg_comm_free(QCryptoAFAlgo *afalg); =20 #endif diff --git a/crypto/hmacpriv.h b/crypto/hmacpriv.h index bd4c498c62..f339596bd9 100644 --- a/crypto/hmacpriv.h +++ b/crypto/hmacpriv.h @@ -37,7 +37,7 @@ extern QCryptoHmacDriver qcrypto_hmac_lib_driver; =20 #include "afalgpriv.h" =20 -QCryptoAFAlg *qcrypto_afalg_hmac_ctx_new(QCryptoHashAlgo alg, +QCryptoAFAlgo *qcrypto_afalg_hmac_ctx_new(QCryptoHashAlgo alg, const uint8_t *key, size_t nkey, Error **errp); extern QCryptoHmacDriver qcrypto_hmac_afalg_driver; diff --git a/crypto/afalg.c b/crypto/afalg.c index 52a491dbb5..246d0679d4 100644 --- a/crypto/afalg.c +++ b/crypto/afalg.c @@ -66,13 +66,13 @@ qcrypto_afalg_socket_bind(const char *type, const char = *name, return sbind; } =20 -QCryptoAFAlg * +QCryptoAFAlgo * qcrypto_afalg_comm_alloc(const char *type, const char *name, Error **errp) { - QCryptoAFAlg *afalg; + QCryptoAFAlgo *afalg; =20 - afalg =3D g_new0(QCryptoAFAlg, 1); + afalg =3D g_new0(QCryptoAFAlgo, 1); /* initialize crypto API socket */ afalg->opfd =3D -1; afalg->tfmfd =3D qcrypto_afalg_socket_bind(type, name, errp); @@ -93,7 +93,7 @@ error: return NULL; } =20 -void qcrypto_afalg_comm_free(QCryptoAFAlg *afalg) +void qcrypto_afalg_comm_free(QCryptoAFAlgo *afalg) { if (!afalg) { return; diff --git a/crypto/cipher-afalg.c b/crypto/cipher-afalg.c index c08eb7a39b..4980d419c4 100644 --- a/crypto/cipher-afalg.c +++ b/crypto/cipher-afalg.c @@ -65,7 +65,7 @@ qcrypto_afalg_cipher_ctx_new(QCryptoCipherAlgo alg, const uint8_t *key, size_t nkey, Error **errp) { - QCryptoAFAlg *afalg; + QCryptoAFAlgo *afalg; size_t expect_niv; char *name; =20 @@ -119,7 +119,7 @@ qcrypto_afalg_cipher_setiv(QCryptoCipher *cipher, const uint8_t *iv, size_t niv, Error **errp) { - QCryptoAFAlg *afalg =3D container_of(cipher, QCryptoAFAlg, base); + QCryptoAFAlgo *afalg =3D container_of(cipher, QCryptoAFAlgo, base); struct af_alg_iv *alg_iv; size_t expect_niv; =20 @@ -143,7 +143,7 @@ qcrypto_afalg_cipher_setiv(QCryptoCipher *cipher, } =20 static int -qcrypto_afalg_cipher_op(QCryptoAFAlg *afalg, +qcrypto_afalg_cipher_op(QCryptoAFAlgo *afalg, const void *in, void *out, size_t len, bool do_encrypt, Error **errp) @@ -202,7 +202,7 @@ qcrypto_afalg_cipher_encrypt(QCryptoCipher *cipher, const void *in, void *out, size_t len, Error **errp) { - QCryptoAFAlg *afalg =3D container_of(cipher, QCryptoAFAlg, base); + QCryptoAFAlgo *afalg =3D container_of(cipher, QCryptoAFAlgo, base); =20 return qcrypto_afalg_cipher_op(afalg, in, out, len, true, errp); } @@ -212,14 +212,14 @@ qcrypto_afalg_cipher_decrypt(QCryptoCipher *cipher, const void *in, void *out, size_t len, Error **errp) { - QCryptoAFAlg *afalg =3D container_of(cipher, QCryptoAFAlg, base); + QCryptoAFAlgo *afalg =3D container_of(cipher, QCryptoAFAlgo, base); =20 return qcrypto_afalg_cipher_op(afalg, in, out, len, false, errp); } =20 static void qcrypto_afalg_comm_ctx_free(QCryptoCipher *cipher) { - QCryptoAFAlg *afalg =3D container_of(cipher, QCryptoAFAlg, base); + QCryptoAFAlgo *afalg =3D container_of(cipher, QCryptoAFAlgo, base); =20 qcrypto_afalg_comm_free(afalg); } diff --git a/crypto/hash-afalg.c b/crypto/hash-afalg.c index 8fc6bd0edf..28ab899b18 100644 --- a/crypto/hash-afalg.c +++ b/crypto/hash-afalg.c @@ -64,12 +64,12 @@ qcrypto_afalg_hash_format_name(QCryptoHashAlgo alg, return name; } =20 -static QCryptoAFAlg * +static QCryptoAFAlgo * qcrypto_afalg_hash_hmac_ctx_new(QCryptoHashAlgo alg, const uint8_t *key, size_t nkey, bool is_hmac, Error **errp) { - QCryptoAFAlg *afalg; + QCryptoAFAlgo *afalg; char *name; =20 name =3D qcrypto_afalg_hash_format_name(alg, is_hmac, errp); @@ -98,14 +98,14 @@ qcrypto_afalg_hash_hmac_ctx_new(QCryptoHashAlgo alg, return afalg; } =20 -static QCryptoAFAlg * +static QCryptoAFAlgo * qcrypto_afalg_hash_ctx_new(QCryptoHashAlgo alg, Error **errp) { return qcrypto_afalg_hash_hmac_ctx_new(alg, NULL, 0, false, errp); } =20 -QCryptoAFAlg * +QCryptoAFAlgo * qcrypto_afalg_hmac_ctx_new(QCryptoHashAlgo alg, const uint8_t *key, size_t nkey, Error **errp) @@ -114,14 +114,14 @@ qcrypto_afalg_hmac_ctx_new(QCryptoHashAlgo alg, } =20 static int -qcrypto_afalg_hash_hmac_bytesv(QCryptoAFAlg *hmac, +qcrypto_afalg_hash_hmac_bytesv(QCryptoAFAlgo *hmac, QCryptoHashAlgo alg, const struct iovec *iov, size_t niov, uint8_t **result, size_t *resultlen, Error **errp) { - QCryptoAFAlg *afalg; + QCryptoAFAlgo *afalg; struct iovec outv; int ret =3D 0; bool is_hmac =3D (hmac !=3D NULL) ? true : false; @@ -197,7 +197,7 @@ qcrypto_afalg_hmac_bytesv(QCryptoHmac *hmac, =20 static void qcrypto_afalg_hmac_ctx_free(QCryptoHmac *hmac) { - QCryptoAFAlg *afalg; + QCryptoAFAlgo *afalg; =20 afalg =3D hmac->opaque; qcrypto_afalg_comm_free(afalg); --=20 2.46.0 From nobody Sun Nov 24 08:32:09 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=1725449366; cv=none; d=zohomail.com; s=zohoarc; b=MneAnownL1GrT3ZvrV5r58wq06AOPWSb2ucMUuxczFTMzc4qkN/LDyPxERbYuz1yfNNoc57rYele+xYTikGJ4BJPIgPgbXga8II1cR3QqGUi7DrKMjnya8kOA5iQUTqOY8eqOj4LOalaOJMkL/pBawvUOb6mjpLx5AEUjrXLhIA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1725449366; 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=oh/NCqjRTQGWDv+iIQfkI/24tYYyPpV/TrHZbGUd03w=; b=KlK7QrFaXoOUzPsLZ8fYGETHavv5s7oLH6qewmZ7uujSd5Evc6VuDPAatNXwCptp1M2YyPqA86bKY5abty7dcpheBKZj8nIaooLsp8L6U6n/b70fqPFx021F6o7vknHeVY7VtbuB3o8xXG61ytcSzSsNpfkF2eXht7VNaIz0fSY= 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 1725449366141116.72538119070441; Wed, 4 Sep 2024 04:29:26 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1slo9P-0001xh-8o; Wed, 04 Sep 2024 07:26:15 -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 1slo9K-0001Nr-RF for qemu-devel@nongnu.org; Wed, 04 Sep 2024 07:26:11 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1slo9D-0004kV-1G for qemu-devel@nongnu.org; Wed, 04 Sep 2024 07:26:10 -0400 Received: from mx-prod-mc-03.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-588-vgWluKH0OjuyiNqi3QfSzw-1; Wed, 04 Sep 2024 07:18:51 -0400 Received: from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.15]) (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-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 98C6D1956057; Wed, 4 Sep 2024 11:18:47 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.192.112]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 0F78D1956094; Wed, 4 Sep 2024 11:18:47 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id DB87221E683A; 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=1725449161; 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=oh/NCqjRTQGWDv+iIQfkI/24tYYyPpV/TrHZbGUd03w=; b=F/7n/RcqrxXrGKksFVr1K0cYSklupAbBErLFE+fkqYyyFmphQSDYnF3KviFG/c7Gqb0qjw C7HRBGjZI+8TNMVoM0BErHLuue0kL/KuKbRcug10phRmInGT2UBFg2UqLYkXIx6i4eiSQh V074Lz1TifBxcEOtUdqLLwdi41SWjsY= X-MC-Unique: vgWluKH0OjuyiNqi3QfSzw-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 17/19] qapi/cryptodev: Drop unwanted 'prefix' Date: Wed, 4 Sep 2024 13:18:34 +0200 Message-ID: <20240904111836.3273842-18-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.0 on 10.30.177.15 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.129.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_H3=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: 1725449366740116600 QAPI's 'prefix' feature can make the connection between enumeration type and its constants less than obvious. It's best used with restraint. QCryptodevBackendServiceType has a 'prefix' that overrides the generated enumeration constants' prefix to QCRYPTODEV_BACKEND_SERVICE. Drop it. The prefix becomes QCRYPTODEV_BACKEND_SERVICE_TYPE. Signed-off-by: Markus Armbruster Reviewed-by: Daniel P. Berrang=C3=A9 --- qapi/cryptodev.json | 1 - backends/cryptodev-builtin.c | 8 ++++---- backends/cryptodev-lkcf.c | 2 +- backends/cryptodev-vhost-user.c | 6 +++--- backends/cryptodev.c | 6 +++--- hw/virtio/virtio-crypto.c | 10 +++++----- 6 files changed, 16 insertions(+), 17 deletions(-) diff --git a/qapi/cryptodev.json b/qapi/cryptodev.json index 60f8fe8e4a..65abc16842 100644 --- a/qapi/cryptodev.json +++ b/qapi/cryptodev.json @@ -31,7 +31,6 @@ # Since: 8.0 ## { 'enum': 'QCryptodevBackendServiceType', - 'prefix': 'QCRYPTODEV_BACKEND_SERVICE', 'data': ['cipher', 'hash', 'mac', 'aead', 'akcipher']} =20 ## diff --git a/backends/cryptodev-builtin.c b/backends/cryptodev-builtin.c index 6f3990481b..170c93a6be 100644 --- a/backends/cryptodev-builtin.c +++ b/backends/cryptodev-builtin.c @@ -68,7 +68,7 @@ static void cryptodev_builtin_init_akcipher(CryptoDevBack= end *backend) opts.u.rsa.padding_alg =3D QCRYPTO_RSA_PADDING_ALGO_RAW; if (qcrypto_akcipher_supports(&opts)) { backend->conf.crypto_services |=3D - (1u << QCRYPTODEV_BACKEND_SERVICE_AKCIPHER); + (1u << QCRYPTODEV_BACKEND_SERVICE_TYPE_AKCIPHER); backend->conf.akcipher_algo =3D 1u << VIRTIO_CRYPTO_AKCIPHER_RSA; } } @@ -93,9 +93,9 @@ static void cryptodev_builtin_init( backend->conf.peers.ccs[0] =3D cc; =20 backend->conf.crypto_services =3D - 1u << QCRYPTODEV_BACKEND_SERVICE_CIPHER | - 1u << QCRYPTODEV_BACKEND_SERVICE_HASH | - 1u << QCRYPTODEV_BACKEND_SERVICE_MAC; + 1u << QCRYPTODEV_BACKEND_SERVICE_TYPE_CIPHER | + 1u << QCRYPTODEV_BACKEND_SERVICE_TYPE_HASH | + 1u << QCRYPTODEV_BACKEND_SERVICE_TYPE_MAC; backend->conf.cipher_algo_l =3D 1u << VIRTIO_CRYPTO_CIPHER_AES_CBC; backend->conf.hash_algo =3D 1u << VIRTIO_CRYPTO_HASH_SHA1; /* diff --git a/backends/cryptodev-lkcf.c b/backends/cryptodev-lkcf.c index fde32950f6..0dc4b067f5 100644 --- a/backends/cryptodev-lkcf.c +++ b/backends/cryptodev-lkcf.c @@ -230,7 +230,7 @@ static void cryptodev_lkcf_init(CryptoDevBackend *backe= nd, Error **errp) backend->conf.peers.ccs[0] =3D cc; =20 backend->conf.crypto_services =3D - 1u << QCRYPTODEV_BACKEND_SERVICE_AKCIPHER; + 1u << QCRYPTODEV_BACKEND_SERVICE_TYPE_AKCIPHER; backend->conf.akcipher_algo =3D 1u << VIRTIO_CRYPTO_AKCIPHER_RSA; lkcf->running =3D true; =20 diff --git a/backends/cryptodev-vhost-user.c b/backends/cryptodev-vhost-use= r.c index c3283ba84a..e33fb78521 100644 --- a/backends/cryptodev-vhost-user.c +++ b/backends/cryptodev-vhost-user.c @@ -221,9 +221,9 @@ static void cryptodev_vhost_user_init( cryptodev_vhost_user_event, NULL, s, NULL, true); =20 backend->conf.crypto_services =3D - 1u << QCRYPTODEV_BACKEND_SERVICE_CIPHER | - 1u << QCRYPTODEV_BACKEND_SERVICE_HASH | - 1u << QCRYPTODEV_BACKEND_SERVICE_MAC; + 1u << QCRYPTODEV_BACKEND_SERVICE_TYPE_CIPHER | + 1u << QCRYPTODEV_BACKEND_SERVICE_TYPE_HASH | + 1u << QCRYPTODEV_BACKEND_SERVICE_TYPE_MAC; backend->conf.cipher_algo_l =3D 1u << VIRTIO_CRYPTO_CIPHER_AES_CBC; backend->conf.hash_algo =3D 1u << VIRTIO_CRYPTO_HASH_SHA1; =20 diff --git a/backends/cryptodev.c b/backends/cryptodev.c index fff89fd62a..76dfe65904 100644 --- a/backends/cryptodev.c +++ b/backends/cryptodev.c @@ -74,7 +74,7 @@ static int qmp_query_cryptodev_foreach(Object *obj, void = *data) =20 backend =3D CRYPTODEV_BACKEND(obj); services =3D backend->conf.crypto_services; - for (i =3D 0; i < QCRYPTODEV_BACKEND_SERVICE__MAX; i++) { + for (i =3D 0; i < QCRYPTODEV_BACKEND_SERVICE_TYPE__MAX; i++) { if (services & (1 << i)) { QAPI_LIST_PREPEND(info->service, i); } @@ -424,11 +424,11 @@ cryptodev_backend_complete(UserCreatable *uc, Error *= *errp) } =20 services =3D backend->conf.crypto_services; - if (services & (1 << QCRYPTODEV_BACKEND_SERVICE_CIPHER)) { + if (services & (1 << QCRYPTODEV_BACKEND_SERVICE_TYPE_CIPHER)) { backend->sym_stat =3D g_new0(CryptodevBackendSymStat, 1); } =20 - if (services & (1 << QCRYPTODEV_BACKEND_SERVICE_AKCIPHER)) { + if (services & (1 << QCRYPTODEV_BACKEND_SERVICE_TYPE_AKCIPHER)) { backend->asym_stat =3D g_new0(CryptodevBackendAsymStat, 1); } } diff --git a/hw/virtio/virtio-crypto.c b/hw/virtio/virtio-crypto.c index 5034768bff..0ab8ae3282 100644 --- a/hw/virtio/virtio-crypto.c +++ b/hw/virtio/virtio-crypto.c @@ -1008,19 +1008,19 @@ static uint32_t virtio_crypto_init_services(uint32_= t qservices) { uint32_t vservices =3D 0; =20 - if (qservices & (1 << QCRYPTODEV_BACKEND_SERVICE_CIPHER)) { + if (qservices & (1 << QCRYPTODEV_BACKEND_SERVICE_TYPE_CIPHER)) { vservices |=3D (1 << VIRTIO_CRYPTO_SERVICE_CIPHER); } - if (qservices & (1 << QCRYPTODEV_BACKEND_SERVICE_HASH)) { + if (qservices & (1 << QCRYPTODEV_BACKEND_SERVICE_TYPE_HASH)) { vservices |=3D (1 << VIRTIO_CRYPTO_SERVICE_HASH); } - if (qservices & (1 << QCRYPTODEV_BACKEND_SERVICE_MAC)) { + if (qservices & (1 << QCRYPTODEV_BACKEND_SERVICE_TYPE_MAC)) { vservices |=3D (1 << VIRTIO_CRYPTO_SERVICE_MAC); } - if (qservices & (1 << QCRYPTODEV_BACKEND_SERVICE_AEAD)) { + if (qservices & (1 << QCRYPTODEV_BACKEND_SERVICE_TYPE_AEAD)) { vservices |=3D (1 << VIRTIO_CRYPTO_SERVICE_AEAD); } - if (qservices & (1 << QCRYPTODEV_BACKEND_SERVICE_AKCIPHER)) { + if (qservices & (1 << QCRYPTODEV_BACKEND_SERVICE_TYPE_AKCIPHER)) { vservices |=3D (1 << VIRTIO_CRYPTO_SERVICE_AKCIPHER); } =20 --=20 2.46.0 From nobody Sun Nov 24 08:32:09 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=1725449239; cv=none; d=zohomail.com; s=zohoarc; b=NGw+qWE4E3/MRSh87azafs9pzSG+yg6XoBNITDDuoX2YlxvMxVPuCBszXlQVAIozvnBSSgZtopkWNFPnw2Hzd8Y1rw9/8CDKQJSiimhmAs0Ci0lCLUa47qk4PRPQanxGVaX7oK2AcGy3Kc4KXT1oPYjUXpKVf/hi9AdQtFONDlY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1725449239; 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=8jvnxF7MUV7TcmDxjDOpIIuDd7PvoOLciN25fnQ1nCo=; b=T0CAtOXnkM6FohvZndulEY1Tn8bOSdgJVU7tCg/IZzexuVmyg1pb55We0+f7RvG+2Vt8z9ZaCIFyXq1dXhWsiXjpm+rCjmkrtrr/0jarq7yWUs7xsR9zEvNivZOzCrLcbql2KhKCsSSBx1G7UZbBeXQp1PpU+UzGBaN8w5a0zc8= 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 1725449239453899.2655685888757; Wed, 4 Sep 2024 04:27:19 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1slo9N-0001ko-SN; Wed, 04 Sep 2024 07:26:13 -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 1slo9H-00012R-2d for qemu-devel@nongnu.org; Wed, 04 Sep 2024 07:26:07 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1slo9C-0004lD-O9 for qemu-devel@nongnu.org; Wed, 04 Sep 2024 07:26:06 -0400 Received: from mx-prod-mc-03.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-613-52aQONzDMiaKr8BhmtZk7g-1; Wed, 04 Sep 2024 07:18:52 -0400 Received: from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.15]) (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-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id D847619560BF; Wed, 4 Sep 2024 11:18:47 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.192.112]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 0F524195608A; Wed, 4 Sep 2024 11:18:47 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id E029721E66C9; 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=1725449161; 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=8jvnxF7MUV7TcmDxjDOpIIuDd7PvoOLciN25fnQ1nCo=; b=ByxNCvaQ25FcE6XGlP1ihad+c3qp9pRiUHrby25yLjR2dejyM4gN1/1urClGusa6XRIyj5 HI5JKiLLUCXenzTSlc5YvtQGYvddf6xNU2/wnfLTmA0xNb6NzEEEPV/zrojeCSKWLcYfXc Ca04FhK48z0d4afrxU53Y87VQKiVIRE= X-MC-Unique: 52aQONzDMiaKr8BhmtZk7g-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 18/19] qapi/cryptodev: Rename QCryptodevBackendAlgType to *Algo, and drop prefix Date: Wed, 4 Sep 2024 13:18:35 +0200 Message-ID: <20240904111836.3273842-19-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.0 on 10.30.177.15 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.129.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_H3=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: 1725449240126116600 QAPI's 'prefix' feature can make the connection between enumeration type and its constants less than obvious. It's best used with restraint. QCryptodevBackendAlgType has a 'prefix' that overrides the generated enumeration constants' prefix to QCRYPTODEV_BACKEND_ALG. We could simply drop 'prefix', but I think the abbreviation "alg" is less than clear. Additionally rename the type to QCryptodevBackendAlgoType. The prefix becomes QCRYPTODEV_BACKEND_ALGO_TYPE. Signed-off-by: Markus Armbruster Reviewed-by: Daniel P. Berrang=C3=A9 --- qapi/cryptodev.json | 5 ++--- include/sysemu/cryptodev.h | 2 +- backends/cryptodev-builtin.c | 6 +++--- backends/cryptodev-lkcf.c | 4 ++-- backends/cryptodev.c | 6 +++--- hw/virtio/virtio-crypto.c | 14 +++++++------- 6 files changed, 18 insertions(+), 19 deletions(-) diff --git a/qapi/cryptodev.json b/qapi/cryptodev.json index 65abc16842..5e417340dc 100644 --- a/qapi/cryptodev.json +++ b/qapi/cryptodev.json @@ -9,7 +9,7 @@ ## =20 ## -# @QCryptodevBackendAlgType: +# @QCryptodevBackendAlgoType: # # The supported algorithm types of a crypto device. # @@ -19,8 +19,7 @@ # # Since: 8.0 ## -{ 'enum': 'QCryptodevBackendAlgType', - 'prefix': 'QCRYPTODEV_BACKEND_ALG', +{ 'enum': 'QCryptodevBackendAlgoType', 'data': ['sym', 'asym']} =20 ## diff --git a/include/sysemu/cryptodev.h b/include/sysemu/cryptodev.h index 96d3998b93..b20822df0d 100644 --- a/include/sysemu/cryptodev.h +++ b/include/sysemu/cryptodev.h @@ -178,7 +178,7 @@ typedef struct CryptoDevBackendAsymOpInfo { typedef void (*CryptoDevCompletionFunc) (void *opaque, int ret); =20 typedef struct CryptoDevBackendOpInfo { - QCryptodevBackendAlgType algtype; + QCryptodevBackendAlgoType algtype; uint32_t op_code; uint32_t queue_index; CryptoDevCompletionFunc cb; diff --git a/backends/cryptodev-builtin.c b/backends/cryptodev-builtin.c index 170c93a6be..b1486be630 100644 --- a/backends/cryptodev-builtin.c +++ b/backends/cryptodev-builtin.c @@ -549,7 +549,7 @@ static int cryptodev_builtin_operation( CryptoDevBackendBuiltinSession *sess; CryptoDevBackendSymOpInfo *sym_op_info; CryptoDevBackendAsymOpInfo *asym_op_info; - QCryptodevBackendAlgType algtype =3D op_info->algtype; + QCryptodevBackendAlgoType algtype =3D op_info->algtype; int status =3D -VIRTIO_CRYPTO_ERR; Error *local_error =3D NULL; =20 @@ -561,11 +561,11 @@ static int cryptodev_builtin_operation( } =20 sess =3D builtin->sessions[op_info->session_id]; - if (algtype =3D=3D QCRYPTODEV_BACKEND_ALG_SYM) { + if (algtype =3D=3D QCRYPTODEV_BACKEND_ALGO_TYPE_SYM) { sym_op_info =3D op_info->u.sym_op_info; status =3D cryptodev_builtin_sym_operation(sess, sym_op_info, &local_error); - } else if (algtype =3D=3D QCRYPTODEV_BACKEND_ALG_ASYM) { + } else if (algtype =3D=3D QCRYPTODEV_BACKEND_ALGO_TYPE_ASYM) { asym_op_info =3D op_info->u.asym_op_info; status =3D cryptodev_builtin_asym_operation(sess, op_info->op_code, asym_op_info, &local_err= or); diff --git a/backends/cryptodev-lkcf.c b/backends/cryptodev-lkcf.c index 0dc4b067f5..38deac0717 100644 --- a/backends/cryptodev-lkcf.c +++ b/backends/cryptodev-lkcf.c @@ -474,7 +474,7 @@ static int cryptodev_lkcf_operation( CryptoDevBackendLKCF *lkcf =3D CRYPTODEV_BACKEND_LKCF(backend); CryptoDevBackendLKCFSession *sess; - QCryptodevBackendAlgType algtype =3D op_info->algtype; + QCryptodevBackendAlgoType algtype =3D op_info->algtype; CryptoDevLKCFTask *task; =20 if (op_info->session_id >=3D MAX_SESSIONS || @@ -485,7 +485,7 @@ static int cryptodev_lkcf_operation( } =20 sess =3D lkcf->sess[op_info->session_id]; - if (algtype !=3D QCRYPTODEV_BACKEND_ALG_ASYM) { + if (algtype !=3D QCRYPTODEV_BACKEND_ALGO_TYPE_ASYM) { error_report("algtype not supported: %u", algtype); return -VIRTIO_CRYPTO_NOTSUPP; } diff --git a/backends/cryptodev.c b/backends/cryptodev.c index 76dfe65904..d8bd2a1ae6 100644 --- a/backends/cryptodev.c +++ b/backends/cryptodev.c @@ -185,10 +185,10 @@ static int cryptodev_backend_operation( static int cryptodev_backend_account(CryptoDevBackend *backend, CryptoDevBackendOpInfo *op_info) { - enum QCryptodevBackendAlgType algtype =3D op_info->algtype; + enum QCryptodevBackendAlgoType algtype =3D op_info->algtype; int len; =20 - if (algtype =3D=3D QCRYPTODEV_BACKEND_ALG_ASYM) { + if (algtype =3D=3D QCRYPTODEV_BACKEND_ALGO_TYPE_ASYM) { CryptoDevBackendAsymOpInfo *asym_op_info =3D op_info->u.asym_op_in= fo; len =3D asym_op_info->src_len; =20 @@ -212,7 +212,7 @@ static int cryptodev_backend_account(CryptoDevBackend *= backend, default: return -VIRTIO_CRYPTO_NOTSUPP; } - } else if (algtype =3D=3D QCRYPTODEV_BACKEND_ALG_SYM) { + } else if (algtype =3D=3D QCRYPTODEV_BACKEND_ALGO_TYPE_SYM) { CryptoDevBackendSymOpInfo *sym_op_info =3D op_info->u.sym_op_info; len =3D sym_op_info->src_len; =20 diff --git a/hw/virtio/virtio-crypto.c b/hw/virtio/virtio-crypto.c index 0ab8ae3282..6e9d8293da 100644 --- a/hw/virtio/virtio-crypto.c +++ b/hw/virtio/virtio-crypto.c @@ -461,7 +461,7 @@ static void virtio_crypto_init_request(VirtIOCrypto *vc= rypto, VirtQueue *vq, req->in_iov =3D NULL; req->in_num =3D 0; req->in_len =3D 0; - req->flags =3D QCRYPTODEV_BACKEND_ALG__MAX; + req->flags =3D QCRYPTODEV_BACKEND_ALGO_TYPE__MAX; memset(&req->op_info, 0x00, sizeof(req->op_info)); } =20 @@ -471,7 +471,7 @@ static void virtio_crypto_free_request(VirtIOCryptoReq = *req) return; } =20 - if (req->flags =3D=3D QCRYPTODEV_BACKEND_ALG_SYM) { + if (req->flags =3D=3D QCRYPTODEV_BACKEND_ALGO_TYPE_SYM) { size_t max_len; CryptoDevBackendSymOpInfo *op_info =3D req->op_info.u.sym_op_info; =20 @@ -486,7 +486,7 @@ static void virtio_crypto_free_request(VirtIOCryptoReq = *req) memset(op_info, 0, sizeof(*op_info) + max_len); g_free(op_info); } - } else if (req->flags =3D=3D QCRYPTODEV_BACKEND_ALG_ASYM) { + } else if (req->flags =3D=3D QCRYPTODEV_BACKEND_ALGO_TYPE_ASYM) { CryptoDevBackendAsymOpInfo *op_info =3D req->op_info.u.asym_op_inf= o; if (op_info) { g_free(op_info->src); @@ -571,10 +571,10 @@ static void virtio_crypto_req_complete(void *opaque, = int ret) VirtIODevice *vdev =3D VIRTIO_DEVICE(vcrypto); uint8_t status =3D -ret; =20 - if (req->flags =3D=3D QCRYPTODEV_BACKEND_ALG_SYM) { + if (req->flags =3D=3D QCRYPTODEV_BACKEND_ALGO_TYPE_SYM) { virtio_crypto_sym_input_data_helper(vdev, req, status, req->op_info.u.sym_op_info); - } else if (req->flags =3D=3D QCRYPTODEV_BACKEND_ALG_ASYM) { + } else if (req->flags =3D=3D QCRYPTODEV_BACKEND_ALGO_TYPE_ASYM) { virtio_crypto_akcipher_input_data_helper(vdev, req, status, req->op_info.u.asym_op_info); } @@ -884,7 +884,7 @@ virtio_crypto_handle_request(VirtIOCryptoReq *request) switch (opcode) { case VIRTIO_CRYPTO_CIPHER_ENCRYPT: case VIRTIO_CRYPTO_CIPHER_DECRYPT: - op_info->algtype =3D request->flags =3D QCRYPTODEV_BACKEND_ALG_SYM; + op_info->algtype =3D request->flags =3D QCRYPTODEV_BACKEND_ALGO_TY= PE_SYM; ret =3D virtio_crypto_handle_sym_req(vcrypto, &req.u.sym_req, op_info, out_iov, out_num); @@ -894,7 +894,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 =3D request->flags =3D QCRYPTODEV_BACKEND_ALG_ASY= M; + op_info->algtype =3D request->flags =3D QCRYPTODEV_BACKEND_ALGO_TY= PE_ASYM; ret =3D virtio_crypto_handle_asym_req(vcrypto, &req.u.akcipher_req, op_info, out_iov, out_num); --=20 2.46.0 From nobody Sun Nov 24 08:32:09 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=1725449157; cv=none; d=zohomail.com; s=zohoarc; b=YViO68y3qc1f+FyAYP3KuvV1MlOjg/7KgCWGaxTEYW1cxAWrXUIw5Ey0lqelYoCKsxeqZ+avC57lSt215P/MnheU002b6M4UcOWVhi0eBG07I6FxkRLVVLf6W1wDkKonykw9teNAzbv1wZqSeh24u1006j2PwV2Z7+72bFCjoVM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1725449157; 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=krwGcnbmK4mJojLce1YySOaQMl7POMJC2LkjDvFBIHA=; b=WCglbM6PMt4Gb9ths7huzuzKeyF2Py1yFvBvdXSLEdi25qZvDNQ5sq9GDK+YtAMNTmpRTC04WWKbzE7oU8vO4MuoCXRdxOmUboYW0DmbCnWdBnCwzJyqLAIrNrRiWLSI9esqxdfLCKAOASiVIuVfy+Nf5OE4t76c4PCRuyIEvXI= 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 1725449157156792.8237026308665; Wed, 4 Sep 2024 04:25:57 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1slo8V-0005Y8-SZ; Wed, 04 Sep 2024 07:25:19 -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 1slo8T-0005Ok-Oc for qemu-devel@nongnu.org; Wed, 04 Sep 2024 07:25:17 -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 1slo8S-0004SH-5E for qemu-devel@nongnu.org; Wed, 04 Sep 2024 07:25:17 -0400 Received: from mx-prod-mc-01.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-613-UFBGwjXIN7CxdUb05skooA-1; Wed, 04 Sep 2024 07:18:52 -0400 Received: from mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.40]) (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-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id EEBEF19560B2; Wed, 4 Sep 2024 11:18:47 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.192.112]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 5F7FE1955F44; Wed, 4 Sep 2024 11:18:47 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id E475921E66CD; 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=1725449115; 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=krwGcnbmK4mJojLce1YySOaQMl7POMJC2LkjDvFBIHA=; b=d2akJHkPL1RufPEo71FUHvIjBBTneXN3mWonxJhXzWJlmIFB/wOpY0QZVyP2w8Vj5inJ82 AtbET9WYeVw0iQ0cnN/GE3jaWGZ8vWtH+rW5X9rDBgixMwgQlyfzZUd3cKD7Z7PAGeEaWO /a8apITDF7L7ZWff2rZJySbvTRtq854= X-MC-Unique: UFBGwjXIN7CxdUb05skooA-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 19/19] qapi/vfio: Rename VfioMigrationState to Qapi*, and drop prefix Date: Wed, 4 Sep 2024 13:18:36 +0200 Message-ID: <20240904111836.3273842-20-armbru@redhat.com> In-Reply-To: <20240904111836.3273842-1-armbru@redhat.com> References: <20240904111836.3273842-1-armbru@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.40 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: 1725449158367116600 Content-Type: text/plain; charset="utf-8" QAPI's 'prefix' feature can make the connection between enumeration type and its constants less than obvious. It's best used with restraint. VfioMigrationState has a 'prefix' that overrides the generated enumeration constants' prefix to QAPI_VFIO_MIGRATION_STATE. We could simply drop 'prefix', but then the enumeration constants would look as if they came from kernel header linux/vfio.h. Rename the type to QapiVfioMigrationState instead, so that 'prefix' is not needed. Signed-off-by: Markus Armbruster --- qapi/vfio.json | 9 ++++----- hw/vfio/migration.c | 2 +- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/qapi/vfio.json b/qapi/vfio.json index eccca82068..b53b7caecd 100644 --- a/qapi/vfio.json +++ b/qapi/vfio.json @@ -7,7 +7,7 @@ ## =20 ## -# @VfioMigrationState: +# @QapiVfioMigrationState: # # An enumeration of the VFIO device migration states. # @@ -32,10 +32,9 @@ # # Since: 9.1 ## -{ 'enum': 'VfioMigrationState', +{ 'enum': 'QapiVfioMigrationState', 'data': [ 'stop', 'running', 'stop-copy', 'resuming', 'running-p2p', - 'pre-copy', 'pre-copy-p2p' ], - 'prefix': 'QAPI_VFIO_MIGRATION_STATE' } + 'pre-copy', 'pre-copy-p2p' ] } =20 ## # @VFIO_MIGRATION: @@ -63,5 +62,5 @@ 'data': { 'device-id': 'str', 'qom-path': 'str', - 'device-state': 'VfioMigrationState' + 'device-state': 'QapiVfioMigrationState' } } diff --git a/hw/vfio/migration.c b/hw/vfio/migration.c index 262d42a46e..17199b73ae 100644 --- a/hw/vfio/migration.c +++ b/hw/vfio/migration.c @@ -81,7 +81,7 @@ static const char *mig_state_to_str(enum vfio_device_mig_= state state) } } =20 -static VfioMigrationState +static QapiVfioMigrationState mig_state_to_qapi_state(enum vfio_device_mig_state state) { switch (state) { --=20 2.46.0