aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/crypto/talitos.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2012-10-04 12:06:34 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2012-10-04 12:06:34 -0400
commitd66e6737d454553e1e62109d8298ede5351178a4 (patch)
treec28b205045935b111527f461d2b114daa26e4fb8 /drivers/crypto/talitos.c
parent612a9aab56a93533e76e3ad91642db7033e03b69 (diff)
parentc9f97a27ceee84998999bf3341e6d5d207b05539 (diff)
Merge git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6
Pull crypto update from Herbert Xu: - Optimised AES/SHA1 for ARM. - IPsec ESN support in talitos and caam. - x86_64/avx implementation of cast5/cast6. - Add/use multi-algorithm registration helpers where possible. - Added IBM Power7+ in-Nest support. - Misc fixes. Fix up trivial conflicts in crypto/Kconfig due to the sparc64 crypto config options being added next to the new ARM ones. [ Side note: cut-and-paste duplicate help texts make those conflicts harder to read than necessary, thanks to git being smart about minimizing conflicts and maximizing the common parts... ] * git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6: (71 commits) crypto: x86/glue_helper - fix storing of new IV in CBC encryption crypto: cast5/avx - fix storing of new IV in CBC encryption crypto: tcrypt - add missing tests for camellia and ghash crypto: testmgr - make test_aead also test 'dst != src' code paths crypto: testmgr - make test_skcipher also test 'dst != src' code paths crypto: testmgr - add test vectors for CTR mode IV increasement crypto: testmgr - add test vectors for partial ctr(cast5) and ctr(cast6) crypto: testmgr - allow non-multi page and multi page skcipher tests from same test template crypto: caam - increase TRNG clocks per sample crypto, tcrypt: remove local_bh_disable/enable() around local_irq_disable/enable() crypto: tegra-aes - fix error return code crypto: crypto4xx - fix error return code crypto: hifn_795x - fix error return code crypto: ux500 - fix error return code crypto: caam - fix error IDs for SEC v5.x RNG4 hwrng: mxc-rnga - Access data via structure hwrng: mxc-rnga - Adapt clocks to new i.mx clock framework crypto: caam - add IPsec ESN support crypto: 842 - remove .cra_list initialization Revert "[CRYPTO] cast6: inline bloat--" ...
Diffstat (limited to 'drivers/crypto/talitos.c')
-rw-r--r--drivers/crypto/talitos.c442
1 files changed, 194 insertions, 248 deletions
diff --git a/drivers/crypto/talitos.c b/drivers/crypto/talitos.c
index efff788d2f1d..da1112765a44 100644
--- a/drivers/crypto/talitos.c
+++ b/drivers/crypto/talitos.c
@@ -38,6 +38,7 @@
38#include <linux/spinlock.h> 38#include <linux/spinlock.h>
39#include <linux/rtnetlink.h> 39#include <linux/rtnetlink.h>
40#include <linux/slab.h> 40#include <linux/slab.h>
41#include <linux/string.h>
41 42
42#include <crypto/algapi.h> 43#include <crypto/algapi.h>
43#include <crypto/aes.h> 44#include <crypto/aes.h>
@@ -714,8 +715,13 @@ badkey:
714 715
715/* 716/*
716 * talitos_edesc - s/w-extended descriptor 717 * talitos_edesc - s/w-extended descriptor
718 * @assoc_nents: number of segments in associated data scatterlist
717 * @src_nents: number of segments in input scatterlist 719 * @src_nents: number of segments in input scatterlist
718 * @dst_nents: number of segments in output scatterlist 720 * @dst_nents: number of segments in output scatterlist
721 * @assoc_chained: whether assoc is chained or not
722 * @src_chained: whether src is chained or not
723 * @dst_chained: whether dst is chained or not
724 * @iv_dma: dma address of iv for checking continuity and link table
719 * @dma_len: length of dma mapped link_tbl space 725 * @dma_len: length of dma mapped link_tbl space
720 * @dma_link_tbl: bus physical address of link_tbl 726 * @dma_link_tbl: bus physical address of link_tbl
721 * @desc: h/w descriptor 727 * @desc: h/w descriptor
@@ -726,10 +732,13 @@ badkey:
726 * of link_tbl data 732 * of link_tbl data
727 */ 733 */
728struct talitos_edesc { 734struct talitos_edesc {
735 int assoc_nents;
729 int src_nents; 736 int src_nents;
730 int dst_nents; 737 int dst_nents;
731 int src_is_chained; 738 bool assoc_chained;
732 int dst_is_chained; 739 bool src_chained;
740 bool dst_chained;
741 dma_addr_t iv_dma;
733 int dma_len; 742 int dma_len;
734 dma_addr_t dma_link_tbl; 743 dma_addr_t dma_link_tbl;
735 struct talitos_desc desc; 744 struct talitos_desc desc;
@@ -738,7 +747,7 @@ struct talitos_edesc {
738 747
739static int talitos_map_sg(struct device *dev, struct scatterlist *sg, 748static int talitos_map_sg(struct device *dev, struct scatterlist *sg,
740 unsigned int nents, enum dma_data_direction dir, 749 unsigned int nents, enum dma_data_direction dir,
741 int chained) 750 bool chained)
742{ 751{
743 if (unlikely(chained)) 752 if (unlikely(chained))
744 while (sg) { 753 while (sg) {
@@ -768,13 +777,13 @@ static void talitos_sg_unmap(struct device *dev,
768 unsigned int dst_nents = edesc->dst_nents ? : 1; 777 unsigned int dst_nents = edesc->dst_nents ? : 1;
769 778
770 if (src != dst) { 779 if (src != dst) {
771 if (edesc->src_is_chained) 780 if (edesc->src_chained)
772 talitos_unmap_sg_chain(dev, src, DMA_TO_DEVICE); 781 talitos_unmap_sg_chain(dev, src, DMA_TO_DEVICE);
773 else 782 else
774 dma_unmap_sg(dev, src, src_nents, DMA_TO_DEVICE); 783 dma_unmap_sg(dev, src, src_nents, DMA_TO_DEVICE);
775 784
776 if (dst) { 785 if (dst) {
777 if (edesc->dst_is_chained) 786 if (edesc->dst_chained)
778 talitos_unmap_sg_chain(dev, dst, 787 talitos_unmap_sg_chain(dev, dst,
779 DMA_FROM_DEVICE); 788 DMA_FROM_DEVICE);
780 else 789 else
@@ -782,7 +791,7 @@ static void talitos_sg_unmap(struct device *dev,
782 DMA_FROM_DEVICE); 791 DMA_FROM_DEVICE);
783 } 792 }
784 } else 793 } else
785 if (edesc->src_is_chained) 794 if (edesc->src_chained)
786 talitos_unmap_sg_chain(dev, src, DMA_BIDIRECTIONAL); 795 talitos_unmap_sg_chain(dev, src, DMA_BIDIRECTIONAL);
787 else 796 else
788 dma_unmap_sg(dev, src, src_nents, DMA_BIDIRECTIONAL); 797 dma_unmap_sg(dev, src, src_nents, DMA_BIDIRECTIONAL);
@@ -797,7 +806,13 @@ static void ipsec_esp_unmap(struct device *dev,
797 unmap_single_talitos_ptr(dev, &edesc->desc.ptr[2], DMA_TO_DEVICE); 806 unmap_single_talitos_ptr(dev, &edesc->desc.ptr[2], DMA_TO_DEVICE);
798 unmap_single_talitos_ptr(dev, &edesc->desc.ptr[0], DMA_TO_DEVICE); 807 unmap_single_talitos_ptr(dev, &edesc->desc.ptr[0], DMA_TO_DEVICE);
799 808
800 dma_unmap_sg(dev, areq->assoc, 1, DMA_TO_DEVICE); 809 if (edesc->assoc_chained)
810 talitos_unmap_sg_chain(dev, areq->assoc, DMA_TO_DEVICE);
811 else
812 /* assoc_nents counts also for IV in non-contiguous cases */
813 dma_unmap_sg(dev, areq->assoc,
814 edesc->assoc_nents ? edesc->assoc_nents - 1 : 1,
815 DMA_TO_DEVICE);
801 816
802 talitos_sg_unmap(dev, edesc, areq->src, areq->dst); 817 talitos_sg_unmap(dev, edesc, areq->src, areq->dst);
803 818
@@ -825,9 +840,10 @@ static void ipsec_esp_encrypt_done(struct device *dev,
825 ipsec_esp_unmap(dev, edesc, areq); 840 ipsec_esp_unmap(dev, edesc, areq);
826 841
827 /* copy the generated ICV to dst */ 842 /* copy the generated ICV to dst */
828 if (edesc->dma_len) { 843 if (edesc->dst_nents) {
829 icvdata = &edesc->link_tbl[edesc->src_nents + 844 icvdata = &edesc->link_tbl[edesc->src_nents +
830 edesc->dst_nents + 2]; 845 edesc->dst_nents + 2 +
846 edesc->assoc_nents];
831 sg = sg_last(areq->dst, edesc->dst_nents); 847 sg = sg_last(areq->dst, edesc->dst_nents);
832 memcpy((char *)sg_virt(sg) + sg->length - ctx->authsize, 848 memcpy((char *)sg_virt(sg) + sg->length - ctx->authsize,
833 icvdata, ctx->authsize); 849 icvdata, ctx->authsize);
@@ -857,7 +873,8 @@ static void ipsec_esp_decrypt_swauth_done(struct device *dev,
857 /* auth check */ 873 /* auth check */
858 if (edesc->dma_len) 874 if (edesc->dma_len)
859 icvdata = &edesc->link_tbl[edesc->src_nents + 875 icvdata = &edesc->link_tbl[edesc->src_nents +
860 edesc->dst_nents + 2]; 876 edesc->dst_nents + 2 +
877 edesc->assoc_nents];
861 else 878 else
862 icvdata = &edesc->link_tbl[0]; 879 icvdata = &edesc->link_tbl[0];
863 880
@@ -932,10 +949,9 @@ static int sg_to_link_tbl(struct scatterlist *sg, int sg_count,
932 * fill in and submit ipsec_esp descriptor 949 * fill in and submit ipsec_esp descriptor
933 */ 950 */
934static int ipsec_esp(struct talitos_edesc *edesc, struct aead_request *areq, 951static int ipsec_esp(struct talitos_edesc *edesc, struct aead_request *areq,
935 u8 *giv, u64 seq, 952 u64 seq, void (*callback) (struct device *dev,
936 void (*callback) (struct device *dev, 953 struct talitos_desc *desc,
937 struct talitos_desc *desc, 954 void *context, int error))
938 void *context, int error))
939{ 955{
940 struct crypto_aead *aead = crypto_aead_reqtfm(areq); 956 struct crypto_aead *aead = crypto_aead_reqtfm(areq);
941 struct talitos_ctx *ctx = crypto_aead_ctx(aead); 957 struct talitos_ctx *ctx = crypto_aead_ctx(aead);
@@ -950,12 +966,42 @@ static int ipsec_esp(struct talitos_edesc *edesc, struct aead_request *areq,
950 /* hmac key */ 966 /* hmac key */
951 map_single_talitos_ptr(dev, &desc->ptr[0], ctx->authkeylen, &ctx->key, 967 map_single_talitos_ptr(dev, &desc->ptr[0], ctx->authkeylen, &ctx->key,
952 0, DMA_TO_DEVICE); 968 0, DMA_TO_DEVICE);
969
953 /* hmac data */ 970 /* hmac data */
954 map_single_talitos_ptr(dev, &desc->ptr[1], areq->assoclen + ivsize, 971 desc->ptr[1].len = cpu_to_be16(areq->assoclen + ivsize);
955 sg_virt(areq->assoc), 0, DMA_TO_DEVICE); 972 if (edesc->assoc_nents) {
973 int tbl_off = edesc->src_nents + edesc->dst_nents + 2;
974 struct talitos_ptr *tbl_ptr = &edesc->link_tbl[tbl_off];
975
976 to_talitos_ptr(&desc->ptr[1], edesc->dma_link_tbl + tbl_off *
977 sizeof(struct talitos_ptr));
978 desc->ptr[1].j_extent = DESC_PTR_LNKTBL_JUMP;
979
980 /* assoc_nents - 1 entries for assoc, 1 for IV */
981 sg_count = sg_to_link_tbl(areq->assoc, edesc->assoc_nents - 1,
982 areq->assoclen, tbl_ptr);
983
984 /* add IV to link table */
985 tbl_ptr += sg_count - 1;
986 tbl_ptr->j_extent = 0;
987 tbl_ptr++;
988 to_talitos_ptr(tbl_ptr, edesc->iv_dma);
989 tbl_ptr->len = cpu_to_be16(ivsize);
990 tbl_ptr->j_extent = DESC_PTR_LNKTBL_RETURN;
991
992 dma_sync_single_for_device(dev, edesc->dma_link_tbl,
993 edesc->dma_len, DMA_BIDIRECTIONAL);
994 } else {
995 to_talitos_ptr(&desc->ptr[1], sg_dma_address(areq->assoc));
996 desc->ptr[1].j_extent = 0;
997 }
998
956 /* cipher iv */ 999 /* cipher iv */
957 map_single_talitos_ptr(dev, &desc->ptr[2], ivsize, giv ?: areq->iv, 0, 1000 to_talitos_ptr(&desc->ptr[2], edesc->iv_dma);
958 DMA_TO_DEVICE); 1001 desc->ptr[2].len = cpu_to_be16(ivsize);
1002 desc->ptr[2].j_extent = 0;
1003 /* Sync needed for the aead_givencrypt case */
1004 dma_sync_single_for_device(dev, edesc->iv_dma, ivsize, DMA_TO_DEVICE);
959 1005
960 /* cipher key */ 1006 /* cipher key */
961 map_single_talitos_ptr(dev, &desc->ptr[3], ctx->enckeylen, 1007 map_single_talitos_ptr(dev, &desc->ptr[3], ctx->enckeylen,
@@ -974,7 +1020,7 @@ static int ipsec_esp(struct talitos_edesc *edesc, struct aead_request *areq,
974 sg_count = talitos_map_sg(dev, areq->src, edesc->src_nents ? : 1, 1020 sg_count = talitos_map_sg(dev, areq->src, edesc->src_nents ? : 1,
975 (areq->src == areq->dst) ? DMA_BIDIRECTIONAL 1021 (areq->src == areq->dst) ? DMA_BIDIRECTIONAL
976 : DMA_TO_DEVICE, 1022 : DMA_TO_DEVICE,
977 edesc->src_is_chained); 1023 edesc->src_chained);
978 1024
979 if (sg_count == 1) { 1025 if (sg_count == 1) {
980 to_talitos_ptr(&desc->ptr[4], sg_dma_address(areq->src)); 1026 to_talitos_ptr(&desc->ptr[4], sg_dma_address(areq->src));
@@ -1006,32 +1052,30 @@ static int ipsec_esp(struct talitos_edesc *edesc, struct aead_request *areq,
1006 if (areq->src != areq->dst) 1052 if (areq->src != areq->dst)
1007 sg_count = talitos_map_sg(dev, areq->dst, 1053 sg_count = talitos_map_sg(dev, areq->dst,
1008 edesc->dst_nents ? : 1, 1054 edesc->dst_nents ? : 1,
1009 DMA_FROM_DEVICE, 1055 DMA_FROM_DEVICE, edesc->dst_chained);
1010 edesc->dst_is_chained);
1011 1056
1012 if (sg_count == 1) { 1057 if (sg_count == 1) {
1013 to_talitos_ptr(&desc->ptr[5], sg_dma_address(areq->dst)); 1058 to_talitos_ptr(&desc->ptr[5], sg_dma_address(areq->dst));
1014 } else { 1059 } else {
1015 struct talitos_ptr *link_tbl_ptr = 1060 int tbl_off = edesc->src_nents + 1;
1016 &edesc->link_tbl[edesc->src_nents + 1]; 1061 struct talitos_ptr *tbl_ptr = &edesc->link_tbl[tbl_off];
1017 1062
1018 to_talitos_ptr(&desc->ptr[5], edesc->dma_link_tbl + 1063 to_talitos_ptr(&desc->ptr[5], edesc->dma_link_tbl +
1019 (edesc->src_nents + 1) * 1064 tbl_off * sizeof(struct talitos_ptr));
1020 sizeof(struct talitos_ptr));
1021 sg_count = sg_to_link_tbl(areq->dst, sg_count, cryptlen, 1065 sg_count = sg_to_link_tbl(areq->dst, sg_count, cryptlen,
1022 link_tbl_ptr); 1066 tbl_ptr);
1023 1067
1024 /* Add an entry to the link table for ICV data */ 1068 /* Add an entry to the link table for ICV data */
1025 link_tbl_ptr += sg_count - 1; 1069 tbl_ptr += sg_count - 1;
1026 link_tbl_ptr->j_extent = 0; 1070 tbl_ptr->j_extent = 0;
1027 sg_count++; 1071 tbl_ptr++;
1028 link_tbl_ptr++; 1072 tbl_ptr->j_extent = DESC_PTR_LNKTBL_RETURN;
1029 link_tbl_ptr->j_extent = DESC_PTR_LNKTBL_RETURN; 1073 tbl_ptr->len = cpu_to_be16(authsize);
1030 link_tbl_ptr->len = cpu_to_be16(authsize);
1031 1074
1032 /* icv data follows link tables */ 1075 /* icv data follows link tables */
1033 to_talitos_ptr(link_tbl_ptr, edesc->dma_link_tbl + 1076 to_talitos_ptr(tbl_ptr, edesc->dma_link_tbl +
1034 (edesc->src_nents + edesc->dst_nents + 2) * 1077 (tbl_off + edesc->dst_nents + 1 +
1078 edesc->assoc_nents) *
1035 sizeof(struct talitos_ptr)); 1079 sizeof(struct talitos_ptr));
1036 desc->ptr[5].j_extent |= DESC_PTR_LNKTBL_JUMP; 1080 desc->ptr[5].j_extent |= DESC_PTR_LNKTBL_JUMP;
1037 dma_sync_single_for_device(ctx->dev, edesc->dma_link_tbl, 1081 dma_sync_single_for_device(ctx->dev, edesc->dma_link_tbl,
@@ -1053,17 +1097,17 @@ static int ipsec_esp(struct talitos_edesc *edesc, struct aead_request *areq,
1053/* 1097/*
1054 * derive number of elements in scatterlist 1098 * derive number of elements in scatterlist
1055 */ 1099 */
1056static int sg_count(struct scatterlist *sg_list, int nbytes, int *chained) 1100static int sg_count(struct scatterlist *sg_list, int nbytes, bool *chained)
1057{ 1101{
1058 struct scatterlist *sg = sg_list; 1102 struct scatterlist *sg = sg_list;
1059 int sg_nents = 0; 1103 int sg_nents = 0;
1060 1104
1061 *chained = 0; 1105 *chained = false;
1062 while (nbytes > 0) { 1106 while (nbytes > 0) {
1063 sg_nents++; 1107 sg_nents++;
1064 nbytes -= sg->length; 1108 nbytes -= sg->length;
1065 if (!sg_is_last(sg) && (sg + 1)->length == 0) 1109 if (!sg_is_last(sg) && (sg + 1)->length == 0)
1066 *chained = 1; 1110 *chained = true;
1067 sg = scatterwalk_sg_next(sg); 1111 sg = scatterwalk_sg_next(sg);
1068 } 1112 }
1069 1113
@@ -1132,17 +1176,21 @@ static size_t sg_copy_end_to_buffer(struct scatterlist *sgl, unsigned int nents,
1132 * allocate and map the extended descriptor 1176 * allocate and map the extended descriptor
1133 */ 1177 */
1134static struct talitos_edesc *talitos_edesc_alloc(struct device *dev, 1178static struct talitos_edesc *talitos_edesc_alloc(struct device *dev,
1179 struct scatterlist *assoc,
1135 struct scatterlist *src, 1180 struct scatterlist *src,
1136 struct scatterlist *dst, 1181 struct scatterlist *dst,
1137 int hash_result, 1182 u8 *iv,
1183 unsigned int assoclen,
1138 unsigned int cryptlen, 1184 unsigned int cryptlen,
1139 unsigned int authsize, 1185 unsigned int authsize,
1186 unsigned int ivsize,
1140 int icv_stashing, 1187 int icv_stashing,
1141 u32 cryptoflags) 1188 u32 cryptoflags)
1142{ 1189{
1143 struct talitos_edesc *edesc; 1190 struct talitos_edesc *edesc;
1144 int src_nents, dst_nents, alloc_len, dma_len; 1191 int assoc_nents = 0, src_nents, dst_nents, alloc_len, dma_len;
1145 int src_chained, dst_chained = 0; 1192 bool assoc_chained = false, src_chained = false, dst_chained = false;
1193 dma_addr_t iv_dma = 0;
1146 gfp_t flags = cryptoflags & CRYPTO_TFM_REQ_MAY_SLEEP ? GFP_KERNEL : 1194 gfp_t flags = cryptoflags & CRYPTO_TFM_REQ_MAY_SLEEP ? GFP_KERNEL :
1147 GFP_ATOMIC; 1195 GFP_ATOMIC;
1148 1196
@@ -1151,10 +1199,29 @@ static struct talitos_edesc *talitos_edesc_alloc(struct device *dev,
1151 return ERR_PTR(-EINVAL); 1199 return ERR_PTR(-EINVAL);
1152 } 1200 }
1153 1201
1202 if (iv)
1203 iv_dma = dma_map_single(dev, iv, ivsize, DMA_TO_DEVICE);
1204
1205 if (assoc) {
1206 /*
1207 * Currently it is assumed that iv is provided whenever assoc
1208 * is.
1209 */
1210 BUG_ON(!iv);
1211
1212 assoc_nents = sg_count(assoc, assoclen, &assoc_chained);
1213 talitos_map_sg(dev, assoc, assoc_nents, DMA_TO_DEVICE,
1214 assoc_chained);
1215 assoc_nents = (assoc_nents == 1) ? 0 : assoc_nents;
1216
1217 if (assoc_nents || sg_dma_address(assoc) + assoclen != iv_dma)
1218 assoc_nents = assoc_nents ? assoc_nents + 1 : 2;
1219 }
1220
1154 src_nents = sg_count(src, cryptlen + authsize, &src_chained); 1221 src_nents = sg_count(src, cryptlen + authsize, &src_chained);
1155 src_nents = (src_nents == 1) ? 0 : src_nents; 1222 src_nents = (src_nents == 1) ? 0 : src_nents;
1156 1223
1157 if (hash_result) { 1224 if (!dst) {
1158 dst_nents = 0; 1225 dst_nents = 0;
1159 } else { 1226 } else {
1160 if (dst == src) { 1227 if (dst == src) {
@@ -1172,9 +1239,9 @@ static struct talitos_edesc *talitos_edesc_alloc(struct device *dev,
1172 * and the ICV data itself 1239 * and the ICV data itself
1173 */ 1240 */
1174 alloc_len = sizeof(struct talitos_edesc); 1241 alloc_len = sizeof(struct talitos_edesc);
1175 if (src_nents || dst_nents) { 1242 if (assoc_nents || src_nents || dst_nents) {
1176 dma_len = (src_nents + dst_nents + 2) * 1243 dma_len = (src_nents + dst_nents + 2 + assoc_nents) *
1177 sizeof(struct talitos_ptr) + authsize; 1244 sizeof(struct talitos_ptr) + authsize;
1178 alloc_len += dma_len; 1245 alloc_len += dma_len;
1179 } else { 1246 } else {
1180 dma_len = 0; 1247 dma_len = 0;
@@ -1183,14 +1250,20 @@ static struct talitos_edesc *talitos_edesc_alloc(struct device *dev,
1183 1250
1184 edesc = kmalloc(alloc_len, GFP_DMA | flags); 1251 edesc = kmalloc(alloc_len, GFP_DMA | flags);
1185 if (!edesc) { 1252 if (!edesc) {
1253 talitos_unmap_sg_chain(dev, assoc, DMA_TO_DEVICE);
1254 if (iv_dma)
1255 dma_unmap_single(dev, iv_dma, ivsize, DMA_TO_DEVICE);
1186 dev_err(dev, "could not allocate edescriptor\n"); 1256 dev_err(dev, "could not allocate edescriptor\n");
1187 return ERR_PTR(-ENOMEM); 1257 return ERR_PTR(-ENOMEM);
1188 } 1258 }
1189 1259
1260 edesc->assoc_nents = assoc_nents;
1190 edesc->src_nents = src_nents; 1261 edesc->src_nents = src_nents;
1191 edesc->dst_nents = dst_nents; 1262 edesc->dst_nents = dst_nents;
1192 edesc->src_is_chained = src_chained; 1263 edesc->assoc_chained = assoc_chained;
1193 edesc->dst_is_chained = dst_chained; 1264 edesc->src_chained = src_chained;
1265 edesc->dst_chained = dst_chained;
1266 edesc->iv_dma = iv_dma;
1194 edesc->dma_len = dma_len; 1267 edesc->dma_len = dma_len;
1195 if (dma_len) 1268 if (dma_len)
1196 edesc->dma_link_tbl = dma_map_single(dev, &edesc->link_tbl[0], 1269 edesc->dma_link_tbl = dma_map_single(dev, &edesc->link_tbl[0],
@@ -1200,14 +1273,16 @@ static struct talitos_edesc *talitos_edesc_alloc(struct device *dev,
1200 return edesc; 1273 return edesc;
1201} 1274}
1202 1275
1203static struct talitos_edesc *aead_edesc_alloc(struct aead_request *areq, 1276static struct talitos_edesc *aead_edesc_alloc(struct aead_request *areq, u8 *iv,
1204 int icv_stashing) 1277 int icv_stashing)
1205{ 1278{
1206 struct crypto_aead *authenc = crypto_aead_reqtfm(areq); 1279 struct crypto_aead *authenc = crypto_aead_reqtfm(areq);
1207 struct talitos_ctx *ctx = crypto_aead_ctx(authenc); 1280 struct talitos_ctx *ctx = crypto_aead_ctx(authenc);
1281 unsigned int ivsize = crypto_aead_ivsize(authenc);
1208 1282
1209 return talitos_edesc_alloc(ctx->dev, areq->src, areq->dst, 0, 1283 return talitos_edesc_alloc(ctx->dev, areq->assoc, areq->src, areq->dst,
1210 areq->cryptlen, ctx->authsize, icv_stashing, 1284 iv, areq->assoclen, areq->cryptlen,
1285 ctx->authsize, ivsize, icv_stashing,
1211 areq->base.flags); 1286 areq->base.flags);
1212} 1287}
1213 1288
@@ -1218,14 +1293,14 @@ static int aead_encrypt(struct aead_request *req)
1218 struct talitos_edesc *edesc; 1293 struct talitos_edesc *edesc;
1219 1294
1220 /* allocate extended descriptor */ 1295 /* allocate extended descriptor */
1221 edesc = aead_edesc_alloc(req, 0); 1296 edesc = aead_edesc_alloc(req, req->iv, 0);
1222 if (IS_ERR(edesc)) 1297 if (IS_ERR(edesc))
1223 return PTR_ERR(edesc); 1298 return PTR_ERR(edesc);
1224 1299
1225 /* set encrypt */ 1300 /* set encrypt */
1226 edesc->desc.hdr = ctx->desc_hdr_template | DESC_HDR_MODE0_ENCRYPT; 1301 edesc->desc.hdr = ctx->desc_hdr_template | DESC_HDR_MODE0_ENCRYPT;
1227 1302
1228 return ipsec_esp(edesc, req, NULL, 0, ipsec_esp_encrypt_done); 1303 return ipsec_esp(edesc, req, 0, ipsec_esp_encrypt_done);
1229} 1304}
1230 1305
1231static int aead_decrypt(struct aead_request *req) 1306static int aead_decrypt(struct aead_request *req)
@@ -1241,7 +1316,7 @@ static int aead_decrypt(struct aead_request *req)
1241 req->cryptlen -= authsize; 1316 req->cryptlen -= authsize;
1242 1317
1243 /* allocate extended descriptor */ 1318 /* allocate extended descriptor */
1244 edesc = aead_edesc_alloc(req, 1); 1319 edesc = aead_edesc_alloc(req, req->iv, 1);
1245 if (IS_ERR(edesc)) 1320 if (IS_ERR(edesc))
1246 return PTR_ERR(edesc); 1321 return PTR_ERR(edesc);
1247 1322
@@ -1257,9 +1332,7 @@ static int aead_decrypt(struct aead_request *req)
1257 /* reset integrity check result bits */ 1332 /* reset integrity check result bits */
1258 edesc->desc.hdr_lo = 0; 1333 edesc->desc.hdr_lo = 0;
1259 1334
1260 return ipsec_esp(edesc, req, NULL, 0, 1335 return ipsec_esp(edesc, req, 0, ipsec_esp_decrypt_hwauth_done);
1261 ipsec_esp_decrypt_hwauth_done);
1262
1263 } 1336 }
1264 1337
1265 /* Have to check the ICV with software */ 1338 /* Have to check the ICV with software */
@@ -1268,7 +1341,8 @@ static int aead_decrypt(struct aead_request *req)
1268 /* stash incoming ICV for later cmp with ICV generated by the h/w */ 1341 /* stash incoming ICV for later cmp with ICV generated by the h/w */
1269 if (edesc->dma_len) 1342 if (edesc->dma_len)
1270 icvdata = &edesc->link_tbl[edesc->src_nents + 1343 icvdata = &edesc->link_tbl[edesc->src_nents +
1271 edesc->dst_nents + 2]; 1344 edesc->dst_nents + 2 +
1345 edesc->assoc_nents];
1272 else 1346 else
1273 icvdata = &edesc->link_tbl[0]; 1347 icvdata = &edesc->link_tbl[0];
1274 1348
@@ -1277,7 +1351,7 @@ static int aead_decrypt(struct aead_request *req)
1277 memcpy(icvdata, (char *)sg_virt(sg) + sg->length - ctx->authsize, 1351 memcpy(icvdata, (char *)sg_virt(sg) + sg->length - ctx->authsize,
1278 ctx->authsize); 1352 ctx->authsize);
1279 1353
1280 return ipsec_esp(edesc, req, NULL, 0, ipsec_esp_decrypt_swauth_done); 1354 return ipsec_esp(edesc, req, 0, ipsec_esp_decrypt_swauth_done);
1281} 1355}
1282 1356
1283static int aead_givencrypt(struct aead_givcrypt_request *req) 1357static int aead_givencrypt(struct aead_givcrypt_request *req)
@@ -1288,7 +1362,7 @@ static int aead_givencrypt(struct aead_givcrypt_request *req)
1288 struct talitos_edesc *edesc; 1362 struct talitos_edesc *edesc;
1289 1363
1290 /* allocate extended descriptor */ 1364 /* allocate extended descriptor */
1291 edesc = aead_edesc_alloc(areq, 0); 1365 edesc = aead_edesc_alloc(areq, req->giv, 0);
1292 if (IS_ERR(edesc)) 1366 if (IS_ERR(edesc))
1293 return PTR_ERR(edesc); 1367 return PTR_ERR(edesc);
1294 1368
@@ -1299,8 +1373,7 @@ static int aead_givencrypt(struct aead_givcrypt_request *req)
1299 /* avoid consecutive packets going out with same IV */ 1373 /* avoid consecutive packets going out with same IV */
1300 *(__be64 *)req->giv ^= cpu_to_be64(req->seq); 1374 *(__be64 *)req->giv ^= cpu_to_be64(req->seq);
1301 1375
1302 return ipsec_esp(edesc, areq, req->giv, req->seq, 1376 return ipsec_esp(edesc, areq, req->seq, ipsec_esp_encrypt_done);
1303 ipsec_esp_encrypt_done);
1304} 1377}
1305 1378
1306static int ablkcipher_setkey(struct crypto_ablkcipher *cipher, 1379static int ablkcipher_setkey(struct crypto_ablkcipher *cipher,
@@ -1356,7 +1429,7 @@ static int common_nonsnoop(struct talitos_edesc *edesc,
1356 struct device *dev = ctx->dev; 1429 struct device *dev = ctx->dev;
1357 struct talitos_desc *desc = &edesc->desc; 1430 struct talitos_desc *desc = &edesc->desc;
1358 unsigned int cryptlen = areq->nbytes; 1431 unsigned int cryptlen = areq->nbytes;
1359 unsigned int ivsize; 1432 unsigned int ivsize = crypto_ablkcipher_ivsize(cipher);
1360 int sg_count, ret; 1433 int sg_count, ret;
1361 1434
1362 /* first DWORD empty */ 1435 /* first DWORD empty */
@@ -1365,9 +1438,9 @@ static int common_nonsnoop(struct talitos_edesc *edesc,
1365 desc->ptr[0].j_extent = 0; 1438 desc->ptr[0].j_extent = 0;
1366 1439
1367 /* cipher iv */ 1440 /* cipher iv */
1368 ivsize = crypto_ablkcipher_ivsize(cipher); 1441 to_talitos_ptr(&desc->ptr[1], edesc->iv_dma);
1369 map_single_talitos_ptr(dev, &desc->ptr[1], ivsize, areq->info, 0, 1442 desc->ptr[1].len = cpu_to_be16(ivsize);
1370 DMA_TO_DEVICE); 1443 desc->ptr[1].j_extent = 0;
1371 1444
1372 /* cipher key */ 1445 /* cipher key */
1373 map_single_talitos_ptr(dev, &desc->ptr[2], ctx->keylen, 1446 map_single_talitos_ptr(dev, &desc->ptr[2], ctx->keylen,
@@ -1382,7 +1455,7 @@ static int common_nonsnoop(struct talitos_edesc *edesc,
1382 sg_count = talitos_map_sg(dev, areq->src, edesc->src_nents ? : 1, 1455 sg_count = talitos_map_sg(dev, areq->src, edesc->src_nents ? : 1,
1383 (areq->src == areq->dst) ? DMA_BIDIRECTIONAL 1456 (areq->src == areq->dst) ? DMA_BIDIRECTIONAL
1384 : DMA_TO_DEVICE, 1457 : DMA_TO_DEVICE,
1385 edesc->src_is_chained); 1458 edesc->src_chained);
1386 1459
1387 if (sg_count == 1) { 1460 if (sg_count == 1) {
1388 to_talitos_ptr(&desc->ptr[3], sg_dma_address(areq->src)); 1461 to_talitos_ptr(&desc->ptr[3], sg_dma_address(areq->src));
@@ -1409,8 +1482,7 @@ static int common_nonsnoop(struct talitos_edesc *edesc,
1409 if (areq->src != areq->dst) 1482 if (areq->src != areq->dst)
1410 sg_count = talitos_map_sg(dev, areq->dst, 1483 sg_count = talitos_map_sg(dev, areq->dst,
1411 edesc->dst_nents ? : 1, 1484 edesc->dst_nents ? : 1,
1412 DMA_FROM_DEVICE, 1485 DMA_FROM_DEVICE, edesc->dst_chained);
1413 edesc->dst_is_chained);
1414 1486
1415 if (sg_count == 1) { 1487 if (sg_count == 1) {
1416 to_talitos_ptr(&desc->ptr[4], sg_dma_address(areq->dst)); 1488 to_talitos_ptr(&desc->ptr[4], sg_dma_address(areq->dst));
@@ -1450,9 +1522,11 @@ static struct talitos_edesc *ablkcipher_edesc_alloc(struct ablkcipher_request *
1450{ 1522{
1451 struct crypto_ablkcipher *cipher = crypto_ablkcipher_reqtfm(areq); 1523 struct crypto_ablkcipher *cipher = crypto_ablkcipher_reqtfm(areq);
1452 struct talitos_ctx *ctx = crypto_ablkcipher_ctx(cipher); 1524 struct talitos_ctx *ctx = crypto_ablkcipher_ctx(cipher);
1525 unsigned int ivsize = crypto_ablkcipher_ivsize(cipher);
1453 1526
1454 return talitos_edesc_alloc(ctx->dev, areq->src, areq->dst, 0, 1527 return talitos_edesc_alloc(ctx->dev, NULL, areq->src, areq->dst,
1455 areq->nbytes, 0, 0, areq->base.flags); 1528 areq->info, 0, areq->nbytes, 0, ivsize, 0,
1529 areq->base.flags);
1456} 1530}
1457 1531
1458static int ablkcipher_encrypt(struct ablkcipher_request *areq) 1532static int ablkcipher_encrypt(struct ablkcipher_request *areq)
@@ -1578,8 +1652,7 @@ static int common_nonsnoop_hash(struct talitos_edesc *edesc,
1578 1652
1579 sg_count = talitos_map_sg(dev, req_ctx->psrc, 1653 sg_count = talitos_map_sg(dev, req_ctx->psrc,
1580 edesc->src_nents ? : 1, 1654 edesc->src_nents ? : 1,
1581 DMA_TO_DEVICE, 1655 DMA_TO_DEVICE, edesc->src_chained);
1582 edesc->src_is_chained);
1583 1656
1584 if (sg_count == 1) { 1657 if (sg_count == 1) {
1585 to_talitos_ptr(&desc->ptr[3], sg_dma_address(req_ctx->psrc)); 1658 to_talitos_ptr(&desc->ptr[3], sg_dma_address(req_ctx->psrc));
@@ -1631,8 +1704,8 @@ static struct talitos_edesc *ahash_edesc_alloc(struct ahash_request *areq,
1631 struct talitos_ctx *ctx = crypto_ahash_ctx(tfm); 1704 struct talitos_ctx *ctx = crypto_ahash_ctx(tfm);
1632 struct talitos_ahash_req_ctx *req_ctx = ahash_request_ctx(areq); 1705 struct talitos_ahash_req_ctx *req_ctx = ahash_request_ctx(areq);
1633 1706
1634 return talitos_edesc_alloc(ctx->dev, req_ctx->psrc, NULL, 1, 1707 return talitos_edesc_alloc(ctx->dev, NULL, req_ctx->psrc, NULL, NULL, 0,
1635 nbytes, 0, 0, areq->base.flags); 1708 nbytes, 0, 0, 0, areq->base.flags);
1636} 1709}
1637 1710
1638static int ahash_init(struct ahash_request *areq) 1711static int ahash_init(struct ahash_request *areq)
@@ -1690,7 +1763,7 @@ static int ahash_process_req(struct ahash_request *areq, unsigned int nbytes)
1690 unsigned int nbytes_to_hash; 1763 unsigned int nbytes_to_hash;
1691 unsigned int to_hash_later; 1764 unsigned int to_hash_later;
1692 unsigned int nsg; 1765 unsigned int nsg;
1693 int chained; 1766 bool chained;
1694 1767
1695 if (!req_ctx->last && (nbytes + req_ctx->nbuf <= blocksize)) { 1768 if (!req_ctx->last && (nbytes + req_ctx->nbuf <= blocksize)) {
1696 /* Buffer up to one whole block */ 1769 /* Buffer up to one whole block */
@@ -1902,21 +1975,18 @@ struct talitos_alg_template {
1902}; 1975};
1903 1976
1904static struct talitos_alg_template driver_algs[] = { 1977static struct talitos_alg_template driver_algs[] = {
1905 /* AEAD algorithms. These use a single-pass ipsec_esp descriptor */ 1978 /*
1979 * AEAD algorithms. These use a single-pass ipsec_esp descriptor.
1980 * authencesn(*,*) is also registered, although not present
1981 * explicitly here.
1982 */
1906 { .type = CRYPTO_ALG_TYPE_AEAD, 1983 { .type = CRYPTO_ALG_TYPE_AEAD,
1907 .alg.crypto = { 1984 .alg.crypto = {
1908 .cra_name = "authenc(hmac(sha1),cbc(aes))", 1985 .cra_name = "authenc(hmac(sha1),cbc(aes))",
1909 .cra_driver_name = "authenc-hmac-sha1-cbc-aes-talitos", 1986 .cra_driver_name = "authenc-hmac-sha1-cbc-aes-talitos",
1910 .cra_blocksize = AES_BLOCK_SIZE, 1987 .cra_blocksize = AES_BLOCK_SIZE,
1911 .cra_flags = CRYPTO_ALG_TYPE_AEAD | CRYPTO_ALG_ASYNC, 1988 .cra_flags = CRYPTO_ALG_TYPE_AEAD | CRYPTO_ALG_ASYNC,
1912 .cra_type = &crypto_aead_type,
1913 .cra_aead = { 1989 .cra_aead = {
1914 .setkey = aead_setkey,
1915 .setauthsize = aead_setauthsize,
1916 .encrypt = aead_encrypt,
1917 .decrypt = aead_decrypt,
1918 .givencrypt = aead_givencrypt,
1919 .geniv = "<built-in>",
1920 .ivsize = AES_BLOCK_SIZE, 1990 .ivsize = AES_BLOCK_SIZE,
1921 .maxauthsize = SHA1_DIGEST_SIZE, 1991 .maxauthsize = SHA1_DIGEST_SIZE,
1922 } 1992 }
@@ -1935,14 +2005,7 @@ static struct talitos_alg_template driver_algs[] = {
1935 .cra_driver_name = "authenc-hmac-sha1-cbc-3des-talitos", 2005 .cra_driver_name = "authenc-hmac-sha1-cbc-3des-talitos",
1936 .cra_blocksize = DES3_EDE_BLOCK_SIZE, 2006 .cra_blocksize = DES3_EDE_BLOCK_SIZE,
1937 .cra_flags = CRYPTO_ALG_TYPE_AEAD | CRYPTO_ALG_ASYNC, 2007 .cra_flags = CRYPTO_ALG_TYPE_AEAD | CRYPTO_ALG_ASYNC,
1938 .cra_type = &crypto_aead_type,
1939 .cra_aead = { 2008 .cra_aead = {
1940 .setkey = aead_setkey,
1941 .setauthsize = aead_setauthsize,
1942 .encrypt = aead_encrypt,
1943 .decrypt = aead_decrypt,
1944 .givencrypt = aead_givencrypt,
1945 .geniv = "<built-in>",
1946 .ivsize = DES3_EDE_BLOCK_SIZE, 2009 .ivsize = DES3_EDE_BLOCK_SIZE,
1947 .maxauthsize = SHA1_DIGEST_SIZE, 2010 .maxauthsize = SHA1_DIGEST_SIZE,
1948 } 2011 }
@@ -1962,14 +2025,7 @@ static struct talitos_alg_template driver_algs[] = {
1962 .cra_driver_name = "authenc-hmac-sha224-cbc-aes-talitos", 2025 .cra_driver_name = "authenc-hmac-sha224-cbc-aes-talitos",
1963 .cra_blocksize = AES_BLOCK_SIZE, 2026 .cra_blocksize = AES_BLOCK_SIZE,
1964 .cra_flags = CRYPTO_ALG_TYPE_AEAD | CRYPTO_ALG_ASYNC, 2027 .cra_flags = CRYPTO_ALG_TYPE_AEAD | CRYPTO_ALG_ASYNC,
1965 .cra_type = &crypto_aead_type,
1966 .cra_aead = { 2028 .cra_aead = {
1967 .setkey = aead_setkey,
1968 .setauthsize = aead_setauthsize,
1969 .encrypt = aead_encrypt,
1970 .decrypt = aead_decrypt,
1971 .givencrypt = aead_givencrypt,
1972 .geniv = "<built-in>",
1973 .ivsize = AES_BLOCK_SIZE, 2029 .ivsize = AES_BLOCK_SIZE,
1974 .maxauthsize = SHA224_DIGEST_SIZE, 2030 .maxauthsize = SHA224_DIGEST_SIZE,
1975 } 2031 }
@@ -1988,14 +2044,7 @@ static struct talitos_alg_template driver_algs[] = {
1988 .cra_driver_name = "authenc-hmac-sha224-cbc-3des-talitos", 2044 .cra_driver_name = "authenc-hmac-sha224-cbc-3des-talitos",
1989 .cra_blocksize = DES3_EDE_BLOCK_SIZE, 2045 .cra_blocksize = DES3_EDE_BLOCK_SIZE,
1990 .cra_flags = CRYPTO_ALG_TYPE_AEAD | CRYPTO_ALG_ASYNC, 2046 .cra_flags = CRYPTO_ALG_TYPE_AEAD | CRYPTO_ALG_ASYNC,
1991 .cra_type = &crypto_aead_type,
1992 .cra_aead = { 2047 .cra_aead = {
1993 .setkey = aead_setkey,
1994 .setauthsize = aead_setauthsize,
1995 .encrypt = aead_encrypt,
1996 .decrypt = aead_decrypt,
1997 .givencrypt = aead_givencrypt,
1998 .geniv = "<built-in>",
1999 .ivsize = DES3_EDE_BLOCK_SIZE, 2048 .ivsize = DES3_EDE_BLOCK_SIZE,
2000 .maxauthsize = SHA224_DIGEST_SIZE, 2049 .maxauthsize = SHA224_DIGEST_SIZE,
2001 } 2050 }
@@ -2015,14 +2064,7 @@ static struct talitos_alg_template driver_algs[] = {
2015 .cra_driver_name = "authenc-hmac-sha256-cbc-aes-talitos", 2064 .cra_driver_name = "authenc-hmac-sha256-cbc-aes-talitos",
2016 .cra_blocksize = AES_BLOCK_SIZE, 2065 .cra_blocksize = AES_BLOCK_SIZE,
2017 .cra_flags = CRYPTO_ALG_TYPE_AEAD | CRYPTO_ALG_ASYNC, 2066 .cra_flags = CRYPTO_ALG_TYPE_AEAD | CRYPTO_ALG_ASYNC,
2018 .cra_type = &crypto_aead_type,
2019 .cra_aead = { 2067 .cra_aead = {
2020 .setkey = aead_setkey,
2021 .setauthsize = aead_setauthsize,
2022 .encrypt = aead_encrypt,
2023 .decrypt = aead_decrypt,
2024 .givencrypt = aead_givencrypt,
2025 .geniv = "<built-in>",
2026 .ivsize = AES_BLOCK_SIZE, 2068 .ivsize = AES_BLOCK_SIZE,
2027 .maxauthsize = SHA256_DIGEST_SIZE, 2069 .maxauthsize = SHA256_DIGEST_SIZE,
2028 } 2070 }
@@ -2041,14 +2083,7 @@ static struct talitos_alg_template driver_algs[] = {
2041 .cra_driver_name = "authenc-hmac-sha256-cbc-3des-talitos", 2083 .cra_driver_name = "authenc-hmac-sha256-cbc-3des-talitos",
2042 .cra_blocksize = DES3_EDE_BLOCK_SIZE, 2084 .cra_blocksize = DES3_EDE_BLOCK_SIZE,
2043 .cra_flags = CRYPTO_ALG_TYPE_AEAD | CRYPTO_ALG_ASYNC, 2085 .cra_flags = CRYPTO_ALG_TYPE_AEAD | CRYPTO_ALG_ASYNC,
2044 .cra_type = &crypto_aead_type,
2045 .cra_aead = { 2086 .cra_aead = {
2046 .setkey = aead_setkey,
2047 .setauthsize = aead_setauthsize,
2048 .encrypt = aead_encrypt,
2049 .decrypt = aead_decrypt,
2050 .givencrypt = aead_givencrypt,
2051 .geniv = "<built-in>",
2052 .ivsize = DES3_EDE_BLOCK_SIZE, 2087 .ivsize = DES3_EDE_BLOCK_SIZE,
2053 .maxauthsize = SHA256_DIGEST_SIZE, 2088 .maxauthsize = SHA256_DIGEST_SIZE,
2054 } 2089 }
@@ -2068,14 +2103,7 @@ static struct talitos_alg_template driver_algs[] = {
2068 .cra_driver_name = "authenc-hmac-sha384-cbc-aes-talitos", 2103 .cra_driver_name = "authenc-hmac-sha384-cbc-aes-talitos",
2069 .cra_blocksize = AES_BLOCK_SIZE, 2104 .cra_blocksize = AES_BLOCK_SIZE,
2070 .cra_flags = CRYPTO_ALG_TYPE_AEAD | CRYPTO_ALG_ASYNC, 2105 .cra_flags = CRYPTO_ALG_TYPE_AEAD | CRYPTO_ALG_ASYNC,
2071 .cra_type = &crypto_aead_type,
2072 .cra_aead = { 2106 .cra_aead = {
2073 .setkey = aead_setkey,
2074 .setauthsize = aead_setauthsize,
2075 .encrypt = aead_encrypt,
2076 .decrypt = aead_decrypt,
2077 .givencrypt = aead_givencrypt,
2078 .geniv = "<built-in>",
2079 .ivsize = AES_BLOCK_SIZE, 2107 .ivsize = AES_BLOCK_SIZE,
2080 .maxauthsize = SHA384_DIGEST_SIZE, 2108 .maxauthsize = SHA384_DIGEST_SIZE,
2081 } 2109 }
@@ -2094,14 +2122,7 @@ static struct talitos_alg_template driver_algs[] = {
2094 .cra_driver_name = "authenc-hmac-sha384-cbc-3des-talitos", 2122 .cra_driver_name = "authenc-hmac-sha384-cbc-3des-talitos",
2095 .cra_blocksize = DES3_EDE_BLOCK_SIZE, 2123 .cra_blocksize = DES3_EDE_BLOCK_SIZE,
2096 .cra_flags = CRYPTO_ALG_TYPE_AEAD | CRYPTO_ALG_ASYNC, 2124 .cra_flags = CRYPTO_ALG_TYPE_AEAD | CRYPTO_ALG_ASYNC,
2097 .cra_type = &crypto_aead_type,
2098 .cra_aead = { 2125 .cra_aead = {
2099 .setkey = aead_setkey,
2100 .setauthsize = aead_setauthsize,
2101 .encrypt = aead_encrypt,
2102 .decrypt = aead_decrypt,
2103 .givencrypt = aead_givencrypt,
2104 .geniv = "<built-in>",
2105 .ivsize = DES3_EDE_BLOCK_SIZE, 2126 .ivsize = DES3_EDE_BLOCK_SIZE,
2106 .maxauthsize = SHA384_DIGEST_SIZE, 2127 .maxauthsize = SHA384_DIGEST_SIZE,
2107 } 2128 }
@@ -2121,14 +2142,7 @@ static struct talitos_alg_template driver_algs[] = {
2121 .cra_driver_name = "authenc-hmac-sha512-cbc-aes-talitos", 2142 .cra_driver_name = "authenc-hmac-sha512-cbc-aes-talitos",
2122 .cra_blocksize = AES_BLOCK_SIZE, 2143 .cra_blocksize = AES_BLOCK_SIZE,
2123 .cra_flags = CRYPTO_ALG_TYPE_AEAD | CRYPTO_ALG_ASYNC, 2144 .cra_flags = CRYPTO_ALG_TYPE_AEAD | CRYPTO_ALG_ASYNC,
2124 .cra_type = &crypto_aead_type,
2125 .cra_aead = { 2145 .cra_aead = {
2126 .setkey = aead_setkey,
2127 .setauthsize = aead_setauthsize,
2128 .encrypt = aead_encrypt,
2129 .decrypt = aead_decrypt,
2130 .givencrypt = aead_givencrypt,
2131 .geniv = "<built-in>",
2132 .ivsize = AES_BLOCK_SIZE, 2146 .ivsize = AES_BLOCK_SIZE,
2133 .maxauthsize = SHA512_DIGEST_SIZE, 2147 .maxauthsize = SHA512_DIGEST_SIZE,
2134 } 2148 }
@@ -2147,14 +2161,7 @@ static struct talitos_alg_template driver_algs[] = {
2147 .cra_driver_name = "authenc-hmac-sha512-cbc-3des-talitos", 2161 .cra_driver_name = "authenc-hmac-sha512-cbc-3des-talitos",
2148 .cra_blocksize = DES3_EDE_BLOCK_SIZE, 2162 .cra_blocksize = DES3_EDE_BLOCK_SIZE,
2149 .cra_flags = CRYPTO_ALG_TYPE_AEAD | CRYPTO_ALG_ASYNC, 2163 .cra_flags = CRYPTO_ALG_TYPE_AEAD | CRYPTO_ALG_ASYNC,
2150 .cra_type = &crypto_aead_type,
2151 .cra_aead = { 2164 .cra_aead = {
2152 .setkey = aead_setkey,
2153 .setauthsize = aead_setauthsize,
2154 .encrypt = aead_encrypt,
2155 .decrypt = aead_decrypt,
2156 .givencrypt = aead_givencrypt,
2157 .geniv = "<built-in>",
2158 .ivsize = DES3_EDE_BLOCK_SIZE, 2165 .ivsize = DES3_EDE_BLOCK_SIZE,
2159 .maxauthsize = SHA512_DIGEST_SIZE, 2166 .maxauthsize = SHA512_DIGEST_SIZE,
2160 } 2167 }
@@ -2174,14 +2181,7 @@ static struct talitos_alg_template driver_algs[] = {
2174 .cra_driver_name = "authenc-hmac-md5-cbc-aes-talitos", 2181 .cra_driver_name = "authenc-hmac-md5-cbc-aes-talitos",
2175 .cra_blocksize = AES_BLOCK_SIZE, 2182 .cra_blocksize = AES_BLOCK_SIZE,
2176 .cra_flags = CRYPTO_ALG_TYPE_AEAD | CRYPTO_ALG_ASYNC, 2183 .cra_flags = CRYPTO_ALG_TYPE_AEAD | CRYPTO_ALG_ASYNC,
2177 .cra_type = &crypto_aead_type,
2178 .cra_aead = { 2184 .cra_aead = {
2179 .setkey = aead_setkey,
2180 .setauthsize = aead_setauthsize,
2181 .encrypt = aead_encrypt,
2182 .decrypt = aead_decrypt,
2183 .givencrypt = aead_givencrypt,
2184 .geniv = "<built-in>",
2185 .ivsize = AES_BLOCK_SIZE, 2185 .ivsize = AES_BLOCK_SIZE,
2186 .maxauthsize = MD5_DIGEST_SIZE, 2186 .maxauthsize = MD5_DIGEST_SIZE,
2187 } 2187 }
@@ -2200,14 +2200,7 @@ static struct talitos_alg_template driver_algs[] = {
2200 .cra_driver_name = "authenc-hmac-md5-cbc-3des-talitos", 2200 .cra_driver_name = "authenc-hmac-md5-cbc-3des-talitos",
2201 .cra_blocksize = DES3_EDE_BLOCK_SIZE, 2201 .cra_blocksize = DES3_EDE_BLOCK_SIZE,
2202 .cra_flags = CRYPTO_ALG_TYPE_AEAD | CRYPTO_ALG_ASYNC, 2202 .cra_flags = CRYPTO_ALG_TYPE_AEAD | CRYPTO_ALG_ASYNC,
2203 .cra_type = &crypto_aead_type,
2204 .cra_aead = { 2203 .cra_aead = {
2205 .setkey = aead_setkey,
2206 .setauthsize = aead_setauthsize,
2207 .encrypt = aead_encrypt,
2208 .decrypt = aead_decrypt,
2209 .givencrypt = aead_givencrypt,
2210 .geniv = "<built-in>",
2211 .ivsize = DES3_EDE_BLOCK_SIZE, 2204 .ivsize = DES3_EDE_BLOCK_SIZE,
2212 .maxauthsize = MD5_DIGEST_SIZE, 2205 .maxauthsize = MD5_DIGEST_SIZE,
2213 } 2206 }
@@ -2229,12 +2222,7 @@ static struct talitos_alg_template driver_algs[] = {
2229 .cra_blocksize = AES_BLOCK_SIZE, 2222 .cra_blocksize = AES_BLOCK_SIZE,
2230 .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER | 2223 .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER |
2231 CRYPTO_ALG_ASYNC, 2224 CRYPTO_ALG_ASYNC,
2232 .cra_type = &crypto_ablkcipher_type,
2233 .cra_ablkcipher = { 2225 .cra_ablkcipher = {
2234 .setkey = ablkcipher_setkey,
2235 .encrypt = ablkcipher_encrypt,
2236 .decrypt = ablkcipher_decrypt,
2237 .geniv = "eseqiv",
2238 .min_keysize = AES_MIN_KEY_SIZE, 2226 .min_keysize = AES_MIN_KEY_SIZE,
2239 .max_keysize = AES_MAX_KEY_SIZE, 2227 .max_keysize = AES_MAX_KEY_SIZE,
2240 .ivsize = AES_BLOCK_SIZE, 2228 .ivsize = AES_BLOCK_SIZE,
@@ -2251,12 +2239,7 @@ static struct talitos_alg_template driver_algs[] = {
2251 .cra_blocksize = DES3_EDE_BLOCK_SIZE, 2239 .cra_blocksize = DES3_EDE_BLOCK_SIZE,
2252 .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER | 2240 .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER |
2253 CRYPTO_ALG_ASYNC, 2241 CRYPTO_ALG_ASYNC,
2254 .cra_type = &crypto_ablkcipher_type,
2255 .cra_ablkcipher = { 2242 .cra_ablkcipher = {
2256 .setkey = ablkcipher_setkey,
2257 .encrypt = ablkcipher_encrypt,
2258 .decrypt = ablkcipher_decrypt,
2259 .geniv = "eseqiv",
2260 .min_keysize = DES3_EDE_KEY_SIZE, 2243 .min_keysize = DES3_EDE_KEY_SIZE,
2261 .max_keysize = DES3_EDE_KEY_SIZE, 2244 .max_keysize = DES3_EDE_KEY_SIZE,
2262 .ivsize = DES3_EDE_BLOCK_SIZE, 2245 .ivsize = DES3_EDE_BLOCK_SIZE,
@@ -2270,11 +2253,6 @@ static struct talitos_alg_template driver_algs[] = {
2270 /* AHASH algorithms. */ 2253 /* AHASH algorithms. */
2271 { .type = CRYPTO_ALG_TYPE_AHASH, 2254 { .type = CRYPTO_ALG_TYPE_AHASH,
2272 .alg.hash = { 2255 .alg.hash = {
2273 .init = ahash_init,
2274 .update = ahash_update,
2275 .final = ahash_final,
2276 .finup = ahash_finup,
2277 .digest = ahash_digest,
2278 .halg.digestsize = MD5_DIGEST_SIZE, 2256 .halg.digestsize = MD5_DIGEST_SIZE,
2279 .halg.base = { 2257 .halg.base = {
2280 .cra_name = "md5", 2258 .cra_name = "md5",
@@ -2282,7 +2260,6 @@ static struct talitos_alg_template driver_algs[] = {
2282 .cra_blocksize = MD5_BLOCK_SIZE, 2260 .cra_blocksize = MD5_BLOCK_SIZE,
2283 .cra_flags = CRYPTO_ALG_TYPE_AHASH | 2261 .cra_flags = CRYPTO_ALG_TYPE_AHASH |
2284 CRYPTO_ALG_ASYNC, 2262 CRYPTO_ALG_ASYNC,
2285 .cra_type = &crypto_ahash_type
2286 } 2263 }
2287 }, 2264 },
2288 .desc_hdr_template = DESC_HDR_TYPE_COMMON_NONSNOOP_NO_AFEU | 2265 .desc_hdr_template = DESC_HDR_TYPE_COMMON_NONSNOOP_NO_AFEU |
@@ -2291,11 +2268,6 @@ static struct talitos_alg_template driver_algs[] = {
2291 }, 2268 },
2292 { .type = CRYPTO_ALG_TYPE_AHASH, 2269 { .type = CRYPTO_ALG_TYPE_AHASH,
2293 .alg.hash = { 2270 .alg.hash = {
2294 .init = ahash_init,
2295 .update = ahash_update,
2296 .final = ahash_final,
2297 .finup = ahash_finup,
2298 .digest = ahash_digest,
2299 .halg.digestsize = SHA1_DIGEST_SIZE, 2271 .halg.digestsize = SHA1_DIGEST_SIZE,
2300 .halg.base = { 2272 .halg.base = {
2301 .cra_name = "sha1", 2273 .cra_name = "sha1",
@@ -2303,7 +2275,6 @@ static struct talitos_alg_template driver_algs[] = {
2303 .cra_blocksize = SHA1_BLOCK_SIZE, 2275 .cra_blocksize = SHA1_BLOCK_SIZE,
2304 .cra_flags = CRYPTO_ALG_TYPE_AHASH | 2276 .cra_flags = CRYPTO_ALG_TYPE_AHASH |
2305 CRYPTO_ALG_ASYNC, 2277 CRYPTO_ALG_ASYNC,
2306 .cra_type = &crypto_ahash_type
2307 } 2278 }
2308 }, 2279 },
2309 .desc_hdr_template = DESC_HDR_TYPE_COMMON_NONSNOOP_NO_AFEU | 2280 .desc_hdr_template = DESC_HDR_TYPE_COMMON_NONSNOOP_NO_AFEU |
@@ -2312,11 +2283,6 @@ static struct talitos_alg_template driver_algs[] = {
2312 }, 2283 },
2313 { .type = CRYPTO_ALG_TYPE_AHASH, 2284 { .type = CRYPTO_ALG_TYPE_AHASH,
2314 .alg.hash = { 2285 .alg.hash = {
2315 .init = ahash_init,
2316 .update = ahash_update,
2317 .final = ahash_final,
2318 .finup = ahash_finup,
2319 .digest = ahash_digest,
2320 .halg.digestsize = SHA224_DIGEST_SIZE, 2286 .halg.digestsize = SHA224_DIGEST_SIZE,
2321 .halg.base = { 2287 .halg.base = {
2322 .cra_name = "sha224", 2288 .cra_name = "sha224",
@@ -2324,7 +2290,6 @@ static struct talitos_alg_template driver_algs[] = {
2324 .cra_blocksize = SHA224_BLOCK_SIZE, 2290 .cra_blocksize = SHA224_BLOCK_SIZE,
2325 .cra_flags = CRYPTO_ALG_TYPE_AHASH | 2291 .cra_flags = CRYPTO_ALG_TYPE_AHASH |
2326 CRYPTO_ALG_ASYNC, 2292 CRYPTO_ALG_ASYNC,
2327 .cra_type = &crypto_ahash_type
2328 } 2293 }
2329 }, 2294 },
2330 .desc_hdr_template = DESC_HDR_TYPE_COMMON_NONSNOOP_NO_AFEU | 2295 .desc_hdr_template = DESC_HDR_TYPE_COMMON_NONSNOOP_NO_AFEU |
@@ -2333,11 +2298,6 @@ static struct talitos_alg_template driver_algs[] = {
2333 }, 2298 },
2334 { .type = CRYPTO_ALG_TYPE_AHASH, 2299 { .type = CRYPTO_ALG_TYPE_AHASH,
2335 .alg.hash = { 2300 .alg.hash = {
2336 .init = ahash_init,
2337 .update = ahash_update,
2338 .final = ahash_final,
2339 .finup = ahash_finup,
2340 .digest = ahash_digest,
2341 .halg.digestsize = SHA256_DIGEST_SIZE, 2301 .halg.digestsize = SHA256_DIGEST_SIZE,
2342 .halg.base = { 2302 .halg.base = {
2343 .cra_name = "sha256", 2303 .cra_name = "sha256",
@@ -2345,7 +2305,6 @@ static struct talitos_alg_template driver_algs[] = {
2345 .cra_blocksize = SHA256_BLOCK_SIZE, 2305 .cra_blocksize = SHA256_BLOCK_SIZE,
2346 .cra_flags = CRYPTO_ALG_TYPE_AHASH | 2306 .cra_flags = CRYPTO_ALG_TYPE_AHASH |
2347 CRYPTO_ALG_ASYNC, 2307 CRYPTO_ALG_ASYNC,
2348 .cra_type = &crypto_ahash_type
2349 } 2308 }
2350 }, 2309 },
2351 .desc_hdr_template = DESC_HDR_TYPE_COMMON_NONSNOOP_NO_AFEU | 2310 .desc_hdr_template = DESC_HDR_TYPE_COMMON_NONSNOOP_NO_AFEU |
@@ -2354,11 +2313,6 @@ static struct talitos_alg_template driver_algs[] = {
2354 }, 2313 },
2355 { .type = CRYPTO_ALG_TYPE_AHASH, 2314 { .type = CRYPTO_ALG_TYPE_AHASH,
2356 .alg.hash = { 2315 .alg.hash = {
2357 .init = ahash_init,
2358 .update = ahash_update,
2359 .final = ahash_final,
2360 .finup = ahash_finup,
2361 .digest = ahash_digest,
2362 .halg.digestsize = SHA384_DIGEST_SIZE, 2316 .halg.digestsize = SHA384_DIGEST_SIZE,
2363 .halg.base = { 2317 .halg.base = {
2364 .cra_name = "sha384", 2318 .cra_name = "sha384",
@@ -2366,7 +2320,6 @@ static struct talitos_alg_template driver_algs[] = {
2366 .cra_blocksize = SHA384_BLOCK_SIZE, 2320 .cra_blocksize = SHA384_BLOCK_SIZE,
2367 .cra_flags = CRYPTO_ALG_TYPE_AHASH | 2321 .cra_flags = CRYPTO_ALG_TYPE_AHASH |
2368 CRYPTO_ALG_ASYNC, 2322 CRYPTO_ALG_ASYNC,
2369 .cra_type = &crypto_ahash_type
2370 } 2323 }
2371 }, 2324 },
2372 .desc_hdr_template = DESC_HDR_TYPE_COMMON_NONSNOOP_NO_AFEU | 2325 .desc_hdr_template = DESC_HDR_TYPE_COMMON_NONSNOOP_NO_AFEU |
@@ -2375,11 +2328,6 @@ static struct talitos_alg_template driver_algs[] = {
2375 }, 2328 },
2376 { .type = CRYPTO_ALG_TYPE_AHASH, 2329 { .type = CRYPTO_ALG_TYPE_AHASH,
2377 .alg.hash = { 2330 .alg.hash = {
2378 .init = ahash_init,
2379 .update = ahash_update,
2380 .final = ahash_final,
2381 .finup = ahash_finup,
2382 .digest = ahash_digest,
2383 .halg.digestsize = SHA512_DIGEST_SIZE, 2331 .halg.digestsize = SHA512_DIGEST_SIZE,
2384 .halg.base = { 2332 .halg.base = {
2385 .cra_name = "sha512", 2333 .cra_name = "sha512",
@@ -2387,7 +2335,6 @@ static struct talitos_alg_template driver_algs[] = {
2387 .cra_blocksize = SHA512_BLOCK_SIZE, 2335 .cra_blocksize = SHA512_BLOCK_SIZE,
2388 .cra_flags = CRYPTO_ALG_TYPE_AHASH | 2336 .cra_flags = CRYPTO_ALG_TYPE_AHASH |
2389 CRYPTO_ALG_ASYNC, 2337 CRYPTO_ALG_ASYNC,
2390 .cra_type = &crypto_ahash_type
2391 } 2338 }
2392 }, 2339 },
2393 .desc_hdr_template = DESC_HDR_TYPE_COMMON_NONSNOOP_NO_AFEU | 2340 .desc_hdr_template = DESC_HDR_TYPE_COMMON_NONSNOOP_NO_AFEU |
@@ -2396,12 +2343,6 @@ static struct talitos_alg_template driver_algs[] = {
2396 }, 2343 },
2397 { .type = CRYPTO_ALG_TYPE_AHASH, 2344 { .type = CRYPTO_ALG_TYPE_AHASH,
2398 .alg.hash = { 2345 .alg.hash = {
2399 .init = ahash_init,
2400 .update = ahash_update,
2401 .final = ahash_final,
2402 .finup = ahash_finup,
2403 .digest = ahash_digest,
2404 .setkey = ahash_setkey,
2405 .halg.digestsize = MD5_DIGEST_SIZE, 2346 .halg.digestsize = MD5_DIGEST_SIZE,
2406 .halg.base = { 2347 .halg.base = {
2407 .cra_name = "hmac(md5)", 2348 .cra_name = "hmac(md5)",
@@ -2409,7 +2350,6 @@ static struct talitos_alg_template driver_algs[] = {
2409 .cra_blocksize = MD5_BLOCK_SIZE, 2350 .cra_blocksize = MD5_BLOCK_SIZE,
2410 .cra_flags = CRYPTO_ALG_TYPE_AHASH | 2351 .cra_flags = CRYPTO_ALG_TYPE_AHASH |
2411 CRYPTO_ALG_ASYNC, 2352 CRYPTO_ALG_ASYNC,
2412 .cra_type = &crypto_ahash_type
2413 } 2353 }
2414 }, 2354 },
2415 .desc_hdr_template = DESC_HDR_TYPE_COMMON_NONSNOOP_NO_AFEU | 2355 .desc_hdr_template = DESC_HDR_TYPE_COMMON_NONSNOOP_NO_AFEU |
@@ -2418,12 +2358,6 @@ static struct talitos_alg_template driver_algs[] = {
2418 }, 2358 },
2419 { .type = CRYPTO_ALG_TYPE_AHASH, 2359 { .type = CRYPTO_ALG_TYPE_AHASH,
2420 .alg.hash = { 2360 .alg.hash = {
2421 .init = ahash_init,
2422 .update = ahash_update,
2423 .final = ahash_final,
2424 .finup = ahash_finup,
2425 .digest = ahash_digest,
2426 .setkey = ahash_setkey,
2427 .halg.digestsize = SHA1_DIGEST_SIZE, 2361 .halg.digestsize = SHA1_DIGEST_SIZE,
2428 .halg.base = { 2362 .halg.base = {
2429 .cra_name = "hmac(sha1)", 2363 .cra_name = "hmac(sha1)",
@@ -2431,7 +2365,6 @@ static struct talitos_alg_template driver_algs[] = {
2431 .cra_blocksize = SHA1_BLOCK_SIZE, 2365 .cra_blocksize = SHA1_BLOCK_SIZE,
2432 .cra_flags = CRYPTO_ALG_TYPE_AHASH | 2366 .cra_flags = CRYPTO_ALG_TYPE_AHASH |
2433 CRYPTO_ALG_ASYNC, 2367 CRYPTO_ALG_ASYNC,
2434 .cra_type = &crypto_ahash_type
2435 } 2368 }
2436 }, 2369 },
2437 .desc_hdr_template = DESC_HDR_TYPE_COMMON_NONSNOOP_NO_AFEU | 2370 .desc_hdr_template = DESC_HDR_TYPE_COMMON_NONSNOOP_NO_AFEU |
@@ -2440,12 +2373,6 @@ static struct talitos_alg_template driver_algs[] = {
2440 }, 2373 },
2441 { .type = CRYPTO_ALG_TYPE_AHASH, 2374 { .type = CRYPTO_ALG_TYPE_AHASH,
2442 .alg.hash = { 2375 .alg.hash = {
2443 .init = ahash_init,
2444 .update = ahash_update,
2445 .final = ahash_final,
2446 .finup = ahash_finup,
2447 .digest = ahash_digest,
2448 .setkey = ahash_setkey,
2449 .halg.digestsize = SHA224_DIGEST_SIZE, 2376 .halg.digestsize = SHA224_DIGEST_SIZE,
2450 .halg.base = { 2377 .halg.base = {
2451 .cra_name = "hmac(sha224)", 2378 .cra_name = "hmac(sha224)",
@@ -2453,7 +2380,6 @@ static struct talitos_alg_template driver_algs[] = {
2453 .cra_blocksize = SHA224_BLOCK_SIZE, 2380 .cra_blocksize = SHA224_BLOCK_SIZE,
2454 .cra_flags = CRYPTO_ALG_TYPE_AHASH | 2381 .cra_flags = CRYPTO_ALG_TYPE_AHASH |
2455 CRYPTO_ALG_ASYNC, 2382 CRYPTO_ALG_ASYNC,
2456 .cra_type = &crypto_ahash_type
2457 } 2383 }
2458 }, 2384 },
2459 .desc_hdr_template = DESC_HDR_TYPE_COMMON_NONSNOOP_NO_AFEU | 2385 .desc_hdr_template = DESC_HDR_TYPE_COMMON_NONSNOOP_NO_AFEU |
@@ -2462,12 +2388,6 @@ static struct talitos_alg_template driver_algs[] = {
2462 }, 2388 },
2463 { .type = CRYPTO_ALG_TYPE_AHASH, 2389 { .type = CRYPTO_ALG_TYPE_AHASH,
2464 .alg.hash = { 2390 .alg.hash = {
2465 .init = ahash_init,
2466 .update = ahash_update,
2467 .final = ahash_final,
2468 .finup = ahash_finup,
2469 .digest = ahash_digest,
2470 .setkey = ahash_setkey,
2471 .halg.digestsize = SHA256_DIGEST_SIZE, 2391 .halg.digestsize = SHA256_DIGEST_SIZE,
2472 .halg.base = { 2392 .halg.base = {
2473 .cra_name = "hmac(sha256)", 2393 .cra_name = "hmac(sha256)",
@@ -2475,7 +2395,6 @@ static struct talitos_alg_template driver_algs[] = {
2475 .cra_blocksize = SHA256_BLOCK_SIZE, 2395 .cra_blocksize = SHA256_BLOCK_SIZE,
2476 .cra_flags = CRYPTO_ALG_TYPE_AHASH | 2396 .cra_flags = CRYPTO_ALG_TYPE_AHASH |
2477 CRYPTO_ALG_ASYNC, 2397 CRYPTO_ALG_ASYNC,
2478 .cra_type = &crypto_ahash_type
2479 } 2398 }
2480 }, 2399 },
2481 .desc_hdr_template = DESC_HDR_TYPE_COMMON_NONSNOOP_NO_AFEU | 2400 .desc_hdr_template = DESC_HDR_TYPE_COMMON_NONSNOOP_NO_AFEU |
@@ -2484,12 +2403,6 @@ static struct talitos_alg_template driver_algs[] = {
2484 }, 2403 },
2485 { .type = CRYPTO_ALG_TYPE_AHASH, 2404 { .type = CRYPTO_ALG_TYPE_AHASH,
2486 .alg.hash = { 2405 .alg.hash = {
2487 .init = ahash_init,
2488 .update = ahash_update,
2489 .final = ahash_final,
2490 .finup = ahash_finup,
2491 .digest = ahash_digest,
2492 .setkey = ahash_setkey,
2493 .halg.digestsize = SHA384_DIGEST_SIZE, 2406 .halg.digestsize = SHA384_DIGEST_SIZE,
2494 .halg.base = { 2407 .halg.base = {
2495 .cra_name = "hmac(sha384)", 2408 .cra_name = "hmac(sha384)",
@@ -2497,7 +2410,6 @@ static struct talitos_alg_template driver_algs[] = {
2497 .cra_blocksize = SHA384_BLOCK_SIZE, 2410 .cra_blocksize = SHA384_BLOCK_SIZE,
2498 .cra_flags = CRYPTO_ALG_TYPE_AHASH | 2411 .cra_flags = CRYPTO_ALG_TYPE_AHASH |
2499 CRYPTO_ALG_ASYNC, 2412 CRYPTO_ALG_ASYNC,
2500 .cra_type = &crypto_ahash_type
2501 } 2413 }
2502 }, 2414 },
2503 .desc_hdr_template = DESC_HDR_TYPE_COMMON_NONSNOOP_NO_AFEU | 2415 .desc_hdr_template = DESC_HDR_TYPE_COMMON_NONSNOOP_NO_AFEU |
@@ -2506,12 +2418,6 @@ static struct talitos_alg_template driver_algs[] = {
2506 }, 2418 },
2507 { .type = CRYPTO_ALG_TYPE_AHASH, 2419 { .type = CRYPTO_ALG_TYPE_AHASH,
2508 .alg.hash = { 2420 .alg.hash = {
2509 .init = ahash_init,
2510 .update = ahash_update,
2511 .final = ahash_final,
2512 .finup = ahash_finup,
2513 .digest = ahash_digest,
2514 .setkey = ahash_setkey,
2515 .halg.digestsize = SHA512_DIGEST_SIZE, 2421 .halg.digestsize = SHA512_DIGEST_SIZE,
2516 .halg.base = { 2422 .halg.base = {
2517 .cra_name = "hmac(sha512)", 2423 .cra_name = "hmac(sha512)",
@@ -2519,7 +2425,6 @@ static struct talitos_alg_template driver_algs[] = {
2519 .cra_blocksize = SHA512_BLOCK_SIZE, 2425 .cra_blocksize = SHA512_BLOCK_SIZE,
2520 .cra_flags = CRYPTO_ALG_TYPE_AHASH | 2426 .cra_flags = CRYPTO_ALG_TYPE_AHASH |
2521 CRYPTO_ALG_ASYNC, 2427 CRYPTO_ALG_ASYNC,
2522 .cra_type = &crypto_ahash_type
2523 } 2428 }
2524 }, 2429 },
2525 .desc_hdr_template = DESC_HDR_TYPE_COMMON_NONSNOOP_NO_AFEU | 2430 .desc_hdr_template = DESC_HDR_TYPE_COMMON_NONSNOOP_NO_AFEU |
@@ -2677,14 +2582,34 @@ static struct talitos_crypto_alg *talitos_alg_alloc(struct device *dev,
2677 case CRYPTO_ALG_TYPE_ABLKCIPHER: 2582 case CRYPTO_ALG_TYPE_ABLKCIPHER:
2678 alg = &t_alg->algt.alg.crypto; 2583 alg = &t_alg->algt.alg.crypto;
2679 alg->cra_init = talitos_cra_init; 2584 alg->cra_init = talitos_cra_init;
2585 alg->cra_type = &crypto_ablkcipher_type;
2586 alg->cra_ablkcipher.setkey = ablkcipher_setkey;
2587 alg->cra_ablkcipher.encrypt = ablkcipher_encrypt;
2588 alg->cra_ablkcipher.decrypt = ablkcipher_decrypt;
2589 alg->cra_ablkcipher.geniv = "eseqiv";
2680 break; 2590 break;
2681 case CRYPTO_ALG_TYPE_AEAD: 2591 case CRYPTO_ALG_TYPE_AEAD:
2682 alg = &t_alg->algt.alg.crypto; 2592 alg = &t_alg->algt.alg.crypto;
2683 alg->cra_init = talitos_cra_init_aead; 2593 alg->cra_init = talitos_cra_init_aead;
2594 alg->cra_type = &crypto_aead_type;
2595 alg->cra_aead.setkey = aead_setkey;
2596 alg->cra_aead.setauthsize = aead_setauthsize;
2597 alg->cra_aead.encrypt = aead_encrypt;
2598 alg->cra_aead.decrypt = aead_decrypt;
2599 alg->cra_aead.givencrypt = aead_givencrypt;
2600 alg->cra_aead.geniv = "<built-in>";
2684 break; 2601 break;
2685 case CRYPTO_ALG_TYPE_AHASH: 2602 case CRYPTO_ALG_TYPE_AHASH:
2686 alg = &t_alg->algt.alg.hash.halg.base; 2603 alg = &t_alg->algt.alg.hash.halg.base;
2687 alg->cra_init = talitos_cra_init_ahash; 2604 alg->cra_init = talitos_cra_init_ahash;
2605 alg->cra_type = &crypto_ahash_type;
2606 t_alg->algt.alg.hash.init = ahash_init;
2607 t_alg->algt.alg.hash.update = ahash_update;
2608 t_alg->algt.alg.hash.final = ahash_final;
2609 t_alg->algt.alg.hash.finup = ahash_finup;
2610 t_alg->algt.alg.hash.digest = ahash_digest;
2611 t_alg->algt.alg.hash.setkey = ahash_setkey;
2612
2688 if (!(priv->features & TALITOS_FTR_HMAC_OK) && 2613 if (!(priv->features & TALITOS_FTR_HMAC_OK) &&
2689 !strncmp(alg->cra_name, "hmac", 4)) { 2614 !strncmp(alg->cra_name, "hmac", 4)) {
2690 kfree(t_alg); 2615 kfree(t_alg);
@@ -2896,7 +2821,9 @@ static int talitos_probe(struct platform_device *ofdev)
2896 if (hw_supports(dev, driver_algs[i].desc_hdr_template)) { 2821 if (hw_supports(dev, driver_algs[i].desc_hdr_template)) {
2897 struct talitos_crypto_alg *t_alg; 2822 struct talitos_crypto_alg *t_alg;
2898 char *name = NULL; 2823 char *name = NULL;
2824 bool authenc = false;
2899 2825
2826authencesn:
2900 t_alg = talitos_alg_alloc(dev, &driver_algs[i]); 2827 t_alg = talitos_alg_alloc(dev, &driver_algs[i]);
2901 if (IS_ERR(t_alg)) { 2828 if (IS_ERR(t_alg)) {
2902 err = PTR_ERR(t_alg); 2829 err = PTR_ERR(t_alg);
@@ -2911,6 +2838,8 @@ static int talitos_probe(struct platform_device *ofdev)
2911 err = crypto_register_alg( 2838 err = crypto_register_alg(
2912 &t_alg->algt.alg.crypto); 2839 &t_alg->algt.alg.crypto);
2913 name = t_alg->algt.alg.crypto.cra_driver_name; 2840 name = t_alg->algt.alg.crypto.cra_driver_name;
2841 authenc = authenc ? !authenc :
2842 !(bool)memcmp(name, "authenc", 7);
2914 break; 2843 break;
2915 case CRYPTO_ALG_TYPE_AHASH: 2844 case CRYPTO_ALG_TYPE_AHASH:
2916 err = crypto_register_ahash( 2845 err = crypto_register_ahash(
@@ -2923,8 +2852,25 @@ static int talitos_probe(struct platform_device *ofdev)
2923 dev_err(dev, "%s alg registration failed\n", 2852 dev_err(dev, "%s alg registration failed\n",
2924 name); 2853 name);
2925 kfree(t_alg); 2854 kfree(t_alg);
2926 } else 2855 } else {
2927 list_add_tail(&t_alg->entry, &priv->alg_list); 2856 list_add_tail(&t_alg->entry, &priv->alg_list);
2857 if (authenc) {
2858 struct crypto_alg *alg =
2859 &driver_algs[i].alg.crypto;
2860
2861 name = alg->cra_name;
2862 memmove(name + 10, name + 7,
2863 strlen(name) - 7);
2864 memcpy(name + 7, "esn", 3);
2865
2866 name = alg->cra_driver_name;
2867 memmove(name + 10, name + 7,
2868 strlen(name) - 7);
2869 memcpy(name + 7, "esn", 3);
2870
2871 goto authencesn;
2872 }
2873 }
2928 } 2874 }
2929 } 2875 }
2930 if (!list_empty(&priv->alg_list)) 2876 if (!list_empty(&priv->alg_list))