crypto: ctr - use template array registering API to simplify the code
Use crypto template array registering API to simplify the code. Signed-off-by: Xiongfeng Wang <xiongfeng.wang@linaro.org> Reviewed-by: Eric Biggers <ebiggers@google.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
This commit is contained in:
parent
56a00d9da1
commit
9f8ef365ef
36
crypto/ctr.c
36
crypto/ctr.c
|
@ -171,12 +171,6 @@ static int crypto_ctr_create(struct crypto_template *tmpl, struct rtattr **tb)
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct crypto_template crypto_ctr_tmpl = {
|
|
||||||
.name = "ctr",
|
|
||||||
.create = crypto_ctr_create,
|
|
||||||
.module = THIS_MODULE,
|
|
||||||
};
|
|
||||||
|
|
||||||
static int crypto_rfc3686_setkey(struct crypto_skcipher *parent,
|
static int crypto_rfc3686_setkey(struct crypto_skcipher *parent,
|
||||||
const u8 *key, unsigned int keylen)
|
const u8 *key, unsigned int keylen)
|
||||||
{
|
{
|
||||||
|
@ -366,36 +360,28 @@ static int crypto_rfc3686_create(struct crypto_template *tmpl,
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct crypto_template crypto_rfc3686_tmpl = {
|
static struct crypto_template crypto_ctr_tmpls[] = {
|
||||||
|
{
|
||||||
|
.name = "ctr",
|
||||||
|
.create = crypto_ctr_create,
|
||||||
|
.module = THIS_MODULE,
|
||||||
|
}, {
|
||||||
.name = "rfc3686",
|
.name = "rfc3686",
|
||||||
.create = crypto_rfc3686_create,
|
.create = crypto_rfc3686_create,
|
||||||
.module = THIS_MODULE,
|
.module = THIS_MODULE,
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
static int __init crypto_ctr_module_init(void)
|
static int __init crypto_ctr_module_init(void)
|
||||||
{
|
{
|
||||||
int err;
|
return crypto_register_templates(crypto_ctr_tmpls,
|
||||||
|
ARRAY_SIZE(crypto_ctr_tmpls));
|
||||||
err = crypto_register_template(&crypto_ctr_tmpl);
|
|
||||||
if (err)
|
|
||||||
goto out;
|
|
||||||
|
|
||||||
err = crypto_register_template(&crypto_rfc3686_tmpl);
|
|
||||||
if (err)
|
|
||||||
goto out_drop_ctr;
|
|
||||||
|
|
||||||
out:
|
|
||||||
return err;
|
|
||||||
|
|
||||||
out_drop_ctr:
|
|
||||||
crypto_unregister_template(&crypto_ctr_tmpl);
|
|
||||||
goto out;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void __exit crypto_ctr_module_exit(void)
|
static void __exit crypto_ctr_module_exit(void)
|
||||||
{
|
{
|
||||||
crypto_unregister_template(&crypto_rfc3686_tmpl);
|
crypto_unregister_templates(crypto_ctr_tmpls,
|
||||||
crypto_unregister_template(&crypto_ctr_tmpl);
|
ARRAY_SIZE(crypto_ctr_tmpls));
|
||||||
}
|
}
|
||||||
|
|
||||||
module_init(crypto_ctr_module_init);
|
module_init(crypto_ctr_module_init);
|
||||||
|
|
Loading…
Reference in New Issue