2008-07-30 08:42:22

by Herbert Xu

[permalink] [raw]
Subject: crypto: tcrypt - Fix AEAD testing

Hi:

Just noticed a regression I caused:

commit 80cdd7e17b52d343c4fe9d3860f84204ead0d9a0
Author: Herbert Xu <[email protected]>
Date: Wed Jul 30 16:23:51 2008 +0800

crypto: tcrypt - Fix AEAD testing

My changeset 4b22f0ddb6564210c9ded7ba25b2a1007733e784

crypto: tcrpyt - Remove unnecessary kmap/kunmap calls

introduced a typo that broke AEAD chunk testing. In particular,
axbuf should really be xbuf.

Signed-off-by: Herbert Xu <[email protected]>

diff --git a/crypto/tcrypt.c b/crypto/tcrypt.c
index 59821a2..a25d6e2 100644
--- a/crypto/tcrypt.c
+++ b/crypto/tcrypt.c
@@ -481,7 +481,7 @@ next_one:

for (k = 0, temp = 0; k < template[i].np; k++) {
printk(KERN_INFO "page %u\n", k);
- q = &axbuf[IDX[k]];
+ q = &xbuf[IDX[k]];
hexdump(q, template[i].tap[k]);
printk(KERN_INFO "%s\n",
memcmp(q, template[i].result + temp,

Cheers,
--
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt


2008-07-30 12:57:36

by Herbert Xu

[permalink] [raw]
Subject: Re: crypto: tcrypt - Fix AEAD testing

On Wed, Jul 30, 2008 at 04:42:19PM +0800, Herbert Xu wrote:
> Hi:
>
> Just noticed a regression I caused:

Hmm, AEAD chunk testing still didn't quite work. Looks like it's
been broken for a while. This makes it go again.

commit 3c19fe451e050111d7da607788f09979a7af92e6
Author: Herbert Xu <[email protected]>
Date: Wed Jul 30 16:23:51 2008 +0800

crypto: tcrypt - Fix AEAD chunk testing

My changeset 4b22f0ddb6564210c9ded7ba25b2a1007733e784

crypto: tcrpyt - Remove unnecessary kmap/kunmap calls

introduced a typo that broke AEAD chunk testing. In particular,
axbuf should really be xbuf.

There is also an issue with testing the last segment when encrypting.
The additional part produced by AEAD wasn't tested. Similarly, on
decryption the additional part of the AEAD input is mistaken for
corruption.

Signed-off-by: Herbert Xu <[email protected]>

diff --git a/crypto/tcrypt.c b/crypto/tcrypt.c
index 59821a2..6636802 100644
--- a/crypto/tcrypt.c
+++ b/crypto/tcrypt.c
@@ -481,21 +481,31 @@ next_one:

for (k = 0, temp = 0; k < template[i].np; k++) {
printk(KERN_INFO "page %u\n", k);
- q = &axbuf[IDX[k]];
- hexdump(q, template[i].tap[k]);
+ q = &xbuf[IDX[k]];
+
+ n = template[i].tap[k];
+ if (k == template[i].np - 1)
+ n += enc ? authsize : -authsize;
+ hexdump(q, n);
printk(KERN_INFO "%s\n",
- memcmp(q, template[i].result + temp,
- template[i].tap[k] -
- (k < template[i].np - 1 || enc ?
- 0 : authsize)) ?
+ memcmp(q, template[i].result + temp, n) ?
"fail" : "pass");

- for (n = 0; q[template[i].tap[k] + n]; n++)
- ;
+ q += n;
+ if (k == template[i].np - 1 && !enc) {
+ if (memcmp(q, template[i].input +
+ temp + n, authsize))
+ n = authsize;
+ else
+ n = 0;
+ } else {
+ for (n = 0; q[n]; n++)
+ ;
+ }
if (n) {
printk("Result buffer corruption %u "
"bytes:\n", n);
- hexdump(&q[template[i].tap[k]], n);
+ hexdump(q, n);
}

temp += template[i].tap[k];

Cheers,
--
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt