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()
57 struct crypto_alg *q, *alg = NULL; in __crypto_alg_lookup() local
83 if (alg) in __crypto_alg_lookup()
84 crypto_mod_put(alg); in __crypto_alg_lookup()
85 alg = q; in __crypto_alg_lookup()
91 return alg; in __crypto_alg_lookup()
94 static void crypto_larval_destroy(struct crypto_alg *alg) in crypto_larval_destroy() argument
96 struct crypto_larval *larval = (void *)alg; in crypto_larval_destroy()
98 BUG_ON(!crypto_is_larval(alg)); in crypto_larval_destroy()
113 larval->alg.cra_flags = CRYPTO_ALG_LARVAL | type; in crypto_larval_alloc()
114 larval->alg.cra_priority = -1; in crypto_larval_alloc()
115 larval->alg.cra_destroy = crypto_larval_destroy; in crypto_larval_alloc()
117 strlcpy(larval->alg.cra_name, name, CRYPTO_MAX_ALG_NAME); in crypto_larval_alloc()
127 struct crypto_alg *alg; in crypto_larval_add() local
134 refcount_set(&larval->alg.cra_refcnt, 2); in crypto_larval_add()
137 alg = __crypto_alg_lookup(name, type, mask); in crypto_larval_add()
138 if (!alg) { in crypto_larval_add()
139 alg = &larval->alg; in crypto_larval_add()
140 list_add(&alg->cra_list, &crypto_alg_list); in crypto_larval_add()
144 if (alg != &larval->alg) { in crypto_larval_add()
146 if (crypto_is_larval(alg)) in crypto_larval_add()
147 alg = crypto_larval_wait(alg); in crypto_larval_add()
150 return alg; in crypto_larval_add()
153 void crypto_larval_kill(struct crypto_alg *alg) in crypto_larval_kill() argument
155 struct crypto_larval *larval = (void *)alg; in crypto_larval_kill()
158 list_del(&alg->cra_list); in crypto_larval_kill()
161 crypto_alg_put(alg); in crypto_larval_kill()
179 crypto_larval_kill(&larval->alg); in crypto_wait_for_test()
203 static struct crypto_alg *crypto_larval_wait(struct crypto_alg *alg) in crypto_larval_wait() argument
205 struct crypto_larval *larval = (void *)alg; in crypto_larval_wait()
214 alg = larval->adult; in crypto_larval_wait()
216 alg = ERR_PTR(-EINTR); in crypto_larval_wait()
218 alg = ERR_PTR(-ETIMEDOUT); in crypto_larval_wait()
219 else if (!alg) in crypto_larval_wait()
220 alg = ERR_PTR(-ENOENT); in crypto_larval_wait()
221 else if (IS_ERR(alg)) in crypto_larval_wait()
224 !(alg->cra_flags & CRYPTO_ALG_TESTED)) in crypto_larval_wait()
225 alg = ERR_PTR(-EAGAIN); in crypto_larval_wait()
226 else if (!crypto_mod_get(alg)) in crypto_larval_wait()
227 alg = ERR_PTR(-EAGAIN); in crypto_larval_wait()
228 crypto_mod_put(&larval->alg); in crypto_larval_wait()
230 return alg; in crypto_larval_wait()
236 struct crypto_alg *alg; in crypto_alg_lookup() local
243 alg = __crypto_alg_lookup(name, type | test, mask | test); in crypto_alg_lookup()
244 if (!alg && test) { in crypto_alg_lookup()
245 alg = __crypto_alg_lookup(name, type, mask); in crypto_alg_lookup()
246 if (alg && !crypto_is_larval(alg)) { in crypto_alg_lookup()
248 crypto_mod_put(alg); in crypto_alg_lookup()
249 alg = ERR_PTR(-ELIBBAD); in crypto_alg_lookup()
254 return alg; in crypto_alg_lookup()
260 struct crypto_alg *alg; in crypto_larval_lookup() local
268 alg = crypto_alg_lookup(name, type, mask); in crypto_larval_lookup()
269 if (!alg && !(mask & CRYPTO_NOLOAD)) { in crypto_larval_lookup()
276 alg = crypto_alg_lookup(name, type, mask); in crypto_larval_lookup()
279 if (!IS_ERR_OR_NULL(alg) && crypto_is_larval(alg)) in crypto_larval_lookup()
280 alg = crypto_larval_wait(alg); in crypto_larval_lookup()
281 else if (!alg) in crypto_larval_lookup()
282 alg = crypto_larval_add(name, type, mask); in crypto_larval_lookup()
284 return alg; in crypto_larval_lookup()
303 struct crypto_alg *alg; in crypto_alg_mod_lookup() local
324 alg = crypto_larval_wait(larval); in crypto_alg_mod_lookup()
327 alg = ERR_PTR(-ENOENT); in crypto_alg_mod_lookup()
330 return alg; in crypto_alg_mod_lookup()
351 static unsigned int crypto_ctxsize(struct crypto_alg *alg, u32 type, u32 mask) in crypto_ctxsize() argument
353 const struct crypto_type *type_obj = alg->cra_type; in crypto_ctxsize()
356 len = alg->cra_alignmask & ~(crypto_tfm_ctx_alignment() - 1); in crypto_ctxsize()
358 return len + type_obj->ctxsize(alg, type, mask); in crypto_ctxsize()
360 switch (alg->cra_flags & CRYPTO_ALG_TYPE_MASK) { in crypto_ctxsize()
365 len += crypto_cipher_ctxsize(alg); in crypto_ctxsize()
369 len += crypto_compress_ctxsize(alg); in crypto_ctxsize()
376 void crypto_shoot_alg(struct crypto_alg *alg) in crypto_shoot_alg() argument
379 alg->cra_flags |= CRYPTO_ALG_DYING; in crypto_shoot_alg()
384 struct crypto_tfm *__crypto_alloc_tfm(struct crypto_alg *alg, u32 type, in __crypto_alloc_tfm() argument
391 tfm_size = sizeof(*tfm) + crypto_ctxsize(alg, type, mask); in __crypto_alloc_tfm()
396 tfm->__crt_alg = alg; in __crypto_alloc_tfm()
402 if (!tfm->exit && alg->cra_init && (err = alg->cra_init(tfm))) in __crypto_alloc_tfm()
411 crypto_shoot_alg(alg); in __crypto_alloc_tfm()
448 struct crypto_alg *alg; in crypto_alloc_base() local
450 alg = crypto_alg_mod_lookup(alg_name, type, mask); in crypto_alloc_base()
451 if (IS_ERR(alg)) { in crypto_alloc_base()
452 err = PTR_ERR(alg); in crypto_alloc_base()
456 tfm = __crypto_alloc_tfm(alg, type, mask); in crypto_alloc_base()
460 crypto_mod_put(alg); in crypto_alloc_base()
476 void *crypto_create_tfm_node(struct crypto_alg *alg, in crypto_create_tfm_node() argument
487 total = tfmsize + sizeof(*tfm) + frontend->extsize(alg); in crypto_create_tfm_node()
494 tfm->__crt_alg = alg; in crypto_create_tfm_node()
501 if (!tfm->exit && alg->cra_init && (err = alg->cra_init(tfm))) in crypto_create_tfm_node()
510 crypto_shoot_alg(alg); in crypto_create_tfm_node()
565 struct crypto_alg *alg; in crypto_alloc_tfm_node() local
567 alg = crypto_find_alg(alg_name, frontend, type, mask); in crypto_alloc_tfm_node()
568 if (IS_ERR(alg)) { in crypto_alloc_tfm_node()
569 err = PTR_ERR(alg); in crypto_alloc_tfm_node()
573 tfm = crypto_create_tfm_node(alg, frontend, node); in crypto_alloc_tfm_node()
577 crypto_mod_put(alg); in crypto_alloc_tfm_node()
603 struct crypto_alg *alg; in crypto_destroy_tfm() local
608 alg = tfm->__crt_alg; in crypto_destroy_tfm()
610 if (!tfm->exit && alg->cra_exit) in crypto_destroy_tfm()
611 alg->cra_exit(tfm); in crypto_destroy_tfm()
613 crypto_mod_put(alg); in crypto_destroy_tfm()
621 struct crypto_alg *alg = crypto_alg_mod_lookup(name, type, mask); in crypto_has_alg() local
623 if (!IS_ERR(alg)) { in crypto_has_alg()
624 crypto_mod_put(alg); in crypto_has_alg()