2019-12-31 03:24:27

by Eric Biggers

[permalink] [raw]
Subject: [PATCH 2/8] crypto: artpec6 - return correct error code for failed setkey()

From: Eric Biggers <[email protected]>

->setkey() is supposed to retun -EINVAL for invalid key lengths, not -1.

Fixes: a21eb94fc4d3 ("crypto: axis - add ARTPEC-6/7 crypto accelerator driver")
Cc: Jesper Nilsson <[email protected]>
Cc: Lars Persson <[email protected]>
Signed-off-by: Eric Biggers <[email protected]>
---
drivers/crypto/axis/artpec6_crypto.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/crypto/axis/artpec6_crypto.c b/drivers/crypto/axis/artpec6_crypto.c
index 4b20606983a4..22ebe40f09f5 100644
--- a/drivers/crypto/axis/artpec6_crypto.c
+++ b/drivers/crypto/axis/artpec6_crypto.c
@@ -1251,7 +1251,7 @@ static int artpec6_crypto_aead_set_key(struct crypto_aead *tfm, const u8 *key,

if (len != 16 && len != 24 && len != 32) {
crypto_aead_set_flags(tfm, CRYPTO_TFM_RES_BAD_KEY_LEN);
- return -1;
+ return -EINVAL;
}

ctx->key_length = len;
--
2.24.1


2019-12-31 04:44:08

by Eric Biggers

[permalink] [raw]
Subject: Re: [PATCH 2/8] crypto: artpec6 - return correct error code for failed setkey()

[+Cc the people with Cc tags in the patch, who I accidentally didn't Cc...
Original message was
https://lkml.kernel.org/linux-crypto/[email protected]/]

On Mon, Dec 30, 2019 at 09:19:32PM -0600, Eric Biggers wrote:
> From: Eric Biggers <[email protected]>
>
> ->setkey() is supposed to retun -EINVAL for invalid key lengths, not -1.
>
> Fixes: a21eb94fc4d3 ("crypto: axis - add ARTPEC-6/7 crypto accelerator driver")
> Cc: Jesper Nilsson <[email protected]>
> Cc: Lars Persson <[email protected]>
> Signed-off-by: Eric Biggers <[email protected]>
> ---
> drivers/crypto/axis/artpec6_crypto.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/crypto/axis/artpec6_crypto.c b/drivers/crypto/axis/artpec6_crypto.c
> index 4b20606983a4..22ebe40f09f5 100644
> --- a/drivers/crypto/axis/artpec6_crypto.c
> +++ b/drivers/crypto/axis/artpec6_crypto.c
> @@ -1251,7 +1251,7 @@ static int artpec6_crypto_aead_set_key(struct crypto_aead *tfm, const u8 *key,
>
> if (len != 16 && len != 24 && len != 32) {
> crypto_aead_set_flags(tfm, CRYPTO_TFM_RES_BAD_KEY_LEN);
> - return -1;
> + return -EINVAL;
> }
>
> ctx->key_length = len;
> --
> 2.24.1
>

2020-01-01 16:11:47

by Lars Persson

[permalink] [raw]
Subject: Re: [PATCH 2/8] crypto: artpec6 - return correct error code for failed setkey()

On 12/31/19 5:43 AM, Eric Biggers wrote:
> [+Cc the people with Cc tags in the patch, who I accidentally didn't Cc...
> ?Original message was
> https://lkml.kernel.org/linux-crypto/[email protected]/]
>
> On Mon, Dec 30, 2019 at 09:19:32PM -0600, Eric Biggers wrote:
>> From: Eric Biggers <[email protected]>
>>
>> ->setkey() is supposed to retun -EINVAL for invalid key lengths, not -1.
>>
>> Fixes: a21eb94fc4d3 ("crypto: axis - add ARTPEC-6/7 crypto accelerator driver")
>> Cc: Jesper Nilsson <[email protected]>
>> Cc: Lars Persson <[email protected]>
>> Signed-off-by: Eric Biggers <[email protected]>
>> ---
>>? drivers/crypto/axis/artpec6_crypto.c | 2 +-
>>? 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/crypto/axis/artpec6_crypto.c b/drivers/crypto/axis/artpec6_crypto.c
>> index 4b20606983a4..22ebe40f09f5 100644
>> --- a/drivers/crypto/axis/artpec6_crypto.c
>> +++ b/drivers/crypto/axis/artpec6_crypto.c
>> @@ -1251,7 +1251,7 @@ static int artpec6_crypto_aead_set_key(struct crypto_aead *tfm, const u8 *key,
>>
>>??????? if (len != 16 && len != 24 && len != 32) {
>>??????????????? crypto_aead_set_flags(tfm, CRYPTO_TFM_RES_BAD_KEY_LEN);
>> -???????????? return -1;
>> +???????????? return -EINVAL;
>>??????? }
>>
>>??????? ctx->key_length = len;
>> --
>> 2.24.1
>>

Acked-by: Lars Persson <[email protected]>

Thanks,
Lars