aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
Diffstat (limited to 'arch')
-rw-r--r--arch/x86/crypto/serpent_sse2_glue.c71
1 files changed, 13 insertions, 58 deletions
diff --git a/arch/x86/crypto/serpent_sse2_glue.c b/arch/x86/crypto/serpent_sse2_glue.c
index 5520c7522200..4b21be85e0a1 100644
--- a/arch/x86/crypto/serpent_sse2_glue.c
+++ b/arch/x86/crypto/serpent_sse2_glue.c
@@ -676,68 +676,23 @@ static void ablk_exit(struct crypto_tfm *tfm)
676 cryptd_free_ablkcipher(ctx->cryptd_tfm); 676 cryptd_free_ablkcipher(ctx->cryptd_tfm);
677} 677}
678 678
679static void ablk_init_common(struct crypto_tfm *tfm, 679static int ablk_init(struct crypto_tfm *tfm)
680 struct cryptd_ablkcipher *cryptd_tfm)
681{ 680{
682 struct async_serpent_ctx *ctx = crypto_tfm_ctx(tfm); 681 struct async_serpent_ctx *ctx = crypto_tfm_ctx(tfm);
683
684 ctx->cryptd_tfm = cryptd_tfm;
685 tfm->crt_ablkcipher.reqsize = sizeof(struct ablkcipher_request) +
686 crypto_ablkcipher_reqsize(&cryptd_tfm->base);
687}
688
689static int ablk_ecb_init(struct crypto_tfm *tfm)
690{
691 struct cryptd_ablkcipher *cryptd_tfm; 682 struct cryptd_ablkcipher *cryptd_tfm;
683 char drv_name[CRYPTO_MAX_ALG_NAME];
692 684
693 cryptd_tfm = cryptd_alloc_ablkcipher("__driver-ecb-serpent-sse2", 0, 0); 685 snprintf(drv_name, sizeof(drv_name), "__driver-%s",
694 if (IS_ERR(cryptd_tfm)) 686 crypto_tfm_alg_driver_name(tfm));
695 return PTR_ERR(cryptd_tfm);
696 ablk_init_common(tfm, cryptd_tfm);
697 return 0;
698}
699
700static int ablk_cbc_init(struct crypto_tfm *tfm)
701{
702 struct cryptd_ablkcipher *cryptd_tfm;
703 687
704 cryptd_tfm = cryptd_alloc_ablkcipher("__driver-cbc-serpent-sse2", 0, 0); 688 cryptd_tfm = cryptd_alloc_ablkcipher(drv_name, 0, 0);
705 if (IS_ERR(cryptd_tfm)) 689 if (IS_ERR(cryptd_tfm))
706 return PTR_ERR(cryptd_tfm); 690 return PTR_ERR(cryptd_tfm);
707 ablk_init_common(tfm, cryptd_tfm);
708 return 0;
709}
710 691
711static int ablk_ctr_init(struct crypto_tfm *tfm) 692 ctx->cryptd_tfm = cryptd_tfm;
712{ 693 tfm->crt_ablkcipher.reqsize = sizeof(struct ablkcipher_request) +
713 struct cryptd_ablkcipher *cryptd_tfm; 694 crypto_ablkcipher_reqsize(&cryptd_tfm->base);
714
715 cryptd_tfm = cryptd_alloc_ablkcipher("__driver-ctr-serpent-sse2", 0, 0);
716 if (IS_ERR(cryptd_tfm))
717 return PTR_ERR(cryptd_tfm);
718 ablk_init_common(tfm, cryptd_tfm);
719 return 0;
720}
721
722static int ablk_lrw_init(struct crypto_tfm *tfm)
723{
724 struct cryptd_ablkcipher *cryptd_tfm;
725
726 cryptd_tfm = cryptd_alloc_ablkcipher("__driver-lrw-serpent-sse2", 0, 0);
727 if (IS_ERR(cryptd_tfm))
728 return PTR_ERR(cryptd_tfm);
729 ablk_init_common(tfm, cryptd_tfm);
730 return 0;
731}
732
733static int ablk_xts_init(struct crypto_tfm *tfm)
734{
735 struct cryptd_ablkcipher *cryptd_tfm;
736 695
737 cryptd_tfm = cryptd_alloc_ablkcipher("__driver-xts-serpent-sse2", 0, 0);
738 if (IS_ERR(cryptd_tfm))
739 return PTR_ERR(cryptd_tfm);
740 ablk_init_common(tfm, cryptd_tfm);
741 return 0; 696 return 0;
742} 697}
743 698
@@ -858,7 +813,7 @@ static struct crypto_alg serpent_algs[10] = { {
858 .cra_type = &crypto_ablkcipher_type, 813 .cra_type = &crypto_ablkcipher_type,
859 .cra_module = THIS_MODULE, 814 .cra_module = THIS_MODULE,
860 .cra_list = LIST_HEAD_INIT(serpent_algs[5].cra_list), 815 .cra_list = LIST_HEAD_INIT(serpent_algs[5].cra_list),
861 .cra_init = ablk_ecb_init, 816 .cra_init = ablk_init,
862 .cra_exit = ablk_exit, 817 .cra_exit = ablk_exit,
863 .cra_u = { 818 .cra_u = {
864 .ablkcipher = { 819 .ablkcipher = {
@@ -880,7 +835,7 @@ static struct crypto_alg serpent_algs[10] = { {
880 .cra_type = &crypto_ablkcipher_type, 835 .cra_type = &crypto_ablkcipher_type,
881 .cra_module = THIS_MODULE, 836 .cra_module = THIS_MODULE,
882 .cra_list = LIST_HEAD_INIT(serpent_algs[6].cra_list), 837 .cra_list = LIST_HEAD_INIT(serpent_algs[6].cra_list),
883 .cra_init = ablk_cbc_init, 838 .cra_init = ablk_init,
884 .cra_exit = ablk_exit, 839 .cra_exit = ablk_exit,
885 .cra_u = { 840 .cra_u = {
886 .ablkcipher = { 841 .ablkcipher = {
@@ -903,7 +858,7 @@ static struct crypto_alg serpent_algs[10] = { {
903 .cra_type = &crypto_ablkcipher_type, 858 .cra_type = &crypto_ablkcipher_type,
904 .cra_module = THIS_MODULE, 859 .cra_module = THIS_MODULE,
905 .cra_list = LIST_HEAD_INIT(serpent_algs[7].cra_list), 860 .cra_list = LIST_HEAD_INIT(serpent_algs[7].cra_list),
906 .cra_init = ablk_ctr_init, 861 .cra_init = ablk_init,
907 .cra_exit = ablk_exit, 862 .cra_exit = ablk_exit,
908 .cra_u = { 863 .cra_u = {
909 .ablkcipher = { 864 .ablkcipher = {
@@ -927,7 +882,7 @@ static struct crypto_alg serpent_algs[10] = { {
927 .cra_type = &crypto_ablkcipher_type, 882 .cra_type = &crypto_ablkcipher_type,
928 .cra_module = THIS_MODULE, 883 .cra_module = THIS_MODULE,
929 .cra_list = LIST_HEAD_INIT(serpent_algs[8].cra_list), 884 .cra_list = LIST_HEAD_INIT(serpent_algs[8].cra_list),
930 .cra_init = ablk_lrw_init, 885 .cra_init = ablk_init,
931 .cra_exit = ablk_exit, 886 .cra_exit = ablk_exit,
932 .cra_u = { 887 .cra_u = {
933 .ablkcipher = { 888 .ablkcipher = {
@@ -952,7 +907,7 @@ static struct crypto_alg serpent_algs[10] = { {
952 .cra_type = &crypto_ablkcipher_type, 907 .cra_type = &crypto_ablkcipher_type,
953 .cra_module = THIS_MODULE, 908 .cra_module = THIS_MODULE,
954 .cra_list = LIST_HEAD_INIT(serpent_algs[9].cra_list), 909 .cra_list = LIST_HEAD_INIT(serpent_algs[9].cra_list),
955 .cra_init = ablk_xts_init, 910 .cra_init = ablk_init,
956 .cra_exit = ablk_exit, 911 .cra_exit = ablk_exit,
957 .cra_u = { 912 .cra_u = {
958 .ablkcipher = { 913 .ablkcipher = {