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:
@@ -46,7 +46,7 @@
|
||||
*
|
||||
* splitkey = g_new0(uint8_t, nkey * stripes);
|
||||
*
|
||||
* if (qcrypto_afsplit_encode(QCRYPTO_HASH_ALG_SHA256,
|
||||
* if (qcrypto_afsplit_encode(QCRYPTO_HASH_ALGO_SHA256,
|
||||
* nkey, stripes,
|
||||
* masterkey, splitkey, errp) < 0) {
|
||||
* g_free(splitkey);
|
||||
@@ -71,7 +71,7 @@
|
||||
*
|
||||
* masterkey = g_new0(uint8_t, nkey);
|
||||
*
|
||||
* if (qcrypto_afsplit_decode(QCRYPTO_HASH_ALG_SHA256,
|
||||
* if (qcrypto_afsplit_decode(QCRYPTO_HASH_ALGO_SHA256,
|
||||
* nkey, stripes,
|
||||
* splitkey, masterkey, errp) < 0) {
|
||||
* g_free(splitkey);
|
||||
@@ -102,7 +102,7 @@
|
||||
*
|
||||
* Returns: 0 on success, -1 on error;
|
||||
*/
|
||||
int qcrypto_afsplit_encode(QCryptoHashAlgorithm hash,
|
||||
int qcrypto_afsplit_encode(QCryptoHashAlgo hash,
|
||||
size_t blocklen,
|
||||
uint32_t stripes,
|
||||
const uint8_t *in,
|
||||
@@ -124,7 +124,7 @@ int qcrypto_afsplit_encode(QCryptoHashAlgorithm hash,
|
||||
*
|
||||
* Returns: 0 on success, -1 on error;
|
||||
*/
|
||||
int qcrypto_afsplit_decode(QCryptoHashAlgorithm hash,
|
||||
int qcrypto_afsplit_decode(QCryptoHashAlgo hash,
|
||||
size_t blocklen,
|
||||
uint32_t stripes,
|
||||
const uint8_t *in,
|
||||
|
||||
@@ -287,7 +287,7 @@ QCryptoIVGen *qcrypto_block_get_ivgen(QCryptoBlock *block);
|
||||
*
|
||||
* Returns: the hash algorithm
|
||||
*/
|
||||
QCryptoHashAlgorithm qcrypto_block_get_kdf_hash(QCryptoBlock *block);
|
||||
QCryptoHashAlgo qcrypto_block_get_kdf_hash(QCryptoBlock *block);
|
||||
|
||||
/**
|
||||
* qcrypto_block_get_payload_offset:
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
#define QCRYPTO_HASH_DIGEST_LEN_SHA512 64
|
||||
#define QCRYPTO_HASH_DIGEST_LEN_RIPEMD160 20
|
||||
|
||||
/* See also "QCryptoHashAlgorithm" defined in qapi/crypto.json */
|
||||
/* See also "QCryptoHashAlgo" defined in qapi/crypto.json */
|
||||
|
||||
/**
|
||||
* qcrypto_hash_supports:
|
||||
@@ -42,7 +42,7 @@
|
||||
*
|
||||
* Returns: true if the algorithm is supported, false otherwise
|
||||
*/
|
||||
gboolean qcrypto_hash_supports(QCryptoHashAlgorithm alg);
|
||||
gboolean qcrypto_hash_supports(QCryptoHashAlgo alg);
|
||||
|
||||
|
||||
/**
|
||||
@@ -53,7 +53,7 @@ gboolean qcrypto_hash_supports(QCryptoHashAlgorithm alg);
|
||||
*
|
||||
* Returns: the digest length in bytes
|
||||
*/
|
||||
size_t qcrypto_hash_digest_len(QCryptoHashAlgorithm alg);
|
||||
size_t qcrypto_hash_digest_len(QCryptoHashAlgo alg);
|
||||
|
||||
/**
|
||||
* qcrypto_hash_bytesv:
|
||||
@@ -73,7 +73,7 @@ size_t qcrypto_hash_digest_len(QCryptoHashAlgorithm alg);
|
||||
*
|
||||
* Returns: 0 on success, -1 on error
|
||||
*/
|
||||
int qcrypto_hash_bytesv(QCryptoHashAlgorithm alg,
|
||||
int qcrypto_hash_bytesv(QCryptoHashAlgo alg,
|
||||
const struct iovec *iov,
|
||||
size_t niov,
|
||||
uint8_t **result,
|
||||
@@ -98,7 +98,7 @@ int qcrypto_hash_bytesv(QCryptoHashAlgorithm alg,
|
||||
*
|
||||
* Returns: 0 on success, -1 on error
|
||||
*/
|
||||
int qcrypto_hash_bytes(QCryptoHashAlgorithm alg,
|
||||
int qcrypto_hash_bytes(QCryptoHashAlgo alg,
|
||||
const char *buf,
|
||||
size_t len,
|
||||
uint8_t **result,
|
||||
@@ -122,7 +122,7 @@ int qcrypto_hash_bytes(QCryptoHashAlgorithm alg,
|
||||
*
|
||||
* Returns: 0 on success, -1 on error
|
||||
*/
|
||||
int qcrypto_hash_digestv(QCryptoHashAlgorithm alg,
|
||||
int qcrypto_hash_digestv(QCryptoHashAlgo alg,
|
||||
const struct iovec *iov,
|
||||
size_t niov,
|
||||
char **digest,
|
||||
@@ -145,7 +145,7 @@ int qcrypto_hash_digestv(QCryptoHashAlgorithm alg,
|
||||
*
|
||||
* Returns: 0 on success, -1 on error
|
||||
*/
|
||||
int qcrypto_hash_digest(QCryptoHashAlgorithm alg,
|
||||
int qcrypto_hash_digest(QCryptoHashAlgo alg,
|
||||
const char *buf,
|
||||
size_t len,
|
||||
char **digest,
|
||||
@@ -168,7 +168,7 @@ int qcrypto_hash_digest(QCryptoHashAlgorithm alg,
|
||||
*
|
||||
* Returns: 0 on success, -1 on error
|
||||
*/
|
||||
int qcrypto_hash_base64v(QCryptoHashAlgorithm alg,
|
||||
int qcrypto_hash_base64v(QCryptoHashAlgo alg,
|
||||
const struct iovec *iov,
|
||||
size_t niov,
|
||||
char **base64,
|
||||
@@ -191,7 +191,7 @@ int qcrypto_hash_base64v(QCryptoHashAlgorithm alg,
|
||||
*
|
||||
* Returns: 0 on success, -1 on error
|
||||
*/
|
||||
int qcrypto_hash_base64(QCryptoHashAlgorithm alg,
|
||||
int qcrypto_hash_base64(QCryptoHashAlgo alg,
|
||||
const char *buf,
|
||||
size_t len,
|
||||
char **base64,
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
typedef struct QCryptoHmac QCryptoHmac;
|
||||
struct QCryptoHmac {
|
||||
QCryptoHashAlgorithm alg;
|
||||
QCryptoHashAlgo alg;
|
||||
void *opaque;
|
||||
void *driver;
|
||||
};
|
||||
@@ -31,7 +31,7 @@ struct QCryptoHmac {
|
||||
* Returns:
|
||||
* true if the algorithm is supported, false otherwise
|
||||
*/
|
||||
bool qcrypto_hmac_supports(QCryptoHashAlgorithm alg);
|
||||
bool qcrypto_hmac_supports(QCryptoHashAlgo alg);
|
||||
|
||||
/**
|
||||
* qcrypto_hmac_new:
|
||||
@@ -52,7 +52,7 @@ bool qcrypto_hmac_supports(QCryptoHashAlgorithm alg);
|
||||
* Returns:
|
||||
* a new hmac object, or NULL on error
|
||||
*/
|
||||
QCryptoHmac *qcrypto_hmac_new(QCryptoHashAlgorithm alg,
|
||||
QCryptoHmac *qcrypto_hmac_new(QCryptoHashAlgo alg,
|
||||
const uint8_t *key, size_t nkey,
|
||||
Error **errp);
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@
|
||||
*
|
||||
* QCryptoIVGen *ivgen = qcrypto_ivgen_new(QCRYPTO_IVGEN_ALG_ESSIV,
|
||||
* QCRYPTO_CIPHER_ALG_AES_128,
|
||||
* QCRYPTO_HASH_ALG_SHA256,
|
||||
* QCRYPTO_HASH_ALGO_SHA256,
|
||||
* key, nkey, errp);
|
||||
* if (!ivgen) {
|
||||
* return -1;
|
||||
@@ -135,7 +135,7 @@ typedef struct QCryptoIVGen QCryptoIVGen;
|
||||
*/
|
||||
QCryptoIVGen *qcrypto_ivgen_new(QCryptoIVGenAlgorithm alg,
|
||||
QCryptoCipherAlgorithm cipheralg,
|
||||
QCryptoHashAlgorithm hash,
|
||||
QCryptoHashAlgo hash,
|
||||
const uint8_t *key, size_t nkey,
|
||||
Error **errp);
|
||||
|
||||
@@ -191,7 +191,7 @@ QCryptoCipherAlgorithm qcrypto_ivgen_get_cipher(QCryptoIVGen *ivgen);
|
||||
*
|
||||
* Returns: the hash algorithm
|
||||
*/
|
||||
QCryptoHashAlgorithm qcrypto_ivgen_get_hash(QCryptoIVGen *ivgen);
|
||||
QCryptoHashAlgo qcrypto_ivgen_get_hash(QCryptoIVGen *ivgen);
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -50,7 +50,7 @@
|
||||
* return -1;
|
||||
* }
|
||||
*
|
||||
* iterations = qcrypto_pbkdf2_count_iters(QCRYPTO_HASH_ALG_SHA256,
|
||||
* iterations = qcrypto_pbkdf2_count_iters(QCRYPTO_HASH_ALGO_SHA256,
|
||||
* (const uint8_t *)password,
|
||||
* strlen(password),
|
||||
* salt, nkey, errp);
|
||||
@@ -60,7 +60,7 @@
|
||||
* return -1;
|
||||
* }
|
||||
*
|
||||
* if (qcrypto_pbkdf2(QCRYPTO_HASH_ALG_SHA256,
|
||||
* if (qcrypto_pbkdf2(QCRYPTO_HASH_ALGO_SHA256,
|
||||
* (const uint8_t *)password, strlen(password),
|
||||
* salt, nkey, iterations, key, nkey, errp) < 0) {
|
||||
* g_free(key);
|
||||
@@ -92,7 +92,7 @@
|
||||
*
|
||||
* Returns true if supported, false otherwise
|
||||
*/
|
||||
bool qcrypto_pbkdf2_supports(QCryptoHashAlgorithm hash);
|
||||
bool qcrypto_pbkdf2_supports(QCryptoHashAlgo hash);
|
||||
|
||||
|
||||
/**
|
||||
@@ -119,7 +119,7 @@ bool qcrypto_pbkdf2_supports(QCryptoHashAlgorithm hash);
|
||||
*
|
||||
* Returns: 0 on success, -1 on error
|
||||
*/
|
||||
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,
|
||||
@@ -147,7 +147,7 @@ int qcrypto_pbkdf2(QCryptoHashAlgorithm hash,
|
||||
*
|
||||
* Returns: number of iterations in 1 second, -1 on error
|
||||
*/
|
||||
uint64_t qcrypto_pbkdf2_count_iters(QCryptoHashAlgorithm hash,
|
||||
uint64_t qcrypto_pbkdf2_count_iters(QCryptoHashAlgo hash,
|
||||
const uint8_t *key, size_t nkey,
|
||||
const uint8_t *salt, size_t nsalt,
|
||||
size_t nout,
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
#include "crypto/hash.h"
|
||||
|
||||
int qcrypto_get_x509_cert_fingerprint(uint8_t *cert, size_t size,
|
||||
QCryptoHashAlgorithm hash,
|
||||
QCryptoHashAlgo hash,
|
||||
uint8_t *result,
|
||||
size_t *resultlen,
|
||||
Error **errp);
|
||||
|
||||
Reference in New Issue
Block a user