From patchwork Wed Jan 20 17:38:43 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= X-Patchwork-Id: 8073231 Return-Path: X-Original-To: patchwork-qemu-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 82893BEEED for ; Wed, 20 Jan 2016 17:39:31 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id EC420204D1 for ; Wed, 20 Jan 2016 17:39:30 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 4CE3B20268 for ; Wed, 20 Jan 2016 17:39:30 +0000 (UTC) Received: from localhost ([::1]:44382 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aLwjB-0007bH-Gk for patchwork-qemu-devel@patchwork.kernel.org; Wed, 20 Jan 2016 12:39:29 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47994) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aLwiv-0007VQ-G8 for qemu-devel@nongnu.org; Wed, 20 Jan 2016 12:39:17 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aLwiu-0007Gq-Mj for qemu-devel@nongnu.org; Wed, 20 Jan 2016 12:39:13 -0500 Received: from mx1.redhat.com ([209.132.183.28]:56279) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aLwip-0007Ez-Nk; Wed, 20 Jan 2016 12:39:07 -0500 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (Postfix) with ESMTPS id 5C71FC0AD1C9; Wed, 20 Jan 2016 17:39:07 +0000 (UTC) Received: from t530wlan.home.berrange.com.com (vpn1-6-168.ams2.redhat.com [10.36.6.168]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u0KHd3eK026310; Wed, 20 Jan 2016 12:39:05 -0500 From: "Daniel P. Berrange" To: qemu-devel@nongnu.org Date: Wed, 20 Jan 2016 17:38:43 +0000 Message-Id: <1453311539-1193-2-git-send-email-berrange@redhat.com> In-Reply-To: <1453311539-1193-1-git-send-email-berrange@redhat.com> References: <1453311539-1193-1-git-send-email-berrange@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , Fam Zheng , qemu-block@nongnu.org Subject: [Qemu-devel] [PATCH v2 01/17] crypto: ensure qcrypto_hash_digest_len is always defined X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 Reviewed-by: Fam Zheng --- crypto/hash.c | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) 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 #include +#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,