Received: by 10.223.185.116 with SMTP id b49csp2448527wrg; Thu, 15 Feb 2018 11:43:54 -0800 (PST) X-Google-Smtp-Source: AH8x226h/M4XPSD52S7CpR5BsDZzDEbaW9rMhvw04orc2qffTa0f/6ZR54Jgmn4Yyx0lEra0sxhR X-Received: by 2002:a17:902:5788:: with SMTP id l8-v6mr3150953pli.56.1518723834090; Thu, 15 Feb 2018 11:43:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518723834; cv=none; d=google.com; s=arc-20160816; b=MwOZ4cUks9w7GZy5gtPcLnYggOMsYgOiEzlSRJykt0RHYL0AyeV4E7BvAPwysBmP6T 9trihwMcAoHY0DiWd7x5+3Eu4T7KCj0/H0P3Vad55cMRcQWuXM7L0tGHPJJ4WwuG76nQ T0sXJHwSQJxORhupBk5bWybTucRmR+WyV5Jd/PTVn9jcdvVAfX++d+IqloaJZRPV11lP 48lRU8e1JxUHPpeWCwiIpfQoT7MOt4v/3bNSnJkbtbs1fsmzVN9ucMkWI8qoF+HKwea3 XUGsoi0506iLxysoCxmL8zmW1msM7BVciTdZO+RwMpmF4OgsLrBz6QXOPuYRJaGPaiU4 t+vw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=+WavQRHdyMkzESrKvT0BvG3KADAdB+ti5fc8+58rYuQ=; b=Ks4PyK4gml9gfdAuZf0idheKEXk3a9wuFm1Ha7Vl9cqsIm8jQjESTy5MAZScbabzKA QegHR3+g7iPp+xKR0WzmDy+ftCEXTS0M7rW6kP7cpwDmMfPwxVyT8+zuA1X1QVWaRGCy vsK9rtnDocgsq8QBmtfWSgGJPBXfypgUSOEFQaMHMm4P4fZxzhhUTB5tu9wYAS4OqU0b lZ3Wk02NLHuovFYjzdGjC9e8u4mbPET5BzwRmq5RvDCgAgt9nAvm+Y0o7DJgZGiqWDeq taiMlbW3BZejKxsBlCAdhWN8QBT0rxnr7vynGVujsyy5eClCMwmN5zPmsTaN8FizbEIY yJvg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b1-v6si3611235plc.260.2018.02.15.11.43.39; Thu, 15 Feb 2018 11:43:54 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1033846AbeBOPTi (ORCPT + 99 others); Thu, 15 Feb 2018 10:19:38 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:47944 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1161367AbeBOPTg (ORCPT ); Thu, 15 Feb 2018 10:19:36 -0500 Received: from localhost (LFbn-1-12258-90.w90-92.abo.wanadoo.fr [90.92.71.90]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 45616105B; Thu, 15 Feb 2018 15:19:35 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Eric Biggers , Herbert Xu Subject: [PATCH 3.18 31/45] crypto: hash - introduce crypto_hash_alg_has_setkey() Date: Thu, 15 Feb 2018 16:17:22 +0100 Message-Id: <20180215144122.598907501@linuxfoundation.org> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180215144115.863307741@linuxfoundation.org> References: <20180215144115.863307741@linuxfoundation.org> User-Agent: quilt/0.65 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Eric Biggers commit cd6ed77ad5d223dc6299fb58f62e0f5267f7e2ba upstream. Templates that use an shash spawn can use crypto_shash_alg_has_setkey() to determine whether the underlying algorithm requires a key or not. But there was no corresponding function for ahash spawns. Add it. Note that the new function actually has to support both shash and ahash algorithms, since the ahash API can be used with either. Signed-off-by: Eric Biggers Signed-off-by: Herbert Xu Signed-off-by: Greg Kroah-Hartman --- crypto/ahash.c | 11 +++++++++++ include/crypto/internal/hash.h | 2 ++ 2 files changed, 13 insertions(+) --- a/crypto/ahash.c +++ b/crypto/ahash.c @@ -636,5 +636,16 @@ struct hash_alg_common *ahash_attr_alg(s } EXPORT_SYMBOL_GPL(ahash_attr_alg); +bool crypto_hash_alg_has_setkey(struct hash_alg_common *halg) +{ + struct crypto_alg *alg = &halg->base; + + if (alg->cra_type != &crypto_ahash_type) + return crypto_shash_alg_has_setkey(__crypto_shash_alg(alg)); + + return __crypto_ahash_alg(alg)->setkey != NULL; +} +EXPORT_SYMBOL_GPL(crypto_hash_alg_has_setkey); + MODULE_LICENSE("GPL"); MODULE_DESCRIPTION("Asynchronous cryptographic hash type"); --- a/include/crypto/internal/hash.h +++ b/include/crypto/internal/hash.h @@ -91,6 +91,8 @@ static inline bool crypto_shash_alg_has_ return alg->setkey != shash_no_setkey; } +bool crypto_hash_alg_has_setkey(struct hash_alg_common *halg); + int crypto_init_ahash_spawn(struct crypto_ahash_spawn *spawn, struct hash_alg_common *alg, struct crypto_instance *inst);