Received: by 10.223.185.116 with SMTP id b49csp694147wrg; Fri, 16 Feb 2018 05:49:06 -0800 (PST) X-Google-Smtp-Source: AH8x224qdao52PFQh7esd2BTUx47I3ydRounQ/tdYPs7MMcK6PN3UKxfvbM6u8xJS34PaeJeJ1+s X-Received: by 10.99.96.200 with SMTP id u191mr5252029pgb.252.1518788946319; Fri, 16 Feb 2018 05:49:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518788946; cv=none; d=google.com; s=arc-20160816; b=iE9zCmx4/nFMT8biHW+cvBo05wPvaspV4js0JcSXwGM0A3KhQvoKwanFJ4QUfyiOfg HQGco56WjF6VtPPgAWqDJj1qnbik87Us3/WofTFbetvKWHofmnfeZcoXH0CKUQarwWgt z0YMCUOJNI1tdeomCmZfh0JJYMgP44K82f1tf+J07aUy+4SRAJzCNoL1oxSnJ/tSTuts 0PY1vGNs2VNEQ44w2nLPpS4/0DjXepS19oFyn/wlhuQRpvcqiEuYk6jwlvrhhwujjPTj fIeoCQJjyE62X6eHqFjLtqgkQbumioZpb9IZl19L1vcVCgcdhYCkJFq9BWzLq0pudbp/ TZng== 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=r21UI0UVPHiIKEdbrQO4VgIsO5ynKosgFrCTyVpLM/I=; b=xVenWKzhRaEZlN6vG/C1j8HW28i63SsDN8sHk6Z7AwD5VJyjEEjhK/6qZ39NFNd2F6 gOJr3f2BnlIzL2xnblgKUvyTMGiUQL2EsZvwi97t7j9aw3XKc3sQ5sf+EPFuL5531IS1 +fc+UIVeGv5waTilpuR79sDHVFAQ+xg7i2goJJmhooZsKUtatlpnaC1RjZExaK9VeEwO ndQKeNojO/VOQmhc4uCwBbKudVlvrrNU93igRTKvhZ3RqzcuXAsd9ftyIuyhgqR5YwLL GBbI9eYTRaXrold+mVsqqeSTQ7ne+kiWxxlYs2IA7S5b3mZqOPnVKw1M/GeVxPVWu1VL cxQQ== 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 c11si3339252pgq.305.2018.02.16.05.48.51; Fri, 16 Feb 2018 05:49:06 -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 S1166794AbeBOSl7 (ORCPT + 99 others); Thu, 15 Feb 2018 13:41:59 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:51424 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1162709AbeBOPXm (ORCPT ); Thu, 15 Feb 2018 10:23:42 -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 935BFE8C; Thu, 15 Feb 2018 15:23:22 +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.4 067/108] crypto: hash - introduce crypto_hash_alg_has_setkey() Date: Thu, 15 Feb 2018 16:17:04 +0100 Message-Id: <20180215151231.745826608@linuxfoundation.org> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180215151222.267507937@linuxfoundation.org> References: <20180215151222.267507937@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.4-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 @@ -637,5 +637,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);