qapi/crypto: Rename QCryptoCipherAlgorithm 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.

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 <armbru@redhat.com>
Acked-by: Daniel P. Berrangé <berrange@redhat.com>
Message-ID: <20240904111836.3273842-13-armbru@redhat.com>
This commit is contained in:
Markus Armbruster 2024-09-04 13:18:29 +02:00
parent ef834aa2b2
commit a092c513db
26 changed files with 277 additions and 278 deletions

View File

@ -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",

View File

@ -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;
}

View File

@ -68,38 +68,38 @@ struct QCryptoBlockLUKSCipherNameMap {
static const QCryptoBlockLUKSCipherSizeMap
qcrypto_block_luks_cipher_size_map_aes[] = {
{ 16, QCRYPTO_CIPHER_ALG_AES_128 },
{ 24, QCRYPTO_CIPHER_ALG_AES_192 },
{ 32, QCRYPTO_CIPHER_ALG_AES_256 },
{ 16, QCRYPTO_CIPHER_ALGO_AES_128 },
{ 24, QCRYPTO_CIPHER_ALGO_AES_192 },
{ 32, QCRYPTO_CIPHER_ALGO_AES_256 },
{ 0, 0 },
};
static const QCryptoBlockLUKSCipherSizeMap
qcrypto_block_luks_cipher_size_map_cast5[] = {
{ 16, QCRYPTO_CIPHER_ALG_CAST5_128 },
{ 16, QCRYPTO_CIPHER_ALGO_CAST5_128 },
{ 0, 0 },
};
static const QCryptoBlockLUKSCipherSizeMap
qcrypto_block_luks_cipher_size_map_serpent[] = {
{ 16, QCRYPTO_CIPHER_ALG_SERPENT_128 },
{ 24, QCRYPTO_CIPHER_ALG_SERPENT_192 },
{ 32, QCRYPTO_CIPHER_ALG_SERPENT_256 },
{ 16, QCRYPTO_CIPHER_ALGO_SERPENT_128 },
{ 24, QCRYPTO_CIPHER_ALGO_SERPENT_192 },
{ 32, QCRYPTO_CIPHER_ALGO_SERPENT_256 },
{ 0, 0 },
};
static const QCryptoBlockLUKSCipherSizeMap
qcrypto_block_luks_cipher_size_map_twofish[] = {
{ 16, QCRYPTO_CIPHER_ALG_TWOFISH_128 },
{ 24, QCRYPTO_CIPHER_ALG_TWOFISH_192 },
{ 32, QCRYPTO_CIPHER_ALG_TWOFISH_256 },
{ 16, QCRYPTO_CIPHER_ALGO_TWOFISH_128 },
{ 24, QCRYPTO_CIPHER_ALGO_TWOFISH_192 },
{ 32, QCRYPTO_CIPHER_ALGO_TWOFISH_256 },
{ 0, 0 },
};
#ifdef CONFIG_CRYPTO_SM4
static const QCryptoBlockLUKSCipherSizeMap
qcrypto_block_luks_cipher_size_map_sm4[] = {
{ 16, QCRYPTO_CIPHER_ALG_SM4},
{ 16, QCRYPTO_CIPHER_ALGO_SM4},
{ 0, 0 },
};
#endif
@ -123,7 +123,7 @@ struct QCryptoBlockLUKS {
QCryptoBlockLUKSHeader header;
/* Main encryption algorithm used for encryption*/
QCryptoCipherAlgorithm cipher_alg;
QCryptoCipherAlgo cipher_alg;
/* Mode of encryption for the selected encryption algorithm */
QCryptoCipherMode cipher_mode;
@ -138,7 +138,7 @@ struct QCryptoBlockLUKS {
* Encryption algorithm used for IV generation.
* Usually the same as main encryption algorithm
*/
QCryptoCipherAlgorithm ivgen_cipher_alg;
QCryptoCipherAlgo ivgen_cipher_alg;
/* Hash algorithm used in pbkdf2 function */
QCryptoHashAlgo hash_alg;
@ -179,7 +179,7 @@ static int qcrypto_block_luks_cipher_name_lookup(const char *name,
}
static const char *
qcrypto_block_luks_cipher_alg_lookup(QCryptoCipherAlgorithm alg,
qcrypto_block_luks_cipher_alg_lookup(QCryptoCipherAlgo alg,
Error **errp)
{
const QCryptoBlockLUKSCipherNameMap *map =
@ -195,7 +195,7 @@ qcrypto_block_luks_cipher_alg_lookup(QCryptoCipherAlgorithm alg,
}
error_setg(errp, "Algorithm '%s' not supported",
QCryptoCipherAlgorithm_str(alg));
QCryptoCipherAlgo_str(alg));
return NULL;
}
@ -262,8 +262,8 @@ qcrypto_block_luks_has_format(const uint8_t *buf,
* the cipher since that gets a key length matching the digest
* size, not AES 128 with truncated digest as might be imagined
*/
static QCryptoCipherAlgorithm
qcrypto_block_luks_essiv_cipher(QCryptoCipherAlgorithm cipher,
static QCryptoCipherAlgo
qcrypto_block_luks_essiv_cipher(QCryptoCipherAlgo cipher,
QCryptoHashAlgo hash,
Error **errp)
{
@ -274,54 +274,54 @@ qcrypto_block_luks_essiv_cipher(QCryptoCipherAlgorithm cipher,
}
switch (cipher) {
case QCRYPTO_CIPHER_ALG_AES_128:
case QCRYPTO_CIPHER_ALG_AES_192:
case QCRYPTO_CIPHER_ALG_AES_256:
case QCRYPTO_CIPHER_ALGO_AES_128:
case QCRYPTO_CIPHER_ALGO_AES_192:
case QCRYPTO_CIPHER_ALGO_AES_256:
if (digestlen == qcrypto_cipher_get_key_len(
QCRYPTO_CIPHER_ALG_AES_128)) {
return QCRYPTO_CIPHER_ALG_AES_128;
QCRYPTO_CIPHER_ALGO_AES_128)) {
return QCRYPTO_CIPHER_ALGO_AES_128;
} else if (digestlen == qcrypto_cipher_get_key_len(
QCRYPTO_CIPHER_ALG_AES_192)) {
return QCRYPTO_CIPHER_ALG_AES_192;
QCRYPTO_CIPHER_ALGO_AES_192)) {
return QCRYPTO_CIPHER_ALGO_AES_192;
} else if (digestlen == qcrypto_cipher_get_key_len(
QCRYPTO_CIPHER_ALG_AES_256)) {
return QCRYPTO_CIPHER_ALG_AES_256;
QCRYPTO_CIPHER_ALGO_AES_256)) {
return QCRYPTO_CIPHER_ALGO_AES_256;
} else {
error_setg(errp, "No AES cipher with key size %zu available",
digestlen);
return 0;
}
break;
case QCRYPTO_CIPHER_ALG_SERPENT_128:
case QCRYPTO_CIPHER_ALG_SERPENT_192:
case QCRYPTO_CIPHER_ALG_SERPENT_256:
case QCRYPTO_CIPHER_ALGO_SERPENT_128:
case QCRYPTO_CIPHER_ALGO_SERPENT_192:
case QCRYPTO_CIPHER_ALGO_SERPENT_256:
if (digestlen == qcrypto_cipher_get_key_len(
QCRYPTO_CIPHER_ALG_SERPENT_128)) {
return QCRYPTO_CIPHER_ALG_SERPENT_128;
QCRYPTO_CIPHER_ALGO_SERPENT_128)) {
return QCRYPTO_CIPHER_ALGO_SERPENT_128;
} else if (digestlen == qcrypto_cipher_get_key_len(
QCRYPTO_CIPHER_ALG_SERPENT_192)) {
return QCRYPTO_CIPHER_ALG_SERPENT_192;
QCRYPTO_CIPHER_ALGO_SERPENT_192)) {
return QCRYPTO_CIPHER_ALGO_SERPENT_192;
} else if (digestlen == qcrypto_cipher_get_key_len(
QCRYPTO_CIPHER_ALG_SERPENT_256)) {
return QCRYPTO_CIPHER_ALG_SERPENT_256;
QCRYPTO_CIPHER_ALGO_SERPENT_256)) {
return QCRYPTO_CIPHER_ALGO_SERPENT_256;
} else {
error_setg(errp, "No Serpent cipher with key size %zu available",
digestlen);
return 0;
}
break;
case QCRYPTO_CIPHER_ALG_TWOFISH_128:
case QCRYPTO_CIPHER_ALG_TWOFISH_192:
case QCRYPTO_CIPHER_ALG_TWOFISH_256:
case QCRYPTO_CIPHER_ALGO_TWOFISH_128:
case QCRYPTO_CIPHER_ALGO_TWOFISH_192:
case QCRYPTO_CIPHER_ALGO_TWOFISH_256:
if (digestlen == qcrypto_cipher_get_key_len(
QCRYPTO_CIPHER_ALG_TWOFISH_128)) {
return QCRYPTO_CIPHER_ALG_TWOFISH_128;
QCRYPTO_CIPHER_ALGO_TWOFISH_128)) {
return QCRYPTO_CIPHER_ALGO_TWOFISH_128;
} else if (digestlen == qcrypto_cipher_get_key_len(
QCRYPTO_CIPHER_ALG_TWOFISH_192)) {
return QCRYPTO_CIPHER_ALG_TWOFISH_192;
QCRYPTO_CIPHER_ALGO_TWOFISH_192)) {
return QCRYPTO_CIPHER_ALGO_TWOFISH_192;
} else if (digestlen == qcrypto_cipher_get_key_len(
QCRYPTO_CIPHER_ALG_TWOFISH_256)) {
return QCRYPTO_CIPHER_ALG_TWOFISH_256;
QCRYPTO_CIPHER_ALGO_TWOFISH_256)) {
return QCRYPTO_CIPHER_ALGO_TWOFISH_256;
} else {
error_setg(errp, "No Twofish cipher with key size %zu available",
digestlen);
@ -330,7 +330,7 @@ qcrypto_block_luks_essiv_cipher(QCryptoCipherAlgorithm cipher,
break;
default:
error_setg(errp, "Cipher %s not supported with essiv",
QCryptoCipherAlgorithm_str(cipher));
QCryptoCipherAlgo_str(cipher));
return 0;
}
}
@ -1322,7 +1322,7 @@ qcrypto_block_luks_create(QCryptoBlock *block,
luks_opts.iter_time = QCRYPTO_BLOCK_LUKS_DEFAULT_ITER_TIME_MS;
}
if (!luks_opts.has_cipher_alg) {
luks_opts.cipher_alg = QCRYPTO_CIPHER_ALG_AES_256;
luks_opts.cipher_alg = QCRYPTO_CIPHER_ALGO_AES_256;
}
if (!luks_opts.has_cipher_mode) {
luks_opts.cipher_mode = QCRYPTO_CIPHER_MODE_XTS;

View File

@ -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);

