aboutsummaryrefslogtreecommitdiff
path: root/crypto/hmac-gcrypt.c
diff options
context:
space:
mode:
authorMarkus Armbruster <armbru@redhat.com>2024-09-04 13:18:28 +0200
committerMarkus Armbruster <armbru@redhat.com>2024-09-10 14:02:16 +0200
commitef834aa2b2b52ac44ca97d70d5ef5e975a229034 (patch)
treed175decc323ac64104b4243d6c3389affe1d0804 /crypto/hmac-gcrypt.c
parent5f4059ef33e927ce9f72cb60000efa156566cd5c (diff)
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 7bbadc60b58b resolved]
Diffstat (limited to 'crypto/hmac-gcrypt.c')
-rw-r--r--crypto/hmac-gcrypt.c22
1 files changed, 11 insertions, 11 deletions
diff --git a/crypto/hmac-gcrypt.c b/crypto/hmac-gcrypt.c
index 0c6f979711..19990cb6ed 100644
--- a/crypto/hmac-gcrypt.c
+++ b/crypto/hmac-gcrypt.c
@@ -18,14 +18,14 @@
#include "hmacpriv.h"
#include <gcrypt.h>
-static int qcrypto_hmac_alg_map[QCRYPTO_HASH_ALG__MAX] = {
- [QCRYPTO_HASH_ALG_MD5] = GCRY_MAC_HMAC_MD5,
- [QCRYPTO_HASH_ALG_SHA1] = GCRY_MAC_HMAC_SHA1,
- [QCRYPTO_HASH_ALG_SHA224] = GCRY_MAC_HMAC_SHA224,
- [QCRYPTO_HASH_ALG_SHA256] = GCRY_MAC_HMAC_SHA256,
- [QCRYPTO_HASH_ALG_SHA384] = GCRY_MAC_HMAC_SHA384,
- [QCRYPTO_HASH_ALG_SHA512] = GCRY_MAC_HMAC_SHA512,
- [QCRYPTO_HASH_ALG_RIPEMD160] = GCRY_MAC_HMAC_RMD160,
+static int qcrypto_hmac_alg_map[QCRYPTO_HASH_ALGO__MAX] = {
+ [QCRYPTO_HASH_ALGO_MD5] = GCRY_MAC_HMAC_MD5,
+ [QCRYPTO_HASH_ALGO_SHA1] = GCRY_MAC_HMAC_SHA1,
+ [QCRYPTO_HASH_ALGO_SHA224] = GCRY_MAC_HMAC_SHA224,
+ [QCRYPTO_HASH_ALGO_SHA256] = GCRY_MAC_HMAC_SHA256,
+ [QCRYPTO_HASH_ALGO_SHA384] = GCRY_MAC_HMAC_SHA384,
+ [QCRYPTO_HASH_ALGO_SHA512] = GCRY_MAC_HMAC_SHA512,
+ [QCRYPTO_HASH_ALGO_RIPEMD160] = GCRY_MAC_HMAC_RMD160,
};
typedef struct QCryptoHmacGcrypt QCryptoHmacGcrypt;
@@ -33,7 +33,7 @@ struct QCryptoHmacGcrypt {
gcry_mac_hd_t handle;
};
-bool qcrypto_hmac_supports(QCryptoHashAlgorithm alg)
+bool qcrypto_hmac_supports(QCryptoHashAlgo alg)
{
if (alg < G_N_ELEMENTS(qcrypto_hmac_alg_map) &&
qcrypto_hmac_alg_map[alg] != GCRY_MAC_NONE) {
@@ -43,7 +43,7 @@ bool qcrypto_hmac_supports(QCryptoHashAlgorithm alg)
return false;
}
-void *qcrypto_hmac_ctx_new(QCryptoHashAlgorithm alg,
+void *qcrypto_hmac_ctx_new(QCryptoHashAlgo alg,
const uint8_t *key, size_t nkey,
Error **errp)
{
@@ -52,7 +52,7 @@ void *qcrypto_hmac_ctx_new(QCryptoHashAlgorithm alg,
if (!qcrypto_hmac_supports(alg)) {
error_setg(errp, "Unsupported hmac algorithm %s",
- QCryptoHashAlgorithm_str(alg));
+ QCryptoHashAlgo_str(alg));
return NULL;
}