提交 de197533 编写于 作者: N Nicolas Royer 提交者: Herbert Xu

crypto: atmel - add new tests to tcrypt

- set sg buffers size equals to message size
- add cfb & ofb tests for AES, DES & TDES
Signed-off-by: NNicolas Royer <nicolas@eukrea.com>
Acked-by: NNicolas Ferre <nicolas.ferre@atmel.com>
Acked-by: NEric Bénard <eric@eukrea.com>
Tested-by: NEric Bénard <eric@eukrea.com>
Signed-off-by: NHerbert Xu <herbert@gondor.apana.org.au>
上级 ebc82efa
...@@ -809,7 +809,7 @@ static void test_acipher_speed(const char *algo, int enc, unsigned int sec, ...@@ -809,7 +809,7 @@ static void test_acipher_speed(const char *algo, int enc, unsigned int sec,
struct cipher_speed_template *template, struct cipher_speed_template *template,
unsigned int tcount, u8 *keysize) unsigned int tcount, u8 *keysize)
{ {
unsigned int ret, i, j, iv_len; unsigned int ret, i, j, k, iv_len;
struct tcrypt_result tresult; struct tcrypt_result tresult;
const char *key; const char *key;
char iv[128]; char iv[128];
...@@ -883,11 +883,23 @@ static void test_acipher_speed(const char *algo, int enc, unsigned int sec, ...@@ -883,11 +883,23 @@ static void test_acipher_speed(const char *algo, int enc, unsigned int sec,
} }
sg_init_table(sg, TVMEMSIZE); sg_init_table(sg, TVMEMSIZE);
sg_set_buf(sg, tvmem[0] + *keysize,
k = *keysize + *b_size;
if (k > PAGE_SIZE) {
sg_set_buf(sg, tvmem[0] + *keysize,
PAGE_SIZE - *keysize); PAGE_SIZE - *keysize);
for (j = 1; j < TVMEMSIZE; j++) { k -= PAGE_SIZE;
sg_set_buf(sg + j, tvmem[j], PAGE_SIZE); j = 1;
memset(tvmem[j], 0xff, PAGE_SIZE); while (k > PAGE_SIZE) {
sg_set_buf(sg + j, tvmem[j], PAGE_SIZE);
memset(tvmem[j], 0xff, PAGE_SIZE);
j++;
k -= PAGE_SIZE;
}
sg_set_buf(sg + j, tvmem[j], k);
memset(tvmem[j], 0xff, k);
} else {
sg_set_buf(sg, tvmem[0] + *keysize, *b_size);
} }
iv_len = crypto_ablkcipher_ivsize(tfm); iv_len = crypto_ablkcipher_ivsize(tfm);
...@@ -1520,6 +1532,14 @@ static int do_test(int m) ...@@ -1520,6 +1532,14 @@ static int do_test(int m)
speed_template_16_24_32); speed_template_16_24_32);
test_acipher_speed("ctr(aes)", DECRYPT, sec, NULL, 0, test_acipher_speed("ctr(aes)", DECRYPT, sec, NULL, 0,
speed_template_16_24_32); speed_template_16_24_32);
test_acipher_speed("cfb(aes)", ENCRYPT, sec, NULL, 0,
speed_template_16_24_32);
test_acipher_speed("cfb(aes)", DECRYPT, sec, NULL, 0,
speed_template_16_24_32);
test_acipher_speed("ofb(aes)", ENCRYPT, sec, NULL, 0,
speed_template_16_24_32);
test_acipher_speed("ofb(aes)", DECRYPT, sec, NULL, 0,
speed_template_16_24_32);
break; break;
case 501: case 501:
...@@ -1535,6 +1555,18 @@ static int do_test(int m) ...@@ -1535,6 +1555,18 @@ static int do_test(int m)
test_acipher_speed("cbc(des3_ede)", DECRYPT, sec, test_acipher_speed("cbc(des3_ede)", DECRYPT, sec,
des3_speed_template, DES3_SPEED_VECTORS, des3_speed_template, DES3_SPEED_VECTORS,
speed_template_24); speed_template_24);
test_acipher_speed("cfb(des3_ede)", ENCRYPT, sec,
des3_speed_template, DES3_SPEED_VECTORS,
speed_template_24);
test_acipher_speed("cfb(des3_ede)", DECRYPT, sec,
des3_speed_template, DES3_SPEED_VECTORS,
speed_template_24);
test_acipher_speed("ofb(des3_ede)", ENCRYPT, sec,
des3_speed_template, DES3_SPEED_VECTORS,
speed_template_24);
test_acipher_speed("ofb(des3_ede)", DECRYPT, sec,
des3_speed_template, DES3_SPEED_VECTORS,
speed_template_24);
break; break;
case 502: case 502:
...@@ -1546,6 +1578,14 @@ static int do_test(int m) ...@@ -1546,6 +1578,14 @@ static int do_test(int m)
speed_template_8); speed_template_8);
test_acipher_speed("cbc(des)", DECRYPT, sec, NULL, 0, test_acipher_speed("cbc(des)", DECRYPT, sec, NULL, 0,
speed_template_8); speed_template_8);
test_acipher_speed("cfb(des)", ENCRYPT, sec, NULL, 0,
speed_template_8);
test_acipher_speed("cfb(des)", DECRYPT, sec, NULL, 0,
speed_template_8);
test_acipher_speed("ofb(des)", ENCRYPT, sec, NULL, 0,
speed_template_8);
test_acipher_speed("ofb(des)", DECRYPT, sec, NULL, 0,
speed_template_8);
break; break;
case 503: case 503:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册