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]
diff --git a/crypto/pbkdf-gcrypt.c b/crypto/pbkdf-gcrypt.c
index bc0719c..76bbb55 100644
--- a/crypto/pbkdf-gcrypt.c
+++ b/crypto/pbkdf-gcrypt.c
@@ -23,37 +23,37 @@
#include "qapi/error.h"
#include "crypto/pbkdf.h"
-bool qcrypto_pbkdf2_supports(QCryptoHashAlgorithm hash)
+bool qcrypto_pbkdf2_supports(QCryptoHashAlgo hash)
{
switch (hash) {
- case QCRYPTO_HASH_ALG_MD5:
- case QCRYPTO_HASH_ALG_SHA1:
- case QCRYPTO_HASH_ALG_SHA224:
- case QCRYPTO_HASH_ALG_SHA256:
- case QCRYPTO_HASH_ALG_SHA384:
- case QCRYPTO_HASH_ALG_SHA512:
- case QCRYPTO_HASH_ALG_RIPEMD160:
+ case QCRYPTO_HASH_ALGO_MD5:
+ case QCRYPTO_HASH_ALGO_SHA1:
+ case QCRYPTO_HASH_ALGO_SHA224:
+ case QCRYPTO_HASH_ALGO_SHA256:
+ case QCRYPTO_HASH_ALGO_SHA384:
+ case QCRYPTO_HASH_ALGO_SHA512:
+ case QCRYPTO_HASH_ALGO_RIPEMD160:
return qcrypto_hash_supports(hash);
default:
return false;
}
}
-int qcrypto_pbkdf2(QCryptoHashAlgorithm hash,
+int qcrypto_pbkdf2(QCryptoHashAlgo hash,
const uint8_t *key, size_t nkey,
const uint8_t *salt, size_t nsalt,
uint64_t iterations,
uint8_t *out, size_t nout,
Error **errp)
{
- static const int hash_map[QCRYPTO_HASH_ALG__MAX] = {
- [QCRYPTO_HASH_ALG_MD5] = GCRY_MD_MD5,
- [QCRYPTO_HASH_ALG_SHA1] = GCRY_MD_SHA1,
- [QCRYPTO_HASH_ALG_SHA224] = GCRY_MD_SHA224,
- [QCRYPTO_HASH_ALG_SHA256] = GCRY_MD_SHA256,
- [QCRYPTO_HASH_ALG_SHA384] = GCRY_MD_SHA384,
- [QCRYPTO_HASH_ALG_SHA512] = GCRY_MD_SHA512,
- [QCRYPTO_HASH_ALG_RIPEMD160] = GCRY_MD_RMD160,
+ static const int hash_map[QCRYPTO_HASH_ALGO__MAX] = {
+ [QCRYPTO_HASH_ALGO_MD5] = GCRY_MD_MD5,
+ [QCRYPTO_HASH_ALGO_SHA1] = GCRY_MD_SHA1,
+ [QCRYPTO_HASH_ALGO_SHA224] = GCRY_MD_SHA224,
+ [QCRYPTO_HASH_ALGO_SHA256] = GCRY_MD_SHA256,
+ [QCRYPTO_HASH_ALGO_SHA384] = GCRY_MD_SHA384,
+ [QCRYPTO_HASH_ALGO_SHA512] = GCRY_MD_SHA512,
+ [QCRYPTO_HASH_ALGO_RIPEMD160] = GCRY_MD_RMD160,
};
int ret;
@@ -68,7 +68,7 @@
hash_map[hash] == GCRY_MD_NONE) {
error_setg_errno(errp, ENOSYS,
"PBKDF does not support hash algorithm %s",
- QCryptoHashAlgorithm_str(hash));
+ QCryptoHashAlgo_str(hash));
return -1;
}