Skip to content

Commit cfbda73

Browse files
committed
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>
1 parent 0303b7f commit cfbda73

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

crypto/cryptd.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -446,6 +446,21 @@ static int cryptd_hash_init_tfm(struct crypto_ahash *tfm)
446446
return 0;
447447
}
448448

449+
static int cryptd_hash_clone_tfm(struct crypto_ahash *ntfm,
450+
struct crypto_ahash *tfm)
451+
{
452+
struct cryptd_hash_ctx *nctx = crypto_ahash_ctx(ntfm);
453+
struct cryptd_hash_ctx *ctx = crypto_ahash_ctx(tfm);
454+
struct crypto_shash *hash;
455+
456+
hash = crypto_clone_shash(ctx->child);
457+
if (IS_ERR(hash))
458+
return PTR_ERR(hash);
459+
460+
nctx->child = hash;
461+
return 0;
462+
}
463+
449464
static void cryptd_hash_exit_tfm(struct crypto_ahash *tfm)
450465
{
451466
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,
678693
inst->alg.halg.base.cra_ctxsize = sizeof(struct cryptd_hash_ctx);
679694

680695
inst->alg.init_tfm = cryptd_hash_init_tfm;
696+
inst->alg.clone_tfm = cryptd_hash_clone_tfm;
681697
inst->alg.exit_tfm = cryptd_hash_exit_tfm;
682698

683699
inst->alg.init = cryptd_hash_init_enqueue;

0 commit comments

Comments
 (0)