From: Jussi Kivilinna <jussi.kivilinna@mbnet.fi>
To: linux-crypto@vger.kernel.org
Cc: Herbert Xu <herbert@gondor.apana.org.au>,
"David S. Miller" <davem@davemloft.net>
Subject: [PATCH 04/14] crypto: serpent - use crypto_[un]register_algs
Date: Wed, 11 Jul 2012 14:20:10 +0300 [thread overview]
Message-ID: <20120711112010.6875.37469.stgit@localhost6.localdomain6> (raw)
In-Reply-To: <20120711111949.6875.60269.stgit@localhost6.localdomain6>
Combine all crypto_alg to be registered and use new crypto_[un]register_algs
functions. This simplifies init/exit code.
Signed-off-by: Jussi Kivilinna <jussi.kivilinna@mbnet.fi>
---
crypto/serpent_generic.c | 53 ++++++++++++++++------------------------------
1 file changed, 19 insertions(+), 34 deletions(-)
diff --git a/crypto/serpent_generic.c b/crypto/serpent_generic.c
index 8f32cf3..7ddbd7e 100644
--- a/crypto/serpent_generic.c
+++ b/crypto/serpent_generic.c
@@ -567,24 +567,6 @@ static void serpent_decrypt(struct crypto_tfm *tfm, u8 *dst, const u8 *src)
__serpent_decrypt(ctx, dst, src);
}
-static struct crypto_alg serpent_alg = {
- .cra_name = "serpent",
- .cra_driver_name = "serpent-generic",
- .cra_priority = 100,
- .cra_flags = CRYPTO_ALG_TYPE_CIPHER,
- .cra_blocksize = SERPENT_BLOCK_SIZE,
- .cra_ctxsize = sizeof(struct serpent_ctx),
- .cra_alignmask = 3,
- .cra_module = THIS_MODULE,
- .cra_list = LIST_HEAD_INIT(serpent_alg.cra_list),
- .cra_u = { .cipher = {
- .cia_min_keysize = SERPENT_MIN_KEY_SIZE,
- .cia_max_keysize = SERPENT_MAX_KEY_SIZE,
- .cia_setkey = serpent_setkey,
- .cia_encrypt = serpent_encrypt,
- .cia_decrypt = serpent_decrypt } }
-};
-
static int tnepres_setkey(struct crypto_tfm *tfm, const u8 *key,
unsigned int keylen)
{
@@ -637,41 +619,44 @@ static void tnepres_decrypt(struct crypto_tfm *tfm, u8 *dst, const u8 *src)
d[3] = swab32(rd[0]);
}
-static struct crypto_alg tnepres_alg = {
+static struct crypto_alg srp_algs[2] = { {
+ .cra_name = "serpent",
+ .cra_driver_name = "serpent-generic",
+ .cra_priority = 100,
+ .cra_flags = CRYPTO_ALG_TYPE_CIPHER,
+ .cra_blocksize = SERPENT_BLOCK_SIZE,
+ .cra_ctxsize = sizeof(struct serpent_ctx),
+ .cra_alignmask = 3,
+ .cra_module = THIS_MODULE,
+ .cra_u = { .cipher = {
+ .cia_min_keysize = SERPENT_MIN_KEY_SIZE,
+ .cia_max_keysize = SERPENT_MAX_KEY_SIZE,
+ .cia_setkey = serpent_setkey,
+ .cia_encrypt = serpent_encrypt,
+ .cia_decrypt = serpent_decrypt } }
+}, {
.cra_name = "tnepres",
.cra_flags = CRYPTO_ALG_TYPE_CIPHER,
.cra_blocksize = SERPENT_BLOCK_SIZE,
.cra_ctxsize = sizeof(struct serpent_ctx),
.cra_alignmask = 3,
.cra_module = THIS_MODULE,
- .cra_list = LIST_HEAD_INIT(serpent_alg.cra_list),
.cra_u = { .cipher = {
.cia_min_keysize = SERPENT_MIN_KEY_SIZE,
.cia_max_keysize = SERPENT_MAX_KEY_SIZE,
.cia_setkey = tnepres_setkey,
.cia_encrypt = tnepres_encrypt,
.cia_decrypt = tnepres_decrypt } }
-};
+} };
static int __init serpent_mod_init(void)
{
- int ret = crypto_register_alg(&serpent_alg);
-
- if (ret)
- return ret;
-
- ret = crypto_register_alg(&tnepres_alg);
-
- if (ret)
- crypto_unregister_alg(&serpent_alg);
-
- return ret;
+ return crypto_register_algs(srp_algs, ARRAY_SIZE(srp_algs));
}
static void __exit serpent_mod_fini(void)
{
- crypto_unregister_alg(&tnepres_alg);
- crypto_unregister_alg(&serpent_alg);
+ crypto_unregister_algs(srp_algs, ARRAY_SIZE(srp_algs));
}
module_init(serpent_mod_init);
next prev parent reply other threads:[~2012-07-11 11:20 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-07-11 11:19 [PATCH 00/14] crypto: cleanup - alg and shash init/exit cleanups and remove unneeded cra_list initializations Jussi Kivilinna
2012-07-11 11:19 ` [PATCH 01/14] crypto: tea - use crypto_[un]register_algs Jussi Kivilinna
2012-07-11 11:20 ` [PATCH 02/14] crypto: crypto_null " Jussi Kivilinna
2012-07-11 11:20 ` [PATCH 03/14] crypto: des " Jussi Kivilinna
2012-07-11 11:20 ` Jussi Kivilinna [this message]
2012-07-11 11:20 ` [PATCH 05/14] crypto: ansi_cprng " Jussi Kivilinna
2012-07-11 11:20 ` [PATCH 06/14] crypto: add crypto_[un]register_shashes for [un]registering multiple shash entries at once Jussi Kivilinna
2012-07-11 11:20 ` [PATCH 07/14] crypto: tiger - use crypto_[un]register_shashes Jussi Kivilinna
2012-07-11 11:20 ` [PATCH 08/14] crypto: sha256 " Jussi Kivilinna
2012-07-11 11:20 ` [PATCH 09/14] crypto: sha512 " Jussi Kivilinna
2012-07-11 11:20 ` [PATCH 10/14] crypto: whirlpool " Jussi Kivilinna
2012-07-11 11:20 ` [PATCH 11/14] crypto: cleanup - remove unneeded crypto_alg.cra_list initializations Jussi Kivilinna
2012-07-11 11:20 ` [PATCH 12/14] crypto: arch/x86 - " Jussi Kivilinna
2012-07-11 11:20 ` [PATCH 13/14] crypto: drivers - remove cra_list initialization Jussi Kivilinna
2012-07-13 17:00 ` Kent Yoder
2012-07-18 1:04 ` Vladimir Zapolskiy
2012-07-11 11:21 ` [PATCH 14/14] crypto: arch/s390 - cleanup - remove unneeded " Jussi Kivilinna
2012-07-12 9:28 ` Jan Glauber
2012-07-30 7:52 ` [PATCH 00/14] crypto: cleanup - alg and shash init/exit cleanups and remove unneeded cra_list initializations Herbert Xu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20120711112010.6875.37469.stgit@localhost6.localdomain6 \
--to=jussi.kivilinna@mbnet.fi \
--cc=davem@davemloft.net \
--cc=herbert@gondor.apana.org.au \
--cc=linux-crypto@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).