View File

@ -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)

View File

@ -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);

View File

@ -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)

View File

@ -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;
}

View File

@ -20,33 +20,33 @@
#include <gcrypt.h>
static int qcrypto_cipher_alg_to_gcry_alg(QCryptoCipherAlgorithm alg)
static int qcrypto_cipher_alg_to_gcry_alg(QCryptoCipherAlgo alg)
{
switch (alg) {
case QCRYPTO_CIPHER_ALG_DES:
case QCRYPTO_CIPHER_ALGO_DES:
return GCRY_CIPHER_DES;
case QCRYPTO_CIPHER_ALG_3DES:
case QCRYPTO_CIPHER_ALGO_3DES:
return GCRY_CIPHER_3DES;
case QCRYPTO_CIPHER_ALG_AES_128:
case QCRYPTO_CIPHER_ALGO_AES_128:
return GCRY_CIPHER_AES128;
case QCRYPTO_CIPHER_ALG_AES_192:
case QCRYPTO_CIPHER_ALGO_AES_192:
return GCRY_CIPHER_AES192;
case QCRYPTO_CIPHER_ALG_AES_256:
case QCRYPTO_CIPHER_ALGO_AES_256:
return GCRY_CIPHER_AES256;
case QCRYPTO_CIPHER_ALG_CAST5_128:
case QCRYPTO_CIPHER_ALGO_CAST5_128:
return GCRY_CIPHER_CAST5;
case QCRYPTO_CIPHER_ALG_SERPENT_128:
case QCRYPTO_CIPHER_ALGO_SERPENT_128:
return GCRY_CIPHER_SERPENT128;
case QCRYPTO_CIPHER_ALG_SERPENT_192:
case QCRYPTO_CIPHER_ALGO_SERPENT_192:
return GCRY_CIPHER_SERPENT192;
case QCRYPTO_CIPHER_ALG_SERPENT_256:
case QCRYPTO_CIPHER_ALGO_SERPENT_256:
return GCRY_CIPHER_SERPENT256;
case QCRYPTO_CIPHER_ALG_TWOFISH_128:
case QCRYPTO_CIPHER_ALGO_TWOFISH_128:
return GCRY_CIPHER_TWOFISH128;
case QCRYPTO_CIPHER_ALG_TWOFISH_256:
case QCRYPTO_CIPHER_ALGO_TWOFISH_256:
return GCRY_CIPHER_TWOFISH;
#ifdef CONFIG_CRYPTO_SM4
case QCRYPTO_CIPHER_ALG_SM4:
case QCRYPTO_CIPHER_ALGO_SM4:
return GCRY_CIPHER_SM4;
#endif
default:
@ -70,23 +70,23 @@ static int qcrypto_cipher_mode_to_gcry_mode(QCryptoCipherMode mode)
}
}
bool qcrypto_cipher_supports(QCryptoCipherAlgorithm alg,
bool qcrypto_cipher_supports(QCryptoCipherAlgo alg,
QCryptoCipherMode mode)
{
switch (alg) {
case QCRYPTO_CIPHER_ALG_DES:
case QCRYPTO_CIPHER_ALG_3DES:
case QCRYPTO_CIPHER_ALG_AES_128:
case QCRYPTO_CIPHER_ALG_AES_192:
case QCRYPTO_CIPHER_ALG_AES_256:
case QCRYPTO_CIPHER_ALG_CAST5_128:
case QCRYPTO_CIPHER_ALG_SERPENT_128:
case QCRYPTO_CIPHER_ALG_SERPENT_192:
case QCRYPTO_CIPHER_ALG_SERPENT_256:
case QCRYPTO_CIPHER_ALG_TWOFISH_128:
case QCRYPTO_CIPHER_ALG_TWOFISH_256:
case QCRYPTO_CIPHER_ALGO_DES:
case QCRYPTO_CIPHER_ALGO_3DES:
case QCRYPTO_CIPHER_ALGO_AES_128:
case QCRYPTO_CIPHER_ALGO_AES_192:
case QCRYPTO_CIPHER_ALGO_AES_256:
case QCRYPTO_CIPHER_ALGO_CAST5_128:
case QCRYPTO_CIPHER_ALGO_SERPENT_128:
case QCRYPTO_CIPHER_ALGO_SERPENT_192:
case QCRYPTO_CIPHER_ALGO_SERPENT_256:
case QCRYPTO_CIPHER_ALGO_TWOFISH_128:
case QCRYPTO_CIPHER_ALGO_TWOFISH_256:
#ifdef CONFIG_CRYPTO_SM4
case QCRYPTO_CIPHER_ALG_SM4:
case QCRYPTO_CIPHER_ALGO_SM4:
#endif
break;
default:
@ -228,7 +228,7 @@ static const struct QCryptoCipherDriver qcrypto_gcrypt_ctr_driver = {
.cipher_free = qcrypto_gcrypt_ctx_free,
};
static QCryptoCipher *qcrypto_cipher_ctx_new(QCryptoCipherAlgorithm alg,
static QCryptoCipher *qcrypto_cipher_ctx_new(QCryptoCipherAlgo alg,
QCryptoCipherMode mode,
const uint8_t *key,
size_t nkey,
@ -246,7 +246,7 @@ static QCryptoCipher *qcrypto_cipher_ctx_new(QCryptoCipherAlgorithm alg,
gcryalg = qcrypto_cipher_alg_to_gcry_alg(alg);
if (gcryalg == GCRY_CIPHER_NONE) {
error_setg(errp, "Unsupported cipher algorithm %s",
QCryptoCipherAlgorithm_str(alg));
QCryptoCipherAlgo_str(alg));
return NULL;
}

View File

@ -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;

View File

@ -454,24 +454,24 @@ DEFINE_ECB(qcrypto_nettle_sm4,
sm4_encrypt_native, sm4_decrypt_native)
#endif
bool qcrypto_cipher_supports(QCryptoCipherAlgorithm alg,
bool qcrypto_cipher_supports(QCryptoCipherAlgo alg,
QCryptoCipherMode mode)
{
switch (alg) {
case QCRYPTO_CIPHER_ALG_DES:
case QCRYPTO_CIPHER_ALG_3DES:
case QCRYPTO_CIPHER_ALG_AES_128:
case QCRYPTO_CIPHER_ALG_AES_192:
case QCRYPTO_CIPHER_ALG_AES_256:
case QCRYPTO_CIPHER_ALG_CAST5_128:
case QCRYPTO_CIPHER_ALG_SERPENT_128:
case QCRYPTO_CIPHER_ALG_SERPENT_192:
case QCRYPTO_CIPHER_ALG_SERPENT_256:
case QCRYPTO_CIPHER_ALG_TWOFISH_128:
case QCRYPTO_CIPHER_ALG_TWOFISH_192:
case QCRYPTO_CIPHER_ALG_TWOFISH_256:
case QCRYPTO_CIPHER_ALGO_DES:
case QCRYPTO_CIPHER_ALGO_3DES:
case QCRYPTO_CIPHER_ALGO_AES_128:
case QCRYPTO_CIPHER_ALGO_AES_192:
case QCRYPTO_CIPHER_ALGO_AES_256:
case QCRYPTO_CIPHER_ALGO_CAST5_128:
case QCRYPTO_CIPHER_ALGO_SERPENT_128:
case QCRYPTO_CIPHER_ALGO_SERPENT_192:
case QCRYPTO_CIPHER_ALGO_SERPENT_256:
case QCRYPTO_CIPHER_ALGO_TWOFISH_128:
case QCRYPTO_CIPHER_ALGO_TWOFISH_192:
case QCRYPTO_CIPHER_ALGO_TWOFISH_256:
#ifdef CONFIG_CRYPTO_SM4
case QCRYPTO_CIPHER_ALG_SM4:
case QCRYPTO_CIPHER_ALGO_SM4:
#endif
break;
default:
@ -489,7 +489,7 @@ bool qcrypto_cipher_supports(QCryptoCipherAlgorithm alg,
}
}
static QCryptoCipher *qcrypto_cipher_ctx_new(QCryptoCipherAlgorithm alg,
static QCryptoCipher *qcrypto_cipher_ctx_new(QCryptoCipherAlgo alg,
QCryptoCipherMode mode,
const uint8_t *key,
size_t nkey,
@ -510,7 +510,7 @@ static QCryptoCipher *qcrypto_cipher_ctx_new(QCryptoCipherAlgorithm alg,
}
switch (alg) {
case QCRYPTO_CIPHER_ALG_DES:
case QCRYPTO_CIPHER_ALGO_DES:
{
QCryptoNettleDES *ctx;
const QCryptoCipherDriver *drv;
@ -538,7 +538,7 @@ static QCryptoCipher *qcrypto_cipher_ctx_new(QCryptoCipherAlgorithm alg,
return &ctx->base;
}
case QCRYPTO_CIPHER_ALG_3DES:
case QCRYPTO_CIPHER_ALGO_3DES:
{
QCryptoNettleDES3 *ctx;
const QCryptoCipherDriver *drv;
@ -565,7 +565,7 @@ static QCryptoCipher *qcrypto_cipher_ctx_new(QCryptoCipherAlgorithm alg,
return &ctx->base;
}
case QCRYPTO_CIPHER_ALG_AES_128:
case QCRYPTO_CIPHER_ALGO_AES_128:
{
QCryptoNettleAES128 *ctx = g_new0(QCryptoNettleAES128, 1);
@ -594,7 +594,7 @@ static QCryptoCipher *qcrypto_cipher_ctx_new(QCryptoCipherAlgorithm alg,
return &ctx->base;
}
case QCRYPTO_CIPHER_ALG_AES_192:
case QCRYPTO_CIPHER_ALGO_AES_192:
{
QCryptoNettleAES192 *ctx = g_new0(QCryptoNettleAES192, 1);
@ -623,7 +623,7 @@ static QCryptoCipher *qcrypto_cipher_ctx_new(QCryptoCipherAlgorithm alg,
return &ctx->base;
}
case QCRYPTO_CIPHER_ALG_AES_256:
case QCRYPTO_CIPHER_ALGO_AES_256:
{
QCryptoNettleAES256 *ctx = g_new0(QCryptoNettleAES256, 1);
@ -652,7 +652,7 @@ static QCryptoCipher *qcrypto_cipher_ctx_new(QCryptoCipherAlgorithm alg,
return &ctx->base;
}
case QCRYPTO_CIPHER_ALG_CAST5_128:
case QCRYPTO_CIPHER_ALGO_CAST5_128:
{
QCryptoNettleCAST128 *ctx;
const QCryptoCipherDriver *drv;
@ -680,9 +680,9 @@ static QCryptoCipher *qcrypto_cipher_ctx_new(QCryptoCipherAlgorithm alg,
return &ctx->base;
}
case QCRYPTO_CIPHER_ALG_SERPENT_128:
case QCRYPTO_CIPHER_ALG_SERPENT_192:
case QCRYPTO_CIPHER_ALG_SERPENT_256:
case QCRYPTO_CIPHER_ALGO_SERPENT_128:
case QCRYPTO_CIPHER_ALGO_SERPENT_192:
case QCRYPTO_CIPHER_ALGO_SERPENT_256:
{
QCryptoNettleSerpent *ctx = g_new0(QCryptoNettleSerpent, 1);
@ -709,9 +709,9 @@ static QCryptoCipher *qcrypto_cipher_ctx_new(QCryptoCipherAlgorithm alg,
return &ctx->base;
}
case QCRYPTO_CIPHER_ALG_TWOFISH_128:
case QCRYPTO_CIPHER_ALG_TWOFISH_192:
case QCRYPTO_CIPHER_ALG_TWOFISH_256:
case QCRYPTO_CIPHER_ALGO_TWOFISH_128:
case QCRYPTO_CIPHER_ALGO_TWOFISH_192:
case QCRYPTO_CIPHER_ALGO_TWOFISH_256:
{
QCryptoNettleTwofish *ctx = g_new0(QCryptoNettleTwofish, 1);
@ -738,7 +738,7 @@ static QCryptoCipher *qcrypto_cipher_ctx_new(QCryptoCipherAlgorithm alg,
return &ctx->base;
}
#ifdef CONFIG_CRYPTO_SM4
case QCRYPTO_CIPHER_ALG_SM4:
case QCRYPTO_CIPHER_ALGO_SM4:
{
QCryptoNettleSm4 *ctx;
const QCryptoCipherDriver *drv;
@ -766,7 +766,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;
}

View File

@ -25,39 +25,39 @@
#include "cipherpriv.h"
static const size_t alg_key_len[QCRYPTO_CIPHER_ALG__MAX] = {
[QCRYPTO_CIPHER_ALG_AES_128] = 16,
[QCRYPTO_CIPHER_ALG_AES_192] = 24,
[QCRYPTO_CIPHER_ALG_AES_256] = 32,
[QCRYPTO_CIPHER_ALG_DES] = 8,
[QCRYPTO_CIPHER_ALG_3DES] = 24,
[QCRYPTO_CIPHER_ALG_CAST5_128] = 16,
[QCRYPTO_CIPHER_ALG_SERPENT_128] = 16,
[QCRYPTO_CIPHER_ALG_SERPENT_192] = 24,
[QCRYPTO_CIPHER_ALG_SERPENT_256] = 32,
[QCRYPTO_CIPHER_ALG_TWOFISH_128] = 16,
[QCRYPTO_CIPHER_ALG_TWOFISH_192] = 24,
[QCRYPTO_CIPHER_ALG_TWOFISH_256] = 32,
static const size_t alg_key_len[QCRYPTO_CIPHER_ALGO__MAX] = {
[QCRYPTO_CIPHER_ALGO_AES_128] = 16,
[QCRYPTO_CIPHER_ALGO_AES_192] = 24,
[QCRYPTO_CIPHER_ALGO_AES_256] = 32,
[QCRYPTO_CIPHER_ALGO_DES] = 8,
[QCRYPTO_CIPHER_ALGO_3DES] = 24,
[QCRYPTO_CIPHER_ALGO_CAST5_128] = 16,
[QCRYPTO_CIPHER_ALGO_SERPENT_128] = 16,
[QCRYPTO_CIPHER_ALGO_SERPENT_192] = 24,
[QCRYPTO_CIPHER_ALGO_SERPENT_256] = 32,
[QCRYPTO_CIPHER_ALGO_TWOFISH_128] = 16,
[QCRYPTO_CIPHER_ALGO_TWOFISH_192] = 24,
[QCRYPTO_CIPHER_ALGO_TWOFISH_256] = 32,
#ifdef CONFIG_CRYPTO_SM4
[QCRYPTO_CIPHER_ALG_SM4] = 16,
[QCRYPTO_CIPHER_ALGO_SM4] = 16,
#endif
};
static const size_t alg_block_len[QCRYPTO_CIPHER_ALG__MAX] = {
[QCRYPTO_CIPHER_ALG_AES_128] = 16,
[QCRYPTO_CIPHER_ALG_AES_192] = 16,
[QCRYPTO_CIPHER_ALG_AES_256] = 16,
[QCRYPTO_CIPHER_ALG_DES] = 8,
[QCRYPTO_CIPHER_ALG_3DES] = 8,
[QCRYPTO_CIPHER_ALG_CAST5_128] = 8,
[QCRYPTO_CIPHER_ALG_SERPENT_128] = 16,
[QCRYPTO_CIPHER_ALG_SERPENT_192] = 16,
[QCRYPTO_CIPHER_ALG_SERPENT_256] = 16,
[QCRYPTO_CIPHER_ALG_TWOFISH_128] = 16,
[QCRYPTO_CIPHER_ALG_TWOFISH_192] = 16,
[QCRYPTO_CIPHER_ALG_TWOFISH_256] = 16,
static const size_t alg_block_len[QCRYPTO_CIPHER_ALGO__MAX] = {
[QCRYPTO_CIPHER_ALGO_AES_128] = 16,
[QCRYPTO_CIPHER_ALGO_AES_192] = 16,
[QCRYPTO_CIPHER_ALGO_AES_256] = 16,
[QCRYPTO_CIPHER_ALGO_DES] = 8,
[QCRYPTO_CIPHER_ALGO_3DES] = 8,
[QCRYPTO_CIPHER_ALGO_CAST5_128] = 8,
[QCRYPTO_CIPHER_ALGO_SERPENT_128] = 16,
[QCRYPTO_CIPHER_ALGO_SERPENT_192] = 16,
[QCRYPTO_CIPHER_ALGO_SERPENT_256] = 16,
[QCRYPTO_CIPHER_ALGO_TWOFISH_128] = 16,
[QCRYPTO_CIPHER_ALGO_TWOFISH_192] = 16,
[QCRYPTO_CIPHER_ALGO_TWOFISH_256] = 16,
#ifdef CONFIG_CRYPTO_SM4
[QCRYPTO_CIPHER_ALG_SM4] = 16,
[QCRYPTO_CIPHER_ALGO_SM4] = 16,
#endif
};
@ -69,21 +69,21 @@ static const bool mode_need_iv[QCRYPTO_CIPHER_MODE__MAX] = {
};
size_t qcrypto_cipher_get_block_len(QCryptoCipherAlgorithm alg)
size_t qcrypto_cipher_get_block_len(QCryptoCipherAlgo alg)
{
assert(alg < G_N_ELEMENTS(alg_key_len));
return alg_block_len[alg];
}
size_t qcrypto_cipher_get_key_len(QCryptoCipherAlgorithm alg)
size_t qcrypto_cipher_get_key_len(QCryptoCipherAlgo alg)
{
assert(alg < G_N_ELEMENTS(alg_key_len));
return alg_key_len[alg];
}
size_t qcrypto_cipher_get_iv_len(QCryptoCipherAlgorithm alg,
size_t qcrypto_cipher_get_iv_len(QCryptoCipherAlgo alg,
QCryptoCipherMode mode)
{
if (alg >= G_N_ELEMENTS(alg_block_len)) {
@ -101,20 +101,20 @@ size_t qcrypto_cipher_get_iv_len(QCryptoCipherAlgorithm alg,
static bool
qcrypto_cipher_validate_key_length(QCryptoCipherAlgorithm alg,
qcrypto_cipher_validate_key_length(QCryptoCipherAlgo alg,
QCryptoCipherMode mode,
size_t nkey,
Error **errp)
{
if ((unsigned)alg >= QCRYPTO_CIPHER_ALG__MAX) {
if ((unsigned)alg >= QCRYPTO_CIPHER_ALGO__MAX) {
error_setg(errp, "Cipher algorithm %d out of range",
alg);
return false;
}
if (mode == QCRYPTO_CIPHER_MODE_XTS) {
if (alg == QCRYPTO_CIPHER_ALG_DES ||
alg == QCRYPTO_CIPHER_ALG_3DES) {
if (alg == QCRYPTO_CIPHER_ALGO_DES ||
alg == QCRYPTO_CIPHER_ALGO_3DES) {
error_setg(errp, "XTS mode not compatible with DES/3DES");
return false;
}
@ -148,7 +148,7 @@ qcrypto_cipher_validate_key_length(QCryptoCipherAlgorithm alg,
#include "cipher-builtin.c.inc"
#endif
QCryptoCipher *qcrypto_cipher_new(QCryptoCipherAlgorithm alg,
QCryptoCipher *qcrypto_cipher_new(QCryptoCipherAlgo alg,
QCryptoCipherMode mode,
const uint8_t *key, size_t nkey,
Error **errp)

View File

@ -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);

View File

@ -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;
}

View File

@ -41,7 +41,7 @@ struct QCryptoIVGen {
void *private;
QCryptoIVGenAlgorithm algorithm;
QCryptoCipherAlgorithm cipher;
QCryptoCipherAlgo cipher;
QCryptoHashAlgo hash;
};

View File

@ -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);

View File

@ -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);

View File

@ -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);
/**

View File

@ -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);

View File

@ -4163,7 +4163,7 @@
##
{ 'struct': 'RbdEncryptionCreateOptionsLUKSBase',
'base': 'RbdEncryptionOptionsLUKSBase',
'data': { '*cipher-alg': 'QCryptoCipherAlgorithm' } }
'data': { '*cipher-alg': 'QCryptoCipherAlgo' } }
##
# @RbdEncryptionOptionsLUKS:

View File

@ -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',

View File

@ -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);</