]> git.karo-electronics.de Git - linux-beck.git/commitdiff
crypto: testmgr - Handle AEAD test vectors expected to fail verification
authorJarod Wilson <jarod@redhat.com>
Mon, 4 May 2009 11:22:11 +0000 (19:22 +0800)
committerHerbert Xu <herbert@gondor.apana.org.au>
Tue, 2 Jun 2009 04:04:35 +0000 (14:04 +1000)
Add infrastructure to tcrypt/testmgr to support handling ccm decryption
test vectors that are expected to fail verification.

Signed-off-by: Jarod Wilson <jarod@redhat.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
crypto/testmgr.c
crypto/testmgr.h

index bfee6e9f642dd865cdd4452164fc9dc1e18a9e58..84f96401b29a655d904a77b0ac6b705b7b6a3842 100644 (file)
@@ -363,6 +363,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:
@@ -372,6 +382,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 */
+                                       continue;
                                /* fall through */
                        default:
                                printk(KERN_ERR "alg: aead: %s failed on test "
@@ -481,6 +495,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:
@@ -490,6 +514,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 */
+                                       continue;
                                /* fall through */
                        default:
                                printk(KERN_ERR "alg: aead: %s failed on "
index 526f00a9c72feba6acd49b42f0281a79944657e5..b77b61dad2621cf7bf3c857d7678cb7adf4153f8 100644 (file)
@@ -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;