.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
---|
1 | 2 | /* |
---|
2 | 3 | * Copyright (c) 2010-2011 Picochip Ltd., Jamie Iles |
---|
3 | | - * |
---|
4 | | - * This program is free software; you can redistribute it and/or modify |
---|
5 | | - * it under the terms of the GNU General Public License as published by |
---|
6 | | - * the Free Software Foundation; either version 2 of the License, or |
---|
7 | | - * (at your option) any later version. |
---|
8 | | - * |
---|
9 | | - * This program is distributed in the hope that it will be useful, |
---|
10 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
11 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
12 | | - * GNU General Public License for more details. |
---|
13 | | - * |
---|
14 | | - * You should have received a copy of the GNU General Public License |
---|
15 | | - * along with this program; if not, write to the Free Software |
---|
16 | | - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
---|
17 | 4 | */ |
---|
18 | 5 | #include <crypto/internal/aead.h> |
---|
19 | 6 | #include <crypto/aes.h> |
---|
20 | 7 | #include <crypto/algapi.h> |
---|
21 | 8 | #include <crypto/authenc.h> |
---|
22 | | -#include <crypto/des.h> |
---|
| 9 | +#include <crypto/internal/des.h> |
---|
23 | 10 | #include <crypto/md5.h> |
---|
24 | 11 | #include <crypto/sha.h> |
---|
25 | 12 | #include <crypto/internal/skcipher.h> |
---|
.. | .. |
---|
99 | 86 | dma_addr_t src_addr, dst_addr; |
---|
100 | 87 | struct spacc_ddt *src_ddt, *dst_ddt; |
---|
101 | 88 | void (*complete)(struct spacc_req *req); |
---|
| 89 | + struct skcipher_request fallback_req; // keep at the end |
---|
102 | 90 | }; |
---|
103 | 91 | |
---|
104 | 92 | struct spacc_aead { |
---|
.. | .. |
---|
147 | 135 | struct spacc_alg { |
---|
148 | 136 | unsigned long ctrl_default; |
---|
149 | 137 | unsigned long type; |
---|
150 | | - struct crypto_alg alg; |
---|
| 138 | + struct skcipher_alg alg; |
---|
151 | 139 | struct spacc_engine *engine; |
---|
152 | 140 | struct list_head entry; |
---|
153 | 141 | int key_offs; |
---|
.. | .. |
---|
186 | 174 | |
---|
187 | 175 | static int spacc_ablk_submit(struct spacc_req *req); |
---|
188 | 176 | |
---|
189 | | -static inline struct spacc_alg *to_spacc_alg(struct crypto_alg *alg) |
---|
| 177 | +static inline struct spacc_alg *to_spacc_skcipher(struct skcipher_alg *alg) |
---|
190 | 178 | { |
---|
191 | 179 | return alg ? container_of(alg, struct spacc_alg, alg) : NULL; |
---|
192 | 180 | } |
---|
.. | .. |
---|
478 | 466 | crypto_aead_set_flags(ctx->sw_cipher, crypto_aead_get_flags(tfm) & |
---|
479 | 467 | CRYPTO_TFM_REQ_MASK); |
---|
480 | 468 | err = crypto_aead_setkey(ctx->sw_cipher, key, keylen); |
---|
481 | | - crypto_aead_clear_flags(tfm, CRYPTO_TFM_RES_MASK); |
---|
482 | | - crypto_aead_set_flags(tfm, crypto_aead_get_flags(ctx->sw_cipher) & |
---|
483 | | - CRYPTO_TFM_RES_MASK); |
---|
484 | 469 | if (err) |
---|
485 | 470 | return err; |
---|
486 | 471 | |
---|
.. | .. |
---|
503 | 488 | return 0; |
---|
504 | 489 | |
---|
505 | 490 | badkey: |
---|
506 | | - crypto_aead_set_flags(tfm, CRYPTO_TFM_RES_BAD_KEY_LEN); |
---|
507 | 491 | memzero_explicit(&keys, sizeof(keys)); |
---|
508 | 492 | return -EINVAL; |
---|
509 | 493 | } |
---|
.. | .. |
---|
746 | 730 | * Set the DES key for a block cipher transform. This also performs weak key |
---|
747 | 731 | * checking if the transform has requested it. |
---|
748 | 732 | */ |
---|
749 | | -static int spacc_des_setkey(struct crypto_ablkcipher *cipher, const u8 *key, |
---|
| 733 | +static int spacc_des_setkey(struct crypto_skcipher *cipher, const u8 *key, |
---|
750 | 734 | unsigned int len) |
---|
751 | 735 | { |
---|
752 | | - struct crypto_tfm *tfm = crypto_ablkcipher_tfm(cipher); |
---|
753 | | - struct spacc_ablk_ctx *ctx = crypto_tfm_ctx(tfm); |
---|
754 | | - u32 tmp[DES_EXPKEY_WORDS]; |
---|
| 736 | + struct spacc_ablk_ctx *ctx = crypto_skcipher_ctx(cipher); |
---|
| 737 | + int err; |
---|
755 | 738 | |
---|
756 | | - if (len > DES3_EDE_KEY_SIZE) { |
---|
757 | | - crypto_ablkcipher_set_flags(cipher, CRYPTO_TFM_RES_BAD_KEY_LEN); |
---|
758 | | - return -EINVAL; |
---|
759 | | - } |
---|
| 739 | + err = verify_skcipher_des_key(cipher, key); |
---|
| 740 | + if (err) |
---|
| 741 | + return err; |
---|
760 | 742 | |
---|
761 | | - if (unlikely(!des_ekey(tmp, key)) && |
---|
762 | | - (crypto_ablkcipher_get_flags(cipher) & CRYPTO_TFM_REQ_WEAK_KEY)) { |
---|
763 | | - tfm->crt_flags |= CRYPTO_TFM_RES_WEAK_KEY; |
---|
764 | | - return -EINVAL; |
---|
765 | | - } |
---|
| 743 | + memcpy(ctx->key, key, len); |
---|
| 744 | + ctx->key_len = len; |
---|
| 745 | + |
---|
| 746 | + return 0; |
---|
| 747 | +} |
---|
| 748 | + |
---|
| 749 | +/* |
---|
| 750 | + * Set the 3DES key for a block cipher transform. This also performs weak key |
---|
| 751 | + * checking if the transform has requested it. |
---|
| 752 | + */ |
---|
| 753 | +static int spacc_des3_setkey(struct crypto_skcipher *cipher, const u8 *key, |
---|
| 754 | + unsigned int len) |
---|
| 755 | +{ |
---|
| 756 | + struct spacc_ablk_ctx *ctx = crypto_skcipher_ctx(cipher); |
---|
| 757 | + int err; |
---|
| 758 | + |
---|
| 759 | + err = verify_skcipher_des3_key(cipher, key); |
---|
| 760 | + if (err) |
---|
| 761 | + return err; |
---|
766 | 762 | |
---|
767 | 763 | memcpy(ctx->key, key, len); |
---|
768 | 764 | ctx->key_len = len; |
---|
.. | .. |
---|
774 | 770 | * Set the key for an AES block cipher. Some key lengths are not supported in |
---|
775 | 771 | * hardware so this must also check whether a fallback is needed. |
---|
776 | 772 | */ |
---|
777 | | -static int spacc_aes_setkey(struct crypto_ablkcipher *cipher, const u8 *key, |
---|
| 773 | +static int spacc_aes_setkey(struct crypto_skcipher *cipher, const u8 *key, |
---|
778 | 774 | unsigned int len) |
---|
779 | 775 | { |
---|
780 | | - struct crypto_tfm *tfm = crypto_ablkcipher_tfm(cipher); |
---|
| 776 | + struct crypto_tfm *tfm = crypto_skcipher_tfm(cipher); |
---|
781 | 777 | struct spacc_ablk_ctx *ctx = crypto_tfm_ctx(tfm); |
---|
782 | 778 | int err = 0; |
---|
783 | 779 | |
---|
784 | | - if (len > AES_MAX_KEY_SIZE) { |
---|
785 | | - crypto_ablkcipher_set_flags(cipher, CRYPTO_TFM_RES_BAD_KEY_LEN); |
---|
| 780 | + if (len > AES_MAX_KEY_SIZE) |
---|
786 | 781 | return -EINVAL; |
---|
787 | | - } |
---|
788 | 782 | |
---|
789 | 783 | /* |
---|
790 | 784 | * IPSec engine only supports 128 and 256 bit AES keys. If we get a |
---|
.. | .. |
---|
806 | 800 | CRYPTO_TFM_REQ_MASK); |
---|
807 | 801 | |
---|
808 | 802 | err = crypto_skcipher_setkey(ctx->sw_cipher, key, len); |
---|
809 | | - |
---|
810 | | - tfm->crt_flags &= ~CRYPTO_TFM_RES_MASK; |
---|
811 | | - tfm->crt_flags |= |
---|
812 | | - crypto_skcipher_get_flags(ctx->sw_cipher) & |
---|
813 | | - CRYPTO_TFM_RES_MASK; |
---|
814 | | - |
---|
815 | 803 | if (err) |
---|
816 | 804 | goto sw_setkey_failed; |
---|
817 | 805 | } |
---|
.. | .. |
---|
823 | 811 | return err; |
---|
824 | 812 | } |
---|
825 | 813 | |
---|
826 | | -static int spacc_kasumi_f8_setkey(struct crypto_ablkcipher *cipher, |
---|
| 814 | +static int spacc_kasumi_f8_setkey(struct crypto_skcipher *cipher, |
---|
827 | 815 | const u8 *key, unsigned int len) |
---|
828 | 816 | { |
---|
829 | | - struct crypto_tfm *tfm = crypto_ablkcipher_tfm(cipher); |
---|
| 817 | + struct crypto_tfm *tfm = crypto_skcipher_tfm(cipher); |
---|
830 | 818 | struct spacc_ablk_ctx *ctx = crypto_tfm_ctx(tfm); |
---|
831 | 819 | int err = 0; |
---|
832 | 820 | |
---|
833 | 821 | if (len > AES_MAX_KEY_SIZE) { |
---|
834 | | - crypto_ablkcipher_set_flags(cipher, CRYPTO_TFM_RES_BAD_KEY_LEN); |
---|
835 | 822 | err = -EINVAL; |
---|
836 | 823 | goto out; |
---|
837 | 824 | } |
---|
.. | .. |
---|
845 | 832 | |
---|
846 | 833 | static int spacc_ablk_need_fallback(struct spacc_req *req) |
---|
847 | 834 | { |
---|
| 835 | + struct skcipher_request *ablk_req = skcipher_request_cast(req->req); |
---|
| 836 | + struct crypto_skcipher *tfm = crypto_skcipher_reqtfm(ablk_req); |
---|
| 837 | + struct spacc_alg *spacc_alg = to_spacc_skcipher(crypto_skcipher_alg(tfm)); |
---|
848 | 838 | struct spacc_ablk_ctx *ctx; |
---|
849 | | - struct crypto_tfm *tfm = req->req->tfm; |
---|
850 | | - struct crypto_alg *alg = req->req->tfm->__crt_alg; |
---|
851 | | - struct spacc_alg *spacc_alg = to_spacc_alg(alg); |
---|
852 | 839 | |
---|
853 | | - ctx = crypto_tfm_ctx(tfm); |
---|
| 840 | + ctx = crypto_skcipher_ctx(tfm); |
---|
854 | 841 | |
---|
855 | 842 | return (spacc_alg->ctrl_default & SPACC_CRYPTO_ALG_MASK) == |
---|
856 | 843 | SPA_CTRL_CIPH_ALG_AES && |
---|
.. | .. |
---|
860 | 847 | |
---|
861 | 848 | static void spacc_ablk_complete(struct spacc_req *req) |
---|
862 | 849 | { |
---|
863 | | - struct ablkcipher_request *ablk_req = ablkcipher_request_cast(req->req); |
---|
| 850 | + struct skcipher_request *ablk_req = skcipher_request_cast(req->req); |
---|
864 | 851 | |
---|
865 | 852 | if (ablk_req->src != ablk_req->dst) { |
---|
866 | 853 | spacc_free_ddt(req, req->src_ddt, req->src_addr, ablk_req->src, |
---|
867 | | - ablk_req->nbytes, DMA_TO_DEVICE); |
---|
| 854 | + ablk_req->cryptlen, DMA_TO_DEVICE); |
---|
868 | 855 | spacc_free_ddt(req, req->dst_ddt, req->dst_addr, ablk_req->dst, |
---|
869 | | - ablk_req->nbytes, DMA_FROM_DEVICE); |
---|
| 856 | + ablk_req->cryptlen, DMA_FROM_DEVICE); |
---|
870 | 857 | } else |
---|
871 | 858 | spacc_free_ddt(req, req->dst_ddt, req->dst_addr, ablk_req->dst, |
---|
872 | | - ablk_req->nbytes, DMA_BIDIRECTIONAL); |
---|
| 859 | + ablk_req->cryptlen, DMA_BIDIRECTIONAL); |
---|
873 | 860 | |
---|
874 | 861 | req->req->complete(req->req, req->result); |
---|
875 | 862 | } |
---|
876 | 863 | |
---|
877 | 864 | static int spacc_ablk_submit(struct spacc_req *req) |
---|
878 | 865 | { |
---|
879 | | - struct crypto_tfm *tfm = req->req->tfm; |
---|
880 | | - struct spacc_ablk_ctx *ctx = crypto_tfm_ctx(tfm); |
---|
881 | | - struct ablkcipher_request *ablk_req = ablkcipher_request_cast(req->req); |
---|
882 | | - struct crypto_alg *alg = req->req->tfm->__crt_alg; |
---|
883 | | - struct spacc_alg *spacc_alg = to_spacc_alg(alg); |
---|
| 866 | + struct skcipher_request *ablk_req = skcipher_request_cast(req->req); |
---|
| 867 | + struct crypto_skcipher *tfm = crypto_skcipher_reqtfm(ablk_req); |
---|
| 868 | + struct skcipher_alg *alg = crypto_skcipher_alg(tfm); |
---|
| 869 | + struct spacc_alg *spacc_alg = to_spacc_skcipher(alg); |
---|
| 870 | + struct spacc_ablk_ctx *ctx = crypto_skcipher_ctx(tfm); |
---|
884 | 871 | struct spacc_engine *engine = ctx->generic.engine; |
---|
885 | 872 | u32 ctrl; |
---|
886 | 873 | |
---|
887 | 874 | req->ctx_id = spacc_load_ctx(&ctx->generic, ctx->key, |
---|
888 | | - ctx->key_len, ablk_req->info, alg->cra_ablkcipher.ivsize, |
---|
| 875 | + ctx->key_len, ablk_req->iv, alg->ivsize, |
---|
889 | 876 | NULL, 0); |
---|
890 | 877 | |
---|
891 | 878 | writel(req->src_addr, engine->regs + SPA_SRC_PTR_REG_OFFSET); |
---|
892 | 879 | writel(req->dst_addr, engine->regs + SPA_DST_PTR_REG_OFFSET); |
---|
893 | 880 | writel(0, engine->regs + SPA_OFFSET_REG_OFFSET); |
---|
894 | 881 | |
---|
895 | | - writel(ablk_req->nbytes, engine->regs + SPA_PROC_LEN_REG_OFFSET); |
---|
| 882 | + writel(ablk_req->cryptlen, engine->regs + SPA_PROC_LEN_REG_OFFSET); |
---|
896 | 883 | writel(0, engine->regs + SPA_ICV_OFFSET_REG_OFFSET); |
---|
897 | 884 | writel(0, engine->regs + SPA_AUX_INFO_REG_OFFSET); |
---|
898 | 885 | writel(0, engine->regs + SPA_AAD_LEN_REG_OFFSET); |
---|
.. | .. |
---|
908 | 895 | return -EINPROGRESS; |
---|
909 | 896 | } |
---|
910 | 897 | |
---|
911 | | -static int spacc_ablk_do_fallback(struct ablkcipher_request *req, |
---|
| 898 | +static int spacc_ablk_do_fallback(struct skcipher_request *req, |
---|
912 | 899 | unsigned alg_type, bool is_encrypt) |
---|
913 | 900 | { |
---|
914 | 901 | struct crypto_tfm *old_tfm = |
---|
915 | | - crypto_ablkcipher_tfm(crypto_ablkcipher_reqtfm(req)); |
---|
| 902 | + crypto_skcipher_tfm(crypto_skcipher_reqtfm(req)); |
---|
916 | 903 | struct spacc_ablk_ctx *ctx = crypto_tfm_ctx(old_tfm); |
---|
917 | | - SKCIPHER_REQUEST_ON_STACK(subreq, ctx->sw_cipher); |
---|
| 904 | + struct spacc_req *dev_req = skcipher_request_ctx(req); |
---|
918 | 905 | int err; |
---|
919 | 906 | |
---|
920 | 907 | /* |
---|
.. | .. |
---|
922 | 909 | * the ciphering has completed, put the old transform back into the |
---|
923 | 910 | * request. |
---|
924 | 911 | */ |
---|
925 | | - skcipher_request_set_tfm(subreq, ctx->sw_cipher); |
---|
926 | | - skcipher_request_set_callback(subreq, req->base.flags, NULL, NULL); |
---|
927 | | - skcipher_request_set_crypt(subreq, req->src, req->dst, |
---|
928 | | - req->nbytes, req->info); |
---|
929 | | - err = is_encrypt ? crypto_skcipher_encrypt(subreq) : |
---|
930 | | - crypto_skcipher_decrypt(subreq); |
---|
931 | | - skcipher_request_zero(subreq); |
---|
| 912 | + skcipher_request_set_tfm(&dev_req->fallback_req, ctx->sw_cipher); |
---|
| 913 | + skcipher_request_set_callback(&dev_req->fallback_req, req->base.flags, |
---|
| 914 | + req->base.complete, req->base.data); |
---|
| 915 | + skcipher_request_set_crypt(&dev_req->fallback_req, req->src, req->dst, |
---|
| 916 | + req->cryptlen, req->iv); |
---|
| 917 | + err = is_encrypt ? crypto_skcipher_encrypt(&dev_req->fallback_req) : |
---|
| 918 | + crypto_skcipher_decrypt(&dev_req->fallback_req); |
---|
932 | 919 | |
---|
933 | 920 | return err; |
---|
934 | 921 | } |
---|
935 | 922 | |
---|
936 | | -static int spacc_ablk_setup(struct ablkcipher_request *req, unsigned alg_type, |
---|
| 923 | +static int spacc_ablk_setup(struct skcipher_request *req, unsigned alg_type, |
---|
937 | 924 | bool is_encrypt) |
---|
938 | 925 | { |
---|
939 | | - struct crypto_alg *alg = req->base.tfm->__crt_alg; |
---|
940 | | - struct spacc_engine *engine = to_spacc_alg(alg)->engine; |
---|
941 | | - struct spacc_req *dev_req = ablkcipher_request_ctx(req); |
---|
| 926 | + struct crypto_skcipher *tfm = crypto_skcipher_reqtfm(req); |
---|
| 927 | + struct skcipher_alg *alg = crypto_skcipher_alg(tfm); |
---|
| 928 | + struct spacc_engine *engine = to_spacc_skcipher(alg)->engine; |
---|
| 929 | + struct spacc_req *dev_req = skcipher_request_ctx(req); |
---|
942 | 930 | unsigned long flags; |
---|
943 | 931 | int err = -ENOMEM; |
---|
944 | 932 | |
---|
.. | .. |
---|
957 | 945 | */ |
---|
958 | 946 | if (req->src != req->dst) { |
---|
959 | 947 | dev_req->src_ddt = spacc_sg_to_ddt(engine, req->src, |
---|
960 | | - req->nbytes, DMA_TO_DEVICE, &dev_req->src_addr); |
---|
| 948 | + req->cryptlen, DMA_TO_DEVICE, &dev_req->src_addr); |
---|
961 | 949 | if (!dev_req->src_ddt) |
---|
962 | 950 | goto out; |
---|
963 | 951 | |
---|
964 | 952 | dev_req->dst_ddt = spacc_sg_to_ddt(engine, req->dst, |
---|
965 | | - req->nbytes, DMA_FROM_DEVICE, &dev_req->dst_addr); |
---|
| 953 | + req->cryptlen, DMA_FROM_DEVICE, &dev_req->dst_addr); |
---|
966 | 954 | if (!dev_req->dst_ddt) |
---|
967 | 955 | goto out_free_src; |
---|
968 | 956 | } else { |
---|
969 | 957 | dev_req->dst_ddt = spacc_sg_to_ddt(engine, req->dst, |
---|
970 | | - req->nbytes, DMA_BIDIRECTIONAL, &dev_req->dst_addr); |
---|
| 958 | + req->cryptlen, DMA_BIDIRECTIONAL, &dev_req->dst_addr); |
---|
971 | 959 | if (!dev_req->dst_ddt) |
---|
972 | 960 | goto out; |
---|
973 | 961 | |
---|
.. | .. |
---|
1000 | 988 | |
---|
1001 | 989 | out_free_ddts: |
---|
1002 | 990 | spacc_free_ddt(dev_req, dev_req->dst_ddt, dev_req->dst_addr, req->dst, |
---|
1003 | | - req->nbytes, req->src == req->dst ? |
---|
| 991 | + req->cryptlen, req->src == req->dst ? |
---|
1004 | 992 | DMA_BIDIRECTIONAL : DMA_FROM_DEVICE); |
---|
1005 | 993 | out_free_src: |
---|
1006 | 994 | if (req->src != req->dst) |
---|
1007 | 995 | spacc_free_ddt(dev_req, dev_req->src_ddt, dev_req->src_addr, |
---|
1008 | | - req->src, req->nbytes, DMA_TO_DEVICE); |
---|
| 996 | + req->src, req->cryptlen, DMA_TO_DEVICE); |
---|
1009 | 997 | out: |
---|
1010 | 998 | return err; |
---|
1011 | 999 | } |
---|
1012 | 1000 | |
---|
1013 | | -static int spacc_ablk_cra_init(struct crypto_tfm *tfm) |
---|
| 1001 | +static int spacc_ablk_init_tfm(struct crypto_skcipher *tfm) |
---|
1014 | 1002 | { |
---|
1015 | | - struct spacc_ablk_ctx *ctx = crypto_tfm_ctx(tfm); |
---|
1016 | | - struct crypto_alg *alg = tfm->__crt_alg; |
---|
1017 | | - struct spacc_alg *spacc_alg = to_spacc_alg(alg); |
---|
| 1003 | + struct spacc_ablk_ctx *ctx = crypto_skcipher_ctx(tfm); |
---|
| 1004 | + struct skcipher_alg *alg = crypto_skcipher_alg(tfm); |
---|
| 1005 | + struct spacc_alg *spacc_alg = to_spacc_skcipher(alg); |
---|
1018 | 1006 | struct spacc_engine *engine = spacc_alg->engine; |
---|
1019 | 1007 | |
---|
1020 | 1008 | ctx->generic.flags = spacc_alg->type; |
---|
1021 | 1009 | ctx->generic.engine = engine; |
---|
1022 | | - if (alg->cra_flags & CRYPTO_ALG_NEED_FALLBACK) { |
---|
1023 | | - ctx->sw_cipher = crypto_alloc_skcipher( |
---|
1024 | | - alg->cra_name, 0, CRYPTO_ALG_ASYNC | |
---|
1025 | | - CRYPTO_ALG_NEED_FALLBACK); |
---|
| 1010 | + if (alg->base.cra_flags & CRYPTO_ALG_NEED_FALLBACK) { |
---|
| 1011 | + ctx->sw_cipher = crypto_alloc_skcipher(alg->base.cra_name, 0, |
---|
| 1012 | + CRYPTO_ALG_NEED_FALLBACK); |
---|
1026 | 1013 | if (IS_ERR(ctx->sw_cipher)) { |
---|
1027 | 1014 | dev_warn(engine->dev, "failed to allocate fallback for %s\n", |
---|
1028 | | - alg->cra_name); |
---|
| 1015 | + alg->base.cra_name); |
---|
1029 | 1016 | return PTR_ERR(ctx->sw_cipher); |
---|
1030 | 1017 | } |
---|
| 1018 | + crypto_skcipher_set_reqsize(tfm, sizeof(struct spacc_req) + |
---|
| 1019 | + crypto_skcipher_reqsize(ctx->sw_cipher)); |
---|
| 1020 | + } else { |
---|
| 1021 | + /* take the size without the fallback skcipher_request at the end */ |
---|
| 1022 | + crypto_skcipher_set_reqsize(tfm, offsetof(struct spacc_req, |
---|
| 1023 | + fallback_req)); |
---|
1031 | 1024 | } |
---|
| 1025 | + |
---|
1032 | 1026 | ctx->generic.key_offs = spacc_alg->key_offs; |
---|
1033 | 1027 | ctx->generic.iv_offs = spacc_alg->iv_offs; |
---|
1034 | | - |
---|
1035 | | - tfm->crt_ablkcipher.reqsize = sizeof(struct spacc_req); |
---|
1036 | 1028 | |
---|
1037 | 1029 | return 0; |
---|
1038 | 1030 | } |
---|
1039 | 1031 | |
---|
1040 | | -static void spacc_ablk_cra_exit(struct crypto_tfm *tfm) |
---|
| 1032 | +static void spacc_ablk_exit_tfm(struct crypto_skcipher *tfm) |
---|
1041 | 1033 | { |
---|
1042 | | - struct spacc_ablk_ctx *ctx = crypto_tfm_ctx(tfm); |
---|
| 1034 | + struct spacc_ablk_ctx *ctx = crypto_skcipher_ctx(tfm); |
---|
1043 | 1035 | |
---|
1044 | 1036 | crypto_free_skcipher(ctx->sw_cipher); |
---|
1045 | 1037 | } |
---|
1046 | 1038 | |
---|
1047 | | -static int spacc_ablk_encrypt(struct ablkcipher_request *req) |
---|
| 1039 | +static int spacc_ablk_encrypt(struct skcipher_request *req) |
---|
1048 | 1040 | { |
---|
1049 | | - struct crypto_ablkcipher *cipher = crypto_ablkcipher_reqtfm(req); |
---|
1050 | | - struct crypto_tfm *tfm = crypto_ablkcipher_tfm(cipher); |
---|
1051 | | - struct spacc_alg *alg = to_spacc_alg(tfm->__crt_alg); |
---|
| 1041 | + struct crypto_skcipher *cipher = crypto_skcipher_reqtfm(req); |
---|
| 1042 | + struct skcipher_alg *alg = crypto_skcipher_alg(cipher); |
---|
| 1043 | + struct spacc_alg *spacc_alg = to_spacc_skcipher(alg); |
---|
1052 | 1044 | |
---|
1053 | | - return spacc_ablk_setup(req, alg->type, 1); |
---|
| 1045 | + return spacc_ablk_setup(req, spacc_alg->type, 1); |
---|
1054 | 1046 | } |
---|
1055 | 1047 | |
---|
1056 | | -static int spacc_ablk_decrypt(struct ablkcipher_request *req) |
---|
| 1048 | +static int spacc_ablk_decrypt(struct skcipher_request *req) |
---|
1057 | 1049 | { |
---|
1058 | | - struct crypto_ablkcipher *cipher = crypto_ablkcipher_reqtfm(req); |
---|
1059 | | - struct crypto_tfm *tfm = crypto_ablkcipher_tfm(cipher); |
---|
1060 | | - struct spacc_alg *alg = to_spacc_alg(tfm->__crt_alg); |
---|
| 1050 | + struct crypto_skcipher *cipher = crypto_skcipher_reqtfm(req); |
---|
| 1051 | + struct skcipher_alg *alg = crypto_skcipher_alg(cipher); |
---|
| 1052 | + struct spacc_alg *spacc_alg = to_spacc_skcipher(alg); |
---|
1061 | 1053 | |
---|
1062 | | - return spacc_ablk_setup(req, alg->type, 0); |
---|
| 1054 | + return spacc_ablk_setup(req, spacc_alg->type, 0); |
---|
1063 | 1055 | } |
---|
1064 | 1056 | |
---|
1065 | 1057 | static inline int spacc_fifo_stat_empty(struct spacc_engine *engine) |
---|
.. | .. |
---|
1196 | 1188 | |
---|
1197 | 1189 | static inline struct spacc_engine *spacc_dev_to_engine(struct device *dev) |
---|
1198 | 1190 | { |
---|
1199 | | - return dev ? platform_get_drvdata(to_platform_device(dev)) : NULL; |
---|
| 1191 | + return dev ? dev_get_drvdata(dev) : NULL; |
---|
1200 | 1192 | } |
---|
1201 | 1193 | |
---|
1202 | 1194 | static ssize_t spacc_stat_irq_thresh_show(struct device *dev, |
---|
.. | .. |
---|
1235 | 1227 | .key_offs = 0, |
---|
1236 | 1228 | .iv_offs = AES_MAX_KEY_SIZE, |
---|
1237 | 1229 | .alg = { |
---|
1238 | | - .cra_name = "cbc(aes)", |
---|
1239 | | - .cra_driver_name = "cbc-aes-picoxcell", |
---|
1240 | | - .cra_priority = SPACC_CRYPTO_ALG_PRIORITY, |
---|
1241 | | - .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER | |
---|
1242 | | - CRYPTO_ALG_KERN_DRIVER_ONLY | |
---|
1243 | | - CRYPTO_ALG_ASYNC | |
---|
1244 | | - CRYPTO_ALG_NEED_FALLBACK, |
---|
1245 | | - .cra_blocksize = AES_BLOCK_SIZE, |
---|
1246 | | - .cra_ctxsize = sizeof(struct spacc_ablk_ctx), |
---|
1247 | | - .cra_type = &crypto_ablkcipher_type, |
---|
1248 | | - .cra_module = THIS_MODULE, |
---|
1249 | | - .cra_ablkcipher = { |
---|
1250 | | - .setkey = spacc_aes_setkey, |
---|
1251 | | - .encrypt = spacc_ablk_encrypt, |
---|
1252 | | - .decrypt = spacc_ablk_decrypt, |
---|
1253 | | - .min_keysize = AES_MIN_KEY_SIZE, |
---|
1254 | | - .max_keysize = AES_MAX_KEY_SIZE, |
---|
1255 | | - .ivsize = AES_BLOCK_SIZE, |
---|
1256 | | - }, |
---|
1257 | | - .cra_init = spacc_ablk_cra_init, |
---|
1258 | | - .cra_exit = spacc_ablk_cra_exit, |
---|
| 1230 | + .base.cra_name = "cbc(aes)", |
---|
| 1231 | + .base.cra_driver_name = "cbc-aes-picoxcell", |
---|
| 1232 | + .base.cra_priority = SPACC_CRYPTO_ALG_PRIORITY, |
---|
| 1233 | + .base.cra_flags = CRYPTO_ALG_KERN_DRIVER_ONLY | |
---|
| 1234 | + CRYPTO_ALG_ASYNC | |
---|
| 1235 | + CRYPTO_ALG_ALLOCATES_MEMORY | |
---|
| 1236 | + CRYPTO_ALG_NEED_FALLBACK, |
---|
| 1237 | + .base.cra_blocksize = AES_BLOCK_SIZE, |
---|
| 1238 | + .base.cra_ctxsize = sizeof(struct spacc_ablk_ctx), |
---|
| 1239 | + .base.cra_module = THIS_MODULE, |
---|
| 1240 | + |
---|
| 1241 | + .setkey = spacc_aes_setkey, |
---|
| 1242 | + .encrypt = spacc_ablk_encrypt, |
---|
| 1243 | + .decrypt = spacc_ablk_decrypt, |
---|
| 1244 | + .min_keysize = AES_MIN_KEY_SIZE, |
---|
| 1245 | + .max_keysize = AES_MAX_KEY_SIZE, |
---|
| 1246 | + .ivsize = AES_BLOCK_SIZE, |
---|
| 1247 | + .init = spacc_ablk_init_tfm, |
---|
| 1248 | + .exit = spacc_ablk_exit_tfm, |
---|
1259 | 1249 | }, |
---|
1260 | 1250 | }, |
---|
1261 | 1251 | { |
---|
.. | .. |
---|
1263 | 1253 | .iv_offs = AES_MAX_KEY_SIZE, |
---|
1264 | 1254 | .ctrl_default = SPA_CTRL_CIPH_ALG_AES | SPA_CTRL_CIPH_MODE_ECB, |
---|
1265 | 1255 | .alg = { |
---|
1266 | | - .cra_name = "ecb(aes)", |
---|
1267 | | - .cra_driver_name = "ecb-aes-picoxcell", |
---|
1268 | | - .cra_priority = SPACC_CRYPTO_ALG_PRIORITY, |
---|
1269 | | - .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER | |
---|
1270 | | - CRYPTO_ALG_KERN_DRIVER_ONLY | |
---|
1271 | | - CRYPTO_ALG_ASYNC | CRYPTO_ALG_NEED_FALLBACK, |
---|
1272 | | - .cra_blocksize = AES_BLOCK_SIZE, |
---|
1273 | | - .cra_ctxsize = sizeof(struct spacc_ablk_ctx), |
---|
1274 | | - .cra_type = &crypto_ablkcipher_type, |
---|
1275 | | - .cra_module = THIS_MODULE, |
---|
1276 | | - .cra_ablkcipher = { |
---|
1277 | | - .setkey = spacc_aes_setkey, |
---|
1278 | | - .encrypt = spacc_ablk_encrypt, |
---|
1279 | | - .decrypt = spacc_ablk_decrypt, |
---|
1280 | | - .min_keysize = AES_MIN_KEY_SIZE, |
---|
1281 | | - .max_keysize = AES_MAX_KEY_SIZE, |
---|
1282 | | - }, |
---|
1283 | | - .cra_init = spacc_ablk_cra_init, |
---|
1284 | | - .cra_exit = spacc_ablk_cra_exit, |
---|
| 1256 | + .base.cra_name = "ecb(aes)", |
---|
| 1257 | + .base.cra_driver_name = "ecb-aes-picoxcell", |
---|
| 1258 | + .base.cra_priority = SPACC_CRYPTO_ALG_PRIORITY, |
---|
| 1259 | + .base.cra_flags = CRYPTO_ALG_KERN_DRIVER_ONLY | |
---|
| 1260 | + CRYPTO_ALG_ASYNC | |
---|
| 1261 | + CRYPTO_ALG_ALLOCATES_MEMORY | |
---|
| 1262 | + CRYPTO_ALG_NEED_FALLBACK, |
---|
| 1263 | + .base.cra_blocksize = AES_BLOCK_SIZE, |
---|
| 1264 | + .base.cra_ctxsize = sizeof(struct spacc_ablk_ctx), |
---|
| 1265 | + .base.cra_module = THIS_MODULE, |
---|
| 1266 | + |
---|
| 1267 | + .setkey = spacc_aes_setkey, |
---|
| 1268 | + .encrypt = spacc_ablk_encrypt, |
---|
| 1269 | + .decrypt = spacc_ablk_decrypt, |
---|
| 1270 | + .min_keysize = AES_MIN_KEY_SIZE, |
---|
| 1271 | + .max_keysize = AES_MAX_KEY_SIZE, |
---|
| 1272 | + .init = spacc_ablk_init_tfm, |
---|
| 1273 | + .exit = spacc_ablk_exit_tfm, |
---|
1285 | 1274 | }, |
---|
1286 | 1275 | }, |
---|
1287 | 1276 | { |
---|
.. | .. |
---|
1289 | 1278 | .iv_offs = 0, |
---|
1290 | 1279 | .ctrl_default = SPA_CTRL_CIPH_ALG_DES | SPA_CTRL_CIPH_MODE_CBC, |
---|
1291 | 1280 | .alg = { |
---|
1292 | | - .cra_name = "cbc(des)", |
---|
1293 | | - .cra_driver_name = "cbc-des-picoxcell", |
---|
1294 | | - .cra_priority = SPACC_CRYPTO_ALG_PRIORITY, |
---|
1295 | | - .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER | |
---|
1296 | | - CRYPTO_ALG_ASYNC | |
---|
1297 | | - CRYPTO_ALG_KERN_DRIVER_ONLY, |
---|
1298 | | - .cra_blocksize = DES_BLOCK_SIZE, |
---|
1299 | | - .cra_ctxsize = sizeof(struct spacc_ablk_ctx), |
---|
1300 | | - .cra_type = &crypto_ablkcipher_type, |
---|
1301 | | - .cra_module = THIS_MODULE, |
---|
1302 | | - .cra_ablkcipher = { |
---|
1303 | | - .setkey = spacc_des_setkey, |
---|
1304 | | - .encrypt = spacc_ablk_encrypt, |
---|
1305 | | - .decrypt = spacc_ablk_decrypt, |
---|
1306 | | - .min_keysize = DES_KEY_SIZE, |
---|
1307 | | - .max_keysize = DES_KEY_SIZE, |
---|
1308 | | - .ivsize = DES_BLOCK_SIZE, |
---|
1309 | | - }, |
---|
1310 | | - .cra_init = spacc_ablk_cra_init, |
---|
1311 | | - .cra_exit = spacc_ablk_cra_exit, |
---|
| 1281 | + .base.cra_name = "cbc(des)", |
---|
| 1282 | + .base.cra_driver_name = "cbc-des-picoxcell", |
---|
| 1283 | + .base.cra_priority = SPACC_CRYPTO_ALG_PRIORITY, |
---|
| 1284 | + .base.cra_flags = CRYPTO_ALG_KERN_DRIVER_ONLY | |
---|
| 1285 | + CRYPTO_ALG_ASYNC | |
---|
| 1286 | + CRYPTO_ALG_ALLOCATES_MEMORY, |
---|
| 1287 | + .base.cra_blocksize = DES_BLOCK_SIZE, |
---|
| 1288 | + .base.cra_ctxsize = sizeof(struct spacc_ablk_ctx), |
---|
| 1289 | + .base.cra_module = THIS_MODULE, |
---|
| 1290 | + |
---|
| 1291 | + .setkey = spacc_des_setkey, |
---|
| 1292 | + .encrypt = spacc_ablk_encrypt, |
---|
| 1293 | + .decrypt = spacc_ablk_decrypt, |
---|
| 1294 | + .min_keysize = DES_KEY_SIZE, |
---|
| 1295 | + .max_keysize = DES_KEY_SIZE, |
---|
| 1296 | + .ivsize = DES_BLOCK_SIZE, |
---|
| 1297 | + .init = spacc_ablk_init_tfm, |
---|
| 1298 | + .exit = spacc_ablk_exit_tfm, |
---|
1312 | 1299 | }, |
---|
1313 | 1300 | }, |
---|
1314 | 1301 | { |
---|
.. | .. |
---|
1316 | 1303 | .iv_offs = 0, |
---|
1317 | 1304 | .ctrl_default = SPA_CTRL_CIPH_ALG_DES | SPA_CTRL_CIPH_MODE_ECB, |
---|
1318 | 1305 | .alg = { |
---|
1319 | | - .cra_name = "ecb(des)", |
---|
1320 | | - .cra_driver_name = "ecb-des-picoxcell", |
---|
1321 | | - .cra_priority = SPACC_CRYPTO_ALG_PRIORITY, |
---|
1322 | | - .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER | |
---|
1323 | | - CRYPTO_ALG_ASYNC | |
---|
1324 | | - CRYPTO_ALG_KERN_DRIVER_ONLY, |
---|
1325 | | - .cra_blocksize = DES_BLOCK_SIZE, |
---|
1326 | | - .cra_ctxsize = sizeof(struct spacc_ablk_ctx), |
---|
1327 | | - .cra_type = &crypto_ablkcipher_type, |
---|
1328 | | - .cra_module = THIS_MODULE, |
---|
1329 | | - .cra_ablkcipher = { |
---|
1330 | | - .setkey = spacc_des_setkey, |
---|
1331 | | - .encrypt = spacc_ablk_encrypt, |
---|
1332 | | - .decrypt = spacc_ablk_decrypt, |
---|
1333 | | - .min_keysize = DES_KEY_SIZE, |
---|
1334 | | - .max_keysize = DES_KEY_SIZE, |
---|
1335 | | - }, |
---|
1336 | | - .cra_init = spacc_ablk_cra_init, |
---|
1337 | | - .cra_exit = spacc_ablk_cra_exit, |
---|
| 1306 | + .base.cra_name = "ecb(des)", |
---|
| 1307 | + .base.cra_driver_name = "ecb-des-picoxcell", |
---|
| 1308 | + .base.cra_priority = SPACC_CRYPTO_ALG_PRIORITY, |
---|
| 1309 | + .base.cra_flags = CRYPTO_ALG_KERN_DRIVER_ONLY | |
---|
| 1310 | + CRYPTO_ALG_ASYNC | |
---|
| 1311 | + CRYPTO_ALG_ALLOCATES_MEMORY, |
---|
| 1312 | + .base.cra_blocksize = DES_BLOCK_SIZE, |
---|
| 1313 | + .base.cra_ctxsize = sizeof(struct spacc_ablk_ctx), |
---|
| 1314 | + .base.cra_module = THIS_MODULE, |
---|
| 1315 | + |
---|
| 1316 | + .setkey = spacc_des_setkey, |
---|
| 1317 | + .encrypt = spacc_ablk_encrypt, |
---|
| 1318 | + .decrypt = spacc_ablk_decrypt, |
---|
| 1319 | + .min_keysize = DES_KEY_SIZE, |
---|
| 1320 | + .max_keysize = DES_KEY_SIZE, |
---|
| 1321 | + .init = spacc_ablk_init_tfm, |
---|
| 1322 | + .exit = spacc_ablk_exit_tfm, |
---|
1338 | 1323 | }, |
---|
1339 | 1324 | }, |
---|
1340 | 1325 | { |
---|
.. | .. |
---|
1342 | 1327 | .iv_offs = 0, |
---|
1343 | 1328 | .ctrl_default = SPA_CTRL_CIPH_ALG_DES | SPA_CTRL_CIPH_MODE_CBC, |
---|
1344 | 1329 | .alg = { |
---|
1345 | | - .cra_name = "cbc(des3_ede)", |
---|
1346 | | - .cra_driver_name = "cbc-des3-ede-picoxcell", |
---|
1347 | | - .cra_priority = SPACC_CRYPTO_ALG_PRIORITY, |
---|
1348 | | - .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER | |
---|
1349 | | - CRYPTO_ALG_ASYNC | |
---|
1350 | | - CRYPTO_ALG_KERN_DRIVER_ONLY, |
---|
1351 | | - .cra_blocksize = DES3_EDE_BLOCK_SIZE, |
---|
1352 | | - .cra_ctxsize = sizeof(struct spacc_ablk_ctx), |
---|
1353 | | - .cra_type = &crypto_ablkcipher_type, |
---|
1354 | | - .cra_module = THIS_MODULE, |
---|
1355 | | - .cra_ablkcipher = { |
---|
1356 | | - .setkey = spacc_des_setkey, |
---|
1357 | | - .encrypt = spacc_ablk_encrypt, |
---|
1358 | | - .decrypt = spacc_ablk_decrypt, |
---|
1359 | | - .min_keysize = DES3_EDE_KEY_SIZE, |
---|
1360 | | - .max_keysize = DES3_EDE_KEY_SIZE, |
---|
1361 | | - .ivsize = DES3_EDE_BLOCK_SIZE, |
---|
1362 | | - }, |
---|
1363 | | - .cra_init = spacc_ablk_cra_init, |
---|
1364 | | - .cra_exit = spacc_ablk_cra_exit, |
---|
| 1330 | + .base.cra_name = "cbc(des3_ede)", |
---|
| 1331 | + .base.cra_driver_name = "cbc-des3-ede-picoxcell", |
---|
| 1332 | + .base.cra_priority = SPACC_CRYPTO_ALG_PRIORITY, |
---|
| 1333 | + .base.cra_flags = CRYPTO_ALG_ASYNC | |
---|
| 1334 | + CRYPTO_ALG_ALLOCATES_MEMORY | |
---|
| 1335 | + CRYPTO_ALG_KERN_DRIVER_ONLY, |
---|
| 1336 | + .base.cra_blocksize = DES3_EDE_BLOCK_SIZE, |
---|
| 1337 | + .base.cra_ctxsize = sizeof(struct spacc_ablk_ctx), |
---|
| 1338 | + .base.cra_module = THIS_MODULE, |
---|
| 1339 | + |
---|
| 1340 | + .setkey = spacc_des3_setkey, |
---|
| 1341 | + .encrypt = spacc_ablk_encrypt, |
---|
| 1342 | + .decrypt = spacc_ablk_decrypt, |
---|
| 1343 | + .min_keysize = DES3_EDE_KEY_SIZE, |
---|
| 1344 | + .max_keysize = DES3_EDE_KEY_SIZE, |
---|
| 1345 | + .ivsize = DES3_EDE_BLOCK_SIZE, |
---|
| 1346 | + .init = spacc_ablk_init_tfm, |
---|
| 1347 | + .exit = spacc_ablk_exit_tfm, |
---|
1365 | 1348 | }, |
---|
1366 | 1349 | }, |
---|
1367 | 1350 | { |
---|
.. | .. |
---|
1369 | 1352 | .iv_offs = 0, |
---|
1370 | 1353 | .ctrl_default = SPA_CTRL_CIPH_ALG_DES | SPA_CTRL_CIPH_MODE_ECB, |
---|
1371 | 1354 | .alg = { |
---|
1372 | | - .cra_name = "ecb(des3_ede)", |
---|
1373 | | - .cra_driver_name = "ecb-des3-ede-picoxcell", |
---|
1374 | | - .cra_priority = SPACC_CRYPTO_ALG_PRIORITY, |
---|
1375 | | - .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER | |
---|
1376 | | - CRYPTO_ALG_ASYNC | |
---|
1377 | | - CRYPTO_ALG_KERN_DRIVER_ONLY, |
---|
1378 | | - .cra_blocksize = DES3_EDE_BLOCK_SIZE, |
---|
1379 | | - .cra_ctxsize = sizeof(struct spacc_ablk_ctx), |
---|
1380 | | - .cra_type = &crypto_ablkcipher_type, |
---|
1381 | | - .cra_module = THIS_MODULE, |
---|
1382 | | - .cra_ablkcipher = { |
---|
1383 | | - .setkey = spacc_des_setkey, |
---|
1384 | | - .encrypt = spacc_ablk_encrypt, |
---|
1385 | | - .decrypt = spacc_ablk_decrypt, |
---|
1386 | | - .min_keysize = DES3_EDE_KEY_SIZE, |
---|
1387 | | - .max_keysize = DES3_EDE_KEY_SIZE, |
---|
1388 | | - }, |
---|
1389 | | - .cra_init = spacc_ablk_cra_init, |
---|
1390 | | - .cra_exit = spacc_ablk_cra_exit, |
---|
| 1355 | + .base.cra_name = "ecb(des3_ede)", |
---|
| 1356 | + .base.cra_driver_name = "ecb-des3-ede-picoxcell", |
---|
| 1357 | + .base.cra_priority = SPACC_CRYPTO_ALG_PRIORITY, |
---|
| 1358 | + .base.cra_flags = CRYPTO_ALG_ASYNC | |
---|
| 1359 | + CRYPTO_ALG_ALLOCATES_MEMORY | |
---|
| 1360 | + CRYPTO_ALG_KERN_DRIVER_ONLY, |
---|
| 1361 | + .base.cra_blocksize = DES3_EDE_BLOCK_SIZE, |
---|
| 1362 | + .base.cra_ctxsize = sizeof(struct spacc_ablk_ctx), |
---|
| 1363 | + .base.cra_module = THIS_MODULE, |
---|
| 1364 | + |
---|
| 1365 | + .setkey = spacc_des3_setkey, |
---|
| 1366 | + .encrypt = spacc_ablk_encrypt, |
---|
| 1367 | + .decrypt = spacc_ablk_decrypt, |
---|
| 1368 | + .min_keysize = DES3_EDE_KEY_SIZE, |
---|
| 1369 | + .max_keysize = DES3_EDE_KEY_SIZE, |
---|
| 1370 | + .init = spacc_ablk_init_tfm, |
---|
| 1371 | + .exit = spacc_ablk_exit_tfm, |
---|
1391 | 1372 | }, |
---|
1392 | 1373 | }, |
---|
1393 | 1374 | }; |
---|
.. | .. |
---|
1407 | 1388 | "cbc-aes-picoxcell", |
---|
1408 | 1389 | .cra_priority = SPACC_CRYPTO_ALG_PRIORITY, |
---|
1409 | 1390 | .cra_flags = CRYPTO_ALG_ASYNC | |
---|
| 1391 | + CRYPTO_ALG_ALLOCATES_MEMORY | |
---|
1410 | 1392 | CRYPTO_ALG_NEED_FALLBACK | |
---|
1411 | 1393 | CRYPTO_ALG_KERN_DRIVER_ONLY, |
---|
1412 | 1394 | .cra_blocksize = AES_BLOCK_SIZE, |
---|
.. | .. |
---|
1437 | 1419 | "cbc-aes-picoxcell", |
---|
1438 | 1420 | .cra_priority = SPACC_CRYPTO_ALG_PRIORITY, |
---|
1439 | 1421 | .cra_flags = CRYPTO_ALG_ASYNC | |
---|
| 1422 | + CRYPTO_ALG_ALLOCATES_MEMORY | |
---|
1440 | 1423 | CRYPTO_ALG_NEED_FALLBACK | |
---|
1441 | 1424 | CRYPTO_ALG_KERN_DRIVER_ONLY, |
---|
1442 | 1425 | .cra_blocksize = AES_BLOCK_SIZE, |
---|
.. | .. |
---|
1467 | 1450 | "cbc-aes-picoxcell", |
---|
1468 | 1451 | .cra_priority = SPACC_CRYPTO_ALG_PRIORITY, |
---|
1469 | 1452 | .cra_flags = CRYPTO_ALG_ASYNC | |
---|
| 1453 | + CRYPTO_ALG_ALLOCATES_MEMORY | |
---|
1470 | 1454 | CRYPTO_ALG_NEED_FALLBACK | |
---|
1471 | 1455 | CRYPTO_ALG_KERN_DRIVER_ONLY, |
---|
1472 | 1456 | .cra_blocksize = AES_BLOCK_SIZE, |
---|
.. | .. |
---|
1497 | 1481 | "cbc-3des-picoxcell", |
---|
1498 | 1482 | .cra_priority = SPACC_CRYPTO_ALG_PRIORITY, |
---|
1499 | 1483 | .cra_flags = CRYPTO_ALG_ASYNC | |
---|
| 1484 | + CRYPTO_ALG_ALLOCATES_MEMORY | |
---|
1500 | 1485 | CRYPTO_ALG_NEED_FALLBACK | |
---|
1501 | 1486 | CRYPTO_ALG_KERN_DRIVER_ONLY, |
---|
1502 | 1487 | .cra_blocksize = DES3_EDE_BLOCK_SIZE, |
---|
.. | .. |
---|
1528 | 1513 | "cbc-3des-picoxcell", |
---|
1529 | 1514 | .cra_priority = SPACC_CRYPTO_ALG_PRIORITY, |
---|
1530 | 1515 | .cra_flags = CRYPTO_ALG_ASYNC | |
---|
| 1516 | + CRYPTO_ALG_ALLOCATES_MEMORY | |
---|
1531 | 1517 | CRYPTO_ALG_NEED_FALLBACK | |
---|
1532 | 1518 | CRYPTO_ALG_KERN_DRIVER_ONLY, |
---|
1533 | 1519 | .cra_blocksize = DES3_EDE_BLOCK_SIZE, |
---|
.. | .. |
---|
1558 | 1544 | "cbc-3des-picoxcell", |
---|
1559 | 1545 | .cra_priority = SPACC_CRYPTO_ALG_PRIORITY, |
---|
1560 | 1546 | .cra_flags = CRYPTO_ALG_ASYNC | |
---|
| 1547 | + CRYPTO_ALG_ALLOCATES_MEMORY | |
---|
1561 | 1548 | CRYPTO_ALG_NEED_FALLBACK | |
---|
1562 | 1549 | CRYPTO_ALG_KERN_DRIVER_ONLY, |
---|
1563 | 1550 | .cra_blocksize = DES3_EDE_BLOCK_SIZE, |
---|
.. | .. |
---|
1583 | 1570 | .ctrl_default = SPA_CTRL_CIPH_ALG_KASUMI | |
---|
1584 | 1571 | SPA_CTRL_CIPH_MODE_F8, |
---|
1585 | 1572 | .alg = { |
---|
1586 | | - .cra_name = "f8(kasumi)", |
---|
1587 | | - .cra_driver_name = "f8-kasumi-picoxcell", |
---|
1588 | | - .cra_priority = SPACC_CRYPTO_ALG_PRIORITY, |
---|
1589 | | - .cra_flags = CRYPTO_ALG_TYPE_GIVCIPHER | |
---|
1590 | | - CRYPTO_ALG_ASYNC | |
---|
1591 | | - CRYPTO_ALG_KERN_DRIVER_ONLY, |
---|
1592 | | - .cra_blocksize = 8, |
---|
1593 | | - .cra_ctxsize = sizeof(struct spacc_ablk_ctx), |
---|
1594 | | - .cra_type = &crypto_ablkcipher_type, |
---|
1595 | | - .cra_module = THIS_MODULE, |
---|
1596 | | - .cra_ablkcipher = { |
---|
1597 | | - .setkey = spacc_kasumi_f8_setkey, |
---|
1598 | | - .encrypt = spacc_ablk_encrypt, |
---|
1599 | | - .decrypt = spacc_ablk_decrypt, |
---|
1600 | | - .min_keysize = 16, |
---|
1601 | | - .max_keysize = 16, |
---|
1602 | | - .ivsize = 8, |
---|
1603 | | - }, |
---|
1604 | | - .cra_init = spacc_ablk_cra_init, |
---|
1605 | | - .cra_exit = spacc_ablk_cra_exit, |
---|
| 1573 | + .base.cra_name = "f8(kasumi)", |
---|
| 1574 | + .base.cra_driver_name = "f8-kasumi-picoxcell", |
---|
| 1575 | + .base.cra_priority = SPACC_CRYPTO_ALG_PRIORITY, |
---|
| 1576 | + .base.cra_flags = CRYPTO_ALG_ASYNC | |
---|
| 1577 | + CRYPTO_ALG_ALLOCATES_MEMORY | |
---|
| 1578 | + CRYPTO_ALG_KERN_DRIVER_ONLY, |
---|
| 1579 | + .base.cra_blocksize = 8, |
---|
| 1580 | + .base.cra_ctxsize = sizeof(struct spacc_ablk_ctx), |
---|
| 1581 | + .base.cra_module = THIS_MODULE, |
---|
| 1582 | + |
---|
| 1583 | + .setkey = spacc_kasumi_f8_setkey, |
---|
| 1584 | + .encrypt = spacc_ablk_encrypt, |
---|
| 1585 | + .decrypt = spacc_ablk_decrypt, |
---|
| 1586 | + .min_keysize = 16, |
---|
| 1587 | + .max_keysize = 16, |
---|
| 1588 | + .ivsize = 8, |
---|
| 1589 | + .init = spacc_ablk_init_tfm, |
---|
| 1590 | + .exit = spacc_ablk_exit_tfm, |
---|
1606 | 1591 | }, |
---|
1607 | 1592 | }, |
---|
1608 | 1593 | }; |
---|
.. | .. |
---|
1624 | 1609 | static int spacc_probe(struct platform_device *pdev) |
---|
1625 | 1610 | { |
---|
1626 | 1611 | int i, err, ret; |
---|
1627 | | - struct resource *mem, *irq; |
---|
| 1612 | + struct resource *irq; |
---|
1628 | 1613 | struct device_node *np = pdev->dev.of_node; |
---|
1629 | 1614 | struct spacc_engine *engine = devm_kzalloc(&pdev->dev, sizeof(*engine), |
---|
1630 | 1615 | GFP_KERNEL); |
---|
.. | .. |
---|
1653 | 1638 | |
---|
1654 | 1639 | engine->name = dev_name(&pdev->dev); |
---|
1655 | 1640 | |
---|
1656 | | - mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
---|
1657 | | - engine->regs = devm_ioremap_resource(&pdev->dev, mem); |
---|
| 1641 | + engine->regs = devm_platform_ioremap_resource(pdev, 0); |
---|
1658 | 1642 | if (IS_ERR(engine->regs)) |
---|
1659 | 1643 | return PTR_ERR(engine->regs); |
---|
1660 | 1644 | |
---|
.. | .. |
---|
1735 | 1719 | INIT_LIST_HEAD(&engine->registered_algs); |
---|
1736 | 1720 | for (i = 0; i < engine->num_algs; ++i) { |
---|
1737 | 1721 | engine->algs[i].engine = engine; |
---|
1738 | | - err = crypto_register_alg(&engine->algs[i].alg); |
---|
| 1722 | + err = crypto_register_skcipher(&engine->algs[i].alg); |
---|
1739 | 1723 | if (!err) { |
---|
1740 | 1724 | list_add_tail(&engine->algs[i].entry, |
---|
1741 | 1725 | &engine->registered_algs); |
---|
.. | .. |
---|
1743 | 1727 | } |
---|
1744 | 1728 | if (err) |
---|
1745 | 1729 | dev_err(engine->dev, "failed to register alg \"%s\"\n", |
---|
1746 | | - engine->algs[i].alg.cra_name); |
---|
| 1730 | + engine->algs[i].alg.base.cra_name); |
---|
1747 | 1731 | else |
---|
1748 | 1732 | dev_dbg(engine->dev, "registered alg \"%s\"\n", |
---|
1749 | | - engine->algs[i].alg.cra_name); |
---|
| 1733 | + engine->algs[i].alg.base.cra_name); |
---|
1750 | 1734 | } |
---|
1751 | 1735 | |
---|
1752 | 1736 | INIT_LIST_HEAD(&engine->registered_aeads); |
---|
.. | .. |
---|
1795 | 1779 | |
---|
1796 | 1780 | list_for_each_entry_safe(alg, next, &engine->registered_algs, entry) { |
---|
1797 | 1781 | list_del(&alg->entry); |
---|
1798 | | - crypto_unregister_alg(&alg->alg); |
---|
| 1782 | + crypto_unregister_skcipher(&alg->alg); |
---|
1799 | 1783 | } |
---|
1800 | 1784 | |
---|
1801 | 1785 | clk_disable_unprepare(engine->clk); |
---|