+static int crypto_ahash_init_tfm(struct crypto_tfm *tfm)
+{
+ struct crypto_ahash *hash = __crypto_ahash_cast(tfm);
+ struct ahash_alg *alg = crypto_ahash_alg(hash);
+ struct old_ahash_alg *oalg = crypto_old_ahash_alg(hash);
+
+ if (tfm->__crt_alg->cra_type != &crypto_ahash_type)
+ return crypto_init_shash_ops_async(tfm);
+
+ if (oalg->init)
+ return crypto_init_ahash_ops(tfm, 0, 0);
+
+ hash->init = alg->init;
+ hash->update = alg->update;
+ hash->final = alg->final;
+ hash->digest = alg->digest;
+ hash->setkey = alg->setkey ? ahash_setkey : ahash_nosetkey;
+ hash->digestsize = alg->halg.digestsize;
+
+ return 0;
+}
+
+static unsigned int crypto_ahash_extsize(struct crypto_alg *alg)
+{
+ if (alg->cra_type == &crypto_ahash_type)
+ return alg->cra_ctxsize;
+
+ return sizeof(struct crypto_shash *);
+}
+