Commit 921bae54693f26d01fb8e10ee6968b5cd8184551

Authored by Shikhar Khattar
Committed by Herbert Xu
1 parent 60f208d783

crypto: authenc - Fix cryptlen calculation

This patch (applied against 2.6.34) fixes the calculation of the
length of the ABLKCIPHER decrypt request ("cryptlen") after an
asynchronous hash request has been completed in the AUTHENC interface.

Signed-off-by: Shikhar Khattar <shikhark@gmail.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

Showing 1 changed file with 6 additions and 2 deletions Side-by-side Diff

... ... @@ -181,6 +181,7 @@
181 181 struct crypto_authenc_ctx *ctx = crypto_aead_ctx(authenc);
182 182 struct authenc_request_ctx *areq_ctx = aead_request_ctx(req);
183 183 struct ahash_request *ahreq = (void *)(areq_ctx->tail + ctx->reqoff);
  184 + unsigned int cryptlen = req->cryptlen;
184 185  
185 186 if (err)
186 187 goto out;
... ... @@ -196,6 +197,7 @@
196 197 goto out;
197 198  
198 199 authsize = crypto_aead_authsize(authenc);
  200 + cryptlen -= authsize;
199 201 ihash = ahreq->result + authsize;
200 202 scatterwalk_map_and_copy(ihash, areq_ctx->sg, areq_ctx->cryptlen,
201 203 authsize, 0);
... ... @@ -209,7 +211,7 @@
209 211 ablkcipher_request_set_callback(abreq, aead_request_flags(req),
210 212 req->base.complete, req->base.data);
211 213 ablkcipher_request_set_crypt(abreq, req->src, req->dst,
212   - req->cryptlen, req->iv);
  214 + cryptlen, req->iv);
213 215  
214 216 err = crypto_ablkcipher_decrypt(abreq);
215 217  
216 218  
... ... @@ -228,11 +230,13 @@
228 230 struct crypto_authenc_ctx *ctx = crypto_aead_ctx(authenc);
229 231 struct authenc_request_ctx *areq_ctx = aead_request_ctx(req);
230 232 struct ahash_request *ahreq = (void *)(areq_ctx->tail + ctx->reqoff);
  233 + unsigned int cryptlen = req->cryptlen;
231 234  
232 235 if (err)
233 236 goto out;
234 237  
235 238 authsize = crypto_aead_authsize(authenc);
  239 + cryptlen -= authsize;
236 240 ihash = ahreq->result + authsize;
237 241 scatterwalk_map_and_copy(ihash, areq_ctx->sg, areq_ctx->cryptlen,
238 242 authsize, 0);
... ... @@ -246,7 +250,7 @@
246 250 ablkcipher_request_set_callback(abreq, aead_request_flags(req),
247 251 req->base.complete, req->base.data);
248 252 ablkcipher_request_set_crypt(abreq, req->src, req->dst,
249   - req->cryptlen, req->iv);
  253 + cryptlen, req->iv);
250 254  
251 255 err = crypto_ablkcipher_decrypt(abreq);
252 256