From patchwork Sat May 2 05:31:03 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Biggers X-Patchwork-Id: 11523693 X-Patchwork-Delegate: herbert@gondor.apana.org.au Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8F1F84177 for ; Sat, 2 May 2020 05:33:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7623F206C0 for ; Sat, 2 May 2020 05:33:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1588397614; bh=Xy09gJgOkkbJ0ZYrb6dZNClW7tkDv1nBUg2GeKdk1cQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=Kp0SPO/W6zXrc++WrjsBjENFraloC4ORDchEdT0m+bBZxJ0xB5sH4y0vp9JjOfXy3 NhMGCs3xfTVqeeaM0Y49sWyaPTYbzFee5Yr+0LmEir1GqaLySBAqGdxbfSo+c370Ib g1MAsoiHCnQb0Gr5oKEP+4KAQiJEvxRr9AI+aJFw= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726896AbgEBFdc (ORCPT ); Sat, 2 May 2020 01:33:32 -0400 Received: from mail.kernel.org ([198.145.29.99]:39030 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726058AbgEBFdb (ORCPT ); Sat, 2 May 2020 01:33:31 -0400 Received: from sol.hsd1.ca.comcast.net (c-107-3-166-239.hsd1.ca.comcast.net [107.3.166.239]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 40D182184D; Sat, 2 May 2020 05:33:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1588397610; bh=Xy09gJgOkkbJ0ZYrb6dZNClW7tkDv1nBUg2GeKdk1cQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lAXfGF92DERufghwz00F/QIgqNab18uegXgVsfl+gbihI7P/p7oBkSo2b7SRYemMo leI+9L+LpjxypzBwDoEDHo1kF1Vsv7aU4ikYmzDLr8A4ucNa1VtsvN0WpnFizpRcYI 5y9cBCWx62jX8rIidTrAwvjSxsV+xDpN0LwZDndU= From: Eric Biggers To: linux-crypto@vger.kernel.org Cc: Cheng-Yi Chiang , ecryptfs@vger.kernel.org, Enric Balletbo i Serra , Gilad Ben-Yossef , Guenter Roeck , Jesper Nilsson , Kamil Konieczny , keyrings@vger.kernel.org, Krzysztof Kozlowski , Krzysztof Opasiak , Lars Persson , linux-bluetooth@vger.kernel.org, linux-mtd@lists.infradead.org, linux-nfs@vger.kernel.org, linux-sctp@vger.kernel.org, Robert Baldyga , Tom Lendacky , Vladimir Zapolskiy , Zaibo Xu Subject: [PATCH 01/20] crypto: hash - introduce crypto_shash_tfm_digest() Date: Fri, 1 May 2020 22:31:03 -0700 Message-Id: <20200502053122.995648-2-ebiggers@kernel.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200502053122.995648-1-ebiggers@kernel.org> References: <20200502053122.995648-1-ebiggers@kernel.org> MIME-Version: 1.0 Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org From: Eric Biggers Currently the simplest use of the shash API is to use crypto_shash_digest() to digest a whole buffer. However, this still requires allocating a hash descriptor (struct shash_desc). Many users don't really want to preallocate one and instead just use a one-off descriptor on the stack like the following: { SHASH_DESC_ON_STACK(desc, tfm); int err; desc->tfm = tfm; err = crypto_shash_digest(desc, data, len, out); shash_desc_zero(desc); } Wrap this in a new helper function crypto_shash_tfm_digest() that can be used instead of the above. Signed-off-by: Eric Biggers --- crypto/shash.c | 16 ++++++++++++++++ include/crypto/hash.h | 19 +++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/crypto/shash.c b/crypto/shash.c index c075b26c2a1d9f..e6a4b5f39b8c64 100644 --- a/crypto/shash.c +++ b/crypto/shash.c @@ -206,6 +206,22 @@ int crypto_shash_digest(struct shash_desc *desc, const u8 *data, } EXPORT_SYMBOL_GPL(crypto_shash_digest); +int crypto_shash_tfm_digest(struct crypto_shash *tfm, const u8 *data, + unsigned int len, u8 *out) +{ + SHASH_DESC_ON_STACK(desc, tfm); + int err; + + desc->tfm = tfm; + + err = crypto_shash_digest(desc, data, len, out); + + shash_desc_zero(desc); + + return err; +} +EXPORT_SYMBOL_GPL(crypto_shash_tfm_digest); + static int shash_default_export(struct shash_desc *desc, void *out) { memcpy(out, shash_desc_ctx(desc), crypto_shash_descsize(desc->tfm)); diff --git a/include/crypto/hash.h b/include/crypto/hash.h index cee446c59497c6..4829d2367eda87 100644 --- a/include/crypto/hash.h +++ b/include/crypto/hash.h @@ -855,6 +855,25 @@ int crypto_shash_setkey(struct crypto_shash *tfm, const u8 *key, int crypto_shash_digest(struct shash_desc *desc, const u8 *data, unsigned int len, u8 *out); +/** + * crypto_shash_tfm_digest() - calculate message digest for buffer + * @tfm: hash transformation object + * @data: see crypto_shash_update() + * @len: see crypto_shash_update() + * @out: see crypto_shash_final() + * + * This is a simplified version of crypto_shash_digest() for users who don't + * want to allocate their own hash descriptor (shash_desc). Instead, + * crypto_shash_tfm_digest() takes a hash transformation object (crypto_shash) + * directly, and it allocates a hash descriptor on the stack internally. + * Note that this stack allocation may be fairly large. + * + * Context: Any context. + * Return: 0 on success; < 0 if an error occurred. + */ +int crypto_shash_tfm_digest(struct crypto_shash *tfm, const u8 *data, + unsigned int len, u8 *out); + /** * crypto_shash_export() - extract operational state for message digest * @desc: reference to the operational state handle whose state is exported From patchwork Sat May 2 05:31:04 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Biggers X-Patchwork-Id: 11523695 X-Patchwork-Delegate: herbert@gondor.apana.org.au Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3B09181 for ; Sat, 2 May 2020 05:33:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 248FF2184D for ; Sat, 2 May 2020 05:33:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1588397617; bh=oBgtRZJ95t0RPE1PvPURSgv/NWE/2cwO3eTdsW65i6s=; h=From:To:Subject:Date:In-Reply-To:References:List-ID:From; b=CqwPzjgSHGCZHXkqfjrbztwuqdZYXalWlqfH1nQrik4IBBrCxFTjp91ngGFsnxuf/ YPQkKsJZWl2uyEiPDqfZ0wjbX1bWTI0OM8auIR1eye5Rbo7U+yGjn3TLyG3+fVvnOP /jCjuYuafDogJ1aA/7SggMZEPxByShCcDDTxTakY= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727101AbgEBFde (ORCPT ); Sat, 2 May 2020 01:33:34 -0400 Received: from mail.kernel.org ([198.145.29.99]:39100 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726058AbgEBFdd (ORCPT ); Sat, 2 May 2020 01:33:33 -0400 Received: from sol.hsd1.ca.comcast.net (c-107-3-166-239.hsd1.ca.comcast.net [107.3.166.239]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 7D9D5206D9 for ; Sat, 2 May 2020 05:33:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1588397613; bh=oBgtRZJ95t0RPE1PvPURSgv/NWE/2cwO3eTdsW65i6s=; h=From:To:Subject:Date:In-Reply-To:References:From; b=HijCSXk8llDX/K/Vs+fKG49fcNVvd9NOD3xrUuspSRiIBahSQK+zg7EdrvJADX3Ao EsTtBrzJxplkDfa430wjy4lLofANPnPH0Q2KpYyc7vuvalnwUf6vQB7OXY9GAsEgR8 9S7nL/DV1Q9kW6VwOxoTajwI09PodSJYkJxeCX+E= From: Eric Biggers To: linux-crypto@vger.kernel.org Subject: [PATCH 02/20] crypto: arm64/aes-glue - use crypto_shash_tfm_digest() Date: Fri, 1 May 2020 22:31:04 -0700 Message-Id: <20200502053122.995648-3-ebiggers@kernel.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200502053122.995648-1-ebiggers@kernel.org> References: <20200502053122.995648-1-ebiggers@kernel.org> MIME-Version: 1.0 Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org From: Eric Biggers Instead of manually allocating a 'struct shash_desc' on the stack and calling crypto_shash_digest(), switch to using the new helper function crypto_shash_tfm_digest() which does this for us. Signed-off-by: Eric Biggers --- arch/arm64/crypto/aes-glue.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/arch/arm64/crypto/aes-glue.c b/arch/arm64/crypto/aes-glue.c index ed5409c6abf4e9..395bbf64b2abb3 100644 --- a/arch/arm64/crypto/aes-glue.c +++ b/arch/arm64/crypto/aes-glue.c @@ -158,7 +158,6 @@ static int __maybe_unused essiv_cbc_set_key(struct crypto_skcipher *tfm, unsigned int key_len) { struct crypto_aes_essiv_cbc_ctx *ctx = crypto_skcipher_ctx(tfm); - SHASH_DESC_ON_STACK(desc, ctx->hash); u8 digest[SHA256_DIGEST_SIZE]; int ret; @@ -166,8 +165,7 @@ static int __maybe_unused essiv_cbc_set_key(struct crypto_skcipher *tfm, if (ret) return ret; - desc->tfm = ctx->hash; - crypto_shash_digest(desc, in_key, key_len, digest); + crypto_shash_tfm_digest(ctx->hash, in_key, key_len, digest); return aes_expandkey(&ctx->key2, digest, sizeof(digest)); } From patchwork Sat May 2 05:31:05 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Biggers X-Patchwork-Id: 11523697 X-Patchwork-Delegate: herbert@gondor.apana.org.au Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 608BE1862 for ; Sat, 2 May 2020 05:33:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 404F92184D for ; Sat, 2 May 2020 05:33:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1588397617; bh=mgAQWx3YPWufgVopYjpl/NTHhVsiPfEnGvfZih9FCOY=; h=From:To:Subject:Date:In-Reply-To:References:List-ID:From; b=yxpx0Tyn6qeEPwsbpbFlfVg79SQ3t9a4d9P0DHdh5WGQSD0uAt9MAoiMiHZuYJO89 ZPExWIN7OVSA6rX1iWxAmrL50OUtr8X4oKN+KaonbRVfWeIjV59tqD4tXSyD1xdDmZ gucL7QXePu98mI5nkJQPQcpKHW1WxVKhEQGk0xlg= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727113AbgEBFdf (ORCPT ); Sat, 2 May 2020 01:33:35 -0400 Received: from mail.kernel.org ([198.145.29.99]:39134 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726058AbgEBFdf (ORCPT ); Sat, 2 May 2020 01:33:35 -0400 Received: from sol.hsd1.ca.comcast.net (c-107-3-166-239.hsd1.ca.comcast.net [107.3.166.239]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 0E07320643 for ; Sat, 2 May 2020 05:33:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1588397615; bh=mgAQWx3YPWufgVopYjpl/NTHhVsiPfEnGvfZih9FCOY=; h=From:To:Subject:Date:In-Reply-To:References:From; b=1YTK2g4aZ2ZKA1ffP1YUk5Jey5HbpkpnYWpJdU9+oHOkaOT9b4pS2awMqrIEnyGPI 9jpdKeBu6e2kF0EV5Gx1HbfeQvtzs8ZaMkVFcOhzvUwznm41qmsPZmBO3w/YUGXGQG sS3/uYqT56bdEUkjoA8z5+fQ2kbTQ/2YRuJphWxc= From: Eric Biggers To: linux-crypto@vger.kernel.org Subject: [PATCH 03/20] crypto: essiv - use crypto_shash_tfm_digest() Date: Fri, 1 May 2020 22:31:05 -0700 Message-Id: <20200502053122.995648-4-ebiggers@kernel.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200502053122.995648-1-ebiggers@kernel.org> References: <20200502053122.995648-1-ebiggers@kernel.org> MIME-Version: 1.0 Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org From: Eric Biggers Instead of manually allocating a 'struct shash_desc' on the stack and calling crypto_shash_digest(), switch to using the new helper function crypto_shash_tfm_digest() which does this for us. Signed-off-by: Eric Biggers --- crypto/essiv.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/crypto/essiv.c b/crypto/essiv.c index 465a89c9d1effe..a7f45dbc4ee289 100644 --- a/crypto/essiv.c +++ b/crypto/essiv.c @@ -66,7 +66,6 @@ static int essiv_skcipher_setkey(struct crypto_skcipher *tfm, const u8 *key, unsigned int keylen) { struct essiv_tfm_ctx *tctx = crypto_skcipher_ctx(tfm); - SHASH_DESC_ON_STACK(desc, tctx->hash); u8 salt[HASH_MAX_DIGESTSIZE]; int err; @@ -78,8 +77,7 @@ static int essiv_skcipher_setkey(struct crypto_skcipher *tfm, if (err) return err; - desc->tfm = tctx->hash; - err = crypto_shash_digest(desc, key, keylen, salt); + err = crypto_shash_tfm_digest(tctx->hash, key, keylen, salt); if (err) return err; From patchwork Sat May 2 05:31:06 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Biggers X-Patchwork-Id: 11523699 X-Patchwork-Delegate: herbert@gondor.apana.org.au Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0B7BA81 for ; Sat, 2 May 2020 05:33:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DE53524956 for ; Sat, 2 May 2020 05:33:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1588397623; bh=Cay7/GP0dae7IJrK064oyAbylA+W00bKDeNseMLpuzM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=uhM9mQcnNPk3pSCW3+/cYOPfqdHu2Hp29V/lgTE0qoKvQL5vCGV54gE8lEGuqp87t mKQ0EzyY2AXYF+Dl1RKeCubPOW8R5g2fVOnhSBKCA6AJWhxY7BTpK24J93IGw/RLcX +xW0fnxVg2ZckzzZLSbDNnXVOQ2bkJRO/jCAeVAs= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727115AbgEBFdn (ORCPT ); Sat, 2 May 2020 01:33:43 -0400 Received: from mail.kernel.org ([198.145.29.99]:39210 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726058AbgEBFdm (ORCPT ); Sat, 2 May 2020 01:33:42 -0400 Received: from sol.hsd1.ca.comcast.net (c-107-3-166-239.hsd1.ca.comcast.net [107.3.166.239]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 760BD2071E; Sat, 2 May 2020 05:33:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1588397622; bh=Cay7/GP0dae7IJrK064oyAbylA+W00bKDeNseMLpuzM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sTi1AbLyuRBTE6jA8bd4iplXDUQobJR7Dr/uTPm+lv/8x0J43czffciDP0gb109Iu BZqDfYxI4hlTnRwOYrWaXfdSCvUQyXnKwFVevI5li5UoIvE3pu5bFYkllhUYMxI0pT ULTJydf5V8BYalLHN29p6UX7ufyFaK35VxSmvzH8= From: Eric Biggers To: linux-crypto@vger.kernel.org Cc: Jesper Nilsson , Lars Persson Subject: [PATCH 04/20] crypto: artpec6 - use crypto_shash_tfm_digest() Date: Fri, 1 May 2020 22:31:06 -0700 Message-Id: <20200502053122.995648-5-ebiggers@kernel.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200502053122.995648-1-ebiggers@kernel.org> References: <20200502053122.995648-1-ebiggers@kernel.org> MIME-Version: 1.0 Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org From: Eric Biggers Instead of manually allocating a 'struct shash_desc' on the stack and calling crypto_shash_digest(), switch to using the new helper function crypto_shash_tfm_digest() which does this for us. Cc: Jesper Nilsson Cc: Lars Persson Signed-off-by: Eric Biggers --- drivers/crypto/axis/artpec6_crypto.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/drivers/crypto/axis/artpec6_crypto.c b/drivers/crypto/axis/artpec6_crypto.c index fcf1effc7661ec..62ba0325a61871 100644 --- a/drivers/crypto/axis/artpec6_crypto.c +++ b/drivers/crypto/axis/artpec6_crypto.c @@ -2239,16 +2239,12 @@ artpec6_crypto_hash_set_key(struct crypto_ahash *tfm, blocksize = crypto_tfm_alg_blocksize(crypto_ahash_tfm(tfm)); if (keylen > blocksize) { - SHASH_DESC_ON_STACK(hdesc, tfm_ctx->child_hash); - - hdesc->tfm = tfm_ctx->child_hash; - tfm_ctx->hmac_key_length = blocksize; - ret = crypto_shash_digest(hdesc, key, keylen, - tfm_ctx->hmac_key); + + ret = crypto_shash_tfm_digest(tfm_ctx->child_hash, key, keylen, + tfm_ctx->hmac_key); if (ret) return ret; - } else { memcpy(tfm_ctx->hmac_key, key, keylen); tfm_ctx->hmac_key_length = keylen; From patchwork Sat May 2 05:31:07 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Biggers X-Patchwork-Id: 11523701 X-Patchwork-Delegate: herbert@gondor.apana.org.au Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2FF9E1862 for ; Sat, 2 May 2020 05:33:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 101CE2495C for ; Sat, 2 May 2020 05:33:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1588397624; bh=CT5T+FWIwZZ4k0IhAgE2/ARqIcMpCjboija1/f3cLtY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=I3wos3Y4xZugDRyqj1LWtgx5g5iT3/jnkIKIBi3iTeRHHI/TZqH11nX6FF/Uawq+w d07IGluDKhJRYNO1sL2BFbVHTErz2IBhUpr7DizuPAmI3VbBoNG5b8bfoc0GZHUuGH v+NKKezxWde02P96NnNyjU2euI+ogNKCzyy+TVHQ= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726058AbgEBFdn (ORCPT ); Sat, 2 May 2020 01:33:43 -0400 Received: from mail.kernel.org ([198.145.29.99]:39214 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727114AbgEBFdn (ORCPT ); Sat, 2 May 2020 01:33:43 -0400 Received: from sol.hsd1.ca.comcast.net (c-107-3-166-239.hsd1.ca.comcast.net [107.3.166.239]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id B86FC208DB; Sat, 2 May 2020 05:33:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1588397622; bh=CT5T+FWIwZZ4k0IhAgE2/ARqIcMpCjboija1/f3cLtY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=c3CXxZgb/pHNFcliYxooaDt+5xIHcz6eqtG3BqthskKjGWgYZA5Kvsbd39/VlIVdg 4FaIQcbP8xoa7dZ3ODF9CIXEnHDgSSuBdw5FQqO5gj+5rupNxX5JaYmwC5ju/nuL1O FZoA84/IWINV5U4VnPpTZ1ahCxGZ69fEAo3tm4yw= From: Eric Biggers To: linux-crypto@vger.kernel.org Cc: Tom Lendacky Subject: [PATCH 05/20] crypto: ccp - use crypto_shash_tfm_digest() Date: Fri, 1 May 2020 22:31:07 -0700 Message-Id: <20200502053122.995648-6-ebiggers@kernel.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200502053122.995648-1-ebiggers@kernel.org> References: <20200502053122.995648-1-ebiggers@kernel.org> MIME-Version: 1.0 Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org From: Eric Biggers Instead of manually allocating a 'struct shash_desc' on the stack and calling crypto_shash_digest(), switch to using the new helper function crypto_shash_tfm_digest() which does this for us. Cc: Tom Lendacky Signed-off-by: Eric Biggers Acked-by: Tom Lendacky --- drivers/crypto/ccp/ccp-crypto-sha.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/drivers/crypto/ccp/ccp-crypto-sha.c b/drivers/crypto/ccp/ccp-crypto-sha.c index 474e6f1a6a84ec..b0cc2bd73af804 100644 --- a/drivers/crypto/ccp/ccp-crypto-sha.c +++ b/drivers/crypto/ccp/ccp-crypto-sha.c @@ -272,9 +272,6 @@ static int ccp_sha_setkey(struct crypto_ahash *tfm, const u8 *key, { struct ccp_ctx *ctx = crypto_tfm_ctx(crypto_ahash_tfm(tfm)); struct crypto_shash *shash = ctx->u.sha.hmac_tfm; - - SHASH_DESC_ON_STACK(sdesc, shash); - unsigned int block_size = crypto_shash_blocksize(shash); unsigned int digest_size = crypto_shash_digestsize(shash); int i, ret; @@ -289,10 +286,8 @@ static int ccp_sha_setkey(struct crypto_ahash *tfm, const u8 *key, if (key_len > block_size) { /* Must hash the input key */ - sdesc->tfm = shash; - - ret = crypto_shash_digest(sdesc, key, key_len, - ctx->u.sha.key); + ret = crypto_shash_tfm_digest(shash, key, key_len, + ctx->u.sha.key); if (ret) return -EINVAL; From patchwork Sat May 2 05:31:08 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Biggers X-Patchwork-Id: 11523705 X-Patchwork-Delegate: herbert@gondor.apana.org.au Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 18F081575 for ; Sat, 2 May 2020 05:33:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id ECEDD24959 for ; Sat, 2 May 2020 05:33:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1588397625; bh=k4dI0GB0gHrRZ6B5OBnAUKIW8i+go/Lv5d59euHt+Tg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=GYj17iYI4bRFBG0S1qYMMJQSG3IA1v4sFJl45RNbTAKIvjWE4El6cuxvQ7HtbYVzk 1hMjtGh9jdXw9WeNOctP6ILFc4LYwV2PqK84JSMW9/tku9f2rslxasfpHEbJEp9S/m cs8wPXBlVPdtI1uYsqaFMou9dxEvuR/XYFWzQ99A= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727788AbgEBFdo (ORCPT ); Sat, 2 May 2020 01:33:44 -0400 Received: from mail.kernel.org ([198.145.29.99]:39220 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727118AbgEBFdn (ORCPT ); Sat, 2 May 2020 01:33:43 -0400 Received: from sol.hsd1.ca.comcast.net (c-107-3-166-239.hsd1.ca.comcast.net [107.3.166.239]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 00FA52184D; Sat, 2 May 2020 05:33:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1588397623; bh=k4dI0GB0gHrRZ6B5OBnAUKIW8i+go/Lv5d59euHt+Tg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PjTav+cQbSGGWuldY8NMdzkNO9onUEpro0ZMhr7pU/UC45gNISZdISyLZYb1Yt5kL sq4MdkpOsrSi/PXa8+SRJyip5LNo3edeeuS+SDs1dl8g7NFX1yYZ4WWf7rlPyFo1J6 8A2RzD4pK7I4AfqqYyCcGvGqQDrlWuZfz5iWZuzc= From: Eric Biggers To: linux-crypto@vger.kernel.org Cc: Gilad Ben-Yossef Subject: [PATCH 06/20] crypto: ccree - use crypto_shash_tfm_digest() Date: Fri, 1 May 2020 22:31:08 -0700 Message-Id: <20200502053122.995648-7-ebiggers@kernel.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200502053122.995648-1-ebiggers@kernel.org> References: <20200502053122.995648-1-ebiggers@kernel.org> MIME-Version: 1.0 Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org From: Eric Biggers Instead of manually allocating a 'struct shash_desc' on the stack and calling crypto_shash_digest(), switch to using the new helper function crypto_shash_tfm_digest() which does this for us. Cc: Gilad Ben-Yossef Signed-off-by: Eric Biggers Acked-by: Gilad Ben-Yossef --- drivers/crypto/ccree/cc_cipher.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/drivers/crypto/ccree/cc_cipher.c b/drivers/crypto/ccree/cc_cipher.c index a84335328f371c..872ea3ff1c6ba7 100644 --- a/drivers/crypto/ccree/cc_cipher.c +++ b/drivers/crypto/ccree/cc_cipher.c @@ -427,12 +427,9 @@ static int cc_cipher_setkey(struct crypto_skcipher *sktfm, const u8 *key, int key_len = keylen >> 1; int err; - SHASH_DESC_ON_STACK(desc, ctx_p->shash_tfm); - - desc->tfm = ctx_p->shash_tfm; - - err = crypto_shash_digest(desc, ctx_p->user.key, key_len, - ctx_p->user.key + key_len); + err = crypto_shash_tfm_digest(ctx_p->shash_tfm, + ctx_p->user.key, key_len, + ctx_p->user.key + key_len); if (err) { dev_err(dev, "Failed to hash ESSIV key.\n"); return err; From patchwork Sat May 2 05:31:09 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Biggers X-Patchwork-Id: 11523707 X-Patchwork-Delegate: herbert@gondor.apana.org.au Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 74E6F1864 for ; Sat, 2 May 2020 05:33:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5F0572495B for ; Sat, 2 May 2020 05:33:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1588397625; bh=QZs8P473wPsf3cbvaC4ELX+xuF5ysg6fyzP6woBqpPA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=d6953TrSTtXYcTW7JnA/8cCZNqXJiqQAwrd/d3acasUxoT2b12vv55izf42nevfJH ki3vqd91eglPdOCSZqqu59q8veWWtbvaQ6ISJF6E6aIZqmaJekjbAKvXDhRKTrpw8i 4hRRoxI0eFUxZi9gniyDHb/iCRBAyDWuALIwlKZs= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727798AbgEBFdo (ORCPT ); Sat, 2 May 2020 01:33:44 -0400 Received: from mail.kernel.org ([198.145.29.99]:39222 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727121AbgEBFdn (ORCPT ); Sat, 2 May 2020 01:33:43 -0400 Received: from sol.hsd1.ca.comcast.net (c-107-3-166-239.hsd1.ca.comcast.net [107.3.166.239]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 3A6AA2192A; Sat, 2 May 2020 05:33:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1588397623; bh=QZs8P473wPsf3cbvaC4ELX+xuF5ysg6fyzP6woBqpPA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=scGDPZMjLPExTI6o1Kw6y8aFWf3Ycc36HkEIqM0A6fWvyLU0/CsMpUlOCxKcQ+shq q8vZ8MgGzNd7RbB5xN6/u05DiDoNpb0mfAkK2gP+jVt4ZSD8jNxxG3x8K4/dE40xy1 buNqbQR5mgRkqf6XzNFrTICCy2oKYm7F5DTAEXJ0= From: Eric Biggers To: linux-crypto@vger.kernel.org Cc: Zaibo Xu Subject: [PATCH 07/20] crypto: hisilicon/sec2 - use crypto_shash_tfm_digest() Date: Fri, 1 May 2020 22:31:09 -0700 Message-Id: <20200502053122.995648-8-ebiggers@kernel.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200502053122.995648-1-ebiggers@kernel.org> References: <20200502053122.995648-1-ebiggers@kernel.org> MIME-Version: 1.0 Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org From: Eric Biggers Instead of manually allocating a 'struct shash_desc' on the stack and calling crypto_shash_digest(), switch to using the new helper function crypto_shash_tfm_digest() which does this for us. Cc: Zaibo Xu Signed-off-by: Eric Biggers --- drivers/crypto/hisilicon/sec2/sec_crypto.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/crypto/hisilicon/sec2/sec_crypto.c b/drivers/crypto/hisilicon/sec2/sec_crypto.c index 7f1c6a31b82f35..848ab492d26e3e 100644 --- a/drivers/crypto/hisilicon/sec2/sec_crypto.c +++ b/drivers/crypto/hisilicon/sec2/sec_crypto.c @@ -832,7 +832,6 @@ static int sec_aead_auth_set_key(struct sec_auth_ctx *ctx, struct crypto_authenc_keys *keys) { struct crypto_shash *hash_tfm = ctx->hash_tfm; - SHASH_DESC_ON_STACK(shash, hash_tfm); int blocksize, ret; if (!keys->authkeylen) { @@ -842,8 +841,8 @@ static int sec_aead_auth_set_key(struct sec_auth_ctx *ctx, blocksize = crypto_shash_blocksize(hash_tfm); if (keys->authkeylen > blocksize) { - ret = crypto_shash_digest(shash, keys->authkey, - keys->authkeylen, ctx->a_key); + ret = crypto_shash_tfm_digest(hash_tfm, keys->authkey, + keys->authkeylen, ctx->a_key); if (ret) { pr_err("hisi_sec2: aead auth digest error!\n"); return -EINVAL; From patchwork Sat May 2 05:31:10 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Biggers X-Patchwork-Id: 11523703 X-Patchwork-Delegate: herbert@gondor.apana.org.au Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E77D881 for ; Sat, 2 May 2020 05:33:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C61322495B for ; Sat, 2 May 2020 05:33:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1588397624; bh=yP/fXzlmOFLFUYfLP8XJIbmBwCM906efeHEFJWhwvGs=; h=From:To:Subject:Date:In-Reply-To:References:List-ID:From; b=CBryR3cBu4575JGHfPAfDywxi6hQ4yOF8075f47DjLEYDifWGbeoA4F7R79iLg8HI Dgvp0Jr+Pkk9XIYCWry+8QFkFzXch4OMRtVaIPkc+LHeDwoWsBc0hnhjZr1vLtsDYl DThvOOSbgskbSU72QiE/a6DTgYuVDUDW68PnA03c= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727118AbgEBFdo (ORCPT ); Sat, 2 May 2020 01:33:44 -0400 Received: from mail.kernel.org ([198.145.29.99]:39230 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727114AbgEBFdn (ORCPT ); Sat, 2 May 2020 01:33:43 -0400 Received: from sol.hsd1.ca.comcast.net (c-107-3-166-239.hsd1.ca.comcast.net [107.3.166.239]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 7708121974 for ; Sat, 2 May 2020 05:33:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1588397623; bh=yP/fXzlmOFLFUYfLP8XJIbmBwCM906efeHEFJWhwvGs=; h=From:To:Subject:Date:In-Reply-To:References:From; b=J8liRbwiJYEzkZnRWIJfwVOxB7vSYtfTgK0fWSJlfHMeSxReaS107DHcu1d935euv H5EvEAikylFK/oQfoNrrQuiiPukqZOoQaxuUK0UtpwCF5M5jPjKcPkvEuglDG5TCAF uvy1y+AUyPUZ3h8nFyhUrNBXpPnRgO98AHPVXR1M= From: Eric Biggers To: linux-crypto@vger.kernel.org Subject: [PATCH 08/20] crypto: mediatek - use crypto_shash_tfm_digest() Date: Fri, 1 May 2020 22:31:10 -0700 Message-Id: <20200502053122.995648-9-ebiggers@kernel.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200502053122.995648-1-ebiggers@kernel.org> References: <20200502053122.995648-1-ebiggers@kernel.org> MIME-Version: 1.0 Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org From: Eric Biggers Instead of manually allocating a 'struct shash_desc' on the stack and calling crypto_shash_digest(), switch to using the new helper function crypto_shash_tfm_digest() which does this for us. Signed-off-by: Eric Biggers --- drivers/crypto/mediatek/mtk-sha.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/drivers/crypto/mediatek/mtk-sha.c b/drivers/crypto/mediatek/mtk-sha.c index bd6309e57ab81a..da3f0b8814aa49 100644 --- a/drivers/crypto/mediatek/mtk-sha.c +++ b/drivers/crypto/mediatek/mtk-sha.c @@ -805,12 +805,9 @@ static int mtk_sha_setkey(struct crypto_ahash *tfm, const u8 *key, size_t ds = crypto_shash_digestsize(bctx->shash); int err, i; - SHASH_DESC_ON_STACK(shash, bctx->shash); - - shash->tfm = bctx->shash; - if (keylen > bs) { - err = crypto_shash_digest(shash, key, keylen, bctx->ipad); + err = crypto_shash_tfm_digest(bctx->shash, key, keylen, + bctx->ipad); if (err) return err; keylen = ds; From patchwork Sat May 2 05:31:11 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Biggers X-Patchwork-Id: 11523709 X-Patchwork-Delegate: herbert@gondor.apana.org.au Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 422511575 for ; Sat, 2 May 2020 05:33:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 21B0224959 for ; Sat, 2 May 2020 05:33:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1588397626; bh=uzoN4MbeYC3SID044kBzYTpAiW1qfV2K/bhZYWaEBFc=; h=From:To:Subject:Date:In-Reply-To:References:List-ID:From; b=FQJ2gsMiv1dVmZgqoMg6aXLrEKVraDD0HaYsdN3PGvbWrQ1R3sP1cWUux/BZZsROP 07CJuyMgzL6pdEmMOT6bMKt1SnMKsNDsWI0YvyaTwOvZM2SlXWM8K41fHs3tkJEhlZ 0LCegc45QsCBDDHmCEEh8kxryVnTtQYp1K+djhXI= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727804AbgEBFdo (ORCPT ); Sat, 2 May 2020 01:33:44 -0400 Received: from mail.kernel.org ([198.145.29.99]:39220 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727776AbgEBFdo (ORCPT ); Sat, 2 May 2020 01:33:44 -0400 Received: from sol.hsd1.ca.comcast.net (c-107-3-166-239.hsd1.ca.comcast.net [107.3.166.239]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id AA7C82184D for ; Sat, 2 May 2020 05:33:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1588397623; bh=uzoN4MbeYC3SID044kBzYTpAiW1qfV2K/bhZYWaEBFc=; h=From:To:Subject:Date:In-Reply-To:References:From; b=nMGD3X10FTUNAYs7wDGo6i65S85g2TUudSNMOmc6QzHLSN77ud7VE95bjhabsrhrf lg0ZdPgO7mM5N6GbbnUmsOyznBmezL6PjVVTjNCxJIXjQ/HIhOT7xB2tfibwpx8iF6 /0iqDXuzXhDujB0td+5fL3JKl/3mgHIVYR3MSI5A= From: Eric Biggers To: linux-crypto@vger.kernel.org Subject: [PATCH 09/20] crypto: n2 - use crypto_shash_tfm_digest() Date: Fri, 1 May 2020 22:31:11 -0700 Message-Id: <20200502053122.995648-10-ebiggers@kernel.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200502053122.995648-1-ebiggers@kernel.org> References: <20200502053122.995648-1-ebiggers@kernel.org> MIME-Version: 1.0 Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org From: Eric Biggers Instead of manually allocating a 'struct shash_desc' on the stack and calling crypto_shash_digest(), switch to using the new helper function crypto_shash_tfm_digest() which does this for us. Signed-off-by: Eric Biggers --- drivers/crypto/n2_core.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/drivers/crypto/n2_core.c b/drivers/crypto/n2_core.c index f5c468f2cc82e9..6a828bbecea400 100644 --- a/drivers/crypto/n2_core.c +++ b/drivers/crypto/n2_core.c @@ -462,7 +462,6 @@ static int n2_hmac_async_setkey(struct crypto_ahash *tfm, const u8 *key, struct n2_hmac_ctx *ctx = crypto_ahash_ctx(tfm); struct crypto_shash *child_shash = ctx->child_shash; struct crypto_ahash *fallback_tfm; - SHASH_DESC_ON_STACK(shash, child_shash); int err, bs, ds; fallback_tfm = ctx->base.fallback_tfm; @@ -470,14 +469,12 @@ static int n2_hmac_async_setkey(struct crypto_ahash *tfm, const u8 *key, if (err) return err; - shash->tfm = child_shash; - bs = crypto_shash_blocksize(child_shash); ds = crypto_shash_digestsize(child_shash); BUG_ON(ds > N2_HASH_KEY_MAX); if (keylen > bs) { - err = crypto_shash_digest(shash, key, keylen, - ctx->hash_key); + err = crypto_shash_tfm_digest(child_shash, key, keylen, + ctx->hash_key); if (err) return err; keylen = ds; From patchwork Sat May 2 05:31:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Biggers X-Patchwork-Id: 11523711 X-Patchwork-Delegate: herbert@gondor.apana.org.au Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E59721575 for ; Sat, 2 May 2020 05:33:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C582624956 for ; Sat, 2 May 2020 05:33:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1588397626; bh=i49rYlWOgGRkpQzKkI6h8x4Gn4+mja8Y0bFYbbJ2QY0=; h=From:To:Subject:Date:In-Reply-To:References:List-ID:From; b=Ajo4sCiUbQahUje36kszrApXE8/a6lnjqKy2ox29cKJSdQOkl/TZVBVW+k3xhVWLi Kl/aYL4cbT8D7aIraE2oXtJb9X+XOrwEtH2xTrhKTa9/FvOMwiY4tOVKm92ov5DYxZ Sf99Sv+3CBvz3UtG7OSQMFuvQCbUoZ+afXhM7VKA= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727823AbgEBFdp (ORCPT ); Sat, 2 May 2020 01:33:45 -0400 Received: from mail.kernel.org ([198.145.29.99]:39222 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727778AbgEBFdo (ORCPT ); Sat, 2 May 2020 01:33:44 -0400 Received: from sol.hsd1.ca.comcast.net (c-107-3-166-239.hsd1.ca.comcast.net [107.3.166.239]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id E1E6324957 for ; Sat, 2 May 2020 05:33:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1588397624; bh=i49rYlWOgGRkpQzKkI6h8x4Gn4+mja8Y0bFYbbJ2QY0=; h=From:To:Subject:Date:In-Reply-To:References:From; b=gnQ0t06SZ883q3MY07cVsMqByZiysc+XyC0zDThT390R0X8MXqbUjHcG7QwA6bcHT ACyP1VWn0mb9DbPwzKrJgzaWwq5ly8m7j4bE9axqx6hHWyuvJl2/kJo0ORrqXh+y7j QLYNRO9SvGxwOdjD2+K/+XDkiRVbNfbcEYqtiZeA= From: Eric Biggers To: linux-crypto@vger.kernel.org Subject: [PATCH 10/20] crypto: omap-sham - use crypto_shash_tfm_digest() Date: Fri, 1 May 2020 22:31:12 -0700 Message-Id: <20200502053122.995648-11-ebiggers@kernel.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200502053122.995648-1-ebiggers@kernel.org> References: <20200502053122.995648-1-ebiggers@kernel.org> MIME-Version: 1.0 Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org From: Eric Biggers Instead of manually allocating a 'struct shash_desc' on the stack and calling crypto_shash_digest(), switch to using the new helper function crypto_shash_tfm_digest() which does this for us. Signed-off-by: Eric Biggers --- drivers/crypto/omap-sham.c | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/drivers/crypto/omap-sham.c b/drivers/crypto/omap-sham.c index e4072cd385857c..d600c5b3fdd3f6 100644 --- a/drivers/crypto/omap-sham.c +++ b/drivers/crypto/omap-sham.c @@ -1245,16 +1245,6 @@ static int omap_sham_update(struct ahash_request *req) return omap_sham_enqueue(req, OP_UPDATE); } -static int omap_sham_shash_digest(struct crypto_shash *tfm, u32 flags, - const u8 *data, unsigned int len, u8 *out) -{ - SHASH_DESC_ON_STACK(shash, tfm); - - shash->tfm = tfm; - - return crypto_shash_digest(shash, data, len, out); -} - static int omap_sham_final_shash(struct ahash_request *req) { struct omap_sham_ctx *tctx = crypto_tfm_ctx(req->base.tfm); @@ -1270,9 +1260,8 @@ static int omap_sham_final_shash(struct ahash_request *req) !test_bit(FLAGS_AUTO_XOR, &ctx->dd->flags)) offset = get_block_size(ctx); - return omap_sham_shash_digest(tctx->fallback, req->base.flags, - ctx->buffer + offset, - ctx->bufcnt - offset, req->result); + return crypto_shash_tfm_digest(tctx->fallback, ctx->buffer + offset, + ctx->bufcnt - offset, req->result); } static int omap_sham_final(struct ahash_request *req) @@ -1351,9 +1340,8 @@ static int omap_sham_setkey(struct crypto_ahash *tfm, const u8 *key, return err; if (keylen > bs) { - err = omap_sham_shash_digest(bctx->shash, - crypto_shash_get_flags(bctx->shash), - key, keylen, bctx->ipad); + err = crypto_shash_tfm_digest(bctx->shash, key, keylen, + bctx->ipad); if (err) return err; keylen = ds; From patchwork Sat May 2 05:31:13 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Biggers X-Patchwork-Id: 11523737 X-Patchwork-Delegate: herbert@gondor.apana.org.au Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0C9E181 for ; Sat, 2 May 2020 05:33:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E97322192A for ; Sat, 2 May 2020 05:33:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1588397631; bh=yP0ei9eeyV64D7gyzyKJiWXxmKwgWffX6x3jaj5oYJ0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=gBhhwxkrLKABIaUKqefXCb5FUAsQ056eFsdDs+cLZYmtCPEfHJ6FS6cHZ439aX2nx sBAJPEiOSaALXyiI2kA7SRRWsTHeSk5I42nn0o2m758ijmq0zL/v/EwW4XW5ZRytcm oLxBgwkftYAtDQLm382NyyffHVZaZ8pjRduqdV30= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727808AbgEBFdu (ORCPT ); Sat, 2 May 2020 01:33:50 -0400 Received: from mail.kernel.org ([198.145.29.99]:39230 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727114AbgEBFdo (ORCPT ); Sat, 2 May 2020 01:33:44 -0400 Received: from sol.hsd1.ca.comcast.net (c-107-3-166-239.hsd1.ca.comcast.net [107.3.166.239]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 21EC821974; Sat, 2 May 2020 05:33:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1588397624; bh=yP0ei9eeyV64D7gyzyKJiWXxmKwgWffX6x3jaj5oYJ0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qBUQzoNQj4V13fMB1Vpahw0ccNQnb3jfpta6w3juUullhJDNAFWq38H2RetXCjjTT +MC6q0hNSHRUf8qtr1HloK+AOvl95VtwjoIZNnWizGzV6hJsuwF2q4u0SvWr3xYcb6 M90cy9XT2wYZFnnkEJe2Dg6FZz5+NSLZgrP6yJVU= From: Eric Biggers To: linux-crypto@vger.kernel.org Cc: Krzysztof Kozlowski , Vladimir Zapolskiy , Kamil Konieczny Subject: [PATCH 11/20] crypto: s5p-sss - use crypto_shash_tfm_digest() Date: Fri, 1 May 2020 22:31:13 -0700 Message-Id: <20200502053122.995648-12-ebiggers@kernel.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200502053122.995648-1-ebiggers@kernel.org> References: <20200502053122.995648-1-ebiggers@kernel.org> MIME-Version: 1.0 Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org From: Eric Biggers Instead of manually allocating a 'struct shash_desc' on the stack and calling crypto_shash_digest(), switch to using the new helper function crypto_shash_tfm_digest() which does this for us. Cc: Krzysztof Kozlowski Cc: Vladimir Zapolskiy Cc: Kamil Konieczny Signed-off-by: Eric Biggers Acked-by: Krzysztof Kozlowski --- drivers/crypto/s5p-sss.c | 39 ++++++--------------------------------- 1 file changed, 6 insertions(+), 33 deletions(-) diff --git a/drivers/crypto/s5p-sss.c b/drivers/crypto/s5p-sss.c index 2a16800d257954..341433fbcc4a8b 100644 --- a/drivers/crypto/s5p-sss.c +++ b/drivers/crypto/s5p-sss.c @@ -1520,37 +1520,6 @@ static int s5p_hash_update(struct ahash_request *req) return s5p_hash_enqueue(req, true); /* HASH_OP_UPDATE */ } -/** - * s5p_hash_shash_digest() - calculate shash digest - * @tfm: crypto transformation - * @flags: tfm flags - * @data: input data - * @len: length of data - * @out: output buffer - */ -static int s5p_hash_shash_digest(struct crypto_shash *tfm, u32 flags, - const u8 *data, unsigned int len, u8 *out) -{ - SHASH_DESC_ON_STACK(shash, tfm); - - shash->tfm = tfm; - - return crypto_shash_digest(shash, data, len, out); -} - -/** - * s5p_hash_final_shash() - calculate shash digest - * @req: AHASH request - */ -static int s5p_hash_final_shash(struct ahash_request *req) -{ - struct s5p_hash_ctx *tctx = crypto_tfm_ctx(req->base.tfm); - struct s5p_hash_reqctx *ctx = ahash_request_ctx(req); - - return s5p_hash_shash_digest(tctx->fallback, req->base.flags, - ctx->buffer, ctx->bufcnt, req->result); -} - /** * s5p_hash_final() - close up hash and calculate digest * @req: AHASH request @@ -1582,8 +1551,12 @@ static int s5p_hash_final(struct ahash_request *req) if (ctx->error) return -EINVAL; /* uncompleted hash is not needed */ - if (!ctx->digcnt && ctx->bufcnt < BUFLEN) - return s5p_hash_final_shash(req); + if (!ctx->digcnt && ctx->bufcnt < BUFLEN) { + struct s5p_hash_ctx *tctx = crypto_tfm_ctx(req->base.tfm); + + return crypto_shash_tfm_digest(tctx->fallback, ctx->buffer, + ctx->bufcnt, req->result); + } return s5p_hash_enqueue(req, false); /* HASH_OP_FINAL */ } From patchwork Sat May 2 05:31:14 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Biggers X-Patchwork-Id: 11523713 X-Patchwork-Delegate: herbert@gondor.apana.org.au Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8382581 for ; Sat, 2 May 2020 05:33:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 629B62071E for ; Sat, 2 May 2020 05:33:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1588397627; bh=cxfqhmomB4B2lqaurFr3tfvzNEiRkFVJs96YPeGZ6PM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=ckz98zouu/vChxjR2aeBcREAcyoa+rNbLkeWr8o33bDpRk1nnWHsIrjsn1P5HABsf Ym+Rbs5FX82AO/PtNu8Au8mCoO/SdnVD/6RuZdKE45sA1k47ouy49dD0AmMGDvQ9DT V4IOjRsS022zmfRPieSOlXkxp0kMdY/WD1GuPQqA= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727778AbgEBFdq (ORCPT ); Sat, 2 May 2020 01:33:46 -0400 Received: from mail.kernel.org ([198.145.29.99]:39220 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727121AbgEBFdo (ORCPT ); Sat, 2 May 2020 01:33:44 -0400 Received: from sol.hsd1.ca.comcast.net (c-107-3-166-239.hsd1.ca.comcast.net [107.3.166.239]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 6B90424954; Sat, 2 May 2020 05:33:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1588397624; bh=cxfqhmomB4B2lqaurFr3tfvzNEiRkFVJs96YPeGZ6PM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aVixZg8eo4EcfgOXeA6K8AM0jaE+sVtiEisgo+HET65KuVgG76JYJvoOqNslPenhF vSKrsKQA5pNpBsCre1dtt6n7JXzIW1yAZETtJC6mx2VQc6UaZtsEfr4GmQaxCyBXVB Oq1PMUKvPffJBYL7bKggTTLaUa8d0+PX3UElQVEo= From: Eric Biggers To: linux-crypto@vger.kernel.org Cc: Robert Baldyga , Krzysztof Opasiak Subject: [PATCH 12/20] nfc: s3fwrn5: use crypto_shash_tfm_digest() Date: Fri, 1 May 2020 22:31:14 -0700 Message-Id: <20200502053122.995648-13-ebiggers@kernel.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200502053122.995648-1-ebiggers@kernel.org> References: <20200502053122.995648-1-ebiggers@kernel.org> MIME-Version: 1.0 Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org From: Eric Biggers Instead of manually allocating a 'struct shash_desc' on the stack and calling crypto_shash_digest(), switch to using the new helper function crypto_shash_tfm_digest() which does this for us. Cc: Robert Baldyga Cc: Krzysztof Opasiak Signed-off-by: Eric Biggers --- drivers/nfc/s3fwrn5/firmware.c | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/drivers/nfc/s3fwrn5/firmware.c b/drivers/nfc/s3fwrn5/firmware.c index de613c623a2cf0..69857f0807040c 100644 --- a/drivers/nfc/s3fwrn5/firmware.c +++ b/drivers/nfc/s3fwrn5/firmware.c @@ -434,15 +434,7 @@ int s3fwrn5_fw_download(struct s3fwrn5_fw_info *fw_info) goto out; } - { - SHASH_DESC_ON_STACK(desc, tfm); - - desc->tfm = tfm; - - ret = crypto_shash_digest(desc, fw->image, image_size, - hash_data); - shash_desc_zero(desc); - } + ret = crypto_shash_tfm_digest(tfm, fw->image, image_size, hash_data); crypto_free_shash(tfm); if (ret) { From patchwork Sat May 2 05:31:15 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Biggers X-Patchwork-Id: 11523735 X-Patchwork-Delegate: herbert@gondor.apana.org.au Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B214D1864 for ; Sat, 2 May 2020 05:33:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 916EA24954 for ; Sat, 2 May 2020 05:33:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1588397631; bh=BbS+GJU8E1cfxJI7vp3WOcStloDByRcBqGG0dMSFyjI=; h=From:To:Subject:Date:In-Reply-To:References:List-ID:From; b=RWiYRAQyJGRzBLuWps4feosPUdtHkJU489G7pnyllsBMPr7PBtkB+/eJSzZquVVX4 VYMhM+Y7ciSCxFkmHfDcB0a3kWcQOdBhriMhtWMBiVkxpG7hBUmZf+Mm2cyTbFn41i XBLlM/Dnx5/bbIGAtUC/BlM0RPV/BMy6U3Kd9WN0= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727828AbgEBFdu (ORCPT ); Sat, 2 May 2020 01:33:50 -0400 Received: from mail.kernel.org ([198.145.29.99]:39264 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727808AbgEBFdp (ORCPT ); Sat, 2 May 2020 01:33:45 -0400 Received: from sol.hsd1.ca.comcast.net (c-107-3-166-239.hsd1.ca.comcast.net [107.3.166.239]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id AEFE32184D for ; Sat, 2 May 2020 05:33:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1588397624; bh=BbS+GJU8E1cfxJI7vp3WOcStloDByRcBqGG0dMSFyjI=; h=From:To:Subject:Date:In-Reply-To:References:From; b=t/HrfgcttYLU/IPDBheLMNqHTTMfU5+5GDQ7/qv2XVPDxHiEOkd/oHhkwyNElD6ym JEYEYbYTyLu98/SPcRJwrSzLzoPP+i7Th9YBS7J6ZVVcoog9QIF5tQth+K17vs8roL brnI2suD2smYtxfYQiDmRBd7x6zFKiHYZGGXKAMM= From: Eric Biggers To: linux-crypto@vger.kernel.org Subject: [PATCH 13/20] fscrypt: use crypto_shash_tfm_digest() Date: Fri, 1 May 2020 22:31:15 -0700 Message-Id: <20200502053122.995648-14-ebiggers@kernel.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200502053122.995648-1-ebiggers@kernel.org> References: <20200502053122.995648-1-ebiggers@kernel.org> MIME-Version: 1.0 Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org From: Eric Biggers Instead of manually allocating a 'struct shash_desc' on the stack and calling crypto_shash_digest(), switch to using the new helper function crypto_shash_tfm_digest() which does this for us. Signed-off-by: Eric Biggers --- fs/crypto/fname.c | 7 +------ fs/crypto/hkdf.c | 6 +----- 2 files changed, 2 insertions(+), 11 deletions(-) diff --git a/fs/crypto/fname.c b/fs/crypto/fname.c index 4c212442a8f7f1..5c9fb013e3f757 100644 --- a/fs/crypto/fname.c +++ b/fs/crypto/fname.c @@ -83,13 +83,8 @@ static int fscrypt_do_sha256(const u8 *data, unsigned int data_len, u8 *result) tfm = prev_tfm; } } - { - SHASH_DESC_ON_STACK(desc, tfm); - desc->tfm = tfm; - - return crypto_shash_digest(desc, data, data_len, result); - } + return crypto_shash_tfm_digest(tfm, data, data_len, result); } static inline bool fscrypt_is_dot_dotdot(const struct qstr *str) diff --git a/fs/crypto/hkdf.c b/fs/crypto/hkdf.c index efb95bd19a8948..0cba7928446d34 100644 --- a/fs/crypto/hkdf.c +++ b/fs/crypto/hkdf.c @@ -44,17 +44,13 @@ static int hkdf_extract(struct crypto_shash *hmac_tfm, const u8 *ikm, unsigned int ikmlen, u8 prk[HKDF_HASHLEN]) { static const u8 default_salt[HKDF_HASHLEN]; - SHASH_DESC_ON_STACK(desc, hmac_tfm); int err; err = crypto_shash_setkey(hmac_tfm, default_salt, HKDF_HASHLEN); if (err) return err; - desc->tfm = hmac_tfm; - err = crypto_shash_digest(desc, ikm, ikmlen, prk); - shash_desc_zero(desc); - return err; + return crypto_shash_tfm_digest(hmac_tfm, ikm, ikmlen, prk); } /* From patchwork Sat May 2 05:31:16 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Biggers X-Patchwork-Id: 11523721 X-Patchwork-Delegate: herbert@gondor.apana.org.au Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2670781 for ; Sat, 2 May 2020 05:33:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 04A82208DB for ; Sat, 2 May 2020 05:33:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1588397629; bh=jq54d1r7a1DdG4P2T20EFr5Sm0y5npMj6hm6FZVE7ZI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=UiFdQPAiuxs3wMi+qw5nzlPleDJqC88HQXlC1c/8ek5w13qRTp3BTQz/TzdtWsAnT 3TL5VFRtbKCLZiFE2hBlVsHrByMU2dzLebI0rjiY8rP9cK8OxD0WminchJCzTihkgE p/nkgeMoNZcVZPMgXgsonDf4cPFBhCKC8HtZZSvM= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727121AbgEBFdq (ORCPT ); Sat, 2 May 2020 01:33:46 -0400 Received: from mail.kernel.org ([198.145.29.99]:39282 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727815AbgEBFdp (ORCPT ); Sat, 2 May 2020 01:33:45 -0400 Received: from sol.hsd1.ca.comcast.net (c-107-3-166-239.hsd1.ca.comcast.net [107.3.166.239]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id E349F2495C; Sat, 2 May 2020 05:33:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1588397625; bh=jq54d1r7a1DdG4P2T20EFr5Sm0y5npMj6hm6FZVE7ZI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=2q6VFgcDhqwTtPax6sj8y89VG0iWV50ASfANjIUKqdiQlWQslRXxpIP5hjar2RQR7 pjbYI270igk5GthJXu0s9yRVJ8n4/82LISYSr6/FUJdb2a95BsW9/MlbW+SwMRjtdZ 0snNb9uDEhbSbPbos+mhz855MmDWZk8xrn/ELw0Q= From: Eric Biggers To: linux-crypto@vger.kernel.org Cc: ecryptfs@vger.kernel.org Subject: [PATCH 14/20] ecryptfs: use crypto_shash_tfm_digest() Date: Fri, 1 May 2020 22:31:16 -0700 Message-Id: <20200502053122.995648-15-ebiggers@kernel.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200502053122.995648-1-ebiggers@kernel.org> References: <20200502053122.995648-1-ebiggers@kernel.org> MIME-Version: 1.0 Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org From: Eric Biggers Instead of manually allocating a 'struct shash_desc' on the stack and calling crypto_shash_digest(), switch to using the new helper function crypto_shash_tfm_digest() which does this for us. Cc: ecryptfs@vger.kernel.org Signed-off-by: Eric Biggers --- fs/ecryptfs/crypto.c | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) diff --git a/fs/ecryptfs/crypto.c b/fs/ecryptfs/crypto.c index 2c449aed1b9209..0681540c48d985 100644 --- a/fs/ecryptfs/crypto.c +++ b/fs/ecryptfs/crypto.c @@ -48,18 +48,6 @@ void ecryptfs_from_hex(char *dst, char *src, int dst_size) } } -static int ecryptfs_hash_digest(struct crypto_shash *tfm, - char *src, int len, char *dst) -{ - SHASH_DESC_ON_STACK(desc, tfm); - int err; - - desc->tfm = tfm; - err = crypto_shash_digest(desc, src, len, dst); - shash_desc_zero(desc); - return err; -} - /** * ecryptfs_calculate_md5 - calculates the md5 of @src * @dst: Pointer to 16 bytes of allocated memory @@ -74,11 +62,8 @@ static int ecryptfs_calculate_md5(char *dst, struct ecryptfs_crypt_stat *crypt_stat, char *src, int len) { - struct crypto_shash *tfm; - int rc = 0; + int rc = crypto_shash_tfm_digest(crypt_stat->hash_tfm, src, len, dst); - tfm = crypt_stat->hash_tfm; - rc = ecryptfs_hash_digest(tfm, src, len, dst); if (rc) { printk(KERN_ERR "%s: Error computing crypto hash; rc = [%d]\n", From patchwork Sat May 2 05:31:17 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Biggers X-Patchwork-Id: 11523717 X-Patchwork-Delegate: herbert@gondor.apana.org.au Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2EC721862 for ; Sat, 2 May 2020 05:33:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1832A208DB for ; Sat, 2 May 2020 05:33:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1588397628; bh=D5XW6cZpsJwZ7D6M28ztCkO8mBJw30MPkBRR8dbGTwQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=jer/pGm1Jez1kpV1bah3tTVKRuzW+oRG8C139cVhgv2O0iNfFiJjRFs9c2b63g+La J3U4AcHyHctc9JEsykeMfTILGoUYXPpSzKD0+y+PofnOaf9GWrDaGyfhMa4Z/vYwSL VEGkSBwSAjf+PgGhkAnlZ6oARF2meCwVpg1JiJ7s= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727815AbgEBFdr (ORCPT ); Sat, 2 May 2020 01:33:47 -0400 Received: from mail.kernel.org ([198.145.29.99]:39284 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727776AbgEBFdp (ORCPT ); Sat, 2 May 2020 01:33:45 -0400 Received: from sol.hsd1.ca.comcast.net (c-107-3-166-239.hsd1.ca.comcast.net [107.3.166.239]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 2B6DC208DB; Sat, 2 May 2020 05:33:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1588397625; bh=D5XW6cZpsJwZ7D6M28ztCkO8mBJw30MPkBRR8dbGTwQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aTIMQVl6HdIeINBbS+bh94aY/URMxXAIm5FeH8NT4QtQ2e0rLKrraXahmsRIShFWt aRE6zCqwmeA8G9OFtTVqRIbTV3f/GLhFNwcve20yI7ZmBycn7XiSCwl1yo7eOAGw6G BOuEKV5AX+qzZHZePQ8PfSZmRJz5VoZMvB2agScI= From: Eric Biggers To: linux-crypto@vger.kernel.org Cc: linux-nfs@vger.kernel.org Subject: [PATCH 15/20] nfsd: use crypto_shash_tfm_digest() Date: Fri, 1 May 2020 22:31:17 -0700 Message-Id: <20200502053122.995648-16-ebiggers@kernel.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200502053122.995648-1-ebiggers@kernel.org> References: <20200502053122.995648-1-ebiggers@kernel.org> MIME-Version: 1.0 Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org From: Eric Biggers Instead of manually allocating a 'struct shash_desc' on the stack and calling crypto_shash_digest(), switch to using the new helper function crypto_shash_tfm_digest() which does this for us. Cc: linux-nfs@vger.kernel.org Signed-off-by: Eric Biggers Acked-by: J. Bruce Fields --- fs/nfsd/nfs4recover.c | 26 ++++++-------------------- 1 file changed, 6 insertions(+), 20 deletions(-) diff --git a/fs/nfsd/nfs4recover.c b/fs/nfsd/nfs4recover.c index a8fb18609146a2..9e40dfecf1b1a6 100644 --- a/fs/nfsd/nfs4recover.c +++ b/fs/nfsd/nfs4recover.c @@ -127,16 +127,8 @@ nfs4_make_rec_clidname(char *dname, const struct xdr_netobj *clname) goto out; } - { - SHASH_DESC_ON_STACK(desc, tfm); - - desc->tfm = tfm; - - status = crypto_shash_digest(desc, clname->data, clname->len, - cksum.data); - shash_desc_zero(desc); - } - + status = crypto_shash_tfm_digest(tfm, clname->data, clname->len, + cksum.data); if (status) goto out; @@ -1148,7 +1140,6 @@ nfsd4_cld_create_v2(struct nfs4_client *clp) struct crypto_shash *tfm = cn->cn_tfm; struct xdr_netobj cksum; char *principal = NULL; - SHASH_DESC_ON_STACK(desc, tfm); /* Don't upcall if it's already stored */ if (test_bit(NFSD4_CLIENT_STABLE, &clp->cl_flags)) @@ -1170,16 +1161,14 @@ nfsd4_cld_create_v2(struct nfs4_client *clp) else if (clp->cl_cred.cr_principal) principal = clp->cl_cred.cr_principal; if (principal) { - desc->tfm = tfm; cksum.len = crypto_shash_digestsize(tfm); cksum.data = kmalloc(cksum.len, GFP_KERNEL); if (cksum.data == NULL) { ret = -ENOMEM; goto out; } - ret = crypto_shash_digest(desc, principal, strlen(principal), - cksum.data); - shash_desc_zero(desc); + ret = crypto_shash_tfm_digest(tfm, principal, strlen(principal), + cksum.data); if (ret) { kfree(cksum.data); goto out; @@ -1343,7 +1332,6 @@ nfsd4_cld_check_v2(struct nfs4_client *clp) struct crypto_shash *tfm = cn->cn_tfm; struct xdr_netobj cksum; char *principal = NULL; - SHASH_DESC_ON_STACK(desc, tfm); /* did we already find that this client is stable? */ if (test_bit(NFSD4_CLIENT_STABLE, &clp->cl_flags)) @@ -1381,14 +1369,12 @@ nfsd4_cld_check_v2(struct nfs4_client *clp) principal = clp->cl_cred.cr_principal; if (principal == NULL) return -ENOENT; - desc->tfm = tfm; cksum.len = crypto_shash_digestsize(tfm); cksum.data = kmalloc(cksum.len, GFP_KERNEL); if (cksum.data == NULL) return -ENOENT; - status = crypto_shash_digest(desc, principal, strlen(principal), - cksum.data); - shash_desc_zero(desc); + status = crypto_shash_tfm_digest(tfm, principal, + strlen(principal), cksum.data); if (status) { kfree(cksum.data); return -ENOENT; From patchwork Sat May 2 05:31:18 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Biggers X-Patchwork-Id: 11523719 X-Patchwork-Delegate: herbert@gondor.apana.org.au Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7F8921575 for ; Sat, 2 May 2020 05:33:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 68DD32192A for ; Sat, 2 May 2020 05:33:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1588397628; bh=kOMqG1wtcM/8YN6jSEEZv709OU3+6XUMoquaqptfu2s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=TuR04fIGyUMLBBnaGpUVi8DpeLe/dNWc5o0bvHAilJX5l/hXlJlO7jU4Cs4uOJMi6 az3wz1MoVEJMeJhUnBJN9m//JuNAByTXhjA1hYz6Oc0J2+E0ULbiDyjBc7oq0gBdnV wX+GqjjC7td4VJjy/q3Fsx32SQpt8NIpRwwqmkxQ= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727029AbgEBFdr (ORCPT ); Sat, 2 May 2020 01:33:47 -0400 Received: from mail.kernel.org ([198.145.29.99]:39222 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727818AbgEBFdq (ORCPT ); Sat, 2 May 2020 01:33:46 -0400 Received: from sol.hsd1.ca.comcast.net (c-107-3-166-239.hsd1.ca.comcast.net [107.3.166.239]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 661EE2495D; Sat, 2 May 2020 05:33:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1588397625; bh=kOMqG1wtcM/8YN6jSEEZv709OU3+6XUMoquaqptfu2s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WbitR2DwVVwOWkySkljOEG/ucIKi+bm30pIbzgqiXGrRmv5Agsz4+gDE2PyJ2XGP5 hhbxw/S3PrKwMsH7ZljNFyZT82r60jVBqSrxq65SozFZIpba/6j68Twg8Z78OFNI2l rD0CuVnKuxRqanbc/T4P4ClIy6Q2O97jGc1g8cY4= From: Eric Biggers To: linux-crypto@vger.kernel.org Cc: linux-mtd@lists.infradead.org Subject: [PATCH 16/20] ubifs: use crypto_shash_tfm_digest() Date: Fri, 1 May 2020 22:31:18 -0700 Message-Id: <20200502053122.995648-17-ebiggers@kernel.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200502053122.995648-1-ebiggers@kernel.org> References: <20200502053122.995648-1-ebiggers@kernel.org> MIME-Version: 1.0 Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org From: Eric Biggers Instead of manually allocating a 'struct shash_desc' on the stack and calling crypto_shash_digest(), switch to using the new helper function crypto_shash_tfm_digest() which does this for us. Cc: linux-mtd@lists.infradead.org Signed-off-by: Eric Biggers --- fs/ubifs/auth.c | 20 +++----------------- fs/ubifs/master.c | 9 +++------ fs/ubifs/replay.c | 14 +++----------- 3 files changed, 9 insertions(+), 34 deletions(-) diff --git a/fs/ubifs/auth.c b/fs/ubifs/auth.c index 8cdbd53d780ca7..1e374baafc5255 100644 --- a/fs/ubifs/auth.c +++ b/fs/ubifs/auth.c @@ -31,15 +31,9 @@ int __ubifs_node_calc_hash(const struct ubifs_info *c, const void *node, u8 *hash) { const struct ubifs_ch *ch = node; - SHASH_DESC_ON_STACK(shash, c->hash_tfm); - int err; - - shash->tfm = c->hash_tfm; - err = crypto_shash_digest(shash, node, le32_to_cpu(ch->len), hash); - if (err < 0) - return err; - return 0; + return crypto_shash_tfm_digest(c->hash_tfm, node, le32_to_cpu(ch->len), + hash); } /** @@ -53,15 +47,7 @@ int __ubifs_node_calc_hash(const struct ubifs_info *c, const void *node, static int ubifs_hash_calc_hmac(const struct ubifs_info *c, const u8 *hash, u8 *hmac) { - SHASH_DESC_ON_STACK(shash, c->hmac_tfm); - int err; - - shash->tfm = c->hmac_tfm; - - err = crypto_shash_digest(shash, hash, c->hash_len, hmac); - if (err < 0) - return err; - return 0; + return crypto_shash_tfm_digest(c->hmac_tfm, hash, c->hash_len, hmac); } /** diff --git a/fs/ubifs/master.c b/fs/ubifs/master.c index 52a85c01397ef9..911d0555b9f2b1 100644 --- a/fs/ubifs/master.c +++ b/fs/ubifs/master.c @@ -68,12 +68,9 @@ static int mst_node_check_hash(const struct ubifs_info *c, u8 calc[UBIFS_MAX_HASH_LEN]; const void *node = mst; - SHASH_DESC_ON_STACK(shash, c->hash_tfm); - - shash->tfm = c->hash_tfm; - - crypto_shash_digest(shash, node + sizeof(struct ubifs_ch), - UBIFS_MST_NODE_SZ - sizeof(struct ubifs_ch), calc); + crypto_shash_tfm_digest(c->hash_tfm, node + sizeof(struct ubifs_ch), + UBIFS_MST_NODE_SZ - sizeof(struct ubifs_ch), + calc); if (ubifs_check_hash(c, expected, calc)) return -EPERM; diff --git a/fs/ubifs/replay.c b/fs/ubifs/replay.c index b28ac4dfb4070a..c4047a8f641077 100644 --- a/fs/ubifs/replay.c +++ b/fs/ubifs/replay.c @@ -558,7 +558,7 @@ static int is_last_bud(struct ubifs_info *c, struct ubifs_bud *bud) return data == 0xFFFFFFFF; } -/* authenticate_sleb_hash and authenticate_sleb_hmac are split out for stack usage */ +/* authenticate_sleb_hash is split out for stack usage */ static int authenticate_sleb_hash(struct ubifs_info *c, struct shash_desc *log_hash, u8 *hash) { SHASH_DESC_ON_STACK(hash_desc, c->hash_tfm); @@ -569,15 +569,6 @@ static int authenticate_sleb_hash(struct ubifs_info *c, struct shash_desc *log_h return crypto_shash_final(hash_desc, hash); } -static int authenticate_sleb_hmac(struct ubifs_info *c, u8 *hash, u8 *hmac) -{ - SHASH_DESC_ON_STACK(hmac_desc, c->hmac_tfm); - - hmac_desc->tfm = c->hmac_tfm; - - return crypto_shash_digest(hmac_desc, hash, c->hash_len, hmac); -} - /** * authenticate_sleb - authenticate one scan LEB * @c: UBIFS file-system description object @@ -624,7 +615,8 @@ static int authenticate_sleb(struct ubifs_info *c, struct ubifs_scan_leb *sleb, if (err) goto out; - err = authenticate_sleb_hmac(c, hash, hmac); + err = crypto_shash_tfm_digest(c->hmac_tfm, hash, + c->hash_len, hmac); if (err) goto out; From patchwork Sat May 2 05:31:19 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Biggers X-Patchwork-Id: 11523729 X-Patchwork-Delegate: herbert@gondor.apana.org.au Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 06C3A1864 for ; Sat, 2 May 2020 05:33:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D92E42192A for ; Sat, 2 May 2020 05:33:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1588397630; bh=aRnhsnypAWsWXKVWbib/6Chk6PgcC0D+Q1jEbEW+EEA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=b2c3VTJlijeJq9rHS9pssAcosoClZ3dRjrEopZ7iIpsx2BOmybeHPmrspWkencH6+ ON5FrDgz0SMEujHbed8nVe0DdNJFYEpl5JtjtS+zLcHFA4KNsXLYwnOB94szp/48/9 RreEJJ+AfvhqFgVbD+MsciEq6rIu+e5SBLF445hk= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727832AbgEBFdu (ORCPT ); Sat, 2 May 2020 01:33:50 -0400 Received: from mail.kernel.org ([198.145.29.99]:39294 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727828AbgEBFdq (ORCPT ); Sat, 2 May 2020 01:33:46 -0400 Received: from sol.hsd1.ca.comcast.net (c-107-3-166-239.hsd1.ca.comcast.net [107.3.166.239]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id A0C6924956; Sat, 2 May 2020 05:33:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1588397625; bh=aRnhsnypAWsWXKVWbib/6Chk6PgcC0D+Q1jEbEW+EEA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PTGKbB6CEORZGYYUIt9JxkJSWjc4AMdJy/Ebcqg1ZEvcjNV7zjU8yAoCxLfvgP6p/ GpQs4ja/Otvda6MMGOV78JogJg2t6gr+50RB3vkM0+xAL3oIxIeqJdhj0Hb1ot5mo0 /x72PV9ExK8jtq2rF5WYPlnNqYV+DnwY/s5p22iA= From: Eric Biggers To: linux-crypto@vger.kernel.org Cc: linux-bluetooth@vger.kernel.org Subject: [PATCH 17/20] Bluetooth: use crypto_shash_tfm_digest() Date: Fri, 1 May 2020 22:31:19 -0700 Message-Id: <20200502053122.995648-18-ebiggers@kernel.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200502053122.995648-1-ebiggers@kernel.org> References: <20200502053122.995648-1-ebiggers@kernel.org> MIME-Version: 1.0 Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org From: Eric Biggers Instead of manually allocating a 'struct shash_desc' on the stack and calling crypto_shash_digest(), switch to using the new helper function crypto_shash_tfm_digest() which does this for us. Cc: linux-bluetooth@vger.kernel.org Signed-off-by: Eric Biggers --- net/bluetooth/smp.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/net/bluetooth/smp.c b/net/bluetooth/smp.c index 1476a91ce93572..d022f126eb026b 100644 --- a/net/bluetooth/smp.c +++ b/net/bluetooth/smp.c @@ -170,7 +170,6 @@ static int aes_cmac(struct crypto_shash *tfm, const u8 k[16], const u8 *m, size_t len, u8 mac[16]) { uint8_t tmp[16], mac_msb[16], msg_msb[CMAC_MSG_MAX]; - SHASH_DESC_ON_STACK(desc, tfm); int err; if (len > CMAC_MSG_MAX) @@ -181,8 +180,6 @@ static int aes_cmac(struct crypto_shash *tfm, const u8 k[16], const u8 *m, return -EINVAL; } - desc->tfm = tfm; - /* Swap key and message from LSB to MSB */ swap_buf(k, tmp, 16); swap_buf(m, msg_msb, len); @@ -196,8 +193,7 @@ static int aes_cmac(struct crypto_shash *tfm, const u8 k[16], const u8 *m, return err; } - err = crypto_shash_digest(desc, msg_msb, len, mac_msb); - shash_desc_zero(desc); + err = crypto_shash_tfm_digest(tfm, msg_msb, len, mac_msb); if (err) { BT_ERR("Hash computation error %d", err); return err; From patchwork Sat May 2 05:31:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Biggers X-Patchwork-Id: 11523723 X-Patchwork-Delegate: herbert@gondor.apana.org.au Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4279E1575 for ; Sat, 2 May 2020 05:33:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2B735208DB for ; Sat, 2 May 2020 05:33:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1588397629; bh=DNH8HL7hR1z4xDcsrk0vwGxoghDmgXVHhKNAUdwhCMU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=qEKiQ4cWBTfJgMsPMspBVFsL8jVCs794e7qYsLqqv1xzFFFPRgJmbHpeif8FjJ+bH MiQD59Jt2sZimCev0MdIOrQaLpxJu3DHnuem4hj8dBgO9TlxXkWVajuoD8a/C7Ydgj XD7D5GC12G36pJgfOtf4hWEB6vcWZHuTFg4yKRkE= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727776AbgEBFdr (ORCPT ); Sat, 2 May 2020 01:33:47 -0400 Received: from mail.kernel.org ([198.145.29.99]:39230 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727829AbgEBFdq (ORCPT ); Sat, 2 May 2020 01:33:46 -0400 Received: from sol.hsd1.ca.comcast.net (c-107-3-166-239.hsd1.ca.comcast.net [107.3.166.239]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id DD4E52071E; Sat, 2 May 2020 05:33:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1588397626; bh=DNH8HL7hR1z4xDcsrk0vwGxoghDmgXVHhKNAUdwhCMU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ioPw0U6l6P5ers4ni090dUqsLG8mEYUwGrMBCkQbXNyCcm+gedmvM9881pYACQla+ rpcv3YLfWJYN7wmTj+UPkHKCsTPa15qpS5mwMtCS6n1nOQoSW8lC4nt+jTingAGfDX rvM0jjIRXCRHlS+EmS/yhY6Fc/8H+KS2KCSX5FQ0= From: Eric Biggers To: linux-crypto@vger.kernel.org Cc: linux-sctp@vger.kernel.org Subject: [PATCH 18/20] sctp: use crypto_shash_tfm_digest() Date: Fri, 1 May 2020 22:31:20 -0700 Message-Id: <20200502053122.995648-19-ebiggers@kernel.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200502053122.995648-1-ebiggers@kernel.org> References: <20200502053122.995648-1-ebiggers@kernel.org> MIME-Version: 1.0 Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org From: Eric Biggers Instead of manually allocating a 'struct shash_desc' on the stack and calling crypto_shash_digest(), switch to using the new helper function crypto_shash_tfm_digest() which does this for us. Cc: linux-sctp@vger.kernel.org Signed-off-by: Eric Biggers --- net/sctp/auth.c | 10 ++-------- net/sctp/sm_make_chunk.c | 23 ++++++++--------------- 2 files changed, 10 insertions(+), 23 deletions(-) diff --git a/net/sctp/auth.c b/net/sctp/auth.c index 4278764d82b827..83e97e8892e05a 100644 --- a/net/sctp/auth.c +++ b/net/sctp/auth.c @@ -741,14 +741,8 @@ void sctp_auth_calculate_hmac(const struct sctp_association *asoc, if (crypto_shash_setkey(tfm, &asoc_key->data[0], asoc_key->len)) goto free; - { - SHASH_DESC_ON_STACK(desc, tfm); - - desc->tfm = tfm; - crypto_shash_digest(desc, (u8 *)auth, - end - (unsigned char *)auth, digest); - shash_desc_zero(desc); - } + crypto_shash_tfm_digest(tfm, (u8 *)auth, end - (unsigned char *)auth, + digest); free: if (free_key) diff --git a/net/sctp/sm_make_chunk.c b/net/sctp/sm_make_chunk.c index 09050c1d5517e7..c786215ba69a54 100644 --- a/net/sctp/sm_make_chunk.c +++ b/net/sctp/sm_make_chunk.c @@ -1666,17 +1666,14 @@ static struct sctp_cookie_param *sctp_pack_cookie( ntohs(init_chunk->chunk_hdr->length), raw_addrs, addrs_len); if (sctp_sk(ep->base.sk)->hmac) { - SHASH_DESC_ON_STACK(desc, sctp_sk(ep->base.sk)->hmac); + struct crypto_shash *tfm = sctp_sk(ep->base.sk)->hmac; int err; /* Sign the message. */ - desc->tfm = sctp_sk(ep->base.sk)->hmac; - - err = crypto_shash_setkey(desc->tfm, ep->secret_key, + err = crypto_shash_setkey(tfm, ep->secret_key, sizeof(ep->secret_key)) ?: - crypto_shash_digest(desc, (u8 *)&cookie->c, bodysize, - cookie->signature); - shash_desc_zero(desc); + crypto_shash_tfm_digest(tfm, (u8 *)&cookie->c, bodysize, + cookie->signature); if (err) goto free_cookie; } @@ -1737,17 +1734,13 @@ struct sctp_association *sctp_unpack_cookie( /* Check the signature. */ { - SHASH_DESC_ON_STACK(desc, sctp_sk(ep->base.sk)->hmac); + struct crypto_shash *tfm = sctp_sk(ep->base.sk)->hmac; int err; - desc->tfm = sctp_sk(ep->base.sk)->hmac; - - err = crypto_shash_setkey(desc->tfm, ep->secret_key, + err = crypto_shash_setkey(tfm, ep->secret_key, sizeof(ep->secret_key)) ?: - crypto_shash_digest(desc, (u8 *)bear_cookie, bodysize, - digest); - shash_desc_zero(desc); - + crypto_shash_tfm_digest(tfm, (u8 *)bear_cookie, bodysize, + digest); if (err) { *error = -SCTP_IERROR_NOMEM; goto fail; From patchwork Sat May 2 05:31:21 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Biggers X-Patchwork-Id: 11523731 X-Patchwork-Delegate: herbert@gondor.apana.org.au Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3068F81 for ; Sat, 2 May 2020 05:33:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0C2C7208DB for ; Sat, 2 May 2020 05:33:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1588397631; bh=m9tJRaC/xdkq2x9xEKERQDzme5WlAEgGO8kez0ERpKg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=Lr/jEQxx4kRP5n10qxGbDgYowYN+k03lagURL8UymHd1OM2C6GmWadvFCIrKekKxv yjgaDGdqGbI2KqE152atkqfLGzWwIB8YTcYjMVcU111v++K9Gow5PC6PPoQpjbAqmF 7zIp13y78lTcJ9kolVePAMTpX2p7kPzwlsDHNTC4= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727835AbgEBFdt (ORCPT ); Sat, 2 May 2020 01:33:49 -0400 Received: from mail.kernel.org ([198.145.29.99]:39220 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727832AbgEBFdq (ORCPT ); Sat, 2 May 2020 01:33:46 -0400 Received: from sol.hsd1.ca.comcast.net (c-107-3-166-239.hsd1.ca.comcast.net [107.3.166.239]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 2451C2495B; Sat, 2 May 2020 05:33:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1588397626; bh=m9tJRaC/xdkq2x9xEKERQDzme5WlAEgGO8kez0ERpKg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SElL3uHFWuIiPX2XYV1j5cAPwHYTomeoDZNdTWNxvO1T6CViwnDRIzlHoC8yYzrKo 9vTCU8q8hXm55jXssqRx3kGe3C557tQ6glI3+mdiHo7/f+SYT+yNj5rfM8n+knD9qE F2U+IrJH3LqLvKMPwfctO6NrzAGdULBWAaXsY69s= From: Eric Biggers To: linux-crypto@vger.kernel.org Cc: keyrings@vger.kernel.org Subject: [PATCH 19/20] KEYS: encrypted: use crypto_shash_tfm_digest() Date: Fri, 1 May 2020 22:31:21 -0700 Message-Id: <20200502053122.995648-20-ebiggers@kernel.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200502053122.995648-1-ebiggers@kernel.org> References: <20200502053122.995648-1-ebiggers@kernel.org> MIME-Version: 1.0 Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org From: Eric Biggers Instead of manually allocating a 'struct shash_desc' on the stack and calling crypto_shash_digest(), switch to using the new helper function crypto_shash_tfm_digest() which does this for us. Cc: keyrings@vger.kernel.org Signed-off-by: Eric Biggers --- security/keys/encrypted-keys/encrypted.c | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/security/keys/encrypted-keys/encrypted.c b/security/keys/encrypted-keys/encrypted.c index f6797ba44bf716..14cf81d1a30b14 100644 --- a/security/keys/encrypted-keys/encrypted.c +++ b/security/keys/encrypted-keys/encrypted.c @@ -323,19 +323,6 @@ static struct key *request_user_key(const char *master_desc, const u8 **master_k return ukey; } -static int calc_hash(struct crypto_shash *tfm, u8 *digest, - const u8 *buf, unsigned int buflen) -{ - SHASH_DESC_ON_STACK(desc, tfm); - int err; - - desc->tfm = tfm; - - err = crypto_shash_digest(desc, buf, buflen, digest); - shash_desc_zero(desc); - return err; -} - static int calc_hmac(u8 *digest, const u8 *key, unsigned int keylen, const u8 *buf, unsigned int buflen) { @@ -351,7 +338,7 @@ static int calc_hmac(u8 *digest, const u8 *key, unsigned int keylen, err = crypto_shash_setkey(tfm, key, keylen); if (!err) - err = calc_hash(tfm, digest, buf, buflen); + err = crypto_shash_tfm_digest(tfm, buf, buflen, digest); crypto_free_shash(tfm); return err; } @@ -381,7 +368,8 @@ static int get_derived_key(u8 *derived_key, enum derived_key_type key_type, memcpy(derived_buf + strlen(derived_buf) + 1, master_key, master_keylen); - ret = calc_hash(hash_tfm, derived_key, derived_buf, derived_buf_len); + ret = crypto_shash_tfm_digest(hash_tfm, derived_buf, derived_buf_len, + derived_key); kzfree(derived_buf); return ret; } From patchwork Sat May 2 05:31:22 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Biggers X-Patchwork-Id: 11523733 X-Patchwork-Delegate: herbert@gondor.apana.org.au Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8BF681862 for ; Sat, 2 May 2020 05:33:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6B9752184D for ; Sat, 2 May 2020 05:33:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1588397631; bh=VK3L5BIk03pa6rK76LADKFXOAOOyd/XyN2Ibf6A9B4g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=HH0NlrcgxHiuSOzCeuQYMHGBXgRanMyaUD36Ai+gvt0FOXHixC5Ci5x1niKfdvXvY ar0gG8XWpqBhA79trgiDQ9lxUAb5qCsIQ+nIUKMWHS3PY4ofiSPUyVE9bq53AMfn/J yJo+s+ECPyu91qccGo84cXtH9KhSZKQYoSPyhU+U= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727849AbgEBFdt (ORCPT ); Sat, 2 May 2020 01:33:49 -0400 Received: from mail.kernel.org ([198.145.29.99]:39282 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727835AbgEBFdq (ORCPT ); Sat, 2 May 2020 01:33:46 -0400 Received: from sol.hsd1.ca.comcast.net (c-107-3-166-239.hsd1.ca.comcast.net [107.3.166.239]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 60FC9208DB; Sat, 2 May 2020 05:33:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1588397626; bh=VK3L5BIk03pa6rK76LADKFXOAOOyd/XyN2Ibf6A9B4g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Tc8/LN3Y73ieRgTWJW+guipZirfitS4BA9+w321xwR0kTFI8CLMBHAFcwoOtqjdla glljJzPAU0CVSpNKrSqYxsSNHoJ9dnss9tGUvRRCaYLfxzP+e9x1VP74lzM9asO6bC 68Sd9BVrVibI6whZRhbPX5sJ6OkVBMOLXMZIXvHg= From: Eric Biggers To: linux-crypto@vger.kernel.org Cc: Cheng-Yi Chiang , Enric Balletbo i Serra , Guenter Roeck Subject: [PATCH 20/20] ASoC: cros_ec_codec: use crypto_shash_tfm_digest() Date: Fri, 1 May 2020 22:31:22 -0700 Message-Id: <20200502053122.995648-21-ebiggers@kernel.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200502053122.995648-1-ebiggers@kernel.org> References: <20200502053122.995648-1-ebiggers@kernel.org> MIME-Version: 1.0 Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org From: Eric Biggers Instead of manually allocating a 'struct shash_desc' on the stack and calling crypto_shash_digest(), switch to using the new helper function crypto_shash_tfm_digest() which does this for us. Cc: Cheng-Yi Chiang Cc: Enric Balletbo i Serra Cc: Guenter Roeck Signed-off-by: Eric Biggers --- sound/soc/codecs/cros_ec_codec.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/sound/soc/codecs/cros_ec_codec.c b/sound/soc/codecs/cros_ec_codec.c index d3dc42aa682565..bfdd852bdc0de4 100644 --- a/sound/soc/codecs/cros_ec_codec.c +++ b/sound/soc/codecs/cros_ec_codec.c @@ -115,14 +115,7 @@ static int calculate_sha256(struct cros_ec_codec_priv *priv, return PTR_ERR(tfm); } - { - SHASH_DESC_ON_STACK(desc, tfm); - - desc->tfm = tfm; - - crypto_shash_digest(desc, buf, size, digest); - shash_desc_zero(desc); - } + crypto_shash_tfm_digest(tfm, buf, size, digest); crypto_free_shash(tfm);