crypto: sun4i-ss - use crypto_ahash_digestsize
authorCorentin Labbe <clabbe.montjoie@gmail.com>
Thu, 14 Nov 2019 10:58:13 +0000 (11:58 +0100)
committerHerbert Xu <herbert@gondor.apana.org.au>
Fri, 22 Nov 2019 10:48:37 +0000 (18:48 +0800)
The size of the digest is different between MD5 and SHA1 so instead of
using the higher value (5 words), let's use crypto_ahash_digestsize().

Signed-off-by: Corentin Labbe <clabbe.montjoie@gmail.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
drivers/crypto/allwinner/sun4i-ss/sun4i-ss-hash.c

index 91cf58db3845437304a5a8b6a34d7008ef414ddf..b19dc737dfe3bf43ffa7c2a3bf613568c422a293 100644 (file)
@@ -227,7 +227,7 @@ static int sun4i_hash(struct ahash_request *areq)
         */
        if (op->byte_count) {
                ivmode = SS_IV_ARBITRARY;
-               for (i = 0; i < 5; i++)
+               for (i = 0; i < crypto_ahash_digestsize(tfm) / 4; i++)
                        writel(op->hash[i], ss->base + SS_IV0 + i * 4);
        }
        /* Enable the device */