Commit 8ec25c51 authored by Horia Geanta's avatar Horia Geanta Committed by Herbert Xu

crypto: testmgr - fix sglen in test_aead for case 'dst != src'

Commit d8a32ac2 (crypto: testmgr - make
test_aead also test 'dst != src' code paths) added support for different
source and destination buffers in test_aead.

This patch modifies the source and destination buffer lengths accordingly:
the lengths are not equal since encryption / decryption adds / removes
the ICV.

Cc: Jussi Kivilinna <jussi.kivilinna@mbnet.fi>
Signed-off-by: default avatarHoria Geanta <horia.geanta@freescale.com>
Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
parent 62293a37
...@@ -503,16 +503,16 @@ static int __test_aead(struct crypto_aead *tfm, int enc, ...@@ -503,16 +503,16 @@ static int __test_aead(struct crypto_aead *tfm, int enc,
goto out; goto out;
} }
sg_init_one(&sg[0], input,
template[i].ilen + (enc ? authsize : 0));
if (diff_dst) { if (diff_dst) {
output = xoutbuf[0]; output = xoutbuf[0];
output += align_offset; output += align_offset;
sg_init_one(&sg[0], input, template[i].ilen);
sg_init_one(&sgout[0], output, sg_init_one(&sgout[0], output,
template[i].rlen);
} else {
sg_init_one(&sg[0], input,
template[i].ilen + template[i].ilen +
(enc ? authsize : 0)); (enc ? authsize : 0));
} else {
output = input; output = input;
} }
...@@ -612,12 +612,6 @@ static int __test_aead(struct crypto_aead *tfm, int enc, ...@@ -612,12 +612,6 @@ static int __test_aead(struct crypto_aead *tfm, int enc,
memcpy(q, template[i].input + temp, memcpy(q, template[i].input + temp,
template[i].tap[k]); template[i].tap[k]);
n = template[i].tap[k];
if (k == template[i].np - 1 && enc)
n += authsize;
if (offset_in_page(q) + n < PAGE_SIZE)
q[n] = 0;
sg_set_buf(&sg[k], q, template[i].tap[k]); sg_set_buf(&sg[k], q, template[i].tap[k]);
if (diff_dst) { if (diff_dst) {
...@@ -625,13 +619,17 @@ static int __test_aead(struct crypto_aead *tfm, int enc, ...@@ -625,13 +619,17 @@ static int __test_aead(struct crypto_aead *tfm, int enc,
offset_in_page(IDX[k]); offset_in_page(IDX[k]);
memset(q, 0, template[i].tap[k]); memset(q, 0, template[i].tap[k]);
if (offset_in_page(q) + n < PAGE_SIZE)
q[n] = 0;
sg_set_buf(&sgout[k], q, sg_set_buf(&sgout[k], q,
template[i].tap[k]); template[i].tap[k]);
} }
n = template[i].tap[k];
if (k == template[i].np - 1 && enc)
n += authsize;
if (offset_in_page(q) + n < PAGE_SIZE)
q[n] = 0;
temp += template[i].tap[k]; temp += template[i].tap[k];
} }
...@@ -650,10 +648,10 @@ static int __test_aead(struct crypto_aead *tfm, int enc, ...@@ -650,10 +648,10 @@ static int __test_aead(struct crypto_aead *tfm, int enc,
goto out; goto out;
} }
sg[k - 1].length += authsize;
if (diff_dst) if (diff_dst)
sgout[k - 1].length += authsize; sgout[k - 1].length += authsize;
else
sg[k - 1].length += authsize;
} }
sg_init_table(asg, template[i].anp); sg_init_table(asg, template[i].anp);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment