Re: [PATCH 3/8] crypto: atmel-sha - fix error handling when setting hmac key

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



[+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@xxxxxxxxxx/]

On Mon, Dec 30, 2019 at 09:19:33PM -0600, Eric Biggers wrote:
> From: Eric Biggers <ebiggers@xxxxxxxxxx>
> 
> 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@xxxxxxxxxxxxx>
> Cc: Alexandre Belloni <alexandre.belloni@xxxxxxxxxxx>
> Cc: Ludovic Desroches <ludovic.desroches@xxxxxxxxxxxxx>
> Signed-off-by: Eric Biggers <ebiggers@xxxxxxxxxx>
> ---
>  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
> 



[Index of Archives]     [Kernel]     [Gnu Classpath]     [Gnu Crypto]     [DM Crypt]     [Netfilter]     [Bugtraq]

  Powered by Linux