Lines Matching refs:tfm

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