OSDN Git Service

crypto: caam/qi2 - create ahash shared descriptors only once
authorHoria Geantă <horia.geanta@nxp.com>
Wed, 22 Jul 2020 12:14:54 +0000 (15:14 +0300)
committerHerbert Xu <herbert@gondor.apana.org.au>
Fri, 31 Jul 2020 08:25:27 +0000 (18:25 +1000)
For keyed hash algorithms, shared descriptors are currently generated
twice:
-at tfm initialization time, in cra_init() callback
-in setkey() callback

Since it's mandatory to call setkey() for keyed algorithms, drop the
generation in cra_init().

This is similar to the change in caamhash (caam/jr top-level library)
commit 9a2537d0ebc9 ("crypto: caam - create ahash shared descriptors only once")

Signed-off-by: Horia Geantă <horia.geanta@nxp.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
drivers/crypto/caam/caamalg_qi2.c

index 811d34e..1e90134 100644 (file)
@@ -4500,7 +4500,11 @@ static int caam_hash_cra_init(struct crypto_tfm *tfm)
        crypto_ahash_set_reqsize(__crypto_ahash_cast(tfm),
                                 sizeof(struct caam_hash_state));
 
-       return ahash_set_sh_desc(ahash);
+       /*
+        * For keyed hash algorithms shared descriptors
+        * will be created later in setkey() callback
+        */
+       return alg->setkey ? 0 : ahash_set_sh_desc(ahash);
 }
 
 static void caam_hash_cra_exit(struct crypto_tfm *tfm)