Received: by 10.223.185.116 with SMTP id b49csp2161853wrg; Thu, 15 Feb 2018 07:28:02 -0800 (PST) X-Google-Smtp-Source: AH8x227eQ9oWOhJxSRx0a3l4s9529l5/8IUqiC8g9CP3Ygk63NPFBTRUMNELDphPhhRXljBiWJrw X-Received: by 10.99.97.205 with SMTP id v196mr2494064pgb.319.1518708482818; Thu, 15 Feb 2018 07:28:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518708482; cv=none; d=google.com; s=arc-20160816; b=Z5m5oQYC4Wi/0Ud7MjYFaWY5uI/s9I1pBxAGALjX4vlEAi03AhsBLwdnrUon4cAl78 sEBuyiyiruky8xcegcQaEJuQYU0eHr6CMTUt0yDFiXWL2ntb/6axG1XvopvgojhkimXp qO2GD2GBQPqS0RuICU+CbwvgMQ18tRrgBE6X6GPyLj4T/Cx5vPfr3DWJp4icahgU1BAi LR4ZjstzH1dRsDU8mtj6vhN1nqZ80SYICOWwLtUfKhc4Bd8/a63Z6HBoiAd4NaE+pohb O9SrKWCtKf9yYT5BK5PZoyPG2mSnVoc/NAoLuFSnB5XLQg/YGkKjhXTcW1JvcxxhHqLV Q0dA== 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=iTVu6HASsics833liQDuzl9UsMy2hFlsRKS0SRucBdM=; b=qm06k8bKVlV6W8GVIRZtbkmZKc9IHGdKUh76LbUyw40EjKlrQuhpJ0hsx4tK82u1UH FFRN5ayIW6FDCMgKfSyNMZObKJzQK1YXB0EbxogXxFBtSGtktRiTzlz8TXKBZejCnxw6 +8s+0s2KiaedVvTsFWPpNnLdz69A0TZ7sK8lkGIsOMs3OH9kKeuRhY4r3Bl6fny1vS6Z l7iR5/mmoGj5n97K+mX/L6C4KbGNYL/Qg0FZjGA8V2gm0xl0ARTg19GdYEdIFYmyUnSq iJWYkF7kUVL6lBraGpUV7FCy5BSVfuVfL/ZEXg4lgVforZ0x5kSafNgnGF1X+LJiUWb0 jL7g== 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 i2si1351338pgo.550.2018.02.15.07.27.48; Thu, 15 Feb 2018 07:28:02 -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 S1163462AbeBOP0q (ORCPT + 99 others); Thu, 15 Feb 2018 10:26:46 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:53208 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1163369AbeBOP0n (ORCPT ); Thu, 15 Feb 2018 10:26:43 -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 7725F360; Thu, 15 Feb 2018 15:26:42 +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 4.9 31/88] crypto: hash - introduce crypto_hash_alg_has_setkey() Date: Thu, 15 Feb 2018 16:16:58 +0100 Message-Id: <20180215151226.975885365@linuxfoundation.org> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180215151222.437136975@linuxfoundation.org> References: <20180215151222.437136975@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 4.9-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 @@ -625,5 +625,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 @@ -88,6 +88,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);