diff options
author | Jarod Wilson <jarod@redhat.com> | 2009-05-04 07:22:11 -0400 |
---|---|---|
committer | Herbert Xu <herbert@gondor.apana.org.au> | 2009-06-02 00:04:35 -0400 |
commit | e44a1b44c3a9794236fe038b89a0fbef5adcd523 (patch) | |
tree | 7d7b1555a6ba67ed053b816f3470ce964b156c07 /crypto | |
parent | 2f8174187f409213e63c3589af163c627e8a182a (diff) |
crypto: testmgr - Handle AEAD test vectors expected to fail verification
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>
Diffstat (limited to 'crypto')
-rw-r--r-- | crypto/testmgr.c | 28 | ||||
-rw-r--r-- | crypto/testmgr.h | 1 |
2 files changed, 29 insertions, 0 deletions
diff --git a/crypto/testmgr.c b/crypto/testmgr.c index bfee6e9f642d..84f96401b29a 100644 --- a/crypto/testmgr.c +++ b/crypto/testmgr.c | |||
@@ -363,6 +363,16 @@ static int test_aead(struct crypto_aead *tfm, int enc, | |||
363 | 363 | ||
364 | switch (ret) { | 364 | switch (ret) { |
365 | case 0: | 365 | case 0: |
366 | if (template[i].novrfy) { | ||
367 | /* verification was supposed to fail */ | ||
368 | printk(KERN_ERR "alg: aead: %s failed " | ||
369 | "on test %d for %s: ret was 0, " | ||
370 | "expected -EBADMSG\n", | ||
371 | e, j, algo); | ||
372 | /* so really, we got a bad message */ | ||
373 | ret = -EBADMSG; | ||
374 | goto out; | ||
375 | } | ||
366 | break; | 376 | break; |
367 | case -EINPROGRESS: | 377 | case -EINPROGRESS: |
368 | case -EBUSY: | 378 | case -EBUSY: |
@@ -372,6 +382,10 @@ static int test_aead(struct crypto_aead *tfm, int enc, | |||
372 | INIT_COMPLETION(result.completion); | 382 | INIT_COMPLETION(result.completion); |
373 | break; | 383 | break; |
374 | } | 384 | } |
385 | case -EBADMSG: | ||
386 | if (template[i].novrfy) | ||
387 | /* verification failure was expected */ | ||
388 | continue; | ||
375 | /* fall through */ | 389 | /* fall through */ |
376 | default: | 390 | default: |
377 | printk(KERN_ERR "alg: aead: %s failed on test " | 391 | printk(KERN_ERR "alg: aead: %s failed on test " |
@@ -481,6 +495,16 @@ static int test_aead(struct crypto_aead *tfm, int enc, | |||
481 | 495 | ||
482 | switch (ret) { | 496 | switch (ret) { |
483 | case 0: | 497 | case 0: |
498 | if (template[i].novrfy) { | ||
499 | /* verification was supposed to fail */ | ||
500 | printk(KERN_ERR "alg: aead: %s failed " | ||
501 | "on chunk test %d for %s: ret " | ||
502 | "was 0, expected -EBADMSG\n", | ||
503 | e, j, algo); | ||
504 | /* so really, we got a bad message */ | ||
505 | ret = -EBADMSG; | ||
506 | goto out; | ||
507 | } | ||
484 | break; | 508 | break; |
485 | case -EINPROGRESS: | 509 | case -EINPROGRESS: |
486 | case -EBUSY: | 510 | case -EBUSY: |
@@ -490,6 +514,10 @@ static int test_aead(struct crypto_aead *tfm, int enc, | |||
490 | INIT_COMPLETION(result.completion); | 514 | INIT_COMPLETION(result.completion); |
491 | break; | 515 | break; |
492 | } | 516 | } |
517 | case -EBADMSG: | ||
518 | if (template[i].novrfy) | ||
519 | /* verification failure was expected */ | ||
520 | continue; | ||
493 | /* fall through */ | 521 | /* fall through */ |
494 | default: | 522 | default: |
495 | printk(KERN_ERR "alg: aead: %s failed on " | 523 | printk(KERN_ERR "alg: aead: %s failed on " |
diff --git a/crypto/testmgr.h b/crypto/testmgr.h index 526f00a9c72f..b77b61dad262 100644 --- a/crypto/testmgr.h +++ b/crypto/testmgr.h | |||
@@ -62,6 +62,7 @@ struct aead_testvec { | |||
62 | int np; | 62 | int np; |
63 | int anp; | 63 | int anp; |
64 | unsigned char fail; | 64 | unsigned char fail; |
65 | unsigned char novrfy; /* ccm dec verification failure expected */ | ||
65 | unsigned char wk; /* weak key flag */ | 66 | unsigned char wk; /* weak key flag */ |
66 | unsigned char klen; | 67 | unsigned char klen; |
67 | unsigned short ilen; | 68 | unsigned short ilen; |