crypto: aead - Preserve in-place processing in old_crypt
authorHerbert Xu <herbert@gondor.apana.org.au>
Wed, 27 May 2015 06:37:29 +0000 (14:37 +0800)
committerHerbert Xu <herbert@gondor.apana.org.au>
Thu, 28 May 2015 03:23:17 +0000 (11:23 +0800)
This patch tries to preserve in-place processing in old_crypt as
various algorithms are optimised for in-place processing where
src == dst.

Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
crypto/aead.c

index 7c3d725bd26481bbc9b4574736510b9f0f3090b4..35c55e04fcbc99ddf3dc91d6238bb9da1948ffc4 100644 (file)
@@ -107,7 +107,8 @@ static int old_crypt(struct aead_request *req,
                return crypt(req);
 
        src = scatterwalk_ffwd(nreq->srcbuf, req->src, req->assoclen);
-       dst = scatterwalk_ffwd(nreq->dstbuf, req->dst, req->assoclen);
+       dst = req->src == req->dst ?
+             src : scatterwalk_ffwd(nreq->dstbuf, req->dst, req->assoclen);
 
        aead_request_set_tfm(&nreq->subreq, aead);
        aead_request_set_callback(&nreq->subreq, aead_request_flags(req),