Lines Matching +full:exact +full:- +full:len
1 // SPDX-License-Identifier: GPL-2.0-or-later
46 return try_module_get(alg->cra_module) ? crypto_alg_get(alg) : NULL; in crypto_mod_get()
52 struct module *module = alg->cra_module; in crypto_mod_put()
63 int best = -2; in __crypto_alg_lookup()
66 int exact, fuzzy; in __crypto_alg_lookup() local
71 if ((q->cra_flags ^ type) & mask) in __crypto_alg_lookup()
74 exact = !strcmp(q->cra_driver_name, name); in __crypto_alg_lookup()
75 fuzzy = !strcmp(q->cra_name, name); in __crypto_alg_lookup()
76 if (!exact && !(fuzzy && q->cra_priority > best)) in __crypto_alg_lookup()
82 best = q->cra_priority; in __crypto_alg_lookup()
87 if (exact) in __crypto_alg_lookup()
99 if (!IS_ERR_OR_NULL(larval->adult)) in crypto_larval_destroy()
100 crypto_mod_put(larval->adult); in crypto_larval_destroy()
110 return ERR_PTR(-ENOMEM); in crypto_larval_alloc()
114 larval->mask = mask; in crypto_larval_alloc()
115 larval->alg.cra_flags = CRYPTO_ALG_LARVAL | type; in crypto_larval_alloc()
116 larval->alg.cra_priority = -1; in crypto_larval_alloc()
117 larval->alg.cra_destroy = crypto_larval_destroy; in crypto_larval_alloc()
119 strscpy(larval->alg.cra_name, name, CRYPTO_MAX_ALG_NAME); in crypto_larval_alloc()
120 init_completion(&larval->completion); in crypto_larval_alloc()
136 refcount_set(&larval->alg.cra_refcnt, 2); in crypto_larval_add()
141 alg = &larval->alg; in crypto_larval_add()
142 list_add(&alg->cra_list, &crypto_alg_list); in crypto_larval_add()
146 if (alg != &larval->alg) { in crypto_larval_add()
160 unlinked = list_empty(&larval->alg.cra_list); in crypto_larval_kill()
162 list_del_init(&larval->alg.cra_list); in crypto_larval_kill()
168 complete_all(&larval->completion); in crypto_larval_kill()
169 crypto_alg_put(&larval->alg); in crypto_larval_kill()
176 err = crypto_probing_notify(CRYPTO_MSG_ALG_REGISTER, larval->adult); in crypto_schedule_test()
186 if (larval->test_started) in crypto_start_test()
190 if (larval->test_started) { in crypto_start_test()
195 larval->test_started = true; in crypto_start_test()
214 &larval->completion, 60 * HZ); in crypto_larval_wait()
216 alg = larval->adult; in crypto_larval_wait()
218 alg = ERR_PTR(-EINTR); in crypto_larval_wait()
222 alg = ERR_PTR(-ETIMEDOUT); in crypto_larval_wait()
224 alg = &larval->alg; in crypto_larval_wait()
225 alg = crypto_alg_lookup(alg->cra_name, type, mask) ?: in crypto_larval_wait()
226 ERR_PTR(-EAGAIN); in crypto_larval_wait()
230 !(alg->cra_flags & CRYPTO_ALG_TESTED)) in crypto_larval_wait()
231 alg = ERR_PTR(-EAGAIN); in crypto_larval_wait()
232 else if (alg->cra_flags & CRYPTO_ALG_FIPS_INTERNAL) in crypto_larval_wait()
233 alg = ERR_PTR(-EAGAIN); in crypto_larval_wait()
235 alg = ERR_PTR(-EAGAIN); in crypto_larval_wait()
236 crypto_mod_put(&larval->alg); in crypto_larval_wait()
263 ((type ^ alg->cra_flags) & mask)) { in crypto_alg_lookup()
266 alg = ERR_PTR(-ENOENT); in crypto_alg_lookup()
273 alg = ERR_PTR(-ELIBBAD); in crypto_alg_lookup()
287 return ERR_PTR(-ENOENT); in crypto_larval_lookup()
294 request_module("crypto-%s", name); in crypto_larval_lookup()
298 request_module("crypto-%s-all", name); in crypto_larval_lookup()
310 alg = ERR_PTR(-ENOENT); in crypto_larval_lookup()
355 alg = ERR_PTR(-ENOENT); in crypto_alg_mod_lookup()
364 const struct crypto_type *type = tfm->__crt_alg->cra_type; in crypto_exit_ops()
366 if (type && tfm->exit) in crypto_exit_ops()
367 tfm->exit(tfm); in crypto_exit_ops()
372 const struct crypto_type *type_obj = alg->cra_type; in crypto_ctxsize()
373 unsigned int len; in crypto_ctxsize() local
375 len = alg->cra_alignmask & ~(crypto_tfm_ctx_alignment() - 1); in crypto_ctxsize()
377 return len + type_obj->ctxsize(alg, type, mask); in crypto_ctxsize()
379 switch (alg->cra_flags & CRYPTO_ALG_TYPE_MASK) { in crypto_ctxsize()
384 len += crypto_cipher_ctxsize(alg); in crypto_ctxsize()
388 len += crypto_compress_ctxsize(alg); in crypto_ctxsize()
392 return len; in crypto_ctxsize()
398 alg->cra_flags |= CRYPTO_ALG_DYING; in crypto_shoot_alg()
408 int err = -ENOMEM; in __crypto_alloc_tfmgfp()
415 tfm->__crt_alg = alg; in __crypto_alloc_tfmgfp()
416 refcount_set(&tfm->refcnt, 1); in __crypto_alloc_tfmgfp()
418 if (!tfm->exit && alg->cra_init && (err = alg->cra_init(tfm))) in __crypto_alloc_tfmgfp()
425 if (err == -EAGAIN) in __crypto_alloc_tfmgfp()
443 * crypto_alloc_base - Locate algorithm and allocate transform
458 * The returned transform is of a non-determinate type. Most people
486 if (err != -EAGAIN) in crypto_alloc_base()
489 err = -EINTR; in crypto_alloc_base()
507 tfmsize = frontend->tfmsize; in crypto_alloc_tfmmem()
508 total = tfmsize + sizeof(*tfm) + frontend->extsize(alg); in crypto_alloc_tfmmem()
512 return ERR_PTR(-ENOMEM); in crypto_alloc_tfmmem()
515 tfm->__crt_alg = alg; in crypto_alloc_tfmmem()
516 tfm->node = node; in crypto_alloc_tfmmem()
517 refcount_set(&tfm->refcnt, 1); in crypto_alloc_tfmmem()
534 tfm = (struct crypto_tfm *)(mem + frontend->tfmsize); in crypto_create_tfm_node()
536 err = frontend->init_tfm(tfm); in crypto_create_tfm_node()
540 if (!tfm->exit && alg->cra_init && (err = alg->cra_init(tfm))) in crypto_create_tfm_node()
548 if (err == -EAGAIN) in crypto_create_tfm_node()
560 struct crypto_alg *alg = otfm->__crt_alg; in crypto_clone_tfm()
564 mem = ERR_PTR(-ESTALE); in crypto_clone_tfm()
568 mem = crypto_alloc_tfmmem(alg, frontend, otfm->node, GFP_ATOMIC); in crypto_clone_tfm()
574 tfm = (struct crypto_tfm *)(mem + frontend->tfmsize); in crypto_clone_tfm()
575 tfm->crt_flags = otfm->crt_flags; in crypto_clone_tfm()
576 tfm->exit = otfm->exit; in crypto_clone_tfm()
588 type &= frontend->maskclear; in crypto_find_alg()
589 mask &= frontend->maskclear; in crypto_find_alg()
590 type |= frontend->type; in crypto_find_alg()
591 mask |= frontend->maskset; in crypto_find_alg()
599 * crypto_alloc_tfm_node - Locate algorithm and allocate transform
614 * The returned transform is of a non-determinate type. Most people
645 if (err != -EAGAIN) in crypto_alloc_tfm_node()
648 err = -EINTR; in crypto_alloc_tfm_node()
658 * crypto_destroy_tfm - Free crypto transform
672 if (!refcount_dec_and_test(&tfm->refcnt)) in crypto_destroy_tfm()
674 alg = tfm->__crt_alg; in crypto_destroy_tfm()
676 if (!tfm->exit && alg->cra_exit) in crypto_destroy_tfm()
677 alg->cra_exit(tfm); in crypto_destroy_tfm()
702 if (err == -EINPROGRESS) in crypto_req_done()
705 wait->err = err; in crypto_req_done()
706 complete(&wait->completion); in crypto_req_done()