Skip to contentSkip to conversation

crypto: xcbc - use init_tfm & exit_tfm instead of cra_int & cra_exit

PATCH New Mohamad Raizudeen 1 participant 1 message Nov 23 Crypto API

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 crypto: xcbc - use init_tfm & exit_tfm instead of cra_int & cra_exit

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.

---
 crypto/xcbc.c | 19 ++++++++++---------
 1 file changed, 10 insertions(+), 9 deletions(-)
crypto/xcbc.c +10 -9
index 6c5f6766fdd6..6bb3cddb391b 100644
@@ -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;
Signature · 1 line
2.53.0