mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-10-05 00:20:32 +00:00
crypto: atmel-sha - fix error handling when setting hmac key
commitb529f1983b
upstream. 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:81d8750b2b
("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> Reviewed-by: Tudor Ambarus <tudor.ambarus@microchip.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
e1254ca723
commit
b772f3c499
1 changed files with 1 additions and 6 deletions
|
@ -1921,12 +1921,7 @@ static int atmel_sha_hmac_setkey(struct crypto_ahash *tfm, const u8 *key,
|
||||||
{
|
{
|
||||||
struct atmel_sha_hmac_ctx *hmac = crypto_ahash_ctx(tfm);
|
struct atmel_sha_hmac_ctx *hmac = crypto_ahash_ctx(tfm);
|
||||||
|
|
||||||
if (atmel_sha_hmac_key_set(&hmac->hkey, key, keylen)) {
|
return atmel_sha_hmac_key_set(&hmac->hkey, key, keylen);
|
||||||
crypto_ahash_set_flags(tfm, CRYPTO_TFM_RES_BAD_KEY_LEN);
|
|
||||||
return -EINVAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int atmel_sha_hmac_init(struct ahash_request *req)
|
static int atmel_sha_hmac_init(struct ahash_request *req)
|
||||||
|
|
Loading…
Reference in a new issue