Skip to content

Commit

Permalink
crypto: chacha20poly1305 - use template array registering API to simp…
Browse files Browse the repository at this point in the history
…lify the code

Use crypto template array registering API to simplify the code.

Signed-off-by: Xiongfeng Wang <[email protected]>
Reviewed-by: Eric Biggers <[email protected]>
Signed-off-by: Herbert Xu <[email protected]>
  • Loading branch information
Xiongfeng Wang authored and herbertx committed Jan 25, 2019
1 parent 9f8ef36 commit 1a5e02b
Showing 1 changed file with 14 additions and 23 deletions.
37 changes: 14 additions & 23 deletions crypto/chacha20poly1305.c
Original file line number Diff line number Diff line change
Expand Up @@ -701,37 +701,28 @@ static int rfc7539esp_create(struct crypto_template *tmpl, struct rtattr **tb)
return chachapoly_create(tmpl, tb, "rfc7539esp", 8);
}

static struct crypto_template rfc7539_tmpl = {
.name = "rfc7539",
.create = rfc7539_create,
.module = THIS_MODULE,
};

static struct crypto_template rfc7539esp_tmpl = {
.name = "rfc7539esp",
.create = rfc7539esp_create,
.module = THIS_MODULE,
static struct crypto_template rfc7539_tmpls[] = {
{
.name = "rfc7539",
.create = rfc7539_create,
.module = THIS_MODULE,
}, {
.name = "rfc7539esp",
.create = rfc7539esp_create,
.module = THIS_MODULE,
},
};

static int __init chacha20poly1305_module_init(void)
{
int err;

err = crypto_register_template(&rfc7539_tmpl);
if (err)
return err;

err = crypto_register_template(&rfc7539esp_tmpl);
if (err)
crypto_unregister_template(&rfc7539_tmpl);

return err;
return crypto_register_templates(rfc7539_tmpls,
ARRAY_SIZE(rfc7539_tmpls));
}

static void __exit chacha20poly1305_module_exit(void)
{
crypto_unregister_template(&rfc7539esp_tmpl);
crypto_unregister_template(&rfc7539_tmpl);
crypto_unregister_templates(rfc7539_tmpls,
ARRAY_SIZE(rfc7539_tmpls));
}

module_init(chacha20poly1305_module_init);
Expand Down

0 comments on commit 1a5e02b

Please sign in to comment.