From: <Tudor.Ambarus@microchip.com>
To: <linux-crypto@vger.kernel.org>
Cc: <ebiggers@kernel.org>
Subject: Re: [PATCH 3/8] crypto: atmel-sha - fix error handling when setting hmac key
Date: Wed, 8 Jan 2020 16:06:06 +0000 [thread overview]
Message-ID: <2028004.Oqa5o8bvTI@localhost.localdomain> (raw)
In-Reply-To: <20191231031938.241705-4-ebiggers@kernel.org>
On Tuesday, December 31, 2019 5:19:33 AM EET 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);
The atmel_sha_hmac_key_set() is used just here, maybe it is worth getting rid
of the function and copy its body here. As this is just a cosmetic suggestion,
with or without this, one can add:
Reviewed-by: Tudor Ambarus <tudor.ambarus@microchip.com>
> }
>
> static int atmel_sha_hmac_init(struct ahash_request *req)
next prev parent reply other threads:[~2020-01-08 16:06 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
2020-01-08 16:06 ` Tudor.Ambarus [this message]
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=2028004.Oqa5o8bvTI@localhost.localdomain \
--to=tudor.ambarus@microchip.com \
--cc=ebiggers@kernel.org \
--cc=linux-crypto@vger.kernel.org \
/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