summaryrefslogtreecommitdiff
path: root/crypto
diff options
context:
space:
mode:
authorHerbert Xu <herbert@gondor.apana.org.au>2007-12-07 20:18:17 +0800
committerHerbert Xu <herbert@gondor.apana.org.au>2008-01-11 08:16:40 +1100
commit68b6c7d6919be7c732fc6229c55e35d0166e9258 (patch)
tree137eabe7eaf127c2f1460490733dee415aa7b339 /crypto
parent551a09a7a954f720067f207657bbbd26a3fe156a (diff)
downloadlinux-3.10-68b6c7d6919be7c732fc6229c55e35d0166e9258.tar.gz
linux-3.10-68b6c7d6919be7c732fc6229c55e35d0166e9258.tar.bz2
linux-3.10-68b6c7d6919be7c732fc6229c55e35d0166e9258.zip
[CRYPTO] api: Add crypto_attr_alg_name
This patch adds a new helper crypto_attr_alg_name which is basically the first half of crypto_attr_alg. That is, it returns an algorithm name parameter as a string without looking it up. The caller can then look it up immediately or defer it until later. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'crypto')
-rw-r--r--crypto/algapi.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/crypto/algapi.c b/crypto/algapi.c
index 08eca6da1d5..e65cb50cf4a 100644
--- a/crypto/algapi.c
+++ b/crypto/algapi.c
@@ -472,7 +472,7 @@ int crypto_check_attr_type(struct rtattr **tb, u32 type)
}
EXPORT_SYMBOL_GPL(crypto_check_attr_type);
-struct crypto_alg *crypto_attr_alg(struct rtattr *rta, u32 type, u32 mask)
+const char *crypto_attr_alg_name(struct rtattr *rta)
{
struct crypto_attr_alg *alga;
@@ -486,7 +486,21 @@ struct crypto_alg *crypto_attr_alg(struct rtattr *rta, u32 type, u32 mask)
alga = RTA_DATA(rta);
alga->name[CRYPTO_MAX_ALG_NAME - 1] = 0;
- return crypto_alg_mod_lookup(alga->name, type, mask);
+ return alga->name;
+}
+EXPORT_SYMBOL_GPL(crypto_attr_alg_name);
+
+struct crypto_alg *crypto_attr_alg(struct rtattr *rta, u32 type, u32 mask)
+{
+ const char *name;
+ int err;
+
+ name = crypto_attr_alg_name(rta);
+ err = PTR_ERR(name);
+ if (IS_ERR(name))
+ return ERR_PTR(err);
+
+ return crypto_alg_mod_lookup(name, type, mask);
}
EXPORT_SYMBOL_GPL(crypto_attr_alg);