From: Eric Biggers <ebiggers@kernel.org>
To: linux-crypto@vger.kernel.org
Cc: Nicolas Ferre <nicolas.ferre@microchip.com>,
Alexandre Belloni <alexandre.belloni@bootlin.com>,
Ludovic Desroches <ludovic.desroches@microchip.com>
Subject: Re: [PATCH 3/8] crypto: atmel-sha - fix error handling when setting hmac key
Date: Mon, 30 Dec 2019 22:45:22 -0600 [thread overview]
Message-ID: <20191231044522.GC180988@zzz.localdomain> (raw)
In-Reply-To: <20191231031938.241705-4-ebiggers@kernel.org>
[+Cc the people with Cc tags in the patch, who I accidentally didn't Cc...
Original message was
https://lkml.kernel.org/linux-crypto/20191231031938.241705-4-ebiggers@kernel.org/]
On Mon, Dec 30, 2019 at 09:19:33PM -0600, Eric Biggers wrote:
> From: Eric Biggers <ebiggers@google.com>
>
> HMAC keys can be of any length, and atmel_sha_hmac_key_set() can only
> fail due to -ENOMEM. But atmel_sha_hmac_setkey() incorrectly treated
> any error as a "bad key length" error. Fix it to correctly propagate
> the -ENOMEM error code and not set any tfm result flags.
>
> Fixes: 81d8750b2b59 ("crypto: atmel-sha - add support to hmac(shaX)")
> Cc: Nicolas Ferre <nicolas.ferre@microchip.com>
> Cc: Alexandre Belloni <alexandre.belloni@bootlin.com>
> Cc: Ludovic Desroches <ludovic.desroches@microchip.com>
> Signed-off-by: Eric Biggers <ebiggers@google.com>
> ---
> drivers/crypto/atmel-sha.c | 7 +------
> 1 file changed, 1 insertion(+), 6 deletions(-)
>
> diff --git a/drivers/crypto/atmel-sha.c b/drivers/crypto/atmel-sha.c
> index e8e4200c1ab3..d3bcd14201c2 100644
> --- a/drivers/crypto/atmel-sha.c
> +++ b/drivers/crypto/atmel-sha.c
> @@ -1853,12 +1853,7 @@ static int atmel_sha_hmac_setkey(struct crypto_ahash *tfm, const u8 *key,
> {
> struct atmel_sha_hmac_ctx *hmac = crypto_ahash_ctx(tfm);
>
> - if (atmel_sha_hmac_key_set(&hmac->hkey, key, keylen)) {
> - crypto_ahash_set_flags(tfm, CRYPTO_TFM_RES_BAD_KEY_LEN);
> - return -EINVAL;
> - }
> -
> - return 0;
> + return atmel_sha_hmac_key_set(&hmac->hkey, key, keylen);
> }
>
> static int atmel_sha_hmac_init(struct ahash_request *req)
> --
> 2.24.1
>
next prev parent reply other threads:[~2019-12-31 4:45 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-12-31 3:19 [PATCH 0/8] crypto: remove the CRYPTO_TFM_RES_* flags Eric Biggers
2019-12-31 3:19 ` [PATCH 1/8] crypto: chelsio - fix writing tfm flags to wrong place Eric Biggers
2019-12-31 4:42 ` Eric Biggers
2019-12-31 3:19 ` [PATCH 2/8] crypto: artpec6 - return correct error code for failed setkey() Eric Biggers
2019-12-31 4:43 ` Eric Biggers
2020-01-01 16:04 ` Lars Persson
2019-12-31 3:19 ` [PATCH 3/8] crypto: atmel-sha - fix error handling when setting hmac key Eric Biggers
2019-12-31 4:45 ` Eric Biggers [this message]
2020-01-08 16:06 ` Tudor.Ambarus
2019-12-31 3:19 ` [PATCH 4/8] crypto: remove unused tfm result flags Eric Biggers
2019-12-31 3:19 ` [PATCH 5/8] crypto: remove CRYPTO_TFM_RES_BAD_BLOCK_LEN Eric Biggers
2019-12-31 3:19 ` [PATCH 6/8] crypto: remove CRYPTO_TFM_RES_BAD_KEY_LEN Eric Biggers
2020-01-06 15:00 ` Horia Geanta
2019-12-31 3:19 ` [PATCH 7/8] crypto: remove CRYPTO_TFM_RES_WEAK_KEY Eric Biggers
2019-12-31 3:19 ` [PATCH 8/8] crypto: remove propagation of CRYPTO_TFM_RES_* flags Eric Biggers
2019-12-31 8:14 ` [PATCH 0/8] crypto: remove the " Ard Biesheuvel
2020-01-09 5:14 ` Herbert Xu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20191231044522.GC180988@zzz.localdomain \
--to=ebiggers@kernel.org \
--cc=alexandre.belloni@bootlin.com \
--cc=linux-crypto@vger.kernel.org \
--cc=ludovic.desroches@microchip.com \
--cc=nicolas.ferre@microchip.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox