summaryrefslogtreecommitdiffstats
path: root/crypto
diff options
context:
space:
mode:
authorHerbert Xu <herbert@gondor.apana.org.au>2023-04-13 14:24:25 +0800
committerHerbert Xu <herbert@gondor.apana.org.au>2023-04-20 18:20:04 +0800
commitcfbda734d6678047fd3beb1f67d9682825773341 (patch)
tree8e15e2746f515edc440ea8a72518bb6e05228be9 /crypto
parent0303b7f5df603b91bc12e39c9309c094816ba6a9 (diff)
downloadlinux-cfbda734d6678047fd3beb1f67d9682825773341.tar.gz
linux-cfbda734d6678047fd3beb1f67d9682825773341.tar.bz2
linux-cfbda734d6678047fd3beb1f67d9682825773341.zip
crypto: cryptd - Add support for cloning hashes
Allow cryptd hashes to be cloned. The underlying hash will be cloned. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'crypto')
-rw-r--r--crypto/cryptd.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/crypto/cryptd.c b/crypto/cryptd.c
index 43ce347ccba0..bbcc368b6a55 100644
--- a/crypto/cryptd.c
+++ b/crypto/cryptd.c
@@ -446,6 +446,21 @@ static int cryptd_hash_init_tfm(struct crypto_ahash *tfm)
return 0;
}
+static int cryptd_hash_clone_tfm(struct crypto_ahash *ntfm,
+ struct crypto_ahash *tfm)
+{
+ struct cryptd_hash_ctx *nctx = crypto_ahash_ctx(ntfm);
+ struct cryptd_hash_ctx *ctx = crypto_ahash_ctx(tfm);
+ struct crypto_shash *hash;
+
+ hash = crypto_clone_shash(ctx->child);
+ if (IS_ERR(hash))
+ return PTR_ERR(hash);
+
+ nctx->child = hash;
+ return 0;
+}
+
static void cryptd_hash_exit_tfm(struct crypto_ahash *tfm)
{
struct cryptd_hash_ctx *ctx = crypto_ahash_ctx(tfm);
@@ -678,6 +693,7 @@ static int cryptd_create_hash(struct crypto_template *tmpl, struct rtattr **tb,
inst->alg.halg.base.cra_ctxsize = sizeof(struct cryptd_hash_ctx);
inst->alg.init_tfm = cryptd_hash_init_tfm;
+ inst->alg.clone_tfm = cryptd_hash_clone_tfm;
inst->alg.exit_tfm = cryptd_hash_exit_tfm;
inst->alg.init = cryptd_hash_init_enqueue;