mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] crypto: xcbc - use init_tfm & exit_tfm instead of cra_int & cra_exit
@ 2026-11-23 10:40 Mohamad Raizudeen
  0 siblings, 0 replies; only message in thread
From: Mohamad Raizudeen @ 2026-11-23 10:40 UTC (permalink / raw)
  To: herbert, davem; +Cc: linux-crypto, linux-kernel, Mohamad Raizudeen

The cra_init and cra_exit fields of struct crypto_alg are deprecated.
Switch to the shash-speicific init_tfm & exit_tfm callbacks, which take
a struct crypto_shash directly.

This also removes (void *) cast of tfm->__crt_alg and the manual
crypto_instance_ctx() conversion and drops a stray semicolon after
xcbc_init_tfm().

No functional change.

Signed-off-by: Mohamad Raizudeen <raizudeen.kerneldev@gmail.com>
---
 crypto/xcbc.c | 19 ++++++++++---------
 1 file changed, 10 insertions(+), 9 deletions(-)

diff --git a/crypto/xcbc.c b/crypto/xcbc.c
index 6c5f6766fdd6..6bb3cddb391b 100644
--- a/crypto/xcbc.c
+++ b/crypto/xcbc.c
@@ -102,13 +102,14 @@ static int crypto_xcbc_digest_finup(struct shash_desc *pdesc, const u8 *src,
 	return 0;
 }
 
-static int xcbc_init_tfm(struct crypto_tfm *tfm)
+static int xcbc_init_tfm(struct crypto_shash *tfm)
 {
+	struct shash_instance *inst = shash_alg_instance(tfm);
+	struct xcbc_tfm_ctx *ctx = crypto_shash_ctx(tfm);
+	struct crypto_cipher_spawn *spawn;
 	struct crypto_cipher *cipher;
-	struct crypto_instance *inst = (void *)tfm->__crt_alg;
-	struct crypto_cipher_spawn *spawn = crypto_instance_ctx(inst);
-	struct xcbc_tfm_ctx *ctx = crypto_tfm_ctx(tfm);
 
+	spawn = shash_instance_ctx(inst);
 	cipher = crypto_spawn_cipher(spawn);
 	if (IS_ERR(cipher))
 		return PTR_ERR(cipher);
@@ -116,11 +117,11 @@ static int xcbc_init_tfm(struct crypto_tfm *tfm)
 	ctx->child = cipher;
 
 	return 0;
-};
+}
 
-static void xcbc_exit_tfm(struct crypto_tfm *tfm)
+static void xcbc_exit_tfm(struct crypto_shash *tfm)
 {
-	struct xcbc_tfm_ctx *ctx = crypto_tfm_ctx(tfm);
+	struct xcbc_tfm_ctx *ctx = crypto_shash_ctx(tfm);
 	crypto_free_cipher(ctx->child);
 }
 
@@ -165,8 +166,8 @@ static int xcbc_create(struct crypto_template *tmpl, struct rtattr **tb)
 	inst->alg.digestsize = alg->cra_blocksize;
 	inst->alg.descsize = alg->cra_blocksize;
 
-	inst->alg.base.cra_init = xcbc_init_tfm;
-	inst->alg.base.cra_exit = xcbc_exit_tfm;
+	inst->alg.init_tfm = xcbc_init_tfm;
+	inst->alg.exit_tfm = xcbc_exit_tfm;
 
 	inst->alg.init = crypto_xcbc_digest_init;
 	inst->alg.update = crypto_xcbc_digest_update;
-- 
2.53.0


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2026-11-23 10:40 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-23 10:40 [PATCH] crypto: xcbc - use init_tfm & exit_tfm instead of cra_int & cra_exit Mohamad Raizudeen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®