Skip to content

Commit

Permalink
crypto: cryptd - Convert hash to use modern init_tfm/exit_tfm
Browse files Browse the repository at this point in the history
The cryptd hash template was still using the obsolete cra_init/cra_exit
interface.  Make it use the modern ahash init_tfm/exit_tfm instead.

Signed-off-by: Herbert Xu <[email protected]>
Reviewed-by: Simon Horman <[email protected]>
Signed-off-by: Herbert Xu <[email protected]>
  • Loading branch information
herbertx committed Apr 20, 2023
1 parent 8538e60 commit 0303b7f
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions crypto/cryptd.c
Original file line number Diff line number Diff line change
Expand Up @@ -427,28 +427,28 @@ static int cryptd_create_skcipher(struct crypto_template *tmpl,
return err;
}

static int cryptd_hash_init_tfm(struct crypto_tfm *tfm)
static int cryptd_hash_init_tfm(struct crypto_ahash *tfm)
{
struct crypto_instance *inst = crypto_tfm_alg_instance(tfm);
struct hashd_instance_ctx *ictx = crypto_instance_ctx(inst);
struct ahash_instance *inst = ahash_alg_instance(tfm);
struct hashd_instance_ctx *ictx = ahash_instance_ctx(inst);
struct crypto_shash_spawn *spawn = &ictx->spawn;
struct cryptd_hash_ctx *ctx = crypto_tfm_ctx(tfm);
struct cryptd_hash_ctx *ctx = crypto_ahash_ctx(tfm);
struct crypto_shash *hash;

hash = crypto_spawn_shash(spawn);
if (IS_ERR(hash))
return PTR_ERR(hash);

ctx->child = hash;
crypto_ahash_set_reqsize(__crypto_ahash_cast(tfm),
crypto_ahash_set_reqsize(tfm,
sizeof(struct cryptd_hash_request_ctx) +
crypto_shash_descsize(hash));
return 0;
}

static void cryptd_hash_exit_tfm(struct crypto_tfm *tfm)
static void cryptd_hash_exit_tfm(struct crypto_ahash *tfm)
{
struct cryptd_hash_ctx *ctx = crypto_tfm_ctx(tfm);
struct cryptd_hash_ctx *ctx = crypto_ahash_ctx(tfm);

crypto_free_shash(ctx->child);
}
Expand Down Expand Up @@ -677,8 +677,8 @@ static int cryptd_create_hash(struct crypto_template *tmpl, struct rtattr **tb,
inst->alg.halg.statesize = alg->statesize;
inst->alg.halg.base.cra_ctxsize = sizeof(struct cryptd_hash_ctx);

inst->alg.halg.base.cra_init = cryptd_hash_init_tfm;
inst->alg.halg.base.cra_exit = cryptd_hash_exit_tfm;
inst->alg.init_tfm = cryptd_hash_init_tfm;
inst->alg.exit_tfm = cryptd_hash_exit_tfm;

inst->alg.init = cryptd_hash_init_enqueue;
inst->alg.update = cryptd_hash_update_enqueue;
Expand Down

0 comments on commit 0303b7f

Please sign in to comment.