diff options
Diffstat (limited to 'crypto/api.c')
-rw-r--r-- | crypto/api.c | 31 |
1 files changed, 22 insertions, 9 deletions
diff --git a/crypto/api.c b/crypto/api.c index d5944f92b416..ba81221b3bef 100644 --- a/crypto/api.c +++ b/crypto/api.c | |||
@@ -503,6 +503,27 @@ out: | |||
503 | } | 503 | } |
504 | EXPORT_SYMBOL_GPL(crypto_create_tfm); | 504 | EXPORT_SYMBOL_GPL(crypto_create_tfm); |
505 | 505 | ||
506 | struct crypto_alg *crypto_find_alg(const char *alg_name, | ||
507 | const struct crypto_type *frontend, | ||
508 | u32 type, u32 mask) | ||
509 | { | ||
510 | struct crypto_alg *(*lookup)(const char *name, u32 type, u32 mask) = | ||
511 | crypto_alg_mod_lookup; | ||
512 | |||
513 | if (frontend) { | ||
514 | type &= frontend->maskclear; | ||
515 | mask &= frontend->maskclear; | ||
516 | type |= frontend->type; | ||
517 | mask |= frontend->maskset; | ||
518 | |||
519 | if (frontend->lookup) | ||
520 | lookup = frontend->lookup; | ||
521 | } | ||
522 | |||
523 | return lookup(alg_name, type, mask); | ||
524 | } | ||
525 | EXPORT_SYMBOL_GPL(crypto_find_alg); | ||
526 | |||
506 | /* | 527 | /* |
507 | * crypto_alloc_tfm - Locate algorithm and allocate transform | 528 | * crypto_alloc_tfm - Locate algorithm and allocate transform |
508 | * @alg_name: Name of algorithm | 529 | * @alg_name: Name of algorithm |
@@ -526,21 +547,13 @@ EXPORT_SYMBOL_GPL(crypto_create_tfm); | |||
526 | void *crypto_alloc_tfm(const char *alg_name, | 547 | void *crypto_alloc_tfm(const char *alg_name, |
527 | const struct crypto_type *frontend, u32 type, u32 mask) | 548 | const struct crypto_type *frontend, u32 type, u32 mask) |
528 | { | 549 | { |
529 | struct crypto_alg *(*lookup)(const char *name, u32 type, u32 mask); | ||
530 | void *tfm; | 550 | void *tfm; |
531 | int err; | 551 | int err; |
532 | 552 | ||
533 | type &= frontend->maskclear; | ||
534 | mask &= frontend->maskclear; | ||
535 | type |= frontend->type; | ||
536 | mask |= frontend->maskset; | ||
537 | |||
538 | lookup = frontend->lookup ?: crypto_alg_mod_lookup; | ||
539 | |||
540 | for (;;) { | 553 | for (;;) { |
541 | struct crypto_alg *alg; | 554 | struct crypto_alg *alg; |
542 | 555 | ||
543 | alg = lookup(alg_name, type, mask); | 556 | alg = crypto_find_alg(alg_name, frontend, type, mask); |
544 | if (IS_ERR(alg)) { | 557 | if (IS_ERR(alg)) { |
545 | err = PTR_ERR(alg); | 558 | err = PTR_ERR(alg); |
546 | goto err; | 559 | goto err; |