aboutsummaryrefslogtreecommitdiffstats
path: root/crypto
diff options
context:
space:
mode:
Diffstat (limited to 'crypto')
-rw-r--r--crypto/authenc.c22
-rw-r--r--crypto/eseqiv.c18
-rw-r--r--crypto/gcm.c19
3 files changed, 8 insertions, 51 deletions
diff --git a/crypto/authenc.c b/crypto/authenc.c
index a5a22cfcd07b..5ef7ba6b6a76 100644
--- a/crypto/authenc.c
+++ b/crypto/authenc.c
@@ -107,20 +107,6 @@ badkey:
107 goto out; 107 goto out;
108} 108}
109 109
110static void authenc_chain(struct scatterlist *head, struct scatterlist *sg,
111 int chain)
112{
113 if (chain) {
114 head->length += sg->length;
115 sg = scatterwalk_sg_next(sg);
116 }
117
118 if (sg)
119 scatterwalk_sg_chain(head, 2, sg);
120 else
121 sg_mark_end(head);
122}
123
124static void authenc_geniv_ahash_update_done(struct crypto_async_request *areq, 110static void authenc_geniv_ahash_update_done(struct crypto_async_request *areq,
125 int err) 111 int err)
126{ 112{
@@ -345,7 +331,7 @@ static int crypto_authenc_genicv(struct aead_request *req, u8 *iv,
345 if (ivsize) { 331 if (ivsize) {
346 sg_init_table(cipher, 2); 332 sg_init_table(cipher, 2);
347 sg_set_buf(cipher, iv, ivsize); 333 sg_set_buf(cipher, iv, ivsize);
348 authenc_chain(cipher, dst, vdst == iv + ivsize); 334 scatterwalk_crypto_chain(cipher, dst, vdst == iv + ivsize, 2);
349 dst = cipher; 335 dst = cipher;
350 cryptlen += ivsize; 336 cryptlen += ivsize;
351 } 337 }
@@ -354,7 +340,7 @@ static int crypto_authenc_genicv(struct aead_request *req, u8 *iv,
354 authenc_ahash_fn = crypto_authenc_ahash; 340 authenc_ahash_fn = crypto_authenc_ahash;
355 sg_init_table(asg, 2); 341 sg_init_table(asg, 2);
356 sg_set_page(asg, sg_page(assoc), assoc->length, assoc->offset); 342 sg_set_page(asg, sg_page(assoc), assoc->length, assoc->offset);
357 authenc_chain(asg, dst, 0); 343 scatterwalk_crypto_chain(asg, dst, 0, 2);
358 dst = asg; 344 dst = asg;
359 cryptlen += req->assoclen; 345 cryptlen += req->assoclen;
360 } 346 }
@@ -499,7 +485,7 @@ static int crypto_authenc_iverify(struct aead_request *req, u8 *iv,
499 if (ivsize) { 485 if (ivsize) {
500 sg_init_table(cipher, 2); 486 sg_init_table(cipher, 2);
501 sg_set_buf(cipher, iv, ivsize); 487 sg_set_buf(cipher, iv, ivsize);
502 authenc_chain(cipher, src, vsrc == iv + ivsize); 488 scatterwalk_crypto_chain(cipher, src, vsrc == iv + ivsize, 2);
503 src = cipher; 489 src = cipher;
504 cryptlen += ivsize; 490 cryptlen += ivsize;
505 } 491 }
@@ -508,7 +494,7 @@ static int crypto_authenc_iverify(struct aead_request *req, u8 *iv,
508 authenc_ahash_fn = crypto_authenc_ahash; 494 authenc_ahash_fn = crypto_authenc_ahash;
509 sg_init_table(asg, 2); 495 sg_init_table(asg, 2);
510 sg_set_page(asg, sg_page(assoc), assoc->length, assoc->offset); 496 sg_set_page(asg, sg_page(assoc), assoc->length, assoc->offset);
511 authenc_chain(asg, src, 0); 497 scatterwalk_crypto_chain(asg, src, 0, 2);
512 src = asg; 498 src = asg;
513 cryptlen += req->assoclen; 499 cryptlen += req->assoclen;
514 } 500 }
diff --git a/crypto/eseqiv.c b/crypto/eseqiv.c
index 3ca3b669d5d5..42ce9f570aec 100644
--- a/crypto/eseqiv.c
+++ b/crypto/eseqiv.c
@@ -62,20 +62,6 @@ out:
62 skcipher_givcrypt_complete(req, err); 62 skcipher_givcrypt_complete(req, err);
63} 63}
64 64
65static void eseqiv_chain(struct scatterlist *head, struct scatterlist *sg,
66 int chain)
67{
68 if (chain) {
69 head->length += sg->length;
70 sg = scatterwalk_sg_next(sg);
71 }
72
73 if (sg)
74 scatterwalk_sg_chain(head, 2, sg);
75 else
76 sg_mark_end(head);
77}
78
79static int eseqiv_givencrypt(struct skcipher_givcrypt_request *req) 65static int eseqiv_givencrypt(struct skcipher_givcrypt_request *req)
80{ 66{
81 struct crypto_ablkcipher *geniv = skcipher_givcrypt_reqtfm(req); 67 struct crypto_ablkcipher *geniv = skcipher_givcrypt_reqtfm(req);
@@ -124,13 +110,13 @@ static int eseqiv_givencrypt(struct skcipher_givcrypt_request *req)
124 110
125 sg_init_table(reqctx->src, 2); 111 sg_init_table(reqctx->src, 2);
126 sg_set_buf(reqctx->src, giv, ivsize); 112 sg_set_buf(reqctx->src, giv, ivsize);
127 eseqiv_chain(reqctx->src, osrc, vsrc == giv + ivsize); 113 scatterwalk_crypto_chain(reqctx->src, osrc, vsrc == giv + ivsize, 2);
128 114
129 dst = reqctx->src; 115 dst = reqctx->src;
130 if (osrc != odst) { 116 if (osrc != odst) {
131 sg_init_table(reqctx->dst, 2); 117 sg_init_table(reqctx->dst, 2);
132 sg_set_buf(reqctx->dst, giv, ivsize); 118 sg_set_buf(reqctx->dst, giv, ivsize);
133 eseqiv_chain(reqctx->dst, odst, vdst == giv + ivsize); 119 scatterwalk_crypto_chain(reqctx->dst, odst, vdst == giv + ivsize, 2);
134 120
135 dst = reqctx->dst; 121 dst = reqctx->dst;
136 } 122 }
diff --git a/crypto/gcm.c b/crypto/gcm.c
index 2f5fbba6576c..1a252639ef91 100644
--- a/crypto/gcm.c
+++ b/crypto/gcm.c
@@ -1102,21 +1102,6 @@ static int crypto_rfc4543_setauthsize(struct crypto_aead *parent,
1102 return crypto_aead_setauthsize(ctx->child, authsize); 1102 return crypto_aead_setauthsize(ctx->child, authsize);
1103} 1103}
1104 1104
1105/* this is the same as crypto_authenc_chain */
1106static void crypto_rfc4543_chain(struct scatterlist *head,
1107 struct scatterlist *sg, int chain)
1108{
1109 if (chain) {
1110 head->length += sg->length;
1111 sg = scatterwalk_sg_next(sg);
1112 }
1113
1114 if (sg)
1115 scatterwalk_sg_chain(head, 2, sg);
1116 else
1117 sg_mark_end(head);
1118}
1119
1120static struct aead_request *crypto_rfc4543_crypt(struct aead_request *req, 1105static struct aead_request *crypto_rfc4543_crypt(struct aead_request *req,
1121 int enc) 1106 int enc)
1122{ 1107{
@@ -1154,13 +1139,13 @@ static struct aead_request *crypto_rfc4543_crypt(struct aead_request *req,
1154 1139
1155 sg_init_table(payload, 2); 1140 sg_init_table(payload, 2);
1156 sg_set_buf(payload, req->iv, 8); 1141 sg_set_buf(payload, req->iv, 8);
1157 crypto_rfc4543_chain(payload, dst, vdst == req->iv + 8); 1142 scatterwalk_crypto_chain(payload, dst, vdst == req->iv + 8, 2);
1158 assoclen += 8 + req->cryptlen - (enc ? 0 : authsize); 1143 assoclen += 8 + req->cryptlen - (enc ? 0 : authsize);
1159 1144
1160 sg_init_table(assoc, 2); 1145 sg_init_table(assoc, 2);
1161 sg_set_page(assoc, sg_page(req->assoc), req->assoc->length, 1146 sg_set_page(assoc, sg_page(req->assoc), req->assoc->length,
1162 req->assoc->offset); 1147 req->assoc->offset);
1163 crypto_rfc4543_chain(assoc, payload, 0); 1148 scatterwalk_crypto_chain(assoc, payload, 0, 2);
1164 1149
1165 aead_request_set_tfm(subreq, ctx->child); 1150 aead_request_set_tfm(subreq, ctx->child);
1166 aead_request_set_callback(subreq, req->base.flags, req->base.complete, 1151 aead_request_set_callback(subreq, req->base.flags, req->base.complete,