From patchwork Wed Sep 4 11:18:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Markus Armbruster X-Patchwork-Id: 13790614 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id BA624CD4847 for ; Wed, 4 Sep 2024 11:26:49 +0000 (UTC) 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 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= 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 X-MC-Unique: tzF7ZPmeNqWeDANuQ5DEzA-1 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) 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 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org 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é --- 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' ] } ## @@ -3746,7 +3747,7 @@ # # Since: 4.1 ## -{ 'enum': 'BlkdebugIOType', 'prefix': 'BLKDEBUG_IO_TYPE', +{ 'enum': 'BlkdebugIOType', 'data': [ 'read', 'write', 'write-zeroes', 'discard', 'flush', 'block-status' ] } 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' ] } ## 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']} ## @@ -36,7 +35,6 @@ # Since: 2.6 ## { 'enum': 'QCryptoSecretFormat', - 'prefix': 'QCRYPTO_SECRET_FORMAT', 'data': ['raw', 'base64']} ## @@ -123,7 +121,6 @@ # Since: 2.6 ## { 'enum': 'QCryptoCipherMode', - 'prefix': 'QCRYPTO_CIPHER_MODE', 'data': ['ecb', 'cbc', 'xts', 'ctr']} ## @@ -160,7 +157,7 @@ # Since: 2.6 ## { 'enum': 'QCryptoBlockFormat', -# 'prefix': 'QCRYPTO_BLOCK_FORMAT', + 'prefix': 'Q_CRYPTO_BLOCK_FORMAT', # TODO drop 'data': ['qcow', 'luks']} ## @@ -363,6 +360,7 @@ # Since: 5.1 ## { 'enum': 'QCryptoBlockLUKSKeyslotState', + 'prefix': 'Q_CRYPTO_BLOCKLUKS_KEYSLOT_STATE', # TODO drop 'data': [ 'active', 'inactive' ] } ## 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']} ## 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' } ] } 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' ] } ## @@ -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' ] } 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' ] } ## 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 = c_name(value, False) - if value.isupper(): - return c_fun_str + ret = value[0] + upc = value[0].isupper() - new_name = '' - length = len(c_fun_str) - for i in range(length): - char = 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] != '_': - if i < length - 1 and c_fun_str[i + 1].islower(): - new_name += '_' - elif c_fun_str[i - 1].isdigit(): - new_name += '_' - new_name += char - return new_name.lstrip('_').upper() + # Copy remainder of ``value`` to ``ret`` with '_' inserted + for ch in value[1:]: + if ch.isupper() == 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 = ret[:-1] + '_' + ret[-1] + else: + # ``ret`` doesn't end in upper case, next char is: insert + # '_' before it + if ret[-1].isalnum(): + ret += '_' + ret += ch + upc = ch.isupper() + + return c_name(ret.upper()).lstrip('_') 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 = prefix - return camel_to_upper(type_name) + '_' + c_name(const_name, False).upper() + if prefix is None: + prefix = camel_to_upper(type_name) + return prefix + '_' + c_name(const_name, False).upper() def c_name(name: str, protect: bool = 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) self._def_definition(QAPISchemaEnumType( - 'QType', None, None, None, None, qtype_values, 'QTYPE')) + 'QType', None, None, None, None, qtype_values, None)) def _make_features( self, diff --git a/tests/qapi-schema/alternate-array.out b/tests/qapi-schema/alternate-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/include-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/include-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/indented-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/qapi-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' ] } { 'enum': 'TestUnionEnumA', + 'prefix': 'TEST_UNION_ENUMA', # TODO drop 'data': [ 'value-a1', 'value-a2' ] } { 'struct': 'TestUnionTypeA1', diff --git a/tests/qapi-schema/qapi-schema-test.out b/tests/qapi-schema/qapi-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 From patchwork Wed Sep 4 11:18:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Armbruster X-Patchwork-Id: 13790618 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 719A4CA0ED3 for ; Wed, 4 Sep 2024 11:27:27 +0000 (UTC) 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 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= 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 X-MC-Unique: 8yEoSOX5PNa8sItUOf5ZuQ-1 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) 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-type: text/plain X-Scanned-By: MIMEDefang 3.0 on 10.30.177.15 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org 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-qobject-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(TestInputVisitorData *data, visit_type_TestUnionInUnion(v, NULL, &tmp, &error_abort); g_assert_cmpint(tmp->type, ==, TEST_UNION_ENUM_VALUE_A); - g_assert_cmpint(tmp->u.value_a.type_a, ==, TEST_UNION_ENUMA_VALUE_A1); + g_assert_cmpint(tmp->u.value_a.type_a, ==, TEST_UNION_ENUM_A_VALUE_A1); g_assert_cmpint(tmp->u.value_a.u.value_a1.integer, ==, 2); g_assert_cmpint(strcmp(tmp->u.value_a.u.value_a1.name, "fish"), ==, 0); @@ -734,7 +734,7 @@ static void test_visitor_in_union_in_union(TestInputVisitorData *data, visit_type_TestUnionInUnion(v, NULL, &tmp, &error_abort); g_assert_cmpint(tmp->type, ==, TEST_UNION_ENUM_VALUE_A); - g_assert_cmpint(tmp->u.value_a.type_a, ==, TEST_UNION_ENUMA_VALUE_A2); + g_assert_cmpint(tmp->u.value_a.type_a, ==, TEST_UNION_ENUM_A_VALUE_A2); g_assert_cmpint(tmp->u.value_a.u.value_a2.integer, ==, 1729); g_assert_cmpint(tmp->u.value_a.u.value_a2.size, ==, 87539319); diff --git a/tests/unit/test-qobject-output-visitor.c b/tests/unit/test-qobject-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(TestOutputVisitorData *data, TestUnionInUnion *tmp = g_new0(TestUnionInUnion, 1); tmp->type = TEST_UNION_ENUM_VALUE_A; - tmp->u.value_a.type_a = TEST_UNION_ENUMA_VALUE_A1; + tmp->u.value_a.type_a = TEST_UNION_ENUM_A_VALUE_A1; tmp->u.value_a.u.value_a1.integer = 42; tmp->u.value_a.u.value_a1.name = g_strdup("fish"); @@ -377,7 +377,7 @@ static void test_visitor_out_union_in_union(TestOutputVisitorData *data, visitor_reset(data); tmp = g_new0(TestUnionInUnion, 1); tmp->type = TEST_UNION_ENUM_VALUE_A; - tmp->u.value_a.type_a = TEST_UNION_ENUMA_VALUE_A2; + tmp->u.value_a.type_a = TEST_UNION_ENUM_A_VALUE_A2; tmp->u.value_a.u.value_a2.integer = 1729; tmp->u.value_a.u.value_a2.size = 87539319; diff --git a/tests/qapi-schema/qapi-schema-test.json b/tests/qapi-schema/qapi-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' ] } { 'enum': 'TestUnionEnumA', - 'prefix': 'TEST_UNION_ENUMA', # TODO drop 'data': [ 'value-a1', 'value-a2' ] } { 'struct': 'TestUnionTypeA1', diff --git a/tests/qapi-schema/qapi-schema-test.out b/tests/qapi-schema/qapi-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 From patchwork Wed Sep 4 11:18:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Armbruster X-Patchwork-Id: 13790620 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 96834CA0ED3 for ; Wed, 4 Sep 2024 11:28:22 +0000 (UTC) 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 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= 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 X-MC-Unique: sjpFcQu1MvupF4SYoECIcA-1 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) 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-type: text/plain X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org 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' ] } ## 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 **errp) if (!*name) { name = allocated_name = blk_get_attached_dev_id(blk); } - xdbg_graph_add_node(gr, blk, X_DBG_BLOCK_GRAPH_NODE_TYPE_BLOCK_BACKEND, + xdbg_graph_add_node(gr, blk, XDBG_BLOCK_GRAPH_NODE_TYPE_BLOCK_BACKEND, name); g_free(allocated_name); if (blk_root(blk)) { @@ -6364,7 +6364,7 @@ XDbgBlockGraph *bdrv_get_xdbg_block_graph(Error **errp) job = block_job_next_locked(job)) { GSList *el; - 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 = job->nodes; el; el = el->next) { xdbg_graph_add_edge(gr, job, (BdrvChild *)el->data); @@ -6373,7 +6373,7 @@ XDbgBlockGraph *bdrv_get_xdbg_block_graph(Error **errp) } QTAILQ_FOREACH(bs, &graph_bdrv_states, node_list) { - xdbg_graph_add_node(gr, bs, X_DBG_BLOCK_GRAPH_NODE_TYPE_BLOCK_DRIVER, + xdbg_graph_add_node(gr, bs, XDBG_BLOCK_GRAPH_NODE_TYPE_BLOCK_DRIVER, bs->node_name); QLIST_FOREACH(child, &bs->children, next) { xdbg_graph_add_edge(gr, bs, child); From patchwork Wed Sep 4 11:18:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Markus Armbruster X-Patchwork-Id: 13790624 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 54008CA0ED3 for ; Wed, 4 Sep 2024 11:29:45 +0000 (UTC) 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 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= 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 X-MC-Unique: ofAYSMSyOQ-lOH4Y7zlY6Q-1 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) 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_Le_Goater?= 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 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org 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édric 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' ] } ## 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 *vdev, Error **errp) int target_bar = -1; size_t msix_sz; - if (!vdev->msix || vdev->msix_relo == OFF_AUTOPCIBAR_OFF) { + if (!vdev->msix || vdev->msix_relo == OFF_AUTO_PCIBAR_OFF) { return true; } @@ -1464,7 +1464,7 @@ static bool vfio_pci_relocate_msix(VFIOPCIDevice *vdev, Error **errp) /* PCI BARs must be a power of 2 */ msix_sz = pow2ceil(msix_sz); - if (vdev->msix_relo == OFF_AUTOPCIBAR_AUTO) { + if (vdev->msix_relo == OFF_AUTO_PCIBAR_AUTO) { /* * TODO: Lookup table for known devices. * @@ -1479,7 +1479,7 @@ static bool vfio_pci_relocate_msix(VFIOPCIDevice *vdev, Error **errp) return false; } } else { - target_bar = (int)(vdev->msix_relo - OFF_AUTOPCIBAR_BAR0); + target_bar = (int)(vdev->msix_relo - OFF_AUTO_PCIBAR_BAR0); } /* 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 = 0xb400; - } else if (vdev->msix_relo == OFF_AUTOPCIBAR_OFF) { + } else if (vdev->msix_relo == 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[] = { nv_gpudirect_clique, qdev_prop_nv_gpudirect_clique, uint8_t), DEFINE_PROP_OFF_AUTO_PCIBAR("x-msix-relocation", VFIOPCIDevice, msix_relo, - OFF_AUTOPCIBAR_OFF), + OFF_AUTO_PCIBAR_OFF), #ifdef CONFIG_IOMMUFD DEFINE_PROP_LINK("iommufd", VFIOPCIDevice, vbasedev.iommufd, TYPE_IOMMUFD_BACKEND, IOMMUFDBackend *), From patchwork Wed Sep 4 11:18:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Markus Armbruster X-Patchwork-Id: 13790602 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 56AE9CD3431 for ; Wed, 4 Sep 2024 11:25:58 +0000 (UTC) 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 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= 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 X-MC-Unique: iYG9wXhTNGKOqN7f6QET-Q-1 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) 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 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org 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é --- 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']} ## @@ -360,7 +359,6 @@ # Since: 5.1 ## { 'enum': 'QCryptoBlockLUKSKeyslotState', - 'prefix': 'Q_CRYPTO_BLOCKLUKS_KEYSLOT_STATE', # TODO drop 'data': [ 'active', 'inactive' ] } ## 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); } @@ -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 *create_options, Error **errp) } create_opts = (QCryptoBlockCreateOptions) { - .format = Q_CRYPTO_BLOCK_FORMAT_LUKS, + .format = QCRYPTO_BLOCK_FORMAT_LUKS, .u.luks = *qapi_BlockdevCreateOptionsLUKS_base(luks_opts), }; @@ -889,7 +889,7 @@ block_crypto_get_specific_info_luks(BlockDriverState *bs, Error **errp) if (!info) { return NULL; } - assert(info->format == Q_CRYPTO_BLOCK_FORMAT_LUKS); + assert(info->format == QCRYPTO_BLOCK_FORMAT_LUKS); spec_info = g_new(ImageInfoSpecific, 1); spec_info->type = IMAGE_INFO_SPECIFIC_KIND_LUKS; @@ -1002,7 +1002,7 @@ coroutine_fn block_crypto_co_amend_luks(BlockDriverState *bs, QCryptoBlockAmendOptions amend_opts; amend_opts = (QCryptoBlockAmendOptions) { - .format = Q_CRYPTO_BLOCK_FORMAT_LUKS, + .format = QCRYPTO_BLOCK_FORMAT_LUKS, .u.luks = *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 **errp) } if (qcow_opts->encrypt && - qcow_opts->encrypt->format != Q_CRYPTO_BLOCK_FORMAT_QCOW) + qcow_opts->encrypt->format != 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; switch (cryptoopts->format) { - case Q_CRYPTO_BLOCK_FORMAT_LUKS: + case QCRYPTO_BLOCK_FORMAT_LUKS: fmt = QCOW_CRYPT_LUKS; break; - case Q_CRYPTO_BLOCK_FORMAT_QCOW: + case QCRYPTO_BLOCK_FORMAT_QCOW: fmt = QCOW_CRYPT_AES; break; default: @@ -5306,10 +5306,10 @@ qcow2_get_specific_info(BlockDriverState *bs, Error **errp) ImageInfoSpecificQCow2Encryption *qencrypt = g_new(ImageInfoSpecificQCow2Encryption, 1); switch (encrypt_info->format) { - case Q_CRYPTO_BLOCK_FORMAT_QCOW: + case QCRYPTO_BLOCK_FORMAT_QCOW: qencrypt->format = BLOCKDEV_QCOW2_ENCRYPTION_FORMAT_AES; break; - case Q_CRYPTO_BLOCK_FORMAT_LUKS: + case QCRYPTO_BLOCK_FORMAT_LUKS: qencrypt->format = BLOCKDEV_QCOW2_ENCRYPTION_FORMAT_LUKS; qencrypt->u.luks = encrypt_info->u.luks; break; @@ -5948,7 +5948,7 @@ static int coroutine_fn qcow2_co_amend(BlockDriverState *bs, return -EOPNOTSUPP; } - if (qopts->encrypt->format != Q_CRYPTO_BLOCK_FORMAT_LUKS) { + if (qopts->encrypt->format != 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 *block, QCryptoBlockAmendOptionsLUKS *opts_luks = &options->u.luks; 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, errp); 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" static const QCryptoBlockDriver *qcrypto_block_drivers[] = { - [Q_CRYPTO_BLOCK_FORMAT_QCOW] = &qcrypto_block_driver_qcow, - [Q_CRYPTO_BLOCK_FORMAT_LUKS] = &qcrypto_block_driver_luks, + [QCRYPTO_BLOCK_FORMAT_QCOW] = &qcrypto_block_driver_qcow, + [QCRYPTO_BLOCK_FORMAT_LUKS] = &qcrypto_block_driver_luks, }; 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 static QCryptoBlockCreateOptions qcow_create_opts = { - .format = Q_CRYPTO_BLOCK_FORMAT_QCOW, + .format = QCRYPTO_BLOCK_FORMAT_QCOW, .u.qcow = { .key_secret = (char *)"sec0", }, }; static QCryptoBlockOpenOptions qcow_open_opts = { - .format = Q_CRYPTO_BLOCK_FORMAT_QCOW, + .format = QCRYPTO_BLOCK_FORMAT_QCOW, .u.qcow = { .key_secret = (char *)"sec0", }, @@ -55,7 +55,7 @@ static QCryptoBlockOpenOptions qcow_open_opts = { #ifdef TEST_LUKS static QCryptoBlockOpenOptions luks_open_opts = { - .format = Q_CRYPTO_BLOCK_FORMAT_LUKS, + .format = QCRYPTO_BLOCK_FORMAT_LUKS, .u.luks = { .key_secret = (char *)"sec0", }, @@ -64,7 +64,7 @@ static QCryptoBlockOpenOptions luks_open_opts = { /* Creation with all default values */ static QCryptoBlockCreateOptions luks_create_opts_default = { - .format = Q_CRYPTO_BLOCK_FORMAT_LUKS, + .format = QCRYPTO_BLOCK_FORMAT_LUKS, .u.luks = { .key_secret = (char *)"sec0", }, @@ -73,7 +73,7 @@ static QCryptoBlockCreateOptions luks_create_opts_default = { /* ...and with explicit values */ static QCryptoBlockCreateOptions luks_create_opts_aes256_cbc_plain64 = { - .format = Q_CRYPTO_BLOCK_FORMAT_LUKS, + .format = QCRYPTO_BLOCK_FORMAT_LUKS, .u.luks = { .key_secret = (char *)"sec0", .has_cipher_alg = true, @@ -87,7 +87,7 @@ static QCryptoBlockCreateOptions luks_create_opts_aes256_cbc_plain64 = { static QCryptoBlockCreateOptions luks_create_opts_aes256_cbc_essiv = { - .format = Q_CRYPTO_BLOCK_FORMAT_LUKS, + .format = QCRYPTO_BLOCK_FORMAT_LUKS, .u.luks = { .key_secret = (char *)"sec0", .has_cipher_alg = true, @@ -572,7 +572,7 @@ int main(int argc, char **argv) g_assert(qcrypto_init(NULL) == 0); for (i = 0; i < G_N_ELEMENTS(test_data); i++) { - if (test_data[i].open_opts->format == Q_CRYPTO_BLOCK_FORMAT_LUKS && + if (test_data[i].open_opts->format == QCRYPTO_BLOCK_FORMAT_LUKS && !qcrypto_hash_supports(test_data[i].hash_alg)) { continue; } From patchwork Wed Sep 4 11:18:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Armbruster X-Patchwork-Id: 13790612 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 4E64CCA0ED3 for ; Wed, 4 Sep 2024 11:26:39 +0000 (UTC) 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 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= 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 X-MC-Unique: pVd6KmuaMr2gAXdvQZzOMA-1 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) 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-type: text/plain X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org 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' } ] } 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 = -1; } -ebpf_binary_init(EBPF_PROGRAMID_RSS, rss_bpf__elf_bytes) +ebpf_binary_init(EBPF_PROGRAM_ID_RSS, rss_bpf__elf_bytes) From patchwork Wed Sep 4 11:18:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Armbruster X-Patchwork-Id: 13790622 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 4C48CCD3431 for ; Wed, 4 Sep 2024 11:29:21 +0000 (UTC) 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 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= 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 X-MC-Unique: Ma6bQ6FpOSGSk9Gn1qDidg-1 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) 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-type: text/plain X-Scanned-By: MIMEDefang 3.0 on 10.30.177.40 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org 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' ] } ## @@ -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' ] } 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, NumaHmatLBOptions *node, lb_data.initiator = node->initiator; lb_data.target = node->target; - if (node->data_type <= HMATLB_DATA_TYPE_WRITE_LATENCY) { + if (node->data_type <= HMAT_LB_DATA_TYPE_WRITE_LATENCY) { /* Input latency data */ if (!node->has_latency) { @@ -313,7 +313,7 @@ void parse_numa_hmat_lb(NumaState *numa_state, NumaHmatLBOptions *node, numa_info[node->target].lb_info_provided |= BIT(0); } lb_data.data = node->latency; - } else if (node->data_type >= HMATLB_DATA_TYPE_ACCESS_BANDWIDTH) { + } else if (node->data_type >= 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 = CDAT_TYPE_SSLBIS, .length = sslbis_size, }, - .data_type = HMATLB_DATA_TYPE_ACCESS_LATENCY, + .data_type = HMAT_LB_DATA_TYPE_ACCESS_LATENCY, .entry_base_unit = 10000, }, }; @@ -254,7 +254,7 @@ static int build_cdat_table(CDATSubHeader ***cdat_table, void *priv) .type = CDAT_TYPE_SSLBIS, .length = sslbis_size, }, - .data_type = HMATLB_DATA_TYPE_ACCESS_BANDWIDTH, + .data_type = HMAT_LB_DATA_TYPE_ACCESS_BANDWIDTH, .entry_base_unit = 1024, }, }; From patchwork Wed Sep 4 11:18:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Armbruster X-Patchwork-Id: 13790610 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 8670CCA0ED3 for ; Wed, 4 Sep 2024 11:26:31 +0000 (UTC) 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 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= 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 X-MC-Unique: f_RRaaRgPMeBbeFZ_Pxv9g-1 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) 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-type: text/plain X-Scanned-By: MIMEDefang 3.0 on 10.30.177.15 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org 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' ] } ## 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) qemu_console_early_init(); - if (dpy.has_gl && dpy.gl != DISPLAYGL_MODE_OFF && display_opengl == 0) { + if (dpy.has_gl && dpy.gl != DISPLAY_GL_MODE_OFF && display_opengl == 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, Error **errp) assert(con); if (qemu_console_is_graphic(con) && - dd->gl_mode != DISPLAYGL_MODE_OFF) { + dd->gl_mode != DISPLAY_GL_MODE_OFF) { qemu_console_set_display_gl_ctx(con, &dd->glctx); } @@ -466,9 +466,9 @@ static const TypeInfo dbus_vc_type_info = { static void early_dbus_init(DisplayOptions *opts) { - DisplayGLMode mode = opts->has_gl ? opts->gl : DISPLAYGL_MODE_OFF; + DisplayGLMode mode = opts->has_gl ? opts->gl : DISPLAY_GL_MODE_OFF; - if (mode != DISPLAYGL_MODE_OFF) { + if (mode != 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 = opts->has_gl ? opts->gl : DISPLAYGL_MODE_OFF; + DisplayGLMode mode = opts->has_gl ? opts->gl : DISPLAY_GL_MODE_OFF; if (opts->u.dbus.addr && opts->u.dbus.p2p) { error_report("dbus: can't accept both addr=X and p2p=yes options"); 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 = (qemu_egl_mode == DISPLAYGL_MODE_ES); + bool gles = (qemu_egl_mode == DISPLAY_GL_MODE_ES); ctx = 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 = { static void early_egl_headless_init(DisplayOptions *opts) { - DisplayGLMode mode = DISPLAYGL_MODE_ON; + DisplayGLMode mode = DISPLAY_GL_MODE_ON; if (opts->has_gl) { mode = 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 = (mode == DISPLAYGL_MODE_ES); + bool gles = (mode == DISPLAY_GL_MODE_ES); qemu_egl_display = qemu_egl_get_display(dpy, platform); if (qemu_egl_display == EGL_NO_DISPLAY) { @@ -533,7 +533,7 @@ static int qemu_egl_init_dpy(EGLNativeDisplayType dpy, return -1; } - qemu_egl_mode = gles ? DISPLAYGL_MODE_ES : DISPLAYGL_MODE_CORE; + qemu_egl_mode = gles ? DISPLAY_GL_MODE_ES : DISPLAY_GL_MODE_CORE; return 0; } @@ -564,8 +564,8 @@ int qemu_egl_init_dpy_mesa(EGLNativeDisplayType dpy, DisplayGLMode mode) int qemu_egl_init_dpy_win32(EGLNativeDisplayType dpy, DisplayGLMode mode) { /* prefer GL ES, as that's what ANGLE supports */ - if (mode == DISPLAYGL_MODE_ON) { - mode = DISPLAYGL_MODE_ES; + if (mode == DISPLAY_GL_MODE_ON) { + mode = DISPLAY_GL_MODE_ES; } 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 = (qemu_egl_mode == DISPLAYGL_MODE_ES); + bool gles = (qemu_egl_mode == DISPLAY_GL_MODE_ES); EGLContext ectx; EGLBoolean b; @@ -642,7 +642,7 @@ bool egl_init(const char *rendernode, DisplayGLMode mode, Error **errp) { ERRP_GUARD(); - if (mode == DISPLAYGL_MODE_OFF) { + if (mode == 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 *opts) } assert(opts->type == DISPLAY_TYPE_GTK); - if (opts->has_gl && opts->gl != DISPLAYGL_MODE_OFF) { + if (opts->has_gl && opts->gl != 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 *opts) #endif { #ifdef CONFIG_X11 - DisplayGLMode mode = opts->has_gl ? opts->gl : DISPLAYGL_MODE_ON; + DisplayGLMode mode = opts->has_gl ? opts->gl : DISPLAY_GL_MODE_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 *dgc, SDL_GL_MakeCurrent(scon->real_window, scon->winctx); SDL_GL_SetAttribute(SDL_GL_SHARE_WITH_CURRENT_CONTEXT, 1); - if (scon->opts->gl == DISPLAYGL_MODE_ON || - scon->opts->gl == DISPLAYGL_MODE_CORE) { + if (scon->opts->gl == DISPLAY_GL_MODE_ON || + scon->opts->gl == DISPLAY_GL_MODE_CORE) { SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE); - } else if (scon->opts->gl == DISPLAYGL_MODE_ES) { + } else if (scon->opts->gl == 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 == DISPLAYGL_MODE_ON) { + if (!ctx && scon->opts->gl == DISPLAY_GL_MODE_ON) { SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_ES); ctx = 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 = "opengl"; - if (scon->opts->gl == DISPLAYGL_MODE_ES) { + if (scon->opts->gl == DISPLAY_GL_MODE_ES) { driver = "opengles2"; } 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, &error_fatal); + egl_init(qemu_opt_get(opts, "rendernode"), DISPLAY_GL_MODE_ON, &error_fatal); spice_opengl = 1; } #endif From patchwork Wed Sep 4 11:18:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Markus Armbruster X-Patchwork-Id: 13790613 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B5B52CD3431 for ; Wed, 4 Sep 2024 11:26:49 +0000 (UTC) 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 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= 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 X-MC-Unique: 63Bd3otfNrOJFq-UnnzLfw-1 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) 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 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org 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é 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 @@ ## ## -# @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' ] } } ## -# @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' ] } } 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' ] } ## -# @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' ] } ## @@ -66,9 +65,9 @@ # Since: 2.12 ## { 'struct': 'CpuInfoS390', - 'data': { 'cpu-state': 'CpuS390State', + 'data': { 'cpu-state': 'S390CpuState', '*dedicated': 'bool', - '*entitlement': 'CpuS390Entitlement' } } + '*entitlement': 'S390CpuEntitlement' } } ## # @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-properties-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_list; #define DEFINE_PROP_CPUS390ENTITLEMENT(_n, _s, _f, _d) \ DEFINE_PROP_SIGNED(_n, _s, _f, _d, qdev_prop_cpus390entitlement, \ - CpuS390Entitlement) + S390CpuEntitlement) #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-topology.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 { typedef struct S390Topology { uint8_t *cores_per_socket; - CpuS390Polarization polarization; + S390CpuPolarization polarization; } S390Topology; 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 diff --git a/hw/core/qdev-properties-system.c b/hw/core/qdev-properties-system.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 = { /* --- s390 cpu entitlement policy --- */ -QEMU_BUILD_BUG_ON(sizeof(CpuS390Entitlement) != sizeof(int)); +QEMU_BUILD_BUG_ON(sizeof(S390CpuEntitlement) != sizeof(int)); const PropertyInfo qdev_prop_cpus390entitlement = { - .name = "CpuS390Entitlement", + .name = "S390CpuEntitlement", .description = "low/medium (default)/high", - .enum_table = &CpuS390Entitlement_lookup, + .enum_table = &S390CpuEntitlement_lookup, .get = qdev_propinfo_get_enum, .set = qdev_propinfo_set_enum, .set_default_value = 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 = &cpu->env; uint64_t reg = env->regs[r1]; int fc = 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 entitlement, + bool has_entitlement, S390CpuEntitlement entitlement, bool has_dedicated, bool dedicated, Error **errp) { From patchwork Wed Sep 4 11:18:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Markus Armbruster X-Patchwork-Id: 13790626 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 96B4BCD3431 for ; Wed, 4 Sep 2024 11:30:14 +0000 (UTC) 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 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= 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 X-MC-Unique: PrQIcrxeMyCg09Ng8bdaoQ-1 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) 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 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org 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é --- 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']} ## 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( switch (sess_info->keytype) { case VIRTIO_CRYPTO_AKCIPHER_KEY_TYPE_PUBLIC: - type = QCRYPTO_AKCIPHER_KEY_TYPE_PUBLIC; + type = QCRYPTO_AK_CIPHER_KEY_TYPE_PUBLIC; break; case VIRTIO_CRYPTO_AKCIPHER_KEY_TYPE_PRIVATE: - type = QCRYPTO_AKCIPHER_KEY_TYPE_PRIVATE; + type = QCRYPTO_AK_CIPHER_KEY_TYPE_PRIVATE; break; 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(CryptoDevLKCFTask *task) * 2. generally, public key related compution is fast, just compute it with * thread-pool. */ - if (session->keytype == QCRYPTO_AKCIPHER_KEY_TYPE_PRIVATE) { + if (session->keytype == 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( switch (sess_info->keytype) { case VIRTIO_CRYPTO_AKCIPHER_KEY_TYPE_PUBLIC: - sess->keytype = QCRYPTO_AKCIPHER_KEY_TYPE_PUBLIC; + sess->keytype = QCRYPTO_AK_CIPHER_KEY_TYPE_PUBLIC; break; case VIRTIO_CRYPTO_AKCIPHER_KEY_TYPE_PRIVATE: - sess->keytype = QCRYPTO_AKCIPHER_KEY_TYPE_PRIVATE; + sess->keytype = QCRYPTO_AK_CIPHER_KEY_TYPE_PRIVATE; break; default: diff --git a/tests/bench/benchmark-crypto-akcipher.c b/tests/bench/benchmark-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 = QCRYPTO_AKCIPHER_ALG_RSA; opt.u.rsa.padding_alg = padding; opt.u.rsa.hash_alg = 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); } diff --git a/tests/unit/test-crypto-akcipher.c b/tests/unit/test-crypto-akcipher.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[] = { { .path = "/crypto/akcipher/rsakey-1024-public", - .key_type = QCRYPTO_AKCIPHER_KEY_TYPE_PUBLIC, + .key_type = QCRYPTO_AK_CIPHER_KEY_TYPE_PUBLIC, .key = rsa1024_public_key, .keylen = sizeof(rsa1024_public_key), .is_valid_key = true, @@ -700,7 +700,7 @@ static QCryptoRSAKeyTestData rsakey_test_data[] = { }, { .path = "/crypto/akcipher/rsakey-1024-private", - .key_type = QCRYPTO_AKCIPHER_KEY_TYPE_PRIVATE, + .key_type = QCRYPTO_AK_CIPHER_KEY_TYPE_PRIVATE, .key = rsa1024_private_key, .keylen = sizeof(rsa1024_private_key), .is_valid_key = true, @@ -708,7 +708,7 @@ static QCryptoRSAKeyTestData rsakey_test_data[] = { }, { .path = "/crypto/akcipher/rsakey-2048-public", - .key_type = QCRYPTO_AKCIPHER_KEY_TYPE_PUBLIC, + .key_type = QCRYPTO_AK_CIPHER_KEY_TYPE_PUBLIC, .key = rsa2048_public_key, .keylen = sizeof(rsa2048_public_key), .is_valid_key = true, @@ -716,7 +716,7 @@ static QCryptoRSAKeyTestData rsakey_test_data[] = { }, { .path = "/crypto/akcipher/rsakey-2048-private", - .key_type = QCRYPTO_AKCIPHER_KEY_TYPE_PRIVATE, + .key_type = QCRYPTO_AK_CIPHER_KEY_TYPE_PRIVATE, .key = rsa2048_private_key, .keylen = sizeof(rsa2048_private_key), .is_valid_key = true, @@ -724,56 +724,56 @@ static QCryptoRSAKeyTestData rsakey_test_data[] = { }, { .path = "/crypto/akcipher/rsakey-public-lack-elem", - .key_type = QCRYPTO_AKCIPHER_KEY_TYPE_PUBLIC, + .key_type = QCRYPTO_AK_CIPHER_KEY_TYPE_PUBLIC, .key = rsa_public_key_lack_element, .keylen = sizeof(rsa_public_key_lack_element), .is_valid_key = false, }, { .path = "/crypto/akcipher/rsakey-private-lack-elem", - .key_type = QCRYPTO_AKCIPHER_KEY_TYPE_PRIVATE, + .key_type = QCRYPTO_AK_CIPHER_KEY_TYPE_PRIVATE, .key = rsa_private_key_lack_element, .keylen = sizeof(rsa_private_key_lack_element), .is_valid_key = false, }, { .path = "/crypto/akcipher/rsakey-public-empty-elem", - .key_type = QCRYPTO_AKCIPHER_KEY_TYPE_PUBLIC, + .key_type = QCRYPTO_AK_CIPHER_KEY_TYPE_PUBLIC, .key = rsa_public_key_empty_element, .keylen = sizeof(rsa_public_key_empty_element), .is_valid_key = false, }, { .path = "/crypto/akcipher/rsakey-private-empty-elem", - .key_type = QCRYPTO_AKCIPHER_KEY_TYPE_PRIVATE, + .key_type = QCRYPTO_AK_CIPHER_KEY_TYPE_PRIVATE, .key = rsa_private_key_empty_element, .keylen = sizeof(rsa_private_key_empty_element), .is_valid_key = false, }, { .path = "/crypto/akcipher/rsakey-public-empty-key", - .key_type = QCRYPTO_AKCIPHER_KEY_TYPE_PUBLIC, + .key_type = QCRYPTO_AK_CIPHER_KEY_TYPE_PUBLIC, .key = NULL, .keylen = 0, .is_valid_key = false, }, { .path = "/crypto/akcipher/rsakey-private-empty-key", - .key_type = QCRYPTO_AKCIPHER_KEY_TYPE_PRIVATE, + .key_type = QCRYPTO_AK_CIPHER_KEY_TYPE_PRIVATE, .key = NULL, .keylen = 0, .is_valid_key = false, }, { .path = "/crypto/akcipher/rsakey-public-invalid-length-val", - .key_type = QCRYPTO_AKCIPHER_KEY_TYPE_PUBLIC, + .key_type = QCRYPTO_AK_CIPHER_KEY_TYPE_PUBLIC, .key = rsa_public_key_invalid_length_val, .keylen = sizeof(rsa_public_key_invalid_length_val), .is_valid_key = false, }, { .path = "/crypto/akcipher/rsakey-public-extra-elem", - .key_type = QCRYPTO_AKCIPHER_KEY_TYPE_PUBLIC, + .key_type = QCRYPTO_AK_CIPHER_KEY_TYPE_PUBLIC, .key = rsa_public_key_extra_elem, .keylen = sizeof(rsa_public_key_extra_elem), .is_valid_key = false, @@ -885,12 +885,12 @@ static void test_akcipher(const void *opaque) return; } pub_key = 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 != NULL); priv_key = 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 != 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 = qcrypto_akcipher_rsakey_parse( - QCRYPTO_AKCIPHER_KEY_TYPE_PRIVATE, key, keylen, errp); + QCRYPTO_AK_CIPHER_KEY_TYPE_PRIVATE, key, keylen, errp); gcry_mpi_t n = NULL, e = NULL, d = NULL, p = NULL, q = NULL, u = NULL; bool compute_mul_inv = false; int ret = -1; @@ -178,7 +178,7 @@ static int qcrypto_gcrypt_parse_rsa_public_key(QCryptoGcryptRSA *rsa, { g_autoptr(QCryptoAkCipherRSAKey) rsa_key = qcrypto_akcipher_rsakey_parse( - QCRYPTO_AKCIPHER_KEY_TYPE_PUBLIC, key, keylen, errp); + QCRYPTO_AK_CIPHER_KEY_TYPE_PUBLIC, key, keylen, errp); gcry_mpi_t n = NULL, e = NULL; int ret = -1; gcry_error_t err; @@ -540,13 +540,13 @@ static QCryptoGcryptRSA *qcrypto_gcrypt_rsa_new( rsa->akcipher.driver = &gcrypt_rsa; 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) != 0) { goto error; } break; - case QCRYPTO_AKCIPHER_KEY_TYPE_PUBLIC: + case QCRYPTO_AK_CIPHER_KEY_TYPE_PUBLIC: if (qcrypto_gcrypt_parse_rsa_public_key(rsa, key, keylen, errp) != 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(QCryptoNettleRSA *rsa, Error **errp) { g_autoptr(QCryptoAkCipherRSAKey) rsa_key = qcrypto_akcipher_rsakey_parse( - QCRYPTO_AKCIPHER_KEY_TYPE_PRIVATE, key, keylen, errp); + QCRYPTO_AK_CIPHER_KEY_TYPE_PRIVATE, key, keylen, errp); if (!rsa_key) { return -1; @@ -137,7 +137,7 @@ static int qcrypt_nettle_parse_rsa_public_key(QCryptoNettleRSA *rsa, Error **errp) { g_autoptr(QCryptoAkCipherRSAKey) rsa_key = qcrypto_akcipher_rsakey_parse( - QCRYPTO_AKCIPHER_KEY_TYPE_PUBLIC, key, keylen, errp); + QCRYPTO_AK_CIPHER_KEY_TYPE_PUBLIC, key, keylen, errp); if (!rsa_key) { return -1; @@ -397,13 +397,13 @@ static QCryptoAkCipher *qcrypto_nettle_rsa_new( rsa_private_key_init(&rsa->priv); 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) != 0) { goto error; } break; - case QCRYPTO_AKCIPHER_KEY_TYPE_PUBLIC: + case QCRYPTO_AK_CIPHER_KEY_TYPE_PUBLIC: if (qcrypt_nettle_parse_rsa_public_key(rsa, key, keylen, errp) != 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); - case QCRYPTO_AKCIPHER_KEY_TYPE_PUBLIC: + case QCRYPTO_AK_CIPHER_KEY_TYPE_PUBLIC: return qcrypto_builtin_rsa_public_key_parse(key, keylen, errp); 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); - case QCRYPTO_AKCIPHER_KEY_TYPE_PUBLIC: + case QCRYPTO_AK_CIPHER_KEY_TYPE_PUBLIC: return qcrypto_nettle_rsa_public_key_parse(key, keylen, errp); default: From patchwork Wed Sep 4 11:18:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Markus Armbruster X-Patchwork-Id: 13790611 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 96D59CD4849 for ; Wed, 4 Sep 2024 11:26:31 +0000 (UTC) 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 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= 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 X-MC-Unique: kPFm4qfVNPiD0eqbEwR-kw-1 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) 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 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.15 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org 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é --- 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']} ## -# @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', 'ripemd160']} ## @@ -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' }} ## @@ -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'}} ## 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; - 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; 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); }; -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; #include "afalgpriv.h" -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 { QCryptoIVGenAlgorithm algorithm; QCryptoCipherAlgorithm cipher; - QCryptoHashAlgorithm hash; + QCryptoHashAlgo hash; }; 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 = 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 = 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 *block); * * Returns: the hash algorithm */ -QCryptoHashAlgorithm qcrypto_block_get_kdf_hash(QCryptoBlock *block); +QCryptoHashAlgo qcrypto_block_get_kdf_hash(QCryptoBlock *block); /** * 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 @@ #include "qapi/qapi-types-crypto.h" -/* See also "QCryptoHashAlgorithm" defined in qapi/crypto.json */ +/* See also "QCryptoHashAlgo" defined in qapi/crypto.json */ /** * 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); /** @@ -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); /** * 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 @@ 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); /** * 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); 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 = 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); @@ -191,7 +191,7 @@ QCryptoCipherAlgorithm qcrypto_ivgen_get_cipher(QCryptoIVGen *ivgen); * * Returns: the hash algorithm */ -QCryptoHashAlgorithm qcrypto_ivgen_get_hash(QCryptoIVGen *ivgen); +QCryptoHashAlgo qcrypto_ivgen_get_hash(QCryptoIVGen *ivgen); /** 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 = qcrypto_pbkdf2_count_iters(QCRYPTO_HASH_ALG_SHA256, + * iterations = 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); /** @@ -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; case VIRTIO_CRYPTO_RSA_SHA1: - return QCRYPTO_HASH_ALG_SHA1; + return QCRYPTO_HASH_ALGO_SHA1; case VIRTIO_CRYPTO_RSA_SHA256: - return QCRYPTO_HASH_ALG_SHA256; + return QCRYPTO_HASH_ALGO_SHA256; case VIRTIO_CRYPTO_RSA_SHA512: - return QCRYPTO_HASH_ALG_SHA512; + return QCRYPTO_HASH_ALGO_SHA512; 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(QCryptoAkCipherOptions *opts, if (rsa_opt->padding_alg == QCRYPTO_RSA_PADDING_ALG_PKCS1) { snprintf(key_desc, desc_len, "enc=%s hash=%s", QCryptoRSAPaddingAlgorithm_str(rsa_opt->padding_alg), - QCryptoHashAlgorithm_str(rsa_opt->hash_alg)); + QCryptoHashAlgo_str(rsa_opt->hash_alg)); } else { snprintf(key_desc, desc_len, "enc=%s", @@ -161,19 +161,19 @@ static int cryptodev_lkcf_set_rsa_opt(int virtio_padding_alg, switch (virtio_hash_alg) { case VIRTIO_CRYPTO_RSA_MD5: - opt->hash_alg = QCRYPTO_HASH_ALG_MD5; + opt->hash_alg = QCRYPTO_HASH_ALGO_MD5; break; case VIRTIO_CRYPTO_RSA_SHA1: - opt->hash_alg = QCRYPTO_HASH_ALG_SHA1; + opt->hash_alg = QCRYPTO_HASH_ALGO_SHA1; break; case VIRTIO_CRYPTO_RSA_SHA256: - opt->hash_alg = QCRYPTO_HASH_ALG_SHA256; + opt->hash_alg = QCRYPTO_HASH_ALGO_SHA256; break; case VIRTIO_CRYPTO_RSA_SHA512: - opt->hash_alg = QCRYPTO_HASH_ALG_SHA512; + opt->hash_alg = QCRYPTO_HASH_ALGO_SHA512; break; 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; } - ret = qcrypto_hash_bytes(QCRYPTO_HASH_ALG_MD5, (char *)pos, remaining, + ret = qcrypto_hash_bytes(QCRYPTO_HASH_ALGO_MD5, (char *)pos, remaining, &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 = { 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, } -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, } -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, } -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; /* Hash algorithm used for IV generation*/ - QCryptoHashAlgorithm ivgen_hash_alg; + QCryptoHashAlgo ivgen_hash_alg; /* * Encryption algorithm used for IV generation. @@ -141,7 +141,7 @@ struct QCryptoBlockLUKS { QCryptoCipherAlgorithm ivgen_cipher_alg; /* Hash algorithm used in pbkdf2 function */ - QCryptoHashAlgorithm hash_alg; + QCryptoHashAlgo hash_alg; /* 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 *name, #define qcrypto_block_luks_hash_name_lookup(name, errp) \ qcrypto_block_luks_name_lookup(name, \ - &QCryptoHashAlgorithm_lookup, \ + &QCryptoHashAlgo_lookup, \ "Hash algorithm", \ errp) @@ -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 = qcrypto_hash_digest_len(hash); @@ -1331,11 +1331,11 @@ qcrypto_block_luks_create(QCryptoBlock *block, luks_opts.ivgen_alg = QCRYPTO_IVGEN_ALG_PLAIN64; } if (!luks_opts.has_hash_alg) { - luks_opts.hash_alg = QCRYPTO_HASH_ALG_SHA256; + luks_opts.hash_alg = QCRYPTO_HASH_ALGO_SHA256; } if (luks_opts.ivgen_alg == QCRYPTO_IVGEN_ALG_ESSIV) { if (!luks_opts.has_ivgen_hash_alg) { - luks_opts.ivgen_hash_alg = QCRYPTO_HASH_ALG_SHA256; + luks_opts.ivgen_hash_alg = QCRYPTO_HASH_ALGO_SHA256; luks_opts.has_ivgen_hash_alg = true; } } @@ -1386,13 +1386,13 @@ qcrypto_block_luks_create(QCryptoBlock *block, cipher_mode = QCryptoCipherMode_str(luks_opts.cipher_mode); ivgen_alg = QCryptoIVGenAlgorithm_str(luks_opts.ivgen_alg); if (luks_opts.has_ivgen_hash_alg) { - ivgen_hash_alg = QCryptoHashAlgorithm_str(luks_opts.ivgen_hash_alg); + ivgen_hash_alg = QCryptoHashAlgo_str(luks_opts.ivgen_hash_alg); cipher_mode_spec = g_strdup_printf("%s-%s:%s", cipher_mode, ivgen_alg, ivgen_hash_alg); } else { cipher_mode_spec = g_strdup_printf("%s-%s", cipher_mode, ivgen_alg); } - hash_alg = QCryptoHashAlgorithm_str(luks_opts.hash_alg); + hash_alg = QCryptoHashAlgo_str(luks_opts.hash_alg); if (strlen(cipher_alg) >= 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 *block) } -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" 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; switch (alg) { - case QCRYPTO_HASH_ALG_MD5: + case QCRYPTO_HASH_ALGO_MD5: alg_name = "md5"; break; - case QCRYPTO_HASH_ALG_SHA1: + case QCRYPTO_HASH_ALGO_SHA1: alg_name = "sha1"; break; - case QCRYPTO_HASH_ALG_SHA224: + case QCRYPTO_HASH_ALGO_SHA224: alg_name = "sha224"; break; - case QCRYPTO_HASH_ALG_SHA256: + case QCRYPTO_HASH_ALGO_SHA256: alg_name = "sha256"; break; - case QCRYPTO_HASH_ALG_SHA384: + case QCRYPTO_HASH_ALGO_SHA384: alg_name = "sha384"; break; - case QCRYPTO_HASH_ALG_SHA512: + case QCRYPTO_HASH_ALGO_SHA512: alg_name = "sha512"; break; - case QCRYPTO_HASH_ALG_RIPEMD160: + case QCRYPTO_HASH_ALGO_RIPEMD160: alg_name = "rmd160"; break; @@ -65,7 +65,7 @@ qcrypto_afalg_hash_format_name(QCryptoHashAlgorithm alg, } 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 alg, } 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); } 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, 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: } 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" -static int qcrypto_hash_alg_map[QCRYPTO_HASH_ALG__MAX] = { - [QCRYPTO_HASH_ALG_MD5] = GCRY_MD_MD5, - [QCRYPTO_HASH_ALG_SHA1] = GCRY_MD_SHA1, - [QCRYPTO_HASH_ALG_SHA224] = GCRY_MD_SHA224, - [QCRYPTO_HASH_ALG_SHA256] = GCRY_MD_SHA256, - [QCRYPTO_HASH_ALG_SHA384] = GCRY_MD_SHA384, - [QCRYPTO_HASH_ALG_SHA512] = GCRY_MD_SHA512, - [QCRYPTO_HASH_ALG_RIPEMD160] = GCRY_MD_RMD160, +static int qcrypto_hash_alg_map[QCRYPTO_HASH_ALGO__MAX] = { + [QCRYPTO_HASH_ALGO_MD5] = GCRY_MD_MD5, + [QCRYPTO_HASH_ALGO_SHA1] = GCRY_MD_SHA1, + [QCRYPTO_HASH_ALGO_SHA224] = GCRY_MD_SHA224, + [QCRYPTO_HASH_ALGO_SHA256] = GCRY_MD_SHA256, + [QCRYPTO_HASH_ALGO_SHA384] = GCRY_MD_SHA384, + [QCRYPTO_HASH_ALGO_SHA512] = GCRY_MD_SHA512, + [QCRYPTO_HASH_ALGO_RIPEMD160] = GCRY_MD_RMD160, }; -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] != GCRY_MD_NONE) { @@ -46,7 +46,7 @@ gboolean qcrypto_hash_supports(QCryptoHashAlgorithm alg) 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" -static int qcrypto_hash_alg_map[QCRYPTO_HASH_ALG__MAX] = { - [QCRYPTO_HASH_ALG_MD5] = G_CHECKSUM_MD5, - [QCRYPTO_HASH_ALG_SHA1] = G_CHECKSUM_SHA1, - [QCRYPTO_HASH_ALG_SHA224] = -1, - [QCRYPTO_HASH_ALG_SHA256] = G_CHECKSUM_SHA256, - [QCRYPTO_HASH_ALG_SHA384] = -1, - [QCRYPTO_HASH_ALG_SHA512] = G_CHECKSUM_SHA512, - [QCRYPTO_HASH_ALG_RIPEMD160] = -1, +static int qcrypto_hash_alg_map[QCRYPTO_HASH_ALGO__MAX] = { + [QCRYPTO_HASH_ALGO_MD5] = G_CHECKSUM_MD5, + [QCRYPTO_HASH_ALGO_SHA1] = G_CHECKSUM_SHA1, + [QCRYPTO_HASH_ALGO_SHA224] = -1, + [QCRYPTO_HASH_ALGO_SHA256] = G_CHECKSUM_SHA256, + [QCRYPTO_HASH_ALGO_SHA384] = -1, + [QCRYPTO_HASH_ALGO_SHA512] = G_CHECKSUM_SHA512, + [QCRYPTO_HASH_ALGO_RIPEMD160] = -1, }; -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] != -1) { @@ -45,7 +45,7 @@ gboolean qcrypto_hash_supports(QCryptoHashAlgorithm alg) 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" -static int qcrypto_hash_alg_map[QCRYPTO_HASH_ALG__MAX] = { - [QCRYPTO_HASH_ALG_MD5] = GNUTLS_DIG_MD5, - [QCRYPTO_HASH_ALG_SHA1] = GNUTLS_DIG_SHA1, - [QCRYPTO_HASH_ALG_SHA224] = GNUTLS_DIG_SHA224, - [QCRYPTO_HASH_ALG_SHA256] = GNUTLS_DIG_SHA256, - [QCRYPTO_HASH_ALG_SHA384] = GNUTLS_DIG_SHA384, - [QCRYPTO_HASH_ALG_SHA512] = GNUTLS_DIG_SHA512, - [QCRYPTO_HASH_ALG_RIPEMD160] = GNUTLS_DIG_RMD160, +static int qcrypto_hash_alg_map[QCRYPTO_HASH_ALGO__MAX] = { + [QCRYPTO_HASH_ALGO_MD5] = GNUTLS_DIG_MD5, + [QCRYPTO_HASH_ALGO_SHA1] = GNUTLS_DIG_SHA1, + [QCRYPTO_HASH_ALGO_SHA224] = GNUTLS_DIG_SHA224, + [QCRYPTO_HASH_ALGO_SHA256] = GNUTLS_DIG_SHA256, + [QCRYPTO_HASH_ALGO_SHA384] = GNUTLS_DIG_SHA384, + [QCRYPTO_HASH_ALGO_SHA512] = GNUTLS_DIG_SHA512, + [QCRYPTO_HASH_ALGO_RIPEMD160] = GNUTLS_DIG_RMD160, }; -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) 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[] = { - [QCRYPTO_HASH_ALG_MD5] = { + [QCRYPTO_HASH_ALGO_MD5] = { .init = (qcrypto_nettle_init)md5_init, .write = (qcrypto_nettle_write)md5_update, .result = (qcrypto_nettle_result)md5_digest, .len = MD5_DIGEST_SIZE, }, - [QCRYPTO_HASH_ALG_SHA1] = { + [QCRYPTO_HASH_ALGO_SHA1] = { .init = (qcrypto_nettle_init)sha1_init, .write = (qcrypto_nettle_write)sha1_update, .result = (qcrypto_nettle_result)sha1_digest, .len = SHA1_DIGEST_SIZE, }, - [QCRYPTO_HASH_ALG_SHA224] = { + [QCRYPTO_HASH_ALGO_SHA224] = { .init = (qcrypto_nettle_init)sha224_init, .write = (qcrypto_nettle_write)sha224_update, .result = (qcrypto_nettle_result)sha224_digest, .len = SHA224_DIGEST_SIZE, }, - [QCRYPTO_HASH_ALG_SHA256] = { + [QCRYPTO_HASH_ALGO_SHA256] = { .init = (qcrypto_nettle_init)sha256_init, .write = (qcrypto_nettle_write)sha256_update, .result = (qcrypto_nettle_result)sha256_digest, .len = SHA256_DIGEST_SIZE, }, - [QCRYPTO_HASH_ALG_SHA384] = { + [QCRYPTO_HASH_ALGO_SHA384] = { .init = (qcrypto_nettle_init)sha384_init, .write = (qcrypto_nettle_write)sha384_update, .result = (qcrypto_nettle_result)sha384_digest, .len = SHA384_DIGEST_SIZE, }, - [QCRYPTO_HASH_ALG_SHA512] = { + [QCRYPTO_HASH_ALGO_SHA512] = { .init = (qcrypto_nettle_init)sha512_init, .write = (qcrypto_nettle_write)sha512_update, .result = (qcrypto_nettle_result)sha512_digest, .len = SHA512_DIGEST_SIZE, }, - [QCRYPTO_HASH_ALG_RIPEMD160] = { + [QCRYPTO_HASH_ALGO_RIPEMD160] = { .init = (qcrypto_nettle_init)ripemd160_init, .write = (qcrypto_nettle_write)ripemd160_update, .result = (qcrypto_nettle_result)ripemd160_digest, @@ -94,7 +94,7 @@ struct qcrypto_hash_alg { }, }; -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 != NULL) { @@ -105,7 +105,7 @@ gboolean qcrypto_hash_supports(QCryptoHashAlgorithm alg) 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" -static size_t qcrypto_hash_alg_size[QCRYPTO_HASH_ALG__MAX] = { - [QCRYPTO_HASH_ALG_MD5] = 16, - [QCRYPTO_HASH_ALG_SHA1] = 20, - [QCRYPTO_HASH_ALG_SHA224] = 28, - [QCRYPTO_HASH_ALG_SHA256] = 32, - [QCRYPTO_HASH_ALG_SHA384] = 48, - [QCRYPTO_HASH_ALG_SHA512] = 64, - [QCRYPTO_HASH_ALG_RIPEMD160] = 20, +static size_t qcrypto_hash_alg_size[QCRYPTO_HASH_ALGO__MAX] = { + [QCRYPTO_HASH_ALGO_MD5] = 16, + [QCRYPTO_HASH_ALGO_SHA1] = 20, + [QCRYPTO_HASH_ALGO_SHA224] = 28, + [QCRYPTO_HASH_ALGO_SHA256] = 32, + [QCRYPTO_HASH_ALGO_SHA384] = 48, + [QCRYPTO_HASH_ALGO_SHA512] = 64, + [QCRYPTO_HASH_ALGO_RIPEMD160] = 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]; } -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, } -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, static const char hex[] = "0123456789abcdef"; -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; } -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); } -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; } -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 -static int qcrypto_hmac_alg_map[QCRYPTO_HASH_ALG__MAX] = { - [QCRYPTO_HASH_ALG_MD5] = GCRY_MAC_HMAC_MD5, - [QCRYPTO_HASH_ALG_SHA1] = GCRY_MAC_HMAC_SHA1, - [QCRYPTO_HASH_ALG_SHA224] = GCRY_MAC_HMAC_SHA224, - [QCRYPTO_HASH_ALG_SHA256] = GCRY_MAC_HMAC_SHA256, - [QCRYPTO_HASH_ALG_SHA384] = GCRY_MAC_HMAC_SHA384, - [QCRYPTO_HASH_ALG_SHA512] = GCRY_MAC_HMAC_SHA512, - [QCRYPTO_HASH_ALG_RIPEMD160] = GCRY_MAC_HMAC_RMD160, +static int qcrypto_hmac_alg_map[QCRYPTO_HASH_ALGO__MAX] = { + [QCRYPTO_HASH_ALGO_MD5] = GCRY_MAC_HMAC_MD5, + [QCRYPTO_HASH_ALGO_SHA1] = GCRY_MAC_HMAC_SHA1, + [QCRYPTO_HASH_ALGO_SHA224] = GCRY_MAC_HMAC_SHA224, + [QCRYPTO_HASH_ALGO_SHA256] = GCRY_MAC_HMAC_SHA256, + [QCRYPTO_HASH_ALGO_SHA384] = GCRY_MAC_HMAC_SHA384, + [QCRYPTO_HASH_ALGO_SHA512] = GCRY_MAC_HMAC_SHA512, + [QCRYPTO_HASH_ALGO_RIPEMD160] = GCRY_MAC_HMAC_RMD160, }; typedef struct QCryptoHmacGcrypt QCryptoHmacGcrypt; @@ -33,7 +33,7 @@ struct QCryptoHmacGcrypt { gcry_mac_hd_t handle; }; -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] != GCRY_MAC_NONE) { @@ -43,7 +43,7 @@ bool qcrypto_hmac_supports(QCryptoHashAlgorithm alg) return false; } -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, if (!qcrypto_hmac_supports(alg)) { error_setg(errp, "Unsupported hmac algorithm %s", - QCryptoHashAlgorithm_str(alg)); + QCryptoHashAlgo_str(alg)); return NULL; } 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" -static int qcrypto_hmac_alg_map[QCRYPTO_HASH_ALG__MAX] = { - [QCRYPTO_HASH_ALG_MD5] = G_CHECKSUM_MD5, - [QCRYPTO_HASH_ALG_SHA1] = G_CHECKSUM_SHA1, - [QCRYPTO_HASH_ALG_SHA256] = G_CHECKSUM_SHA256, - [QCRYPTO_HASH_ALG_SHA512] = G_CHECKSUM_SHA512, - [QCRYPTO_HASH_ALG_SHA224] = -1, - [QCRYPTO_HASH_ALG_SHA384] = -1, - [QCRYPTO_HASH_ALG_RIPEMD160] = -1, +static int qcrypto_hmac_alg_map[QCRYPTO_HASH_ALGO__MAX] = { + [QCRYPTO_HASH_ALGO_MD5] = G_CHECKSUM_MD5, + [QCRYPTO_HASH_ALGO_SHA1] = G_CHECKSUM_SHA1, + [QCRYPTO_HASH_ALGO_SHA256] = G_CHECKSUM_SHA256, + [QCRYPTO_HASH_ALGO_SHA512] = G_CHECKSUM_SHA512, + [QCRYPTO_HASH_ALGO_SHA224] = -1, + [QCRYPTO_HASH_ALGO_SHA384] = -1, + [QCRYPTO_HASH_ALGO_RIPEMD160] = -1, }; typedef struct QCryptoHmacGlib QCryptoHmacGlib; @@ -32,7 +32,7 @@ struct QCryptoHmacGlib { GHmac *ghmac; }; -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] != -1) { @@ -42,7 +42,7 @@ bool qcrypto_hmac_supports(QCryptoHashAlgorithm alg) return false; } -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, if (!qcrypto_hmac_supports(alg)) { error_setg(errp, "Unsupported hmac algorithm %s", - QCryptoHashAlgorithm_str(alg)); + QCryptoHashAlgo_str(alg)); return NULL; } 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" -static int qcrypto_hmac_alg_map[QCRYPTO_HASH_ALG__MAX] = { - [QCRYPTO_HASH_ALG_MD5] = GNUTLS_MAC_MD5, - [QCRYPTO_HASH_ALG_SHA1] = GNUTLS_MAC_SHA1, - [QCRYPTO_HASH_ALG_SHA224] = GNUTLS_MAC_SHA224, - [QCRYPTO_HASH_ALG_SHA256] = GNUTLS_MAC_SHA256, - [QCRYPTO_HASH_ALG_SHA384] = GNUTLS_MAC_SHA384, - [QCRYPTO_HASH_ALG_SHA512] = GNUTLS_MAC_SHA512, - [QCRYPTO_HASH_ALG_RIPEMD160] = GNUTLS_MAC_RMD160, +static int qcrypto_hmac_alg_map[QCRYPTO_HASH_ALGO__MAX] = { + [QCRYPTO_HASH_ALGO_MD5] = GNUTLS_MAC_MD5, + [QCRYPTO_HASH_ALGO_SHA1] = GNUTLS_MAC_SHA1, + [QCRYPTO_HASH_ALGO_SHA224] = GNUTLS_MAC_SHA224, + [QCRYPTO_HASH_ALGO_SHA256] = GNUTLS_MAC_SHA256, + [QCRYPTO_HASH_ALGO_SHA384] = GNUTLS_MAC_SHA384, + [QCRYPTO_HASH_ALGO_SHA512] = GNUTLS_MAC_SHA512, + [QCRYPTO_HASH_ALGO_RIPEMD160] = GNUTLS_MAC_RMD160, }; typedef struct QCryptoHmacGnutls QCryptoHmacGnutls; @@ -35,7 +35,7 @@ struct QCryptoHmacGnutls { gnutls_hmac_hd_t handle; }; -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; } -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, if (!qcrypto_hmac_supports(alg)) { error_setg(errp, "Unsupported hmac algorithm %s", - QCryptoHashAlgorithm_str(alg)); + QCryptoHashAlgo_str(alg)); return NULL; } 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] = { - [QCRYPTO_HASH_ALG_MD5] = { +} qcrypto_hmac_alg_map[QCRYPTO_HASH_ALGO__MAX] = { + [QCRYPTO_HASH_ALGO_MD5] = { .setkey = (qcrypto_nettle_hmac_setkey)hmac_md5_set_key, .update = (qcrypto_nettle_hmac_update)hmac_md5_update, .digest = (qcrypto_nettle_hmac_digest)hmac_md5_digest, .len = MD5_DIGEST_SIZE, }, - [QCRYPTO_HASH_ALG_SHA1] = { + [QCRYPTO_HASH_ALGO_SHA1] = { .setkey = (qcrypto_nettle_hmac_setkey)hmac_sha1_set_key, .update = (qcrypto_nettle_hmac_update)hmac_sha1_update, .digest = (qcrypto_nettle_hmac_digest)hmac_sha1_digest, .len = SHA1_DIGEST_SIZE, }, - [QCRYPTO_HASH_ALG_SHA224] = { + [QCRYPTO_HASH_ALGO_SHA224] = { .setkey = (qcrypto_nettle_hmac_setkey)hmac_sha224_set_key, .update = (qcrypto_nettle_hmac_update)hmac_sha224_update, .digest = (qcrypto_nettle_hmac_digest)hmac_sha224_digest, .len = SHA224_DIGEST_SIZE, }, - [QCRYPTO_HASH_ALG_SHA256] = { + [QCRYPTO_HASH_ALGO_SHA256] = { .setkey = (qcrypto_nettle_hmac_setkey)hmac_sha256_set_key, .update = (qcrypto_nettle_hmac_update)hmac_sha256_update, .digest = (qcrypto_nettle_hmac_digest)hmac_sha256_digest, .len = SHA256_DIGEST_SIZE, }, - [QCRYPTO_HASH_ALG_SHA384] = { + [QCRYPTO_HASH_ALGO_SHA384] = { .setkey = (qcrypto_nettle_hmac_setkey)hmac_sha384_set_key, .update = (qcrypto_nettle_hmac_update)hmac_sha384_update, .digest = (qcrypto_nettle_hmac_digest)hmac_sha384_digest, .len = SHA384_DIGEST_SIZE, }, - [QCRYPTO_HASH_ALG_SHA512] = { + [QCRYPTO_HASH_ALGO_SHA512] = { .setkey = (qcrypto_nettle_hmac_setkey)hmac_sha512_set_key, .update = (qcrypto_nettle_hmac_update)hmac_sha512_update, .digest = (qcrypto_nettle_hmac_digest)hmac_sha512_digest, .len = SHA512_DIGEST_SIZE, }, - [QCRYPTO_HASH_ALG_RIPEMD160] = { + [QCRYPTO_HASH_ALGO_RIPEMD160] = { .setkey = (qcrypto_nettle_hmac_setkey)hmac_ripemd160_set_key, .update = (qcrypto_nettle_hmac_update)hmac_ripemd160_update, .digest = (qcrypto_nettle_hmac_digest)hmac_ripemd160_digest, @@ -91,7 +91,7 @@ struct qcrypto_nettle_hmac_alg { }, }; -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 != NULL) { @@ -101,7 +101,7 @@ bool qcrypto_hmac_supports(QCryptoHashAlgorithm alg) return false; } -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, if (!qcrypto_hmac_supports(alg)) { error_setg(errp, "Unsupported hmac algorithm %s", - QCryptoHashAlgorithm_str(alg)); + QCryptoHashAlgo_str(alg)); return NULL; } 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); } -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 @@ 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(QCryptoIVGen *ivgen) } -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" -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; } } -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] = { - [QCRYPTO_HASH_ALG_MD5] = GCRY_MD_MD5, - [QCRYPTO_HASH_ALG_SHA1] = GCRY_MD_SHA1, - [QCRYPTO_HASH_ALG_SHA224] = GCRY_MD_SHA224, - [QCRYPTO_HASH_ALG_SHA256] = GCRY_MD_SHA256, - [QCRYPTO_HASH_ALG_SHA384] = GCRY_MD_SHA384, - [QCRYPTO_HASH_ALG_SHA512] = GCRY_MD_SHA512, - [QCRYPTO_HASH_ALG_RIPEMD160] = GCRY_MD_RMD160, + static const int hash_map[QCRYPTO_HASH_ALGO__MAX] = { + [QCRYPTO_HASH_ALGO_MD5] = GCRY_MD_MD5, + [QCRYPTO_HASH_ALGO_SHA1] = GCRY_MD_SHA1, + [QCRYPTO_HASH_ALGO_SHA224] = GCRY_MD_SHA224, + [QCRYPTO_HASH_ALGO_SHA256] = GCRY_MD_SHA256, + [QCRYPTO_HASH_ALGO_SHA384] = GCRY_MD_SHA384, + [QCRYPTO_HASH_ALGO_SHA512] = GCRY_MD_SHA512, + [QCRYPTO_HASH_ALGO_RIPEMD160] = GCRY_MD_RMD160, }; int ret; @@ -68,7 +68,7 @@ int qcrypto_pbkdf2(QCryptoHashAlgorithm hash, hash_map[hash] == GCRY_MD_NONE) { error_setg_errno(errp, ENOSYS, "PBKDF does not support hash algorithm %s", - QCryptoHashAlgorithm_str(hash)); + QCryptoHashAlgo_str(hash)); return -1; } 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" -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; } } -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] = { - [QCRYPTO_HASH_ALG_MD5] = GNUTLS_DIG_MD5, - [QCRYPTO_HASH_ALG_SHA1] = GNUTLS_DIG_SHA1, - [QCRYPTO_HASH_ALG_SHA224] = GNUTLS_DIG_SHA224, - [QCRYPTO_HASH_ALG_SHA256] = GNUTLS_DIG_SHA256, - [QCRYPTO_HASH_ALG_SHA384] = GNUTLS_DIG_SHA384, - [QCRYPTO_HASH_ALG_SHA512] = GNUTLS_DIG_SHA512, - [QCRYPTO_HASH_ALG_RIPEMD160] = GNUTLS_DIG_RMD160, + static const int hash_map[QCRYPTO_HASH_ALGO__MAX] = { + [QCRYPTO_HASH_ALGO_MD5] = GNUTLS_DIG_MD5, + [QCRYPTO_HASH_ALGO_SHA1] = GNUTLS_DIG_SHA1, + [QCRYPTO_HASH_ALGO_SHA224] = GNUTLS_DIG_SHA224, + [QCRYPTO_HASH_ALGO_SHA256] = GNUTLS_DIG_SHA256, + [QCRYPTO_HASH_ALGO_SHA384] = GNUTLS_DIG_SHA384, + [QCRYPTO_HASH_ALGO_SHA512] = GNUTLS_DIG_SHA512, + [QCRYPTO_HASH_ALGO_RIPEMD160] = GNUTLS_DIG_RMD160, }; int ret; const gnutls_datum_t gkey = { (unsigned char *)key, nkey }; @@ -70,7 +70,7 @@ int qcrypto_pbkdf2(QCryptoHashAlgorithm hash, hash_map[hash] == GNUTLS_DIG_UNKNOWN) { error_setg_errno(errp, ENOSYS, "PBKDF does not support hash algorithm %s", - QCryptoHashAlgorithm_str(hash)); + QCryptoHashAlgo_str(hash)); return -1; } 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" -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; } } -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, } 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; - 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; - 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; - 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; - 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; - 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; - 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_digest, 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" -bool qcrypto_pbkdf2_supports(QCryptoHashAlgorithm hash G_GNUC_UNUSED) +bool qcrypto_pbkdf2_supports(QCryptoHashAlgo hash G_GNUC_UNUSED) { return false; } -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 long *val_ms, #endif } -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 @@ static const struct { uint32_t mask; - QCryptoHashAlgorithm algo; + QCryptoHashAlgo algo; } hash_algo_map[] = { - { 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 }, }; 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(QIOChannelWebsock *ioc, QIO_CHANNEL_WEBSOCK_GUID_LEN + 1); /* 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(PaddedSevHashTable *padded_ht, * be used. */ hashp = 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(PaddedSevHashTable *padded_ht, * -initrd, an empty buffer will be used (ctx->initrd_size == 0). */ hashp = 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(PaddedSevHashTable *padded_ht, { .iov_base = ctx->setup_data, .iov_len = ctx->setup_size }, { .iov_base = ctx->kernel_data, .iov_len = 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/benchmark-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 padding, - QCryptoHashAlgorithm hash) + QCryptoHashAlgo hash) { QCryptoAkCipherOptions opt; @@ -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 g_autoptr(QCryptoAkCipher) rsa = 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, 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 = 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, size_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()); 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 = 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-crypto-hash.c index 927b00bb4d..252098a69d 100644 --- a/tests/bench/benchmark-crypto-hash.c +++ b/tests/bench/benchmark-crypto-hash.c @@ -17,7 +17,7 @@ typedef struct QCryptoHashOpts { size_t chunk_size; - QCryptoHashAlgorithm alg; + QCryptoHashAlgo alg; } QCryptoHashOpts; static void test_hash_speed(const void *opaque) @@ -49,7 +49,7 @@ static void test_hash_speed(const void *opaque) g_test_timer_elapsed(); 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()); g_free(out); @@ -65,14 +65,14 @@ int main(int argc, char **argv) #define TEST_ONE(a, c) \ QCryptoHashOpts opts ## a ## c = { \ - .alg = QCRYPTO_HASH_ALG_ ## a, .chunk_size = c, \ + .alg = QCRYPTO_HASH_ALGO_ ## a, .chunk_size = 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-crypto-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 = NULL; int ret; - if (!qcrypto_hmac_supports(QCRYPTO_HASH_ALG_SHA256)) { + if (!qcrypto_hmac_supports(QCRYPTO_HASH_ALGO_SHA256)) { return; } @@ -40,7 +40,7 @@ static void test_hmac_speed(const void *opaque) g_test_timer_start(); do { - hmac = qcrypto_hmac_new(QCRYPTO_HASH_ALG_SHA256, + hmac = qcrypto_hmac_new(QCRYPTO_HASH_ALGO_SHA256, (const uint8_t *)KEY, strlen(KEY), &err); g_assert(err == NULL); g_assert(hmac != NULL); @@ -56,7 +56,7 @@ static void test_hmac_speed(const void *opaque) total /= 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()); g_free(out); diff --git a/tests/unit/test-crypto-afsplit.c b/tests/unit/test-crypto-afsplit.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[] = { { .path = "/crypto/afsplit/sha256/5", - .hash = QCRYPTO_HASH_ALG_SHA256, + .hash = QCRYPTO_HASH_ALGO_SHA256, .stripes = 5, .blocklen = 32, .key = (const uint8_t *) @@ -68,7 +68,7 @@ static QCryptoAFSplitTestData test_data[] = { }, { .path = "/crypto/afsplit/sha256/5000", - .hash = QCRYPTO_HASH_ALG_SHA256, + .hash = QCRYPTO_HASH_ALGO_SHA256, .stripes = 5000, .blocklen = 16, .key = (const uint8_t *) @@ -77,7 +77,7 @@ static QCryptoAFSplitTestData test_data[] = { }, { .path = "/crypto/afsplit/sha1/1000", - .hash = QCRYPTO_HASH_ALG_SHA1, + .hash = QCRYPTO_HASH_ALGO_SHA1, .stripes = 1000, .blocklen = 32, .key = (const uint8_t *) @@ -88,7 +88,7 @@ static QCryptoAFSplitTestData test_data[] = { }, { .path = "/crypto/afsplit/sha256/big", - .hash = QCRYPTO_HASH_ALG_SHA256, + .hash = QCRYPTO_HASH_ALGO_SHA256, .stripes = 1000, .blocklen = 64, .key = (const uint8_t *) diff --git a/tests/unit/test-crypto-akcipher.c b/tests/unit/test-crypto-akcipher.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[] = { .alg = QCRYPTO_AKCIPHER_ALG_RSA, .u.rsa = { .padding_alg = QCRYPTO_RSA_PADDING_ALG_PKCS1, - .hash_alg = QCRYPTO_HASH_ALG_SHA1, + .hash_alg = QCRYPTO_HASH_ALGO_SHA1, }, }, .pub_key = rsa1024_public_key, @@ -853,7 +853,7 @@ static QCryptoAkCipherTestData akcipher_test_data[] = { .alg = QCRYPTO_AKCIPHER_ALG_RSA, .u.rsa = { .padding_alg = QCRYPTO_RSA_PADDING_ALG_PKCS1, - .hash_alg = QCRYPTO_HASH_ALG_SHA1, + .hash_alg = QCRYPTO_HASH_ALGO_SHA1, }, }, .pub_key = rsa2048_public_key, @@ -947,7 +947,7 @@ static void test_rsakey(const void *opaque) .alg = QCRYPTO_AKCIPHER_ALG_RSA, .u.rsa = { .padding_alg = QCRYPTO_RSA_PADDING_ALG_PKCS1, - .hash_alg = QCRYPTO_HASH_ALG_SHA1, + .hash_alg = QCRYPTO_HASH_ALGO_SHA1, } }; g_autoptr(QCryptoAkCipher) key = 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 = { .has_ivgen_alg = true, .ivgen_alg = QCRYPTO_IVGEN_ALG_ESSIV, .has_ivgen_hash_alg = true, - .ivgen_hash_alg = QCRYPTO_HASH_ALG_SHA256, + .ivgen_hash_alg = QCRYPTO_HASH_ALGO_SHA256, .has_hash_alg = true, - .hash_alg = QCRYPTO_HASH_ALG_SHA1, + .hash_alg = QCRYPTO_HASH_ALGO_SHA1, }, }; #endif /* TEST_LUKS */ @@ -114,10 +114,10 @@ static struct QCryptoBlockTestData { QCryptoCipherAlgorithm cipher_alg; QCryptoCipherMode cipher_mode; - QCryptoHashAlgorithm hash_alg; + QCryptoHashAlgo hash_alg; QCryptoIVGenAlgorithm ivgen_alg; - QCryptoHashAlgorithm ivgen_hash; + QCryptoHashAlgo ivgen_hash; bool slow; } test_data[] = { @@ -143,7 +143,7 @@ static struct QCryptoBlockTestData { .cipher_alg = QCRYPTO_CIPHER_ALG_AES_256, .cipher_mode = QCRYPTO_CIPHER_MODE_XTS, - .hash_alg = QCRYPTO_HASH_ALG_SHA256, + .hash_alg = QCRYPTO_HASH_ALGO_SHA256, .ivgen_alg = QCRYPTO_IVGEN_ALG_PLAIN64, @@ -158,7 +158,7 @@ static struct QCryptoBlockTestData { .cipher_alg = QCRYPTO_CIPHER_ALG_AES_256, .cipher_mode = QCRYPTO_CIPHER_MODE_CBC, - .hash_alg = QCRYPTO_HASH_ALG_SHA256, + .hash_alg = QCRYPTO_HASH_ALGO_SHA256, .ivgen_alg = QCRYPTO_IVGEN_ALG_PLAIN64, @@ -173,10 +173,10 @@ static struct QCryptoBlockTestData { .cipher_alg = QCRYPTO_CIPHER_ALG_AES_256, .cipher_mode = QCRYPTO_CIPHER_MODE_CBC, - .hash_alg = QCRYPTO_HASH_ALG_SHA1, + .hash_alg = QCRYPTO_HASH_ALGO_SHA1, .ivgen_alg = QCRYPTO_IVGEN_ALG_ESSIV, - .ivgen_hash = QCRYPTO_HASH_ALG_SHA256, + .ivgen_hash = QCRYPTO_HASH_ALGO_SHA256, .slow = 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=" static const char *expected_outputs[] = { - [QCRYPTO_HASH_ALG_MD5] = OUTPUT_MD5, - [QCRYPTO_HASH_ALG_SHA1] = OUTPUT_SHA1, - [QCRYPTO_HASH_ALG_SHA224] = OUTPUT_SHA224, - [QCRYPTO_HASH_ALG_SHA256] = OUTPUT_SHA256, - [QCRYPTO_HASH_ALG_SHA384] = OUTPUT_SHA384, - [QCRYPTO_HASH_ALG_SHA512] = OUTPUT_SHA512, - [QCRYPTO_HASH_ALG_RIPEMD160] = OUTPUT_RIPEMD160, + [QCRYPTO_HASH_ALGO_MD5] = OUTPUT_MD5, + [QCRYPTO_HASH_ALGO_SHA1] = OUTPUT_SHA1, + [QCRYPTO_HASH_ALGO_SHA224] = OUTPUT_SHA224, + [QCRYPTO_HASH_ALGO_SHA256] = OUTPUT_SHA256, + [QCRYPTO_HASH_ALGO_SHA384] = OUTPUT_SHA384, + [QCRYPTO_HASH_ALGO_SHA512] = OUTPUT_SHA512, + [QCRYPTO_HASH_ALGO_RIPEMD160] = OUTPUT_RIPEMD160, }; static const char *expected_outputs_b64[] = { - [QCRYPTO_HASH_ALG_MD5] = OUTPUT_MD5_B64, - [QCRYPTO_HASH_ALG_SHA1] = OUTPUT_SHA1_B64, - [QCRYPTO_HASH_ALG_SHA224] = OUTPUT_SHA224_B64, - [QCRYPTO_HASH_ALG_SHA256] = OUTPUT_SHA256_B64, - [QCRYPTO_HASH_ALG_SHA384] = OUTPUT_SHA384_B64, - [QCRYPTO_HASH_ALG_SHA512] = OUTPUT_SHA512_B64, - [QCRYPTO_HASH_ALG_RIPEMD160] = OUTPUT_RIPEMD160_B64, + [QCRYPTO_HASH_ALGO_MD5] = OUTPUT_MD5_B64, + [QCRYPTO_HASH_ALGO_SHA1] = OUTPUT_SHA1_B64, + [QCRYPTO_HASH_ALGO_SHA224] = OUTPUT_SHA224_B64, + [QCRYPTO_HASH_ALGO_SHA256] = OUTPUT_SHA256_B64, + [QCRYPTO_HASH_ALGO_SHA384] = OUTPUT_SHA384_B64, + [QCRYPTO_HASH_ALGO_SHA512] = OUTPUT_SHA512_B64, + [QCRYPTO_HASH_ALGO_RIPEMD160] = OUTPUT_RIPEMD160_B64, }; static const int expected_lens[] = { - [QCRYPTO_HASH_ALG_MD5] = 16, - [QCRYPTO_HASH_ALG_SHA1] = 20, - [QCRYPTO_HASH_ALG_SHA224] = 28, - [QCRYPTO_HASH_ALG_SHA256] = 32, - [QCRYPTO_HASH_ALG_SHA384] = 48, - [QCRYPTO_HASH_ALG_SHA512] = 64, - [QCRYPTO_HASH_ALG_RIPEMD160] = 20, + [QCRYPTO_HASH_ALGO_MD5] = 16, + [QCRYPTO_HASH_ALGO_SHA1] = 20, + [QCRYPTO_HASH_ALGO_SHA224] = 28, + [QCRYPTO_HASH_ALGO_SHA256] = 32, + [QCRYPTO_HASH_ALGO_SHA384] = 48, + [QCRYPTO_HASH_ALGO_SHA512] = 64, + [QCRYPTO_HASH_ALGO_RIPEMD160] = 20, }; static const char hex[] = "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 @@ typedef struct QCryptoHmacTestData QCryptoHmacTestData; struct QCryptoHmacTestData { - QCryptoHashAlgorithm alg; + QCryptoHashAlgo alg; const char *hex_digest; }; static QCryptoHmacTestData test_data[] = { { - .alg = QCRYPTO_HASH_ALG_MD5, + .alg = QCRYPTO_HASH_ALGO_MD5, .hex_digest = "ede9cb83679ba82d88fbeae865b3f8fc", }, { - .alg = QCRYPTO_HASH_ALG_SHA1, + .alg = QCRYPTO_HASH_ALGO_SHA1, .hex_digest = "c7b5a631e3aac975c4ededfcd346e469" "dbc5f2d1", }, { - .alg = QCRYPTO_HASH_ALG_SHA224, + .alg = QCRYPTO_HASH_ALGO_SHA224, .hex_digest = "5f768179dbb29ca722875d0f461a2e2f" "597d0210340a84df1a8e9c63", }, { - .alg = QCRYPTO_HASH_ALG_SHA256, + .alg = QCRYPTO_HASH_ALGO_SHA256, .hex_digest = "3798f363c57afa6edaffe39016ca7bad" "efd1e670afb0e3987194307dec3197db", }, { - .alg = QCRYPTO_HASH_ALG_SHA384, + .alg = QCRYPTO_HASH_ALGO_SHA384, .hex_digest = "d218680a6032d33dccd9882d6a6a7164" "64f26623be257a9b2919b185294f4a49" "9e54b190bfd6bc5cedd2cd05c7e65e82", }, { - .alg = QCRYPTO_HASH_ALG_SHA512, + .alg = QCRYPTO_HASH_ALGO_SHA512, .hex_digest = "835a4f5b3750b4c1fccfa88da2f746a4" "900160c9f18964309bb736c13b59491b" @@ -71,7 +71,7 @@ static QCryptoHmacTestData test_data[] = { "94c4ba26862b2dadb59b7ede1d08d53e", }, { - .alg = QCRYPTO_HASH_ALG_RIPEMD160, + .alg = QCRYPTO_HASH_ALGO_RIPEMD160, .hex_digest = "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 = 0x1, .ivalg = QCRYPTO_IVGEN_ALG_ESSIV, .cipheralg = QCRYPTO_CIPHER_ALG_AES_128, - .hashalg = QCRYPTO_HASH_ALG_SHA256, + .hashalg = QCRYPTO_HASH_ALGO_SHA256, .key = (const uint8_t *)"\x00\x01\x02\x03\x04\x05\x06\x07" "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f", .nkey = 16, @@ -108,7 +108,7 @@ struct QCryptoIVGenTestData { .sector = 0x1f2e3d4cULL, .ivalg = QCRYPTO_IVGEN_ALG_ESSIV, .cipheralg = QCRYPTO_CIPHER_ALG_AES_128, - .hashalg = QCRYPTO_HASH_ALG_SHA256, + .hashalg = QCRYPTO_HASH_ALGO_SHA256, .key = (const uint8_t *)"\x00\x01\x02\x03\x04\x05\x06\x07" "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f", .nkey = 16, @@ -122,7 +122,7 @@ struct QCryptoIVGenTestData { .sector = 0x1f2e3d4c5b6a7988ULL, .ivalg = QCRYPTO_IVGEN_ALG_ESSIV, .cipheralg = QCRYPTO_CIPHER_ALG_AES_128, - .hashalg = QCRYPTO_HASH_ALG_SHA256, + .hashalg = QCRYPTO_HASH_ALGO_SHA256, .key = (const uint8_t *)"\x00\x01\x02\x03\x04\x05\x06\x07" "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f", .nkey = 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[] = { /* RFC 3962 test data */ { .path = "/crypto/pbkdf/rfc3962/sha1/iter1", - .hash = QCRYPTO_HASH_ALG_SHA1, + .hash = QCRYPTO_HASH_ALGO_SHA1, .iterations = 1, .key = "password", .nkey = 8, @@ -67,7 +67,7 @@ static QCryptoPbkdfTestData test_data[] = { }, { .path = "/crypto/pbkdf/rfc3962/sha1/iter2", - .hash = QCRYPTO_HASH_ALG_SHA1, + .hash = QCRYPTO_HASH_ALGO_SHA1, .iterations = 2, .key = "password", .nkey = 8, @@ -81,7 +81,7 @@ static QCryptoPbkdfTestData test_data[] = { }, { .path = "/crypto/pbkdf/rfc3962/sha1/iter1200a", - .hash = QCRYPTO_HASH_ALG_SHA1, + .hash = QCRYPTO_HASH_ALGO_SHA1, .iterations = 1200, .key = "password", .nkey = 8, @@ -95,7 +95,7 @@ static QCryptoPbkdfTestData test_data[] = { }, { .path = "/crypto/pbkdf/rfc3962/sha1/iter5", - .hash = QCRYPTO_HASH_ALG_SHA1, + .hash = QCRYPTO_HASH_ALGO_SHA1, .iterations = 5, .key = "password", .nkey = 8, @@ -109,7 +109,7 @@ static QCryptoPbkdfTestData test_data[] = { }, { .path = "/crypto/pbkdf/rfc3962/sha1/iter1200b", - .hash = QCRYPTO_HASH_ALG_SHA1, + .hash = QCRYPTO_HASH_ALGO_SHA1, .iterations = 1200, .key = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", @@ -124,7 +124,7 @@ static QCryptoPbkdfTestData test_data[] = { }, { .path = "/crypto/pbkdf/rfc3962/sha1/iter1200c", - .hash = QCRYPTO_HASH_ALG_SHA1, + .hash = QCRYPTO_HASH_ALGO_SHA1, .iterations = 1200, .key = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", @@ -139,7 +139,7 @@ static QCryptoPbkdfTestData test_data[] = { }, { .path = "/crypto/pbkdf/rfc3962/sha1/iter50", - .hash = QCRYPTO_HASH_ALG_SHA1, + .hash = QCRYPTO_HASH_ALGO_SHA1, .iterations = 50, .key = "\360\235\204\236", /* g-clef ("\xf09d849e) */ .nkey = 4, @@ -155,7 +155,7 @@ static QCryptoPbkdfTestData test_data[] = { /* RFC-6070 test data */ { .path = "/crypto/pbkdf/rfc6070/sha1/iter1", - .hash = QCRYPTO_HASH_ALG_SHA1, + .hash = QCRYPTO_HASH_ALGO_SHA1, .iterations = 1, .key = "password", .nkey = 8, @@ -167,7 +167,7 @@ static QCryptoPbkdfTestData test_data[] = { }, { .path = "/crypto/pbkdf/rfc6070/sha1/iter2", - .hash = QCRYPTO_HASH_ALG_SHA1, + .hash = QCRYPTO_HASH_ALGO_SHA1, .iterations = 2, .key = "password", .nkey = 8, @@ -179,7 +179,7 @@ static QCryptoPbkdfTestData test_data[] = { }, { .path = "/crypto/pbkdf/rfc6070/sha1/iter4096", - .hash = QCRYPTO_HASH_ALG_SHA1, + .hash = QCRYPTO_HASH_ALGO_SHA1, .iterations = 4096, .key = "password", .nkey = 8, @@ -191,7 +191,7 @@ static QCryptoPbkdfTestData test_data[] = { }, { .path = "/crypto/pbkdf/rfc6070/sha1/iter16777216", - .hash = QCRYPTO_HASH_ALG_SHA1, + .hash = QCRYPTO_HASH_ALGO_SHA1, .iterations = 16777216, .key = "password", .nkey = 8, @@ -204,7 +204,7 @@ static QCryptoPbkdfTestData test_data[] = { }, { .path = "/crypto/pbkdf/rfc6070/sha1/iter4096a", - .hash = QCRYPTO_HASH_ALG_SHA1, + .hash = QCRYPTO_HASH_ALGO_SHA1, .iterations = 4096, .key = "passwordPASSWORDpassword", .nkey = 24, @@ -217,7 +217,7 @@ static QCryptoPbkdfTestData test_data[] = { }, { .path = "/crypto/pbkdf/rfc6070/sha1/iter4096b", - .hash = QCRYPTO_HASH_ALG_SHA1, + .hash = QCRYPTO_HASH_ALGO_SHA1, .iterations = 4096, .key = "pass\0word", .nkey = 9, @@ -232,7 +232,7 @@ static QCryptoPbkdfTestData test_data[] = { { /* empty password test. */ .path = "/crypto/pbkdf/nonrfc/sha1/iter2", - .hash = QCRYPTO_HASH_ALG_SHA1, + .hash = QCRYPTO_HASH_ALGO_SHA1, .iterations = 2, .key = "", .nkey = 0, @@ -245,7 +245,7 @@ static QCryptoPbkdfTestData test_data[] = { { /* Password exceeds block size test */ .path = "/crypto/pbkdf/nonrfc/sha256/iter1200", - .hash = QCRYPTO_HASH_ALG_SHA256, + .hash = QCRYPTO_HASH_ALGO_SHA256, .iterations = 1200, .key = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", @@ -260,7 +260,7 @@ static QCryptoPbkdfTestData test_data[] = { }, { .path = "/crypto/pbkdf/nonrfc/sha512/iter1200", - .hash = QCRYPTO_HASH_ALG_SHA512, + .hash = QCRYPTO_HASH_ALGO_SHA512, .iterations = 1200, .key = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" @@ -277,7 +277,7 @@ static QCryptoPbkdfTestData test_data[] = { }, { .path = "/crypto/pbkdf/nonrfc/sha224/iter1200", - .hash = QCRYPTO_HASH_ALG_SHA224, + .hash = QCRYPTO_HASH_ALGO_SHA224, .iterations = 1200, .key = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" @@ -294,7 +294,7 @@ static QCryptoPbkdfTestData test_data[] = { }, { .path = "/crypto/pbkdf/nonrfc/sha384/iter1200", - .hash = QCRYPTO_HASH_ALG_SHA384, + .hash = QCRYPTO_HASH_ALGO_SHA384, .iterations = 1200, .key = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" @@ -311,7 +311,7 @@ static QCryptoPbkdfTestData test_data[] = { }, { .path = "/crypto/pbkdf/nonrfc/ripemd160/iter1200", - .hash = QCRYPTO_HASH_ALG_RIPEMD160, + .hash = QCRYPTO_HASH_ALGO_RIPEMD160, .iterations = 1200, .key = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" @@ -329,7 +329,7 @@ static QCryptoPbkdfTestData test_data[] = { #if 0 { .path = "/crypto/pbkdf/nonrfc/whirlpool/iter1200", - .hash = QCRYPTO_HASH_ALG_WHIRLPOOL, + .hash = QCRYPTO_HASH_ALGO_WHIRLPOOL, .iterations = 1200, .key = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", @@ -403,7 +403,7 @@ static void test_pbkdf_timing(void) memset(key, 0x5d, sizeof(key)); memset(salt, 0x7c, sizeof(salt)); - iters = qcrypto_pbkdf2_count_iters(QCRYPTO_HASH_ALG_SHA256, + iters = 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 **errp) size_t size = bitmap->sizes[HBITMAP_LEVELS - 1] * sizeof(unsigned long); char *data = (char *)bitmap->levels[HBITMAP_LEVELS - 1]; char *hash = NULL; - qcrypto_hash_digest(QCRYPTO_HASH_ALG_SHA256, data, size, &hash, errp); + qcrypto_hash_digest(QCRYPTO_HASH_ALGO_SHA256, data, size, &hash, errp); 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; static void qcrypto_gcrypt_rsa_free(QCryptoAkCipher *akcipher) @@ -417,7 +417,7 @@ static int qcrypto_gcrypt_rsa_sign(QCryptoAkCipher *akcipher, err = 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) != 0) { error_setg(errp, "Failed to build dgst: %s/%s", @@ -497,7 +497,7 @@ static int qcrypto_gcrypt_rsa_verify(QCryptoAkCipher *akcipher, err = 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) != 0) { error_setg(errp, "Failed to build dgst: %s/%s", @@ -575,10 +575,10 @@ bool qcrypto_akcipher_supports(QCryptoAkCipherOptions *opts) 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; 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; static void qcrypto_nettle_rsa_free(QCryptoAkCipher *akcipher) @@ -276,19 +276,19 @@ static int qcrypto_nettle_rsa_sign(QCryptoAkCipher *akcipher, mpz_init(s); switch (rsa->hash_alg) { - case QCRYPTO_HASH_ALG_MD5: + case QCRYPTO_HASH_ALGO_MD5: rv = rsa_md5_sign_digest(&rsa->priv, data, s); break; - case QCRYPTO_HASH_ALG_SHA1: + case QCRYPTO_HASH_ALGO_SHA1: rv = rsa_sha1_sign_digest(&rsa->priv, data, s); break; - case QCRYPTO_HASH_ALG_SHA256: + case QCRYPTO_HASH_ALGO_SHA256: rv = rsa_sha256_sign_digest(&rsa->priv, data, s); break; - case QCRYPTO_HASH_ALG_SHA512: + case QCRYPTO_HASH_ALGO_SHA512: rv = rsa_sha512_sign_digest(&rsa->priv, data, s); break; @@ -341,19 +341,19 @@ static int qcrypto_nettle_rsa_verify(QCryptoAkCipher *akcipher, 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 = rsa_md5_verify_digest(&rsa->pub, data, s); break; - case QCRYPTO_HASH_ALG_SHA1: + case QCRYPTO_HASH_ALGO_SHA1: rv = rsa_sha1_verify_digest(&rsa->pub, data, s); break; - case QCRYPTO_HASH_ALG_SHA256: + case QCRYPTO_HASH_ALGO_SHA256: rv = rsa_sha256_verify_digest(&rsa->pub, data, s); break; - case QCRYPTO_HASH_ALG_SHA512: + case QCRYPTO_HASH_ALGO_SHA512: rv = rsa_sha512_verify_digest(&rsa->pub, data, s); break; @@ -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; default: From patchwork Wed Sep 4 11:18:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Markus Armbruster X-Patchwork-Id: 13790617 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C0C0FCD3431 for ; Wed, 4 Sep 2024 11:27:18 +0000 (UTC) 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 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= 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 X-MC-Unique: 6Jl6ORluM_atKYsEPg3h4w-1 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) 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 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.15 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org 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é --- 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' } } ## # @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', 'ripemd160']} ## -# @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; /* 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); 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" 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; QCryptoIVGenAlgorithm algorithm; - QCryptoCipherAlgorithm cipher; + QCryptoCipherAlgo cipher; QCryptoHashAlgo hash; }; 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; -/* See also "QCryptoCipherAlgorithm" and "QCryptoCipherMode" +/* See also "QCryptoCipherAlgo" and "QCryptoCipherMode" * enums defined in qapi/crypto.json */ /** @@ -50,12 +50,12 @@ typedef struct QCryptoCipherDriver QCryptoCipherDriver; * size_t keylen = 16; * uint8_t iv = ....; * - * 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 = qcrypto_cipher_new(QCRYPTO_CIPHER_ALG_AES_128, + * cipher = qcrypto_cipher_new(QCRYPTO_CIPHER_ALGO_AES_128, * QCRYPTO_CIPHER_MODE_CBC, * key, keylen, * errp); @@ -78,7 +78,7 @@ typedef struct QCryptoCipherDriver QCryptoCipherDriver; */ 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); /** @@ -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); /** @@ -117,7 +117,7 @@ size_t qcrypto_cipher_get_block_len(QCryptoCipherAlgorithm 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); /** @@ -130,7 +130,7 @@ size_t qcrypto_cipher_get_key_len(QCryptoCipherAlgorithm 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); @@ -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) == 0); * * QCryptoIVGen *ivgen = 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 = qcrypto_cipher_new(QCRYPTO_CIPHER_ALG_AES_128, + * QCryptoCipher *cipher = qcrypto_cipher_new(QCRYPTO_CIPHER_ALGO_AES_128, * QCRYPTO_CIPHER_MODE_CBC, * key, nkey, errp); * if (!cipher) { * goto error; * } * - * niv = qcrypto_cipher_get_iv_len(QCRYPTO_CIPHER_ALG_AES_128, + * niv = qcrypto_cipher_get_iv_len(QCRYPTO_CIPHER_ALGO_AES_128, * QCRYPTO_CIPHER_MODE_CBC); * iv = 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(QCryptoIVGen *ivgen); * * Returns: the cipher algorithm */ -QCryptoCipherAlgorithm qcrypto_ivgen_get_cipher(QCryptoIVGen *ivgen); +QCryptoCipherAlgo qcrypto_ivgen_get_cipher(QCryptoIVGen *ivgen); /** 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 = "a-typical-awful-user-password"; - * size_t nkey = qcrypto_cipher_get_key_len(QCRYPTO_CIPHER_ALG_AES_128); + * size_t nkey = qcrypto_cipher_get_key_len(QCRYPTO_CIPHER_ALGO_AES_128); * uint8_t *salt = g_new0(uint8_t, nkey); * uint8_t *key = g_new0(uint8_t, nkey); * int iterations; @@ -70,7 +70,7 @@ * * g_free(salt); * - * cipher = qcrypto_cipher_new(QCRYPTO_CIPHER_ALG_AES_128, + * cipher = 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; if (key_len == AES_KEYSIZE_128) { - algo = QCRYPTO_CIPHER_ALG_AES_128; + algo = QCRYPTO_CIPHER_ALGO_AES_128; } else if (key_len == AES_KEYSIZE_192) { - algo = QCRYPTO_CIPHER_ALG_AES_192; + algo = QCRYPTO_CIPHER_ALGO_AES_192; } else if (key_len == AES_KEYSIZE_256) { /* equals AES_KEYSIZE_128_XTS */ if (mode == QCRYPTO_CIPHER_MODE_XTS) { - algo = QCRYPTO_CIPHER_ALG_AES_128; + algo = QCRYPTO_CIPHER_ALGO_AES_128; } else { - algo = QCRYPTO_CIPHER_ALG_AES_256; + algo = QCRYPTO_CIPHER_ALGO_AES_256; } } else if (key_len == AES_KEYSIZE_256_XTS) { if (mode == QCRYPTO_CIPHER_MODE_XTS) { - algo = QCRYPTO_CIPHER_ALG_AES_256; + algo = 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 = QCRYPTO_CIPHER_MODE_ECB; - algo = QCRYPTO_CIPHER_ALG_3DES; + algo = QCRYPTO_CIPHER_ALGO_3DES; break; case VIRTIO_CRYPTO_CIPHER_3DES_CBC: mode = QCRYPTO_CIPHER_MODE_CBC; - algo = QCRYPTO_CIPHER_ALG_3DES; + algo = QCRYPTO_CIPHER_ALGO_3DES; break; case VIRTIO_CRYPTO_CIPHER_3DES_CTR: mode = QCRYPTO_CIPHER_MODE_CTR; - algo = QCRYPTO_CIPHER_ALG_3DES; + algo = 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( if (luks_opts->has_cipher_alg) { switch (luks_opts->cipher_alg) { - case QCRYPTO_CIPHER_ALG_AES_128: { + case QCRYPTO_CIPHER_ALGO_AES_128: { *alg = RBD_ENCRYPTION_ALGORITHM_AES128; break; } - case QCRYPTO_CIPHER_ALG_AES_256: { + case QCRYPTO_CIPHER_ALGO_AES_256: { *alg = 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 { static const QCryptoBlockLUKSCipherSizeMap qcrypto_block_luks_cipher_size_map_aes[] = { - { 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 }, }; static const QCryptoBlockLUKSCipherSizeMap qcrypto_block_luks_cipher_size_map_cast5[] = { - { 16, QCRYPTO_CIPHER_ALG_CAST5_128 }, + { 16, QCRYPTO_CIPHER_ALGO_CAST5_128 }, { 0, 0 }, }; static const QCryptoBlockLUKSCipherSizeMap qcrypto_block_luks_cipher_size_map_serpent[] = { - { 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 }, }; static const QCryptoBlockLUKSCipherSizeMap qcrypto_block_luks_cipher_size_map_twofish[] = { - { 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 }, }; #ifdef CONFIG_CRYPTO_SM4 static const QCryptoBlockLUKSCipherSizeMap qcrypto_block_luks_cipher_size_map_sm4[] = { - { 16, QCRYPTO_CIPHER_ALG_SM4}, + { 16, QCRYPTO_CIPHER_ALGO_SM4}, { 0, 0 }, }; #endif @@ -123,7 +123,7 @@ struct QCryptoBlockLUKS { QCryptoBlockLUKSHeader header; /* Main encryption algorithm used for encryption*/ - QCryptoCipherAlgorithm cipher_alg; + QCryptoCipherAlgo cipher_alg; /* 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; /* Hash algorithm used in pbkdf2 function */ QCryptoHashAlgo hash_alg; @@ -179,7 +179,7 @@ static int qcrypto_block_luks_cipher_name_lookup(const char *name, } static const char * -qcrypto_block_luks_cipher_alg_lookup(QCryptoCipherAlgorithm alg, +qcrypto_block_luks_cipher_alg_lookup(QCryptoCipherAlgo alg, Error **errp) { const QCryptoBlockLUKSCipherNameMap *map = @@ -195,7 +195,7 @@ qcrypto_block_luks_cipher_alg_lookup(QCryptoCipherAlgorithm alg, } error_setg(errp, "Algorithm '%s' not supported", - QCryptoCipherAlgorithm_str(alg)); + QCryptoCipherAlgo_str(alg)); return NULL; } @@ -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(QCryptoCipherAlgorithm cipher, } 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 == 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 == 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 == 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 == 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 == 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 == 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 available", 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 == 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 == 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 == 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 available", 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 = QCRYPTO_BLOCK_LUKS_DEFAULT_ITER_TIME_MS; } if (!luks_opts.has_cipher_alg) { - luks_opts.cipher_alg = QCRYPTO_CIPHER_ALG_AES_256; + luks_opts.cipher_alg = QCRYPTO_CIPHER_ALGO_AES_256; } if (!luks_opts.has_cipher_mode) { luks_opts.cipher_mode = 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); - block->niv = qcrypto_cipher_get_iv_len(QCRYPTO_CIPHER_ALG_AES_128, + block->niv = qcrypto_cipher_get_iv_len(QCRYPTO_CIPHER_ALGO_AES_128, QCRYPTO_CIPHER_MODE_CBC); block->ivgen = qcrypto_ivgen_new(QCRYPTO_IVGEN_ALG_PLAIN64, 0, 0, NULL, 0, errp); @@ -71,7 +71,7 @@ qcrypto_block_qcow_init(QCryptoBlock *block, goto fail; } - ret = qcrypto_block_init_cipher(block, QCRYPTO_CIPHER_ALG_AES_128, + ret = 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 *block, 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 @@ 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; 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 = "aes"; break; - case QCRYPTO_CIPHER_ALG_CAST5_128: + case QCRYPTO_CIPHER_ALGO_CAST5_128: alg_name = "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 = "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 = "twofish"; break; @@ -60,7 +60,7 @@ qcrypto_afalg_cipher_format_name(QCryptoCipherAlgorithm alg, static const struct QCryptoCipherDriver qcrypto_cipher_afalg_driver; 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" -static const size_t alg_key_len[QCRYPTO_CIPHER_ALG__MAX] = { - [QCRYPTO_CIPHER_ALG_AES_128] = 16, - [QCRYPTO_CIPHER_ALG_AES_192] = 24, - [QCRYPTO_CIPHER_ALG_AES_256] = 32, - [QCRYPTO_CIPHER_ALG_DES] = 8, - [QCRYPTO_CIPHER_ALG_3DES] = 24, - [QCRYPTO_CIPHER_ALG_CAST5_128] = 16, - [QCRYPTO_CIPHER_ALG_SERPENT_128] = 16, - [QCRYPTO_CIPHER_ALG_SERPENT_192] = 24, - [QCRYPTO_CIPHER_ALG_SERPENT_256] = 32, - [QCRYPTO_CIPHER_ALG_TWOFISH_128] = 16, - [QCRYPTO_CIPHER_ALG_TWOFISH_192] = 24, - [QCRYPTO_CIPHER_ALG_TWOFISH_256] = 32, +static const size_t alg_key_len[QCRYPTO_CIPHER_ALGO__MAX] = { + [QCRYPTO_CIPHER_ALGO_AES_128] = 16, + [QCRYPTO_CIPHER_ALGO_AES_192] = 24, + [QCRYPTO_CIPHER_ALGO_AES_256] = 32, + [QCRYPTO_CIPHER_ALGO_DES] = 8, + [QCRYPTO_CIPHER_ALGO_3DES] = 24, + [QCRYPTO_CIPHER_ALGO_CAST5_128] = 16, + [QCRYPTO_CIPHER_ALGO_SERPENT_128] = 16, + [QCRYPTO_CIPHER_ALGO_SERPENT_192] = 24, + [QCRYPTO_CIPHER_ALGO_SERPENT_256] = 32, + [QCRYPTO_CIPHER_ALGO_TWOFISH_128] = 16, + [QCRYPTO_CIPHER_ALGO_TWOFISH_192] = 24, + [QCRYPTO_CIPHER_ALGO_TWOFISH_256] = 32, #ifdef CONFIG_CRYPTO_SM4 - [QCRYPTO_CIPHER_ALG_SM4] = 16, + [QCRYPTO_CIPHER_ALGO_SM4] = 16, #endif }; -static const size_t alg_block_len[QCRYPTO_CIPHER_ALG__MAX] = { - [QCRYPTO_CIPHER_ALG_AES_128] = 16, - [QCRYPTO_CIPHER_ALG_AES_192] = 16, - [QCRYPTO_CIPHER_ALG_AES_256] = 16, - [QCRYPTO_CIPHER_ALG_DES] = 8, - [QCRYPTO_CIPHER_ALG_3DES] = 8, - [QCRYPTO_CIPHER_ALG_CAST5_128] = 8, - [QCRYPTO_CIPHER_ALG_SERPENT_128] = 16, - [QCRYPTO_CIPHER_ALG_SERPENT_192] = 16, - [QCRYPTO_CIPHER_ALG_SERPENT_256] = 16, - [QCRYPTO_CIPHER_ALG_TWOFISH_128] = 16, - [QCRYPTO_CIPHER_ALG_TWOFISH_192] = 16, - [QCRYPTO_CIPHER_ALG_TWOFISH_256] = 16, +static const size_t alg_block_len[QCRYPTO_CIPHER_ALGO__MAX] = { + [QCRYPTO_CIPHER_ALGO_AES_128] = 16, + [QCRYPTO_CIPHER_ALGO_AES_192] = 16, + [QCRYPTO_CIPHER_ALGO_AES_256] = 16, + [QCRYPTO_CIPHER_ALGO_DES] = 8, + [QCRYPTO_CIPHER_ALGO_3DES] = 8, + [QCRYPTO_CIPHER_ALGO_CAST5_128] = 8, + [QCRYPTO_CIPHER_ALGO_SERPENT_128] = 16, + [QCRYPTO_CIPHER_ALGO_SERPENT_192] = 16, + [QCRYPTO_CIPHER_ALGO_SERPENT_256] = 16, + [QCRYPTO_CIPHER_ALGO_TWOFISH_128] = 16, + [QCRYPTO_CIPHER_ALGO_TWOFISH_192] = 16, + [QCRYPTO_CIPHER_ALGO_TWOFISH_256] = 16, #ifdef CONFIG_CRYPTO_SM4 - [QCRYPTO_CIPHER_ALG_SM4] = 16, + [QCRYPTO_CIPHER_ALGO_SM4] = 16, #endif }; @@ -69,21 +69,21 @@ static const bool mode_need_iv[QCRYPTO_CIPHER_MODE__MAX] = { }; -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]; } -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]; } -size_t qcrypto_cipher_get_iv_len(QCryptoCipherAlgorithm alg, +size_t qcrypto_cipher_get_iv_len(QCryptoCipherAlgo alg, QCryptoCipherMode mode) { if (alg >= G_N_ELEMENTS(alg_block_len)) { @@ -101,20 +101,20 @@ size_t qcrypto_cipher_get_iv_len(QCryptoCipherAlgorithm alg, 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 >= QCRYPTO_CIPHER_ALG__MAX) { + if ((unsigned)alg >= QCRYPTO_CIPHER_ALGO__MAX) { error_setg(errp, "Cipher algorithm %d out of range", alg); return false; } if (mode == QCRYPTO_CIPHER_MODE_XTS) { - if (alg == QCRYPTO_CIPHER_ALG_DES || - alg == QCRYPTO_CIPHER_ALG_3DES) { + if (alg == QCRYPTO_CIPHER_ALGO_DES || + alg == 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(QCryptoCipherAlgorithm alg, #include "cipher-builtin.c.inc" #endif -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 @@ 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(QCryptoIVGen *ivgen) } -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 *secret, return; } - aes = qcrypto_cipher_new(QCRYPTO_CIPHER_ALG_AES_256, + aes = 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 @@ static void test_cipher_speed(size_t chunk_size, QCryptoCipherMode mode, - QCryptoCipherAlgorithm alg) + QCryptoCipherAlgo alg) { QCryptoCipher *cipher; Error *err = NULL; @@ -71,7 +71,7 @@ static void test_cipher_speed(size_t chunk_size, g_test_timer_elapsed(); 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()); @@ -88,7 +88,7 @@ static void test_cipher_speed(size_t chunk_size, g_test_timer_elapsed(); 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()); @@ -105,7 +105,7 @@ static void test_cipher_speed_ecb_aes_128(const void *opaque) size_t chunk_size = (size_t)opaque; test_cipher_speed(chunk_size, QCRYPTO_CIPHER_MODE_ECB, - QCRYPTO_CIPHER_ALG_AES_128); + QCRYPTO_CIPHER_ALGO_AES_128); } 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 *opaque) size_t chunk_size = (size_t)opaque; test_cipher_speed(chunk_size, QCRYPTO_CIPHER_MODE_ECB, - QCRYPTO_CIPHER_ALG_AES_256); + QCRYPTO_CIPHER_ALGO_AES_256); } 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 *opaque) size_t chunk_size = (size_t)opaque; test_cipher_speed(chunk_size, QCRYPTO_CIPHER_MODE_CBC, - QCRYPTO_CIPHER_ALG_AES_128); + QCRYPTO_CIPHER_ALGO_AES_128); } 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 *opaque) size_t chunk_size = (size_t)opaque; test_cipher_speed(chunk_size, QCRYPTO_CIPHER_MODE_CBC, - QCRYPTO_CIPHER_ALG_AES_256); + QCRYPTO_CIPHER_ALGO_AES_256); } 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 *opaque) size_t chunk_size = (size_t)opaque; test_cipher_speed(chunk_size, QCRYPTO_CIPHER_MODE_CTR, - QCRYPTO_CIPHER_ALG_AES_128); + QCRYPTO_CIPHER_ALGO_AES_128); } 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 *opaque) size_t chunk_size = (size_t)opaque; test_cipher_speed(chunk_size, QCRYPTO_CIPHER_MODE_CTR, - QCRYPTO_CIPHER_ALG_AES_256); + QCRYPTO_CIPHER_ALGO_AES_256); } 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 *opaque) size_t chunk_size = (size_t)opaque; test_cipher_speed(chunk_size, QCRYPTO_CIPHER_MODE_XTS, - QCRYPTO_CIPHER_ALG_AES_128); + QCRYPTO_CIPHER_ALGO_AES_128); } 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 *opaque) size_t chunk_size = (size_t)opaque; test_cipher_speed(chunk_size, QCRYPTO_CIPHER_MODE_XTS, - QCRYPTO_CIPHER_ALG_AES_256); + QCRYPTO_CIPHER_ALGO_AES_256); } 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 = { .u.luks = { .key_secret = (char *)"sec0", .has_cipher_alg = true, - .cipher_alg = QCRYPTO_CIPHER_ALG_AES_256, + .cipher_alg = QCRYPTO_CIPHER_ALGO_AES_256, .has_cipher_mode = true, .cipher_mode = QCRYPTO_CIPHER_MODE_CBC, .has_ivgen_alg = true, @@ -91,7 +91,7 @@ static QCryptoBlockCreateOptions luks_create_opts_aes256_cbc_essiv = { .u.luks = { .key_secret = (char *)"sec0", .has_cipher_alg = true, - .cipher_alg = QCRYPTO_CIPHER_ALG_AES_256, + .cipher_alg = QCRYPTO_CIPHER_ALGO_AES_256, .has_cipher_mode = true, .cipher_mode = QCRYPTO_CIPHER_MODE_CBC, .has_ivgen_alg = true, @@ -112,7 +112,7 @@ static struct QCryptoBlockTestData { bool expect_header; - QCryptoCipherAlgorithm cipher_alg; + QCryptoCipherAlgo cipher_alg; QCryptoCipherMode cipher_mode; QCryptoHashAlgo hash_alg; @@ -128,7 +128,7 @@ static struct QCryptoBlockTestData { .expect_header = false, - .cipher_alg = QCRYPTO_CIPHER_ALG_AES_128, + .cipher_alg = QCRYPTO_CIPHER_ALGO_AES_128, .cipher_mode = QCRYPTO_CIPHER_MODE_CBC, .ivgen_alg = QCRYPTO_IVGEN_ALG_PLAIN64, @@ -141,7 +141,7 @@ static struct QCryptoBlockTestData { .expect_header = true, - .cipher_alg = QCRYPTO_CIPHER_ALG_AES_256, + .cipher_alg = QCRYPTO_CIPHER_ALGO_AES_256, .cipher_mode = QCRYPTO_CIPHER_MODE_XTS, .hash_alg = QCRYPTO_HASH_ALGO_SHA256, @@ -156,7 +156,7 @@ static struct QCryptoBlockTestData { .expect_header = true, - .cipher_alg = QCRYPTO_CIPHER_ALG_AES_256, + .cipher_alg = QCRYPTO_CIPHER_ALGO_AES_256, .cipher_mode = QCRYPTO_CIPHER_MODE_CBC, .hash_alg = QCRYPTO_HASH_ALGO_SHA256, @@ -171,7 +171,7 @@ static struct QCryptoBlockTestData { .expect_header = true, - .cipher_alg = QCRYPTO_CIPHER_ALG_AES_256, + .cipher_alg = QCRYPTO_CIPHER_ALGO_AES_256, .cipher_mode = QCRYPTO_CIPHER_MODE_CBC, .hash_alg = QCRYPTO_HASH_ALGO_SHA1, diff --git a/tests/unit/test-crypto-cipher.c b/tests/unit/test-crypto-cipher.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[] = { { /* NIST F.1.1 ECB-AES128.Encrypt */ .path = "/crypto/cipher/aes-ecb-128", - .alg = QCRYPTO_CIPHER_ALG_AES_128, + .alg = QCRYPTO_CIPHER_ALGO_AES_128, .mode = QCRYPTO_CIPHER_MODE_ECB, .key = "2b7e151628aed2a6abf7158809cf4f3c", .plaintext = @@ -60,7 +60,7 @@ static QCryptoCipherTestData test_data[] = { { /* NIST F.1.3 ECB-AES192.Encrypt */ .path = "/crypto/cipher/aes-ecb-192", - .alg = QCRYPTO_CIPHER_ALG_AES_192, + .alg = QCRYPTO_CIPHER_ALGO_AES_192, .mode = QCRYPTO_CIPHER_MODE_ECB, .key = "8e73b0f7da0e6452c810f32b809079e562f8ead2522c6b7b", .plaintext = @@ -77,7 +77,7 @@ static QCryptoCipherTestData test_data[] = { { /* NIST F.1.5 ECB-AES256.Encrypt */ .path = "/crypto/cipher/aes-ecb-256", - .alg = QCRYPTO_CIPHER_ALG_AES_256, + .alg = QCRYPTO_CIPHER_ALGO_AES_256, .mode = QCRYPTO_CIPHER_MODE_ECB, .key = "603deb1015ca71be2b73aef0857d7781" @@ -96,7 +96,7 @@ static QCryptoCipherTestData test_data[] = { { /* NIST F.2.1 CBC-AES128.Encrypt */ .path = "/crypto/cipher/aes-cbc-128", - .alg = QCRYPTO_CIPHER_ALG_AES_128, + .alg = QCRYPTO_CIPHER_ALGO_AES_128, .mode = QCRYPTO_CIPHER_MODE_CBC, .key = "2b7e151628aed2a6abf7158809cf4f3c", .iv = "000102030405060708090a0b0c0d0e0f", @@ -114,7 +114,7 @@ static QCryptoCipherTestData test_data[] = { { /* NIST F.2.3 CBC-AES128.Encrypt */ .path = "/crypto/cipher/aes-cbc-192", - .alg = QCRYPTO_CIPHER_ALG_AES_192, + .alg = QCRYPTO_CIPHER_ALGO_AES_192, .mode = QCRYPTO_CIPHER_MODE_CBC, .key = "8e73b0f7da0e6452c810f32b809079e562f8ead2522c6b7b", .iv = "000102030405060708090a0b0c0d0e0f", @@ -132,7 +132,7 @@ static QCryptoCipherTestData test_data[] = { { /* NIST F.2.5 CBC-AES128.Encrypt */ .path = "/crypto/cipher/aes-cbc-256", - .alg = QCRYPTO_CIPHER_ALG_AES_256, + .alg = QCRYPTO_CIPHER_ALGO_AES_256, .mode = QCRYPTO_CIPHER_MODE_CBC, .key = "603deb1015ca71be2b73aef0857d7781" @@ -156,7 +156,7 @@ static QCryptoCipherTestData test_data[] = { * ciphertext in ECB and CBC modes */ .path = "/crypto/cipher/des-ecb-56-one-block", - .alg = QCRYPTO_CIPHER_ALG_DES, + .alg = QCRYPTO_CIPHER_ALGO_DES, .mode = QCRYPTO_CIPHER_MODE_ECB, .key = "80c4a2e691d5b3f7", .plaintext = "70617373776f7264", @@ -165,7 +165,7 @@ static QCryptoCipherTestData test_data[] = { { /* See previous comment */ .path = "/crypto/cipher/des-cbc-56-one-block", - .alg = QCRYPTO_CIPHER_ALG_DES, + .alg = QCRYPTO_CIPHER_ALGO_DES, .mode = QCRYPTO_CIPHER_MODE_CBC, .key = "80c4a2e691d5b3f7", .iv = "0000000000000000", @@ -174,7 +174,7 @@ static QCryptoCipherTestData test_data[] = { }, { .path = "/crypto/cipher/des-ecb-56", - .alg = QCRYPTO_CIPHER_ALG_DES, + .alg = QCRYPTO_CIPHER_ALGO_DES, .mode = QCRYPTO_CIPHER_MODE_ECB, .key = "80c4a2e691d5b3f7", .plaintext = @@ -191,7 +191,7 @@ static QCryptoCipherTestData test_data[] = { { /* Borrowed from linux-kernel crypto/testmgr.h */ .path = "/crypto/cipher/3des-cbc", - .alg = QCRYPTO_CIPHER_ALG_3DES, + .alg = QCRYPTO_CIPHER_ALGO_3DES, .mode = QCRYPTO_CIPHER_MODE_CBC, .key = "e9c0ff2e760b6424444d995a12d640c0" @@ -220,7 +220,7 @@ static QCryptoCipherTestData test_data[] = { { /* Borrowed from linux-kernel crypto/testmgr.h */ .path = "/crypto/cipher/3des-ecb", - .alg = QCRYPTO_CIPHER_ALG_3DES, + .alg = QCRYPTO_CIPHER_ALGO_3DES, .mode = QCRYPTO_CIPHER_MODE_ECB, .key = "0123456789abcdef5555555555555555" @@ -233,7 +233,7 @@ static QCryptoCipherTestData test_data[] = { { /* Borrowed from linux-kernel crypto/testmgr.h */ .path = "/crypto/cipher/3des-ctr", - .alg = QCRYPTO_CIPHER_ALG_3DES, + .alg = QCRYPTO_CIPHER_ALGO_3DES, .mode = QCRYPTO_CIPHER_MODE_CTR, .key = "9cd6f39cb95a67005a67002dceeb2dce" @@ -308,7 +308,7 @@ static QCryptoCipherTestData test_data[] = { { /* RFC 2144, Appendix B.1 */ .path = "/crypto/cipher/cast5-128", - .alg = QCRYPTO_CIPHER_ALG_CAST5_128, + .alg = QCRYPTO_CIPHER_ALGO_CAST5_128, .mode = QCRYPTO_CIPHER_MODE_ECB, .key = "0123456712345678234567893456789A", .plaintext = "0123456789abcdef", @@ -317,7 +317,7 @@ static QCryptoCipherTestData test_data[] = { { /* libgcrypt serpent.c */ .path = "/crypto/cipher/serpent-128", - .alg = QCRYPTO_CIPHER_ALG_SERPENT_128, + .alg = QCRYPTO_CIPHER_ALGO_SERPENT_128, .mode = QCRYPTO_CIPHER_MODE_ECB, .key = "00000000000000000000000000000000", .plaintext = "d29d576fcea3a3a7ed9099f29273d78e", @@ -326,7 +326,7 @@ static QCryptoCipherTestData test_data[] = { { /* libgcrypt serpent.c */ .path = "/crypto/cipher/serpent-192", - .alg = QCRYPTO_CIPHER_ALG_SERPENT_192, + .alg = QCRYPTO_CIPHER_ALGO_SERPENT_192, .mode = QCRYPTO_CIPHER_MODE_ECB, .key = "00000000000000000000000000000000" "0000000000000000", @@ -336,7 +336,7 @@ static QCryptoCipherTestData test_data[] = { { /* libgcrypt serpent.c */ .path = "/crypto/cipher/serpent-256a", - .alg = QCRYPTO_CIPHER_ALG_SERPENT_256, + .alg = QCRYPTO_CIPHER_ALGO_SERPENT_256, .mode = QCRYPTO_CIPHER_MODE_ECB, .key = "00000000000000000000000000000000" "00000000000000000000000000000000", @@ -346,7 +346,7 @@ static QCryptoCipherTestData test_data[] = { { /* libgcrypt serpent.c */ .path = "/crypto/cipher/serpent-256b", - .alg = QCRYPTO_CIPHER_ALG_SERPENT_256, + .alg = QCRYPTO_CIPHER_ALGO_SERPENT_256, .mode = QCRYPTO_CIPHER_MODE_ECB, .key = "00000000000000000000000000000000" "00000000000000000000000000000000", @@ -356,7 +356,7 @@ static QCryptoCipherTestData test_data[] = { { /* Twofish paper "Known Answer Test" */ .path = "/crypto/cipher/twofish-128", - .alg = QCRYPTO_CIPHER_ALG_TWOFISH_128, + .alg = QCRYPTO_CIPHER_ALGO_TWOFISH_128, .mode = QCRYPTO_CIPHER_MODE_ECB, .key = "d491db16e7b1c39e86cb086b789f5419", .plaintext = "019f9809de1711858faac3a3ba20fbc3", @@ -365,7 +365,7 @@ static QCryptoCipherTestData test_data[] = { { /* Twofish paper "Known Answer Test", I=3 */ .path = "/crypto/cipher/twofish-192", - .alg = QCRYPTO_CIPHER_ALG_TWOFISH_192, + .alg = QCRYPTO_CIPHER_ALGO_TWOFISH_192, .mode = QCRYPTO_CIPHER_MODE_ECB, .key = "88b2b2706b105e36b446bb6d731a1e88" "efa71f788965bd44", @@ -375,7 +375,7 @@ static QCryptoCipherTestData test_data[] = { { /* Twofish paper "Known Answer Test", I=4 */ .path = "/crypto/cipher/twofish-256", - .alg = QCRYPTO_CIPHER_ALG_TWOFISH_256, + .alg = QCRYPTO_CIPHER_ALGO_TWOFISH_256, .mode = QCRYPTO_CIPHER_MODE_ECB, .key = "d43bb7556ea32e46f2a282b7d45b4e0d" "57ff739d4dc92c1bd7fc01700cc8216f", @@ -386,7 +386,7 @@ static QCryptoCipherTestData test_data[] = { { /* SM4, GB/T 32907-2016, Appendix A.1 */ .path = "/crypto/cipher/sm4", - .alg = QCRYPTO_CIPHER_ALG_SM4, + .alg = QCRYPTO_CIPHER_ALGO_SM4, .mode = QCRYPTO_CIPHER_MODE_ECB, .key = "0123456789abcdeffedcba9876543210", .plaintext = @@ -398,7 +398,7 @@ static QCryptoCipherTestData test_data[] = { { /* #1 32 byte key, 32 byte PTX */ .path = "/crypto/cipher/aes-xts-128-1", - .alg = QCRYPTO_CIPHER_ALG_AES_128, + .alg = QCRYPTO_CIPHER_ALGO_AES_128, .mode = QCRYPTO_CIPHER_MODE_XTS, .key = "00000000000000000000000000000000" @@ -415,7 +415,7 @@ static QCryptoCipherTestData test_data[] = { { /* #2, 32 byte key, 32 byte PTX */ .path = "/crypto/cipher/aes-xts-128-2", - .alg = QCRYPTO_CIPHER_ALG_AES_128, + .alg = QCRYPTO_CIPHER_ALGO_AES_128, .mode = QCRYPTO_CIPHER_MODE_XTS, .key = "11111111111111111111111111111111" @@ -432,7 +432,7 @@ static QCryptoCipherTestData test_data[] = { { /* #5 from xts.7, 32 byte key, 32 byte PTX */ .path = "/crypto/cipher/aes-xts-128-3", - .alg = QCRYPTO_CIPHER_ALG_AES_128, + .alg = QCRYPTO_CIPHER_ALGO_AES_128, .mode = QCRYPTO_CIPHER_MODE_XTS, .key = "fffefdfcfbfaf9f8f7f6f5f4f3f2f1f0" @@ -449,7 +449,7 @@ static QCryptoCipherTestData test_data[] = { { /* #4, 32 byte key, 512 byte PTX */ .path = "/crypto/cipher/aes-xts-128-4", - .alg = QCRYPTO_CIPHER_ALG_AES_128, + .alg = QCRYPTO_CIPHER_ALGO_AES_128, .mode = QCRYPTO_CIPHER_MODE_XTS, .key = "27182818284590452353602874713526" @@ -528,7 +528,7 @@ static QCryptoCipherTestData test_data[] = { * which is incompatible with XTS */ .path = "/crypto/cipher/cast5-xts-128", - .alg = QCRYPTO_CIPHER_ALG_CAST5_128, + .alg = QCRYPTO_CIPHER_ALGO_CAST5_128, .mode = QCRYPTO_CIPHER_MODE_XTS, .key = "27182818284590452353602874713526" @@ -537,7 +537,7 @@ static QCryptoCipherTestData test_data[] = { { /* NIST F.5.1 CTR-AES128.Encrypt */ .path = "/crypto/cipher/aes-ctr-128", - .alg = QCRYPTO_CIPHER_ALG_AES_128, + .alg = QCRYPTO_CIPHER_ALGO_AES_128, .mode = QCRYPTO_CIPHER_MODE_CTR, .key = "2b7e151628aed2a6abf7158809cf4f3c", .iv = "f0f1f2f3f4f5f6f7f8f9fafbfcfdfeff", @@ -555,7 +555,7 @@ static QCryptoCipherTestData test_data[] = { { /* NIST F.5.3 CTR-AES192.Encrypt */ .path = "/crypto/cipher/aes-ctr-192", - .alg = QCRYPTO_CIPHER_ALG_AES_192, + .alg = QCRYPTO_CIPHER_ALGO_AES_192, .mode = QCRYPTO_CIPHER_MODE_CTR, .key = "8e73b0f7da0e6452c810f32b809079e562f8ead2522c6b7b", .iv = "f0f1f2f3f4f5f6f7f8f9fafbfcfdfeff", @@ -573,7 +573,7 @@ static QCryptoCipherTestData test_data[] = { { /* NIST F.5.5 CTR-AES256.Encrypt */ .path = "/crypto/cipher/aes-ctr-256", - .alg = QCRYPTO_CIPHER_ALG_AES_256, + .alg = QCRYPTO_CIPHER_ALGO_AES_256, .mode = QCRYPTO_CIPHER_MODE_CTR, .key = "603deb1015ca71be2b73aef0857d7781" "1f352c073b6108d72d9810a30914dff4", @@ -750,7 +750,7 @@ static void test_cipher_null_iv(void) uint8_t ciphertext[32] = { 0 }; cipher = 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; cipher = 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_cipher); } 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 = 0x1, .ivalg = QCRYPTO_IVGEN_ALG_ESSIV, - .cipheralg = QCRYPTO_CIPHER_ALG_AES_128, + .cipheralg = QCRYPTO_CIPHER_ALGO_AES_128, .hashalg = QCRYPTO_HASH_ALGO_SHA256, .key = (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 = 0x1f2e3d4cULL, .ivalg = QCRYPTO_IVGEN_ALG_ESSIV, - .cipheralg = QCRYPTO_CIPHER_ALG_AES_128, + .cipheralg = QCRYPTO_CIPHER_ALGO_AES_128, .hashalg = QCRYPTO_HASH_ALGO_SHA256, .key = (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 = 0x1f2e3d4c5b6a7988ULL, .ivalg = QCRYPTO_IVGEN_ALG_ESSIV, - .cipheralg = QCRYPTO_CIPHER_ALG_AES_128, + .cipheralg = QCRYPTO_CIPHER_ALGO_AES_128, .hashalg = QCRYPTO_HASH_ALGO_SHA256, .key = (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, uint8_t *data, size_t len) vnc_munge_des_rfb_key(key, sizeof(key)); cipher = 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_cipher_aes_driver_cbc = { .cipher_free = qcrypto_cipher_ctx_free, }; -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, } } -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(QCryptoCipherAlgorithm alg, } 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(QCryptoCipherAlgorithm alg, default: error_setg(errp, "Unsupported cipher algorithm %s", - QCryptoCipherAlgorithm_str(alg)); + QCryptoCipherAlgo_str(alg)); return NULL; } 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 @@ #include -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(QCryptoCipherMode mode) } } -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 = { .cipher_free = qcrypto_gcrypt_ctx_free, }; -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(QCryptoCipherAlgorithm alg, gcryalg = qcrypto_cipher_alg_to_gcry_alg(alg); if (gcryalg == GCRY_CIPHER_NONE) { error_setg(errp, "Unsupported cipher algorithm %s", - QCryptoCipherAlgorithm_str(alg)); + QCryptoCipherAlgo_str(alg)); return NULL; } 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 -bool qcrypto_cipher_supports(QCryptoCipherAlgorithm alg, +bool qcrypto_cipher_supports(QCryptoCipherAlgo alg, QCryptoCipherMode mode) { @@ -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 = { .cipher_free = qcrypto_gnutls_cipher_free, }; -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(QCryptoCipherAlgorithm 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 = GNUTLS_CIPHER_AES_128_XTS; break; - case QCRYPTO_CIPHER_ALG_AES_256: + case QCRYPTO_CIPHER_ALGO_AES_256: galg = GNUTLS_CIPHER_AES_256_XTS; break; default: @@ -259,19 +259,19 @@ static QCryptoCipher *qcrypto_cipher_ctx_new(QCryptoCipherAlgorithm 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 = GNUTLS_CIPHER_AES_128_CBC; break; - case QCRYPTO_CIPHER_ALG_AES_192: + case QCRYPTO_CIPHER_ALGO_AES_192: galg = GNUTLS_CIPHER_AES_192_CBC; break; - case QCRYPTO_CIPHER_ALG_AES_256: + case QCRYPTO_CIPHER_ALGO_AES_256: galg = GNUTLS_CIPHER_AES_256_CBC; break; - case QCRYPTO_CIPHER_ALG_DES: + case QCRYPTO_CIPHER_ALGO_DES: galg = GNUTLS_CIPHER_DES_CBC; break; - case QCRYPTO_CIPHER_ALG_3DES: + case QCRYPTO_CIPHER_ALGO_3DES: galg = GNUTLS_CIPHER_3DES_CBC; break; default: @@ -284,7 +284,7 @@ static QCryptoCipher *qcrypto_cipher_ctx_new(QCryptoCipherAlgorithm alg, if (galg == 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(QCryptoCipherAlgorithm alg, } } - if (alg == QCRYPTO_CIPHER_ALG_DES || - alg == QCRYPTO_CIPHER_ALG_3DES) + if (alg == QCRYPTO_CIPHER_ALGO_DES || + alg == QCRYPTO_CIPHER_ALGO_3DES) ctx->blocksize = 8; else ctx->blocksize = 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 -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, } } -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(QCryptoCipherAlgorithm alg, } 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(QCryptoCipherAlgorithm alg, return &ctx->base; } - 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(QCryptoCipherAlgorithm alg, return &ctx->base; } - case QCRYPTO_CIPHER_ALG_AES_128: + case QCRYPTO_CIPHER_ALGO_AES_128: { QCryptoNettleAES128 *ctx = g_new0(QCryptoNettleAES128, 1); @@ -590,7 +590,7 @@ static QCryptoCipher *qcrypto_cipher_ctx_new(QCryptoCipherAlgorithm alg, return &ctx->base; } - case QCRYPTO_CIPHER_ALG_AES_192: + case QCRYPTO_CIPHER_ALGO_AES_192: { QCryptoNettleAES192 *ctx = g_new0(QCryptoNettleAES192, 1); @@ -619,7 +619,7 @@ static QCryptoCipher *qcrypto_cipher_ctx_new(QCryptoCipherAlgorithm alg, return &ctx->base; } - case QCRYPTO_CIPHER_ALG_AES_256: + case QCRYPTO_CIPHER_ALGO_AES_256: { QCryptoNettleAES256 *ctx = g_new0(QCryptoNettleAES256, 1); @@ -648,7 +648,7 @@ static QCryptoCipher *qcrypto_cipher_ctx_new(QCryptoCipherAlgorithm alg, return &ctx->base; } - 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(QCryptoCipherAlgorithm alg, return &ctx->base; } - 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 = g_new0(QCryptoNettleSerpent, 1); @@ -703,9 +703,9 @@ static QCryptoCipher *qcrypto_cipher_ctx_new(QCryptoCipherAlgorithm alg, return &ctx->base; } - 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 = g_new0(QCryptoNettleTwofish, 1); @@ -732,7 +732,7 @@ static QCryptoCipher *qcrypto_cipher_ctx_new(QCryptoCipherAlgorithm alg, return &ctx->base; } #ifdef CONFIG_CRYPTO_SM4 - case QCRYPTO_CIPHER_ALG_SM4: + case QCRYPTO_CIPHER_ALGO_SM4: { QCryptoNettleSm4 *ctx = g_new0(QCryptoNettleSm4, 1); @@ -753,7 +753,7 @@ static QCryptoCipher *qcrypto_cipher_ctx_new(QCryptoCipherAlgorithm alg, default: error_setg(errp, "Unsupported cipher algorithm %s", - QCryptoCipherAlgorithm_str(alg)); + QCryptoCipherAlgo_str(alg)); return NULL; } From patchwork Wed Sep 4 11:18:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Markus Armbruster X-Patchwork-Id: 13790621 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 4F03ACD4847 for ; Wed, 4 Sep 2024 11:28:23 +0000 (UTC) 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 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= 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 X-MC-Unique: kfPfu0HXPWi1c5ZIfT_ZuQ-1 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) 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 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org 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é --- 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']} ## -# @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']} ## @@ -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; - 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) == 0); * - * QCryptoIVGen *ivgen = qcrypto_ivgen_new(QCRYPTO_IVGEN_ALG_ESSIV, + * QCryptoIVGen *ivgen = qcrypto_ivgen_new(QCRYPTO_IV_GEN_ALGO_ESSIV, * QCRYPTO_CIPHER_ALGO_AES_128, * QCRYPTO_HASH_ALGO_SHA256, * key, nkey, errp); @@ -97,7 +97,7 @@ typedef struct QCryptoIVGen QCryptoIVGen; -/* See also QCryptoIVGenAlgorithm enum in qapi/crypto.json */ +/* See also QCryptoIVGenAlgo enum in qapi/crypto.json */ /** @@ -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); /** 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; /* Initialization vector generation algorithm */ - QCryptoIVGenAlgorithm ivgen_alg; + QCryptoIVGenAlgo ivgen_alg; /* Hash algorithm used for IV generation*/ QCryptoHashAlgo ivgen_hash_alg; @@ -229,7 +229,7 @@ static int qcrypto_block_luks_name_lookup(const char *name, #define qcrypto_block_luks_ivgen_name_lookup(name, errp) \ qcrypto_block_luks_name_lookup(name, \ - &QCryptoIVGenAlgorithm_lookup, \ + &QCryptoIVGenAlgo_lookup, \ "IV generator", \ errp) @@ -660,7 +660,7 @@ qcrypto_block_luks_parse_header(QCryptoBlockLUKS *luks, Error **errp) return -1; } - if (luks->ivgen_alg == QCRYPTO_IVGEN_ALG_ESSIV) { + if (luks->ivgen_alg == 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 = QCRYPTO_CIPHER_MODE_XTS; } if (!luks_opts.has_ivgen_alg) { - luks_opts.ivgen_alg = QCRYPTO_IVGEN_ALG_PLAIN64; + luks_opts.ivgen_alg = QCRYPTO_IV_GEN_ALGO_PLAIN64; } if (!luks_opts.has_hash_alg) { luks_opts.hash_alg = QCRYPTO_HASH_ALGO_SHA256; } - if (luks_opts.ivgen_alg == QCRYPTO_IVGEN_ALG_ESSIV) { + if (luks_opts.ivgen_alg == QCRYPTO_IV_GEN_ALGO_ESSIV) { if (!luks_opts.has_ivgen_hash_alg) { luks_opts.ivgen_hash_alg = QCRYPTO_HASH_ALGO_SHA256; luks_opts.has_ivgen_hash_alg = true; @@ -1384,7 +1384,7 @@ qcrypto_block_luks_create(QCryptoBlock *block, } cipher_mode = QCryptoCipherMode_str(luks_opts.cipher_mode); - ivgen_alg = QCryptoIVGenAlgorithm_str(luks_opts.ivgen_alg); + ivgen_alg = QCryptoIVGenAlgo_str(luks_opts.ivgen_alg); if (luks_opts.has_ivgen_hash_alg) { ivgen_hash_alg = QCryptoHashAlgo_str(luks_opts.ivgen_hash_alg); cipher_mode_spec = g_strdup_printf("%s-%s:%s", cipher_mode, ivgen_alg, @@ -1411,7 +1411,7 @@ qcrypto_block_luks_create(QCryptoBlock *block, goto error; } - if (luks_opts.ivgen_alg == QCRYPTO_IVGEN_ALG_ESSIV) { + if (luks_opts.ivgen_alg == QCRYPTO_IV_GEN_ALGO_ESSIV) { luks->ivgen_cipher_alg = 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 = luks->cipher_alg; info->u.luks.cipher_mode = luks->cipher_mode; info->u.luks.ivgen_alg = luks->ivgen_alg; - if (info->u.luks.ivgen_alg == QCRYPTO_IVGEN_ALG_ESSIV) { + if (info->u.luks.ivgen_alg == QCRYPTO_IV_GEN_ALGO_ESSIV) { info->u.luks.has_ivgen_hash_alg = true; info->u.luks.ivgen_hash_alg = 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, block->niv = qcrypto_cipher_get_iv_len(QCRYPTO_CIPHER_ALGO_AES_128, QCRYPTO_CIPHER_MODE_CBC); - block->ivgen = qcrypto_ivgen_new(QCRYPTO_IVGEN_ALG_PLAIN64, + block->ivgen = qcrypto_ivgen_new(QCRYPTO_IV_GEN_ALGO_PLAIN64, 0, 0, NULL, 0, errp); if (!block->ivgen) { ret = -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" -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 alg, ivgen->hash = hash; switch (alg) { - case QCRYPTO_IVGEN_ALG_PLAIN: + case QCRYPTO_IV_GEN_ALGO_PLAIN: ivgen->driver = &qcrypto_ivgen_plain; break; - case QCRYPTO_IVGEN_ALG_PLAIN64: + case QCRYPTO_IV_GEN_ALGO_PLAIN64: ivgen->driver = &qcrypto_ivgen_plain64; break; - case QCRYPTO_IVGEN_ALG_ESSIV: + case QCRYPTO_IV_GEN_ALGO_ESSIV: ivgen->driver = &qcrypto_ivgen_essiv; break; default: @@ -73,7 +73,7 @@ int qcrypto_ivgen_calculate(QCryptoIVGen *ivgen, } -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 = { .has_cipher_mode = true, .cipher_mode = QCRYPTO_CIPHER_MODE_CBC, .has_ivgen_alg = true, - .ivgen_alg = QCRYPTO_IVGEN_ALG_PLAIN64, + .ivgen_alg = QCRYPTO_IV_GEN_ALGO_PLAIN64, }, }; @@ -95,7 +95,7 @@ static QCryptoBlockCreateOptions luks_create_opts_aes256_cbc_essiv = { .has_cipher_mode = true, .cipher_mode = QCRYPTO_CIPHER_MODE_CBC, .has_ivgen_alg = true, - .ivgen_alg = QCRYPTO_IVGEN_ALG_ESSIV, + .ivgen_alg = QCRYPTO_IV_GEN_ALGO_ESSIV, .has_ivgen_hash_alg = true, .ivgen_hash_alg = QCRYPTO_HASH_ALGO_SHA256, .has_hash_alg = true, @@ -116,7 +116,7 @@ static struct QCryptoBlockTestData { QCryptoCipherMode cipher_mode; QCryptoHashAlgo hash_alg; - QCryptoIVGenAlgorithm ivgen_alg; + QCryptoIVGenAlgo ivgen_alg; QCryptoHashAlgo ivgen_hash; bool slow; @@ -131,7 +131,7 @@ static struct QCryptoBlockTestData { .cipher_alg = QCRYPTO_CIPHER_ALGO_AES_128, .cipher_mode = QCRYPTO_CIPHER_MODE_CBC, - .ivgen_alg = QCRYPTO_IVGEN_ALG_PLAIN64, + .ivgen_alg = QCRYPTO_IV_GEN_ALGO_PLAIN64, }, #ifdef TEST_LUKS { @@ -145,7 +145,7 @@ static struct QCryptoBlockTestData { .cipher_mode = QCRYPTO_CIPHER_MODE_XTS, .hash_alg = QCRYPTO_HASH_ALGO_SHA256, - .ivgen_alg = QCRYPTO_IVGEN_ALG_PLAIN64, + .ivgen_alg = QCRYPTO_IV_GEN_ALGO_PLAIN64, .slow = true, }, @@ -160,7 +160,7 @@ static struct QCryptoBlockTestData { .cipher_mode = QCRYPTO_CIPHER_MODE_CBC, .hash_alg = QCRYPTO_HASH_ALGO_SHA256, - .ivgen_alg = QCRYPTO_IVGEN_ALG_PLAIN64, + .ivgen_alg = QCRYPTO_IV_GEN_ALGO_PLAIN64, .slow = true, }, @@ -175,7 +175,7 @@ static struct QCryptoBlockTestData { .cipher_mode = QCRYPTO_CIPHER_MODE_CBC, .hash_alg = QCRYPTO_HASH_ALGO_SHA1, - .ivgen_alg = QCRYPTO_IVGEN_ALG_ESSIV, + .ivgen_alg = QCRYPTO_IV_GEN_ALGO_ESSIV, .ivgen_hash = QCRYPTO_HASH_ALGO_SHA256, .slow = 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 = 0x1, - .ivalg = QCRYPTO_IVGEN_ALG_PLAIN, + .ivalg = QCRYPTO_IV_GEN_ALGO_PLAIN, .iv = (const uint8_t *)"\x01\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00", .niv = 16, @@ -47,7 +47,7 @@ struct QCryptoIVGenTestData { { "/crypto/ivgen/plain/1f2e3d4c", .sector = 0x1f2e3d4cULL, - .ivalg = QCRYPTO_IVGEN_ALG_PLAIN, + .ivalg = QCRYPTO_IV_GEN_ALGO_PLAIN, .iv = (const uint8_t *)"\x4c\x3d\x2e\x1f\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00", .niv = 16, @@ -56,7 +56,7 @@ struct QCryptoIVGenTestData { { "/crypto/ivgen/plain/1f2e3d4c5b6a7988", .sector = 0x1f2e3d4c5b6a7988ULL, - .ivalg = QCRYPTO_IVGEN_ALG_PLAIN, + .ivalg = QCRYPTO_IV_GEN_ALGO_PLAIN, .iv = (const uint8_t *)"\x88\x79\x6a\x5b\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00", .niv = 16, @@ -65,7 +65,7 @@ struct QCryptoIVGenTestData { { "/crypto/ivgen/plain64/1", .sector = 0x1, - .ivalg = QCRYPTO_IVGEN_ALG_PLAIN64, + .ivalg = QCRYPTO_IV_GEN_ALGO_PLAIN64, .iv = (const uint8_t *)"\x01\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00", .niv = 16, @@ -74,7 +74,7 @@ struct QCryptoIVGenTestData { { "/crypto/ivgen/plain64/1f2e3d4c", .sector = 0x1f2e3d4cULL, - .ivalg = QCRYPTO_IVGEN_ALG_PLAIN64, + .ivalg = QCRYPTO_IV_GEN_ALGO_PLAIN64, .iv = (const uint8_t *)"\x4c\x3d\x2e\x1f\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00", .niv = 16, @@ -83,7 +83,7 @@ struct QCryptoIVGenTestData { { "/crypto/ivgen/plain64/1f2e3d4c5b6a7988", .sector = 0x1f2e3d4c5b6a7988ULL, - .ivalg = QCRYPTO_IVGEN_ALG_PLAIN64, + .ivalg = QCRYPTO_IV_GEN_ALGO_PLAIN64, .iv = (const uint8_t *)"\x88\x79\x6a\x5b\x4c\x3d\x2e\x1f" "\x00\x00\x00\x00\x00\x00\x00\x00", .niv = 16, @@ -92,7 +92,7 @@ struct QCryptoIVGenTestData { { "/crypto/ivgen/essiv/1", .sector = 0x1, - .ivalg = QCRYPTO_IVGEN_ALG_ESSIV, + .ivalg = QCRYPTO_IV_GEN_ALGO_ESSIV, .cipheralg = QCRYPTO_CIPHER_ALGO_AES_128, .hashalg = QCRYPTO_HASH_ALGO_SHA256, .key = (const uint8_t *)"\x00\x01\x02\x03\x04\x05\x06\x07" @@ -106,7 +106,7 @@ struct QCryptoIVGenTestData { { "/crypto/ivgen/essiv/1f2e3d4c", .sector = 0x1f2e3d4cULL, - .ivalg = QCRYPTO_IVGEN_ALG_ESSIV, + .ivalg = QCRYPTO_IV_GEN_ALGO_ESSIV, .cipheralg = QCRYPTO_CIPHER_ALGO_AES_128, .hashalg = QCRYPTO_HASH_ALGO_SHA256, .key = (const uint8_t *)"\x00\x01\x02\x03\x04\x05\x06\x07" @@ -120,7 +120,7 @@ struct QCryptoIVGenTestData { { "/crypto/ivgen/essiv/1f2e3d4c5b6a7988", .sector = 0x1f2e3d4c5b6a7988ULL, - .ivalg = QCRYPTO_IVGEN_ALG_ESSIV, + .ivalg = QCRYPTO_IV_GEN_ALGO_ESSIV, .cipheralg = QCRYPTO_CIPHER_ALGO_AES_128, .hashalg = QCRYPTO_HASH_ALGO_SHA256, .key = (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 = 0; i < G_N_ELEMENTS(test_data); i++) { - if (test_data[i].ivalg == QCRYPTO_IVGEN_ALG_ESSIV && + if (test_data[i].ivalg == QCRYPTO_IV_GEN_ALGO_ESSIV && !qcrypto_hash_supports(test_data[i].hashalg)) { continue; } From patchwork Wed Sep 4 11:18:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Markus Armbruster X-Patchwork-Id: 13790615 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 1C3EDCA0ED3 for ; Wed, 4 Sep 2024 11:26:50 +0000 (UTC) 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 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= 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 X-MC-Unique: OsK3oRsuOyiaiP7MSTnNqw-1 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) 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 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org 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é --- 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']} ## @@ -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; 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(CryptoDevBackend *backend) { QCryptoAkCipherOptions opts; - opts.alg = QCRYPTO_AKCIPHER_ALG_RSA; + opts.alg = QCRYPTO_AK_CIPHER_ALGO_RSA; opts.u.rsa.padding_alg = QCRYPTO_RSA_PADDING_ALG_RAW; if (qcrypto_akcipher_supports(&opts)) { backend->conf.crypto_services |= @@ -318,7 +318,7 @@ static int cryptodev_builtin_create_akcipher_session( switch (sess_info->algo) { case VIRTIO_CRYPTO_AKCIPHER_RSA: - opts.alg = QCRYPTO_AKCIPHER_ALG_RSA; + opts.alg = QCRYPTO_AK_CIPHER_ALGO_RSA; if (cryptodev_builtin_set_rsa_options(sess_info->u.rsa.padding_algo, sess_info->u.rsa.hash_algo, &opts.u.rsa, errp) != 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(QCryptoAkCipherOptions *opts, Error **errp) { QCryptoAkCipherOptionsRSA *rsa_opt; - if (opts->alg != QCRYPTO_AKCIPHER_ALG_RSA) { + if (opts->alg != 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( switch (sess_info->algo) { case VIRTIO_CRYPTO_AKCIPHER_RSA: - sess->akcipher_opts.alg = QCRYPTO_AKCIPHER_ALG_RSA; + sess->akcipher_opts.alg = 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) != 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 QCryptoAkCipherOptions *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; diff --git a/tests/bench/benchmark-crypto-akcipher.c b/tests/bench/benchmark-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; - opt.alg = QCRYPTO_AKCIPHER_ALG_RSA; + opt.alg = QCRYPTO_AK_CIPHER_ALGO_RSA; opt.u.rsa.padding_alg = padding; opt.u.rsa.hash_alg = 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-akcipher.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[] = { { .path = "/crypto/akcipher/rsa1024-raw", .opt = { - .alg = QCRYPTO_AKCIPHER_ALG_RSA, + .alg = QCRYPTO_AK_CIPHER_ALGO_RSA, .u.rsa = { .padding_alg = QCRYPTO_RSA_PADDING_ALG_RAW, }, @@ -805,7 +805,7 @@ static QCryptoAkCipherTestData akcipher_test_data[] = { { .path = "/crypto/akcipher/rsa1024-pkcs1", .opt = { - .alg = QCRYPTO_AKCIPHER_ALG_RSA, + .alg = QCRYPTO_AK_CIPHER_ALGO_RSA, .u.rsa = { .padding_alg = QCRYPTO_RSA_PADDING_ALG_PKCS1, .hash_alg = QCRYPTO_HASH_ALGO_SHA1, @@ -830,7 +830,7 @@ static QCryptoAkCipherTestData akcipher_test_data[] = { { .path = "/crypto/akcipher/rsa2048-raw", .opt = { - .alg = QCRYPTO_AKCIPHER_ALG_RSA, + .alg = QCRYPTO_AK_CIPHER_ALGO_RSA, .u.rsa = { .padding_alg = QCRYPTO_RSA_PADDING_ALG_RAW, }, @@ -850,7 +850,7 @@ static QCryptoAkCipherTestData akcipher_test_data[] = { { .path = "/crypto/akcipher/rsa2048-pkcs1", .opt = { - .alg = QCRYPTO_AKCIPHER_ALG_RSA, + .alg = QCRYPTO_AK_CIPHER_ALGO_RSA, .u.rsa = { .padding_alg = QCRYPTO_RSA_PADDING_ALG_PKCS1, .hash_alg = QCRYPTO_HASH_ALGO_SHA1, @@ -944,7 +944,7 @@ static void test_rsakey(const void *opaque) { const QCryptoRSAKeyTestData *data = (const QCryptoRSAKeyTestData *)opaque; QCryptoAkCipherOptions opt = { - .alg = QCRYPTO_AKCIPHER_ALG_RSA, + .alg = QCRYPTO_AK_CIPHER_ALGO_RSA, .u.rsa = { .padding_alg = QCRYPTO_RSA_PADDING_ALG_PKCS1, .hash_alg = 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 QCryptoAkCipherOptions *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); @@ -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 QCryptoAkCipherOptions *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, errp); 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) { From patchwork Wed Sep 4 11:18:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Markus Armbruster X-Patchwork-Id: 13790619 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id BF531CD3431 for ; Wed, 4 Sep 2024 11:28:19 +0000 (UTC) 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 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= 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 X-MC-Unique: EQ1bwIKsP2y4bb1iuwKx4A-1 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) 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 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.15 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org 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é --- 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']} ## -# @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']} ## @@ -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'}} ## # @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(CryptoDevBackend *backend) QCryptoAkCipherOptions opts; opts.alg = QCRYPTO_AK_CIPHER_ALGO_RSA; - opts.u.rsa.padding_alg = QCRYPTO_RSA_PADDING_ALG_RAW; + opts.u.rsa.padding_alg = QCRYPTO_RSA_PADDING_ALGO_RAW; if (qcrypto_akcipher_supports(&opts)) { backend->conf.crypto_services |= (1u << QCRYPTODEV_BACKEND_SERVICE_AKCIPHER); @@ -200,12 +200,12 @@ static int cryptodev_builtin_set_rsa_options( return -1; } opt->hash_alg = hash_alg; - opt->padding_alg = QCRYPTO_RSA_PADDING_ALG_PKCS1; + opt->padding_alg = QCRYPTO_RSA_PADDING_ALGO_PKCS1; return 0; } if (virtio_padding_algo == VIRTIO_CRYPTO_RSA_RAW_PADDING) { - opt->padding_alg = QCRYPTO_RSA_PADDING_ALG_RAW; + opt->padding_alg = QCRYPTO_RSA_PADDING_ALGO_RAW; return 0; } 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(QCryptoAkCipherOptions *opts, } rsa_opt = &opts->u.rsa; - if (rsa_opt->padding_alg == QCRYPTO_RSA_PADDING_ALG_PKCS1) { + if (rsa_opt->padding_alg == QCRYPTO_RSA_PADDING_ALGO_PKCS1) { snprintf(key_desc, desc_len, "enc=%s hash=%s", - QCryptoRSAPaddingAlgorithm_str(rsa_opt->padding_alg), + QCryptoRSAPaddingAlgo_str(rsa_opt->padding_alg), QCryptoHashAlgo_str(rsa_opt->hash_alg)); } else { snprintf(key_desc, desc_len, "enc=%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_padding_alg, Error **errp) { if (virtio_padding_alg == VIRTIO_CRYPTO_RSA_PKCS1_PADDING) { - opt->padding_alg = QCRYPTO_RSA_PADDING_ALG_PKCS1; + opt->padding_alg = QCRYPTO_RSA_PADDING_ALGO_PKCS1; switch (virtio_hash_alg) { case VIRTIO_CRYPTO_RSA_MD5: @@ -184,7 +184,7 @@ static int cryptodev_lkcf_set_rsa_opt(int virtio_padding_alg, } if (virtio_padding_alg == VIRTIO_CRYPTO_RSA_RAW_PADDING) { - opt->padding_alg = QCRYPTO_RSA_PADDING_ALG_RAW; + opt->padding_alg = QCRYPTO_RSA_PADDING_ALGO_RAW; return 0; } diff --git a/tests/bench/benchmark-crypto-akcipher.c b/tests/bench/benchmark-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 @@ static QCryptoAkCipher *create_rsa_akcipher(const uint8_t *priv_key, size_t keylen, - QCryptoRSAPaddingAlgorithm padding, + 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 g_autoptr(QCryptoAkCipher) rsa = @@ -53,7 +53,7 @@ static void test_rsa_speed(const uint8_t *priv_key, size_t keylen, signature = g_new0(uint8_t, key_size / BYTE); 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 = 0; count < SIGN_TIMES; ++count) { @@ -64,13 +64,13 @@ static void test_rsa_speed(const uint8_t *priv_key, size_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()); 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 = 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-akcipher.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[] = { .opt = { .alg = QCRYPTO_AK_CIPHER_ALGO_RSA, .u.rsa = { - .padding_alg = QCRYPTO_RSA_PADDING_ALG_RAW, + .padding_alg = QCRYPTO_RSA_PADDING_ALGO_RAW, }, }, .pub_key = rsa1024_public_key, @@ -807,7 +807,7 @@ static QCryptoAkCipherTestData akcipher_test_data[] = { .opt = { .alg = QCRYPTO_AK_CIPHER_ALGO_RSA, .u.rsa = { - .padding_alg = QCRYPTO_RSA_PADDING_ALG_PKCS1, + .padding_alg = QCRYPTO_RSA_PADDING_ALGO_PKCS1, .hash_alg = QCRYPTO_HASH_ALGO_SHA1, }, }, @@ -832,7 +832,7 @@ static QCryptoAkCipherTestData akcipher_test_data[] = { .opt = { .alg = QCRYPTO_AK_CIPHER_ALGO_RSA, .u.rsa = { - .padding_alg = QCRYPTO_RSA_PADDING_ALG_RAW, + .padding_alg = QCRYPTO_RSA_PADDING_ALGO_RAW, }, }, .pub_key = rsa2048_public_key, @@ -852,7 +852,7 @@ static QCryptoAkCipherTestData akcipher_test_data[] = { .opt = { .alg = QCRYPTO_AK_CIPHER_ALGO_RSA, .u.rsa = { - .padding_alg = QCRYPTO_RSA_PADDING_ALG_PKCS1, + .padding_alg = QCRYPTO_RSA_PADDING_ALGO_PKCS1, .hash_alg = QCRYPTO_HASH_ALGO_SHA1, }, }, @@ -946,7 +946,7 @@ static void test_rsakey(const void *opaque) QCryptoAkCipherOptions opt = { .alg = QCRYPTO_AK_CIPHER_ALGO_RSA, .u.rsa = { - .padding_alg = QCRYPTO_RSA_PADDING_ALG_PKCS1, + .padding_alg = QCRYPTO_RSA_PADDING_ALGO_PKCS1, .hash_alg = 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; @@ -241,7 +241,7 @@ static int qcrypto_gcrypt_rsa_encrypt(QCryptoAkCipher *akcipher, err = 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) != 0) { error_setg(errp, "Failed to build plaintext: %s/%s", @@ -263,7 +263,7 @@ static int qcrypto_gcrypt_rsa_encrypt(QCryptoAkCipher *akcipher, goto cleanup; } - if (rsa->padding_alg == QCRYPTO_RSA_PADDING_ALG_RAW) { + if (rsa->padding_alg == QCRYPTO_RSA_PADDING_ALGO_RAW) { cipher_mpi = 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, err = 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) != 0) { error_setg(errp, "Failed to build ciphertext: %s/%s", @@ -348,7 +348,7 @@ static int qcrypto_gcrypt_rsa_decrypt(QCryptoAkCipher *akcipher, } /* S-expression of plaintext: (value plaintext) */ - if (rsa->padding_alg == QCRYPTO_RSA_PADDING_ALG_RAW) { + if (rsa->padding_alg == QCRYPTO_RSA_PADDING_ALGO_RAW) { data_mpi = 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 *akcipher, return ret; } - if (rsa->padding_alg != QCRYPTO_RSA_PADDING_ALG_PKCS1) { + if (rsa->padding_alg != 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 *akcipher, return ret; } - if (rsa->padding_alg != QCRYPTO_RSA_PADDING_ALG_PKCS1) { + if (rsa->padding_alg != 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; - 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; @@ -184,11 +184,11 @@ static int qcrypto_nettle_rsa_encrypt(QCryptoAkCipher *akcipher, /* 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; - 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) != 1) { @@ -223,11 +223,11 @@ static int qcrypto_nettle_rsa_decrypt(QCryptoAkCipher *akcipher, } 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; - 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 *akcipher, * The RSA algorithm cannot be used for signature/verification * without padding. */ - if (rsa->padding_alg == QCRYPTO_RSA_PADDING_ALG_RAW) { + if (rsa->padding_alg == 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 *akcipher, * The RSA algorithm cannot be used for signature/verification * without padding. */ - if (rsa->padding_alg == QCRYPTO_RSA_PADDING_ALG_RAW) { + if (rsa->padding_alg == 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; } - case QCRYPTO_RSA_PADDING_ALG_RAW: + case QCRYPTO_RSA_PADDING_ALGO_RAW: default: return false; } From patchwork Wed Sep 4 11:18:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Markus Armbruster X-Patchwork-Id: 13790603 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 9A7B5CD3431 for ; Wed, 4 Sep 2024 11:26:01 +0000 (UTC) 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 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= 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 X-MC-Unique: RA6P3sr1OiqPVB6mMsX1Cw-1 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) 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 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org For consistency with other types names *Algo. Signed-off-by: Markus Armbruster Acked-by: Daniel P. Berrangé --- 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)) -typedef struct QCryptoAFAlg QCryptoAFAlg; +typedef struct QCryptoAFAlgo QCryptoAFAlgo; -struct QCryptoAFAlg { +struct QCryptoAFAlgo { QCryptoCipher base; 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); /** * 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); #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; #include "afalgpriv.h" -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; } -QCryptoAFAlg * +QCryptoAFAlgo * qcrypto_afalg_comm_alloc(const char *type, const char *name, Error **errp) { - QCryptoAFAlg *afalg; + QCryptoAFAlgo *afalg; - afalg = g_new0(QCryptoAFAlg, 1); + afalg = g_new0(QCryptoAFAlgo, 1); /* initialize crypto API socket */ afalg->opfd = -1; afalg->tfmfd = qcrypto_afalg_socket_bind(type, name, errp); @@ -93,7 +93,7 @@ error: return NULL; } -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; @@ -119,7 +119,7 @@ qcrypto_afalg_cipher_setiv(QCryptoCipher *cipher, const uint8_t *iv, size_t niv, Error **errp) { - QCryptoAFAlg *afalg = container_of(cipher, QCryptoAFAlg, base); + QCryptoAFAlgo *afalg = container_of(cipher, QCryptoAFAlgo, base); struct af_alg_iv *alg_iv; size_t expect_niv; @@ -143,7 +143,7 @@ qcrypto_afalg_cipher_setiv(QCryptoCipher *cipher, } 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 = container_of(cipher, QCryptoAFAlg, base); + QCryptoAFAlgo *afalg = container_of(cipher, QCryptoAFAlgo, base); 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 = container_of(cipher, QCryptoAFAlg, base); + QCryptoAFAlgo *afalg = container_of(cipher, QCryptoAFAlgo, base); return qcrypto_afalg_cipher_op(afalg, in, out, len, false, errp); } static void qcrypto_afalg_comm_ctx_free(QCryptoCipher *cipher) { - QCryptoAFAlg *afalg = container_of(cipher, QCryptoAFAlg, base); + QCryptoAFAlgo *afalg = container_of(cipher, QCryptoAFAlgo, base); 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; } -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; name = qcrypto_afalg_hash_format_name(alg, is_hmac, errp); @@ -98,14 +98,14 @@ qcrypto_afalg_hash_hmac_ctx_new(QCryptoHashAlgo alg, return afalg; } -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); } -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, } 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 = 0; bool is_hmac = (hmac != NULL) ? true : false; @@ -197,7 +197,7 @@ qcrypto_afalg_hmac_bytesv(QCryptoHmac *hmac, static void qcrypto_afalg_hmac_ctx_free(QCryptoHmac *hmac) { - QCryptoAFAlg *afalg; + QCryptoAFAlgo *afalg; afalg = hmac->opaque; qcrypto_afalg_comm_free(afalg); From patchwork Wed Sep 4 11:18:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Markus Armbruster X-Patchwork-Id: 13790623 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D3E9FCA0ED3 for ; Wed, 4 Sep 2024 11:29:25 +0000 (UTC) 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 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= 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 X-MC-Unique: vgWluKH0OjuyiNqi3QfSzw-1 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) 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 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.15 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org 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é --- 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']} ## 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(CryptoDevBackend *backend) opts.u.rsa.padding_alg = QCRYPTO_RSA_PADDING_ALGO_RAW; if (qcrypto_akcipher_supports(&opts)) { backend->conf.crypto_services |= - (1u << QCRYPTODEV_BACKEND_SERVICE_AKCIPHER); + (1u << QCRYPTODEV_BACKEND_SERVICE_TYPE_AKCIPHER); backend->conf.akcipher_algo = 1u << VIRTIO_CRYPTO_AKCIPHER_RSA; } } @@ -93,9 +93,9 @@ static void cryptodev_builtin_init( backend->conf.peers.ccs[0] = cc; backend->conf.crypto_services = - 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 = 1u << VIRTIO_CRYPTO_CIPHER_AES_CBC; backend->conf.hash_algo = 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 *backend, Error **errp) backend->conf.peers.ccs[0] = cc; backend->conf.crypto_services = - 1u << QCRYPTODEV_BACKEND_SERVICE_AKCIPHER; + 1u << QCRYPTODEV_BACKEND_SERVICE_TYPE_AKCIPHER; backend->conf.akcipher_algo = 1u << VIRTIO_CRYPTO_AKCIPHER_RSA; lkcf->running = true; diff --git a/backends/cryptodev-vhost-user.c b/backends/cryptodev-vhost-user.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); backend->conf.crypto_services = - 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 = 1u << VIRTIO_CRYPTO_CIPHER_AES_CBC; backend->conf.hash_algo = 1u << VIRTIO_CRYPTO_HASH_SHA1; 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) backend = CRYPTODEV_BACKEND(obj); services = backend->conf.crypto_services; - for (i = 0; i < QCRYPTODEV_BACKEND_SERVICE__MAX; i++) { + for (i = 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) } services = backend->conf.crypto_services; - if (services & (1 << QCRYPTODEV_BACKEND_SERVICE_CIPHER)) { + if (services & (1 << QCRYPTODEV_BACKEND_SERVICE_TYPE_CIPHER)) { backend->sym_stat = g_new0(CryptodevBackendSymStat, 1); } - if (services & (1 << QCRYPTODEV_BACKEND_SERVICE_AKCIPHER)) { + if (services & (1 << QCRYPTODEV_BACKEND_SERVICE_TYPE_AKCIPHER)) { backend->asym_stat = 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 = 0; - if (qservices & (1 << QCRYPTODEV_BACKEND_SERVICE_CIPHER)) { + if (qservices & (1 << QCRYPTODEV_BACKEND_SERVICE_TYPE_CIPHER)) { vservices |= (1 << VIRTIO_CRYPTO_SERVICE_CIPHER); } - if (qservices & (1 << QCRYPTODEV_BACKEND_SERVICE_HASH)) { + if (qservices & (1 << QCRYPTODEV_BACKEND_SERVICE_TYPE_HASH)) { vservices |= (1 << VIRTIO_CRYPTO_SERVICE_HASH); } - if (qservices & (1 << QCRYPTODEV_BACKEND_SERVICE_MAC)) { + if (qservices & (1 << QCRYPTODEV_BACKEND_SERVICE_TYPE_MAC)) { vservices |= (1 << VIRTIO_CRYPTO_SERVICE_MAC); } - if (qservices & (1 << QCRYPTODEV_BACKEND_SERVICE_AEAD)) { + if (qservices & (1 << QCRYPTODEV_BACKEND_SERVICE_TYPE_AEAD)) { vservices |= (1 << VIRTIO_CRYPTO_SERVICE_AEAD); } - if (qservices & (1 << QCRYPTODEV_BACKEND_SERVICE_AKCIPHER)) { + if (qservices & (1 << QCRYPTODEV_BACKEND_SERVICE_TYPE_AKCIPHER)) { vservices |= (1 << VIRTIO_CRYPTO_SERVICE_AKCIPHER); } From patchwork Wed Sep 4 11:18:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Markus Armbruster X-Patchwork-Id: 13790616 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 3F8DCCA0ED3 for ; Wed, 4 Sep 2024 11:27:19 +0000 (UTC) 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 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= 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 X-MC-Unique: 52aQONzDMiaKr8BhmtZk7g-1 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) 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 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.15 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org 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é --- 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 @@ ## ## -# @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']} ## 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); 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 = op_info->algtype; + QCryptodevBackendAlgoType algtype = op_info->algtype; int status = -VIRTIO_CRYPTO_ERR; Error *local_error = NULL; @@ -561,11 +561,11 @@ static int cryptodev_builtin_operation( } sess = builtin->sessions[op_info->session_id]; - if (algtype == QCRYPTODEV_BACKEND_ALG_SYM) { + if (algtype == QCRYPTODEV_BACKEND_ALGO_TYPE_SYM) { sym_op_info = op_info->u.sym_op_info; status = cryptodev_builtin_sym_operation(sess, sym_op_info, &local_error); - } else if (algtype == QCRYPTODEV_BACKEND_ALG_ASYM) { + } else if (algtype == QCRYPTODEV_BACKEND_ALGO_TYPE_ASYM) { asym_op_info = op_info->u.asym_op_info; status = cryptodev_builtin_asym_operation(sess, op_info->op_code, asym_op_info, &local_error); 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 = CRYPTODEV_BACKEND_LKCF(backend); CryptoDevBackendLKCFSession *sess; - QCryptodevBackendAlgType algtype = op_info->algtype; + QCryptodevBackendAlgoType algtype = op_info->algtype; CryptoDevLKCFTask *task; if (op_info->session_id >= MAX_SESSIONS || @@ -485,7 +485,7 @@ static int cryptodev_lkcf_operation( } sess = lkcf->sess[op_info->session_id]; - if (algtype != QCRYPTODEV_BACKEND_ALG_ASYM) { + if (algtype != 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 = op_info->algtype; + enum QCryptodevBackendAlgoType algtype = op_info->algtype; int len; - if (algtype == QCRYPTODEV_BACKEND_ALG_ASYM) { + if (algtype == QCRYPTODEV_BACKEND_ALGO_TYPE_ASYM) { CryptoDevBackendAsymOpInfo *asym_op_info = op_info->u.asym_op_info; len = asym_op_info->src_len; @@ -212,7 +212,7 @@ static int cryptodev_backend_account(CryptoDevBackend *backend, default: return -VIRTIO_CRYPTO_NOTSUPP; } - } else if (algtype == QCRYPTODEV_BACKEND_ALG_SYM) { + } else if (algtype == QCRYPTODEV_BACKEND_ALGO_TYPE_SYM) { CryptoDevBackendSymOpInfo *sym_op_info = op_info->u.sym_op_info; len = sym_op_info->src_len; 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 *vcrypto, VirtQueue *vq, req->in_iov = NULL; req->in_num = 0; req->in_len = 0; - req->flags = QCRYPTODEV_BACKEND_ALG__MAX; + req->flags = QCRYPTODEV_BACKEND_ALGO_TYPE__MAX; memset(&req->op_info, 0x00, sizeof(req->op_info)); } @@ -471,7 +471,7 @@ static void virtio_crypto_free_request(VirtIOCryptoReq *req) return; } - if (req->flags == QCRYPTODEV_BACKEND_ALG_SYM) { + if (req->flags == QCRYPTODEV_BACKEND_ALGO_TYPE_SYM) { size_t max_len; CryptoDevBackendSymOpInfo *op_info = req->op_info.u.sym_op_info; @@ -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 == QCRYPTODEV_BACKEND_ALG_ASYM) { + } else if (req->flags == QCRYPTODEV_BACKEND_ALGO_TYPE_ASYM) { CryptoDevBackendAsymOpInfo *op_info = req->op_info.u.asym_op_info; if (op_info) { g_free(op_info->src); @@ -571,10 +571,10 @@ static void virtio_crypto_req_complete(void *opaque, int ret) VirtIODevice *vdev = VIRTIO_DEVICE(vcrypto); uint8_t status = -ret; - if (req->flags == QCRYPTODEV_BACKEND_ALG_SYM) { + if (req->flags == 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 == QCRYPTODEV_BACKEND_ALG_ASYM) { + } else if (req->flags == 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 = request->flags = QCRYPTODEV_BACKEND_ALG_SYM; + op_info->algtype = request->flags = QCRYPTODEV_BACKEND_ALGO_TYPE_SYM; ret = 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 = request->flags = QCRYPTODEV_BACKEND_ALG_ASYM; + op_info->algtype = request->flags = QCRYPTODEV_BACKEND_ALGO_TYPE_ASYM; ret = virtio_crypto_handle_asym_req(vcrypto, &req.u.akcipher_req, op_info, out_iov, out_num); From patchwork Wed Sep 4 11:18:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Markus Armbruster X-Patchwork-Id: 13790601 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 0A6F1CA0ED3 for ; Wed, 4 Sep 2024 11:25:57 +0000 (UTC) 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 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= 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 X-MC-Unique: UFBGwjXIN7CxdUb05skooA-1 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) 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-type: text/plain X-Scanned-By: MIMEDefang 3.0 on 10.30.177.40 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org 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 Reviewed-by: Cédric Le Goater --- 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 @@ ## ## -# @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' ] } ## # @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) } } -static VfioMigrationState +static QapiVfioMigrationState mig_state_to_qapi_state(enum vfio_device_mig_state state) { switch (state) {