summaryrefslogtreecommitdiff
path: root/drivers/crypto/atmel-sha.c
diff options
context:
space:
mode:
authorEric Biggers <ebiggers@google.com>2019-12-31 06:19:33 +0300
committerHerbert Xu <herbert@gondor.apana.org.au>2020-01-09 06:30:52 +0300
commitb529f1983b2dcc46354f311feda92e07b6e9e2da (patch)
tree8f2ad13aee56ee35f00ba823fd338482c7fad9cd /drivers/crypto/atmel-sha.c
parentb828f905904cd76424230c69741a4cabb0174168 (diff)
downloadlinux-b529f1983b2dcc46354f311feda92e07b6e9e2da.tar.xz
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 <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>
Diffstat (limited to 'drivers/crypto/atmel-sha.c')
-rw-r--r--drivers/crypto/atmel-sha.c7
1 files changed, 1 insertions, 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)