diff mbox series

crypto: tcrypt - fix ghash-generic speed test

Message ID 20180912132048.18780-1-horia.geanta@nxp.com (mailing list archive)
State Accepted
Delegated to: Herbert Xu
Headers show
Series crypto: tcrypt - fix ghash-generic speed test | expand

Commit Message

Horia Geanta Sept. 12, 2018, 1:20 p.m. UTC
ghash is a keyed hash algorithm, thus setkey needs to be called.
Otherwise the following error occurs:
$ modprobe tcrypt mode=318 sec=1
testing speed of async ghash-generic (ghash-generic)
tcrypt: test  0 (   16 byte blocks,   16 bytes per update,   1 updates):
tcrypt: hashing failed ret=-126

Cc: <stable@vger.kernel.org> # 4.6+
Fixes: 0660511c0bee ("crypto: tcrypt - Use ahash")
Tested-by: Franck Lenormand <franck.lenormand@nxp.com>
Signed-off-by: Horia Geantă <horia.geanta@nxp.com>
---
 crypto/tcrypt.c | 3 +++
 1 file changed, 3 insertions(+)

Comments

Ard Biesheuvel Sept. 12, 2018, 2:26 p.m. UTC | #1
On 12 September 2018 at 15:20, Horia Geantă <horia.geanta@nxp.com> wrote:
> ghash is a keyed hash algorithm, thus setkey needs to be called.
> Otherwise the following error occurs:
> $ modprobe tcrypt mode=318 sec=1
> testing speed of async ghash-generic (ghash-generic)
> tcrypt: test  0 (   16 byte blocks,   16 bytes per update,   1 updates):
> tcrypt: hashing failed ret=-126
>
> Cc: <stable@vger.kernel.org> # 4.6+
> Fixes: 0660511c0bee ("crypto: tcrypt - Use ahash")
> Tested-by: Franck Lenormand <franck.lenormand@nxp.com>
> Signed-off-by: Horia Geantă <horia.geanta@nxp.com>

Acked-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>

> ---
>  crypto/tcrypt.c | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/crypto/tcrypt.c b/crypto/tcrypt.c
> index bdde95e8d369..6e0a054bb61d 100644
> --- a/crypto/tcrypt.c
> +++ b/crypto/tcrypt.c
> @@ -1103,6 +1103,9 @@ static void test_ahash_speed_common(const char *algo, unsigned int secs,
>                         break;
>                 }
>
> +               if (speed[i].klen)
> +                       crypto_ahash_setkey(tfm, tvmem[0], speed[i].klen);
> +
>                 pr_info("test%3u "
>                         "(%5u byte blocks,%5u bytes per update,%4u updates): ",
>                         i, speed[i].blen, speed[i].plen, speed[i].blen / speed[i].plen);
> --
> 2.16.2
>
Herbert Xu Sept. 21, 2018, 5:45 a.m. UTC | #2
On Wed, Sep 12, 2018 at 04:20:48PM +0300, Horia Geantă wrote:
> ghash is a keyed hash algorithm, thus setkey needs to be called.
> Otherwise the following error occurs:
> $ modprobe tcrypt mode=318 sec=1
> testing speed of async ghash-generic (ghash-generic)
> tcrypt: test  0 (   16 byte blocks,   16 bytes per update,   1 updates):
> tcrypt: hashing failed ret=-126
> 
> Cc: <stable@vger.kernel.org> # 4.6+
> Fixes: 0660511c0bee ("crypto: tcrypt - Use ahash")
> Tested-by: Franck Lenormand <franck.lenormand@nxp.com>
> Signed-off-by: Horia Geantă <horia.geanta@nxp.com>

Patch applied.  Thanks.
diff mbox series

Patch

diff --git a/crypto/tcrypt.c b/crypto/tcrypt.c
index bdde95e8d369..6e0a054bb61d 100644
--- a/crypto/tcrypt.c
+++ b/crypto/tcrypt.c
@@ -1103,6 +1103,9 @@  static void test_ahash_speed_common(const char *algo, unsigned int secs,
 			break;
 		}
 
+		if (speed[i].klen)
+			crypto_ahash_setkey(tfm, tvmem[0], speed[i].klen);
+
 		pr_info("test%3u "
 			"(%5u byte blocks,%5u bytes per update,%4u updates): ",
 			i, speed[i].blen, speed[i].plen, speed[i].blen / speed[i].plen);