Lines Matching refs:alg

37 static struct crypto_alg *crypto_larval_wait(struct crypto_alg *alg);
39 struct crypto_alg *crypto_mod_get(struct crypto_alg *alg) in crypto_mod_get() argument
41 return try_module_get(alg->cra_module) ? crypto_alg_get(alg) : NULL; in crypto_mod_get()
45 void crypto_mod_put(struct crypto_alg *alg) in crypto_mod_put() argument
47 struct module *module = alg->cra_module; in crypto_mod_put()
49 crypto_alg_put(alg); in crypto_mod_put()
56 return larval->alg.cra_driver_name[0]; in crypto_is_test_larval()
62 struct crypto_alg *q, *alg = NULL; in __crypto_alg_lookup() local
88 if (alg) in __crypto_alg_lookup()
89 crypto_mod_put(alg); in __crypto_alg_lookup()
90 alg = q; in __crypto_alg_lookup()
96 return alg; in __crypto_alg_lookup()
99 static void crypto_larval_destroy(struct crypto_alg *alg) in crypto_larval_destroy() argument
101 struct crypto_larval *larval = (void *)alg; in crypto_larval_destroy()
103 BUG_ON(!crypto_is_larval(alg)); in crypto_larval_destroy()
118 larval->alg.cra_flags = CRYPTO_ALG_LARVAL | type; in crypto_larval_alloc()
119 larval->alg.cra_priority = -1; in crypto_larval_alloc()
120 larval->alg.cra_destroy = crypto_larval_destroy; in crypto_larval_alloc()
122 strlcpy(larval->alg.cra_name, name, CRYPTO_MAX_ALG_NAME); in crypto_larval_alloc()
132 struct crypto_alg *alg; in crypto_larval_add() local
139 atomic_set(&larval->alg.cra_refcnt, 2); in crypto_larval_add()
142 alg = __crypto_alg_lookup(name, type, mask); in crypto_larval_add()
143 if (!alg) { in crypto_larval_add()
144 alg = &larval->alg; in crypto_larval_add()
145 list_add(&alg->cra_list, &crypto_alg_list); in crypto_larval_add()
149 if (alg != &larval->alg) { in crypto_larval_add()
151 if (crypto_is_larval(alg)) in crypto_larval_add()
152 alg = crypto_larval_wait(alg); in crypto_larval_add()
155 return alg; in crypto_larval_add()
158 void crypto_larval_kill(struct crypto_alg *alg) in crypto_larval_kill() argument
160 struct crypto_larval *larval = (void *)alg; in crypto_larval_kill()
163 list_del(&alg->cra_list); in crypto_larval_kill()
166 crypto_alg_put(alg); in crypto_larval_kill()
170 static struct crypto_alg *crypto_larval_wait(struct crypto_alg *alg) in crypto_larval_wait() argument
172 struct crypto_larval *larval = (void *)alg; in crypto_larval_wait()
178 alg = larval->adult; in crypto_larval_wait()
180 alg = ERR_PTR(-EINTR); in crypto_larval_wait()
182 alg = ERR_PTR(-ETIMEDOUT); in crypto_larval_wait()
183 else if (!alg) in crypto_larval_wait()
184 alg = ERR_PTR(-ENOENT); in crypto_larval_wait()
186 !(alg->cra_flags & CRYPTO_ALG_TESTED)) in crypto_larval_wait()
187 alg = ERR_PTR(-EAGAIN); in crypto_larval_wait()
188 else if (!crypto_mod_get(alg)) in crypto_larval_wait()
189 alg = ERR_PTR(-EAGAIN); in crypto_larval_wait()
190 crypto_mod_put(&larval->alg); in crypto_larval_wait()
192 return alg; in crypto_larval_wait()
197 struct crypto_alg *alg; in crypto_alg_lookup() local
200 alg = __crypto_alg_lookup(name, type, mask); in crypto_alg_lookup()
203 return alg; in crypto_alg_lookup()
209 struct crypto_alg *alg; in crypto_larval_lookup() local
217 alg = crypto_alg_lookup(name, type, mask); in crypto_larval_lookup()
218 if (!alg) { in crypto_larval_lookup()
225 alg = crypto_alg_lookup(name, type, mask); in crypto_larval_lookup()
228 if (alg) in crypto_larval_lookup()
229 return crypto_is_larval(alg) ? crypto_larval_wait(alg) : alg; in crypto_larval_lookup()
251 struct crypto_alg *alg; in crypto_alg_mod_lookup() local
277 alg = crypto_larval_wait(larval); in crypto_alg_mod_lookup()
280 alg = ERR_PTR(-ENOENT); in crypto_alg_mod_lookup()
283 return alg; in crypto_alg_mod_lookup()
333 static unsigned int crypto_ctxsize(struct crypto_alg *alg, u32 type, u32 mask) in crypto_ctxsize() argument
335 const struct crypto_type *type_obj = alg->cra_type; in crypto_ctxsize()
338 len = alg->cra_alignmask & ~(crypto_tfm_ctx_alignment() - 1); in crypto_ctxsize()
340 return len + type_obj->ctxsize(alg, type, mask); in crypto_ctxsize()
342 switch (alg->cra_flags & CRYPTO_ALG_TYPE_MASK) { in crypto_ctxsize()
347 len += crypto_cipher_ctxsize(alg); in crypto_ctxsize()
351 len += crypto_compress_ctxsize(alg); in crypto_ctxsize()
358 void crypto_shoot_alg(struct crypto_alg *alg) in crypto_shoot_alg() argument
361 alg->cra_flags |= CRYPTO_ALG_DYING; in crypto_shoot_alg()
366 struct crypto_tfm *__crypto_alloc_tfm(struct crypto_alg *alg, u32 type, in __crypto_alloc_tfm() argument
373 tfm_size = sizeof(*tfm) + crypto_ctxsize(alg, type, mask); in __crypto_alloc_tfm()
378 tfm->__crt_alg = alg; in __crypto_alloc_tfm()
384 if (!tfm->exit && alg->cra_init && (err = alg->cra_init(tfm))) in __crypto_alloc_tfm()
393 crypto_shoot_alg(alg); in __crypto_alloc_tfm()
430 struct crypto_alg *alg; in crypto_alloc_base() local
432 alg = crypto_alg_mod_lookup(alg_name, type, mask); in crypto_alloc_base()
433 if (IS_ERR(alg)) { in crypto_alloc_base()
434 err = PTR_ERR(alg); in crypto_alloc_base()
438 tfm = __crypto_alloc_tfm(alg, type, mask); in crypto_alloc_base()
442 crypto_mod_put(alg); in crypto_alloc_base()
458 void *crypto_create_tfm(struct crypto_alg *alg, in crypto_create_tfm() argument
468 total = tfmsize + sizeof(*tfm) + frontend->extsize(alg); in crypto_create_tfm()
475 tfm->__crt_alg = alg; in crypto_create_tfm()
481 if (!tfm->exit && alg->cra_init && (err = alg->cra_init(tfm))) in crypto_create_tfm()
490 crypto_shoot_alg(alg); in crypto_create_tfm()
547 struct crypto_alg *alg; in crypto_alloc_tfm() local
549 alg = crypto_find_alg(alg_name, frontend, type, mask); in crypto_alloc_tfm()
550 if (IS_ERR(alg)) { in crypto_alloc_tfm()
551 err = PTR_ERR(alg); in crypto_alloc_tfm()
555 tfm = crypto_create_tfm(alg, frontend); in crypto_alloc_tfm()
559 crypto_mod_put(alg); in crypto_alloc_tfm()
585 struct crypto_alg *alg; in crypto_destroy_tfm() local
590 alg = tfm->__crt_alg; in crypto_destroy_tfm()
592 if (!tfm->exit && alg->cra_exit) in crypto_destroy_tfm()
593 alg->cra_exit(tfm); in crypto_destroy_tfm()
595 crypto_mod_put(alg); in crypto_destroy_tfm()
603 struct crypto_alg *alg = crypto_alg_mod_lookup(name, type, mask); in crypto_has_alg() local
605 if (!IS_ERR(alg)) { in crypto_has_alg()
606 crypto_mod_put(alg); in crypto_has_alg()