From patchwork Tue Feb 2 13:15:23 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: 8190281 Return-Path: X-Original-To: patchwork-qemu-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 927F79FBE9 for ; Tue, 2 Feb 2016 13:15:47 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E2F6620279 for ; Tue, 2 Feb 2016 13:15:46 +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 2A2A3201F5 for ; Tue, 2 Feb 2016 13:15:46 +0000 (UTC) Received: from localhost ([::1]:57092 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aQao5-0002cD-EJ for patchwork-qemu-devel@patchwork.kernel.org; Tue, 02 Feb 2016 08:15:45 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36916) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aQanu-0002bV-15 for qemu-devel@nongnu.org; Tue, 02 Feb 2016 08:15:35 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aQant-0000lt-5B for qemu-devel@nongnu.org; Tue, 02 Feb 2016 08:15:33 -0500 Received: from mx1.redhat.com ([209.132.183.28]:33556) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aQans-0000ln-SB for qemu-devel@nongnu.org; Tue, 02 Feb 2016 08:15:33 -0500 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id 9539DC0A848A; Tue, 2 Feb 2016 13:15:32 +0000 (UTC) Received: from t530wlan.home.berrange.com.com (vpn1-5-164.ams2.redhat.com [10.36.5.164]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u12DFRtr021577; Tue, 2 Feb 2016 08:15:31 -0500 From: "Daniel P. Berrange" To: qemu-devel@nongnu.org Date: Tue, 2 Feb 2016 13:15:23 +0000 Message-Id: <1454418923-19489-4-git-send-email-berrange@redhat.com> In-Reply-To: <1454418923-19489-1-git-send-email-berrange@redhat.com> References: <1454418923-19489-1-git-send-email-berrange@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Peter Maydell Subject: [Qemu-devel] [PULL v1 3/3] 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. Reviewed-by: Fam Zheng Signed-off-by: Daniel P. Berrange --- crypto/hash.c | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/crypto/hash.c b/crypto/hash.c index 33324b6..4a8c0ca 100644 --- a/crypto/hash.c +++ b/crypto/hash.c @@ -24,12 +24,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, @@ -37,14 +33,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)) { @@ -54,6 +42,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,