qapi/crypto: Rename QCryptoIVGenAlgorithm to *Algo, and drop prefix
QAPI's 'prefix' feature can make the connection between enumeration type and its constants less than obvious. It's best used with restraint. QCryptoIVGenAlgorithm has a 'prefix' that overrides the generated enumeration constants' prefix to QCRYPTO_IVGEN_ALG. We could simply drop 'prefix', but then the prefix becomes QCRYPTO_IV_GEN_ALGORITHM, which is rather long. We could additionally rename the type to QCryptoIVGenAlg, but I think the abbreviation "alg" is less than clear. Rename the type to QCryptoIVGenAlgo instead. The prefix becomes QCRYPTO_IV_GEN_ALGO. Signed-off-by: Markus Armbruster <armbru@redhat.com> Acked-by: Daniel P. Berrangé <berrange@redhat.com> Message-ID: <20240904111836.3273842-14-armbru@redhat.com>
This commit is contained in:
+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;
|
||||
}
|
||||
|
||||
+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;
|
||||
|
||||
+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;
|
||||
}
|
||||
|
||||
+1
-1
@@ -40,7 +40,7 @@ struct QCryptoIVGen {
|
||||
QCryptoIVGenDriver *driver;
|
||||
void *private;
|
||||
|
||||
QCryptoIVGenAlgorithm algorithm;
|
||||
QCryptoIVGenAlgo algorithm;
|
||||
QCryptoCipherAlgo cipher;
|
||||
QCryptoHashAlgo hash;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user