summaryrefslogtreecommitdiff
path: root/crypto/cryptomgr.c
diff options
context:
space:
mode:
authorHerbert Xu <herbert@gondor.apana.org.au>2007-01-01 10:37:02 +0300
committerHerbert Xu <herbert@gondor.apana.org.au>2007-05-02 08:38:31 +0400
commitebc610e5bc76df073221e64e86c3f7533a09ea40 (patch)
treed53f4fa3da412f6df4b5891e23ca7c7607a3a5ce /crypto/cryptomgr.c
parent6158efc09016d3186263f6fd3a50667446ec4008 (diff)
downloadlinux-ebc610e5bc76df073221e64e86c3f7533a09ea40.tar.xz
[CRYPTO] templates: Pass type/mask when creating instances
This patch passes the type/mask along when constructing instances of templates. This is in preparation for templates that may support multiple types of instances depending on what is requested. For example, the planned software async crypto driver will use this construct. For the moment this allows us to check whether the instance constructed is of the correct type and avoid returning success if the type does not match. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'crypto/cryptomgr.c')
-rw-r--r--crypto/cryptomgr.c28
1 files changed, 18 insertions, 10 deletions
diff --git a/crypto/cryptomgr.c b/crypto/cryptomgr.c
index 2ebffb84f1d9..7a3df9b41218 100644
--- a/crypto/cryptomgr.c
+++ b/crypto/cryptomgr.c
@@ -26,14 +26,19 @@
struct cryptomgr_param {
struct work_struct work;
+ struct rtattr *tb[CRYPTOA_MAX];
+
+ struct {
+ struct rtattr attr;
+ struct crypto_attr_type data;
+ } type;
+
struct {
struct rtattr attr;
struct crypto_attr_alg data;
} alg;
struct {
- u32 type;
- u32 mask;
char name[CRYPTO_MAX_ALG_NAME];
} larval;
@@ -53,7 +58,7 @@ static void cryptomgr_probe(struct work_struct *work)
goto err;
do {
- inst = tmpl->alloc(&param->alg, sizeof(param->alg));
+ inst = tmpl->alloc(param->tb);
if (IS_ERR(inst))
err = PTR_ERR(inst);
else if ((err = crypto_register_instance(tmpl, inst)))
@@ -70,8 +75,8 @@ out:
return;
err:
- crypto_larval_error(param->larval.name, param->larval.type,
- param->larval.mask);
+ crypto_larval_error(param->larval.name, param->type.data.type,
+ param->type.data.mask);
goto out;
}
@@ -82,7 +87,7 @@ static int cryptomgr_schedule_probe(struct crypto_larval *larval)
const char *p;
unsigned int len;
- param = kmalloc(sizeof(*param), GFP_KERNEL);
+ param = kzalloc(sizeof(*param), GFP_KERNEL);
if (!param)
goto err;
@@ -94,7 +99,6 @@ static int cryptomgr_schedule_probe(struct crypto_larval *larval)
goto err_free_param;
memcpy(param->template, name, len);
- param->template[len] = 0;
name = p + 1;
for (p = name; isalnum(*p) || *p == '-' || *p == '_'; p++)
@@ -104,14 +108,18 @@ static int cryptomgr_schedule_probe(struct crypto_larval *larval)
if (!len || *p != ')' || p[1])
goto err_free_param;
+ param->type.attr.rta_len = sizeof(param->type);
+ param->type.attr.rta_type = CRYPTOA_TYPE;
+ param->type.data.type = larval->alg.cra_flags;
+ param->type.data.mask = larval->mask;
+ param->tb[CRYPTOA_TYPE - 1] = &param->type.attr;
+
param->alg.attr.rta_len = sizeof(param->alg);
param->alg.attr.rta_type = CRYPTOA_ALG;
memcpy(param->alg.data.name, name, len);
- param->alg.data.name[len] = 0;
+ param->tb[CRYPTOA_ALG - 1] = &param->alg.attr;
memcpy(param->larval.name, larval->alg.cra_name, CRYPTO_MAX_ALG_NAME);
- param->larval.type = larval->alg.cra_flags;
- param->larval.mask = larval->mask;
INIT_WORK(&param->work, cryptomgr_probe);
schedule_work(&param->work);