Commit 68b6c7d6919be7c732fc6229c55e35d0166e9258

Authored by Herbert Xu
1 parent 551a09a7a9

[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>

Showing 2 changed files with 17 additions and 2 deletions Side-by-side Diff

... ... @@ -472,7 +472,7 @@
472 472 }
473 473 EXPORT_SYMBOL_GPL(crypto_check_attr_type);
474 474  
475   -struct crypto_alg *crypto_attr_alg(struct rtattr *rta, u32 type, u32 mask)
  475 +const char *crypto_attr_alg_name(struct rtattr *rta)
476 476 {
477 477 struct crypto_attr_alg *alga;
478 478  
... ... @@ -486,7 +486,21 @@
486 486 alga = RTA_DATA(rta);
487 487 alga->name[CRYPTO_MAX_ALG_NAME - 1] = 0;
488 488  
489   - return crypto_alg_mod_lookup(alga->name, type, mask);
  489 + return alga->name;
  490 +}
  491 +EXPORT_SYMBOL_GPL(crypto_attr_alg_name);
  492 +
  493 +struct crypto_alg *crypto_attr_alg(struct rtattr *rta, u32 type, u32 mask)
  494 +{
  495 + const char *name;
  496 + int err;
  497 +
  498 + name = crypto_attr_alg_name(rta);
  499 + err = PTR_ERR(name);
  500 + if (IS_ERR(name))
  501 + return ERR_PTR(err);
  502 +
  503 + return crypto_alg_mod_lookup(name, type, mask);
490 504 }
491 505 EXPORT_SYMBOL_GPL(crypto_attr_alg);
492 506  
include/crypto/algapi.h
... ... @@ -113,6 +113,7 @@
113 113  
114 114 struct crypto_attr_type *crypto_get_attr_type(struct rtattr **tb);
115 115 int crypto_check_attr_type(struct rtattr **tb, u32 type);
  116 +const char *crypto_attr_alg_name(struct rtattr *rta);
116 117 struct crypto_alg *crypto_attr_alg(struct rtattr *rta, u32 type, u32 mask);
117 118 int crypto_attr_u32(struct rtattr *rta, u32 *num);
118 119 struct crypto_instance *crypto_alloc_instance(const char *name,