qapi: Reduce use of 'prefix'
Subsystems (5)
v2 cover qapi: Reduce use of 'prefix'
QAPI's 'prefix' feature can make the connection between enumeration type and its constants less than obvious. It's best used with restraint.
We use 'prefix' for a number of reasons:
* To override an ugly default.
* To shorten the prefix.
* To work around name clashes.
This series attacks the first two. It additionally improves a number of ugly prefixes we don't override.
PATCH 01 improves the default prefix, and drops 'prefix' where it is now redundant. The patch adds temporary 'prefix' to not change generated code.
PATCH 02-08 revert the temporary 'prefix'.
PATCH 10,17 drop 'prefix' where the default is now better.
PATCH 09,11-15,18,19 rename QAPI types, and drop their 'prefix'. I'm prepared to adjust the renames according to maintainers' preference.
PATCH 16 renames a non-QAPI type for consistency.
v2:
* PATCH 01: Fix camel_to_upper() to avoid '__' and leading '_'.
* PATCH 01+07: Actually add a 'prefix' to HmatLBMemoryHierarchy in PATCH 01, as the commit message advertizes. Remove it in PATCH 07, and adjust the commit message.
* PATCH 09: Keep pragma documentation-exceptions sorted.
* PATCH 04+09+18: Fix commit message typos.
* PATCH 19: New.
Markus Armbruster (19):
qapi: Smarter camel_to_upper() to reduce need for 'prefix' tests/qapi-schema: Drop temporary 'prefix' qapi/block-core: Drop temporary 'prefix'
qapi/common: Drop temporary 'prefix'
qapi/crypto: Drop temporary 'prefix'
qapi/ebpf: Drop temporary 'prefix'
qapi/machine: Drop temporary 'prefix'
qapi/ui: Drop temporary 'prefix'
qapi/machine: Rename CpuS390* to S390Cpu*, and drop 'prefix' qapi/crypto: Drop unwanted 'prefix'
qapi/crypto: Rename QCryptoHashAlgorithm to *Algo, and drop prefix qapi/crypto: Rename QCryptoCipherAlgorithm to *Algo, and drop prefix qapi/crypto: Rename QCryptoIVGenAlgorithm to *Algo, and drop prefix qapi/crypto: Rename QCryptoAkCipherAlgorithm to *Algo, and drop prefix qapi/crypto: Rename QCryptoRSAPaddingAlgorithm to *Algo, and drop
prefix
qapi/crypto: Rename QCryptoAFAlg to QCryptoAFAlgo qapi/cryptodev: Drop unwanted 'prefix'
qapi/cryptodev: Rename QCryptodevBackendAlgType to *Algo, and drop
prefix
qapi/vfio: Rename VfioMigrationState to Qapi*, and drop prefix
qapi/block-core.json | 4 +- qapi/crypto.json | 56 ++++------ qapi/cryptodev.json | 7 +- qapi/machine-common.json | 5 +- qapi/machine-target.json | 11 +- qapi/machine.json | 9 +- qapi/migration.json | 1 + qapi/pragma.json | 6 +- qapi/ui.json | 1 + qapi/vfio.json | 9 +- crypto/afalgpriv.h | 14 +-- crypto/akcipherpriv.h | 2 +- crypto/blockpriv.h | 6 +- crypto/cipherpriv.h | 2 +- crypto/hashpriv.h | 2 +- crypto/hmacpriv.h | 4 +- crypto/ivgenpriv.h | 6 +- include/crypto/afsplit.h | 8 +- include/crypto/block.h | 2 +- include/crypto/cipher.h | 18 ++-- include/crypto/hash.h | 18 ++-- include/crypto/hmac.h | 6 +- include/crypto/ivgen.h | 30 +++--- include/crypto/pbkdf.h | 14 +-- include/hw/qdev-properties-system.h | 2 +- include/hw/s390x/cpu-topology.h | 2 +- include/sysemu/cryptodev.h | 2 +- target/s390x/cpu.h | 2 +- backends/cryptodev-builtin.c | 52 ++++----- backends/cryptodev-lkcf.c | 36 +++---- backends/cryptodev-vhost-user.c | 6 +- backends/cryptodev.c | 12 +-- block.c | 6 +- block/crypto.c | 10 +- block/parallels-ext.c | 2 +- block/qcow.c | 2 +- block/qcow2.c | 10 +- block/quorum.c | 4 +- block/rbd.c | 4 +- crypto/afalg.c | 8 +- crypto/afsplit.c | 6 +- crypto/akcipher.c | 2 +- crypto/block-luks.c | 128 +++++++++++------------ crypto/block-qcow.c | 6 +- crypto/block.c | 8 +- crypto/cipher-afalg.c | 36 +++---- crypto/cipher.c | 72 ++++++------- crypto/hash-afalg.c | 40 +++---- 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 | 18 ++-- crypto/pbkdf-gcrypt.c | 36 +++---- crypto/pbkdf-gnutls.c | 36 +++---- crypto/pbkdf-nettle.c | 32 +++--- crypto/pbkdf-stub.c | 4 +- crypto/pbkdf.c | 2 +- crypto/secret_common.c | 2 +- ebpf/ebpf_rss.c | 2 +- hw/core/numa.c | 4 +- hw/core/qdev-properties-system.c | 6 +- hw/misc/aspeed_hace.c | 16 +-- hw/pci-bridge/cxl_upstream.c | 4 +- hw/s390x/cpu-topology.c | 6 +- hw/vfio/migration.c | 2 +- hw/vfio/pci.c | 10 +- hw/virtio/virtio-crypto.c | 24 ++--- io/channel-websock.c | 2 +- system/vl.c | 2 +- target/i386/sev.c | 6 +- tests/bench/benchmark-crypto-akcipher.c | 28 ++--- tests/bench/benchmark-crypto-cipher.c | 22 ++-- 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 | 54 +++++----- tests/unit/test-crypto-block.c | 58 +++++----- tests/unit/test-crypto-cipher.c | 66 ++++++------ tests/unit/test-crypto-hash.c | 42 ++++---- tests/unit/test-crypto-hmac.c | 16 +-- tests/unit/test-crypto-ivgen.c | 38 +++---- tests/unit/test-crypto-pbkdf.c | 44 ++++---- tests/unit/test-qobject-input-visitor.c | 4 +- tests/unit/test-qobject-output-visitor.c | 4 +- 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 +- ui/vnc.c | 6 +- util/hbitmap.c | 2 +- crypto/akcipher-gcrypt.c.inc | 44 ++++---- crypto/akcipher-nettle.c.inc | 56 +++++----- crypto/cipher-builtin.c.inc | 18 ++-- crypto/cipher-gcrypt.c.inc | 56 +++++----- crypto/cipher-gnutls.c.inc | 38 +++---- crypto/cipher-nettle.c.inc | 58 +++++----- crypto/rsakey-builtin.c.inc | 4 +- crypto/rsakey-nettle.c.inc | 4 +- 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.out | 1 - 119 files changed, 937 insertions(+), 954 deletions(-)
Signature · 1 line
2.46.0
PATCH v2 1/19 qapi: Smarter camel_to_upper() to reduce need for 'prefix'
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_THREE2. 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_SERVICESubsequent commits will tweak things to remove most of these prefixes. Only QAUTHZ_LIST_FORMAT and QAUTHZ_LIST_POLICY will remain.
--- 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(-)
qapi/block-core.json +2 -1
@@ -2011,6 +2011,7 @@ # Since: 4.0 ## { 'enum': 'XDbgBlockGraphNodeType', + 'prefix': 'X_DBG_BLOCK_GRAPH_NODE_TYPE', # TODO drop 'data': [ 'block-backend', 'block-job', 'block-driver' ] } ##
@@ -3746,7 +3747,7 @@ # # Since: 4.1 ## -{ 'enum': 'BlkdebugIOType', 'prefix': 'BLKDEBUG_IO_TYPE', +{ 'enum': 'BlkdebugIOType', 'data': [ 'read', 'write', 'write-zeroes', 'discard', 'flush', 'block-status' ] }
qapi/common.json +1 -0
@@ -92,6 +92,7 @@ # Since: 2.12 ## { 'enum': 'OffAutoPCIBAR', + 'prefix': 'OFF_AUTOPCIBAR', # TODO drop 'data': [ 'off', 'auto', 'bar0', 'bar1', 'bar2', 'bar3', 'bar4', 'bar5' ] } ##
qapi/crypto.json +2 -4
@@ -20,7 +20,6 @@ # Since: 2.5 ## { 'enum': 'QCryptoTLSCredsEndpoint', - 'prefix': 'QCRYPTO_TLS_CREDS_ENDPOINT', 'data': ['client', 'server']} ##
@@ -36,7 +35,6 @@ # Since: 2.6 ## { 'enum': 'QCryptoSecretFormat', - 'prefix': 'QCRYPTO_SECRET_FORMAT', 'data': ['raw', 'base64']} ##
@@ -123,7 +121,6 @@ # Since: 2.6 ## { 'enum': 'QCryptoCipherMode', - 'prefix': 'QCRYPTO_CIPHER_MODE', 'data': ['ecb', 'cbc', 'xts', 'ctr']} ##
@@ -160,7 +157,7 @@ # Since: 2.6 ## { 'enum': 'QCryptoBlockFormat', -# 'prefix': 'QCRYPTO_BLOCK_FORMAT', + 'prefix': 'Q_CRYPTO_BLOCK_FORMAT', # TODO drop 'data': ['qcow', 'luks']} ##
@@ -363,6 +360,7 @@ # Since: 5.1 ## { 'enum': 'QCryptoBlockLUKSKeyslotState', + 'prefix': 'Q_CRYPTO_BLOCKLUKS_KEYSLOT_STATE', # TODO drop 'data': [ 'active', 'inactive' ] } ##
qapi/cryptodev.json +0 -1
@@ -48,7 +48,6 @@ # Since: 8.0 ## { 'enum': 'QCryptodevBackendType', - 'prefix': 'QCRYPTODEV_BACKEND_TYPE', 'data': ['builtin', 'vhost-user', 'lkcf']} ##
qapi/ebpf.json +1 -0
@@ -42,6 +42,7 @@ # Since: 9.0 ## { 'enum': 'EbpfProgramID', + 'prefix': 'EBPF_PROGRAMID', # TODO drop 'if': 'CONFIG_EBPF', 'data': [ { 'name': 'rss' } ] }
qapi/machine.json +2 -0
@@ -686,6 +686,7 @@ # Since: 5.0 ## { 'enum': 'HmatLBMemoryHierarchy', + 'prefix': 'HMATLB_MEMORY_HIERARCHY', # TODO drop 'data': [ 'memory', 'first-level', 'second-level', 'third-level' ] } ##
@@ -712,6 +713,7 @@ # Since: 5.0 ## { 'enum': 'HmatLBDataType', + 'prefix': 'HMATLB_DATA_TYPE', # TODO drop 'data': [ 'access-latency', 'read-latency', 'write-latency', 'access-bandwidth', 'read-bandwidth', 'write-bandwidth' ] }
qapi/migration.json +1 -0
@@ -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' },
qapi/ui.json +2 -0
@@ -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' ] } ##
scripts/qapi/common.py +24 -18
55 lines not on this page · raw message
scripts/qapi/schema.py +1 -1
@@ -1249,7 +1249,7 @@ def _def_predefineds(self) -> None: [{'name': n} for n in qtypes], None) self._def_definition(QAPISchemaEnumType( - 'QType', None, None, None, None, qtype_values, 'QTYPE')) + 'QType', None, None, None, None, qtype_values, None)) def _make_features( self,
tests/qapi-schema/alternate-array.out +0 -1
@@ -1,7 +1,6 @@ module ./builtin object q_empty enum QType - prefix QTYPE member none member qnull member qnum
tests/qapi-schema/comments.out +0 -1
@@ -1,7 +1,6 @@ module ./builtin object q_empty enum QType - prefix QTYPE member none member qnull member qnum
tests/qapi-schema/doc-good.out +0 -1
@@ -1,7 +1,6 @@ module ./builtin object q_empty enum QType - prefix QTYPE member none member qnull member qnum
tests/qapi-schema/empty.out +0 -1
@@ -1,7 +1,6 @@ module ./builtin object q_empty enum QType - prefix QTYPE member none member qnull member qnum
tests/qapi-schema/include-repetition.out +0 -1
@@ -1,7 +1,6 @@ module ./builtin object q_empty enum QType - prefix QTYPE member none member qnull member qnum
tests/qapi-schema/include-simple.out +0 -1
@@ -1,7 +1,6 @@ module ./builtin object q_empty enum QType - prefix QTYPE member none member qnull member qnum
tests/qapi-schema/indented-expr.out +0 -1
@@ -1,7 +1,6 @@ module ./builtin object q_empty enum QType - prefix QTYPE member none member qnull member qnum
tests/qapi-schema/qapi-schema-test.json +1 -0
@@ -119,6 +119,7 @@ 'data': [ 'value-a', 'value-b' ] } { 'enum': 'TestUnionEnumA', + 'prefix': 'TEST_UNION_ENUMA', # TODO drop 'data': [ 'value-a1', 'value-a2' ] } { 'struct': 'TestUnionTypeA1',
tests/qapi-schema/qapi-schema-test.out +1 -1
@@ -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
Signature · 1 line
2.46.0
Re: [PATCH v2 01/19] qapi: Smarter camel_to_upper() to reduce need for 'prefix'
Quoted 8 lines · Markus Armbruster
camel_to_upper()converts its argument from camel case to upper case with '_' between words. Used for generated enumeration constant prefixes.Signed-off-by Markus Armbruster <[email protected]>Reviewed-by Daniel P. Berrang?? <[email protected]>
The accent in my name is getting mangled in this series.
IIRC your mail client (git send-email ?) needs to be explicitly setting a chardset eg
Content-type: text/plain; charset=utf8
so that mail clients & intermediate servers know how to interpret the 8bit data.
With regards,
Daniel
Signature · 3 lines
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
Re: [PATCH v2 01/19] qapi: Smarter camel_to_upper() to reduce need for 'prefix'
Quoted 11 lines · Daniel P. Berrangé
Quoted 8 lines · Markus Armbruster
camel_to_upper()converts its argument from camel case to upper case with '_' between words. Used for generated enumeration constant prefixes.Signed-off-by Markus Armbruster <[email protected]>Reviewed-by Daniel P. Berrang?? <[email protected]>The accent in my name is getting mangled in this series.
Uh-oh!
Checking... Hmm. It's correct in git, correct in output of git-format-patch, correct in the copy I got from git-send-email --bcc armbru via localhost MTA, and the copy I got from --to [email protected], correct in lore.kernel.org[*], correct in an mbox downloaded from patchew.
Could the culprit be on your side?
Quoted 10 lines
IIRC your mail client (git send-email ?) needs to be explicitly setting a chardset eg
Content-type: text/plain; charset=utf8
so that mail clients & intermediate servers know how to interpret the 8bit data.
With regards,
Daniel
[*] https://lore.kernel.org/qemu-devel/[email protected]/T/#m4a7625a47ce94c30ca2ae6d94acd2901e0d0d176
Re: [PATCH v2 01/19] qapi: Smarter camel_to_upper() to reduce need for 'prefix'
Quoted 16 lines · Markus Armbruster
Quoted 11 lines · Daniel P. Berrangé
Quoted 8 lines · Markus Armbruster
camel_to_upper()converts its argument from camel case to upper case with '_' between words. Used for generated enumeration constant prefixes.Signed-off-by Markus Armbruster <[email protected]>Reviewed-by Daniel P. Berrang?? <[email protected]>The accent in my name is getting mangled in this series.
Uh-oh!
Quoted 7 lines
Checking... Hmm. It's correct in git, correct in output of git-format-patch, correct in the copy I got from git-send-email --bcc armbru via localhost MTA, and the copy I got from --to [email protected], correct in lore.kernel.org[*], correct in an mbox downloaded from patchew.
Could the culprit be on your side?
I compared my received mail vs the mbox archive on nongnu.org for qemu-devel.
In both cases the actual mail body seems to be valid UTF-8 and is identical. The message in the nongnu.org archive, however, has
Content-Type: text/plain; charset=UTF-8
while the copy I got in my inbox has merely
Content-Type: text/plain
What I can't determine is whether your original sent message had "charset=UTF-8" which then got stripped by redhat's incoming mail server, or whether your original lacked 'charset=UTF8' and it got added by mailman when saving the message to the mbox archives ?
With regards,
Daniel
Signature · 3 lines
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
Re: [PATCH v2 01/19] qapi: Smarter camel_to_upper() to reduce need for 'prefix'
Quoted 33 lines · Daniel P. Berrangé
Quoted 16 lines · Markus Armbruster
Quoted 11 lines · Daniel P. Berrangé
Quoted 8 lines · Markus Armbruster
camel_to_upper()converts its argument from camel case to upper case with '_' between words. Used for generated enumeration constant prefixes.Signed-off-by Markus Armbruster <[email protected]>Reviewed-by Daniel P. Berrang?? <[email protected]>The accent in my name is getting mangled in this series.
Uh-oh!
Quoted 7 lines
Checking... Hmm. It's correct in git, correct in output of git-format-patch, correct in the copy I got from git-send-email --bcc armbru via localhost MTA, and the copy I got from --to [email protected], correct in lore.kernel.org[*], correct in an mbox downloaded from patchew.
Could the culprit be on your side?
I compared my received mail vs the mbox archive on nongnu.org for qemu-devel.
In both cases the actual mail body seems to be valid UTF-8 and is identical. The message in the nongnu.org archive, however, has
Content-Type: text/plain; charset=UTF-8
Quoted 8 lines
while the copy I got in my inbox has merely
Content-Type: text/plain
What I can't determine is whether your original sent message had "charset=UTF-8" which then got stripped by redhat's incoming mail server, or whether your original lacked 'charset=UTF8' and it got added by mailman when saving the message to the mbox archives ?
I didn't read into details of what Markus hit, but I just remembered I hit similar things before and Dan reported similar issue. At that time (which I tried to recall..) was because I used git-publish sending patches, in which there is an encoding issue. I tried to fix with this branch:
https://github.com/xzpeter/git-publish/commits/fix-print-2/
I also remember I tried to upstream that to Stefan's repo but I totally forgot what happened later, but the result is I am still using this branch internally (which I completely forgot which version I'm using... but I found that until I see this discussion and checked..).
Please ignore everything if git-publish is not used at all.. but just in case helpful..
Signature · 1 line
Peter Xu
PATCH v2 2/19 tests/qapi-schema: Drop temporary 'prefix'
In reply to Markus ArmbrusterRecent 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.
--- 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(-)
tests/unit/test-qobject-input-visitor.c +2 -2
@@ -720,7 +720,7 @@ static void test_visitor_in_union_in_union(TestInputVisitorData *data,visit_type_TestUnionInUnion (v,NULL , &tmp, &error_abort); g_assert_cmpint(tmp->type, ==, TEST_UNION_ENUM_VALUE_A); - g_assert_cmpint(tmp->u.value_a.type_a, ==, TEST_UNION_ENUMA_VALUE_A1); + g_assert_cmpint(tmp->u.value_a.type_a, ==, TEST_UNION_ENUM_A_VALUE_A1); g_assert_cmpint(tmp->u.value_a.u.value_a1.integer, ==, 2); g_assert_cmpint(strcmp(tmp->u.value_a.u.value_a1.name, "fish"), ==, 0);
@@ -734,7 +734,7 @@ static void test_visitor_in_union_in_union(TestInputVisitorData *data,visit_type_TestUnionInUnion (v,NULL , &tmp, &error_abort); g_assert_cmpint(tmp->type, ==, TEST_UNION_ENUM_VALUE_A); - g_assert_cmpint(tmp->u.value_a.type_a, ==, TEST_UNION_ENUMA_VALUE_A2); + g_assert_cmpint(tmp->u.value_a.type_a, ==, TEST_UNION_ENUM_A_VALUE_A2); g_assert_cmpint(tmp->u.value_a.u.value_a2.integer, ==, 1729); g_assert_cmpint(tmp->u.value_a.u.value_a2.size, ==, 87539319);
tests/unit/test-qobject-output-visitor.c +2 -2
@@ -359,7 +359,7 @@ static void test_visitor_out_union_in_union(TestOutputVisitorData *data,TestUnionInUnion *tmp =g_new0 (TestUnionInUnion,1 ); tmp->type =TEST_UNION_ENUM_VALUE_A ; - tmp->u.value_a.type_a =TEST_UNION_ENUMA_VALUE_A1 ; + tmp->u.value_a.type_a =TEST_UNION_ENUM_A_VALUE_A1 ; tmp->u.value_a.u.value_a1.integer =42 ; tmp->u.value_a.u.value_a1.name =g_strdup ("fish" );
@@ -377,7 +377,7 @@ static void test_visitor_out_union_in_union(TestOutputVisitorData *data,visitor_reset (data); tmp =g_new0 (TestUnionInUnion,1 ); tmp->type =TEST_UNION_ENUM_VALUE_A ; - tmp->u.value_a.type_a =TEST_UNION_ENUMA_VALUE_A2 ; + tmp->u.value_a.type_a =TEST_UNION_ENUM_A_VALUE_A2 ; tmp->u.value_a.u.value_a2.integer =1729 ; tmp->u.value_a.u.value_a2.size =87539319 ;
tests/qapi-schema/qapi-schema-test.json +0 -1
@@ -119,7 +119,6 @@ 'data': [ 'value-a', 'value-b' ] } { 'enum': 'TestUnionEnumA', - 'prefix': 'TEST_UNION_ENUMA', # TODO drop 'data': [ 'value-a1', 'value-a2' ] } { 'struct': 'TestUnionTypeA1',
tests/qapi-schema/qapi-schema-test.out +0 -1
@@ -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
Signature · 1 line
2.46.0
PATCH v2 3/19 qapi/block-core: Drop temporary 'prefix'
In reply to Markus ArmbrusterRecent 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.
--- qapi/block-core.json | 1 - block.c | 6 +++--- 2 files changed, 3 insertions(+), 4 deletions(-)
qapi/block-core.json +0 -1
@@ -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' ] } ##
block.c +3 -3
@@ -6351,7 +6351,7 @@ XDbgBlockGraph *bdrv_get_xdbg_block_graph(Error **errp)if (!*name) { name = allocated_name =blk_get_attached_dev_id (blk); } -xdbg_graph_add_node (gr, blk,X_DBG_BLOCK_GRAPH_NODE_TYPE_BLOCK_BACKEND , +xdbg_graph_add_node (gr, blk,XDBG_BLOCK_GRAPH_NODE_TYPE_BLOCK_BACKEND , name);g_free (allocated_name);if (blk_root (blk)) {
@@ -6364,7 +6364,7 @@ XDbgBlockGraph *bdrv_get_xdbg_block_graph(Error **errp) job = block_job_next_locked(job)) {GSList *el; -xdbg_graph_add_node (gr, job,X_DBG_BLOCK_GRAPH_NODE_TYPE_BLOCK_JOB , +xdbg_graph_add_node (gr, job,XDBG_BLOCK_GRAPH_NODE_TYPE_BLOCK_JOB , job->job.id);for (el = job->nodes; el; el = el->next) {xdbg_graph_add_edge (gr, job, (BdrvChild *)el->data);
@@ -6373,7 +6373,7 @@ XDbgBlockGraph *bdrv_get_xdbg_block_graph(Error **errp) } QTAILQ_FOREACH(bs, &graph_bdrv_states, node_list) { -xdbg_graph_add_node (gr, bs,X_DBG_BLOCK_GRAPH_NODE_TYPE_BLOCK_DRIVER , +xdbg_graph_add_node (gr, bs,XDBG_BLOCK_GRAPH_NODE_TYPE_BLOCK_DRIVER , bs->node_name); QLIST_FOREACH(child, &bs->children, next) {xdbg_graph_add_edge (gr, bs, child);
Signature · 1 line
2.46.0
Re: [PATCH v2 03/19] qapi/block-core: Drop temporary 'prefix'
Quoted 10 lines · Markus Armbruster
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_BACKENDtoXDBG_BLOCK_GRAPH_NODE_TYPE_BLOCK_BACKEND.Signed-off-by Markus Armbruster<[email protected]>
Signature · 2 lines
Best regards, Vladimir
Re: [PATCH v2 03/19] qapi/block-core: Drop temporary 'prefix'
Quoted 5 lines · Vladimir Sementsov-Ogievskiy
Quoted 4 lines · Markus Armbruster
Recent commit "qapi: Smarter
camel_to_upper()to reduce need for 'prefix'" added a temporary 'prefix' to delay changing the generated code.
Quoted 9 lines
Quoted 6 lines
Revert it. This improves XDbgBlockGraphNodeType's generated enumeration constant prefix from
X_DBG_BLOCK_GRAPH_NODE_TYPE_BLOCK_BACKENDtoXDBG_BLOCK_GRAPH_NODE_TYPE_BLOCK_BACKEND.Signed-off-by Markus Armbruster<[email protected]>Reviewed-by Vladimir Sementsov-Ogievskiy <[email protected]>
Oops sorry, I see now that was merged already.
Signature · 2 lines
Best regards, Vladimir
PATCH v2 4/19 qapi/common: Drop temporary 'prefix'
In reply to Markus ArmbrusterRecent 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.
--- qapi/common.json | 1 - hw/vfio/pci.c | 10 +++++----- 2 files changed, 5 insertions(+), 6 deletions(-)
qapi/common.json +0 -1
@@ -92,7 +92,6 @@ # Since: 2.12 ## { 'enum': 'OffAutoPCIBAR', - 'prefix': 'OFF_AUTOPCIBAR', # TODO drop 'data': [ 'off', 'auto', 'bar0', 'bar1', 'bar2', 'bar3', 'bar4', 'bar5' ] } ##
hw/vfio/pci.c +5 -5
@@ -1452,7 +1452,7 @@ static bool vfio_pci_relocate_msix(VFIOPCIDevice *vdev, Error **errp)int target_bar =-1 ;size_t msix_sz; -if (!vdev->msix || vdev->msix_relo ==OFF_AUTOPCIBAR_OFF ) { +if (!vdev->msix || vdev->msix_relo ==OFF_AUTO_PCIBAR_OFF ) {return true; }
@@ -1464,7 +1464,7 @@ static bool vfio_pci_relocate_msix(VFIOPCIDevice *vdev, Error **errp)/* PCI BARs must be a power of 2 */ msix_sz =pow2ceil (msix_sz); -if (vdev->msix_relo ==OFF_AUTOPCIBAR_AUTO ) { +if (vdev->msix_relo ==OFF_AUTO_PCIBAR_AUTO ) {/* * TODO: Lookup table for known devices. *
@@ -1479,7 +1479,7 @@ static bool vfio_pci_relocate_msix(VFIOPCIDevice *vdev, Error **errp)return false; } }else { - target_bar = (int )(vdev->msix_relo -OFF_AUTOPCIBAR_BAR0 ); + target_bar = (int )(vdev->msix_relo -OFF_AUTO_PCIBAR_BAR0 ); }/* I/O port BARs cannot host MSI-X structures */
@@ -1624,7 +1624,7 @@ static bool vfio_msix_early_setup(VFIOPCIDevice *vdev, Error **errp) }else if (vfio_pci_is (vdev,PCI_VENDOR_ID_BAIDU ,PCI_DEVICE_ID_KUNLUN_VF )) { msix->pba_offset =0xb400 ; - }else if (vdev->msix_relo ==OFF_AUTOPCIBAR_OFF ) { + }else if (vdev->msix_relo ==OFF_AUTO_PCIBAR_OFF ) {error_setg (errp,"hardware reports invalid configuration, " "MSIX PBA outside of specified BAR" );g_free (msix);
@@ -3403,7 +3403,7 @@ static Property vfio_pci_dev_properties[] = { nv_gpudirect_clique, qdev_prop_nv_gpudirect_clique, uint8_t), DEFINE_PROP_OFF_AUTO_PCIBAR("x-msix-relocation", VFIOPCIDevice, msix_relo, - OFF_AUTOPCIBAR_OFF), + OFF_AUTO_PCIBAR_OFF),#ifdef CONFIG_IOMMUFD DEFINE_PROP_LINK ("iommufd" , VFIOPCIDevice, vbasedev.iommufd, TYPE_IOMMUFD_BACKEND, IOMMUFDBackend *),
Signature · 1 line
2.46.0
PATCH v2 5/19 qapi/crypto: Drop temporary 'prefix'
In reply to Markus ArmbrusterRecent 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.
--- 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(-)
qapi/crypto.json +0 -2
@@ -157,7 +157,6 @@ # Since: 2.6 ## { 'enum': 'QCryptoBlockFormat', - 'prefix': 'Q_CRYPTO_BLOCK_FORMAT', # TODO drop 'data': ['qcow', 'luks']} ##
@@ -360,7 +359,6 @@ # Since: 5.1 ## { 'enum': 'QCryptoBlockLUKSKeyslotState', - 'prefix': 'Q_CRYPTO_BLOCKLUKS_KEYSLOT_STATE', # TODO drop 'data': [ 'active', 'inactive' ] } ##
block/crypto.c +5 -5
@@ -682,7 +682,7 @@ err:static int block_crypto_probe_luks (const uint8_t *buf,int buf_size,const char *filename) { -return block_crypto_probe_generic (Q_CRYPTO_BLOCK_FORMAT_LUKS , +return block_crypto_probe_generic (QCRYPTO_BLOCK_FORMAT_LUKS , buf, buf_size, filename); }
@@ -691,7 +691,7 @@ static int block_crypto_open_luks(BlockDriverState *bs,int flags, Error **errp) { - return block_crypto_open_generic(Q_CRYPTO_BLOCK_FORMAT_LUKS, + return block_crypto_open_generic(QCRYPTO_BLOCK_FORMAT_LUKS, &block_crypto_runtime_opts_luks,bs ,options ,flags ,errp ); }
@@ -724,7 +724,7 @@ block_crypto_co_create_luks(BlockdevCreateOptions *create_options, Error **errp) } create_opts = (QCryptoBlockCreateOptions ) { - .format =Q_CRYPTO_BLOCK_FORMAT_LUKS , + .format =QCRYPTO_BLOCK_FORMAT_LUKS , .u.luks = *qapi_BlockdevCreateOptionsLUKS_base (luks_opts), };
@@ -889,7 +889,7 @@ block_crypto_get_specific_info_luks(BlockDriverState *bs, Error **errp)if (!info) {return NULL ; } -assert (info->format ==Q_CRYPTO_BLOCK_FORMAT_LUKS ); +assert (info->format ==QCRYPTO_BLOCK_FORMAT_LUKS ); spec_info =g_new (ImageInfoSpecific,1 ); spec_info->type =IMAGE_INFO_SPECIFIC_KIND_LUKS ;
@@ -1002,7 +1002,7 @@ coroutine_fn block_crypto_co_amend_luks(BlockDriverState *bs,QCryptoBlockAmendOptions amend_opts; amend_opts = (QCryptoBlockAmendOptions ) { - .format =Q_CRYPTO_BLOCK_FORMAT_LUKS , + .format =QCRYPTO_BLOCK_FORMAT_LUKS , .u.luks = *qapi_BlockdevAmendOptionsLUKS_base (&opts->u.luks), }; return block_crypto_amend_options_generic_luks(bs, &amend_opts,
block/qcow.c +1 -1
@@ -831,7 +831,7 @@ qcow_co_create(BlockdevCreateOptions *opts, Error **errp) }if (qcow_opts->encrypt && - qcow_opts->encrypt->format !=Q_CRYPTO_BLOCK_FORMAT_QCOW ) + qcow_opts->encrypt->format !=QCRYPTO_BLOCK_FORMAT_QCOW ) {error_setg (errp,"Unsupported encryption format" );return -EINVAL ;
block/qcow2.c +5 -5
@@ -3214,10 +3214,10 @@ qcow2_set_up_encryption(BlockDriverState *bs,int fmt, ret;switch (cryptoopts->format) { -case Q_CRYPTO_BLOCK_FORMAT_LUKS : +case QCRYPTO_BLOCK_FORMAT_LUKS : fmt =QCOW_CRYPT_LUKS ;break ; -case Q_CRYPTO_BLOCK_FORMAT_QCOW : +case QCRYPTO_BLOCK_FORMAT_QCOW : fmt =QCOW_CRYPT_AES ;break ;default :
@@ -5306,10 +5306,10 @@ qcow2_get_specific_info(BlockDriverState *bs, Error **errp)ImageInfoSpecificQCow2Encryption *qencrypt =g_new (ImageInfoSpecificQCow2Encryption,1 );switch (encrypt_info->format) { -case Q_CRYPTO_BLOCK_FORMAT_QCOW : +case QCRYPTO_BLOCK_FORMAT_QCOW : qencrypt->format =BLOCKDEV_QCOW2_ENCRYPTION_FORMAT_AES ;break ; -case Q_CRYPTO_BLOCK_FORMAT_LUKS : +case QCRYPTO_BLOCK_FORMAT_LUKS : qencrypt->format =BLOCKDEV_QCOW2_ENCRYPTION_FORMAT_LUKS ; qencrypt->u.luks = encrypt_info->u.luks;break ;
@@ -5948,7 +5948,7 @@ static int coroutine_fn qcow2_co_amend(BlockDriverState *bs,return -EOPNOTSUPP ; } -if (qopts->encrypt->format !=Q_CRYPTO_BLOCK_FORMAT_LUKS ) { +if (qopts->encrypt->format !=QCRYPTO_BLOCK_FORMAT_LUKS ) {error_setg (errp,"Amend can't be used to change the qcow2 encryption format" );return -EOPNOTSUPP ;
crypto/block-luks.c +2 -2
@@ -1861,11 +1861,11 @@ qcrypto_block_luks_amend_options(QCryptoBlock *block,QCryptoBlockAmendOptionsLUKS *opts_luks = &options->u.luks;switch (opts_luks->state) { -case Q_CRYPTO_BLOCKLUKS_KEYSLOT_STATE_ACTIVE : +case QCRYPTO_BLOCK_LUKS_KEYSLOT_STATE_ACTIVE :return qcrypto_block_luks_amend_add_keyslot (block, readfunc, writefunc, opaque, opts_luks, force, errp); -case Q_CRYPTO_BLOCKLUKS_KEYSLOT_STATE_INACTIVE : +case QCRYPTO_BLOCK_LUKS_KEYSLOT_STATE_INACTIVE :return qcrypto_block_luks_amend_erase_keyslots (block, readfunc, writefunc, opaque, opts_luks, force, errp);
crypto/block.c +2 -2
@@ -26,8 +26,8 @@#include "block-luks.h" static const QCryptoBlockDriver *qcrypto_block_drivers[] = { - [Q_CRYPTO_BLOCK_FORMAT_QCOW ] = &qcrypto_block_driver_qcow, - [Q_CRYPTO_BLOCK_FORMAT_LUKS ] = &qcrypto_block_driver_luks, + [QCRYPTO_BLOCK_FORMAT_QCOW ] = &qcrypto_block_driver_qcow, + [QCRYPTO_BLOCK_FORMAT_LUKS ] = &qcrypto_block_driver_luks, };
tests/unit/test-crypto-block.c +7 -7
@@ -39,14 +39,14 @@#endif static QCryptoBlockCreateOptions qcow_create_opts = { - .format =Q_CRYPTO_BLOCK_FORMAT_QCOW , + .format =QCRYPTO_BLOCK_FORMAT_QCOW , .u.qcow = { .key_secret = (char *)"sec0" , }, };static QCryptoBlockOpenOptions qcow_open_opts = { - .format =Q_CRYPTO_BLOCK_FORMAT_QCOW , + .format =QCRYPTO_BLOCK_FORMAT_QCOW , .u.qcow = { .key_secret = (char *)"sec0" , },
@@ -55,7 +55,7 @@ static QCryptoBlockOpenOptions qcow_open_opts = {#ifdef TEST_LUKS static QCryptoBlockOpenOptions luks_open_opts = { - .format =Q_CRYPTO_BLOCK_FORMAT_LUKS , + .format =QCRYPTO_BLOCK_FORMAT_LUKS , .u.luks = { .key_secret = (char *)"sec0" , },
@@ -64,7 +64,7 @@ static QCryptoBlockOpenOptions luks_open_opts = {/* Creation with all default values */ static QCryptoBlockCreateOptions luks_create_opts_default = { - .format =Q_CRYPTO_BLOCK_FORMAT_LUKS , + .format =QCRYPTO_BLOCK_FORMAT_LUKS , .u.luks = { .key_secret = (char *)"sec0" , },
@@ -73,7 +73,7 @@ static QCryptoBlockCreateOptions luks_create_opts_default = {/* ...and with explicit values */ static QCryptoBlockCreateOptions luks_create_opts_aes256_cbc_plain64 = { - .format =Q_CRYPTO_BLOCK_FORMAT_LUKS , + .format =QCRYPTO_BLOCK_FORMAT_LUKS , .u.luks = { .key_secret = (char *)"sec0" , .has_cipher_alg = true,
@@ -87,7 +87,7 @@ static QCryptoBlockCreateOptions luks_create_opts_aes256_cbc_plain64 = {static QCryptoBlockCreateOptions luks_create_opts_aes256_cbc_essiv = { - .format =Q_CRYPTO_BLOCK_FORMAT_LUKS , + .format =QCRYPTO_BLOCK_FORMAT_LUKS , .u.luks = { .key_secret = (char *)"sec0" , .has_cipher_alg = true,
@@ -572,7 +572,7 @@ int main(int argc, char **argv)g_assert (qcrypto_init (NULL ) ==0 );for (i =0 ; i <G_N_ELEMENTS (test_data); i++) { -if (test_data[i].open_opts->format ==Q_CRYPTO_BLOCK_FORMAT_LUKS && +if (test_data[i].open_opts->format ==QCRYPTO_BLOCK_FORMAT_LUKS && !qcrypto_hash_supports (test_data[i].hash_alg)) {continue ; }
Signature · 1 line
2.46.0
PATCH v2 6/19 qapi/ebpf: Drop temporary 'prefix'
In reply to Markus ArmbrusterRecent 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.
--- qapi/ebpf.json | 1 - ebpf/ebpf_rss.c | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-)
qapi/ebpf.json +0 -1
@@ -42,7 +42,6 @@ # Since: 9.0 ## { 'enum': 'EbpfProgramID', - 'prefix': 'EBPF_PROGRAMID', # TODO drop 'if': 'CONFIG_EBPF', 'data': [ { 'name': 'rss' } ] }
ebpf/ebpf_rss.c +1 -1
@@ -271,4 +271,4 @@ void ebpf_rss_unload(struct EBPFRSSContext *ctx) ctx->map_indirections_table =-1 ; } -ebpf_binary_init (EBPF_PROGRAMID_RSS , rss_bpf__elf_bytes) +ebpf_binary_init (EBPF_PROGRAM_ID_RSS , rss_bpf__elf_bytes)
Signature · 1 line
2.46.0
PATCH v2 7/19 qapi/machine: Drop temporary 'prefix'
In reply to Markus ArmbrusterRecent 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.
--- qapi/machine.json | 2 -- hw/core/numa.c | 4 ++-- hw/pci-bridge/cxl_upstream.c | 4 ++-- 3 files changed, 4 insertions(+), 6 deletions(-)
qapi/machine.json +0 -2
@@ -686,7 +686,6 @@ # Since: 5.0 ## { 'enum': 'HmatLBMemoryHierarchy', - 'prefix': 'HMATLB_MEMORY_HIERARCHY', # TODO drop 'data': [ 'memory', 'first-level', 'second-level', 'third-level' ] } ##
@@ -713,7 +712,6 @@ # Since: 5.0 ## { 'enum': 'HmatLBDataType', - 'prefix': 'HMATLB_DATA_TYPE', # TODO drop 'data': [ 'access-latency', 'read-latency', 'write-latency', 'access-bandwidth', 'read-bandwidth', 'write-bandwidth' ] }
hw/core/numa.c +2 -2
@@ -249,7 +249,7 @@ void parse_numa_hmat_lb(NumaState *numa_state, NumaHmatLBOptions *node, lb_data.initiator = node->initiator; lb_data.target = node->target; -if (node->data_type <=HMATLB_DATA_TYPE_WRITE_LATENCY ) { +if (node->data_type <=HMAT_LB_DATA_TYPE_WRITE_LATENCY ) {/* Input latency data */ if (!node->has_latency) {
@@ -313,7 +313,7 @@ void parse_numa_hmat_lb(NumaState *numa_state, NumaHmatLBOptions *node, numa_info[node->target].lb_info_provided |=BIT (0 ); } lb_data.data = node->latency; - }else if (node->data_type >=HMATLB_DATA_TYPE_ACCESS_BANDWIDTH ) { + }else if (node->data_type >=HMAT_LB_DATA_TYPE_ACCESS_BANDWIDTH ) {/* Input bandwidth data */ if (!node->has_bandwidth) {error_setg (errp,"Missing 'bandwidth' option" );
hw/pci-bridge/cxl_upstream.c +2 -2
@@ -234,7 +234,7 @@ static int build_cdat_table(CDATSubHeader ***cdat_table, void *priv) .type = CDAT_TYPE_SSLBIS, .length = sslbis_size, }, - .data_type = HMATLB_DATA_TYPE_ACCESS_LATENCY, + .data_type = HMAT_LB_DATA_TYPE_ACCESS_LATENCY, .entry_base_unit = 10000, }, };
@@ -254,7 +254,7 @@ static int build_cdat_table(CDATSubHeader ***cdat_table, void *priv) .type = CDAT_TYPE_SSLBIS, .length = sslbis_size, }, - .data_type = HMATLB_DATA_TYPE_ACCESS_BANDWIDTH, + .data_type = HMAT_LB_DATA_TYPE_ACCESS_BANDWIDTH, .entry_base_unit = 1024, }, };
Signature · 1 line
2.46.0
PATCH v2 8/19 qapi/ui: Drop temporary 'prefix'
In reply to Markus ArmbrusterRecent 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.
--- 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(-)
qapi/ui.json +0 -1
@@ -1397,7 +1397,6 @@ # Since: 3.0 ## { 'enum' : 'DisplayGLMode', - 'prefix' : 'DISPLAYGL_MODE', # TODO drop 'data' : [ 'off', 'on', 'core', 'es' ] } ##
system/vl.c +1 -1
@@ -1971,7 +1971,7 @@ static void qemu_create_early_backends(void)qemu_console_early_init (); -if (dpy.has_gl && dpy.gl !=DISPLAYGL_MODE_OFF && display_opengl ==0 ) { +if (dpy.has_gl && dpy.gl !=DISPLAY_GL_MODE_OFF && display_opengl ==0 ) {#if defined(CONFIG_OPENGL )error_report ("OpenGL is not supported by display backend '%s'" ,DisplayType_str (dpy.type));
ui/dbus.c +4 -4
@@ -176,7 +176,7 @@ dbus_display_add_console(DBusDisplay *dd, int idx, Error **errp)assert (con);if (qemu_console_is_graphic (con) && - dd->gl_mode !=DISPLAYGL_MODE_OFF ) { + dd->gl_mode !=DISPLAY_GL_MODE_OFF ) {qemu_console_set_display_gl_ctx (con, &dd->glctx); }
@@ -466,9 +466,9 @@ static const TypeInfo dbus_vc_type_info = {static void early_dbus_init (DisplayOptions *opts) { -DisplayGLMode mode = opts->has_gl ? opts->gl :DISPLAYGL_MODE_OFF ; +DisplayGLMode mode = opts->has_gl ? opts->gl :DISPLAY_GL_MODE_OFF ; -if (mode !=DISPLAYGL_MODE_OFF ) { +if (mode !=DISPLAY_GL_MODE_OFF ) {#ifdef CONFIG_OPENGL egl_init (opts->u.dbus.rendernode, mode, &error_fatal);#else
@@ -482,7 +482,7 @@ early_dbus_init(DisplayOptions *opts)static void dbus_init (DisplayState *ds,DisplayOptions *opts) { -DisplayGLMode mode = opts->has_gl ? opts->gl :DISPLAYGL_MODE_OFF ; +DisplayGLMode mode = opts->has_gl ? opts->gl :DISPLAY_GL_MODE_OFF ;if (opts->u.dbus.addr && opts->u.dbus.p2p) {error_report ("dbus: can't accept both addr=X and p2p=yes options" );
ui/egl-context.c +1 -1
@@ -17,7 +17,7 @@ QEMUGLContext qemu_egl_create_context(DisplayGLCtx *dgc,EGL_CONTEXT_MINOR_VERSION_KHR , params->minor_ver,EGL_NONE }; -bool gles = (qemu_egl_mode ==DISPLAYGL_MODE_ES ); +bool gles = (qemu_egl_mode ==DISPLAY_GL_MODE_ES ); ctx = eglCreateContext(qemu_egl_display, qemu_egl_config, eglGetCurrentContext(),
ui/egl-headless.c +1 -1
@@ -207,7 +207,7 @@ static const DisplayGLCtxOps eglctx_ops = {static void early_egl_headless_init (DisplayOptions *opts) { -DisplayGLMode mode =DISPLAYGL_MODE_ON ; +DisplayGLMode mode =DISPLAY_GL_MODE_ON ;if (opts->has_gl) { mode = opts->gl;
ui/egl-helpers.c +6 -6
@@ -503,7 +503,7 @@ static int qemu_egl_init_dpy(EGLNativeDisplayType dpy,EGLint major, minor;EGLBoolean b;EGLint n; -bool gles = (mode ==DISPLAYGL_MODE_ES ); +bool gles = (mode ==DISPLAY_GL_MODE_ES ); qemu_egl_display =qemu_egl_get_display (dpy, platform);if (qemu_egl_display ==EGL_NO_DISPLAY ) {
@@ -533,7 +533,7 @@ static int qemu_egl_init_dpy(EGLNativeDisplayType dpy,return -1 ; } - qemu_egl_mode = gles ?DISPLAYGL_MODE_ES :DISPLAYGL_MODE_CORE ; + qemu_egl_mode = gles ?DISPLAY_GL_MODE_ES :DISPLAY_GL_MODE_CORE ;return 0 ; }
@@ -564,8 +564,8 @@ int qemu_egl_init_dpy_mesa(EGLNativeDisplayType dpy, DisplayGLMode mode)int qemu_egl_init_dpy_win32 (EGLNativeDisplayType dpy,DisplayGLMode mode) {/* prefer GL ES, as that's what ANGLE supports */ -if (mode ==DISPLAYGL_MODE_ON ) { - mode =DISPLAYGL_MODE_ES ; +if (mode ==DISPLAY_GL_MODE_ON ) { + mode =DISPLAY_GL_MODE_ES ; }if (qemu_egl_init_dpy (dpy,0 , mode) <0 ) {
@@ -618,7 +618,7 @@ EGLContext qemu_egl_init_ctx(void)EGL_CONTEXT_CLIENT_VERSION ,2 , EGL_NONE }; -bool gles = (qemu_egl_mode ==DISPLAYGL_MODE_ES ); +bool gles = (qemu_egl_mode ==DISPLAY_GL_MODE_ES );EGLContext ectx;EGLBoolean b;
@@ -642,7 +642,7 @@ bool egl_init(const char *rendernode, DisplayGLMode mode, Error **errp) {ERRP_GUARD (); -if (mode ==DISPLAYGL_MODE_OFF ) { +if (mode ==DISPLAY_GL_MODE_OFF ) {error_setg (errp,"egl: turning off GL doesn't make sense" );return false; }
ui/gtk.c +2 -2
@@ -2514,7 +2514,7 @@ static void early_gtk_display_init(DisplayOptions *opts) }assert (opts->type ==DISPLAY_TYPE_GTK ); -if (opts->has_gl && opts->gl !=DISPLAYGL_MODE_OFF ) { +if (opts->has_gl && opts->gl !=DISPLAY_GL_MODE_OFF ) { #if defined(CONFIG_OPENGL) #if defined(GDK_WINDOWING_WAYLAND) if (GDK_IS_WAYLAND_DISPLAY(gdk_display_get_default())) {
@@ -2530,7 +2530,7 @@ static void early_gtk_display_init(DisplayOptions *opts)#endif {#ifdef CONFIG_X11 -DisplayGLMode mode = opts->has_gl ? opts->gl :DISPLAYGL_MODE_ON ; +DisplayGLMode mode = opts->has_gl ? opts->gl :DISPLAY_GL_MODE_ON ;gtk_egl_init (mode);#endif }
ui/sdl2-gl.c +4 -4
@@ -147,11 +147,11 @@ QEMUGLContext sdl2_gl_create_context(DisplayGLCtx *dgc,SDL_GL_MakeCurrent (scon->real_window, scon->winctx);SDL_GL_SetAttribute (SDL_GL_SHARE_WITH_CURRENT_CONTEXT ,1 ); -if (scon->opts->gl ==DISPLAYGL_MODE_ON || - scon->opts->gl ==DISPLAYGL_MODE_CORE ) { +if (scon->opts->gl ==DISPLAY_GL_MODE_ON || + scon->opts->gl ==DISPLAY_GL_MODE_CORE ) {SDL_GL_SetAttribute (SDL_GL_CONTEXT_PROFILE_MASK ,SDL_GL_CONTEXT_PROFILE_CORE ); - }else if (scon->opts->gl ==DISPLAYGL_MODE_ES ) { + }else if (scon->opts->gl ==DISPLAY_GL_MODE_ES ) {SDL_GL_SetAttribute (SDL_GL_CONTEXT_PROFILE_MASK ,SDL_GL_CONTEXT_PROFILE_ES ); }
@@ -163,7 +163,7 @@ QEMUGLContext sdl2_gl_create_context(DisplayGLCtx *dgc,/* If SDL fail to create a GL context and we use the "on" flag, * then try to fallback to GLES. */ -if (!ctx && scon->opts->gl ==DISPLAYGL_MODE_ON ) { +if (!ctx && scon->opts->gl ==DISPLAY_GL_MODE_ON ) {SDL_GL_SetAttribute (SDL_GL_CONTEXT_PROFILE_MASK ,SDL_GL_CONTEXT_PROFILE_ES ); ctx =SDL_GL_CreateContext (scon->real_window);
ui/sdl2.c +1 -1
@@ -107,7 +107,7 @@ void sdl2_window_create(struct sdl2_console *scon)if (scon->opengl) {const char *driver ="opengl" ; -if (scon->opts->gl ==DISPLAYGL_MODE_ES ) { +if (scon->opts->gl ==DISPLAY_GL_MODE_ES ) { driver ="opengles2" ; }
ui/spice-core.c +1 -1
@@ -840,7 +840,7 @@ static void qemu_spice_init(void) "incompatible with -spice port/tls-port");exit (1 ); } -egl_init (qemu_opt_get (opts,"rendernode" ),DISPLAYGL_MODE_ON , &error_fatal); +egl_init (qemu_opt_get (opts,"rendernode" ),DISPLAY_GL_MODE_ON , &error_fatal); spice_opengl =1 ; }#endif
Signature · 1 line
2.46.0
PATCH v2 9/19 qapi/machine: Rename CpuS390* to S390Cpu*, and drop 'prefix'
In reply to Markus ArmbrusterQAPI'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.
--- 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(-)
qapi/machine-common.json +2 -3
@@ -9,13 +9,12 @@ ## ## -# @CpuS390Entitlement: +# @S390CpuEntitlement: # # An enumeration of CPU entitlements that can be assumed by a virtual # S390 CPU # # Since: 8.2 ## -{ 'enum': 'CpuS390Entitlement', - 'prefix': 'S390_CPU_ENTITLEMENT', +{ 'enum': 'S390CpuEntitlement', 'data': [ 'auto', 'low', 'medium', 'high' ] }
qapi/machine-target.json +5 -6
@@ -405,15 +405,14 @@ 'TARGET_RISCV' ] } } ## -# @CpuS390Polarization: +# @S390CpuPolarization: # # An enumeration of CPU polarization that can be assumed by a virtual # S390 CPU # # Since: 8.2 ## -{ 'enum': 'CpuS390Polarization', - 'prefix': 'S390_CPU_POLARIZATION', +{ 'enum': 'S390CpuPolarization', 'data': [ 'horizontal', 'vertical' ], 'if': 'TARGET_S390X' }
@@ -450,7 +449,7 @@ '*socket-id': 'uint16', '*book-id': 'uint16', '*drawer-id': 'uint16', - '*entitlement': 'CpuS390Entitlement', + '*entitlement': 'S390CpuEntitlement', '*dedicated': 'bool' }, 'features': [ 'unstable' ],
@@ -488,7 +487,7 @@ # "timestamp": { "seconds": 1401385907, "microseconds": 422329 } } ## { 'event': 'CPU_POLARIZATION_CHANGE', - 'data': { 'polarization': 'CpuS390Polarization' }, + 'data': { 'polarization': 'S390CpuPolarization' }, 'features': [ 'unstable' ], 'if': { 'all': [ 'TARGET_S390X', 'CONFIG_KVM' ] } }
@@ -503,7 +502,7 @@ # Since: 8.2 ## { 'struct': 'CpuPolarizationInfo', - 'data': { 'polarization': 'CpuS390Polarization' }, + 'data': { 'polarization': 'S390CpuPolarization' }, 'if': { 'all': [ 'TARGET_S390X', 'CONFIG_KVM' ] } }
qapi/machine.json +4 -5
@@ -41,15 +41,14 @@ 'x86_64', 'xtensa', 'xtensaeb' ] } ## -# @CpuS390State: +# @S390CpuState: # # An enumeration of cpu states that can be assumed by a virtual S390 # CPU # # Since: 2.12 ## -{ 'enum': 'CpuS390State', - 'prefix': 'S390_CPU_STATE', +{ 'enum': 'S390CpuState', 'data': [ 'uninitialized', 'stopped', 'check-stop', 'operating', 'load' ] } ##
@@ -66,9 +65,9 @@ # Since: 2.12 ## { 'struct': 'CpuInfoS390', - 'data': { 'cpu-state': 'CpuS390State', + 'data': { 'cpu-state': 'S390CpuState', '*dedicated': 'bool', - '*entitlement': 'CpuS390Entitlement' } } + '*entitlement': 'S390CpuEntitlement' } } ## # @CpuInfoFast:
qapi/pragma.json +3 -3
@@ -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',
include/hw/qdev-properties-system.h +1 -1
@@ -88,7 +88,7 @@ extern const PropertyInfo qdev_prop_iothread_vq_mapping_list;#define DEFINE_PROP_CPUS390ENTITLEMENT (_n, _s, _f, _d) \ DEFINE_PROP_SIGNED(_n, _s, _f, _d, qdev_prop_cpus390entitlement, \ - CpuS390Entitlement) + S390CpuEntitlement)#define DEFINE_PROP_IOTHREAD_VQ_MAPPING_LIST (_name, _state, _field) \ DEFINE_PROP(_name, _state, _field, qdev_prop_iothread_vq_mapping_list, \
include/hw/s390x/cpu-topology.h +1 -1
@@ -37,7 +37,7 @@ typedef struct S390TopologyEntry {typedef struct S390Topology {uint8_t *cores_per_socket; -CpuS390Polarization polarization; +S390CpuPolarization polarization; }S390Topology ; typedef QTAILQ_HEAD(, S390TopologyEntry) S390TopologyList;
target/s390x/cpu.h +1 -1
@@ -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
hw/core/qdev-properties-system.c +3 -3
@@ -1188,12 +1188,12 @@ const PropertyInfo qdev_prop_uuid = {/* --- s390 cpu entitlement policy --- */ -QEMU_BUILD_BUG_ON (sizeof (CpuS390Entitlement) !=sizeof (int )); +QEMU_BUILD_BUG_ON (sizeof (S390CpuEntitlement) !=sizeof (int ));const PropertyInfo qdev_prop_cpus390entitlement = { - .name ="CpuS390Entitlement" , + .name ="S390CpuEntitlement" , .description ="low/medium (default)/high" , - .enum_table = &CpuS390Entitlement_lookup, + .enum_table = &S390CpuEntitlement_lookup, .get = qdev_propinfo_get_enum, .set = qdev_propinfo_set_enum, .set_default_value = qdev_propinfo_set_default_value_enum,
hw/s390x/cpu-topology.c +3 -3
@@ -105,7 +105,7 @@ static void s390_topology_init(MachineState *ms)*/ void s390_handle_ptf (S390CPU *cpu,uint8_t r1,uintptr_t ra) { -CpuS390Polarization polarization; +S390CpuPolarization polarization;CPUS390XState *env = &cpu->env;uint64_t reg = env->regs[r1];int fc = reg &S390_TOPO_FC_MASK ;
@@ -357,7 +357,7 @@ static void s390_change_topology(uint16_t core_id, bool has_book_id, uint16_t book_id, bool has_drawer_id, uint16_t drawer_id, bool has_entitlement, - CpuS390Entitlement entitlement, + S390CpuEntitlement entitlement, bool has_dedicated, bool dedicated, Error **errp) {
@@ -446,7 +446,7 @@ void qmp_set_cpu_topology(uint16_t core, bool has_socket, uint16_t socket, bool has_book, uint16_t book, bool has_drawer, uint16_t drawer, - bool has_entitlement, CpuS390Entitlement entitlement, + bool has_entitlement, S390CpuEntitlement entitlement, bool has_dedicated, bool dedicated, Error **errp) {
Signature · 1 line
2.46.0
PATCH v2 10/19 qapi/crypto: Drop unwanted 'prefix'
In reply to Markus ArmbrusterQAPI'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.
--- 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(-)
qapi/crypto.json +0 -1
@@ -609,7 +609,6 @@ # Since: 7.1 ## { 'enum': 'QCryptoAkCipherKeyType', - 'prefix': 'QCRYPTO_AKCIPHER_KEY_TYPE', 'data': ['public', 'private']} ##
backends/cryptodev-builtin.c +2 -2
@@ -334,11 +334,11 @@ static int cryptodev_builtin_create_akcipher_session(switch (sess_info->keytype) {case VIRTIO_CRYPTO_AKCIPHER_KEY_TYPE_PUBLIC : - type =QCRYPTO_AKCIPHER_KEY_TYPE_PUBLIC ; + type =QCRYPTO_AK_CIPHER_KEY_TYPE_PUBLIC ;break ;case VIRTIO_CRYPTO_AKCIPHER_KEY_TYPE_PRIVATE : - type =QCRYPTO_AKCIPHER_KEY_TYPE_PRIVATE ; + type =QCRYPTO_AK_CIPHER_KEY_TYPE_PRIVATE ;break ;default :
backends/cryptodev-lkcf.c +3 -3
@@ -322,7 +322,7 @@ static void cryptodev_lkcf_execute_task(CryptoDevLKCFTask *task)* 2. generally, public key related compution is fast, just compute it with * thread-pool. */ -if (session->keytype ==QCRYPTO_AKCIPHER_KEY_TYPE_PRIVATE ) { +if (session->keytype ==QCRYPTO_AK_CIPHER_KEY_TYPE_PRIVATE ) { if (qcrypto_akcipher_export_p8info(&session->akcipher_opts, session->key, session->keylen, &p8info, &p8info_len,
@@ -534,11 +534,11 @@ static int cryptodev_lkcf_create_asym_session(switch (sess_info->keytype) {case VIRTIO_CRYPTO_AKCIPHER_KEY_TYPE_PUBLIC : - sess->keytype =QCRYPTO_AKCIPHER_KEY_TYPE_PUBLIC ; + sess->keytype =QCRYPTO_AK_CIPHER_KEY_TYPE_PUBLIC ;break ;case VIRTIO_CRYPTO_AKCIPHER_KEY_TYPE_PRIVATE : - sess->keytype =QCRYPTO_AKCIPHER_KEY_TYPE_PRIVATE ; + sess->keytype =QCRYPTO_AK_CIPHER_KEY_TYPE_PRIVATE ;break ;default :
tests/bench/benchmark-crypto-akcipher.c +1 -1
@@ -28,7 +28,7 @@ static QCryptoAkCipher *create_rsa_akcipher(const uint8_t *priv_key, opt.alg =QCRYPTO_AKCIPHER_ALG_RSA ; opt.u.rsa.padding_alg = padding; opt.u.rsa.hash_alg = hash; -return qcrypto_akcipher_new (&opt,QCRYPTO_AKCIPHER_KEY_TYPE_PRIVATE , +return qcrypto_akcipher_new (&opt,QCRYPTO_AK_CIPHER_KEY_TYPE_PRIVATE , priv_key, keylen, &error_abort); }
tests/unit/test-crypto-akcipher.c +14 -14
@@ -692,7 +692,7 @@ struct QCryptoAkCipherTestData {static QCryptoRSAKeyTestData rsakey_test_data[] = { { .path ="/crypto/akcipher/rsakey-1024-public" , - .key_type =QCRYPTO_AKCIPHER_KEY_TYPE_PUBLIC , + .key_type =QCRYPTO_AK_CIPHER_KEY_TYPE_PUBLIC , .key = rsa1024_public_key, .keylen =sizeof (rsa1024_public_key), .is_valid_key = true,
@@ -700,7 +700,7 @@ static QCryptoRSAKeyTestData rsakey_test_data[] = { }, { .path = "/crypto/akcipher/rsakey-1024-private", - .key_type = QCRYPTO_AKCIPHER_KEY_TYPE_PRIVATE, + .key_type = QCRYPTO_AK_CIPHER_KEY_TYPE_PRIVATE, .key = rsa1024_private_key, .keylen = sizeof(rsa1024_private_key), .is_valid_key = true,
@@ -708,7 +708,7 @@ static QCryptoRSAKeyTestData rsakey_test_data[] = { }, { .path = "/crypto/akcipher/rsakey-2048-public", - .key_type = QCRYPTO_AKCIPHER_KEY_TYPE_PUBLIC, + .key_type = QCRYPTO_AK_CIPHER_KEY_TYPE_PUBLIC, .key = rsa2048_public_key, .keylen = sizeof(rsa2048_public_key), .is_valid_key = true,
@@ -716,7 +716,7 @@ static QCryptoRSAKeyTestData rsakey_test_data[] = { }, { .path = "/crypto/akcipher/rsakey-2048-private", - .key_type = QCRYPTO_AKCIPHER_KEY_TYPE_PRIVATE, + .key_type = QCRYPTO_AK_CIPHER_KEY_TYPE_PRIVATE, .key = rsa2048_private_key, .keylen = sizeof(rsa2048_private_key), .is_valid_key = true,
@@ -724,56 +724,56 @@ static QCryptoRSAKeyTestData rsakey_test_data[] = { }, { .path = "/crypto/akcipher/rsakey-public-lack-elem", - .key_type = QCRYPTO_AKCIPHER_KEY_TYPE_PUBLIC, + .key_type = QCRYPTO_AK_CIPHER_KEY_TYPE_PUBLIC, .key = rsa_public_key_lack_element, .keylen = sizeof(rsa_public_key_lack_element), .is_valid_key = false, }, { .path = "/crypto/akcipher/rsakey-private-lack-elem", - .key_type = QCRYPTO_AKCIPHER_KEY_TYPE_PRIVATE, + .key_type = QCRYPTO_AK_CIPHER_KEY_TYPE_PRIVATE, .key = rsa_private_key_lack_element, .keylen = sizeof(rsa_private_key_lack_element), .is_valid_key = false, }, { .path = "/crypto/akcipher/rsakey-public-empty-elem", - .key_type = QCRYPTO_AKCIPHER_KEY_TYPE_PUBLIC, + .key_type = QCRYPTO_AK_CIPHER_KEY_TYPE_PUBLIC, .key = rsa_public_key_empty_element, .keylen = sizeof(rsa_public_key_empty_element), .is_valid_key = false, }, { .path = "/crypto/akcipher/rsakey-private-empty-elem", - .key_type = QCRYPTO_AKCIPHER_KEY_TYPE_PRIVATE, + .key_type = QCRYPTO_AK_CIPHER_KEY_TYPE_PRIVATE, .key = rsa_private_key_empty_element, .keylen = sizeof(rsa_private_key_empty_element), .is_valid_key = false, }, { .path = "/crypto/akcipher/rsakey-public-empty-key", - .key_type = QCRYPTO_AKCIPHER_KEY_TYPE_PUBLIC, + .key_type = QCRYPTO_AK_CIPHER_KEY_TYPE_PUBLIC, .key = NULL, .keylen = 0, .is_valid_key = false, }, { .path = "/crypto/akcipher/rsakey-private-empty-key", - .key_type = QCRYPTO_AKCIPHER_KEY_TYPE_PRIVATE, + .key_type = QCRYPTO_AK_CIPHER_KEY_TYPE_PRIVATE, .key = NULL, .keylen = 0, .is_valid_key = false, }, { .path = "/crypto/akcipher/rsakey-public-invalid-length-val", - .key_type = QCRYPTO_AKCIPHER_KEY_TYPE_PUBLIC, + .key_type = QCRYPTO_AK_CIPHER_KEY_TYPE_PUBLIC, .key = rsa_public_key_invalid_length_val, .keylen = sizeof(rsa_public_key_invalid_length_val), .is_valid_key = false, }, { .path = "/crypto/akcipher/rsakey-public-extra-elem", - .key_type = QCRYPTO_AKCIPHER_KEY_TYPE_PUBLIC, + .key_type = QCRYPTO_AK_CIPHER_KEY_TYPE_PUBLIC, .key = rsa_public_key_extra_elem, .keylen = sizeof(rsa_public_key_extra_elem), .is_valid_key = false,
@@ -885,12 +885,12 @@ static void test_akcipher(const void *opaque)return ; } pub_key =qcrypto_akcipher_new (&data->opt, -QCRYPTO_AKCIPHER_KEY_TYPE_PUBLIC , +QCRYPTO_AK_CIPHER_KEY_TYPE_PUBLIC , data->pub_key, data->pub_key_len, &error_abort);g_assert (pub_key !=NULL ); priv_key =qcrypto_akcipher_new (&data->opt, -QCRYPTO_AKCIPHER_KEY_TYPE_PRIVATE , +QCRYPTO_AK_CIPHER_KEY_TYPE_PRIVATE , data->priv_key, data->priv_key_len, &error_abort);g_assert (priv_key !=NULL );
crypto/akcipher-gcrypt.c.inc +4 -4
@@ -85,7 +85,7 @@ static int qcrypto_gcrypt_parse_rsa_private_key( const uint8_t *key, size_t keylen, Error **errp) { g_autoptr(QCryptoAkCipherRSAKey) rsa_key = qcrypto_akcipher_rsakey_parse( - QCRYPTO_AKCIPHER_KEY_TYPE_PRIVATE, key, keylen, errp); + QCRYPTO_AK_CIPHER_KEY_TYPE_PRIVATE, key, keylen, errp); gcry_mpi_t n = NULL, e = NULL, d = NULL, p = NULL, q = NULL, u = NULL; bool compute_mul_inv = false; int ret = -1;
@@ -178,7 +178,7 @@ static int qcrypto_gcrypt_parse_rsa_public_key(QCryptoGcryptRSA *rsa, { g_autoptr(QCryptoAkCipherRSAKey) rsa_key = qcrypto_akcipher_rsakey_parse( - QCRYPTO_AKCIPHER_KEY_TYPE_PUBLIC, key, keylen, errp); + QCRYPTO_AK_CIPHER_KEY_TYPE_PUBLIC, key, keylen, errp); gcry_mpi_t n = NULL, e = NULL; int ret = -1; gcry_error_t err;
@@ -540,13 +540,13 @@ static QCryptoGcryptRSA *qcrypto_gcrypt_rsa_new( rsa->akcipher.driver = &gcrypt_rsa; switch (type) { - case QCRYPTO_AKCIPHER_KEY_TYPE_PRIVATE: + case QCRYPTO_AK_CIPHER_KEY_TYPE_PRIVATE: if (qcrypto_gcrypt_parse_rsa_private_key(rsa, key, keylen, errp) != 0) { goto error; } break; - case QCRYPTO_AKCIPHER_KEY_TYPE_PUBLIC: + case QCRYPTO_AK_CIPHER_KEY_TYPE_PUBLIC: if (qcrypto_gcrypt_parse_rsa_public_key(rsa, key, keylen, errp) != 0) { goto error; }
crypto/akcipher-nettle.c.inc +4 -4
@@ -87,7 +87,7 @@ static int qcrypt_nettle_parse_rsa_private_key(QCryptoNettleRSA *rsa, Error **errp) { g_autoptr(QCryptoAkCipherRSAKey) rsa_key = qcrypto_akcipher_rsakey_parse( - QCRYPTO_AKCIPHER_KEY_TYPE_PRIVATE, key, keylen, errp); + QCRYPTO_AK_CIPHER_KEY_TYPE_PRIVATE, key, keylen, errp); if (!rsa_key) { return -1;
@@ -137,7 +137,7 @@ static int qcrypt_nettle_parse_rsa_public_key(QCryptoNettleRSA *rsa, Error **errp) { g_autoptr(QCryptoAkCipherRSAKey) rsa_key = qcrypto_akcipher_rsakey_parse( - QCRYPTO_AKCIPHER_KEY_TYPE_PUBLIC, key, keylen, errp); + QCRYPTO_AK_CIPHER_KEY_TYPE_PUBLIC, key, keylen, errp); if (!rsa_key) { return -1;
@@ -397,13 +397,13 @@ static QCryptoAkCipher *qcrypto_nettle_rsa_new( rsa_private_key_init(&rsa->priv); switch (type) { - case QCRYPTO_AKCIPHER_KEY_TYPE_PRIVATE: + case QCRYPTO_AK_CIPHER_KEY_TYPE_PRIVATE: if (qcrypt_nettle_parse_rsa_private_key(rsa, key, keylen, errp) != 0) { goto error; } break; - case QCRYPTO_AKCIPHER_KEY_TYPE_PUBLIC: + case QCRYPTO_AK_CIPHER_KEY_TYPE_PUBLIC: if (qcrypt_nettle_parse_rsa_public_key(rsa, key, keylen, errp) != 0) { goto error; }
crypto/rsakey-builtin.c.inc +2 -2
@@ -183,10 +183,10 @@ QCryptoAkCipherRSAKey *qcrypto_akcipher_rsakey_parse( size_t keylen, Error **errp) { switch (type) { - case QCRYPTO_AKCIPHER_KEY_TYPE_PRIVATE: + case QCRYPTO_AK_CIPHER_KEY_TYPE_PRIVATE: return qcrypto_builtin_rsa_private_key_parse(key, keylen, errp); - case QCRYPTO_AKCIPHER_KEY_TYPE_PUBLIC: + case QCRYPTO_AK_CIPHER_KEY_TYPE_PUBLIC: return qcrypto_builtin_rsa_public_key_parse(key, keylen, errp); default:
crypto/rsakey-nettle.c.inc +2 -2
@@ -145,10 +145,10 @@ QCryptoAkCipherRSAKey *qcrypto_akcipher_rsakey_parse( size_t keylen, Error **errp) { switch (type) { - case QCRYPTO_AKCIPHER_KEY_TYPE_PRIVATE: + case QCRYPTO_AK_CIPHER_KEY_TYPE_PRIVATE: return qcrypto_nettle_rsa_private_key_parse(key, keylen, errp); - case QCRYPTO_AKCIPHER_KEY_TYPE_PUBLIC: + case QCRYPTO_AK_CIPHER_KEY_TYPE_PUBLIC: return qcrypto_nettle_rsa_public_key_parse(key, keylen, errp); default:
Signature · 1 line
2.46.0
PATCH v2 11/19 qapi/crypto: Rename QCryptoHashAlgorithm to *Algo, and drop prefix
In reply to Markus ArmbrusterQAPI'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.
--- qapi/crypto.json | 17 +++++----- crypto/blockpriv.h | 2 +- crypto/hashpriv.h | 2 +- crypto/hmacpriv.h | 4 +-- crypto/ivgenpriv.h | 2 +- include/crypto/afsplit.h | 8 ++--- include/crypto/block.h | 2 +- include/crypto/hash.h | 18 +++++----- include/crypto/hmac.h | 6 ++-- include/crypto/ivgen.h | 6 ++-- include/crypto/pbkdf.h | 10 +++--- backends/cryptodev-builtin.c | 8 ++--- backends/cryptodev-lkcf.c | 10 +++--- block/parallels-ext.c | 2 +- block/quorum.c | 4 +-- crypto/afsplit.c | 6 ++-- crypto/block-luks.c | 16 ++++----- crypto/block.c | 2 +- crypto/hash-afalg.c | 26 +++++++-------- crypto/hash-gcrypt.c | 20 +++++------ crypto/hash-glib.c | 20 +++++------ crypto/hash-gnutls.c | 20 +++++------ crypto/hash-nettle.c | 18 +++++----- crypto/hash.c | 30 ++++++++--------- crypto/hmac-gcrypt.c | 22 ++++++------- crypto/hmac-glib.c | 22 ++++++------- crypto/hmac-gnutls.c | 22 ++++++------- crypto/hmac-nettle.c | 22 ++++++------- crypto/hmac.c | 2 +- crypto/ivgen.c | 4 +-- crypto/pbkdf-gcrypt.c | 36 ++++++++++---------- crypto/pbkdf-gnutls.c | 36 ++++++++++---------- crypto/pbkdf-nettle.c | 32 +++++++++--------- crypto/pbkdf-stub.c | 4 +-- crypto/pbkdf.c | 2 +- hw/misc/aspeed_hace.c | 16 ++++----- io/channel-websock.c | 2 +- target/i386/sev.c | 6 ++-- tests/bench/benchmark-crypto-akcipher.c | 12 +++---- tests/bench/benchmark-crypto-hash.c | 10 +++--- tests/bench/benchmark-crypto-hmac.c | 6 ++-- tests/unit/test-crypto-afsplit.c | 10 +++--- tests/unit/test-crypto-akcipher.c | 6 ++-- tests/unit/test-crypto-block.c | 16 ++++----- tests/unit/test-crypto-hash.c | 42 +++++++++++------------ tests/unit/test-crypto-hmac.c | 16 ++++----- tests/unit/test-crypto-ivgen.c | 8 ++--- tests/unit/test-crypto-pbkdf.c | 44 ++++++++++++------------- ui/vnc.c | 2 +- util/hbitmap.c | 2 +- crypto/akcipher-gcrypt.c.inc | 14 ++++---- crypto/akcipher-nettle.c.inc | 26 +++++++-------- 52 files changed, 350 insertions(+), 351 deletions(-)
qapi/crypto.json +8 -9
@@ -38,7 +38,7 @@ 'data': ['raw', 'base64']} ## -# @QCryptoHashAlgorithm: +# @QCryptoHashAlgo: # # The supported algorithms for computing content digests #
@@ -58,8 +58,7 @@ # # Since: 2.6 ## -{ 'enum': 'QCryptoHashAlgorithm', - 'prefix': 'QCRYPTO_HASH_ALG', +{ 'enum': 'QCryptoHashAlgo', 'data': ['md5', 'sha1', 'sha224', 'sha256', 'sha384', 'sha512', 'ripemd160']} ##
@@ -229,8 +228,8 @@ 'data': { '*cipher-alg': 'QCryptoCipherAlgorithm', '*cipher-mode': 'QCryptoCipherMode', '*ivgen-alg': 'QCryptoIVGenAlgorithm', - '*ivgen-hash-alg': 'QCryptoHashAlgorithm', - '*hash-alg': 'QCryptoHashAlgorithm', + '*ivgen-hash-alg': 'QCryptoHashAlgo', + '*hash-alg': 'QCryptoHashAlgo', '*iter-time': 'int' }} ##
@@ -326,8 +325,8 @@ 'data': {'cipher-alg': 'QCryptoCipherAlgorithm', 'cipher-mode': 'QCryptoCipherMode', 'ivgen-alg': 'QCryptoIVGenAlgorithm', - '*ivgen-hash-alg': 'QCryptoHashAlgorithm', - 'hash-alg': 'QCryptoHashAlgorithm', + '*ivgen-hash-alg': 'QCryptoHashAlgo', + 'hash-alg': 'QCryptoHashAlgo', 'detached-header': 'bool', 'payload-offset': 'int', 'master-key-iters': 'int',
@@ -631,14 +630,14 @@ # # Specific parameters for RSA algorithm. # -# @hash-alg: QCryptoHashAlgorithm +# @hash-alg: QCryptoHashAlgo # # @padding-alg: QCryptoRSAPaddingAlgorithm # # Since: 7.1 ## { 'struct': 'QCryptoAkCipherOptionsRSA', - 'data': { 'hash-alg':'QCryptoHashAlgorithm', + 'data': { 'hash-alg':'QCryptoHashAlgo', 'padding-alg': 'QCryptoRSAPaddingAlgorithm'}} ##
crypto/blockpriv.h +1 -1
@@ -44,7 +44,7 @@ struct QCryptoBlock {QCryptoIVGen *ivgen;QemuMutex mutex; -QCryptoHashAlgorithm kdfhash; +QCryptoHashAlgo kdfhash;size_t niv;uint64_t payload_offset;/* In bytes */ uint64_t sector_size;/* In bytes */
crypto/hashpriv.h +1 -1
@@ -18,7 +18,7 @@typedef struct QCryptoHashDriver QCryptoHashDriver ;struct QCryptoHashDriver { - int (*hash_bytesv)(QCryptoHashAlgorithm alg, + int (*hash_bytesv)(QCryptoHashAlgo alg, const struct iovec *iov, size_t niov, uint8_t **result,
crypto/hmacpriv.h +2 -2
@@ -28,7 +28,7 @@ struct QCryptoHmacDriver {void (*hmac_free)(QCryptoHmac *hmac); }; -void *qcrypto_hmac_ctx_new (QCryptoHashAlgorithm alg, +void *qcrypto_hmac_ctx_new (QCryptoHashAlgo alg,const uint8_t *key,size_t nkey,Error **errp);extern QCryptoHmacDriver qcrypto_hmac_lib_driver;
@@ -37,7 +37,7 @@ extern QCryptoHmacDriver qcrypto_hmac_lib_driver;#include "afalgpriv.h" -QCryptoAFAlg *qcrypto_afalg_hmac_ctx_new (QCryptoHashAlgorithm alg, +QCryptoAFAlg *qcrypto_afalg_hmac_ctx_new (QCryptoHashAlgo alg,const uint8_t *key,size_t nkey,Error **errp);extern QCryptoHmacDriver qcrypto_hmac_afalg_driver;
crypto/ivgenpriv.h +1 -1
@@ -42,7 +42,7 @@ struct QCryptoIVGen {QCryptoIVGenAlgorithm algorithm;QCryptoCipherAlgorithm cipher; -QCryptoHashAlgorithm hash; +QCryptoHashAlgo hash; };
include/crypto/afsplit.h +4 -4
@@ -46,7 +46,7 @@* * splitkey = g_new0(uint8_t, nkey * stripes); * -* if (qcrypto_afsplit_encode(QCRYPTO_HASH_ALG_SHA256, +* if (qcrypto_afsplit_encode(QCRYPTO_HASH_ALGO_SHA256, * nkey, stripes, * masterkey, splitkey, errp) < 0) { * g_free(splitkey);
@@ -71,7 +71,7 @@* * masterkey = g_new0(uint8_t, nkey); * -* if (qcrypto_afsplit_decode(QCRYPTO_HASH_ALG_SHA256, +* if (qcrypto_afsplit_decode(QCRYPTO_HASH_ALGO_SHA256, * nkey, stripes, * splitkey, masterkey, errp) < 0) { * g_free(splitkey);
@@ -102,7 +102,7 @@* * Returns: 0 on success, -1 on error; */ -int qcrypto_afsplit_encode(QCryptoHashAlgorithm hash, +int qcrypto_afsplit_encode(QCryptoHashAlgo hash, size_t blocklen, uint32_t stripes, const uint8_t *in,
@@ -124,7 +124,7 @@ int qcrypto_afsplit_encode(QCryptoHashAlgorithm hash,* * Returns: 0 on success, -1 on error; */ -int qcrypto_afsplit_decode(QCryptoHashAlgorithm hash, +int qcrypto_afsplit_decode(QCryptoHashAlgo hash, size_t blocklen, uint32_t stripes, const uint8_t *in,
include/crypto/block.h +1 -1
@@ -287,7 +287,7 @@ QCryptoIVGen *qcrypto_block_get_ivgen(QCryptoBlock *block);* * Returns: the hash algorithm */ -QCryptoHashAlgorithm qcrypto_block_get_kdf_hash (QCryptoBlock *block); +QCryptoHashAlgo qcrypto_block_get_kdf_hash (QCryptoBlock *block);/** * qcrypto_block_get_payload_offset:
include/crypto/hash.h +9 -9
@@ -23,7 +23,7 @@#include "qapi/qapi-types-crypto.h" -/* See also "QCryptoHashAlgorithm" defined in qapi/crypto.json */ +/* See also "QCryptoHashAlgo" defined in qapi/crypto.json */ /** * qcrypto_hash_supports:
@@ -34,7 +34,7 @@* * Returns: true if the algorithm is supported, false otherwise */ -gboolean qcrypto_hash_supports (QCryptoHashAlgorithm alg); +gboolean qcrypto_hash_supports (QCryptoHashAlgo alg);/**
@@ -45,7 +45,7 @@ gboolean qcrypto_hash_supports(QCryptoHashAlgorithm alg);* * Returns: the digest length in bytes */ -size_t qcrypto_hash_digest_len (QCryptoHashAlgorithm alg); +size_t qcrypto_hash_digest_len (QCryptoHashAlgo alg);/** * qcrypto_hash_bytesv:
@@ -65,7 +65,7 @@ size_t qcrypto_hash_digest_len(QCryptoHashAlgorithm alg);* * Returns: 0 on success, -1 on error */ -int qcrypto_hash_bytesv(QCryptoHashAlgorithm alg, +int qcrypto_hash_bytesv(QCryptoHashAlgo alg, const struct iovec *iov, size_t niov, uint8_t **result,
@@ -90,7 +90,7 @@ int qcrypto_hash_bytesv(QCryptoHashAlgorithm alg,* * Returns: 0 on success, -1 on error */ -int qcrypto_hash_bytes(QCryptoHashAlgorithm alg, +int qcrypto_hash_bytes(QCryptoHashAlgo alg, const char *buf, size_t len, uint8_t **result,
@@ -114,7 +114,7 @@ int qcrypto_hash_bytes(QCryptoHashAlgorithm alg,* * Returns: 0 on success, -1 on error */ -int qcrypto_hash_digestv(QCryptoHashAlgorithm alg, +int qcrypto_hash_digestv(QCryptoHashAlgo alg, const struct iovec *iov, size_t niov, char **digest,
@@ -137,7 +137,7 @@ int qcrypto_hash_digestv(QCryptoHashAlgorithm alg,* * Returns: 0 on success, -1 on error */ -int qcrypto_hash_digest(QCryptoHashAlgorithm alg, +int qcrypto_hash_digest(QCryptoHashAlgo alg, const char *buf, size_t len, char **digest,
@@ -160,7 +160,7 @@ int qcrypto_hash_digest(QCryptoHashAlgorithm alg,* * Returns: 0 on success, -1 on error */ -int qcrypto_hash_base64v(QCryptoHashAlgorithm alg, +int qcrypto_hash_base64v(QCryptoHashAlgo alg, const struct iovec *iov, size_t niov, char **base64,
@@ -183,7 +183,7 @@ int qcrypto_hash_base64v(QCryptoHashAlgorithm alg,* * Returns: 0 on success, -1 on error */ -int qcrypto_hash_base64(QCryptoHashAlgorithm alg, +int qcrypto_hash_base64(QCryptoHashAlgo alg, const char *buf, size_t len, char **base64,
include/crypto/hmac.h +3 -3
@@ -16,7 +16,7 @@typedef struct QCryptoHmac QCryptoHmac ;struct QCryptoHmac { -QCryptoHashAlgorithm alg; +QCryptoHashAlgo alg;void *opaque;void *driver; };
@@ -31,7 +31,7 @@ struct QCryptoHmac {* Returns: * true if the algorithm is supported, false otherwise */ -bool qcrypto_hmac_supports (QCryptoHashAlgorithm alg); +bool qcrypto_hmac_supports (QCryptoHashAlgo alg);/** * qcrypto_hmac_new:
@@ -52,7 +52,7 @@ bool qcrypto_hmac_supports(QCryptoHashAlgorithm alg);* Returns: * a new hmac object, or NULL on error */ -QCryptoHmac *qcrypto_hmac_new (QCryptoHashAlgorithm alg, +QCryptoHmac *qcrypto_hmac_new (QCryptoHashAlgo alg,const uint8_t *key,size_t nkey,Error **errp);
include/crypto/ivgen.h +3 -3
@@ -46,7 +46,7 @@* * QCryptoIVGen *ivgen = qcrypto_ivgen_new(QCRYPTO_IVGEN_ALG_ESSIV, * QCRYPTO_CIPHER_ALG_AES_128, -* QCRYPTO_HASH_ALG_SHA256, +* QCRYPTO_HASH_ALGO_SHA256, * key, nkey, errp); * if (!ivgen) { * return -1;
@@ -135,7 +135,7 @@ typedef struct QCryptoIVGen QCryptoIVGen;*/ QCryptoIVGen *qcrypto_ivgen_new (QCryptoIVGenAlgorithm alg,QCryptoCipherAlgorithm cipheralg, -QCryptoHashAlgorithm hash, +QCryptoHashAlgo hash,const uint8_t *key,size_t nkey,Error **errp);
@@ -191,7 +191,7 @@ QCryptoCipherAlgorithm qcrypto_ivgen_get_cipher(QCryptoIVGen *ivgen);* * Returns: the hash algorithm */ -QCryptoHashAlgorithm qcrypto_ivgen_get_hash (QCryptoIVGen *ivgen); +QCryptoHashAlgo qcrypto_ivgen_get_hash (QCryptoIVGen *ivgen);/**
include/crypto/pbkdf.h +5 -5
@@ -50,7 +50,7 @@* return -1; * } * -* iterations = qcrypto_pbkdf2_count_iters(QCRYPTO_HASH_ALG_SHA256, +* iterations = qcrypto_pbkdf2_count_iters(QCRYPTO_HASH_ALGO_SHA256, * (const uint8_t *)password, * strlen(password), * salt, nkey, errp);
@@ -60,7 +60,7 @@* return -1; * } * -* if (qcrypto_pbkdf2(QCRYPTO_HASH_ALG_SHA256, +* if (qcrypto_pbkdf2(QCRYPTO_HASH_ALGO_SHA256, * (const uint8_t *)password, strlen(password), * salt, nkey, iterations, key, nkey, errp) < 0) { * g_free(key);
@@ -92,7 +92,7 @@* * Returns true if supported, false otherwise */ -bool qcrypto_pbkdf2_supports (QCryptoHashAlgorithm hash); +bool qcrypto_pbkdf2_supports (QCryptoHashAlgo hash);/**
@@ -119,7 +119,7 @@ bool qcrypto_pbkdf2_supports(QCryptoHashAlgorithm hash);* * Returns: 0 on success, -1 on error */ -int qcrypto_pbkdf2(QCryptoHashAlgorithm hash, +int qcrypto_pbkdf2(QCryptoHashAlgo hash, const uint8_t *key, size_t nkey, const uint8_t *salt, size_t nsalt, uint64_t iterations,
@@ -147,7 +147,7 @@ int qcrypto_pbkdf2(QCryptoHashAlgorithm hash,* * Returns: number of iterations in 1 second, -1 on error */ -uint64_t qcrypto_pbkdf2_count_iters(QCryptoHashAlgorithm hash, +uint64_t qcrypto_pbkdf2_count_iters(QCryptoHashAlgo hash, const uint8_t *key, size_t nkey, const uint8_t *salt, size_t nsalt, size_t nout,
backends/cryptodev-builtin.c +4 -4
@@ -169,16 +169,16 @@ static int cryptodev_builtin_get_rsa_hash_algo( {switch (virtio_rsa_hash) {case VIRTIO_CRYPTO_RSA_MD5 : -return QCRYPTO_HASH_ALG_MD5 ; +return QCRYPTO_HASH_ALGO_MD5 ;case VIRTIO_CRYPTO_RSA_SHA1 : -return QCRYPTO_HASH_ALG_SHA1 ; +return QCRYPTO_HASH_ALGO_SHA1 ;case VIRTIO_CRYPTO_RSA_SHA256 : -return QCRYPTO_HASH_ALG_SHA256 ; +return QCRYPTO_HASH_ALGO_SHA256 ;case VIRTIO_CRYPTO_RSA_SHA512 : -return QCRYPTO_HASH_ALG_SHA512 ; +return QCRYPTO_HASH_ALGO_SHA512 ;default :error_setg (errp,"Unsupported rsa hash algo: %d" , virtio_rsa_hash);
backends/cryptodev-lkcf.c +5 -5
@@ -142,7 +142,7 @@ static int cryptodev_lkcf_set_op_desc(QCryptoAkCipherOptions *opts,if (rsa_opt->padding_alg ==QCRYPTO_RSA_PADDING_ALG_PKCS1 ) {snprintf (key_desc, desc_len,"enc=%s hash=%s" ,QCryptoRSAPaddingAlgorithm_str (rsa_opt->padding_alg), -QCryptoHashAlgorithm_str (rsa_opt->hash_alg)); +QCryptoHashAlgo_str (rsa_opt->hash_alg)); }else { snprintf(key_desc, desc_len, "enc=%s",
@@ -161,19 +161,19 @@ static int cryptodev_lkcf_set_rsa_opt(int virtio_padding_alg,switch (virtio_hash_alg) {case VIRTIO_CRYPTO_RSA_MD5 : - opt->hash_alg =QCRYPTO_HASH_ALG_MD5 ; + opt->hash_alg =QCRYPTO_HASH_ALGO_MD5 ;break ;case VIRTIO_CRYPTO_RSA_SHA1 : - opt->hash_alg =QCRYPTO_HASH_ALG_SHA1 ; + opt->hash_alg =QCRYPTO_HASH_ALGO_SHA1 ;break ;case VIRTIO_CRYPTO_RSA_SHA256 : - opt->hash_alg =QCRYPTO_HASH_ALG_SHA256 ; + opt->hash_alg =QCRYPTO_HASH_ALGO_SHA256 ;break ;case VIRTIO_CRYPTO_RSA_SHA512 : - opt->hash_alg =QCRYPTO_HASH_ALG_SHA512 ; + opt->hash_alg =QCRYPTO_HASH_ALGO_SHA512 ;break ;default :
block/parallels-ext.c +1 -1
@@ -206,7 +206,7 @@ parallels_parse_format_extension(BlockDriverState *bs, uint8_t *ext_cluster, goto fail; } - ret =qcrypto_hash_bytes (QCRYPTO_HASH_ALG_MD5 , (char *)pos, remaining, + ret =qcrypto_hash_bytes (QCRYPTO_HASH_ALGO_MD5 , (char *)pos, remaining, &hash, &hash_len, errp);if (ret <0 ) { goto fail;
block/quorum.c +2 -2
@@ -393,7 +393,7 @@ static int quorum_compute_hash(QuorumAIOCB *acb, int i, QuorumVoteValue *hash)/* XXX - would be nice if we could pass in the Error ** * and propagate that back, but this quorum code is * restricted to just errno values currently */ -if (qcrypto_hash_bytesv (QCRYPTO_HASH_ALG_SHA256 , +if (qcrypto_hash_bytesv (QCRYPTO_HASH_ALGO_SHA256 , qiov->iov, qiov->niov, &data, &len,NULL ) <0 ) {
@@ -1308,7 +1308,7 @@ static BlockDriver bdrv_quorum = {static void bdrv_quorum_init (void ) { -if (!qcrypto_hash_supports (QCRYPTO_HASH_ALG_SHA256 )) { +if (!qcrypto_hash_supports (QCRYPTO_HASH_ALGO_SHA256 )) {/* SHA256 hash support is required for quorum device */ return ; }
crypto/afsplit.c +3 -3
@@ -40,7 +40,7 @@ static void qcrypto_afsplit_xor(size_t blocklen, } -static int qcrypto_afsplit_hash (QCryptoHashAlgorithm hash, +static int qcrypto_afsplit_hash (QCryptoHashAlgo hash,size_t blocklen,uint8_t *block,Error **errp)
@@ -85,7 +85,7 @@ static int qcrypto_afsplit_hash(QCryptoHashAlgorithm hash, } -int qcrypto_afsplit_encode(QCryptoHashAlgorithm hash, +int qcrypto_afsplit_encode(QCryptoHashAlgo hash, size_t blocklen, uint32_t stripes, const uint8_t *in,
@@ -117,7 +117,7 @@ int qcrypto_afsplit_encode(QCryptoHashAlgorithm hash, } -int qcrypto_afsplit_decode(QCryptoHashAlgorithm hash, +int qcrypto_afsplit_decode(QCryptoHashAlgo hash, size_t blocklen, uint32_t stripes, const uint8_t *in,
crypto/block-luks.c +8 -8
@@ -132,7 +132,7 @@ struct QCryptoBlockLUKS {QCryptoIVGenAlgorithm ivgen_alg;/* Hash algorithm used for IV generation*/ -QCryptoHashAlgorithm ivgen_hash_alg; +QCryptoHashAlgo ivgen_hash_alg;/* * Encryption algorithm used for IV generation.
@@ -141,7 +141,7 @@ struct QCryptoBlockLUKS {QCryptoCipherAlgorithm ivgen_cipher_alg;/* Hash algorithm used in pbkdf2 function */ -QCryptoHashAlgorithm hash_alg; +QCryptoHashAlgo hash_alg;/* Name of the secret that was used to open the image */ char *secret;
@@ -223,7 +223,7 @@ static int qcrypto_block_luks_name_lookup(const char *name,#define qcrypto_block_luks_hash_name_lookup (name, errp) \ qcrypto_block_luks_name_lookup(name, \ - &QCryptoHashAlgorithm_lookup, \ + &QCryptoHashAlgo_lookup, \ "Hash algorithm", \ errp)
@@ -264,7 +264,7 @@ qcrypto_block_luks_has_format(const uint8_t *buf,*/ static QCryptoCipherAlgorithm qcrypto_block_luks_essiv_cipher (QCryptoCipherAlgorithm cipher, -QCryptoHashAlgorithm hash, +QCryptoHashAlgo hash,Error **errp) {size_t digestlen =qcrypto_hash_digest_len (hash);
@@ -1331,11 +1331,11 @@ qcrypto_block_luks_create(QCryptoBlock *block, luks_opts.ivgen_alg =QCRYPTO_IVGEN_ALG_PLAIN64 ; }if (!luks_opts.has_hash_alg) { - luks_opts.hash_alg =QCRYPTO_HASH_ALG_SHA256 ; + luks_opts.hash_alg =QCRYPTO_HASH_ALGO_SHA256 ; }if (luks_opts.ivgen_alg ==QCRYPTO_IVGEN_ALG_ESSIV ) {if (!luks_opts.has_ivgen_hash_alg) { - luks_opts.ivgen_hash_alg =QCRYPTO_HASH_ALG_SHA256 ; + luks_opts.ivgen_hash_alg =QCRYPTO_HASH_ALGO_SHA256 ; luks_opts.has_ivgen_hash_alg = true; } }
@@ -1386,13 +1386,13 @@ qcrypto_block_luks_create(QCryptoBlock *block, cipher_mode =QCryptoCipherMode_str (luks_opts.cipher_mode); ivgen_alg =QCryptoIVGenAlgorithm_str (luks_opts.ivgen_alg);if (luks_opts.has_ivgen_hash_alg) { - ivgen_hash_alg =QCryptoHashAlgorithm_str (luks_opts.ivgen_hash_alg); + ivgen_hash_alg =QCryptoHashAlgo_str (luks_opts.ivgen_hash_alg); cipher_mode_spec =g_strdup_printf ("%s-%s:%s" , cipher_mode, ivgen_alg, ivgen_hash_alg); }else { cipher_mode_spec =g_strdup_printf ("%s-%s" , cipher_mode, ivgen_alg); } - hash_alg =QCryptoHashAlgorithm_str (luks_opts.hash_alg); + hash_alg =QCryptoHashAlgo_str (luks_opts.hash_alg);if (strlen (cipher_alg) >=QCRYPTO_BLOCK_LUKS_CIPHER_NAME_LEN ) {
crypto/block.c +1 -1
@@ -332,7 +332,7 @@ QCryptoIVGen *qcrypto_block_get_ivgen(QCryptoBlock *block) } -QCryptoHashAlgorithm qcrypto_block_get_kdf_hash (QCryptoBlock *block) +QCryptoHashAlgo qcrypto_block_get_kdf_hash (QCryptoBlock *block) {return block->kdfhash; }
crypto/hash-afalg.c +13 -13
@@ -20,7 +20,7 @@#include "hmacpriv.h" static char * -qcrypto_afalg_hash_format_name (QCryptoHashAlgorithm alg, +qcrypto_afalg_hash_format_name (QCryptoHashAlgo alg,bool is_hmac,Error **errp) {
@@ -28,25 +28,25 @@ qcrypto_afalg_hash_format_name(QCryptoHashAlgorithm alg,const char *alg_name;switch (alg) { -case QCRYPTO_HASH_ALG_MD5 : +case QCRYPTO_HASH_ALGO_MD5 : alg_name ="md5" ;break ; -case QCRYPTO_HASH_ALG_SHA1 : +case QCRYPTO_HASH_ALGO_SHA1 : alg_name ="sha1" ;break ; -case QCRYPTO_HASH_ALG_SHA224 : +case QCRYPTO_HASH_ALGO_SHA224 : alg_name ="sha224" ;break ; -case QCRYPTO_HASH_ALG_SHA256 : +case QCRYPTO_HASH_ALGO_SHA256 : alg_name ="sha256" ;break ; -case QCRYPTO_HASH_ALG_SHA384 : +case QCRYPTO_HASH_ALGO_SHA384 : alg_name ="sha384" ;break ; -case QCRYPTO_HASH_ALG_SHA512 : +case QCRYPTO_HASH_ALGO_SHA512 : alg_name ="sha512" ;break ; -case QCRYPTO_HASH_ALG_RIPEMD160 : +case QCRYPTO_HASH_ALGO_RIPEMD160 : alg_name ="rmd160" ;break ;
@@ -65,7 +65,7 @@ qcrypto_afalg_hash_format_name(QCryptoHashAlgorithm alg, }static QCryptoAFAlg * -qcrypto_afalg_hash_hmac_ctx_new (QCryptoHashAlgorithm alg, +qcrypto_afalg_hash_hmac_ctx_new (QCryptoHashAlgo alg,const uint8_t *key,size_t nkey,bool is_hmac,Error **errp) {
@@ -99,14 +99,14 @@ qcrypto_afalg_hash_hmac_ctx_new(QCryptoHashAlgorithm alg, }static QCryptoAFAlg * -qcrypto_afalg_hash_ctx_new (QCryptoHashAlgorithm alg, +qcrypto_afalg_hash_ctx_new (QCryptoHashAlgo alg,Error **errp) {return qcrypto_afalg_hash_hmac_ctx_new (alg,NULL ,0 , false, errp); }QCryptoAFAlg * -qcrypto_afalg_hmac_ctx_new (QCryptoHashAlgorithm alg, +qcrypto_afalg_hmac_ctx_new (QCryptoHashAlgo alg,const uint8_t *key,size_t nkey,Error **errp) {
@@ -115,7 +115,7 @@ qcrypto_afalg_hmac_ctx_new(QCryptoHashAlgorithm alg, static int qcrypto_afalg_hash_hmac_bytesv(QCryptoAFAlg *hmac, - QCryptoHashAlgorithm alg, + QCryptoHashAlgo alg, const struct iovec *iov, size_t niov, uint8_t **result, size_t *resultlen,
@@ -173,7 +173,7 @@ out: } static int -qcrypto_afalg_hash_bytesv(QCryptoHashAlgorithm alg, +qcrypto_afalg_hash_bytesv(QCryptoHashAlgo alg, const struct iovec *iov, size_t niov, uint8_t **result, size_t *resultlen,
crypto/hash-gcrypt.c +10 -10
@@ -25,17 +25,17 @@#include "hashpriv.h" -static int qcrypto_hash_alg_map[QCRYPTO_HASH_ALG__MAX ] = { - [QCRYPTO_HASH_ALG_MD5 ] =GCRY_MD_MD5 , - [QCRYPTO_HASH_ALG_SHA1 ] =GCRY_MD_SHA1 , - [QCRYPTO_HASH_ALG_SHA224 ] =GCRY_MD_SHA224 , - [QCRYPTO_HASH_ALG_SHA256 ] =GCRY_MD_SHA256 , - [QCRYPTO_HASH_ALG_SHA384 ] =GCRY_MD_SHA384 , - [QCRYPTO_HASH_ALG_SHA512 ] =GCRY_MD_SHA512 , - [QCRYPTO_HASH_ALG_RIPEMD160 ] =GCRY_MD_RMD160 , +static int qcrypto_hash_alg_map[QCRYPTO_HASH_ALGO__MAX ] = { + [QCRYPTO_HASH_ALGO_MD5 ] =GCRY_MD_MD5 , + [QCRYPTO_HASH_ALGO_SHA1 ] =GCRY_MD_SHA1 , + [QCRYPTO_HASH_ALGO_SHA224 ] =GCRY_MD_SHA224 , + [QCRYPTO_HASH_ALGO_SHA256 ] =GCRY_MD_SHA256 , + [QCRYPTO_HASH_ALGO_SHA384 ] =GCRY_MD_SHA384 , + [QCRYPTO_HASH_ALGO_SHA512 ] =GCRY_MD_SHA512 , + [QCRYPTO_HASH_ALGO_RIPEMD160 ] =GCRY_MD_RMD160 , }; -gboolean qcrypto_hash_supports (QCryptoHashAlgorithm alg) +gboolean qcrypto_hash_supports (QCryptoHashAlgo alg) {if (alg <G_N_ELEMENTS (qcrypto_hash_alg_map) && qcrypto_hash_alg_map[alg] !=GCRY_MD_NONE ) {
@@ -46,7 +46,7 @@ gboolean qcrypto_hash_supports(QCryptoHashAlgorithm alg) static int -qcrypto_gcrypt_hash_bytesv(QCryptoHashAlgorithm alg, +qcrypto_gcrypt_hash_bytesv(QCryptoHashAlgo alg, const struct iovec *iov, size_t niov, uint8_t **result,
crypto/hash-glib.c +10 -10
@@ -24,17 +24,17 @@#include "hashpriv.h" -static int qcrypto_hash_alg_map[QCRYPTO_HASH_ALG__MAX ] = { - [QCRYPTO_HASH_ALG_MD5 ] =G_CHECKSUM_MD5 , - [QCRYPTO_HASH_ALG_SHA1 ] =G_CHECKSUM_SHA1 , - [QCRYPTO_HASH_ALG_SHA224 ] =-1 , - [QCRYPTO_HASH_ALG_SHA256 ] =G_CHECKSUM_SHA256 , - [QCRYPTO_HASH_ALG_SHA384 ] =-1 , - [QCRYPTO_HASH_ALG_SHA512 ] =G_CHECKSUM_SHA512 , - [QCRYPTO_HASH_ALG_RIPEMD160 ] =-1 , +static int qcrypto_hash_alg_map[QCRYPTO_HASH_ALGO__MAX ] = { + [QCRYPTO_HASH_ALGO_MD5 ] =G_CHECKSUM_MD5 , + [QCRYPTO_HASH_ALGO_SHA1 ] =G_CHECKSUM_SHA1 , + [QCRYPTO_HASH_ALGO_SHA224 ] =-1 , + [QCRYPTO_HASH_ALGO_SHA256 ] =G_CHECKSUM_SHA256 , + [QCRYPTO_HASH_ALGO_SHA384 ] =-1 , + [QCRYPTO_HASH_ALGO_SHA512 ] =G_CHECKSUM_SHA512 , + [QCRYPTO_HASH_ALGO_RIPEMD160 ] =-1 , }; -gboolean qcrypto_hash_supports (QCryptoHashAlgorithm alg) +gboolean qcrypto_hash_supports (QCryptoHashAlgo alg) {if (alg <G_N_ELEMENTS (qcrypto_hash_alg_map) && qcrypto_hash_alg_map[alg] !=-1 ) {
@@ -45,7 +45,7 @@ gboolean qcrypto_hash_supports(QCryptoHashAlgorithm alg) static int -qcrypto_glib_hash_bytesv(QCryptoHashAlgorithm alg, +qcrypto_glib_hash_bytesv(QCryptoHashAlgo alg, const struct iovec *iov, size_t niov, uint8_t **result,
crypto/hash-gnutls.c +10 -10
@@ -25,17 +25,17 @@#include "hashpriv.h" -static int qcrypto_hash_alg_map[QCRYPTO_HASH_ALG__MAX ] = { - [QCRYPTO_HASH_ALG_MD5 ] =GNUTLS_DIG_MD5 , - [QCRYPTO_HASH_ALG_SHA1 ] =GNUTLS_DIG_SHA1 , - [QCRYPTO_HASH_ALG_SHA224 ] =GNUTLS_DIG_SHA224 , - [QCRYPTO_HASH_ALG_SHA256 ] =GNUTLS_DIG_SHA256 , - [QCRYPTO_HASH_ALG_SHA384 ] =GNUTLS_DIG_SHA384 , - [QCRYPTO_HASH_ALG_SHA512 ] =GNUTLS_DIG_SHA512 , - [QCRYPTO_HASH_ALG_RIPEMD160 ] =GNUTLS_DIG_RMD160 , +static int qcrypto_hash_alg_map[QCRYPTO_HASH_ALGO__MAX ] = { + [QCRYPTO_HASH_ALGO_MD5 ] =GNUTLS_DIG_MD5 , + [QCRYPTO_HASH_ALGO_SHA1 ] =GNUTLS_DIG_SHA1 , + [QCRYPTO_HASH_ALGO_SHA224 ] =GNUTLS_DIG_SHA224 , + [QCRYPTO_HASH_ALGO_SHA256 ] =GNUTLS_DIG_SHA256 , + [QCRYPTO_HASH_ALGO_SHA384 ] =GNUTLS_DIG_SHA384 , + [QCRYPTO_HASH_ALGO_SHA512 ] =GNUTLS_DIG_SHA512 , + [QCRYPTO_HASH_ALGO_RIPEMD160 ] =GNUTLS_DIG_RMD160 , }; -gboolean qcrypto_hash_supports (QCryptoHashAlgorithm alg) +gboolean qcrypto_hash_supports (QCryptoHashAlgo alg) {size_t i;const gnutls_digest_algorithm_t *algs;
@@ -54,7 +54,7 @@ gboolean qcrypto_hash_supports(QCryptoHashAlgorithm alg) static int -qcrypto_gnutls_hash_bytesv(QCryptoHashAlgorithm alg, +qcrypto_gnutls_hash_bytesv(QCryptoHashAlgo alg, const struct iovec *iov, size_t niov, uint8_t **result,
crypto/hash-nettle.c +9 -9
@@ -50,43 +50,43 @@ struct qcrypto_hash_alg {qcrypto_nettle_result result;size_t len; } qcrypto_hash_alg_map[] = { - [QCRYPTO_HASH_ALG_MD5] = { + [QCRYPTO_HASH_ALGO_MD5] = { .init = (qcrypto_nettle_init)md5_init, .write = (qcrypto_nettle_write)md5_update, .result = (qcrypto_nettle_result)md5_digest, .len = MD5_DIGEST_SIZE, }, - [QCRYPTO_HASH_ALG_SHA1] = { + [QCRYPTO_HASH_ALGO_SHA1] = { .init = (qcrypto_nettle_init)sha1_init, .write = (qcrypto_nettle_write)sha1_update, .result = (qcrypto_nettle_result)sha1_digest, .len = SHA1_DIGEST_SIZE, }, - [QCRYPTO_HASH_ALG_SHA224] = { + [QCRYPTO_HASH_ALGO_SHA224] = { .init = (qcrypto_nettle_init)sha224_init, .write = (qcrypto_nettle_write)sha224_update, .result = (qcrypto_nettle_result)sha224_digest, .len = SHA224_DIGEST_SIZE, }, - [QCRYPTO_HASH_ALG_SHA256] = { + [QCRYPTO_HASH_ALGO_SHA256] = { .init = (qcrypto_nettle_init)sha256_init, .write = (qcrypto_nettle_write)sha256_update, .result = (qcrypto_nettle_result)sha256_digest, .len = SHA256_DIGEST_SIZE, }, - [QCRYPTO_HASH_ALG_SHA384] = { + [QCRYPTO_HASH_ALGO_SHA384] = { .init = (qcrypto_nettle_init)sha384_init, .write = (qcrypto_nettle_write)sha384_update, .result = (qcrypto_nettle_result)sha384_digest, .len = SHA384_DIGEST_SIZE, }, - [QCRYPTO_HASH_ALG_SHA512] = { + [QCRYPTO_HASH_ALGO_SHA512] = { .init = (qcrypto_nettle_init)sha512_init, .write = (qcrypto_nettle_write)sha512_update, .result = (qcrypto_nettle_result)sha512_digest, .len = SHA512_DIGEST_SIZE, }, - [QCRYPTO_HASH_ALG_RIPEMD160] = { + [QCRYPTO_HASH_ALGO_RIPEMD160] = { .init = (qcrypto_nettle_init)ripemd160_init, .write = (qcrypto_nettle_write)ripemd160_update, .result = (qcrypto_nettle_result)ripemd160_digest,
@@ -94,7 +94,7 @@ struct qcrypto_hash_alg { }, }; -gboolean qcrypto_hash_supports (QCryptoHashAlgorithm alg) +gboolean qcrypto_hash_supports (QCryptoHashAlgo alg) {if (alg <G_N_ELEMENTS (qcrypto_hash_alg_map) && qcrypto_hash_alg_map[alg].init !=NULL ) {
@@ -105,7 +105,7 @@ gboolean qcrypto_hash_supports(QCryptoHashAlgorithm alg) static int -qcrypto_nettle_hash_bytesv(QCryptoHashAlgorithm alg, +qcrypto_nettle_hash_bytesv(QCryptoHashAlgo alg, const struct iovec *iov, size_t niov, uint8_t **result,
crypto/hash.c +15 -15
@@ -22,23 +22,23 @@#include "crypto/hash.h" #include "hashpriv.h" -static size_t qcrypto_hash_alg_size[QCRYPTO_HASH_ALG__MAX ] = { - [QCRYPTO_HASH_ALG_MD5 ] =16 , - [QCRYPTO_HASH_ALG_SHA1 ] =20 , - [QCRYPTO_HASH_ALG_SHA224 ] =28 , - [QCRYPTO_HASH_ALG_SHA256 ] =32 , - [QCRYPTO_HASH_ALG_SHA384 ] =48 , - [QCRYPTO_HASH_ALG_SHA512 ] =64 , - [QCRYPTO_HASH_ALG_RIPEMD160 ] =20 , +static size_t qcrypto_hash_alg_size[QCRYPTO_HASH_ALGO__MAX ] = { + [QCRYPTO_HASH_ALGO_MD5 ] =16 , + [QCRYPTO_HASH_ALGO_SHA1 ] =20 , + [QCRYPTO_HASH_ALGO_SHA224 ] =28 , + [QCRYPTO_HASH_ALGO_SHA256 ] =32 , + [QCRYPTO_HASH_ALGO_SHA384 ] =48 , + [QCRYPTO_HASH_ALGO_SHA512 ] =64 , + [QCRYPTO_HASH_ALGO_RIPEMD160 ] =20 , }; -size_t qcrypto_hash_digest_len (QCryptoHashAlgorithm alg) +size_t qcrypto_hash_digest_len (QCryptoHashAlgo alg) {assert (alg <G_N_ELEMENTS (qcrypto_hash_alg_size));return qcrypto_hash_alg_size[alg]; } -int qcrypto_hash_bytesv(QCryptoHashAlgorithm alg, +int qcrypto_hash_bytesv(QCryptoHashAlgo alg, const struct iovec *iov, size_t niov, uint8_t **result,
@@ -65,7 +65,7 @@ int qcrypto_hash_bytesv(QCryptoHashAlgorithm alg, } -int qcrypto_hash_bytes(QCryptoHashAlgorithm alg, +int qcrypto_hash_bytes(QCryptoHashAlgo alg, const char *buf, size_t len, uint8_t **result,
@@ -79,7 +79,7 @@ int qcrypto_hash_bytes(QCryptoHashAlgorithm alg,static const char hex[] ="0123456789abcdef" ; -int qcrypto_hash_digestv(QCryptoHashAlgorithm alg, +int qcrypto_hash_digestv(QCryptoHashAlgo alg, const struct iovec *iov, size_t niov, char **digest,
@@ -103,7 +103,7 @@ int qcrypto_hash_digestv(QCryptoHashAlgorithm alg,return 0 ; } -int qcrypto_hash_digest(QCryptoHashAlgorithm alg, +int qcrypto_hash_digest(QCryptoHashAlgo alg, const char *buf, size_t len, char **digest,
@@ -114,7 +114,7 @@ int qcrypto_hash_digest(QCryptoHashAlgorithm alg,return qcrypto_hash_digestv (alg, &iov,1 , digest, errp); } -int qcrypto_hash_base64v(QCryptoHashAlgorithm alg, +int qcrypto_hash_base64v(QCryptoHashAlgo alg, const struct iovec *iov, size_t niov, char **base64,
@@ -132,7 +132,7 @@ int qcrypto_hash_base64v(QCryptoHashAlgorithm alg,return 0 ; } -int qcrypto_hash_base64(QCryptoHashAlgorithm alg, +int qcrypto_hash_base64(QCryptoHashAlgo alg, const char *buf, size_t len, char **base64,
crypto/hmac-gcrypt.c +11 -11
@@ -18,14 +18,14 @@#include "hmacpriv.h" #include <gcrypt.h> -static int qcrypto_hmac_alg_map[QCRYPTO_HASH_ALG__MAX ] = { - [QCRYPTO_HASH_ALG_MD5 ] =GCRY_MAC_HMAC_MD5 , - [QCRYPTO_HASH_ALG_SHA1 ] =GCRY_MAC_HMAC_SHA1 , - [QCRYPTO_HASH_ALG_SHA224 ] =GCRY_MAC_HMAC_SHA224 , - [QCRYPTO_HASH_ALG_SHA256 ] =GCRY_MAC_HMAC_SHA256 , - [QCRYPTO_HASH_ALG_SHA384 ] =GCRY_MAC_HMAC_SHA384 , - [QCRYPTO_HASH_ALG_SHA512 ] =GCRY_MAC_HMAC_SHA512 , - [QCRYPTO_HASH_ALG_RIPEMD160 ] =GCRY_MAC_HMAC_RMD160 , +static int qcrypto_hmac_alg_map[QCRYPTO_HASH_ALGO__MAX ] = { + [QCRYPTO_HASH_ALGO_MD5 ] =GCRY_MAC_HMAC_MD5 , + [QCRYPTO_HASH_ALGO_SHA1 ] =GCRY_MAC_HMAC_SHA1 , + [QCRYPTO_HASH_ALGO_SHA224 ] =GCRY_MAC_HMAC_SHA224 , + [QCRYPTO_HASH_ALGO_SHA256 ] =GCRY_MAC_HMAC_SHA256 , + [QCRYPTO_HASH_ALGO_SHA384 ] =GCRY_MAC_HMAC_SHA384 , + [QCRYPTO_HASH_ALGO_SHA512 ] =GCRY_MAC_HMAC_SHA512 , + [QCRYPTO_HASH_ALGO_RIPEMD160 ] =GCRY_MAC_HMAC_RMD160 , };typedef struct QCryptoHmacGcrypt QCryptoHmacGcrypt ;
@@ -33,7 +33,7 @@ struct QCryptoHmacGcrypt {gcry_mac_hd_t handle; }; -bool qcrypto_hmac_supports (QCryptoHashAlgorithm alg) +bool qcrypto_hmac_supports (QCryptoHashAlgo alg) {if (alg <G_N_ELEMENTS (qcrypto_hmac_alg_map) && qcrypto_hmac_alg_map[alg] !=GCRY_MAC_NONE ) {
@@ -43,7 +43,7 @@ bool qcrypto_hmac_supports(QCryptoHashAlgorithm alg)return false; } -void *qcrypto_hmac_ctx_new (QCryptoHashAlgorithm alg, +void *qcrypto_hmac_ctx_new (QCryptoHashAlgo alg,const uint8_t *key,size_t nkey,Error **errp) {
@@ -52,7 +52,7 @@ void *qcrypto_hmac_ctx_new(QCryptoHashAlgorithm alg,if (!qcrypto_hmac_supports (alg)) {error_setg (errp,"Unsupported hmac algorithm %s" , -QCryptoHashAlgorithm_str (alg)); +QCryptoHashAlgo_str (alg));return NULL ; }
crypto/hmac-glib.c +11 -11
@@ -17,14 +17,14 @@#include "crypto/hmac.h" #include "hmacpriv.h" -static int qcrypto_hmac_alg_map[QCRYPTO_HASH_ALG__MAX ] = { - [QCRYPTO_HASH_ALG_MD5 ] =G_CHECKSUM_MD5 , - [QCRYPTO_HASH_ALG_SHA1 ] =G_CHECKSUM_SHA1 , - [QCRYPTO_HASH_ALG_SHA256 ] =G_CHECKSUM_SHA256 , - [QCRYPTO_HASH_ALG_SHA512 ] =G_CHECKSUM_SHA512 , - [QCRYPTO_HASH_ALG_SHA224 ] =-1 , - [QCRYPTO_HASH_ALG_SHA384 ] =-1 , - [QCRYPTO_HASH_ALG_RIPEMD160 ] =-1 , +static int qcrypto_hmac_alg_map[QCRYPTO_HASH_ALGO__MAX ] = { + [QCRYPTO_HASH_ALGO_MD5 ] =G_CHECKSUM_MD5 , + [QCRYPTO_HASH_ALGO_SHA1 ] =G_CHECKSUM_SHA1 , + [QCRYPTO_HASH_ALGO_SHA256 ] =G_CHECKSUM_SHA256 , + [QCRYPTO_HASH_ALGO_SHA512 ] =G_CHECKSUM_SHA512 , + [QCRYPTO_HASH_ALGO_SHA224 ] =-1 , + [QCRYPTO_HASH_ALGO_SHA384 ] =-1 , + [QCRYPTO_HASH_ALGO_RIPEMD160 ] =-1 , };typedef struct QCryptoHmacGlib QCryptoHmacGlib ;
@@ -32,7 +32,7 @@ struct QCryptoHmacGlib {GHmac *ghmac; }; -bool qcrypto_hmac_supports (QCryptoHashAlgorithm alg) +bool qcrypto_hmac_supports (QCryptoHashAlgo alg) {if (alg <G_N_ELEMENTS (qcrypto_hmac_alg_map) && qcrypto_hmac_alg_map[alg] !=-1 ) {
@@ -42,7 +42,7 @@ bool qcrypto_hmac_supports(QCryptoHashAlgorithm alg)return false; } -void *qcrypto_hmac_ctx_new (QCryptoHashAlgorithm alg, +void *qcrypto_hmac_ctx_new (QCryptoHashAlgo alg,const uint8_t *key,size_t nkey,Error **errp) {
@@ -50,7 +50,7 @@ void *qcrypto_hmac_ctx_new(QCryptoHashAlgorithm alg,if (!qcrypto_hmac_supports (alg)) {error_setg (errp,"Unsupported hmac algorithm %s" , -QCryptoHashAlgorithm_str (alg)); +QCryptoHashAlgo_str (alg));return NULL ; }
crypto/hmac-gnutls.c +11 -11
@@ -20,14 +20,14 @@#include "crypto/hmac.h" #include "hmacpriv.h" -static int qcrypto_hmac_alg_map[QCRYPTO_HASH_ALG__MAX ] = { - [QCRYPTO_HASH_ALG_MD5 ] =GNUTLS_MAC_MD5 , - [QCRYPTO_HASH_ALG_SHA1 ] =GNUTLS_MAC_SHA1 , - [QCRYPTO_HASH_ALG_SHA224 ] =GNUTLS_MAC_SHA224 , - [QCRYPTO_HASH_ALG_SHA256 ] =GNUTLS_MAC_SHA256 , - [QCRYPTO_HASH_ALG_SHA384 ] =GNUTLS_MAC_SHA384 , - [QCRYPTO_HASH_ALG_SHA512 ] =GNUTLS_MAC_SHA512 , - [QCRYPTO_HASH_ALG_RIPEMD160 ] =GNUTLS_MAC_RMD160 , +static int qcrypto_hmac_alg_map[QCRYPTO_HASH_ALGO__MAX ] = { + [QCRYPTO_HASH_ALGO_MD5 ] =GNUTLS_MAC_MD5 , + [QCRYPTO_HASH_ALGO_SHA1 ] =GNUTLS_MAC_SHA1 , + [QCRYPTO_HASH_ALGO_SHA224 ] =GNUTLS_MAC_SHA224 , + [QCRYPTO_HASH_ALGO_SHA256 ] =GNUTLS_MAC_SHA256 , + [QCRYPTO_HASH_ALGO_SHA384 ] =GNUTLS_MAC_SHA384 , + [QCRYPTO_HASH_ALGO_SHA512 ] =GNUTLS_MAC_SHA512 , + [QCRYPTO_HASH_ALGO_RIPEMD160 ] =GNUTLS_MAC_RMD160 , };typedef struct QCryptoHmacGnutls QCryptoHmacGnutls ;
@@ -35,7 +35,7 @@ struct QCryptoHmacGnutls {gnutls_hmac_hd_t handle; }; -bool qcrypto_hmac_supports (QCryptoHashAlgorithm alg) +bool qcrypto_hmac_supports (QCryptoHashAlgo alg) {size_t i;const gnutls_digest_algorithm_t *algs;
@@ -52,7 +52,7 @@ bool qcrypto_hmac_supports(QCryptoHashAlgorithm alg)return false; } -void *qcrypto_hmac_ctx_new (QCryptoHashAlgorithm alg, +void *qcrypto_hmac_ctx_new (QCryptoHashAlgo alg,const uint8_t *key,size_t nkey,Error **errp) {
@@ -61,7 +61,7 @@ void *qcrypto_hmac_ctx_new(QCryptoHashAlgorithm alg,if (!qcrypto_hmac_supports (alg)) {error_setg (errp,"Unsupported hmac algorithm %s" , -QCryptoHashAlgorithm_str (alg)); +QCryptoHashAlgo_str (alg));return NULL ; }
crypto/hmac-nettle.c +11 -11
@@ -46,44 +46,44 @@ struct qcrypto_nettle_hmac_alg {qcrypto_nettle_hmac_update update;qcrypto_nettle_hmac_digest digest;size_t len; -} qcrypto_hmac_alg_map[QCRYPTO_HASH_ALG__MAX] = { - [QCRYPTO_HASH_ALG_MD5] = { +} qcrypto_hmac_alg_map[QCRYPTO_HASH_ALGO__MAX] = { + [QCRYPTO_HASH_ALGO_MD5] = { .setkey = (qcrypto_nettle_hmac_setkey)hmac_md5_set_key, .update = (qcrypto_nettle_hmac_update)hmac_md5_update, .digest = (qcrypto_nettle_hmac_digest)hmac_md5_digest, .len = MD5_DIGEST_SIZE, }, - [QCRYPTO_HASH_ALG_SHA1] = { + [QCRYPTO_HASH_ALGO_SHA1] = { .setkey = (qcrypto_nettle_hmac_setkey)hmac_sha1_set_key, .update = (qcrypto_nettle_hmac_update)hmac_sha1_update, .digest = (qcrypto_nettle_hmac_digest)hmac_sha1_digest, .len = SHA1_DIGEST_SIZE, }, - [QCRYPTO_HASH_ALG_SHA224] = { + [QCRYPTO_HASH_ALGO_SHA224] = { .setkey = (qcrypto_nettle_hmac_setkey)hmac_sha224_set_key, .update = (qcrypto_nettle_hmac_update)hmac_sha224_update, .digest = (qcrypto_nettle_hmac_digest)hmac_sha224_digest, .len = SHA224_DIGEST_SIZE, }, - [QCRYPTO_HASH_ALG_SHA256] = { + [QCRYPTO_HASH_ALGO_SHA256] = { .setkey = (qcrypto_nettle_hmac_setkey)hmac_sha256_set_key, .update = (qcrypto_nettle_hmac_update)hmac_sha256_update, .digest = (qcrypto_nettle_hmac_digest)hmac_sha256_digest, .len = SHA256_DIGEST_SIZE, }, - [QCRYPTO_HASH_ALG_SHA384] = { + [QCRYPTO_HASH_ALGO_SHA384] = { .setkey = (qcrypto_nettle_hmac_setkey)hmac_sha384_set_key, .update = (qcrypto_nettle_hmac_update)hmac_sha384_update, .digest = (qcrypto_nettle_hmac_digest)hmac_sha384_digest, .len = SHA384_DIGEST_SIZE, }, - [QCRYPTO_HASH_ALG_SHA512] = { + [QCRYPTO_HASH_ALGO_SHA512] = { .setkey = (qcrypto_nettle_hmac_setkey)hmac_sha512_set_key, .update = (qcrypto_nettle_hmac_update)hmac_sha512_update, .digest = (qcrypto_nettle_hmac_digest)hmac_sha512_digest, .len = SHA512_DIGEST_SIZE, }, - [QCRYPTO_HASH_ALG_RIPEMD160] = { + [QCRYPTO_HASH_ALGO_RIPEMD160] = { .setkey = (qcrypto_nettle_hmac_setkey)hmac_ripemd160_set_key, .update = (qcrypto_nettle_hmac_update)hmac_ripemd160_update, .digest = (qcrypto_nettle_hmac_digest)hmac_ripemd160_digest,
@@ -91,7 +91,7 @@ struct qcrypto_nettle_hmac_alg { }, }; -bool qcrypto_hmac_supports (QCryptoHashAlgorithm alg) +bool qcrypto_hmac_supports (QCryptoHashAlgo alg) {if (alg <G_N_ELEMENTS (qcrypto_hmac_alg_map) && qcrypto_hmac_alg_map[alg].setkey !=NULL ) {
@@ -101,7 +101,7 @@ bool qcrypto_hmac_supports(QCryptoHashAlgorithm alg)return false; } -void *qcrypto_hmac_ctx_new (QCryptoHashAlgorithm alg, +void *qcrypto_hmac_ctx_new (QCryptoHashAlgo alg,const uint8_t *key,size_t nkey,Error **errp) {
@@ -109,7 +109,7 @@ void *qcrypto_hmac_ctx_new(QCryptoHashAlgorithm alg,if (!qcrypto_hmac_supports (alg)) {error_setg (errp,"Unsupported hmac algorithm %s" , -QCryptoHashAlgorithm_str (alg)); +QCryptoHashAlgo_str (alg));return NULL ; }
crypto/hmac.c +1 -1
@@ -83,7 +83,7 @@ int qcrypto_hmac_digest(QCryptoHmac *hmac,return qcrypto_hmac_digestv (hmac, &iov,1 , digest, errp); } -QCryptoHmac *qcrypto_hmac_new (QCryptoHashAlgorithm alg, +QCryptoHmac *qcrypto_hmac_new (QCryptoHashAlgo alg,const uint8_t *key,size_t nkey,Error **errp) {
crypto/ivgen.c +2 -2
@@ -29,7 +29,7 @@QCryptoIVGen *qcrypto_ivgen_new (QCryptoIVGenAlgorithm alg,QCryptoCipherAlgorithm cipheralg, -QCryptoHashAlgorithm hash, +QCryptoHashAlgo hash,const uint8_t *key,size_t nkey,Error **errp) {
@@ -85,7 +85,7 @@ QCryptoCipherAlgorithm qcrypto_ivgen_get_cipher(QCryptoIVGen *ivgen) } -QCryptoHashAlgorithm qcrypto_ivgen_get_hash (QCryptoIVGen *ivgen) +QCryptoHashAlgo qcrypto_ivgen_get_hash (QCryptoIVGen *ivgen) {return ivgen->hash; }
crypto/pbkdf-gcrypt.c +18 -18
@@ -23,37 +23,37 @@#include "qapi/error.h" #include "crypto/pbkdf.h" -bool qcrypto_pbkdf2_supports (QCryptoHashAlgorithm hash) +bool qcrypto_pbkdf2_supports (QCryptoHashAlgo hash) {switch (hash) { -case QCRYPTO_HASH_ALG_MD5 : -case QCRYPTO_HASH_ALG_SHA1 : -case QCRYPTO_HASH_ALG_SHA224 : -case QCRYPTO_HASH_ALG_SHA256 : -case QCRYPTO_HASH_ALG_SHA384 : -case QCRYPTO_HASH_ALG_SHA512 : -case QCRYPTO_HASH_ALG_RIPEMD160 : +case QCRYPTO_HASH_ALGO_MD5 : +case QCRYPTO_HASH_ALGO_SHA1 : +case QCRYPTO_HASH_ALGO_SHA224 : +case QCRYPTO_HASH_ALGO_SHA256 : +case QCRYPTO_HASH_ALGO_SHA384 : +case QCRYPTO_HASH_ALGO_SHA512 : +case QCRYPTO_HASH_ALGO_RIPEMD160 :return true;default :return false; } } -int qcrypto_pbkdf2 (QCryptoHashAlgorithm hash, +int qcrypto_pbkdf2 (QCryptoHashAlgo hash,const uint8_t *key,size_t nkey,const uint8_t *salt,size_t nsalt,uint64_t iterations,uint8_t *out,size_t nout,Error **errp) { -static const int hash_map[QCRYPTO_HASH_ALG__MAX ] = { - [QCRYPTO_HASH_ALG_MD5 ] =GCRY_MD_MD5 , - [QCRYPTO_HASH_ALG_SHA1 ] =GCRY_MD_SHA1 , - [QCRYPTO_HASH_ALG_SHA224 ] =GCRY_MD_SHA224 , - [QCRYPTO_HASH_ALG_SHA256 ] =GCRY_MD_SHA256 , - [QCRYPTO_HASH_ALG_SHA384 ] =GCRY_MD_SHA384 , - [QCRYPTO_HASH_ALG_SHA512 ] =GCRY_MD_SHA512 , - [QCRYPTO_HASH_ALG_RIPEMD160 ] =GCRY_MD_RMD160 , +static const int hash_map[QCRYPTO_HASH_ALGO__MAX ] = { + [QCRYPTO_HASH_ALGO_MD5 ] =GCRY_MD_MD5 , + [QCRYPTO_HASH_ALGO_SHA1 ] =GCRY_MD_SHA1 , + [QCRYPTO_HASH_ALGO_SHA224 ] =GCRY_MD_SHA224 , + [QCRYPTO_HASH_ALGO_SHA256 ] =GCRY_MD_SHA256 , + [QCRYPTO_HASH_ALGO_SHA384 ] =GCRY_MD_SHA384 , + [QCRYPTO_HASH_ALGO_SHA512 ] =GCRY_MD_SHA512 , + [QCRYPTO_HASH_ALGO_RIPEMD160 ] =GCRY_MD_RMD160 , };int ret;
@@ -68,7 +68,7 @@ int qcrypto_pbkdf2(QCryptoHashAlgorithm hash, hash_map[hash] == GCRY_MD_NONE) {error_setg_errno (errp,ENOSYS ,"PBKDF does not support hash algorithm %s" , -QCryptoHashAlgorithm_str (hash)); +QCryptoHashAlgo_str (hash));return -1 ; }
crypto/pbkdf-gnutls.c +18 -18
@@ -23,37 +23,37 @@#include "qapi/error.h" #include "crypto/pbkdf.h" -bool qcrypto_pbkdf2_supports (QCryptoHashAlgorithm hash) +bool qcrypto_pbkdf2_supports (QCryptoHashAlgo hash) {switch (hash) { -case QCRYPTO_HASH_ALG_MD5 : -case QCRYPTO_HASH_ALG_SHA1 : -case QCRYPTO_HASH_ALG_SHA224 : -case QCRYPTO_HASH_ALG_SHA256 : -case QCRYPTO_HASH_ALG_SHA384 : -case QCRYPTO_HASH_ALG_SHA512 : -case QCRYPTO_HASH_ALG_RIPEMD160 : +case QCRYPTO_HASH_ALGO_MD5 : +case QCRYPTO_HASH_ALGO_SHA1 : +case QCRYPTO_HASH_ALGO_SHA224 : +case QCRYPTO_HASH_ALGO_SHA256 : +case QCRYPTO_HASH_ALGO_SHA384 : +case QCRYPTO_HASH_ALGO_SHA512 : +case QCRYPTO_HASH_ALGO_RIPEMD160 :return true;default :return false; } } -int qcrypto_pbkdf2 (QCryptoHashAlgorithm hash, +int qcrypto_pbkdf2 (QCryptoHashAlgo hash,const uint8_t *key,size_t nkey,const uint8_t *salt,size_t nsalt,uint64_t iterations,uint8_t *out,size_t nout,Error **errp) { -static const int hash_map[QCRYPTO_HASH_ALG__MAX ] = { - [QCRYPTO_HASH_ALG_MD5 ] =GNUTLS_DIG_MD5 , - [QCRYPTO_HASH_ALG_SHA1 ] =GNUTLS_DIG_SHA1 , - [QCRYPTO_HASH_ALG_SHA224 ] =GNUTLS_DIG_SHA224 , - [QCRYPTO_HASH_ALG_SHA256 ] =GNUTLS_DIG_SHA256 , - [QCRYPTO_HASH_ALG_SHA384 ] =GNUTLS_DIG_SHA384 , - [QCRYPTO_HASH_ALG_SHA512 ] =GNUTLS_DIG_SHA512 , - [QCRYPTO_HASH_ALG_RIPEMD160 ] =GNUTLS_DIG_RMD160 , +static const int hash_map[QCRYPTO_HASH_ALGO__MAX ] = { + [QCRYPTO_HASH_ALGO_MD5 ] =GNUTLS_DIG_MD5 , + [QCRYPTO_HASH_ALGO_SHA1 ] =GNUTLS_DIG_SHA1 , + [QCRYPTO_HASH_ALGO_SHA224 ] =GNUTLS_DIG_SHA224 , + [QCRYPTO_HASH_ALGO_SHA256 ] =GNUTLS_DIG_SHA256 , + [QCRYPTO_HASH_ALGO_SHA384 ] =GNUTLS_DIG_SHA384 , + [QCRYPTO_HASH_ALGO_SHA512 ] =GNUTLS_DIG_SHA512 , + [QCRYPTO_HASH_ALGO_RIPEMD160 ] =GNUTLS_DIG_RMD160 , };int ret;const gnutls_datum_t gkey = { (unsigned char *)key, nkey };
@@ -70,7 +70,7 @@ int qcrypto_pbkdf2(QCryptoHashAlgorithm hash, hash_map[hash] == GNUTLS_DIG_UNKNOWN) {error_setg_errno (errp,ENOSYS ,"PBKDF does not support hash algorithm %s" , -QCryptoHashAlgorithm_str (hash)); +QCryptoHashAlgo_str (hash));return -1 ; }
crypto/pbkdf-nettle.c +16 -16
@@ -25,22 +25,22 @@#include "crypto/pbkdf.h" -bool qcrypto_pbkdf2_supports (QCryptoHashAlgorithm hash) +bool qcrypto_pbkdf2_supports (QCryptoHashAlgo hash) {switch (hash) { -case QCRYPTO_HASH_ALG_SHA1 : -case QCRYPTO_HASH_ALG_SHA224 : -case QCRYPTO_HASH_ALG_SHA256 : -case QCRYPTO_HASH_ALG_SHA384 : -case QCRYPTO_HASH_ALG_SHA512 : -case QCRYPTO_HASH_ALG_RIPEMD160 : +case QCRYPTO_HASH_ALGO_SHA1 : +case QCRYPTO_HASH_ALGO_SHA224 : +case QCRYPTO_HASH_ALGO_SHA256 : +case QCRYPTO_HASH_ALGO_SHA384 : +case QCRYPTO_HASH_ALGO_SHA512 : +case QCRYPTO_HASH_ALGO_RIPEMD160 :return true;default :return false; } } -int qcrypto_pbkdf2(QCryptoHashAlgorithm hash, +int qcrypto_pbkdf2(QCryptoHashAlgo hash, const uint8_t *key, size_t nkey, const uint8_t *salt, size_t nsalt, uint64_t iterations,
@@ -65,43 +65,43 @@ int qcrypto_pbkdf2(QCryptoHashAlgorithm hash, }switch (hash) { -case QCRYPTO_HASH_ALG_MD5 : +case QCRYPTO_HASH_ALGO_MD5 :hmac_md5_set_key (&ctx.md5, nkey, key);PBKDF2 (&ctx.md5, hmac_md5_update, hmac_md5_digest,MD5_DIGEST_SIZE , iterations, nsalt, salt, nout, out);break ; -case QCRYPTO_HASH_ALG_SHA1 : +case QCRYPTO_HASH_ALGO_SHA1 :hmac_sha1_set_key (&ctx.sha1, nkey, key);PBKDF2 (&ctx.sha1, hmac_sha1_update, hmac_sha1_digest,SHA1_DIGEST_SIZE , iterations, nsalt, salt, nout, out);break ; -case QCRYPTO_HASH_ALG_SHA224 : +case QCRYPTO_HASH_ALGO_SHA224 :hmac_sha224_set_key (&ctx.sha224, nkey, key);PBKDF2 (&ctx.sha224, hmac_sha224_update, hmac_sha224_digest,SHA224_DIGEST_SIZE , iterations, nsalt, salt, nout, out);break ; -case QCRYPTO_HASH_ALG_SHA256 : +case QCRYPTO_HASH_ALGO_SHA256 :hmac_sha256_set_key (&ctx.sha256, nkey, key);PBKDF2 (&ctx.sha256, hmac_sha256_update, hmac_sha256_digest,SHA256_DIGEST_SIZE , iterations, nsalt, salt, nout, out);break ; -case QCRYPTO_HASH_ALG_SHA384 : +case QCRYPTO_HASH_ALGO_SHA384 :hmac_sha384_set_key (&ctx.sha384, nkey, key);PBKDF2 (&ctx.sha384, hmac_sha384_update, hmac_sha384_digest,SHA384_DIGEST_SIZE , iterations, nsalt, salt, nout, out);break ; -case QCRYPTO_HASH_ALG_SHA512 : +case QCRYPTO_HASH_ALGO_SHA512 :hmac_sha512_set_key (&ctx.sha512, nkey, key);PBKDF2 (&ctx.sha512, hmac_sha512_update, hmac_sha512_digest,SHA512_DIGEST_SIZE , iterations, nsalt, salt, nout, out);break ; -case QCRYPTO_HASH_ALG_RIPEMD160 : +case QCRYPTO_HASH_ALGO_RIPEMD160 :hmac_ripemd160_set_key (&ctx.ripemd160, nkey, key);PBKDF2 (&ctx.ripemd160, hmac_ripemd160_update, hmac_ripemd160_digest,RIPEMD160_DIGEST_SIZE , iterations, nsalt, salt, nout, out);
@@ -110,7 +110,7 @@ int qcrypto_pbkdf2(QCryptoHashAlgorithm hash,default :error_setg_errno (errp,ENOSYS ,"PBKDF does not support hash algorithm %s" , -QCryptoHashAlgorithm_str (hash)); +QCryptoHashAlgo_str (hash));return -1 ; }return 0 ;
crypto/pbkdf-stub.c +2 -2
@@ -22,12 +22,12 @@#include "qapi/error.h" #include "crypto/pbkdf.h" -bool qcrypto_pbkdf2_supports(QCryptoHashAlgorithm hash G_GNUC_UNUSED) +bool qcrypto_pbkdf2_supports(QCryptoHashAlgo hash G_GNUC_UNUSED) {return false; } -int qcrypto_pbkdf2(QCryptoHashAlgorithm hash G_GNUC_UNUSED, +int qcrypto_pbkdf2(QCryptoHashAlgo hash G_GNUC_UNUSED, const uint8_t *key G_GNUC_UNUSED, size_t nkey G_GNUC_UNUSED, const uint8_t *salt G_GNUC_UNUSED,
crypto/pbkdf.c +1 -1
@@ -85,7 +85,7 @@ static int qcrypto_pbkdf2_get_thread_cpu(unsigned long long *val_ms,#endif } -uint64_t qcrypto_pbkdf2_count_iters(QCryptoHashAlgorithm hash, +uint64_t qcrypto_pbkdf2_count_iters(QCryptoHashAlgo hash, const uint8_t *key, size_t nkey, const uint8_t *salt, size_t nsalt, size_t nout,
hw/misc/aspeed_hace.c +8 -8
@@ -68,15 +68,15 @@static const struct {uint32_t mask; -QCryptoHashAlgorithm algo; +QCryptoHashAlgo algo; } hash_algo_map[] = { - {HASH_ALGO_MD5 ,QCRYPTO_HASH_ALG_MD5 }, - {HASH_ALGO_SHA1 ,QCRYPTO_HASH_ALG_SHA1 }, - {HASH_ALGO_SHA224 ,QCRYPTO_HASH_ALG_SHA224 }, - {HASH_ALGO_SHA256 ,QCRYPTO_HASH_ALG_SHA256 }, - {HASH_ALGO_SHA512_SERIES |HASH_ALGO_SHA512_SHA512 ,QCRYPTO_HASH_ALG_SHA512 }, - {HASH_ALGO_SHA512_SERIES |HASH_ALGO_SHA512_SHA384 ,QCRYPTO_HASH_ALG_SHA384 }, - {HASH_ALGO_SHA512_SERIES |HASH_ALGO_SHA512_SHA256 ,QCRYPTO_HASH_ALG_SHA256 }, + {HASH_ALGO_MD5 ,QCRYPTO_HASH_ALGO_MD5 }, + {HASH_ALGO_SHA1 ,QCRYPTO_HASH_ALGO_SHA1 }, + {HASH_ALGO_SHA224 ,QCRYPTO_HASH_ALGO_SHA224 }, + {HASH_ALGO_SHA256 ,QCRYPTO_HASH_ALGO_SHA256 }, + {HASH_ALGO_SHA512_SERIES |HASH_ALGO_SHA512_SHA512 ,QCRYPTO_HASH_ALGO_SHA512 }, + {HASH_ALGO_SHA512_SERIES |HASH_ALGO_SHA512_SHA384 ,QCRYPTO_HASH_ALGO_SHA384 }, + {HASH_ALGO_SHA512_SERIES |HASH_ALGO_SHA512_SHA256 ,QCRYPTO_HASH_ALGO_SHA256 }, };static int hash_algo_lookup (uint32_t reg)
io/channel-websock.c +1 -1
@@ -351,7 +351,7 @@ static void qio_channel_websock_handshake_send_res_ok(QIOChannelWebsock *ioc, QIO_CHANNEL_WEBSOCK_GUID_LEN + 1);/* hash and encode it */ - if (qcrypto_hash_base64(QCRYPTO_HASH_ALG_SHA1, + if (qcrypto_hash_base64(QCRYPTO_HASH_ALGO_SHA1, combined_key, QIO_CHANNEL_WEBSOCK_CLIENT_KEY_LEN + QIO_CHANNEL_WEBSOCK_GUID_LEN,
target/i386/sev.c +3 -3
@@ -1883,7 +1883,7 @@ static bool build_kernel_loader_hashes(PaddedSevHashTable *padded_ht,* be used. */ hashp = cmdline_hash; -if (qcrypto_hash_bytes (QCRYPTO_HASH_ALG_SHA256 , ctx->cmdline_data, +if (qcrypto_hash_bytes (QCRYPTO_HASH_ALGO_SHA256 , ctx->cmdline_data, ctx->cmdline_size, &hashp, &hash_len, errp) <0 ) {return false; }
@@ -1894,7 +1894,7 @@ static bool build_kernel_loader_hashes(PaddedSevHashTable *padded_ht,* -initrd, an empty buffer will be used (ctx->initrd_size == 0). */ hashp = initrd_hash; -if (qcrypto_hash_bytes (QCRYPTO_HASH_ALG_SHA256 , ctx->initrd_data, +if (qcrypto_hash_bytes (QCRYPTO_HASH_ALGO_SHA256 , ctx->initrd_data, ctx->initrd_size, &hashp, &hash_len, errp) <0 ) {return false; }
@@ -1906,7 +1906,7 @@ static bool build_kernel_loader_hashes(PaddedSevHashTable *padded_ht, { .iov_base = ctx->setup_data, .iov_len = ctx->setup_size }, { .iov_base = ctx->kernel_data, .iov_len = ctx->kernel_size } }; -if (qcrypto_hash_bytesv (QCRYPTO_HASH_ALG_SHA256 , iov,ARRAY_SIZE (iov), +if (qcrypto_hash_bytesv (QCRYPTO_HASH_ALGO_SHA256 , iov,ARRAY_SIZE (iov), &hashp, &hash_len, errp) <0 ) {return false; }
tests/bench/benchmark-crypto-akcipher.c +6 -6
@@ -21,7 +21,7 @@static QCryptoAkCipher *create_rsa_akcipher (const uint8_t *priv_key,size_t keylen,QCryptoRSAPaddingAlgorithm padding, -QCryptoHashAlgorithm hash) +QCryptoHashAlgo hash) {QCryptoAkCipherOptions opt;
@@ -40,7 +40,7 @@ static void test_rsa_speed(const uint8_t *priv_key, size_t keylen,#define SIGN_TIMES 10000#define VERIFY_TIMES 100000#define PADDING QCRYPTO_RSA_PADDING_ALG_PKCS1 -#define HASH QCRYPTO_HASH_ALG_SHA1 +#define HASH QCRYPTO_HASH_ALGO_SHA1g_autoptr (QCryptoAkCipher) rsa =create_rsa_akcipher (priv_key, keylen,PADDING ,HASH );
@@ -54,7 +54,7 @@ static void test_rsa_speed(const uint8_t *priv_key, size_t keylen,g_test_message ("benchmark rsa%zu (%s-%s) sign..." , key_size,QCryptoRSAPaddingAlgorithm_str (PADDING ), -QCryptoHashAlgorithm_str (HASH )); +QCryptoHashAlgo_str (HASH ));g_test_timer_start ();for (count =0 ; count <SIGN_TIMES ; ++count) { g_assert(qcrypto_akcipher_sign(rsa, dgst, SHA1_DGST_LEN,
@@ -65,13 +65,13 @@ static void test_rsa_speed(const uint8_t *priv_key, size_t keylen,g_test_message ("rsa%zu (%s-%s) sign %zu times in %.2f seconds," " %.2f times/sec " , key_size,QCryptoRSAPaddingAlgorithm_str (PADDING ), -QCryptoHashAlgorithm_str (HASH ), +QCryptoHashAlgo_str (HASH ), count,g_test_timer_last (), (double )count /g_test_timer_last ());g_test_message ("benchmark rsa%zu (%s-%s) verification..." , key_size,QCryptoRSAPaddingAlgorithm_str (PADDING ), -QCryptoHashAlgorithm_str (HASH )); +QCryptoHashAlgo_str (HASH ));g_test_timer_start ();for (count =0 ; count <VERIFY_TIMES ; ++count) { g_assert(qcrypto_akcipher_verify(rsa, signature, key_size / BYTE,
@@ -82,7 +82,7 @@ static void test_rsa_speed(const uint8_t *priv_key, size_t keylen,g_test_message ("rsa%zu (%s-%s) verify %zu times in %.2f seconds," " %.2f times/sec " , key_size,QCryptoRSAPaddingAlgorithm_str (PADDING ), -QCryptoHashAlgorithm_str (HASH ), +QCryptoHashAlgo_str (HASH ), count,g_test_timer_last (), (double )count /g_test_timer_last ()); }
tests/bench/benchmark-crypto-hash.c +5 -5
@@ -17,7 +17,7 @@typedef struct QCryptoHashOpts {size_t chunk_size; -QCryptoHashAlgorithm alg; +QCryptoHashAlgo alg; }QCryptoHashOpts ;static void test_hash_speed (const void *opaque)
@@ -49,7 +49,7 @@ static void test_hash_speed(const void *opaque)g_test_timer_elapsed ();g_test_message ("hash(%s): chunk %zu bytes %.2f MB/sec" , -QCryptoHashAlgorithm_str (opts->alg), +QCryptoHashAlgo_str (opts->alg), opts->chunk_size, total /g_test_timer_last ());g_free (out);
@@ -65,14 +65,14 @@ int main(int argc, char **argv)#define TEST_ONE (a, c) \ QCryptoHashOpts opts ## a ## c = { \ - .alg = QCRYPTO_HASH_ALG_ ## a, .chunk_size = c, \ + .alg = QCRYPTO_HASH_ALGO_ ## a, .chunk_size = c, \ }; \ memset(name, 0 , sizeof(name)); \ snprintf(name, sizeof(name), \ "/crypto/benchmark/hash/%s/bufsize-%d", \ - QCryptoHashAlgorithm_str(QCRYPTO_HASH_ALG_ ## a), \ + QCryptoHashAlgo_str(QCRYPTO_HASH_ALGO_ ## a), \ c); \ - if (qcrypto_hash_supports(QCRYPTO_HASH_ALG_ ## a)) \ + if (qcrypto_hash_supports(QCRYPTO_HASH_ALGO_ ## a)) \ g_test_add_data_func(name, \ &opts ## a ## c, \ test_hash_speed);
tests/bench/benchmark-crypto-hmac.c +3 -3
@@ -28,7 +28,7 @@ static void test_hmac_speed(const void *opaque)Error *err =NULL ;int ret; -if (!qcrypto_hmac_supports (QCRYPTO_HASH_ALG_SHA256 )) { +if (!qcrypto_hmac_supports (QCRYPTO_HASH_ALGO_SHA256 )) {return ; }
@@ -40,7 +40,7 @@ static void test_hmac_speed(const void *opaque)g_test_timer_start (); do { - hmac = qcrypto_hmac_new(QCRYPTO_HASH_ALG_SHA256, + hmac = qcrypto_hmac_new(QCRYPTO_HASH_ALGO_SHA256, (const uint8_t *)KEY, strlen(KEY), &err); g_assert(err == NULL); g_assert(hmac != NULL);
@@ -56,7 +56,7 @@ static void test_hmac_speed(const void *opaque) total /= MiB;g_test_message ("hmac(%s): chunk %zu bytes %.2f MB/sec" , -QCryptoHashAlgorithm_str (QCRYPTO_HASH_ALG_SHA256 ), +QCryptoHashAlgo_str (QCRYPTO_HASH_ALGO_SHA256 ), chunk_size, total /g_test_timer_last ());g_free (out);
tests/unit/test-crypto-afsplit.c +5 -5
@@ -26,7 +26,7 @@typedef struct QCryptoAFSplitTestData QCryptoAFSplitTestData ;struct QCryptoAFSplitTestData {const char *path; -QCryptoHashAlgorithm hash; +QCryptoHashAlgo hash;uint32_t stripes;size_t blocklen;const uint8_t *key;
@@ -36,7 +36,7 @@ struct QCryptoAFSplitTestData {static QCryptoAFSplitTestData test_data[] = { { .path ="/crypto/afsplit/sha256/5" , - .hash =QCRYPTO_HASH_ALG_SHA256 , + .hash =QCRYPTO_HASH_ALGO_SHA256 , .stripes =5 , .blocklen =32 , .key = (const uint8_t *)
@@ -68,7 +68,7 @@ static QCryptoAFSplitTestData test_data[] = { }, { .path = "/crypto/afsplit/sha256/5000", - .hash = QCRYPTO_HASH_ALG_SHA256, + .hash = QCRYPTO_HASH_ALGO_SHA256, .stripes = 5000, .blocklen = 16, .key = (const uint8_t *)
@@ -77,7 +77,7 @@ static QCryptoAFSplitTestData test_data[] = { }, { .path = "/crypto/afsplit/sha1/1000", - .hash = QCRYPTO_HASH_ALG_SHA1, + .hash = QCRYPTO_HASH_ALGO_SHA1, .stripes = 1000, .blocklen = 32, .key = (const uint8_t *)
@@ -88,7 +88,7 @@ static QCryptoAFSplitTestData test_data[] = { }, { .path = "/crypto/afsplit/sha256/big", - .hash = QCRYPTO_HASH_ALG_SHA256, + .hash = QCRYPTO_HASH_ALGO_SHA256, .stripes = 1000, .blocklen = 64, .key = (const uint8_t *)
tests/unit/test-crypto-akcipher.c +3 -3
@@ -808,7 +808,7 @@ static QCryptoAkCipherTestData akcipher_test_data[] = { .alg = QCRYPTO_AKCIPHER_ALG_RSA, .u.rsa = { .padding_alg = QCRYPTO_RSA_PADDING_ALG_PKCS1, - .hash_alg = QCRYPTO_HASH_ALG_SHA1, + .hash_alg = QCRYPTO_HASH_ALGO_SHA1, }, }, .pub_key = rsa1024_public_key,
@@ -853,7 +853,7 @@ static QCryptoAkCipherTestData akcipher_test_data[] = { .alg = QCRYPTO_AKCIPHER_ALG_RSA, .u.rsa = { .padding_alg = QCRYPTO_RSA_PADDING_ALG_PKCS1, - .hash_alg = QCRYPTO_HASH_ALG_SHA1, + .hash_alg = QCRYPTO_HASH_ALGO_SHA1, }, }, .pub_key = rsa2048_public_key,
@@ -947,7 +947,7 @@ static void test_rsakey(const void *opaque) .alg = QCRYPTO_AKCIPHER_ALG_RSA, .u.rsa = { .padding_alg = QCRYPTO_RSA_PADDING_ALG_PKCS1, - .hash_alg = QCRYPTO_HASH_ALG_SHA1, + .hash_alg = QCRYPTO_HASH_ALGO_SHA1, } }; g_autoptr(QCryptoAkCipher) key = qcrypto_akcipher_new(
tests/unit/test-crypto-block.c +8 -8
@@ -97,9 +97,9 @@ static QCryptoBlockCreateOptions luks_create_opts_aes256_cbc_essiv = { .has_ivgen_alg = true, .ivgen_alg = QCRYPTO_IVGEN_ALG_ESSIV, .has_ivgen_hash_alg = true, - .ivgen_hash_alg = QCRYPTO_HASH_ALG_SHA256, + .ivgen_hash_alg = QCRYPTO_HASH_ALGO_SHA256, .has_hash_alg = true, - .hash_alg = QCRYPTO_HASH_ALG_SHA1, + .hash_alg = QCRYPTO_HASH_ALGO_SHA1, }, };#endif /* TEST_LUKS */
@@ -114,10 +114,10 @@ static struct QCryptoBlockTestData {QCryptoCipherAlgorithm cipher_alg;QCryptoCipherMode cipher_mode; -QCryptoHashAlgorithm hash_alg; +QCryptoHashAlgo hash_alg;QCryptoIVGenAlgorithm ivgen_alg; -QCryptoHashAlgorithm ivgen_hash; +QCryptoHashAlgo ivgen_hash;bool slow; } test_data[] = {
@@ -143,7 +143,7 @@ static struct QCryptoBlockTestData { .cipher_alg = QCRYPTO_CIPHER_ALG_AES_256, .cipher_mode = QCRYPTO_CIPHER_MODE_XTS, - .hash_alg = QCRYPTO_HASH_ALG_SHA256, + .hash_alg = QCRYPTO_HASH_ALGO_SHA256, .ivgen_alg = QCRYPTO_IVGEN_ALG_PLAIN64,
@@ -158,7 +158,7 @@ static struct QCryptoBlockTestData { .cipher_alg = QCRYPTO_CIPHER_ALG_AES_256, .cipher_mode = QCRYPTO_CIPHER_MODE_CBC, - .hash_alg = QCRYPTO_HASH_ALG_SHA256, + .hash_alg = QCRYPTO_HASH_ALGO_SHA256, .ivgen_alg = QCRYPTO_IVGEN_ALG_PLAIN64,
@@ -173,10 +173,10 @@ static struct QCryptoBlockTestData { .cipher_alg = QCRYPTO_CIPHER_ALG_AES_256, .cipher_mode = QCRYPTO_CIPHER_MODE_CBC, - .hash_alg = QCRYPTO_HASH_ALG_SHA1, + .hash_alg = QCRYPTO_HASH_ALGO_SHA1, .ivgen_alg = QCRYPTO_IVGEN_ALG_ESSIV, - .ivgen_hash = QCRYPTO_HASH_ALG_SHA256, + .ivgen_hash = QCRYPTO_HASH_ALGO_SHA256, .slow = true, },
tests/unit/test-crypto-hash.c +21 -21
52 lines not on this page · raw message
tests/unit/test-crypto-hmac.c +8 -8
@@ -27,43 +27,43 @@typedef struct QCryptoHmacTestData QCryptoHmacTestData ;struct QCryptoHmacTestData { -QCryptoHashAlgorithm alg; +QCryptoHashAlgo alg;const char *hex_digest; };static QCryptoHmacTestData test_data[] = { { - .alg =QCRYPTO_HASH_ALG_MD5 , + .alg =QCRYPTO_HASH_ALGO_MD5 , .hex_digest ="ede9cb83679ba82d88fbeae865b3f8fc" , }, { - .alg =QCRYPTO_HASH_ALG_SHA1 , + .alg =QCRYPTO_HASH_ALGO_SHA1 , .hex_digest ="c7b5a631e3aac975c4ededfcd346e469" "dbc5f2d1" , }, { - .alg =QCRYPTO_HASH_ALG_SHA224 , + .alg =QCRYPTO_HASH_ALGO_SHA224 , .hex_digest ="5f768179dbb29ca722875d0f461a2e2f" "597d0210340a84df1a8e9c63" , }, { - .alg =QCRYPTO_HASH_ALG_SHA256 , + .alg =QCRYPTO_HASH_ALGO_SHA256 , .hex_digest ="3798f363c57afa6edaffe39016ca7bad" "efd1e670afb0e3987194307dec3197db" , }, { - .alg =QCRYPTO_HASH_ALG_SHA384 , + .alg =QCRYPTO_HASH_ALGO_SHA384 , .hex_digest ="d218680a6032d33dccd9882d6a6a7164" "64f26623be257a9b2919b185294f4a49" "9e54b190bfd6bc5cedd2cd05c7e65e82" , }, { - .alg =QCRYPTO_HASH_ALG_SHA512 , + .alg =QCRYPTO_HASH_ALGO_SHA512 , .hex_digest ="835a4f5b3750b4c1fccfa88da2f746a4" "900160c9f18964309bb736c13b59491b"
@@ -71,7 +71,7 @@ static QCryptoHmacTestData test_data[] = { "94c4ba26862b2dadb59b7ede1d08d53e", }, { - .alg = QCRYPTO_HASH_ALG_RIPEMD160, + .alg = QCRYPTO_HASH_ALGO_RIPEMD160, .hex_digest ="94964ed4c1155b62b668c241d67279e5" "8a711676",
tests/unit/test-crypto-ivgen.c +4 -4
@@ -27,7 +27,7 @@ struct QCryptoIVGenTestData {const char *path;uint64_t sector;QCryptoIVGenAlgorithm ivalg; -QCryptoHashAlgorithm hashalg; +QCryptoHashAlgo hashalg;QCryptoCipherAlgorithm cipheralg;const uint8_t *key;size_t nkey;
@@ -94,7 +94,7 @@ struct QCryptoIVGenTestData { .sector = 0x1, .ivalg = QCRYPTO_IVGEN_ALG_ESSIV, .cipheralg = QCRYPTO_CIPHER_ALG_AES_128, - .hashalg = QCRYPTO_HASH_ALG_SHA256, + .hashalg = QCRYPTO_HASH_ALGO_SHA256, .key = (const uint8_t *)"\x00\x01\x02\x03\x04\x05\x06\x07" "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f", .nkey = 16,
@@ -108,7 +108,7 @@ struct QCryptoIVGenTestData { .sector = 0x1f2e3d4cULL, .ivalg = QCRYPTO_IVGEN_ALG_ESSIV, .cipheralg = QCRYPTO_CIPHER_ALG_AES_128, - .hashalg = QCRYPTO_HASH_ALG_SHA256, + .hashalg = QCRYPTO_HASH_ALGO_SHA256, .key = (const uint8_t *)"\x00\x01\x02\x03\x04\x05\x06\x07" "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f", .nkey = 16,
@@ -122,7 +122,7 @@ struct QCryptoIVGenTestData { .sector = 0x1f2e3d4c5b6a7988ULL, .ivalg = QCRYPTO_IVGEN_ALG_ESSIV, .cipheralg = QCRYPTO_CIPHER_ALG_AES_128, - .hashalg = QCRYPTO_HASH_ALG_SHA256, + .hashalg = QCRYPTO_HASH_ALGO_SHA256, .key = (const uint8_t *)"\x00\x01\x02\x03\x04\x05\x06\x07" "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f", .nkey = 16,
tests/unit/test-crypto-pbkdf.c +22 -22
176 lines not on this page · raw message
ui/vnc.c +1 -1
@@ -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 ;
util/hbitmap.c +1 -1
@@ -949,7 +949,7 @@ char *hbitmap_sha256(const HBitmap *bitmap, Error **errp)size_t size = bitmap->sizes[HBITMAP_LEVELS -1 ] *sizeof (unsigned long );char *data = (char *)bitmap->levels[HBITMAP_LEVELS -1 ];char *hash =NULL ; -qcrypto_hash_digest (QCRYPTO_HASH_ALG_SHA256 , data, size, &hash, errp); +qcrypto_hash_digest (QCRYPTO_HASH_ALGO_SHA256 , data, size, &hash, errp);return hash; }
crypto/akcipher-gcrypt.c.inc +7 -7
@@ -33,7 +33,7 @@ typedef struct QCryptoGcryptRSA { QCryptoAkCipher akcipher; gcry_sexp_t key; QCryptoRSAPaddingAlgorithm padding_alg; - QCryptoHashAlgorithm hash_alg; + QCryptoHashAlgo hash_alg; } QCryptoGcryptRSA; static void qcrypto_gcrypt_rsa_free(QCryptoAkCipher *akcipher)
@@ -417,7 +417,7 @@ static int qcrypto_gcrypt_rsa_sign(QCryptoAkCipher *akcipher, err = gcry_sexp_build(&dgst_sexp, NULL, "(data (flags pkcs1) (hash %s %b))", - QCryptoHashAlgorithm_str(rsa->hash_alg), + QCryptoHashAlgo_str(rsa->hash_alg), in_len, in); if (gcry_err_code(err) != 0) { error_setg(errp, "Failed to build dgst: %s/%s",
@@ -497,7 +497,7 @@ static int qcrypto_gcrypt_rsa_verify(QCryptoAkCipher *akcipher, err = gcry_sexp_build(&dgst_sexp, NULL, "(data (flags pkcs1) (hash %s %b))", - QCryptoHashAlgorithm_str(rsa->hash_alg), + QCryptoHashAlgo_str(rsa->hash_alg), in2_len, in2); if (gcry_err_code(err) != 0) { error_setg(errp, "Failed to build dgst: %s/%s",
@@ -575,10 +575,10 @@ bool qcrypto_akcipher_supports(QCryptoAkCipherOptions *opts) case QCRYPTO_RSA_PADDING_ALG_PKCS1: switch (opts->u.rsa.hash_alg) { - case QCRYPTO_HASH_ALG_MD5: - case QCRYPTO_HASH_ALG_SHA1: - case QCRYPTO_HASH_ALG_SHA256: - case QCRYPTO_HASH_ALG_SHA512: + case QCRYPTO_HASH_ALGO_MD5: + case QCRYPTO_HASH_ALGO_SHA1: + case QCRYPTO_HASH_ALGO_SHA256: + case QCRYPTO_HASH_ALGO_SHA512: return true; default:
crypto/akcipher-nettle.c.inc +13 -13
@@ -34,7 +34,7 @@ typedef struct QCryptoNettleRSA { struct rsa_public_key pub; struct rsa_private_key priv; QCryptoRSAPaddingAlgorithm padding_alg; - QCryptoHashAlgorithm hash_alg; + QCryptoHashAlgo hash_alg; } QCryptoNettleRSA; static void qcrypto_nettle_rsa_free(QCryptoAkCipher *akcipher)
@@ -276,19 +276,19 @@ static int qcrypto_nettle_rsa_sign(QCryptoAkCipher *akcipher, mpz_init(s); switch (rsa->hash_alg) { - case QCRYPTO_HASH_ALG_MD5: + case QCRYPTO_HASH_ALGO_MD5: rv = rsa_md5_sign_digest(&rsa->priv, data, s); break; - case QCRYPTO_HASH_ALG_SHA1: + case QCRYPTO_HASH_ALGO_SHA1: rv = rsa_sha1_sign_digest(&rsa->priv, data, s); break; - case QCRYPTO_HASH_ALG_SHA256: + case QCRYPTO_HASH_ALGO_SHA256: rv = rsa_sha256_sign_digest(&rsa->priv, data, s); break; - case QCRYPTO_HASH_ALG_SHA512: + case QCRYPTO_HASH_ALGO_SHA512: rv = rsa_sha512_sign_digest(&rsa->priv, data, s); break;
@@ -341,19 +341,19 @@ static int qcrypto_nettle_rsa_verify(QCryptoAkCipher *akcipher, nettle_mpz_init_set_str_256_u(s, sig_len, sig); switch (rsa->hash_alg) { - case QCRYPTO_HASH_ALG_MD5: + case QCRYPTO_HASH_ALGO_MD5: rv = rsa_md5_verify_digest(&rsa->pub, data, s); break; - case QCRYPTO_HASH_ALG_SHA1: + case QCRYPTO_HASH_ALGO_SHA1: rv = rsa_sha1_verify_digest(&rsa->pub, data, s); break; - case QCRYPTO_HASH_ALG_SHA256: + case QCRYPTO_HASH_ALGO_SHA256: rv = rsa_sha256_verify_digest(&rsa->pub, data, s); break; - case QCRYPTO_HASH_ALG_SHA512: + case QCRYPTO_HASH_ALGO_SHA512: rv = rsa_sha512_verify_digest(&rsa->pub, data, s); break;
@@ -429,10 +429,10 @@ bool qcrypto_akcipher_supports(QCryptoAkCipherOptions *opts) switch (opts->u.rsa.padding_alg) { case QCRYPTO_RSA_PADDING_ALG_PKCS1: switch (opts->u.rsa.hash_alg) { - case QCRYPTO_HASH_ALG_MD5: - case QCRYPTO_HASH_ALG_SHA1: - case QCRYPTO_HASH_ALG_SHA256: - case QCRYPTO_HASH_ALG_SHA512: + case QCRYPTO_HASH_ALGO_MD5: + case QCRYPTO_HASH_ALGO_SHA1: + case QCRYPTO_HASH_ALGO_SHA256: + case QCRYPTO_HASH_ALGO_SHA512: return true; default:
Signature · 1 line
2.46.0
PATCH v2 12/19 qapi/crypto: Rename QCryptoCipherAlgorithm to *Algo, and drop prefix
In reply to Markus ArmbrusterQAPI'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.
--- 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(-)
qapi/block-core.json +1 -1
@@ -4163,7 +4163,7 @@ ## { 'struct': 'RbdEncryptionCreateOptionsLUKSBase', 'base': 'RbdEncryptionOptionsLUKSBase', - 'data': { '*cipher-alg': 'QCryptoCipherAlgorithm' } } + 'data': { '*cipher-alg': 'QCryptoCipherAlgo' } } ## # @RbdEncryptionOptionsLUKS:
qapi/crypto.json +4 -5
@@ -62,7 +62,7 @@ 'data': ['md5', 'sha1', 'sha224', 'sha256', 'sha384', 'sha512', 'ripemd160']} ## -# @QCryptoCipherAlgorithm: +# @QCryptoCipherAlgo: # # The supported algorithms for content encryption ciphers #
@@ -95,8 +95,7 @@ # # Since: 2.6 ## -{ 'enum': 'QCryptoCipherAlgorithm', - 'prefix': 'QCRYPTO_CIPHER_ALG', +{ 'enum': 'QCryptoCipherAlgo', 'data': ['aes-128', 'aes-192', 'aes-256', 'des', '3des', 'cast5-128',
@@ -225,7 +224,7 @@ ## { 'struct': 'QCryptoBlockCreateOptionsLUKS', 'base': 'QCryptoBlockOptionsLUKS', - 'data': { '*cipher-alg': 'QCryptoCipherAlgorithm', + 'data': { '*cipher-alg': 'QCryptoCipherAlgo', '*cipher-mode': 'QCryptoCipherMode', '*ivgen-alg': 'QCryptoIVGenAlgorithm', '*ivgen-hash-alg': 'QCryptoHashAlgo',
@@ -322,7 +321,7 @@ # Since: 2.7 ## { 'struct': 'QCryptoBlockInfoLUKS', - 'data': {'cipher-alg': 'QCryptoCipherAlgorithm', + 'data': {'cipher-alg': 'QCryptoCipherAlgo', 'cipher-mode': 'QCryptoCipherMode', 'ivgen-alg': 'QCryptoIVGenAlgorithm', '*ivgen-hash-alg': 'QCryptoHashAlgo',
crypto/blockpriv.h +2 -2
@@ -33,7 +33,7 @@ struct QCryptoBlock {void *opaque;/* Cipher parameters */ -QCryptoCipherAlgorithm alg; +QCryptoCipherAlgo alg;QCryptoCipherMode mode;uint8_t *key;size_t nkey;
@@ -132,7 +132,7 @@ int qcrypto_block_encrypt_helper(QCryptoBlock *block, Error **errp);int qcrypto_block_init_cipher (QCryptoBlock *block, -QCryptoCipherAlgorithm alg, +QCryptoCipherAlgo alg,QCryptoCipherMode mode,const uint8_t *key,size_t nkey,Error **errp);
crypto/cipherpriv.h +1 -1
@@ -42,7 +42,7 @@ struct QCryptoCipherDriver {#include "afalgpriv.h" extern QCryptoCipher * -qcrypto_afalg_cipher_ctx_new (QCryptoCipherAlgorithm alg, +qcrypto_afalg_cipher_ctx_new (QCryptoCipherAlgo alg,QCryptoCipherMode mode,const uint8_t *key,size_t nkey,Error **errp);
crypto/ivgenpriv.h +1 -1
@@ -41,7 +41,7 @@ struct QCryptoIVGen {void *private;QCryptoIVGenAlgorithm algorithm; -QCryptoCipherAlgorithm cipher; +QCryptoCipherAlgo cipher;QCryptoHashAlgo hash; };
include/crypto/cipher.h +9 -9
@@ -26,7 +26,7 @@typedef struct QCryptoCipher QCryptoCipher ;typedef struct QCryptoCipherDriver QCryptoCipherDriver ; -/* See also "QCryptoCipherAlgorithm" and "QCryptoCipherMode" +/* See also "QCryptoCipherAlgo" and "QCryptoCipherMode" * enums defined in qapi/crypto.json */ /**
@@ -50,12 +50,12 @@ typedef struct QCryptoCipherDriver QCryptoCipherDriver;* size_t keylen = 16; * uint8_t iv = ....; * -* if (!qcrypto_cipher_supports(QCRYPTO_CIPHER_ALG_AES_128)) { +* if (!qcrypto_cipher_supports(QCRYPTO_CIPHER_ALGO_AES_128)) { * error_report(errp, "Feature <blah> requires AES cipher support"); * return -1; * } * -* cipher = qcrypto_cipher_new(QCRYPTO_CIPHER_ALG_AES_128, +* cipher = qcrypto_cipher_new(QCRYPTO_CIPHER_ALGO_AES_128, * QCRYPTO_CIPHER_MODE_CBC, * key, keylen, * errp);
@@ -78,7 +78,7 @@ typedef struct QCryptoCipherDriver QCryptoCipherDriver;*/ struct QCryptoCipher { -QCryptoCipherAlgorithm alg; +QCryptoCipherAlgo alg;QCryptoCipherMode mode;const QCryptoCipherDriver *driver; };
@@ -93,7 +93,7 @@ struct QCryptoCipher {* * Returns: true if the algorithm is supported, false otherwise */ -bool qcrypto_cipher_supports (QCryptoCipherAlgorithm alg, +bool qcrypto_cipher_supports (QCryptoCipherAlgo alg,QCryptoCipherMode mode);/**
@@ -106,7 +106,7 @@ bool qcrypto_cipher_supports(QCryptoCipherAlgorithm alg,* * Returns: the block size in bytes */ -size_t qcrypto_cipher_get_block_len (QCryptoCipherAlgorithm alg); +size_t qcrypto_cipher_get_block_len (QCryptoCipherAlgo alg);/**
@@ -117,7 +117,7 @@ size_t qcrypto_cipher_get_block_len(QCryptoCipherAlgorithm alg);* * Returns: the key size in bytes */ -size_t qcrypto_cipher_get_key_len (QCryptoCipherAlgorithm alg); +size_t qcrypto_cipher_get_key_len (QCryptoCipherAlgo alg);/**
@@ -130,7 +130,7 @@ size_t qcrypto_cipher_get_key_len(QCryptoCipherAlgorithm alg);* * Returns: the IV size in bytes, or 0 if no IV is permitted */ -size_t qcrypto_cipher_get_iv_len (QCryptoCipherAlgorithm alg, +size_t qcrypto_cipher_get_iv_len (QCryptoCipherAlgo alg,QCryptoCipherMode mode);
@@ -156,7 +156,7 @@ size_t qcrypto_cipher_get_iv_len(QCryptoCipherAlgorithm alg,* * Returns: a new cipher object, or NULL on error */ -QCryptoCipher *qcrypto_cipher_new (QCryptoCipherAlgorithm alg, +QCryptoCipher *qcrypto_cipher_new (QCryptoCipherAlgo alg,QCryptoCipherMode mode,const uint8_t *key,size_t nkey,Error **errp);
include/crypto/ivgen.h +5 -5
@@ -45,21 +45,21 @@* g_assert((ndata % 512) == 0); * * QCryptoIVGen *ivgen = qcrypto_ivgen_new(QCRYPTO_IVGEN_ALG_ESSIV, -* QCRYPTO_CIPHER_ALG_AES_128, +* QCRYPTO_CIPHER_ALGO_AES_128, * QCRYPTO_HASH_ALGO_SHA256, * key, nkey, errp); * if (!ivgen) { * return -1; * } * -* QCryptoCipher *cipher = qcrypto_cipher_new(QCRYPTO_CIPHER_ALG_AES_128, +* QCryptoCipher *cipher = qcrypto_cipher_new(QCRYPTO_CIPHER_ALGO_AES_128, * QCRYPTO_CIPHER_MODE_CBC, * key, nkey, errp); * if (!cipher) { * goto error; * } * -* niv = qcrypto_cipher_get_iv_len(QCRYPTO_CIPHER_ALG_AES_128, +* niv = qcrypto_cipher_get_iv_len(QCRYPTO_CIPHER_ALGO_AES_128, * QCRYPTO_CIPHER_MODE_CBC); * iv = g_new0(uint8_t, niv); *
@@ -134,7 +134,7 @@ typedef struct QCryptoIVGen QCryptoIVGen;* Returns: a new IV generator, or NULL on error */ QCryptoIVGen *qcrypto_ivgen_new (QCryptoIVGenAlgorithm alg, -QCryptoCipherAlgorithm cipheralg, +QCryptoCipherAlgo cipheralg,QCryptoHashAlgo hash,const uint8_t *key,size_t nkey,Error **errp);
@@ -179,7 +179,7 @@ QCryptoIVGenAlgorithm qcrypto_ivgen_get_algorithm(QCryptoIVGen *ivgen);* * Returns: the cipher algorithm */ -QCryptoCipherAlgorithm qcrypto_ivgen_get_cipher (QCryptoIVGen *ivgen); +QCryptoCipherAlgo qcrypto_ivgen_get_cipher (QCryptoIVGen *ivgen);/**
include/crypto/pbkdf.h +2 -2
@@ -38,7 +38,7 @@* .... * * char *password = "a-typical-awful-user-password"; -* size_t nkey = qcrypto_cipher_get_key_len(QCRYPTO_CIPHER_ALG_AES_128); +* size_t nkey = qcrypto_cipher_get_key_len(QCRYPTO_CIPHER_ALGO_AES_128); * uint8_t *salt = g_new0(uint8_t, nkey); * uint8_t *key = g_new0(uint8_t, nkey); * int iterations;
@@ -70,7 +70,7 @@* * g_free(salt); * -* cipher = qcrypto_cipher_new(QCRYPTO_CIPHER_ALG_AES_128, +* cipher = qcrypto_cipher_new(QCRYPTO_CIPHER_ALGO_AES_128, * QCRYPTO_CIPHER_MODE_ECB, * key, nkey, errp); * g_free(key);
backends/cryptodev-builtin.c +8 -8
@@ -138,18 +138,18 @@ cryptodev_builtin_get_aes_algo(uint32_t key_len, int mode, Error **errp)int algo;if (key_len ==AES_KEYSIZE_128 ) { - algo =QCRYPTO_CIPHER_ALG_AES_128 ; + algo =QCRYPTO_CIPHER_ALGO_AES_128 ; }else if (key_len ==AES_KEYSIZE_192 ) { - algo =QCRYPTO_CIPHER_ALG_AES_192 ; + algo =QCRYPTO_CIPHER_ALGO_AES_192 ; }else if (key_len ==AES_KEYSIZE_256 ) {/* equals AES_KEYSIZE_128_XTS */ if (mode ==QCRYPTO_CIPHER_MODE_XTS ) { - algo =QCRYPTO_CIPHER_ALG_AES_128 ; + algo =QCRYPTO_CIPHER_ALGO_AES_128 ; }else { - algo =QCRYPTO_CIPHER_ALG_AES_256 ; + algo =QCRYPTO_CIPHER_ALGO_AES_256 ; } }else if (key_len ==AES_KEYSIZE_256_XTS ) {if (mode ==QCRYPTO_CIPHER_MODE_XTS ) { - algo =QCRYPTO_CIPHER_ALG_AES_256 ; + algo =QCRYPTO_CIPHER_ALGO_AES_256 ; }else { goto err; }
@@ -271,15 +271,15 @@ static int cryptodev_builtin_create_cipher_session(break ;case VIRTIO_CRYPTO_CIPHER_3DES_ECB : mode =QCRYPTO_CIPHER_MODE_ECB ; - algo =QCRYPTO_CIPHER_ALG_3DES ; + algo =QCRYPTO_CIPHER_ALGO_3DES ;break ;case VIRTIO_CRYPTO_CIPHER_3DES_CBC : mode =QCRYPTO_CIPHER_MODE_CBC ; - algo =QCRYPTO_CIPHER_ALG_3DES ; + algo =QCRYPTO_CIPHER_ALGO_3DES ;break ;case VIRTIO_CRYPTO_CIPHER_3DES_CTR : mode =QCRYPTO_CIPHER_MODE_CTR ; - algo =QCRYPTO_CIPHER_ALG_3DES ; + algo =QCRYPTO_CIPHER_ALGO_3DES ;break ;default : error_setg(errp, "Unsupported cipher alg :%u",
block/rbd.c +2 -2
@@ -367,11 +367,11 @@ static int qemu_rbd_convert_luks_create_options(if (luks_opts->has_cipher_alg) {switch (luks_opts->cipher_alg) { -case QCRYPTO_CIPHER_ALG_AES_128 : { +case QCRYPTO_CIPHER_ALGO_AES_128 : { *alg =RBD_ENCRYPTION_ALGORITHM_AES128 ;break ; } -case QCRYPTO_CIPHER_ALG_AES_256 : { +case QCRYPTO_CIPHER_ALGO_AES_256 : { *alg =RBD_ENCRYPTION_ALGORITHM_AES256 ;break ; }
crypto/block-luks.c +46 -46
188 lines not on this page · raw message
crypto/block-qcow.c +2 -2
@@ -62,7 +62,7 @@ qcrypto_block_qcow_init(QCryptoBlock *block,memcpy (keybuf, password,MIN (len,sizeof (keybuf)));g_free (password); - block->niv =qcrypto_cipher_get_iv_len (QCRYPTO_CIPHER_ALG_AES_128 , + block->niv =qcrypto_cipher_get_iv_len (QCRYPTO_CIPHER_ALGO_AES_128 ,QCRYPTO_CIPHER_MODE_CBC ); block->ivgen =qcrypto_ivgen_new (QCRYPTO_IVGEN_ALG_PLAIN64 ,0 ,0 ,NULL ,0 , errp);
@@ -71,7 +71,7 @@ qcrypto_block_qcow_init(QCryptoBlock *block, goto fail; } - ret =qcrypto_block_init_cipher (block,QCRYPTO_CIPHER_ALG_AES_128 , + ret =qcrypto_block_init_cipher (block,QCRYPTO_CIPHER_ALGO_AES_128 ,QCRYPTO_CIPHER_MODE_CBC , keybuf,G_N_ELEMENTS (keybuf), errp);
crypto/block.c +1 -1
@@ -267,7 +267,7 @@ static void qcrypto_block_push_cipher(QCryptoBlock *block,int qcrypto_block_init_cipher (QCryptoBlock *block, -QCryptoCipherAlgorithm alg, +QCryptoCipherAlgo alg,QCryptoCipherMode mode,const uint8_t *key,size_t nkey,Error **errp)
crypto/cipher-afalg.c +12 -12
@@ -18,7 +18,7 @@static char * -qcrypto_afalg_cipher_format_name (QCryptoCipherAlgorithm alg, +qcrypto_afalg_cipher_format_name (QCryptoCipherAlgo alg,QCryptoCipherMode mode,Error **errp) {
@@ -27,22 +27,22 @@ qcrypto_afalg_cipher_format_name(QCryptoCipherAlgorithm alg,const char *mode_name;switch (alg) { -case QCRYPTO_CIPHER_ALG_AES_128 : -case QCRYPTO_CIPHER_ALG_AES_192 : -case QCRYPTO_CIPHER_ALG_AES_256 : +case QCRYPTO_CIPHER_ALGO_AES_128 : +case QCRYPTO_CIPHER_ALGO_AES_192 : +case QCRYPTO_CIPHER_ALGO_AES_256 : alg_name ="aes" ;break ; -case QCRYPTO_CIPHER_ALG_CAST5_128 : +case QCRYPTO_CIPHER_ALGO_CAST5_128 : alg_name ="cast5" ;break ; -case QCRYPTO_CIPHER_ALG_SERPENT_128 : -case QCRYPTO_CIPHER_ALG_SERPENT_192 : -case QCRYPTO_CIPHER_ALG_SERPENT_256 : +case QCRYPTO_CIPHER_ALGO_SERPENT_128 : +case QCRYPTO_CIPHER_ALGO_SERPENT_192 : +case QCRYPTO_CIPHER_ALGO_SERPENT_256 : alg_name ="serpent" ;break ; -case QCRYPTO_CIPHER_ALG_TWOFISH_128 : -case QCRYPTO_CIPHER_ALG_TWOFISH_192 : -case QCRYPTO_CIPHER_ALG_TWOFISH_256 : +case QCRYPTO_CIPHER_ALGO_TWOFISH_128 : +case QCRYPTO_CIPHER_ALGO_TWOFISH_192 : +case QCRYPTO_CIPHER_ALGO_TWOFISH_256 : alg_name ="twofish" ;break ;
@@ -60,7 +60,7 @@ qcrypto_afalg_cipher_format_name(QCryptoCipherAlgorithm alg,static const struct QCryptoCipherDriver qcrypto_cipher_afalg_driver;QCryptoCipher * -qcrypto_afalg_cipher_ctx_new (QCryptoCipherAlgorithm alg, +qcrypto_afalg_cipher_ctx_new (QCryptoCipherAlgo alg,QCryptoCipherMode mode,const uint8_t *key,size_t nkey,Error **errp)
crypto/cipher.c +36 -36
123 lines not on this page · raw message
crypto/ivgen.c +2 -2
@@ -28,7 +28,7 @@QCryptoIVGen *qcrypto_ivgen_new (QCryptoIVGenAlgorithm alg, -QCryptoCipherAlgorithm cipheralg, +QCryptoCipherAlgo cipheralg,QCryptoHashAlgo hash,const uint8_t *key,size_t nkey,Error **errp)
@@ -79,7 +79,7 @@ QCryptoIVGenAlgorithm qcrypto_ivgen_get_algorithm(QCryptoIVGen *ivgen) } -QCryptoCipherAlgorithm qcrypto_ivgen_get_cipher (QCryptoIVGen *ivgen) +QCryptoCipherAlgo qcrypto_ivgen_get_cipher (QCryptoIVGen *ivgen) {return ivgen->cipher; }
crypto/secret_common.c +1 -1
@@ -71,7 +71,7 @@ static void qcrypto_secret_decrypt(QCryptoSecretCommon *secret,return ; } - aes =qcrypto_cipher_new (QCRYPTO_CIPHER_ALG_AES_256 , + aes =qcrypto_cipher_new (QCRYPTO_CIPHER_ALGO_AES_256 ,QCRYPTO_CIPHER_MODE_CBC , key, keylen, errp);
tests/bench/benchmark-crypto-cipher.c +11 -11
@@ -17,7 +17,7 @@static void test_cipher_speed (size_t chunk_size,QCryptoCipherMode mode, -QCryptoCipherAlgorithm alg) +QCryptoCipherAlgo alg) {QCryptoCipher *cipher;Error *err =NULL ;
@@ -71,7 +71,7 @@ static void test_cipher_speed(size_t chunk_size,g_test_timer_elapsed ();g_test_message ("enc(%s-%s) chunk %zu bytes %.2f MB/sec " , -QCryptoCipherAlgorithm_str (alg), +QCryptoCipherAlgo_str (alg),QCryptoCipherMode_str (mode), chunk_size, (double )total / MiB /g_test_timer_last ());
@@ -88,7 +88,7 @@ static void test_cipher_speed(size_t chunk_size,g_test_timer_elapsed ();g_test_message ("dec(%s-%s) chunk %zu bytes %.2f MB/sec " , -QCryptoCipherAlgorithm_str (alg), +QCryptoCipherAlgo_str (alg),QCryptoCipherMode_str (mode), chunk_size, (double )total / MiB /g_test_timer_last ());
@@ -105,7 +105,7 @@ static void test_cipher_speed_ecb_aes_128(const void *opaque)size_t chunk_size = (size_t )opaque;test_cipher_speed (chunk_size,QCRYPTO_CIPHER_MODE_ECB , -QCRYPTO_CIPHER_ALG_AES_128 ); +QCRYPTO_CIPHER_ALGO_AES_128 ); }static void test_cipher_speed_ecb_aes_256 (const void *opaque)
@@ -113,7 +113,7 @@ static void test_cipher_speed_ecb_aes_256(const void *opaque)size_t chunk_size = (size_t )opaque;test_cipher_speed (chunk_size,QCRYPTO_CIPHER_MODE_ECB , -QCRYPTO_CIPHER_ALG_AES_256 ); +QCRYPTO_CIPHER_ALGO_AES_256 ); }static void test_cipher_speed_cbc_aes_128 (const void *opaque)
@@ -121,7 +121,7 @@ static void test_cipher_speed_cbc_aes_128(const void *opaque)size_t chunk_size = (size_t )opaque;test_cipher_speed (chunk_size,QCRYPTO_CIPHER_MODE_CBC , -QCRYPTO_CIPHER_ALG_AES_128 ); +QCRYPTO_CIPHER_ALGO_AES_128 ); }static void test_cipher_speed_cbc_aes_256 (const void *opaque)
@@ -129,7 +129,7 @@ static void test_cipher_speed_cbc_aes_256(const void *opaque)size_t chunk_size = (size_t )opaque;test_cipher_speed (chunk_size,QCRYPTO_CIPHER_MODE_CBC , -QCRYPTO_CIPHER_ALG_AES_256 ); +QCRYPTO_CIPHER_ALGO_AES_256 ); }static void test_cipher_speed_ctr_aes_128 (const void *opaque)
@@ -137,7 +137,7 @@ static void test_cipher_speed_ctr_aes_128(const void *opaque)size_t chunk_size = (size_t )opaque;test_cipher_speed (chunk_size,QCRYPTO_CIPHER_MODE_CTR , -QCRYPTO_CIPHER_ALG_AES_128 ); +QCRYPTO_CIPHER_ALGO_AES_128 ); }static void test_cipher_speed_ctr_aes_256 (const void *opaque)
@@ -145,7 +145,7 @@ static void test_cipher_speed_ctr_aes_256(const void *opaque)size_t chunk_size = (size_t )opaque;test_cipher_speed (chunk_size,QCRYPTO_CIPHER_MODE_CTR , -QCRYPTO_CIPHER_ALG_AES_256 ); +QCRYPTO_CIPHER_ALGO_AES_256 ); }static void test_cipher_speed_xts_aes_128 (const void *opaque)
@@ -153,7 +153,7 @@ static void test_cipher_speed_xts_aes_128(const void *opaque)size_t chunk_size = (size_t )opaque;test_cipher_speed (chunk_size,QCRYPTO_CIPHER_MODE_XTS , -QCRYPTO_CIPHER_ALG_AES_128 ); +QCRYPTO_CIPHER_ALGO_AES_128 ); }static void test_cipher_speed_xts_aes_256 (const void *opaque)
@@ -161,7 +161,7 @@ static void test_cipher_speed_xts_aes_256(const void *opaque)size_t chunk_size = (size_t )opaque;test_cipher_speed (chunk_size,QCRYPTO_CIPHER_MODE_XTS , -QCRYPTO_CIPHER_ALG_AES_256 ); +QCRYPTO_CIPHER_ALGO_AES_256 ); }
tests/unit/test-crypto-block.c +7 -7
@@ -77,7 +77,7 @@ static QCryptoBlockCreateOptions luks_create_opts_aes256_cbc_plain64 = { .u.luks = { .key_secret = (char *)"sec0", .has_cipher_alg = true, - .cipher_alg = QCRYPTO_CIPHER_ALG_AES_256, + .cipher_alg = QCRYPTO_CIPHER_ALGO_AES_256, .has_cipher_mode = true, .cipher_mode = QCRYPTO_CIPHER_MODE_CBC, .has_ivgen_alg = true,
@@ -91,7 +91,7 @@ static QCryptoBlockCreateOptions luks_create_opts_aes256_cbc_essiv = { .u.luks = { .key_secret = (char *)"sec0", .has_cipher_alg = true, - .cipher_alg = QCRYPTO_CIPHER_ALG_AES_256, + .cipher_alg = QCRYPTO_CIPHER_ALGO_AES_256, .has_cipher_mode = true, .cipher_mode = QCRYPTO_CIPHER_MODE_CBC, .has_ivgen_alg = true,
@@ -112,7 +112,7 @@ static struct QCryptoBlockTestData {bool expect_header; -QCryptoCipherAlgorithm cipher_alg; +QCryptoCipherAlgo cipher_alg;QCryptoCipherMode cipher_mode;QCryptoHashAlgo hash_alg;
@@ -128,7 +128,7 @@ static struct QCryptoBlockTestData { .expect_header = false, - .cipher_alg = QCRYPTO_CIPHER_ALG_AES_128, + .cipher_alg = QCRYPTO_CIPHER_ALGO_AES_128, .cipher_mode = QCRYPTO_CIPHER_MODE_CBC, .ivgen_alg = QCRYPTO_IVGEN_ALG_PLAIN64,
@@ -141,7 +141,7 @@ static struct QCryptoBlockTestData { .expect_header = true, - .cipher_alg = QCRYPTO_CIPHER_ALG_AES_256, + .cipher_alg = QCRYPTO_CIPHER_ALGO_AES_256, .cipher_mode = QCRYPTO_CIPHER_MODE_XTS, .hash_alg = QCRYPTO_HASH_ALGO_SHA256,
@@ -156,7 +156,7 @@ static struct QCryptoBlockTestData { .expect_header = true, - .cipher_alg = QCRYPTO_CIPHER_ALG_AES_256, + .cipher_alg = QCRYPTO_CIPHER_ALGO_AES_256, .cipher_mode = QCRYPTO_CIPHER_MODE_CBC, .hash_alg = QCRYPTO_HASH_ALGO_SHA256,
@@ -171,7 +171,7 @@ static struct QCryptoBlockTestData { .expect_header = true, - .cipher_alg = QCRYPTO_CIPHER_ALG_AES_256, + .cipher_alg = QCRYPTO_CIPHER_ALGO_AES_256, .cipher_mode = QCRYPTO_CIPHER_MODE_CBC, .hash_alg = QCRYPTO_HASH_ALGO_SHA1,
tests/unit/test-crypto-cipher.c +33 -33
264 lines not on this page · raw message
tests/unit/test-crypto-ivgen.c +4 -4
@@ -28,7 +28,7 @@ struct QCryptoIVGenTestData {uint64_t sector;QCryptoIVGenAlgorithm ivalg;QCryptoHashAlgo hashalg; -QCryptoCipherAlgorithm cipheralg; +QCryptoCipherAlgo cipheralg;const uint8_t *key;size_t nkey;const uint8_t *iv;
@@ -93,7 +93,7 @@ struct QCryptoIVGenTestData { "/crypto/ivgen/essiv/1", .sector = 0x1, .ivalg = QCRYPTO_IVGEN_ALG_ESSIV, - .cipheralg = QCRYPTO_CIPHER_ALG_AES_128, + .cipheralg = QCRYPTO_CIPHER_ALGO_AES_128, .hashalg = QCRYPTO_HASH_ALGO_SHA256, .key = (const uint8_t *)"\x00\x01\x02\x03\x04\x05\x06\x07" "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f",
@@ -107,7 +107,7 @@ struct QCryptoIVGenTestData { "/crypto/ivgen/essiv/1f2e3d4c", .sector = 0x1f2e3d4cULL, .ivalg = QCRYPTO_IVGEN_ALG_ESSIV, - .cipheralg = QCRYPTO_CIPHER_ALG_AES_128, + .cipheralg = QCRYPTO_CIPHER_ALGO_AES_128, .hashalg = QCRYPTO_HASH_ALGO_SHA256, .key = (const uint8_t *)"\x00\x01\x02\x03\x04\x05\x06\x07" "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f",
@@ -121,7 +121,7 @@ struct QCryptoIVGenTestData { "/crypto/ivgen/essiv/1f2e3d4c5b6a7988", .sector = 0x1f2e3d4c5b6a7988ULL, .ivalg = QCRYPTO_IVGEN_ALG_ESSIV, - .cipheralg = QCRYPTO_CIPHER_ALG_AES_128, + .cipheralg = QCRYPTO_CIPHER_ALGO_AES_128, .hashalg = QCRYPTO_HASH_ALGO_SHA256, .key = (const uint8_t *)"\x00\x01\x02\x03\x04\x05\x06\x07" "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f",
ui/vnc.c +2 -2
@@ -2783,7 +2783,7 @@ static int protocol_client_auth_vnc(VncState *vs, uint8_t *data, size_t len)vnc_munge_des_rfb_key (key,sizeof (key)); cipher =qcrypto_cipher_new ( -QCRYPTO_CIPHER_ALG_DES , +QCRYPTO_CIPHER_ALGO_DES ,QCRYPTO_CIPHER_MODE_ECB , key,G_N_ELEMENTS (key), &err);
@@ -4064,7 +4064,7 @@ void vnc_display_open(const char *id, Error **errp) }if (password) {if (!qcrypto_cipher_supports ( -QCRYPTO_CIPHER_ALG_DES ,QCRYPTO_CIPHER_MODE_ECB )) { +QCRYPTO_CIPHER_ALGO_DES ,QCRYPTO_CIPHER_MODE_ECB )) {error_setg (errp,"Cipher backend does not support DES algorithm" ); goto fail;
crypto/cipher-builtin.c.inc +9 -9
@@ -221,13 +221,13 @@ static const struct QCryptoCipherDriver qcrypto_cipher_aes_driver_cbc = { .cipher_free = qcrypto_cipher_ctx_free, }; -bool qcrypto_cipher_supports(QCryptoCipherAlgorithm alg, +bool qcrypto_cipher_supports(QCryptoCipherAlgo alg, QCryptoCipherMode mode) { switch (alg) { - case QCRYPTO_CIPHER_ALG_AES_128: - case QCRYPTO_CIPHER_ALG_AES_192: - case QCRYPTO_CIPHER_ALG_AES_256: + case QCRYPTO_CIPHER_ALGO_AES_128: + case QCRYPTO_CIPHER_ALGO_AES_192: + case QCRYPTO_CIPHER_ALGO_AES_256: switch (mode) { case QCRYPTO_CIPHER_MODE_ECB: case QCRYPTO_CIPHER_MODE_CBC:
@@ -241,7 +241,7 @@ bool qcrypto_cipher_supports(QCryptoCipherAlgorithm alg, } } -static QCryptoCipher *qcrypto_cipher_ctx_new(QCryptoCipherAlgorithm alg, +static QCryptoCipher *qcrypto_cipher_ctx_new(QCryptoCipherAlgo alg, QCryptoCipherMode mode, const uint8_t *key, size_t nkey,
@@ -252,9 +252,9 @@ static QCryptoCipher *qcrypto_cipher_ctx_new(QCryptoCipherAlgorithm alg, } switch (alg) { - case QCRYPTO_CIPHER_ALG_AES_128: - case QCRYPTO_CIPHER_ALG_AES_192: - case QCRYPTO_CIPHER_ALG_AES_256: + case QCRYPTO_CIPHER_ALGO_AES_128: + case QCRYPTO_CIPHER_ALGO_AES_192: + case QCRYPTO_CIPHER_ALGO_AES_256: { QCryptoCipherBuiltinAES *ctx; const QCryptoCipherDriver *drv;
@@ -292,7 +292,7 @@ static QCryptoCipher *qcrypto_cipher_ctx_new(QCryptoCipherAlgorithm alg, default: error_setg(errp, "Unsupported cipher algorithm %s", - QCryptoCipherAlgorithm_str(alg)); + QCryptoCipherAlgo_str(alg)); return NULL; }
crypto/cipher-gcrypt.c.inc +28 -28
98 lines not on this page · raw message
crypto/cipher-gnutls.c.inc +19 -19
@@ -27,7 +27,7 @@ #define QEMU_GNUTLS_XTS #endif -bool qcrypto_cipher_supports(QCryptoCipherAlgorithm alg, +bool qcrypto_cipher_supports(QCryptoCipherAlgo alg, QCryptoCipherMode mode) {
@@ -35,11 +35,11 @@ bool qcrypto_cipher_supports(QCryptoCipherAlgorithm alg, case QCRYPTO_CIPHER_MODE_ECB: case QCRYPTO_CIPHER_MODE_CBC: switch (alg) { - case QCRYPTO_CIPHER_ALG_AES_128: - case QCRYPTO_CIPHER_ALG_AES_192: - case QCRYPTO_CIPHER_ALG_AES_256: - case QCRYPTO_CIPHER_ALG_DES: - case QCRYPTO_CIPHER_ALG_3DES: + case QCRYPTO_CIPHER_ALGO_AES_128: + case QCRYPTO_CIPHER_ALGO_AES_192: + case QCRYPTO_CIPHER_ALGO_AES_256: + case QCRYPTO_CIPHER_ALGO_DES: + case QCRYPTO_CIPHER_ALGO_3DES: return true; default: return false;
@@ -47,8 +47,8 @@ bool qcrypto_cipher_supports(QCryptoCipherAlgorithm alg, #ifdef QEMU_GNUTLS_XTS case QCRYPTO_CIPHER_MODE_XTS: switch (alg) { - case QCRYPTO_CIPHER_ALG_AES_128: - case QCRYPTO_CIPHER_ALG_AES_256: + case QCRYPTO_CIPHER_ALGO_AES_128: + case QCRYPTO_CIPHER_ALGO_AES_256: return true; default: return false;
@@ -229,7 +229,7 @@ static struct QCryptoCipherDriver gnutls_driver = { .cipher_free = qcrypto_gnutls_cipher_free, }; -static QCryptoCipher *qcrypto_cipher_ctx_new(QCryptoCipherAlgorithm alg, +static QCryptoCipher *qcrypto_cipher_ctx_new(QCryptoCipherAlgo alg, QCryptoCipherMode mode, const uint8_t *key, size_t nkey,
@@ -244,10 +244,10 @@ static QCryptoCipher *qcrypto_cipher_ctx_new(QCryptoCipherAlgorithm alg, #ifdef QEMU_GNUTLS_XTS case QCRYPTO_CIPHER_MODE_XTS: switch (alg) { - case QCRYPTO_CIPHER_ALG_AES_128: + case QCRYPTO_CIPHER_ALGO_AES_128: galg = GNUTLS_CIPHER_AES_128_XTS; break; - case QCRYPTO_CIPHER_ALG_AES_256: + case QCRYPTO_CIPHER_ALGO_AES_256: galg = GNUTLS_CIPHER_AES_256_XTS; break; default:
@@ -259,19 +259,19 @@ static QCryptoCipher *qcrypto_cipher_ctx_new(QCryptoCipherAlgorithm alg, case QCRYPTO_CIPHER_MODE_ECB: case QCRYPTO_CIPHER_MODE_CBC: switch (alg) { - case QCRYPTO_CIPHER_ALG_AES_128: + case QCRYPTO_CIPHER_ALGO_AES_128: galg = GNUTLS_CIPHER_AES_128_CBC; break; - case QCRYPTO_CIPHER_ALG_AES_192: + case QCRYPTO_CIPHER_ALGO_AES_192: galg = GNUTLS_CIPHER_AES_192_CBC; break; - case QCRYPTO_CIPHER_ALG_AES_256: + case QCRYPTO_CIPHER_ALGO_AES_256: galg = GNUTLS_CIPHER_AES_256_CBC; break; - case QCRYPTO_CIPHER_ALG_DES: + case QCRYPTO_CIPHER_ALGO_DES: galg = GNUTLS_CIPHER_DES_CBC; break; - case QCRYPTO_CIPHER_ALG_3DES: + case QCRYPTO_CIPHER_ALGO_3DES: galg = GNUTLS_CIPHER_3DES_CBC; break; default:
@@ -284,7 +284,7 @@ static QCryptoCipher *qcrypto_cipher_ctx_new(QCryptoCipherAlgorithm alg, if (galg == GNUTLS_CIPHER_UNKNOWN) { error_setg(errp, "Unsupported cipher algorithm %s with %s mode", - QCryptoCipherAlgorithm_str(alg), + QCryptoCipherAlgo_str(alg), QCryptoCipherMode_str(mode)); return NULL; }
@@ -310,8 +310,8 @@ static QCryptoCipher *qcrypto_cipher_ctx_new(QCryptoCipherAlgorithm alg, } } - if (alg == QCRYPTO_CIPHER_ALG_DES || - alg == QCRYPTO_CIPHER_ALG_3DES) + if (alg == QCRYPTO_CIPHER_ALGO_DES || + alg == QCRYPTO_CIPHER_ALGO_3DES) ctx->blocksize = 8; else ctx->blocksize = 16;
crypto/cipher-nettle.c.inc +29 -29
134 lines not on this page · raw message
Signature · 1 line
2.46.0
PATCH v2 13/19 qapi/crypto: Rename QCryptoIVGenAlgorithm to *Algo, and drop prefix
In reply to Markus ArmbrusterQAPI'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.
--- 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(-)
qapi/crypto.json +4 -5
@@ -122,7 +122,7 @@ 'data': ['ecb', 'cbc', 'xts', 'ctr']} ## -# @QCryptoIVGenAlgorithm: +# @QCryptoIVGenAlgo: # # The supported algorithms for generating initialization vectors for # full disk encryption. The 'plain' generator should not be used for
@@ -138,8 +138,7 @@ # # Since: 2.6 ## -{ 'enum': 'QCryptoIVGenAlgorithm', - 'prefix': 'QCRYPTO_IVGEN_ALG', +{ 'enum': 'QCryptoIVGenAlgo', 'data': ['plain', 'plain64', 'essiv']} ##
@@ -226,7 +225,7 @@ 'base': 'QCryptoBlockOptionsLUKS', 'data': { '*cipher-alg': 'QCryptoCipherAlgo', '*cipher-mode': 'QCryptoCipherMode', - '*ivgen-alg': 'QCryptoIVGenAlgorithm', + '*ivgen-alg': 'QCryptoIVGenAlgo', '*ivgen-hash-alg': 'QCryptoHashAlgo', '*hash-alg': 'QCryptoHashAlgo', '*iter-time': 'int' }}
@@ -323,7 +322,7 @@ { 'struct': 'QCryptoBlockInfoLUKS', 'data': {'cipher-alg': 'QCryptoCipherAlgo', 'cipher-mode': 'QCryptoCipherMode', - 'ivgen-alg': 'QCryptoIVGenAlgorithm', + 'ivgen-alg': 'QCryptoIVGenAlgo', '*ivgen-hash-alg': 'QCryptoHashAlgo', 'hash-alg': 'QCryptoHashAlgo', 'detached-header': 'bool',
crypto/ivgenpriv.h +1 -1
@@ -40,7 +40,7 @@ struct QCryptoIVGen {QCryptoIVGenDriver *driver;void *private; -QCryptoIVGenAlgorithm algorithm; +QCryptoIVGenAlgo algorithm;QCryptoCipherAlgo cipher;QCryptoHashAlgo hash; };
include/crypto/ivgen.h +7 -7
@@ -44,7 +44,7 @@* * g_assert((ndata % 512) == 0); * -* QCryptoIVGen *ivgen = qcrypto_ivgen_new(QCRYPTO_IVGEN_ALG_ESSIV, +* QCryptoIVGen *ivgen = qcrypto_ivgen_new(QCRYPTO_IV_GEN_ALGO_ESSIV, * QCRYPTO_CIPHER_ALGO_AES_128, * QCRYPTO_HASH_ALGO_SHA256, * key, nkey, errp);
@@ -97,7 +97,7 @@typedef struct QCryptoIVGen QCryptoIVGen ; -/* See also QCryptoIVGenAlgorithm enum in qapi/crypto.json */ +/* See also QCryptoIVGenAlgo enum in qapi/crypto.json */ /**
@@ -113,19 +113,19 @@ typedef struct QCryptoIVGen QCryptoIVGen;* are required or not depends on the choice of @alg * requested. * -* - QCRYPTO_IVGEN_ALG_PLAIN +* - QCRYPTO_IV_GEN_ALGO_PLAIN * * The IVs are generated by the 32-bit truncated sector * number. This should never be used for block devices * that are larger than 2^32 sectors in size. * All the other parameters are unused. * -* - QCRYPTO_IVGEN_ALG_PLAIN64 +* - QCRYPTO_IV_GEN_ALGO_PLAIN64 * * The IVs are generated by the 64-bit sector number. * All the other parameters are unused. * -* - QCRYPTO_IVGEN_ALG_ESSIV: +* - QCRYPTO_IV_GEN_ALGO_ESSIV: * * The IVs are generated by encrypting the 64-bit sector * number with a hash of an encryption key. The @cipheralg,
@@ -133,7 +133,7 @@ typedef struct QCryptoIVGen QCryptoIVGen;* * Returns: a new IV generator, or NULL on error */ -QCryptoIVGen *qcrypto_ivgen_new(QCryptoIVGenAlgorithm alg, +QCryptoIVGen *qcrypto_ivgen_new(QCryptoIVGenAlgo alg, QCryptoCipherAlgo cipheralg, QCryptoHashAlgo hash, const uint8_t *key, size_t nkey,
@@ -167,7 +167,7 @@ int qcrypto_ivgen_calculate(QCryptoIVGen *ivgen,* * Returns: the IV generator algorithm */ -QCryptoIVGenAlgorithm qcrypto_ivgen_get_algorithm (QCryptoIVGen *ivgen); +QCryptoIVGenAlgo qcrypto_ivgen_get_algorithm (QCryptoIVGen *ivgen);/**
crypto/block-luks.c +8 -8
@@ -129,7 +129,7 @@ struct QCryptoBlockLUKS {QCryptoCipherMode cipher_mode;/* Initialization vector generation algorithm */ -QCryptoIVGenAlgorithm ivgen_alg; +QCryptoIVGenAlgo ivgen_alg;/* Hash algorithm used for IV generation*/ QCryptoHashAlgo ivgen_hash_alg;
@@ -229,7 +229,7 @@ static int qcrypto_block_luks_name_lookup(const char *name,#define qcrypto_block_luks_ivgen_name_lookup (name, errp) \ qcrypto_block_luks_name_lookup(name, \ - &QCryptoIVGenAlgorithm_lookup, \ + &QCryptoIVGenAlgo_lookup, \ "IV generator", \ errp)
@@ -660,7 +660,7 @@ qcrypto_block_luks_parse_header(QCryptoBlockLUKS *luks, Error **errp)return -1 ; } -if (luks->ivgen_alg ==QCRYPTO_IVGEN_ALG_ESSIV ) { +if (luks->ivgen_alg ==QCRYPTO_IV_GEN_ALGO_ESSIV ) {if (!ivhash_name) {error_setg (errp,"Missing IV generator hash specification" );return -1 ;
@@ -1328,12 +1328,12 @@ qcrypto_block_luks_create(QCryptoBlock *block, luks_opts.cipher_mode =QCRYPTO_CIPHER_MODE_XTS ; }if (!luks_opts.has_ivgen_alg) { - luks_opts.ivgen_alg =QCRYPTO_IVGEN_ALG_PLAIN64 ; + luks_opts.ivgen_alg =QCRYPTO_IV_GEN_ALGO_PLAIN64 ; }if (!luks_opts.has_hash_alg) { luks_opts.hash_alg =QCRYPTO_HASH_ALGO_SHA256 ; } -if (luks_opts.ivgen_alg ==QCRYPTO_IVGEN_ALG_ESSIV ) { +if (luks_opts.ivgen_alg ==QCRYPTO_IV_GEN_ALGO_ESSIV ) {if (!luks_opts.has_ivgen_hash_alg) { luks_opts.ivgen_hash_alg =QCRYPTO_HASH_ALGO_SHA256 ; luks_opts.has_ivgen_hash_alg = true;
@@ -1384,7 +1384,7 @@ qcrypto_block_luks_create(QCryptoBlock *block, } cipher_mode =QCryptoCipherMode_str (luks_opts.cipher_mode); - ivgen_alg =QCryptoIVGenAlgorithm_str (luks_opts.ivgen_alg); + ivgen_alg =QCryptoIVGenAlgo_str (luks_opts.ivgen_alg);if (luks_opts.has_ivgen_hash_alg) { ivgen_hash_alg =QCryptoHashAlgo_str (luks_opts.ivgen_hash_alg); cipher_mode_spec = g_strdup_printf("%s-%s:%s", cipher_mode, ivgen_alg,
@@ -1411,7 +1411,7 @@ qcrypto_block_luks_create(QCryptoBlock *block, goto error; } -if (luks_opts.ivgen_alg ==QCRYPTO_IVGEN_ALG_ESSIV ) { +if (luks_opts.ivgen_alg ==QCRYPTO_IV_GEN_ALGO_ESSIV ) { luks->ivgen_cipher_alg = qcrypto_block_luks_essiv_cipher(luks_opts.cipher_alg, luks_opts.ivgen_hash_alg,
@@ -1886,7 +1886,7 @@ static int qcrypto_block_luks_get_info(QCryptoBlock *block, info->u.luks.cipher_alg = luks->cipher_alg; info->u.luks.cipher_mode = luks->cipher_mode; info->u.luks.ivgen_alg = luks->ivgen_alg; -if (info->u.luks.ivgen_alg ==QCRYPTO_IVGEN_ALG_ESSIV ) { +if (info->u.luks.ivgen_alg ==QCRYPTO_IV_GEN_ALGO_ESSIV ) { info->u.luks.has_ivgen_hash_alg = true; info->u.luks.ivgen_hash_alg = luks->ivgen_hash_alg; }
crypto/block-qcow.c +1 -1
@@ -64,7 +64,7 @@ qcrypto_block_qcow_init(QCryptoBlock *block, block->niv =qcrypto_cipher_get_iv_len (QCRYPTO_CIPHER_ALGO_AES_128 ,QCRYPTO_CIPHER_MODE_CBC ); - block->ivgen =qcrypto_ivgen_new (QCRYPTO_IVGEN_ALG_PLAIN64 , + block->ivgen =qcrypto_ivgen_new (QCRYPTO_IV_GEN_ALGO_PLAIN64 ,0 ,0 ,NULL ,0 , errp);if (!block->ivgen) { ret = -ENOTSUP ;
crypto/ivgen.c +5 -5
@@ -27,7 +27,7 @@#include "ivgen-essiv.h" -QCryptoIVGen *qcrypto_ivgen_new(QCryptoIVGenAlgorithm alg, +QCryptoIVGen *qcrypto_ivgen_new(QCryptoIVGenAlgo alg, QCryptoCipherAlgo cipheralg, QCryptoHashAlgo hash, const uint8_t *key, size_t nkey,
@@ -40,13 +40,13 @@ QCryptoIVGen *qcrypto_ivgen_new(QCryptoIVGenAlgorithm alg, ivgen->hash = hash;switch (alg) { -case QCRYPTO_IVGEN_ALG_PLAIN : +case QCRYPTO_IV_GEN_ALGO_PLAIN : ivgen->driver = &qcrypto_ivgen_plain;break ; -case QCRYPTO_IVGEN_ALG_PLAIN64 : +case QCRYPTO_IV_GEN_ALGO_PLAIN64 : ivgen->driver = &qcrypto_ivgen_plain64;break ; -case QCRYPTO_IVGEN_ALG_ESSIV : +case QCRYPTO_IV_GEN_ALGO_ESSIV : ivgen->driver = &qcrypto_ivgen_essiv;break ;default :
@@ -73,7 +73,7 @@ int qcrypto_ivgen_calculate(QCryptoIVGen *ivgen, } -QCryptoIVGenAlgorithm qcrypto_ivgen_get_algorithm (QCryptoIVGen *ivgen) +QCryptoIVGenAlgo qcrypto_ivgen_get_algorithm (QCryptoIVGen *ivgen) {return ivgen->algorithm; }
tests/unit/test-crypto-block.c +7 -7
@@ -81,7 +81,7 @@ static QCryptoBlockCreateOptions luks_create_opts_aes256_cbc_plain64 = { .has_cipher_mode = true, .cipher_mode = QCRYPTO_CIPHER_MODE_CBC, .has_ivgen_alg = true, - .ivgen_alg = QCRYPTO_IVGEN_ALG_PLAIN64, + .ivgen_alg = QCRYPTO_IV_GEN_ALGO_PLAIN64, }, };
@@ -95,7 +95,7 @@ static QCryptoBlockCreateOptions luks_create_opts_aes256_cbc_essiv = { .has_cipher_mode = true, .cipher_mode = QCRYPTO_CIPHER_MODE_CBC, .has_ivgen_alg = true, - .ivgen_alg = QCRYPTO_IVGEN_ALG_ESSIV, + .ivgen_alg = QCRYPTO_IV_GEN_ALGO_ESSIV, .has_ivgen_hash_alg = true, .ivgen_hash_alg = QCRYPTO_HASH_ALGO_SHA256, .has_hash_alg = true,
@@ -116,7 +116,7 @@ static struct QCryptoBlockTestData {QCryptoCipherMode cipher_mode;QCryptoHashAlgo hash_alg; -QCryptoIVGenAlgorithm ivgen_alg; +QCryptoIVGenAlgo ivgen_alg;QCryptoHashAlgo ivgen_hash;bool slow;
@@ -131,7 +131,7 @@ static struct QCryptoBlockTestData { .cipher_alg = QCRYPTO_CIPHER_ALGO_AES_128, .cipher_mode = QCRYPTO_CIPHER_MODE_CBC, - .ivgen_alg = QCRYPTO_IVGEN_ALG_PLAIN64, + .ivgen_alg = QCRYPTO_IV_GEN_ALGO_PLAIN64, },#ifdef TEST_LUKS {
@@ -145,7 +145,7 @@ static struct QCryptoBlockTestData { .cipher_mode = QCRYPTO_CIPHER_MODE_XTS, .hash_alg = QCRYPTO_HASH_ALGO_SHA256, - .ivgen_alg = QCRYPTO_IVGEN_ALG_PLAIN64, + .ivgen_alg = QCRYPTO_IV_GEN_ALGO_PLAIN64, .slow = true, },
@@ -160,7 +160,7 @@ static struct QCryptoBlockTestData { .cipher_mode = QCRYPTO_CIPHER_MODE_CBC, .hash_alg = QCRYPTO_HASH_ALGO_SHA256, - .ivgen_alg = QCRYPTO_IVGEN_ALG_PLAIN64, + .ivgen_alg = QCRYPTO_IV_GEN_ALGO_PLAIN64, .slow = true, },
@@ -175,7 +175,7 @@ static struct QCryptoBlockTestData { .cipher_mode = QCRYPTO_CIPHER_MODE_CBC, .hash_alg = QCRYPTO_HASH_ALGO_SHA1, - .ivgen_alg = QCRYPTO_IVGEN_ALG_ESSIV, + .ivgen_alg = QCRYPTO_IV_GEN_ALGO_ESSIV, .ivgen_hash = QCRYPTO_HASH_ALGO_SHA256, .slow = true,
tests/unit/test-crypto-ivgen.c +11 -11
@@ -26,7 +26,7 @@struct QCryptoIVGenTestData {const char *path;uint64_t sector; -QCryptoIVGenAlgorithm ivalg; +QCryptoIVGenAlgo ivalg;QCryptoHashAlgo hashalg;QCryptoCipherAlgo cipheralg;const uint8_t *key;
@@ -38,7 +38,7 @@ struct QCryptoIVGenTestData { { "/crypto/ivgen/plain/1", .sector = 0x1, - .ivalg = QCRYPTO_IVGEN_ALG_PLAIN, + .ivalg = QCRYPTO_IV_GEN_ALGO_PLAIN, .iv = (const uint8_t *)"\x01\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00", .niv = 16,
@@ -47,7 +47,7 @@ struct QCryptoIVGenTestData { { "/crypto/ivgen/plain/1f2e3d4c", .sector = 0x1f2e3d4cULL, - .ivalg = QCRYPTO_IVGEN_ALG_PLAIN, + .ivalg = QCRYPTO_IV_GEN_ALGO_PLAIN, .iv = (const uint8_t *)"\x4c\x3d\x2e\x1f\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00", .niv = 16,
@@ -56,7 +56,7 @@ struct QCryptoIVGenTestData { { "/crypto/ivgen/plain/1f2e3d4c5b6a7988", .sector = 0x1f2e3d4c5b6a7988ULL, - .ivalg = QCRYPTO_IVGEN_ALG_PLAIN, + .ivalg = QCRYPTO_IV_GEN_ALGO_PLAIN, .iv = (const uint8_t *)"\x88\x79\x6a\x5b\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00", .niv = 16,
@@ -65,7 +65,7 @@ struct QCryptoIVGenTestData { { "/crypto/ivgen/plain64/1", .sector = 0x1, - .ivalg = QCRYPTO_IVGEN_ALG_PLAIN64, + .ivalg = QCRYPTO_IV_GEN_ALGO_PLAIN64, .iv = (const uint8_t *)"\x01\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00", .niv = 16,
@@ -74,7 +74,7 @@ struct QCryptoIVGenTestData { { "/crypto/ivgen/plain64/1f2e3d4c", .sector = 0x1f2e3d4cULL, - .ivalg = QCRYPTO_IVGEN_ALG_PLAIN64, + .ivalg = QCRYPTO_IV_GEN_ALGO_PLAIN64, .iv = (const uint8_t *)"\x4c\x3d\x2e\x1f\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00", .niv = 16,
@@ -83,7 +83,7 @@ struct QCryptoIVGenTestData { { "/crypto/ivgen/plain64/1f2e3d4c5b6a7988", .sector = 0x1f2e3d4c5b6a7988ULL, - .ivalg = QCRYPTO_IVGEN_ALG_PLAIN64, + .ivalg = QCRYPTO_IV_GEN_ALGO_PLAIN64, .iv = (const uint8_t *)"\x88\x79\x6a\x5b\x4c\x3d\x2e\x1f" "\x00\x00\x00\x00\x00\x00\x00\x00", .niv = 16,
@@ -92,7 +92,7 @@ struct QCryptoIVGenTestData { { "/crypto/ivgen/essiv/1", .sector = 0x1, - .ivalg = QCRYPTO_IVGEN_ALG_ESSIV, + .ivalg = QCRYPTO_IV_GEN_ALGO_ESSIV, .cipheralg = QCRYPTO_CIPHER_ALGO_AES_128, .hashalg =QCRYPTO_HASH_ALGO_SHA256 , .key = (const uint8_t *)"\x00\x01\x02\x03\x04\x05\x06\x07"
@@ -106,7 +106,7 @@ struct QCryptoIVGenTestData { { "/crypto/ivgen/essiv/1f2e3d4c", .sector = 0x1f2e3d4cULL, - .ivalg = QCRYPTO_IVGEN_ALG_ESSIV, + .ivalg = QCRYPTO_IV_GEN_ALGO_ESSIV, .cipheralg = QCRYPTO_CIPHER_ALGO_AES_128, .hashalg =QCRYPTO_HASH_ALGO_SHA256 , .key = (const uint8_t *)"\x00\x01\x02\x03\x04\x05\x06\x07"
@@ -120,7 +120,7 @@ struct QCryptoIVGenTestData { { "/crypto/ivgen/essiv/1f2e3d4c5b6a7988", .sector = 0x1f2e3d4c5b6a7988ULL, - .ivalg = QCRYPTO_IVGEN_ALG_ESSIV, + .ivalg = QCRYPTO_IV_GEN_ALGO_ESSIV, .cipheralg = QCRYPTO_CIPHER_ALGO_AES_128, .hashalg =QCRYPTO_HASH_ALGO_SHA256 , .key = (const uint8_t *)"\x00\x01\x02\x03\x04\x05\x06\x07"
@@ -166,7 +166,7 @@ int main(int argc, char **argv)size_t i;g_test_init (&argc, &argv,NULL );for (i =0 ; i <G_N_ELEMENTS (test_data); i++) { -if (test_data[i].ivalg ==QCRYPTO_IVGEN_ALG_ESSIV && +if (test_data[i].ivalg ==QCRYPTO_IV_GEN_ALGO_ESSIV && !qcrypto_hash_supports (test_data[i].hashalg)) {continue ; }
Signature · 1 line
2.46.0
PATCH v2 14/19 qapi/crypto: Rename QCryptoAkCipherAlgorithm to *Algo, and drop prefix
In reply to Markus ArmbrusterQAPI'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.
--- 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(-)
qapi/crypto.json +3 -4
@@ -586,7 +586,7 @@ '*sanity-check': 'bool', '*passwordid': 'str' } } ## -# @QCryptoAkCipherAlgorithm: +# @QCryptoAkCipherAlgo: # # The supported algorithms for asymmetric encryption ciphers #
@@ -594,8 +594,7 @@ # # Since: 7.1 ## -{ 'enum': 'QCryptoAkCipherAlgorithm', - 'prefix': 'QCRYPTO_AKCIPHER_ALG', +{ 'enum': 'QCryptoAkCipherAlgo', 'data': ['rsa']} ##
@@ -649,6 +648,6 @@ # Since: 7.1 ## { 'union': 'QCryptoAkCipherOptions', - 'base': { 'alg': 'QCryptoAkCipherAlgorithm' }, + 'base': { 'alg': 'QCryptoAkCipherAlgo' }, 'discriminator': 'alg', 'data': { 'rsa': 'QCryptoAkCipherOptionsRSA' }}
crypto/akcipherpriv.h +1 -1
@@ -27,7 +27,7 @@typedef struct QCryptoAkCipherDriver QCryptoAkCipherDriver ;struct QCryptoAkCipher { -QCryptoAkCipherAlgorithm alg; +QCryptoAkCipherAlgo alg;QCryptoAkCipherKeyType type;int max_plaintext_len;int max_ciphertext_len;
backends/cryptodev-builtin.c +2 -2
@@ -64,7 +64,7 @@ static void cryptodev_builtin_init_akcipher(CryptoDevBackend *backend) {QCryptoAkCipherOptions opts; - opts.alg =QCRYPTO_AKCIPHER_ALG_RSA ; + opts.alg =QCRYPTO_AK_CIPHER_ALGO_RSA ; opts.u.rsa.padding_alg =QCRYPTO_RSA_PADDING_ALG_RAW ;if (qcrypto_akcipher_supports (&opts)) { backend->conf.crypto_services |=
@@ -318,7 +318,7 @@ static int cryptodev_builtin_create_akcipher_session(switch (sess_info->algo) {case VIRTIO_CRYPTO_AKCIPHER_RSA : - opts.alg =QCRYPTO_AKCIPHER_ALG_RSA ; + opts.alg =QCRYPTO_AK_CIPHER_ALGO_RSA ;if (cryptodev_builtin_set_rsa_options (sess_info->u.rsa.padding_algo, sess_info->u.rsa.hash_algo, &opts.u.rsa, errp) !=0 ) {return -1 ;
backends/cryptodev-lkcf.c +2 -2
@@ -133,7 +133,7 @@ static int cryptodev_lkcf_set_op_desc(QCryptoAkCipherOptions *opts, Error **errp) {QCryptoAkCipherOptionsRSA *rsa_opt; -if (opts->alg !=QCRYPTO_AKCIPHER_ALG_RSA ) { +if (opts->alg !=QCRYPTO_AK_CIPHER_ALGO_RSA ) {error_setg (errp,"Unsupported alg: %u" , opts->alg);return -1 ; }
@@ -518,7 +518,7 @@ static int cryptodev_lkcf_create_asym_session(switch (sess_info->algo) {case VIRTIO_CRYPTO_AKCIPHER_RSA : - sess->akcipher_opts.alg =QCRYPTO_AKCIPHER_ALG_RSA ; + sess->akcipher_opts.alg =QCRYPTO_AK_CIPHER_ALGO_RSA ;if (cryptodev_lkcf_set_rsa_opt ( sess_info->u.rsa.padding_algo, sess_info->u.rsa.hash_algo, &sess->akcipher_opts.u.rsa, &local_error) !=0 ) {
crypto/akcipher.c +1 -1
@@ -115,7 +115,7 @@ int qcrypto_akcipher_export_p8info(const QCryptoAkCipherOptions *opts, Error **errp) {switch (opts->alg) { -case QCRYPTO_AKCIPHER_ALG_RSA : +case QCRYPTO_AK_CIPHER_ALGO_RSA :qcrypto_akcipher_rsakey_export_p8info (key, keylen, dst, dst_len);return 0 ;
tests/bench/benchmark-crypto-akcipher.c +1 -1
@@ -25,7 +25,7 @@ static QCryptoAkCipher *create_rsa_akcipher(const uint8_t *priv_key, {QCryptoAkCipherOptions opt; - opt.alg =QCRYPTO_AKCIPHER_ALG_RSA ; + opt.alg =QCRYPTO_AK_CIPHER_ALGO_RSA ; opt.u.rsa.padding_alg = padding; opt.u.rsa.hash_alg = hash; return qcrypto_akcipher_new(&opt, QCRYPTO_AK_CIPHER_KEY_TYPE_PRIVATE,
tests/unit/test-crypto-akcipher.c +5 -5
@@ -785,7 +785,7 @@ static QCryptoAkCipherTestData akcipher_test_data[] = { { .path = "/crypto/akcipher/rsa1024-raw", .opt = { - .alg = QCRYPTO_AKCIPHER_ALG_RSA, + .alg = QCRYPTO_AK_CIPHER_ALGO_RSA, .u.rsa = { .padding_alg = QCRYPTO_RSA_PADDING_ALG_RAW, },
@@ -805,7 +805,7 @@ static QCryptoAkCipherTestData akcipher_test_data[] = { { .path = "/crypto/akcipher/rsa1024-pkcs1", .opt = { - .alg = QCRYPTO_AKCIPHER_ALG_RSA, + .alg = QCRYPTO_AK_CIPHER_ALGO_RSA, .u.rsa = { .padding_alg = QCRYPTO_RSA_PADDING_ALG_PKCS1, .hash_alg = QCRYPTO_HASH_ALGO_SHA1,
@@ -830,7 +830,7 @@ static QCryptoAkCipherTestData akcipher_test_data[] = { { .path = "/crypto/akcipher/rsa2048-raw", .opt = { - .alg = QCRYPTO_AKCIPHER_ALG_RSA, + .alg = QCRYPTO_AK_CIPHER_ALGO_RSA, .u.rsa = { .padding_alg = QCRYPTO_RSA_PADDING_ALG_RAW, },
@@ -850,7 +850,7 @@ static QCryptoAkCipherTestData akcipher_test_data[] = { { .path = "/crypto/akcipher/rsa2048-pkcs1", .opt = { - .alg = QCRYPTO_AKCIPHER_ALG_RSA, + .alg = QCRYPTO_AK_CIPHER_ALGO_RSA, .u.rsa = { .padding_alg = QCRYPTO_RSA_PADDING_ALG_PKCS1, .hash_alg = QCRYPTO_HASH_ALGO_SHA1,
@@ -944,7 +944,7 @@ static void test_rsakey(const void *opaque) {const QCryptoRSAKeyTestData *data = (const QCryptoRSAKeyTestData *)opaque;QCryptoAkCipherOptions opt = { - .alg =QCRYPTO_AKCIPHER_ALG_RSA , + .alg =QCRYPTO_AK_CIPHER_ALGO_RSA , .u.rsa = { .padding_alg =QCRYPTO_RSA_PADDING_ALG_PKCS1 , .hash_alg =QCRYPTO_HASH_ALGO_SHA1 ,
crypto/akcipher-gcrypt.c.inc +2 -2
@@ -59,7 +59,7 @@ QCryptoAkCipher *qcrypto_akcipher_new(const QCryptoAkCipherOptions *opts, Error **errp) { switch (opts->alg) { - case QCRYPTO_AKCIPHER_ALG_RSA: + case QCRYPTO_AK_CIPHER_ALGO_RSA: return (QCryptoAkCipher *)qcrypto_gcrypt_rsa_new( &opts->u.rsa, type, key, keylen, errp);
@@ -568,7 +568,7 @@ error: bool qcrypto_akcipher_supports(QCryptoAkCipherOptions *opts) { switch (opts->alg) { - case QCRYPTO_AKCIPHER_ALG_RSA: + case QCRYPTO_AK_CIPHER_ALGO_RSA: switch (opts->u.rsa.padding_alg) { case QCRYPTO_RSA_PADDING_ALG_RAW: return true;
crypto/akcipher-nettle.c.inc +2 -2
@@ -61,7 +61,7 @@ QCryptoAkCipher *qcrypto_akcipher_new(const QCryptoAkCipherOptions *opts, Error **errp) { switch (opts->alg) { - case QCRYPTO_AKCIPHER_ALG_RSA: + case QCRYPTO_AK_CIPHER_ALGO_RSA: return qcrypto_nettle_rsa_new(&opts->u.rsa, type, key, keylen, errp); default:
@@ -425,7 +425,7 @@ error: bool qcrypto_akcipher_supports(QCryptoAkCipherOptions *opts) { switch (opts->alg) { - case QCRYPTO_AKCIPHER_ALG_RSA: + case QCRYPTO_AK_CIPHER_ALGO_RSA: switch (opts->u.rsa.padding_alg) { case QCRYPTO_RSA_PADDING_ALG_PKCS1: switch (opts->u.rsa.hash_alg) {
Signature · 1 line
2.46.0
PATCH v2 15/19 qapi/crypto: Rename QCryptoRSAPaddingAlgorithm to *Algo, and drop prefix
In reply to Markus ArmbrusterQAPI'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.
--- 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(-)
qapi/crypto.json +4 -5
@@ -608,7 +608,7 @@ 'data': ['public', 'private']} ## -# @QCryptoRSAPaddingAlgorithm: +# @QCryptoRSAPaddingAlgo: # # The padding algorithm for RSA. #
@@ -618,8 +618,7 @@ # # Since: 7.1 ## -{ 'enum': 'QCryptoRSAPaddingAlgorithm', - 'prefix': 'QCRYPTO_RSA_PADDING_ALG', +{ 'enum': 'QCryptoRSAPaddingAlgo', 'data': ['raw', 'pkcs1']} ##
@@ -629,13 +628,13 @@ # # @hash-alg: QCryptoHashAlgo # -# @padding-alg: QCryptoRSAPaddingAlgorithm +# @padding-alg: QCryptoRSAPaddingAlgo # # Since: 7.1 ## { 'struct': 'QCryptoAkCipherOptionsRSA', 'data': { 'hash-alg':'QCryptoHashAlgo', - 'padding-alg': 'QCryptoRSAPaddingAlgorithm'}} + 'padding-alg': 'QCryptoRSAPaddingAlgo'}} ## # @QCryptoAkCipherOptions:
backends/cryptodev-builtin.c +3 -3
@@ -65,7 +65,7 @@ static void cryptodev_builtin_init_akcipher(CryptoDevBackend *backend)QCryptoAkCipherOptions opts; opts.alg =QCRYPTO_AK_CIPHER_ALGO_RSA ; - opts.u.rsa.padding_alg =QCRYPTO_RSA_PADDING_ALG_RAW ; + opts.u.rsa.padding_alg =QCRYPTO_RSA_PADDING_ALGO_RAW ;if (qcrypto_akcipher_supports (&opts)) { backend->conf.crypto_services |= (1u <<QCRYPTODEV_BACKEND_SERVICE_AKCIPHER );
@@ -200,12 +200,12 @@ static int cryptodev_builtin_set_rsa_options(return -1 ; } opt->hash_alg = hash_alg; - opt->padding_alg =QCRYPTO_RSA_PADDING_ALG_PKCS1 ; + opt->padding_alg =QCRYPTO_RSA_PADDING_ALGO_PKCS1 ;return 0 ; }if (virtio_padding_algo ==VIRTIO_CRYPTO_RSA_RAW_PADDING ) { - opt->padding_alg =QCRYPTO_RSA_PADDING_ALG_RAW ; + opt->padding_alg =QCRYPTO_RSA_PADDING_ALGO_RAW ;return 0 ; }
backends/cryptodev-lkcf.c +5 -5
@@ -139,14 +139,14 @@ static int cryptodev_lkcf_set_op_desc(QCryptoAkCipherOptions *opts, } rsa_opt = &opts->u.rsa; -if (rsa_opt->padding_alg ==QCRYPTO_RSA_PADDING_ALG_PKCS1 ) { +if (rsa_opt->padding_alg ==QCRYPTO_RSA_PADDING_ALGO_PKCS1 ) {snprintf (key_desc, desc_len,"enc=%s hash=%s" , -QCryptoRSAPaddingAlgorithm_str (rsa_opt->padding_alg), +QCryptoRSAPaddingAlgo_str (rsa_opt->padding_alg),QCryptoHashAlgo_str (rsa_opt->hash_alg)); }else {snprintf (key_desc, desc_len,"enc=%s" , -QCryptoRSAPaddingAlgorithm_str (rsa_opt->padding_alg)); +QCryptoRSAPaddingAlgo_str (rsa_opt->padding_alg)); }return 0 ; }
@@ -157,7 +157,7 @@ static int cryptodev_lkcf_set_rsa_opt(int virtio_padding_alg, Error **errp) {if (virtio_padding_alg ==VIRTIO_CRYPTO_RSA_PKCS1_PADDING ) { - opt->padding_alg =QCRYPTO_RSA_PADDING_ALG_PKCS1 ; + opt->padding_alg =QCRYPTO_RSA_PADDING_ALGO_PKCS1 ;switch (virtio_hash_alg) {case VIRTIO_CRYPTO_RSA_MD5 :
@@ -184,7 +184,7 @@ static int cryptodev_lkcf_set_rsa_opt(int virtio_padding_alg, }if (virtio_padding_alg ==VIRTIO_CRYPTO_RSA_RAW_PADDING ) { - opt->padding_alg =QCRYPTO_RSA_PADDING_ALG_RAW ; + opt->padding_alg =QCRYPTO_RSA_PADDING_ALGO_RAW ;return 0 ; }
tests/bench/benchmark-crypto-akcipher.c +6 -6
@@ -20,7 +20,7 @@static QCryptoAkCipher *create_rsa_akcipher (const uint8_t *priv_key,size_t keylen, -QCryptoRSAPaddingAlgorithm padding, +QCryptoRSAPaddingAlgo padding,QCryptoHashAlgo hash) {QCryptoAkCipherOptions opt;
@@ -39,7 +39,7 @@ static void test_rsa_speed(const uint8_t *priv_key, size_t keylen,#define SHA1_DGST_LEN 20#define SIGN_TIMES 10000#define VERIFY_TIMES 100000 -#define PADDING QCRYPTO_RSA_PADDING_ALG_PKCS1 +#define PADDING QCRYPTO_RSA_PADDING_ALGO_PKCS1#define HASH QCRYPTO_HASH_ALGO_SHA1 g_autoptr(QCryptoAkCipher) rsa =
@@ -53,7 +53,7 @@ static void test_rsa_speed(const uint8_t *priv_key, size_t keylen, signature =g_new0 (uint8_t, key_size /BYTE );g_test_message ("benchmark rsa%zu (%s-%s) sign..." , key_size, -QCryptoRSAPaddingAlgorithm_str (PADDING ), +QCryptoRSAPaddingAlgo_str (PADDING ),QCryptoHashAlgo_str (HASH ));g_test_timer_start ();for (count =0 ; count <SIGN_TIMES ; ++count) {
@@ -64,13 +64,13 @@ static void test_rsa_speed(const uint8_t *priv_key, size_t keylen,g_test_timer_elapsed ();g_test_message ("rsa%zu (%s-%s) sign %zu times in %.2f seconds," " %.2f times/sec " , - key_size,QCryptoRSAPaddingAlgorithm_str (PADDING ), + key_size,QCryptoRSAPaddingAlgo_str (PADDING ),QCryptoHashAlgo_str (HASH ), count,g_test_timer_last (), (double )count /g_test_timer_last ());g_test_message ("benchmark rsa%zu (%s-%s) verification..." , key_size, -QCryptoRSAPaddingAlgorithm_str (PADDING ), +QCryptoRSAPaddingAlgo_str (PADDING ),QCryptoHashAlgo_str (HASH ));g_test_timer_start ();for (count =0 ; count <VERIFY_TIMES ; ++count) {
@@ -81,7 +81,7 @@ static void test_rsa_speed(const uint8_t *priv_key, size_t keylen,g_test_timer_elapsed ();g_test_message ("rsa%zu (%s-%s) verify %zu times in %.2f seconds," " %.2f times/sec " , - key_size,QCryptoRSAPaddingAlgorithm_str (PADDING ), + key_size,QCryptoRSAPaddingAlgo_str (PADDING ),QCryptoHashAlgo_str (HASH ), count,g_test_timer_last (), (double )count /g_test_timer_last ());
tests/unit/test-crypto-akcipher.c +5 -5
@@ -787,7 +787,7 @@ static QCryptoAkCipherTestData akcipher_test_data[] = { .opt = { .alg = QCRYPTO_AK_CIPHER_ALGO_RSA, .u.rsa = { - .padding_alg = QCRYPTO_RSA_PADDING_ALG_RAW, + .padding_alg = QCRYPTO_RSA_PADDING_ALGO_RAW, }, }, .pub_key = rsa1024_public_key,
@@ -807,7 +807,7 @@ static QCryptoAkCipherTestData akcipher_test_data[] = { .opt = { .alg = QCRYPTO_AK_CIPHER_ALGO_RSA, .u.rsa = { - .padding_alg = QCRYPTO_RSA_PADDING_ALG_PKCS1, + .padding_alg = QCRYPTO_RSA_PADDING_ALGO_PKCS1, .hash_alg = QCRYPTO_HASH_ALGO_SHA1, }, },
@@ -832,7 +832,7 @@ static QCryptoAkCipherTestData akcipher_test_data[] = { .opt = { .alg = QCRYPTO_AK_CIPHER_ALGO_RSA, .u.rsa = { - .padding_alg = QCRYPTO_RSA_PADDING_ALG_RAW, + .padding_alg = QCRYPTO_RSA_PADDING_ALGO_RAW, }, }, .pub_key = rsa2048_public_key,
@@ -852,7 +852,7 @@ static QCryptoAkCipherTestData akcipher_test_data[] = { .opt = { .alg = QCRYPTO_AK_CIPHER_ALGO_RSA, .u.rsa = { - .padding_alg = QCRYPTO_RSA_PADDING_ALG_PKCS1, + .padding_alg = QCRYPTO_RSA_PADDING_ALGO_PKCS1, .hash_alg = QCRYPTO_HASH_ALGO_SHA1, }, },
@@ -946,7 +946,7 @@ static void test_rsakey(const void *opaque)QCryptoAkCipherOptions opt = { .alg =QCRYPTO_AK_CIPHER_ALGO_RSA , .u.rsa = { - .padding_alg =QCRYPTO_RSA_PADDING_ALG_PKCS1 , + .padding_alg =QCRYPTO_RSA_PADDING_ALGO_PKCS1 , .hash_alg =QCRYPTO_HASH_ALGO_SHA1 , } };
crypto/akcipher-gcrypt.c.inc +9 -9
@@ -32,7 +32,7 @@ typedef struct QCryptoGcryptRSA { QCryptoAkCipher akcipher; gcry_sexp_t key; - QCryptoRSAPaddingAlgorithm padding_alg; + QCryptoRSAPaddingAlgo padding_alg; QCryptoHashAlgo hash_alg; } QCryptoGcryptRSA;
@@ -241,7 +241,7 @@ static int qcrypto_gcrypt_rsa_encrypt(QCryptoAkCipher *akcipher, err = gcry_sexp_build(&data_sexp, NULL, "(data (flags %s) (value %b))", - QCryptoRSAPaddingAlgorithm_str(rsa->padding_alg), + QCryptoRSAPaddingAlgo_str(rsa->padding_alg), in_len, in); if (gcry_err_code(err) != 0) { error_setg(errp, "Failed to build plaintext: %s/%s",
@@ -263,7 +263,7 @@ static int qcrypto_gcrypt_rsa_encrypt(QCryptoAkCipher *akcipher, goto cleanup; } - if (rsa->padding_alg == QCRYPTO_RSA_PADDING_ALG_RAW) { + if (rsa->padding_alg == QCRYPTO_RSA_PADDING_ALGO_RAW) { cipher_mpi = gcry_sexp_nth_mpi(cipher_sexp_item, 1, GCRYMPI_FMT_USG); if (!cipher_mpi) { error_setg(errp, "Invalid ciphertext result");
@@ -332,7 +332,7 @@ static int qcrypto_gcrypt_rsa_decrypt(QCryptoAkCipher *akcipher, err = gcry_sexp_build(&cipher_sexp, NULL, "(enc-val (flags %s) (rsa (a %b) ))", - QCryptoRSAPaddingAlgorithm_str(rsa->padding_alg), + QCryptoRSAPaddingAlgo_str(rsa->padding_alg), in_len, in); if (gcry_err_code(err) != 0) { error_setg(errp, "Failed to build ciphertext: %s/%s",
@@ -348,7 +348,7 @@ static int qcrypto_gcrypt_rsa_decrypt(QCryptoAkCipher *akcipher, } /* S-expression of plaintext: (value plaintext) */ - if (rsa->padding_alg == QCRYPTO_RSA_PADDING_ALG_RAW) { + if (rsa->padding_alg == QCRYPTO_RSA_PADDING_ALGO_RAW) { data_mpi = gcry_sexp_nth_mpi(data_sexp, 1, GCRYMPI_FMT_USG); if (!data_mpi) { error_setg(errp, "Invalid plaintext result");
@@ -410,7 +410,7 @@ static int qcrypto_gcrypt_rsa_sign(QCryptoAkCipher *akcipher, return ret; } - if (rsa->padding_alg != QCRYPTO_RSA_PADDING_ALG_PKCS1) { + if (rsa->padding_alg != QCRYPTO_RSA_PADDING_ALGO_PKCS1) { error_setg(errp, "Invalid padding %u", rsa->padding_alg); return ret; }
@@ -482,7 +482,7 @@ static int qcrypto_gcrypt_rsa_verify(QCryptoAkCipher *akcipher, return ret; } - if (rsa->padding_alg != QCRYPTO_RSA_PADDING_ALG_PKCS1) { + if (rsa->padding_alg != QCRYPTO_RSA_PADDING_ALGO_PKCS1) { error_setg(errp, "Invalid padding %u", rsa->padding_alg); return ret; }
@@ -570,10 +570,10 @@ bool qcrypto_akcipher_supports(QCryptoAkCipherOptions *opts) switch (opts->alg) { case QCRYPTO_AK_CIPHER_ALGO_RSA: switch (opts->u.rsa.padding_alg) { - case QCRYPTO_RSA_PADDING_ALG_RAW: + case QCRYPTO_RSA_PADDING_ALGO_RAW: return true; - case QCRYPTO_RSA_PADDING_ALG_PKCS1: + case QCRYPTO_RSA_PADDING_ALGO_PKCS1: switch (opts->u.rsa.hash_alg) { case QCRYPTO_HASH_ALGO_MD5: case QCRYPTO_HASH_ALGO_SHA1:
crypto/akcipher-nettle.c.inc +9 -9
@@ -33,7 +33,7 @@ typedef struct QCryptoNettleRSA { QCryptoAkCipher akcipher; struct rsa_public_key pub; struct rsa_private_key priv; - QCryptoRSAPaddingAlgorithm padding_alg; + QCryptoRSAPaddingAlgo padding_alg; QCryptoHashAlgo hash_alg; } QCryptoNettleRSA;
@@ -184,11 +184,11 @@ static int qcrypto_nettle_rsa_encrypt(QCryptoAkCipher *akcipher, /* Nettle do not support RSA encryption without any padding */ switch (rsa->padding_alg) { - case QCRYPTO_RSA_PADDING_ALG_RAW: + case QCRYPTO_RSA_PADDING_ALGO_RAW: error_setg(errp, "RSA with raw padding is not supported"); break; - case QCRYPTO_RSA_PADDING_ALG_PKCS1: + case QCRYPTO_RSA_PADDING_ALGO_PKCS1: mpz_init(c); if (rsa_encrypt(&rsa->pub, NULL, wrap_nettle_random_func, data_len, (uint8_t *)data, c) != 1) {
@@ -223,11 +223,11 @@ static int qcrypto_nettle_rsa_decrypt(QCryptoAkCipher *akcipher, } switch (rsa->padding_alg) { - case QCRYPTO_RSA_PADDING_ALG_RAW: + case QCRYPTO_RSA_PADDING_ALGO_RAW: error_setg(errp, "RSA with raw padding is not supported"); break; - case QCRYPTO_RSA_PADDING_ALG_PKCS1: + case QCRYPTO_RSA_PADDING_ALGO_PKCS1: nettle_mpz_init_set_str_256_u(c, enc_len, enc); if (!rsa_decrypt(&rsa->priv, &data_len, (uint8_t *)data, c)) { error_setg(errp, "Failed to decrypt");
@@ -257,7 +257,7 @@ static int qcrypto_nettle_rsa_sign(QCryptoAkCipher *akcipher, * The RSA algorithm cannot be used for signature/verification * without padding. */ - if (rsa->padding_alg == QCRYPTO_RSA_PADDING_ALG_RAW) { + if (rsa->padding_alg == QCRYPTO_RSA_PADDING_ALGO_RAW) { error_setg(errp, "Try to make signature without padding"); return ret; }
@@ -324,7 +324,7 @@ static int qcrypto_nettle_rsa_verify(QCryptoAkCipher *akcipher, * The RSA algorithm cannot be used for signature/verification * without padding. */ - if (rsa->padding_alg == QCRYPTO_RSA_PADDING_ALG_RAW) { + if (rsa->padding_alg == QCRYPTO_RSA_PADDING_ALGO_RAW) { error_setg(errp, "Try to verify signature without padding"); return ret; }
@@ -427,7 +427,7 @@ bool qcrypto_akcipher_supports(QCryptoAkCipherOptions *opts) switch (opts->alg) { case QCRYPTO_AK_CIPHER_ALGO_RSA: switch (opts->u.rsa.padding_alg) { - case QCRYPTO_RSA_PADDING_ALG_PKCS1: + case QCRYPTO_RSA_PADDING_ALGO_PKCS1: switch (opts->u.rsa.hash_alg) { case QCRYPTO_HASH_ALGO_MD5: case QCRYPTO_HASH_ALGO_SHA1:
@@ -439,7 +439,7 @@ bool qcrypto_akcipher_supports(QCryptoAkCipherOptions *opts) return false; } - case QCRYPTO_RSA_PADDING_ALG_RAW: + case QCRYPTO_RSA_PADDING_ALGO_RAW: default: return false; }
Signature · 1 line
2.46.0
PATCH v2 16/19 qapi/crypto: Rename QCryptoAFAlg to QCryptoAFAlgo
In reply to Markus ArmbrusterFor consistency with other types names *Algo.
--- 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(-)
crypto/afalgpriv.h +7 -7
@@ -30,9 +30,9 @@#define ALG_OPTYPE_LEN 4#define ALG_MSGIV_LEN (len) (sizeof(struct af_alg_iv) + (len)) -typedef struct QCryptoAFAlg QCryptoAFAlg ; +typedef struct QCryptoAFAlgo QCryptoAFAlgo ; -struct QCryptoAFAlg { +struct QCryptoAFAlgo {QCryptoCipher base;int tfmfd;
@@ -46,22 +46,22 @@ struct QCryptoAFAlg {* @type: the type of crypto operation * @name: the name of crypto operation * -* Allocate a QCryptoAFAlg object and bind itself to +* Allocate a QCryptoAFAlgo object and bind itself to * a AF_ALG socket. * * Returns: -* a new QCryptoAFAlg object, or NULL in error. +* a new QCryptoAFAlgo object, or NULL in error. */ -QCryptoAFAlg * +QCryptoAFAlgo *qcrypto_afalg_comm_alloc (const char *type,const char *name,Error **errp);/** * afalg_comm_free: -* @afalg: the QCryptoAFAlg object +* @afalg: the QCryptoAFAlgo object * * Free the @afalg. */ -void qcrypto_afalg_comm_free (QCryptoAFAlg *afalg); +void qcrypto_afalg_comm_free (QCryptoAFAlgo *afalg);#endif
crypto/hmacpriv.h +1 -1
@@ -37,7 +37,7 @@ extern QCryptoHmacDriver qcrypto_hmac_lib_driver;#include "afalgpriv.h" -QCryptoAFAlg *qcrypto_afalg_hmac_ctx_new (QCryptoHashAlgo alg, +QCryptoAFAlgo *qcrypto_afalg_hmac_ctx_new (QCryptoHashAlgo alg,const uint8_t *key,size_t nkey,Error **errp);extern QCryptoHmacDriver qcrypto_hmac_afalg_driver;
crypto/afalg.c +4 -4
@@ -66,13 +66,13 @@ qcrypto_afalg_socket_bind(const char *type, const char *name,return sbind; } -QCryptoAFAlg * +QCryptoAFAlgo *qcrypto_afalg_comm_alloc (const char *type,const char *name,Error **errp) { -QCryptoAFAlg *afalg; +QCryptoAFAlgo *afalg; - afalg =g_new0 (QCryptoAFAlg,1 ); + afalg =g_new0 (QCryptoAFAlgo,1 );/* initialize crypto API socket */ afalg->opfd =-1 ; afalg->tfmfd =qcrypto_afalg_socket_bind (type, name, errp);
@@ -93,7 +93,7 @@ error:return NULL ; } -void qcrypto_afalg_comm_free (QCryptoAFAlg *afalg) +void qcrypto_afalg_comm_free (QCryptoAFAlgo *afalg) {if (!afalg) {return ;
crypto/cipher-afalg.c +6 -6
@@ -65,7 +65,7 @@ qcrypto_afalg_cipher_ctx_new(QCryptoCipherAlgo alg,const uint8_t *key, size_t nkey, Error **errp) { - QCryptoAFAlg *afalg; + QCryptoAFAlgo *afalg;size_t expect_niv;char *name;
@@ -119,7 +119,7 @@ qcrypto_afalg_cipher_setiv(QCryptoCipher *cipher,const uint8_t *iv, size_t niv, Error **errp) { - QCryptoAFAlg *afalg = container_of(cipher, QCryptoAFAlg, base); + QCryptoAFAlgo *afalg = container_of(cipher, QCryptoAFAlgo, base);struct af_alg_iv *alg_iv;size_t expect_niv;
@@ -143,7 +143,7 @@ qcrypto_afalg_cipher_setiv(QCryptoCipher *cipher, }static int -qcrypto_afalg_cipher_op (QCryptoAFAlg *afalg, +qcrypto_afalg_cipher_op (QCryptoAFAlgo *afalg,const void *in,void *out,size_t len,bool do_encrypt,Error **errp)
@@ -202,7 +202,7 @@ qcrypto_afalg_cipher_encrypt(QCryptoCipher *cipher, const void *in, void *out, size_t len, Error **errp) { - QCryptoAFAlg *afalg = container_of(cipher, QCryptoAFAlg, base); + QCryptoAFAlgo *afalg = container_of(cipher, QCryptoAFAlgo, base);return qcrypto_afalg_cipher_op (afalg, in, out, len, true, errp); }
@@ -212,14 +212,14 @@ qcrypto_afalg_cipher_decrypt(QCryptoCipher *cipher, const void *in, void *out, size_t len, Error **errp) { - QCryptoAFAlg *afalg = container_of(cipher, QCryptoAFAlg, base); + QCryptoAFAlgo *afalg = container_of(cipher, QCryptoAFAlgo, base);return qcrypto_afalg_cipher_op (afalg, in, out, len, false, errp); }static void qcrypto_afalg_comm_ctx_free (QCryptoCipher *cipher) { -QCryptoAFAlg *afalg =container_of (cipher, QCryptoAFAlg, base); +QCryptoAFAlgo *afalg =container_of (cipher, QCryptoAFAlgo, base);qcrypto_afalg_comm_free (afalg); }
crypto/hash-afalg.c +7 -7
@@ -64,12 +64,12 @@ qcrypto_afalg_hash_format_name(QCryptoHashAlgo alg,return name; } -static QCryptoAFAlg * +static QCryptoAFAlgo *qcrypto_afalg_hash_hmac_ctx_new (QCryptoHashAlgo alg,const uint8_t *key,size_t nkey,bool is_hmac,Error **errp) { -QCryptoAFAlg *afalg; +QCryptoAFAlgo *afalg;char *name; name =qcrypto_afalg_hash_format_name (alg, is_hmac, errp);
@@ -98,14 +98,14 @@ qcrypto_afalg_hash_hmac_ctx_new(QCryptoHashAlgo alg,return afalg; } -static QCryptoAFAlg * +static QCryptoAFAlgo *qcrypto_afalg_hash_ctx_new (QCryptoHashAlgo alg,Error **errp) {return qcrypto_afalg_hash_hmac_ctx_new (alg,NULL ,0 , false, errp); } -QCryptoAFAlg * +QCryptoAFAlgo *qcrypto_afalg_hmac_ctx_new (QCryptoHashAlgo alg,const uint8_t *key,size_t nkey,Error **errp)
@@ -114,14 +114,14 @@ qcrypto_afalg_hmac_ctx_new(QCryptoHashAlgo alg, }static int -qcrypto_afalg_hash_hmac_bytesv (QCryptoAFAlg *hmac, +qcrypto_afalg_hash_hmac_bytesv (QCryptoAFAlgo *hmac,QCryptoHashAlgo alg,const struct iovec *iov,size_t niov,uint8_t **result,size_t *resultlen,Error **errp) { -QCryptoAFAlg *afalg; +QCryptoAFAlgo *afalg;struct iovec outv;int ret =0 ;bool is_hmac = (hmac !=NULL ) ? true : false;
@@ -197,7 +197,7 @@ qcrypto_afalg_hmac_bytesv(QCryptoHmac *hmac,static void qcrypto_afalg_hmac_ctx_free (QCryptoHmac *hmac) { -QCryptoAFAlg *afalg; +QCryptoAFAlgo *afalg; afalg = hmac->opaque;qcrypto_afalg_comm_free (afalg);
Signature · 1 line
2.46.0
PATCH v2 17/19 qapi/cryptodev: Drop unwanted 'prefix'
In reply to Markus ArmbrusterQAPI'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.
--- 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(-)
qapi/cryptodev.json +0 -1
@@ -31,7 +31,6 @@ # Since: 8.0 ## { 'enum': 'QCryptodevBackendServiceType', - 'prefix': 'QCRYPTODEV_BACKEND_SERVICE', 'data': ['cipher', 'hash', 'mac', 'aead', 'akcipher']} ##
backends/cryptodev-builtin.c +4 -4
@@ -68,7 +68,7 @@ static void cryptodev_builtin_init_akcipher(CryptoDevBackend *backend) opts.u.rsa.padding_alg =QCRYPTO_RSA_PADDING_ALGO_RAW ;if (qcrypto_akcipher_supports (&opts)) { backend->conf.crypto_services |= - (1u <<QCRYPTODEV_BACKEND_SERVICE_AKCIPHER ); + (1u <<QCRYPTODEV_BACKEND_SERVICE_TYPE_AKCIPHER ); backend->conf.akcipher_algo =1u <<VIRTIO_CRYPTO_AKCIPHER_RSA ; } }
@@ -93,9 +93,9 @@ static void cryptodev_builtin_init( backend->conf.peers.ccs[0 ] = cc; backend->conf.crypto_services = -1u <<QCRYPTODEV_BACKEND_SERVICE_CIPHER | -1u <<QCRYPTODEV_BACKEND_SERVICE_HASH | -1u <<QCRYPTODEV_BACKEND_SERVICE_MAC ; +1u <<QCRYPTODEV_BACKEND_SERVICE_TYPE_CIPHER | +1u <<QCRYPTODEV_BACKEND_SERVICE_TYPE_HASH | +1u <<QCRYPTODEV_BACKEND_SERVICE_TYPE_MAC ; backend->conf.cipher_algo_l =1u <<VIRTIO_CRYPTO_CIPHER_AES_CBC ; backend->conf.hash_algo =1u <<VIRTIO_CRYPTO_HASH_SHA1 ;/*
backends/cryptodev-lkcf.c +1 -1
@@ -230,7 +230,7 @@ static void cryptodev_lkcf_init(CryptoDevBackend *backend, Error **errp) backend->conf.peers.ccs[0 ] = cc; backend->conf.crypto_services = -1u <<QCRYPTODEV_BACKEND_SERVICE_AKCIPHER ; +1u <<QCRYPTODEV_BACKEND_SERVICE_TYPE_AKCIPHER ; backend->conf.akcipher_algo =1u <<VIRTIO_CRYPTO_AKCIPHER_RSA ; lkcf->running = true;
backends/cryptodev-vhost-user.c +3 -3
@@ -221,9 +221,9 @@ static void cryptodev_vhost_user_init( cryptodev_vhost_user_event, NULL, s, NULL, true); backend->conf.crypto_services = -1u <<QCRYPTODEV_BACKEND_SERVICE_CIPHER | -1u <<QCRYPTODEV_BACKEND_SERVICE_HASH | -1u <<QCRYPTODEV_BACKEND_SERVICE_MAC ; +1u <<QCRYPTODEV_BACKEND_SERVICE_TYPE_CIPHER | +1u <<QCRYPTODEV_BACKEND_SERVICE_TYPE_HASH | +1u <<QCRYPTODEV_BACKEND_SERVICE_TYPE_MAC ; backend->conf.cipher_algo_l =1u <<VIRTIO_CRYPTO_CIPHER_AES_CBC ; backend->conf.hash_algo =1u <<VIRTIO_CRYPTO_HASH_SHA1 ;
backends/cryptodev.c +3 -3
@@ -74,7 +74,7 @@ static int qmp_query_cryptodev_foreach(Object *obj, void *data) backend =CRYPTODEV_BACKEND (obj); services = backend->conf.crypto_services; -for (i =0 ; i <QCRYPTODEV_BACKEND_SERVICE__MAX ; i++) { +for (i =0 ; i <QCRYPTODEV_BACKEND_SERVICE_TYPE__MAX ; i++) {if (services & (1 << i)) {QAPI_LIST_PREPEND (info->service, i); }
@@ -424,11 +424,11 @@ cryptodev_backend_complete(UserCreatable *uc, Error **errp) } services = backend->conf.crypto_services; -if (services & (1 <<QCRYPTODEV_BACKEND_SERVICE_CIPHER )) { +if (services & (1 <<QCRYPTODEV_BACKEND_SERVICE_TYPE_CIPHER )) { backend->sym_stat =g_new0 (CryptodevBackendSymStat,1 ); } -if (services & (1 <<QCRYPTODEV_BACKEND_SERVICE_AKCIPHER )) { +if (services & (1 <<QCRYPTODEV_BACKEND_SERVICE_TYPE_AKCIPHER )) { backend->asym_stat =g_new0 (CryptodevBackendAsymStat,1 ); } }
hw/virtio/virtio-crypto.c +5 -5
@@ -1008,19 +1008,19 @@ static uint32_t virtio_crypto_init_services(uint32_t qservices) {uint32_t vservices =0 ; -if (qservices & (1 <<QCRYPTODEV_BACKEND_SERVICE_CIPHER )) { +if (qservices & (1 <<QCRYPTODEV_BACKEND_SERVICE_TYPE_CIPHER )) { vservices |= (1 <<VIRTIO_CRYPTO_SERVICE_CIPHER ); } -if (qservices & (1 <<QCRYPTODEV_BACKEND_SERVICE_HASH )) { +if (qservices & (1 <<QCRYPTODEV_BACKEND_SERVICE_TYPE_HASH )) { vservices |= (1 <<VIRTIO_CRYPTO_SERVICE_HASH ); } -if (qservices & (1 <<QCRYPTODEV_BACKEND_SERVICE_MAC )) { +if (qservices & (1 <<QCRYPTODEV_BACKEND_SERVICE_TYPE_MAC )) { vservices |= (1 <<VIRTIO_CRYPTO_SERVICE_MAC ); } -if (qservices & (1 <<QCRYPTODEV_BACKEND_SERVICE_AEAD )) { +if (qservices & (1 <<QCRYPTODEV_BACKEND_SERVICE_TYPE_AEAD )) { vservices |= (1 <<VIRTIO_CRYPTO_SERVICE_AEAD ); } -if (qservices & (1 <<QCRYPTODEV_BACKEND_SERVICE_AKCIPHER )) { +if (qservices & (1 <<QCRYPTODEV_BACKEND_SERVICE_TYPE_AKCIPHER )) { vservices |= (1 <<VIRTIO_CRYPTO_SERVICE_AKCIPHER ); }
Signature · 1 line
2.46.0
PATCH v2 18/19 qapi/cryptodev: Rename QCryptodevBackendAlgType to *Algo, and drop prefix
In reply to Markus ArmbrusterQAPI'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.
--- 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(-)
qapi/cryptodev.json +2 -3
@@ -9,7 +9,7 @@ ## ## -# @QCryptodevBackendAlgType: +# @QCryptodevBackendAlgoType: # # The supported algorithm types of a crypto device. #
@@ -19,8 +19,7 @@ # # Since: 8.0 ## -{ 'enum': 'QCryptodevBackendAlgType', - 'prefix': 'QCRYPTODEV_BACKEND_ALG', +{ 'enum': 'QCryptodevBackendAlgoType', 'data': ['sym', 'asym']} ##
include/sysemu/cryptodev.h +1 -1
@@ -178,7 +178,7 @@ typedef struct CryptoDevBackendAsymOpInfo {typedef void (*CryptoDevCompletionFunc ) (void *opaque,int ret); typedef struct CryptoDevBackendOpInfo { - QCryptodevBackendAlgType algtype; + QCryptodevBackendAlgoType algtype; uint32_t op_code; uint32_t queue_index; CryptoDevCompletionFunc cb;
backends/cryptodev-builtin.c +3 -3
@@ -549,7 +549,7 @@ static int cryptodev_builtin_operation(CryptoDevBackendBuiltinSession *sess;CryptoDevBackendSymOpInfo *sym_op_info;CryptoDevBackendAsymOpInfo *asym_op_info; -QCryptodevBackendAlgType algtype = op_info->algtype; +QCryptodevBackendAlgoType algtype = op_info->algtype;int status = -VIRTIO_CRYPTO_ERR ;Error *local_error =NULL ;
@@ -561,11 +561,11 @@ static int cryptodev_builtin_operation( } sess = builtin->sessions[op_info->session_id]; -if (algtype ==QCRYPTODEV_BACKEND_ALG_SYM ) { +if (algtype ==QCRYPTODEV_BACKEND_ALGO_TYPE_SYM ) { sym_op_info = op_info->u.sym_op_info; status =cryptodev_builtin_sym_operation (sess, sym_op_info, &local_error); - }else if (algtype ==QCRYPTODEV_BACKEND_ALG_ASYM ) { + }else if (algtype ==QCRYPTODEV_BACKEND_ALGO_TYPE_ASYM ) { asym_op_info = op_info->u.asym_op_info; status =cryptodev_builtin_asym_operation (sess, op_info->op_code, asym_op_info, &local_error);
backends/cryptodev-lkcf.c +2 -2
@@ -474,7 +474,7 @@ static int cryptodev_lkcf_operation(CryptoDevBackendLKCF *lkcf =CRYPTODEV_BACKEND_LKCF (backend);CryptoDevBackendLKCFSession *sess; -QCryptodevBackendAlgType algtype = op_info->algtype; +QCryptodevBackendAlgoType algtype = op_info->algtype;CryptoDevLKCFTask *task; if (op_info->session_id >= MAX_SESSIONS ||
@@ -485,7 +485,7 @@ static int cryptodev_lkcf_operation( } sess = lkcf->sess[op_info->session_id]; -if (algtype !=QCRYPTODEV_BACKEND_ALG_ASYM ) { +if (algtype !=QCRYPTODEV_BACKEND_ALGO_TYPE_ASYM ) {error_report ("algtype not supported: %u" , algtype);return -VIRTIO_CRYPTO_NOTSUPP ; }
backends/cryptodev.c +3 -3
@@ -185,10 +185,10 @@ static int cryptodev_backend_operation(static int cryptodev_backend_account (CryptoDevBackend *backend,CryptoDevBackendOpInfo *op_info) { -enum QCryptodevBackendAlgType algtype = op_info->algtype; +enum QCryptodevBackendAlgoType algtype = op_info->algtype;int len; -if (algtype ==QCRYPTODEV_BACKEND_ALG_ASYM ) { +if (algtype ==QCRYPTODEV_BACKEND_ALGO_TYPE_ASYM ) {CryptoDevBackendAsymOpInfo *asym_op_info = op_info->u.asym_op_info; len = asym_op_info->src_len;
@@ -212,7 +212,7 @@ static int cryptodev_backend_account(CryptoDevBackend *backend,default :return -VIRTIO_CRYPTO_NOTSUPP ; } - }else if (algtype ==QCRYPTODEV_BACKEND_ALG_SYM ) { + }else if (algtype ==QCRYPTODEV_BACKEND_ALGO_TYPE_SYM ) {CryptoDevBackendSymOpInfo *sym_op_info = op_info->u.sym_op_info; len = sym_op_info->src_len;
hw/virtio/virtio-crypto.c +7 -7
@@ -461,7 +461,7 @@ static void virtio_crypto_init_request(VirtIOCrypto *vcrypto, VirtQueue *vq, req->in_iov =NULL ; req->in_num =0 ; req->in_len =0 ; - req->flags =QCRYPTODEV_BACKEND_ALG__MAX ; + req->flags =QCRYPTODEV_BACKEND_ALGO_TYPE__MAX ;memset (&req->op_info,0x00 ,sizeof (req->op_info)); }
@@ -471,7 +471,7 @@ static void virtio_crypto_free_request(VirtIOCryptoReq *req)return ; } -if (req->flags ==QCRYPTODEV_BACKEND_ALG_SYM ) { +if (req->flags ==QCRYPTODEV_BACKEND_ALGO_TYPE_SYM ) {size_t max_len;CryptoDevBackendSymOpInfo *op_info = req->op_info.u.sym_op_info;
@@ -486,7 +486,7 @@ static void virtio_crypto_free_request(VirtIOCryptoReq *req)memset (op_info,0 ,sizeof (*op_info) + max_len);g_free (op_info); } - }else if (req->flags ==QCRYPTODEV_BACKEND_ALG_ASYM ) { + }else if (req->flags ==QCRYPTODEV_BACKEND_ALGO_TYPE_ASYM ) {CryptoDevBackendAsymOpInfo *op_info = req->op_info.u.asym_op_info;if (op_info) {g_free (op_info->src);
@@ -571,10 +571,10 @@ static void virtio_crypto_req_complete(void *opaque, int ret)VirtIODevice *vdev =VIRTIO_DEVICE (vcrypto);uint8_t status = -ret; -if (req->flags ==QCRYPTODEV_BACKEND_ALG_SYM ) { +if (req->flags ==QCRYPTODEV_BACKEND_ALGO_TYPE_SYM ) {virtio_crypto_sym_input_data_helper (vdev, req, status, req->op_info.u.sym_op_info); - }else if (req->flags ==QCRYPTODEV_BACKEND_ALG_ASYM ) { + }else if (req->flags ==QCRYPTODEV_BACKEND_ALGO_TYPE_ASYM ) {virtio_crypto_akcipher_input_data_helper (vdev, req, status, req->op_info.u.asym_op_info); }
@@ -884,7 +884,7 @@ virtio_crypto_handle_request(VirtIOCryptoReq *request)switch (opcode) {case VIRTIO_CRYPTO_CIPHER_ENCRYPT :case VIRTIO_CRYPTO_CIPHER_DECRYPT : - op_info->algtype = request->flags =QCRYPTODEV_BACKEND_ALG_SYM ; + op_info->algtype = request->flags =QCRYPTODEV_BACKEND_ALGO_TYPE_SYM ; ret =virtio_crypto_handle_sym_req (vcrypto, &req.u.sym_req, op_info, out_iov, out_num);
@@ -894,7 +894,7 @@ virtio_crypto_handle_request(VirtIOCryptoReq *request)case VIRTIO_CRYPTO_AKCIPHER_DECRYPT :case VIRTIO_CRYPTO_AKCIPHER_SIGN :case VIRTIO_CRYPTO_AKCIPHER_VERIFY : - op_info->algtype = request->flags =QCRYPTODEV_BACKEND_ALG_ASYM ; + op_info->algtype = request->flags =QCRYPTODEV_BACKEND_ALGO_TYPE_ASYM ; ret =virtio_crypto_handle_asym_req (vcrypto, &req.u.akcipher_req, op_info, out_iov, out_num);
Signature · 1 line
2.46.0
PATCH v2 19/19 qapi/vfio: Rename VfioMigrationState to Qapi*, and drop prefix
In reply to Markus ArmbrusterQAPI'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.
--- qapi/vfio.json | 9 ++++----- hw/vfio/migration.c | 2 +- 2 files changed, 5 insertions(+), 6 deletions(-)
qapi/vfio.json +4 -5
@@ -7,7 +7,7 @@ ## ## -# @VfioMigrationState: +# @QapiVfioMigrationState: # # An enumeration of the VFIO device migration states. #
@@ -32,10 +32,9 @@ # # Since: 9.1 ## -{ 'enum': 'VfioMigrationState', +{ 'enum': 'QapiVfioMigrationState', 'data': [ 'stop', 'running', 'stop-copy', 'resuming', 'running-p2p', - 'pre-copy', 'pre-copy-p2p' ], - 'prefix': 'QAPI_VFIO_MIGRATION_STATE' } + 'pre-copy', 'pre-copy-p2p' ] } ## # @VFIO_MIGRATION:
@@ -63,5 +62,5 @@ 'data': { 'device-id': 'str', 'qom-path': 'str', - 'device-state': 'VfioMigrationState' + 'device-state': 'QapiVfioMigrationState' } }
hw/vfio/migration.c +1 -1
@@ -81,7 +81,7 @@ static const char *mig_state_to_str(enum vfio_device_mig_state state) } } -static VfioMigrationState +static QapiVfioMigrationState mig_state_to_qapi_state (enum vfio_device_mig_state state) {switch (state) {
Signature · 1 line
2.46.0
Re: [PATCH v2 19/19] qapi/vfio: Rename VfioMigrationState to Qapi*, and drop prefix
Quoted 7 lines · Markus Armbruster
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.
Quoted 7 lines
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 <[email protected]>
Thanks,
C.
Quoted 51 lines
--- qapi/vfio.json | 9 ++++----- hw/vfio/migration.c | 2 +- 2 files changed, 5 insertions(+), 6 deletions(-)qapi/vfio.json +4
-5@@ -7,7 +7,7 @@ ## ## -# @VfioMigrationState: +# @QapiVfioMigrationState: # # An enumeration of the VFIO device migration states. #@@ -32,10 +32,9 @@ # # Since: 9.1 ## -{ 'enum': 'VfioMigrationState', +{ 'enum': 'QapiVfioMigrationState', 'data': [ 'stop', 'running', 'stop-copy', 'resuming', 'running-p2p', - 'pre-copy', 'pre-copy-p2p' ], - 'prefix': 'QAPI_VFIO_MIGRATION_STATE' } + 'pre-copy', 'pre-copy-p2p' ] } ## # @VFIO_MIGRATION:@@ -63,5 +62,5 @@ 'data': { 'device-id': 'str', 'qom-path': 'str', - 'device-state': 'VfioMigrationState' + 'device-state': 'QapiVfioMigrationState' } }hw/vfio/migration.c +1
-1@@ -81,7 +81,7 @@ static const char *mig_state_to_str(enum vfio_device_mig_state state) } } -static VfioMigrationState +static QapiVfioMigrationState mig_state_to_qapi_state (enum vfio_device_mig_state state) {switch (state) {