From: Jarod Wilson <jarod@redhat.com>
To: Herbert Xu <herbert@gondor.apana.org.au>
Cc: linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org,
Neil Horman <nhorman@tuxdriver.com>
Subject: [PATCH 2/3] crypto: handle ccm dec test vectors expected to fail verification
Date: Wed, 15 Apr 2009 09:36:43 -0400 [thread overview]
Message-ID: <200904150936.43919.jarod@redhat.com> (raw)
In-Reply-To: <200904150935.15947.jarod@redhat.com>
Add infrastructure to tcrypt to support handling ccm decryption test
vectors that are expected to fail verification.
Signed-off-by: Jarod Wilson <jarod@redhat.com>
---
crypto/testmgr.c | 32 ++++++++++++++++++++++++++++++++
crypto/testmgr.h | 1 +
2 files changed, 33 insertions(+), 0 deletions(-)
diff --git a/crypto/testmgr.c b/crypto/testmgr.c
index a8bdcb3..92f4df0 100644
--- a/crypto/testmgr.c
+++ b/crypto/testmgr.c
@@ -373,6 +373,16 @@ static int test_aead(struct crypto_aead *tfm, int enc,
switch (ret) {
case 0:
+ if (template[i].novrfy) {
+ /* verification was supposed to fail */
+ printk(KERN_ERR "alg: aead: %s failed "
+ "on test %d for %s: ret was 0, "
+ "expected -EBADMSG\n",
+ e, j, algo);
+ /* so really, we got a bad message */
+ ret = -EBADMSG;
+ goto out;
+ }
break;
case -EINPROGRESS:
case -EBUSY:
@@ -382,6 +392,10 @@ static int test_aead(struct crypto_aead *tfm, int enc,
INIT_COMPLETION(result.completion);
break;
}
+ case -EBADMSG:
+ if (template[i].novrfy)
+ /* verification failure was expected */
+ goto next_aead_vector;
/* fall through */
default:
printk(KERN_ERR "alg: aead: %s failed on test "
@@ -398,6 +412,8 @@ static int test_aead(struct crypto_aead *tfm, int enc,
goto out;
}
}
+next_aead_vector:
+ continue;
}
for (i = 0, j = 0; i < tcount; i++) {
@@ -491,6 +507,16 @@ static int test_aead(struct crypto_aead *tfm, int enc,
switch (ret) {
case 0:
+ if (template[i].novrfy) {
+ /* verification was supposed to fail */
+ printk(KERN_ERR "alg: aead: %s failed "
+ "on chunk test %d for %s: ret "
+ "was 0, expected -EBADMSG\n",
+ e, j, algo);
+ /* so really, we got a bad message */
+ ret = -EBADMSG;
+ goto out;
+ }
break;
case -EINPROGRESS:
case -EBUSY:
@@ -500,6 +526,10 @@ static int test_aead(struct crypto_aead *tfm, int enc,
INIT_COMPLETION(result.completion);
break;
}
+ case -EBADMSG:
+ if (template[i].novrfy)
+ /* verification failure was expected */
+ goto next_aead_chunk_vector;
/* fall through */
default:
printk(KERN_ERR "alg: aead: %s failed on "
@@ -550,6 +580,8 @@ static int test_aead(struct crypto_aead *tfm, int enc,
temp += template[i].tap[k];
}
}
+next_aead_chunk_vector:
+ continue;
}
ret = 0;
diff --git a/crypto/testmgr.h b/crypto/testmgr.h
index 526f00a..b77b61d 100644
--- a/crypto/testmgr.h
+++ b/crypto/testmgr.h
@@ -62,6 +62,7 @@ struct aead_testvec {
int np;
int anp;
unsigned char fail;
+ unsigned char novrfy; /* ccm dec verification failure expected */
unsigned char wk; /* weak key flag */
unsigned char klen;
unsigned short ilen;
--
1.6.2.2
--
Jarod Wilson
jarod@redhat.com
next prev parent reply other threads:[~2009-04-15 13:36 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-04-09 18:34 [PATCH] add self-tests for rfc4309(ccm(aes)) Jarod Wilson
2009-04-09 18:52 ` Neil Horman
2009-04-09 19:16 ` Jarod Wilson
2009-04-10 2:31 ` Neil Horman
2009-04-13 21:03 ` Jarod Wilson
2009-04-13 23:11 ` [PATCH v2] crypto: " Jarod Wilson
2009-04-14 11:13 ` Neil Horman
2009-04-15 11:20 ` Herbert Xu
2009-04-15 12:35 ` Jarod Wilson
2009-04-15 13:35 ` [PATCH 0/3] crypto: add testmgr support and self-tests for rfc4309 Jarod Wilson
2009-04-15 13:36 ` [PATCH 1/3] crypto: properly handle null input and assoc data aead test vectors Jarod Wilson
2009-04-20 6:23 ` Herbert Xu
2009-04-23 17:30 ` Jarod Wilson
2009-04-15 13:36 ` Jarod Wilson [this message]
2009-04-20 6:25 ` [PATCH 2/3] crypto: handle ccm dec test vectors expected to fail verification Herbert Xu
2009-04-23 17:31 ` Jarod Wilson
2009-04-15 13:37 ` [PATCH 3/3] crypto: add self-tests for rfc4309(ccm(aes)) Jarod Wilson
2009-04-20 6:26 ` Herbert Xu
2009-04-23 18:17 ` [PATCH v4 0/2] crypto: add testmgr support and self-tests for rfc4309 Jarod Wilson
2009-04-23 18:22 ` [PATCH 1/2] crypto: handle ccm dec test vectors expected to fail verification Jarod Wilson
2009-04-23 18:23 ` [PATCH 2/2] crypto: add self-tests for rfc4309(ccm(aes)) Jarod Wilson
2009-05-04 11:24 ` [PATCH v4 0/2] crypto: add testmgr support and self-tests for rfc4309 Herbert Xu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200904150936.43919.jarod@redhat.com \
--to=jarod@redhat.com \
--cc=herbert@gondor.apana.org.au \
--cc=linux-crypto@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nhorman@tuxdriver.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.