crypto: seqiv - Copy AD along with plain/cipher text

As the AD does not necessarily exist in the destination buffer
it must be copied along with the plain/cipher text.

Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
This commit is contained in:
Herbert Xu 2015-05-27 14:37:36 +08:00
parent 9d03aee125
commit d0ad1b246d

View file

@ -315,19 +315,12 @@ static int seqiv_aead_encrypt_compat(struct aead_request *req)
data = req; data = req;
if (req->src != req->dst) { if (req->src != req->dst) {
struct scatterlist srcbuf[2];
struct scatterlist dstbuf[2];
struct blkcipher_desc desc = { struct blkcipher_desc desc = {
.tfm = ctx->null, .tfm = ctx->null,
}; };
err = crypto_blkcipher_encrypt( err = crypto_blkcipher_encrypt(&desc, req->dst, req->src,
&desc, req->assoclen + req->cryptlen);
scatterwalk_ffwd(dstbuf, req->dst,
req->assoclen + ivsize),
scatterwalk_ffwd(srcbuf, req->src,
req->assoclen + ivsize),
req->cryptlen - ivsize);
if (err) if (err)
return err; return err;
} }
@ -373,19 +366,12 @@ static int seqiv_aead_encrypt(struct aead_request *req)
info = req->iv; info = req->iv;
if (req->src != req->dst) { if (req->src != req->dst) {
struct scatterlist src[2];
struct scatterlist dst[2];
struct blkcipher_desc desc = { struct blkcipher_desc desc = {
.tfm = ctx->null, .tfm = ctx->null,
}; };
err = crypto_blkcipher_encrypt( err = crypto_blkcipher_encrypt(&desc, req->dst, req->src,
&desc, req->assoclen + req->cryptlen);
scatterwalk_ffwd(dst, req->dst,
req->assoclen + ivsize),
scatterwalk_ffwd(src, req->src,
req->assoclen + ivsize),
req->cryptlen - ivsize);
if (err) if (err)
return err; return err;
} }
@ -446,19 +432,12 @@ static int seqiv_aead_decrypt_compat(struct aead_request *req)
} }
if (req->src != req->dst) { if (req->src != req->dst) {
struct scatterlist srcbuf[2];
struct scatterlist dstbuf[2];
struct blkcipher_desc desc = { struct blkcipher_desc desc = {
.tfm = ctx->null, .tfm = ctx->null,
}; };
err = crypto_blkcipher_encrypt( err = crypto_blkcipher_encrypt(&desc, req->dst, req->src,
&desc, req->assoclen + req->cryptlen);
scatterwalk_ffwd(dstbuf, req->dst,
req->assoclen + ivsize),
scatterwalk_ffwd(srcbuf, req->src,
req->assoclen + ivsize),
req->cryptlen - ivsize);
if (err) if (err)
return err; return err;
} }