summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHerbert Xu <herbert@gondor.apana.org.au>2020-08-18 18:25:34 +1000
committerHerbert Xu <herbert@gondor.apana.org.au>2020-08-28 16:58:28 +1000
commitf700e72d44ae2db03cc20c0fd415d4a6287661c8 (patch)
tree284ebbc072b4127ca968f3664cdf077617eb3385
parent1f3783b73e9f81f956624f8edb0122935c0a52ba (diff)
downloadlinux-crypto-f700e72d44ae2db03cc20c0fd415d4a6287661c8.tar.gz
linux-crypto-f700e72d44ae2db03cc20c0fd415d4a6287661c8.zip
crypto: ahash - Add init_tfm/exit_tfm
This patch adds the type-safe init_tfm/exit_tfm functions to the ahash interface. This is meant to replace the unsafe cra_init and cra_exit interface. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
-rw-r--r--crypto/ahash.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/crypto/ahash.c b/crypto/ahash.c
index d84ad925..c2ca631a 100644
--- a/crypto/ahash.c
+++ b/crypto/ahash.c
@@ -444,6 +444,14 @@ static int ahash_def_finup(struct ahash_request *req)
return ahash_def_finup_finish1(req, err);
}
+static void crypto_ahash_exit_tfm(struct crypto_tfm *tfm)
+{
+ struct crypto_ahash *hash = __crypto_ahash_cast(tfm);
+ struct ahash_alg *alg = crypto_ahash_alg(hash);
+
+ alg->exit_tfm(hash);
+}
+
static int crypto_ahash_init_tfm(struct crypto_tfm *tfm)
{
struct crypto_ahash *hash = __crypto_ahash_cast(tfm);
@@ -467,7 +475,10 @@ static int crypto_ahash_init_tfm(struct crypto_tfm *tfm)
ahash_set_needkey(hash);
}
- return 0;
+ if (alg->exit_tfm)
+ tfm->exit = crypto_ahash_exit_tfm;
+
+ return alg->init_tfm ? alg->init_tfm(hash) : 0;
}
static unsigned int crypto_ahash_extsize(struct crypto_alg *alg)