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

QCryptoRSAPaddingAlgorithm has a 'prefix' that overrides the generated
enumeration constants' prefix to QCRYPTO_RSA_PADDING_ALG.

We could simply drop 'prefix', but then the prefix becomes
QCRYPTO_RSA_PADDING_ALGORITHM, which is rather long.

We could additionally rename the type to QCryptoRSAPaddingAlg, but I
think the abbreviation "alg" is less than clear.

Rename the type to QCryptoRSAPaddingAlgo instead.  The prefix becomes
QCRYPTO_RSA_PADDING_ALGO.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Acked-by: Daniel P. Berrangé <berrange@redhat.com>
Message-ID: <20240904111836.3273842-16-armbru@redhat.com>
This commit is contained in:
Markus Armbruster 2024-09-04 13:18:32 +02:00
parent cd48d82a50
commit c96050f43e
7 changed files with 41 additions and 42 deletions

View file

@ -20,7 +20,7 @@
static QCryptoAkCipher *create_rsa_akcipher(const uint8_t *priv_key,
size_t keylen,
QCryptoRSAPaddingAlgorithm padding,
QCryptoRSAPaddingAlgo padding,
QCryptoHashAlgo hash)
{
QCryptoAkCipherOptions opt;
@ -39,7 +39,7 @@ static void test_rsa_speed(const uint8_t *priv_key, size_t keylen,
#define SHA1_DGST_LEN 20
#define SIGN_TIMES 10000
#define VERIFY_TIMES 100000
#define PADDING QCRYPTO_RSA_PADDING_ALG_PKCS1
#define PADDING QCRYPTO_RSA_PADDING_ALGO_PKCS1
#define HASH QCRYPTO_HASH_ALGO_SHA1
g_autoptr(QCryptoAkCipher) rsa =
@ -53,7 +53,7 @@ static void test_rsa_speed(const uint8_t *priv_key, size_t keylen,
signature = g_new0(uint8_t, key_size / BYTE);
g_test_message("benchmark rsa%zu (%s-%s) sign...", key_size,
QCryptoRSAPaddingAlgorithm_str(PADDING),
QCryptoRSAPaddingAlgo_str(PADDING),
QCryptoHashAlgo_str(HASH));
g_test_timer_start();
for (count = 0; count < SIGN_TIMES; ++count) {
@ -64,13 +64,13 @@ static void test_rsa_speed(const uint8_t *priv_key, size_t keylen,
g_test_timer_elapsed();
g_test_message("rsa%zu (%s-%s) sign %zu times in %.2f seconds,"
" %.2f times/sec ",
key_size, QCryptoRSAPaddingAlgorithm_str(PADDING),
key_size, QCryptoRSAPaddingAlgo_str(PADDING),
QCryptoHashAlgo_str(HASH),
count, g_test_timer_last(),
(double)count / g_test_timer_last());
g_test_message("benchmark rsa%zu (%s-%s) verification...", key_size,
QCryptoRSAPaddingAlgorithm_str(PADDING),
QCryptoRSAPaddingAlgo_str(PADDING),
QCryptoHashAlgo_str(HASH));
g_test_timer_start();
for (count = 0; count < VERIFY_TIMES; ++count) {
@ -81,7 +81,7 @@ static void test_rsa_speed(const uint8_t *priv_key, size_t keylen,
g_test_timer_elapsed();
g_test_message("rsa%zu (%s-%s) verify %zu times in %.2f seconds,"
" %.2f times/sec ",
key_size, QCryptoRSAPaddingAlgorithm_str(PADDING),
key_size, QCryptoRSAPaddingAlgo_str(PADDING),
QCryptoHashAlgo_str(HASH),
count, g_test_timer_last(),
(double)count / g_test_timer_last());

View file

@ -787,7 +787,7 @@ static QCryptoAkCipherTestData akcipher_test_data[] = {
.opt = {
.alg = QCRYPTO_AK_CIPHER_ALGO_RSA,
.u.rsa = {
.padding_alg = QCRYPTO_RSA_PADDING_ALG_RAW,
.padding_alg = QCRYPTO_RSA_PADDING_ALGO_RAW,
},
},
.pub_key = rsa1024_public_key,
@ -807,7 +807,7 @@ static QCryptoAkCipherTestData akcipher_test_data[] = {
.opt = {
.alg = QCRYPTO_AK_CIPHER_ALGO_RSA,
.u.rsa = {
.padding_alg = QCRYPTO_RSA_PADDING_ALG_PKCS1,
.padding_alg = QCRYPTO_RSA_PADDING_ALGO_PKCS1,
.hash_alg = QCRYPTO_HASH_ALGO_SHA1,
},
},
@ -832,7 +832,7 @@ static QCryptoAkCipherTestData akcipher_test_data[] = {
.opt = {
.alg = QCRYPTO_AK_CIPHER_ALGO_RSA,
.u.rsa = {
.padding_alg = QCRYPTO_RSA_PADDING_ALG_RAW,
.padding_alg = QCRYPTO_RSA_PADDING_ALGO_RAW,
},
},
.pub_key = rsa2048_public_key,
@ -852,7 +852,7 @@ static QCryptoAkCipherTestData akcipher_test_data[] = {
.opt = {
.alg = QCRYPTO_AK_CIPHER_ALGO_RSA,
.u.rsa = {
.padding_alg = QCRYPTO_RSA_PADDING_ALG_PKCS1,
.padding_alg = QCRYPTO_RSA_PADDING_ALGO_PKCS1,
.hash_alg = QCRYPTO_HASH_ALGO_SHA1,
},
},
@ -946,7 +946,7 @@ static void test_rsakey(const void *opaque)
QCryptoAkCipherOptions opt = {
.alg = QCRYPTO_AK_CIPHER_ALGO_RSA,
.u.rsa = {
.padding_alg = QCRYPTO_RSA_PADDING_ALG_PKCS1,
.padding_alg = QCRYPTO_RSA_PADDING_ALGO_PKCS1,
.hash_alg = QCRYPTO_HASH_ALGO_SHA1,
}
};