mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-09 02:24:58 -06:00
qapi/crypto: Rename QCryptoHashAlgorithm 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.
QCryptoHashAlgorithm has a 'prefix' that overrides the generated
enumeration constants' prefix to QCRYPTO_HASH_ALG.
We could simply drop 'prefix', but then the prefix becomes
QCRYPTO_HASH_ALGORITHM, which is rather long.
We could additionally rename the type to QCryptoHashAlg, but I think
the abbreviation "alg" is less than clear.
Rename the type to QCryptoHashAlgo instead. The prefix becomes to
QCRYPTO_HASH_ALGO.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Acked-by: Daniel P. Berrangé <berrange@redhat.com>
Message-ID: <20240904111836.3273842-12-armbru@redhat.com>
[Conflicts with merge commit 7bbadc60b5
resolved]
This commit is contained in:
parent
5f4059ef33
commit
ef834aa2b2
54 changed files with 363 additions and 364 deletions
|
@ -21,7 +21,7 @@
|
|||
static QCryptoAkCipher *create_rsa_akcipher(const uint8_t *priv_key,
|
||||
size_t keylen,
|
||||
QCryptoRSAPaddingAlgorithm padding,
|
||||
QCryptoHashAlgorithm hash)
|
||||
QCryptoHashAlgo hash)
|
||||
{
|
||||
QCryptoAkCipherOptions opt;
|
||||
|
||||
|
@ -40,7 +40,7 @@ static void test_rsa_speed(const uint8_t *priv_key, size_t keylen,
|
|||
#define SIGN_TIMES 10000
|
||||
#define VERIFY_TIMES 100000
|
||||
#define PADDING QCRYPTO_RSA_PADDING_ALG_PKCS1
|
||||
#define HASH QCRYPTO_HASH_ALG_SHA1
|
||||
#define HASH QCRYPTO_HASH_ALGO_SHA1
|
||||
|
||||
g_autoptr(QCryptoAkCipher) rsa =
|
||||
create_rsa_akcipher(priv_key, keylen, PADDING, HASH);
|
||||
|
@ -54,7 +54,7 @@ static void test_rsa_speed(const uint8_t *priv_key, size_t keylen,
|
|||
|
||||
g_test_message("benchmark rsa%zu (%s-%s) sign...", key_size,
|
||||
QCryptoRSAPaddingAlgorithm_str(PADDING),
|
||||
QCryptoHashAlgorithm_str(HASH));
|
||||
QCryptoHashAlgo_str(HASH));
|
||||
g_test_timer_start();
|
||||
for (count = 0; count < SIGN_TIMES; ++count) {
|
||||
g_assert(qcrypto_akcipher_sign(rsa, dgst, SHA1_DGST_LEN,
|
||||
|
@ -65,13 +65,13 @@ static void test_rsa_speed(const uint8_t *priv_key, size_t keylen,
|
|||
g_test_message("rsa%zu (%s-%s) sign %zu times in %.2f seconds,"
|
||||
" %.2f times/sec ",
|
||||
key_size, QCryptoRSAPaddingAlgorithm_str(PADDING),
|
||||
QCryptoHashAlgorithm_str(HASH),
|
||||
QCryptoHashAlgo_str(HASH),
|
||||
count, g_test_timer_last(),
|
||||
(double)count / g_test_timer_last());
|
||||
|
||||
g_test_message("benchmark rsa%zu (%s-%s) verification...", key_size,
|
||||
QCryptoRSAPaddingAlgorithm_str(PADDING),
|
||||
QCryptoHashAlgorithm_str(HASH));
|
||||
QCryptoHashAlgo_str(HASH));
|
||||
g_test_timer_start();
|
||||
for (count = 0; count < VERIFY_TIMES; ++count) {
|
||||
g_assert(qcrypto_akcipher_verify(rsa, signature, key_size / BYTE,
|
||||
|
@ -82,7 +82,7 @@ static void test_rsa_speed(const uint8_t *priv_key, size_t keylen,
|
|||
g_test_message("rsa%zu (%s-%s) verify %zu times in %.2f seconds,"
|
||||
" %.2f times/sec ",
|
||||
key_size, QCryptoRSAPaddingAlgorithm_str(PADDING),
|
||||
QCryptoHashAlgorithm_str(HASH),
|
||||
QCryptoHashAlgo_str(HASH),
|
||||
count, g_test_timer_last(),
|
||||
(double)count / g_test_timer_last());
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
|
||||
typedef struct QCryptoHashOpts {
|
||||
size_t chunk_size;
|
||||
QCryptoHashAlgorithm alg;
|
||||
QCryptoHashAlgo alg;
|
||||
} QCryptoHashOpts;
|
||||
|
||||
static void test_hash_speed(const void *opaque)
|
||||
|
@ -49,7 +49,7 @@ static void test_hash_speed(const void *opaque)
|
|||
g_test_timer_elapsed();
|
||||
|
||||
g_test_message("hash(%s): chunk %zu bytes %.2f MB/sec",
|
||||
QCryptoHashAlgorithm_str(opts->alg),
|
||||
QCryptoHashAlgo_str(opts->alg),
|
||||
opts->chunk_size, total / g_test_timer_last());
|
||||
|
||||
g_free(out);
|
||||
|
@ -65,14 +65,14 @@ int main(int argc, char **argv)
|
|||
|
||||
#define TEST_ONE(a, c) \
|
||||
QCryptoHashOpts opts ## a ## c = { \
|
||||
.alg = QCRYPTO_HASH_ALG_ ## a, .chunk_size = c, \
|
||||
.alg = QCRYPTO_HASH_ALGO_ ## a, .chunk_size = c, \
|
||||
}; \
|
||||
memset(name, 0 , sizeof(name)); \
|
||||
snprintf(name, sizeof(name), \
|
||||
"/crypto/benchmark/hash/%s/bufsize-%d", \
|
||||
QCryptoHashAlgorithm_str(QCRYPTO_HASH_ALG_ ## a), \
|
||||
QCryptoHashAlgo_str(QCRYPTO_HASH_ALGO_ ## a), \
|
||||
c); \
|
||||
if (qcrypto_hash_supports(QCRYPTO_HASH_ALG_ ## a)) \
|
||||
if (qcrypto_hash_supports(QCRYPTO_HASH_ALGO_ ## a)) \
|
||||
g_test_add_data_func(name, \
|
||||
&opts ## a ## c, \
|
||||
test_hash_speed);
|
||||
|
|
|
@ -28,7 +28,7 @@ static void test_hmac_speed(const void *opaque)
|
|||
Error *err = NULL;
|
||||
int ret;
|
||||
|
||||
if (!qcrypto_hmac_supports(QCRYPTO_HASH_ALG_SHA256)) {
|
||||
if (!qcrypto_hmac_supports(QCRYPTO_HASH_ALGO_SHA256)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -40,7 +40,7 @@ static void test_hmac_speed(const void *opaque)
|
|||
|
||||
g_test_timer_start();
|
||||
do {
|
||||
hmac = qcrypto_hmac_new(QCRYPTO_HASH_ALG_SHA256,
|
||||
hmac = qcrypto_hmac_new(QCRYPTO_HASH_ALGO_SHA256,
|
||||
(const uint8_t *)KEY, strlen(KEY), &err);
|
||||
g_assert(err == NULL);
|
||||
g_assert(hmac != NULL);
|
||||
|
@ -56,7 +56,7 @@ static void test_hmac_speed(const void *opaque)
|
|||
|
||||
total /= MiB;
|
||||
g_test_message("hmac(%s): chunk %zu bytes %.2f MB/sec",
|
||||
QCryptoHashAlgorithm_str(QCRYPTO_HASH_ALG_SHA256),
|
||||
QCryptoHashAlgo_str(QCRYPTO_HASH_ALGO_SHA256),
|
||||
chunk_size, total / g_test_timer_last());
|
||||
|
||||
g_free(out);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue