Received: by 10.223.185.116 with SMTP id b49csp2298717wrg; Thu, 15 Feb 2018 09:27:20 -0800 (PST) X-Google-Smtp-Source: AH8x226sMmf9xxkDyo/h5hM2Ri4zlbErGDnztsUyC3beEXzLKqQI7trOCciTqVY06Oj9gUVLxmC9 X-Received: by 10.98.48.2 with SMTP id w2mr3293680pfw.162.1518715640360; Thu, 15 Feb 2018 09:27:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518715640; cv=none; d=google.com; s=arc-20160816; b=bUVp9lDv52Zjp6YYohVDlNkY1nTsUNCh4jYyrVEjT8GvEoLb43pehPVikkmP7EMC4K Q25IJktj55qpCaHn6PNbwzMSRBN4C6PkBtXy7UkcrydyB9jB0bB8exML/eJnh4YURM60 447z3vuGsy7DiTP/b4sg6Bwk2B458Mtp2fPHaPbSRlRyHBQlDftDEABejvjFGhSr8fKc hEaufxL7EO162bg06TMLM4WBw2VlYPeN73ntS8+wZIRfmwT8zKv8eJXJ8rhtrg5w7DxZ hLAzawX5MwxRY459+6tumtPWEcubCnd2l9KwyKDvZvJyyteuCo9zkDPTgn+Rq+fDcPLk BERw== 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=OD3yHYxbbYvfac4O8aYU84SgoSh+hdeLVi5biWJF6L0=; b=Apsml17Do5iebP5ys8Ifse3++uHNjhozWj3rUGpqP1kfeGvh6my+iU3TXKM4s1EjEd zGhUlL6tkPQEL6J6dtAt7UgjTz0E2com7OT0BwG3vvJEDOk1jCAZHGyYGLCxSwBQmtU/ NYmLrW7vC/N4Jvym0euesYJYzip13qx45gKA1NdqlwtTPa+CDd3gFvu3BcFZCpJKVfoK 2ou9/hgjTNtiwMzvYpV746rGrNALpbQQ0LoiXvpuvxRegLn0u9LmSeAVroVor1rOOm2T gR2Tr+UZvPwJKu6pv8YfoouJxiO5RLmjii9oBO8kLQPhP5GuuaDFuValYhI8MOyAQxCH 35lg== 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 7si1992875pft.305.2018.02.15.09.27.05; Thu, 15 Feb 2018 09:27:20 -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 S1427325AbeBORZx (ORCPT + 99 others); Thu, 15 Feb 2018 12:25:53 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:57232 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1165129AbeBOPek (ORCPT ); Thu, 15 Feb 2018 10:34:40 -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 2D6AB1112; Thu, 15 Feb 2018 15:34:40 +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.14 114/195] crypto: hash - introduce crypto_hash_alg_has_setkey() Date: Thu, 15 Feb 2018 16:16:45 +0100 Message-Id: <20180215151711.389219837@linuxfoundation.org> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180215151705.738773577@linuxfoundation.org> References: <20180215151705.738773577@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.14-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 @@ -655,5 +655,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);