aboutsummaryrefslogtreecommitdiffstats
path: root/crypto
diff options
context:
space:
mode:
authorJussi Kivilinna <jussi.kivilinna@mbnet.fi>2012-07-11 07:20:10 -0400
committerHerbert Xu <herbert@gondor.apana.org.au>2012-08-01 05:47:25 -0400
commitbbc406b9d2de4182a4b2990efcd1754ae9e2c483 (patch)
treeda6714266c12150c4ad41a22cdc4a8a7f39fedd1 /crypto
parent9935e6d2f3b5670550e48a55172cab546ae5d096 (diff)
crypto: serpent - use crypto_[un]register_algs
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> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'crypto')
-rw-r--r--crypto/serpent_generic.c53
1 files changed, 19 insertions, 34 deletions
diff --git a/crypto/serpent_generic.c b/crypto/serpent_generic.c
index 8f32cf35e5ce..7ddbd7e88859 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)
567 __serpent_decrypt(ctx, dst, src); 567 __serpent_decrypt(ctx, dst, src);
568} 568}
569 569
570static struct crypto_alg serpent_alg = {
571 .cra_name = "serpent",
572 .cra_driver_name = "serpent-generic",
573 .cra_priority = 100,
574 .cra_flags = CRYPTO_ALG_TYPE_CIPHER,
575 .cra_blocksize = SERPENT_BLOCK_SIZE,
576 .cra_ctxsize = sizeof(struct serpent_ctx),
577 .cra_alignmask = 3,
578 .cra_module = THIS_MODULE,
579 .cra_list = LIST_HEAD_INIT(serpent_alg.cra_list),
580 .cra_u = { .cipher = {
581 .cia_min_keysize = SERPENT_MIN_KEY_SIZE,
582 .cia_max_keysize = SERPENT_MAX_KEY_SIZE,
583 .cia_setkey = serpent_setkey,
584 .cia_encrypt = serpent_encrypt,
585 .cia_decrypt = serpent_decrypt } }
586};
587
588static int tnepres_setkey(struct crypto_tfm *tfm, const u8 *key, 570static int tnepres_setkey(struct crypto_tfm *tfm, const u8 *key,
589 unsigned int keylen) 571 unsigned int keylen)
590{ 572{
@@ -637,41 +619,44 @@ static void tnepres_decrypt(struct crypto_tfm *tfm, u8 *dst, const u8 *src)
637 d[3] = swab32(rd[0]); 619 d[3] = swab32(rd[0]);
638} 620}
639 621
640static struct crypto_alg tnepres_alg = { 622static struct crypto_alg srp_algs[2] = { {
623 .cra_name = "serpent",
624 .cra_driver_name = "serpent-generic",
625 .cra_priority = 100,
626 .cra_flags = CRYPTO_ALG_TYPE_CIPHER,
627 .cra_blocksize = SERPENT_BLOCK_SIZE,
628 .cra_ctxsize = sizeof(struct serpent_ctx),
629 .cra_alignmask = 3,
630 .cra_module = THIS_MODULE,
631 .cra_u = { .cipher = {
632 .cia_min_keysize = SERPENT_MIN_KEY_SIZE,
633 .cia_max_keysize = SERPENT_MAX_KEY_SIZE,
634 .cia_setkey = serpent_setkey,
635 .cia_encrypt = serpent_encrypt,
636 .cia_decrypt = serpent_decrypt } }
637}, {
641 .cra_name = "tnepres", 638 .cra_name = "tnepres",
642 .cra_flags = CRYPTO_ALG_TYPE_CIPHER, 639 .cra_flags = CRYPTO_ALG_TYPE_CIPHER,
643 .cra_blocksize = SERPENT_BLOCK_SIZE, 640 .cra_blocksize = SERPENT_BLOCK_SIZE,
644 .cra_ctxsize = sizeof(struct serpent_ctx), 641 .cra_ctxsize = sizeof(struct serpent_ctx),
645 .cra_alignmask = 3, 642 .cra_alignmask = 3,
646 .cra_module = THIS_MODULE, 643 .cra_module = THIS_MODULE,
647 .cra_list = LIST_HEAD_INIT(serpent_alg.cra_list),
648 .cra_u = { .cipher = { 644 .cra_u = { .cipher = {
649 .cia_min_keysize = SERPENT_MIN_KEY_SIZE, 645 .cia_min_keysize = SERPENT_MIN_KEY_SIZE,
650 .cia_max_keysize = SERPENT_MAX_KEY_SIZE, 646 .cia_max_keysize = SERPENT_MAX_KEY_SIZE,
651 .cia_setkey = tnepres_setkey, 647 .cia_setkey = tnepres_setkey,
652 .cia_encrypt = tnepres_encrypt, 648 .cia_encrypt = tnepres_encrypt,
653 .cia_decrypt = tnepres_decrypt } } 649 .cia_decrypt = tnepres_decrypt } }
654}; 650} };
655 651
656static int __init serpent_mod_init(void) 652static int __init serpent_mod_init(void)
657{ 653{
658 int ret = crypto_register_alg(&serpent_alg); 654 return crypto_register_algs(srp_algs, ARRAY_SIZE(srp_algs));
659
660 if (ret)
661 return ret;
662
663 ret = crypto_register_alg(&tnepres_alg);
664
665 if (ret)
666 crypto_unregister_alg(&serpent_alg);
667
668 return ret;
669} 655}
670 656
671static void __exit serpent_mod_fini(void) 657static void __exit serpent_mod_fini(void)
672{ 658{
673 crypto_unregister_alg(&tnepres_alg); 659 crypto_unregister_algs(srp_algs, ARRAY_SIZE(srp_algs));
674 crypto_unregister_alg(&serpent_alg);
675} 660}
676 661
677module_init(serpent_mod_init); 662module_init(serpent_mod_init);