crypto: testmgr - Allow hash test vectors longer than a page

As it stands we will each test hash vector both linearly and as
a scatter list if applicable.  This means that we cannot have
vectors longer than a page, even with scatter lists.

This patch fixes this by skipping test vectors with np != 0 when
testing linearly.

Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
This commit is contained in:
Herbert Xu 2009-05-29 16:23:12 +10:00
parent fd57f22a09
commit a0cfae59f8
1 changed files with 8 additions and 3 deletions

View File

@ -180,7 +180,12 @@ static int test_hash(struct crypto_ahash *tfm, struct hash_testvec *template,
ahash_request_set_callback(req, CRYPTO_TFM_REQ_MAY_BACKLOG, ahash_request_set_callback(req, CRYPTO_TFM_REQ_MAY_BACKLOG,
tcrypt_complete, &tresult); tcrypt_complete, &tresult);
j = 0;
for (i = 0; i < tcount; i++) { for (i = 0; i < tcount; i++) {
if (template[i].np)
continue;
j++;
memset(result, 0, 64); memset(result, 0, 64);
hash_buff = xbuf[0]; hash_buff = xbuf[0];
@ -198,7 +203,7 @@ static int test_hash(struct crypto_ahash *tfm, struct hash_testvec *template,
template[i].ksize); template[i].ksize);
if (ret) { if (ret) {
printk(KERN_ERR "alg: hash: setkey failed on " printk(KERN_ERR "alg: hash: setkey failed on "
"test %d for %s: ret=%d\n", i + 1, algo, "test %d for %s: ret=%d\n", j, algo,
-ret); -ret);
goto out; goto out;
} }
@ -220,14 +225,14 @@ static int test_hash(struct crypto_ahash *tfm, struct hash_testvec *template,
/* fall through */ /* fall through */
default: default:
printk(KERN_ERR "alg: hash: digest failed on test %d " printk(KERN_ERR "alg: hash: digest failed on test %d "
"for %s: ret=%d\n", i + 1, algo, -ret); "for %s: ret=%d\n", j, algo, -ret);
goto out; goto out;
} }
if (memcmp(result, template[i].digest, if (memcmp(result, template[i].digest,
crypto_ahash_digestsize(tfm))) { crypto_ahash_digestsize(tfm))) {
printk(KERN_ERR "alg: hash: Test %d failed for %s\n", printk(KERN_ERR "alg: hash: Test %d failed for %s\n",
i + 1, algo); j, algo);
hexdump(result, crypto_ahash_digestsize(tfm)); hexdump(result, crypto_ahash_digestsize(tfm));
ret = -EINVAL; ret = -EINVAL;
goto out; goto out;