Skip to content

Commit

Permalink
crypto: testmgr - Allow hash test vectors longer than a page
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Herbert Xu committed Jun 2, 2009
1 parent fd57f22 commit a0cfae5
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions crypto/testmgr.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
tcrypt_complete, &tresult);

j = 0;
for (i = 0; i < tcount; i++) {
if (template[i].np)
continue;

j++;
memset(result, 0, 64);

hash_buff = xbuf[0];
Expand All @@ -198,7 +203,7 @@ static int test_hash(struct crypto_ahash *tfm, struct hash_testvec *template,
template[i].ksize);
if (ret) {
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);
goto out;
}
Expand All @@ -220,14 +225,14 @@ static int test_hash(struct crypto_ahash *tfm, struct hash_testvec *template,
/* fall through */
default:
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;
}

if (memcmp(result, template[i].digest,
crypto_ahash_digestsize(tfm))) {
printk(KERN_ERR "alg: hash: Test %d failed for %s\n",
i + 1, algo);
j, algo);
hexdump(result, crypto_ahash_digestsize(tfm));
ret = -EINVAL;
goto out;
Expand Down

0 comments on commit a0cfae5

Please sign in to comment.