From nobody Sun Nov 24 07:29:30 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1725986987; cv=none; d=zohomail.com; s=zohoarc; b=NK74uUW9znAhjZTuqTLnjEinaWbudP7S74Lbwy/8AV2I1MhkN8+DGlE17zKwH74HB/4g2p6RCjc5sIo44LpFNMLH72QN14kShgwM2P/3k0yApIXcFFKCoQKn2tv08W9qShzyZbNtSdNtAqgHu56IMcaN79LYymMJqj2JVEGMYwU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1725986987; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=Cy/MS5RDkwnuKcLg6VIXiODxYMuznqznxyuPu17sIqM=; b=OgVQby9NSq8jdFu/nSZgdRsJMKQa6e64MAHiWMRi9nGyjr/7rdlbH5vGXwoWb9rAg6Yu0UY/2YWo1RhdBtrRIMfkqFx0w9fs1rLoUpNWpkLTXMhM4nLLVhbOAzq204pyOoJuh4FG7ZIFUBfzpKNJMH9A56WHQEO+SS6vBfip1g0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1725986987132377.37092700416827; Tue, 10 Sep 2024 09:49:47 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1so41p-0007QI-16; Tue, 10 Sep 2024 12:47:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1so41Z-0006nN-Lt for qemu-devel@nongnu.org; Tue, 10 Sep 2024 12:47:29 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1so41T-0007Yk-O5 for qemu-devel@nongnu.org; Tue, 10 Sep 2024 12:47:29 -0400 Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-652-G9L0UnO6PvyYSviKmtjT3A-1; Tue, 10 Sep 2024 12:47:21 -0400 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 755B21955DCD; Tue, 10 Sep 2024 16:47:20 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.192.112]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 5886D1956053; Tue, 10 Sep 2024 16:47:19 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 9A22D21E682A; Tue, 10 Sep 2024 18:47:14 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1725986843; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Cy/MS5RDkwnuKcLg6VIXiODxYMuznqznxyuPu17sIqM=; b=cuU98HPw+vz3t85eN3KGYBDTmMF17Xpzg2EwiuXH1Yqj4diXA1Ehnu2AtaMwuABL/NBHh0 SCypvMHo2ukGOU4cR6ny4kJsJhIQasaCsu2lFi0KvAdd3M7Ry87ghgNu8od1VhrSuW8qyn WcDMWFpuwY4cTOo8ZVgmQEx4fD4p6EQ= X-MC-Unique: G9L0UnO6PvyYSviKmtjT3A-1 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org, =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= Subject: [PULL 12/19] qapi/crypto: Rename QCryptoCipherAlgorithm to *Algo, and drop prefix Date: Tue, 10 Sep 2024 18:47:07 +0200 Message-ID: <20240910164714.1993531-13-armbru@redhat.com> In-Reply-To: <20240910164714.1993531-1-armbru@redhat.com> References: <20240910164714.1993531-1-armbru@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.145, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, PDS_BTC_ID=0.156, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1725986987978116600 QAPI's 'prefix' feature can make the connection between enumeration type and its constants less than obvious. It's best used with restraint. QCryptoCipherAlgorithm has a 'prefix' that overrides the generated enumeration constants' prefix to QCRYPTO_CIPHER_ALG. We could simply drop 'prefix', but then the prefix becomes QCRYPTO_CIPHER_ALGORITHM, which is rather long. We could additionally rename the type to QCryptoCipherAlg, but I think the abbreviation "alg" is less than clear. Rename the type to QCryptoCipherAlgo instead. The prefix becomes QCRYPTO_CIPHER_ALGO. Signed-off-by: Markus Armbruster Acked-by: Daniel P. Berrang=C3=A9 Message-ID: <20240904111836.3273842-13-armbru@redhat.com> --- qapi/block-core.json | 2 +- qapi/crypto.json | 9 ++- crypto/blockpriv.h | 4 +- crypto/cipherpriv.h | 2 +- crypto/ivgenpriv.h | 2 +- include/crypto/cipher.h | 18 +++--- include/crypto/ivgen.h | 10 +-- include/crypto/pbkdf.h | 4 +- backends/cryptodev-builtin.c | 16 ++--- block/rbd.c | 4 +- crypto/block-luks.c | 92 +++++++++++++-------------- crypto/block-qcow.c | 4 +- crypto/block.c | 2 +- crypto/cipher-afalg.c | 24 +++---- crypto/cipher.c | 72 ++++++++++----------- crypto/ivgen.c | 4 +- crypto/secret_common.c | 2 +- tests/bench/benchmark-crypto-cipher.c | 22 +++---- tests/unit/test-crypto-block.c | 14 ++-- tests/unit/test-crypto-cipher.c | 66 +++++++++---------- tests/unit/test-crypto-ivgen.c | 8 +-- ui/vnc.c | 4 +- crypto/cipher-builtin.c.inc | 18 +++--- crypto/cipher-gcrypt.c.inc | 56 ++++++++-------- crypto/cipher-gnutls.c.inc | 38 +++++------ crypto/cipher-nettle.c.inc | 58 ++++++++--------- 26 files changed, 277 insertions(+), 278 deletions(-) diff --git a/qapi/block-core.json b/qapi/block-core.json index a7ae2da47b..9f6dd59298 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -4163,7 +4163,7 @@ ## { 'struct': 'RbdEncryptionCreateOptionsLUKSBase', 'base': 'RbdEncryptionOptionsLUKSBase', - 'data': { '*cipher-alg': 'QCryptoCipherAlgorithm' } } + 'data': { '*cipher-alg': 'QCryptoCipherAlgo' } } =20 ## # @RbdEncryptionOptionsLUKS: diff --git a/qapi/crypto.json b/qapi/crypto.json index 68393568cf..0591d62f67 100644 --- a/qapi/crypto.json +++ b/qapi/crypto.json @@ -62,7 +62,7 @@ 'data': ['md5', 'sha1', 'sha224', 'sha256', 'sha384', 'sha512', 'ripemd1= 60']} =20 ## -# @QCryptoCipherAlgorithm: +# @QCryptoCipherAlgo: # # The supported algorithms for content encryption ciphers # @@ -95,8 +95,7 @@ # # Since: 2.6 ## -{ 'enum': 'QCryptoCipherAlgorithm', - 'prefix': 'QCRYPTO_CIPHER_ALG', +{ 'enum': 'QCryptoCipherAlgo', 'data': ['aes-128', 'aes-192', 'aes-256', 'des', '3des', 'cast5-128', @@ -225,7 +224,7 @@ ## { 'struct': 'QCryptoBlockCreateOptionsLUKS', 'base': 'QCryptoBlockOptionsLUKS', - 'data': { '*cipher-alg': 'QCryptoCipherAlgorithm', + 'data': { '*cipher-alg': 'QCryptoCipherAlgo', '*cipher-mode': 'QCryptoCipherMode', '*ivgen-alg': 'QCryptoIVGenAlgorithm', '*ivgen-hash-alg': 'QCryptoHashAlgo', @@ -322,7 +321,7 @@ # Since: 2.7 ## { 'struct': 'QCryptoBlockInfoLUKS', - 'data': {'cipher-alg': 'QCryptoCipherAlgorithm', + 'data': {'cipher-alg': 'QCryptoCipherAlgo', 'cipher-mode': 'QCryptoCipherMode', 'ivgen-alg': 'QCryptoIVGenAlgorithm', '*ivgen-hash-alg': 'QCryptoHashAlgo', diff --git a/crypto/blockpriv.h b/crypto/blockpriv.h index cf1a66c00d..edf0b3a3d9 100644 --- a/crypto/blockpriv.h +++ b/crypto/blockpriv.h @@ -33,7 +33,7 @@ struct QCryptoBlock { void *opaque; =20 /* Cipher parameters */ - QCryptoCipherAlgorithm alg; + QCryptoCipherAlgo alg; QCryptoCipherMode mode; uint8_t *key; size_t nkey; @@ -132,7 +132,7 @@ int qcrypto_block_encrypt_helper(QCryptoBlock *block, Error **errp); =20 int qcrypto_block_init_cipher(QCryptoBlock *block, - QCryptoCipherAlgorithm alg, + QCryptoCipherAlgo alg, QCryptoCipherMode mode, const uint8_t *key, size_t nkey, Error **errp); diff --git a/crypto/cipherpriv.h b/crypto/cipherpriv.h index 396527857d..64737ce961 100644 --- a/crypto/cipherpriv.h +++ b/crypto/cipherpriv.h @@ -42,7 +42,7 @@ struct QCryptoCipherDriver { #include "afalgpriv.h" =20 extern QCryptoCipher * -qcrypto_afalg_cipher_ctx_new(QCryptoCipherAlgorithm alg, +qcrypto_afalg_cipher_ctx_new(QCryptoCipherAlgo alg, QCryptoCipherMode mode, const uint8_t *key, size_t nkey, Error **errp); diff --git a/crypto/ivgenpriv.h b/crypto/ivgenpriv.h index 0227ae4d00..ef24c76345 100644 --- a/crypto/ivgenpriv.h +++ b/crypto/ivgenpriv.h @@ -41,7 +41,7 @@ struct QCryptoIVGen { void *private; =20 QCryptoIVGenAlgorithm algorithm; - QCryptoCipherAlgorithm cipher; + QCryptoCipherAlgo cipher; QCryptoHashAlgo hash; }; =20 diff --git a/include/crypto/cipher.h b/include/crypto/cipher.h index 083e12a7d9..92939310ef 100644 --- a/include/crypto/cipher.h +++ b/include/crypto/cipher.h @@ -26,7 +26,7 @@ typedef struct QCryptoCipher QCryptoCipher; typedef struct QCryptoCipherDriver QCryptoCipherDriver; =20 -/* See also "QCryptoCipherAlgorithm" and "QCryptoCipherMode" +/* See also "QCryptoCipherAlgo" and "QCryptoCipherMode" * enums defined in qapi/crypto.json */ =20 /** @@ -50,12 +50,12 @@ typedef struct QCryptoCipherDriver QCryptoCipherDriver; * size_t keylen =3D 16; * uint8_t iv =3D ....; * - * if (!qcrypto_cipher_supports(QCRYPTO_CIPHER_ALG_AES_128)) { + * if (!qcrypto_cipher_supports(QCRYPTO_CIPHER_ALGO_AES_128)) { * error_report(errp, "Feature requires AES cipher support"); * return -1; * } * - * cipher =3D qcrypto_cipher_new(QCRYPTO_CIPHER_ALG_AES_128, + * cipher =3D qcrypto_cipher_new(QCRYPTO_CIPHER_ALGO_AES_128, * QCRYPTO_CIPHER_MODE_CBC, * key, keylen, * errp); @@ -78,7 +78,7 @@ typedef struct QCryptoCipherDriver QCryptoCipherDriver; */ =20 struct QCryptoCipher { - QCryptoCipherAlgorithm alg; + QCryptoCipherAlgo alg; QCryptoCipherMode mode; const QCryptoCipherDriver *driver; }; @@ -93,7 +93,7 @@ struct QCryptoCipher { * * Returns: true if the algorithm is supported, false otherwise */ -bool qcrypto_cipher_supports(QCryptoCipherAlgorithm alg, +bool qcrypto_cipher_supports(QCryptoCipherAlgo alg, QCryptoCipherMode mode); =20 /** @@ -106,7 +106,7 @@ bool qcrypto_cipher_supports(QCryptoCipherAlgorithm alg, * * Returns: the block size in bytes */ -size_t qcrypto_cipher_get_block_len(QCryptoCipherAlgorithm alg); +size_t qcrypto_cipher_get_block_len(QCryptoCipherAlgo alg); =20 =20 /** @@ -117,7 +117,7 @@ size_t qcrypto_cipher_get_block_len(QCryptoCipherAlgori= thm alg); * * Returns: the key size in bytes */ -size_t qcrypto_cipher_get_key_len(QCryptoCipherAlgorithm alg); +size_t qcrypto_cipher_get_key_len(QCryptoCipherAlgo alg); =20 =20 /** @@ -130,7 +130,7 @@ size_t qcrypto_cipher_get_key_len(QCryptoCipherAlgorith= m alg); * * Returns: the IV size in bytes, or 0 if no IV is permitted */ -size_t qcrypto_cipher_get_iv_len(QCryptoCipherAlgorithm alg, +size_t qcrypto_cipher_get_iv_len(QCryptoCipherAlgo alg, QCryptoCipherMode mode); =20 =20 @@ -156,7 +156,7 @@ size_t qcrypto_cipher_get_iv_len(QCryptoCipherAlgorithm= alg, * * Returns: a new cipher object, or NULL on error */ -QCryptoCipher *qcrypto_cipher_new(QCryptoCipherAlgorithm alg, +QCryptoCipher *qcrypto_cipher_new(QCryptoCipherAlgo alg, QCryptoCipherMode mode, const uint8_t *key, size_t nkey, Error **errp); diff --git a/include/crypto/ivgen.h b/include/crypto/ivgen.h index ab5f1a648e..b059e332cd 100644 --- a/include/crypto/ivgen.h +++ b/include/crypto/ivgen.h @@ -45,21 +45,21 @@ * g_assert((ndata % 512) =3D=3D 0); * * QCryptoIVGen *ivgen =3D qcrypto_ivgen_new(QCRYPTO_IVGEN_ALG_ESSIV, - * QCRYPTO_CIPHER_ALG_AES_128, + * QCRYPTO_CIPHER_ALGO_AES_128, * QCRYPTO_HASH_ALGO_SHA256, * key, nkey, errp); * if (!ivgen) { * return -1; * } * - * QCryptoCipher *cipher =3D qcrypto_cipher_new(QCRYPTO_CIPHER_ALG_AES_128, + * QCryptoCipher *cipher =3D qcrypto_cipher_new(QCRYPTO_CIPHER_ALGO_AES_12= 8, * QCRYPTO_CIPHER_MODE_CBC, * key, nkey, errp); * if (!cipher) { * goto error; * } * - * niv =3D qcrypto_cipher_get_iv_len(QCRYPTO_CIPHER_ALG_AES_128, + * niv =3D qcrypto_cipher_get_iv_len(QCRYPTO_CIPHER_ALGO_AES_128, * QCRYPTO_CIPHER_MODE_CBC); * iv =3D g_new0(uint8_t, niv); * @@ -134,7 +134,7 @@ typedef struct QCryptoIVGen QCryptoIVGen; * Returns: a new IV generator, or NULL on error */ QCryptoIVGen *qcrypto_ivgen_new(QCryptoIVGenAlgorithm alg, - QCryptoCipherAlgorithm cipheralg, + QCryptoCipherAlgo cipheralg, QCryptoHashAlgo hash, const uint8_t *key, size_t nkey, Error **errp); @@ -179,7 +179,7 @@ QCryptoIVGenAlgorithm qcrypto_ivgen_get_algorithm(QCryp= toIVGen *ivgen); * * Returns: the cipher algorithm */ -QCryptoCipherAlgorithm qcrypto_ivgen_get_cipher(QCryptoIVGen *ivgen); +QCryptoCipherAlgo qcrypto_ivgen_get_cipher(QCryptoIVGen *ivgen); =20 =20 /** diff --git a/include/crypto/pbkdf.h b/include/crypto/pbkdf.h index 6cf29e78ee..cf59fce610 100644 --- a/include/crypto/pbkdf.h +++ b/include/crypto/pbkdf.h @@ -38,7 +38,7 @@ * .... * * char *password =3D "a-typical-awful-user-password"; - * size_t nkey =3D qcrypto_cipher_get_key_len(QCRYPTO_CIPHER_ALG_AES_128); + * size_t nkey =3D qcrypto_cipher_get_key_len(QCRYPTO_CIPHER_ALGO_AES_128); * uint8_t *salt =3D g_new0(uint8_t, nkey); * uint8_t *key =3D g_new0(uint8_t, nkey); * int iterations; @@ -70,7 +70,7 @@ * * g_free(salt); * - * cipher =3D qcrypto_cipher_new(QCRYPTO_CIPHER_ALG_AES_128, + * cipher =3D qcrypto_cipher_new(QCRYPTO_CIPHER_ALGO_AES_128, * QCRYPTO_CIPHER_MODE_ECB, * key, nkey, errp); * g_free(key); diff --git a/backends/cryptodev-builtin.c b/backends/cryptodev-builtin.c index 4a49d328ec..2672755661 100644 --- a/backends/cryptodev-builtin.c +++ b/backends/cryptodev-builtin.c @@ -138,18 +138,18 @@ cryptodev_builtin_get_aes_algo(uint32_t key_len, int = mode, Error **errp) int algo; =20 if (key_len =3D=3D AES_KEYSIZE_128) { - algo =3D QCRYPTO_CIPHER_ALG_AES_128; + algo =3D QCRYPTO_CIPHER_ALGO_AES_128; } else if (key_len =3D=3D AES_KEYSIZE_192) { - algo =3D QCRYPTO_CIPHER_ALG_AES_192; + algo =3D QCRYPTO_CIPHER_ALGO_AES_192; } else if (key_len =3D=3D AES_KEYSIZE_256) { /* equals AES_KEYSIZE_128= _XTS */ if (mode =3D=3D QCRYPTO_CIPHER_MODE_XTS) { - algo =3D QCRYPTO_CIPHER_ALG_AES_128; + algo =3D QCRYPTO_CIPHER_ALGO_AES_128; } else { - algo =3D QCRYPTO_CIPHER_ALG_AES_256; + algo =3D QCRYPTO_CIPHER_ALGO_AES_256; } } else if (key_len =3D=3D AES_KEYSIZE_256_XTS) { if (mode =3D=3D QCRYPTO_CIPHER_MODE_XTS) { - algo =3D QCRYPTO_CIPHER_ALG_AES_256; + algo =3D QCRYPTO_CIPHER_ALGO_AES_256; } else { goto err; } @@ -271,15 +271,15 @@ static int cryptodev_builtin_create_cipher_session( break; case VIRTIO_CRYPTO_CIPHER_3DES_ECB: mode =3D QCRYPTO_CIPHER_MODE_ECB; - algo =3D QCRYPTO_CIPHER_ALG_3DES; + algo =3D QCRYPTO_CIPHER_ALGO_3DES; break; case VIRTIO_CRYPTO_CIPHER_3DES_CBC: mode =3D QCRYPTO_CIPHER_MODE_CBC; - algo =3D QCRYPTO_CIPHER_ALG_3DES; + algo =3D QCRYPTO_CIPHER_ALGO_3DES; break; case VIRTIO_CRYPTO_CIPHER_3DES_CTR: mode =3D QCRYPTO_CIPHER_MODE_CTR; - algo =3D QCRYPTO_CIPHER_ALG_3DES; + algo =3D QCRYPTO_CIPHER_ALGO_3DES; break; default: error_setg(errp, "Unsupported cipher alg :%u", diff --git a/block/rbd.c b/block/rbd.c index 9c0fd0cb3f..04ed0e242e 100644 --- a/block/rbd.c +++ b/block/rbd.c @@ -367,11 +367,11 @@ static int qemu_rbd_convert_luks_create_options( =20 if (luks_opts->has_cipher_alg) { switch (luks_opts->cipher_alg) { - case QCRYPTO_CIPHER_ALG_AES_128: { + case QCRYPTO_CIPHER_ALGO_AES_128: { *alg =3D RBD_ENCRYPTION_ALGORITHM_AES128; break; } - case QCRYPTO_CIPHER_ALG_AES_256: { + case QCRYPTO_CIPHER_ALGO_AES_256: { *alg =3D RBD_ENCRYPTION_ALGORITHM_AES256; break; } diff --git a/crypto/block-luks.c b/crypto/block-luks.c index 59af733b8c..8eadf124fc 100644 --- a/crypto/block-luks.c +++ b/crypto/block-luks.c @@ -68,38 +68,38 @@ struct QCryptoBlockLUKSCipherNameMap { =20 static const QCryptoBlockLUKSCipherSizeMap qcrypto_block_luks_cipher_size_map_aes[] =3D { - { 16, QCRYPTO_CIPHER_ALG_AES_128 }, - { 24, QCRYPTO_CIPHER_ALG_AES_192 }, - { 32, QCRYPTO_CIPHER_ALG_AES_256 }, + { 16, QCRYPTO_CIPHER_ALGO_AES_128 }, + { 24, QCRYPTO_CIPHER_ALGO_AES_192 }, + { 32, QCRYPTO_CIPHER_ALGO_AES_256 }, { 0, 0 }, }; =20 static const QCryptoBlockLUKSCipherSizeMap qcrypto_block_luks_cipher_size_map_cast5[] =3D { - { 16, QCRYPTO_CIPHER_ALG_CAST5_128 }, + { 16, QCRYPTO_CIPHER_ALGO_CAST5_128 }, { 0, 0 }, }; =20 static const QCryptoBlockLUKSCipherSizeMap qcrypto_block_luks_cipher_size_map_serpent[] =3D { - { 16, QCRYPTO_CIPHER_ALG_SERPENT_128 }, - { 24, QCRYPTO_CIPHER_ALG_SERPENT_192 }, - { 32, QCRYPTO_CIPHER_ALG_SERPENT_256 }, + { 16, QCRYPTO_CIPHER_ALGO_SERPENT_128 }, + { 24, QCRYPTO_CIPHER_ALGO_SERPENT_192 }, + { 32, QCRYPTO_CIPHER_ALGO_SERPENT_256 }, { 0, 0 }, }; =20 static const QCryptoBlockLUKSCipherSizeMap qcrypto_block_luks_cipher_size_map_twofish[] =3D { - { 16, QCRYPTO_CIPHER_ALG_TWOFISH_128 }, - { 24, QCRYPTO_CIPHER_ALG_TWOFISH_192 }, - { 32, QCRYPTO_CIPHER_ALG_TWOFISH_256 }, + { 16, QCRYPTO_CIPHER_ALGO_TWOFISH_128 }, + { 24, QCRYPTO_CIPHER_ALGO_TWOFISH_192 }, + { 32, QCRYPTO_CIPHER_ALGO_TWOFISH_256 }, { 0, 0 }, }; =20 #ifdef CONFIG_CRYPTO_SM4 static const QCryptoBlockLUKSCipherSizeMap qcrypto_block_luks_cipher_size_map_sm4[] =3D { - { 16, QCRYPTO_CIPHER_ALG_SM4}, + { 16, QCRYPTO_CIPHER_ALGO_SM4}, { 0, 0 }, }; #endif @@ -123,7 +123,7 @@ struct QCryptoBlockLUKS { QCryptoBlockLUKSHeader header; =20 /* Main encryption algorithm used for encryption*/ - QCryptoCipherAlgorithm cipher_alg; + QCryptoCipherAlgo cipher_alg; =20 /* Mode of encryption for the selected encryption algorithm */ QCryptoCipherMode cipher_mode; @@ -138,7 +138,7 @@ struct QCryptoBlockLUKS { * Encryption algorithm used for IV generation. * Usually the same as main encryption algorithm */ - QCryptoCipherAlgorithm ivgen_cipher_alg; + QCryptoCipherAlgo ivgen_cipher_alg; =20 /* Hash algorithm used in pbkdf2 function */ QCryptoHashAlgo hash_alg; @@ -179,7 +179,7 @@ static int qcrypto_block_luks_cipher_name_lookup(const = char *name, } =20 static const char * -qcrypto_block_luks_cipher_alg_lookup(QCryptoCipherAlgorithm alg, +qcrypto_block_luks_cipher_alg_lookup(QCryptoCipherAlgo alg, Error **errp) { const QCryptoBlockLUKSCipherNameMap *map =3D @@ -195,7 +195,7 @@ qcrypto_block_luks_cipher_alg_lookup(QCryptoCipherAlgor= ithm alg, } =20 error_setg(errp, "Algorithm '%s' not supported", - QCryptoCipherAlgorithm_str(alg)); + QCryptoCipherAlgo_str(alg)); return NULL; } =20 @@ -262,8 +262,8 @@ qcrypto_block_luks_has_format(const uint8_t *buf, * the cipher since that gets a key length matching the digest * size, not AES 128 with truncated digest as might be imagined */ -static QCryptoCipherAlgorithm -qcrypto_block_luks_essiv_cipher(QCryptoCipherAlgorithm cipher, +static QCryptoCipherAlgo +qcrypto_block_luks_essiv_cipher(QCryptoCipherAlgo cipher, QCryptoHashAlgo hash, Error **errp) { @@ -274,54 +274,54 @@ qcrypto_block_luks_essiv_cipher(QCryptoCipherAlgorith= m cipher, } =20 switch (cipher) { - case QCRYPTO_CIPHER_ALG_AES_128: - case QCRYPTO_CIPHER_ALG_AES_192: - case QCRYPTO_CIPHER_ALG_AES_256: + case QCRYPTO_CIPHER_ALGO_AES_128: + case QCRYPTO_CIPHER_ALGO_AES_192: + case QCRYPTO_CIPHER_ALGO_AES_256: if (digestlen =3D=3D qcrypto_cipher_get_key_len( - QCRYPTO_CIPHER_ALG_AES_128)) { - return QCRYPTO_CIPHER_ALG_AES_128; + QCRYPTO_CIPHER_ALGO_AES_128)) { + return QCRYPTO_CIPHER_ALGO_AES_128; } else if (digestlen =3D=3D qcrypto_cipher_get_key_len( - QCRYPTO_CIPHER_ALG_AES_192)) { - return QCRYPTO_CIPHER_ALG_AES_192; + QCRYPTO_CIPHER_ALGO_AES_192)) { + return QCRYPTO_CIPHER_ALGO_AES_192; } else if (digestlen =3D=3D qcrypto_cipher_get_key_len( - QCRYPTO_CIPHER_ALG_AES_256)) { - return QCRYPTO_CIPHER_ALG_AES_256; + QCRYPTO_CIPHER_ALGO_AES_256)) { + return QCRYPTO_CIPHER_ALGO_AES_256; } else { error_setg(errp, "No AES cipher with key size %zu available", digestlen); return 0; } break; - case QCRYPTO_CIPHER_ALG_SERPENT_128: - case QCRYPTO_CIPHER_ALG_SERPENT_192: - case QCRYPTO_CIPHER_ALG_SERPENT_256: + case QCRYPTO_CIPHER_ALGO_SERPENT_128: + case QCRYPTO_CIPHER_ALGO_SERPENT_192: + case QCRYPTO_CIPHER_ALGO_SERPENT_256: if (digestlen =3D=3D qcrypto_cipher_get_key_len( - QCRYPTO_CIPHER_ALG_SERPENT_128)) { - return QCRYPTO_CIPHER_ALG_SERPENT_128; + QCRYPTO_CIPHER_ALGO_SERPENT_128)) { + return QCRYPTO_CIPHER_ALGO_SERPENT_128; } else if (digestlen =3D=3D qcrypto_cipher_get_key_len( - QCRYPTO_CIPHER_ALG_SERPENT_192)) { - return QCRYPTO_CIPHER_ALG_SERPENT_192; + QCRYPTO_CIPHER_ALGO_SERPENT_192)) { + return QCRYPTO_CIPHER_ALGO_SERPENT_192; } else if (digestlen =3D=3D qcrypto_cipher_get_key_len( - QCRYPTO_CIPHER_ALG_SERPENT_256)) { - return QCRYPTO_CIPHER_ALG_SERPENT_256; + QCRYPTO_CIPHER_ALGO_SERPENT_256)) { + return QCRYPTO_CIPHER_ALGO_SERPENT_256; } else { error_setg(errp, "No Serpent cipher with key size %zu availabl= e", digestlen); return 0; } break; - case QCRYPTO_CIPHER_ALG_TWOFISH_128: - case QCRYPTO_CIPHER_ALG_TWOFISH_192: - case QCRYPTO_CIPHER_ALG_TWOFISH_256: + case QCRYPTO_CIPHER_ALGO_TWOFISH_128: + case QCRYPTO_CIPHER_ALGO_TWOFISH_192: + case QCRYPTO_CIPHER_ALGO_TWOFISH_256: if (digestlen =3D=3D qcrypto_cipher_get_key_len( - QCRYPTO_CIPHER_ALG_TWOFISH_128)) { - return QCRYPTO_CIPHER_ALG_TWOFISH_128; + QCRYPTO_CIPHER_ALGO_TWOFISH_128)) { + return QCRYPTO_CIPHER_ALGO_TWOFISH_128; } else if (digestlen =3D=3D qcrypto_cipher_get_key_len( - QCRYPTO_CIPHER_ALG_TWOFISH_192)) { - return QCRYPTO_CIPHER_ALG_TWOFISH_192; + QCRYPTO_CIPHER_ALGO_TWOFISH_192)) { + return QCRYPTO_CIPHER_ALGO_TWOFISH_192; } else if (digestlen =3D=3D qcrypto_cipher_get_key_len( - QCRYPTO_CIPHER_ALG_TWOFISH_256)) { - return QCRYPTO_CIPHER_ALG_TWOFISH_256; + QCRYPTO_CIPHER_ALGO_TWOFISH_256)) { + return QCRYPTO_CIPHER_ALGO_TWOFISH_256; } else { error_setg(errp, "No Twofish cipher with key size %zu availabl= e", digestlen); @@ -330,7 +330,7 @@ qcrypto_block_luks_essiv_cipher(QCryptoCipherAlgorithm = cipher, break; default: error_setg(errp, "Cipher %s not supported with essiv", - QCryptoCipherAlgorithm_str(cipher)); + QCryptoCipherAlgo_str(cipher)); return 0; } } @@ -1322,7 +1322,7 @@ qcrypto_block_luks_create(QCryptoBlock *block, luks_opts.iter_time =3D QCRYPTO_BLOCK_LUKS_DEFAULT_ITER_TIME_MS; } if (!luks_opts.has_cipher_alg) { - luks_opts.cipher_alg =3D QCRYPTO_CIPHER_ALG_AES_256; + luks_opts.cipher_alg =3D QCRYPTO_CIPHER_ALGO_AES_256; } if (!luks_opts.has_cipher_mode) { luks_opts.cipher_mode =3D QCRYPTO_CIPHER_MODE_XTS; diff --git a/crypto/block-qcow.c b/crypto/block-qcow.c index 42e9556e42..a0ba9c1f2e 100644 --- a/crypto/block-qcow.c +++ b/crypto/block-qcow.c @@ -62,7 +62,7 @@ qcrypto_block_qcow_init(QCryptoBlock *block, memcpy(keybuf, password, MIN(len, sizeof(keybuf))); g_free(password); =20 - block->niv =3D qcrypto_cipher_get_iv_len(QCRYPTO_CIPHER_ALG_AES_128, + block->niv =3D qcrypto_cipher_get_iv_len(QCRYPTO_CIPHER_ALGO_AES_128, QCRYPTO_CIPHER_MODE_CBC); block->ivgen =3D qcrypto_ivgen_new(QCRYPTO_IVGEN_ALG_PLAIN64, 0, 0, NULL, 0, errp); @@ -71,7 +71,7 @@ qcrypto_block_qcow_init(QCryptoBlock *block, goto fail; } =20 - ret =3D qcrypto_block_init_cipher(block, QCRYPTO_CIPHER_ALG_AES_128, + ret =3D qcrypto_block_init_cipher(block, QCRYPTO_CIPHER_ALGO_AES_128, QCRYPTO_CIPHER_MODE_CBC, keybuf, G_N_ELEMENTS(keybuf), errp); diff --git a/crypto/block.c b/crypto/block.c index 9846caa591..96c83e60b9 100644 --- a/crypto/block.c +++ b/crypto/block.c @@ -267,7 +267,7 @@ static void qcrypto_block_push_cipher(QCryptoBlock *blo= ck, =20 =20 int qcrypto_block_init_cipher(QCryptoBlock *block, - QCryptoCipherAlgorithm alg, + QCryptoCipherAlgo alg, QCryptoCipherMode mode, const uint8_t *key, size_t nkey, Error **errp) diff --git a/crypto/cipher-afalg.c b/crypto/cipher-afalg.c index 3df8fc54c0..c08eb7a39b 100644 --- a/crypto/cipher-afalg.c +++ b/crypto/cipher-afalg.c @@ -18,7 +18,7 @@ =20 =20 static char * -qcrypto_afalg_cipher_format_name(QCryptoCipherAlgorithm alg, +qcrypto_afalg_cipher_format_name(QCryptoCipherAlgo alg, QCryptoCipherMode mode, Error **errp) { @@ -27,22 +27,22 @@ qcrypto_afalg_cipher_format_name(QCryptoCipherAlgorithm= alg, const char *mode_name; =20 switch (alg) { - case QCRYPTO_CIPHER_ALG_AES_128: - case QCRYPTO_CIPHER_ALG_AES_192: - case QCRYPTO_CIPHER_ALG_AES_256: + case QCRYPTO_CIPHER_ALGO_AES_128: + case QCRYPTO_CIPHER_ALGO_AES_192: + case QCRYPTO_CIPHER_ALGO_AES_256: alg_name =3D "aes"; break; - case QCRYPTO_CIPHER_ALG_CAST5_128: + case QCRYPTO_CIPHER_ALGO_CAST5_128: alg_name =3D "cast5"; break; - case QCRYPTO_CIPHER_ALG_SERPENT_128: - case QCRYPTO_CIPHER_ALG_SERPENT_192: - case QCRYPTO_CIPHER_ALG_SERPENT_256: + case QCRYPTO_CIPHER_ALGO_SERPENT_128: + case QCRYPTO_CIPHER_ALGO_SERPENT_192: + case QCRYPTO_CIPHER_ALGO_SERPENT_256: alg_name =3D "serpent"; break; - case QCRYPTO_CIPHER_ALG_TWOFISH_128: - case QCRYPTO_CIPHER_ALG_TWOFISH_192: - case QCRYPTO_CIPHER_ALG_TWOFISH_256: + case QCRYPTO_CIPHER_ALGO_TWOFISH_128: + case QCRYPTO_CIPHER_ALGO_TWOFISH_192: + case QCRYPTO_CIPHER_ALGO_TWOFISH_256: alg_name =3D "twofish"; break; =20 @@ -60,7 +60,7 @@ qcrypto_afalg_cipher_format_name(QCryptoCipherAlgorithm a= lg, static const struct QCryptoCipherDriver qcrypto_cipher_afalg_driver; =20 QCryptoCipher * -qcrypto_afalg_cipher_ctx_new(QCryptoCipherAlgorithm alg, +qcrypto_afalg_cipher_ctx_new(QCryptoCipherAlgo alg, QCryptoCipherMode mode, const uint8_t *key, size_t nkey, Error **errp) diff --git a/crypto/cipher.c b/crypto/cipher.c index 5f512768ea..c14a8b8a11 100644 --- a/crypto/cipher.c +++ b/crypto/cipher.c @@ -25,39 +25,39 @@ #include "cipherpriv.h" =20 =20 -static const size_t alg_key_len[QCRYPTO_CIPHER_ALG__MAX] =3D { - [QCRYPTO_CIPHER_ALG_AES_128] =3D 16, - [QCRYPTO_CIPHER_ALG_AES_192] =3D 24, - [QCRYPTO_CIPHER_ALG_AES_256] =3D 32, - [QCRYPTO_CIPHER_ALG_DES] =3D 8, - [QCRYPTO_CIPHER_ALG_3DES] =3D 24, - [QCRYPTO_CIPHER_ALG_CAST5_128] =3D 16, - [QCRYPTO_CIPHER_ALG_SERPENT_128] =3D 16, - [QCRYPTO_CIPHER_ALG_SERPENT_192] =3D 24, - [QCRYPTO_CIPHER_ALG_SERPENT_256] =3D 32, - [QCRYPTO_CIPHER_ALG_TWOFISH_128] =3D 16, - [QCRYPTO_CIPHER_ALG_TWOFISH_192] =3D 24, - [QCRYPTO_CIPHER_ALG_TWOFISH_256] =3D 32, +static const size_t alg_key_len[QCRYPTO_CIPHER_ALGO__MAX] =3D { + [QCRYPTO_CIPHER_ALGO_AES_128] =3D 16, + [QCRYPTO_CIPHER_ALGO_AES_192] =3D 24, + [QCRYPTO_CIPHER_ALGO_AES_256] =3D 32, + [QCRYPTO_CIPHER_ALGO_DES] =3D 8, + [QCRYPTO_CIPHER_ALGO_3DES] =3D 24, + [QCRYPTO_CIPHER_ALGO_CAST5_128] =3D 16, + [QCRYPTO_CIPHER_ALGO_SERPENT_128] =3D 16, + [QCRYPTO_CIPHER_ALGO_SERPENT_192] =3D 24, + [QCRYPTO_CIPHER_ALGO_SERPENT_256] =3D 32, + [QCRYPTO_CIPHER_ALGO_TWOFISH_128] =3D 16, + [QCRYPTO_CIPHER_ALGO_TWOFISH_192] =3D 24, + [QCRYPTO_CIPHER_ALGO_TWOFISH_256] =3D 32, #ifdef CONFIG_CRYPTO_SM4 - [QCRYPTO_CIPHER_ALG_SM4] =3D 16, + [QCRYPTO_CIPHER_ALGO_SM4] =3D 16, #endif }; =20 -static const size_t alg_block_len[QCRYPTO_CIPHER_ALG__MAX] =3D { - [QCRYPTO_CIPHER_ALG_AES_128] =3D 16, - [QCRYPTO_CIPHER_ALG_AES_192] =3D 16, - [QCRYPTO_CIPHER_ALG_AES_256] =3D 16, - [QCRYPTO_CIPHER_ALG_DES] =3D 8, - [QCRYPTO_CIPHER_ALG_3DES] =3D 8, - [QCRYPTO_CIPHER_ALG_CAST5_128] =3D 8, - [QCRYPTO_CIPHER_ALG_SERPENT_128] =3D 16, - [QCRYPTO_CIPHER_ALG_SERPENT_192] =3D 16, - [QCRYPTO_CIPHER_ALG_SERPENT_256] =3D 16, - [QCRYPTO_CIPHER_ALG_TWOFISH_128] =3D 16, - [QCRYPTO_CIPHER_ALG_TWOFISH_192] =3D 16, - [QCRYPTO_CIPHER_ALG_TWOFISH_256] =3D 16, +static const size_t alg_block_len[QCRYPTO_CIPHER_ALGO__MAX] =3D { + [QCRYPTO_CIPHER_ALGO_AES_128] =3D 16, + [QCRYPTO_CIPHER_ALGO_AES_192] =3D 16, + [QCRYPTO_CIPHER_ALGO_AES_256] =3D 16, + [QCRYPTO_CIPHER_ALGO_DES] =3D 8, + [QCRYPTO_CIPHER_ALGO_3DES] =3D 8, + [QCRYPTO_CIPHER_ALGO_CAST5_128] =3D 8, + [QCRYPTO_CIPHER_ALGO_SERPENT_128] =3D 16, + [QCRYPTO_CIPHER_ALGO_SERPENT_192] =3D 16, + [QCRYPTO_CIPHER_ALGO_SERPENT_256] =3D 16, + [QCRYPTO_CIPHER_ALGO_TWOFISH_128] =3D 16, + [QCRYPTO_CIPHER_ALGO_TWOFISH_192] =3D 16, + [QCRYPTO_CIPHER_ALGO_TWOFISH_256] =3D 16, #ifdef CONFIG_CRYPTO_SM4 - [QCRYPTO_CIPHER_ALG_SM4] =3D 16, + [QCRYPTO_CIPHER_ALGO_SM4] =3D 16, #endif }; =20 @@ -69,21 +69,21 @@ static const bool mode_need_iv[QCRYPTO_CIPHER_MODE__MAX= ] =3D { }; =20 =20 -size_t qcrypto_cipher_get_block_len(QCryptoCipherAlgorithm alg) +size_t qcrypto_cipher_get_block_len(QCryptoCipherAlgo alg) { assert(alg < G_N_ELEMENTS(alg_key_len)); return alg_block_len[alg]; } =20 =20 -size_t qcrypto_cipher_get_key_len(QCryptoCipherAlgorithm alg) +size_t qcrypto_cipher_get_key_len(QCryptoCipherAlgo alg) { assert(alg < G_N_ELEMENTS(alg_key_len)); return alg_key_len[alg]; } =20 =20 -size_t qcrypto_cipher_get_iv_len(QCryptoCipherAlgorithm alg, +size_t qcrypto_cipher_get_iv_len(QCryptoCipherAlgo alg, QCryptoCipherMode mode) { if (alg >=3D G_N_ELEMENTS(alg_block_len)) { @@ -101,20 +101,20 @@ size_t qcrypto_cipher_get_iv_len(QCryptoCipherAlgorit= hm alg, =20 =20 static bool -qcrypto_cipher_validate_key_length(QCryptoCipherAlgorithm alg, +qcrypto_cipher_validate_key_length(QCryptoCipherAlgo alg, QCryptoCipherMode mode, size_t nkey, Error **errp) { - if ((unsigned)alg >=3D QCRYPTO_CIPHER_ALG__MAX) { + if ((unsigned)alg >=3D QCRYPTO_CIPHER_ALGO__MAX) { error_setg(errp, "Cipher algorithm %d out of range", alg); return false; } =20 if (mode =3D=3D QCRYPTO_CIPHER_MODE_XTS) { - if (alg =3D=3D QCRYPTO_CIPHER_ALG_DES || - alg =3D=3D QCRYPTO_CIPHER_ALG_3DES) { + if (alg =3D=3D QCRYPTO_CIPHER_ALGO_DES || + alg =3D=3D QCRYPTO_CIPHER_ALGO_3DES) { error_setg(errp, "XTS mode not compatible with DES/3DES"); return false; } @@ -148,7 +148,7 @@ qcrypto_cipher_validate_key_length(QCryptoCipherAlgorit= hm alg, #include "cipher-builtin.c.inc" #endif =20 -QCryptoCipher *qcrypto_cipher_new(QCryptoCipherAlgorithm alg, +QCryptoCipher *qcrypto_cipher_new(QCryptoCipherAlgo alg, QCryptoCipherMode mode, const uint8_t *key, size_t nkey, Error **errp) diff --git a/crypto/ivgen.c b/crypto/ivgen.c index 080846cb74..ec0cb1a25b 100644 --- a/crypto/ivgen.c +++ b/crypto/ivgen.c @@ -28,7 +28,7 @@ =20 =20 QCryptoIVGen *qcrypto_ivgen_new(QCryptoIVGenAlgorithm alg, - QCryptoCipherAlgorithm cipheralg, + QCryptoCipherAlgo cipheralg, QCryptoHashAlgo hash, const uint8_t *key, size_t nkey, Error **errp) @@ -79,7 +79,7 @@ QCryptoIVGenAlgorithm qcrypto_ivgen_get_algorithm(QCrypto= IVGen *ivgen) } =20 =20 -QCryptoCipherAlgorithm qcrypto_ivgen_get_cipher(QCryptoIVGen *ivgen) +QCryptoCipherAlgo qcrypto_ivgen_get_cipher(QCryptoIVGen *ivgen) { return ivgen->cipher; } diff --git a/crypto/secret_common.c b/crypto/secret_common.c index 3441c44ca8..2c141107a5 100644 --- a/crypto/secret_common.c +++ b/crypto/secret_common.c @@ -71,7 +71,7 @@ static void qcrypto_secret_decrypt(QCryptoSecretCommon *s= ecret, return; } =20 - aes =3D qcrypto_cipher_new(QCRYPTO_CIPHER_ALG_AES_256, + aes =3D qcrypto_cipher_new(QCRYPTO_CIPHER_ALGO_AES_256, QCRYPTO_CIPHER_MODE_CBC, key, keylen, errp); diff --git a/tests/bench/benchmark-crypto-cipher.c b/tests/bench/benchmark-= crypto-cipher.c index c04f0a0fba..889a29ba5c 100644 --- a/tests/bench/benchmark-crypto-cipher.c +++ b/tests/bench/benchmark-crypto-cipher.c @@ -17,7 +17,7 @@ =20 static void test_cipher_speed(size_t chunk_size, QCryptoCipherMode mode, - QCryptoCipherAlgorithm alg) + QCryptoCipherAlgo alg) { QCryptoCipher *cipher; Error *err =3D NULL; @@ -71,7 +71,7 @@ static void test_cipher_speed(size_t chunk_size, g_test_timer_elapsed(); =20 g_test_message("enc(%s-%s) chunk %zu bytes %.2f MB/sec ", - QCryptoCipherAlgorithm_str(alg), + QCryptoCipherAlgo_str(alg), QCryptoCipherMode_str(mode), chunk_size, (double)total / MiB / g_test_timer_last()); =20 @@ -88,7 +88,7 @@ static void test_cipher_speed(size_t chunk_size, g_test_timer_elapsed(); =20 g_test_message("dec(%s-%s) chunk %zu bytes %.2f MB/sec ", - QCryptoCipherAlgorithm_str(alg), + QCryptoCipherAlgo_str(alg), QCryptoCipherMode_str(mode), chunk_size, (double)total / MiB / g_test_timer_last()); =20 @@ -105,7 +105,7 @@ static void test_cipher_speed_ecb_aes_128(const void *o= paque) size_t chunk_size =3D (size_t)opaque; test_cipher_speed(chunk_size, QCRYPTO_CIPHER_MODE_ECB, - QCRYPTO_CIPHER_ALG_AES_128); + QCRYPTO_CIPHER_ALGO_AES_128); } =20 static void test_cipher_speed_ecb_aes_256(const void *opaque) @@ -113,7 +113,7 @@ static void test_cipher_speed_ecb_aes_256(const void *o= paque) size_t chunk_size =3D (size_t)opaque; test_cipher_speed(chunk_size, QCRYPTO_CIPHER_MODE_ECB, - QCRYPTO_CIPHER_ALG_AES_256); + QCRYPTO_CIPHER_ALGO_AES_256); } =20 static void test_cipher_speed_cbc_aes_128(const void *opaque) @@ -121,7 +121,7 @@ static void test_cipher_speed_cbc_aes_128(const void *o= paque) size_t chunk_size =3D (size_t)opaque; test_cipher_speed(chunk_size, QCRYPTO_CIPHER_MODE_CBC, - QCRYPTO_CIPHER_ALG_AES_128); + QCRYPTO_CIPHER_ALGO_AES_128); } =20 static void test_cipher_speed_cbc_aes_256(const void *opaque) @@ -129,7 +129,7 @@ static void test_cipher_speed_cbc_aes_256(const void *o= paque) size_t chunk_size =3D (size_t)opaque; test_cipher_speed(chunk_size, QCRYPTO_CIPHER_MODE_CBC, - QCRYPTO_CIPHER_ALG_AES_256); + QCRYPTO_CIPHER_ALGO_AES_256); } =20 static void test_cipher_speed_ctr_aes_128(const void *opaque) @@ -137,7 +137,7 @@ static void test_cipher_speed_ctr_aes_128(const void *o= paque) size_t chunk_size =3D (size_t)opaque; test_cipher_speed(chunk_size, QCRYPTO_CIPHER_MODE_CTR, - QCRYPTO_CIPHER_ALG_AES_128); + QCRYPTO_CIPHER_ALGO_AES_128); } =20 static void test_cipher_speed_ctr_aes_256(const void *opaque) @@ -145,7 +145,7 @@ static void test_cipher_speed_ctr_aes_256(const void *o= paque) size_t chunk_size =3D (size_t)opaque; test_cipher_speed(chunk_size, QCRYPTO_CIPHER_MODE_CTR, - QCRYPTO_CIPHER_ALG_AES_256); + QCRYPTO_CIPHER_ALGO_AES_256); } =20 static void test_cipher_speed_xts_aes_128(const void *opaque) @@ -153,7 +153,7 @@ static void test_cipher_speed_xts_aes_128(const void *o= paque) size_t chunk_size =3D (size_t)opaque; test_cipher_speed(chunk_size, QCRYPTO_CIPHER_MODE_XTS, - QCRYPTO_CIPHER_ALG_AES_128); + QCRYPTO_CIPHER_ALGO_AES_128); } =20 static void test_cipher_speed_xts_aes_256(const void *opaque) @@ -161,7 +161,7 @@ static void test_cipher_speed_xts_aes_256(const void *o= paque) size_t chunk_size =3D (size_t)opaque; test_cipher_speed(chunk_size, QCRYPTO_CIPHER_MODE_XTS, - QCRYPTO_CIPHER_ALG_AES_256); + QCRYPTO_CIPHER_ALGO_AES_256); } =20 =20 diff --git a/tests/unit/test-crypto-block.c b/tests/unit/test-crypto-block.c index c2f5fe7b25..1a0d329368 100644 --- a/tests/unit/test-crypto-block.c +++ b/tests/unit/test-crypto-block.c @@ -77,7 +77,7 @@ static QCryptoBlockCreateOptions luks_create_opts_aes256_= cbc_plain64 =3D { .u.luks =3D { .key_secret =3D (char *)"sec0", .has_cipher_alg =3D true, - .cipher_alg =3D QCRYPTO_CIPHER_ALG_AES_256, + .cipher_alg =3D QCRYPTO_CIPHER_ALGO_AES_256, .has_cipher_mode =3D true, .cipher_mode =3D QCRYPTO_CIPHER_MODE_CBC, .has_ivgen_alg =3D true, @@ -91,7 +91,7 @@ static QCryptoBlockCreateOptions luks_create_opts_aes256_= cbc_essiv =3D { .u.luks =3D { .key_secret =3D (char *)"sec0", .has_cipher_alg =3D true, - .cipher_alg =3D QCRYPTO_CIPHER_ALG_AES_256, + .cipher_alg =3D QCRYPTO_CIPHER_ALGO_AES_256, .has_cipher_mode =3D true, .cipher_mode =3D QCRYPTO_CIPHER_MODE_CBC, .has_ivgen_alg =3D true, @@ -112,7 +112,7 @@ static struct QCryptoBlockTestData { =20 bool expect_header; =20 - QCryptoCipherAlgorithm cipher_alg; + QCryptoCipherAlgo cipher_alg; QCryptoCipherMode cipher_mode; QCryptoHashAlgo hash_alg; =20 @@ -128,7 +128,7 @@ static struct QCryptoBlockTestData { =20 .expect_header =3D false, =20 - .cipher_alg =3D QCRYPTO_CIPHER_ALG_AES_128, + .cipher_alg =3D QCRYPTO_CIPHER_ALGO_AES_128, .cipher_mode =3D QCRYPTO_CIPHER_MODE_CBC, =20 .ivgen_alg =3D QCRYPTO_IVGEN_ALG_PLAIN64, @@ -141,7 +141,7 @@ static struct QCryptoBlockTestData { =20 .expect_header =3D true, =20 - .cipher_alg =3D QCRYPTO_CIPHER_ALG_AES_256, + .cipher_alg =3D QCRYPTO_CIPHER_ALGO_AES_256, .cipher_mode =3D QCRYPTO_CIPHER_MODE_XTS, .hash_alg =3D QCRYPTO_HASH_ALGO_SHA256, =20 @@ -156,7 +156,7 @@ static struct QCryptoBlockTestData { =20 .expect_header =3D true, =20 - .cipher_alg =3D QCRYPTO_CIPHER_ALG_AES_256, + .cipher_alg =3D QCRYPTO_CIPHER_ALGO_AES_256, .cipher_mode =3D QCRYPTO_CIPHER_MODE_CBC, .hash_alg =3D QCRYPTO_HASH_ALGO_SHA256, =20 @@ -171,7 +171,7 @@ static struct QCryptoBlockTestData { =20 .expect_header =3D true, =20 - .cipher_alg =3D QCRYPTO_CIPHER_ALG_AES_256, + .cipher_alg =3D QCRYPTO_CIPHER_ALGO_AES_256, .cipher_mode =3D QCRYPTO_CIPHER_MODE_CBC, .hash_alg =3D QCRYPTO_HASH_ALGO_SHA1, =20 diff --git a/tests/unit/test-crypto-cipher.c b/tests/unit/test-crypto-ciphe= r.c index f5152e569d..b328b482e1 100644 --- a/tests/unit/test-crypto-cipher.c +++ b/tests/unit/test-crypto-cipher.c @@ -27,7 +27,7 @@ typedef struct QCryptoCipherTestData QCryptoCipherTestData; struct QCryptoCipherTestData { const char *path; - QCryptoCipherAlgorithm alg; + QCryptoCipherAlgo alg; QCryptoCipherMode mode; const char *key; const char *plaintext; @@ -43,7 +43,7 @@ static QCryptoCipherTestData test_data[] =3D { { /* NIST F.1.1 ECB-AES128.Encrypt */ .path =3D "/crypto/cipher/aes-ecb-128", - .alg =3D QCRYPTO_CIPHER_ALG_AES_128, + .alg =3D QCRYPTO_CIPHER_ALGO_AES_128, .mode =3D QCRYPTO_CIPHER_MODE_ECB, .key =3D "2b7e151628aed2a6abf7158809cf4f3c", .plaintext =3D @@ -60,7 +60,7 @@ static QCryptoCipherTestData test_data[] =3D { { /* NIST F.1.3 ECB-AES192.Encrypt */ .path =3D "/crypto/cipher/aes-ecb-192", - .alg =3D QCRYPTO_CIPHER_ALG_AES_192, + .alg =3D QCRYPTO_CIPHER_ALGO_AES_192, .mode =3D QCRYPTO_CIPHER_MODE_ECB, .key =3D "8e73b0f7da0e6452c810f32b809079e562f8ead2522c6b7b", .plaintext =3D @@ -77,7 +77,7 @@ static QCryptoCipherTestData test_data[] =3D { { /* NIST F.1.5 ECB-AES256.Encrypt */ .path =3D "/crypto/cipher/aes-ecb-256", - .alg =3D QCRYPTO_CIPHER_ALG_AES_256, + .alg =3D QCRYPTO_CIPHER_ALGO_AES_256, .mode =3D QCRYPTO_CIPHER_MODE_ECB, .key =3D "603deb1015ca71be2b73aef0857d7781" @@ -96,7 +96,7 @@ static QCryptoCipherTestData test_data[] =3D { { /* NIST F.2.1 CBC-AES128.Encrypt */ .path =3D "/crypto/cipher/aes-cbc-128", - .alg =3D QCRYPTO_CIPHER_ALG_AES_128, + .alg =3D QCRYPTO_CIPHER_ALGO_AES_128, .mode =3D QCRYPTO_CIPHER_MODE_CBC, .key =3D "2b7e151628aed2a6abf7158809cf4f3c", .iv =3D "000102030405060708090a0b0c0d0e0f", @@ -114,7 +114,7 @@ static QCryptoCipherTestData test_data[] =3D { { /* NIST F.2.3 CBC-AES128.Encrypt */ .path =3D "/crypto/cipher/aes-cbc-192", - .alg =3D QCRYPTO_CIPHER_ALG_AES_192, + .alg =3D QCRYPTO_CIPHER_ALGO_AES_192, .mode =3D QCRYPTO_CIPHER_MODE_CBC, .key =3D "8e73b0f7da0e6452c810f32b809079e562f8ead2522c6b7b", .iv =3D "000102030405060708090a0b0c0d0e0f", @@ -132,7 +132,7 @@ static QCryptoCipherTestData test_data[] =3D { { /* NIST F.2.5 CBC-AES128.Encrypt */ .path =3D "/crypto/cipher/aes-cbc-256", - .alg =3D QCRYPTO_CIPHER_ALG_AES_256, + .alg =3D QCRYPTO_CIPHER_ALGO_AES_256, .mode =3D QCRYPTO_CIPHER_MODE_CBC, .key =3D "603deb1015ca71be2b73aef0857d7781" @@ -156,7 +156,7 @@ static QCryptoCipherTestData test_data[] =3D { * ciphertext in ECB and CBC modes */ .path =3D "/crypto/cipher/des-ecb-56-one-block", - .alg =3D QCRYPTO_CIPHER_ALG_DES, + .alg =3D QCRYPTO_CIPHER_ALGO_DES, .mode =3D QCRYPTO_CIPHER_MODE_ECB, .key =3D "80c4a2e691d5b3f7", .plaintext =3D "70617373776f7264", @@ -165,7 +165,7 @@ static QCryptoCipherTestData test_data[] =3D { { /* See previous comment */ .path =3D "/crypto/cipher/des-cbc-56-one-block", - .alg =3D QCRYPTO_CIPHER_ALG_DES, + .alg =3D QCRYPTO_CIPHER_ALGO_DES, .mode =3D QCRYPTO_CIPHER_MODE_CBC, .key =3D "80c4a2e691d5b3f7", .iv =3D "0000000000000000", @@ -174,7 +174,7 @@ static QCryptoCipherTestData test_data[] =3D { }, { .path =3D "/crypto/cipher/des-ecb-56", - .alg =3D QCRYPTO_CIPHER_ALG_DES, + .alg =3D QCRYPTO_CIPHER_ALGO_DES, .mode =3D QCRYPTO_CIPHER_MODE_ECB, .key =3D "80c4a2e691d5b3f7", .plaintext =3D @@ -191,7 +191,7 @@ static QCryptoCipherTestData test_data[] =3D { { /* Borrowed from linux-kernel crypto/testmgr.h */ .path =3D "/crypto/cipher/3des-cbc", - .alg =3D QCRYPTO_CIPHER_ALG_3DES, + .alg =3D QCRYPTO_CIPHER_ALGO_3DES, .mode =3D QCRYPTO_CIPHER_MODE_CBC, .key =3D "e9c0ff2e760b6424444d995a12d640c0" @@ -220,7 +220,7 @@ static QCryptoCipherTestData test_data[] =3D { { /* Borrowed from linux-kernel crypto/testmgr.h */ .path =3D "/crypto/cipher/3des-ecb", - .alg =3D QCRYPTO_CIPHER_ALG_3DES, + .alg =3D QCRYPTO_CIPHER_ALGO_3DES, .mode =3D QCRYPTO_CIPHER_MODE_ECB, .key =3D "0123456789abcdef5555555555555555" @@ -233,7 +233,7 @@ static QCryptoCipherTestData test_data[] =3D { { /* Borrowed from linux-kernel crypto/testmgr.h */ .path =3D "/crypto/cipher/3des-ctr", - .alg =3D QCRYPTO_CIPHER_ALG_3DES, + .alg =3D QCRYPTO_CIPHER_ALGO_3DES, .mode =3D QCRYPTO_CIPHER_MODE_CTR, .key =3D "9cd6f39cb95a67005a67002dceeb2dce" @@ -308,7 +308,7 @@ static QCryptoCipherTestData test_data[] =3D { { /* RFC 2144, Appendix B.1 */ .path =3D "/crypto/cipher/cast5-128", - .alg =3D QCRYPTO_CIPHER_ALG_CAST5_128, + .alg =3D QCRYPTO_CIPHER_ALGO_CAST5_128, .mode =3D QCRYPTO_CIPHER_MODE_ECB, .key =3D "0123456712345678234567893456789A", .plaintext =3D "0123456789abcdef", @@ -317,7 +317,7 @@ static QCryptoCipherTestData test_data[] =3D { { /* libgcrypt serpent.c */ .path =3D "/crypto/cipher/serpent-128", - .alg =3D QCRYPTO_CIPHER_ALG_SERPENT_128, + .alg =3D QCRYPTO_CIPHER_ALGO_SERPENT_128, .mode =3D QCRYPTO_CIPHER_MODE_ECB, .key =3D "00000000000000000000000000000000", .plaintext =3D "d29d576fcea3a3a7ed9099f29273d78e", @@ -326,7 +326,7 @@ static QCryptoCipherTestData test_data[] =3D { { /* libgcrypt serpent.c */ .path =3D "/crypto/cipher/serpent-192", - .alg =3D QCRYPTO_CIPHER_ALG_SERPENT_192, + .alg =3D QCRYPTO_CIPHER_ALGO_SERPENT_192, .mode =3D QCRYPTO_CIPHER_MODE_ECB, .key =3D "00000000000000000000000000000000" "0000000000000000", @@ -336,7 +336,7 @@ static QCryptoCipherTestData test_data[] =3D { { /* libgcrypt serpent.c */ .path =3D "/crypto/cipher/serpent-256a", - .alg =3D QCRYPTO_CIPHER_ALG_SERPENT_256, + .alg =3D QCRYPTO_CIPHER_ALGO_SERPENT_256, .mode =3D QCRYPTO_CIPHER_MODE_ECB, .key =3D "00000000000000000000000000000000" "00000000000000000000000000000000", @@ -346,7 +346,7 @@ static QCryptoCipherTestData test_data[] =3D { { /* libgcrypt serpent.c */ .path =3D "/crypto/cipher/serpent-256b", - .alg =3D QCRYPTO_CIPHER_ALG_SERPENT_256, + .alg =3D QCRYPTO_CIPHER_ALGO_SERPENT_256, .mode =3D QCRYPTO_CIPHER_MODE_ECB, .key =3D "00000000000000000000000000000000" "00000000000000000000000000000000", @@ -356,7 +356,7 @@ static QCryptoCipherTestData test_data[] =3D { { /* Twofish paper "Known Answer Test" */ .path =3D "/crypto/cipher/twofish-128", - .alg =3D QCRYPTO_CIPHER_ALG_TWOFISH_128, + .alg =3D QCRYPTO_CIPHER_ALGO_TWOFISH_128, .mode =3D QCRYPTO_CIPHER_MODE_ECB, .key =3D "d491db16e7b1c39e86cb086b789f5419", .plaintext =3D "019f9809de1711858faac3a3ba20fbc3", @@ -365,7 +365,7 @@ static QCryptoCipherTestData test_data[] =3D { { /* Twofish paper "Known Answer Test", I=3D3 */ .path =3D "/crypto/cipher/twofish-192", - .alg =3D QCRYPTO_CIPHER_ALG_TWOFISH_192, + .alg =3D QCRYPTO_CIPHER_ALGO_TWOFISH_192, .mode =3D QCRYPTO_CIPHER_MODE_ECB, .key =3D "88b2b2706b105e36b446bb6d731a1e88" "efa71f788965bd44", @@ -375,7 +375,7 @@ static QCryptoCipherTestData test_data[] =3D { { /* Twofish paper "Known Answer Test", I=3D4 */ .path =3D "/crypto/cipher/twofish-256", - .alg =3D QCRYPTO_CIPHER_ALG_TWOFISH_256, + .alg =3D QCRYPTO_CIPHER_ALGO_TWOFISH_256, .mode =3D QCRYPTO_CIPHER_MODE_ECB, .key =3D "d43bb7556ea32e46f2a282b7d45b4e0d" "57ff739d4dc92c1bd7fc01700cc8216f", @@ -386,7 +386,7 @@ static QCryptoCipherTestData test_data[] =3D { { /* SM4, GB/T 32907-2016, Appendix A.1 */ .path =3D "/crypto/cipher/sm4", - .alg =3D QCRYPTO_CIPHER_ALG_SM4, + .alg =3D QCRYPTO_CIPHER_ALGO_SM4, .mode =3D QCRYPTO_CIPHER_MODE_ECB, .key =3D "0123456789abcdeffedcba9876543210", .plaintext =3D @@ -398,7 +398,7 @@ static QCryptoCipherTestData test_data[] =3D { { /* #1 32 byte key, 32 byte PTX */ .path =3D "/crypto/cipher/aes-xts-128-1", - .alg =3D QCRYPTO_CIPHER_ALG_AES_128, + .alg =3D QCRYPTO_CIPHER_ALGO_AES_128, .mode =3D QCRYPTO_CIPHER_MODE_XTS, .key =3D "00000000000000000000000000000000" @@ -415,7 +415,7 @@ static QCryptoCipherTestData test_data[] =3D { { /* #2, 32 byte key, 32 byte PTX */ .path =3D "/crypto/cipher/aes-xts-128-2", - .alg =3D QCRYPTO_CIPHER_ALG_AES_128, + .alg =3D QCRYPTO_CIPHER_ALGO_AES_128, .mode =3D QCRYPTO_CIPHER_MODE_XTS, .key =3D "11111111111111111111111111111111" @@ -432,7 +432,7 @@ static QCryptoCipherTestData test_data[] =3D { { /* #5 from xts.7, 32 byte key, 32 byte PTX */ .path =3D "/crypto/cipher/aes-xts-128-3", - .alg =3D QCRYPTO_CIPHER_ALG_AES_128, + .alg =3D QCRYPTO_CIPHER_ALGO_AES_128, .mode =3D QCRYPTO_CIPHER_MODE_XTS, .key =3D "fffefdfcfbfaf9f8f7f6f5f4f3f2f1f0" @@ -449,7 +449,7 @@ static QCryptoCipherTestData test_data[] =3D { { /* #4, 32 byte key, 512 byte PTX */ .path =3D "/crypto/cipher/aes-xts-128-4", - .alg =3D QCRYPTO_CIPHER_ALG_AES_128, + .alg =3D QCRYPTO_CIPHER_ALGO_AES_128, .mode =3D QCRYPTO_CIPHER_MODE_XTS, .key =3D "27182818284590452353602874713526" @@ -528,7 +528,7 @@ static QCryptoCipherTestData test_data[] =3D { * which is incompatible with XTS */ .path =3D "/crypto/cipher/cast5-xts-128", - .alg =3D QCRYPTO_CIPHER_ALG_CAST5_128, + .alg =3D QCRYPTO_CIPHER_ALGO_CAST5_128, .mode =3D QCRYPTO_CIPHER_MODE_XTS, .key =3D "27182818284590452353602874713526" @@ -537,7 +537,7 @@ static QCryptoCipherTestData test_data[] =3D { { /* NIST F.5.1 CTR-AES128.Encrypt */ .path =3D "/crypto/cipher/aes-ctr-128", - .alg =3D QCRYPTO_CIPHER_ALG_AES_128, + .alg =3D QCRYPTO_CIPHER_ALGO_AES_128, .mode =3D QCRYPTO_CIPHER_MODE_CTR, .key =3D "2b7e151628aed2a6abf7158809cf4f3c", .iv =3D "f0f1f2f3f4f5f6f7f8f9fafbfcfdfeff", @@ -555,7 +555,7 @@ static QCryptoCipherTestData test_data[] =3D { { /* NIST F.5.3 CTR-AES192.Encrypt */ .path =3D "/crypto/cipher/aes-ctr-192", - .alg =3D QCRYPTO_CIPHER_ALG_AES_192, + .alg =3D QCRYPTO_CIPHER_ALGO_AES_192, .mode =3D QCRYPTO_CIPHER_MODE_CTR, .key =3D "8e73b0f7da0e6452c810f32b809079e562f8ead2522c6b7b", .iv =3D "f0f1f2f3f4f5f6f7f8f9fafbfcfdfeff", @@ -573,7 +573,7 @@ static QCryptoCipherTestData test_data[] =3D { { /* NIST F.5.5 CTR-AES256.Encrypt */ .path =3D "/crypto/cipher/aes-ctr-256", - .alg =3D QCRYPTO_CIPHER_ALG_AES_256, + .alg =3D QCRYPTO_CIPHER_ALGO_AES_256, .mode =3D QCRYPTO_CIPHER_MODE_CTR, .key =3D "603deb1015ca71be2b73aef0857d7781" "1f352c073b6108d72d9810a30914dff4", @@ -750,7 +750,7 @@ static void test_cipher_null_iv(void) uint8_t ciphertext[32] =3D { 0 }; =20 cipher =3D qcrypto_cipher_new( - QCRYPTO_CIPHER_ALG_AES_256, + QCRYPTO_CIPHER_ALGO_AES_256, QCRYPTO_CIPHER_MODE_CBC, key, sizeof(key), &error_abort); @@ -779,7 +779,7 @@ static void test_cipher_short_plaintext(void) int ret; =20 cipher =3D qcrypto_cipher_new( - QCRYPTO_CIPHER_ALG_AES_256, + QCRYPTO_CIPHER_ALGO_AES_256, QCRYPTO_CIPHER_MODE_CBC, key, sizeof(key), &error_abort); @@ -823,7 +823,7 @@ int main(int argc, char **argv) g_test_add_data_func(test_data[i].path, &test_data[i], test_ci= pher); } else { g_printerr("# skip unsupported %s:%s\n", - QCryptoCipherAlgorithm_str(test_data[i].alg), + QCryptoCipherAlgo_str(test_data[i].alg), QCryptoCipherMode_str(test_data[i].mode)); } } diff --git a/tests/unit/test-crypto-ivgen.c b/tests/unit/test-crypto-ivgen.c index 9aa3f6018b..6b4110775a 100644 --- a/tests/unit/test-crypto-ivgen.c +++ b/tests/unit/test-crypto-ivgen.c @@ -28,7 +28,7 @@ struct QCryptoIVGenTestData { uint64_t sector; QCryptoIVGenAlgorithm ivalg; QCryptoHashAlgo hashalg; - QCryptoCipherAlgorithm cipheralg; + QCryptoCipherAlgo cipheralg; const uint8_t *key; size_t nkey; const uint8_t *iv; @@ -93,7 +93,7 @@ struct QCryptoIVGenTestData { "/crypto/ivgen/essiv/1", .sector =3D 0x1, .ivalg =3D QCRYPTO_IVGEN_ALG_ESSIV, - .cipheralg =3D QCRYPTO_CIPHER_ALG_AES_128, + .cipheralg =3D QCRYPTO_CIPHER_ALGO_AES_128, .hashalg =3D QCRYPTO_HASH_ALGO_SHA256, .key =3D (const uint8_t *)"\x00\x01\x02\x03\x04\x05\x06\x07" "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f", @@ -107,7 +107,7 @@ struct QCryptoIVGenTestData { "/crypto/ivgen/essiv/1f2e3d4c", .sector =3D 0x1f2e3d4cULL, .ivalg =3D QCRYPTO_IVGEN_ALG_ESSIV, - .cipheralg =3D QCRYPTO_CIPHER_ALG_AES_128, + .cipheralg =3D QCRYPTO_CIPHER_ALGO_AES_128, .hashalg =3D QCRYPTO_HASH_ALGO_SHA256, .key =3D (const uint8_t *)"\x00\x01\x02\x03\x04\x05\x06\x07" "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f", @@ -121,7 +121,7 @@ struct QCryptoIVGenTestData { "/crypto/ivgen/essiv/1f2e3d4c5b6a7988", .sector =3D 0x1f2e3d4c5b6a7988ULL, .ivalg =3D QCRYPTO_IVGEN_ALG_ESSIV, - .cipheralg =3D QCRYPTO_CIPHER_ALG_AES_128, + .cipheralg =3D QCRYPTO_CIPHER_ALGO_AES_128, .hashalg =3D QCRYPTO_HASH_ALGO_SHA256, .key =3D (const uint8_t *)"\x00\x01\x02\x03\x04\x05\x06\x07" "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f", diff --git a/ui/vnc.c b/ui/vnc.c index 9a17994969..b59af625dd 100644 --- a/ui/vnc.c +++ b/ui/vnc.c @@ -2783,7 +2783,7 @@ static int protocol_client_auth_vnc(VncState *vs, uin= t8_t *data, size_t len) vnc_munge_des_rfb_key(key, sizeof(key)); =20 cipher =3D qcrypto_cipher_new( - QCRYPTO_CIPHER_ALG_DES, + QCRYPTO_CIPHER_ALGO_DES, QCRYPTO_CIPHER_MODE_ECB, key, G_N_ELEMENTS(key), &err); @@ -4064,7 +4064,7 @@ void vnc_display_open(const char *id, Error **errp) } if (password) { if (!qcrypto_cipher_supports( - QCRYPTO_CIPHER_ALG_DES, QCRYPTO_CIPHER_MODE_ECB)) { + QCRYPTO_CIPHER_ALGO_DES, QCRYPTO_CIPHER_MODE_ECB)) { error_setg(errp, "Cipher backend does not support DES algorithm"); goto fail; diff --git a/crypto/cipher-builtin.c.inc b/crypto/cipher-builtin.c.inc index b409089095..da5fcbd9a3 100644 --- a/crypto/cipher-builtin.c.inc +++ b/crypto/cipher-builtin.c.inc @@ -221,13 +221,13 @@ static const struct QCryptoCipherDriver qcrypto_ciphe= r_aes_driver_cbc =3D { .cipher_free =3D qcrypto_cipher_ctx_free, }; =20 -bool qcrypto_cipher_supports(QCryptoCipherAlgorithm alg, +bool qcrypto_cipher_supports(QCryptoCipherAlgo alg, QCryptoCipherMode mode) { switch (alg) { - case QCRYPTO_CIPHER_ALG_AES_128: - case QCRYPTO_CIPHER_ALG_AES_192: - case QCRYPTO_CIPHER_ALG_AES_256: + case QCRYPTO_CIPHER_ALGO_AES_128: + case QCRYPTO_CIPHER_ALGO_AES_192: + case QCRYPTO_CIPHER_ALGO_AES_256: switch (mode) { case QCRYPTO_CIPHER_MODE_ECB: case QCRYPTO_CIPHER_MODE_CBC: @@ -241,7 +241,7 @@ bool qcrypto_cipher_supports(QCryptoCipherAlgorithm alg, } } =20 -static QCryptoCipher *qcrypto_cipher_ctx_new(QCryptoCipherAlgorithm alg, +static QCryptoCipher *qcrypto_cipher_ctx_new(QCryptoCipherAlgo alg, QCryptoCipherMode mode, const uint8_t *key, size_t nkey, @@ -252,9 +252,9 @@ static QCryptoCipher *qcrypto_cipher_ctx_new(QCryptoCip= herAlgorithm alg, } =20 switch (alg) { - case QCRYPTO_CIPHER_ALG_AES_128: - case QCRYPTO_CIPHER_ALG_AES_192: - case QCRYPTO_CIPHER_ALG_AES_256: + case QCRYPTO_CIPHER_ALGO_AES_128: + case QCRYPTO_CIPHER_ALGO_AES_192: + case QCRYPTO_CIPHER_ALGO_AES_256: { QCryptoCipherBuiltinAES *ctx; const QCryptoCipherDriver *drv; @@ -292,7 +292,7 @@ static QCryptoCipher *qcrypto_cipher_ctx_new(QCryptoCip= herAlgorithm alg, default: error_setg(errp, "Unsupported cipher algorithm %s", - QCryptoCipherAlgorithm_str(alg)); + QCryptoCipherAlgo_str(alg)); return NULL; } =20 diff --git a/crypto/cipher-gcrypt.c.inc b/crypto/cipher-gcrypt.c.inc index 4a8314746d..12eb9ddb5a 100644 --- a/crypto/cipher-gcrypt.c.inc +++ b/crypto/cipher-gcrypt.c.inc @@ -20,33 +20,33 @@ =20 #include =20 -static int qcrypto_cipher_alg_to_gcry_alg(QCryptoCipherAlgorithm alg) +static int qcrypto_cipher_alg_to_gcry_alg(QCryptoCipherAlgo alg) { switch (alg) { - case QCRYPTO_CIPHER_ALG_DES: + case QCRYPTO_CIPHER_ALGO_DES: return GCRY_CIPHER_DES; - case QCRYPTO_CIPHER_ALG_3DES: + case QCRYPTO_CIPHER_ALGO_3DES: return GCRY_CIPHER_3DES; - case QCRYPTO_CIPHER_ALG_AES_128: + case QCRYPTO_CIPHER_ALGO_AES_128: return GCRY_CIPHER_AES128; - case QCRYPTO_CIPHER_ALG_AES_192: + case QCRYPTO_CIPHER_ALGO_AES_192: return GCRY_CIPHER_AES192; - case QCRYPTO_CIPHER_ALG_AES_256: + case QCRYPTO_CIPHER_ALGO_AES_256: return GCRY_CIPHER_AES256; - case QCRYPTO_CIPHER_ALG_CAST5_128: + case QCRYPTO_CIPHER_ALGO_CAST5_128: return GCRY_CIPHER_CAST5; - case QCRYPTO_CIPHER_ALG_SERPENT_128: + case QCRYPTO_CIPHER_ALGO_SERPENT_128: return GCRY_CIPHER_SERPENT128; - case QCRYPTO_CIPHER_ALG_SERPENT_192: + case QCRYPTO_CIPHER_ALGO_SERPENT_192: return GCRY_CIPHER_SERPENT192; - case QCRYPTO_CIPHER_ALG_SERPENT_256: + case QCRYPTO_CIPHER_ALGO_SERPENT_256: return GCRY_CIPHER_SERPENT256; - case QCRYPTO_CIPHER_ALG_TWOFISH_128: + case QCRYPTO_CIPHER_ALGO_TWOFISH_128: return GCRY_CIPHER_TWOFISH128; - case QCRYPTO_CIPHER_ALG_TWOFISH_256: + case QCRYPTO_CIPHER_ALGO_TWOFISH_256: return GCRY_CIPHER_TWOFISH; #ifdef CONFIG_CRYPTO_SM4 - case QCRYPTO_CIPHER_ALG_SM4: + case QCRYPTO_CIPHER_ALGO_SM4: return GCRY_CIPHER_SM4; #endif default: @@ -70,23 +70,23 @@ static int qcrypto_cipher_mode_to_gcry_mode(QCryptoCiph= erMode mode) } } =20 -bool qcrypto_cipher_supports(QCryptoCipherAlgorithm alg, +bool qcrypto_cipher_supports(QCryptoCipherAlgo alg, QCryptoCipherMode mode) { switch (alg) { - case QCRYPTO_CIPHER_ALG_DES: - case QCRYPTO_CIPHER_ALG_3DES: - case QCRYPTO_CIPHER_ALG_AES_128: - case QCRYPTO_CIPHER_ALG_AES_192: - case QCRYPTO_CIPHER_ALG_AES_256: - case QCRYPTO_CIPHER_ALG_CAST5_128: - case QCRYPTO_CIPHER_ALG_SERPENT_128: - case QCRYPTO_CIPHER_ALG_SERPENT_192: - case QCRYPTO_CIPHER_ALG_SERPENT_256: - case QCRYPTO_CIPHER_ALG_TWOFISH_128: - case QCRYPTO_CIPHER_ALG_TWOFISH_256: + case QCRYPTO_CIPHER_ALGO_DES: + case QCRYPTO_CIPHER_ALGO_3DES: + case QCRYPTO_CIPHER_ALGO_AES_128: + case QCRYPTO_CIPHER_ALGO_AES_192: + case QCRYPTO_CIPHER_ALGO_AES_256: + case QCRYPTO_CIPHER_ALGO_CAST5_128: + case QCRYPTO_CIPHER_ALGO_SERPENT_128: + case QCRYPTO_CIPHER_ALGO_SERPENT_192: + case QCRYPTO_CIPHER_ALGO_SERPENT_256: + case QCRYPTO_CIPHER_ALGO_TWOFISH_128: + case QCRYPTO_CIPHER_ALGO_TWOFISH_256: #ifdef CONFIG_CRYPTO_SM4 - case QCRYPTO_CIPHER_ALG_SM4: + case QCRYPTO_CIPHER_ALGO_SM4: #endif break; default: @@ -228,7 +228,7 @@ static const struct QCryptoCipherDriver qcrypto_gcrypt_= ctr_driver =3D { .cipher_free =3D qcrypto_gcrypt_ctx_free, }; =20 -static QCryptoCipher *qcrypto_cipher_ctx_new(QCryptoCipherAlgorithm alg, +static QCryptoCipher *qcrypto_cipher_ctx_new(QCryptoCipherAlgo alg, QCryptoCipherMode mode, const uint8_t *key, size_t nkey, @@ -246,7 +246,7 @@ static QCryptoCipher *qcrypto_cipher_ctx_new(QCryptoCip= herAlgorithm alg, gcryalg =3D qcrypto_cipher_alg_to_gcry_alg(alg); if (gcryalg =3D=3D GCRY_CIPHER_NONE) { error_setg(errp, "Unsupported cipher algorithm %s", - QCryptoCipherAlgorithm_str(alg)); + QCryptoCipherAlgo_str(alg)); return NULL; } =20 diff --git a/crypto/cipher-gnutls.c.inc b/crypto/cipher-gnutls.c.inc index d3e231c13c..b9450d48b0 100644 --- a/crypto/cipher-gnutls.c.inc +++ b/crypto/cipher-gnutls.c.inc @@ -27,7 +27,7 @@ #define QEMU_GNUTLS_XTS #endif =20 -bool qcrypto_cipher_supports(QCryptoCipherAlgorithm alg, +bool qcrypto_cipher_supports(QCryptoCipherAlgo alg, QCryptoCipherMode mode) { =20 @@ -35,11 +35,11 @@ bool qcrypto_cipher_supports(QCryptoCipherAlgorithm alg, case QCRYPTO_CIPHER_MODE_ECB: case QCRYPTO_CIPHER_MODE_CBC: switch (alg) { - case QCRYPTO_CIPHER_ALG_AES_128: - case QCRYPTO_CIPHER_ALG_AES_192: - case QCRYPTO_CIPHER_ALG_AES_256: - case QCRYPTO_CIPHER_ALG_DES: - case QCRYPTO_CIPHER_ALG_3DES: + case QCRYPTO_CIPHER_ALGO_AES_128: + case QCRYPTO_CIPHER_ALGO_AES_192: + case QCRYPTO_CIPHER_ALGO_AES_256: + case QCRYPTO_CIPHER_ALGO_DES: + case QCRYPTO_CIPHER_ALGO_3DES: return true; default: return false; @@ -47,8 +47,8 @@ bool qcrypto_cipher_supports(QCryptoCipherAlgorithm alg, #ifdef QEMU_GNUTLS_XTS case QCRYPTO_CIPHER_MODE_XTS: switch (alg) { - case QCRYPTO_CIPHER_ALG_AES_128: - case QCRYPTO_CIPHER_ALG_AES_256: + case QCRYPTO_CIPHER_ALGO_AES_128: + case QCRYPTO_CIPHER_ALGO_AES_256: return true; default: return false; @@ -229,7 +229,7 @@ static struct QCryptoCipherDriver gnutls_driver =3D { .cipher_free =3D qcrypto_gnutls_cipher_free, }; =20 -static QCryptoCipher *qcrypto_cipher_ctx_new(QCryptoCipherAlgorithm alg, +static QCryptoCipher *qcrypto_cipher_ctx_new(QCryptoCipherAlgo alg, QCryptoCipherMode mode, const uint8_t *key, size_t nkey, @@ -244,10 +244,10 @@ static QCryptoCipher *qcrypto_cipher_ctx_new(QCryptoC= ipherAlgorithm alg, #ifdef QEMU_GNUTLS_XTS case QCRYPTO_CIPHER_MODE_XTS: switch (alg) { - case QCRYPTO_CIPHER_ALG_AES_128: + case QCRYPTO_CIPHER_ALGO_AES_128: galg =3D GNUTLS_CIPHER_AES_128_XTS; break; - case QCRYPTO_CIPHER_ALG_AES_256: + case QCRYPTO_CIPHER_ALGO_AES_256: galg =3D GNUTLS_CIPHER_AES_256_XTS; break; default: @@ -259,19 +259,19 @@ static QCryptoCipher *qcrypto_cipher_ctx_new(QCryptoC= ipherAlgorithm alg, case QCRYPTO_CIPHER_MODE_ECB: case QCRYPTO_CIPHER_MODE_CBC: switch (alg) { - case QCRYPTO_CIPHER_ALG_AES_128: + case QCRYPTO_CIPHER_ALGO_AES_128: galg =3D GNUTLS_CIPHER_AES_128_CBC; break; - case QCRYPTO_CIPHER_ALG_AES_192: + case QCRYPTO_CIPHER_ALGO_AES_192: galg =3D GNUTLS_CIPHER_AES_192_CBC; break; - case QCRYPTO_CIPHER_ALG_AES_256: + case QCRYPTO_CIPHER_ALGO_AES_256: galg =3D GNUTLS_CIPHER_AES_256_CBC; break; - case QCRYPTO_CIPHER_ALG_DES: + case QCRYPTO_CIPHER_ALGO_DES: galg =3D GNUTLS_CIPHER_DES_CBC; break; - case QCRYPTO_CIPHER_ALG_3DES: + case QCRYPTO_CIPHER_ALGO_3DES: galg =3D GNUTLS_CIPHER_3DES_CBC; break; default: @@ -284,7 +284,7 @@ static QCryptoCipher *qcrypto_cipher_ctx_new(QCryptoCip= herAlgorithm alg, =20 if (galg =3D=3D GNUTLS_CIPHER_UNKNOWN) { error_setg(errp, "Unsupported cipher algorithm %s with %s mode", - QCryptoCipherAlgorithm_str(alg), + QCryptoCipherAlgo_str(alg), QCryptoCipherMode_str(mode)); return NULL; } @@ -310,8 +310,8 @@ static QCryptoCipher *qcrypto_cipher_ctx_new(QCryptoCip= herAlgorithm alg, } } =20 - if (alg =3D=3D QCRYPTO_CIPHER_ALG_DES || - alg =3D=3D QCRYPTO_CIPHER_ALG_3DES) + if (alg =3D=3D QCRYPTO_CIPHER_ALGO_DES || + alg =3D=3D QCRYPTO_CIPHER_ALGO_3DES) ctx->blocksize =3D 8; else ctx->blocksize =3D 16; diff --git a/crypto/cipher-nettle.c.inc b/crypto/cipher-nettle.c.inc index 2654b439c1..ae91363772 100644 --- a/crypto/cipher-nettle.c.inc +++ b/crypto/cipher-nettle.c.inc @@ -454,24 +454,24 @@ DEFINE_ECB(qcrypto_nettle_sm4, sm4_encrypt_native, sm4_decrypt_native) #endif =20 -bool qcrypto_cipher_supports(QCryptoCipherAlgorithm alg, +bool qcrypto_cipher_supports(QCryptoCipherAlgo alg, QCryptoCipherMode mode) { switch (alg) { - case QCRYPTO_CIPHER_ALG_DES: - case QCRYPTO_CIPHER_ALG_3DES: - case QCRYPTO_CIPHER_ALG_AES_128: - case QCRYPTO_CIPHER_ALG_AES_192: - case QCRYPTO_CIPHER_ALG_AES_256: - case QCRYPTO_CIPHER_ALG_CAST5_128: - case QCRYPTO_CIPHER_ALG_SERPENT_128: - case QCRYPTO_CIPHER_ALG_SERPENT_192: - case QCRYPTO_CIPHER_ALG_SERPENT_256: - case QCRYPTO_CIPHER_ALG_TWOFISH_128: - case QCRYPTO_CIPHER_ALG_TWOFISH_192: - case QCRYPTO_CIPHER_ALG_TWOFISH_256: + case QCRYPTO_CIPHER_ALGO_DES: + case QCRYPTO_CIPHER_ALGO_3DES: + case QCRYPTO_CIPHER_ALGO_AES_128: + case QCRYPTO_CIPHER_ALGO_AES_192: + case QCRYPTO_CIPHER_ALGO_AES_256: + case QCRYPTO_CIPHER_ALGO_CAST5_128: + case QCRYPTO_CIPHER_ALGO_SERPENT_128: + case QCRYPTO_CIPHER_ALGO_SERPENT_192: + case QCRYPTO_CIPHER_ALGO_SERPENT_256: + case QCRYPTO_CIPHER_ALGO_TWOFISH_128: + case QCRYPTO_CIPHER_ALGO_TWOFISH_192: + case QCRYPTO_CIPHER_ALGO_TWOFISH_256: #ifdef CONFIG_CRYPTO_SM4 - case QCRYPTO_CIPHER_ALG_SM4: + case QCRYPTO_CIPHER_ALGO_SM4: #endif break; default: @@ -489,7 +489,7 @@ bool qcrypto_cipher_supports(QCryptoCipherAlgorithm alg, } } =20 -static QCryptoCipher *qcrypto_cipher_ctx_new(QCryptoCipherAlgorithm alg, +static QCryptoCipher *qcrypto_cipher_ctx_new(QCryptoCipherAlgo alg, QCryptoCipherMode mode, const uint8_t *key, size_t nkey, @@ -510,7 +510,7 @@ static QCryptoCipher *qcrypto_cipher_ctx_new(QCryptoCip= herAlgorithm alg, } =20 switch (alg) { - case QCRYPTO_CIPHER_ALG_DES: + case QCRYPTO_CIPHER_ALGO_DES: { QCryptoNettleDES *ctx; const QCryptoCipherDriver *drv; @@ -538,7 +538,7 @@ static QCryptoCipher *qcrypto_cipher_ctx_new(QCryptoCip= herAlgorithm alg, return &ctx->base; } =20 - case QCRYPTO_CIPHER_ALG_3DES: + case QCRYPTO_CIPHER_ALGO_3DES: { QCryptoNettleDES3 *ctx; const QCryptoCipherDriver *drv; @@ -565,7 +565,7 @@ static QCryptoCipher *qcrypto_cipher_ctx_new(QCryptoCip= herAlgorithm alg, return &ctx->base; } =20 - case QCRYPTO_CIPHER_ALG_AES_128: + case QCRYPTO_CIPHER_ALGO_AES_128: { QCryptoNettleAES128 *ctx =3D g_new0(QCryptoNettleAES128, 1); =20 @@ -594,7 +594,7 @@ static QCryptoCipher *qcrypto_cipher_ctx_new(QCryptoCip= herAlgorithm alg, return &ctx->base; } =20 - case QCRYPTO_CIPHER_ALG_AES_192: + case QCRYPTO_CIPHER_ALGO_AES_192: { QCryptoNettleAES192 *ctx =3D g_new0(QCryptoNettleAES192, 1); =20 @@ -623,7 +623,7 @@ static QCryptoCipher *qcrypto_cipher_ctx_new(QCryptoCip= herAlgorithm alg, return &ctx->base; } =20 - case QCRYPTO_CIPHER_ALG_AES_256: + case QCRYPTO_CIPHER_ALGO_AES_256: { QCryptoNettleAES256 *ctx =3D g_new0(QCryptoNettleAES256, 1); =20 @@ -652,7 +652,7 @@ static QCryptoCipher *qcrypto_cipher_ctx_new(QCryptoCip= herAlgorithm alg, return &ctx->base; } =20 - case QCRYPTO_CIPHER_ALG_CAST5_128: + case QCRYPTO_CIPHER_ALGO_CAST5_128: { QCryptoNettleCAST128 *ctx; const QCryptoCipherDriver *drv; @@ -680,9 +680,9 @@ static QCryptoCipher *qcrypto_cipher_ctx_new(QCryptoCip= herAlgorithm alg, return &ctx->base; } =20 - case QCRYPTO_CIPHER_ALG_SERPENT_128: - case QCRYPTO_CIPHER_ALG_SERPENT_192: - case QCRYPTO_CIPHER_ALG_SERPENT_256: + case QCRYPTO_CIPHER_ALGO_SERPENT_128: + case QCRYPTO_CIPHER_ALGO_SERPENT_192: + case QCRYPTO_CIPHER_ALGO_SERPENT_256: { QCryptoNettleSerpent *ctx =3D g_new0(QCryptoNettleSerpent, 1); =20 @@ -709,9 +709,9 @@ static QCryptoCipher *qcrypto_cipher_ctx_new(QCryptoCip= herAlgorithm alg, return &ctx->base; } =20 - case QCRYPTO_CIPHER_ALG_TWOFISH_128: - case QCRYPTO_CIPHER_ALG_TWOFISH_192: - case QCRYPTO_CIPHER_ALG_TWOFISH_256: + case QCRYPTO_CIPHER_ALGO_TWOFISH_128: + case QCRYPTO_CIPHER_ALGO_TWOFISH_192: + case QCRYPTO_CIPHER_ALGO_TWOFISH_256: { QCryptoNettleTwofish *ctx =3D g_new0(QCryptoNettleTwofish, 1); =20 @@ -738,7 +738,7 @@ static QCryptoCipher *qcrypto_cipher_ctx_new(QCryptoCip= herAlgorithm alg, return &ctx->base; } #ifdef CONFIG_CRYPTO_SM4 - case QCRYPTO_CIPHER_ALG_SM4: + case QCRYPTO_CIPHER_ALGO_SM4: { QCryptoNettleSm4 *ctx; const QCryptoCipherDriver *drv; @@ -766,7 +766,7 @@ static QCryptoCipher *qcrypto_cipher_ctx_new(QCryptoCip= herAlgorithm alg, =20 default: error_setg(errp, "Unsupported cipher algorithm %s", - QCryptoCipherAlgorithm_str(alg)); + QCryptoCipherAlgo_str(alg)); return NULL; } =20 --=20 2.46.0