diff mbox

[v2,01/17] crypto: ensure qcrypto_hash_digest_len is always defined

Message ID 1453311539-1193-2-git-send-email-berrange@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Daniel P. Berrangé Jan. 20, 2016, 5:38 p.m. UTC
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.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
---
 crypto/hash.c | 30 +++++++++++++++++-------------
 1 file changed, 17 insertions(+), 13 deletions(-)

Comments

Fam Zheng Jan. 21, 2016, 6:12 a.m. UTC | #1
On Wed, 01/20 17:38, Daniel P. Berrange wrote:
> 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.
> 
> Signed-off-by: Daniel P. Berrange <berrange@redhat.com>

Reviewed-by: Fam Zheng <famz@redhat.com>
diff mbox

Patch

diff --git a/crypto/hash.c b/crypto/hash.c
index 6e83f43..24cabd5 100644
--- a/crypto/hash.c
+++ b/crypto/hash.c
@@ -23,12 +23,8 @@ 
 #ifdef CONFIG_GNUTLS_HASH
 #include <gnutls/gnutls.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] = {
     [QCRYPTO_HASH_ALG_MD5] = 16,
@@ -36,14 +32,6 @@  static size_t qcrypto_hash_alg_size[QCRYPTO_HASH_ALG__MAX] = {
     [QCRYPTO_HASH_ALG_SHA256] = 32,
 };
 
-gboolean qcrypto_hash_supports(QCryptoHashAlgorithm alg)
-{
-    if (alg < G_N_ELEMENTS(qcrypto_hash_alg_map)) {
-        return true;
-    }
-    return false;
-}
-
 size_t qcrypto_hash_digest_len(QCryptoHashAlgorithm alg)
 {
     if (alg >= G_N_ELEMENTS(qcrypto_hash_alg_size)) {
@@ -53,6 +41,22 @@  size_t qcrypto_hash_digest_len(QCryptoHashAlgorithm 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)
+{
+    if (alg < G_N_ELEMENTS(qcrypto_hash_alg_map)) {
+        return true;
+    }
+    return false;
+}
+
+
 int qcrypto_hash_bytesv(QCryptoHashAlgorithm alg,
                         const struct iovec *iov,
                         size_t niov,