Commit 32f27c74 authored by Herbert Xu's avatar Herbert Xu

crypto: api - Add crypto_inst_setname

This patch adds the helper crypto_inst_setname because the current
helper crypto_alloc_instance2 is no longer useful given that we
now look up the algorithm after we allocate the instance object.
Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
parent 64e26807
...@@ -811,6 +811,21 @@ int crypto_attr_u32(struct rtattr *rta, u32 *num) ...@@ -811,6 +811,21 @@ int crypto_attr_u32(struct rtattr *rta, u32 *num)
} }
EXPORT_SYMBOL_GPL(crypto_attr_u32); EXPORT_SYMBOL_GPL(crypto_attr_u32);
int crypto_inst_setname(struct crypto_instance *inst, const char *name,
struct crypto_alg *alg)
{
if (snprintf(inst->alg.cra_name, CRYPTO_MAX_ALG_NAME, "%s(%s)", name,
alg->cra_name) >= CRYPTO_MAX_ALG_NAME)
return -ENAMETOOLONG;
if (snprintf(inst->alg.cra_driver_name, CRYPTO_MAX_ALG_NAME, "%s(%s)",
name, alg->cra_driver_name) >= CRYPTO_MAX_ALG_NAME)
return -ENAMETOOLONG;
return 0;
}
EXPORT_SYMBOL_GPL(crypto_inst_setname);
void *crypto_alloc_instance2(const char *name, struct crypto_alg *alg, void *crypto_alloc_instance2(const char *name, struct crypto_alg *alg,
unsigned int head) unsigned int head)
{ {
...@@ -825,13 +840,8 @@ void *crypto_alloc_instance2(const char *name, struct crypto_alg *alg, ...@@ -825,13 +840,8 @@ void *crypto_alloc_instance2(const char *name, struct crypto_alg *alg,
inst = (void *)(p + head); inst = (void *)(p + head);
err = -ENAMETOOLONG; err = crypto_inst_setname(inst, name, alg);
if (snprintf(inst->alg.cra_name, CRYPTO_MAX_ALG_NAME, "%s(%s)", name, if (err)
alg->cra_name) >= CRYPTO_MAX_ALG_NAME)
goto err_free_inst;
if (snprintf(inst->alg.cra_driver_name, CRYPTO_MAX_ALG_NAME, "%s(%s)",
name, alg->cra_driver_name) >= CRYPTO_MAX_ALG_NAME)
goto err_free_inst; goto err_free_inst;
return p; return p;
......
...@@ -244,6 +244,8 @@ static inline struct crypto_alg *crypto_attr_alg(struct rtattr *rta, ...@@ -244,6 +244,8 @@ static inline struct crypto_alg *crypto_attr_alg(struct rtattr *rta,
} }
int crypto_attr_u32(struct rtattr *rta, u32 *num); int crypto_attr_u32(struct rtattr *rta, u32 *num);
int crypto_inst_setname(struct crypto_instance *inst, const char *name,
struct crypto_alg *alg);
void *crypto_alloc_instance2(const char *name, struct crypto_alg *alg, void *crypto_alloc_instance2(const char *name, struct crypto_alg *alg,
unsigned int head); unsigned int head);
struct crypto_instance *crypto_alloc_instance(const char *name, struct crypto_instance *crypto_alloc_instance(const char *name,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment