From: Eric Biggers Date: Tue, 31 Dec 2019 03:19:33 +0000 (-0600) Subject: crypto: atmel-sha - fix error handling when setting hmac key X-Git-Tag: v5.15~4288^2~103 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b529f1983b2dcc46354f311feda92e07b6e9e2da;p=platform%2Fkernel%2Flinux-starfive.git crypto: atmel-sha - fix error handling when setting hmac key 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 Cc: Alexandre Belloni Cc: Ludovic Desroches Signed-off-by: Eric Biggers Reviewed-by: Tudor Ambarus Signed-off-by: Herbert Xu --- diff --git a/drivers/crypto/atmel-sha.c b/drivers/crypto/atmel-sha.c index e8e4200..d3bcd14 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)