From nobody Sun Nov 24 05:28:16 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1725986877; cv=none; d=zohomail.com; s=zohoarc; b=VWaiAETteZorI6VKigU0iOTBXLHi2YS5FfRPy7P2UGQtlSrccHW4N//dRNeVcQ1UiidGzVyN0XOnHzV0awLkHY9k7N45mpx7JwIOmsGU5pXodmN4/h3RpIGD9BuEKCeHellLTB1hqSqTPeU9P/ZU6HOXl5Y6oT3VEKL4c0PcSh0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1725986877; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=vKlkknEoreIVA3SKab42/gGdIdfzvM7boKioIE7gm2Y=; b=a1GV+tWFD164IdJSnikeSgrtji4PIRca0Em0M+guQUHugSZasoDIHyI6g1BmiFTAMOaGH1X5P+gqkxSTd+/vmCKKw83FRkCYtgNFl1tL0j47yjdzWS9/W4IsYKz1ghBiMNqHObtrAAzRgw0xlCPUcR8gkXStnbadNfqpAnUJCD0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1725986877036321.10107337425063; Tue, 10 Sep 2024 09:47:57 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1so41g-0006qL-OG; Tue, 10 Sep 2024 12:47:38 -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 1so41V-0006jg-IL for qemu-devel@nongnu.org; Tue, 10 Sep 2024 12:47:27 -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 1so41T-0007YB-1n for qemu-devel@nongnu.org; Tue, 10 Sep 2024 12:47:25 -0400 Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-417-8bsLZAquN7Oo0vYI54HIeA-1; Tue, 10 Sep 2024 12:47:18 -0400 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 408921955D56; Tue, 10 Sep 2024 16:47:17 +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 9B8131956052; Tue, 10 Sep 2024 16:47:16 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 7593821E691E; Tue, 10 Sep 2024 18:47:14 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1725986839; 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=vKlkknEoreIVA3SKab42/gGdIdfzvM7boKioIE7gm2Y=; b=dk24RV1EESXK5Vso0NUHnNAxJx6x3GtLogQcu5Ubg2KETVRfBy/ULAE/RrwfpP/3uow17j eFoEme73kkJ/YUWYehOk0X1/sZ2fJ5oI7spnMH36YyTNQ4rrpDQEJxko14wANdzmu0axC8 gkJU7x6TlC4SiDxRoVyOIvrYp3mQJ30= X-MC-Unique: 8bsLZAquN7Oo0vYI54HIeA-1 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org, =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= Subject: [PULL 01/19] qapi: Smarter camel_to_upper() to reduce need for 'prefix' Date: Tue, 10 Sep 2024 18:46:56 +0200 Message-ID: <20240910164714.1993531-2-armbru@redhat.com> In-Reply-To: <20240910164714.1993531-1-armbru@redhat.com> References: <20240910164714.1993531-1-armbru@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.145, 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, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1725986877746116600 camel_to_upper() converts its argument from camel case to upper case with '_' between words. Used for generated enumeration constant prefixes. When some of the words are spelled all caps, where exactly to insert '_' is guesswork. camel_to_upper()'s guesses are bad enough in places to make people override them with a 'prefix' in the schema. Rewrite it to guess better: 1. Insert '_' after a non-upper case character followed by an upper case character: OneTwo -> ONE_TWO One2Three -> ONE2_THREE 2. Insert '_' before the last upper case character followed by a non-upper case character: ACRONYMWord -> ACRONYM_Word Except at the beginning (as in OneTwo above), or when there is already one: AbCd -> AB_CD This changes the default enumeration constant prefix for a number of enums. Generated enumeration constants change only where the default is not overridden with 'prefix'. The following enumerations without a 'prefix' change: enum old camel_to_upper() new camel_to_upper() ------------------------------------------------------------------ DisplayGLMode DISPLAYGL_MODE DISPLAY_GL_MODE EbpfProgramID EBPF_PROGRAMID EBPF_PROGRAM_ID HmatLBDataType HMATLB_DATA_TYPE HMAT_LB_DATA_TYPE HmatLBMemoryHierarchy HMATLB_MEMORY_HIERARCHY HMAT_LB_MEMORY_HIERARCHY MultiFDCompression MULTIFD_COMPRESSION MULTI_FD_COMPRESSION OffAutoPCIBAR OFF_AUTOPCIBAR OFF_AUTO_PCIBAR QCryptoBlockFormat Q_CRYPTO_BLOCK_FORMAT QCRYPTO_BLOCK_FORMAT QCryptoBlockLUKSKeyslotState Q_CRYPTO_BLOCKLUKS_KEYSLOT_STATE QCRYPTO_BLOCK_LUKS_KEYSLOT_STATE QKeyCode Q_KEY_CODE QKEY_CODE XDbgBlockGraphNodeType X_DBG_BLOCK_GRAPH_NODE_TYPE XDBG_BLOCK_GRAPH_NODE_TYPE TestUnionEnumA TEST_UNION_ENUMA TEST_UNION_ENUM_A Add a 'prefix' so generated code doesn't change now. Subsequent commits will remove most of them again. Two will remain: MULTIFD_COMPRESSION, because migration code generally spells "multifd" that way, and Q_KEY_CODE, because that one is baked into subprojects/keycodemapdb/tools/keymap-gen. The following enumerations with a 'prefix' change so that the prefix is now superfluous: enum old camel_to_upper() new camel_to_upper() [equal to prefix] ------------------------------------------------------------------ BlkdebugIOType BLKDEBUGIO_TYPE BLKDEBUG_IO_TYPE QCryptoTLSCredsEndpoint Q_CRYPTOTLS_CREDS_ENDPOINT QCRYPTO_TLS_CREDS_ENDPOINT QCryptoSecretFormat Q_CRYPTO_SECRET_FORMAT QCRYPTO_SECRET_FORMAT QCryptoCipherMode Q_CRYPTO_CIPHER_MODE QCRYPTO_CIPHER_MODE QCryptodevBackendType Q_CRYPTODEV_BACKEND_TYPE QCRYPTODEV_BACKEND_TYPE QType [builtin] Q_TYPE QTYPE Drop these prefixes. The following enumerations with a 'prefix' change without making the 'prefix' superfluous: enum old camel_to_upper() new camel_to_upper() [equal to prefix] prefix ------------------------------------------------------------------ CpuS390Entitlement CPUS390_ENTITLEMENT CPU_S390_ENTITLEMENT S390_CPU_ENTITLEMENT CpuS390Polarization CPUS390_POLARIZATION CPU_S390_POLARIZATION S390_CPU_POLARIZATION CpuS390State CPUS390_STATE CPU_S390_STATE S390_CPU_STATE QAuthZListFormat Q_AUTHZ_LIST_FORMAT QAUTH_Z_LIST_FORMAT QAUTHZ_LIST_FORMAT QAuthZListPolicy Q_AUTHZ_LIST_POLICY QAUTH_Z_LIST_POLICY QAUTHZ_LIST_POLICY QCryptoAkCipherAlgorithm Q_CRYPTO_AK_CIPHER_ALGORITHM QCRYPTO_AK_CIPHER_ALGORITHM QCRYPTO_AKCIPHER_ALG QCryptoAkCipherKeyType Q_CRYPTO_AK_CIPHER_KEY_TYPE QCRYPTO_AK_CIPHER_KEY_TYPE QCRYPTO_AKCIPHER_KEY_TYPE QCryptoCipherAlgorithm Q_CRYPTO_CIPHER_ALGORITHM QCRYPTO_CIPHER_ALGORITHM QCRYPTO_CIPHER_ALG QCryptoHashAlgorithm Q_CRYPTO_HASH_ALGORITHM QCRYPTO_HASH_ALGORITHM QCRYPTO_HASH_ALG QCryptoIVGenAlgorithm Q_CRYPTOIV_GEN_ALGORITHM QCRYPTO_IV_GEN_ALGORITHM QCRYPTO_IVGEN_ALG QCryptoRSAPaddingAlgorithm Q_CRYPTORSA_PADDING_ALGORITHM QCRYPTO_RSA_PADDING_ALGORITHM QCRYPTO_RSA_PADDING_ALG QCryptodevBackendAlgType Q_CRYPTODEV_BACKEND_ALG_TYPE QCRYPTODEV_BACKEND_ALG_TYPE QCRYPTODEV_BACKEND_ALG QCryptodevBackendServiceType Q_CRYPTODEV_BACKEND_SERVICE_TYPE QCRYPTODEV_BACKEND_SERVICE_TYPE QCRYPTODEV_BACKEND_SERVICE Subsequent commits will tweak things to remove most of these prefixes. Only QAUTHZ_LIST_FORMAT and QAUTHZ_LIST_POLICY will remain. Signed-off-by: Markus Armbruster Reviewed-by: Daniel P. Berrang=C3=A9 Message-ID: <20240904111836.3273842-2-armbru@redhat.com> --- qapi/block-core.json | 3 +- qapi/common.json | 1 + qapi/crypto.json | 6 ++-- qapi/cryptodev.json | 1 - qapi/ebpf.json | 1 + qapi/machine.json | 2 ++ qapi/migration.json | 1 + qapi/ui.json | 2 ++ scripts/qapi/common.py | 42 ++++++++++++++---------- scripts/qapi/schema.py | 2 +- tests/qapi-schema/alternate-array.out | 1 - tests/qapi-schema/comments.out | 1 - tests/qapi-schema/doc-good.out | 1 - tests/qapi-schema/empty.out | 1 - tests/qapi-schema/include-repetition.out | 1 - tests/qapi-schema/include-simple.out | 1 - tests/qapi-schema/indented-expr.out | 1 - tests/qapi-schema/qapi-schema-test.json | 1 + tests/qapi-schema/qapi-schema-test.out | 2 +- 19 files changed, 38 insertions(+), 33 deletions(-) diff --git a/qapi/block-core.json b/qapi/block-core.json index aa40d44f1d..452047102a 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -2011,6 +2011,7 @@ # Since: 4.0 ## { 'enum': 'XDbgBlockGraphNodeType', + 'prefix': 'X_DBG_BLOCK_GRAPH_NODE_TYPE', # TODO drop 'data': [ 'block-backend', 'block-job', 'block-driver' ] } =20 ## @@ -3746,7 +3747,7 @@ # # Since: 4.1 ## -{ 'enum': 'BlkdebugIOType', 'prefix': 'BLKDEBUG_IO_TYPE', +{ 'enum': 'BlkdebugIOType', 'data': [ 'read', 'write', 'write-zeroes', 'discard', 'flush', 'block-status' ] } =20 diff --git a/qapi/common.json b/qapi/common.json index 7558ce5430..25726d3113 100644 --- a/qapi/common.json +++ b/qapi/common.json @@ -92,6 +92,7 @@ # Since: 2.12 ## { 'enum': 'OffAutoPCIBAR', + 'prefix': 'OFF_AUTOPCIBAR', # TODO drop 'data': [ 'off', 'auto', 'bar0', 'bar1', 'bar2', 'bar3', 'bar4', 'bar5' = ] } =20 ## diff --git a/qapi/crypto.json b/qapi/crypto.json index 97e02dbd59..a192641a03 100644 --- a/qapi/crypto.json +++ b/qapi/crypto.json @@ -20,7 +20,6 @@ # Since: 2.5 ## { 'enum': 'QCryptoTLSCredsEndpoint', - 'prefix': 'QCRYPTO_TLS_CREDS_ENDPOINT', 'data': ['client', 'server']} =20 ## @@ -36,7 +35,6 @@ # Since: 2.6 ## { 'enum': 'QCryptoSecretFormat', - 'prefix': 'QCRYPTO_SECRET_FORMAT', 'data': ['raw', 'base64']} =20 ## @@ -123,7 +121,6 @@ # Since: 2.6 ## { 'enum': 'QCryptoCipherMode', - 'prefix': 'QCRYPTO_CIPHER_MODE', 'data': ['ecb', 'cbc', 'xts', 'ctr']} =20 ## @@ -160,7 +157,7 @@ # Since: 2.6 ## { 'enum': 'QCryptoBlockFormat', -# 'prefix': 'QCRYPTO_BLOCK_FORMAT', + 'prefix': 'Q_CRYPTO_BLOCK_FORMAT', # TODO drop 'data': ['qcow', 'luks']} =20 ## @@ -363,6 +360,7 @@ # Since: 5.1 ## { 'enum': 'QCryptoBlockLUKSKeyslotState', + 'prefix': 'Q_CRYPTO_BLOCKLUKS_KEYSLOT_STATE', # TODO drop 'data': [ 'active', 'inactive' ] } =20 ## diff --git a/qapi/cryptodev.json b/qapi/cryptodev.json index 68289f4984..60f8fe8e4a 100644 --- a/qapi/cryptodev.json +++ b/qapi/cryptodev.json @@ -48,7 +48,6 @@ # Since: 8.0 ## { 'enum': 'QCryptodevBackendType', - 'prefix': 'QCRYPTODEV_BACKEND_TYPE', 'data': ['builtin', 'vhost-user', 'lkcf']} =20 ## diff --git a/qapi/ebpf.json b/qapi/ebpf.json index db19ae850f..42df548777 100644 --- a/qapi/ebpf.json +++ b/qapi/ebpf.json @@ -42,6 +42,7 @@ # Since: 9.0 ## { 'enum': 'EbpfProgramID', + 'prefix': 'EBPF_PROGRAMID', # TODO drop 'if': 'CONFIG_EBPF', 'data': [ { 'name': 'rss' } ] } =20 diff --git a/qapi/machine.json b/qapi/machine.json index d4317435e7..552d1c20e9 100644 --- a/qapi/machine.json +++ b/qapi/machine.json @@ -686,6 +686,7 @@ # Since: 5.0 ## { 'enum': 'HmatLBMemoryHierarchy', + 'prefix': 'HMATLB_MEMORY_HIERARCHY', # TODO drop 'data': [ 'memory', 'first-level', 'second-level', 'third-level' ] } =20 ## @@ -712,6 +713,7 @@ # Since: 5.0 ## { 'enum': 'HmatLBDataType', + 'prefix': 'HMATLB_DATA_TYPE', # TODO drop 'data': [ 'access-latency', 'read-latency', 'write-latency', 'access-bandwidth', 'read-bandwidth', 'write-bandwidth' ] } =20 diff --git a/qapi/migration.json b/qapi/migration.json index 7324571e92..f0ff7b93b4 100644 --- a/qapi/migration.json +++ b/qapi/migration.json @@ -571,6 +571,7 @@ # Since: 5.0 ## { 'enum': 'MultiFDCompression', + 'prefix': 'MULTIFD_COMPRESSION', 'data': [ 'none', 'zlib', { 'name': 'zstd', 'if': 'CONFIG_ZSTD' }, { 'name': 'qpl', 'if': 'CONFIG_QPL' }, diff --git a/qapi/ui.json b/qapi/ui.json index 8c8464faac..f61a2b6b65 100644 --- a/qapi/ui.json +++ b/qapi/ui.json @@ -949,6 +949,7 @@ # Since: 1.3 ## { 'enum': 'QKeyCode', + 'prefix': 'Q_KEY_CODE', 'data': [ 'unmapped', 'shift', 'shift_r', 'alt', 'alt_r', 'ctrl', 'ctrl_r', 'menu', 'esc', '1', '2', '3', '4', '5', '6', '7', '8= ', @@ -1396,6 +1397,7 @@ # Since: 3.0 ## { 'enum' : 'DisplayGLMode', + 'prefix' : 'DISPLAYGL_MODE', # TODO drop 'data' : [ 'off', 'on', 'core', 'es' ] } =20 ## diff --git a/scripts/qapi/common.py b/scripts/qapi/common.py index 737b059e62..d7c8aa3365 100644 --- a/scripts/qapi/common.py +++ b/scripts/qapi/common.py @@ -40,22 +40,28 @@ def camel_to_upper(value: str) -> str: ENUM_Name2 -> ENUM_NAME2 ENUM24_Name -> ENUM24_NAME """ - c_fun_str =3D c_name(value, False) - if value.isupper(): - return c_fun_str + ret =3D value[0] + upc =3D value[0].isupper() =20 - new_name =3D '' - length =3D len(c_fun_str) - for i in range(length): - char =3D c_fun_str[i] - # When char is upper case and no '_' appears before, do more checks - if char.isupper() and (i > 0) and c_fun_str[i - 1] !=3D '_': - if i < length - 1 and c_fun_str[i + 1].islower(): - new_name +=3D '_' - elif c_fun_str[i - 1].isdigit(): - new_name +=3D '_' - new_name +=3D char - return new_name.lstrip('_').upper() + # Copy remainder of ``value`` to ``ret`` with '_' inserted + for ch in value[1:]: + if ch.isupper() =3D=3D upc: + pass + elif upc: + # ``ret`` ends in upper case, next char isn't: insert '_' + # before the last upper case char unless there is one + # already, or it's at the beginning + if len(ret) > 2 and ret[-2].isalnum(): + ret =3D ret[:-1] + '_' + ret[-1] + else: + # ``ret`` doesn't end in upper case, next char is: insert + # '_' before it + if ret[-1].isalnum(): + ret +=3D '_' + ret +=3D ch + upc =3D ch.isupper() + + return c_name(ret.upper()).lstrip('_') =20 =20 def c_enum_const(type_name: str, @@ -68,9 +74,9 @@ def c_enum_const(type_name: str, :param const_name: The name of this constant. :param prefix: Optional, prefix that overrides the type_name. """ - if prefix is not None: - type_name =3D prefix - return camel_to_upper(type_name) + '_' + c_name(const_name, False).upp= er() + if prefix is None: + prefix =3D camel_to_upper(type_name) + return prefix + '_' + c_name(const_name, False).upper() =20 =20 def c_name(name: str, protect: bool =3D True) -> str: diff --git a/scripts/qapi/schema.py b/scripts/qapi/schema.py index d65c35f6ee..e97c978d38 100644 --- a/scripts/qapi/schema.py +++ b/scripts/qapi/schema.py @@ -1249,7 +1249,7 @@ def _def_predefineds(self) -> None: [{'name': n} for n in qtypes], None) =20 self._def_definition(QAPISchemaEnumType( - 'QType', None, None, None, None, qtype_values, 'QTYPE')) + 'QType', None, None, None, None, qtype_values, None)) =20 def _make_features( self, diff --git a/tests/qapi-schema/alternate-array.out b/tests/qapi-schema/alte= rnate-array.out index a657d85738..2f30973ac3 100644 --- a/tests/qapi-schema/alternate-array.out +++ b/tests/qapi-schema/alternate-array.out @@ -1,7 +1,6 @@ module ./builtin object q_empty enum QType - prefix QTYPE member none member qnull member qnum diff --git a/tests/qapi-schema/comments.out b/tests/qapi-schema/comments.out index ce4f6a4f0f..937070c2c4 100644 --- a/tests/qapi-schema/comments.out +++ b/tests/qapi-schema/comments.out @@ -1,7 +1,6 @@ module ./builtin object q_empty enum QType - prefix QTYPE member none member qnull member qnum diff --git a/tests/qapi-schema/doc-good.out b/tests/qapi-schema/doc-good.out index 6d24f1127b..ec277be91e 100644 --- a/tests/qapi-schema/doc-good.out +++ b/tests/qapi-schema/doc-good.out @@ -1,7 +1,6 @@ module ./builtin object q_empty enum QType - prefix QTYPE member none member qnull member qnum diff --git a/tests/qapi-schema/empty.out b/tests/qapi-schema/empty.out index 3feb3f69d3..d1981f8586 100644 --- a/tests/qapi-schema/empty.out +++ b/tests/qapi-schema/empty.out @@ -1,7 +1,6 @@ module ./builtin object q_empty enum QType - prefix QTYPE member none member qnull member qnum diff --git a/tests/qapi-schema/include-repetition.out b/tests/qapi-schema/i= nclude-repetition.out index 16dbd9b819..c564d27862 100644 --- a/tests/qapi-schema/include-repetition.out +++ b/tests/qapi-schema/include-repetition.out @@ -1,7 +1,6 @@ module ./builtin object q_empty enum QType - prefix QTYPE member none member qnull member qnum diff --git a/tests/qapi-schema/include-simple.out b/tests/qapi-schema/inclu= de-simple.out index 48e923bfbc..ec8200ab18 100644 --- a/tests/qapi-schema/include-simple.out +++ b/tests/qapi-schema/include-simple.out @@ -1,7 +1,6 @@ module ./builtin object q_empty enum QType - prefix QTYPE member none member qnull member qnum diff --git a/tests/qapi-schema/indented-expr.out b/tests/qapi-schema/indent= ed-expr.out index 6a30ded3fa..a7c22c3eef 100644 --- a/tests/qapi-schema/indented-expr.out +++ b/tests/qapi-schema/indented-expr.out @@ -1,7 +1,6 @@ module ./builtin object q_empty enum QType - prefix QTYPE member none member qnull member qnum diff --git a/tests/qapi-schema/qapi-schema-test.json b/tests/qapi-schema/qa= pi-schema-test.json index 8ca977c49d..0f5f54e621 100644 --- a/tests/qapi-schema/qapi-schema-test.json +++ b/tests/qapi-schema/qapi-schema-test.json @@ -119,6 +119,7 @@ 'data': [ 'value-a', 'value-b' ] } =20 { 'enum': 'TestUnionEnumA', + 'prefix': 'TEST_UNION_ENUMA', # TODO drop 'data': [ 'value-a1', 'value-a2' ] } =20 { 'struct': 'TestUnionTypeA1', diff --git a/tests/qapi-schema/qapi-schema-test.out b/tests/qapi-schema/qap= i-schema-test.out index e2f0981348..add7346f49 100644 --- a/tests/qapi-schema/qapi-schema-test.out +++ b/tests/qapi-schema/qapi-schema-test.out @@ -1,7 +1,6 @@ module ./builtin object q_empty enum QType - prefix QTYPE member none member qnull member qnum @@ -109,6 +108,7 @@ enum TestUnionEnum member value-a member value-b enum TestUnionEnumA + prefix TEST_UNION_ENUMA member value-a1 member value-a2 object TestUnionTypeA1 --=20 2.46.0 From nobody Sun Nov 24 05:28:16 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1725987050; cv=none; d=zohomail.com; s=zohoarc; b=QjxpqYD+tcmTWPLyhLII4148t/j4wLHGhJzY3nMiyU8+kWbiSN2ZpnnEYxMBEFPTJ+JlvCsrwgLjVemXqBw5gUeqAuGdzsCp/dWej4wtJtdWszRbSG7apkmLbasiaomsyt5b97Zeiqoqi7kUQ7TDZzo1Yzlq+yQVcroABSTK+7A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1725987050; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=pvJ3I/LFPv/AoNzC4WsomuASlFhsZEcwMqPZXb4j8i8=; b=V5QL5dpAR8/WSCO0pryqGUKv+VexzyQH1ojHqahNyGtumaG+dQHvlIU8atR9LEtWAOJldoS4zwOuYgE8X+BtZjFVsc6/FegzMD05UX+gfT1r6sw0Lu4pBXEljJCLlPdD1sEN7oEMnlMO1nyO3qQeNS1wUvtOEfcpIoODTfXg/kI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1725987050613301.6012846667885; Tue, 10 Sep 2024 09:50:50 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1so41n-0007Jv-KS; Tue, 10 Sep 2024 12:47:43 -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 1so41V-0006ji-N3 for qemu-devel@nongnu.org; Tue, 10 Sep 2024 12:47:27 -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 1so41T-0007YR-3Z for qemu-devel@nongnu.org; Tue, 10 Sep 2024 12:47:25 -0400 Received: from mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-14-P_mH9M-iPL2jwDYi34h3Rw-1; Tue, 10 Sep 2024 12:47:18 -0400 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 557031955DCE; Tue, 10 Sep 2024 16:47:17 +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 9B36019560AD; Tue, 10 Sep 2024 16:47:16 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 796AE21E692E; Tue, 10 Sep 2024 18:47:14 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1725986841; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=pvJ3I/LFPv/AoNzC4WsomuASlFhsZEcwMqPZXb4j8i8=; b=get+OCmnFOMl8ki983dvAWxuRoON0onvdZUDiY368xtsxWaAgTQpeqWtihyewPHSol0b6O XrUf4Wv01KN5VZPis9tUqIbm9A6sv13Q5orDB3BKgGpNw+aNN3Z6iu2br1R4BTP+GOKUIH wA/HNYGxblLWl9vkD6vhV4f5FZ7XAvA= X-MC-Unique: P_mH9M-iPL2jwDYi34h3Rw-1 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org, Thomas Huth Subject: [PULL 02/19] tests/qapi-schema: Drop temporary 'prefix' Date: Tue, 10 Sep 2024 18:46:57 +0200 Message-ID: <20240910164714.1993531-3-armbru@redhat.com> In-Reply-To: <20240910164714.1993531-1-armbru@redhat.com> References: <20240910164714.1993531-1-armbru@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.145, 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, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1725987052141116600 Content-Type: text/plain; charset="utf-8" Recent commit "qapi: Smarter camel_to_upper() to reduce need for 'prefix'" added a temporary 'prefix' to delay changing the generated code. Revert it. This changes TestUnionEnumA's generated enumeration constant prefix from TEST_UNION_ENUMA to TEST_UNION_ENUM_A. Signed-off-by: Markus Armbruster Reviewed-by: Thomas Huth Message-ID: <20240904111836.3273842-3-armbru@redhat.com> --- tests/unit/test-qobject-input-visitor.c | 4 ++-- tests/unit/test-qobject-output-visitor.c | 4 ++-- tests/qapi-schema/qapi-schema-test.json | 1 - tests/qapi-schema/qapi-schema-test.out | 1 - 4 files changed, 4 insertions(+), 6 deletions(-) diff --git a/tests/unit/test-qobject-input-visitor.c b/tests/unit/test-qobj= ect-input-visitor.c index 024e26c49e..5479e68237 100644 --- a/tests/unit/test-qobject-input-visitor.c +++ b/tests/unit/test-qobject-input-visitor.c @@ -720,7 +720,7 @@ static void test_visitor_in_union_in_union(TestInputVis= itorData *data, =20 visit_type_TestUnionInUnion(v, NULL, &tmp, &error_abort); g_assert_cmpint(tmp->type, =3D=3D, TEST_UNION_ENUM_VALUE_A); - g_assert_cmpint(tmp->u.value_a.type_a, =3D=3D, TEST_UNION_ENUMA_VALUE_= A1); + g_assert_cmpint(tmp->u.value_a.type_a, =3D=3D, TEST_UNION_ENUM_A_VALUE= _A1); g_assert_cmpint(tmp->u.value_a.u.value_a1.integer, =3D=3D, 2); g_assert_cmpint(strcmp(tmp->u.value_a.u.value_a1.name, "fish"), =3D=3D= , 0); =20 @@ -734,7 +734,7 @@ static void test_visitor_in_union_in_union(TestInputVis= itorData *data, =20 visit_type_TestUnionInUnion(v, NULL, &tmp, &error_abort); g_assert_cmpint(tmp->type, =3D=3D, TEST_UNION_ENUM_VALUE_A); - g_assert_cmpint(tmp->u.value_a.type_a, =3D=3D, TEST_UNION_ENUMA_VALUE_= A2); + g_assert_cmpint(tmp->u.value_a.type_a, =3D=3D, TEST_UNION_ENUM_A_VALUE= _A2); g_assert_cmpint(tmp->u.value_a.u.value_a2.integer, =3D=3D, 1729); g_assert_cmpint(tmp->u.value_a.u.value_a2.size, =3D=3D, 87539319); =20 diff --git a/tests/unit/test-qobject-output-visitor.c b/tests/unit/test-qob= ject-output-visitor.c index 1535b3ad17..3455f3b107 100644 --- a/tests/unit/test-qobject-output-visitor.c +++ b/tests/unit/test-qobject-output-visitor.c @@ -359,7 +359,7 @@ static void test_visitor_out_union_in_union(TestOutputV= isitorData *data, =20 TestUnionInUnion *tmp =3D g_new0(TestUnionInUnion, 1); tmp->type =3D TEST_UNION_ENUM_VALUE_A; - tmp->u.value_a.type_a =3D TEST_UNION_ENUMA_VALUE_A1; + tmp->u.value_a.type_a =3D TEST_UNION_ENUM_A_VALUE_A1; tmp->u.value_a.u.value_a1.integer =3D 42; tmp->u.value_a.u.value_a1.name =3D g_strdup("fish"); =20 @@ -377,7 +377,7 @@ static void test_visitor_out_union_in_union(TestOutputV= isitorData *data, visitor_reset(data); tmp =3D g_new0(TestUnionInUnion, 1); tmp->type =3D TEST_UNION_ENUM_VALUE_A; - tmp->u.value_a.type_a =3D TEST_UNION_ENUMA_VALUE_A2; + tmp->u.value_a.type_a =3D TEST_UNION_ENUM_A_VALUE_A2; tmp->u.value_a.u.value_a2.integer =3D 1729; tmp->u.value_a.u.value_a2.size =3D 87539319; =20 diff --git a/tests/qapi-schema/qapi-schema-test.json b/tests/qapi-schema/qa= pi-schema-test.json index 0f5f54e621..8ca977c49d 100644 --- a/tests/qapi-schema/qapi-schema-test.json +++ b/tests/qapi-schema/qapi-schema-test.json @@ -119,7 +119,6 @@ 'data': [ 'value-a', 'value-b' ] } =20 { 'enum': 'TestUnionEnumA', - 'prefix': 'TEST_UNION_ENUMA', # TODO drop 'data': [ 'value-a1', 'value-a2' ] } =20 { 'struct': 'TestUnionTypeA1', diff --git a/tests/qapi-schema/qapi-schema-test.out b/tests/qapi-schema/qap= i-schema-test.out index add7346f49..4617eb4e98 100644 --- a/tests/qapi-schema/qapi-schema-test.out +++ b/tests/qapi-schema/qapi-schema-test.out @@ -108,7 +108,6 @@ enum TestUnionEnum member value-a member value-b enum TestUnionEnumA - prefix TEST_UNION_ENUMA member value-a1 member value-a2 object TestUnionTypeA1 --=20 2.46.0 From nobody Sun Nov 24 05:28:16 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1725987044; cv=none; d=zohomail.com; s=zohoarc; b=N4ikBoJd0GOHYL87Oc8sqJkd2H9VttjnKxj+JPhvq9KIBGDOk82B53nPnS8mQpV4wDHjbuw6awl+yyVi75Yxwlh9KyagccXgzaP9Fi8tcRVTajItIkdApZHRogIcqsgSJRNisp14CEnvZzztPpNU6PYWXO8pMc2TJOGKAQeuj34= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1725987044; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=VxJ87lsjswNomZOhBoYjMc6BZ+sgw659BedRk/JNaSI=; b=TWfShzAtOwoz7EkoaarZcUEz2t9HK8veoIo6DZH4gLSOPwvxsvfz2G04X5rM+boNf90RElp2vfu95/w94MnACP7uij402P9ExvZXc7fK/BWBaV9ZS1joLuISmNOEhY0/iq6/LvkmoYotiZU0YTngWl5QOC3eiTjUmU6aMcR5NT4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 172598704451533.45937118351446; Tue, 10 Sep 2024 09:50:44 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1so41n-0007LE-VE; Tue, 10 Sep 2024 12:47:43 -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 1so41a-0006pk-F2 for qemu-devel@nongnu.org; Tue, 10 Sep 2024 12:47: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 1so41V-0007YE-Hl for qemu-devel@nongnu.org; Tue, 10 Sep 2024 12:47:30 -0400 Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-12-k-Go2SSZORe6qGDz1H8MBQ-1; Tue, 10 Sep 2024 12:47:18 -0400 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 0DB161955F2E; Tue, 10 Sep 2024 16:47:17 +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 A16493000239; Tue, 10 Sep 2024 16:47:16 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 7C4E121E6939; Tue, 10 Sep 2024 18:47:14 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1725986840; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=VxJ87lsjswNomZOhBoYjMc6BZ+sgw659BedRk/JNaSI=; b=FkWZTV1jrALP0MxpaZ/q7cuYGeDN4GMMGGY3R50fUHGdhNdMDphez/mN9rBDZsGwdbJOma T4qeDVU9GdnYGkBZzWMlYU5Au5UJkp+pV7sAsVk/RSxzIrBLAQtGT6IMQ5c33/OEbW2GHN krqcaHwNrC2LaK7n/eF/siZ6thkBwNM= X-MC-Unique: k-Go2SSZORe6qGDz1H8MBQ-1 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org Subject: [PULL 03/19] qapi/block-core: Drop temporary 'prefix' Date: Tue, 10 Sep 2024 18:46:58 +0200 Message-ID: <20240910164714.1993531-4-armbru@redhat.com> In-Reply-To: <20240910164714.1993531-1-armbru@redhat.com> References: <20240910164714.1993531-1-armbru@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.145, 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, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1725987046077116600 Content-Type: text/plain; charset="utf-8" Recent commit "qapi: Smarter camel_to_upper() to reduce need for 'prefix'" added a temporary 'prefix' to delay changing the generated code. Revert it. This improves XDbgBlockGraphNodeType's generated enumeration constant prefix from X_DBG_BLOCK_GRAPH_NODE_TYPE_BLOCK_BACKEND to XDBG_BLOCK_GRAPH_NODE_TYPE_BLOCK_BACKEND. Signed-off-by: Markus Armbruster Message-ID: <20240904111836.3273842-4-armbru@redhat.com> --- qapi/block-core.json | 1 - block.c | 6 +++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/qapi/block-core.json b/qapi/block-core.json index 452047102a..a7ae2da47b 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -2011,7 +2011,6 @@ # Since: 4.0 ## { 'enum': 'XDbgBlockGraphNodeType', - 'prefix': 'X_DBG_BLOCK_GRAPH_NODE_TYPE', # TODO drop 'data': [ 'block-backend', 'block-job', 'block-driver' ] } =20 ## diff --git a/block.c b/block.c index c317de9eaa..7d90007cae 100644 --- a/block.c +++ b/block.c @@ -6351,7 +6351,7 @@ XDbgBlockGraph *bdrv_get_xdbg_block_graph(Error **err= p) if (!*name) { name =3D allocated_name =3D blk_get_attached_dev_id(blk); } - xdbg_graph_add_node(gr, blk, X_DBG_BLOCK_GRAPH_NODE_TYPE_BLOCK_BAC= KEND, + xdbg_graph_add_node(gr, blk, XDBG_BLOCK_GRAPH_NODE_TYPE_BLOCK_BACK= END, name); g_free(allocated_name); if (blk_root(blk)) { @@ -6364,7 +6364,7 @@ XDbgBlockGraph *bdrv_get_xdbg_block_graph(Error **err= p) job =3D block_job_next_locked(job)) { GSList *el; =20 - xdbg_graph_add_node(gr, job, X_DBG_BLOCK_GRAPH_NODE_TYPE_BLOCK= _JOB, + xdbg_graph_add_node(gr, job, XDBG_BLOCK_GRAPH_NODE_TYPE_BLOCK_= JOB, job->job.id); for (el =3D job->nodes; el; el =3D el->next) { xdbg_graph_add_edge(gr, job, (BdrvChild *)el->data); @@ -6373,7 +6373,7 @@ XDbgBlockGraph *bdrv_get_xdbg_block_graph(Error **err= p) } =20 QTAILQ_FOREACH(bs, &graph_bdrv_states, node_list) { - xdbg_graph_add_node(gr, bs, X_DBG_BLOCK_GRAPH_NODE_TYPE_BLOCK_DRIV= ER, + xdbg_graph_add_node(gr, bs, XDBG_BLOCK_GRAPH_NODE_TYPE_BLOCK_DRIVE= R, bs->node_name); QLIST_FOREACH(child, &bs->children, next) { xdbg_graph_add_edge(gr, bs, child); --=20 2.46.0 From nobody Sun Nov 24 05:28:16 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1725986977; cv=none; d=zohomail.com; s=zohoarc; b=iNchmryiHg9+NbKyjgLB+p1VMaknH8Y0oc2fR7iNFAmg5C+LAThYrlmixAlcuAG1b9SJBUbzOrCyfPu0prxWZgUKYyAY70EIXvwNU7V8O0q9IZmUS1uk8Yl8dvg4al1zpCrI2yn/nq6BUrZ0Siv+EuvnyOMUemc0Jw2Obj+9Peo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1725986977; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=U/GyNdP3SCPmm98PzjfyGhHCVDHjKCxS619UzLclrnA=; b=H3vLgmVoykEhbmXAK52zMOvafEuqGqff9gXdIqEXNZOK2VdO39uMbwUMkgQGe+qjOC2/99STCVhYVVEnQ9kYKdWq71+a6hcq3YzgoLYCMOJ3TQuiX45JsUnLdb9KVxz89ispFGAysC7vTC1mBLVli7gUF6qX8IXra8/3x4H6iOk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1725986977765761.9386840684018; Tue, 10 Sep 2024 09:49:37 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1so41k-00072G-9N; Tue, 10 Sep 2024 12:47:40 -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 1so41V-0006jh-Lv for qemu-devel@nongnu.org; Tue, 10 Sep 2024 12:47:27 -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 1so41T-0007Ye-BG for qemu-devel@nongnu.org; Tue, 10 Sep 2024 12:47:25 -0400 Received: from mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-12-2988NX_cMAyI8bJ1e76rXA-1; Tue, 10 Sep 2024 12:47:18 -0400 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 150EE19560B7; Tue, 10 Sep 2024 16:47:17 +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 8711D30001A1; Tue, 10 Sep 2024 16:47:16 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 7F39B21E6889; Tue, 10 Sep 2024 18:47:14 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1725986842; 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=U/GyNdP3SCPmm98PzjfyGhHCVDHjKCxS619UzLclrnA=; b=ULDbHgj2gJqOa3TgUCOJrJNimFd7gaL9GWFMmO3vfV8mlMOwh4+zKPtTe86J1csRTv4FPS JJGEQEVd/UTHafvaYdXAKhXqHbiVFdk9JLqBXGOfW/FdbfIUUQzOyjrketK5pnXlIie3+j RbBp/Y2SBjR6Mb7j4hue/bE+2ndESAg= X-MC-Unique: 2988NX_cMAyI8bJ1e76rXA-1 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org, =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Subject: [PULL 04/19] qapi/common: Drop temporary 'prefix' Date: Tue, 10 Sep 2024 18:46:59 +0200 Message-ID: <20240910164714.1993531-5-armbru@redhat.com> In-Reply-To: <20240910164714.1993531-1-armbru@redhat.com> References: <20240910164714.1993531-1-armbru@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.145, 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, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1725986979820116600 Recent commit "qapi: Smarter camel_to_upper() to reduce need for 'prefix'" added a temporary 'prefix' to delay changing the generated code. Revert it. This improves OffAutoPCIBAR's generated enumeration constant prefix from OFF_AUTOPCIBAR to OFF_AUTO_PCIBAR. Signed-off-by: Markus Armbruster Reviewed-by: C=C3=A9dric Le Goater Message-ID: <20240904111836.3273842-5-armbru@redhat.com> --- qapi/common.json | 1 - hw/vfio/pci.c | 10 +++++----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/qapi/common.json b/qapi/common.json index 25726d3113..7558ce5430 100644 --- a/qapi/common.json +++ b/qapi/common.json @@ -92,7 +92,6 @@ # Since: 2.12 ## { 'enum': 'OffAutoPCIBAR', - 'prefix': 'OFF_AUTOPCIBAR', # TODO drop 'data': [ 'off', 'auto', 'bar0', 'bar1', 'bar2', 'bar3', 'bar4', 'bar5' = ] } =20 ## diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c index 2407720c35..0a99e55247 100644 --- a/hw/vfio/pci.c +++ b/hw/vfio/pci.c @@ -1452,7 +1452,7 @@ static bool vfio_pci_relocate_msix(VFIOPCIDevice *vde= v, Error **errp) int target_bar =3D -1; size_t msix_sz; =20 - if (!vdev->msix || vdev->msix_relo =3D=3D OFF_AUTOPCIBAR_OFF) { + if (!vdev->msix || vdev->msix_relo =3D=3D OFF_AUTO_PCIBAR_OFF) { return true; } =20 @@ -1464,7 +1464,7 @@ static bool vfio_pci_relocate_msix(VFIOPCIDevice *vde= v, Error **errp) /* PCI BARs must be a power of 2 */ msix_sz =3D pow2ceil(msix_sz); =20 - if (vdev->msix_relo =3D=3D OFF_AUTOPCIBAR_AUTO) { + if (vdev->msix_relo =3D=3D OFF_AUTO_PCIBAR_AUTO) { /* * TODO: Lookup table for known devices. * @@ -1479,7 +1479,7 @@ static bool vfio_pci_relocate_msix(VFIOPCIDevice *vde= v, Error **errp) return false; } } else { - target_bar =3D (int)(vdev->msix_relo - OFF_AUTOPCIBAR_BAR0); + target_bar =3D (int)(vdev->msix_relo - OFF_AUTO_PCIBAR_BAR0); } =20 /* I/O port BARs cannot host MSI-X structures */ @@ -1624,7 +1624,7 @@ static bool vfio_msix_early_setup(VFIOPCIDevice *vdev= , Error **errp) } else if (vfio_pci_is(vdev, PCI_VENDOR_ID_BAIDU, PCI_DEVICE_ID_KUNLUN_VF)) { msix->pba_offset =3D 0xb400; - } else if (vdev->msix_relo =3D=3D OFF_AUTOPCIBAR_OFF) { + } else if (vdev->msix_relo =3D=3D OFF_AUTO_PCIBAR_OFF) { error_setg(errp, "hardware reports invalid configuration, " "MSIX PBA outside of specified BAR"); g_free(msix); @@ -3403,7 +3403,7 @@ static Property vfio_pci_dev_properties[] =3D { nv_gpudirect_clique, qdev_prop_nv_gpudirect_clique, uint8_t), DEFINE_PROP_OFF_AUTO_PCIBAR("x-msix-relocation", VFIOPCIDevice, msix_r= elo, - OFF_AUTOPCIBAR_OFF), + OFF_AUTO_PCIBAR_OFF), #ifdef CONFIG_IOMMUFD DEFINE_PROP_LINK("iommufd", VFIOPCIDevice, vbasedev.iommufd, TYPE_IOMMUFD_BACKEND, IOMMUFDBackend *), --=20 2.46.0 From nobody Sun Nov 24 05:28:16 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1725986990; cv=none; d=zohomail.com; s=zohoarc; b=IB70nJLz6LEUTrJsLclxdwmlCSiOVNqIYRHAgP7GBP19Y84qm4U2LHgsHuyNKo62gdwx1rnDS6yI2S/iqcgBnGUiGTIeeqtgBRRNgCeBieAyaSfhkf4BqngWw6E3ostBwy8dsuCZPl6UzZ1yjUyT4Jws35OFtZCYGs/+ItO0VOA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1725986990; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=z7skFJZCEQ+/qGT73BeWIdkvXRnSdSNsKlxhz2l2CaQ=; b=Uk2IXwLSUzMWtDLv0k42Hc8DIJegn17Ka1CNkO5Kz3RhcR2INJvLeuL+kautdi3052ZadQ0SxLgldqXTPQg5OTFQaahlBr6HmV3LU3YkxZ19s8awhigQ85PwnV4PY13RjHq9FBmYGHzWZIuKY1mE1vJ6ZHLFBPPGTKzJN2WwxFo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1725986990093917.0156589663777; Tue, 10 Sep 2024 09:49:50 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1so41k-00078Z-N7; Tue, 10 Sep 2024 12:47:40 -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 1so41Z-0006mG-0i for qemu-devel@nongnu.org; Tue, 10 Sep 2024 12:47: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 1so41U-0007Yz-Pf for qemu-devel@nongnu.org; Tue, 10 Sep 2024 12:47:28 -0400 Received: from mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-455-TfHpH4kNPP6ExrdaIus-Tw-1; Tue, 10 Sep 2024 12:47:21 -0400 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id DFC581953956; Tue, 10 Sep 2024 16:47:19 +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 055B43000239; Tue, 10 Sep 2024 16:47:19 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 826C721E688F; Tue, 10 Sep 2024 18:47:14 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1725986844; 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=z7skFJZCEQ+/qGT73BeWIdkvXRnSdSNsKlxhz2l2CaQ=; b=fb44cXulWV2UArW1NQH4myhdEt8lmxmdvImGtQViAL2r+WrS8+n8mFOz0Q+9KrKee50eLC NqEEZV/ygHxRBtHs4f4o2aVMvPMqiD9Ep8j5sHMXK4Qrwf1yo//2vNCkkXztp/Ev61LCaO +37pYCIx+kRgSm00kaQA97Uzws6n4tE= X-MC-Unique: TfHpH4kNPP6ExrdaIus-Tw-1 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org, =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= Subject: [PULL 05/19] qapi/crypto: Drop temporary 'prefix' Date: Tue, 10 Sep 2024 18:47:00 +0200 Message-ID: <20240910164714.1993531-6-armbru@redhat.com> In-Reply-To: <20240910164714.1993531-1-armbru@redhat.com> References: <20240910164714.1993531-1-armbru@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.145, 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, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1725986991954116600 Recent commit "qapi: Smarter camel_to_upper() to reduce need for 'prefix'" added two temporary 'prefix' to delay changing the generated code. Revert them. This improves QCryptoBlockFormat's generated enumeration constant prefix from Q_CRYPTO_BLOCK_FORMAT to QCRYPTO_BLOCK_FORMAT, and QCryptoBlockLUKSKeyslotState's from Q_CRYPTO_BLOCKLUKS_KEYSLOT_STATE to QCRYPTO_BLOCK_LUKS_KEYSLOT_STATE. Signed-off-by: Markus Armbruster Acked-by: Daniel P. Berrang=C3=A9 Message-ID: <20240904111836.3273842-6-armbru@redhat.com> --- qapi/crypto.json | 2 -- block/crypto.c | 10 +++++----- block/qcow.c | 2 +- block/qcow2.c | 10 +++++----- crypto/block-luks.c | 4 ++-- crypto/block.c | 4 ++-- tests/unit/test-crypto-block.c | 14 +++++++------- 7 files changed, 22 insertions(+), 24 deletions(-) diff --git a/qapi/crypto.json b/qapi/crypto.json index a192641a03..fb00c706b2 100644 --- a/qapi/crypto.json +++ b/qapi/crypto.json @@ -157,7 +157,6 @@ # Since: 2.6 ## { 'enum': 'QCryptoBlockFormat', - 'prefix': 'Q_CRYPTO_BLOCK_FORMAT', # TODO drop 'data': ['qcow', 'luks']} =20 ## @@ -360,7 +359,6 @@ # Since: 5.1 ## { 'enum': 'QCryptoBlockLUKSKeyslotState', - 'prefix': 'Q_CRYPTO_BLOCKLUKS_KEYSLOT_STATE', # TODO drop 'data': [ 'active', 'inactive' ] } =20 ## diff --git a/block/crypto.c b/block/crypto.c index 4eed3ffa6a..80b2dba17a 100644 --- a/block/crypto.c +++ b/block/crypto.c @@ -682,7 +682,7 @@ err: static int block_crypto_probe_luks(const uint8_t *buf, int buf_size, const char *filename) { - return block_crypto_probe_generic(Q_CRYPTO_BLOCK_FORMAT_LUKS, + return block_crypto_probe_generic(QCRYPTO_BLOCK_FORMAT_LUKS, buf, buf_size, filename); } =20 @@ -691,7 +691,7 @@ static int block_crypto_open_luks(BlockDriverState *bs, int flags, Error **errp) { - return block_crypto_open_generic(Q_CRYPTO_BLOCK_FORMAT_LUKS, + return block_crypto_open_generic(QCRYPTO_BLOCK_FORMAT_LUKS, &block_crypto_runtime_opts_luks, bs, options, flags, errp); } @@ -724,7 +724,7 @@ block_crypto_co_create_luks(BlockdevCreateOptions *crea= te_options, Error **errp) } =20 create_opts =3D (QCryptoBlockCreateOptions) { - .format =3D Q_CRYPTO_BLOCK_FORMAT_LUKS, + .format =3D QCRYPTO_BLOCK_FORMAT_LUKS, .u.luks =3D *qapi_BlockdevCreateOptionsLUKS_base(luks_opts), }; =20 @@ -889,7 +889,7 @@ block_crypto_get_specific_info_luks(BlockDriverState *b= s, Error **errp) if (!info) { return NULL; } - assert(info->format =3D=3D Q_CRYPTO_BLOCK_FORMAT_LUKS); + assert(info->format =3D=3D QCRYPTO_BLOCK_FORMAT_LUKS); =20 spec_info =3D g_new(ImageInfoSpecific, 1); spec_info->type =3D IMAGE_INFO_SPECIFIC_KIND_LUKS; @@ -1002,7 +1002,7 @@ coroutine_fn block_crypto_co_amend_luks(BlockDriverSt= ate *bs, QCryptoBlockAmendOptions amend_opts; =20 amend_opts =3D (QCryptoBlockAmendOptions) { - .format =3D Q_CRYPTO_BLOCK_FORMAT_LUKS, + .format =3D QCRYPTO_BLOCK_FORMAT_LUKS, .u.luks =3D *qapi_BlockdevAmendOptionsLUKS_base(&opts->u.luks), }; return block_crypto_amend_options_generic_luks(bs, &amend_opts, diff --git a/block/qcow.c b/block/qcow.c index c2f89db055..84d1cca296 100644 --- a/block/qcow.c +++ b/block/qcow.c @@ -831,7 +831,7 @@ qcow_co_create(BlockdevCreateOptions *opts, Error **err= p) } =20 if (qcow_opts->encrypt && - qcow_opts->encrypt->format !=3D Q_CRYPTO_BLOCK_FORMAT_QCOW) + qcow_opts->encrypt->format !=3D QCRYPTO_BLOCK_FORMAT_QCOW) { error_setg(errp, "Unsupported encryption format"); return -EINVAL; diff --git a/block/qcow2.c b/block/qcow2.c index 70b19730a3..dd359d241b 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -3214,10 +3214,10 @@ qcow2_set_up_encryption(BlockDriverState *bs, int fmt, ret; =20 switch (cryptoopts->format) { - case Q_CRYPTO_BLOCK_FORMAT_LUKS: + case QCRYPTO_BLOCK_FORMAT_LUKS: fmt =3D QCOW_CRYPT_LUKS; break; - case Q_CRYPTO_BLOCK_FORMAT_QCOW: + case QCRYPTO_BLOCK_FORMAT_QCOW: fmt =3D QCOW_CRYPT_AES; break; default: @@ -5306,10 +5306,10 @@ qcow2_get_specific_info(BlockDriverState *bs, Error= **errp) ImageInfoSpecificQCow2Encryption *qencrypt =3D g_new(ImageInfoSpecificQCow2Encryption, 1); switch (encrypt_info->format) { - case Q_CRYPTO_BLOCK_FORMAT_QCOW: + case QCRYPTO_BLOCK_FORMAT_QCOW: qencrypt->format =3D BLOCKDEV_QCOW2_ENCRYPTION_FORMAT_AES; break; - case Q_CRYPTO_BLOCK_FORMAT_LUKS: + case QCRYPTO_BLOCK_FORMAT_LUKS: qencrypt->format =3D BLOCKDEV_QCOW2_ENCRYPTION_FORMAT_LUKS; qencrypt->u.luks =3D encrypt_info->u.luks; break; @@ -5948,7 +5948,7 @@ static int coroutine_fn qcow2_co_amend(BlockDriverSta= te *bs, return -EOPNOTSUPP; } =20 - if (qopts->encrypt->format !=3D Q_CRYPTO_BLOCK_FORMAT_LUKS) { + if (qopts->encrypt->format !=3D QCRYPTO_BLOCK_FORMAT_LUKS) { error_setg(errp, "Amend can't be used to change the qcow2 encryption= format"); return -EOPNOTSUPP; diff --git a/crypto/block-luks.c b/crypto/block-luks.c index 45347adeeb..7b9c7b292d 100644 --- a/crypto/block-luks.c +++ b/crypto/block-luks.c @@ -1861,11 +1861,11 @@ qcrypto_block_luks_amend_options(QCryptoBlock *bloc= k, QCryptoBlockAmendOptionsLUKS *opts_luks =3D &options->u.luks; =20 switch (opts_luks->state) { - case Q_CRYPTO_BLOCKLUKS_KEYSLOT_STATE_ACTIVE: + case QCRYPTO_BLOCK_LUKS_KEYSLOT_STATE_ACTIVE: return qcrypto_block_luks_amend_add_keyslot(block, readfunc, writefunc, opaque, opts_luks, force, errp= ); - case Q_CRYPTO_BLOCKLUKS_KEYSLOT_STATE_INACTIVE: + case QCRYPTO_BLOCK_LUKS_KEYSLOT_STATE_INACTIVE: return qcrypto_block_luks_amend_erase_keyslots(block, readfunc, writefunc, opaque, opts_luks, force, e= rrp); diff --git a/crypto/block.c b/crypto/block.c index 3bcc4270c3..899561a080 100644 --- a/crypto/block.c +++ b/crypto/block.c @@ -26,8 +26,8 @@ #include "block-luks.h" =20 static const QCryptoBlockDriver *qcrypto_block_drivers[] =3D { - [Q_CRYPTO_BLOCK_FORMAT_QCOW] =3D &qcrypto_block_driver_qcow, - [Q_CRYPTO_BLOCK_FORMAT_LUKS] =3D &qcrypto_block_driver_luks, + [QCRYPTO_BLOCK_FORMAT_QCOW] =3D &qcrypto_block_driver_qcow, + [QCRYPTO_BLOCK_FORMAT_LUKS] =3D &qcrypto_block_driver_luks, }; =20 =20 diff --git a/tests/unit/test-crypto-block.c b/tests/unit/test-crypto-block.c index 42cfab6067..2a6c6e99e5 100644 --- a/tests/unit/test-crypto-block.c +++ b/tests/unit/test-crypto-block.c @@ -39,14 +39,14 @@ #endif =20 static QCryptoBlockCreateOptions qcow_create_opts =3D { - .format =3D Q_CRYPTO_BLOCK_FORMAT_QCOW, + .format =3D QCRYPTO_BLOCK_FORMAT_QCOW, .u.qcow =3D { .key_secret =3D (char *)"sec0", }, }; =20 static QCryptoBlockOpenOptions qcow_open_opts =3D { - .format =3D Q_CRYPTO_BLOCK_FORMAT_QCOW, + .format =3D QCRYPTO_BLOCK_FORMAT_QCOW, .u.qcow =3D { .key_secret =3D (char *)"sec0", }, @@ -55,7 +55,7 @@ static QCryptoBlockOpenOptions qcow_open_opts =3D { =20 #ifdef TEST_LUKS static QCryptoBlockOpenOptions luks_open_opts =3D { - .format =3D Q_CRYPTO_BLOCK_FORMAT_LUKS, + .format =3D QCRYPTO_BLOCK_FORMAT_LUKS, .u.luks =3D { .key_secret =3D (char *)"sec0", }, @@ -64,7 +64,7 @@ static QCryptoBlockOpenOptions luks_open_opts =3D { =20 /* Creation with all default values */ static QCryptoBlockCreateOptions luks_create_opts_default =3D { - .format =3D Q_CRYPTO_BLOCK_FORMAT_LUKS, + .format =3D QCRYPTO_BLOCK_FORMAT_LUKS, .u.luks =3D { .key_secret =3D (char *)"sec0", }, @@ -73,7 +73,7 @@ static QCryptoBlockCreateOptions luks_create_opts_default= =3D { =20 /* ...and with explicit values */ static QCryptoBlockCreateOptions luks_create_opts_aes256_cbc_plain64 =3D { - .format =3D Q_CRYPTO_BLOCK_FORMAT_LUKS, + .format =3D QCRYPTO_BLOCK_FORMAT_LUKS, .u.luks =3D { .key_secret =3D (char *)"sec0", .has_cipher_alg =3D true, @@ -87,7 +87,7 @@ static QCryptoBlockCreateOptions luks_create_opts_aes256_= cbc_plain64 =3D { =20 =20 static QCryptoBlockCreateOptions luks_create_opts_aes256_cbc_essiv =3D { - .format =3D Q_CRYPTO_BLOCK_FORMAT_LUKS, + .format =3D QCRYPTO_BLOCK_FORMAT_LUKS, .u.luks =3D { .key_secret =3D (char *)"sec0", .has_cipher_alg =3D true, @@ -572,7 +572,7 @@ int main(int argc, char **argv) g_assert(qcrypto_init(NULL) =3D=3D 0); =20 for (i =3D 0; i < G_N_ELEMENTS(test_data); i++) { - if (test_data[i].open_opts->format =3D=3D Q_CRYPTO_BLOCK_FORMAT_LU= KS && + if (test_data[i].open_opts->format =3D=3D QCRYPTO_BLOCK_FORMAT_LUK= S && !qcrypto_hash_supports(test_data[i].hash_alg)) { continue; } --=20 2.46.0 From nobody Sun Nov 24 05:28:16 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1725986944; cv=none; d=zohomail.com; s=zohoarc; b=n5L3btt1Pfp/qFKdBHM/HpiJD3+ApmdlIatRPlUY1Ms4uFYLd1dDVZDGcct+Fyem4yxRP0F66QfB4TeCPI/niTFUl8I28GKisW0/yQQP8+1fq/R4tecsuNEgCkJZJJLhxn7vYmkv50FCGcXgbDgoZCeVgRiv60/duXxh0kMZCXU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1725986944; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=S15FajVd/CEbaI9z1Sm6npoZAyDk4248vaEzQt4CKCE=; b=lmK54W+OxIJASrQC25hRuyOqWAbPKoPfhow9LPLjWdUr4GQEaQTj3jSXJNaUplCZ/wBqgTcZLb85fPXlekApkCuAK02TL4vd9xa6xr95fR+ADDv1bByHitxQgMQF3r2nr1mLCOfHe7n04jZ+LYiIsYRX5vCsarrcuZv25uA7DLI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1725986944560789.1624911790319; Tue, 10 Sep 2024 09:49:04 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1so41a-0006p9-LI; Tue, 10 Sep 2024 12:47:32 -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 1so41V-0006jf-FM for qemu-devel@nongnu.org; Tue, 10 Sep 2024 12:47:27 -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 1so41T-0007YU-3b for qemu-devel@nongnu.org; Tue, 10 Sep 2024 12:47:25 -0400 Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-644-fTjYUipWOVuvZj4fuUsBeg-1; Tue, 10 Sep 2024 12:47:20 -0400 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 4AEBC1955D6A; Tue, 10 Sep 2024 16:47:19 +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 052A230001A1; Tue, 10 Sep 2024 16:47:19 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 851DD21E6891; Tue, 10 Sep 2024 18:47:14 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1725986841; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=S15FajVd/CEbaI9z1Sm6npoZAyDk4248vaEzQt4CKCE=; b=N0AtqTbHRmiQuuGNv8+p0GEn0aTsSu1hbjitO7LaD0PpVewAWRAbeXhB6IUpDDG6A6YF6m FUZ/g0cjnxyKj2yYEcfVXdMu8NxAX139T5Gvl9Jp5nDOUsLJr9p5ujEsSQxfZ3QeSkzHYO MS2NuiG1nlKom88Q78sJaEYkkEVhRa0= X-MC-Unique: fTjYUipWOVuvZj4fuUsBeg-1 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org Subject: [PULL 06/19] qapi/ebpf: Drop temporary 'prefix' Date: Tue, 10 Sep 2024 18:47:01 +0200 Message-ID: <20240910164714.1993531-7-armbru@redhat.com> In-Reply-To: <20240910164714.1993531-1-armbru@redhat.com> References: <20240910164714.1993531-1-armbru@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.145, 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, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1725986945600116600 Content-Type: text/plain; charset="utf-8" Recent commit "qapi: Smarter camel_to_upper() to reduce need for 'prefix'" added a temporary 'prefix' to delay changing the generated code. Revert it. This improves EbpfProgramID's generated enumeration constant prefix from EBPF_PROGRAMID to EBPF_PROGRAM_ID. Signed-off-by: Markus Armbruster Message-ID: <20240904111836.3273842-7-armbru@redhat.com> --- qapi/ebpf.json | 1 - ebpf/ebpf_rss.c | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/qapi/ebpf.json b/qapi/ebpf.json index 42df548777..db19ae850f 100644 --- a/qapi/ebpf.json +++ b/qapi/ebpf.json @@ -42,7 +42,6 @@ # Since: 9.0 ## { 'enum': 'EbpfProgramID', - 'prefix': 'EBPF_PROGRAMID', # TODO drop 'if': 'CONFIG_EBPF', 'data': [ { 'name': 'rss' } ] } =20 diff --git a/ebpf/ebpf_rss.c b/ebpf/ebpf_rss.c index 87f0714910..dcaa80f380 100644 --- a/ebpf/ebpf_rss.c +++ b/ebpf/ebpf_rss.c @@ -271,4 +271,4 @@ void ebpf_rss_unload(struct EBPFRSSContext *ctx) ctx->map_indirections_table =3D -1; } =20 -ebpf_binary_init(EBPF_PROGRAMID_RSS, rss_bpf__elf_bytes) +ebpf_binary_init(EBPF_PROGRAM_ID_RSS, rss_bpf__elf_bytes) --=20 2.46.0 From nobody Sun Nov 24 05:28:16 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1725986877; cv=none; d=zohomail.com; s=zohoarc; b=jEIN0O2IuJL+dZgGVjZ4QdRN3xzjdZlYHQ1hpRdiqHvaPKrwQ6OZLHFD332FeSvoa0RsrF3hKeg/iJr3Eb3rkr1/C7Pmh+5aaNqdd269MFjyzCIj5l3nLzTiTjeS3tViz279e7Efdr4BLYGhT0h1mrQTi1BOtB/swWEirlHs3Qg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1725986877; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=mIrpcTitkOc4K2UB5YyHsO9cfr2Gf4P39jPxeVVxCG8=; b=Ja+MgtgXfhxSqu5g8iYKBGYJKkXzYFA62Y07hXfu/V+VUPeYrZmIq2bKRH9NB2EjVjhKPksQ1HqPY9pBFsmn04jZZWKJLxIz3KVDgEOabrZElQke72/HD+D97pvWlvqfiwC1CXfuKlyhf0PRTUrIYlkO1kZ4VOBDiDscochub68= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1725986877022321.747142731546; Tue, 10 Sep 2024 09:47:57 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1so41Z-0006oK-W9; Tue, 10 Sep 2024 12:47:30 -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 1so41X-0006js-G7 for qemu-devel@nongnu.org; Tue, 10 Sep 2024 12:47:27 -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 1so41U-0007Yv-M9 for qemu-devel@nongnu.org; Tue, 10 Sep 2024 12:47:27 -0400 Received: from mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-179-4j1Ak-sZNSex-qEkHyk4yA-1; Tue, 10 Sep 2024 12:47:20 -0400 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 9B1A119560A7; Tue, 10 Sep 2024 16:47:19 +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 3E08E1956048; Tue, 10 Sep 2024 16:47:19 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 8814621E68B2; Tue, 10 Sep 2024 18:47:14 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1725986843; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=mIrpcTitkOc4K2UB5YyHsO9cfr2Gf4P39jPxeVVxCG8=; b=PHeWtE/Gq8zsstOgdjofzAVqT6RG1BAAfuFfsKjdhQ9E1seghVUy3Bqgd6qWEFMtSEAdMB axIehzgXz0Siogm/sLkw/OTKgT2eO/8mmX3DBCtxTJafniyoYepKJjautwYBkxUAIIFhaj Pb93zXvDSdW2AIfKJ6CefJqqDP5bU84= X-MC-Unique: 4j1Ak-sZNSex-qEkHyk4yA-1 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org, Zhao Liu Subject: [PULL 07/19] qapi/machine: Drop temporary 'prefix' Date: Tue, 10 Sep 2024 18:47:02 +0200 Message-ID: <20240910164714.1993531-8-armbru@redhat.com> In-Reply-To: <20240910164714.1993531-1-armbru@redhat.com> References: <20240910164714.1993531-1-armbru@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.145, 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, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1725986877617116600 Content-Type: text/plain; charset="utf-8" Recent commit "qapi: Smarter camel_to_upper() to reduce need for 'prefix'" added a temporary 'prefix' to delay changing the generated code. Revert it. This improves HmatLBDataType's generated enumeration constant prefix from HMATLB_DATA_TYPE to HMAT_LB_DATA_TYPE, and HmatLBMemoryHierarchy's from HMATLB_MEMORY_HIERARCHY to HMAT_LB_MEMORY_HIERARCHY. Signed-off-by: Markus Armbruster Reviewed-by: Zhao Liu Message-ID: <20240904111836.3273842-8-armbru@redhat.com> --- qapi/machine.json | 2 -- hw/core/numa.c | 4 ++-- hw/pci-bridge/cxl_upstream.c | 4 ++-- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/qapi/machine.json b/qapi/machine.json index 552d1c20e9..d4317435e7 100644 --- a/qapi/machine.json +++ b/qapi/machine.json @@ -686,7 +686,6 @@ # Since: 5.0 ## { 'enum': 'HmatLBMemoryHierarchy', - 'prefix': 'HMATLB_MEMORY_HIERARCHY', # TODO drop 'data': [ 'memory', 'first-level', 'second-level', 'third-level' ] } =20 ## @@ -713,7 +712,6 @@ # Since: 5.0 ## { 'enum': 'HmatLBDataType', - 'prefix': 'HMATLB_DATA_TYPE', # TODO drop 'data': [ 'access-latency', 'read-latency', 'write-latency', 'access-bandwidth', 'read-bandwidth', 'write-bandwidth' ] } =20 diff --git a/hw/core/numa.c b/hw/core/numa.c index f8ce332cfe..fb81c1ed51 100644 --- a/hw/core/numa.c +++ b/hw/core/numa.c @@ -249,7 +249,7 @@ void parse_numa_hmat_lb(NumaState *numa_state, NumaHmat= LBOptions *node, lb_data.initiator =3D node->initiator; lb_data.target =3D node->target; =20 - if (node->data_type <=3D HMATLB_DATA_TYPE_WRITE_LATENCY) { + if (node->data_type <=3D HMAT_LB_DATA_TYPE_WRITE_LATENCY) { /* Input latency data */ =20 if (!node->has_latency) { @@ -313,7 +313,7 @@ void parse_numa_hmat_lb(NumaState *numa_state, NumaHmat= LBOptions *node, numa_info[node->target].lb_info_provided |=3D BIT(0); } lb_data.data =3D node->latency; - } else if (node->data_type >=3D HMATLB_DATA_TYPE_ACCESS_BANDWIDTH) { + } else if (node->data_type >=3D HMAT_LB_DATA_TYPE_ACCESS_BANDWIDTH) { /* Input bandwidth data */ if (!node->has_bandwidth) { error_setg(errp, "Missing 'bandwidth' option"); diff --git a/hw/pci-bridge/cxl_upstream.c b/hw/pci-bridge/cxl_upstream.c index e51221a5f3..f3e46f0651 100644 --- a/hw/pci-bridge/cxl_upstream.c +++ b/hw/pci-bridge/cxl_upstream.c @@ -234,7 +234,7 @@ static int build_cdat_table(CDATSubHeader ***cdat_table= , void *priv) .type =3D CDAT_TYPE_SSLBIS, .length =3D sslbis_size, }, - .data_type =3D HMATLB_DATA_TYPE_ACCESS_LATENCY, + .data_type =3D HMAT_LB_DATA_TYPE_ACCESS_LATENCY, .entry_base_unit =3D 10000, }, }; @@ -254,7 +254,7 @@ static int build_cdat_table(CDATSubHeader ***cdat_table= , void *priv) .type =3D CDAT_TYPE_SSLBIS, .length =3D sslbis_size, }, - .data_type =3D HMATLB_DATA_TYPE_ACCESS_BANDWIDTH, + .data_type =3D HMAT_LB_DATA_TYPE_ACCESS_BANDWIDTH, .entry_base_unit =3D 1024, }, }; --=20 2.46.0 From nobody Sun Nov 24 05:28:16 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1725986876; cv=none; d=zohomail.com; s=zohoarc; b=DqLax8VVeeC79KjLWc3qkKC5YKXGHv+8rnKWXDBCmR+gRHcoRB2iG0/GiXlzthd3fWs+rjHiD8+LR3ArdnS5gGkDnP62F++mjigwHPILEAaL7VHD2qPPpnY9OEKpGMvvgCcWOeOSO7tAKuOD95JbFRY7HIacs/xIXhe2Mpr+5/g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1725986876; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=7TEeDRNI4nlkcZXLYiB+Dgz0gXilxg9iKvDeu32MDsY=; b=GEO+LlTdXmjFQE+AnGllAPzJ5wYgEiTUpzX1XzhqIJ1DIzVRLX1/hoaYu+VHHu5cckwS/q0FfbPWT3hagd5wLn3JeE0LqnBZr7jGWpmimqGWarT4hbstN8hfpumTq+xKpZmUU4+CD0UyN/CdNGNQetBOb/CRpVS8K9EZvckJyqc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1725986876964363.6479495946079; Tue, 10 Sep 2024 09:47:56 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1so41l-0007Bg-E8; Tue, 10 Sep 2024 12:47:41 -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 1so41b-0006rx-IN for qemu-devel@nongnu.org; Tue, 10 Sep 2024 12:47:34 -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 1so41V-0007Ze-Sr for qemu-devel@nongnu.org; Tue, 10 Sep 2024 12:47:30 -0400 Received: from mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-322-2WZ-qFHXPZqIwOPrBQeUtg-1; Tue, 10 Sep 2024 12:47:20 -0400 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id B52E919560AB; Tue, 10 Sep 2024 16:47:19 +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 1D4CF3001476; Tue, 10 Sep 2024 16:47:19 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 8BF7B21E68BD; Tue, 10 Sep 2024 18:47:14 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1725986845; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=7TEeDRNI4nlkcZXLYiB+Dgz0gXilxg9iKvDeu32MDsY=; b=fh7zL30DNWYqR25sjpIB435rC9mH4FE8bKqaFgoRWeQwvzc9VJ7JW+0XHrP5tGPrU2b3xc IZC79qfO68a7iwJmJBPRz9DuVUWmEgEjKefnzSLRpkSoFAHORZwFDDr9T49lQhM/rAZCSr t8bDa467IVAYLHsSD/KVtXN7qosUw50= X-MC-Unique: 2WZ-qFHXPZqIwOPrBQeUtg-1 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org Subject: [PULL 08/19] qapi/ui: Drop temporary 'prefix' Date: Tue, 10 Sep 2024 18:47:03 +0200 Message-ID: <20240910164714.1993531-9-armbru@redhat.com> In-Reply-To: <20240910164714.1993531-1-armbru@redhat.com> References: <20240910164714.1993531-1-armbru@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.145, 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, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1725986877550116600 Content-Type: text/plain; charset="utf-8" Recent commit "qapi: Smarter camel_to_upper() to reduce need for 'prefix'" added a temporary 'prefix' to delay changing the generated code. Revert it. This improves DisplayGLMode's generated enumeration constant prefix from DISPLAYGL_MODE to DISPLAY_GL_MODE. Signed-off-by: Markus Armbruster Message-ID: <20240904111836.3273842-9-armbru@redhat.com> --- qapi/ui.json | 1 - system/vl.c | 2 +- ui/dbus.c | 8 ++++---- ui/egl-context.c | 2 +- ui/egl-headless.c | 2 +- ui/egl-helpers.c | 12 ++++++------ ui/gtk.c | 4 ++-- ui/sdl2-gl.c | 8 ++++---- ui/sdl2.c | 2 +- ui/spice-core.c | 2 +- 10 files changed, 21 insertions(+), 22 deletions(-) diff --git a/qapi/ui.json b/qapi/ui.json index f61a2b6b65..460a26b981 100644 --- a/qapi/ui.json +++ b/qapi/ui.json @@ -1397,7 +1397,6 @@ # Since: 3.0 ## { 'enum' : 'DisplayGLMode', - 'prefix' : 'DISPLAYGL_MODE', # TODO drop 'data' : [ 'off', 'on', 'core', 'es' ] } =20 ## diff --git a/system/vl.c b/system/vl.c index 01b8b8e77a..fe547ca47c 100644 --- a/system/vl.c +++ b/system/vl.c @@ -1971,7 +1971,7 @@ static void qemu_create_early_backends(void) =20 qemu_console_early_init(); =20 - if (dpy.has_gl && dpy.gl !=3D DISPLAYGL_MODE_OFF && display_opengl =3D= =3D 0) { + if (dpy.has_gl && dpy.gl !=3D DISPLAY_GL_MODE_OFF && display_opengl = =3D=3D 0) { #if defined(CONFIG_OPENGL) error_report("OpenGL is not supported by display backend '%s'", DisplayType_str(dpy.type)); diff --git a/ui/dbus.c b/ui/dbus.c index e08b5de064..7ecd39e784 100644 --- a/ui/dbus.c +++ b/ui/dbus.c @@ -176,7 +176,7 @@ dbus_display_add_console(DBusDisplay *dd, int idx, Erro= r **errp) assert(con); =20 if (qemu_console_is_graphic(con) && - dd->gl_mode !=3D DISPLAYGL_MODE_OFF) { + dd->gl_mode !=3D DISPLAY_GL_MODE_OFF) { qemu_console_set_display_gl_ctx(con, &dd->glctx); } =20 @@ -466,9 +466,9 @@ static const TypeInfo dbus_vc_type_info =3D { static void early_dbus_init(DisplayOptions *opts) { - DisplayGLMode mode =3D opts->has_gl ? opts->gl : DISPLAYGL_MODE_OFF; + DisplayGLMode mode =3D opts->has_gl ? opts->gl : DISPLAY_GL_MODE_OFF; =20 - if (mode !=3D DISPLAYGL_MODE_OFF) { + if (mode !=3D DISPLAY_GL_MODE_OFF) { #ifdef CONFIG_OPENGL egl_init(opts->u.dbus.rendernode, mode, &error_fatal); #else @@ -482,7 +482,7 @@ early_dbus_init(DisplayOptions *opts) static void dbus_init(DisplayState *ds, DisplayOptions *opts) { - DisplayGLMode mode =3D opts->has_gl ? opts->gl : DISPLAYGL_MODE_OFF; + DisplayGLMode mode =3D opts->has_gl ? opts->gl : DISPLAY_GL_MODE_OFF; =20 if (opts->u.dbus.addr && opts->u.dbus.p2p) { error_report("dbus: can't accept both addr=3DX and p2p=3Dyes optio= ns"); diff --git a/ui/egl-context.c b/ui/egl-context.c index 9e0df466f3..aed3e3ba1f 100644 --- a/ui/egl-context.c +++ b/ui/egl-context.c @@ -17,7 +17,7 @@ QEMUGLContext qemu_egl_create_context(DisplayGLCtx *dgc, EGL_CONTEXT_MINOR_VERSION_KHR, params->minor_ver, EGL_NONE }; - bool gles =3D (qemu_egl_mode =3D=3D DISPLAYGL_MODE_ES); + bool gles =3D (qemu_egl_mode =3D=3D DISPLAY_GL_MODE_ES); =20 ctx =3D eglCreateContext(qemu_egl_display, qemu_egl_config, eglGetCurrentContext(), diff --git a/ui/egl-headless.c b/ui/egl-headless.c index 6187249c73..1f6b845500 100644 --- a/ui/egl-headless.c +++ b/ui/egl-headless.c @@ -207,7 +207,7 @@ static const DisplayGLCtxOps eglctx_ops =3D { =20 static void early_egl_headless_init(DisplayOptions *opts) { - DisplayGLMode mode =3D DISPLAYGL_MODE_ON; + DisplayGLMode mode =3D DISPLAY_GL_MODE_ON; =20 if (opts->has_gl) { mode =3D opts->gl; diff --git a/ui/egl-helpers.c b/ui/egl-helpers.c index 99b2ebbe23..81a57fa975 100644 --- a/ui/egl-helpers.c +++ b/ui/egl-helpers.c @@ -503,7 +503,7 @@ static int qemu_egl_init_dpy(EGLNativeDisplayType dpy, EGLint major, minor; EGLBoolean b; EGLint n; - bool gles =3D (mode =3D=3D DISPLAYGL_MODE_ES); + bool gles =3D (mode =3D=3D DISPLAY_GL_MODE_ES); =20 qemu_egl_display =3D qemu_egl_get_display(dpy, platform); if (qemu_egl_display =3D=3D EGL_NO_DISPLAY) { @@ -533,7 +533,7 @@ static int qemu_egl_init_dpy(EGLNativeDisplayType dpy, return -1; } =20 - qemu_egl_mode =3D gles ? DISPLAYGL_MODE_ES : DISPLAYGL_MODE_CORE; + qemu_egl_mode =3D gles ? DISPLAY_GL_MODE_ES : DISPLAY_GL_MODE_CORE; return 0; } =20 @@ -564,8 +564,8 @@ int qemu_egl_init_dpy_mesa(EGLNativeDisplayType dpy, Di= splayGLMode mode) int qemu_egl_init_dpy_win32(EGLNativeDisplayType dpy, DisplayGLMode mode) { /* prefer GL ES, as that's what ANGLE supports */ - if (mode =3D=3D DISPLAYGL_MODE_ON) { - mode =3D DISPLAYGL_MODE_ES; + if (mode =3D=3D DISPLAY_GL_MODE_ON) { + mode =3D DISPLAY_GL_MODE_ES; } =20 if (qemu_egl_init_dpy(dpy, 0, mode) < 0) { @@ -618,7 +618,7 @@ EGLContext qemu_egl_init_ctx(void) EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE }; - bool gles =3D (qemu_egl_mode =3D=3D DISPLAYGL_MODE_ES); + bool gles =3D (qemu_egl_mode =3D=3D DISPLAY_GL_MODE_ES); EGLContext ectx; EGLBoolean b; =20 @@ -642,7 +642,7 @@ bool egl_init(const char *rendernode, DisplayGLMode mod= e, Error **errp) { ERRP_GUARD(); =20 - if (mode =3D=3D DISPLAYGL_MODE_OFF) { + if (mode =3D=3D DISPLAY_GL_MODE_OFF) { error_setg(errp, "egl: turning off GL doesn't make sense"); return false; } diff --git a/ui/gtk.c b/ui/gtk.c index 8e14c2ac81..bf9d3dd679 100644 --- a/ui/gtk.c +++ b/ui/gtk.c @@ -2514,7 +2514,7 @@ static void early_gtk_display_init(DisplayOptions *op= ts) } =20 assert(opts->type =3D=3D DISPLAY_TYPE_GTK); - if (opts->has_gl && opts->gl !=3D DISPLAYGL_MODE_OFF) { + if (opts->has_gl && opts->gl !=3D DISPLAY_GL_MODE_OFF) { #if defined(CONFIG_OPENGL) #if defined(GDK_WINDOWING_WAYLAND) if (GDK_IS_WAYLAND_DISPLAY(gdk_display_get_default())) { @@ -2530,7 +2530,7 @@ static void early_gtk_display_init(DisplayOptions *op= ts) #endif { #ifdef CONFIG_X11 - DisplayGLMode mode =3D opts->has_gl ? opts->gl : DISPLAYGL_MOD= E_ON; + DisplayGLMode mode =3D opts->has_gl ? opts->gl : DISPLAY_GL_MO= DE_ON; gtk_egl_init(mode); #endif } diff --git a/ui/sdl2-gl.c b/ui/sdl2-gl.c index 91b7ee2419..e01d9ab0c7 100644 --- a/ui/sdl2-gl.c +++ b/ui/sdl2-gl.c @@ -147,11 +147,11 @@ QEMUGLContext sdl2_gl_create_context(DisplayGLCtx *dg= c, SDL_GL_MakeCurrent(scon->real_window, scon->winctx); =20 SDL_GL_SetAttribute(SDL_GL_SHARE_WITH_CURRENT_CONTEXT, 1); - if (scon->opts->gl =3D=3D DISPLAYGL_MODE_ON || - scon->opts->gl =3D=3D DISPLAYGL_MODE_CORE) { + if (scon->opts->gl =3D=3D DISPLAY_GL_MODE_ON || + scon->opts->gl =3D=3D DISPLAY_GL_MODE_CORE) { SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE); - } else if (scon->opts->gl =3D=3D DISPLAYGL_MODE_ES) { + } else if (scon->opts->gl =3D=3D DISPLAY_GL_MODE_ES) { SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_ES); } @@ -163,7 +163,7 @@ QEMUGLContext sdl2_gl_create_context(DisplayGLCtx *dgc, /* If SDL fail to create a GL context and we use the "on" flag, * then try to fallback to GLES. */ - if (!ctx && scon->opts->gl =3D=3D DISPLAYGL_MODE_ON) { + if (!ctx && scon->opts->gl =3D=3D DISPLAY_GL_MODE_ON) { SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_ES); ctx =3D SDL_GL_CreateContext(scon->real_window); diff --git a/ui/sdl2.c b/ui/sdl2.c index 98ed974371..251ce97796 100644 --- a/ui/sdl2.c +++ b/ui/sdl2.c @@ -107,7 +107,7 @@ void sdl2_window_create(struct sdl2_console *scon) if (scon->opengl) { const char *driver =3D "opengl"; =20 - if (scon->opts->gl =3D=3D DISPLAYGL_MODE_ES) { + if (scon->opts->gl =3D=3D DISPLAY_GL_MODE_ES) { driver =3D "opengles2"; } =20 diff --git a/ui/spice-core.c b/ui/spice-core.c index 15be640286..bd9dbe03f1 100644 --- a/ui/spice-core.c +++ b/ui/spice-core.c @@ -840,7 +840,7 @@ static void qemu_spice_init(void) "incompatible with -spice port/tls-port"); exit(1); } - egl_init(qemu_opt_get(opts, "rendernode"), DISPLAYGL_MODE_ON, &err= or_fatal); + egl_init(qemu_opt_get(opts, "rendernode"), DISPLAY_GL_MODE_ON, &er= ror_fatal); spice_opengl =3D 1; } #endif --=20 2.46.0 From nobody Sun Nov 24 05:28:16 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1725987005; cv=none; d=zohomail.com; s=zohoarc; b=DyoTVylA2XB47FDjk7oSRmRbT3JrHA0B7xPA97VAN8LPbWRpgupxvj7jSSyE+DI3yWeh5P2Gm4MP4hg1UhshTyEtWA7zGUIPuRpiHLCYnUQ+xFtJENWtWn7MviRNArlJwf37ORG1tnDkrtkuq2WOTbuXf0B03hLEQwDsB+N2Qks= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1725987005; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=8fMon+YxTIxS+k58/Zsqce2WkPiMQU1CcnAkwRuN4bU=; b=iC0k63N9jUTUDiH+VBaAn7/dWZy01/JXWUHKRD+pEAoQoE/a2HyVpRUCz8dl9u6zrEAVlq/Vr5fAlTErA5o1LJweXydW/2uZ2gM0mnqu0JYVtM/QVLUSDQGY9OpxTOJdbymqh7uKS3k+Iz2XWVHUuWBEOe8BILNERRyEgcwsod4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 172598700566759.783287254641095; Tue, 10 Sep 2024 09:50:05 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1so41o-0007Mr-9v; Tue, 10 Sep 2024 12:47:44 -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 1so41X-0006jq-Ey for qemu-devel@nongnu.org; Tue, 10 Sep 2024 12:47:27 -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 1so41U-0007Yr-I2 for qemu-devel@nongnu.org; Tue, 10 Sep 2024 12:47:27 -0400 Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-553-tpx7mYeKMbeD91VPcSIiKQ-1; Tue, 10 Sep 2024 12:47:20 -0400 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id B050E1955F45; Tue, 10 Sep 2024 16:47:19 +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 34E2A19560A3; Tue, 10 Sep 2024 16:47:19 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 8F14621E681A; Tue, 10 Sep 2024 18:47:14 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1725986843; 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=8fMon+YxTIxS+k58/Zsqce2WkPiMQU1CcnAkwRuN4bU=; b=dq6plg4wNmOKlXYf/1IlsWuVjwmq4u1PVp8gn/7aIltpTnM3b5gwy8C/V6CWxm3qO5P9nC +l62axOgbQyaFY+VXeS6TWShifd5Ss0ecQxev6QdE1ju+giunLO0oi2mY2K7VBitu7AtjS uWXHXaLdmzRz8UX9jws6MrZ6WyM5PAQ= X-MC-Unique: tpx7mYeKMbeD91VPcSIiKQ-1 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org, =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Zhao Liu , Thomas Huth Subject: [PULL 09/19] qapi/machine: Rename CpuS390* to S390Cpu*, and drop 'prefix' Date: Tue, 10 Sep 2024 18:47:04 +0200 Message-ID: <20240910164714.1993531-10-armbru@redhat.com> In-Reply-To: <20240910164714.1993531-1-armbru@redhat.com> References: <20240910164714.1993531-1-armbru@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.145, 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, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1725987006048116600 QAPI's 'prefix' feature can make the connection between enumeration type and its constants less than obvious. It's best used with restraint. CpuS390Entitlement has a 'prefix' to change the generated enumeration constants' prefix from CPU_S390_ENTITLEMENT to S390_CPU_ENTITLEMENT. Rename the type to S390CpuEntitlement, so that 'prefix' is not needed. Likewise change CpuS390Polarization to S390CpuPolarization, and CpuS390State to S390CpuState. Signed-off-by: Markus Armbruster Reviewed-by: Daniel P. Berrang=C3=A9 Reviewed-by: Zhao Liu Acked-by: Thomas Huth Message-ID: <20240904111836.3273842-10-armbru@redhat.com> --- qapi/machine-common.json | 5 ++--- qapi/machine-target.json | 11 +++++------ qapi/machine.json | 9 ++++----- qapi/pragma.json | 6 +++--- include/hw/qdev-properties-system.h | 2 +- include/hw/s390x/cpu-topology.h | 2 +- target/s390x/cpu.h | 2 +- hw/core/qdev-properties-system.c | 6 +++--- hw/s390x/cpu-topology.c | 6 +++--- 9 files changed, 23 insertions(+), 26 deletions(-) diff --git a/qapi/machine-common.json b/qapi/machine-common.json index fa6bd71d12..b64e4895cf 100644 --- a/qapi/machine-common.json +++ b/qapi/machine-common.json @@ -9,13 +9,12 @@ ## =20 ## -# @CpuS390Entitlement: +# @S390CpuEntitlement: # # An enumeration of CPU entitlements that can be assumed by a virtual # S390 CPU # # Since: 8.2 ## -{ 'enum': 'CpuS390Entitlement', - 'prefix': 'S390_CPU_ENTITLEMENT', +{ 'enum': 'S390CpuEntitlement', 'data': [ 'auto', 'low', 'medium', 'high' ] } diff --git a/qapi/machine-target.json b/qapi/machine-target.json index 1a394c08f5..541f93eeb7 100644 --- a/qapi/machine-target.json +++ b/qapi/machine-target.json @@ -405,15 +405,14 @@ 'TARGET_RISCV' ] } } =20 ## -# @CpuS390Polarization: +# @S390CpuPolarization: # # An enumeration of CPU polarization that can be assumed by a virtual # S390 CPU # # Since: 8.2 ## -{ 'enum': 'CpuS390Polarization', - 'prefix': 'S390_CPU_POLARIZATION', +{ 'enum': 'S390CpuPolarization', 'data': [ 'horizontal', 'vertical' ], 'if': 'TARGET_S390X' } @@ -450,7 +449,7 @@ '*socket-id': 'uint16', '*book-id': 'uint16', '*drawer-id': 'uint16', - '*entitlement': 'CpuS390Entitlement', + '*entitlement': 'S390CpuEntitlement', '*dedicated': 'bool' }, 'features': [ 'unstable' ], @@ -488,7 +487,7 @@ # "timestamp": { "seconds": 1401385907, "microseconds": 422329 } } ## { 'event': 'CPU_POLARIZATION_CHANGE', - 'data': { 'polarization': 'CpuS390Polarization' }, + 'data': { 'polarization': 'S390CpuPolarization' }, 'features': [ 'unstable' ], 'if': { 'all': [ 'TARGET_S390X', 'CONFIG_KVM' ] } } @@ -503,7 +502,7 @@ # Since: 8.2 ## { 'struct': 'CpuPolarizationInfo', - 'data': { 'polarization': 'CpuS390Polarization' }, + 'data': { 'polarization': 'S390CpuPolarization' }, 'if': { 'all': [ 'TARGET_S390X', 'CONFIG_KVM' ] } } =20 diff --git a/qapi/machine.json b/qapi/machine.json index d4317435e7..63a5eb0070 100644 --- a/qapi/machine.json +++ b/qapi/machine.json @@ -41,15 +41,14 @@ 'x86_64', 'xtensa', 'xtensaeb' ] } =20 ## -# @CpuS390State: +# @S390CpuState: # # An enumeration of cpu states that can be assumed by a virtual S390 # CPU # # Since: 2.12 ## -{ 'enum': 'CpuS390State', - 'prefix': 'S390_CPU_STATE', +{ 'enum': 'S390CpuState', 'data': [ 'uninitialized', 'stopped', 'check-stop', 'operating', 'load' = ] } =20 ## @@ -66,9 +65,9 @@ # Since: 2.12 ## { 'struct': 'CpuInfoS390', - 'data': { 'cpu-state': 'CpuS390State', + 'data': { 'cpu-state': 'S390CpuState', '*dedicated': 'bool', - '*entitlement': 'CpuS390Entitlement' } } + '*entitlement': 'S390CpuEntitlement' } } =20 ## # @CpuInfoFast: diff --git a/qapi/pragma.json b/qapi/pragma.json index 59fbe74b8c..fad3a31628 100644 --- a/qapi/pragma.json +++ b/qapi/pragma.json @@ -47,9 +47,6 @@ 'BlockdevSnapshotWrapper', 'BlockdevVmdkAdapterType', 'ChardevBackendKind', - 'CpuS390Entitlement', - 'CpuS390Polarization', - 'CpuS390State', 'CxlCorErrorType', 'DisplayProtocol', 'DriveBackupWrapper', @@ -74,6 +71,9 @@ 'QKeyCode', 'RbdAuthMode', 'RbdImageEncryptionFormat', + 'S390CpuEntitlement', + 'S390CpuPolarization', + 'S390CpuState', 'String', 'StringWrapper', 'SysEmuTarget', diff --git a/include/hw/qdev-properties-system.h b/include/hw/qdev-properti= es-system.h index 438f65389f..cdcc63056e 100644 --- a/include/hw/qdev-properties-system.h +++ b/include/hw/qdev-properties-system.h @@ -88,7 +88,7 @@ extern const PropertyInfo qdev_prop_iothread_vq_mapping_l= ist; =20 #define DEFINE_PROP_CPUS390ENTITLEMENT(_n, _s, _f, _d) \ DEFINE_PROP_SIGNED(_n, _s, _f, _d, qdev_prop_cpus390entitlement, \ - CpuS390Entitlement) + S390CpuEntitlement) =20 #define DEFINE_PROP_IOTHREAD_VQ_MAPPING_LIST(_name, _state, _field) \ DEFINE_PROP(_name, _state, _field, qdev_prop_iothread_vq_mapping_list,= \ diff --git a/include/hw/s390x/cpu-topology.h b/include/hw/s390x/cpu-topolog= y.h index c064f427e9..a11b1baa77 100644 --- a/include/hw/s390x/cpu-topology.h +++ b/include/hw/s390x/cpu-topology.h @@ -37,7 +37,7 @@ typedef struct S390TopologyEntry { =20 typedef struct S390Topology { uint8_t *cores_per_socket; - CpuS390Polarization polarization; + S390CpuPolarization polarization; } S390Topology; =20 typedef QTAILQ_HEAD(, S390TopologyEntry) S390TopologyList; diff --git a/target/s390x/cpu.h b/target/s390x/cpu.h index d6b75ad0e0..6cbd77dfdf 100644 --- a/target/s390x/cpu.h +++ b/target/s390x/cpu.h @@ -133,7 +133,7 @@ typedef struct CPUArchState { int32_t book_id; int32_t drawer_id; bool dedicated; - CpuS390Entitlement entitlement; /* Used only for vertical polarization= */ + S390CpuEntitlement entitlement; /* Used only for vertical polarization= */ uint64_t cpuid; #endif =20 diff --git a/hw/core/qdev-properties-system.c b/hw/core/qdev-properties-sys= tem.c index f13350b4fb..f2db20417a 100644 --- a/hw/core/qdev-properties-system.c +++ b/hw/core/qdev-properties-system.c @@ -1188,12 +1188,12 @@ const PropertyInfo qdev_prop_uuid =3D { =20 /* --- s390 cpu entitlement policy --- */ =20 -QEMU_BUILD_BUG_ON(sizeof(CpuS390Entitlement) !=3D sizeof(int)); +QEMU_BUILD_BUG_ON(sizeof(S390CpuEntitlement) !=3D sizeof(int)); =20 const PropertyInfo qdev_prop_cpus390entitlement =3D { - .name =3D "CpuS390Entitlement", + .name =3D "S390CpuEntitlement", .description =3D "low/medium (default)/high", - .enum_table =3D &CpuS390Entitlement_lookup, + .enum_table =3D &S390CpuEntitlement_lookup, .get =3D qdev_propinfo_get_enum, .set =3D qdev_propinfo_set_enum, .set_default_value =3D qdev_propinfo_set_default_value_enum, diff --git a/hw/s390x/cpu-topology.c b/hw/s390x/cpu-topology.c index f16bdf65fa..7d4e1f5472 100644 --- a/hw/s390x/cpu-topology.c +++ b/hw/s390x/cpu-topology.c @@ -105,7 +105,7 @@ static void s390_topology_init(MachineState *ms) */ void s390_handle_ptf(S390CPU *cpu, uint8_t r1, uintptr_t ra) { - CpuS390Polarization polarization; + S390CpuPolarization polarization; CPUS390XState *env =3D &cpu->env; uint64_t reg =3D env->regs[r1]; int fc =3D reg & S390_TOPO_FC_MASK; @@ -357,7 +357,7 @@ static void s390_change_topology(uint16_t core_id, bool has_book_id, uint16_t book_id, bool has_drawer_id, uint16_t drawer_id, bool has_entitlement, - CpuS390Entitlement entitlement, + S390CpuEntitlement entitlement, bool has_dedicated, bool dedicated, Error **errp) { @@ -446,7 +446,7 @@ void qmp_set_cpu_topology(uint16_t core, bool has_socket, uint16_t socket, bool has_book, uint16_t book, bool has_drawer, uint16_t drawer, - bool has_entitlement, CpuS390Entitlement entitle= ment, + bool has_entitlement, S390CpuEntitlement entitle= ment, bool has_dedicated, bool dedicated, Error **errp) { --=20 2.46.0 From nobody Sun Nov 24 05:28:16 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1725986976; cv=none; d=zohomail.com; s=zohoarc; b=BhdtIi4WECvCZrxPmqvlYXgGzDkJSzB3M6ew2Jh3f5Sg0dbuYCSuly4h/2Lai755+fjHMTWxr9bP5H+8y2TNHBX15thbSFxXZFn1dwL++W2ooHRU8prBX8LRMD0TlNlDdB/w6yVoHsQm4cBPqmtbTU2cRK/bAB4F15LbTFn38hQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1725986976; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=PydUzejW3OmfbnNZOGPbw9odvqLIxws3j18KThH2+9g=; b=HHugOG5lwSu9NtIUL6XQI9um+0G+bnVuqMK/+1E1u/W+l8oSv5MjR+SapV1TzZFwecC1odwfRrIiUiO27sXBN1luUHUTEXHpqFQlfDE5VCFuNTmxqprJgF7j6lUxzo+twlryim0rrITXruSUDZeK4TzSQOPXGIdOCNolRANSRQU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1725986976310114.70265376323039; Tue, 10 Sep 2024 09:49:36 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1so41m-0007GN-Ms; Tue, 10 Sep 2024 12:47:42 -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 1so41Z-0006nM-LH for qemu-devel@nongnu.org; Tue, 10 Sep 2024 12:47:29 -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 1so41V-0007ZD-1t for qemu-devel@nongnu.org; Tue, 10 Sep 2024 12:47:29 -0400 Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-352-89mGMmzDMKCu1URXx3wcaw-1; Tue, 10 Sep 2024 12:47:21 -0400 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 106D21955F3D; Tue, 10 Sep 2024 16:47:20 +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 526FD1956052; Tue, 10 Sep 2024 16:47:19 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 921A121E6828; Tue, 10 Sep 2024 18:47:14 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1725986844; 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=PydUzejW3OmfbnNZOGPbw9odvqLIxws3j18KThH2+9g=; b=GMQ4xetglBTC156LLwXpAcArGNsuJbeEgC2vri4zTmx0/DPYwvfmXqHzQdeyOl5AzDPqHF 0XE1937nZcI0ySi45ns9d0a7o0tRxcJ4IrZYnEivUSK51iiOBnUPvGvzDjg1qMo8Az0zhD MZ6v+AFhnloTRoFw5axBWW88nllUQdQ= X-MC-Unique: 89mGMmzDMKCu1URXx3wcaw-1 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org, =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= Subject: [PULL 10/19] qapi/crypto: Drop unwanted 'prefix' Date: Tue, 10 Sep 2024 18:47:05 +0200 Message-ID: <20240910164714.1993531-11-armbru@redhat.com> In-Reply-To: <20240910164714.1993531-1-armbru@redhat.com> References: <20240910164714.1993531-1-armbru@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.145, 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, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1725986977893116600 QAPI's 'prefix' feature can make the connection between enumeration type and its constants less than obvious. It's best used with restraint. QCryptoAkCipherKeyType has a 'prefix' that overrides the generated enumeration constants' prefix to QCRYPTO_AKCIPHER_KEY_TYPE. Drop it. The prefix becomes QCRYPTO_AK_CIPHER_KEY_TYPE. Signed-off-by: Markus Armbruster Acked-by: Daniel P. Berrang=C3=A9 Message-ID: <20240904111836.3273842-11-armbru@redhat.com> --- qapi/crypto.json | 1 - backends/cryptodev-builtin.c | 4 ++-- backends/cryptodev-lkcf.c | 6 +++--- tests/bench/benchmark-crypto-akcipher.c | 2 +- tests/unit/test-crypto-akcipher.c | 28 ++++++++++++------------- crypto/akcipher-gcrypt.c.inc | 8 +++---- crypto/akcipher-nettle.c.inc | 8 +++---- crypto/rsakey-builtin.c.inc | 4 ++-- crypto/rsakey-nettle.c.inc | 4 ++-- 9 files changed, 32 insertions(+), 33 deletions(-) diff --git a/qapi/crypto.json b/qapi/crypto.json index fb00c706b2..b5c25e7cd9 100644 --- a/qapi/crypto.json +++ b/qapi/crypto.json @@ -609,7 +609,6 @@ # Since: 7.1 ## { 'enum': 'QCryptoAkCipherKeyType', - 'prefix': 'QCRYPTO_AKCIPHER_KEY_TYPE', 'data': ['public', 'private']} =20 ## diff --git a/backends/cryptodev-builtin.c b/backends/cryptodev-builtin.c index 940104ee55..e95af9bb72 100644 --- a/backends/cryptodev-builtin.c +++ b/backends/cryptodev-builtin.c @@ -334,11 +334,11 @@ static int cryptodev_builtin_create_akcipher_session( =20 switch (sess_info->keytype) { case VIRTIO_CRYPTO_AKCIPHER_KEY_TYPE_PUBLIC: - type =3D QCRYPTO_AKCIPHER_KEY_TYPE_PUBLIC; + type =3D QCRYPTO_AK_CIPHER_KEY_TYPE_PUBLIC; break; =20 case VIRTIO_CRYPTO_AKCIPHER_KEY_TYPE_PRIVATE: - type =3D QCRYPTO_AKCIPHER_KEY_TYPE_PRIVATE; + type =3D QCRYPTO_AK_CIPHER_KEY_TYPE_PRIVATE; break; =20 default: diff --git a/backends/cryptodev-lkcf.c b/backends/cryptodev-lkcf.c index 45aba1ff67..e1ee11a158 100644 --- a/backends/cryptodev-lkcf.c +++ b/backends/cryptodev-lkcf.c @@ -322,7 +322,7 @@ static void cryptodev_lkcf_execute_task(CryptoDevLKCFTa= sk *task) * 2. generally, public key related compution is fast, just compute it= with * thread-pool. */ - if (session->keytype =3D=3D QCRYPTO_AKCIPHER_KEY_TYPE_PRIVATE) { + if (session->keytype =3D=3D QCRYPTO_AK_CIPHER_KEY_TYPE_PRIVATE) { if (qcrypto_akcipher_export_p8info(&session->akcipher_opts, session->key, session->keylen, &p8info, &p8info_len, @@ -534,11 +534,11 @@ static int cryptodev_lkcf_create_asym_session( =20 switch (sess_info->keytype) { case VIRTIO_CRYPTO_AKCIPHER_KEY_TYPE_PUBLIC: - sess->keytype =3D QCRYPTO_AKCIPHER_KEY_TYPE_PUBLIC; + sess->keytype =3D QCRYPTO_AK_CIPHER_KEY_TYPE_PUBLIC; break; =20 case VIRTIO_CRYPTO_AKCIPHER_KEY_TYPE_PRIVATE: - sess->keytype =3D QCRYPTO_AKCIPHER_KEY_TYPE_PRIVATE; + sess->keytype =3D QCRYPTO_AK_CIPHER_KEY_TYPE_PRIVATE; break; =20 default: diff --git a/tests/bench/benchmark-crypto-akcipher.c b/tests/bench/benchmar= k-crypto-akcipher.c index 5e68cb0a1c..bbc29c9b12 100644 --- a/tests/bench/benchmark-crypto-akcipher.c +++ b/tests/bench/benchmark-crypto-akcipher.c @@ -28,7 +28,7 @@ static QCryptoAkCipher *create_rsa_akcipher(const uint8_t= *priv_key, opt.alg =3D QCRYPTO_AKCIPHER_ALG_RSA; opt.u.rsa.padding_alg =3D padding; opt.u.rsa.hash_alg =3D hash; - return qcrypto_akcipher_new(&opt, QCRYPTO_AKCIPHER_KEY_TYPE_PRIVATE, + return qcrypto_akcipher_new(&opt, QCRYPTO_AK_CIPHER_KEY_TYPE_PRIVATE, priv_key, keylen, &error_abort); } =20 diff --git a/tests/unit/test-crypto-akcipher.c b/tests/unit/test-crypto-akc= ipher.c index 4f1f4214dd..59bc6f1e69 100644 --- a/tests/unit/test-crypto-akcipher.c +++ b/tests/unit/test-crypto-akcipher.c @@ -692,7 +692,7 @@ struct QCryptoAkCipherTestData { static QCryptoRSAKeyTestData rsakey_test_data[] =3D { { .path =3D "/crypto/akcipher/rsakey-1024-public", - .key_type =3D QCRYPTO_AKCIPHER_KEY_TYPE_PUBLIC, + .key_type =3D QCRYPTO_AK_CIPHER_KEY_TYPE_PUBLIC, .key =3D rsa1024_public_key, .keylen =3D sizeof(rsa1024_public_key), .is_valid_key =3D true, @@ -700,7 +700,7 @@ static QCryptoRSAKeyTestData rsakey_test_data[] =3D { }, { .path =3D "/crypto/akcipher/rsakey-1024-private", - .key_type =3D QCRYPTO_AKCIPHER_KEY_TYPE_PRIVATE, + .key_type =3D QCRYPTO_AK_CIPHER_KEY_TYPE_PRIVATE, .key =3D rsa1024_private_key, .keylen =3D sizeof(rsa1024_private_key), .is_valid_key =3D true, @@ -708,7 +708,7 @@ static QCryptoRSAKeyTestData rsakey_test_data[] =3D { }, { .path =3D "/crypto/akcipher/rsakey-2048-public", - .key_type =3D QCRYPTO_AKCIPHER_KEY_TYPE_PUBLIC, + .key_type =3D QCRYPTO_AK_CIPHER_KEY_TYPE_PUBLIC, .key =3D rsa2048_public_key, .keylen =3D sizeof(rsa2048_public_key), .is_valid_key =3D true, @@ -716,7 +716,7 @@ static QCryptoRSAKeyTestData rsakey_test_data[] =3D { }, { .path =3D "/crypto/akcipher/rsakey-2048-private", - .key_type =3D QCRYPTO_AKCIPHER_KEY_TYPE_PRIVATE, + .key_type =3D QCRYPTO_AK_CIPHER_KEY_TYPE_PRIVATE, .key =3D rsa2048_private_key, .keylen =3D sizeof(rsa2048_private_key), .is_valid_key =3D true, @@ -724,56 +724,56 @@ static QCryptoRSAKeyTestData rsakey_test_data[] =3D { }, { .path =3D "/crypto/akcipher/rsakey-public-lack-elem", - .key_type =3D QCRYPTO_AKCIPHER_KEY_TYPE_PUBLIC, + .key_type =3D QCRYPTO_AK_CIPHER_KEY_TYPE_PUBLIC, .key =3D rsa_public_key_lack_element, .keylen =3D sizeof(rsa_public_key_lack_element), .is_valid_key =3D false, }, { .path =3D "/crypto/akcipher/rsakey-private-lack-elem", - .key_type =3D QCRYPTO_AKCIPHER_KEY_TYPE_PRIVATE, + .key_type =3D QCRYPTO_AK_CIPHER_KEY_TYPE_PRIVATE, .key =3D rsa_private_key_lack_element, .keylen =3D sizeof(rsa_private_key_lack_element), .is_valid_key =3D false, }, { .path =3D "/crypto/akcipher/rsakey-public-empty-elem", - .key_type =3D QCRYPTO_AKCIPHER_KEY_TYPE_PUBLIC, + .key_type =3D QCRYPTO_AK_CIPHER_KEY_TYPE_PUBLIC, .key =3D rsa_public_key_empty_element, .keylen =3D sizeof(rsa_public_key_empty_element), .is_valid_key =3D false, }, { .path =3D "/crypto/akcipher/rsakey-private-empty-elem", - .key_type =3D QCRYPTO_AKCIPHER_KEY_TYPE_PRIVATE, + .key_type =3D QCRYPTO_AK_CIPHER_KEY_TYPE_PRIVATE, .key =3D rsa_private_key_empty_element, .keylen =3D sizeof(rsa_private_key_empty_element), .is_valid_key =3D false, }, { .path =3D "/crypto/akcipher/rsakey-public-empty-key", - .key_type =3D QCRYPTO_AKCIPHER_KEY_TYPE_PUBLIC, + .key_type =3D QCRYPTO_AK_CIPHER_KEY_TYPE_PUBLIC, .key =3D NULL, .keylen =3D 0, .is_valid_key =3D false, }, { .path =3D "/crypto/akcipher/rsakey-private-empty-key", - .key_type =3D QCRYPTO_AKCIPHER_KEY_TYPE_PRIVATE, + .key_type =3D QCRYPTO_AK_CIPHER_KEY_TYPE_PRIVATE, .key =3D NULL, .keylen =3D 0, .is_valid_key =3D false, }, { .path =3D "/crypto/akcipher/rsakey-public-invalid-length-val", - .key_type =3D QCRYPTO_AKCIPHER_KEY_TYPE_PUBLIC, + .key_type =3D QCRYPTO_AK_CIPHER_KEY_TYPE_PUBLIC, .key =3D rsa_public_key_invalid_length_val, .keylen =3D sizeof(rsa_public_key_invalid_length_val), .is_valid_key =3D false, }, { .path =3D "/crypto/akcipher/rsakey-public-extra-elem", - .key_type =3D QCRYPTO_AKCIPHER_KEY_TYPE_PUBLIC, + .key_type =3D QCRYPTO_AK_CIPHER_KEY_TYPE_PUBLIC, .key =3D rsa_public_key_extra_elem, .keylen =3D sizeof(rsa_public_key_extra_elem), .is_valid_key =3D false, @@ -885,12 +885,12 @@ static void test_akcipher(const void *opaque) return; } pub_key =3D qcrypto_akcipher_new(&data->opt, - QCRYPTO_AKCIPHER_KEY_TYPE_PUBLIC, + QCRYPTO_AK_CIPHER_KEY_TYPE_PUBLIC, data->pub_key, data->pub_key_len, &error_abort); g_assert(pub_key !=3D NULL); priv_key =3D qcrypto_akcipher_new(&data->opt, - QCRYPTO_AKCIPHER_KEY_TYPE_PRIVATE, + QCRYPTO_AK_CIPHER_KEY_TYPE_PRIVATE, data->priv_key, data->priv_key_len, &error_abort); g_assert(priv_key !=3D NULL); diff --git a/crypto/akcipher-gcrypt.c.inc b/crypto/akcipher-gcrypt.c.inc index abb1fb272e..e942d43421 100644 --- a/crypto/akcipher-gcrypt.c.inc +++ b/crypto/akcipher-gcrypt.c.inc @@ -85,7 +85,7 @@ static int qcrypto_gcrypt_parse_rsa_private_key( const uint8_t *key, size_t keylen, Error **errp) { g_autoptr(QCryptoAkCipherRSAKey) rsa_key =3D qcrypto_akcipher_rsakey_p= arse( - QCRYPTO_AKCIPHER_KEY_TYPE_PRIVATE, key, keylen, errp); + QCRYPTO_AK_CIPHER_KEY_TYPE_PRIVATE, key, keylen, errp); gcry_mpi_t n =3D NULL, e =3D NULL, d =3D NULL, p =3D NULL, q =3D NULL,= u =3D NULL; bool compute_mul_inv =3D false; int ret =3D -1; @@ -178,7 +178,7 @@ static int qcrypto_gcrypt_parse_rsa_public_key(QCryptoG= cryptRSA *rsa, { =20 g_autoptr(QCryptoAkCipherRSAKey) rsa_key =3D qcrypto_akcipher_rsakey_p= arse( - QCRYPTO_AKCIPHER_KEY_TYPE_PUBLIC, key, keylen, errp); + QCRYPTO_AK_CIPHER_KEY_TYPE_PUBLIC, key, keylen, errp); gcry_mpi_t n =3D NULL, e =3D NULL; int ret =3D -1; gcry_error_t err; @@ -540,13 +540,13 @@ static QCryptoGcryptRSA *qcrypto_gcrypt_rsa_new( rsa->akcipher.driver =3D &gcrypt_rsa; =20 switch (type) { - case QCRYPTO_AKCIPHER_KEY_TYPE_PRIVATE: + case QCRYPTO_AK_CIPHER_KEY_TYPE_PRIVATE: if (qcrypto_gcrypt_parse_rsa_private_key(rsa, key, keylen, errp) != =3D 0) { goto error; } break; =20 - case QCRYPTO_AKCIPHER_KEY_TYPE_PUBLIC: + case QCRYPTO_AK_CIPHER_KEY_TYPE_PUBLIC: if (qcrypto_gcrypt_parse_rsa_public_key(rsa, key, keylen, errp) != =3D 0) { goto error; } diff --git a/crypto/akcipher-nettle.c.inc b/crypto/akcipher-nettle.c.inc index 02699e6e6d..62ac8699c4 100644 --- a/crypto/akcipher-nettle.c.inc +++ b/crypto/akcipher-nettle.c.inc @@ -87,7 +87,7 @@ static int qcrypt_nettle_parse_rsa_private_key(QCryptoNet= tleRSA *rsa, Error **errp) { g_autoptr(QCryptoAkCipherRSAKey) rsa_key =3D qcrypto_akcipher_rsakey_p= arse( - QCRYPTO_AKCIPHER_KEY_TYPE_PRIVATE, key, keylen, errp); + QCRYPTO_AK_CIPHER_KEY_TYPE_PRIVATE, key, keylen, errp); =20 if (!rsa_key) { return -1; @@ -137,7 +137,7 @@ static int qcrypt_nettle_parse_rsa_public_key(QCryptoNe= ttleRSA *rsa, Error **errp) { g_autoptr(QCryptoAkCipherRSAKey) rsa_key =3D qcrypto_akcipher_rsakey_p= arse( - QCRYPTO_AKCIPHER_KEY_TYPE_PUBLIC, key, keylen, errp); + QCRYPTO_AK_CIPHER_KEY_TYPE_PUBLIC, key, keylen, errp); =20 if (!rsa_key) { return -1; @@ -397,13 +397,13 @@ static QCryptoAkCipher *qcrypto_nettle_rsa_new( rsa_private_key_init(&rsa->priv); =20 switch (type) { - case QCRYPTO_AKCIPHER_KEY_TYPE_PRIVATE: + case QCRYPTO_AK_CIPHER_KEY_TYPE_PRIVATE: if (qcrypt_nettle_parse_rsa_private_key(rsa, key, keylen, errp) != =3D 0) { goto error; } break; =20 - case QCRYPTO_AKCIPHER_KEY_TYPE_PUBLIC: + case QCRYPTO_AK_CIPHER_KEY_TYPE_PUBLIC: if (qcrypt_nettle_parse_rsa_public_key(rsa, key, keylen, errp) != =3D 0) { goto error; } diff --git a/crypto/rsakey-builtin.c.inc b/crypto/rsakey-builtin.c.inc index 46cc7afe87..6337b84c54 100644 --- a/crypto/rsakey-builtin.c.inc +++ b/crypto/rsakey-builtin.c.inc @@ -183,10 +183,10 @@ QCryptoAkCipherRSAKey *qcrypto_akcipher_rsakey_parse( size_t keylen, Error **errp) { switch (type) { - case QCRYPTO_AKCIPHER_KEY_TYPE_PRIVATE: + case QCRYPTO_AK_CIPHER_KEY_TYPE_PRIVATE: return qcrypto_builtin_rsa_private_key_parse(key, keylen, errp); =20 - case QCRYPTO_AKCIPHER_KEY_TYPE_PUBLIC: + case QCRYPTO_AK_CIPHER_KEY_TYPE_PUBLIC: return qcrypto_builtin_rsa_public_key_parse(key, keylen, errp); =20 default: diff --git a/crypto/rsakey-nettle.c.inc b/crypto/rsakey-nettle.c.inc index cc49872e78..b7f34b0234 100644 --- a/crypto/rsakey-nettle.c.inc +++ b/crypto/rsakey-nettle.c.inc @@ -145,10 +145,10 @@ QCryptoAkCipherRSAKey *qcrypto_akcipher_rsakey_parse( size_t keylen, Error **errp) { switch (type) { - case QCRYPTO_AKCIPHER_KEY_TYPE_PRIVATE: + case QCRYPTO_AK_CIPHER_KEY_TYPE_PRIVATE: return qcrypto_nettle_rsa_private_key_parse(key, keylen, errp); =20 - case QCRYPTO_AKCIPHER_KEY_TYPE_PUBLIC: + case QCRYPTO_AK_CIPHER_KEY_TYPE_PUBLIC: return qcrypto_nettle_rsa_public_key_parse(key, keylen, errp); =20 default: --=20 2.46.0 From nobody Sun Nov 24 05:28:16 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1725986926; cv=none; d=zohomail.com; s=zohoarc; b=F1mT1OexXlhLpkROYJvUjox6bYaGVzlDKzTEpMrpln5JZDf/sPEIgffUpWsLtjNgkt2KWO0JaOhUOnjdPvKHK6oI7Rx9wapEYT3ywD6FgrPg+ETjYx7CmivGVUSzxZYrhl7coIdlFWMPXzPFNDwZPhFsn18GWGsP8pqoqm10sIA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1725986926; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=cSQYdCqqcYbLzplGdm9WP9jq1W4I65AiUO+19S8pEBw=; b=ZDasRLTW4FntgUhdhefyiRxxq8HklHCXXLbYFl5yuaJiXRUWCWVf4AKF/6D8OqKZCordSoX8J+aETegBQedrM5Mp432ibonhIADtTGZxoch3CEmEDpbfgCpGbB4BdCwgc9Iq1m8miIYWZsSnhnlhRQcfm0yB87ymKTEj+F/aa+0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1725986926038341.4056626031702; Tue, 10 Sep 2024 09:48:46 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1so41q-0007Vs-Ex; Tue, 10 Sep 2024 12:47:46 -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 1so41d-0006sA-Ut for qemu-devel@nongnu.org; Tue, 10 Sep 2024 12:47:34 -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 1so41W-0007a7-Mi for qemu-devel@nongnu.org; Tue, 10 Sep 2024 12:47:33 -0400 Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-414-szQNo6CZMZKxnBXwKYjs_g-1; Tue, 10 Sep 2024 12:47:21 -0400 Received: from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.15]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 9547A1955D45; Tue, 10 Sep 2024 16:47:20 +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 356861956086; Tue, 10 Sep 2024 16:47:19 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 963CB21E6829; Tue, 10 Sep 2024 18:47:14 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1725986846; 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=cSQYdCqqcYbLzplGdm9WP9jq1W4I65AiUO+19S8pEBw=; b=ROH9banpTDbzEQjyC/6DrP5XFhkqdjwbaKmUXWQrOF0mcqCIcsm9Rk/txJ56wsmz4Ju5vs skTZQ0A6kjigPBiFVpU7rgw5ST6WXxqPyponvD7ei8UzG8QR9DeXA4cZfKwyhgMlRt1EFU 0z5UTf+hBDDo/P27kA/3n95GQFaF0no= X-MC-Unique: szQNo6CZMZKxnBXwKYjs_g-1 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org, =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= Subject: [PULL 11/19] qapi/crypto: Rename QCryptoHashAlgorithm to *Algo, and drop prefix Date: Tue, 10 Sep 2024 18:47:06 +0200 Message-ID: <20240910164714.1993531-12-armbru@redhat.com> In-Reply-To: <20240910164714.1993531-1-armbru@redhat.com> References: <20240910164714.1993531-1-armbru@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.15 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.145, 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, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1725986928014116600 QAPI's 'prefix' feature can make the connection between enumeration type and its constants less than obvious. It's best used with restraint. QCryptoHashAlgorithm has a 'prefix' that overrides the generated enumeration constants' prefix to QCRYPTO_HASH_ALG. We could simply drop 'prefix', but then the prefix becomes QCRYPTO_HASH_ALGORITHM, which is rather long. We could additionally rename the type to QCryptoHashAlg, but I think the abbreviation "alg" is less than clear. Rename the type to QCryptoHashAlgo instead. The prefix becomes to QCRYPTO_HASH_ALGO. Signed-off-by: Markus Armbruster Acked-by: Daniel P. Berrang=C3=A9 Message-ID: <20240904111836.3273842-12-armbru@redhat.com> [Conflicts with merge commit 7bbadc60b58b resolved] --- 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 +++--- include/crypto/x509-utils.h | 2 +- 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 | 6 ++-- crypto/x509-utils.c | 18 +++++----- 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 | 46 ++++++++++++------------- ui/vnc.c | 2 +- util/hbitmap.c | 2 +- crypto/akcipher-gcrypt.c.inc | 14 ++++---- crypto/akcipher-nettle.c.inc | 26 +++++++------- 54 files changed, 363 insertions(+), 364 deletions(-) diff --git a/qapi/crypto.json b/qapi/crypto.json index b5c25e7cd9..68393568cf 100644 --- a/qapi/crypto.json +++ b/qapi/crypto.json @@ -38,7 +38,7 @@ 'data': ['raw', 'base64']} =20 ## -# @QCryptoHashAlgorithm: +# @QCryptoHashAlgo: # # The supported algorithms for computing content digests # @@ -58,8 +58,7 @@ # # Since: 2.6 ## -{ 'enum': 'QCryptoHashAlgorithm', - 'prefix': 'QCRYPTO_HASH_ALG', +{ 'enum': 'QCryptoHashAlgo', 'data': ['md5', 'sha1', 'sha224', 'sha256', 'sha384', 'sha512', 'ripemd1= 60']} =20 ## @@ -229,8 +228,8 @@ 'data': { '*cipher-alg': 'QCryptoCipherAlgorithm', '*cipher-mode': 'QCryptoCipherMode', '*ivgen-alg': 'QCryptoIVGenAlgorithm', - '*ivgen-hash-alg': 'QCryptoHashAlgorithm', - '*hash-alg': 'QCryptoHashAlgorithm', + '*ivgen-hash-alg': 'QCryptoHashAlgo', + '*hash-alg': 'QCryptoHashAlgo', '*iter-time': 'int' }} =20 ## @@ -326,8 +325,8 @@ 'data': {'cipher-alg': 'QCryptoCipherAlgorithm', 'cipher-mode': 'QCryptoCipherMode', 'ivgen-alg': 'QCryptoIVGenAlgorithm', - '*ivgen-hash-alg': 'QCryptoHashAlgorithm', - 'hash-alg': 'QCryptoHashAlgorithm', + '*ivgen-hash-alg': 'QCryptoHashAlgo', + 'hash-alg': 'QCryptoHashAlgo', 'detached-header': 'bool', 'payload-offset': 'int', 'master-key-iters': 'int', @@ -631,14 +630,14 @@ # # Specific parameters for RSA algorithm. # -# @hash-alg: QCryptoHashAlgorithm +# @hash-alg: QCryptoHashAlgo # # @padding-alg: QCryptoRSAPaddingAlgorithm # # Since: 7.1 ## { 'struct': 'QCryptoAkCipherOptionsRSA', - 'data': { 'hash-alg':'QCryptoHashAlgorithm', + 'data': { 'hash-alg':'QCryptoHashAlgo', 'padding-alg': 'QCryptoRSAPaddingAlgorithm'}} =20 ## diff --git a/crypto/blockpriv.h b/crypto/blockpriv.h index b8f77cb5eb..cf1a66c00d 100644 --- a/crypto/blockpriv.h +++ b/crypto/blockpriv.h @@ -44,7 +44,7 @@ struct QCryptoBlock { QCryptoIVGen *ivgen; QemuMutex mutex; =20 - QCryptoHashAlgorithm kdfhash; + QCryptoHashAlgo kdfhash; size_t niv; uint64_t payload_offset; /* In bytes */ uint64_t sector_size; /* In bytes */ diff --git a/crypto/hashpriv.h b/crypto/hashpriv.h index cee26ccb47..47daec3f7a 100644 --- a/crypto/hashpriv.h +++ b/crypto/hashpriv.h @@ -18,7 +18,7 @@ typedef struct QCryptoHashDriver QCryptoHashDriver; =20 struct QCryptoHashDriver { - int (*hash_bytesv)(QCryptoHashAlgorithm alg, + int (*hash_bytesv)(QCryptoHashAlgo alg, const struct iovec *iov, size_t niov, uint8_t **result, diff --git a/crypto/hmacpriv.h b/crypto/hmacpriv.h index 62dfe8257a..bd4c498c62 100644 --- a/crypto/hmacpriv.h +++ b/crypto/hmacpriv.h @@ -28,7 +28,7 @@ struct QCryptoHmacDriver { void (*hmac_free)(QCryptoHmac *hmac); }; =20 -void *qcrypto_hmac_ctx_new(QCryptoHashAlgorithm alg, +void *qcrypto_hmac_ctx_new(QCryptoHashAlgo alg, const uint8_t *key, size_t nkey, Error **errp); extern QCryptoHmacDriver qcrypto_hmac_lib_driver; @@ -37,7 +37,7 @@ extern QCryptoHmacDriver qcrypto_hmac_lib_driver; =20 #include "afalgpriv.h" =20 -QCryptoAFAlg *qcrypto_afalg_hmac_ctx_new(QCryptoHashAlgorithm alg, +QCryptoAFAlg *qcrypto_afalg_hmac_ctx_new(QCryptoHashAlgo alg, const uint8_t *key, size_t nkey, Error **errp); extern QCryptoHmacDriver qcrypto_hmac_afalg_driver; diff --git a/crypto/ivgenpriv.h b/crypto/ivgenpriv.h index cecdbedfde..0227ae4d00 100644 --- a/crypto/ivgenpriv.h +++ b/crypto/ivgenpriv.h @@ -42,7 +42,7 @@ struct QCryptoIVGen { =20 QCryptoIVGenAlgorithm algorithm; QCryptoCipherAlgorithm cipher; - QCryptoHashAlgorithm hash; + QCryptoHashAlgo hash; }; =20 =20 diff --git a/include/crypto/afsplit.h b/include/crypto/afsplit.h index 4894d64330..06f28fe67c 100644 --- a/include/crypto/afsplit.h +++ b/include/crypto/afsplit.h @@ -46,7 +46,7 @@ * * splitkey =3D g_new0(uint8_t, nkey * stripes); * - * if (qcrypto_afsplit_encode(QCRYPTO_HASH_ALG_SHA256, + * if (qcrypto_afsplit_encode(QCRYPTO_HASH_ALGO_SHA256, * nkey, stripes, * masterkey, splitkey, errp) < 0) { * g_free(splitkey); @@ -71,7 +71,7 @@ * * masterkey =3D g_new0(uint8_t, nkey); * - * if (qcrypto_afsplit_decode(QCRYPTO_HASH_ALG_SHA256, + * if (qcrypto_afsplit_decode(QCRYPTO_HASH_ALGO_SHA256, * nkey, stripes, * splitkey, masterkey, errp) < 0) { * g_free(splitkey); @@ -102,7 +102,7 @@ * * Returns: 0 on success, -1 on error; */ -int qcrypto_afsplit_encode(QCryptoHashAlgorithm hash, +int qcrypto_afsplit_encode(QCryptoHashAlgo hash, size_t blocklen, uint32_t stripes, const uint8_t *in, @@ -124,7 +124,7 @@ int qcrypto_afsplit_encode(QCryptoHashAlgorithm hash, * * Returns: 0 on success, -1 on error; */ -int qcrypto_afsplit_decode(QCryptoHashAlgorithm hash, +int qcrypto_afsplit_decode(QCryptoHashAlgo hash, size_t blocklen, uint32_t stripes, const uint8_t *in, diff --git a/include/crypto/block.h b/include/crypto/block.h index 5b5d039800..b013d27f00 100644 --- a/include/crypto/block.h +++ b/include/crypto/block.h @@ -287,7 +287,7 @@ QCryptoIVGen *qcrypto_block_get_ivgen(QCryptoBlock *blo= ck); * * Returns: the hash algorithm */ -QCryptoHashAlgorithm qcrypto_block_get_kdf_hash(QCryptoBlock *block); +QCryptoHashAlgo qcrypto_block_get_kdf_hash(QCryptoBlock *block); =20 /** * qcrypto_block_get_payload_offset: diff --git a/include/crypto/hash.h b/include/crypto/hash.h index a113cc3b04..6038a52d0e 100644 --- a/include/crypto/hash.h +++ b/include/crypto/hash.h @@ -31,7 +31,7 @@ #define QCRYPTO_HASH_DIGEST_LEN_SHA512 64 #define QCRYPTO_HASH_DIGEST_LEN_RIPEMD160 20 =20 -/* See also "QCryptoHashAlgorithm" defined in qapi/crypto.json */ +/* See also "QCryptoHashAlgo" defined in qapi/crypto.json */ =20 /** * qcrypto_hash_supports: @@ -42,7 +42,7 @@ * * Returns: true if the algorithm is supported, false otherwise */ -gboolean qcrypto_hash_supports(QCryptoHashAlgorithm alg); +gboolean qcrypto_hash_supports(QCryptoHashAlgo alg); =20 =20 /** @@ -53,7 +53,7 @@ gboolean qcrypto_hash_supports(QCryptoHashAlgorithm alg); * * Returns: the digest length in bytes */ -size_t qcrypto_hash_digest_len(QCryptoHashAlgorithm alg); +size_t qcrypto_hash_digest_len(QCryptoHashAlgo alg); =20 /** * qcrypto_hash_bytesv: @@ -73,7 +73,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, @@ -98,7 +98,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, @@ -122,7 +122,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, @@ -145,7 +145,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, @@ -168,7 +168,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, @@ -191,7 +191,7 @@ int qcrypto_hash_base64v(QCryptoHashAlgorithm alg, * * Returns: 0 on success, -1 on error */ -int qcrypto_hash_base64(QCryptoHashAlgorithm alg, +int qcrypto_hash_base64(QCryptoHashAlgo alg, const char *buf, size_t len, char **base64, diff --git a/include/crypto/hmac.h b/include/crypto/hmac.h index ad4d778416..c69a0dfab3 100644 --- a/include/crypto/hmac.h +++ b/include/crypto/hmac.h @@ -16,7 +16,7 @@ =20 typedef struct QCryptoHmac QCryptoHmac; struct QCryptoHmac { - QCryptoHashAlgorithm alg; + QCryptoHashAlgo alg; void *opaque; void *driver; }; @@ -31,7 +31,7 @@ struct QCryptoHmac { * Returns: * true if the algorithm is supported, false otherwise */ -bool qcrypto_hmac_supports(QCryptoHashAlgorithm alg); +bool qcrypto_hmac_supports(QCryptoHashAlgo alg); =20 /** * qcrypto_hmac_new: @@ -52,7 +52,7 @@ bool qcrypto_hmac_supports(QCryptoHashAlgorithm alg); * Returns: * a new hmac object, or NULL on error */ -QCryptoHmac *qcrypto_hmac_new(QCryptoHashAlgorithm alg, +QCryptoHmac *qcrypto_hmac_new(QCryptoHashAlgo alg, const uint8_t *key, size_t nkey, Error **errp); =20 diff --git a/include/crypto/ivgen.h b/include/crypto/ivgen.h index a09d5732da..ab5f1a648e 100644 --- a/include/crypto/ivgen.h +++ b/include/crypto/ivgen.h @@ -46,7 +46,7 @@ * * QCryptoIVGen *ivgen =3D qcrypto_ivgen_new(QCRYPTO_IVGEN_ALG_ESSIV, * QCRYPTO_CIPHER_ALG_AES_128, - * QCRYPTO_HASH_ALG_SHA256, + * QCRYPTO_HASH_ALGO_SHA256, * key, nkey, errp); * if (!ivgen) { * return -1; @@ -135,7 +135,7 @@ typedef struct QCryptoIVGen QCryptoIVGen; */ QCryptoIVGen *qcrypto_ivgen_new(QCryptoIVGenAlgorithm alg, QCryptoCipherAlgorithm cipheralg, - QCryptoHashAlgorithm hash, + QCryptoHashAlgo hash, const uint8_t *key, size_t nkey, Error **errp); =20 @@ -191,7 +191,7 @@ QCryptoCipherAlgorithm qcrypto_ivgen_get_cipher(QCrypto= IVGen *ivgen); * * Returns: the hash algorithm */ -QCryptoHashAlgorithm qcrypto_ivgen_get_hash(QCryptoIVGen *ivgen); +QCryptoHashAlgo qcrypto_ivgen_get_hash(QCryptoIVGen *ivgen); =20 =20 /** diff --git a/include/crypto/pbkdf.h b/include/crypto/pbkdf.h index 2c31a44a27..6cf29e78ee 100644 --- a/include/crypto/pbkdf.h +++ b/include/crypto/pbkdf.h @@ -50,7 +50,7 @@ * return -1; * } * - * iterations =3D qcrypto_pbkdf2_count_iters(QCRYPTO_HASH_ALG_SHA256, + * iterations =3D qcrypto_pbkdf2_count_iters(QCRYPTO_HASH_ALGO_SHA256, * (const uint8_t *)password, * strlen(password), * salt, nkey, errp); @@ -60,7 +60,7 @@ * return -1; * } * - * if (qcrypto_pbkdf2(QCRYPTO_HASH_ALG_SHA256, + * if (qcrypto_pbkdf2(QCRYPTO_HASH_ALGO_SHA256, * (const uint8_t *)password, strlen(password), * salt, nkey, iterations, key, nkey, errp) < 0) { * g_free(key); @@ -92,7 +92,7 @@ * * Returns true if supported, false otherwise */ -bool qcrypto_pbkdf2_supports(QCryptoHashAlgorithm hash); +bool qcrypto_pbkdf2_supports(QCryptoHashAlgo hash); =20 =20 /** @@ -119,7 +119,7 @@ bool qcrypto_pbkdf2_supports(QCryptoHashAlgorithm hash); * * Returns: 0 on success, -1 on error */ -int qcrypto_pbkdf2(QCryptoHashAlgorithm hash, +int qcrypto_pbkdf2(QCryptoHashAlgo hash, const uint8_t *key, size_t nkey, const uint8_t *salt, size_t nsalt, uint64_t iterations, @@ -147,7 +147,7 @@ int qcrypto_pbkdf2(QCryptoHashAlgorithm hash, * * Returns: number of iterations in 1 second, -1 on error */ -uint64_t qcrypto_pbkdf2_count_iters(QCryptoHashAlgorithm hash, +uint64_t qcrypto_pbkdf2_count_iters(QCryptoHashAlgo hash, const uint8_t *key, size_t nkey, const uint8_t *salt, size_t nsalt, size_t nout, diff --git a/include/crypto/x509-utils.h b/include/crypto/x509-utils.h index 4210dfbcfc..1e99661a71 100644 --- a/include/crypto/x509-utils.h +++ b/include/crypto/x509-utils.h @@ -14,7 +14,7 @@ #include "crypto/hash.h" =20 int qcrypto_get_x509_cert_fingerprint(uint8_t *cert, size_t size, - QCryptoHashAlgorithm hash, + QCryptoHashAlgo hash, uint8_t *result, size_t *resultlen, Error **errp); diff --git a/backends/cryptodev-builtin.c b/backends/cryptodev-builtin.c index e95af9bb72..4a49d328ec 100644 --- a/backends/cryptodev-builtin.c +++ b/backends/cryptodev-builtin.c @@ -169,16 +169,16 @@ static int cryptodev_builtin_get_rsa_hash_algo( { switch (virtio_rsa_hash) { case VIRTIO_CRYPTO_RSA_MD5: - return QCRYPTO_HASH_ALG_MD5; + return QCRYPTO_HASH_ALGO_MD5; =20 case VIRTIO_CRYPTO_RSA_SHA1: - return QCRYPTO_HASH_ALG_SHA1; + return QCRYPTO_HASH_ALGO_SHA1; =20 case VIRTIO_CRYPTO_RSA_SHA256: - return QCRYPTO_HASH_ALG_SHA256; + return QCRYPTO_HASH_ALGO_SHA256; =20 case VIRTIO_CRYPTO_RSA_SHA512: - return QCRYPTO_HASH_ALG_SHA512; + return QCRYPTO_HASH_ALGO_SHA512; =20 default: error_setg(errp, "Unsupported rsa hash algo: %d", virtio_rsa_hash); diff --git a/backends/cryptodev-lkcf.c b/backends/cryptodev-lkcf.c index e1ee11a158..6e6012e716 100644 --- a/backends/cryptodev-lkcf.c +++ b/backends/cryptodev-lkcf.c @@ -142,7 +142,7 @@ static int cryptodev_lkcf_set_op_desc(QCryptoAkCipherOp= tions *opts, if (rsa_opt->padding_alg =3D=3D QCRYPTO_RSA_PADDING_ALG_PKCS1) { snprintf(key_desc, desc_len, "enc=3D%s hash=3D%s", QCryptoRSAPaddingAlgorithm_str(rsa_opt->padding_alg), - QCryptoHashAlgorithm_str(rsa_opt->hash_alg)); + QCryptoHashAlgo_str(rsa_opt->hash_alg)); =20 } else { snprintf(key_desc, desc_len, "enc=3D%s", @@ -161,19 +161,19 @@ static int cryptodev_lkcf_set_rsa_opt(int virtio_padd= ing_alg, =20 switch (virtio_hash_alg) { case VIRTIO_CRYPTO_RSA_MD5: - opt->hash_alg =3D QCRYPTO_HASH_ALG_MD5; + opt->hash_alg =3D QCRYPTO_HASH_ALGO_MD5; break; =20 case VIRTIO_CRYPTO_RSA_SHA1: - opt->hash_alg =3D QCRYPTO_HASH_ALG_SHA1; + opt->hash_alg =3D QCRYPTO_HASH_ALGO_SHA1; break; =20 case VIRTIO_CRYPTO_RSA_SHA256: - opt->hash_alg =3D QCRYPTO_HASH_ALG_SHA256; + opt->hash_alg =3D QCRYPTO_HASH_ALGO_SHA256; break; =20 case VIRTIO_CRYPTO_RSA_SHA512: - opt->hash_alg =3D QCRYPTO_HASH_ALG_SHA512; + opt->hash_alg =3D QCRYPTO_HASH_ALGO_SHA512; break; =20 default: diff --git a/block/parallels-ext.c b/block/parallels-ext.c index b4e14c88f2..778b8f684e 100644 --- a/block/parallels-ext.c +++ b/block/parallels-ext.c @@ -206,7 +206,7 @@ parallels_parse_format_extension(BlockDriverState *bs, = uint8_t *ext_cluster, goto fail; } =20 - ret =3D qcrypto_hash_bytes(QCRYPTO_HASH_ALG_MD5, (char *)pos, remainin= g, + ret =3D qcrypto_hash_bytes(QCRYPTO_HASH_ALGO_MD5, (char *)pos, remaini= ng, &hash, &hash_len, errp); if (ret < 0) { goto fail; diff --git a/block/quorum.c b/block/quorum.c index db8fe891c4..46be65a95f 100644 --- a/block/quorum.c +++ b/block/quorum.c @@ -393,7 +393,7 @@ static int quorum_compute_hash(QuorumAIOCB *acb, int i,= QuorumVoteValue *hash) /* XXX - would be nice if we could pass in the Error ** * and propagate that back, but this quorum code is * restricted to just errno values currently */ - if (qcrypto_hash_bytesv(QCRYPTO_HASH_ALG_SHA256, + if (qcrypto_hash_bytesv(QCRYPTO_HASH_ALGO_SHA256, qiov->iov, qiov->niov, &data, &len, NULL) < 0) { @@ -1308,7 +1308,7 @@ static BlockDriver bdrv_quorum =3D { =20 static void bdrv_quorum_init(void) { - if (!qcrypto_hash_supports(QCRYPTO_HASH_ALG_SHA256)) { + if (!qcrypto_hash_supports(QCRYPTO_HASH_ALGO_SHA256)) { /* SHA256 hash support is required for quorum device */ return; } diff --git a/crypto/afsplit.c b/crypto/afsplit.c index b1a5a20899..b2e383aa67 100644 --- a/crypto/afsplit.c +++ b/crypto/afsplit.c @@ -40,7 +40,7 @@ static void qcrypto_afsplit_xor(size_t blocklen, } =20 =20 -static int qcrypto_afsplit_hash(QCryptoHashAlgorithm hash, +static int qcrypto_afsplit_hash(QCryptoHashAlgo hash, size_t blocklen, uint8_t *block, Error **errp) @@ -85,7 +85,7 @@ static int qcrypto_afsplit_hash(QCryptoHashAlgorithm hash, } =20 =20 -int qcrypto_afsplit_encode(QCryptoHashAlgorithm hash, +int qcrypto_afsplit_encode(QCryptoHashAlgo hash, size_t blocklen, uint32_t stripes, const uint8_t *in, @@ -117,7 +117,7 @@ int qcrypto_afsplit_encode(QCryptoHashAlgorithm hash, } =20 =20 -int qcrypto_afsplit_decode(QCryptoHashAlgorithm hash, +int qcrypto_afsplit_decode(QCryptoHashAlgo hash, size_t blocklen, uint32_t stripes, const uint8_t *in, diff --git a/crypto/block-luks.c b/crypto/block-luks.c index 7b9c7b292d..59af733b8c 100644 --- a/crypto/block-luks.c +++ b/crypto/block-luks.c @@ -132,7 +132,7 @@ struct QCryptoBlockLUKS { QCryptoIVGenAlgorithm ivgen_alg; =20 /* Hash algorithm used for IV generation*/ - QCryptoHashAlgorithm ivgen_hash_alg; + QCryptoHashAlgo ivgen_hash_alg; =20 /* * Encryption algorithm used for IV generation. @@ -141,7 +141,7 @@ struct QCryptoBlockLUKS { QCryptoCipherAlgorithm ivgen_cipher_alg; =20 /* Hash algorithm used in pbkdf2 function */ - QCryptoHashAlgorithm hash_alg; + QCryptoHashAlgo hash_alg; =20 /* Name of the secret that was used to open the image */ char *secret; @@ -223,7 +223,7 @@ static int qcrypto_block_luks_name_lookup(const char *n= ame, =20 #define qcrypto_block_luks_hash_name_lookup(name, errp) \ qcrypto_block_luks_name_lookup(name, \ - &QCryptoHashAlgorithm_lookup, \ + &QCryptoHashAlgo_lookup, \ "Hash algorithm", \ errp) =20 @@ -264,7 +264,7 @@ qcrypto_block_luks_has_format(const uint8_t *buf, */ static QCryptoCipherAlgorithm qcrypto_block_luks_essiv_cipher(QCryptoCipherAlgorithm cipher, - QCryptoHashAlgorithm hash, + QCryptoHashAlgo hash, Error **errp) { size_t digestlen =3D qcrypto_hash_digest_len(hash); @@ -1331,11 +1331,11 @@ qcrypto_block_luks_create(QCryptoBlock *block, luks_opts.ivgen_alg =3D QCRYPTO_IVGEN_ALG_PLAIN64; } if (!luks_opts.has_hash_alg) { - luks_opts.hash_alg =3D QCRYPTO_HASH_ALG_SHA256; + luks_opts.hash_alg =3D QCRYPTO_HASH_ALGO_SHA256; } if (luks_opts.ivgen_alg =3D=3D QCRYPTO_IVGEN_ALG_ESSIV) { if (!luks_opts.has_ivgen_hash_alg) { - luks_opts.ivgen_hash_alg =3D QCRYPTO_HASH_ALG_SHA256; + luks_opts.ivgen_hash_alg =3D QCRYPTO_HASH_ALGO_SHA256; luks_opts.has_ivgen_hash_alg =3D true; } } @@ -1386,13 +1386,13 @@ qcrypto_block_luks_create(QCryptoBlock *block, cipher_mode =3D QCryptoCipherMode_str(luks_opts.cipher_mode); ivgen_alg =3D QCryptoIVGenAlgorithm_str(luks_opts.ivgen_alg); if (luks_opts.has_ivgen_hash_alg) { - ivgen_hash_alg =3D QCryptoHashAlgorithm_str(luks_opts.ivgen_hash_a= lg); + ivgen_hash_alg =3D QCryptoHashAlgo_str(luks_opts.ivgen_hash_alg); cipher_mode_spec =3D g_strdup_printf("%s-%s:%s", cipher_mode, ivge= n_alg, ivgen_hash_alg); } else { cipher_mode_spec =3D g_strdup_printf("%s-%s", cipher_mode, ivgen_a= lg); } - hash_alg =3D QCryptoHashAlgorithm_str(luks_opts.hash_alg); + hash_alg =3D QCryptoHashAlgo_str(luks_opts.hash_alg); =20 =20 if (strlen(cipher_alg) >=3D QCRYPTO_BLOCK_LUKS_CIPHER_NAME_LEN) { diff --git a/crypto/block.c b/crypto/block.c index 899561a080..9846caa591 100644 --- a/crypto/block.c +++ b/crypto/block.c @@ -332,7 +332,7 @@ QCryptoIVGen *qcrypto_block_get_ivgen(QCryptoBlock *blo= ck) } =20 =20 -QCryptoHashAlgorithm qcrypto_block_get_kdf_hash(QCryptoBlock *block) +QCryptoHashAlgo qcrypto_block_get_kdf_hash(QCryptoBlock *block) { return block->kdfhash; } diff --git a/crypto/hash-afalg.c b/crypto/hash-afalg.c index 3ebea39292..8fc6bd0edf 100644 --- a/crypto/hash-afalg.c +++ b/crypto/hash-afalg.c @@ -20,7 +20,7 @@ #include "hmacpriv.h" =20 static char * -qcrypto_afalg_hash_format_name(QCryptoHashAlgorithm alg, +qcrypto_afalg_hash_format_name(QCryptoHashAlgo alg, bool is_hmac, Error **errp) { @@ -28,25 +28,25 @@ qcrypto_afalg_hash_format_name(QCryptoHashAlgorithm alg, const char *alg_name; =20 switch (alg) { - case QCRYPTO_HASH_ALG_MD5: + case QCRYPTO_HASH_ALGO_MD5: alg_name =3D "md5"; break; - case QCRYPTO_HASH_ALG_SHA1: + case QCRYPTO_HASH_ALGO_SHA1: alg_name =3D "sha1"; break; - case QCRYPTO_HASH_ALG_SHA224: + case QCRYPTO_HASH_ALGO_SHA224: alg_name =3D "sha224"; break; - case QCRYPTO_HASH_ALG_SHA256: + case QCRYPTO_HASH_ALGO_SHA256: alg_name =3D "sha256"; break; - case QCRYPTO_HASH_ALG_SHA384: + case QCRYPTO_HASH_ALGO_SHA384: alg_name =3D "sha384"; break; - case QCRYPTO_HASH_ALG_SHA512: + case QCRYPTO_HASH_ALGO_SHA512: alg_name =3D "sha512"; break; - case QCRYPTO_HASH_ALG_RIPEMD160: + case QCRYPTO_HASH_ALGO_RIPEMD160: alg_name =3D "rmd160"; break; =20 @@ -65,7 +65,7 @@ qcrypto_afalg_hash_format_name(QCryptoHashAlgorithm alg, } =20 static QCryptoAFAlg * -qcrypto_afalg_hash_hmac_ctx_new(QCryptoHashAlgorithm alg, +qcrypto_afalg_hash_hmac_ctx_new(QCryptoHashAlgo alg, const uint8_t *key, size_t nkey, bool is_hmac, Error **errp) { @@ -99,14 +99,14 @@ qcrypto_afalg_hash_hmac_ctx_new(QCryptoHashAlgorithm al= g, } =20 static QCryptoAFAlg * -qcrypto_afalg_hash_ctx_new(QCryptoHashAlgorithm alg, +qcrypto_afalg_hash_ctx_new(QCryptoHashAlgo alg, Error **errp) { return qcrypto_afalg_hash_hmac_ctx_new(alg, NULL, 0, false, errp); } =20 QCryptoAFAlg * -qcrypto_afalg_hmac_ctx_new(QCryptoHashAlgorithm alg, +qcrypto_afalg_hmac_ctx_new(QCryptoHashAlgo alg, const uint8_t *key, size_t nkey, Error **errp) { @@ -115,7 +115,7 @@ qcrypto_afalg_hmac_ctx_new(QCryptoHashAlgorithm alg, =20 static int qcrypto_afalg_hash_hmac_bytesv(QCryptoAFAlg *hmac, - QCryptoHashAlgorithm alg, + QCryptoHashAlgo alg, const struct iovec *iov, size_t niov, uint8_t **result, size_t *resultlen, @@ -173,7 +173,7 @@ out: } =20 static int -qcrypto_afalg_hash_bytesv(QCryptoHashAlgorithm alg, +qcrypto_afalg_hash_bytesv(QCryptoHashAlgo alg, const struct iovec *iov, size_t niov, uint8_t **result, size_t *resultlen, diff --git a/crypto/hash-gcrypt.c b/crypto/hash-gcrypt.c index 829e48258d..0973cc0d93 100644 --- a/crypto/hash-gcrypt.c +++ b/crypto/hash-gcrypt.c @@ -25,17 +25,17 @@ #include "hashpriv.h" =20 =20 -static int qcrypto_hash_alg_map[QCRYPTO_HASH_ALG__MAX] =3D { - [QCRYPTO_HASH_ALG_MD5] =3D GCRY_MD_MD5, - [QCRYPTO_HASH_ALG_SHA1] =3D GCRY_MD_SHA1, - [QCRYPTO_HASH_ALG_SHA224] =3D GCRY_MD_SHA224, - [QCRYPTO_HASH_ALG_SHA256] =3D GCRY_MD_SHA256, - [QCRYPTO_HASH_ALG_SHA384] =3D GCRY_MD_SHA384, - [QCRYPTO_HASH_ALG_SHA512] =3D GCRY_MD_SHA512, - [QCRYPTO_HASH_ALG_RIPEMD160] =3D GCRY_MD_RMD160, +static int qcrypto_hash_alg_map[QCRYPTO_HASH_ALGO__MAX] =3D { + [QCRYPTO_HASH_ALGO_MD5] =3D GCRY_MD_MD5, + [QCRYPTO_HASH_ALGO_SHA1] =3D GCRY_MD_SHA1, + [QCRYPTO_HASH_ALGO_SHA224] =3D GCRY_MD_SHA224, + [QCRYPTO_HASH_ALGO_SHA256] =3D GCRY_MD_SHA256, + [QCRYPTO_HASH_ALGO_SHA384] =3D GCRY_MD_SHA384, + [QCRYPTO_HASH_ALGO_SHA512] =3D GCRY_MD_SHA512, + [QCRYPTO_HASH_ALGO_RIPEMD160] =3D GCRY_MD_RMD160, }; =20 -gboolean qcrypto_hash_supports(QCryptoHashAlgorithm alg) +gboolean qcrypto_hash_supports(QCryptoHashAlgo alg) { if (alg < G_N_ELEMENTS(qcrypto_hash_alg_map) && qcrypto_hash_alg_map[alg] !=3D GCRY_MD_NONE) { @@ -46,7 +46,7 @@ gboolean qcrypto_hash_supports(QCryptoHashAlgorithm alg) =20 =20 static int -qcrypto_gcrypt_hash_bytesv(QCryptoHashAlgorithm alg, +qcrypto_gcrypt_hash_bytesv(QCryptoHashAlgo alg, const struct iovec *iov, size_t niov, uint8_t **result, diff --git a/crypto/hash-glib.c b/crypto/hash-glib.c index 18e64faa9c..a5a2949333 100644 --- a/crypto/hash-glib.c +++ b/crypto/hash-glib.c @@ -24,17 +24,17 @@ #include "hashpriv.h" =20 =20 -static int qcrypto_hash_alg_map[QCRYPTO_HASH_ALG__MAX] =3D { - [QCRYPTO_HASH_ALG_MD5] =3D G_CHECKSUM_MD5, - [QCRYPTO_HASH_ALG_SHA1] =3D G_CHECKSUM_SHA1, - [QCRYPTO_HASH_ALG_SHA224] =3D -1, - [QCRYPTO_HASH_ALG_SHA256] =3D G_CHECKSUM_SHA256, - [QCRYPTO_HASH_ALG_SHA384] =3D G_CHECKSUM_SHA384, - [QCRYPTO_HASH_ALG_SHA512] =3D G_CHECKSUM_SHA512, - [QCRYPTO_HASH_ALG_RIPEMD160] =3D -1, +static int qcrypto_hash_alg_map[QCRYPTO_HASH_ALGO__MAX] =3D { + [QCRYPTO_HASH_ALGO_MD5] =3D G_CHECKSUM_MD5, + [QCRYPTO_HASH_ALGO_SHA1] =3D G_CHECKSUM_SHA1, + [QCRYPTO_HASH_ALGO_SHA224] =3D -1, + [QCRYPTO_HASH_ALGO_SHA256] =3D G_CHECKSUM_SHA256, + [QCRYPTO_HASH_ALGO_SHA384] =3D G_CHECKSUM_SHA384, + [QCRYPTO_HASH_ALGO_SHA512] =3D G_CHECKSUM_SHA512, + [QCRYPTO_HASH_ALGO_RIPEMD160] =3D -1, }; =20 -gboolean qcrypto_hash_supports(QCryptoHashAlgorithm alg) +gboolean qcrypto_hash_supports(QCryptoHashAlgo alg) { if (alg < G_N_ELEMENTS(qcrypto_hash_alg_map) && qcrypto_hash_alg_map[alg] !=3D -1) { @@ -45,7 +45,7 @@ gboolean qcrypto_hash_supports(QCryptoHashAlgorithm alg) =20 =20 static int -qcrypto_glib_hash_bytesv(QCryptoHashAlgorithm alg, +qcrypto_glib_hash_bytesv(QCryptoHashAlgo alg, const struct iovec *iov, size_t niov, uint8_t **result, diff --git a/crypto/hash-gnutls.c b/crypto/hash-gnutls.c index 17911ac5d1..0636c0727a 100644 --- a/crypto/hash-gnutls.c +++ b/crypto/hash-gnutls.c @@ -25,17 +25,17 @@ #include "hashpriv.h" =20 =20 -static int qcrypto_hash_alg_map[QCRYPTO_HASH_ALG__MAX] =3D { - [QCRYPTO_HASH_ALG_MD5] =3D GNUTLS_DIG_MD5, - [QCRYPTO_HASH_ALG_SHA1] =3D GNUTLS_DIG_SHA1, - [QCRYPTO_HASH_ALG_SHA224] =3D GNUTLS_DIG_SHA224, - [QCRYPTO_HASH_ALG_SHA256] =3D GNUTLS_DIG_SHA256, - [QCRYPTO_HASH_ALG_SHA384] =3D GNUTLS_DIG_SHA384, - [QCRYPTO_HASH_ALG_SHA512] =3D GNUTLS_DIG_SHA512, - [QCRYPTO_HASH_ALG_RIPEMD160] =3D GNUTLS_DIG_RMD160, +static int qcrypto_hash_alg_map[QCRYPTO_HASH_ALGO__MAX] =3D { + [QCRYPTO_HASH_ALGO_MD5] =3D GNUTLS_DIG_MD5, + [QCRYPTO_HASH_ALGO_SHA1] =3D GNUTLS_DIG_SHA1, + [QCRYPTO_HASH_ALGO_SHA224] =3D GNUTLS_DIG_SHA224, + [QCRYPTO_HASH_ALGO_SHA256] =3D GNUTLS_DIG_SHA256, + [QCRYPTO_HASH_ALGO_SHA384] =3D GNUTLS_DIG_SHA384, + [QCRYPTO_HASH_ALGO_SHA512] =3D GNUTLS_DIG_SHA512, + [QCRYPTO_HASH_ALGO_RIPEMD160] =3D GNUTLS_DIG_RMD160, }; =20 -gboolean qcrypto_hash_supports(QCryptoHashAlgorithm alg) +gboolean qcrypto_hash_supports(QCryptoHashAlgo alg) { size_t i; const gnutls_digest_algorithm_t *algs; @@ -54,7 +54,7 @@ gboolean qcrypto_hash_supports(QCryptoHashAlgorithm alg) =20 =20 static int -qcrypto_gnutls_hash_bytesv(QCryptoHashAlgorithm alg, +qcrypto_gnutls_hash_bytesv(QCryptoHashAlgo alg, const struct iovec *iov, size_t niov, uint8_t **result, diff --git a/crypto/hash-nettle.c b/crypto/hash-nettle.c index 1ca1a41062..8b08a9c675 100644 --- a/crypto/hash-nettle.c +++ b/crypto/hash-nettle.c @@ -50,43 +50,43 @@ struct qcrypto_hash_alg { qcrypto_nettle_result result; size_t len; } qcrypto_hash_alg_map[] =3D { - [QCRYPTO_HASH_ALG_MD5] =3D { + [QCRYPTO_HASH_ALGO_MD5] =3D { .init =3D (qcrypto_nettle_init)md5_init, .write =3D (qcrypto_nettle_write)md5_update, .result =3D (qcrypto_nettle_result)md5_digest, .len =3D MD5_DIGEST_SIZE, }, - [QCRYPTO_HASH_ALG_SHA1] =3D { + [QCRYPTO_HASH_ALGO_SHA1] =3D { .init =3D (qcrypto_nettle_init)sha1_init, .write =3D (qcrypto_nettle_write)sha1_update, .result =3D (qcrypto_nettle_result)sha1_digest, .len =3D SHA1_DIGEST_SIZE, }, - [QCRYPTO_HASH_ALG_SHA224] =3D { + [QCRYPTO_HASH_ALGO_SHA224] =3D { .init =3D (qcrypto_nettle_init)sha224_init, .write =3D (qcrypto_nettle_write)sha224_update, .result =3D (qcrypto_nettle_result)sha224_digest, .len =3D SHA224_DIGEST_SIZE, }, - [QCRYPTO_HASH_ALG_SHA256] =3D { + [QCRYPTO_HASH_ALGO_SHA256] =3D { .init =3D (qcrypto_nettle_init)sha256_init, .write =3D (qcrypto_nettle_write)sha256_update, .result =3D (qcrypto_nettle_result)sha256_digest, .len =3D SHA256_DIGEST_SIZE, }, - [QCRYPTO_HASH_ALG_SHA384] =3D { + [QCRYPTO_HASH_ALGO_SHA384] =3D { .init =3D (qcrypto_nettle_init)sha384_init, .write =3D (qcrypto_nettle_write)sha384_update, .result =3D (qcrypto_nettle_result)sha384_digest, .len =3D SHA384_DIGEST_SIZE, }, - [QCRYPTO_HASH_ALG_SHA512] =3D { + [QCRYPTO_HASH_ALGO_SHA512] =3D { .init =3D (qcrypto_nettle_init)sha512_init, .write =3D (qcrypto_nettle_write)sha512_update, .result =3D (qcrypto_nettle_result)sha512_digest, .len =3D SHA512_DIGEST_SIZE, }, - [QCRYPTO_HASH_ALG_RIPEMD160] =3D { + [QCRYPTO_HASH_ALGO_RIPEMD160] =3D { .init =3D (qcrypto_nettle_init)ripemd160_init, .write =3D (qcrypto_nettle_write)ripemd160_update, .result =3D (qcrypto_nettle_result)ripemd160_digest, @@ -94,7 +94,7 @@ struct qcrypto_hash_alg { }, }; =20 -gboolean qcrypto_hash_supports(QCryptoHashAlgorithm alg) +gboolean qcrypto_hash_supports(QCryptoHashAlgo alg) { if (alg < G_N_ELEMENTS(qcrypto_hash_alg_map) && qcrypto_hash_alg_map[alg].init !=3D NULL) { @@ -105,7 +105,7 @@ gboolean qcrypto_hash_supports(QCryptoHashAlgorithm alg) =20 =20 static int -qcrypto_nettle_hash_bytesv(QCryptoHashAlgorithm alg, +qcrypto_nettle_hash_bytesv(QCryptoHashAlgo alg, const struct iovec *iov, size_t niov, uint8_t **result, diff --git a/crypto/hash.c b/crypto/hash.c index 8087f5dae6..4a265582b8 100644 --- a/crypto/hash.c +++ b/crypto/hash.c @@ -22,23 +22,23 @@ #include "crypto/hash.h" #include "hashpriv.h" =20 -static size_t qcrypto_hash_alg_size[QCRYPTO_HASH_ALG__MAX] =3D { - [QCRYPTO_HASH_ALG_MD5] =3D QCRYPTO_HASH_DIGEST_LEN_MD5, - [QCRYPTO_HASH_ALG_SHA1] =3D QCRYPTO_HASH_DIGEST_LEN_SHA1, - [QCRYPTO_HASH_ALG_SHA224] =3D QCRYPTO_HASH_DIGEST_LEN_SHA224, - [QCRYPTO_HASH_ALG_SHA256] =3D QCRYPTO_HASH_DIGEST_LEN_SHA256, - [QCRYPTO_HASH_ALG_SHA384] =3D QCRYPTO_HASH_DIGEST_LEN_SHA384, - [QCRYPTO_HASH_ALG_SHA512] =3D QCRYPTO_HASH_DIGEST_LEN_SHA512, - [QCRYPTO_HASH_ALG_RIPEMD160] =3D QCRYPTO_HASH_DIGEST_LEN_RIPEMD160, +static size_t qcrypto_hash_alg_size[QCRYPTO_HASH_ALGO__MAX] =3D { + [QCRYPTO_HASH_ALGO_MD5] =3D QCRYPTO_HASH_DIGEST_LEN_MD5, + [QCRYPTO_HASH_ALGO_SHA1] =3D QCRYPTO_HASH_DIGEST_LEN_SHA1, + [QCRYPTO_HASH_ALGO_SHA224] =3D QCRYPTO_HASH_DIGEST_LEN_SHA224, + [QCRYPTO_HASH_ALGO_SHA256] =3D QCRYPTO_HASH_DIGEST_LEN_SHA256, + [QCRYPTO_HASH_ALGO_SHA384] =3D QCRYPTO_HASH_DIGEST_LEN_SHA384, + [QCRYPTO_HASH_ALGO_SHA512] =3D QCRYPTO_HASH_DIGEST_LEN_SHA512, + [QCRYPTO_HASH_ALGO_RIPEMD160] =3D QCRYPTO_HASH_DIGEST_LEN_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]; } =20 -int qcrypto_hash_bytesv(QCryptoHashAlgorithm alg, +int qcrypto_hash_bytesv(QCryptoHashAlgo alg, const struct iovec *iov, size_t niov, uint8_t **result, @@ -65,7 +65,7 @@ int qcrypto_hash_bytesv(QCryptoHashAlgorithm alg, } =20 =20 -int qcrypto_hash_bytes(QCryptoHashAlgorithm alg, +int qcrypto_hash_bytes(QCryptoHashAlgo alg, const char *buf, size_t len, uint8_t **result, @@ -79,7 +79,7 @@ int qcrypto_hash_bytes(QCryptoHashAlgorithm alg, =20 static const char hex[] =3D "0123456789abcdef"; =20 -int qcrypto_hash_digestv(QCryptoHashAlgorithm alg, +int qcrypto_hash_digestv(QCryptoHashAlgo alg, const struct iovec *iov, size_t niov, char **digest, @@ -103,7 +103,7 @@ int qcrypto_hash_digestv(QCryptoHashAlgorithm alg, return 0; } =20 -int qcrypto_hash_digest(QCryptoHashAlgorithm alg, +int qcrypto_hash_digest(QCryptoHashAlgo alg, const char *buf, size_t len, char **digest, @@ -114,7 +114,7 @@ int qcrypto_hash_digest(QCryptoHashAlgorithm alg, return qcrypto_hash_digestv(alg, &iov, 1, digest, errp); } =20 -int qcrypto_hash_base64v(QCryptoHashAlgorithm alg, +int qcrypto_hash_base64v(QCryptoHashAlgo alg, const struct iovec *iov, size_t niov, char **base64, @@ -132,7 +132,7 @@ int qcrypto_hash_base64v(QCryptoHashAlgorithm alg, return 0; } =20 -int qcrypto_hash_base64(QCryptoHashAlgorithm alg, +int qcrypto_hash_base64(QCryptoHashAlgo alg, const char *buf, size_t len, char **base64, diff --git a/crypto/hmac-gcrypt.c b/crypto/hmac-gcrypt.c index 0c6f979711..19990cb6ed 100644 --- a/crypto/hmac-gcrypt.c +++ b/crypto/hmac-gcrypt.c @@ -18,14 +18,14 @@ #include "hmacpriv.h" #include =20 -static int qcrypto_hmac_alg_map[QCRYPTO_HASH_ALG__MAX] =3D { - [QCRYPTO_HASH_ALG_MD5] =3D GCRY_MAC_HMAC_MD5, - [QCRYPTO_HASH_ALG_SHA1] =3D GCRY_MAC_HMAC_SHA1, - [QCRYPTO_HASH_ALG_SHA224] =3D GCRY_MAC_HMAC_SHA224, - [QCRYPTO_HASH_ALG_SHA256] =3D GCRY_MAC_HMAC_SHA256, - [QCRYPTO_HASH_ALG_SHA384] =3D GCRY_MAC_HMAC_SHA384, - [QCRYPTO_HASH_ALG_SHA512] =3D GCRY_MAC_HMAC_SHA512, - [QCRYPTO_HASH_ALG_RIPEMD160] =3D GCRY_MAC_HMAC_RMD160, +static int qcrypto_hmac_alg_map[QCRYPTO_HASH_ALGO__MAX] =3D { + [QCRYPTO_HASH_ALGO_MD5] =3D GCRY_MAC_HMAC_MD5, + [QCRYPTO_HASH_ALGO_SHA1] =3D GCRY_MAC_HMAC_SHA1, + [QCRYPTO_HASH_ALGO_SHA224] =3D GCRY_MAC_HMAC_SHA224, + [QCRYPTO_HASH_ALGO_SHA256] =3D GCRY_MAC_HMAC_SHA256, + [QCRYPTO_HASH_ALGO_SHA384] =3D GCRY_MAC_HMAC_SHA384, + [QCRYPTO_HASH_ALGO_SHA512] =3D GCRY_MAC_HMAC_SHA512, + [QCRYPTO_HASH_ALGO_RIPEMD160] =3D GCRY_MAC_HMAC_RMD160, }; =20 typedef struct QCryptoHmacGcrypt QCryptoHmacGcrypt; @@ -33,7 +33,7 @@ struct QCryptoHmacGcrypt { gcry_mac_hd_t handle; }; =20 -bool qcrypto_hmac_supports(QCryptoHashAlgorithm alg) +bool qcrypto_hmac_supports(QCryptoHashAlgo alg) { if (alg < G_N_ELEMENTS(qcrypto_hmac_alg_map) && qcrypto_hmac_alg_map[alg] !=3D GCRY_MAC_NONE) { @@ -43,7 +43,7 @@ bool qcrypto_hmac_supports(QCryptoHashAlgorithm alg) return false; } =20 -void *qcrypto_hmac_ctx_new(QCryptoHashAlgorithm alg, +void *qcrypto_hmac_ctx_new(QCryptoHashAlgo alg, const uint8_t *key, size_t nkey, Error **errp) { @@ -52,7 +52,7 @@ void *qcrypto_hmac_ctx_new(QCryptoHashAlgorithm alg, =20 if (!qcrypto_hmac_supports(alg)) { error_setg(errp, "Unsupported hmac algorithm %s", - QCryptoHashAlgorithm_str(alg)); + QCryptoHashAlgo_str(alg)); return NULL; } =20 diff --git a/crypto/hmac-glib.c b/crypto/hmac-glib.c index 509bbc74c2..ea80c8d1b2 100644 --- a/crypto/hmac-glib.c +++ b/crypto/hmac-glib.c @@ -17,14 +17,14 @@ #include "crypto/hmac.h" #include "hmacpriv.h" =20 -static int qcrypto_hmac_alg_map[QCRYPTO_HASH_ALG__MAX] =3D { - [QCRYPTO_HASH_ALG_MD5] =3D G_CHECKSUM_MD5, - [QCRYPTO_HASH_ALG_SHA1] =3D G_CHECKSUM_SHA1, - [QCRYPTO_HASH_ALG_SHA256] =3D G_CHECKSUM_SHA256, - [QCRYPTO_HASH_ALG_SHA512] =3D G_CHECKSUM_SHA512, - [QCRYPTO_HASH_ALG_SHA224] =3D -1, - [QCRYPTO_HASH_ALG_SHA384] =3D -1, - [QCRYPTO_HASH_ALG_RIPEMD160] =3D -1, +static int qcrypto_hmac_alg_map[QCRYPTO_HASH_ALGO__MAX] =3D { + [QCRYPTO_HASH_ALGO_MD5] =3D G_CHECKSUM_MD5, + [QCRYPTO_HASH_ALGO_SHA1] =3D G_CHECKSUM_SHA1, + [QCRYPTO_HASH_ALGO_SHA256] =3D G_CHECKSUM_SHA256, + [QCRYPTO_HASH_ALGO_SHA512] =3D G_CHECKSUM_SHA512, + [QCRYPTO_HASH_ALGO_SHA224] =3D -1, + [QCRYPTO_HASH_ALGO_SHA384] =3D -1, + [QCRYPTO_HASH_ALGO_RIPEMD160] =3D -1, }; =20 typedef struct QCryptoHmacGlib QCryptoHmacGlib; @@ -32,7 +32,7 @@ struct QCryptoHmacGlib { GHmac *ghmac; }; =20 -bool qcrypto_hmac_supports(QCryptoHashAlgorithm alg) +bool qcrypto_hmac_supports(QCryptoHashAlgo alg) { if (alg < G_N_ELEMENTS(qcrypto_hmac_alg_map) && qcrypto_hmac_alg_map[alg] !=3D -1) { @@ -42,7 +42,7 @@ bool qcrypto_hmac_supports(QCryptoHashAlgorithm alg) return false; } =20 -void *qcrypto_hmac_ctx_new(QCryptoHashAlgorithm alg, +void *qcrypto_hmac_ctx_new(QCryptoHashAlgo alg, const uint8_t *key, size_t nkey, Error **errp) { @@ -50,7 +50,7 @@ void *qcrypto_hmac_ctx_new(QCryptoHashAlgorithm alg, =20 if (!qcrypto_hmac_supports(alg)) { error_setg(errp, "Unsupported hmac algorithm %s", - QCryptoHashAlgorithm_str(alg)); + QCryptoHashAlgo_str(alg)); return NULL; } =20 diff --git a/crypto/hmac-gnutls.c b/crypto/hmac-gnutls.c index 24db383322..822995505c 100644 --- a/crypto/hmac-gnutls.c +++ b/crypto/hmac-gnutls.c @@ -20,14 +20,14 @@ #include "crypto/hmac.h" #include "hmacpriv.h" =20 -static int qcrypto_hmac_alg_map[QCRYPTO_HASH_ALG__MAX] =3D { - [QCRYPTO_HASH_ALG_MD5] =3D GNUTLS_MAC_MD5, - [QCRYPTO_HASH_ALG_SHA1] =3D GNUTLS_MAC_SHA1, - [QCRYPTO_HASH_ALG_SHA224] =3D GNUTLS_MAC_SHA224, - [QCRYPTO_HASH_ALG_SHA256] =3D GNUTLS_MAC_SHA256, - [QCRYPTO_HASH_ALG_SHA384] =3D GNUTLS_MAC_SHA384, - [QCRYPTO_HASH_ALG_SHA512] =3D GNUTLS_MAC_SHA512, - [QCRYPTO_HASH_ALG_RIPEMD160] =3D GNUTLS_MAC_RMD160, +static int qcrypto_hmac_alg_map[QCRYPTO_HASH_ALGO__MAX] =3D { + [QCRYPTO_HASH_ALGO_MD5] =3D GNUTLS_MAC_MD5, + [QCRYPTO_HASH_ALGO_SHA1] =3D GNUTLS_MAC_SHA1, + [QCRYPTO_HASH_ALGO_SHA224] =3D GNUTLS_MAC_SHA224, + [QCRYPTO_HASH_ALGO_SHA256] =3D GNUTLS_MAC_SHA256, + [QCRYPTO_HASH_ALGO_SHA384] =3D GNUTLS_MAC_SHA384, + [QCRYPTO_HASH_ALGO_SHA512] =3D GNUTLS_MAC_SHA512, + [QCRYPTO_HASH_ALGO_RIPEMD160] =3D GNUTLS_MAC_RMD160, }; =20 typedef struct QCryptoHmacGnutls QCryptoHmacGnutls; @@ -35,7 +35,7 @@ struct QCryptoHmacGnutls { gnutls_hmac_hd_t handle; }; =20 -bool qcrypto_hmac_supports(QCryptoHashAlgorithm alg) +bool qcrypto_hmac_supports(QCryptoHashAlgo alg) { size_t i; const gnutls_digest_algorithm_t *algs; @@ -52,7 +52,7 @@ bool qcrypto_hmac_supports(QCryptoHashAlgorithm alg) return false; } =20 -void *qcrypto_hmac_ctx_new(QCryptoHashAlgorithm alg, +void *qcrypto_hmac_ctx_new(QCryptoHashAlgo alg, const uint8_t *key, size_t nkey, Error **errp) { @@ -61,7 +61,7 @@ void *qcrypto_hmac_ctx_new(QCryptoHashAlgorithm alg, =20 if (!qcrypto_hmac_supports(alg)) { error_setg(errp, "Unsupported hmac algorithm %s", - QCryptoHashAlgorithm_str(alg)); + QCryptoHashAlgo_str(alg)); return NULL; } =20 diff --git a/crypto/hmac-nettle.c b/crypto/hmac-nettle.c index 1ad6c4f253..54dd75d5ff 100644 --- a/crypto/hmac-nettle.c +++ b/crypto/hmac-nettle.c @@ -46,44 +46,44 @@ struct qcrypto_nettle_hmac_alg { qcrypto_nettle_hmac_update update; qcrypto_nettle_hmac_digest digest; size_t len; -} qcrypto_hmac_alg_map[QCRYPTO_HASH_ALG__MAX] =3D { - [QCRYPTO_HASH_ALG_MD5] =3D { +} qcrypto_hmac_alg_map[QCRYPTO_HASH_ALGO__MAX] =3D { + [QCRYPTO_HASH_ALGO_MD5] =3D { .setkey =3D (qcrypto_nettle_hmac_setkey)hmac_md5_set_key, .update =3D (qcrypto_nettle_hmac_update)hmac_md5_update, .digest =3D (qcrypto_nettle_hmac_digest)hmac_md5_digest, .len =3D MD5_DIGEST_SIZE, }, - [QCRYPTO_HASH_ALG_SHA1] =3D { + [QCRYPTO_HASH_ALGO_SHA1] =3D { .setkey =3D (qcrypto_nettle_hmac_setkey)hmac_sha1_set_key, .update =3D (qcrypto_nettle_hmac_update)hmac_sha1_update, .digest =3D (qcrypto_nettle_hmac_digest)hmac_sha1_digest, .len =3D SHA1_DIGEST_SIZE, }, - [QCRYPTO_HASH_ALG_SHA224] =3D { + [QCRYPTO_HASH_ALGO_SHA224] =3D { .setkey =3D (qcrypto_nettle_hmac_setkey)hmac_sha224_set_key, .update =3D (qcrypto_nettle_hmac_update)hmac_sha224_update, .digest =3D (qcrypto_nettle_hmac_digest)hmac_sha224_digest, .len =3D SHA224_DIGEST_SIZE, }, - [QCRYPTO_HASH_ALG_SHA256] =3D { + [QCRYPTO_HASH_ALGO_SHA256] =3D { .setkey =3D (qcrypto_nettle_hmac_setkey)hmac_sha256_set_key, .update =3D (qcrypto_nettle_hmac_update)hmac_sha256_update, .digest =3D (qcrypto_nettle_hmac_digest)hmac_sha256_digest, .len =3D SHA256_DIGEST_SIZE, }, - [QCRYPTO_HASH_ALG_SHA384] =3D { + [QCRYPTO_HASH_ALGO_SHA384] =3D { .setkey =3D (qcrypto_nettle_hmac_setkey)hmac_sha384_set_key, .update =3D (qcrypto_nettle_hmac_update)hmac_sha384_update, .digest =3D (qcrypto_nettle_hmac_digest)hmac_sha384_digest, .len =3D SHA384_DIGEST_SIZE, }, - [QCRYPTO_HASH_ALG_SHA512] =3D { + [QCRYPTO_HASH_ALGO_SHA512] =3D { .setkey =3D (qcrypto_nettle_hmac_setkey)hmac_sha512_set_key, .update =3D (qcrypto_nettle_hmac_update)hmac_sha512_update, .digest =3D (qcrypto_nettle_hmac_digest)hmac_sha512_digest, .len =3D SHA512_DIGEST_SIZE, }, - [QCRYPTO_HASH_ALG_RIPEMD160] =3D { + [QCRYPTO_HASH_ALGO_RIPEMD160] =3D { .setkey =3D (qcrypto_nettle_hmac_setkey)hmac_ripemd160_set_key, .update =3D (qcrypto_nettle_hmac_update)hmac_ripemd160_update, .digest =3D (qcrypto_nettle_hmac_digest)hmac_ripemd160_digest, @@ -91,7 +91,7 @@ struct qcrypto_nettle_hmac_alg { }, }; =20 -bool qcrypto_hmac_supports(QCryptoHashAlgorithm alg) +bool qcrypto_hmac_supports(QCryptoHashAlgo alg) { if (alg < G_N_ELEMENTS(qcrypto_hmac_alg_map) && qcrypto_hmac_alg_map[alg].setkey !=3D NULL) { @@ -101,7 +101,7 @@ bool qcrypto_hmac_supports(QCryptoHashAlgorithm alg) return false; } =20 -void *qcrypto_hmac_ctx_new(QCryptoHashAlgorithm alg, +void *qcrypto_hmac_ctx_new(QCryptoHashAlgo alg, const uint8_t *key, size_t nkey, Error **errp) { @@ -109,7 +109,7 @@ void *qcrypto_hmac_ctx_new(QCryptoHashAlgorithm alg, =20 if (!qcrypto_hmac_supports(alg)) { error_setg(errp, "Unsupported hmac algorithm %s", - QCryptoHashAlgorithm_str(alg)); + QCryptoHashAlgo_str(alg)); return NULL; } =20 diff --git a/crypto/hmac.c b/crypto/hmac.c index 4de7e8c9cb..422e005182 100644 --- a/crypto/hmac.c +++ b/crypto/hmac.c @@ -83,7 +83,7 @@ int qcrypto_hmac_digest(QCryptoHmac *hmac, return qcrypto_hmac_digestv(hmac, &iov, 1, digest, errp); } =20 -QCryptoHmac *qcrypto_hmac_new(QCryptoHashAlgorithm alg, +QCryptoHmac *qcrypto_hmac_new(QCryptoHashAlgo alg, const uint8_t *key, size_t nkey, Error **errp) { diff --git a/crypto/ivgen.c b/crypto/ivgen.c index 12822f8519..080846cb74 100644 --- a/crypto/ivgen.c +++ b/crypto/ivgen.c @@ -29,7 +29,7 @@ =20 QCryptoIVGen *qcrypto_ivgen_new(QCryptoIVGenAlgorithm alg, QCryptoCipherAlgorithm cipheralg, - QCryptoHashAlgorithm hash, + QCryptoHashAlgo hash, const uint8_t *key, size_t nkey, Error **errp) { @@ -85,7 +85,7 @@ QCryptoCipherAlgorithm qcrypto_ivgen_get_cipher(QCryptoIV= Gen *ivgen) } =20 =20 -QCryptoHashAlgorithm qcrypto_ivgen_get_hash(QCryptoIVGen *ivgen) +QCryptoHashAlgo qcrypto_ivgen_get_hash(QCryptoIVGen *ivgen) { return ivgen->hash; } diff --git a/crypto/pbkdf-gcrypt.c b/crypto/pbkdf-gcrypt.c index bc0719c831..76bbb55f7a 100644 --- a/crypto/pbkdf-gcrypt.c +++ b/crypto/pbkdf-gcrypt.c @@ -23,37 +23,37 @@ #include "qapi/error.h" #include "crypto/pbkdf.h" =20 -bool qcrypto_pbkdf2_supports(QCryptoHashAlgorithm hash) +bool qcrypto_pbkdf2_supports(QCryptoHashAlgo hash) { switch (hash) { - case QCRYPTO_HASH_ALG_MD5: - case QCRYPTO_HASH_ALG_SHA1: - case QCRYPTO_HASH_ALG_SHA224: - case QCRYPTO_HASH_ALG_SHA256: - case QCRYPTO_HASH_ALG_SHA384: - case QCRYPTO_HASH_ALG_SHA512: - case QCRYPTO_HASH_ALG_RIPEMD160: + case QCRYPTO_HASH_ALGO_MD5: + case QCRYPTO_HASH_ALGO_SHA1: + case QCRYPTO_HASH_ALGO_SHA224: + case QCRYPTO_HASH_ALGO_SHA256: + case QCRYPTO_HASH_ALGO_SHA384: + case QCRYPTO_HASH_ALGO_SHA512: + case QCRYPTO_HASH_ALGO_RIPEMD160: return qcrypto_hash_supports(hash); default: return false; } } =20 -int qcrypto_pbkdf2(QCryptoHashAlgorithm hash, +int qcrypto_pbkdf2(QCryptoHashAlgo hash, const uint8_t *key, size_t nkey, const uint8_t *salt, size_t nsalt, uint64_t iterations, uint8_t *out, size_t nout, Error **errp) { - static const int hash_map[QCRYPTO_HASH_ALG__MAX] =3D { - [QCRYPTO_HASH_ALG_MD5] =3D GCRY_MD_MD5, - [QCRYPTO_HASH_ALG_SHA1] =3D GCRY_MD_SHA1, - [QCRYPTO_HASH_ALG_SHA224] =3D GCRY_MD_SHA224, - [QCRYPTO_HASH_ALG_SHA256] =3D GCRY_MD_SHA256, - [QCRYPTO_HASH_ALG_SHA384] =3D GCRY_MD_SHA384, - [QCRYPTO_HASH_ALG_SHA512] =3D GCRY_MD_SHA512, - [QCRYPTO_HASH_ALG_RIPEMD160] =3D GCRY_MD_RMD160, + static const int hash_map[QCRYPTO_HASH_ALGO__MAX] =3D { + [QCRYPTO_HASH_ALGO_MD5] =3D GCRY_MD_MD5, + [QCRYPTO_HASH_ALGO_SHA1] =3D GCRY_MD_SHA1, + [QCRYPTO_HASH_ALGO_SHA224] =3D GCRY_MD_SHA224, + [QCRYPTO_HASH_ALGO_SHA256] =3D GCRY_MD_SHA256, + [QCRYPTO_HASH_ALGO_SHA384] =3D GCRY_MD_SHA384, + [QCRYPTO_HASH_ALGO_SHA512] =3D GCRY_MD_SHA512, + [QCRYPTO_HASH_ALGO_RIPEMD160] =3D GCRY_MD_RMD160, }; int ret; =20 @@ -68,7 +68,7 @@ int qcrypto_pbkdf2(QCryptoHashAlgorithm hash, hash_map[hash] =3D=3D GCRY_MD_NONE) { error_setg_errno(errp, ENOSYS, "PBKDF does not support hash algorithm %s", - QCryptoHashAlgorithm_str(hash)); + QCryptoHashAlgo_str(hash)); return -1; } =20 diff --git a/crypto/pbkdf-gnutls.c b/crypto/pbkdf-gnutls.c index 911b565bea..f34423f918 100644 --- a/crypto/pbkdf-gnutls.c +++ b/crypto/pbkdf-gnutls.c @@ -23,37 +23,37 @@ #include "qapi/error.h" #include "crypto/pbkdf.h" =20 -bool qcrypto_pbkdf2_supports(QCryptoHashAlgorithm hash) +bool qcrypto_pbkdf2_supports(QCryptoHashAlgo hash) { switch (hash) { - case QCRYPTO_HASH_ALG_MD5: - case QCRYPTO_HASH_ALG_SHA1: - case QCRYPTO_HASH_ALG_SHA224: - case QCRYPTO_HASH_ALG_SHA256: - case QCRYPTO_HASH_ALG_SHA384: - case QCRYPTO_HASH_ALG_SHA512: - case QCRYPTO_HASH_ALG_RIPEMD160: + case QCRYPTO_HASH_ALGO_MD5: + case QCRYPTO_HASH_ALGO_SHA1: + case QCRYPTO_HASH_ALGO_SHA224: + case QCRYPTO_HASH_ALGO_SHA256: + case QCRYPTO_HASH_ALGO_SHA384: + case QCRYPTO_HASH_ALGO_SHA512: + case QCRYPTO_HASH_ALGO_RIPEMD160: return qcrypto_hash_supports(hash); default: return false; } } =20 -int qcrypto_pbkdf2(QCryptoHashAlgorithm hash, +int qcrypto_pbkdf2(QCryptoHashAlgo hash, const uint8_t *key, size_t nkey, const uint8_t *salt, size_t nsalt, uint64_t iterations, uint8_t *out, size_t nout, Error **errp) { - static const int hash_map[QCRYPTO_HASH_ALG__MAX] =3D { - [QCRYPTO_HASH_ALG_MD5] =3D GNUTLS_DIG_MD5, - [QCRYPTO_HASH_ALG_SHA1] =3D GNUTLS_DIG_SHA1, - [QCRYPTO_HASH_ALG_SHA224] =3D GNUTLS_DIG_SHA224, - [QCRYPTO_HASH_ALG_SHA256] =3D GNUTLS_DIG_SHA256, - [QCRYPTO_HASH_ALG_SHA384] =3D GNUTLS_DIG_SHA384, - [QCRYPTO_HASH_ALG_SHA512] =3D GNUTLS_DIG_SHA512, - [QCRYPTO_HASH_ALG_RIPEMD160] =3D GNUTLS_DIG_RMD160, + static const int hash_map[QCRYPTO_HASH_ALGO__MAX] =3D { + [QCRYPTO_HASH_ALGO_MD5] =3D GNUTLS_DIG_MD5, + [QCRYPTO_HASH_ALGO_SHA1] =3D GNUTLS_DIG_SHA1, + [QCRYPTO_HASH_ALGO_SHA224] =3D GNUTLS_DIG_SHA224, + [QCRYPTO_HASH_ALGO_SHA256] =3D GNUTLS_DIG_SHA256, + [QCRYPTO_HASH_ALGO_SHA384] =3D GNUTLS_DIG_SHA384, + [QCRYPTO_HASH_ALGO_SHA512] =3D GNUTLS_DIG_SHA512, + [QCRYPTO_HASH_ALGO_RIPEMD160] =3D GNUTLS_DIG_RMD160, }; int ret; const gnutls_datum_t gkey =3D { (unsigned char *)key, nkey }; @@ -70,7 +70,7 @@ int qcrypto_pbkdf2(QCryptoHashAlgorithm hash, hash_map[hash] =3D=3D GNUTLS_DIG_UNKNOWN) { error_setg_errno(errp, ENOSYS, "PBKDF does not support hash algorithm %s", - QCryptoHashAlgorithm_str(hash)); + QCryptoHashAlgo_str(hash)); return -1; } =20 diff --git a/crypto/pbkdf-nettle.c b/crypto/pbkdf-nettle.c index d6293c25a1..93e686c2c6 100644 --- a/crypto/pbkdf-nettle.c +++ b/crypto/pbkdf-nettle.c @@ -25,22 +25,22 @@ #include "crypto/pbkdf.h" =20 =20 -bool qcrypto_pbkdf2_supports(QCryptoHashAlgorithm hash) +bool qcrypto_pbkdf2_supports(QCryptoHashAlgo hash) { switch (hash) { - case QCRYPTO_HASH_ALG_SHA1: - case QCRYPTO_HASH_ALG_SHA224: - case QCRYPTO_HASH_ALG_SHA256: - case QCRYPTO_HASH_ALG_SHA384: - case QCRYPTO_HASH_ALG_SHA512: - case QCRYPTO_HASH_ALG_RIPEMD160: + case QCRYPTO_HASH_ALGO_SHA1: + case QCRYPTO_HASH_ALGO_SHA224: + case QCRYPTO_HASH_ALGO_SHA256: + case QCRYPTO_HASH_ALGO_SHA384: + case QCRYPTO_HASH_ALGO_SHA512: + case QCRYPTO_HASH_ALGO_RIPEMD160: return true; default: return false; } } =20 -int qcrypto_pbkdf2(QCryptoHashAlgorithm hash, +int qcrypto_pbkdf2(QCryptoHashAlgo hash, const uint8_t *key, size_t nkey, const uint8_t *salt, size_t nsalt, uint64_t iterations, @@ -65,43 +65,43 @@ int qcrypto_pbkdf2(QCryptoHashAlgorithm hash, } =20 switch (hash) { - case QCRYPTO_HASH_ALG_MD5: + case QCRYPTO_HASH_ALGO_MD5: hmac_md5_set_key(&ctx.md5, nkey, key); PBKDF2(&ctx.md5, hmac_md5_update, hmac_md5_digest, MD5_DIGEST_SIZE, iterations, nsalt, salt, nout, out); break; =20 - case QCRYPTO_HASH_ALG_SHA1: + case QCRYPTO_HASH_ALGO_SHA1: hmac_sha1_set_key(&ctx.sha1, nkey, key); PBKDF2(&ctx.sha1, hmac_sha1_update, hmac_sha1_digest, SHA1_DIGEST_SIZE, iterations, nsalt, salt, nout, out); break; =20 - case QCRYPTO_HASH_ALG_SHA224: + case QCRYPTO_HASH_ALGO_SHA224: hmac_sha224_set_key(&ctx.sha224, nkey, key); PBKDF2(&ctx.sha224, hmac_sha224_update, hmac_sha224_digest, SHA224_DIGEST_SIZE, iterations, nsalt, salt, nout, out); break; =20 - case QCRYPTO_HASH_ALG_SHA256: + case QCRYPTO_HASH_ALGO_SHA256: hmac_sha256_set_key(&ctx.sha256, nkey, key); PBKDF2(&ctx.sha256, hmac_sha256_update, hmac_sha256_digest, SHA256_DIGEST_SIZE, iterations, nsalt, salt, nout, out); break; =20 - case QCRYPTO_HASH_ALG_SHA384: + case QCRYPTO_HASH_ALGO_SHA384: hmac_sha384_set_key(&ctx.sha384, nkey, key); PBKDF2(&ctx.sha384, hmac_sha384_update, hmac_sha384_digest, SHA384_DIGEST_SIZE, iterations, nsalt, salt, nout, out); break; =20 - case QCRYPTO_HASH_ALG_SHA512: + case QCRYPTO_HASH_ALGO_SHA512: hmac_sha512_set_key(&ctx.sha512, nkey, key); PBKDF2(&ctx.sha512, hmac_sha512_update, hmac_sha512_digest, SHA512_DIGEST_SIZE, iterations, nsalt, salt, nout, out); break; =20 - case QCRYPTO_HASH_ALG_RIPEMD160: + case QCRYPTO_HASH_ALGO_RIPEMD160: hmac_ripemd160_set_key(&ctx.ripemd160, nkey, key); PBKDF2(&ctx.ripemd160, hmac_ripemd160_update, hmac_ripemd160_diges= t, RIPEMD160_DIGEST_SIZE, iterations, nsalt, salt, nout, out); @@ -110,7 +110,7 @@ int qcrypto_pbkdf2(QCryptoHashAlgorithm hash, default: error_setg_errno(errp, ENOSYS, "PBKDF does not support hash algorithm %s", - QCryptoHashAlgorithm_str(hash)); + QCryptoHashAlgo_str(hash)); return -1; } return 0; diff --git a/crypto/pbkdf-stub.c b/crypto/pbkdf-stub.c index 9c4622e424..9f29d0eed7 100644 --- a/crypto/pbkdf-stub.c +++ b/crypto/pbkdf-stub.c @@ -22,12 +22,12 @@ #include "qapi/error.h" #include "crypto/pbkdf.h" =20 -bool qcrypto_pbkdf2_supports(QCryptoHashAlgorithm hash G_GNUC_UNUSED) +bool qcrypto_pbkdf2_supports(QCryptoHashAlgo hash G_GNUC_UNUSED) { return false; } =20 -int qcrypto_pbkdf2(QCryptoHashAlgorithm hash G_GNUC_UNUSED, +int qcrypto_pbkdf2(QCryptoHashAlgo hash G_GNUC_UNUSED, const uint8_t *key G_GNUC_UNUSED, size_t nkey G_GNUC_UNUSED, const uint8_t *salt G_GNUC_UNUSED, diff --git a/crypto/pbkdf.c b/crypto/pbkdf.c index d1c06ef3ed..0dd7c3aeaa 100644 --- a/crypto/pbkdf.c +++ b/crypto/pbkdf.c @@ -87,7 +87,7 @@ static int qcrypto_pbkdf2_get_thread_cpu(unsigned long lo= ng *val_ms, } =20 typedef struct CountItersData { - QCryptoHashAlgorithm hash; + QCryptoHashAlgo hash; const uint8_t *key; size_t nkey; const uint8_t *salt; @@ -100,7 +100,7 @@ typedef struct CountItersData { static void *threaded_qcrypto_pbkdf2_count_iters(void *data) { CountItersData *iters_data =3D (CountItersData *) data; - QCryptoHashAlgorithm hash =3D iters_data->hash; + QCryptoHashAlgo hash =3D iters_data->hash; const uint8_t *key =3D iters_data->key; size_t nkey =3D iters_data->nkey; const uint8_t *salt =3D iters_data->salt; @@ -153,7 +153,7 @@ static void *threaded_qcrypto_pbkdf2_count_iters(void *= data) return NULL; } =20 -uint64_t qcrypto_pbkdf2_count_iters(QCryptoHashAlgorithm hash, +uint64_t qcrypto_pbkdf2_count_iters(QCryptoHashAlgo hash, const uint8_t *key, size_t nkey, const uint8_t *salt, size_t nsalt, size_t nout, diff --git a/crypto/x509-utils.c b/crypto/x509-utils.c index 6e157af76b..8bad00a51b 100644 --- a/crypto/x509-utils.c +++ b/crypto/x509-utils.c @@ -15,18 +15,18 @@ #include #include =20 -static const int qcrypto_to_gnutls_hash_alg_map[QCRYPTO_HASH_ALG__MAX] =3D= { - [QCRYPTO_HASH_ALG_MD5] =3D GNUTLS_DIG_MD5, - [QCRYPTO_HASH_ALG_SHA1] =3D GNUTLS_DIG_SHA1, - [QCRYPTO_HASH_ALG_SHA224] =3D GNUTLS_DIG_SHA224, - [QCRYPTO_HASH_ALG_SHA256] =3D GNUTLS_DIG_SHA256, - [QCRYPTO_HASH_ALG_SHA384] =3D GNUTLS_DIG_SHA384, - [QCRYPTO_HASH_ALG_SHA512] =3D GNUTLS_DIG_SHA512, - [QCRYPTO_HASH_ALG_RIPEMD160] =3D GNUTLS_DIG_RMD160, +static const int qcrypto_to_gnutls_hash_alg_map[QCRYPTO_HASH_ALGO__MAX] = =3D { + [QCRYPTO_HASH_ALGO_MD5] =3D GNUTLS_DIG_MD5, + [QCRYPTO_HASH_ALGO_SHA1] =3D GNUTLS_DIG_SHA1, + [QCRYPTO_HASH_ALGO_SHA224] =3D GNUTLS_DIG_SHA224, + [QCRYPTO_HASH_ALGO_SHA256] =3D GNUTLS_DIG_SHA256, + [QCRYPTO_HASH_ALGO_SHA384] =3D GNUTLS_DIG_SHA384, + [QCRYPTO_HASH_ALGO_SHA512] =3D GNUTLS_DIG_SHA512, + [QCRYPTO_HASH_ALGO_RIPEMD160] =3D GNUTLS_DIG_RMD160, }; =20 int qcrypto_get_x509_cert_fingerprint(uint8_t *cert, size_t size, - QCryptoHashAlgorithm alg, + QCryptoHashAlgo alg, uint8_t *result, size_t *resultlen, Error **errp) diff --git a/hw/misc/aspeed_hace.c b/hw/misc/aspeed_hace.c index c06c04ddc6..3541adf813 100644 --- a/hw/misc/aspeed_hace.c +++ b/hw/misc/aspeed_hace.c @@ -68,15 +68,15 @@ =20 static const struct { uint32_t mask; - QCryptoHashAlgorithm algo; + QCryptoHashAlgo algo; } hash_algo_map[] =3D { - { HASH_ALGO_MD5, QCRYPTO_HASH_ALG_MD5 }, - { HASH_ALGO_SHA1, QCRYPTO_HASH_ALG_SHA1 }, - { HASH_ALGO_SHA224, QCRYPTO_HASH_ALG_SHA224 }, - { HASH_ALGO_SHA256, QCRYPTO_HASH_ALG_SHA256 }, - { HASH_ALGO_SHA512_SERIES | HASH_ALGO_SHA512_SHA512, QCRYPTO_HASH_ALG_= SHA512 }, - { HASH_ALGO_SHA512_SERIES | HASH_ALGO_SHA512_SHA384, QCRYPTO_HASH_ALG_= SHA384 }, - { HASH_ALGO_SHA512_SERIES | HASH_ALGO_SHA512_SHA256, QCRYPTO_HASH_ALG_= SHA256 }, + { HASH_ALGO_MD5, QCRYPTO_HASH_ALGO_MD5 }, + { HASH_ALGO_SHA1, QCRYPTO_HASH_ALGO_SHA1 }, + { HASH_ALGO_SHA224, QCRYPTO_HASH_ALGO_SHA224 }, + { HASH_ALGO_SHA256, QCRYPTO_HASH_ALGO_SHA256 }, + { HASH_ALGO_SHA512_SERIES | HASH_ALGO_SHA512_SHA512, QCRYPTO_HASH_ALGO= _SHA512 }, + { HASH_ALGO_SHA512_SERIES | HASH_ALGO_SHA512_SHA384, QCRYPTO_HASH_ALGO= _SHA384 }, + { HASH_ALGO_SHA512_SERIES | HASH_ALGO_SHA512_SHA256, QCRYPTO_HASH_ALGO= _SHA256 }, }; =20 static int hash_algo_lookup(uint32_t reg) diff --git a/io/channel-websock.c b/io/channel-websock.c index de39f0d182..55192b770a 100644 --- a/io/channel-websock.c +++ b/io/channel-websock.c @@ -351,7 +351,7 @@ static void qio_channel_websock_handshake_send_res_ok(Q= IOChannelWebsock *ioc, QIO_CHANNEL_WEBSOCK_GUID_LEN + 1); =20 /* hash and encode it */ - if (qcrypto_hash_base64(QCRYPTO_HASH_ALG_SHA1, + if (qcrypto_hash_base64(QCRYPTO_HASH_ALGO_SHA1, combined_key, QIO_CHANNEL_WEBSOCK_CLIENT_KEY_LEN + QIO_CHANNEL_WEBSOCK_GUID_LEN, diff --git a/target/i386/sev.c b/target/i386/sev.c index a0d271f898..1a4eb1ada6 100644 --- a/target/i386/sev.c +++ b/target/i386/sev.c @@ -1883,7 +1883,7 @@ static bool build_kernel_loader_hashes(PaddedSevHashT= able *padded_ht, * be used. */ hashp =3D cmdline_hash; - if (qcrypto_hash_bytes(QCRYPTO_HASH_ALG_SHA256, ctx->cmdline_data, + if (qcrypto_hash_bytes(QCRYPTO_HASH_ALGO_SHA256, ctx->cmdline_data, ctx->cmdline_size, &hashp, &hash_len, errp) < 0= ) { return false; } @@ -1894,7 +1894,7 @@ static bool build_kernel_loader_hashes(PaddedSevHashT= able *padded_ht, * -initrd, an empty buffer will be used (ctx->initrd_size =3D=3D 0). */ hashp =3D initrd_hash; - if (qcrypto_hash_bytes(QCRYPTO_HASH_ALG_SHA256, ctx->initrd_data, + if (qcrypto_hash_bytes(QCRYPTO_HASH_ALGO_SHA256, ctx->initrd_data, ctx->initrd_size, &hashp, &hash_len, errp) < 0)= { return false; } @@ -1906,7 +1906,7 @@ static bool build_kernel_loader_hashes(PaddedSevHashT= able *padded_ht, { .iov_base =3D ctx->setup_data, .iov_len =3D ctx->setup_size }, { .iov_base =3D ctx->kernel_data, .iov_len =3D ctx->kernel_size } }; - if (qcrypto_hash_bytesv(QCRYPTO_HASH_ALG_SHA256, iov, ARRAY_SIZE(iov), + if (qcrypto_hash_bytesv(QCRYPTO_HASH_ALGO_SHA256, iov, ARRAY_SIZE(iov), &hashp, &hash_len, errp) < 0) { return false; } diff --git a/tests/bench/benchmark-crypto-akcipher.c b/tests/bench/benchmar= k-crypto-akcipher.c index bbc29c9b12..0029972385 100644 --- a/tests/bench/benchmark-crypto-akcipher.c +++ b/tests/bench/benchmark-crypto-akcipher.c @@ -21,7 +21,7 @@ static QCryptoAkCipher *create_rsa_akcipher(const uint8_t *priv_key, size_t keylen, QCryptoRSAPaddingAlgorithm pad= ding, - QCryptoHashAlgorithm hash) + QCryptoHashAlgo hash) { QCryptoAkCipherOptions opt; =20 @@ -40,7 +40,7 @@ static void test_rsa_speed(const uint8_t *priv_key, size_= t keylen, #define SIGN_TIMES 10000 #define VERIFY_TIMES 100000 #define PADDING QCRYPTO_RSA_PADDING_ALG_PKCS1 -#define HASH QCRYPTO_HASH_ALG_SHA1 +#define HASH QCRYPTO_HASH_ALGO_SHA1 =20 g_autoptr(QCryptoAkCipher) rsa =3D create_rsa_akcipher(priv_key, keylen, PADDING, HASH); @@ -54,7 +54,7 @@ static void test_rsa_speed(const uint8_t *priv_key, size_= t keylen, =20 g_test_message("benchmark rsa%zu (%s-%s) sign...", key_size, QCryptoRSAPaddingAlgorithm_str(PADDING), - QCryptoHashAlgorithm_str(HASH)); + QCryptoHashAlgo_str(HASH)); g_test_timer_start(); for (count =3D 0; count < SIGN_TIMES; ++count) { g_assert(qcrypto_akcipher_sign(rsa, dgst, SHA1_DGST_LEN, @@ -65,13 +65,13 @@ static void test_rsa_speed(const uint8_t *priv_key, siz= e_t keylen, g_test_message("rsa%zu (%s-%s) sign %zu times in %.2f seconds," " %.2f times/sec ", key_size, QCryptoRSAPaddingAlgorithm_str(PADDING), - QCryptoHashAlgorithm_str(HASH), + QCryptoHashAlgo_str(HASH), count, g_test_timer_last(), (double)count / g_test_timer_last()); =20 g_test_message("benchmark rsa%zu (%s-%s) verification...", key_size, QCryptoRSAPaddingAlgorithm_str(PADDING), - QCryptoHashAlgorithm_str(HASH)); + QCryptoHashAlgo_str(HASH)); g_test_timer_start(); for (count =3D 0; count < VERIFY_TIMES; ++count) { g_assert(qcrypto_akcipher_verify(rsa, signature, key_size / BYTE, @@ -82,7 +82,7 @@ static void test_rsa_speed(const uint8_t *priv_key, size_= t keylen, g_test_message("rsa%zu (%s-%s) verify %zu times in %.2f seconds," " %.2f times/sec ", key_size, QCryptoRSAPaddingAlgorithm_str(PADDING), - QCryptoHashAlgorithm_str(HASH), + QCryptoHashAlgo_str(HASH), count, g_test_timer_last(), (double)count / g_test_timer_last()); } diff --git a/tests/bench/benchmark-crypto-hash.c b/tests/bench/benchmark-cr= ypto-hash.c index 927b00bb4d..252098a69d 100644 --- a/tests/bench/benchmark-crypto-hash.c +++ b/tests/bench/benchmark-crypto-hash.c @@ -17,7 +17,7 @@ =20 typedef struct QCryptoHashOpts { size_t chunk_size; - QCryptoHashAlgorithm alg; + QCryptoHashAlgo alg; } QCryptoHashOpts; =20 static void test_hash_speed(const void *opaque) @@ -49,7 +49,7 @@ static void test_hash_speed(const void *opaque) g_test_timer_elapsed(); =20 g_test_message("hash(%s): chunk %zu bytes %.2f MB/sec", - QCryptoHashAlgorithm_str(opts->alg), + QCryptoHashAlgo_str(opts->alg), opts->chunk_size, total / g_test_timer_last()); =20 g_free(out); @@ -65,14 +65,14 @@ int main(int argc, char **argv) =20 #define TEST_ONE(a, c) \ QCryptoHashOpts opts ## a ## c =3D { \ - .alg =3D QCRYPTO_HASH_ALG_ ## a, .chunk_size =3D c, \ + .alg =3D QCRYPTO_HASH_ALGO_ ## a, .chunk_size =3D c, \ }; \ memset(name, 0 , sizeof(name)); \ snprintf(name, sizeof(name), \ "/crypto/benchmark/hash/%s/bufsize-%d", \ - QCryptoHashAlgorithm_str(QCRYPTO_HASH_ALG_ ## a), \ + QCryptoHashAlgo_str(QCRYPTO_HASH_ALGO_ ## a), \ c); \ - if (qcrypto_hash_supports(QCRYPTO_HASH_ALG_ ## a)) \ + if (qcrypto_hash_supports(QCRYPTO_HASH_ALGO_ ## a)) \ g_test_add_data_func(name, \ &opts ## a ## c, \ test_hash_speed); diff --git a/tests/bench/benchmark-crypto-hmac.c b/tests/bench/benchmark-cr= ypto-hmac.c index 5cca636789..d51de98f47 100644 --- a/tests/bench/benchmark-crypto-hmac.c +++ b/tests/bench/benchmark-crypto-hmac.c @@ -28,7 +28,7 @@ static void test_hmac_speed(const void *opaque) Error *err =3D NULL; int ret; =20 - if (!qcrypto_hmac_supports(QCRYPTO_HASH_ALG_SHA256)) { + if (!qcrypto_hmac_supports(QCRYPTO_HASH_ALGO_SHA256)) { return; } =20 @@ -40,7 +40,7 @@ static void test_hmac_speed(const void *opaque) =20 g_test_timer_start(); do { - hmac =3D qcrypto_hmac_new(QCRYPTO_HASH_ALG_SHA256, + hmac =3D qcrypto_hmac_new(QCRYPTO_HASH_ALGO_SHA256, (const uint8_t *)KEY, strlen(KEY), &err); g_assert(err =3D=3D NULL); g_assert(hmac !=3D NULL); @@ -56,7 +56,7 @@ static void test_hmac_speed(const void *opaque) =20 total /=3D MiB; g_test_message("hmac(%s): chunk %zu bytes %.2f MB/sec", - QCryptoHashAlgorithm_str(QCRYPTO_HASH_ALG_SHA256), + QCryptoHashAlgo_str(QCRYPTO_HASH_ALGO_SHA256), chunk_size, total / g_test_timer_last()); =20 g_free(out); diff --git a/tests/unit/test-crypto-afsplit.c b/tests/unit/test-crypto-afsp= lit.c index 00a7c180fd..45e9046bf6 100644 --- a/tests/unit/test-crypto-afsplit.c +++ b/tests/unit/test-crypto-afsplit.c @@ -26,7 +26,7 @@ typedef struct QCryptoAFSplitTestData QCryptoAFSplitTestData; struct QCryptoAFSplitTestData { const char *path; - QCryptoHashAlgorithm hash; + QCryptoHashAlgo hash; uint32_t stripes; size_t blocklen; const uint8_t *key; @@ -36,7 +36,7 @@ struct QCryptoAFSplitTestData { static QCryptoAFSplitTestData test_data[] =3D { { .path =3D "/crypto/afsplit/sha256/5", - .hash =3D QCRYPTO_HASH_ALG_SHA256, + .hash =3D QCRYPTO_HASH_ALGO_SHA256, .stripes =3D 5, .blocklen =3D 32, .key =3D (const uint8_t *) @@ -68,7 +68,7 @@ static QCryptoAFSplitTestData test_data[] =3D { }, { .path =3D "/crypto/afsplit/sha256/5000", - .hash =3D QCRYPTO_HASH_ALG_SHA256, + .hash =3D QCRYPTO_HASH_ALGO_SHA256, .stripes =3D 5000, .blocklen =3D 16, .key =3D (const uint8_t *) @@ -77,7 +77,7 @@ static QCryptoAFSplitTestData test_data[] =3D { }, { .path =3D "/crypto/afsplit/sha1/1000", - .hash =3D QCRYPTO_HASH_ALG_SHA1, + .hash =3D QCRYPTO_HASH_ALGO_SHA1, .stripes =3D 1000, .blocklen =3D 32, .key =3D (const uint8_t *) @@ -88,7 +88,7 @@ static QCryptoAFSplitTestData test_data[] =3D { }, { .path =3D "/crypto/afsplit/sha256/big", - .hash =3D QCRYPTO_HASH_ALG_SHA256, + .hash =3D QCRYPTO_HASH_ALGO_SHA256, .stripes =3D 1000, .blocklen =3D 64, .key =3D (const uint8_t *) diff --git a/tests/unit/test-crypto-akcipher.c b/tests/unit/test-crypto-akc= ipher.c index 59bc6f1e69..86501f19ab 100644 --- a/tests/unit/test-crypto-akcipher.c +++ b/tests/unit/test-crypto-akcipher.c @@ -808,7 +808,7 @@ static QCryptoAkCipherTestData akcipher_test_data[] =3D= { .alg =3D QCRYPTO_AKCIPHER_ALG_RSA, .u.rsa =3D { .padding_alg =3D QCRYPTO_RSA_PADDING_ALG_PKCS1, - .hash_alg =3D QCRYPTO_HASH_ALG_SHA1, + .hash_alg =3D QCRYPTO_HASH_ALGO_SHA1, }, }, .pub_key =3D rsa1024_public_key, @@ -853,7 +853,7 @@ static QCryptoAkCipherTestData akcipher_test_data[] =3D= { .alg =3D QCRYPTO_AKCIPHER_ALG_RSA, .u.rsa =3D { .padding_alg =3D QCRYPTO_RSA_PADDING_ALG_PKCS1, - .hash_alg =3D QCRYPTO_HASH_ALG_SHA1, + .hash_alg =3D QCRYPTO_HASH_ALGO_SHA1, }, }, .pub_key =3D rsa2048_public_key, @@ -947,7 +947,7 @@ static void test_rsakey(const void *opaque) .alg =3D QCRYPTO_AKCIPHER_ALG_RSA, .u.rsa =3D { .padding_alg =3D QCRYPTO_RSA_PADDING_ALG_PKCS1, - .hash_alg =3D QCRYPTO_HASH_ALG_SHA1, + .hash_alg =3D QCRYPTO_HASH_ALGO_SHA1, } }; g_autoptr(QCryptoAkCipher) key =3D qcrypto_akcipher_new( diff --git a/tests/unit/test-crypto-block.c b/tests/unit/test-crypto-block.c index 2a6c6e99e5..c2f5fe7b25 100644 --- a/tests/unit/test-crypto-block.c +++ b/tests/unit/test-crypto-block.c @@ -97,9 +97,9 @@ static QCryptoBlockCreateOptions luks_create_opts_aes256_= cbc_essiv =3D { .has_ivgen_alg =3D true, .ivgen_alg =3D QCRYPTO_IVGEN_ALG_ESSIV, .has_ivgen_hash_alg =3D true, - .ivgen_hash_alg =3D QCRYPTO_HASH_ALG_SHA256, + .ivgen_hash_alg =3D QCRYPTO_HASH_ALGO_SHA256, .has_hash_alg =3D true, - .hash_alg =3D QCRYPTO_HASH_ALG_SHA1, + .hash_alg =3D QCRYPTO_HASH_ALGO_SHA1, }, }; #endif /* TEST_LUKS */ @@ -114,10 +114,10 @@ static struct QCryptoBlockTestData { =20 QCryptoCipherAlgorithm cipher_alg; QCryptoCipherMode cipher_mode; - QCryptoHashAlgorithm hash_alg; + QCryptoHashAlgo hash_alg; =20 QCryptoIVGenAlgorithm ivgen_alg; - QCryptoHashAlgorithm ivgen_hash; + QCryptoHashAlgo ivgen_hash; =20 bool slow; } test_data[] =3D { @@ -143,7 +143,7 @@ static struct QCryptoBlockTestData { =20 .cipher_alg =3D QCRYPTO_CIPHER_ALG_AES_256, .cipher_mode =3D QCRYPTO_CIPHER_MODE_XTS, - .hash_alg =3D QCRYPTO_HASH_ALG_SHA256, + .hash_alg =3D QCRYPTO_HASH_ALGO_SHA256, =20 .ivgen_alg =3D QCRYPTO_IVGEN_ALG_PLAIN64, =20 @@ -158,7 +158,7 @@ static struct QCryptoBlockTestData { =20 .cipher_alg =3D QCRYPTO_CIPHER_ALG_AES_256, .cipher_mode =3D QCRYPTO_CIPHER_MODE_CBC, - .hash_alg =3D QCRYPTO_HASH_ALG_SHA256, + .hash_alg =3D QCRYPTO_HASH_ALGO_SHA256, =20 .ivgen_alg =3D QCRYPTO_IVGEN_ALG_PLAIN64, =20 @@ -173,10 +173,10 @@ static struct QCryptoBlockTestData { =20 .cipher_alg =3D QCRYPTO_CIPHER_ALG_AES_256, .cipher_mode =3D QCRYPTO_CIPHER_MODE_CBC, - .hash_alg =3D QCRYPTO_HASH_ALG_SHA1, + .hash_alg =3D QCRYPTO_HASH_ALGO_SHA1, =20 .ivgen_alg =3D QCRYPTO_IVGEN_ALG_ESSIV, - .ivgen_hash =3D QCRYPTO_HASH_ALG_SHA256, + .ivgen_hash =3D QCRYPTO_HASH_ALGO_SHA256, =20 .slow =3D true, }, diff --git a/tests/unit/test-crypto-hash.c b/tests/unit/test-crypto-hash.c index 1f4abb822b..124d204485 100644 --- a/tests/unit/test-crypto-hash.c +++ b/tests/unit/test-crypto-hash.c @@ -55,31 +55,31 @@ #define OUTPUT_RIPEMD160_B64 "89ZY+tP9+ytSyTac8NRBJJ3fqKA=3D" =20 static const char *expected_outputs[] =3D { - [QCRYPTO_HASH_ALG_MD5] =3D OUTPUT_MD5, - [QCRYPTO_HASH_ALG_SHA1] =3D OUTPUT_SHA1, - [QCRYPTO_HASH_ALG_SHA224] =3D OUTPUT_SHA224, - [QCRYPTO_HASH_ALG_SHA256] =3D OUTPUT_SHA256, - [QCRYPTO_HASH_ALG_SHA384] =3D OUTPUT_SHA384, - [QCRYPTO_HASH_ALG_SHA512] =3D OUTPUT_SHA512, - [QCRYPTO_HASH_ALG_RIPEMD160] =3D OUTPUT_RIPEMD160, + [QCRYPTO_HASH_ALGO_MD5] =3D OUTPUT_MD5, + [QCRYPTO_HASH_ALGO_SHA1] =3D OUTPUT_SHA1, + [QCRYPTO_HASH_ALGO_SHA224] =3D OUTPUT_SHA224, + [QCRYPTO_HASH_ALGO_SHA256] =3D OUTPUT_SHA256, + [QCRYPTO_HASH_ALGO_SHA384] =3D OUTPUT_SHA384, + [QCRYPTO_HASH_ALGO_SHA512] =3D OUTPUT_SHA512, + [QCRYPTO_HASH_ALGO_RIPEMD160] =3D OUTPUT_RIPEMD160, }; static const char *expected_outputs_b64[] =3D { - [QCRYPTO_HASH_ALG_MD5] =3D OUTPUT_MD5_B64, - [QCRYPTO_HASH_ALG_SHA1] =3D OUTPUT_SHA1_B64, - [QCRYPTO_HASH_ALG_SHA224] =3D OUTPUT_SHA224_B64, - [QCRYPTO_HASH_ALG_SHA256] =3D OUTPUT_SHA256_B64, - [QCRYPTO_HASH_ALG_SHA384] =3D OUTPUT_SHA384_B64, - [QCRYPTO_HASH_ALG_SHA512] =3D OUTPUT_SHA512_B64, - [QCRYPTO_HASH_ALG_RIPEMD160] =3D OUTPUT_RIPEMD160_B64, + [QCRYPTO_HASH_ALGO_MD5] =3D OUTPUT_MD5_B64, + [QCRYPTO_HASH_ALGO_SHA1] =3D OUTPUT_SHA1_B64, + [QCRYPTO_HASH_ALGO_SHA224] =3D OUTPUT_SHA224_B64, + [QCRYPTO_HASH_ALGO_SHA256] =3D OUTPUT_SHA256_B64, + [QCRYPTO_HASH_ALGO_SHA384] =3D OUTPUT_SHA384_B64, + [QCRYPTO_HASH_ALGO_SHA512] =3D OUTPUT_SHA512_B64, + [QCRYPTO_HASH_ALGO_RIPEMD160] =3D OUTPUT_RIPEMD160_B64, }; static const int expected_lens[] =3D { - [QCRYPTO_HASH_ALG_MD5] =3D 16, - [QCRYPTO_HASH_ALG_SHA1] =3D 20, - [QCRYPTO_HASH_ALG_SHA224] =3D 28, - [QCRYPTO_HASH_ALG_SHA256] =3D 32, - [QCRYPTO_HASH_ALG_SHA384] =3D 48, - [QCRYPTO_HASH_ALG_SHA512] =3D 64, - [QCRYPTO_HASH_ALG_RIPEMD160] =3D 20, + [QCRYPTO_HASH_ALGO_MD5] =3D 16, + [QCRYPTO_HASH_ALGO_SHA1] =3D 20, + [QCRYPTO_HASH_ALGO_SHA224] =3D 28, + [QCRYPTO_HASH_ALGO_SHA256] =3D 32, + [QCRYPTO_HASH_ALGO_SHA384] =3D 48, + [QCRYPTO_HASH_ALGO_SHA512] =3D 64, + [QCRYPTO_HASH_ALGO_RIPEMD160] =3D 20, }; =20 static const char hex[] =3D "0123456789abcdef"; diff --git a/tests/unit/test-crypto-hmac.c b/tests/unit/test-crypto-hmac.c index 23eb724d94..3fa50f24bb 100644 --- a/tests/unit/test-crypto-hmac.c +++ b/tests/unit/test-crypto-hmac.c @@ -27,43 +27,43 @@ =20 typedef struct QCryptoHmacTestData QCryptoHmacTestData; struct QCryptoHmacTestData { - QCryptoHashAlgorithm alg; + QCryptoHashAlgo alg; const char *hex_digest; }; =20 static QCryptoHmacTestData test_data[] =3D { { - .alg =3D QCRYPTO_HASH_ALG_MD5, + .alg =3D QCRYPTO_HASH_ALGO_MD5, .hex_digest =3D "ede9cb83679ba82d88fbeae865b3f8fc", }, { - .alg =3D QCRYPTO_HASH_ALG_SHA1, + .alg =3D QCRYPTO_HASH_ALGO_SHA1, .hex_digest =3D "c7b5a631e3aac975c4ededfcd346e469" "dbc5f2d1", }, { - .alg =3D QCRYPTO_HASH_ALG_SHA224, + .alg =3D QCRYPTO_HASH_ALGO_SHA224, .hex_digest =3D "5f768179dbb29ca722875d0f461a2e2f" "597d0210340a84df1a8e9c63", }, { - .alg =3D QCRYPTO_HASH_ALG_SHA256, + .alg =3D QCRYPTO_HASH_ALGO_SHA256, .hex_digest =3D "3798f363c57afa6edaffe39016ca7bad" "efd1e670afb0e3987194307dec3197db", }, { - .alg =3D QCRYPTO_HASH_ALG_SHA384, + .alg =3D QCRYPTO_HASH_ALGO_SHA384, .hex_digest =3D "d218680a6032d33dccd9882d6a6a7164" "64f26623be257a9b2919b185294f4a49" "9e54b190bfd6bc5cedd2cd05c7e65e82", }, { - .alg =3D QCRYPTO_HASH_ALG_SHA512, + .alg =3D QCRYPTO_HASH_ALGO_SHA512, .hex_digest =3D "835a4f5b3750b4c1fccfa88da2f746a4" "900160c9f18964309bb736c13b59491b" @@ -71,7 +71,7 @@ static QCryptoHmacTestData test_data[] =3D { "94c4ba26862b2dadb59b7ede1d08d53e", }, { - .alg =3D QCRYPTO_HASH_ALG_RIPEMD160, + .alg =3D QCRYPTO_HASH_ALGO_RIPEMD160, .hex_digest =3D "94964ed4c1155b62b668c241d67279e5" "8a711676", diff --git a/tests/unit/test-crypto-ivgen.c b/tests/unit/test-crypto-ivgen.c index 29630ed348..9aa3f6018b 100644 --- a/tests/unit/test-crypto-ivgen.c +++ b/tests/unit/test-crypto-ivgen.c @@ -27,7 +27,7 @@ struct QCryptoIVGenTestData { const char *path; uint64_t sector; QCryptoIVGenAlgorithm ivalg; - QCryptoHashAlgorithm hashalg; + QCryptoHashAlgo hashalg; QCryptoCipherAlgorithm cipheralg; const uint8_t *key; size_t nkey; @@ -94,7 +94,7 @@ struct QCryptoIVGenTestData { .sector =3D 0x1, .ivalg =3D QCRYPTO_IVGEN_ALG_ESSIV, .cipheralg =3D QCRYPTO_CIPHER_ALG_AES_128, - .hashalg =3D QCRYPTO_HASH_ALG_SHA256, + .hashalg =3D QCRYPTO_HASH_ALGO_SHA256, .key =3D (const uint8_t *)"\x00\x01\x02\x03\x04\x05\x06\x07" "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f", .nkey =3D 16, @@ -108,7 +108,7 @@ struct QCryptoIVGenTestData { .sector =3D 0x1f2e3d4cULL, .ivalg =3D QCRYPTO_IVGEN_ALG_ESSIV, .cipheralg =3D QCRYPTO_CIPHER_ALG_AES_128, - .hashalg =3D QCRYPTO_HASH_ALG_SHA256, + .hashalg =3D QCRYPTO_HASH_ALGO_SHA256, .key =3D (const uint8_t *)"\x00\x01\x02\x03\x04\x05\x06\x07" "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f", .nkey =3D 16, @@ -122,7 +122,7 @@ struct QCryptoIVGenTestData { .sector =3D 0x1f2e3d4c5b6a7988ULL, .ivalg =3D QCRYPTO_IVGEN_ALG_ESSIV, .cipheralg =3D QCRYPTO_CIPHER_ALG_AES_128, - .hashalg =3D QCRYPTO_HASH_ALG_SHA256, + .hashalg =3D QCRYPTO_HASH_ALGO_SHA256, .key =3D (const uint8_t *)"\x00\x01\x02\x03\x04\x05\x06\x07" "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f", .nkey =3D 16, diff --git a/tests/unit/test-crypto-pbkdf.c b/tests/unit/test-crypto-pbkdf.c index 39264cb662..b477cf4e4b 100644 --- a/tests/unit/test-crypto-pbkdf.c +++ b/tests/unit/test-crypto-pbkdf.c @@ -31,7 +31,7 @@ typedef struct QCryptoPbkdfTestData QCryptoPbkdfTestData; struct QCryptoPbkdfTestData { const char *path; - QCryptoHashAlgorithm hash; + QCryptoHashAlgo hash; unsigned int iterations; const char *key; size_t nkey; @@ -52,7 +52,7 @@ static QCryptoPbkdfTestData test_data[] =3D { /* RFC 3962 test data */ { .path =3D "/crypto/pbkdf/rfc3962/sha1/iter1", - .hash =3D QCRYPTO_HASH_ALG_SHA1, + .hash =3D QCRYPTO_HASH_ALGO_SHA1, .iterations =3D 1, .key =3D "password", .nkey =3D 8, @@ -66,7 +66,7 @@ static QCryptoPbkdfTestData test_data[] =3D { }, { .path =3D "/crypto/pbkdf/rfc3962/sha1/iter2", - .hash =3D QCRYPTO_HASH_ALG_SHA1, + .hash =3D QCRYPTO_HASH_ALGO_SHA1, .iterations =3D 2, .key =3D "password", .nkey =3D 8, @@ -80,7 +80,7 @@ static QCryptoPbkdfTestData test_data[] =3D { }, { .path =3D "/crypto/pbkdf/rfc3962/sha1/iter1200a", - .hash =3D QCRYPTO_HASH_ALG_SHA1, + .hash =3D QCRYPTO_HASH_ALGO_SHA1, .iterations =3D 1200, .key =3D "password", .nkey =3D 8, @@ -94,7 +94,7 @@ static QCryptoPbkdfTestData test_data[] =3D { }, { .path =3D "/crypto/pbkdf/rfc3962/sha1/iter5", - .hash =3D QCRYPTO_HASH_ALG_SHA1, + .hash =3D QCRYPTO_HASH_ALGO_SHA1, .iterations =3D 5, .key =3D "password", .nkey =3D 8, @@ -108,7 +108,7 @@ static QCryptoPbkdfTestData test_data[] =3D { }, { .path =3D "/crypto/pbkdf/rfc3962/sha1/iter1200b", - .hash =3D QCRYPTO_HASH_ALG_SHA1, + .hash =3D QCRYPTO_HASH_ALGO_SHA1, .iterations =3D 1200, .key =3D "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", @@ -123,7 +123,7 @@ static QCryptoPbkdfTestData test_data[] =3D { }, { .path =3D "/crypto/pbkdf/rfc3962/sha1/iter1200c", - .hash =3D QCRYPTO_HASH_ALG_SHA1, + .hash =3D QCRYPTO_HASH_ALGO_SHA1, .iterations =3D 1200, .key =3D "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", @@ -138,7 +138,7 @@ static QCryptoPbkdfTestData test_data[] =3D { }, { .path =3D "/crypto/pbkdf/rfc3962/sha1/iter50", - .hash =3D QCRYPTO_HASH_ALG_SHA1, + .hash =3D QCRYPTO_HASH_ALGO_SHA1, .iterations =3D 50, .key =3D "\360\235\204\236", /* g-clef ("\xf09d849e) */ .nkey =3D 4, @@ -154,7 +154,7 @@ static QCryptoPbkdfTestData test_data[] =3D { /* RFC-6070 test data */ { .path =3D "/crypto/pbkdf/rfc6070/sha1/iter1", - .hash =3D QCRYPTO_HASH_ALG_SHA1, + .hash =3D QCRYPTO_HASH_ALGO_SHA1, .iterations =3D 1, .key =3D "password", .nkey =3D 8, @@ -166,7 +166,7 @@ static QCryptoPbkdfTestData test_data[] =3D { }, { .path =3D "/crypto/pbkdf/rfc6070/sha1/iter2", - .hash =3D QCRYPTO_HASH_ALG_SHA1, + .hash =3D QCRYPTO_HASH_ALGO_SHA1, .iterations =3D 2, .key =3D "password", .nkey =3D 8, @@ -178,7 +178,7 @@ static QCryptoPbkdfTestData test_data[] =3D { }, { .path =3D "/crypto/pbkdf/rfc6070/sha1/iter4096", - .hash =3D QCRYPTO_HASH_ALG_SHA1, + .hash =3D QCRYPTO_HASH_ALGO_SHA1, .iterations =3D 4096, .key =3D "password", .nkey =3D 8, @@ -190,7 +190,7 @@ static QCryptoPbkdfTestData test_data[] =3D { }, { .path =3D "/crypto/pbkdf/rfc6070/sha1/iter16777216", - .hash =3D QCRYPTO_HASH_ALG_SHA1, + .hash =3D QCRYPTO_HASH_ALGO_SHA1, .iterations =3D 16777216, .key =3D "password", .nkey =3D 8, @@ -203,7 +203,7 @@ static QCryptoPbkdfTestData test_data[] =3D { }, { .path =3D "/crypto/pbkdf/rfc6070/sha1/iter4096a", - .hash =3D QCRYPTO_HASH_ALG_SHA1, + .hash =3D QCRYPTO_HASH_ALGO_SHA1, .iterations =3D 4096, .key =3D "passwordPASSWORDpassword", .nkey =3D 24, @@ -216,7 +216,7 @@ static QCryptoPbkdfTestData test_data[] =3D { }, { .path =3D "/crypto/pbkdf/rfc6070/sha1/iter4096b", - .hash =3D QCRYPTO_HASH_ALG_SHA1, + .hash =3D QCRYPTO_HASH_ALGO_SHA1, .iterations =3D 4096, .key =3D "pass\0word", .nkey =3D 9, @@ -231,7 +231,7 @@ static QCryptoPbkdfTestData test_data[] =3D { { /* empty password test. */ .path =3D "/crypto/pbkdf/nonrfc/sha1/iter2", - .hash =3D QCRYPTO_HASH_ALG_SHA1, + .hash =3D QCRYPTO_HASH_ALGO_SHA1, .iterations =3D 2, .key =3D "", .nkey =3D 0, @@ -244,7 +244,7 @@ static QCryptoPbkdfTestData test_data[] =3D { { /* Password exceeds block size test */ .path =3D "/crypto/pbkdf/nonrfc/sha256/iter1200", - .hash =3D QCRYPTO_HASH_ALG_SHA256, + .hash =3D QCRYPTO_HASH_ALGO_SHA256, .iterations =3D 1200, .key =3D "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", @@ -259,7 +259,7 @@ static QCryptoPbkdfTestData test_data[] =3D { }, { .path =3D "/crypto/pbkdf/nonrfc/sha512/iter1200", - .hash =3D QCRYPTO_HASH_ALG_SHA512, + .hash =3D QCRYPTO_HASH_ALGO_SHA512, .iterations =3D 1200, .key =3D "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" @@ -276,7 +276,7 @@ static QCryptoPbkdfTestData test_data[] =3D { }, { .path =3D "/crypto/pbkdf/nonrfc/sha224/iter1200", - .hash =3D QCRYPTO_HASH_ALG_SHA224, + .hash =3D QCRYPTO_HASH_ALGO_SHA224, .iterations =3D 1200, .key =3D "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" @@ -293,7 +293,7 @@ static QCryptoPbkdfTestData test_data[] =3D { }, { .path =3D "/crypto/pbkdf/nonrfc/sha384/iter1200", - .hash =3D QCRYPTO_HASH_ALG_SHA384, + .hash =3D QCRYPTO_HASH_ALGO_SHA384, .iterations =3D 1200, .key =3D "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" @@ -310,7 +310,7 @@ static QCryptoPbkdfTestData test_data[] =3D { }, { .path =3D "/crypto/pbkdf/nonrfc/ripemd160/iter1200", - .hash =3D QCRYPTO_HASH_ALG_RIPEMD160, + .hash =3D QCRYPTO_HASH_ALGO_RIPEMD160, .iterations =3D 1200, .key =3D "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" @@ -328,7 +328,7 @@ static QCryptoPbkdfTestData test_data[] =3D { #if 0 { .path =3D "/crypto/pbkdf/nonrfc/whirlpool/iter1200", - .hash =3D QCRYPTO_HASH_ALG_WHIRLPOOL, + .hash =3D QCRYPTO_HASH_ALGO_WHIRLPOOL, .iterations =3D 1200, .key =3D "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", @@ -402,7 +402,7 @@ static void test_pbkdf_timing_sha256(void) memset(key, 0x5d, sizeof(key)); memset(salt, 0x7c, sizeof(salt)); =20 - iters =3D qcrypto_pbkdf2_count_iters(QCRYPTO_HASH_ALG_SHA256, + iters =3D qcrypto_pbkdf2_count_iters(QCRYPTO_HASH_ALGO_SHA256, key, sizeof(key), salt, sizeof(salt), 32, @@ -431,7 +431,7 @@ int main(int argc, char **argv) } } =20 - if (g_test_slow() && qcrypto_pbkdf2_supports(QCRYPTO_HASH_ALG_SHA256))= { + if (g_test_slow() && qcrypto_pbkdf2_supports(QCRYPTO_HASH_ALGO_SHA256)= ) { g_test_add_func("/crypt0/pbkdf/timing/sha256", test_pbkdf_timing_s= ha256); } =20 diff --git a/ui/vnc.c b/ui/vnc.c index dae5d51210..9a17994969 100644 --- a/ui/vnc.c +++ b/ui/vnc.c @@ -3852,7 +3852,7 @@ static int vnc_display_get_addresses(QemuOpts *opts, return 0; } if (qemu_opt_get(opts, "websocket") && - !qcrypto_hash_supports(QCRYPTO_HASH_ALG_SHA1)) { + !qcrypto_hash_supports(QCRYPTO_HASH_ALGO_SHA1)) { error_setg(errp, "SHA1 hash support is required for websockets"); return -1; diff --git a/util/hbitmap.c b/util/hbitmap.c index 6d6e1b595d..d9a1dabc63 100644 --- a/util/hbitmap.c +++ b/util/hbitmap.c @@ -949,7 +949,7 @@ char *hbitmap_sha256(const HBitmap *bitmap, Error **err= p) size_t size =3D bitmap->sizes[HBITMAP_LEVELS - 1] * sizeof(unsigned lo= ng); char *data =3D (char *)bitmap->levels[HBITMAP_LEVELS - 1]; char *hash =3D NULL; - qcrypto_hash_digest(QCRYPTO_HASH_ALG_SHA256, data, size, &hash, errp); + qcrypto_hash_digest(QCRYPTO_HASH_ALGO_SHA256, data, size, &hash, errp); =20 return hash; } diff --git a/crypto/akcipher-gcrypt.c.inc b/crypto/akcipher-gcrypt.c.inc index e942d43421..2c81de97de 100644 --- a/crypto/akcipher-gcrypt.c.inc +++ b/crypto/akcipher-gcrypt.c.inc @@ -33,7 +33,7 @@ typedef struct QCryptoGcryptRSA { QCryptoAkCipher akcipher; gcry_sexp_t key; QCryptoRSAPaddingAlgorithm padding_alg; - QCryptoHashAlgorithm hash_alg; + QCryptoHashAlgo hash_alg; } QCryptoGcryptRSA; =20 static void qcrypto_gcrypt_rsa_free(QCryptoAkCipher *akcipher) @@ -417,7 +417,7 @@ static int qcrypto_gcrypt_rsa_sign(QCryptoAkCipher *akc= ipher, =20 err =3D gcry_sexp_build(&dgst_sexp, NULL, "(data (flags pkcs1) (hash %s %b))", - QCryptoHashAlgorithm_str(rsa->hash_alg), + QCryptoHashAlgo_str(rsa->hash_alg), in_len, in); if (gcry_err_code(err) !=3D 0) { error_setg(errp, "Failed to build dgst: %s/%s", @@ -497,7 +497,7 @@ static int qcrypto_gcrypt_rsa_verify(QCryptoAkCipher *a= kcipher, =20 err =3D gcry_sexp_build(&dgst_sexp, NULL, "(data (flags pkcs1) (hash %s %b))", - QCryptoHashAlgorithm_str(rsa->hash_alg), + QCryptoHashAlgo_str(rsa->hash_alg), in2_len, in2); if (gcry_err_code(err) !=3D 0) { error_setg(errp, "Failed to build dgst: %s/%s", @@ -575,10 +575,10 @@ bool qcrypto_akcipher_supports(QCryptoAkCipherOptions= *opts) =20 case QCRYPTO_RSA_PADDING_ALG_PKCS1: switch (opts->u.rsa.hash_alg) { - case QCRYPTO_HASH_ALG_MD5: - case QCRYPTO_HASH_ALG_SHA1: - case QCRYPTO_HASH_ALG_SHA256: - case QCRYPTO_HASH_ALG_SHA512: + case QCRYPTO_HASH_ALGO_MD5: + case QCRYPTO_HASH_ALGO_SHA1: + case QCRYPTO_HASH_ALGO_SHA256: + case QCRYPTO_HASH_ALGO_SHA512: return true; =20 default: diff --git a/crypto/akcipher-nettle.c.inc b/crypto/akcipher-nettle.c.inc index 62ac8699c4..37a579fbd9 100644 --- a/crypto/akcipher-nettle.c.inc +++ b/crypto/akcipher-nettle.c.inc @@ -34,7 +34,7 @@ typedef struct QCryptoNettleRSA { struct rsa_public_key pub; struct rsa_private_key priv; QCryptoRSAPaddingAlgorithm padding_alg; - QCryptoHashAlgorithm hash_alg; + QCryptoHashAlgo hash_alg; } QCryptoNettleRSA; =20 static void qcrypto_nettle_rsa_free(QCryptoAkCipher *akcipher) @@ -276,19 +276,19 @@ static int qcrypto_nettle_rsa_sign(QCryptoAkCipher *a= kcipher, =20 mpz_init(s); switch (rsa->hash_alg) { - case QCRYPTO_HASH_ALG_MD5: + case QCRYPTO_HASH_ALGO_MD5: rv =3D rsa_md5_sign_digest(&rsa->priv, data, s); break; =20 - case QCRYPTO_HASH_ALG_SHA1: + case QCRYPTO_HASH_ALGO_SHA1: rv =3D rsa_sha1_sign_digest(&rsa->priv, data, s); break; =20 - case QCRYPTO_HASH_ALG_SHA256: + case QCRYPTO_HASH_ALGO_SHA256: rv =3D rsa_sha256_sign_digest(&rsa->priv, data, s); break; =20 - case QCRYPTO_HASH_ALG_SHA512: + case QCRYPTO_HASH_ALGO_SHA512: rv =3D rsa_sha512_sign_digest(&rsa->priv, data, s); break; =20 @@ -341,19 +341,19 @@ static int qcrypto_nettle_rsa_verify(QCryptoAkCipher = *akcipher, =20 nettle_mpz_init_set_str_256_u(s, sig_len, sig); switch (rsa->hash_alg) { - case QCRYPTO_HASH_ALG_MD5: + case QCRYPTO_HASH_ALGO_MD5: rv =3D rsa_md5_verify_digest(&rsa->pub, data, s); break; =20 - case QCRYPTO_HASH_ALG_SHA1: + case QCRYPTO_HASH_ALGO_SHA1: rv =3D rsa_sha1_verify_digest(&rsa->pub, data, s); break; =20 - case QCRYPTO_HASH_ALG_SHA256: + case QCRYPTO_HASH_ALGO_SHA256: rv =3D rsa_sha256_verify_digest(&rsa->pub, data, s); break; =20 - case QCRYPTO_HASH_ALG_SHA512: + case QCRYPTO_HASH_ALGO_SHA512: rv =3D rsa_sha512_verify_digest(&rsa->pub, data, s); break; =20 @@ -429,10 +429,10 @@ bool qcrypto_akcipher_supports(QCryptoAkCipherOptions= *opts) switch (opts->u.rsa.padding_alg) { case QCRYPTO_RSA_PADDING_ALG_PKCS1: switch (opts->u.rsa.hash_alg) { - case QCRYPTO_HASH_ALG_MD5: - case QCRYPTO_HASH_ALG_SHA1: - case QCRYPTO_HASH_ALG_SHA256: - case QCRYPTO_HASH_ALG_SHA512: + case QCRYPTO_HASH_ALGO_MD5: + case QCRYPTO_HASH_ALGO_SHA1: + case QCRYPTO_HASH_ALGO_SHA256: + case QCRYPTO_HASH_ALGO_SHA512: return true; =20 default: --=20 2.46.0 From nobody Sun Nov 24 05:28:16 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1725986987; cv=none; d=zohomail.com; s=zohoarc; b=NK74uUW9znAhjZTuqTLnjEinaWbudP7S74Lbwy/8AV2I1MhkN8+DGlE17zKwH74HB/4g2p6RCjc5sIo44LpFNMLH72QN14kShgwM2P/3k0yApIXcFFKCoQKn2tv08W9qShzyZbNtSdNtAqgHu56IMcaN79LYymMJqj2JVEGMYwU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1725986987; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=Cy/MS5RDkwnuKcLg6VIXiODxYMuznqznxyuPu17sIqM=; b=OgVQby9NSq8jdFu/nSZgdRsJMKQa6e64MAHiWMRi9nGyjr/7rdlbH5vGXwoWb9rAg6Yu0UY/2YWo1RhdBtrRIMfkqFx0w9fs1rLoUpNWpkLTXMhM4nLLVhbOAzq204pyOoJuh4FG7ZIFUBfzpKNJMH9A56WHQEO+SS6vBfip1g0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1725986987132377.37092700416827; Tue, 10 Sep 2024 09:49:47 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1so41p-0007QI-16; Tue, 10 Sep 2024 12:47:45 -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 1so41Z-0006nN-Lt for qemu-devel@nongnu.org; Tue, 10 Sep 2024 12:47:29 -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 1so41T-0007Yk-O5 for qemu-devel@nongnu.org; Tue, 10 Sep 2024 12:47:29 -0400 Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-652-G9L0UnO6PvyYSviKmtjT3A-1; Tue, 10 Sep 2024 12:47:21 -0400 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 755B21955DCD; Tue, 10 Sep 2024 16:47:20 +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 5886D1956053; Tue, 10 Sep 2024 16:47:19 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 9A22D21E682A; Tue, 10 Sep 2024 18:47:14 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1725986843; 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=Cy/MS5RDkwnuKcLg6VIXiODxYMuznqznxyuPu17sIqM=; b=cuU98HPw+vz3t85eN3KGYBDTmMF17Xpzg2EwiuXH1Yqj4diXA1Ehnu2AtaMwuABL/NBHh0 SCypvMHo2ukGOU4cR6ny4kJsJhIQasaCsu2lFi0KvAdd3M7Ry87ghgNu8od1VhrSuW8qyn WcDMWFpuwY4cTOo8ZVgmQEx4fD4p6EQ= X-MC-Unique: G9L0UnO6PvyYSviKmtjT3A-1 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org, =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= Subject: [PULL 12/19] qapi/crypto: Rename QCryptoCipherAlgorithm to *Algo, and drop prefix Date: Tue, 10 Sep 2024 18:47:07 +0200 Message-ID: <20240910164714.1993531-13-armbru@redhat.com> In-Reply-To: <20240910164714.1993531-1-armbru@redhat.com> References: <20240910164714.1993531-1-armbru@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.145, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, PDS_BTC_ID=0.156, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1725986987978116600 QAPI's 'prefix' feature can make the connection between enumeration type and its constants less than obvious. It's best used with restraint. QCryptoCipherAlgorithm has a 'prefix' that overrides the generated enumeration constants' prefix to QCRYPTO_CIPHER_ALG. We could simply drop 'prefix', but then the prefix becomes QCRYPTO_CIPHER_ALGORITHM, which is rather long. We could additionally rename the type to QCryptoCipherAlg, but I think the abbreviation "alg" is less than clear. Rename the type to QCryptoCipherAlgo instead. The prefix becomes QCRYPTO_CIPHER_ALGO. Signed-off-by: Markus Armbruster Acked-by: Daniel P. Berrang=C3=A9 Message-ID: <20240904111836.3273842-13-armbru@redhat.com> --- qapi/block-core.json | 2 +- qapi/crypto.json | 9 ++- crypto/blockpriv.h | 4 +- crypto/cipherpriv.h | 2 +- crypto/ivgenpriv.h | 2 +- include/crypto/cipher.h | 18 +++--- include/crypto/ivgen.h | 10 +-- include/crypto/pbkdf.h | 4 +- backends/cryptodev-builtin.c | 16 ++--- block/rbd.c | 4 +- crypto/block-luks.c | 92 +++++++++++++-------------- crypto/block-qcow.c | 4 +- crypto/block.c | 2 +- crypto/cipher-afalg.c | 24 +++---- crypto/cipher.c | 72 ++++++++++----------- crypto/ivgen.c | 4 +- crypto/secret_common.c | 2 +- tests/bench/benchmark-crypto-cipher.c | 22 +++---- tests/unit/test-crypto-block.c | 14 ++-- tests/unit/test-crypto-cipher.c | 66 +++++++++---------- tests/unit/test-crypto-ivgen.c | 8 +-- ui/vnc.c | 4 +- crypto/cipher-builtin.c.inc | 18 +++--- crypto/cipher-gcrypt.c.inc | 56 ++++++++-------- crypto/cipher-gnutls.c.inc | 38 +++++------ crypto/cipher-nettle.c.inc | 58 ++++++++--------- 26 files changed, 277 insertions(+), 278 deletions(-) diff --git a/qapi/block-core.json b/qapi/block-core.json index a7ae2da47b..9f6dd59298 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -4163,7 +4163,7 @@ ## { 'struct': 'RbdEncryptionCreateOptionsLUKSBase', 'base': 'RbdEncryptionOptionsLUKSBase', - 'data': { '*cipher-alg': 'QCryptoCipherAlgorithm' } } + 'data': { '*cipher-alg': 'QCryptoCipherAlgo' } } =20 ## # @RbdEncryptionOptionsLUKS: diff --git a/qapi/crypto.json b/qapi/crypto.json index 68393568cf..0591d62f67 100644 --- a/qapi/crypto.json +++ b/qapi/crypto.json @@ -62,7 +62,7 @@ 'data': ['md5', 'sha1', 'sha224', 'sha256', 'sha384', 'sha512', 'ripemd1= 60']} =20 ## -# @QCryptoCipherAlgorithm: +# @QCryptoCipherAlgo: # # The supported algorithms for content encryption ciphers # @@ -95,8 +95,7 @@ # # Since: 2.6 ## -{ 'enum': 'QCryptoCipherAlgorithm', - 'prefix': 'QCRYPTO_CIPHER_ALG', +{ 'enum': 'QCryptoCipherAlgo', 'data': ['aes-128', 'aes-192', 'aes-256', 'des', '3des', 'cast5-128', @@ -225,7 +224,7 @@ ## { 'struct': 'QCryptoBlockCreateOptionsLUKS', 'base': 'QCryptoBlockOptionsLUKS', - 'data': { '*cipher-alg': 'QCryptoCipherAlgorithm', + 'data': { '*cipher-alg': 'QCryptoCipherAlgo', '*cipher-mode': 'QCryptoCipherMode', '*ivgen-alg': 'QCryptoIVGenAlgorithm', '*ivgen-hash-alg': 'QCryptoHashAlgo', @@ -322,7 +321,7 @@ # Since: 2.7 ## { 'struct': 'QCryptoBlockInfoLUKS', - 'data': {'cipher-alg': 'QCryptoCipherAlgorithm', + 'data': {'cipher-alg': 'QCryptoCipherAlgo', 'cipher-mode': 'QCryptoCipherMode', 'ivgen-alg': 'QCryptoIVGenAlgorithm', '*ivgen-hash-alg': 'QCryptoHashAlgo', diff --git a/crypto/blockpriv.h b/crypto/blockpriv.h index cf1a66c00d..edf0b3a3d9 100644 --- a/crypto/blockpriv.h +++ b/crypto/blockpriv.h @@ -33,7 +33,7 @@ struct QCryptoBlock { void *opaque; =20 /* Cipher parameters */ - QCryptoCipherAlgorithm alg; + QCryptoCipherAlgo alg; QCryptoCipherMode mode; uint8_t *key; size_t nkey; @@ -132,7 +132,7 @@ int qcrypto_block_encrypt_helper(QCryptoBlock *block, Error **errp); =20 int qcrypto_block_init_cipher(QCryptoBlock *block, - QCryptoCipherAlgorithm alg, + QCryptoCipherAlgo alg, QCryptoCipherMode mode, const uint8_t *key, size_t nkey, Error **errp); diff --git a/crypto/cipherpriv.h b/crypto/cipherpriv.h index 396527857d..64737ce961 100644 --- a/crypto/cipherpriv.h +++ b/crypto/cipherpriv.h @@ -42,7 +42,7 @@ struct QCryptoCipherDriver { #include "afalgpriv.h" =20 extern QCryptoCipher * -qcrypto_afalg_cipher_ctx_new(QCryptoCipherAlgorithm alg, +qcrypto_afalg_cipher_ctx_new(QCryptoCipherAlgo alg, QCryptoCipherMode mode, const uint8_t *key, size_t nkey, Error **errp); diff --git a/crypto/ivgenpriv.h b/crypto/ivgenpriv.h index 0227ae4d00..ef24c76345 100644 --- a/crypto/ivgenpriv.h +++ b/crypto/ivgenpriv.h @@ -41,7 +41,7 @@ struct QCryptoIVGen { void *private; =20 QCryptoIVGenAlgorithm algorithm; - QCryptoCipherAlgorithm cipher; + QCryptoCipherAlgo cipher; QCryptoHashAlgo hash; }; =20 diff --git a/include/crypto/cipher.h b/include/crypto/cipher.h index 083e12a7d9..92939310ef 100644 --- a/include/crypto/cipher.h +++ b/include/crypto/cipher.h @@ -26,7 +26,7 @@ typedef struct QCryptoCipher QCryptoCipher; typedef struct QCryptoCipherDriver QCryptoCipherDriver; =20 -/* See also "QCryptoCipherAlgorithm" and "QCryptoCipherMode" +/* See also "QCryptoCipherAlgo" and "QCryptoCipherMode" * enums defined in qapi/crypto.json */ =20 /** @@ -50,12 +50,12 @@ typedef struct QCryptoCipherDriver QCryptoCipherDriver; * size_t keylen =3D 16; * uint8_t iv =3D ....; * - * if (!qcrypto_cipher_supports(QCRYPTO_CIPHER_ALG_AES_128)) { + * if (!qcrypto_cipher_supports(QCRYPTO_CIPHER_ALGO_AES_128)) { * error_report(errp, "Feature requires AES cipher support"); * return -1; * } * - * cipher =3D qcrypto_cipher_new(QCRYPTO_CIPHER_ALG_AES_128, + * cipher =3D qcrypto_cipher_new(QCRYPTO_CIPHER_ALGO_AES_128, * QCRYPTO_CIPHER_MODE_CBC, * key, keylen, * errp); @@ -78,7 +78,7 @@ typedef struct QCryptoCipherDriver QCryptoCipherDriver; */ =20 struct QCryptoCipher { - QCryptoCipherAlgorithm alg; + QCryptoCipherAlgo alg; QCryptoCipherMode mode; const QCryptoCipherDriver *driver; }; @@ -93,7 +93,7 @@ struct QCryptoCipher { * * Returns: true if the algorithm is supported, false otherwise */ -bool qcrypto_cipher_supports(QCryptoCipherAlgorithm alg, +bool qcrypto_cipher_supports(QCryptoCipherAlgo alg, QCryptoCipherMode mode); =20 /** @@ -106,7 +106,7 @@ bool qcrypto_cipher_supports(QCryptoCipherAlgorithm alg, * * Returns: the block size in bytes */ -size_t qcrypto_cipher_get_block_len(QCryptoCipherAlgorithm alg); +size_t qcrypto_cipher_get_block_len(QCryptoCipherAlgo alg); =20 =20 /** @@ -117,7 +117,7 @@ size_t qcrypto_cipher_get_block_len(QCryptoCipherAlgori= thm alg); * * Returns: the key size in bytes */ -size_t qcrypto_cipher_get_key_len(QCryptoCipherAlgorithm alg); +size_t qcrypto_cipher_get_key_len(QCryptoCipherAlgo alg); =20 =20 /** @@ -130,7 +130,7 @@ size_t qcrypto_cipher_get_key_len(QCryptoCipherAlgorith= m alg); * * Returns: the IV size in bytes, or 0 if no IV is permitted */ -size_t qcrypto_cipher_get_iv_len(QCryptoCipherAlgorithm alg, +size_t qcrypto_cipher_get_iv_len(QCryptoCipherAlgo alg, QCryptoCipherMode mode); =20 =20 @@ -156,7 +156,7 @@ size_t qcrypto_cipher_get_iv_len(QCryptoCipherAlgorithm= alg, * * Returns: a new cipher object, or NULL on error */ -QCryptoCipher *qcrypto_cipher_new(QCryptoCipherAlgorithm alg, +QCryptoCipher *qcrypto_cipher_new(QCryptoCipherAlgo alg, QCryptoCipherMode mode, const uint8_t *key, size_t nkey, Error **errp); diff --git a/include/crypto/ivgen.h b/include/crypto/ivgen.h index ab5f1a648e..b059e332cd 100644 --- a/include/crypto/ivgen.h +++ b/include/crypto/ivgen.h @@ -45,21 +45,21 @@ * g_assert((ndata % 512) =3D=3D 0); * * QCryptoIVGen *ivgen =3D qcrypto_ivgen_new(QCRYPTO_IVGEN_ALG_ESSIV, - * QCRYPTO_CIPHER_ALG_AES_128, + * QCRYPTO_CIPHER_ALGO_AES_128, * QCRYPTO_HASH_ALGO_SHA256, * key, nkey, errp); * if (!ivgen) { * return -1; * } * - * QCryptoCipher *cipher =3D qcrypto_cipher_new(QCRYPTO_CIPHER_ALG_AES_128, + * QCryptoCipher *cipher =3D qcrypto_cipher_new(QCRYPTO_CIPHER_ALGO_AES_12= 8, * QCRYPTO_CIPHER_MODE_CBC, * key, nkey, errp); * if (!cipher) { * goto error; * } * - * niv =3D qcrypto_cipher_get_iv_len(QCRYPTO_CIPHER_ALG_AES_128, + * niv =3D qcrypto_cipher_get_iv_len(QCRYPTO_CIPHER_ALGO_AES_128, * QCRYPTO_CIPHER_MODE_CBC); * iv =3D g_new0(uint8_t, niv); * @@ -134,7 +134,7 @@ typedef struct QCryptoIVGen QCryptoIVGen; * Returns: a new IV generator, or NULL on error */ QCryptoIVGen *qcrypto_ivgen_new(QCryptoIVGenAlgorithm alg, - QCryptoCipherAlgorithm cipheralg, + QCryptoCipherAlgo cipheralg, QCryptoHashAlgo hash, const uint8_t *key, size_t nkey, Error **errp); @@ -179,7 +179,7 @@ QCryptoIVGenAlgorithm qcrypto_ivgen_get_algorithm(QCryp= toIVGen *ivgen); * * Returns: the cipher algorithm */ -QCryptoCipherAlgorithm qcrypto_ivgen_get_cipher(QCryptoIVGen *ivgen); +QCryptoCipherAlgo qcrypto_ivgen_get_cipher(QCryptoIVGen *ivgen); =20 =20 /** diff --git a/include/crypto/pbkdf.h b/include/crypto/pbkdf.h index 6cf29e78ee..cf59fce610 100644 --- a/include/crypto/pbkdf.h +++ b/include/crypto/pbkdf.h @@ -38,7 +38,7 @@ * .... * * char *password =3D "a-typical-awful-user-password"; - * size_t nkey =3D qcrypto_cipher_get_key_len(QCRYPTO_CIPHER_ALG_AES_128); + * size_t nkey =3D qcrypto_cipher_get_key_len(QCRYPTO_CIPHER_ALGO_AES_128); * uint8_t *salt =3D g_new0(uint8_t, nkey); * uint8_t *key =3D g_new0(uint8_t, nkey); * int iterations; @@ -70,7 +70,7 @@ * * g_free(salt); * - * cipher =3D qcrypto_cipher_new(QCRYPTO_CIPHER_ALG_AES_128, + * cipher =3D qcrypto_cipher_new(QCRYPTO_CIPHER_ALGO_AES_128, * QCRYPTO_CIPHER_MODE_ECB, * key, nkey, errp); * g_free(key); diff --git a/backends/cryptodev-builtin.c b/backends/cryptodev-builtin.c index 4a49d328ec..2672755661 100644 --- a/backends/cryptodev-builtin.c +++ b/backends/cryptodev-builtin.c @@ -138,18 +138,18 @@ cryptodev_builtin_get_aes_algo(uint32_t key_len, int = mode, Error **errp) int algo; =20 if (key_len =3D=3D AES_KEYSIZE_128) { - algo =3D QCRYPTO_CIPHER_ALG_AES_128; + algo =3D QCRYPTO_CIPHER_ALGO_AES_128; } else if (key_len =3D=3D AES_KEYSIZE_192) { - algo =3D QCRYPTO_CIPHER_ALG_AES_192; + algo =3D QCRYPTO_CIPHER_ALGO_AES_192; } else if (key_len =3D=3D AES_KEYSIZE_256) { /* equals AES_KEYSIZE_128= _XTS */ if (mode =3D=3D QCRYPTO_CIPHER_MODE_XTS) { - algo =3D QCRYPTO_CIPHER_ALG_AES_128; + algo =3D QCRYPTO_CIPHER_ALGO_AES_128; } else { - algo =3D QCRYPTO_CIPHER_ALG_AES_256; + algo =3D QCRYPTO_CIPHER_ALGO_AES_256; } } else if (key_len =3D=3D AES_KEYSIZE_256_XTS) { if (mode =3D=3D QCRYPTO_CIPHER_MODE_XTS) { - algo =3D QCRYPTO_CIPHER_ALG_AES_256; + algo =3D QCRYPTO_CIPHER_ALGO_AES_256; } else { goto err; } @@ -271,15 +271,15 @@ static int cryptodev_builtin_create_cipher_session( break; case VIRTIO_CRYPTO_CIPHER_3DES_ECB: mode =3D QCRYPTO_CIPHER_MODE_ECB; - algo =3D QCRYPTO_CIPHER_ALG_3DES; + algo =3D QCRYPTO_CIPHER_ALGO_3DES; break; case VIRTIO_CRYPTO_CIPHER_3DES_CBC: mode =3D QCRYPTO_CIPHER_MODE_CBC; - algo =3D QCRYPTO_CIPHER_ALG_3DES; + algo =3D QCRYPTO_CIPHER_ALGO_3DES; break; case VIRTIO_CRYPTO_CIPHER_3DES_CTR: mode =3D QCRYPTO_CIPHER_MODE_CTR; - algo =3D QCRYPTO_CIPHER_ALG_3DES; + algo =3D QCRYPTO_CIPHER_ALGO_3DES; break; default: error_setg(errp, "Unsupported cipher alg :%u", diff --git a/block/rbd.c b/block/rbd.c index 9c0fd0cb3f..04ed0e242e 100644 --- a/block/rbd.c +++ b/block/rbd.c @@ -367,11 +367,11 @@ static int qemu_rbd_convert_luks_create_options( =20 if (luks_opts->has_cipher_alg) { switch (luks_opts->cipher_alg) { - case QCRYPTO_CIPHER_ALG_AES_128: { + case QCRYPTO_CIPHER_ALGO_AES_128: { *alg =3D RBD_ENCRYPTION_ALGORITHM_AES128; break; } - case QCRYPTO_CIPHER_ALG_AES_256: { + case QCRYPTO_CIPHER_ALGO_AES_256: { *alg =3D RBD_ENCRYPTION_ALGORITHM_AES256; break; } diff --git a/crypto/block-luks.c b/crypto/block-luks.c index 59af733b8c..8eadf124fc 100644 --- a/crypto/block-luks.c +++ b/crypto/block-luks.c @@ -68,38 +68,38 @@ struct QCryptoBlockLUKSCipherNameMap { =20 static const QCryptoBlockLUKSCipherSizeMap qcrypto_block_luks_cipher_size_map_aes[] =3D { - { 16, QCRYPTO_CIPHER_ALG_AES_128 }, - { 24, QCRYPTO_CIPHER_ALG_AES_192 }, - { 32, QCRYPTO_CIPHER_ALG_AES_256 }, + { 16, QCRYPTO_CIPHER_ALGO_AES_128 }, + { 24, QCRYPTO_CIPHER_ALGO_AES_192 }, + { 32, QCRYPTO_CIPHER_ALGO_AES_256 }, { 0, 0 }, }; =20 static const QCryptoBlockLUKSCipherSizeMap qcrypto_block_luks_cipher_size_map_cast5[] =3D { - { 16, QCRYPTO_CIPHER_ALG_CAST5_128 }, + { 16, QCRYPTO_CIPHER_ALGO_CAST5_128 }, { 0, 0 }, }; =20 static const QCryptoBlockLUKSCipherSizeMap qcrypto_block_luks_cipher_size_map_serpent[] =3D { - { 16, QCRYPTO_CIPHER_ALG_SERPENT_128 }, - { 24, QCRYPTO_CIPHER_ALG_SERPENT_192 }, - { 32, QCRYPTO_CIPHER_ALG_SERPENT_256 }, + { 16, QCRYPTO_CIPHER_ALGO_SERPENT_128 }, + { 24, QCRYPTO_CIPHER_ALGO_SERPENT_192 }, + { 32, QCRYPTO_CIPHER_ALGO_SERPENT_256 }, { 0, 0 }, }; =20 static const QCryptoBlockLUKSCipherSizeMap qcrypto_block_luks_cipher_size_map_twofish[] =3D { - { 16, QCRYPTO_CIPHER_ALG_TWOFISH_128 }, - { 24, QCRYPTO_CIPHER_ALG_TWOFISH_192 }, - { 32, QCRYPTO_CIPHER_ALG_TWOFISH_256 }, + { 16, QCRYPTO_CIPHER_ALGO_TWOFISH_128 }, + { 24, QCRYPTO_CIPHER_ALGO_TWOFISH_192 }, + { 32, QCRYPTO_CIPHER_ALGO_TWOFISH_256 }, { 0, 0 }, }; =20 #ifdef CONFIG_CRYPTO_SM4 static const QCryptoBlockLUKSCipherSizeMap qcrypto_block_luks_cipher_size_map_sm4[] =3D { - { 16, QCRYPTO_CIPHER_ALG_SM4}, + { 16, QCRYPTO_CIPHER_ALGO_SM4}, { 0, 0 }, }; #endif @@ -123,7 +123,7 @@ struct QCryptoBlockLUKS { QCryptoBlockLUKSHeader header; =20 /* Main encryption algorithm used for encryption*/ - QCryptoCipherAlgorithm cipher_alg; + QCryptoCipherAlgo cipher_alg; =20 /* Mode of encryption for the selected encryption algorithm */ QCryptoCipherMode cipher_mode; @@ -138,7 +138,7 @@ struct QCryptoBlockLUKS { * Encryption algorithm used for IV generation. * Usually the same as main encryption algorithm */ - QCryptoCipherAlgorithm ivgen_cipher_alg; + QCryptoCipherAlgo ivgen_cipher_alg; =20 /* Hash algorithm used in pbkdf2 function */ QCryptoHashAlgo hash_alg; @@ -179,7 +179,7 @@ static int qcrypto_block_luks_cipher_name_lookup(const = char *name, } =20 static const char * -qcrypto_block_luks_cipher_alg_lookup(QCryptoCipherAlgorithm alg, +qcrypto_block_luks_cipher_alg_lookup(QCryptoCipherAlgo alg, Error **errp) { const QCryptoBlockLUKSCipherNameMap *map =3D @@ -195,7 +195,7 @@ qcrypto_block_luks_cipher_alg_lookup(QCryptoCipherAlgor= ithm alg, } =20 error_setg(errp, "Algorithm '%s' not supported", - QCryptoCipherAlgorithm_str(alg)); + QCryptoCipherAlgo_str(alg)); return NULL; } =20 @@ -262,8 +262,8 @@ qcrypto_block_luks_has_format(const uint8_t *buf, * the cipher since that gets a key length matching the digest * size, not AES 128 with truncated digest as might be imagined */ -static QCryptoCipherAlgorithm -qcrypto_block_luks_essiv_cipher(QCryptoCipherAlgorithm cipher, +static QCryptoCipherAlgo +qcrypto_block_luks_essiv_cipher(QCryptoCipherAlgo cipher, QCryptoHashAlgo hash, Error **errp) { @@ -274,54 +274,54 @@ qcrypto_block_luks_essiv_cipher(QCryptoCipherAlgorith= m cipher, } =20 switch (cipher) { - case QCRYPTO_CIPHER_ALG_AES_128: - case QCRYPTO_CIPHER_ALG_AES_192: - case QCRYPTO_CIPHER_ALG_AES_256: + case QCRYPTO_CIPHER_ALGO_AES_128: + case QCRYPTO_CIPHER_ALGO_AES_192: + case QCRYPTO_CIPHER_ALGO_AES_256: if (digestlen =3D=3D qcrypto_cipher_get_key_len( - QCRYPTO_CIPHER_ALG_AES_128)) { - return QCRYPTO_CIPHER_ALG_AES_128; + QCRYPTO_CIPHER_ALGO_AES_128)) { + return QCRYPTO_CIPHER_ALGO_AES_128; } else if (digestlen =3D=3D qcrypto_cipher_get_key_len( - QCRYPTO_CIPHER_ALG_AES_192)) { - return QCRYPTO_CIPHER_ALG_AES_192; + QCRYPTO_CIPHER_ALGO_AES_192)) { + return QCRYPTO_CIPHER_ALGO_AES_192; } else if (digestlen =3D=3D qcrypto_cipher_get_key_len( - QCRYPTO_CIPHER_ALG_AES_256)) { - return QCRYPTO_CIPHER_ALG_AES_256; + QCRYPTO_CIPHER_ALGO_AES_256)) { + return QCRYPTO_CIPHER_ALGO_AES_256; } else { error_setg(errp, "No AES cipher with key size %zu available", digestlen); return 0; } break; - case QCRYPTO_CIPHER_ALG_SERPENT_128: - case QCRYPTO_CIPHER_ALG_SERPENT_192: - case QCRYPTO_CIPHER_ALG_SERPENT_256: + case QCRYPTO_CIPHER_ALGO_SERPENT_128: + case QCRYPTO_CIPHER_ALGO_SERPENT_192: + case QCRYPTO_CIPHER_ALGO_SERPENT_256: if (digestlen =3D=3D qcrypto_cipher_get_key_len( - QCRYPTO_CIPHER_ALG_SERPENT_128)) { - return QCRYPTO_CIPHER_ALG_SERPENT_128; + QCRYPTO_CIPHER_ALGO_SERPENT_128)) { + return QCRYPTO_CIPHER_ALGO_SERPENT_128; } else if (digestlen =3D=3D qcrypto_cipher_get_key_len( - QCRYPTO_CIPHER_ALG_SERPENT_192)) { - return QCRYPTO_CIPHER_ALG_SERPENT_192; + QCRYPTO_CIPHER_ALGO_SERPENT_192)) { + return QCRYPTO_CIPHER_ALGO_SERPENT_192; } else if (digestlen =3D=3D qcrypto_cipher_get_key_len( - QCRYPTO_CIPHER_ALG_SERPENT_256)) { - return QCRYPTO_CIPHER_ALG_SERPENT_256; + QCRYPTO_CIPHER_ALGO_SERPENT_256)) { + return QCRYPTO_CIPHER_ALGO_SERPENT_256; } else { error_setg(errp, "No Serpent cipher with key size %zu availabl= e", digestlen); return 0; } break; - case QCRYPTO_CIPHER_ALG_TWOFISH_128: - case QCRYPTO_CIPHER_ALG_TWOFISH_192: - case QCRYPTO_CIPHER_ALG_TWOFISH_256: + case QCRYPTO_CIPHER_ALGO_TWOFISH_128: + case QCRYPTO_CIPHER_ALGO_TWOFISH_192: + case QCRYPTO_CIPHER_ALGO_TWOFISH_256: if (digestlen =3D=3D qcrypto_cipher_get_key_len( - QCRYPTO_CIPHER_ALG_TWOFISH_128)) { - return QCRYPTO_CIPHER_ALG_TWOFISH_128; + QCRYPTO_CIPHER_ALGO_TWOFISH_128)) { + return QCRYPTO_CIPHER_ALGO_TWOFISH_128; } else if (digestlen =3D=3D qcrypto_cipher_get_key_len( - QCRYPTO_CIPHER_ALG_TWOFISH_192)) { - return QCRYPTO_CIPHER_ALG_TWOFISH_192; + QCRYPTO_CIPHER_ALGO_TWOFISH_192)) { + return QCRYPTO_CIPHER_ALGO_TWOFISH_192; } else if (digestlen =3D=3D qcrypto_cipher_get_key_len( - QCRYPTO_CIPHER_ALG_TWOFISH_256)) { - return QCRYPTO_CIPHER_ALG_TWOFISH_256; + QCRYPTO_CIPHER_ALGO_TWOFISH_256)) { + return QCRYPTO_CIPHER_ALGO_TWOFISH_256; } else { error_setg(errp, "No Twofish cipher with key size %zu availabl= e", digestlen); @@ -330,7 +330,7 @@ qcrypto_block_luks_essiv_cipher(QCryptoCipherAlgorithm = cipher, break; default: error_setg(errp, "Cipher %s not supported with essiv", - QCryptoCipherAlgorithm_str(cipher)); + QCryptoCipherAlgo_str(cipher)); return 0; } } @@ -1322,7 +1322,7 @@ qcrypto_block_luks_create(QCryptoBlock *block, luks_opts.iter_time =3D QCRYPTO_BLOCK_LUKS_DEFAULT_ITER_TIME_MS; } if (!luks_opts.has_cipher_alg) { - luks_opts.cipher_alg =3D QCRYPTO_CIPHER_ALG_AES_256; + luks_opts.cipher_alg =3D QCRYPTO_CIPHER_ALGO_AES_256; } if (!luks_opts.has_cipher_mode) { luks_opts.cipher_mode =3D QCRYPTO_CIPHER_MODE_XTS; diff --git a/crypto/block-qcow.c b/crypto/block-qcow.c index 42e9556e42..a0ba9c1f2e 100644 --- a/crypto/block-qcow.c +++ b/crypto/block-qcow.c @@ -62,7 +62,7 @@ qcrypto_block_qcow_init(QCryptoBlock *block, memcpy(keybuf, password, MIN(len, sizeof(keybuf))); g_free(password); =20 - block->niv =3D qcrypto_cipher_get_iv_len(QCRYPTO_CIPHER_ALG_AES_128, + block->niv =3D qcrypto_cipher_get_iv_len(QCRYPTO_CIPHER_ALGO_AES_128, QCRYPTO_CIPHER_MODE_CBC); block->ivgen =3D qcrypto_ivgen_new(QCRYPTO_IVGEN_ALG_PLAIN64, 0, 0, NULL, 0, errp); @@ -71,7 +71,7 @@ qcrypto_block_qcow_init(QCryptoBlock *block, goto fail; } =20 - ret =3D qcrypto_block_init_cipher(block, QCRYPTO_CIPHER_ALG_AES_128, + ret =3D qcrypto_block_init_cipher(block, QCRYPTO_CIPHER_ALGO_AES_128, QCRYPTO_CIPHER_MODE_CBC, keybuf, G_N_ELEMENTS(keybuf), errp); diff --git a/crypto/block.c b/crypto/block.c index 9846caa591..96c83e60b9 100644 --- a/crypto/block.c +++ b/crypto/block.c @@ -267,7 +267,7 @@ static void qcrypto_block_push_cipher(QCryptoBlock *blo= ck, =20 =20 int qcrypto_block_init_cipher(QCryptoBlock *block, - QCryptoCipherAlgorithm alg, + QCryptoCipherAlgo alg, QCryptoCipherMode mode, const uint8_t *key, size_t nkey, Error **errp) diff --git a/crypto/cipher-afalg.c b/crypto/cipher-afalg.c index 3df8fc54c0..c08eb7a39b 100644 --- a/crypto/cipher-afalg.c +++ b/crypto/cipher-afalg.c @@ -18,7 +18,7 @@ =20 =20 static char * -qcrypto_afalg_cipher_format_name(QCryptoCipherAlgorithm alg, +qcrypto_afalg_cipher_format_name(QCryptoCipherAlgo alg, QCryptoCipherMode mode, Error **errp) { @@ -27,22 +27,22 @@ qcrypto_afalg_cipher_format_name(QCryptoCipherAlgorithm= alg, const char *mode_name; =20 switch (alg) { - case QCRYPTO_CIPHER_ALG_AES_128: - case QCRYPTO_CIPHER_ALG_AES_192: - case QCRYPTO_CIPHER_ALG_AES_256: + case QCRYPTO_CIPHER_ALGO_AES_128: + case QCRYPTO_CIPHER_ALGO_AES_192: + case QCRYPTO_CIPHER_ALGO_AES_256: alg_name =3D "aes"; break; - case QCRYPTO_CIPHER_ALG_CAST5_128: + case QCRYPTO_CIPHER_ALGO_CAST5_128: alg_name =3D "cast5"; break; - case QCRYPTO_CIPHER_ALG_SERPENT_128: - case QCRYPTO_CIPHER_ALG_SERPENT_192: - case QCRYPTO_CIPHER_ALG_SERPENT_256: + case QCRYPTO_CIPHER_ALGO_SERPENT_128: + case QCRYPTO_CIPHER_ALGO_SERPENT_192: + case QCRYPTO_CIPHER_ALGO_SERPENT_256: alg_name =3D "serpent"; break; - case QCRYPTO_CIPHER_ALG_TWOFISH_128: - case QCRYPTO_CIPHER_ALG_TWOFISH_192: - case QCRYPTO_CIPHER_ALG_TWOFISH_256: + case QCRYPTO_CIPHER_ALGO_TWOFISH_128: + case QCRYPTO_CIPHER_ALGO_TWOFISH_192: + case QCRYPTO_CIPHER_ALGO_TWOFISH_256: alg_name =3D "twofish"; break; =20 @@ -60,7 +60,7 @@ qcrypto_afalg_cipher_format_name(QCryptoCipherAlgorithm a= lg, static const struct QCryptoCipherDriver qcrypto_cipher_afalg_driver; =20 QCryptoCipher * -qcrypto_afalg_cipher_ctx_new(QCryptoCipherAlgorithm alg, +qcrypto_afalg_cipher_ctx_new(QCryptoCipherAlgo alg, QCryptoCipherMode mode, const uint8_t *key, size_t nkey, Error **errp) diff --git a/crypto/cipher.c b/crypto/cipher.c index 5f512768ea..c14a8b8a11 100644 --- a/crypto/cipher.c +++ b/crypto/cipher.c @@ -25,39 +25,39 @@ #include "cipherpriv.h" =20 =20 -static const size_t alg_key_len[QCRYPTO_CIPHER_ALG__MAX] =3D { - [QCRYPTO_CIPHER_ALG_AES_128] =3D 16, - [QCRYPTO_CIPHER_ALG_AES_192] =3D 24, - [QCRYPTO_CIPHER_ALG_AES_256] =3D 32, - [QCRYPTO_CIPHER_ALG_DES] =3D 8, - [QCRYPTO_CIPHER_ALG_3DES] =3D 24, - [QCRYPTO_CIPHER_ALG_CAST5_128] =3D 16, - [QCRYPTO_CIPHER_ALG_SERPENT_128] =3D 16, - [QCRYPTO_CIPHER_ALG_SERPENT_192] =3D 24, - [QCRYPTO_CIPHER_ALG_SERPENT_256] =3D 32, - [QCRYPTO_CIPHER_ALG_TWOFISH_128] =3D 16, - [QCRYPTO_CIPHER_ALG_TWOFISH_192] =3D 24, - [QCRYPTO_CIPHER_ALG_TWOFISH_256] =3D 32, +static const size_t alg_key_len[QCRYPTO_CIPHER_ALGO__MAX] =3D { + [QCRYPTO_CIPHER_ALGO_AES_128] =3D 16, + [QCRYPTO_CIPHER_ALGO_AES_192] =3D 24, + [QCRYPTO_CIPHER_ALGO_AES_256] =3D 32, + [QCRYPTO_CIPHER_ALGO_DES] =3D 8, + [QCRYPTO_CIPHER_ALGO_3DES] =3D 24, + [QCRYPTO_CIPHER_ALGO_CAST5_128] =3D 16, + [QCRYPTO_CIPHER_ALGO_SERPENT_128] =3D 16, + [QCRYPTO_CIPHER_ALGO_SERPENT_192] =3D 24, + [QCRYPTO_CIPHER_ALGO_SERPENT_256] =3D 32, + [QCRYPTO_CIPHER_ALGO_TWOFISH_128] =3D 16, + [QCRYPTO_CIPHER_ALGO_TWOFISH_192] =3D 24, + [QCRYPTO_CIPHER_ALGO_TWOFISH_256] =3D 32, #ifdef CONFIG_CRYPTO_SM4 - [QCRYPTO_CIPHER_ALG_SM4] =3D 16, + [QCRYPTO_CIPHER_ALGO_SM4] =3D 16, #endif }; =20 -static const size_t alg_block_len[QCRYPTO_CIPHER_ALG__MAX] =3D { - [QCRYPTO_CIPHER_ALG_AES_128] =3D 16, - [QCRYPTO_CIPHER_ALG_AES_192] =3D 16, - [QCRYPTO_CIPHER_ALG_AES_256] =3D 16, - [QCRYPTO_CIPHER_ALG_DES] =3D 8, - [QCRYPTO_CIPHER_ALG_3DES] =3D 8, - [QCRYPTO_CIPHER_ALG_CAST5_128] =3D 8, - [QCRYPTO_CIPHER_ALG_SERPENT_128] =3D 16, - [QCRYPTO_CIPHER_ALG_SERPENT_192] =3D 16, - [QCRYPTO_CIPHER_ALG_SERPENT_256] =3D 16, - [QCRYPTO_CIPHER_ALG_TWOFISH_128] =3D 16, - [QCRYPTO_CIPHER_ALG_TWOFISH_192] =3D 16, - [QCRYPTO_CIPHER_ALG_TWOFISH_256] =3D 16, +static const size_t alg_block_len[QCRYPTO_CIPHER_ALGO__MAX] =3D { + [QCRYPTO_CIPHER_ALGO_AES_128] =3D 16, + [QCRYPTO_CIPHER_ALGO_AES_192] =3D 16, + [QCRYPTO_CIPHER_ALGO_AES_256] =3D 16, + [QCRYPTO_CIPHER_ALGO_DES] =3D 8, + [QCRYPTO_CIPHER_ALGO_3DES] =3D 8, + [QCRYPTO_CIPHER_ALGO_CAST5_128] =3D 8, + [QCRYPTO_CIPHER_ALGO_SERPENT_128] =3D 16, + [QCRYPTO_CIPHER_ALGO_SERPENT_192] =3D 16, + [QCRYPTO_CIPHER_ALGO_SERPENT_256] =3D 16, + [QCRYPTO_CIPHER_ALGO_TWOFISH_128] =3D 16, + [QCRYPTO_CIPHER_ALGO_TWOFISH_192] =3D 16, + [QCRYPTO_CIPHER_ALGO_TWOFISH_256] =3D 16, #ifdef CONFIG_CRYPTO_SM4 - [QCRYPTO_CIPHER_ALG_SM4] =3D 16, + [QCRYPTO_CIPHER_ALGO_SM4] =3D 16, #endif }; =20 @@ -69,21 +69,21 @@ static const bool mode_need_iv[QCRYPTO_CIPHER_MODE__MAX= ] =3D { }; =20 =20 -size_t qcrypto_cipher_get_block_len(QCryptoCipherAlgorithm alg) +size_t qcrypto_cipher_get_block_len(QCryptoCipherAlgo alg) { assert(alg < G_N_ELEMENTS(alg_key_len)); return alg_block_len[alg]; } =20 =20 -size_t qcrypto_cipher_get_key_len(QCryptoCipherAlgorithm alg) +size_t qcrypto_cipher_get_key_len(QCryptoCipherAlgo alg) { assert(alg < G_N_ELEMENTS(alg_key_len)); return alg_key_len[alg]; } =20 =20 -size_t qcrypto_cipher_get_iv_len(QCryptoCipherAlgorithm alg, +size_t qcrypto_cipher_get_iv_len(QCryptoCipherAlgo alg, QCryptoCipherMode mode) { if (alg >=3D G_N_ELEMENTS(alg_block_len)) { @@ -101,20 +101,20 @@ size_t qcrypto_cipher_get_iv_len(QCryptoCipherAlgorit= hm alg, =20 =20 static bool -qcrypto_cipher_validate_key_length(QCryptoCipherAlgorithm alg, +qcrypto_cipher_validate_key_length(QCryptoCipherAlgo alg, QCryptoCipherMode mode, size_t nkey, Error **errp) { - if ((unsigned)alg >=3D QCRYPTO_CIPHER_ALG__MAX) { + if ((unsigned)alg >=3D QCRYPTO_CIPHER_ALGO__MAX) { error_setg(errp, "Cipher algorithm %d out of range", alg); return false; } =20 if (mode =3D=3D QCRYPTO_CIPHER_MODE_XTS) { - if (alg =3D=3D QCRYPTO_CIPHER_ALG_DES || - alg =3D=3D QCRYPTO_CIPHER_ALG_3DES) { + if (alg =3D=3D QCRYPTO_CIPHER_ALGO_DES || + alg =3D=3D QCRYPTO_CIPHER_ALGO_3DES) { error_setg(errp, "XTS mode not compatible with DES/3DES"); return false; } @@ -148,7 +148,7 @@ qcrypto_cipher_validate_key_length(QCryptoCipherAlgorit= hm alg, #include "cipher-builtin.c.inc" #endif =20 -QCryptoCipher *qcrypto_cipher_new(QCryptoCipherAlgorithm alg, +QCryptoCipher *qcrypto_cipher_new(QCryptoCipherAlgo alg, QCryptoCipherMode mode, const uint8_t *key, size_t nkey, Error **errp) diff --git a/crypto/ivgen.c b/crypto/ivgen.c index 080846cb74..ec0cb1a25b 100644 --- a/crypto/ivgen.c +++ b/crypto/ivgen.c @@ -28,7 +28,7 @@ =20 =20 QCryptoIVGen *qcrypto_ivgen_new(QCryptoIVGenAlgorithm alg, - QCryptoCipherAlgorithm cipheralg, + QCryptoCipherAlgo cipheralg, QCryptoHashAlgo hash, const uint8_t *key, size_t nkey, Error **errp) @@ -79,7 +79,7 @@ QCryptoIVGenAlgorithm qcrypto_ivgen_get_algorithm(QCrypto= IVGen *ivgen) } =20 =20 -QCryptoCipherAlgorithm qcrypto_ivgen_get_cipher(QCryptoIVGen *ivgen) +QCryptoCipherAlgo qcrypto_ivgen_get_cipher(QCryptoIVGen *ivgen) { return ivgen->cipher; } diff --git a/crypto/secret_common.c b/crypto/secret_common.c index 3441c44ca8..2c141107a5 100644 --- a/crypto/secret_common.c +++ b/crypto/secret_common.c @@ -71,7 +71,7 @@ static void qcrypto_secret_decrypt(QCryptoSecretCommon *s= ecret, return; } =20 - aes =3D qcrypto_cipher_new(QCRYPTO_CIPHER_ALG_AES_256, + aes =3D qcrypto_cipher_new(QCRYPTO_CIPHER_ALGO_AES_256, QCRYPTO_CIPHER_MODE_CBC, key, keylen, errp); diff --git a/tests/bench/benchmark-crypto-cipher.c b/tests/bench/benchmark-= crypto-cipher.c index c04f0a0fba..889a29ba5c 100644 --- a/tests/bench/benchmark-crypto-cipher.c +++ b/tests/bench/benchmark-crypto-cipher.c @@ -17,7 +17,7 @@ =20 static void test_cipher_speed(size_t chunk_size, QCryptoCipherMode mode, - QCryptoCipherAlgorithm alg) + QCryptoCipherAlgo alg) { QCryptoCipher *cipher; Error *err =3D NULL; @@ -71,7 +71,7 @@ static void test_cipher_speed(size_t chunk_size, g_test_timer_elapsed(); =20 g_test_message("enc(%s-%s) chunk %zu bytes %.2f MB/sec ", - QCryptoCipherAlgorithm_str(alg), + QCryptoCipherAlgo_str(alg), QCryptoCipherMode_str(mode), chunk_size, (double)total / MiB / g_test_timer_last()); =20 @@ -88,7 +88,7 @@ static void test_cipher_speed(size_t chunk_size, g_test_timer_elapsed(); =20 g_test_message("dec(%s-%s) chunk %zu bytes %.2f MB/sec ", - QCryptoCipherAlgorithm_str(alg), + QCryptoCipherAlgo_str(alg), QCryptoCipherMode_str(mode), chunk_size, (double)total / MiB / g_test_timer_last()); =20 @@ -105,7 +105,7 @@ static void test_cipher_speed_ecb_aes_128(const void *o= paque) size_t chunk_size =3D (size_t)opaque; test_cipher_speed(chunk_size, QCRYPTO_CIPHER_MODE_ECB, - QCRYPTO_CIPHER_ALG_AES_128); + QCRYPTO_CIPHER_ALGO_AES_128); } =20 static void test_cipher_speed_ecb_aes_256(const void *opaque) @@ -113,7 +113,7 @@ static void test_cipher_speed_ecb_aes_256(const void *o= paque) size_t chunk_size =3D (size_t)opaque; test_cipher_speed(chunk_size, QCRYPTO_CIPHER_MODE_ECB, - QCRYPTO_CIPHER_ALG_AES_256); + QCRYPTO_CIPHER_ALGO_AES_256); } =20 static void test_cipher_speed_cbc_aes_128(const void *opaque) @@ -121,7 +121,7 @@ static void test_cipher_speed_cbc_aes_128(const void *o= paque) size_t chunk_size =3D (size_t)opaque; test_cipher_speed(chunk_size, QCRYPTO_CIPHER_MODE_CBC, - QCRYPTO_CIPHER_ALG_AES_128); + QCRYPTO_CIPHER_ALGO_AES_128); } =20 static void test_cipher_speed_cbc_aes_256(const void *opaque) @@ -129,7 +129,7 @@ static void test_cipher_speed_cbc_aes_256(const void *o= paque) size_t chunk_size =3D (size_t)opaque; test_cipher_speed(chunk_size, QCRYPTO_CIPHER_MODE_CBC, - QCRYPTO_CIPHER_ALG_AES_256); + QCRYPTO_CIPHER_ALGO_AES_256); } =20 static void test_cipher_speed_ctr_aes_128(const void *opaque) @@ -137,7 +137,7 @@ static void test_cipher_speed_ctr_aes_128(const void *o= paque) size_t chunk_size =3D (size_t)opaque; test_cipher_speed(chunk_size, QCRYPTO_CIPHER_MODE_CTR, - QCRYPTO_CIPHER_ALG_AES_128); + QCRYPTO_CIPHER_ALGO_AES_128); } =20 static void test_cipher_speed_ctr_aes_256(const void *opaque) @@ -145,7 +145,7 @@ static void test_cipher_speed_ctr_aes_256(const void *o= paque) size_t chunk_size =3D (size_t)opaque; test_cipher_speed(chunk_size, QCRYPTO_CIPHER_MODE_CTR, - QCRYPTO_CIPHER_ALG_AES_256); + QCRYPTO_CIPHER_ALGO_AES_256); } =20 static void test_cipher_speed_xts_aes_128(const void *opaque) @@ -153,7 +153,7 @@ static void test_cipher_speed_xts_aes_128(const void *o= paque) size_t chunk_size =3D (size_t)opaque; test_cipher_speed(chunk_size, QCRYPTO_CIPHER_MODE_XTS, - QCRYPTO_CIPHER_ALG_AES_128); + QCRYPTO_CIPHER_ALGO_AES_128); } =20 static void test_cipher_speed_xts_aes_256(const void *opaque) @@ -161,7 +161,7 @@ static void test_cipher_speed_xts_aes_256(const void *o= paque) size_t chunk_size =3D (size_t)opaque; test_cipher_speed(chunk_size, QCRYPTO_CIPHER_MODE_XTS, - QCRYPTO_CIPHER_ALG_AES_256); + QCRYPTO_CIPHER_ALGO_AES_256); } =20 =20 diff --git a/tests/unit/test-crypto-block.c b/tests/unit/test-crypto-block.c index c2f5fe7b25..1a0d329368 100644 --- a/tests/unit/test-crypto-block.c +++ b/tests/unit/test-crypto-block.c @@ -77,7 +77,7 @@ static QCryptoBlockCreateOptions luks_create_opts_aes256_= cbc_plain64 =3D { .u.luks =3D { .key_secret =3D (char *)"sec0", .has_cipher_alg =3D true, - .cipher_alg =3D QCRYPTO_CIPHER_ALG_AES_256, + .cipher_alg =3D QCRYPTO_CIPHER_ALGO_AES_256, .has_cipher_mode =3D true, .cipher_mode =3D QCRYPTO_CIPHER_MODE_CBC, .has_ivgen_alg =3D true, @@ -91,7 +91,7 @@ static QCryptoBlockCreateOptions luks_create_opts_aes256_= cbc_essiv =3D { .u.luks =3D { .key_secret =3D (char *)"sec0", .has_cipher_alg =3D true, - .cipher_alg =3D QCRYPTO_CIPHER_ALG_AES_256, + .cipher_alg =3D QCRYPTO_CIPHER_ALGO_AES_256, .has_cipher_mode =3D true, .cipher_mode =3D QCRYPTO_CIPHER_MODE_CBC, .has_ivgen_alg =3D true, @@ -112,7 +112,7 @@ static struct QCryptoBlockTestData { =20 bool expect_header; =20 - QCryptoCipherAlgorithm cipher_alg; + QCryptoCipherAlgo cipher_alg; QCryptoCipherMode cipher_mode; QCryptoHashAlgo hash_alg; =20 @@ -128,7 +128,7 @@ static struct QCryptoBlockTestData { =20 .expect_header =3D false, =20 - .cipher_alg =3D QCRYPTO_CIPHER_ALG_AES_128, + .cipher_alg =3D QCRYPTO_CIPHER_ALGO_AES_128, .cipher_mode =3D QCRYPTO_CIPHER_MODE_CBC, =20 .ivgen_alg =3D QCRYPTO_IVGEN_ALG_PLAIN64, @@ -141,7 +141,7 @@ static struct QCryptoBlockTestData { =20 .expect_header =3D true, =20 - .cipher_alg =3D QCRYPTO_CIPHER_ALG_AES_256, + .cipher_alg =3D QCRYPTO_CIPHER_ALGO_AES_256, .cipher_mode =3D QCRYPTO_CIPHER_MODE_XTS, .hash_alg =3D QCRYPTO_HASH_ALGO_SHA256, =20 @@ -156,7 +156,7 @@ static struct QCryptoBlockTestData { =20 .expect_header =3D true, =20 - .cipher_alg =3D QCRYPTO_CIPHER_ALG_AES_256, + .cipher_alg =3D QCRYPTO_CIPHER_ALGO_AES_256, .cipher_mode =3D QCRYPTO_CIPHER_MODE_CBC, .hash_alg =3D QCRYPTO_HASH_ALGO_SHA256, =20 @@ -171,7 +171,7 @@ static struct QCryptoBlockTestData { =20 .expect_header =3D true, =20 - .cipher_alg =3D QCRYPTO_CIPHER_ALG_AES_256, + .cipher_alg =3D QCRYPTO_CIPHER_ALGO_AES_256, .cipher_mode =3D QCRYPTO_CIPHER_MODE_CBC, .hash_alg =3D QCRYPTO_HASH_ALGO_SHA1, =20 diff --git a/tests/unit/test-crypto-cipher.c b/tests/unit/test-crypto-ciphe= r.c index f5152e569d..b328b482e1 100644 --- a/tests/unit/test-crypto-cipher.c +++ b/tests/unit/test-crypto-cipher.c @@ -27,7 +27,7 @@ typedef struct QCryptoCipherTestData QCryptoCipherTestData; struct QCryptoCipherTestData { const char *path; - QCryptoCipherAlgorithm alg; + QCryptoCipherAlgo alg; QCryptoCipherMode mode; const char *key; const char *plaintext; @@ -43,7 +43,7 @@ static QCryptoCipherTestData test_data[] =3D { { /* NIST F.1.1 ECB-AES128.Encrypt */ .path =3D "/crypto/cipher/aes-ecb-128", - .alg =3D QCRYPTO_CIPHER_ALG_AES_128, + .alg =3D QCRYPTO_CIPHER_ALGO_AES_128, .mode =3D QCRYPTO_CIPHER_MODE_ECB, .key =3D "2b7e151628aed2a6abf7158809cf4f3c", .plaintext =3D @@ -60,7 +60,7 @@ static QCryptoCipherTestData test_data[] =3D { { /* NIST F.1.3 ECB-AES192.Encrypt */ .path =3D "/crypto/cipher/aes-ecb-192", - .alg =3D QCRYPTO_CIPHER_ALG_AES_192, + .alg =3D QCRYPTO_CIPHER_ALGO_AES_192, .mode =3D QCRYPTO_CIPHER_MODE_ECB, .key =3D "8e73b0f7da0e6452c810f32b809079e562f8ead2522c6b7b", .plaintext =3D @@ -77,7 +77,7 @@ static QCryptoCipherTestData test_data[] =3D { { /* NIST F.1.5 ECB-AES256.Encrypt */ .path =3D "/crypto/cipher/aes-ecb-256", - .alg =3D QCRYPTO_CIPHER_ALG_AES_256, + .alg =3D QCRYPTO_CIPHER_ALGO_AES_256, .mode =3D QCRYPTO_CIPHER_MODE_ECB, .key =3D "603deb1015ca71be2b73aef0857d7781" @@ -96,7 +96,7 @@ static QCryptoCipherTestData test_data[] =3D { { /* NIST F.2.1 CBC-AES128.Encrypt */ .path =3D "/crypto/cipher/aes-cbc-128", - .alg =3D QCRYPTO_CIPHER_ALG_AES_128, + .alg =3D QCRYPTO_CIPHER_ALGO_AES_128, .mode =3D QCRYPTO_CIPHER_MODE_CBC, .key =3D "2b7e151628aed2a6abf7158809cf4f3c", .iv =3D "000102030405060708090a0b0c0d0e0f", @@ -114,7 +114,7 @@ static QCryptoCipherTestData test_data[] =3D { { /* NIST F.2.3 CBC-AES128.Encrypt */ .path =3D "/crypto/cipher/aes-cbc-192", - .alg =3D QCRYPTO_CIPHER_ALG_AES_192, + .alg =3D QCRYPTO_CIPHER_ALGO_AES_192, .mode =3D QCRYPTO_CIPHER_MODE_CBC, .key =3D "8e73b0f7da0e6452c810f32b809079e562f8ead2522c6b7b", .iv =3D "000102030405060708090a0b0c0d0e0f", @@ -132,7 +132,7 @@ static QCryptoCipherTestData test_data[] =3D { { /* NIST F.2.5 CBC-AES128.Encrypt */ .path =3D "/crypto/cipher/aes-cbc-256", - .alg =3D QCRYPTO_CIPHER_ALG_AES_256, + .alg =3D QCRYPTO_CIPHER_ALGO_AES_256, .mode =3D QCRYPTO_CIPHER_MODE_CBC, .key =3D "603deb1015ca71be2b73aef0857d7781" @@ -156,7 +156,7 @@ static QCryptoCipherTestData test_data[] =3D { * ciphertext in ECB and CBC modes */ .path =3D "/crypto/cipher/des-ecb-56-one-block", - .alg =3D QCRYPTO_CIPHER_ALG_DES, + .alg =3D QCRYPTO_CIPHER_ALGO_DES, .mode =3D QCRYPTO_CIPHER_MODE_ECB, .key =3D "80c4a2e691d5b3f7", .plaintext =3D "70617373776f7264", @@ -165,7 +165,7 @@ static QCryptoCipherTestData test_data[] =3D { { /* See previous comment */ .path =3D "/crypto/cipher/des-cbc-56-one-block", - .alg =3D QCRYPTO_CIPHER_ALG_DES, + .alg =3D QCRYPTO_CIPHER_ALGO_DES, .mode =3D QCRYPTO_CIPHER_MODE_CBC, .key =3D "80c4a2e691d5b3f7", .iv =3D "0000000000000000", @@ -174,7 +174,7 @@ static QCryptoCipherTestData test_data[] =3D { }, { .path =3D "/crypto/cipher/des-ecb-56", - .alg =3D QCRYPTO_CIPHER_ALG_DES, + .alg =3D QCRYPTO_CIPHER_ALGO_DES, .mode =3D QCRYPTO_CIPHER_MODE_ECB, .key =3D "80c4a2e691d5b3f7", .plaintext =3D @@ -191,7 +191,7 @@ static QCryptoCipherTestData test_data[] =3D { { /* Borrowed from linux-kernel crypto/testmgr.h */ .path =3D "/crypto/cipher/3des-cbc", - .alg =3D QCRYPTO_CIPHER_ALG_3DES, + .alg =3D QCRYPTO_CIPHER_ALGO_3DES, .mode =3D QCRYPTO_CIPHER_MODE_CBC, .key =3D "e9c0ff2e760b6424444d995a12d640c0" @@ -220,7 +220,7 @@ static QCryptoCipherTestData test_data[] =3D { { /* Borrowed from linux-kernel crypto/testmgr.h */ .path =3D "/crypto/cipher/3des-ecb", - .alg =3D QCRYPTO_CIPHER_ALG_3DES, + .alg =3D QCRYPTO_CIPHER_ALGO_3DES, .mode =3D QCRYPTO_CIPHER_MODE_ECB, .key =3D "0123456789abcdef5555555555555555" @@ -233,7 +233,7 @@ static QCryptoCipherTestData test_data[] =3D { { /* Borrowed from linux-kernel crypto/testmgr.h */ .path =3D "/crypto/cipher/3des-ctr", - .alg =3D QCRYPTO_CIPHER_ALG_3DES, + .alg =3D QCRYPTO_CIPHER_ALGO_3DES, .mode =3D QCRYPTO_CIPHER_MODE_CTR, .key =3D "9cd6f39cb95a67005a67002dceeb2dce" @@ -308,7 +308,7 @@ static QCryptoCipherTestData test_data[] =3D { { /* RFC 2144, Appendix B.1 */ .path =3D "/crypto/cipher/cast5-128", - .alg =3D QCRYPTO_CIPHER_ALG_CAST5_128, + .alg =3D QCRYPTO_CIPHER_ALGO_CAST5_128, .mode =3D QCRYPTO_CIPHER_MODE_ECB, .key =3D "0123456712345678234567893456789A", .plaintext =3D "0123456789abcdef", @@ -317,7 +317,7 @@ static QCryptoCipherTestData test_data[] =3D { { /* libgcrypt serpent.c */ .path =3D "/crypto/cipher/serpent-128", - .alg =3D QCRYPTO_CIPHER_ALG_SERPENT_128, + .alg =3D QCRYPTO_CIPHER_ALGO_SERPENT_128, .mode =3D QCRYPTO_CIPHER_MODE_ECB, .key =3D "00000000000000000000000000000000", .plaintext =3D "d29d576fcea3a3a7ed9099f29273d78e", @@ -326,7 +326,7 @@ static QCryptoCipherTestData test_data[] =3D { { /* libgcrypt serpent.c */ .path =3D "/crypto/cipher/serpent-192", - .alg =3D QCRYPTO_CIPHER_ALG_SERPENT_192, + .alg =3D QCRYPTO_CIPHER_ALGO_SERPENT_192, .mode =3D QCRYPTO_CIPHER_MODE_ECB, .key =3D "00000000000000000000000000000000" "0000000000000000", @@ -336,7 +336,7 @@ static QCryptoCipherTestData test_data[] =3D { { /* libgcrypt serpent.c */ .path =3D "/crypto/cipher/serpent-256a", - .alg =3D QCRYPTO_CIPHER_ALG_SERPENT_256, + .alg =3D QCRYPTO_CIPHER_ALGO_SERPENT_256, .mode =3D QCRYPTO_CIPHER_MODE_ECB, .key =3D "00000000000000000000000000000000" "00000000000000000000000000000000", @@ -346,7 +346,7 @@ static QCryptoCipherTestData test_data[] =3D { { /* libgcrypt serpent.c */ .path =3D "/crypto/cipher/serpent-256b", - .alg =3D QCRYPTO_CIPHER_ALG_SERPENT_256, + .alg =3D QCRYPTO_CIPHER_ALGO_SERPENT_256, .mode =3D QCRYPTO_CIPHER_MODE_ECB, .key =3D "00000000000000000000000000000000" "00000000000000000000000000000000", @@ -356,7 +356,7 @@ static QCryptoCipherTestData test_data[] =3D { { /* Twofish paper "Known Answer Test" */ .path =3D "/crypto/cipher/twofish-128", - .alg =3D QCRYPTO_CIPHER_ALG_TWOFISH_128, + .alg =3D QCRYPTO_CIPHER_ALGO_TWOFISH_128, .mode =3D QCRYPTO_CIPHER_MODE_ECB, .key =3D "d491db16e7b1c39e86cb086b789f5419", .plaintext =3D "019f9809de1711858faac3a3ba20fbc3", @@ -365,7 +365,7 @@ static QCryptoCipherTestData test_data[] =3D { { /* Twofish paper "Known Answer Test", I=3D3 */ .path =3D "/crypto/cipher/twofish-192", - .alg =3D QCRYPTO_CIPHER_ALG_TWOFISH_192, + .alg =3D QCRYPTO_CIPHER_ALGO_TWOFISH_192, .mode =3D QCRYPTO_CIPHER_MODE_ECB, .key =3D "88b2b2706b105e36b446bb6d731a1e88" "efa71f788965bd44", @@ -375,7 +375,7 @@ static QCryptoCipherTestData test_data[] =3D { { /* Twofish paper "Known Answer Test", I=3D4 */ .path =3D "/crypto/cipher/twofish-256", - .alg =3D QCRYPTO_CIPHER_ALG_TWOFISH_256, + .alg =3D QCRYPTO_CIPHER_ALGO_TWOFISH_256, .mode =3D QCRYPTO_CIPHER_MODE_ECB, .key =3D "d43bb7556ea32e46f2a282b7d45b4e0d" "57ff739d4dc92c1bd7fc01700cc8216f", @@ -386,7 +386,7 @@ static QCryptoCipherTestData test_data[] =3D { { /* SM4, GB/T 32907-2016, Appendix A.1 */ .path =3D "/crypto/cipher/sm4", - .alg =3D QCRYPTO_CIPHER_ALG_SM4, + .alg =3D QCRYPTO_CIPHER_ALGO_SM4, .mode =3D QCRYPTO_CIPHER_MODE_ECB, .key =3D "0123456789abcdeffedcba9876543210", .plaintext =3D @@ -398,7 +398,7 @@ static QCryptoCipherTestData test_data[] =3D { { /* #1 32 byte key, 32 byte PTX */ .path =3D "/crypto/cipher/aes-xts-128-1", - .alg =3D QCRYPTO_CIPHER_ALG_AES_128, + .alg =3D QCRYPTO_CIPHER_ALGO_AES_128, .mode =3D QCRYPTO_CIPHER_MODE_XTS, .key =3D "00000000000000000000000000000000" @@ -415,7 +415,7 @@ static QCryptoCipherTestData test_data[] =3D { { /* #2, 32 byte key, 32 byte PTX */ .path =3D "/crypto/cipher/aes-xts-128-2", - .alg =3D QCRYPTO_CIPHER_ALG_AES_128, + .alg =3D QCRYPTO_CIPHER_ALGO_AES_128, .mode =3D QCRYPTO_CIPHER_MODE_XTS, .key =3D "11111111111111111111111111111111" @@ -432,7 +432,7 @@ static QCryptoCipherTestData test_data[] =3D { { /* #5 from xts.7, 32 byte key, 32 byte PTX */ .path =3D "/crypto/cipher/aes-xts-128-3", - .alg =3D QCRYPTO_CIPHER_ALG_AES_128, + .alg =3D QCRYPTO_CIPHER_ALGO_AES_128, .mode =3D QCRYPTO_CIPHER_MODE_XTS, .key =3D "fffefdfcfbfaf9f8f7f6f5f4f3f2f1f0" @@ -449,7 +449,7 @@ static QCryptoCipherTestData test_data[] =3D { { /* #4, 32 byte key, 512 byte PTX */ .path =3D "/crypto/cipher/aes-xts-128-4", - .alg =3D QCRYPTO_CIPHER_ALG_AES_128, + .alg =3D QCRYPTO_CIPHER_ALGO_AES_128, .mode =3D QCRYPTO_CIPHER_MODE_XTS, .key =3D "27182818284590452353602874713526" @@ -528,7 +528,7 @@ static QCryptoCipherTestData test_data[] =3D { * which is incompatible with XTS */ .path =3D "/crypto/cipher/cast5-xts-128", - .alg =3D QCRYPTO_CIPHER_ALG_CAST5_128, + .alg =3D QCRYPTO_CIPHER_ALGO_CAST5_128, .mode =3D QCRYPTO_CIPHER_MODE_XTS, .key =3D "27182818284590452353602874713526" @@ -537,7 +537,7 @@ static QCryptoCipherTestData test_data[] =3D { { /* NIST F.5.1 CTR-AES128.Encrypt */ .path =3D "/crypto/cipher/aes-ctr-128", - .alg =3D QCRYPTO_CIPHER_ALG_AES_128, + .alg =3D QCRYPTO_CIPHER_ALGO_AES_128, .mode =3D QCRYPTO_CIPHER_MODE_CTR, .key =3D "2b7e151628aed2a6abf7158809cf4f3c", .iv =3D "f0f1f2f3f4f5f6f7f8f9fafbfcfdfeff", @@ -555,7 +555,7 @@ static QCryptoCipherTestData test_data[] =3D { { /* NIST F.5.3 CTR-AES192.Encrypt */ .path =3D "/crypto/cipher/aes-ctr-192", - .alg =3D QCRYPTO_CIPHER_ALG_AES_192, + .alg =3D QCRYPTO_CIPHER_ALGO_AES_192, .mode =3D QCRYPTO_CIPHER_MODE_CTR, .key =3D "8e73b0f7da0e6452c810f32b809079e562f8ead2522c6b7b", .iv =3D "f0f1f2f3f4f5f6f7f8f9fafbfcfdfeff", @@ -573,7 +573,7 @@ static QCryptoCipherTestData test_data[] =3D { { /* NIST F.5.5 CTR-AES256.Encrypt */ .path =3D "/crypto/cipher/aes-ctr-256", - .alg =3D QCRYPTO_CIPHER_ALG_AES_256, + .alg =3D QCRYPTO_CIPHER_ALGO_AES_256, .mode =3D QCRYPTO_CIPHER_MODE_CTR, .key =3D "603deb1015ca71be2b73aef0857d7781" "1f352c073b6108d72d9810a30914dff4", @@ -750,7 +750,7 @@ static void test_cipher_null_iv(void) uint8_t ciphertext[32] =3D { 0 }; =20 cipher =3D qcrypto_cipher_new( - QCRYPTO_CIPHER_ALG_AES_256, + QCRYPTO_CIPHER_ALGO_AES_256, QCRYPTO_CIPHER_MODE_CBC, key, sizeof(key), &error_abort); @@ -779,7 +779,7 @@ static void test_cipher_short_plaintext(void) int ret; =20 cipher =3D qcrypto_cipher_new( - QCRYPTO_CIPHER_ALG_AES_256, + QCRYPTO_CIPHER_ALGO_AES_256, QCRYPTO_CIPHER_MODE_CBC, key, sizeof(key), &error_abort); @@ -823,7 +823,7 @@ int main(int argc, char **argv) g_test_add_data_func(test_data[i].path, &test_data[i], test_ci= pher); } else { g_printerr("# skip unsupported %s:%s\n", - QCryptoCipherAlgorithm_str(test_data[i].alg), + QCryptoCipherAlgo_str(test_data[i].alg), QCryptoCipherMode_str(test_data[i].mode)); } } diff --git a/tests/unit/test-crypto-ivgen.c b/tests/unit/test-crypto-ivgen.c index 9aa3f6018b..6b4110775a 100644 --- a/tests/unit/test-crypto-ivgen.c +++ b/tests/unit/test-crypto-ivgen.c @@ -28,7 +28,7 @@ struct QCryptoIVGenTestData { uint64_t sector; QCryptoIVGenAlgorithm ivalg; QCryptoHashAlgo hashalg; - QCryptoCipherAlgorithm cipheralg; + QCryptoCipherAlgo cipheralg; const uint8_t *key; size_t nkey; const uint8_t *iv; @@ -93,7 +93,7 @@ struct QCryptoIVGenTestData { "/crypto/ivgen/essiv/1", .sector =3D 0x1, .ivalg =3D QCRYPTO_IVGEN_ALG_ESSIV, - .cipheralg =3D QCRYPTO_CIPHER_ALG_AES_128, + .cipheralg =3D QCRYPTO_CIPHER_ALGO_AES_128, .hashalg =3D QCRYPTO_HASH_ALGO_SHA256, .key =3D (const uint8_t *)"\x00\x01\x02\x03\x04\x05\x06\x07" "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f", @@ -107,7 +107,7 @@ struct QCryptoIVGenTestData { "/crypto/ivgen/essiv/1f2e3d4c", .sector =3D 0x1f2e3d4cULL, .ivalg =3D QCRYPTO_IVGEN_ALG_ESSIV, - .cipheralg =3D QCRYPTO_CIPHER_ALG_AES_128, + .cipheralg =3D QCRYPTO_CIPHER_ALGO_AES_128, .hashalg =3D QCRYPTO_HASH_ALGO_SHA256, .key =3D (const uint8_t *)"\x00\x01\x02\x03\x04\x05\x06\x07" "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f", @@ -121,7 +121,7 @@ struct QCryptoIVGenTestData { "/crypto/ivgen/essiv/1f2e3d4c5b6a7988", .sector =3D 0x1f2e3d4c5b6a7988ULL, .ivalg =3D QCRYPTO_IVGEN_ALG_ESSIV, - .cipheralg =3D QCRYPTO_CIPHER_ALG_AES_128, + .cipheralg =3D QCRYPTO_CIPHER_ALGO_AES_128, .hashalg =3D QCRYPTO_HASH_ALGO_SHA256, .key =3D (const uint8_t *)"\x00\x01\x02\x03\x04\x05\x06\x07" "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f", diff --git a/ui/vnc.c b/ui/vnc.c index 9a17994969..b59af625dd 100644 --- a/ui/vnc.c +++ b/ui/vnc.c @@ -2783,7 +2783,7 @@ static int protocol_client_auth_vnc(VncState *vs, uin= t8_t *data, size_t len) vnc_munge_des_rfb_key(key, sizeof(key)); =20 cipher =3D qcrypto_cipher_new( - QCRYPTO_CIPHER_ALG_DES, + QCRYPTO_CIPHER_ALGO_DES, QCRYPTO_CIPHER_MODE_ECB, key, G_N_ELEMENTS(key), &err); @@ -4064,7 +4064,7 @@ void vnc_display_open(const char *id, Error **errp) } if (password) { if (!qcrypto_cipher_supports( - QCRYPTO_CIPHER_ALG_DES, QCRYPTO_CIPHER_MODE_ECB)) { + QCRYPTO_CIPHER_ALGO_DES, QCRYPTO_CIPHER_MODE_ECB)) { error_setg(errp, "Cipher backend does not support DES algorithm"); goto fail; diff --git a/crypto/cipher-builtin.c.inc b/crypto/cipher-builtin.c.inc index b409089095..da5fcbd9a3 100644 --- a/crypto/cipher-builtin.c.inc +++ b/crypto/cipher-builtin.c.inc @@ -221,13 +221,13 @@ static const struct QCryptoCipherDriver qcrypto_ciphe= r_aes_driver_cbc =3D { .cipher_free =3D qcrypto_cipher_ctx_free, }; =20 -bool qcrypto_cipher_supports(QCryptoCipherAlgorithm alg, +bool qcrypto_cipher_supports(QCryptoCipherAlgo alg, QCryptoCipherMode mode) { switch (alg) { - case QCRYPTO_CIPHER_ALG_AES_128: - case QCRYPTO_CIPHER_ALG_AES_192: - case QCRYPTO_CIPHER_ALG_AES_256: + case QCRYPTO_CIPHER_ALGO_AES_128: + case QCRYPTO_CIPHER_ALGO_AES_192: + case QCRYPTO_CIPHER_ALGO_AES_256: switch (mode) { case QCRYPTO_CIPHER_MODE_ECB: case QCRYPTO_CIPHER_MODE_CBC: @@ -241,7 +241,7 @@ bool qcrypto_cipher_supports(QCryptoCipherAlgorithm alg, } } =20 -static QCryptoCipher *qcrypto_cipher_ctx_new(QCryptoCipherAlgorithm alg, +static QCryptoCipher *qcrypto_cipher_ctx_new(QCryptoCipherAlgo alg, QCryptoCipherMode mode, const uint8_t *key, size_t nkey, @@ -252,9 +252,9 @@ static QCryptoCipher *qcrypto_cipher_ctx_new(QCryptoCip= herAlgorithm alg, } =20 switch (alg) { - case QCRYPTO_CIPHER_ALG_AES_128: - case QCRYPTO_CIPHER_ALG_AES_192: - case QCRYPTO_CIPHER_ALG_AES_256: + case QCRYPTO_CIPHER_ALGO_AES_128: + case QCRYPTO_CIPHER_ALGO_AES_192: + case QCRYPTO_CIPHER_ALGO_AES_256: { QCryptoCipherBuiltinAES *ctx; const QCryptoCipherDriver *drv; @@ -292,7 +292,7 @@ static QCryptoCipher *qcrypto_cipher_ctx_new(QCryptoCip= herAlgorithm alg, default: error_setg(errp, "Unsupported cipher algorithm %s", - QCryptoCipherAlgorithm_str(alg)); + QCryptoCipherAlgo_str(alg)); return NULL; } =20 diff --git a/crypto/cipher-gcrypt.c.inc b/crypto/cipher-gcrypt.c.inc index 4a8314746d..12eb9ddb5a 100644 --- a/crypto/cipher-gcrypt.c.inc +++ b/crypto/cipher-gcrypt.c.inc @@ -20,33 +20,33 @@ =20 #include =20 -static int qcrypto_cipher_alg_to_gcry_alg(QCryptoCipherAlgorithm alg) +static int qcrypto_cipher_alg_to_gcry_alg(QCryptoCipherAlgo alg) { switch (alg) { - case QCRYPTO_CIPHER_ALG_DES: + case QCRYPTO_CIPHER_ALGO_DES: return GCRY_CIPHER_DES; - case QCRYPTO_CIPHER_ALG_3DES: + case QCRYPTO_CIPHER_ALGO_3DES: return GCRY_CIPHER_3DES; - case QCRYPTO_CIPHER_ALG_AES_128: + case QCRYPTO_CIPHER_ALGO_AES_128: return GCRY_CIPHER_AES128; - case QCRYPTO_CIPHER_ALG_AES_192: + case QCRYPTO_CIPHER_ALGO_AES_192: return GCRY_CIPHER_AES192; - case QCRYPTO_CIPHER_ALG_AES_256: + case QCRYPTO_CIPHER_ALGO_AES_256: return GCRY_CIPHER_AES256; - case QCRYPTO_CIPHER_ALG_CAST5_128: + case QCRYPTO_CIPHER_ALGO_CAST5_128: return GCRY_CIPHER_CAST5; - case QCRYPTO_CIPHER_ALG_SERPENT_128: + case QCRYPTO_CIPHER_ALGO_SERPENT_128: return GCRY_CIPHER_SERPENT128; - case QCRYPTO_CIPHER_ALG_SERPENT_192: + case QCRYPTO_CIPHER_ALGO_SERPENT_192: return GCRY_CIPHER_SERPENT192; - case QCRYPTO_CIPHER_ALG_SERPENT_256: + case QCRYPTO_CIPHER_ALGO_SERPENT_256: return GCRY_CIPHER_SERPENT256; - case QCRYPTO_CIPHER_ALG_TWOFISH_128: + case QCRYPTO_CIPHER_ALGO_TWOFISH_128: return GCRY_CIPHER_TWOFISH128; - case QCRYPTO_CIPHER_ALG_TWOFISH_256: + case QCRYPTO_CIPHER_ALGO_TWOFISH_256: return GCRY_CIPHER_TWOFISH; #ifdef CONFIG_CRYPTO_SM4 - case QCRYPTO_CIPHER_ALG_SM4: + case QCRYPTO_CIPHER_ALGO_SM4: return GCRY_CIPHER_SM4; #endif default: @@ -70,23 +70,23 @@ static int qcrypto_cipher_mode_to_gcry_mode(QCryptoCiph= erMode mode) } } =20 -bool qcrypto_cipher_supports(QCryptoCipherAlgorithm alg, +bool qcrypto_cipher_supports(QCryptoCipherAlgo alg, QCryptoCipherMode mode) { switch (alg) { - case QCRYPTO_CIPHER_ALG_DES: - case QCRYPTO_CIPHER_ALG_3DES: - case QCRYPTO_CIPHER_ALG_AES_128: - case QCRYPTO_CIPHER_ALG_AES_192: - case QCRYPTO_CIPHER_ALG_AES_256: - case QCRYPTO_CIPHER_ALG_CAST5_128: - case QCRYPTO_CIPHER_ALG_SERPENT_128: - case QCRYPTO_CIPHER_ALG_SERPENT_192: - case QCRYPTO_CIPHER_ALG_SERPENT_256: - case QCRYPTO_CIPHER_ALG_TWOFISH_128: - case QCRYPTO_CIPHER_ALG_TWOFISH_256: + case QCRYPTO_CIPHER_ALGO_DES: + case QCRYPTO_CIPHER_ALGO_3DES: + case QCRYPTO_CIPHER_ALGO_AES_128: + case QCRYPTO_CIPHER_ALGO_AES_192: + case QCRYPTO_CIPHER_ALGO_AES_256: + case QCRYPTO_CIPHER_ALGO_CAST5_128: + case QCRYPTO_CIPHER_ALGO_SERPENT_128: + case QCRYPTO_CIPHER_ALGO_SERPENT_192: + case QCRYPTO_CIPHER_ALGO_SERPENT_256: + case QCRYPTO_CIPHER_ALGO_TWOFISH_128: + case QCRYPTO_CIPHER_ALGO_TWOFISH_256: #ifdef CONFIG_CRYPTO_SM4 - case QCRYPTO_CIPHER_ALG_SM4: + case QCRYPTO_CIPHER_ALGO_SM4: #endif break; default: @@ -228,7 +228,7 @@ static const struct QCryptoCipherDriver qcrypto_gcrypt_= ctr_driver =3D { .cipher_free =3D qcrypto_gcrypt_ctx_free, }; =20 -static QCryptoCipher *qcrypto_cipher_ctx_new(QCryptoCipherAlgorithm alg, +static QCryptoCipher *qcrypto_cipher_ctx_new(QCryptoCipherAlgo alg, QCryptoCipherMode mode, const uint8_t *key, size_t nkey, @@ -246,7 +246,7 @@ static QCryptoCipher *qcrypto_cipher_ctx_new(QCryptoCip= herAlgorithm alg, gcryalg =3D qcrypto_cipher_alg_to_gcry_alg(alg); if (gcryalg =3D=3D GCRY_CIPHER_NONE) { error_setg(errp, "Unsupported cipher algorithm %s", - QCryptoCipherAlgorithm_str(alg)); + QCryptoCipherAlgo_str(alg)); return NULL; } =20 diff --git a/crypto/cipher-gnutls.c.inc b/crypto/cipher-gnutls.c.inc index d3e231c13c..b9450d48b0 100644 --- a/crypto/cipher-gnutls.c.inc +++ b/crypto/cipher-gnutls.c.inc @@ -27,7 +27,7 @@ #define QEMU_GNUTLS_XTS #endif =20 -bool qcrypto_cipher_supports(QCryptoCipherAlgorithm alg, +bool qcrypto_cipher_supports(QCryptoCipherAlgo alg, QCryptoCipherMode mode) { =20 @@ -35,11 +35,11 @@ bool qcrypto_cipher_supports(QCryptoCipherAlgorithm alg, case QCRYPTO_CIPHER_MODE_ECB: case QCRYPTO_CIPHER_MODE_CBC: switch (alg) { - case QCRYPTO_CIPHER_ALG_AES_128: - case QCRYPTO_CIPHER_ALG_AES_192: - case QCRYPTO_CIPHER_ALG_AES_256: - case QCRYPTO_CIPHER_ALG_DES: - case QCRYPTO_CIPHER_ALG_3DES: + case QCRYPTO_CIPHER_ALGO_AES_128: + case QCRYPTO_CIPHER_ALGO_AES_192: + case QCRYPTO_CIPHER_ALGO_AES_256: + case QCRYPTO_CIPHER_ALGO_DES: + case QCRYPTO_CIPHER_ALGO_3DES: return true; default: return false; @@ -47,8 +47,8 @@ bool qcrypto_cipher_supports(QCryptoCipherAlgorithm alg, #ifdef QEMU_GNUTLS_XTS case QCRYPTO_CIPHER_MODE_XTS: switch (alg) { - case QCRYPTO_CIPHER_ALG_AES_128: - case QCRYPTO_CIPHER_ALG_AES_256: + case QCRYPTO_CIPHER_ALGO_AES_128: + case QCRYPTO_CIPHER_ALGO_AES_256: return true; default: return false; @@ -229,7 +229,7 @@ static struct QCryptoCipherDriver gnutls_driver =3D { .cipher_free =3D qcrypto_gnutls_cipher_free, }; =20 -static QCryptoCipher *qcrypto_cipher_ctx_new(QCryptoCipherAlgorithm alg, +static QCryptoCipher *qcrypto_cipher_ctx_new(QCryptoCipherAlgo alg, QCryptoCipherMode mode, const uint8_t *key, size_t nkey, @@ -244,10 +244,10 @@ static QCryptoCipher *qcrypto_cipher_ctx_new(QCryptoC= ipherAlgorithm alg, #ifdef QEMU_GNUTLS_XTS case QCRYPTO_CIPHER_MODE_XTS: switch (alg) { - case QCRYPTO_CIPHER_ALG_AES_128: + case QCRYPTO_CIPHER_ALGO_AES_128: galg =3D GNUTLS_CIPHER_AES_128_XTS; break; - case QCRYPTO_CIPHER_ALG_AES_256: + case QCRYPTO_CIPHER_ALGO_AES_256: galg =3D GNUTLS_CIPHER_AES_256_XTS; break; default: @@ -259,19 +259,19 @@ static QCryptoCipher *qcrypto_cipher_ctx_new(QCryptoC= ipherAlgorithm alg, case QCRYPTO_CIPHER_MODE_ECB: case QCRYPTO_CIPHER_MODE_CBC: switch (alg) { - case QCRYPTO_CIPHER_ALG_AES_128: + case QCRYPTO_CIPHER_ALGO_AES_128: galg =3D GNUTLS_CIPHER_AES_128_CBC; break; - case QCRYPTO_CIPHER_ALG_AES_192: + case QCRYPTO_CIPHER_ALGO_AES_192: galg =3D GNUTLS_CIPHER_AES_192_CBC; break; - case QCRYPTO_CIPHER_ALG_AES_256: + case QCRYPTO_CIPHER_ALGO_AES_256: galg =3D GNUTLS_CIPHER_AES_256_CBC; break; - case QCRYPTO_CIPHER_ALG_DES: + case QCRYPTO_CIPHER_ALGO_DES: galg =3D GNUTLS_CIPHER_DES_CBC; break; - case QCRYPTO_CIPHER_ALG_3DES: + case QCRYPTO_CIPHER_ALGO_3DES: galg =3D GNUTLS_CIPHER_3DES_CBC; break; default: @@ -284,7 +284,7 @@ static QCryptoCipher *qcrypto_cipher_ctx_new(QCryptoCip= herAlgorithm alg, =20 if (galg =3D=3D GNUTLS_CIPHER_UNKNOWN) { error_setg(errp, "Unsupported cipher algorithm %s with %s mode", - QCryptoCipherAlgorithm_str(alg), + QCryptoCipherAlgo_str(alg), QCryptoCipherMode_str(mode)); return NULL; } @@ -310,8 +310,8 @@ static QCryptoCipher *qcrypto_cipher_ctx_new(QCryptoCip= herAlgorithm alg, } } =20 - if (alg =3D=3D QCRYPTO_CIPHER_ALG_DES || - alg =3D=3D QCRYPTO_CIPHER_ALG_3DES) + if (alg =3D=3D QCRYPTO_CIPHER_ALGO_DES || + alg =3D=3D QCRYPTO_CIPHER_ALGO_3DES) ctx->blocksize =3D 8; else ctx->blocksize =3D 16; diff --git a/crypto/cipher-nettle.c.inc b/crypto/cipher-nettle.c.inc index 2654b439c1..ae91363772 100644 --- a/crypto/cipher-nettle.c.inc +++ b/crypto/cipher-nettle.c.inc @@ -454,24 +454,24 @@ DEFINE_ECB(qcrypto_nettle_sm4, sm4_encrypt_native, sm4_decrypt_native) #endif =20 -bool qcrypto_cipher_supports(QCryptoCipherAlgorithm alg, +bool qcrypto_cipher_supports(QCryptoCipherAlgo alg, QCryptoCipherMode mode) { switch (alg) { - case QCRYPTO_CIPHER_ALG_DES: - case QCRYPTO_CIPHER_ALG_3DES: - case QCRYPTO_CIPHER_ALG_AES_128: - case QCRYPTO_CIPHER_ALG_AES_192: - case QCRYPTO_CIPHER_ALG_AES_256: - case QCRYPTO_CIPHER_ALG_CAST5_128: - case QCRYPTO_CIPHER_ALG_SERPENT_128: - case QCRYPTO_CIPHER_ALG_SERPENT_192: - case QCRYPTO_CIPHER_ALG_SERPENT_256: - case QCRYPTO_CIPHER_ALG_TWOFISH_128: - case QCRYPTO_CIPHER_ALG_TWOFISH_192: - case QCRYPTO_CIPHER_ALG_TWOFISH_256: + case QCRYPTO_CIPHER_ALGO_DES: + case QCRYPTO_CIPHER_ALGO_3DES: + case QCRYPTO_CIPHER_ALGO_AES_128: + case QCRYPTO_CIPHER_ALGO_AES_192: + case QCRYPTO_CIPHER_ALGO_AES_256: + case QCRYPTO_CIPHER_ALGO_CAST5_128: + case QCRYPTO_CIPHER_ALGO_SERPENT_128: + case QCRYPTO_CIPHER_ALGO_SERPENT_192: + case QCRYPTO_CIPHER_ALGO_SERPENT_256: + case QCRYPTO_CIPHER_ALGO_TWOFISH_128: + case QCRYPTO_CIPHER_ALGO_TWOFISH_192: + case QCRYPTO_CIPHER_ALGO_TWOFISH_256: #ifdef CONFIG_CRYPTO_SM4 - case QCRYPTO_CIPHER_ALG_SM4: + case QCRYPTO_CIPHER_ALGO_SM4: #endif break; default: @@ -489,7 +489,7 @@ bool qcrypto_cipher_supports(QCryptoCipherAlgorithm alg, } } =20 -static QCryptoCipher *qcrypto_cipher_ctx_new(QCryptoCipherAlgorithm alg, +static QCryptoCipher *qcrypto_cipher_ctx_new(QCryptoCipherAlgo alg, QCryptoCipherMode mode, const uint8_t *key, size_t nkey, @@ -510,7 +510,7 @@ static QCryptoCipher *qcrypto_cipher_ctx_new(QCryptoCip= herAlgorithm alg, } =20 switch (alg) { - case QCRYPTO_CIPHER_ALG_DES: + case QCRYPTO_CIPHER_ALGO_DES: { QCryptoNettleDES *ctx; const QCryptoCipherDriver *drv; @@ -538,7 +538,7 @@ static QCryptoCipher *qcrypto_cipher_ctx_new(QCryptoCip= herAlgorithm alg, return &ctx->base; } =20 - case QCRYPTO_CIPHER_ALG_3DES: + case QCRYPTO_CIPHER_ALGO_3DES: { QCryptoNettleDES3 *ctx; const QCryptoCipherDriver *drv; @@ -565,7 +565,7 @@ static QCryptoCipher *qcrypto_cipher_ctx_new(QCryptoCip= herAlgorithm alg, return &ctx->base; } =20 - case QCRYPTO_CIPHER_ALG_AES_128: + case QCRYPTO_CIPHER_ALGO_AES_128: { QCryptoNettleAES128 *ctx =3D g_new0(QCryptoNettleAES128, 1); =20 @@ -594,7 +594,7 @@ static QCryptoCipher *qcrypto_cipher_ctx_new(QCryptoCip= herAlgorithm alg, return &ctx->base; } =20 - case QCRYPTO_CIPHER_ALG_AES_192: + case QCRYPTO_CIPHER_ALGO_AES_192: { QCryptoNettleAES192 *ctx =3D g_new0(QCryptoNettleAES192, 1); =20 @@ -623,7 +623,7 @@ static QCryptoCipher *qcrypto_cipher_ctx_new(QCryptoCip= herAlgorithm alg, return &ctx->base; } =20 - case QCRYPTO_CIPHER_ALG_AES_256: + case QCRYPTO_CIPHER_ALGO_AES_256: { QCryptoNettleAES256 *ctx =3D g_new0(QCryptoNettleAES256, 1); =20 @@ -652,7 +652,7 @@ static QCryptoCipher *qcrypto_cipher_ctx_new(QCryptoCip= herAlgorithm alg, return &ctx->base; } =20 - case QCRYPTO_CIPHER_ALG_CAST5_128: + case QCRYPTO_CIPHER_ALGO_CAST5_128: { QCryptoNettleCAST128 *ctx; const QCryptoCipherDriver *drv; @@ -680,9 +680,9 @@ static QCryptoCipher *qcrypto_cipher_ctx_new(QCryptoCip= herAlgorithm alg, return &ctx->base; } =20 - case QCRYPTO_CIPHER_ALG_SERPENT_128: - case QCRYPTO_CIPHER_ALG_SERPENT_192: - case QCRYPTO_CIPHER_ALG_SERPENT_256: + case QCRYPTO_CIPHER_ALGO_SERPENT_128: + case QCRYPTO_CIPHER_ALGO_SERPENT_192: + case QCRYPTO_CIPHER_ALGO_SERPENT_256: { QCryptoNettleSerpent *ctx =3D g_new0(QCryptoNettleSerpent, 1); =20 @@ -709,9 +709,9 @@ static QCryptoCipher *qcrypto_cipher_ctx_new(QCryptoCip= herAlgorithm alg, return &ctx->base; } =20 - case QCRYPTO_CIPHER_ALG_TWOFISH_128: - case QCRYPTO_CIPHER_ALG_TWOFISH_192: - case QCRYPTO_CIPHER_ALG_TWOFISH_256: + case QCRYPTO_CIPHER_ALGO_TWOFISH_128: + case QCRYPTO_CIPHER_ALGO_TWOFISH_192: + case QCRYPTO_CIPHER_ALGO_TWOFISH_256: { QCryptoNettleTwofish *ctx =3D g_new0(QCryptoNettleTwofish, 1); =20 @@ -738,7 +738,7 @@ static QCryptoCipher *qcrypto_cipher_ctx_new(QCryptoCip= herAlgorithm alg, return &ctx->base; } #ifdef CONFIG_CRYPTO_SM4 - case QCRYPTO_CIPHER_ALG_SM4: + case QCRYPTO_CIPHER_ALGO_SM4: { QCryptoNettleSm4 *ctx; const QCryptoCipherDriver *drv; @@ -766,7 +766,7 @@ static QCryptoCipher *qcrypto_cipher_ctx_new(QCryptoCip= herAlgorithm alg, =20 default: error_setg(errp, "Unsupported cipher algorithm %s", - QCryptoCipherAlgorithm_str(alg)); + QCryptoCipherAlgo_str(alg)); return NULL; } =20 --=20 2.46.0 From nobody Sun Nov 24 05:28:16 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1725986979; cv=none; d=zohomail.com; s=zohoarc; b=XZV6GK2IB9v/hahMKYP3ntV2zec03MG2jLWYudzSAwWVTWiUDA9cTqL54Qw7mrGysIY+q5URsSfLEPKD8LRU8BF9tndUtpvKOkdahjag7Zttm+wtgDmJrjYPHMZtWRsakVIoC+Aoa9KLiRPkQ3SQc2oWJPnucqjOeRQXj7GanVw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1725986979; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=9xPmcjVBHaUKKTI613Oz8M3KcY8T/Vhq8MLN3FkBcsw=; b=MER79FvfbQNKNLDVlUpbUBQD+8b1WGoR73zMNYy6IrAd0BzG2Z8IE46l1U1DNk5qOxMP72wZg7CF2LzdFeNci6bwG09wQqqrl4k9p/Z1ia9iCgmhrWGkJj2d+0hhu7M4fHxzOx7Zjas9eXPuVNB51NW81QlLkwSaxb/9o9PQbVk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1725986979062648.8155186648319; Tue, 10 Sep 2024 09:49:39 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1so41k-00072H-9g; Tue, 10 Sep 2024 12:47:40 -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 1so41X-0006ju-N1 for qemu-devel@nongnu.org; Tue, 10 Sep 2024 12:47:27 -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 1so41T-0007Yc-DC for qemu-devel@nongnu.org; Tue, 10 Sep 2024 12:47:27 -0400 Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-553-dAz02H9FNfW6PLTwLICR7Q-1; Tue, 10 Sep 2024 12:47:20 -0400 Received: from mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.40]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id C568E19560B4; Tue, 10 Sep 2024 16:47:19 +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 4B31719560AD; Tue, 10 Sep 2024 16:47:19 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 9D31021E682B; Tue, 10 Sep 2024 18:47:14 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1725986842; 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=9xPmcjVBHaUKKTI613Oz8M3KcY8T/Vhq8MLN3FkBcsw=; b=iCuSSSH9OxvAtUUKjzSy8TMomKT+7hLlrjdfMqKO+6ekGjGCKND6bVs2n/grN0+SyeF18H H8RYTDxZlhjuI2Qj7t2Rue+gpqxjyXhHT+0fYg0lzgMAY5VrKEghbGPBG5B5drgxcNsc00 6Qn7DR/3I3zKuRpobfxkAYcFpVxD8nI= X-MC-Unique: dAz02H9FNfW6PLTwLICR7Q-1 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org, =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= Subject: [PULL 13/19] qapi/crypto: Rename QCryptoIVGenAlgorithm to *Algo, and drop prefix Date: Tue, 10 Sep 2024 18:47:08 +0200 Message-ID: <20240910164714.1993531-14-armbru@redhat.com> In-Reply-To: <20240910164714.1993531-1-armbru@redhat.com> References: <20240910164714.1993531-1-armbru@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.40 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.145, 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, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1725986979921116600 QAPI's 'prefix' feature can make the connection between enumeration type and its constants less than obvious. It's best used with restraint. QCryptoIVGenAlgorithm has a 'prefix' that overrides the generated enumeration constants' prefix to QCRYPTO_IVGEN_ALG. We could simply drop 'prefix', but then the prefix becomes QCRYPTO_IV_GEN_ALGORITHM, which is rather long. We could additionally rename the type to QCryptoIVGenAlg, but I think the abbreviation "alg" is less than clear. Rename the type to QCryptoIVGenAlgo instead. The prefix becomes QCRYPTO_IV_GEN_ALGO. Signed-off-by: Markus Armbruster Acked-by: Daniel P. Berrang=C3=A9 Message-ID: <20240904111836.3273842-14-armbru@redhat.com> --- qapi/crypto.json | 9 ++++----- crypto/ivgenpriv.h | 2 +- include/crypto/ivgen.h | 14 +++++++------- crypto/block-luks.c | 16 ++++++++-------- crypto/block-qcow.c | 2 +- crypto/ivgen.c | 10 +++++----- tests/unit/test-crypto-block.c | 14 +++++++------- tests/unit/test-crypto-ivgen.c | 22 +++++++++++----------- 8 files changed, 44 insertions(+), 45 deletions(-) diff --git a/qapi/crypto.json b/qapi/crypto.json index 0591d62f67..3e6a7fb8e5 100644 --- a/qapi/crypto.json +++ b/qapi/crypto.json @@ -122,7 +122,7 @@ 'data': ['ecb', 'cbc', 'xts', 'ctr']} =20 ## -# @QCryptoIVGenAlgorithm: +# @QCryptoIVGenAlgo: # # The supported algorithms for generating initialization vectors for # full disk encryption. The 'plain' generator should not be used for @@ -138,8 +138,7 @@ # # Since: 2.6 ## -{ 'enum': 'QCryptoIVGenAlgorithm', - 'prefix': 'QCRYPTO_IVGEN_ALG', +{ 'enum': 'QCryptoIVGenAlgo', 'data': ['plain', 'plain64', 'essiv']} =20 ## @@ -226,7 +225,7 @@ 'base': 'QCryptoBlockOptionsLUKS', 'data': { '*cipher-alg': 'QCryptoCipherAlgo', '*cipher-mode': 'QCryptoCipherMode', - '*ivgen-alg': 'QCryptoIVGenAlgorithm', + '*ivgen-alg': 'QCryptoIVGenAlgo', '*ivgen-hash-alg': 'QCryptoHashAlgo', '*hash-alg': 'QCryptoHashAlgo', '*iter-time': 'int' }} @@ -323,7 +322,7 @@ { 'struct': 'QCryptoBlockInfoLUKS', 'data': {'cipher-alg': 'QCryptoCipherAlgo', 'cipher-mode': 'QCryptoCipherMode', - 'ivgen-alg': 'QCryptoIVGenAlgorithm', + 'ivgen-alg': 'QCryptoIVGenAlgo', '*ivgen-hash-alg': 'QCryptoHashAlgo', 'hash-alg': 'QCryptoHashAlgo', 'detached-header': 'bool', diff --git a/crypto/ivgenpriv.h b/crypto/ivgenpriv.h index ef24c76345..e3388d30be 100644 --- a/crypto/ivgenpriv.h +++ b/crypto/ivgenpriv.h @@ -40,7 +40,7 @@ struct QCryptoIVGen { QCryptoIVGenDriver *driver; void *private; =20 - QCryptoIVGenAlgorithm algorithm; + QCryptoIVGenAlgo algorithm; QCryptoCipherAlgo cipher; QCryptoHashAlgo hash; }; diff --git a/include/crypto/ivgen.h b/include/crypto/ivgen.h index b059e332cd..bfa5d28103 100644 --- a/include/crypto/ivgen.h +++ b/include/crypto/ivgen.h @@ -44,7 +44,7 @@ * * g_assert((ndata % 512) =3D=3D 0); * - * QCryptoIVGen *ivgen =3D qcrypto_ivgen_new(QCRYPTO_IVGEN_ALG_ESSIV, + * QCryptoIVGen *ivgen =3D qcrypto_ivgen_new(QCRYPTO_IV_GEN_ALGO_ESSIV, * QCRYPTO_CIPHER_ALGO_AES_128, * QCRYPTO_HASH_ALGO_SHA256, * key, nkey, errp); @@ -97,7 +97,7 @@ =20 typedef struct QCryptoIVGen QCryptoIVGen; =20 -/* See also QCryptoIVGenAlgorithm enum in qapi/crypto.json */ +/* See also QCryptoIVGenAlgo enum in qapi/crypto.json */ =20 =20 /** @@ -113,19 +113,19 @@ typedef struct QCryptoIVGen QCryptoIVGen; * are required or not depends on the choice of @alg * requested. * - * - QCRYPTO_IVGEN_ALG_PLAIN + * - QCRYPTO_IV_GEN_ALGO_PLAIN * * The IVs are generated by the 32-bit truncated sector * number. This should never be used for block devices * that are larger than 2^32 sectors in size. * All the other parameters are unused. * - * - QCRYPTO_IVGEN_ALG_PLAIN64 + * - QCRYPTO_IV_GEN_ALGO_PLAIN64 * * The IVs are generated by the 64-bit sector number. * All the other parameters are unused. * - * - QCRYPTO_IVGEN_ALG_ESSIV: + * - QCRYPTO_IV_GEN_ALGO_ESSIV: * * The IVs are generated by encrypting the 64-bit sector * number with a hash of an encryption key. The @cipheralg, @@ -133,7 +133,7 @@ typedef struct QCryptoIVGen QCryptoIVGen; * * Returns: a new IV generator, or NULL on error */ -QCryptoIVGen *qcrypto_ivgen_new(QCryptoIVGenAlgorithm alg, +QCryptoIVGen *qcrypto_ivgen_new(QCryptoIVGenAlgo alg, QCryptoCipherAlgo cipheralg, QCryptoHashAlgo hash, const uint8_t *key, size_t nkey, @@ -167,7 +167,7 @@ int qcrypto_ivgen_calculate(QCryptoIVGen *ivgen, * * Returns: the IV generator algorithm */ -QCryptoIVGenAlgorithm qcrypto_ivgen_get_algorithm(QCryptoIVGen *ivgen); +QCryptoIVGenAlgo qcrypto_ivgen_get_algorithm(QCryptoIVGen *ivgen); =20 =20 /** diff --git a/crypto/block-luks.c b/crypto/block-luks.c index 8eadf124fc..0926ad28f0 100644 --- a/crypto/block-luks.c +++ b/crypto/block-luks.c @@ -129,7 +129,7 @@ struct QCryptoBlockLUKS { QCryptoCipherMode cipher_mode; =20 /* Initialization vector generation algorithm */ - QCryptoIVGenAlgorithm ivgen_alg; + QCryptoIVGenAlgo ivgen_alg; =20 /* Hash algorithm used for IV generation*/ QCryptoHashAlgo ivgen_hash_alg; @@ -229,7 +229,7 @@ static int qcrypto_block_luks_name_lookup(const char *n= ame, =20 #define qcrypto_block_luks_ivgen_name_lookup(name, errp) \ qcrypto_block_luks_name_lookup(name, \ - &QCryptoIVGenAlgorithm_lookup, \ + &QCryptoIVGenAlgo_lookup, \ "IV generator", \ errp) =20 @@ -660,7 +660,7 @@ qcrypto_block_luks_parse_header(QCryptoBlockLUKS *luks,= Error **errp) return -1; } =20 - if (luks->ivgen_alg =3D=3D QCRYPTO_IVGEN_ALG_ESSIV) { + if (luks->ivgen_alg =3D=3D QCRYPTO_IV_GEN_ALGO_ESSIV) { if (!ivhash_name) { error_setg(errp, "Missing IV generator hash specification"); return -1; @@ -1328,12 +1328,12 @@ qcrypto_block_luks_create(QCryptoBlock *block, luks_opts.cipher_mode =3D QCRYPTO_CIPHER_MODE_XTS; } if (!luks_opts.has_ivgen_alg) { - luks_opts.ivgen_alg =3D QCRYPTO_IVGEN_ALG_PLAIN64; + luks_opts.ivgen_alg =3D QCRYPTO_IV_GEN_ALGO_PLAIN64; } if (!luks_opts.has_hash_alg) { luks_opts.hash_alg =3D QCRYPTO_HASH_ALGO_SHA256; } - if (luks_opts.ivgen_alg =3D=3D QCRYPTO_IVGEN_ALG_ESSIV) { + if (luks_opts.ivgen_alg =3D=3D QCRYPTO_IV_GEN_ALGO_ESSIV) { if (!luks_opts.has_ivgen_hash_alg) { luks_opts.ivgen_hash_alg =3D QCRYPTO_HASH_ALGO_SHA256; luks_opts.has_ivgen_hash_alg =3D true; @@ -1384,7 +1384,7 @@ qcrypto_block_luks_create(QCryptoBlock *block, } =20 cipher_mode =3D QCryptoCipherMode_str(luks_opts.cipher_mode); - ivgen_alg =3D QCryptoIVGenAlgorithm_str(luks_opts.ivgen_alg); + ivgen_alg =3D QCryptoIVGenAlgo_str(luks_opts.ivgen_alg); if (luks_opts.has_ivgen_hash_alg) { ivgen_hash_alg =3D QCryptoHashAlgo_str(luks_opts.ivgen_hash_alg); cipher_mode_spec =3D g_strdup_printf("%s-%s:%s", cipher_mode, ivge= n_alg, @@ -1411,7 +1411,7 @@ qcrypto_block_luks_create(QCryptoBlock *block, goto error; } =20 - if (luks_opts.ivgen_alg =3D=3D QCRYPTO_IVGEN_ALG_ESSIV) { + if (luks_opts.ivgen_alg =3D=3D QCRYPTO_IV_GEN_ALGO_ESSIV) { luks->ivgen_cipher_alg =3D qcrypto_block_luks_essiv_cipher(luks_opts.cipher_alg, luks_opts.ivgen_hash_alg, @@ -1886,7 +1886,7 @@ static int qcrypto_block_luks_get_info(QCryptoBlock *= block, info->u.luks.cipher_alg =3D luks->cipher_alg; info->u.luks.cipher_mode =3D luks->cipher_mode; info->u.luks.ivgen_alg =3D luks->ivgen_alg; - if (info->u.luks.ivgen_alg =3D=3D QCRYPTO_IVGEN_ALG_ESSIV) { + if (info->u.luks.ivgen_alg =3D=3D QCRYPTO_IV_GEN_ALGO_ESSIV) { info->u.luks.has_ivgen_hash_alg =3D true; info->u.luks.ivgen_hash_alg =3D luks->ivgen_hash_alg; } diff --git a/crypto/block-qcow.c b/crypto/block-qcow.c index a0ba9c1f2e..054078b895 100644 --- a/crypto/block-qcow.c +++ b/crypto/block-qcow.c @@ -64,7 +64,7 @@ qcrypto_block_qcow_init(QCryptoBlock *block, =20 block->niv =3D qcrypto_cipher_get_iv_len(QCRYPTO_CIPHER_ALGO_AES_128, QCRYPTO_CIPHER_MODE_CBC); - block->ivgen =3D qcrypto_ivgen_new(QCRYPTO_IVGEN_ALG_PLAIN64, + block->ivgen =3D qcrypto_ivgen_new(QCRYPTO_IV_GEN_ALGO_PLAIN64, 0, 0, NULL, 0, errp); if (!block->ivgen) { ret =3D -ENOTSUP; diff --git a/crypto/ivgen.c b/crypto/ivgen.c index ec0cb1a25b..6b7d24d889 100644 --- a/crypto/ivgen.c +++ b/crypto/ivgen.c @@ -27,7 +27,7 @@ #include "ivgen-essiv.h" =20 =20 -QCryptoIVGen *qcrypto_ivgen_new(QCryptoIVGenAlgorithm alg, +QCryptoIVGen *qcrypto_ivgen_new(QCryptoIVGenAlgo alg, QCryptoCipherAlgo cipheralg, QCryptoHashAlgo hash, const uint8_t *key, size_t nkey, @@ -40,13 +40,13 @@ QCryptoIVGen *qcrypto_ivgen_new(QCryptoIVGenAlgorithm a= lg, ivgen->hash =3D hash; =20 switch (alg) { - case QCRYPTO_IVGEN_ALG_PLAIN: + case QCRYPTO_IV_GEN_ALGO_PLAIN: ivgen->driver =3D &qcrypto_ivgen_plain; break; - case QCRYPTO_IVGEN_ALG_PLAIN64: + case QCRYPTO_IV_GEN_ALGO_PLAIN64: ivgen->driver =3D &qcrypto_ivgen_plain64; break; - case QCRYPTO_IVGEN_ALG_ESSIV: + case QCRYPTO_IV_GEN_ALGO_ESSIV: ivgen->driver =3D &qcrypto_ivgen_essiv; break; default: @@ -73,7 +73,7 @@ int qcrypto_ivgen_calculate(QCryptoIVGen *ivgen, } =20 =20 -QCryptoIVGenAlgorithm qcrypto_ivgen_get_algorithm(QCryptoIVGen *ivgen) +QCryptoIVGenAlgo qcrypto_ivgen_get_algorithm(QCryptoIVGen *ivgen) { return ivgen->algorithm; } diff --git a/tests/unit/test-crypto-block.c b/tests/unit/test-crypto-block.c index 1a0d329368..9217b9a2ef 100644 --- a/tests/unit/test-crypto-block.c +++ b/tests/unit/test-crypto-block.c @@ -81,7 +81,7 @@ static QCryptoBlockCreateOptions luks_create_opts_aes256_= cbc_plain64 =3D { .has_cipher_mode =3D true, .cipher_mode =3D QCRYPTO_CIPHER_MODE_CBC, .has_ivgen_alg =3D true, - .ivgen_alg =3D QCRYPTO_IVGEN_ALG_PLAIN64, + .ivgen_alg =3D QCRYPTO_IV_GEN_ALGO_PLAIN64, }, }; =20 @@ -95,7 +95,7 @@ static QCryptoBlockCreateOptions luks_create_opts_aes256_= cbc_essiv =3D { .has_cipher_mode =3D true, .cipher_mode =3D QCRYPTO_CIPHER_MODE_CBC, .has_ivgen_alg =3D true, - .ivgen_alg =3D QCRYPTO_IVGEN_ALG_ESSIV, + .ivgen_alg =3D QCRYPTO_IV_GEN_ALGO_ESSIV, .has_ivgen_hash_alg =3D true, .ivgen_hash_alg =3D QCRYPTO_HASH_ALGO_SHA256, .has_hash_alg =3D true, @@ -116,7 +116,7 @@ static struct QCryptoBlockTestData { QCryptoCipherMode cipher_mode; QCryptoHashAlgo hash_alg; =20 - QCryptoIVGenAlgorithm ivgen_alg; + QCryptoIVGenAlgo ivgen_alg; QCryptoHashAlgo ivgen_hash; =20 bool slow; @@ -131,7 +131,7 @@ static struct QCryptoBlockTestData { .cipher_alg =3D QCRYPTO_CIPHER_ALGO_AES_128, .cipher_mode =3D QCRYPTO_CIPHER_MODE_CBC, =20 - .ivgen_alg =3D QCRYPTO_IVGEN_ALG_PLAIN64, + .ivgen_alg =3D QCRYPTO_IV_GEN_ALGO_PLAIN64, }, #ifdef TEST_LUKS { @@ -145,7 +145,7 @@ static struct QCryptoBlockTestData { .cipher_mode =3D QCRYPTO_CIPHER_MODE_XTS, .hash_alg =3D QCRYPTO_HASH_ALGO_SHA256, =20 - .ivgen_alg =3D QCRYPTO_IVGEN_ALG_PLAIN64, + .ivgen_alg =3D QCRYPTO_IV_GEN_ALGO_PLAIN64, =20 .slow =3D true, }, @@ -160,7 +160,7 @@ static struct QCryptoBlockTestData { .cipher_mode =3D QCRYPTO_CIPHER_MODE_CBC, .hash_alg =3D QCRYPTO_HASH_ALGO_SHA256, =20 - .ivgen_alg =3D QCRYPTO_IVGEN_ALG_PLAIN64, + .ivgen_alg =3D QCRYPTO_IV_GEN_ALGO_PLAIN64, =20 .slow =3D true, }, @@ -175,7 +175,7 @@ static struct QCryptoBlockTestData { .cipher_mode =3D QCRYPTO_CIPHER_MODE_CBC, .hash_alg =3D QCRYPTO_HASH_ALGO_SHA1, =20 - .ivgen_alg =3D QCRYPTO_IVGEN_ALG_ESSIV, + .ivgen_alg =3D QCRYPTO_IV_GEN_ALGO_ESSIV, .ivgen_hash =3D QCRYPTO_HASH_ALGO_SHA256, =20 .slow =3D true, diff --git a/tests/unit/test-crypto-ivgen.c b/tests/unit/test-crypto-ivgen.c index 6b4110775a..bc9ffe34e7 100644 --- a/tests/unit/test-crypto-ivgen.c +++ b/tests/unit/test-crypto-ivgen.c @@ -26,7 +26,7 @@ struct QCryptoIVGenTestData { const char *path; uint64_t sector; - QCryptoIVGenAlgorithm ivalg; + QCryptoIVGenAlgo ivalg; QCryptoHashAlgo hashalg; QCryptoCipherAlgo cipheralg; const uint8_t *key; @@ -38,7 +38,7 @@ struct QCryptoIVGenTestData { { "/crypto/ivgen/plain/1", .sector =3D 0x1, - .ivalg =3D QCRYPTO_IVGEN_ALG_PLAIN, + .ivalg =3D QCRYPTO_IV_GEN_ALGO_PLAIN, .iv =3D (const uint8_t *)"\x01\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00", .niv =3D 16, @@ -47,7 +47,7 @@ struct QCryptoIVGenTestData { { "/crypto/ivgen/plain/1f2e3d4c", .sector =3D 0x1f2e3d4cULL, - .ivalg =3D QCRYPTO_IVGEN_ALG_PLAIN, + .ivalg =3D QCRYPTO_IV_GEN_ALGO_PLAIN, .iv =3D (const uint8_t *)"\x4c\x3d\x2e\x1f\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00", .niv =3D 16, @@ -56,7 +56,7 @@ struct QCryptoIVGenTestData { { "/crypto/ivgen/plain/1f2e3d4c5b6a7988", .sector =3D 0x1f2e3d4c5b6a7988ULL, - .ivalg =3D QCRYPTO_IVGEN_ALG_PLAIN, + .ivalg =3D QCRYPTO_IV_GEN_ALGO_PLAIN, .iv =3D (const uint8_t *)"\x88\x79\x6a\x5b\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00", .niv =3D 16, @@ -65,7 +65,7 @@ struct QCryptoIVGenTestData { { "/crypto/ivgen/plain64/1", .sector =3D 0x1, - .ivalg =3D QCRYPTO_IVGEN_ALG_PLAIN64, + .ivalg =3D QCRYPTO_IV_GEN_ALGO_PLAIN64, .iv =3D (const uint8_t *)"\x01\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00", .niv =3D 16, @@ -74,7 +74,7 @@ struct QCryptoIVGenTestData { { "/crypto/ivgen/plain64/1f2e3d4c", .sector =3D 0x1f2e3d4cULL, - .ivalg =3D QCRYPTO_IVGEN_ALG_PLAIN64, + .ivalg =3D QCRYPTO_IV_GEN_ALGO_PLAIN64, .iv =3D (const uint8_t *)"\x4c\x3d\x2e\x1f\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00", .niv =3D 16, @@ -83,7 +83,7 @@ struct QCryptoIVGenTestData { { "/crypto/ivgen/plain64/1f2e3d4c5b6a7988", .sector =3D 0x1f2e3d4c5b6a7988ULL, - .ivalg =3D QCRYPTO_IVGEN_ALG_PLAIN64, + .ivalg =3D QCRYPTO_IV_GEN_ALGO_PLAIN64, .iv =3D (const uint8_t *)"\x88\x79\x6a\x5b\x4c\x3d\x2e\x1f" "\x00\x00\x00\x00\x00\x00\x00\x00", .niv =3D 16, @@ -92,7 +92,7 @@ struct QCryptoIVGenTestData { { "/crypto/ivgen/essiv/1", .sector =3D 0x1, - .ivalg =3D QCRYPTO_IVGEN_ALG_ESSIV, + .ivalg =3D QCRYPTO_IV_GEN_ALGO_ESSIV, .cipheralg =3D QCRYPTO_CIPHER_ALGO_AES_128, .hashalg =3D QCRYPTO_HASH_ALGO_SHA256, .key =3D (const uint8_t *)"\x00\x01\x02\x03\x04\x05\x06\x07" @@ -106,7 +106,7 @@ struct QCryptoIVGenTestData { { "/crypto/ivgen/essiv/1f2e3d4c", .sector =3D 0x1f2e3d4cULL, - .ivalg =3D QCRYPTO_IVGEN_ALG_ESSIV, + .ivalg =3D QCRYPTO_IV_GEN_ALGO_ESSIV, .cipheralg =3D QCRYPTO_CIPHER_ALGO_AES_128, .hashalg =3D QCRYPTO_HASH_ALGO_SHA256, .key =3D (const uint8_t *)"\x00\x01\x02\x03\x04\x05\x06\x07" @@ -120,7 +120,7 @@ struct QCryptoIVGenTestData { { "/crypto/ivgen/essiv/1f2e3d4c5b6a7988", .sector =3D 0x1f2e3d4c5b6a7988ULL, - .ivalg =3D QCRYPTO_IVGEN_ALG_ESSIV, + .ivalg =3D QCRYPTO_IV_GEN_ALGO_ESSIV, .cipheralg =3D QCRYPTO_CIPHER_ALGO_AES_128, .hashalg =3D QCRYPTO_HASH_ALGO_SHA256, .key =3D (const uint8_t *)"\x00\x01\x02\x03\x04\x05\x06\x07" @@ -166,7 +166,7 @@ int main(int argc, char **argv) size_t i; g_test_init(&argc, &argv, NULL); for (i =3D 0; i < G_N_ELEMENTS(test_data); i++) { - if (test_data[i].ivalg =3D=3D QCRYPTO_IVGEN_ALG_ESSIV && + if (test_data[i].ivalg =3D=3D QCRYPTO_IV_GEN_ALGO_ESSIV && !qcrypto_hash_supports(test_data[i].hashalg)) { continue; } --=20 2.46.0 From nobody Sun Nov 24 05:28:16 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1725986891; cv=none; d=zohomail.com; s=zohoarc; b=P0J2SuCPMujh7+R1rMGa9QG6LUdTEhhstkWD2oaTeT2psJZ/X2ckREsvkxioNCp9/nagBH3o6cDDuo0T1wX0DkWOLlug4KEFUbNG6sYMy4Y4MOICPQv5Z2qdilbMkroG0+2LlEa2jQBoZxp2a0o4QnLmGuJlyQUrbS2OiR6YRcE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1725986891; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=BPgIWJFDXw1X3s4ousUDlkeawfkmplLI8vxddj+tXTs=; b=UCWz9gbo4SsPe8wfM9CQ8DKSCol0hyUq7VBw7i9D0s784ansG+tNsSQ64J7CnRlsVLJIG4C/9L3uFSKRyEvWzWSyRdNxG8nmb+CNMTmW/XKZW75vG0tiUSOj7IlmdDggxLW6/2H9TFCITfNlY2q54Y9hKBtdRtDmWZMCiclqZkY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1725986891453932.8518240022925; Tue, 10 Sep 2024 09:48:11 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1so41k-00079U-TX; Tue, 10 Sep 2024 12:47:40 -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 1so41Z-0006nJ-L1 for qemu-devel@nongnu.org; Tue, 10 Sep 2024 12:47: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 1so41V-0007Z5-1k for qemu-devel@nongnu.org; Tue, 10 Sep 2024 12:47:29 -0400 Received: from mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-561-cSlpnjj7NnSS0oGVLzBofw-1; Tue, 10 Sep 2024 12:47:21 -0400 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id E4B2219560A2; Tue, 10 Sep 2024 16:47:19 +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 6B83D19560AB; Tue, 10 Sep 2024 16:47:19 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id A031121E682C; Tue, 10 Sep 2024 18:47:14 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1725986844; 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=BPgIWJFDXw1X3s4ousUDlkeawfkmplLI8vxddj+tXTs=; b=iUe0Swe5wZoDUGlzMrI/07tDvjZ7mxRSJ10G0IlP+NGGd++ehJR/VqGShkh5Uep0XvGR5A sZkpDD1gQHRweseEOzzt2YVlIf0IwxJlwxPbxps/H5QWE9lj36WsHB63WPMUuUlyVgAzB6 7SnFjMPk/PrleiGMaARK2/H9rH3rj/w= X-MC-Unique: cSlpnjj7NnSS0oGVLzBofw-1 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org, =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= Subject: [PULL 14/19] qapi/crypto: Rename QCryptoAkCipherAlgorithm to *Algo, and drop prefix Date: Tue, 10 Sep 2024 18:47:09 +0200 Message-ID: <20240910164714.1993531-15-armbru@redhat.com> In-Reply-To: <20240910164714.1993531-1-armbru@redhat.com> References: <20240910164714.1993531-1-armbru@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.145, 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, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1725986893505116600 QAPI's 'prefix' feature can make the connection between enumeration type and its constants less than obvious. It's best used with restraint. QCryptoAkCipherAlgorithm has a 'prefix' that overrides the generated enumeration constants' prefix to QCRYPTO_AKCIPHER_ALG. We could simply drop 'prefix', but then the prefix becomes QCRYPTO_AK_CIPHER_ALGORITHM, which is rather long. We could additionally rename the type to QCryptoAkCipherAlg, but I think the abbreviation "alg" is less than clear. Rename the type to QCryptoAkCipherAlgo instead. The prefix becomes QCRYPTO_AK_CIPHER_ALGO. Signed-off-by: Markus Armbruster Acked-by: Daniel P. Berrang=C3=A9 Message-ID: <20240904111836.3273842-15-armbru@redhat.com> --- qapi/crypto.json | 7 +++---- crypto/akcipherpriv.h | 2 +- backends/cryptodev-builtin.c | 4 ++-- backends/cryptodev-lkcf.c | 4 ++-- crypto/akcipher.c | 2 +- tests/bench/benchmark-crypto-akcipher.c | 2 +- tests/unit/test-crypto-akcipher.c | 10 +++++----- crypto/akcipher-gcrypt.c.inc | 4 ++-- crypto/akcipher-nettle.c.inc | 4 ++-- 9 files changed, 19 insertions(+), 20 deletions(-) diff --git a/qapi/crypto.json b/qapi/crypto.json index 3e6a7fb8e5..331d49ebb8 100644 --- a/qapi/crypto.json +++ b/qapi/crypto.json @@ -586,7 +586,7 @@ '*sanity-check': 'bool', '*passwordid': 'str' } } ## -# @QCryptoAkCipherAlgorithm: +# @QCryptoAkCipherAlgo: # # The supported algorithms for asymmetric encryption ciphers # @@ -594,8 +594,7 @@ # # Since: 7.1 ## -{ 'enum': 'QCryptoAkCipherAlgorithm', - 'prefix': 'QCRYPTO_AKCIPHER_ALG', +{ 'enum': 'QCryptoAkCipherAlgo', 'data': ['rsa']} =20 ## @@ -649,6 +648,6 @@ # Since: 7.1 ## { 'union': 'QCryptoAkCipherOptions', - 'base': { 'alg': 'QCryptoAkCipherAlgorithm' }, + 'base': { 'alg': 'QCryptoAkCipherAlgo' }, 'discriminator': 'alg', 'data': { 'rsa': 'QCryptoAkCipherOptionsRSA' }} diff --git a/crypto/akcipherpriv.h b/crypto/akcipherpriv.h index 739f639bcf..3b33e54f08 100644 --- a/crypto/akcipherpriv.h +++ b/crypto/akcipherpriv.h @@ -27,7 +27,7 @@ typedef struct QCryptoAkCipherDriver QCryptoAkCipherDriver; =20 struct QCryptoAkCipher { - QCryptoAkCipherAlgorithm alg; + QCryptoAkCipherAlgo alg; QCryptoAkCipherKeyType type; int max_plaintext_len; int max_ciphertext_len; diff --git a/backends/cryptodev-builtin.c b/backends/cryptodev-builtin.c index 2672755661..d8b64091b6 100644 --- a/backends/cryptodev-builtin.c +++ b/backends/cryptodev-builtin.c @@ -64,7 +64,7 @@ static void cryptodev_builtin_init_akcipher(CryptoDevBack= end *backend) { QCryptoAkCipherOptions opts; =20 - opts.alg =3D QCRYPTO_AKCIPHER_ALG_RSA; + opts.alg =3D QCRYPTO_AK_CIPHER_ALGO_RSA; opts.u.rsa.padding_alg =3D QCRYPTO_RSA_PADDING_ALG_RAW; if (qcrypto_akcipher_supports(&opts)) { backend->conf.crypto_services |=3D @@ -318,7 +318,7 @@ static int cryptodev_builtin_create_akcipher_session( =20 switch (sess_info->algo) { case VIRTIO_CRYPTO_AKCIPHER_RSA: - opts.alg =3D QCRYPTO_AKCIPHER_ALG_RSA; + opts.alg =3D QCRYPTO_AK_CIPHER_ALGO_RSA; if (cryptodev_builtin_set_rsa_options(sess_info->u.rsa.padding_alg= o, sess_info->u.rsa.hash_algo, &opts.u.rsa, errp) !=3D 0) { return -1; diff --git a/backends/cryptodev-lkcf.c b/backends/cryptodev-lkcf.c index 6e6012e716..6fb6e03d98 100644 --- a/backends/cryptodev-lkcf.c +++ b/backends/cryptodev-lkcf.c @@ -133,7 +133,7 @@ static int cryptodev_lkcf_set_op_desc(QCryptoAkCipherOp= tions *opts, Error **errp) { QCryptoAkCipherOptionsRSA *rsa_opt; - if (opts->alg !=3D QCRYPTO_AKCIPHER_ALG_RSA) { + if (opts->alg !=3D QCRYPTO_AK_CIPHER_ALGO_RSA) { error_setg(errp, "Unsupported alg: %u", opts->alg); return -1; } @@ -518,7 +518,7 @@ static int cryptodev_lkcf_create_asym_session( =20 switch (sess_info->algo) { case VIRTIO_CRYPTO_AKCIPHER_RSA: - sess->akcipher_opts.alg =3D QCRYPTO_AKCIPHER_ALG_RSA; + sess->akcipher_opts.alg =3D QCRYPTO_AK_CIPHER_ALGO_RSA; if (cryptodev_lkcf_set_rsa_opt( sess_info->u.rsa.padding_algo, sess_info->u.rsa.hash_algo, &sess->akcipher_opts.u.rsa, &local_error) !=3D 0) { diff --git a/crypto/akcipher.c b/crypto/akcipher.c index e4bbc6e5f1..0a0576b792 100644 --- a/crypto/akcipher.c +++ b/crypto/akcipher.c @@ -115,7 +115,7 @@ int qcrypto_akcipher_export_p8info(const QCryptoAkCiphe= rOptions *opts, Error **errp) { switch (opts->alg) { - case QCRYPTO_AKCIPHER_ALG_RSA: + case QCRYPTO_AK_CIPHER_ALGO_RSA: qcrypto_akcipher_rsakey_export_p8info(key, keylen, dst, dst_len); return 0; =20 diff --git a/tests/bench/benchmark-crypto-akcipher.c b/tests/bench/benchmar= k-crypto-akcipher.c index 0029972385..225e426bde 100644 --- a/tests/bench/benchmark-crypto-akcipher.c +++ b/tests/bench/benchmark-crypto-akcipher.c @@ -25,7 +25,7 @@ static QCryptoAkCipher *create_rsa_akcipher(const uint8_t= *priv_key, { QCryptoAkCipherOptions opt; =20 - opt.alg =3D QCRYPTO_AKCIPHER_ALG_RSA; + opt.alg =3D QCRYPTO_AK_CIPHER_ALGO_RSA; opt.u.rsa.padding_alg =3D padding; opt.u.rsa.hash_alg =3D hash; return qcrypto_akcipher_new(&opt, QCRYPTO_AK_CIPHER_KEY_TYPE_PRIVATE, diff --git a/tests/unit/test-crypto-akcipher.c b/tests/unit/test-crypto-akc= ipher.c index 86501f19ab..7dd86125c2 100644 --- a/tests/unit/test-crypto-akcipher.c +++ b/tests/unit/test-crypto-akcipher.c @@ -785,7 +785,7 @@ static QCryptoAkCipherTestData akcipher_test_data[] =3D= { { .path =3D "/crypto/akcipher/rsa1024-raw", .opt =3D { - .alg =3D QCRYPTO_AKCIPHER_ALG_RSA, + .alg =3D QCRYPTO_AK_CIPHER_ALGO_RSA, .u.rsa =3D { .padding_alg =3D QCRYPTO_RSA_PADDING_ALG_RAW, }, @@ -805,7 +805,7 @@ static QCryptoAkCipherTestData akcipher_test_data[] =3D= { { .path =3D "/crypto/akcipher/rsa1024-pkcs1", .opt =3D { - .alg =3D QCRYPTO_AKCIPHER_ALG_RSA, + .alg =3D QCRYPTO_AK_CIPHER_ALGO_RSA, .u.rsa =3D { .padding_alg =3D QCRYPTO_RSA_PADDING_ALG_PKCS1, .hash_alg =3D QCRYPTO_HASH_ALGO_SHA1, @@ -830,7 +830,7 @@ static QCryptoAkCipherTestData akcipher_test_data[] =3D= { { .path =3D "/crypto/akcipher/rsa2048-raw", .opt =3D { - .alg =3D QCRYPTO_AKCIPHER_ALG_RSA, + .alg =3D QCRYPTO_AK_CIPHER_ALGO_RSA, .u.rsa =3D { .padding_alg =3D QCRYPTO_RSA_PADDING_ALG_RAW, }, @@ -850,7 +850,7 @@ static QCryptoAkCipherTestData akcipher_test_data[] =3D= { { .path =3D "/crypto/akcipher/rsa2048-pkcs1", .opt =3D { - .alg =3D QCRYPTO_AKCIPHER_ALG_RSA, + .alg =3D QCRYPTO_AK_CIPHER_ALGO_RSA, .u.rsa =3D { .padding_alg =3D QCRYPTO_RSA_PADDING_ALG_PKCS1, .hash_alg =3D QCRYPTO_HASH_ALGO_SHA1, @@ -944,7 +944,7 @@ static void test_rsakey(const void *opaque) { const QCryptoRSAKeyTestData *data =3D (const QCryptoRSAKeyTestData *)o= paque; QCryptoAkCipherOptions opt =3D { - .alg =3D QCRYPTO_AKCIPHER_ALG_RSA, + .alg =3D QCRYPTO_AK_CIPHER_ALGO_RSA, .u.rsa =3D { .padding_alg =3D QCRYPTO_RSA_PADDING_ALG_PKCS1, .hash_alg =3D QCRYPTO_HASH_ALGO_SHA1, diff --git a/crypto/akcipher-gcrypt.c.inc b/crypto/akcipher-gcrypt.c.inc index 2c81de97de..8f1c2b8143 100644 --- a/crypto/akcipher-gcrypt.c.inc +++ b/crypto/akcipher-gcrypt.c.inc @@ -59,7 +59,7 @@ QCryptoAkCipher *qcrypto_akcipher_new(const QCryptoAkCiph= erOptions *opts, Error **errp) { switch (opts->alg) { - case QCRYPTO_AKCIPHER_ALG_RSA: + case QCRYPTO_AK_CIPHER_ALGO_RSA: return (QCryptoAkCipher *)qcrypto_gcrypt_rsa_new( &opts->u.rsa, type, key, keylen, errp); =20 @@ -568,7 +568,7 @@ error: bool qcrypto_akcipher_supports(QCryptoAkCipherOptions *opts) { switch (opts->alg) { - case QCRYPTO_AKCIPHER_ALG_RSA: + case QCRYPTO_AK_CIPHER_ALGO_RSA: switch (opts->u.rsa.padding_alg) { case QCRYPTO_RSA_PADDING_ALG_RAW: return true; diff --git a/crypto/akcipher-nettle.c.inc b/crypto/akcipher-nettle.c.inc index 37a579fbd9..21f27f8286 100644 --- a/crypto/akcipher-nettle.c.inc +++ b/crypto/akcipher-nettle.c.inc @@ -61,7 +61,7 @@ QCryptoAkCipher *qcrypto_akcipher_new(const QCryptoAkCiph= erOptions *opts, Error **errp) { switch (opts->alg) { - case QCRYPTO_AKCIPHER_ALG_RSA: + case QCRYPTO_AK_CIPHER_ALGO_RSA: return qcrypto_nettle_rsa_new(&opts->u.rsa, type, key, keylen, err= p); =20 default: @@ -425,7 +425,7 @@ error: bool qcrypto_akcipher_supports(QCryptoAkCipherOptions *opts) { switch (opts->alg) { - case QCRYPTO_AKCIPHER_ALG_RSA: + case QCRYPTO_AK_CIPHER_ALGO_RSA: switch (opts->u.rsa.padding_alg) { case QCRYPTO_RSA_PADDING_ALG_PKCS1: switch (opts->u.rsa.hash_alg) { --=20 2.46.0 From nobody Sun Nov 24 05:28:16 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1725987003; cv=none; d=zohomail.com; s=zohoarc; b=fWzfvCyjt5RATvrHki4xzn0/mOfuA31JvKDbYfbZPDlK4JElCjQGjQQfzzgrz6d7fy5pzByarPDs/GENhEgdPqXcQZRw+gw2i7DZoZ/7EW0o55nA/+E1aYJN3YXjfe8+v8Te6Moad+NWQmJUzbOqzwKjtoo9v5YbkLPhr0oVPSA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1725987003; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=1rXzMcCbj8yDCnKP3Vuyl5AEDmCfQMlVvi0hKgKsKgU=; b=LWxM/vWIAS+fpFXlo4SdvBP28/W4Bj9q5xNVV9XjYi+Pt5nTqMz01KshGUnGUEPnr/Ic20WzhVOYhl7SZz/JBaOeJERsbXIe6g8KqsBkoDjUNNz+zSSgwu5R8/zCDqHUPJJik2I+RJqh8MpCDnaP/teejuC5ZtHi+XeVRDAH5J4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1725987003852905.6620408442559; Tue, 10 Sep 2024 09:50:03 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1so41m-0007Dw-Ff; Tue, 10 Sep 2024 12:47:42 -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 1so41c-0006s5-Ga for qemu-devel@nongnu.org; Tue, 10 Sep 2024 12:47:34 -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 1so41W-0007a9-PL for qemu-devel@nongnu.org; Tue, 10 Sep 2024 12:47:32 -0400 Received: from mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-221-rKEGVqq5PsmLcOzHjqk_9w-1; Tue, 10 Sep 2024 12:47:23 -0400 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id EBADA19560B5; Tue, 10 Sep 2024 16:47:21 +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 56A6B30001A1; Tue, 10 Sep 2024 16:47:21 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id A36ED21E682D; Tue, 10 Sep 2024 18:47:14 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1725986846; 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=1rXzMcCbj8yDCnKP3Vuyl5AEDmCfQMlVvi0hKgKsKgU=; b=anqlyRA/mYiyXcgXkdC7iQX8LiQg06yH4lEIFDlwaOo093XqcVlVh/q+s9yq38nPtjJD+Y jkROK/owqdOIy27OsfUn4dgEM+XmJtDun2H+q60ot11Q4B6KdeNwHeXyG3bH6fH6FEXy1t sGcPdtLPO1U9M3gfE6AH3zZjm+AOqlg= X-MC-Unique: rKEGVqq5PsmLcOzHjqk_9w-1 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org, =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= Subject: [PULL 15/19] qapi/crypto: Rename QCryptoRSAPaddingAlgorithm to *Algo, and drop prefix Date: Tue, 10 Sep 2024 18:47:10 +0200 Message-ID: <20240910164714.1993531-16-armbru@redhat.com> In-Reply-To: <20240910164714.1993531-1-armbru@redhat.com> References: <20240910164714.1993531-1-armbru@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.145, 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, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1725987006079116600 QAPI's 'prefix' feature can make the connection between enumeration type and its constants less than obvious. It's best used with restraint. QCryptoRSAPaddingAlgorithm has a 'prefix' that overrides the generated enumeration constants' prefix to QCRYPTO_RSA_PADDING_ALG. We could simply drop 'prefix', but then the prefix becomes QCRYPTO_RSA_PADDING_ALGORITHM, which is rather long. We could additionally rename the type to QCryptoRSAPaddingAlg, but I think the abbreviation "alg" is less than clear. Rename the type to QCryptoRSAPaddingAlgo instead. The prefix becomes QCRYPTO_RSA_PADDING_ALGO. Signed-off-by: Markus Armbruster Acked-by: Daniel P. Berrang=C3=A9 Message-ID: <20240904111836.3273842-16-armbru@redhat.com> --- qapi/crypto.json | 9 ++++----- backends/cryptodev-builtin.c | 6 +++--- backends/cryptodev-lkcf.c | 10 +++++----- tests/bench/benchmark-crypto-akcipher.c | 12 ++++++------ tests/unit/test-crypto-akcipher.c | 10 +++++----- crypto/akcipher-gcrypt.c.inc | 18 +++++++++--------- crypto/akcipher-nettle.c.inc | 18 +++++++++--------- 7 files changed, 41 insertions(+), 42 deletions(-) diff --git a/qapi/crypto.json b/qapi/crypto.json index 331d49ebb8..867b09d322 100644 --- a/qapi/crypto.json +++ b/qapi/crypto.json @@ -608,7 +608,7 @@ 'data': ['public', 'private']} =20 ## -# @QCryptoRSAPaddingAlgorithm: +# @QCryptoRSAPaddingAlgo: # # The padding algorithm for RSA. # @@ -618,8 +618,7 @@ # # Since: 7.1 ## -{ 'enum': 'QCryptoRSAPaddingAlgorithm', - 'prefix': 'QCRYPTO_RSA_PADDING_ALG', +{ 'enum': 'QCryptoRSAPaddingAlgo', 'data': ['raw', 'pkcs1']} =20 ## @@ -629,13 +628,13 @@ # # @hash-alg: QCryptoHashAlgo # -# @padding-alg: QCryptoRSAPaddingAlgorithm +# @padding-alg: QCryptoRSAPaddingAlgo # # Since: 7.1 ## { 'struct': 'QCryptoAkCipherOptionsRSA', 'data': { 'hash-alg':'QCryptoHashAlgo', - 'padding-alg': 'QCryptoRSAPaddingAlgorithm'}} + 'padding-alg': 'QCryptoRSAPaddingAlgo'}} =20 ## # @QCryptoAkCipherOptions: diff --git a/backends/cryptodev-builtin.c b/backends/cryptodev-builtin.c index d8b64091b6..6f3990481b 100644 --- a/backends/cryptodev-builtin.c +++ b/backends/cryptodev-builtin.c @@ -65,7 +65,7 @@ static void cryptodev_builtin_init_akcipher(CryptoDevBack= end *backend) QCryptoAkCipherOptions opts; =20 opts.alg =3D QCRYPTO_AK_CIPHER_ALGO_RSA; - opts.u.rsa.padding_alg =3D QCRYPTO_RSA_PADDING_ALG_RAW; + opts.u.rsa.padding_alg =3D QCRYPTO_RSA_PADDING_ALGO_RAW; if (qcrypto_akcipher_supports(&opts)) { backend->conf.crypto_services |=3D (1u << QCRYPTODEV_BACKEND_SERVICE_AKCIPHER); @@ -200,12 +200,12 @@ static int cryptodev_builtin_set_rsa_options( return -1; } opt->hash_alg =3D hash_alg; - opt->padding_alg =3D QCRYPTO_RSA_PADDING_ALG_PKCS1; + opt->padding_alg =3D QCRYPTO_RSA_PADDING_ALGO_PKCS1; return 0; } =20 if (virtio_padding_algo =3D=3D VIRTIO_CRYPTO_RSA_RAW_PADDING) { - opt->padding_alg =3D QCRYPTO_RSA_PADDING_ALG_RAW; + opt->padding_alg =3D QCRYPTO_RSA_PADDING_ALGO_RAW; return 0; } =20 diff --git a/backends/cryptodev-lkcf.c b/backends/cryptodev-lkcf.c index 6fb6e03d98..fde32950f6 100644 --- a/backends/cryptodev-lkcf.c +++ b/backends/cryptodev-lkcf.c @@ -139,14 +139,14 @@ static int cryptodev_lkcf_set_op_desc(QCryptoAkCipher= Options *opts, } =20 rsa_opt =3D &opts->u.rsa; - if (rsa_opt->padding_alg =3D=3D QCRYPTO_RSA_PADDING_ALG_PKCS1) { + if (rsa_opt->padding_alg =3D=3D QCRYPTO_RSA_PADDING_ALGO_PKCS1) { snprintf(key_desc, desc_len, "enc=3D%s hash=3D%s", - QCryptoRSAPaddingAlgorithm_str(rsa_opt->padding_alg), + QCryptoRSAPaddingAlgo_str(rsa_opt->padding_alg), QCryptoHashAlgo_str(rsa_opt->hash_alg)); =20 } else { snprintf(key_desc, desc_len, "enc=3D%s", - QCryptoRSAPaddingAlgorithm_str(rsa_opt->padding_alg)); + QCryptoRSAPaddingAlgo_str(rsa_opt->padding_alg)); } return 0; } @@ -157,7 +157,7 @@ static int cryptodev_lkcf_set_rsa_opt(int virtio_paddin= g_alg, Error **errp) { if (virtio_padding_alg =3D=3D VIRTIO_CRYPTO_RSA_PKCS1_PADDING) { - opt->padding_alg =3D QCRYPTO_RSA_PADDING_ALG_PKCS1; + opt->padding_alg =3D QCRYPTO_RSA_PADDING_ALGO_PKCS1; =20 switch (virtio_hash_alg) { case VIRTIO_CRYPTO_RSA_MD5: @@ -184,7 +184,7 @@ static int cryptodev_lkcf_set_rsa_opt(int virtio_paddin= g_alg, } =20 if (virtio_padding_alg =3D=3D VIRTIO_CRYPTO_RSA_RAW_PADDING) { - opt->padding_alg =3D QCRYPTO_RSA_PADDING_ALG_RAW; + opt->padding_alg =3D QCRYPTO_RSA_PADDING_ALGO_RAW; return 0; } =20 diff --git a/tests/bench/benchmark-crypto-akcipher.c b/tests/bench/benchmar= k-crypto-akcipher.c index 225e426bde..750c7e89ee 100644 --- a/tests/bench/benchmark-crypto-akcipher.c +++ b/tests/bench/benchmark-crypto-akcipher.c @@ -20,7 +20,7 @@ =20 static QCryptoAkCipher *create_rsa_akcipher(const uint8_t *priv_key, size_t keylen, - QCryptoRSAPaddingAlgorithm pad= ding, + QCryptoRSAPaddingAlgo padding, QCryptoHashAlgo hash) { QCryptoAkCipherOptions opt; @@ -39,7 +39,7 @@ static void test_rsa_speed(const uint8_t *priv_key, size_= t keylen, #define SHA1_DGST_LEN 20 #define SIGN_TIMES 10000 #define VERIFY_TIMES 100000 -#define PADDING QCRYPTO_RSA_PADDING_ALG_PKCS1 +#define PADDING QCRYPTO_RSA_PADDING_ALGO_PKCS1 #define HASH QCRYPTO_HASH_ALGO_SHA1 =20 g_autoptr(QCryptoAkCipher) rsa =3D @@ -53,7 +53,7 @@ static void test_rsa_speed(const uint8_t *priv_key, size_= t keylen, signature =3D g_new0(uint8_t, key_size / BYTE); =20 g_test_message("benchmark rsa%zu (%s-%s) sign...", key_size, - QCryptoRSAPaddingAlgorithm_str(PADDING), + QCryptoRSAPaddingAlgo_str(PADDING), QCryptoHashAlgo_str(HASH)); g_test_timer_start(); for (count =3D 0; count < SIGN_TIMES; ++count) { @@ -64,13 +64,13 @@ static void test_rsa_speed(const uint8_t *priv_key, siz= e_t keylen, g_test_timer_elapsed(); g_test_message("rsa%zu (%s-%s) sign %zu times in %.2f seconds," " %.2f times/sec ", - key_size, QCryptoRSAPaddingAlgorithm_str(PADDING), + key_size, QCryptoRSAPaddingAlgo_str(PADDING), QCryptoHashAlgo_str(HASH), count, g_test_timer_last(), (double)count / g_test_timer_last()); =20 g_test_message("benchmark rsa%zu (%s-%s) verification...", key_size, - QCryptoRSAPaddingAlgorithm_str(PADDING), + QCryptoRSAPaddingAlgo_str(PADDING), QCryptoHashAlgo_str(HASH)); g_test_timer_start(); for (count =3D 0; count < VERIFY_TIMES; ++count) { @@ -81,7 +81,7 @@ static void test_rsa_speed(const uint8_t *priv_key, size_= t keylen, g_test_timer_elapsed(); g_test_message("rsa%zu (%s-%s) verify %zu times in %.2f seconds," " %.2f times/sec ", - key_size, QCryptoRSAPaddingAlgorithm_str(PADDING), + key_size, QCryptoRSAPaddingAlgo_str(PADDING), QCryptoHashAlgo_str(HASH), count, g_test_timer_last(), (double)count / g_test_timer_last()); diff --git a/tests/unit/test-crypto-akcipher.c b/tests/unit/test-crypto-akc= ipher.c index 7dd86125c2..53c2211ba8 100644 --- a/tests/unit/test-crypto-akcipher.c +++ b/tests/unit/test-crypto-akcipher.c @@ -787,7 +787,7 @@ static QCryptoAkCipherTestData akcipher_test_data[] =3D= { .opt =3D { .alg =3D QCRYPTO_AK_CIPHER_ALGO_RSA, .u.rsa =3D { - .padding_alg =3D QCRYPTO_RSA_PADDING_ALG_RAW, + .padding_alg =3D QCRYPTO_RSA_PADDING_ALGO_RAW, }, }, .pub_key =3D rsa1024_public_key, @@ -807,7 +807,7 @@ static QCryptoAkCipherTestData akcipher_test_data[] =3D= { .opt =3D { .alg =3D QCRYPTO_AK_CIPHER_ALGO_RSA, .u.rsa =3D { - .padding_alg =3D QCRYPTO_RSA_PADDING_ALG_PKCS1, + .padding_alg =3D QCRYPTO_RSA_PADDING_ALGO_PKCS1, .hash_alg =3D QCRYPTO_HASH_ALGO_SHA1, }, }, @@ -832,7 +832,7 @@ static QCryptoAkCipherTestData akcipher_test_data[] =3D= { .opt =3D { .alg =3D QCRYPTO_AK_CIPHER_ALGO_RSA, .u.rsa =3D { - .padding_alg =3D QCRYPTO_RSA_PADDING_ALG_RAW, + .padding_alg =3D QCRYPTO_RSA_PADDING_ALGO_RAW, }, }, .pub_key =3D rsa2048_public_key, @@ -852,7 +852,7 @@ static QCryptoAkCipherTestData akcipher_test_data[] =3D= { .opt =3D { .alg =3D QCRYPTO_AK_CIPHER_ALGO_RSA, .u.rsa =3D { - .padding_alg =3D QCRYPTO_RSA_PADDING_ALG_PKCS1, + .padding_alg =3D QCRYPTO_RSA_PADDING_ALGO_PKCS1, .hash_alg =3D QCRYPTO_HASH_ALGO_SHA1, }, }, @@ -946,7 +946,7 @@ static void test_rsakey(const void *opaque) QCryptoAkCipherOptions opt =3D { .alg =3D QCRYPTO_AK_CIPHER_ALGO_RSA, .u.rsa =3D { - .padding_alg =3D QCRYPTO_RSA_PADDING_ALG_PKCS1, + .padding_alg =3D QCRYPTO_RSA_PADDING_ALGO_PKCS1, .hash_alg =3D QCRYPTO_HASH_ALGO_SHA1, } }; diff --git a/crypto/akcipher-gcrypt.c.inc b/crypto/akcipher-gcrypt.c.inc index 8f1c2b8143..5a880f6638 100644 --- a/crypto/akcipher-gcrypt.c.inc +++ b/crypto/akcipher-gcrypt.c.inc @@ -32,7 +32,7 @@ typedef struct QCryptoGcryptRSA { QCryptoAkCipher akcipher; gcry_sexp_t key; - QCryptoRSAPaddingAlgorithm padding_alg; + QCryptoRSAPaddingAlgo padding_alg; QCryptoHashAlgo hash_alg; } QCryptoGcryptRSA; =20 @@ -241,7 +241,7 @@ static int qcrypto_gcrypt_rsa_encrypt(QCryptoAkCipher *= akcipher, =20 err =3D gcry_sexp_build(&data_sexp, NULL, "(data (flags %s) (value %b))", - QCryptoRSAPaddingAlgorithm_str(rsa->padding_alg), + QCryptoRSAPaddingAlgo_str(rsa->padding_alg), in_len, in); if (gcry_err_code(err) !=3D 0) { error_setg(errp, "Failed to build plaintext: %s/%s", @@ -263,7 +263,7 @@ static int qcrypto_gcrypt_rsa_encrypt(QCryptoAkCipher *= akcipher, goto cleanup; } =20 - if (rsa->padding_alg =3D=3D QCRYPTO_RSA_PADDING_ALG_RAW) { + if (rsa->padding_alg =3D=3D QCRYPTO_RSA_PADDING_ALGO_RAW) { cipher_mpi =3D gcry_sexp_nth_mpi(cipher_sexp_item, 1, GCRYMPI_FMT_= USG); if (!cipher_mpi) { error_setg(errp, "Invalid ciphertext result"); @@ -332,7 +332,7 @@ static int qcrypto_gcrypt_rsa_decrypt(QCryptoAkCipher *= akcipher, =20 err =3D gcry_sexp_build(&cipher_sexp, NULL, "(enc-val (flags %s) (rsa (a %b) ))", - QCryptoRSAPaddingAlgorithm_str(rsa->padding_alg), + QCryptoRSAPaddingAlgo_str(rsa->padding_alg), in_len, in); if (gcry_err_code(err) !=3D 0) { error_setg(errp, "Failed to build ciphertext: %s/%s", @@ -348,7 +348,7 @@ static int qcrypto_gcrypt_rsa_decrypt(QCryptoAkCipher *= akcipher, } =20 /* S-expression of plaintext: (value plaintext) */ - if (rsa->padding_alg =3D=3D QCRYPTO_RSA_PADDING_ALG_RAW) { + if (rsa->padding_alg =3D=3D QCRYPTO_RSA_PADDING_ALGO_RAW) { data_mpi =3D gcry_sexp_nth_mpi(data_sexp, 1, GCRYMPI_FMT_USG); if (!data_mpi) { error_setg(errp, "Invalid plaintext result"); @@ -410,7 +410,7 @@ static int qcrypto_gcrypt_rsa_sign(QCryptoAkCipher *akc= ipher, return ret; } =20 - if (rsa->padding_alg !=3D QCRYPTO_RSA_PADDING_ALG_PKCS1) { + if (rsa->padding_alg !=3D QCRYPTO_RSA_PADDING_ALGO_PKCS1) { error_setg(errp, "Invalid padding %u", rsa->padding_alg); return ret; } @@ -482,7 +482,7 @@ static int qcrypto_gcrypt_rsa_verify(QCryptoAkCipher *a= kcipher, return ret; } =20 - if (rsa->padding_alg !=3D QCRYPTO_RSA_PADDING_ALG_PKCS1) { + if (rsa->padding_alg !=3D QCRYPTO_RSA_PADDING_ALGO_PKCS1) { error_setg(errp, "Invalid padding %u", rsa->padding_alg); return ret; } @@ -570,10 +570,10 @@ bool qcrypto_akcipher_supports(QCryptoAkCipherOptions= *opts) switch (opts->alg) { case QCRYPTO_AK_CIPHER_ALGO_RSA: switch (opts->u.rsa.padding_alg) { - case QCRYPTO_RSA_PADDING_ALG_RAW: + case QCRYPTO_RSA_PADDING_ALGO_RAW: return true; =20 - case QCRYPTO_RSA_PADDING_ALG_PKCS1: + case QCRYPTO_RSA_PADDING_ALGO_PKCS1: switch (opts->u.rsa.hash_alg) { case QCRYPTO_HASH_ALGO_MD5: case QCRYPTO_HASH_ALGO_SHA1: diff --git a/crypto/akcipher-nettle.c.inc b/crypto/akcipher-nettle.c.inc index 21f27f8286..1720f84362 100644 --- a/crypto/akcipher-nettle.c.inc +++ b/crypto/akcipher-nettle.c.inc @@ -33,7 +33,7 @@ typedef struct QCryptoNettleRSA { QCryptoAkCipher akcipher; struct rsa_public_key pub; struct rsa_private_key priv; - QCryptoRSAPaddingAlgorithm padding_alg; + QCryptoRSAPaddingAlgo padding_alg; QCryptoHashAlgo hash_alg; } QCryptoNettleRSA; =20 @@ -184,11 +184,11 @@ static int qcrypto_nettle_rsa_encrypt(QCryptoAkCipher= *akcipher, =20 /* Nettle do not support RSA encryption without any padding */ switch (rsa->padding_alg) { - case QCRYPTO_RSA_PADDING_ALG_RAW: + case QCRYPTO_RSA_PADDING_ALGO_RAW: error_setg(errp, "RSA with raw padding is not supported"); break; =20 - case QCRYPTO_RSA_PADDING_ALG_PKCS1: + case QCRYPTO_RSA_PADDING_ALGO_PKCS1: mpz_init(c); if (rsa_encrypt(&rsa->pub, NULL, wrap_nettle_random_func, data_len, (uint8_t *)data, c) !=3D 1) { @@ -223,11 +223,11 @@ static int qcrypto_nettle_rsa_decrypt(QCryptoAkCipher= *akcipher, } =20 switch (rsa->padding_alg) { - case QCRYPTO_RSA_PADDING_ALG_RAW: + case QCRYPTO_RSA_PADDING_ALGO_RAW: error_setg(errp, "RSA with raw padding is not supported"); break; =20 - case QCRYPTO_RSA_PADDING_ALG_PKCS1: + case QCRYPTO_RSA_PADDING_ALGO_PKCS1: nettle_mpz_init_set_str_256_u(c, enc_len, enc); if (!rsa_decrypt(&rsa->priv, &data_len, (uint8_t *)data, c)) { error_setg(errp, "Failed to decrypt"); @@ -257,7 +257,7 @@ static int qcrypto_nettle_rsa_sign(QCryptoAkCipher *akc= ipher, * The RSA algorithm cannot be used for signature/verification * without padding. */ - if (rsa->padding_alg =3D=3D QCRYPTO_RSA_PADDING_ALG_RAW) { + if (rsa->padding_alg =3D=3D QCRYPTO_RSA_PADDING_ALGO_RAW) { error_setg(errp, "Try to make signature without padding"); return ret; } @@ -324,7 +324,7 @@ static int qcrypto_nettle_rsa_verify(QCryptoAkCipher *a= kcipher, * The RSA algorithm cannot be used for signature/verification * without padding. */ - if (rsa->padding_alg =3D=3D QCRYPTO_RSA_PADDING_ALG_RAW) { + if (rsa->padding_alg =3D=3D QCRYPTO_RSA_PADDING_ALGO_RAW) { error_setg(errp, "Try to verify signature without padding"); return ret; } @@ -427,7 +427,7 @@ bool qcrypto_akcipher_supports(QCryptoAkCipherOptions *= opts) switch (opts->alg) { case QCRYPTO_AK_CIPHER_ALGO_RSA: switch (opts->u.rsa.padding_alg) { - case QCRYPTO_RSA_PADDING_ALG_PKCS1: + case QCRYPTO_RSA_PADDING_ALGO_PKCS1: switch (opts->u.rsa.hash_alg) { case QCRYPTO_HASH_ALGO_MD5: case QCRYPTO_HASH_ALGO_SHA1: @@ -439,7 +439,7 @@ bool qcrypto_akcipher_supports(QCryptoAkCipherOptions *= opts) return false; } =20 - case QCRYPTO_RSA_PADDING_ALG_RAW: + case QCRYPTO_RSA_PADDING_ALGO_RAW: default: return false; } --=20 2.46.0 From nobody Sun Nov 24 05:28:16 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1725987003; cv=none; d=zohomail.com; s=zohoarc; b=BlcFuWNTtqmmv5TkJgocDP29zeMWHaqX41IZgS16JeMD8RAPjYeHFrJnRwDSWJlE9X8FOIp7gUkfGGUgQiJ/LoWCgkcZhBwjWUBKW9igtOr3NBjYIr08dZHP5MIIepYj7HkojaYxpydvxadVnNHVo2/pdyqffmeCxNsNxWUixLU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1725987003; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=vRYYtntswjaQMtqf/VLLPL1q7rDvK6d2rmfKXxnrSmI=; b=emETtMYUWpiMDKzYmsJxYAX68SD2jAPCohZi69Qj4FyDWDzJ39gtjdqa1WErVCLuINm7BBnSya5YgEE1IbwkRg1m3cSeD3WPcC9OJabU5j9WtnO7cI7rcQBZCX8mMLGoHwruyQEVqcLuHhUSSZC5jkmsoIK0Az4ksCpnD2IiEX8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 172598700326533.317594050047546; Tue, 10 Sep 2024 09:50:03 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1so41n-0007KD-NT; Tue, 10 Sep 2024 12:47:43 -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 1so41Z-0006mH-7M for qemu-devel@nongnu.org; Tue, 10 Sep 2024 12:47:29 -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 1so41V-0007ZC-1Z for qemu-devel@nongnu.org; Tue, 10 Sep 2024 12:47:28 -0400 Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-444-sqJXt8ksOpGfWyd4eVYHWQ-1; Tue, 10 Sep 2024 12:47:23 -0400 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 341CB1955BCD; Tue, 10 Sep 2024 16:47:22 +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 928ED19560A3; Tue, 10 Sep 2024 16:47:21 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id A66B121E682E; Tue, 10 Sep 2024 18:47:14 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1725986844; 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=vRYYtntswjaQMtqf/VLLPL1q7rDvK6d2rmfKXxnrSmI=; b=LNJWn/yTv+R1bNc79i1/UthsDND7SPW3xwBSk4AnEfiYbJ/PK2pzMchyg3MbhOHsKEWJvJ z9GEzwpmtTbtT5K0qtQNgrtDjUShL/5DH0OZS4dUAn84d8rxqiOb8bg8SA4CeT3vfcOGSi jQxKvrglQZGO4N88p0YO/jvPpPVW3Jc= X-MC-Unique: sqJXt8ksOpGfWyd4eVYHWQ-1 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org, =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= Subject: [PULL 16/19] qapi/crypto: Rename QCryptoAFAlg to QCryptoAFAlgo Date: Tue, 10 Sep 2024 18:47:11 +0200 Message-ID: <20240910164714.1993531-17-armbru@redhat.com> In-Reply-To: <20240910164714.1993531-1-armbru@redhat.com> References: <20240910164714.1993531-1-armbru@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.145, 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, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1725987004051116600 For consistency with other types names *Algo. Signed-off-by: Markus Armbruster Acked-by: Daniel P. Berrang=C3=A9 Message-ID: <20240904111836.3273842-17-armbru@redhat.com> --- crypto/afalgpriv.h | 14 +++++++------- crypto/hmacpriv.h | 2 +- crypto/afalg.c | 8 ++++---- crypto/cipher-afalg.c | 12 ++++++------ crypto/hash-afalg.c | 14 +++++++------- 5 files changed, 25 insertions(+), 25 deletions(-) diff --git a/crypto/afalgpriv.h b/crypto/afalgpriv.h index 5a2393f1b7..3fdcc0f831 100644 --- a/crypto/afalgpriv.h +++ b/crypto/afalgpriv.h @@ -30,9 +30,9 @@ #define ALG_OPTYPE_LEN 4 #define ALG_MSGIV_LEN(len) (sizeof(struct af_alg_iv) + (len)) =20 -typedef struct QCryptoAFAlg QCryptoAFAlg; +typedef struct QCryptoAFAlgo QCryptoAFAlgo; =20 -struct QCryptoAFAlg { +struct QCryptoAFAlgo { QCryptoCipher base; =20 int tfmfd; @@ -46,22 +46,22 @@ struct QCryptoAFAlg { * @type: the type of crypto operation * @name: the name of crypto operation * - * Allocate a QCryptoAFAlg object and bind itself to + * Allocate a QCryptoAFAlgo object and bind itself to * a AF_ALG socket. * * Returns: - * a new QCryptoAFAlg object, or NULL in error. + * a new QCryptoAFAlgo object, or NULL in error. */ -QCryptoAFAlg * +QCryptoAFAlgo * qcrypto_afalg_comm_alloc(const char *type, const char *name, Error **errp); =20 /** * afalg_comm_free: - * @afalg: the QCryptoAFAlg object + * @afalg: the QCryptoAFAlgo object * * Free the @afalg. */ -void qcrypto_afalg_comm_free(QCryptoAFAlg *afalg); +void qcrypto_afalg_comm_free(QCryptoAFAlgo *afalg); =20 #endif diff --git a/crypto/hmacpriv.h b/crypto/hmacpriv.h index bd4c498c62..f339596bd9 100644 --- a/crypto/hmacpriv.h +++ b/crypto/hmacpriv.h @@ -37,7 +37,7 @@ extern QCryptoHmacDriver qcrypto_hmac_lib_driver; =20 #include "afalgpriv.h" =20 -QCryptoAFAlg *qcrypto_afalg_hmac_ctx_new(QCryptoHashAlgo alg, +QCryptoAFAlgo *qcrypto_afalg_hmac_ctx_new(QCryptoHashAlgo alg, const uint8_t *key, size_t nkey, Error **errp); extern QCryptoHmacDriver qcrypto_hmac_afalg_driver; diff --git a/crypto/afalg.c b/crypto/afalg.c index 52a491dbb5..246d0679d4 100644 --- a/crypto/afalg.c +++ b/crypto/afalg.c @@ -66,13 +66,13 @@ qcrypto_afalg_socket_bind(const char *type, const char = *name, return sbind; } =20 -QCryptoAFAlg * +QCryptoAFAlgo * qcrypto_afalg_comm_alloc(const char *type, const char *name, Error **errp) { - QCryptoAFAlg *afalg; + QCryptoAFAlgo *afalg; =20 - afalg =3D g_new0(QCryptoAFAlg, 1); + afalg =3D g_new0(QCryptoAFAlgo, 1); /* initialize crypto API socket */ afalg->opfd =3D -1; afalg->tfmfd =3D qcrypto_afalg_socket_bind(type, name, errp); @@ -93,7 +93,7 @@ error: return NULL; } =20 -void qcrypto_afalg_comm_free(QCryptoAFAlg *afalg) +void qcrypto_afalg_comm_free(QCryptoAFAlgo *afalg) { if (!afalg) { return; diff --git a/crypto/cipher-afalg.c b/crypto/cipher-afalg.c index c08eb7a39b..4980d419c4 100644 --- a/crypto/cipher-afalg.c +++ b/crypto/cipher-afalg.c @@ -65,7 +65,7 @@ qcrypto_afalg_cipher_ctx_new(QCryptoCipherAlgo alg, const uint8_t *key, size_t nkey, Error **errp) { - QCryptoAFAlg *afalg; + QCryptoAFAlgo *afalg; size_t expect_niv; char *name; =20 @@ -119,7 +119,7 @@ qcrypto_afalg_cipher_setiv(QCryptoCipher *cipher, const uint8_t *iv, size_t niv, Error **errp) { - QCryptoAFAlg *afalg =3D container_of(cipher, QCryptoAFAlg, base); + QCryptoAFAlgo *afalg =3D container_of(cipher, QCryptoAFAlgo, base); struct af_alg_iv *alg_iv; size_t expect_niv; =20 @@ -143,7 +143,7 @@ qcrypto_afalg_cipher_setiv(QCryptoCipher *cipher, } =20 static int -qcrypto_afalg_cipher_op(QCryptoAFAlg *afalg, +qcrypto_afalg_cipher_op(QCryptoAFAlgo *afalg, const void *in, void *out, size_t len, bool do_encrypt, Error **errp) @@ -202,7 +202,7 @@ qcrypto_afalg_cipher_encrypt(QCryptoCipher *cipher, const void *in, void *out, size_t len, Error **errp) { - QCryptoAFAlg *afalg =3D container_of(cipher, QCryptoAFAlg, base); + QCryptoAFAlgo *afalg =3D container_of(cipher, QCryptoAFAlgo, base); =20 return qcrypto_afalg_cipher_op(afalg, in, out, len, true, errp); } @@ -212,14 +212,14 @@ qcrypto_afalg_cipher_decrypt(QCryptoCipher *cipher, const void *in, void *out, size_t len, Error **errp) { - QCryptoAFAlg *afalg =3D container_of(cipher, QCryptoAFAlg, base); + QCryptoAFAlgo *afalg =3D container_of(cipher, QCryptoAFAlgo, base); =20 return qcrypto_afalg_cipher_op(afalg, in, out, len, false, errp); } =20 static void qcrypto_afalg_comm_ctx_free(QCryptoCipher *cipher) { - QCryptoAFAlg *afalg =3D container_of(cipher, QCryptoAFAlg, base); + QCryptoAFAlgo *afalg =3D container_of(cipher, QCryptoAFAlgo, base); =20 qcrypto_afalg_comm_free(afalg); } diff --git a/crypto/hash-afalg.c b/crypto/hash-afalg.c index 8fc6bd0edf..28ab899b18 100644 --- a/crypto/hash-afalg.c +++ b/crypto/hash-afalg.c @@ -64,12 +64,12 @@ qcrypto_afalg_hash_format_name(QCryptoHashAlgo alg, return name; } =20 -static QCryptoAFAlg * +static QCryptoAFAlgo * qcrypto_afalg_hash_hmac_ctx_new(QCryptoHashAlgo alg, const uint8_t *key, size_t nkey, bool is_hmac, Error **errp) { - QCryptoAFAlg *afalg; + QCryptoAFAlgo *afalg; char *name; =20 name =3D qcrypto_afalg_hash_format_name(alg, is_hmac, errp); @@ -98,14 +98,14 @@ qcrypto_afalg_hash_hmac_ctx_new(QCryptoHashAlgo alg, return afalg; } =20 -static QCryptoAFAlg * +static QCryptoAFAlgo * qcrypto_afalg_hash_ctx_new(QCryptoHashAlgo alg, Error **errp) { return qcrypto_afalg_hash_hmac_ctx_new(alg, NULL, 0, false, errp); } =20 -QCryptoAFAlg * +QCryptoAFAlgo * qcrypto_afalg_hmac_ctx_new(QCryptoHashAlgo alg, const uint8_t *key, size_t nkey, Error **errp) @@ -114,14 +114,14 @@ qcrypto_afalg_hmac_ctx_new(QCryptoHashAlgo alg, } =20 static int -qcrypto_afalg_hash_hmac_bytesv(QCryptoAFAlg *hmac, +qcrypto_afalg_hash_hmac_bytesv(QCryptoAFAlgo *hmac, QCryptoHashAlgo alg, const struct iovec *iov, size_t niov, uint8_t **result, size_t *resultlen, Error **errp) { - QCryptoAFAlg *afalg; + QCryptoAFAlgo *afalg; struct iovec outv; int ret =3D 0; bool is_hmac =3D (hmac !=3D NULL) ? true : false; @@ -197,7 +197,7 @@ qcrypto_afalg_hmac_bytesv(QCryptoHmac *hmac, =20 static void qcrypto_afalg_hmac_ctx_free(QCryptoHmac *hmac) { - QCryptoAFAlg *afalg; + QCryptoAFAlgo *afalg; =20 afalg =3D hmac->opaque; qcrypto_afalg_comm_free(afalg); --=20 2.46.0 From nobody Sun Nov 24 05:28:16 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1725986899; cv=none; d=zohomail.com; s=zohoarc; b=fO/BULRCufyLlpJPwPgaaITBgv3ZZc88MZV5NKLzchMMBbZLcBSdeDV9OcYvI1CNrq+jzb/IIW7XhIZ1hqA4hIlsoxQdm7d5a69k7QvsJmLko9KgQvjBZTCU/Zb2TTUOuAct91pH0m/ssS2PCIYH6j5SL2vUVWOkFHfzg1S352k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1725986899; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=LRmFhYSLxv+IPWQZuvsDU0iiyPAqhQqOAvKJtCUY8Fw=; b=efJ0AHljteyfHBwQXiNyowHxZXeIukjKboHL7sx8RhxHM/tKRaRlaL+yqGR7L3jyJ0Pj1S+TcU32pNT0P2AwADzP74U5zIjFNBcFz+Ct3c6U8tw074+CFf0QMJZ2kYLQIFP9N77S8/dAo+AmFw+wFaARFxO5c0zEuMhkGfJ3FQ8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1725986899657827.667641310801; Tue, 10 Sep 2024 09:48:19 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1so41p-0007Sr-PX; Tue, 10 Sep 2024 12:47:45 -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 1so41c-0006s0-Ct for qemu-devel@nongnu.org; Tue, 10 Sep 2024 12:47:34 -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 1so41X-0007aG-2F for qemu-devel@nongnu.org; Tue, 10 Sep 2024 12:47:32 -0400 Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-686-Lm8P1UUQPqCs97vpgkaOKg-1; Tue, 10 Sep 2024 12:47:23 -0400 Received: from mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.40]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 303031955DA6; Tue, 10 Sep 2024 16:47:22 +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 AAFDD19560AD; Tue, 10 Sep 2024 16:47:21 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id A962321E683A; Tue, 10 Sep 2024 18:47:14 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1725986846; 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=LRmFhYSLxv+IPWQZuvsDU0iiyPAqhQqOAvKJtCUY8Fw=; b=OwxdW8uDTe3zThcg5olSgGWUWxvfCVPE9Tx4pRrzQXk8UK95VoYVpKwv049pBUbOwrwQjV 7LPIB/+QGiEhDUIQXLj4oQJVdDSrOJskjdWhJNZhzPsugVfJ0ugpwVAAe4g/nPTXNki8er 2q//+2vJnM5iS1G+zFyxuru1cHsS7g4= X-MC-Unique: Lm8P1UUQPqCs97vpgkaOKg-1 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org, =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= Subject: [PULL 17/19] qapi/cryptodev: Drop unwanted 'prefix' Date: Tue, 10 Sep 2024 18:47:12 +0200 Message-ID: <20240910164714.1993531-18-armbru@redhat.com> In-Reply-To: <20240910164714.1993531-1-armbru@redhat.com> References: <20240910164714.1993531-1-armbru@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.40 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.145, 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, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1725986901459116600 QAPI's 'prefix' feature can make the connection between enumeration type and its constants less than obvious. It's best used with restraint. QCryptodevBackendServiceType has a 'prefix' that overrides the generated enumeration constants' prefix to QCRYPTODEV_BACKEND_SERVICE. Drop it. The prefix becomes QCRYPTODEV_BACKEND_SERVICE_TYPE. Signed-off-by: Markus Armbruster Reviewed-by: Daniel P. Berrang=C3=A9 Message-ID: <20240904111836.3273842-18-armbru@redhat.com> --- qapi/cryptodev.json | 1 - backends/cryptodev-builtin.c | 8 ++++---- backends/cryptodev-lkcf.c | 2 +- backends/cryptodev-vhost-user.c | 6 +++--- backends/cryptodev.c | 6 +++--- hw/virtio/virtio-crypto.c | 10 +++++----- 6 files changed, 16 insertions(+), 17 deletions(-) diff --git a/qapi/cryptodev.json b/qapi/cryptodev.json index 60f8fe8e4a..65abc16842 100644 --- a/qapi/cryptodev.json +++ b/qapi/cryptodev.json @@ -31,7 +31,6 @@ # Since: 8.0 ## { 'enum': 'QCryptodevBackendServiceType', - 'prefix': 'QCRYPTODEV_BACKEND_SERVICE', 'data': ['cipher', 'hash', 'mac', 'aead', 'akcipher']} =20 ## diff --git a/backends/cryptodev-builtin.c b/backends/cryptodev-builtin.c index 6f3990481b..170c93a6be 100644 --- a/backends/cryptodev-builtin.c +++ b/backends/cryptodev-builtin.c @@ -68,7 +68,7 @@ static void cryptodev_builtin_init_akcipher(CryptoDevBack= end *backend) opts.u.rsa.padding_alg =3D QCRYPTO_RSA_PADDING_ALGO_RAW; if (qcrypto_akcipher_supports(&opts)) { backend->conf.crypto_services |=3D - (1u << QCRYPTODEV_BACKEND_SERVICE_AKCIPHER); + (1u << QCRYPTODEV_BACKEND_SERVICE_TYPE_AKCIPHER); backend->conf.akcipher_algo =3D 1u << VIRTIO_CRYPTO_AKCIPHER_RSA; } } @@ -93,9 +93,9 @@ static void cryptodev_builtin_init( backend->conf.peers.ccs[0] =3D cc; =20 backend->conf.crypto_services =3D - 1u << QCRYPTODEV_BACKEND_SERVICE_CIPHER | - 1u << QCRYPTODEV_BACKEND_SERVICE_HASH | - 1u << QCRYPTODEV_BACKEND_SERVICE_MAC; + 1u << QCRYPTODEV_BACKEND_SERVICE_TYPE_CIPHER | + 1u << QCRYPTODEV_BACKEND_SERVICE_TYPE_HASH | + 1u << QCRYPTODEV_BACKEND_SERVICE_TYPE_MAC; backend->conf.cipher_algo_l =3D 1u << VIRTIO_CRYPTO_CIPHER_AES_CBC; backend->conf.hash_algo =3D 1u << VIRTIO_CRYPTO_HASH_SHA1; /* diff --git a/backends/cryptodev-lkcf.c b/backends/cryptodev-lkcf.c index fde32950f6..0dc4b067f5 100644 --- a/backends/cryptodev-lkcf.c +++ b/backends/cryptodev-lkcf.c @@ -230,7 +230,7 @@ static void cryptodev_lkcf_init(CryptoDevBackend *backe= nd, Error **errp) backend->conf.peers.ccs[0] =3D cc; =20 backend->conf.crypto_services =3D - 1u << QCRYPTODEV_BACKEND_SERVICE_AKCIPHER; + 1u << QCRYPTODEV_BACKEND_SERVICE_TYPE_AKCIPHER; backend->conf.akcipher_algo =3D 1u << VIRTIO_CRYPTO_AKCIPHER_RSA; lkcf->running =3D true; =20 diff --git a/backends/cryptodev-vhost-user.c b/backends/cryptodev-vhost-use= r.c index c3283ba84a..e33fb78521 100644 --- a/backends/cryptodev-vhost-user.c +++ b/backends/cryptodev-vhost-user.c @@ -221,9 +221,9 @@ static void cryptodev_vhost_user_init( cryptodev_vhost_user_event, NULL, s, NULL, true); =20 backend->conf.crypto_services =3D - 1u << QCRYPTODEV_BACKEND_SERVICE_CIPHER | - 1u << QCRYPTODEV_BACKEND_SERVICE_HASH | - 1u << QCRYPTODEV_BACKEND_SERVICE_MAC; + 1u << QCRYPTODEV_BACKEND_SERVICE_TYPE_CIPHER | + 1u << QCRYPTODEV_BACKEND_SERVICE_TYPE_HASH | + 1u << QCRYPTODEV_BACKEND_SERVICE_TYPE_MAC; backend->conf.cipher_algo_l =3D 1u << VIRTIO_CRYPTO_CIPHER_AES_CBC; backend->conf.hash_algo =3D 1u << VIRTIO_CRYPTO_HASH_SHA1; =20 diff --git a/backends/cryptodev.c b/backends/cryptodev.c index fff89fd62a..76dfe65904 100644 --- a/backends/cryptodev.c +++ b/backends/cryptodev.c @@ -74,7 +74,7 @@ static int qmp_query_cryptodev_foreach(Object *obj, void = *data) =20 backend =3D CRYPTODEV_BACKEND(obj); services =3D backend->conf.crypto_services; - for (i =3D 0; i < QCRYPTODEV_BACKEND_SERVICE__MAX; i++) { + for (i =3D 0; i < QCRYPTODEV_BACKEND_SERVICE_TYPE__MAX; i++) { if (services & (1 << i)) { QAPI_LIST_PREPEND(info->service, i); } @@ -424,11 +424,11 @@ cryptodev_backend_complete(UserCreatable *uc, Error *= *errp) } =20 services =3D backend->conf.crypto_services; - if (services & (1 << QCRYPTODEV_BACKEND_SERVICE_CIPHER)) { + if (services & (1 << QCRYPTODEV_BACKEND_SERVICE_TYPE_CIPHER)) { backend->sym_stat =3D g_new0(CryptodevBackendSymStat, 1); } =20 - if (services & (1 << QCRYPTODEV_BACKEND_SERVICE_AKCIPHER)) { + if (services & (1 << QCRYPTODEV_BACKEND_SERVICE_TYPE_AKCIPHER)) { backend->asym_stat =3D g_new0(CryptodevBackendAsymStat, 1); } } diff --git a/hw/virtio/virtio-crypto.c b/hw/virtio/virtio-crypto.c index 5034768bff..0ab8ae3282 100644 --- a/hw/virtio/virtio-crypto.c +++ b/hw/virtio/virtio-crypto.c @@ -1008,19 +1008,19 @@ static uint32_t virtio_crypto_init_services(uint32_= t qservices) { uint32_t vservices =3D 0; =20 - if (qservices & (1 << QCRYPTODEV_BACKEND_SERVICE_CIPHER)) { + if (qservices & (1 << QCRYPTODEV_BACKEND_SERVICE_TYPE_CIPHER)) { vservices |=3D (1 << VIRTIO_CRYPTO_SERVICE_CIPHER); } - if (qservices & (1 << QCRYPTODEV_BACKEND_SERVICE_HASH)) { + if (qservices & (1 << QCRYPTODEV_BACKEND_SERVICE_TYPE_HASH)) { vservices |=3D (1 << VIRTIO_CRYPTO_SERVICE_HASH); } - if (qservices & (1 << QCRYPTODEV_BACKEND_SERVICE_MAC)) { + if (qservices & (1 << QCRYPTODEV_BACKEND_SERVICE_TYPE_MAC)) { vservices |=3D (1 << VIRTIO_CRYPTO_SERVICE_MAC); } - if (qservices & (1 << QCRYPTODEV_BACKEND_SERVICE_AEAD)) { + if (qservices & (1 << QCRYPTODEV_BACKEND_SERVICE_TYPE_AEAD)) { vservices |=3D (1 << VIRTIO_CRYPTO_SERVICE_AEAD); } - if (qservices & (1 << QCRYPTODEV_BACKEND_SERVICE_AKCIPHER)) { + if (qservices & (1 << QCRYPTODEV_BACKEND_SERVICE_TYPE_AKCIPHER)) { vservices |=3D (1 << VIRTIO_CRYPTO_SERVICE_AKCIPHER); } =20 --=20 2.46.0 From nobody Sun Nov 24 05:28:16 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1725987019; cv=none; d=zohomail.com; s=zohoarc; b=ltHhwUehgACVnmMCM+s2q/Nyv+TdsNelQI2hPHPbTsulh/xwvXTQcTtBkl1zaUQ6bBbNtqnVnQBw0yVNyplxSs2EFmCkFdNr0tzMbPemw+/b0pKQ9hsdcnEO6oDfjhLJZLoGgZFOvp72QSaJfD0V12DJfE3YdVAngm6bFJnp0cY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1725987019; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=XVjWOqpRKvgrj/1JG9ZZuyqeYROAAb2f2zG6zzrjVVU=; b=FWL1hEx47sXQ8P2SuPPkN/nQkul8ryeZarK25XPhs+1wZ/NBDzTvpnfAOOLeLC97gG7YW2OdQ2+xQqx+dPl7P03iv93d0VGq41DNbev4E7ekz+uYjDGOlmIxebTQE+Gn6kAY5pRGs+VaHTWyCfVD7j15V3OLLoBFFinsG0drq6w= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 172598701910285.70300737394791; Tue, 10 Sep 2024 09:50:19 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1so41o-0007OE-K0; Tue, 10 Sep 2024 12:47:44 -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 1so41b-0006rw-IC for qemu-devel@nongnu.org; Tue, 10 Sep 2024 12:47:34 -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 1so41W-0007Zu-7J for qemu-devel@nongnu.org; Tue, 10 Sep 2024 12:47:30 -0400 Received: from mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-661--sSoOU0IOW2p0k-LU8YS5Q-1; Tue, 10 Sep 2024 12:47:24 -0400 Received: from mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.40]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 7088B1955D56; Tue, 10 Sep 2024 16:47:22 +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 ABBBC195605A; Tue, 10 Sep 2024 16:47:21 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id AC3D021E66E2; Tue, 10 Sep 2024 18:47:14 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1725986845; 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=XVjWOqpRKvgrj/1JG9ZZuyqeYROAAb2f2zG6zzrjVVU=; b=RBlSl1Zt/HXT0PUsQQLGPef3AnRjl9dKynUR3vt+oufwx+rFONUYqyp+iEPUzRhKa5zcqZ vHTZ3ZOUoMif7Y8+40SqFxp8CSiI4o+jl4/5ds9Am4N9mopkPH89njilkgtCI9KP0NLI/V PO4mVsTZE2OKBWCANe62MMvsy11AC7A= X-MC-Unique: -sSoOU0IOW2p0k-LU8YS5Q-1 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org, =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= Subject: [PULL 18/19] qapi/cryptodev: Rename QCryptodevBackendAlgType to *Algo, and drop prefix Date: Tue, 10 Sep 2024 18:47:13 +0200 Message-ID: <20240910164714.1993531-19-armbru@redhat.com> In-Reply-To: <20240910164714.1993531-1-armbru@redhat.com> References: <20240910164714.1993531-1-armbru@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.40 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.145, 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, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1725987020122116600 QAPI's 'prefix' feature can make the connection between enumeration type and its constants less than obvious. It's best used with restraint. QCryptodevBackendAlgType has a 'prefix' that overrides the generated enumeration constants' prefix to QCRYPTODEV_BACKEND_ALG. We could simply drop 'prefix', but I think the abbreviation "alg" is less than clear. Additionally rename the type to QCryptodevBackendAlgoType. The prefix becomes QCRYPTODEV_BACKEND_ALGO_TYPE. Signed-off-by: Markus Armbruster Reviewed-by: Daniel P. Berrang=C3=A9 Message-ID: <20240904111836.3273842-19-armbru@redhat.com> --- qapi/cryptodev.json | 5 ++--- include/sysemu/cryptodev.h | 2 +- backends/cryptodev-builtin.c | 6 +++--- backends/cryptodev-lkcf.c | 4 ++-- backends/cryptodev.c | 6 +++--- hw/virtio/virtio-crypto.c | 14 +++++++------- 6 files changed, 18 insertions(+), 19 deletions(-) diff --git a/qapi/cryptodev.json b/qapi/cryptodev.json index 65abc16842..5e417340dc 100644 --- a/qapi/cryptodev.json +++ b/qapi/cryptodev.json @@ -9,7 +9,7 @@ ## =20 ## -# @QCryptodevBackendAlgType: +# @QCryptodevBackendAlgoType: # # The supported algorithm types of a crypto device. # @@ -19,8 +19,7 @@ # # Since: 8.0 ## -{ 'enum': 'QCryptodevBackendAlgType', - 'prefix': 'QCRYPTODEV_BACKEND_ALG', +{ 'enum': 'QCryptodevBackendAlgoType', 'data': ['sym', 'asym']} =20 ## diff --git a/include/sysemu/cryptodev.h b/include/sysemu/cryptodev.h index 96d3998b93..b20822df0d 100644 --- a/include/sysemu/cryptodev.h +++ b/include/sysemu/cryptodev.h @@ -178,7 +178,7 @@ typedef struct CryptoDevBackendAsymOpInfo { typedef void (*CryptoDevCompletionFunc) (void *opaque, int ret); =20 typedef struct CryptoDevBackendOpInfo { - QCryptodevBackendAlgType algtype; + QCryptodevBackendAlgoType algtype; uint32_t op_code; uint32_t queue_index; CryptoDevCompletionFunc cb; diff --git a/backends/cryptodev-builtin.c b/backends/cryptodev-builtin.c index 170c93a6be..b1486be630 100644 --- a/backends/cryptodev-builtin.c +++ b/backends/cryptodev-builtin.c @@ -549,7 +549,7 @@ static int cryptodev_builtin_operation( CryptoDevBackendBuiltinSession *sess; CryptoDevBackendSymOpInfo *sym_op_info; CryptoDevBackendAsymOpInfo *asym_op_info; - QCryptodevBackendAlgType algtype =3D op_info->algtype; + QCryptodevBackendAlgoType algtype =3D op_info->algtype; int status =3D -VIRTIO_CRYPTO_ERR; Error *local_error =3D NULL; =20 @@ -561,11 +561,11 @@ static int cryptodev_builtin_operation( } =20 sess =3D builtin->sessions[op_info->session_id]; - if (algtype =3D=3D QCRYPTODEV_BACKEND_ALG_SYM) { + if (algtype =3D=3D QCRYPTODEV_BACKEND_ALGO_TYPE_SYM) { sym_op_info =3D op_info->u.sym_op_info; status =3D cryptodev_builtin_sym_operation(sess, sym_op_info, &local_error); - } else if (algtype =3D=3D QCRYPTODEV_BACKEND_ALG_ASYM) { + } else if (algtype =3D=3D QCRYPTODEV_BACKEND_ALGO_TYPE_ASYM) { asym_op_info =3D op_info->u.asym_op_info; status =3D cryptodev_builtin_asym_operation(sess, op_info->op_code, asym_op_info, &local_err= or); diff --git a/backends/cryptodev-lkcf.c b/backends/cryptodev-lkcf.c index 0dc4b067f5..38deac0717 100644 --- a/backends/cryptodev-lkcf.c +++ b/backends/cryptodev-lkcf.c @@ -474,7 +474,7 @@ static int cryptodev_lkcf_operation( CryptoDevBackendLKCF *lkcf =3D CRYPTODEV_BACKEND_LKCF(backend); CryptoDevBackendLKCFSession *sess; - QCryptodevBackendAlgType algtype =3D op_info->algtype; + QCryptodevBackendAlgoType algtype =3D op_info->algtype; CryptoDevLKCFTask *task; =20 if (op_info->session_id >=3D MAX_SESSIONS || @@ -485,7 +485,7 @@ static int cryptodev_lkcf_operation( } =20 sess =3D lkcf->sess[op_info->session_id]; - if (algtype !=3D QCRYPTODEV_BACKEND_ALG_ASYM) { + if (algtype !=3D QCRYPTODEV_BACKEND_ALGO_TYPE_ASYM) { error_report("algtype not supported: %u", algtype); return -VIRTIO_CRYPTO_NOTSUPP; } diff --git a/backends/cryptodev.c b/backends/cryptodev.c index 76dfe65904..d8bd2a1ae6 100644 --- a/backends/cryptodev.c +++ b/backends/cryptodev.c @@ -185,10 +185,10 @@ static int cryptodev_backend_operation( static int cryptodev_backend_account(CryptoDevBackend *backend, CryptoDevBackendOpInfo *op_info) { - enum QCryptodevBackendAlgType algtype =3D op_info->algtype; + enum QCryptodevBackendAlgoType algtype =3D op_info->algtype; int len; =20 - if (algtype =3D=3D QCRYPTODEV_BACKEND_ALG_ASYM) { + if (algtype =3D=3D QCRYPTODEV_BACKEND_ALGO_TYPE_ASYM) { CryptoDevBackendAsymOpInfo *asym_op_info =3D op_info->u.asym_op_in= fo; len =3D asym_op_info->src_len; =20 @@ -212,7 +212,7 @@ static int cryptodev_backend_account(CryptoDevBackend *= backend, default: return -VIRTIO_CRYPTO_NOTSUPP; } - } else if (algtype =3D=3D QCRYPTODEV_BACKEND_ALG_SYM) { + } else if (algtype =3D=3D QCRYPTODEV_BACKEND_ALGO_TYPE_SYM) { CryptoDevBackendSymOpInfo *sym_op_info =3D op_info->u.sym_op_info; len =3D sym_op_info->src_len; =20 diff --git a/hw/virtio/virtio-crypto.c b/hw/virtio/virtio-crypto.c index 0ab8ae3282..6e9d8293da 100644 --- a/hw/virtio/virtio-crypto.c +++ b/hw/virtio/virtio-crypto.c @@ -461,7 +461,7 @@ static void virtio_crypto_init_request(VirtIOCrypto *vc= rypto, VirtQueue *vq, req->in_iov =3D NULL; req->in_num =3D 0; req->in_len =3D 0; - req->flags =3D QCRYPTODEV_BACKEND_ALG__MAX; + req->flags =3D QCRYPTODEV_BACKEND_ALGO_TYPE__MAX; memset(&req->op_info, 0x00, sizeof(req->op_info)); } =20 @@ -471,7 +471,7 @@ static void virtio_crypto_free_request(VirtIOCryptoReq = *req) return; } =20 - if (req->flags =3D=3D QCRYPTODEV_BACKEND_ALG_SYM) { + if (req->flags =3D=3D QCRYPTODEV_BACKEND_ALGO_TYPE_SYM) { size_t max_len; CryptoDevBackendSymOpInfo *op_info =3D req->op_info.u.sym_op_info; =20 @@ -486,7 +486,7 @@ static void virtio_crypto_free_request(VirtIOCryptoReq = *req) memset(op_info, 0, sizeof(*op_info) + max_len); g_free(op_info); } - } else if (req->flags =3D=3D QCRYPTODEV_BACKEND_ALG_ASYM) { + } else if (req->flags =3D=3D QCRYPTODEV_BACKEND_ALGO_TYPE_ASYM) { CryptoDevBackendAsymOpInfo *op_info =3D req->op_info.u.asym_op_inf= o; if (op_info) { g_free(op_info->src); @@ -571,10 +571,10 @@ static void virtio_crypto_req_complete(void *opaque, = int ret) VirtIODevice *vdev =3D VIRTIO_DEVICE(vcrypto); uint8_t status =3D -ret; =20 - if (req->flags =3D=3D QCRYPTODEV_BACKEND_ALG_SYM) { + if (req->flags =3D=3D QCRYPTODEV_BACKEND_ALGO_TYPE_SYM) { virtio_crypto_sym_input_data_helper(vdev, req, status, req->op_info.u.sym_op_info); - } else if (req->flags =3D=3D QCRYPTODEV_BACKEND_ALG_ASYM) { + } else if (req->flags =3D=3D QCRYPTODEV_BACKEND_ALGO_TYPE_ASYM) { virtio_crypto_akcipher_input_data_helper(vdev, req, status, req->op_info.u.asym_op_info); } @@ -884,7 +884,7 @@ virtio_crypto_handle_request(VirtIOCryptoReq *request) switch (opcode) { case VIRTIO_CRYPTO_CIPHER_ENCRYPT: case VIRTIO_CRYPTO_CIPHER_DECRYPT: - op_info->algtype =3D request->flags =3D QCRYPTODEV_BACKEND_ALG_SYM; + op_info->algtype =3D request->flags =3D QCRYPTODEV_BACKEND_ALGO_TY= PE_SYM; ret =3D virtio_crypto_handle_sym_req(vcrypto, &req.u.sym_req, op_info, out_iov, out_num); @@ -894,7 +894,7 @@ virtio_crypto_handle_request(VirtIOCryptoReq *request) case VIRTIO_CRYPTO_AKCIPHER_DECRYPT: case VIRTIO_CRYPTO_AKCIPHER_SIGN: case VIRTIO_CRYPTO_AKCIPHER_VERIFY: - op_info->algtype =3D request->flags =3D QCRYPTODEV_BACKEND_ALG_ASY= M; + op_info->algtype =3D request->flags =3D QCRYPTODEV_BACKEND_ALGO_TY= PE_ASYM; ret =3D virtio_crypto_handle_asym_req(vcrypto, &req.u.akcipher_req, op_info, out_iov, out_num); --=20 2.46.0 From nobody Sun Nov 24 05:28:16 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1725986972; cv=none; d=zohomail.com; s=zohoarc; b=EEqB5YUxOgkTpSfTT1+eGeyhRNUiVgcfnxDl4eO3CZYBGcj7Ojqo3nCZcUXQum+Z0V9z8upecMpfT4YuHvH5ZUXZEN3as9CsEh9yqOeXKPpUOkYP5jgvh6yfc47qKObOjc4DsjR4ja9oubnB6nYBLxlStA1t2nkopO3XgD+lUCY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1725986972; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=1Zdqqub+sWEXimNYFiEIiGuFYzmKpVqenGTfkuTRG8Q=; b=U3dDyCAfbz0Z+gLjVJNKKhaIcrO1xHmEl4CZtwTK2Xi2ftHxPSgagZ1qluBEDX1lSAHgLpJJy8QwfBmXpuOlrSF07gbgg7nmgq1oiswRx90P/JNDT8oWji1TiCCaCVkci8IsqT3vcoKBrKFLI5stKimIuk0pRCsNKGOdxuwtndQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1725986972752250.23590800421107; Tue, 10 Sep 2024 09:49:32 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1so41q-0007V4-AC; Tue, 10 Sep 2024 12:47:46 -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 1so41a-0006qf-SR for qemu-devel@nongnu.org; Tue, 10 Sep 2024 12:47:33 -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 1so41W-0007a1-FO for qemu-devel@nongnu.org; Tue, 10 Sep 2024 12:47:30 -0400 Received: from mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-244-I2gFaTf2OnqIVR15HPRgGg-1; Tue, 10 Sep 2024 12:47:22 -0400 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id F409819560A7; Tue, 10 Sep 2024 16:47:21 +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 931FF19560AB; Tue, 10 Sep 2024 16:47:21 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id AED2521E66E6; Tue, 10 Sep 2024 18:47:14 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1725986845; 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=1Zdqqub+sWEXimNYFiEIiGuFYzmKpVqenGTfkuTRG8Q=; b=dXaTKnEjFnL0r+EfNJKY+I4HunfpJ4ptb/s9mYOVdvD+FcP0VLqAo30s0WKldJeMDZLrvA u3wB+WY5iwFCWBT4IpmbXkfs9usqXnmgiqb+SyTX7jKbdGLQa3pzCQbcbOmhA/t1PJOYJ6 5Qm50ESq4jWDWijpHFTjelEWpKFSoSE= X-MC-Unique: I2gFaTf2OnqIVR15HPRgGg-1 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org, =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Subject: [PULL 19/19] qapi/vfio: Rename VfioMigrationState to Qapi*, and drop prefix Date: Tue, 10 Sep 2024 18:47:14 +0200 Message-ID: <20240910164714.1993531-20-armbru@redhat.com> In-Reply-To: <20240910164714.1993531-1-armbru@redhat.com> References: <20240910164714.1993531-1-armbru@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.145, 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, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1725986973776116600 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 Message-ID: <20240904111836.3273842-20-armbru@redhat.com> Reviewed-by: C=C3=A9dric 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 @@ ## =20 ## -# @VfioMigrationState: +# @QapiVfioMigrationState: # # An enumeration of the VFIO device migration states. # @@ -32,10 +32,9 @@ # # Since: 9.1 ## -{ 'enum': 'VfioMigrationState', +{ 'enum': 'QapiVfioMigrationState', 'data': [ 'stop', 'running', 'stop-copy', 'resuming', 'running-p2p', - 'pre-copy', 'pre-copy-p2p' ], - 'prefix': 'QAPI_VFIO_MIGRATION_STATE' } + 'pre-copy', 'pre-copy-p2p' ] } =20 ## # @VFIO_MIGRATION: @@ -63,5 +62,5 @@ 'data': { 'device-id': 'str', 'qom-path': 'str', - 'device-state': 'VfioMigrationState' + 'device-state': 'QapiVfioMigrationState' } } diff --git a/hw/vfio/migration.c b/hw/vfio/migration.c index 262d42a46e..17199b73ae 100644 --- a/hw/vfio/migration.c +++ b/hw/vfio/migration.c @@ -81,7 +81,7 @@ static const char *mig_state_to_str(enum vfio_device_mig_= state state) } } =20 -static VfioMigrationState +static QapiVfioMigrationState mig_state_to_qapi_state(enum vfio_device_mig_state state) { switch (state) { --=20 2.46.0