crypto: ensure qcrypto_hash_digest_len is always defined
The qcrypto_hash_digest_len method was accidentally inside a CONFIG_GNUTLS_HASH block, even though it doesn't depend on gnutls. Re-arrange it to be unconditionally defined. Reviewed-by: Fam Zheng <famz@redhat.com> Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
This commit is contained in:
parent
9884abee8f
commit
c0377a7cc6
@ -24,12 +24,8 @@
|
|||||||
#ifdef CONFIG_GNUTLS_HASH
|
#ifdef CONFIG_GNUTLS_HASH
|
||||||
#include <gnutls/gnutls.h>
|
#include <gnutls/gnutls.h>
|
||||||
#include <gnutls/crypto.h>
|
#include <gnutls/crypto.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
static int qcrypto_hash_alg_map[QCRYPTO_HASH_ALG__MAX] = {
|
|
||||||
[QCRYPTO_HASH_ALG_MD5] = GNUTLS_DIG_MD5,
|
|
||||||
[QCRYPTO_HASH_ALG_SHA1] = GNUTLS_DIG_SHA1,
|
|
||||||
[QCRYPTO_HASH_ALG_SHA256] = GNUTLS_DIG_SHA256,
|
|
||||||
};
|
|
||||||
|
|
||||||
static size_t qcrypto_hash_alg_size[QCRYPTO_HASH_ALG__MAX] = {
|
static size_t qcrypto_hash_alg_size[QCRYPTO_HASH_ALG__MAX] = {
|
||||||
[QCRYPTO_HASH_ALG_MD5] = 16,
|
[QCRYPTO_HASH_ALG_MD5] = 16,
|
||||||
@ -37,6 +33,22 @@ static size_t qcrypto_hash_alg_size[QCRYPTO_HASH_ALG__MAX] = {
|
|||||||
[QCRYPTO_HASH_ALG_SHA256] = 32,
|
[QCRYPTO_HASH_ALG_SHA256] = 32,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
size_t qcrypto_hash_digest_len(QCryptoHashAlgorithm alg)
|
||||||
|
{
|
||||||
|
if (alg >= G_N_ELEMENTS(qcrypto_hash_alg_size)) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return qcrypto_hash_alg_size[alg];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef CONFIG_GNUTLS_HASH
|
||||||
|
static int qcrypto_hash_alg_map[QCRYPTO_HASH_ALG__MAX] = {
|
||||||
|
[QCRYPTO_HASH_ALG_MD5] = GNUTLS_DIG_MD5,
|
||||||
|
[QCRYPTO_HASH_ALG_SHA1] = GNUTLS_DIG_SHA1,
|
||||||
|
[QCRYPTO_HASH_ALG_SHA256] = GNUTLS_DIG_SHA256,
|
||||||
|
};
|
||||||
|
|
||||||
gboolean qcrypto_hash_supports(QCryptoHashAlgorithm alg)
|
gboolean qcrypto_hash_supports(QCryptoHashAlgorithm alg)
|
||||||
{
|
{
|
||||||
if (alg < G_N_ELEMENTS(qcrypto_hash_alg_map)) {
|
if (alg < G_N_ELEMENTS(qcrypto_hash_alg_map)) {
|
||||||
@ -45,14 +57,6 @@ gboolean qcrypto_hash_supports(QCryptoHashAlgorithm alg)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t qcrypto_hash_digest_len(QCryptoHashAlgorithm alg)
|
|
||||||
{
|
|
||||||
if (alg >= G_N_ELEMENTS(qcrypto_hash_alg_size)) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return qcrypto_hash_alg_size[alg];
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int qcrypto_hash_bytesv(QCryptoHashAlgorithm alg,
|
int qcrypto_hash_bytesv(QCryptoHashAlgorithm alg,
|
||||||
const struct iovec *iov,
|
const struct iovec *iov,
|
||||||
|
Loading…
Reference in New Issue
Block a user