aboutsummaryrefslogtreecommitdiffstats
path: root/crypto
diff options
context:
space:
mode:
Diffstat (limited to 'crypto')
-rw-r--r--crypto/authenc.c24
-rw-r--r--crypto/blkcipher.c2
-rw-r--r--crypto/ccm.c2
3 files changed, 18 insertions, 10 deletions
diff --git a/crypto/authenc.c b/crypto/authenc.c
index 40b6e9ec9e3a..5793b64c81a8 100644
--- a/crypto/authenc.c
+++ b/crypto/authenc.c
@@ -158,16 +158,19 @@ static int crypto_authenc_genicv(struct aead_request *req, u8 *iv,
158 dstp = sg_page(dst); 158 dstp = sg_page(dst);
159 vdst = PageHighMem(dstp) ? NULL : page_address(dstp) + dst->offset; 159 vdst = PageHighMem(dstp) ? NULL : page_address(dstp) + dst->offset;
160 160
161 sg_init_table(cipher, 2); 161 if (ivsize) {
162 sg_set_buf(cipher, iv, ivsize); 162 sg_init_table(cipher, 2);
163 authenc_chain(cipher, dst, vdst == iv + ivsize); 163 sg_set_buf(cipher, iv, ivsize);
164 authenc_chain(cipher, dst, vdst == iv + ivsize);
165 dst = cipher;
166 }
164 167
165 cryptlen = req->cryptlen + ivsize; 168 cryptlen = req->cryptlen + ivsize;
166 hash = crypto_authenc_hash(req, flags, cipher, cryptlen); 169 hash = crypto_authenc_hash(req, flags, dst, cryptlen);
167 if (IS_ERR(hash)) 170 if (IS_ERR(hash))
168 return PTR_ERR(hash); 171 return PTR_ERR(hash);
169 172
170 scatterwalk_map_and_copy(hash, cipher, cryptlen, 173 scatterwalk_map_and_copy(hash, dst, cryptlen,
171 crypto_aead_authsize(authenc), 1); 174 crypto_aead_authsize(authenc), 1);
172 return 0; 175 return 0;
173} 176}
@@ -285,11 +288,14 @@ static int crypto_authenc_iverify(struct aead_request *req, u8 *iv,
285 srcp = sg_page(src); 288 srcp = sg_page(src);
286 vsrc = PageHighMem(srcp) ? NULL : page_address(srcp) + src->offset; 289 vsrc = PageHighMem(srcp) ? NULL : page_address(srcp) + src->offset;
287 290
288 sg_init_table(cipher, 2); 291 if (ivsize) {
289 sg_set_buf(cipher, iv, ivsize); 292 sg_init_table(cipher, 2);
290 authenc_chain(cipher, src, vsrc == iv + ivsize); 293 sg_set_buf(cipher, iv, ivsize);
294 authenc_chain(cipher, src, vsrc == iv + ivsize);
295 src = cipher;
296 }
291 297
292 return crypto_authenc_verify(req, cipher, cryptlen + ivsize); 298 return crypto_authenc_verify(req, src, cryptlen + ivsize);
293} 299}
294 300
295static int crypto_authenc_decrypt(struct aead_request *req) 301static int crypto_authenc_decrypt(struct aead_request *req)
diff --git a/crypto/blkcipher.c b/crypto/blkcipher.c
index 4a7e65c4df4d..d70a41c002df 100644
--- a/crypto/blkcipher.c
+++ b/crypto/blkcipher.c
@@ -124,6 +124,7 @@ int blkcipher_walk_done(struct blkcipher_desc *desc,
124 scatterwalk_done(&walk->in, 0, nbytes); 124 scatterwalk_done(&walk->in, 0, nbytes);
125 scatterwalk_done(&walk->out, 1, nbytes); 125 scatterwalk_done(&walk->out, 1, nbytes);
126 126
127err:
127 walk->total = nbytes; 128 walk->total = nbytes;
128 walk->nbytes = nbytes; 129 walk->nbytes = nbytes;
129 130
@@ -132,7 +133,6 @@ int blkcipher_walk_done(struct blkcipher_desc *desc,
132 return blkcipher_walk_next(desc, walk); 133 return blkcipher_walk_next(desc, walk);
133 } 134 }
134 135
135err:
136 if (walk->iv != desc->info) 136 if (walk->iv != desc->info)
137 memcpy(desc->info, walk->iv, crypto_blkcipher_ivsize(tfm)); 137 memcpy(desc->info, walk->iv, crypto_blkcipher_ivsize(tfm));
138 if (walk->buffer != walk->page) 138 if (walk->buffer != walk->page)
diff --git a/crypto/ccm.c b/crypto/ccm.c
index 7cf7e5a6b781..c36d654cf56a 100644
--- a/crypto/ccm.c
+++ b/crypto/ccm.c
@@ -266,6 +266,8 @@ static int crypto_ccm_auth(struct aead_request *req, struct scatterlist *plain,
266 if (assoclen) { 266 if (assoclen) {
267 pctx->ilen = format_adata(idata, assoclen); 267 pctx->ilen = format_adata(idata, assoclen);
268 get_data_to_compute(cipher, pctx, req->assoc, req->assoclen); 268 get_data_to_compute(cipher, pctx, req->assoc, req->assoclen);
269 } else {
270 pctx->ilen = 0;
269 } 271 }
270 272
271 /* compute plaintext into mac */ 273 /* compute plaintext into mac */