From: "Tan Swee Heng" <thesweeheng@gmail.com>
To: "Herbert Xu" <herbert@gondor.apana.org.au>,
"Linux Crypto" <linux-crypto@vger.kernel.org>
Subject: Re: [PATCH 1/2] tcrypt.c: Support for more test vectors
Date: Wed, 28 Nov 2007 07:20:24 +0800 [thread overview]
Message-ID: <fd3e431c0711271520i5c85c407w4753528bbeb70f3d@mail.gmail.com> (raw)
In-Reply-To: <fd3e431c0711271519j14fcd71aqc399c1dc524df274@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 447 bytes --]
New year resolution: I've got to remember to attach my patches. :-)
On Nov 28, 2007 7:19 AM, Tan Swee Heng <thesweeheng@gmail.com> wrote:
> Currently the number of entries in a cipher test vector template is
> limited by TVMEMSIZE/sizeof(struct cipher_testvec). This patch
> circumvents the problem by pointing cipher_tv to each entry in the
> template, rather than the template itself.
>
> Signed-off-by: Tan Swee Heng <thesweeheng@gmail.com>
>
[-- Attachment #2: patch1-more_tvs.txt --]
[-- Type: text/plain, Size: 4294 bytes --]
diff --git a/crypto/tcrypt.c b/crypto/tcrypt.c
index 1e12b86..71dc02a 100644
--- a/crypto/tcrypt.c
+++ b/crypto/tcrypt.c
@@ -471,15 +471,11 @@ static void test_cipher(char *algo, int enc,
printk("\ntesting %s %s\n", algo, e);
tsize = sizeof (struct cipher_testvec);
- tsize *= tcount;
-
if (tsize > TVMEMSIZE) {
printk("template (%u) too big for tvmem (%u)\n", tsize,
TVMEMSIZE);
return;
}
-
- memcpy(tvmem, template, tsize);
cipher_tv = (void *)tvmem;
init_completion(&result.completion);
@@ -503,33 +499,34 @@ static void test_cipher(char *algo, int enc,
j = 0;
for (i = 0; i < tcount; i++) {
- if (!(cipher_tv[i].np)) {
+ memcpy(cipher_tv, &template[i], tsize);
+ if (!(cipher_tv->np)) {
j++;
printk("test %u (%d bit key):\n",
- j, cipher_tv[i].klen * 8);
+ j, cipher_tv->klen * 8);
crypto_ablkcipher_clear_flags(tfm, ~0);
- if (cipher_tv[i].wk)
+ if (cipher_tv->wk)
crypto_ablkcipher_set_flags(
tfm, CRYPTO_TFM_REQ_WEAK_KEY);
- key = cipher_tv[i].key;
+ key = cipher_tv->key;
ret = crypto_ablkcipher_setkey(tfm, key,
- cipher_tv[i].klen);
+ cipher_tv->klen);
if (ret) {
printk("setkey() failed flags=%x\n",
crypto_ablkcipher_get_flags(tfm));
- if (!cipher_tv[i].fail)
+ if (!cipher_tv->fail)
goto out;
}
- sg_init_one(&sg[0], cipher_tv[i].input,
- cipher_tv[i].ilen);
+ sg_init_one(&sg[0], cipher_tv->input,
+ cipher_tv->ilen);
ablkcipher_request_set_crypt(req, sg, sg,
- cipher_tv[i].ilen,
- cipher_tv[i].iv);
+ cipher_tv->ilen,
+ cipher_tv->iv);
ret = enc ?
crypto_ablkcipher_encrypt(req) :
@@ -553,11 +550,11 @@ static void test_cipher(char *algo, int enc,
}
q = kmap(sg_page(&sg[0])) + sg[0].offset;
- hexdump(q, cipher_tv[i].rlen);
+ hexdump(q, cipher_tv->rlen);
printk("%s\n",
- memcmp(q, cipher_tv[i].result,
- cipher_tv[i].rlen) ? "fail" : "pass");
+ memcmp(q, cipher_tv->result,
+ cipher_tv->rlen) ? "fail" : "pass");
}
}
@@ -566,41 +563,42 @@ static void test_cipher(char *algo, int enc,
j = 0;
for (i = 0; i < tcount; i++) {
- if (cipher_tv[i].np) {
+ memcpy(cipher_tv, &template[i], tsize);
+ if (cipher_tv->np) {
j++;
printk("test %u (%d bit key):\n",
- j, cipher_tv[i].klen * 8);
+ j, cipher_tv->klen * 8);
crypto_ablkcipher_clear_flags(tfm, ~0);
- if (cipher_tv[i].wk)
+ if (cipher_tv->wk)
crypto_ablkcipher_set_flags(
tfm, CRYPTO_TFM_REQ_WEAK_KEY);
- key = cipher_tv[i].key;
+ key = cipher_tv->key;
ret = crypto_ablkcipher_setkey(tfm, key,
- cipher_tv[i].klen);
+ cipher_tv->klen);
if (ret) {
printk("setkey() failed flags=%x\n",
crypto_ablkcipher_get_flags(tfm));
- if (!cipher_tv[i].fail)
+ if (!cipher_tv->fail)
goto out;
}
temp = 0;
- sg_init_table(sg, cipher_tv[i].np);
- for (k = 0; k < cipher_tv[i].np; k++) {
+ sg_init_table(sg, cipher_tv->np);
+ for (k = 0; k < cipher_tv->np; k++) {
memcpy(&xbuf[IDX[k]],
- cipher_tv[i].input + temp,
- cipher_tv[i].tap[k]);
- temp += cipher_tv[i].tap[k];
+ cipher_tv->input + temp,
+ cipher_tv->tap[k]);
+ temp += cipher_tv->tap[k];
sg_set_buf(&sg[k], &xbuf[IDX[k]],
- cipher_tv[i].tap[k]);
+ cipher_tv->tap[k]);
}
ablkcipher_request_set_crypt(req, sg, sg,
- cipher_tv[i].ilen,
- cipher_tv[i].iv);
+ cipher_tv->ilen,
+ cipher_tv->iv);
ret = enc ?
crypto_ablkcipher_encrypt(req) :
@@ -624,15 +622,15 @@ static void test_cipher(char *algo, int enc,
}
temp = 0;
- for (k = 0; k < cipher_tv[i].np; k++) {
+ for (k = 0; k < cipher_tv->np; k++) {
printk("page %u\n", k);
q = kmap(sg_page(&sg[k])) + sg[k].offset;
- hexdump(q, cipher_tv[i].tap[k]);
+ hexdump(q, cipher_tv->tap[k]);
printk("%s\n",
- memcmp(q, cipher_tv[i].result + temp,
- cipher_tv[i].tap[k]) ? "fail" :
+ memcmp(q, cipher_tv->result + temp,
+ cipher_tv->tap[k]) ? "fail" :
"pass");
- temp += cipher_tv[i].tap[k];
+ temp += cipher_tv->tap[k];
}
}
}
next prev parent reply other threads:[~2007-11-27 23:20 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-11-27 23:19 [PATCH 1/2] tcrypt.c: Support for more test vectors Tan Swee Heng
2007-11-27 23:20 ` Tan Swee Heng [this message]
2007-11-29 13:30 ` 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=fd3e431c0711271520i5c85c407w4753528bbeb70f3d@mail.gmail.com \
--to=thesweeheng@gmail.com \
--cc=herbert@gondor.apana.org.au \
--cc=linux-crypto@vger.kernel.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).