Received: by 10.223.185.116 with SMTP id b49csp366542wrg; Thu, 15 Feb 2018 23:48:56 -0800 (PST) X-Google-Smtp-Source: AH8x224zpAeoN8v//h2aNVdfmvKno+maAVkr/mbOBUD+0IbOcAR2ZVVex2uIqJOPiVP8DnuHBbUp X-Received: by 10.98.72.204 with SMTP id q73mr4831216pfi.48.1518767336152; Thu, 15 Feb 2018 23:48:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518767336; cv=none; d=google.com; s=arc-20160816; b=ylrQxqKVoo2rzbsgoxpbhS0eMDDZ4xAyjvPHSUt/0C3SSDkm5i2mgEDwihJ1bdnMHT YXkQas+xfisD+orF1P/RU+7eKTdEE9oskm2PzMM1Qk3Z1bUPRCM7b41sbxq93wp8Tz9w bhnNaHtY44+VrZx68ItEvjOvbcraVIr7ZdVq+WUTWMEMagGBIUCCpG0ffspdl2iTZt8o qumcrjstJHbjI5o53tsFiB8Z0odns3lkTcp57iZo5TLVMymVkfTg3ZHDEaGG2rlmD2jf DtkAMC5iurKfEO/xPvqtE3NL23z4/zo9wxy4MPqJYkUaP0qCJ5QVWF/Jl44sbUe9BDD3 APNA== 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=2L+kV8D08mBSoCtpDsMc+hBybxhDF80vR1jj2JriSaA=; b=aFoRh2EaseoSdwVR/nuiaLwJIe+7Nq/9DJKi7o31WyjUdAkc++0tJCNbjd8lPateHY 83CVmdIjdGIsd+3fgTz83hKQCTp39GQRP3gdLi6Bto+4iDA8QF/Be2XQdEMbi70DeN8K bQhBm/1keovv94z2qJmL6HHr4CVrHpqEqADBetNBCOdTrc03b74JxcHA2GwlDZBenZe4 uRRs0Q+lsR1Ve4yjswjrSFtmui0nlNyaDVl/2CGfLatWv72wRPJ45XIw9+ez1Lp03IZH DVJGzwuO2Re6nfPFnEYrA4ewSdb6os/3pIHDBqHyRopdnr0+XKa91dtPLpu50xhG5H7h +GDA== 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 z1-v6si2676997plb.178.2018.02.15.23.48.40; Thu, 15 Feb 2018 23:48:56 -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 S1165585AbeBOQU3 (ORCPT + 99 others); Thu, 15 Feb 2018 11:20:29 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:34012 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1165279AbeBOPnc (ORCPT ); Thu, 15 Feb 2018 10:43:32 -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 C3402117F; Thu, 15 Feb 2018 15:43:31 +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.15 108/202] crypto: hash - introduce crypto_hash_alg_has_setkey() Date: Thu, 15 Feb 2018 16:16:48 +0100 Message-Id: <20180215151718.892416554@linuxfoundation.org> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180215151712.768794354@linuxfoundation.org> References: <20180215151712.768794354@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.15-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 @@ -649,5 +649,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 @@ -90,6 +90,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);