Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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>

authored by

Eric Biggers and committed by
Herbert Xu
b529f198 b828f905

+1 -6
+1 -6
drivers/crypto/atmel-sha.c
··· 1853 1853 { 1854 1854 struct atmel_sha_hmac_ctx *hmac = crypto_ahash_ctx(tfm); 1855 1855 1856 - if (atmel_sha_hmac_key_set(&hmac->hkey, key, keylen)) { 1857 - crypto_ahash_set_flags(tfm, CRYPTO_TFM_RES_BAD_KEY_LEN); 1858 - return -EINVAL; 1859 - } 1860 - 1861 - return 0; 1856 + return atmel_sha_hmac_key_set(&hmac->hkey, key, keylen); 1862 1857 } 1863 1858 1864 1859 static int atmel_sha_hmac_init(struct ahash_request *req)