diff options
Diffstat (limited to 'crypto/tcrypt.c')
| -rw-r--r-- | crypto/tcrypt.c | 56 | 
1 files changed, 17 insertions, 39 deletions
| diff --git a/crypto/tcrypt.c b/crypto/tcrypt.c index 68639419c5bd..53f4ee804bdb 100644 --- a/crypto/tcrypt.c +++ b/crypto/tcrypt.c | |||
| @@ -21,7 +21,7 @@ | |||
| 21 | #include <linux/module.h> | 21 | #include <linux/module.h> | 
| 22 | #include <linux/mm.h> | 22 | #include <linux/mm.h> | 
| 23 | #include <linux/slab.h> | 23 | #include <linux/slab.h> | 
| 24 | #include <asm/scatterlist.h> | 24 | #include <linux/scatterlist.h> | 
| 25 | #include <linux/string.h> | 25 | #include <linux/string.h> | 
| 26 | #include <linux/crypto.h> | 26 | #include <linux/crypto.h> | 
| 27 | #include <linux/highmem.h> | 27 | #include <linux/highmem.h> | 
| @@ -86,7 +86,6 @@ static void hexdump(unsigned char *buf, unsigned int len) | |||
| 86 | static void test_hash(char *algo, struct hash_testvec *template, | 86 | static void test_hash(char *algo, struct hash_testvec *template, | 
| 87 | unsigned int tcount) | 87 | unsigned int tcount) | 
| 88 | { | 88 | { | 
| 89 | char *p; | ||
| 90 | unsigned int i, j, k, temp; | 89 | unsigned int i, j, k, temp; | 
| 91 | struct scatterlist sg[8]; | 90 | struct scatterlist sg[8]; | 
| 92 | char result[64]; | 91 | char result[64]; | 
| @@ -116,10 +115,7 @@ static void test_hash(char *algo, struct hash_testvec *template, | |||
| 116 | printk("test %u:\n", i + 1); | 115 | printk("test %u:\n", i + 1); | 
| 117 | memset(result, 0, 64); | 116 | memset(result, 0, 64); | 
| 118 | 117 | ||
| 119 | p = hash_tv[i].plaintext; | 118 | sg_set_buf(&sg[0], hash_tv[i].plaintext, hash_tv[i].psize); | 
| 120 | sg[0].page = virt_to_page(p); | ||
| 121 | sg[0].offset = offset_in_page(p); | ||
| 122 | sg[0].length = hash_tv[i].psize; | ||
| 123 | 119 | ||
| 124 | crypto_digest_init(tfm); | 120 | crypto_digest_init(tfm); | 
| 125 | if (tfm->crt_u.digest.dit_setkey) { | 121 | if (tfm->crt_u.digest.dit_setkey) { | 
| @@ -154,10 +150,8 @@ static void test_hash(char *algo, struct hash_testvec *template, | |||
| 154 | hash_tv[i].plaintext + temp, | 150 | hash_tv[i].plaintext + temp, | 
| 155 | hash_tv[i].tap[k]); | 151 | hash_tv[i].tap[k]); | 
| 156 | temp += hash_tv[i].tap[k]; | 152 | temp += hash_tv[i].tap[k]; | 
| 157 | p = &xbuf[IDX[k]]; | 153 | sg_set_buf(&sg[k], &xbuf[IDX[k]], | 
| 158 | sg[k].page = virt_to_page(p); | 154 | hash_tv[i].tap[k]); | 
| 159 | sg[k].offset = offset_in_page(p); | ||
| 160 | sg[k].length = hash_tv[i].tap[k]; | ||
| 161 | } | 155 | } | 
| 162 | 156 | ||
| 163 | crypto_digest_digest(tfm, sg, hash_tv[i].np, result); | 157 | crypto_digest_digest(tfm, sg, hash_tv[i].np, result); | 
| @@ -179,7 +173,6 @@ static void test_hash(char *algo, struct hash_testvec *template, | |||
| 179 | static void test_hmac(char *algo, struct hmac_testvec *template, | 173 | static void test_hmac(char *algo, struct hmac_testvec *template, | 
| 180 | unsigned int tcount) | 174 | unsigned int tcount) | 
| 181 | { | 175 | { | 
| 182 | char *p; | ||
| 183 | unsigned int i, j, k, temp; | 176 | unsigned int i, j, k, temp; | 
| 184 | struct scatterlist sg[8]; | 177 | struct scatterlist sg[8]; | 
| 185 | char result[64]; | 178 | char result[64]; | 
| @@ -210,11 +203,8 @@ static void test_hmac(char *algo, struct hmac_testvec *template, | |||
| 210 | printk("test %u:\n", i + 1); | 203 | printk("test %u:\n", i + 1); | 
| 211 | memset(result, 0, sizeof (result)); | 204 | memset(result, 0, sizeof (result)); | 
| 212 | 205 | ||
| 213 | p = hmac_tv[i].plaintext; | ||
| 214 | klen = hmac_tv[i].ksize; | 206 | klen = hmac_tv[i].ksize; | 
| 215 | sg[0].page = virt_to_page(p); | 207 | sg_set_buf(&sg[0], hmac_tv[i].plaintext, hmac_tv[i].psize); | 
| 216 | sg[0].offset = offset_in_page(p); | ||
| 217 | sg[0].length = hmac_tv[i].psize; | ||
| 218 | 208 | ||
| 219 | crypto_hmac(tfm, hmac_tv[i].key, &klen, sg, 1, result); | 209 | crypto_hmac(tfm, hmac_tv[i].key, &klen, sg, 1, result); | 
| 220 | 210 | ||
| @@ -243,10 +233,8 @@ static void test_hmac(char *algo, struct hmac_testvec *template, | |||
| 243 | hmac_tv[i].plaintext + temp, | 233 | hmac_tv[i].plaintext + temp, | 
| 244 | hmac_tv[i].tap[k]); | 234 | hmac_tv[i].tap[k]); | 
| 245 | temp += hmac_tv[i].tap[k]; | 235 | temp += hmac_tv[i].tap[k]; | 
| 246 | p = &xbuf[IDX[k]]; | 236 | sg_set_buf(&sg[k], &xbuf[IDX[k]], | 
| 247 | sg[k].page = virt_to_page(p); | 237 | hmac_tv[i].tap[k]); | 
| 248 | sg[k].offset = offset_in_page(p); | ||
| 249 | sg[k].length = hmac_tv[i].tap[k]; | ||
| 250 | } | 238 | } | 
| 251 | 239 | ||
| 252 | crypto_hmac(tfm, hmac_tv[i].key, &klen, sg, | 240 | crypto_hmac(tfm, hmac_tv[i].key, &klen, sg, | 
| @@ -270,7 +258,7 @@ static void test_cipher(char *algo, int mode, int enc, | |||
| 270 | { | 258 | { | 
| 271 | unsigned int ret, i, j, k, temp; | 259 | unsigned int ret, i, j, k, temp; | 
| 272 | unsigned int tsize; | 260 | unsigned int tsize; | 
| 273 | char *p, *q; | 261 | char *q; | 
| 274 | struct crypto_tfm *tfm; | 262 | struct crypto_tfm *tfm; | 
| 275 | char *key; | 263 | char *key; | 
| 276 | struct cipher_testvec *cipher_tv; | 264 | struct cipher_testvec *cipher_tv; | 
| @@ -330,10 +318,8 @@ static void test_cipher(char *algo, int mode, int enc, | |||
| 330 | goto out; | 318 | goto out; | 
| 331 | } | 319 | } | 
| 332 | 320 | ||
| 333 | p = cipher_tv[i].input; | 321 | sg_set_buf(&sg[0], cipher_tv[i].input, | 
| 334 | sg[0].page = virt_to_page(p); | 322 | cipher_tv[i].ilen); | 
| 335 | sg[0].offset = offset_in_page(p); | ||
| 336 | sg[0].length = cipher_tv[i].ilen; | ||
| 337 | 323 | ||
| 338 | if (!mode) { | 324 | if (!mode) { | 
| 339 | crypto_cipher_set_iv(tfm, cipher_tv[i].iv, | 325 | crypto_cipher_set_iv(tfm, cipher_tv[i].iv, | 
| @@ -389,10 +375,8 @@ static void test_cipher(char *algo, int mode, int enc, | |||
| 389 | cipher_tv[i].input + temp, | 375 | cipher_tv[i].input + temp, | 
| 390 | cipher_tv[i].tap[k]); | 376 | cipher_tv[i].tap[k]); | 
| 391 | temp += cipher_tv[i].tap[k]; | 377 | temp += cipher_tv[i].tap[k]; | 
| 392 | p = &xbuf[IDX[k]]; | 378 | sg_set_buf(&sg[k], &xbuf[IDX[k]], | 
| 393 | sg[k].page = virt_to_page(p); | 379 | cipher_tv[i].tap[k]); | 
| 394 | sg[k].offset = offset_in_page(p); | ||
| 395 | sg[k].length = cipher_tv[i].tap[k]; | ||
| 396 | } | 380 | } | 
| 397 | 381 | ||
| 398 | if (!mode) { | 382 | if (!mode) { | 
| @@ -431,14 +415,12 @@ out: | |||
| 431 | static int test_cipher_jiffies(struct crypto_tfm *tfm, int enc, char *p, | 415 | static int test_cipher_jiffies(struct crypto_tfm *tfm, int enc, char *p, | 
| 432 | int blen, int sec) | 416 | int blen, int sec) | 
| 433 | { | 417 | { | 
| 434 | struct scatterlist sg[8]; | 418 | struct scatterlist sg[1]; | 
| 435 | unsigned long start, end; | 419 | unsigned long start, end; | 
| 436 | int bcount; | 420 | int bcount; | 
| 437 | int ret; | 421 | int ret; | 
| 438 | 422 | ||
| 439 | sg[0].page = virt_to_page(p); | 423 | sg_set_buf(sg, p, blen); | 
| 440 | sg[0].offset = offset_in_page(p); | ||
| 441 | sg[0].length = blen; | ||
| 442 | 424 | ||
| 443 | for (start = jiffies, end = start + sec * HZ, bcount = 0; | 425 | for (start = jiffies, end = start + sec * HZ, bcount = 0; | 
| 444 | time_before(jiffies, end); bcount++) { | 426 | time_before(jiffies, end); bcount++) { | 
| @@ -459,14 +441,12 @@ static int test_cipher_jiffies(struct crypto_tfm *tfm, int enc, char *p, | |||
| 459 | static int test_cipher_cycles(struct crypto_tfm *tfm, int enc, char *p, | 441 | static int test_cipher_cycles(struct crypto_tfm *tfm, int enc, char *p, | 
| 460 | int blen) | 442 | int blen) | 
| 461 | { | 443 | { | 
| 462 | struct scatterlist sg[8]; | 444 | struct scatterlist sg[1]; | 
| 463 | unsigned long cycles = 0; | 445 | unsigned long cycles = 0; | 
| 464 | int ret = 0; | 446 | int ret = 0; | 
| 465 | int i; | 447 | int i; | 
| 466 | 448 | ||
| 467 | sg[0].page = virt_to_page(p); | 449 | sg_set_buf(sg, p, blen); | 
| 468 | sg[0].offset = offset_in_page(p); | ||
| 469 | sg[0].length = blen; | ||
| 470 | 450 | ||
| 471 | local_bh_disable(); | 451 | local_bh_disable(); | 
| 472 | local_irq_disable(); | 452 | local_irq_disable(); | 
| @@ -709,9 +689,7 @@ static void test_crc32c(void) | |||
| 709 | for (i = 0; i < NUMVEC; i++) { | 689 | for (i = 0; i < NUMVEC; i++) { | 
| 710 | for (j = 0; j < VECSIZE; j++) | 690 | for (j = 0; j < VECSIZE; j++) | 
| 711 | test_vec[i][j] = ++b; | 691 | test_vec[i][j] = ++b; | 
| 712 | sg[i].page = virt_to_page(test_vec[i]); | 692 | sg_set_buf(&sg[i], test_vec[i], VECSIZE); | 
| 713 | sg[i].offset = offset_in_page(test_vec[i]); | ||
| 714 | sg[i].length = VECSIZE; | ||
| 715 | } | 693 | } | 
| 716 | 694 | ||
| 717 | seed = SEEDTESTVAL; | 695 | seed = SEEDTESTVAL; | 
