Lines Matching refs:tfm

31  * For an ahash tfm that is using an shash algorithm (instead of an ahash
32 * algorithm), this returns the underlying shash tfm.
34 static inline struct crypto_shash *ahash_to_shash(struct crypto_ahash *tfm)
36 return *(struct crypto_shash **)crypto_ahash_ctx(tfm);
40 struct crypto_ahash *tfm)
44 desc->tfm = ahash_to_shash(tfm);
106 static void crypto_exit_ahash_using_shash(struct crypto_tfm *tfm)
108 struct crypto_shash **ctx = crypto_tfm_ctx(tfm);
113 static int crypto_init_ahash_using_shash(struct crypto_tfm *tfm)
115 struct crypto_alg *calg = tfm->__crt_alg;
116 struct crypto_ahash *crt = __crypto_ahash_cast(tfm);
117 struct crypto_shash **ctx = crypto_tfm_ctx(tfm);
131 tfm->exit = crypto_exit_ahash_using_shash;
211 static int ahash_nosetkey(struct crypto_ahash *tfm, const u8 *key,
217 static void ahash_set_needkey(struct crypto_ahash *tfm, struct ahash_alg *alg)
221 crypto_ahash_set_flags(tfm, CRYPTO_TFM_NEED_KEY);
224 int crypto_ahash_setkey(struct crypto_ahash *tfm, const u8 *key,
227 if (likely(tfm->using_shash)) {
228 struct crypto_shash *shash = ahash_to_shash(tfm);
233 crypto_ahash_set_flags(tfm,
239 struct ahash_alg *alg = crypto_ahash_alg(tfm);
242 err = alg->setkey(tfm, key, keylen);
244 ahash_set_needkey(tfm, alg);
248 crypto_ahash_clear_flags(tfm, CRYPTO_TFM_NEED_KEY);
255 struct crypto_ahash *tfm = crypto_ahash_reqtfm(req);
257 if (likely(tfm->using_shash))
258 return crypto_shash_init(prepare_shash_desc(req, tfm));
259 if (crypto_ahash_get_flags(tfm) & CRYPTO_TFM_NEED_KEY)
261 return crypto_ahash_alg(tfm)->init(req);
268 struct crypto_ahash *tfm = crypto_ahash_reqtfm(req);
269 unsigned int ds = crypto_ahash_digestsize(tfm);
278 reqsize = crypto_ahash_reqsize(tfm);
289 ahash_request_set_tfm(subreq, tfm);
299 state = kmalloc(crypto_ahash_statesize(tfm), gfp);
330 struct crypto_ahash *tfm = crypto_ahash_reqtfm(req);
332 if (likely(tfm->using_shash))
335 return crypto_ahash_alg(tfm)->update(req);
341 struct crypto_ahash *tfm = crypto_ahash_reqtfm(req);
343 if (likely(tfm->using_shash))
346 return crypto_ahash_alg(tfm)->final(req);
352 struct crypto_ahash *tfm = crypto_ahash_reqtfm(req);
354 if (likely(tfm->using_shash))
357 return crypto_ahash_alg(tfm)->finup(req);
363 struct crypto_ahash *tfm = crypto_ahash_reqtfm(req);
365 if (likely(tfm->using_shash))
366 return shash_ahash_digest(req, prepare_shash_desc(req, tfm));
368 if (crypto_ahash_get_flags(tfm) & CRYPTO_TFM_NEED_KEY)
371 return crypto_ahash_alg(tfm)->digest(req);
426 struct crypto_ahash *tfm = crypto_ahash_reqtfm(req);
433 err = crypto_ahash_alg(tfm)->update(req->priv);
442 struct crypto_ahash *tfm = crypto_ahash_reqtfm(req);
444 if (likely(tfm->using_shash))
446 return crypto_ahash_alg(tfm)->export(req, out);
452 struct crypto_ahash *tfm = crypto_ahash_reqtfm(req);
454 if (likely(tfm->using_shash))
455 return crypto_shash_import(prepare_shash_desc(req, tfm), in);
456 if (crypto_ahash_get_flags(tfm) & CRYPTO_TFM_NEED_KEY)
458 return crypto_ahash_alg(tfm)->import(req, in);
462 static void crypto_ahash_exit_tfm(struct crypto_tfm *tfm)
464 struct crypto_ahash *hash = __crypto_ahash_cast(tfm);
470 static int crypto_ahash_init_tfm(struct crypto_tfm *tfm)
472 struct crypto_ahash *hash = __crypto_ahash_cast(tfm);
477 if (tfm->__crt_alg->cra_type == &crypto_shash_type)
478 return crypto_init_ahash_using_shash(tfm);
483 tfm->exit = crypto_ahash_exit_tfm;
581 struct crypto_tfm *tfm = crypto_ahash_tfm(hash);
587 tfm = crypto_tfm_get(tfm);
588 if (IS_ERR(tfm))
589 return ERR_CAST(tfm);
594 nhash = crypto_clone_tfm(&crypto_ahash_type, tfm);