diff options
author | Herbert Xu <herbert@gondor.apana.org.au> | 2016-01-23 13:51:01 +0800 |
---|---|---|
committer | Herbert Xu <herbert@gondor.apana.org.au> | 2016-01-25 22:42:12 +0800 |
commit | 94eb8ced58f2d3e4c9e1550d45da08597863ad58 (patch) | |
tree | 68e935b91d785f9f8ee5b91b75dd6a49b25815f6 | |
parent | 8b6744f170572bc7278461a4525b1b65b1aac81d (diff) | |
download | linux-crypto-94eb8ced58f2d3e4c9e1550d45da08597863ad58.tar.gz linux-crypto-94eb8ced58f2d3e4c9e1550d45da08597863ad58.zip |
crypto: api - Add crypto_type_has_alg helper
This patch adds the helper crypto_type_has_alg which is meant
to replace crypto_has_alg for new-style crypto types. Rather
than hard-coding type/mask information they're now retrieved
from the crypto_type object.
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to '')
-rw-r--r-- | crypto/algapi.c | 15 | ||||
-rw-r--r-- | crypto/internal.h | 3 |
2 files changed, 18 insertions, 0 deletions
diff --git a/crypto/algapi.c b/crypto/algapi.c index 7be76aa3..731255a6 100644 --- a/crypto/algapi.c +++ b/crypto/algapi.c @@ -987,6 +987,21 @@ unsigned int crypto_alg_extsize(struct crypto_alg *alg) } EXPORT_SYMBOL_GPL(crypto_alg_extsize); +int crypto_type_has_alg(const char *name, const struct crypto_type *frontend, + u32 type, u32 mask) +{ + int ret = 0; + struct crypto_alg *alg = crypto_find_alg(name, frontend, type, mask); + + if (!IS_ERR(alg)) { + crypto_mod_put(alg); + ret = 1; + } + + return ret; +} +EXPORT_SYMBOL_GPL(crypto_type_has_alg); + static int __init crypto_algapi_init(void) { crypto_init_proc(); diff --git a/crypto/internal.h b/crypto/internal.h index 00e42a3e..7eefcdb0 100644 --- a/crypto/internal.h +++ b/crypto/internal.h @@ -104,6 +104,9 @@ int crypto_probing_notify(unsigned long val, void *v); unsigned int crypto_alg_extsize(struct crypto_alg *alg); +int crypto_type_has_alg(const char *name, const struct crypto_type *frontend, + u32 type, u32 mask); + static inline struct crypto_alg *crypto_alg_get(struct crypto_alg *alg) { atomic_inc(&alg->cra_refcnt); |